create-windy 0.6.11 → 0.6.14
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 +580 -269
- package/package.json +1 -1
- package/template/.agents/skills/windy-business-module/SKILL.md +98 -70
- package/template/.windy-template.json +3 -3
- package/template/AGENTS.md +3 -6
- package/template/apps/agent-server/Dockerfile +2 -3
- package/template/apps/agent-server/README.md +38 -54
- package/template/apps/agent-server/pyproject.toml +0 -1
- package/template/apps/agent-server/src/southwind_agent_server/app.py +4 -2
- package/template/apps/agent-server/src/southwind_agent_server/attempt_context.py +191 -0
- package/template/apps/agent-server/src/southwind_agent_server/attempt_context_projection.py +203 -0
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_contracts.py +61 -0
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_governance.py +82 -0
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_routes.py +121 -0
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_runtime.py +158 -0
- package/template/apps/agent-server/src/southwind_agent_server/context_message_digest.py +24 -0
- package/template/apps/agent-server/src/southwind_agent_server/context_version_contracts.py +71 -0
- package/template/apps/agent-server/src/southwind_agent_server/context_version_port.py +307 -0
- package/template/apps/agent-server/src/southwind_agent_server/contracts.py +39 -0
- package/template/apps/agent-server/src/southwind_agent_server/deterministic.py +2 -0
- package/template/apps/agent-server/src/southwind_agent_server/engine.py +9 -1
- package/template/apps/agent-server/src/southwind_agent_server/engine_identity.py +2 -0
- package/template/apps/agent-server/src/southwind_agent_server/fingerprint.py +15 -0
- package/template/apps/agent-server/src/southwind_agent_server/health_routes.py +37 -3
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +46 -26
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine_validation.py +32 -0
- package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +7 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_insert.py +5 -2
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_queries.py +1 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_store.py +6 -1
- package/template/apps/agent-server/src/southwind_agent_server/postgres_store.py +3 -2
- package/template/apps/agent-server/src/southwind_agent_server/postgres_store_backend.py +1 -0
- package/template/apps/agent-server/src/southwind_agent_server/provider_governance.py +21 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_lifecycle.py +2 -1
- package/template/apps/agent-server/src/southwind_agent_server/report_presenter.py +1 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_routes.py +7 -1
- package/template/apps/agent-server/src/southwind_agent_server/report_store.py +10 -56
- package/template/apps/agent-server/src/southwind_agent_server/report_store_protocol.py +75 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_types.py +9 -2
- package/template/apps/agent-server/src/southwind_agent_server/runtime_budget.py +74 -0
- package/template/apps/agent-server/src/southwind_agent_server/runtime_factory.py +11 -3
- package/template/apps/agent-server/src/southwind_agent_server/service.py +41 -65
- package/template/apps/agent-server/src/southwind_agent_server/service_control.py +64 -0
- package/template/apps/agent-server/src/southwind_agent_server/service_execution.py +3 -0
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_errors.py +2 -0
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_schema.py +9 -1
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_store.py +6 -5
- package/template/apps/agent-server/src/southwind_agent_server/store.py +2 -0
- package/template/apps/agent-server/src/southwind_agent_server/trajectory.py +137 -0
- package/template/apps/agent-server/src/southwind_agent_server/unavailable_engine.py +58 -0
- package/template/apps/agent-server/tests/test_api.py +30 -11
- package/template/apps/agent-server/tests/test_client_completion.py +230 -0
- package/template/apps/agent-server/tests/test_provider_attempt_reporting.py +12 -24
- package/template/apps/agent-server/tests/test_report_resilience.py +2 -0
- package/template/apps/agent-server/tests/test_report_routes.py +58 -1
- package/template/apps/agent-server/tests/test_report_summary_parity.py +1 -0
- package/template/apps/agent-server/tests/test_run_capacity.py +2 -0
- package/template/apps/agent-server/tests/test_runtime_factory_readiness.py +18 -3
- package/template/apps/agent-server/tests/test_trajectory.py +91 -0
- package/template/apps/agent-server/uv.lock +0 -259
- package/template/apps/server/Dockerfile +9 -4
- package/template/apps/server/src/agent/actor-projection-audit.ts +6 -0
- package/template/apps/server/src/agent/agent-run-delegation-policy.ts +115 -0
- package/template/apps/server/src/agent/agent-session-bootstrap.ts +23 -0
- package/template/apps/server/src/agent/{debug-session-facade-provider-failure.test.ts → agent-session-facade-provider-failure.test.ts} +24 -33
- package/template/apps/server/src/agent/{debug-session-facade.test.ts → agent-session-facade.test.ts} +34 -45
- package/template/apps/server/src/agent/{debug-session-facade.ts → agent-session-facade.ts} +50 -57
- package/template/apps/server/src/agent/{debug-session-id.test.ts → agent-session-id.test.ts} +5 -5
- package/template/apps/server/src/agent/{debug-session-id.ts → agent-session-id.ts} +7 -7
- package/template/apps/server/src/agent/{debug-session-provider-reader.ts → agent-session-provider-reader.ts} +18 -15
- package/template/apps/server/src/agent/{debug-session-routes.test.ts → agent-session-routes.test.ts} +16 -16
- package/template/apps/server/src/agent/{debug-session-routes.ts → agent-session-routes.ts} +12 -12
- package/template/apps/server/src/agent/{debug-session-validation.ts → agent-session-validation.ts} +13 -11
- package/template/apps/server/src/agent/client-session/authorization.ts +47 -0
- package/template/apps/server/src/agent/client-session/bootstrap.ts +96 -0
- package/template/apps/server/src/agent/client-session/capabilities.ts +19 -0
- package/template/apps/server/src/agent/client-session/completion.ts +299 -0
- package/template/apps/server/src/agent/client-session/contracts.ts +136 -0
- package/template/apps/server/src/agent/client-session/digest.ts +39 -0
- package/template/apps/server/src/agent/client-session/drizzle-repository.integration.test.ts +170 -0
- package/template/apps/server/src/agent/client-session/drizzle-repository.ts +345 -0
- package/template/apps/server/src/agent/client-session/errors.ts +28 -0
- package/template/apps/server/src/agent/client-session/fixtures/page-agent-1.12.2-request.json +52 -0
- package/template/apps/server/src/agent/client-session/host-auth.test.ts +144 -0
- package/template/apps/server/src/agent/client-session/host-auth.ts +110 -0
- package/template/apps/server/src/agent/client-session/manifest-admission.ts +240 -0
- package/template/apps/server/src/agent/client-session/openai-stream.ts +123 -0
- package/template/apps/server/src/agent/client-session/presentation.ts +46 -0
- package/template/apps/server/src/agent/client-session/remote-provider.test.ts +144 -0
- package/template/apps/server/src/agent/client-session/remote-provider.ts +216 -0
- package/template/apps/server/src/agent/client-session/repository.ts +225 -0
- package/template/apps/server/src/agent/client-session/request.test.ts +69 -0
- package/template/apps/server/src/agent/client-session/request.ts +289 -0
- package/template/apps/server/src/agent/client-session/revocation.ts +23 -0
- package/template/apps/server/src/agent/client-session/routes.ts +315 -0
- package/template/apps/server/src/agent/client-session/runtime-audit.ts +42 -0
- package/template/apps/server/src/agent/client-session/service.test-support.ts +226 -0
- package/template/apps/server/src/agent/client-session/service.test.ts +268 -0
- package/template/apps/server/src/agent/client-session/service.ts +346 -0
- package/template/apps/server/src/agent/context-memory/attempt-context-contracts.ts +60 -0
- package/template/apps/server/src/agent/context-memory/authoritative-source-registry.ts +127 -0
- package/template/apps/server/src/agent/context-memory/context-builder.test.ts +160 -0
- package/template/apps/server/src/agent/context-memory/context-builder.ts +184 -0
- package/template/apps/server/src/agent/context-memory/contracts.ts +284 -0
- package/template/apps/server/src/agent/context-memory/digest.ts +22 -0
- package/template/apps/server/src/agent/context-memory/memory-authorization.ts +82 -0
- package/template/apps/server/src/agent/context-memory/memory-content.ts +69 -0
- package/template/apps/server/src/agent/context-memory/memory-object-registry.ts +87 -0
- package/template/apps/server/src/agent/context-memory/memory-projector-contracts.ts +121 -0
- package/template/apps/server/src/agent/context-memory/memory-projector-validation.ts +155 -0
- package/template/apps/server/src/agent/context-memory/memory-projector.test.ts +19 -0
- package/template/apps/server/src/agent/context-memory/memory-projector.ts +259 -0
- package/template/apps/server/src/agent/context-memory/memory-retrieval-policy.ts +195 -0
- package/template/apps/server/src/agent/context-memory/memory-retriever.test.ts +339 -0
- package/template/apps/server/src/agent/context-memory/memory-retriever.ts +184 -0
- package/template/apps/server/src/agent/context-memory/search-provider-port.test.ts +62 -0
- package/template/apps/server/src/agent/context-memory/search-provider-port.ts +75 -0
- package/template/apps/server/src/agent/context-memory/working-context-expiry.ts +95 -0
- package/template/apps/server/src/agent/context-message-recovery.ts +23 -0
- package/template/apps/server/src/agent/context-version-routes.ts +241 -0
- package/template/apps/server/src/agent/context-version-runtime.ts +332 -0
- package/template/apps/server/src/agent/context-version-support.ts +93 -0
- package/template/apps/server/src/agent/context-version-validation.ts +118 -0
- package/template/apps/server/src/agent/drizzle-run-binding-repository.ts +11 -0
- package/template/apps/server/src/agent/idempotency-key.ts +9 -1
- package/template/apps/server/src/agent/memory-runtime-adapters.ts +266 -0
- package/template/apps/server/src/agent/memory-scope-binding.ts +14 -0
- package/template/apps/server/src/agent/module-ai-port-factory.ts +41 -0
- package/template/apps/server/src/agent/provider-input-governance.ts +19 -0
- package/template/apps/server/src/agent/remote-runtime-response.ts +162 -0
- package/template/apps/server/src/agent/remote-runtime.ts +53 -153
- package/template/apps/server/src/agent/run-audit.ts +2 -2
- package/template/apps/server/src/agent/run-authorization.test.ts +27 -0
- package/template/apps/server/src/agent/run-authorization.ts +60 -1
- package/template/apps/server/src/agent/run-binding-repository.ts +9 -0
- package/template/apps/server/src/agent/run-browser-authorization.ts +79 -0
- package/template/apps/server/src/agent/run-contracts.ts +23 -0
- package/template/apps/server/src/agent/run-facade.ts +139 -139
- package/template/apps/server/src/agent/run-failure-cleanup.ts +58 -0
- package/template/apps/server/src/agent/run-operation-policy.ts +20 -0
- package/template/apps/server/src/agent/run-route-input.ts +19 -1
- package/template/apps/server/src/agent/run-routes.ts +133 -5
- package/template/apps/server/src/agent/run-runtime-request.ts +89 -0
- package/template/apps/server/src/agent/run-session-authorization.ts +95 -0
- package/template/apps/server/src/agent/run-start-preparation.ts +71 -0
- package/template/apps/server/src/agent/runtime-bootstrap-input.ts +42 -0
- package/template/apps/server/src/agent/runtime-bootstrap-report.test.ts +53 -1
- package/template/apps/server/src/agent/runtime-bootstrap.ts +114 -111
- package/template/apps/server/src/agent/runtime-tool-composition.ts +38 -0
- package/template/apps/server/src/agent/session-context-source-support.ts +38 -0
- package/template/apps/server/src/agent/session-context-source.ts +346 -0
- package/template/apps/server/src/agent/session-invalidation/contracts.ts +217 -0
- package/template/apps/server/src/agent/session-invalidation/dispatcher.contract.test.ts +333 -0
- package/template/apps/server/src/agent/session-invalidation/dispatcher.ts +205 -0
- package/template/apps/server/src/agent/session-invalidation/module-authoritative-producer.test.ts +127 -0
- package/template/apps/server/src/agent/session-invalidation/module-authoritative-producer.ts +202 -0
- package/template/apps/server/src/agent/session-invalidation/read-guard.ts +39 -0
- package/template/apps/server/src/agent/session-invalidation/runtime.ts +69 -0
- package/template/apps/server/src/agent/session-invalidation/test-envelopes.ts +24 -0
- package/template/apps/server/src/agent/session-invalidation/worker.contract.test.ts +135 -0
- package/template/apps/server/src/agent/session-invalidation/worker.ts +76 -0
- package/template/apps/server/src/agent/session-log/checkpoint-digest.ts +36 -0
- package/template/apps/server/src/agent/session-log/domain.ts +123 -0
- package/template/apps/server/src/agent/session-log/events.ts +229 -0
- package/template/apps/server/src/agent/session-log/history.ts +143 -0
- package/template/apps/server/src/agent/session-log/in-memory-repository.ts +340 -0
- package/template/apps/server/src/agent/session-log/lifecycle.ts +67 -0
- package/template/apps/server/src/agent/session-log/replay-policy.ts +76 -0
- package/template/apps/server/src/agent/session-log/repository.ts +103 -0
- package/template/apps/server/src/agent/session-log/service.ts +349 -0
- package/template/apps/server/src/agent/session-log/session-log.test.ts +282 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-context-memory.ts +348 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-governed-context.ts +328 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-invalidation-outbox.ts +260 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-memory-projection-deletion.ts +56 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-run-projection-receipt.ts +80 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-session-fork.ts +147 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-session-list.ts +24 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-session-mapping.ts +154 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-session-mutations.ts +64 -0
- package/template/apps/server/src/agent/session-persistence/drizzle-session-repository.ts +335 -0
- package/template/apps/server/src/agent/session-persistence/invalidation-projections.ts +229 -0
- package/template/apps/server/src/agent/session-persistence/payload-codec.ts +90 -0
- package/template/apps/server/src/agent/session-projection-access.ts +155 -0
- package/template/apps/server/src/agent/session-projection-bootstrap.ts +87 -0
- package/template/apps/server/src/agent/session-projection-errors.ts +22 -0
- package/template/apps/server/src/agent/session-projection-facade.ts +349 -0
- package/template/apps/server/src/agent/session-projection-routes.ts +215 -0
- package/template/apps/server/src/agent/session-projection-view.ts +137 -0
- package/template/apps/server/src/agent/session-result-memory.ts +228 -0
- package/template/apps/server/src/agent/session-run-lifecycle.ts +85 -0
- package/template/apps/server/src/agent/session-run-link-contracts.ts +56 -0
- package/template/apps/server/src/agent/session-run-link.ts +343 -0
- package/template/apps/server/src/agent/session-run-recovery.ts +16 -0
- package/template/apps/server/src/agent/session-runtime-composition.ts +265 -0
- package/template/apps/server/src/agent/session-source-chain-authorizer.ts +141 -0
- package/template/apps/server/src/agent/session-terminal-reconciler.ts +100 -0
- package/template/apps/server/src/agent/session-turn-state.ts +49 -0
- package/template/apps/server/src/agent/tool-audit.ts +3 -3
- package/template/apps/server/src/agent/tool-execution-receipt.ts +13 -0
- package/template/apps/server/src/agent/tool-host.ts +41 -4
- package/template/apps/server/src/agent/tool-registry-composition.ts +52 -0
- package/template/apps/server/src/agent/tool-registry.test.ts +5 -5
- package/template/apps/server/src/agent/tool-registry.ts +53 -59
- package/template/apps/server/src/agent/unavailable-routes.ts +49 -5
- package/template/apps/server/src/agent/workflow-durable-runtime-input.ts +32 -0
- package/template/apps/server/src/agent/workflow-runtime-bootstrap.ts +59 -0
- package/template/apps/server/src/agent-workflow/adapter-dispatch.ts +148 -0
- package/template/apps/server/src/agent-workflow/approval-node-adapter.ts +77 -0
- package/template/apps/server/src/agent-workflow/artifact-access-error.ts +9 -0
- package/template/apps/server/src/agent-workflow/artifact-node-adapter.ts +67 -0
- package/template/apps/server/src/agent-workflow/artifact-policy.ts +71 -0
- package/template/apps/server/src/agent-workflow/artifact-source-authorization.ts +85 -0
- package/template/apps/server/src/agent-workflow/authorization.ts +238 -0
- package/template/apps/server/src/agent-workflow/budget-ledger.ts +118 -0
- package/template/apps/server/src/agent-workflow/budget-validation.ts +305 -0
- package/template/apps/server/src/agent-workflow/canonical-agent-run-binding.ts +17 -0
- package/template/apps/server/src/agent-workflow/canonical-agent-run-evidence.ts +142 -0
- package/template/apps/server/src/agent-workflow/canonical-agent-run-port.ts +304 -0
- package/template/apps/server/src/agent-workflow/canonical-agent-run-remote.ts +64 -0
- package/template/apps/server/src/agent-workflow/canonical-json.ts +16 -0
- package/template/apps/server/src/agent-workflow/command-drive.ts +195 -0
- package/template/apps/server/src/agent-workflow/command-error.ts +9 -0
- package/template/apps/server/src/agent-workflow/command-facade.ts +290 -0
- package/template/apps/server/src/agent-workflow/command-input.ts +133 -0
- package/template/apps/server/src/agent-workflow/condition-node-adapter.ts +69 -0
- package/template/apps/server/src/agent-workflow/definition-budget-validation.ts +41 -0
- package/template/apps/server/src/agent-workflow/definition-node-validation.ts +197 -0
- package/template/apps/server/src/agent-workflow/definition-validation.ts +198 -0
- package/template/apps/server/src/agent-workflow/delegated-tool-authorization.ts +15 -0
- package/template/apps/server/src/agent-workflow/delegation-child-delivery.ts +129 -0
- package/template/apps/server/src/agent-workflow/delegation-execution-authorization.ts +218 -0
- package/template/apps/server/src/agent-workflow/delegation-policy-validation.ts +253 -0
- package/template/apps/server/src/agent-workflow/delegation-policy.ts +179 -0
- package/template/apps/server/src/agent-workflow/drizzle-artifact-port.ts +211 -0
- package/template/apps/server/src/agent-workflow/drizzle-artifact-support.ts +152 -0
- package/template/apps/server/src/agent-workflow/drizzle-budget-ledger-settlement.ts +271 -0
- package/template/apps/server/src/agent-workflow/drizzle-budget-ledger-support.ts +226 -0
- package/template/apps/server/src/agent-workflow/drizzle-budget-ledger.ts +189 -0
- package/template/apps/server/src/agent-workflow/drizzle-cancellation-reconcile.ts +177 -0
- package/template/apps/server/src/agent-workflow/drizzle-delegated-tool-authorization.ts +155 -0
- package/template/apps/server/src/agent-workflow/drizzle-delegation-completion.ts +84 -0
- package/template/apps/server/src/agent-workflow/drizzle-delegation-lifecycle.ts +139 -0
- package/template/apps/server/src/agent-workflow/drizzle-delegation-port.ts +288 -0
- package/template/apps/server/src/agent-workflow/drizzle-effect-command-fence.ts +333 -0
- package/template/apps/server/src/agent-workflow/drizzle-evaluation-repository.ts +214 -0
- package/template/apps/server/src/agent-workflow/drizzle-event-validation.ts +43 -0
- package/template/apps/server/src/agent-workflow/drizzle-recovery-admission.ts +115 -0
- package/template/apps/server/src/agent-workflow/drizzle-repository-lineage.ts +103 -0
- package/template/apps/server/src/agent-workflow/drizzle-repository-mappers.ts +317 -0
- package/template/apps/server/src/agent-workflow/drizzle-repository-write.ts +311 -0
- package/template/apps/server/src/agent-workflow/drizzle-repository.ts +285 -0
- package/template/apps/server/src/agent-workflow/drizzle-side-effect-repository.ts +83 -0
- package/template/apps/server/src/agent-workflow/drizzle-write-support.ts +101 -0
- package/template/apps/server/src/agent-workflow/durable-continuation-authorization.ts +109 -0
- package/template/apps/server/src/agent-workflow/durable-continuation-driver.ts +97 -0
- package/template/apps/server/src/agent-workflow/durable-continuation-runtime.ts +173 -0
- package/template/apps/server/src/agent-workflow/durable-job-node-adapter.ts +106 -0
- package/template/apps/server/src/agent-workflow/effect-command-fence.ts +250 -0
- package/template/apps/server/src/agent-workflow/evaluation-evidence-coordinates.ts +225 -0
- package/template/apps/server/src/agent-workflow/evaluation-evidence-metrics.ts +280 -0
- package/template/apps/server/src/agent-workflow/evaluation-evidence-reader.ts +326 -0
- package/template/apps/server/src/agent-workflow/evaluation-metrics-validation.ts +85 -0
- package/template/apps/server/src/agent-workflow/evaluation-projection.ts +70 -0
- package/template/apps/server/src/agent-workflow/evaluation-repository.ts +134 -0
- package/template/apps/server/src/agent-workflow/evaluation-service.ts +292 -0
- package/template/apps/server/src/agent-workflow/evaluation-tool-registration.ts +95 -0
- package/template/apps/server/src/agent-workflow/evaluation-validation.ts +331 -0
- package/template/apps/server/src/agent-workflow/event-validation.ts +277 -0
- package/template/apps/server/src/agent-workflow/governed-tool-schema.ts +55 -0
- package/template/apps/server/src/agent-workflow/in-memory-evaluation-repository.ts +123 -0
- package/template/apps/server/src/agent-workflow/in-memory-mutation-validation.ts +154 -0
- package/template/apps/server/src/agent-workflow/in-memory-repository-support.ts +277 -0
- package/template/apps/server/src/agent-workflow/in-memory-repository.ts +339 -0
- package/template/apps/server/src/agent-workflow/in-memory-side-effect-store.ts +78 -0
- package/template/apps/server/src/agent-workflow/input-receipt.ts +55 -0
- package/template/apps/server/src/agent-workflow/model-node-adapter.ts +86 -0
- package/template/apps/server/src/agent-workflow/model-pricing-catalog.ts +215 -0
- package/template/apps/server/src/agent-workflow/node-adapter-factory.ts +83 -0
- package/template/apps/server/src/agent-workflow/node-adapters.ts +50 -0
- package/template/apps/server/src/agent-workflow/node-execution-ports.ts +185 -0
- package/template/apps/server/src/agent-workflow/node-input-receipt-port.ts +42 -0
- package/template/apps/server/src/agent-workflow/node-result-receipt.ts +50 -0
- package/template/apps/server/src/agent-workflow/platform-node-adapter-support.ts +185 -0
- package/template/apps/server/src/agent-workflow/platform-node-adapters.ts +256 -0
- package/template/apps/server/src/agent-workflow/platform-node-approval.ts +146 -0
- package/template/apps/server/src/agent-workflow/platform-node-direct-adapters.ts +65 -0
- package/template/apps/server/src/agent-workflow/production-delegation-scope.ts +58 -0
- package/template/apps/server/src/agent-workflow/production-node-policies.ts +62 -0
- package/template/apps/server/src/agent-workflow/query-service.ts +198 -0
- package/template/apps/server/src/agent-workflow/release.ts +96 -0
- package/template/apps/server/src/agent-workflow/repository.ts +157 -0
- package/template/apps/server/src/agent-workflow/routes.ts +307 -0
- package/template/apps/server/src/agent-workflow/runtime-composition.ts +308 -0
- package/template/apps/server/src/agent-workflow/scheduler-cancellation-reconcile.ts +253 -0
- package/template/apps/server/src/agent-workflow/scheduler-cancellation-support.ts +145 -0
- package/template/apps/server/src/agent-workflow/scheduler-cancellation.ts +2 -0
- package/template/apps/server/src/agent-workflow/scheduler-context.ts +85 -0
- package/template/apps/server/src/agent-workflow/scheduler-deadline.ts +65 -0
- package/template/apps/server/src/agent-workflow/scheduler-effect-result.ts +205 -0
- package/template/apps/server/src/agent-workflow/scheduler-execution-convergence.ts +174 -0
- package/template/apps/server/src/agent-workflow/scheduler-execution.ts +211 -0
- package/template/apps/server/src/agent-workflow/scheduler-failure.ts +102 -0
- package/template/apps/server/src/agent-workflow/scheduler-join-cancellation.ts +282 -0
- package/template/apps/server/src/agent-workflow/scheduler-mutation-queue.ts +13 -0
- package/template/apps/server/src/agent-workflow/scheduler-node-timeout.ts +139 -0
- package/template/apps/server/src/agent-workflow/scheduler-parallel-dispatch.ts +99 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-activation.ts +63 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-budget.ts +41 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-effect.ts +331 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-event-time.ts +26 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-failed-policy.ts +129 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-node.ts +208 -0
- package/template/apps/server/src/agent-workflow/scheduler-recovery-policy-convergence.ts +140 -0
- package/template/apps/server/src/agent-workflow/scheduler-reservation-convergence.ts +40 -0
- package/template/apps/server/src/agent-workflow/scheduler-side-effect-execution.ts +249 -0
- package/template/apps/server/src/agent-workflow/scheduler-support.ts +235 -0
- package/template/apps/server/src/agent-workflow/scheduler-workflow-cancellation.ts +296 -0
- package/template/apps/server/src/agent-workflow/scheduler.ts +289 -0
- package/template/apps/server/src/agent-workflow/service-completion.ts +102 -0
- package/template/apps/server/src/agent-workflow/service-mutation-identity.ts +94 -0
- package/template/apps/server/src/agent-workflow/service-node-admission.ts +36 -0
- package/template/apps/server/src/agent-workflow/service-node-run-update.ts +55 -0
- package/template/apps/server/src/agent-workflow/service-recovery-events.ts +38 -0
- package/template/apps/server/src/agent-workflow/service-recovery.ts +264 -0
- package/template/apps/server/src/agent-workflow/service-retry.ts +86 -0
- package/template/apps/server/src/agent-workflow/service-run-command.ts +131 -0
- package/template/apps/server/src/agent-workflow/service-state-error.ts +21 -0
- package/template/apps/server/src/agent-workflow/service-state-invariants.ts +44 -0
- package/template/apps/server/src/agent-workflow/service-support.ts +152 -0
- package/template/apps/server/src/agent-workflow/service.ts +307 -0
- package/template/apps/server/src/agent-workflow/side-effect-state.ts +226 -0
- package/template/apps/server/src/agent-workflow/state-machine.ts +321 -0
- package/template/apps/server/src/agent-workflow/subagent-node-adapter.ts +229 -0
- package/template/apps/server/src/agent-workflow/tool-node-adapter.ts +259 -0
- package/template/apps/server/src/agent-workflow/usage.ts +149 -0
- package/template/apps/server/src/agent-workflow/wait-signal-service.ts +147 -0
- package/template/apps/server/src/agent-workflow/workflow-artifact-token.ts +109 -0
- package/template/apps/server/src/agent-workflow/workflow-value-validation.ts +101 -0
- package/template/apps/server/src/agent-workflow/workspace-policy.ts +109 -0
- package/template/apps/server/src/ai-runtime-report/remote-parser.ts +41 -0
- package/template/apps/server/src/ai-runtime-report/service.test.ts +2 -0
- package/template/apps/server/src/app/agent-runtime-composition.ts +38 -0
- package/template/apps/server/src/app/client-agent-host-auth-binding.ts +10 -0
- package/template/apps/server/src/auth/actor-resolver.test.ts +33 -0
- package/template/apps/server/src/auth/actor-resolver.ts +6 -1
- package/template/apps/server/src/auth/composition.ts +36 -0
- package/template/apps/server/src/auth/routes.test-support.ts +2 -0
- package/template/apps/server/src/auth/routes.test.ts +18 -0
- package/template/apps/server/src/auth/runtime.ts +2 -0
- package/template/apps/server/src/auth/service-options.ts +16 -0
- package/template/apps/server/src/auth/service.ts +7 -12
- package/template/apps/server/src/index.ts +35 -37
- package/template/apps/server/src/license/pairing-service.test.ts +1 -1
- package/template/apps/server/src/module-host/agent-session-memory-port.ts +91 -0
- package/template/apps/server/src/module-host/{debug-session-provider-registration.test.ts → agent-session-provider-registration.test.ts} +42 -17
- package/template/apps/server/src/module-host/{debug-session-provider-registration.ts → agent-session-provider-registration.ts} +18 -18
- package/template/apps/server/src/module-host/agent-source-invalidation-port.ts +53 -0
- package/template/apps/server/src/module-host/http-runtime.ts +14 -0
- package/template/apps/server/src/module-host/initialize-contracts.ts +4 -5
- package/template/apps/server/src/module-host/initialize.ts +4 -4
- package/template/apps/server/src/module-host/request-context.test.ts +5 -5
- package/template/apps/server/src/module-host/request-context.ts +8 -0
- package/template/apps/server/src/module-host/route-install-context.ts +65 -0
- package/template/apps/server/src/module-host/route-installer.ts +11 -56
- package/template/apps/server/src/module-host/scoped-host.ts +17 -12
- package/template/apps/server/src/module-host/storage-authorization-binding.test.ts +3 -3
- package/template/apps/server/src/module-host.ts +3 -5
- package/template/apps/server/src/runtime.ts +3 -36
- package/template/apps/server/src/storage/routes-stream-cancellation.test.ts +19 -0
- package/template/apps/server/src/storage/routes.ts +3 -1
- package/template/apps/server/src/system/actor.ts +15 -2
- package/template/apps/server/src/system/authorization-invalidation-bridge.ts +30 -0
- package/template/apps/server/src/system/authorization-invalidation-composition.ts +36 -0
- package/template/apps/server/src/system/drizzle-system.ts +8 -1
- package/template/apps/server/src/system/identity-route-config.ts +9 -1
- package/template/apps/server/src/system/routes.ts +3 -0
- package/template/apps/server/src/system/seed.ts +3 -0
- package/template/apps/server/src/system/user-account-policy.ts +91 -0
- package/template/apps/web/package.json +1 -0
- package/template/apps/web/src/layout/AppSidebar.vue +2 -0
- package/template/apps/web/src/pages/system/AgentSessionPage.vue +73 -0
- package/template/apps/web/src/pages/system/AgentSessionPage.webtest.ts +66 -0
- package/template/apps/web/src/pages/system/AgentWorkflowPage.vue +69 -0
- package/template/apps/web/src/pages/system/components/agent-session/AgentSessionDetail.vue +114 -0
- package/template/apps/web/src/pages/system/components/agent-session/AgentSessionList.vue +84 -0
- package/template/apps/web/src/pages/system/components/agent-session/ContextVersionPanel.vue +119 -0
- package/template/apps/web/src/pages/system/components/agent-session/ContextVersionPanel.webtest.ts +46 -0
- package/template/apps/web/src/pages/system/components/agent-session/MemoryProjectionPanel.vue +163 -0
- package/template/apps/web/src/pages/system/components/agent-session/MemoryProjectionPanel.webtest.ts +62 -0
- package/template/apps/web/src/pages/system/components/agent-session/SessionTimeline.vue +71 -0
- package/template/apps/web/src/pages/system/components/agent-session/SessionTimeline.webtest.ts +34 -0
- package/template/apps/web/src/pages/system/components/agent-session/agent-session-presenter.ts +56 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowNodeCard.vue +39 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowNodeDetail.vue +172 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowRunDetail.vue +151 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowRunGraph.vue +96 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowRunList.vue +100 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowRunSummary.vue +148 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/agent-workflow-presenter.ts +74 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/workflow-graph-layout.ts +108 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunDetailDialog.vue +9 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunDetailDialog.webtest.ts +22 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunTable.webtest.ts +2 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeTrajectory.vue +118 -0
- package/template/apps/web/src/pages/system/composables/useAgentSessions.ts +209 -0
- package/template/apps/web/src/pages/system/composables/useAgentSessions.webtest.ts +138 -0
- package/template/apps/web/src/pages/system/composables/useAgentWorkflowRuns.ts +173 -0
- package/template/apps/web/src/router/index.ts +4 -0
- package/template/apps/web/src/router/platform-admin-route-bindings.ts +6 -0
- package/template/apps/web/src/services/agent-session-api.ts +159 -0
- package/template/apps/web/src/services/agent-session-api.webtest.ts +65 -0
- package/template/apps/web/src/services/agent-workflow-api.ts +181 -0
- package/template/apps/web/src/services/ai-runtime-api.ts +4 -0
- package/template/docker-compose.yml +11 -8
- package/template/docs/adr/0003-agent-session-event-source.md +3 -0
- package/template/docs/architecture/agent-harness.md +464 -0
- package/template/docs/architecture/agent-workflow.md +99 -0
- package/template/docs/architecture/ai-runtime.md +55 -47
- package/template/docs/architecture/module-host.md +4 -3
- package/template/docs/operations/adk-retirement.md +98 -0
- package/template/docs/operations/agent-session-memory.md +162 -0
- package/template/docs/operations/agent-session-troubleshooting.md +196 -0
- package/template/docs/operations/agent-workflow-recovery.md +74 -0
- package/template/docs/operations/incremental-delivery.md +1 -1
- package/template/docs/platform/agent-production-store.md +82 -0
- package/template/docs/platform/agent-run-reattachment.md +52 -0
- package/template/docs/platform/agent-runtime-observability.md +4 -3
- package/template/docs/platform/agent-runtime.md +116 -281
- package/template/docs/platform/agent-tool-approval.md +61 -0
- package/template/docs/platform/background-ai-operations.md +50 -0
- package/template/docs/platform/client-agent-session.md +173 -0
- package/template/docs/platform/embedding-ai-runtime.md +94 -0
- package/template/docs/platform/platform-authentication.md +5 -8
- package/template/package.json +0 -1
- package/template/packages/ai-client/index.ts +1 -0
- package/template/packages/ai-client/package.json +2 -1
- package/template/packages/ai-client/src/agent/client/client.ts +15 -2
- package/template/packages/ai-client/src/agent/client/run-protocol.test.ts +39 -25
- package/template/packages/ai-client/src/agent/client/types.ts +4 -0
- package/template/packages/ai-client/src/agent/contracts/contracts.test.ts +49 -7
- package/template/packages/ai-client/src/agent/contracts/events.ts +61 -0
- package/template/packages/ai-client/src/agent/contracts/runs.ts +1 -0
- package/template/packages/ai-client/src/client-agent/contracts.ts +131 -0
- package/template/packages/ai-client/src/client-agent/http.test.ts +60 -0
- package/template/packages/ai-client/src/client-agent/http.ts +66 -0
- package/template/packages/ai-client/src/client-agent/index.ts +3 -0
- package/template/packages/ai-client/src/client-agent/validation.test.ts +57 -0
- package/template/packages/ai-client/src/client-agent/validation.ts +152 -0
- package/template/packages/config/index.test.ts +18 -0
- package/template/packages/config/package.json +1 -1
- package/template/packages/config/src/platform-validation.ts +8 -0
- package/template/packages/config/src/platform.ts +22 -9
- package/template/packages/database/drizzle/0055_square_yellowjacket.sql +47 -0
- package/template/packages/database/drizzle/0056_tricky_living_mummy.sql +2 -0
- package/template/packages/database/drizzle/0057_mature_doomsday.sql +4 -0
- package/template/packages/database/drizzle/0058_agent_session_memory.sql +159 -0
- package/template/packages/database/drizzle/0059_agent_source_module_key.sql +16 -0
- package/template/packages/database/drizzle/0060_slimy_rocket_raccoon.sql +43 -0
- package/template/packages/database/drizzle/0061_agent_workflow.sql +303 -0
- package/template/packages/database/drizzle/meta/0055_snapshot.json +11071 -0
- package/template/packages/database/drizzle/meta/0056_snapshot.json +11098 -0
- package/template/packages/database/drizzle/meta/0057_snapshot.json +10878 -0
- package/template/packages/database/drizzle/meta/0058_snapshot.json +12294 -0
- package/template/packages/database/drizzle/meta/0059_snapshot.json +12344 -0
- package/template/packages/database/drizzle/meta/0060_snapshot.json +12326 -0
- package/template/packages/database/drizzle/meta/0061_snapshot.json +14395 -0
- package/template/packages/database/drizzle/meta/_journal.json +49 -0
- package/template/packages/database/package.json +1 -1
- package/template/packages/database/src/agent-runtime-schema.test.ts +26 -0
- package/template/packages/database/src/schema/agent-context-message.ts +38 -0
- package/template/packages/database/src/schema/agent-runtime.ts +7 -0
- package/template/packages/database/src/schema/agent-session-receipt.ts +36 -0
- package/template/packages/database/src/schema/agent-session.ts +344 -0
- package/template/packages/database/src/schema/agent-workflow-delegation.ts +126 -0
- package/template/packages/database/src/schema/agent-workflow-effects.ts +213 -0
- package/template/packages/database/src/schema/agent-workflow-evaluation.ts +67 -0
- package/template/packages/database/src/schema/agent-workflow.ts +270 -0
- package/template/packages/database/src/schema/client-agent.ts +95 -0
- package/template/packages/database/src/schema/index.ts +8 -0
- package/template/packages/jobs/package.json +1 -1
- package/template/packages/modules/index.ts +2 -0
- package/template/packages/modules/package.json +1 -1
- package/template/packages/modules/src/ai-client-execution-composition.test.ts +98 -0
- package/template/packages/modules/src/ai-client-execution-policy.ts +54 -0
- package/template/packages/modules/src/ai-operation-composition.ts +2 -0
- package/template/packages/modules/src/manifest.ts +15 -0
- package/template/packages/modules/src/system-admin-routes.ts +16 -0
- package/template/packages/modules/src/system-admin-ui-catalog.ts +4 -1
- package/template/packages/modules/src/system-agent-audit-actions.ts +26 -0
- package/template/packages/modules/src/system-ai-api-bindings.ts +262 -0
- package/template/packages/modules/src/system-api-control-plane.ts +4 -78
- package/template/packages/modules/src/system-audit-actions.ts +113 -0
- package/template/packages/modules/src/system-features.ts +17 -0
- package/template/packages/modules/src/system-module-catalog.ts +21 -11
- package/template/packages/modules/src/system-modules.ts +22 -0
- package/template/packages/modules/src/system-permissions.ts +8 -0
- package/template/packages/server-sdk/index.ts +43 -0
- package/template/packages/server-sdk/package.json +5 -1
- package/template/packages/server-sdk/src/agent-session-memory-port.ts +64 -0
- package/template/packages/server-sdk/src/agent-session-provider.ts +63 -0
- package/template/packages/server-sdk/src/agent-source-invalidation-port.ts +54 -0
- package/template/packages/server-sdk/src/ai-operation-registration.ts +2 -0
- package/template/packages/server-sdk/src/client-agent-session.ts +95 -0
- package/template/packages/server-sdk/src/debug-session-provider.ts +14 -63
- package/template/packages/server-sdk/src/module-host.ts +7 -3
- package/template/packages/server-sdk/src/request-context.ts +6 -0
- package/template/packages/shared/index.ts +3 -0
- package/template/packages/shared/package.json +1 -1
- package/template/packages/shared/src/agent-workflow-definition.ts +113 -0
- package/template/packages/shared/src/agent-workflow-delegation.ts +123 -0
- package/template/packages/shared/src/agent-workflow-evaluation.ts +159 -0
- package/template/packages/shared/src/agent-workflow-events.ts +99 -0
- package/template/packages/shared/src/agent-workflow-run.ts +259 -0
- package/template/packages/shared/src/agent-workflow.ts +3 -0
- package/template/packages/shared/src/ai-runtime-report.ts +25 -0
- package/template/packages/shared/src/rbac.ts +24 -0
- package/template/packages/storage/package.json +1 -1
- package/template/packages/storage/src/upload-streams.test.ts +31 -0
- package/template/packages/storage/src/upload-streams.ts +20 -6
- package/template/apps/agent-server/adk_web_agents/__init__.py +0 -1
- package/template/apps/agent-server/adk_web_agents/canonical_debug/__init__.py +0 -1
- package/template/apps/agent-server/adk_web_agents/canonical_debug/agent.py +0 -145
- package/template/apps/agent-server/adk_web_agents/safe_debug/__init__.py +0 -3
- package/template/apps/agent-server/adk_web_agents/safe_debug/agent.py +0 -40
- package/template/apps/agent-server/adk_web_agents/services.py +0 -25
- package/template/apps/agent-server/project/adk-web-debug.json +0 -4
- package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +0 -333
- package/template/apps/agent-server/src/southwind_agent_server/adk_debug.py +0 -348
- package/template/apps/agent-server/src/southwind_agent_server/adk_debug_sessions.py +0 -325
- package/template/apps/agent-server/src/southwind_agent_server/adk_failure.py +0 -13
- package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +0 -304
- package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +0 -143
- package/template/apps/agent-server/tests/test_adk_adapter.py +0 -307
- package/template/apps/agent-server/tests/test_adk_debug_result_polling.py +0 -139
- package/template/apps/agent-server/tests/test_adk_debug_sessions.py +0 -215
- package/template/apps/agent-server/tests/test_adk_web_agent.py +0 -12
- package/template/apps/agent-server/tests/test_adk_web_canonical_debug.py +0 -282
- package/template/apps/server/src/agent/run-debug-authorization.ts +0 -27
- package/template/apps/server/src/agent/run-facade-adk-debug.test.ts +0 -95
- package/template/apps/server/src/runtime-adk-debug.test.ts +0 -270
- package/template/apps/server/src/runtime-adk-debug.ts +0 -164
- package/template/apps/server/src/runtime-request-actor.test.ts +0 -55
- package/template/apps/server/src/runtime-request-actor.ts +0 -22
- package/template/docker-compose.agent-debug.yml +0 -58
- package/template/scripts/dev-adk-web.ts +0 -107
package/package.json
CHANGED
|
@@ -1,89 +1,117 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: windy-business-module
|
|
3
|
-
description: "Windy
|
|
3
|
+
description: "在 Windy 或 create-windy 生成项目中新增或修改业务 Module、Manifest、Repository、Service、Agent Tool、AI Operation 或 MCP 暴露时使用;不用于仅修改平台基础设施或普通页面样式。"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Windy 业务模块开发
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
`docs/architecture/`、`docs/development/`、`docs/platform/`
|
|
8
|
+
先读取仓库 `AGENTS.md`;存在 `CONTEXT.md` 时再读取它,并读取与本次能力直接相关的
|
|
9
|
+
`docs/architecture/`、`docs/development/`、`docs/platform/` 长期文档。
|
|
10
10
|
|
|
11
11
|
## 工作流
|
|
12
12
|
|
|
13
|
-
1.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
1. 确认当前装配和物理边界。在生成项目中运行 `bun run windy module list`;在
|
|
14
|
+
windy-platform 源仓库或 CLI 不可用时,直接核对 `windy.modules.json`、canonical
|
|
15
|
+
Manifest 与 project-owned Server Composition,并明确记录限制。执行
|
|
16
|
+
`module add|enable|disable|update|remove` 前先运行同命令的 `--dry-run`;
|
|
17
|
+
`project-composition-required` 是预期的 fail-closed,不能手改 `node_modules`、
|
|
18
|
+
`.windy` 或 registry 伪造成功。**完成标准:已列出实际启用模块、缺失的可选能力和
|
|
19
|
+
生命周期命令结论。**
|
|
20
|
+
2. 选择稳定的模块命名空间和能力基础 Key,先定义业务边界、Actor、数据归属、失败
|
|
21
|
+
语义、幂等边界和跨模块公开 Port,再改代码。**完成标准:能力所有者和每个调用面的
|
|
22
|
+
授权来源清晰且没有客户端自报事实。**
|
|
23
|
+
3. 在业务 package 的 Module Manifest 一次声明 Feature、Permission、API、菜单/Admin
|
|
24
|
+
Route、Audit Action,以及需要的 Migration/Schema Export、Task、Provider、JSON
|
|
25
|
+
Schema、Tool、AI Operation、Secret 和 Data Policy。Feature 使用能力基础 Key,
|
|
26
|
+
Permission 在同一 Key 后追加动作;非匿名入口和 Handler 只能引用已声明且同基础 Key
|
|
27
|
+
的治理能力。**完成标准:Manifest 声明和 Host 实现双向枚举无缺失、未知或重复 Key。**
|
|
24
28
|
4. 数据层使用 Drizzle Schema、前向 Migration 和 Repository;Service 持有业务规则,
|
|
25
|
-
其它模块只能通过 Service、公开 Port
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
29
|
+
其它模块只能通过 Service、公开 Port 或注册机制协作。Manifest 与 Migration Bundle
|
|
30
|
+
版本、顺序、依赖和 Schema Export 必须一致;已发布 Migration ID/checksum 不改写。
|
|
31
|
+
**完成标准:新增变化可前向迁移,业务层不依赖数据库方言或其它模块 Repository。**
|
|
32
|
+
5. 通过 `InstallableServerModule` 和 `ModuleHost` 注册 Guarded Route、Task、Provider、
|
|
33
|
+
Tool、AI Operation、Durable Handler 或治理资源。Handler 调用 Service,不直接取得
|
|
34
|
+
Elysia、数据库、平台 Repository 或其它模块 Repository。选择启用用户时只使用
|
|
35
|
+
`ModuleRequestContext.userDirectory`;业务 RolePreset 只能引用本模块 Permission。
|
|
36
|
+
**完成标准:每个注册项都在模块命名空间内,并绑定 Manifest 中同一能力。**
|
|
37
|
+
6. 按需使用受限 Port,不扩宽 Context:
|
|
38
|
+
- 外部凭据只在 Manifest 声明逻辑 Secret;物理 binding 留在 project-owned Server
|
|
39
|
+
Composition,Request/Durable Handler 通过短生命周期 `resolve()` 使用。Tool 和
|
|
40
|
+
Sandbox 没有 Secret Port。
|
|
41
|
+
- 跨上传者文件读取先注册精确 `purpose + resourceType` 策略;Resolver 用
|
|
42
|
+
project-owned Repository 回查资源、fileId 和对象授权,只返回布尔判定,再调用
|
|
43
|
+
`openResourceFile()`。
|
|
44
|
+
- 流式写入和大报告分别使用可选 Storage Writer / Report Staging Port、显式 policy
|
|
45
|
+
与 `require*()` helper;Tool 不继承 Writer,缺少 `system.storage` 时直接说明物理
|
|
46
|
+
裁剪边界。
|
|
47
|
+
**完成标准:业务代码未注入 UploadRepository、BlobStore、Secret locator 或平台
|
|
48
|
+
manage Repository,缺失 Port 会稳定 fail closed。**
|
|
49
|
+
7. 业务资源含敏感字段时,在 Manifest 声明 Data Policy、standard read、
|
|
50
|
+
sensitive-disclosure reveal、governed-export Permission 和对应 API,再用
|
|
51
|
+
`registerGovernedResources()` 注册对象授权、脱敏投影、受控字段读取与分页 Source。
|
|
52
|
+
正式 PDF/DOCX/XLSX 等产物使用 Host Renderer 契约;审批、再认证、Grant、Durable
|
|
53
|
+
Job、水印、TTL、下载和取消仍由宿主持有。**完成标准:普通读取、明文揭示和导出三条
|
|
54
|
+
路径均复用对象授权与当前 Scope,业务没有自建旁路。**
|
|
55
|
+
8. Tool 输入输出只使用 Manifest 注册的顶层 object JSON Schema。客户端或模型不能提交
|
|
56
|
+
Actor、Permission、Feature、License、Scope 或“已审批”标记;最小调用事实来自
|
|
57
|
+
`ModuleToolContext`,其它 Guard 由 Host Runtime 每次重算。`command/background` Tool
|
|
58
|
+
还必须完成强制幂等、审批、领域 expected-version 和结果追踪;MCP Adapter 当前仍只
|
|
59
|
+
暴露 `operation=query`。**完成标准:Schema、Guard、幂等与审计契约在 Manifest 和
|
|
60
|
+
Handler 间一致,MCP 未复制 Tool 定义。**
|
|
61
|
+
9. 只有无需 Actor、Repository、Secret、Storage、文件系统或外网的纯计算 Tool 才使用
|
|
62
|
+
`setupSandbox()`;注册必须同步且无副作用。其余 Tool 留在普通 `setup()`,不能用
|
|
63
|
+
Sandbox 绕开依赖边界。**完成标准:Sandbox Handler 只依赖输入、`idempotencyKey` 和
|
|
64
|
+
`AbortSignal`。**
|
|
65
|
+
10. 新增 AI Operation 时同步声明 Manifest 与 `registerAiOperationHandlers()`,固定
|
|
66
|
+
allowed Tool、Provider egress/data allowlist、DLP、Tool network policy、输入输出限制
|
|
67
|
+
和可选 readiness pin。`system.agent` 的面向用户回答使用平台 Supervisor typed
|
|
68
|
+
final-answer 契约;Durable Handler 只通过 Actor-aware 后台 AI Port 恢复同一幂等
|
|
69
|
+
Run。浏览器或桌面宿主本地编排模型循环时使用 governed Client Agent Session,不向
|
|
70
|
+
客户端下发 Provider Secret 或 execution grant。**完成标准:Operation 的声明、
|
|
71
|
+
Handler、发布坐标、输出投影和运行边界一致。**
|
|
72
|
+
11. 补齐 Manifest/Composition、Repository/Service、Guard 拒绝和 Handler 契约覆盖;按
|
|
73
|
+
条件覆盖 Durable 重试/恢复、Tool 未授权发现/调用、资源文件、Secret、治理导出、
|
|
74
|
+
可选模块裁剪、Sandbox 隔离和 AI 恢复。**完成标准:每个新增能力至少有成功路径、
|
|
75
|
+
关键拒绝路径和声明/实现漂移检查。**
|
|
76
|
+
12. 更新长期文档,并按当前仓库 `AGENTS.md` 与 `package.json` 分层验证。windy-platform
|
|
77
|
+
普通小提交只运行允许的静态检查;合并候选统一运行 `test:merge`,冻结发版候选才运行
|
|
78
|
+
一次 `release:verify`。仅当项目提供 `lint` 脚本时运行 lint;一个 cohesive slice 一个
|
|
79
|
+
Conventional Commit。**完成标准:验证层级、未执行项和提交 SHA 均可审计。**
|
|
61
80
|
|
|
62
81
|
## 项目所有权与自动装配
|
|
63
82
|
|
|
64
|
-
- `apps/web/src`、`apps/server/src/app`、业务模块源码和
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
隐藏、排序或替换展示;模块不得直接写侧边栏源码。
|
|
83
|
+
- `apps/web/src`、`apps/server/src/app`、业务模块源码和 `windy.modules.json` 都是
|
|
84
|
+
project-owned。日常模块命令不覆盖 Admin、Router、layout 或 Server Composition。
|
|
85
|
+
- Admin Host 从启用模块的 `./admin` 与 Manifest 投影页面、入口和可见性;模块不直接
|
|
86
|
+
写侧边栏源码。
|
|
69
87
|
- Server Host 只接受 canonical `./manifest`、声明兼容范围的 Adapter 和显式
|
|
70
88
|
attachment。动态 package 不获得数据库或平台 Repository;需要项目 Repository 的
|
|
71
89
|
模块在 project-owned Composition 中装配。
|
|
72
|
-
-
|
|
73
|
-
|
|
90
|
+
- 安装、构建和 Server 监听前使用同一套 Manifest/实现双向校验;未知、重复、缺失声明
|
|
91
|
+
以及 setup 后替换或变异 canonical Manifest 都应 fail closed。
|
|
74
92
|
|
|
75
|
-
##
|
|
93
|
+
## 代码与文档事实源
|
|
76
94
|
|
|
77
|
-
- Manifest 与
|
|
78
|
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
95
|
+
- Manifest、Composition 与 Migration:`packages/modules/src/manifest.ts`、
|
|
96
|
+
`packages/modules/src/composition.ts`、`packages/shared/src/migration-bundle-validation.ts`
|
|
97
|
+
- Host 与 Context:`packages/server-sdk/src/module-host.ts`、
|
|
98
|
+
`packages/server-sdk/src/request-context.ts`、`packages/server-sdk/src/durable-handler.ts`
|
|
99
|
+
- Tool 与 AI:`packages/server-sdk/src/tool-registration.ts`、
|
|
100
|
+
`packages/server-sdk/src/sandbox-tool.ts`、
|
|
101
|
+
`packages/server-sdk/src/ai-operation-registration.ts`
|
|
102
|
+
- Secret、Storage 与治理:`packages/server-sdk/src/secret-port.ts`、
|
|
103
|
+
`packages/server-sdk/src/secret-binding.ts`、`packages/server-sdk/src/storage-port.ts`、
|
|
104
|
+
`packages/server-sdk/src/report-staging-port.ts`、
|
|
105
|
+
`packages/server-sdk/src/data-governance-registration.ts`
|
|
106
|
+
- 当前装配:`windy.modules.json`、`apps/server/src/app/server-composition.ts`、
|
|
107
|
+
`apps/server/src/module-host/runtime-composition.ts`
|
|
108
|
+
- 生命周期与运行边界:`docs/development/module-lifecycle.md`、
|
|
109
|
+
`docs/architecture/module-host.md`、`docs/platform/agent-tools.md`、
|
|
110
|
+
`docs/architecture/mcp-business-capabilities.md`
|
|
111
|
+
- 条件能力:`docs/architecture/module-secret-resolution.md`、
|
|
112
|
+
`docs/architecture/report-staging.md`、`docs/platform/governed-export-renderers.md`、
|
|
113
|
+
`docs/platform/agent-tool-approval.md`、`docs/platform/background-ai-operations.md`、
|
|
114
|
+
`docs/platform/client-agent-session.md`
|
|
87
115
|
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
某个事实源或 `system.agent` / `system.storage` 不存在时,先说明当前生成组合的物理边界,
|
|
117
|
+
不在业务层补一套替代实现。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"templateCommit": "
|
|
4
|
-
"generatorVersion": "0.6.
|
|
3
|
+
"templateCommit": "74fc88e548934dbda773291c4ad078d16a5396d1",
|
|
4
|
+
"generatorVersion": "0.6.14",
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"name": "system",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"name": "system.agent",
|
|
36
|
-
"version": "0.1.
|
|
36
|
+
"version": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"name": "system.operations",
|
package/template/AGENTS.md
CHANGED
|
@@ -69,10 +69,8 @@
|
|
|
69
69
|
`providerDataPolicy.inputFields` JSON Pointer allowlist 与
|
|
70
70
|
`envelopeFields`;raw input 会在进入 `prepare` 前裁剪并执行 DLP。接入与升级
|
|
71
71
|
诊断见 `docs/platform/agent-runtime.md`。
|
|
72
|
-
-
|
|
73
|
-
`
|
|
74
|
-
当前启用的真实开发数据用户;Compose、权限收窄、Scope 复核、专用审计主体与
|
|
75
|
-
canonical Run bridge 由 Windy 基线提供。
|
|
72
|
+
- Agent 运行调试统一使用主站 AI Runtime 的受治理 Run/Trajectory;历史业务会话通过
|
|
73
|
+
`registerAgentSessionProviders()` 注册只读投影,并复用当前登录身份、RBAC 与 Scope。
|
|
76
74
|
|
|
77
75
|
## 常用入口
|
|
78
76
|
|
|
@@ -86,8 +84,7 @@
|
|
|
86
84
|
- `bun run dev:build`:依赖、Dockerfile 或 lockfile 变化后重建并启动开发环境;Web 与 Server 并发复用 BuildKit Bun 下载缓存,冷安装会周期输出不含凭据的心跳。
|
|
87
85
|
- `bun run dev:web`:启动 Web 开发服务。
|
|
88
86
|
- `bun run dev:server`:启动 Server 开发服务。
|
|
89
|
-
-
|
|
90
|
-
调试链;生产环境不提供该入口。
|
|
87
|
+
- `/admin/system/ai-runtime`:查看受治理的 Run、Provider Attempt 与脱敏 Trajectory。
|
|
91
88
|
- `bun run lint`、`bun run typecheck`、`bun run test`、`bun run build`:执行基础验证;未选择 Oxc 时没有 lint 脚本。
|
|
92
89
|
- `docs/README.md`:平台架构、模块接入和运维文档入口。
|
|
93
90
|
- `.windy/generation.json`:本次生成器版本、所选模块和选项记录。
|
|
@@ -14,14 +14,13 @@ COPY apps/agent-server/pyproject.toml apps/agent-server/uv.lock ./
|
|
|
14
14
|
RUN windy-agent-python-install lock
|
|
15
15
|
RUN windy-agent-python-install sync --frozen --no-dev --no-install-project
|
|
16
16
|
COPY apps/agent-server/src ./src
|
|
17
|
-
COPY apps/agent-server/adk_web_agents ./adk_web_agents
|
|
18
17
|
RUN windy-agent-python-install sync --frozen --no-dev
|
|
19
18
|
|
|
20
19
|
ENV PATH="/app/apps/agent-server/.venv/bin:${PATH}"
|
|
21
20
|
ENV PYTHONUNBUFFERED=1
|
|
22
21
|
EXPOSE 8080
|
|
23
|
-
RUN mkdir -p /app/data/agent
|
|
24
|
-
&& chown -R windy:windy /app/data
|
|
22
|
+
RUN mkdir -p /app/data/agent \
|
|
23
|
+
&& chown -R windy:windy /app/data
|
|
25
24
|
USER windy
|
|
26
25
|
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=4 \
|
|
27
26
|
CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Windy Agent Server
|
|
2
2
|
|
|
3
|
-
Python 3.12 Agent 运行时。HTTP 层只公开 Windy
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Python 3.12 Agent 运行时。HTTP 层只公开 Windy canonical Agent 契约;真实业务 Run 由
|
|
4
|
+
`OpenAiCompatibleEngineAdapter` 直接执行,模型调用复用受治理的 OpenAI-compatible
|
|
5
|
+
`/chat/completions` Provider。Engine、Provider 和 Tool 私有类型不会越过
|
|
6
|
+
`AgentEngineAdapter`。
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
uv sync --frozen
|
|
@@ -21,10 +21,10 @@ HTTP 接口:
|
|
|
21
21
|
- `POST /api/agent/runs/:runId/cancel`
|
|
22
22
|
|
|
23
23
|
Run 创建使用 `Idempotency-Key`。事件以 SSE 传输,支持 `Last-Event-ID` 和 `after`
|
|
24
|
-
断线重放,并周期发送 comment heartbeat。Provider
|
|
25
|
-
|
|
24
|
+
断线重放,并周期发送 comment heartbeat。Provider 或 Engine 异常只映射为 canonical
|
|
25
|
+
安全错误,不把原始异常正文暴露给调用方。
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
配置以下仅服务端可见的环境变量后启用 Direct Engine:
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
export AGENT_SERVER_INTERNAL_TOKEN='<random-token>'
|
|
@@ -40,9 +40,17 @@ export AI_PROVIDER_AUDIT_RETENTION_DAYS='90'
|
|
|
40
40
|
uv run uvicorn southwind_agent_server.app:app
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
公网 URL 必须使用 HTTPS 且 Host 精确命中 allowlist;本机、容器服务名和内网地址允许
|
|
44
|
+
HTTP。Provider 请求有连接与总超时、响应大小限制、错误脱敏和出网审计。缺少 URL、
|
|
45
|
+
Key 或 Model 时使用 `UnavailableEngineAdapter` 稳定返回 unavailable,不调用模型。
|
|
46
|
+
|
|
47
|
+
Direct Engine 保留文本、结构化输出、Citation、Vision Artifact、受治理 Tool、多轮 Tool、
|
|
48
|
+
审批等待/恢复、取消、Usage 和 Provider Attempt。Tool 只接受 Operation 允许的 Key,执行时
|
|
49
|
+
回调 Windy Tool Host 并携带当前 Run 的 opaque Execution Grant。Service 在每次模型轮次
|
|
50
|
+
和 Tool 前后重新检查取消,避免取消后继续产生副作用或发布成功终态。
|
|
51
|
+
|
|
52
|
+
VLM Operation readiness 比 Endpoint 可达性更严格。必须固定 Deployment 事实并声明图片
|
|
53
|
+
offer;否则 `/health/vlm-ready` 返回 V1 `unavailable` snapshot,视觉 Operation 保持关闭:
|
|
46
54
|
|
|
47
55
|
```bash
|
|
48
56
|
export AI_PROVIDER_CAPABILITIES='text-generation,vision'
|
|
@@ -54,47 +62,23 @@ export AI_PROVIDER_MAX_CONCURRENT_RUNS='1'
|
|
|
54
62
|
export AI_PROVIDER_MAX_QUEUE_DEPTH='0'
|
|
55
63
|
```
|
|
56
64
|
|
|
57
|
-
Readiness
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Windy
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
run、attempt、分类集合、实际序列化请求字节数和 allow/redact/reject 决策写入独立
|
|
78
|
-
SQLite append-only 表。审计不保存 prompt、请求正文或 Secret;审计写入失败时禁止
|
|
79
|
-
出网。记录到期后只由配置的 TTL 清理,清理计数可通过需内部 Token 的
|
|
80
|
-
`GET /health/provider-governance` 查看。SQLite 实现仅支持单副本;多副本部署必须替换
|
|
81
|
-
为共享、并发安全的审计 Adapter。
|
|
82
|
-
|
|
83
|
-
项目在 `project/adk-web-debug.json` 绑定一个满足
|
|
84
|
-
`{ question: string } -> { text: string }` 的真实 Agent Operation 和当前启用的开发
|
|
85
|
-
数据用户后,可启动 ADK Web:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
bun run dev:adk-web
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
访问 `http://127.0.0.1:8000` 并选择 `canonical_debug`。该命令会拉起完整开发
|
|
92
|
-
Runtime;Windy 启动脚本读取项目选择的 Operation,ADK Web 使用 create-windy 自动生成
|
|
93
|
-
的随机调试 Token,经 canonical HTTP/SSE 执行真实 Operation。Server 把它解析成仅限
|
|
94
|
-
Run 路径的专用服务身份,向业务 Module 投影真实用户的成员 ID 和当前 Scope,并把权限
|
|
95
|
-
收窄到该用户已有权限与 Operation/allowed Tools 闭包。Provider、业务 Tool、
|
|
96
|
-
Execution Grant 和审计仍由正式 Server/Agent Server 负责,ADK 容器不持有 Provider
|
|
97
|
-
Key 或内部服务 Token。
|
|
98
|
-
|
|
99
|
-
`safe_debug` 只用于纯 ADK UI smoke。生产 Compose 不包含 ADK Web;当前桥显示的是
|
|
100
|
-
canonical Run 及有界事件摘要,不是内部完整 Workflow 图。
|
|
65
|
+
Readiness 使用固定一像素合成图片调用已配置的 `/chat/completions` 并要求有界结构化结果。
|
|
66
|
+
它不读取客户截图,也不把用户 Artifact、URL、Run ID、Prompt 或 Provider 输出放进 health
|
|
67
|
+
payload。
|
|
68
|
+
|
|
69
|
+
未设置 `AGENT_RUN_STORE_PATH` 时的 `InMemoryRunStore` 仅用于 deterministic 测试。
|
|
70
|
+
配置路径后使用有界 SQLite Store,可在单副本重启后保留 Run/Event/Result 和 cursor;
|
|
71
|
+
多副本部署必须使用共享 Store。Run 固定保存稳定 Engine ID
|
|
72
|
+
`windy.direct.openai-compatible.v1`;历史 `google.adk.v2` Run 只读兼容,不回填,也不能由
|
|
73
|
+
Direct Engine 从中断点继续。
|
|
74
|
+
|
|
75
|
+
每次实际 Provider HTTP 调用前,Runtime 对 Manifest 允许的输入 JSON Pointer 与 outbound
|
|
76
|
+
envelope 执行 DLP,并将 deployment、operation、run、attempt、分类集合、序列化字节数和
|
|
77
|
+
allow/redact/reject 决策写入 append-only 审计。审计不保存 Prompt、请求正文或 Secret;
|
|
78
|
+
审计写入失败时禁止出网。
|
|
79
|
+
|
|
80
|
+
开发与运维统一使用 Windy 主站 `/admin/system/ai-runtime`。详情中的脱敏 Trajectory 展示
|
|
81
|
+
Run、输入模态、Tool Key、审批、Usage、Artifact 数量、取消/失败和终态,不展示输入输出正文、
|
|
82
|
+
Tool 参数、chain-of-thought 或 Provider 原始响应。业务历史会话通过
|
|
83
|
+
`registerAgentSessionProviders()` 投影到受当前登录身份、Feature、RBAC 和对象范围保护的
|
|
84
|
+
主站接口;不再存在独立调试站点、专用调试身份或第二种 Token。
|
|
@@ -11,6 +11,7 @@ from fastapi.responses import JSONResponse, StreamingResponse
|
|
|
11
11
|
from pydantic import ValidationError
|
|
12
12
|
|
|
13
13
|
from .artifact_input import ArtifactLoader
|
|
14
|
+
from .client_completion_routes import install_client_completion_routes
|
|
14
15
|
from .contracts import (
|
|
15
16
|
CancelRunRequest,
|
|
16
17
|
CancelRunResponse,
|
|
@@ -92,10 +93,11 @@ def create_app(
|
|
|
92
93
|
lifespan=lifespan,
|
|
93
94
|
)
|
|
94
95
|
application.include_router(
|
|
95
|
-
create_report_router(runtime_report_store, internal_token)
|
|
96
|
+
create_report_router(runtime_report_store, runtime.store, internal_token)
|
|
96
97
|
)
|
|
97
98
|
|
|
98
|
-
install_health_routes(application, runtime, runtime_engine)
|
|
99
|
+
install_health_routes(application, runtime, runtime_engine, internal_token)
|
|
100
|
+
install_client_completion_routes(application, runtime_engine, internal_token)
|
|
99
101
|
|
|
100
102
|
@application.get("/health/provider-governance", response_model=None)
|
|
101
103
|
async def provider_governance_health(
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from .attempt_context_projection import (
|
|
6
|
+
AttemptContextPreparation,
|
|
7
|
+
governed_envelope,
|
|
8
|
+
)
|
|
9
|
+
from .context_version_port import (
|
|
10
|
+
ContextVersionPort,
|
|
11
|
+
PreparedSource,
|
|
12
|
+
context_unavailable,
|
|
13
|
+
)
|
|
14
|
+
from .contracts import JsonValue, LongSessionContext
|
|
15
|
+
from .engine import EngineRunRequest, PreparedArtifact
|
|
16
|
+
from .openai_provider import OpenAiCompatibleProvider
|
|
17
|
+
from .provider_governance import GovernedAttempt, ProviderRequestGovernance
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class GovernedProviderAttempt:
|
|
22
|
+
governed: GovernedAttempt
|
|
23
|
+
provider_request: bytes
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
async def govern_provider_attempt(
|
|
27
|
+
port: ContextVersionPort,
|
|
28
|
+
governance: ProviderRequestGovernance,
|
|
29
|
+
provider: OpenAiCompatibleProvider,
|
|
30
|
+
request: EngineRunRequest,
|
|
31
|
+
attempt_sequence: int,
|
|
32
|
+
model_attempt_id: str | None,
|
|
33
|
+
messages: list[dict[str, JsonValue]],
|
|
34
|
+
max_output_tokens: int | None = None,
|
|
35
|
+
) -> GovernedProviderAttempt:
|
|
36
|
+
preparation = await prepare_attempt_context(
|
|
37
|
+
port,
|
|
38
|
+
request.long_session,
|
|
39
|
+
request.run_id,
|
|
40
|
+
model_attempt_id,
|
|
41
|
+
request.execution_grant,
|
|
42
|
+
messages,
|
|
43
|
+
)
|
|
44
|
+
try:
|
|
45
|
+
attempt_messages = preparation.messages if preparation else messages
|
|
46
|
+
governed = governance.authorize(
|
|
47
|
+
deployment_key=provider.config.deployment_key,
|
|
48
|
+
operation_key=request.operation_key,
|
|
49
|
+
run_id=request.run_id,
|
|
50
|
+
attempt=attempt_sequence,
|
|
51
|
+
messages=attempt_messages,
|
|
52
|
+
tools=request.allowed_tools,
|
|
53
|
+
policy=request.provider_data_policy,
|
|
54
|
+
input_value=request.input,
|
|
55
|
+
artifact_bytes=sum(artifact.byte_size for artifact in request.artifacts),
|
|
56
|
+
output_schema=request.output_schema,
|
|
57
|
+
measure=lambda current_messages, tools, schema: len(
|
|
58
|
+
provider.request_body(
|
|
59
|
+
current_messages,
|
|
60
|
+
tools,
|
|
61
|
+
request.output_schema_key,
|
|
62
|
+
schema,
|
|
63
|
+
max_output_tokens,
|
|
64
|
+
)
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
provider_request = provider.request_body(
|
|
68
|
+
governed.messages,
|
|
69
|
+
governed.tools,
|
|
70
|
+
request.output_schema_key,
|
|
71
|
+
governed.output_schema,
|
|
72
|
+
max_output_tokens,
|
|
73
|
+
)
|
|
74
|
+
await commit_attempt_context(
|
|
75
|
+
port,
|
|
76
|
+
preparation,
|
|
77
|
+
request.long_session,
|
|
78
|
+
request.run_id,
|
|
79
|
+
model_attempt_id,
|
|
80
|
+
request.execution_grant,
|
|
81
|
+
governed.messages,
|
|
82
|
+
provider_request,
|
|
83
|
+
provider.config.deployment_key,
|
|
84
|
+
provider.config.model,
|
|
85
|
+
request.prompt_version,
|
|
86
|
+
request.artifacts,
|
|
87
|
+
)
|
|
88
|
+
return GovernedProviderAttempt(governed, provider_request)
|
|
89
|
+
except BaseException:
|
|
90
|
+
await abort_attempt_context(
|
|
91
|
+
port,
|
|
92
|
+
preparation,
|
|
93
|
+
request.long_session,
|
|
94
|
+
request.run_id,
|
|
95
|
+
model_attempt_id,
|
|
96
|
+
request.execution_grant,
|
|
97
|
+
)
|
|
98
|
+
raise
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
async def prepare_attempt_context(
|
|
102
|
+
port: ContextVersionPort,
|
|
103
|
+
binding: LongSessionContext | None,
|
|
104
|
+
run_id: str,
|
|
105
|
+
model_attempt_id: str | None,
|
|
106
|
+
authorization_grant: str,
|
|
107
|
+
messages: list[dict[str, JsonValue]],
|
|
108
|
+
) -> AttemptContextPreparation | None:
|
|
109
|
+
if binding is None:
|
|
110
|
+
return None
|
|
111
|
+
if model_attempt_id is None or not authorization_grant.strip():
|
|
112
|
+
raise context_unavailable()
|
|
113
|
+
context = await port.prepare(
|
|
114
|
+
binding,
|
|
115
|
+
run_id,
|
|
116
|
+
model_attempt_id,
|
|
117
|
+
authorization_grant,
|
|
118
|
+
)
|
|
119
|
+
insertion_start = 1 if messages and messages[0].get("role") == "system" else 0
|
|
120
|
+
injected = [_source_message(source) for source in context.sources]
|
|
121
|
+
return AttemptContextPreparation(
|
|
122
|
+
context,
|
|
123
|
+
[*messages[:insertion_start], *injected, *messages[insertion_start:]],
|
|
124
|
+
insertion_start,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
async def commit_attempt_context(
|
|
129
|
+
port: ContextVersionPort,
|
|
130
|
+
preparation: AttemptContextPreparation | None,
|
|
131
|
+
binding: LongSessionContext | None,
|
|
132
|
+
run_id: str,
|
|
133
|
+
model_attempt_id: str | None,
|
|
134
|
+
authorization_grant: str,
|
|
135
|
+
governed_messages: list[dict[str, JsonValue]],
|
|
136
|
+
provider_request: bytes,
|
|
137
|
+
deployment_key: str,
|
|
138
|
+
model: str,
|
|
139
|
+
prompt_version: str,
|
|
140
|
+
artifacts: tuple[PreparedArtifact, ...],
|
|
141
|
+
) -> None:
|
|
142
|
+
if binding is None:
|
|
143
|
+
return
|
|
144
|
+
if preparation is None or model_attempt_id is None:
|
|
145
|
+
raise context_unavailable()
|
|
146
|
+
envelope = governed_envelope(
|
|
147
|
+
preparation,
|
|
148
|
+
run_id,
|
|
149
|
+
model_attempt_id,
|
|
150
|
+
governed_messages,
|
|
151
|
+
provider_request,
|
|
152
|
+
deployment_key,
|
|
153
|
+
model,
|
|
154
|
+
prompt_version,
|
|
155
|
+
artifacts,
|
|
156
|
+
)
|
|
157
|
+
await port.commit(
|
|
158
|
+
preparation.context,
|
|
159
|
+
binding,
|
|
160
|
+
run_id,
|
|
161
|
+
model_attempt_id,
|
|
162
|
+
authorization_grant,
|
|
163
|
+
envelope,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
async def abort_attempt_context(
|
|
168
|
+
port: ContextVersionPort,
|
|
169
|
+
preparation: AttemptContextPreparation | None,
|
|
170
|
+
binding: LongSessionContext | None,
|
|
171
|
+
run_id: str,
|
|
172
|
+
model_attempt_id: str | None,
|
|
173
|
+
authorization_grant: str,
|
|
174
|
+
) -> None:
|
|
175
|
+
if binding is None or preparation is None or model_attempt_id is None:
|
|
176
|
+
return
|
|
177
|
+
try:
|
|
178
|
+
await port.abort(
|
|
179
|
+
preparation.context,
|
|
180
|
+
binding,
|
|
181
|
+
run_id,
|
|
182
|
+
model_attempt_id,
|
|
183
|
+
authorization_grant,
|
|
184
|
+
)
|
|
185
|
+
except Exception:
|
|
186
|
+
# Preparations are never active and have a bounded Server-side TTL.
|
|
187
|
+
return
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _source_message(source: PreparedSource) -> dict[str, JsonValue]:
|
|
191
|
+
return {"role": source.role, "content": source.content}
|