create-windy 0.3.2 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -9
- package/dist/cli.js +825 -117
- package/package.json +1 -1
- package/template/.agents/skills/windy-business-module/SKILL.md +16 -3
- package/template/.windy-template.json +2 -2
- package/template/AGENTS.md +4 -0
- package/template/README.md +18 -11
- package/template/_gitignore +1 -0
- package/template/apps/agent-server/README.md +2 -0
- package/template/apps/agent-server/pyproject.toml +8 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +87 -10
- package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +18 -3
- package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +78 -11
- package/template/apps/agent-server/src/southwind_agent_server/app.py +120 -115
- package/template/apps/agent-server/src/southwind_agent_server/artifact_input.py +153 -0
- package/template/apps/agent-server/src/southwind_agent_server/config.py +29 -0
- package/template/apps/agent-server/src/southwind_agent_server/contracts.py +81 -1
- package/template/apps/agent-server/src/southwind_agent_server/deterministic.py +8 -0
- package/template/apps/agent-server/src/southwind_agent_server/engine.py +28 -0
- package/template/apps/agent-server/src/southwind_agent_server/fingerprint.py +41 -0
- package/template/apps/agent-server/src/southwind_agent_server/http_helpers.py +62 -0
- package/template/apps/agent-server/src/southwind_agent_server/lease.py +15 -0
- package/template/apps/agent-server/src/southwind_agent_server/multimodal.py +76 -0
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +112 -20
- package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +14 -1
- package/template/apps/agent-server/src/southwind_agent_server/postgres_store.py +329 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_store_backend.py +332 -0
- package/template/apps/agent-server/src/southwind_agent_server/provider_governance.py +64 -3
- package/template/apps/agent-server/src/southwind_agent_server/runtime_factory.py +68 -0
- package/template/apps/agent-server/src/southwind_agent_server/service.py +218 -56
- package/template/apps/agent-server/src/southwind_agent_server/signal_events.py +36 -0
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_catalog.py +107 -0
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_schema.py +65 -0
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_serialization.py +16 -0
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_store.py +89 -57
- package/template/apps/agent-server/src/southwind_agent_server/store.py +105 -2
- package/template/apps/agent-server/src/southwind_agent_server/store_cipher.py +40 -0
- package/template/apps/agent-server/src/southwind_agent_server/telemetry.py +89 -0
- package/template/apps/agent-server/src/southwind_agent_server/tool_host.py +72 -0
- package/template/apps/agent-server/tests/test_adk_adapter.py +6 -2
- package/template/apps/agent-server/tests/test_api.py +24 -1
- package/template/apps/agent-server/tests/test_artifact_input.py +110 -0
- package/template/apps/agent-server/tests/test_config.py +4 -0
- package/template/apps/agent-server/tests/test_fingerprint.py +10 -0
- package/template/apps/agent-server/tests/test_multimodal.py +51 -0
- package/template/apps/agent-server/tests/test_openai_provider.py +6 -2
- package/template/apps/agent-server/tests/test_postgres_store.py +131 -0
- package/template/apps/agent-server/tests/test_provider_governance.py +61 -0
- package/template/apps/agent-server/tests/test_sqlite_store.py +95 -10
- package/template/apps/agent-server/tests/test_telemetry.py +25 -0
- package/template/apps/agent-server/tests/test_tool_approval.py +28 -0
- package/template/apps/agent-server/uv.lock +165 -0
- package/template/apps/document-server/Dockerfile +19 -0
- package/template/apps/document-server/pyproject.toml +43 -0
- package/template/apps/document-server/src/southwind_document_server/__init__.py +1 -0
- package/template/apps/document-server/src/southwind_document_server/adapter.py +337 -0
- package/template/apps/document-server/src/southwind_document_server/app.py +151 -0
- package/template/apps/document-server/src/southwind_document_server/config.py +94 -0
- package/template/apps/document-server/src/southwind_document_server/contracts.py +103 -0
- package/template/apps/document-server/src/southwind_document_server/service.py +149 -0
- package/template/apps/document-server/src/southwind_document_server/store.py +185 -0
- package/template/apps/document-server/tests/__init__.py +1 -0
- package/template/apps/document-server/tests/test_config.py +42 -0
- package/template/apps/document-server/tests/test_service.py +140 -0
- package/template/apps/document-server/uv.lock +430 -0
- package/template/apps/embedding-server/Dockerfile +17 -0
- package/template/apps/embedding-server/pyproject.toml +44 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/__init__.py +1 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/adapter.py +254 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/app.py +119 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/config.py +120 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/contracts.py +106 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/error.py +6 -0
- package/template/apps/embedding-server/src/southwind_embedding_server/image_input.py +87 -0
- package/template/apps/embedding-server/tests/__init__.py +1 -0
- package/template/apps/embedding-server/tests/test_adapter.py +92 -0
- package/template/apps/embedding-server/tests/test_config.py +38 -0
- package/template/apps/embedding-server/uv.lock +449 -0
- package/template/apps/server/src/agent/background-operation-port.ts +37 -0
- package/template/apps/server/src/agent/background-operation.test.ts +231 -0
- package/template/apps/server/src/agent/background-operation.ts +252 -0
- package/template/apps/server/src/agent/drizzle-run-binding-repository.ts +114 -0
- package/template/apps/server/src/agent/execution-grants.ts +7 -1
- package/template/apps/server/src/agent/fake-runtime.test-support.ts +43 -0
- package/template/apps/server/src/agent/idempotency-key.test.ts +28 -0
- package/template/apps/server/src/agent/idempotency-key.ts +11 -0
- package/template/apps/server/src/agent/remote-runtime.test.ts +115 -1
- package/template/apps/server/src/agent/remote-runtime.ts +173 -5
- package/template/apps/server/src/agent/run-authorization.test-support.ts +9 -0
- package/template/apps/server/src/agent/run-authorization.test.ts +126 -0
- package/template/apps/server/src/agent/run-authorization.ts +180 -0
- package/template/apps/server/src/agent/run-binding-repository.ts +93 -0
- package/template/apps/server/src/agent/run-contracts.ts +88 -1
- package/template/apps/server/src/agent/run-definition-support.ts +58 -0
- package/template/apps/server/src/agent/run-errors.ts +25 -0
- package/template/apps/server/src/agent/run-facade.test.ts +57 -46
- package/template/apps/server/src/agent/run-facade.ts +185 -65
- package/template/apps/server/src/agent/run-release.ts +78 -0
- package/template/apps/server/src/agent/run-route-input.ts +169 -0
- package/template/apps/server/src/agent/run-routes.ts +63 -76
- package/template/apps/server/src/agent/runtime-bootstrap.ts +169 -13
- package/template/apps/server/src/agent/sandbox-client.ts +200 -0
- package/template/apps/server/src/agent/sandbox-protocol.ts +76 -0
- package/template/apps/server/src/agent/sandbox-registry.ts +205 -0
- package/template/apps/server/src/agent/sandbox-runtime.test.ts +137 -0
- package/template/apps/server/src/agent/sandbox-worker-server.ts +195 -0
- package/template/apps/server/src/agent/sandbox-worker.ts +12 -0
- package/template/apps/server/src/agent/tool-approval.test.ts +75 -0
- package/template/apps/server/src/agent/tool-approval.ts +115 -0
- package/template/apps/server/src/agent/tool-audit.ts +62 -0
- package/template/apps/server/src/agent/tool-host.test.ts +39 -11
- package/template/apps/server/src/agent/tool-host.ts +184 -17
- package/template/apps/server/src/agent/tool-registry.ts +52 -47
- package/template/apps/server/src/agent/vision-facade.test.ts +256 -0
- package/template/apps/server/src/agent/vision-input.ts +120 -0
- package/template/apps/server/src/ai-artifact/codec.test.ts +44 -0
- package/template/apps/server/src/ai-artifact/codec.ts +137 -0
- package/template/apps/server/src/ai-artifact/routes.ts +37 -0
- package/template/apps/server/src/ai-artifact/runtime.ts +205 -0
- package/template/apps/server/src/application-services.ts +62 -2
- package/template/apps/server/src/auth/reauthentication.test.ts +40 -0
- package/template/apps/server/src/auth/reauthentication.ts +19 -0
- package/template/apps/server/src/auth/runtime.ts +9 -1
- package/template/apps/server/src/data-access/context.ts +6 -4
- package/template/apps/server/src/data-access/scope-snapshot.ts +27 -0
- package/template/apps/server/src/data-governance/export/approval-port.ts +6 -3
- package/template/apps/server/src/data-governance/export/authorization-port.test.ts +23 -4
- package/template/apps/server/src/data-governance/export/authorization-port.ts +89 -25
- package/template/apps/server/src/data-governance/export/drizzle-repository.integration.test.ts +2 -0
- package/template/apps/server/src/data-governance/export/drizzle-repository.ts +1 -0
- package/template/apps/server/src/data-governance/export/job-runtime.test.ts +15 -4
- package/template/apps/server/src/data-governance/export/job-runtime.ts +68 -15
- package/template/apps/server/src/data-governance/export/ndjson-stream.ts +25 -6
- package/template/apps/server/src/data-governance/export/postgres-recovery.integration.test.ts +4 -2
- package/template/apps/server/src/data-governance/export/renderer-job-runtime.test.ts +235 -0
- package/template/apps/server/src/data-governance/export/renderer-runtime.ts +293 -0
- package/template/apps/server/src/data-governance/export/renderer-selection.test.ts +67 -0
- package/template/apps/server/src/data-governance/export/repository.test.ts +2 -0
- package/template/apps/server/src/data-governance/export/request-fingerprint.test.ts +13 -0
- package/template/apps/server/src/data-governance/export/request-fingerprint.ts +2 -0
- package/template/apps/server/src/data-governance/export/routes.ts +11 -1
- package/template/apps/server/src/data-governance/export/scope-snapshot.ts +6 -18
- package/template/apps/server/src/data-governance/export/service-support.ts +188 -0
- package/template/apps/server/src/data-governance/export/service.ts +90 -113
- package/template/apps/server/src/data-governance/export/source.ts +101 -0
- package/template/apps/server/src/data-governance/export/types.ts +27 -0
- package/template/apps/server/src/document/contracts.ts +76 -0
- package/template/apps/server/src/document/facade.ts +339 -0
- package/template/apps/server/src/document/remote-runtime.test.ts +96 -0
- package/template/apps/server/src/document/remote-runtime.ts +223 -0
- package/template/apps/server/src/document/routes.ts +193 -0
- package/template/apps/server/src/embedding/contracts.ts +83 -0
- package/template/apps/server/src/embedding/error.ts +10 -0
- package/template/apps/server/src/embedding/facade.ts +217 -0
- package/template/apps/server/src/embedding/input.ts +172 -0
- package/template/apps/server/src/embedding/remote-runtime.test.ts +66 -0
- package/template/apps/server/src/embedding/remote-runtime.ts +218 -0
- package/template/apps/server/src/embedding/routes.ts +152 -0
- package/template/apps/server/src/index.ts +40 -43
- package/template/apps/server/src/jobs/artifact-service.test.ts +14 -2
- package/template/apps/server/src/jobs/artifact-service.ts +10 -0
- package/template/apps/server/src/jobs/drizzle-execution-repository.ts +17 -18
- package/template/apps/server/src/jobs/drizzle-execution.integration.test.ts +19 -1
- package/template/apps/server/src/jobs/drizzle-mappers.ts +4 -1
- package/template/apps/server/src/jobs/drizzle-recovery-repository.ts +49 -2
- package/template/apps/server/src/jobs/drizzle-repository.ts +1 -0
- package/template/apps/server/src/jobs/execution-repository.ts +17 -0
- package/template/apps/server/src/jobs/execution.test.ts +34 -0
- package/template/apps/server/src/jobs/in-memory-control.ts +135 -0
- package/template/apps/server/src/jobs/in-memory-execution.ts +34 -65
- package/template/apps/server/src/jobs/legacy-service-runtime.ts +5 -2
- package/template/apps/server/src/jobs/repository.ts +3 -0
- package/template/apps/server/src/jobs/worker.ts +80 -41
- package/template/apps/server/src/module-host/ai-operation-port.ts +170 -0
- package/template/apps/server/src/module-host/durable-context.test.ts +312 -0
- package/template/apps/server/src/module-host/durable-context.ts +124 -0
- package/template/apps/server/src/module-host/durable-handler-registration.ts +72 -0
- package/template/apps/server/src/module-host/governed-export-route-support.ts +171 -0
- package/template/apps/server/src/module-host/governed-export-routes.test.ts +327 -0
- package/template/apps/server/src/module-host/governed-export-routes.ts +238 -0
- package/template/apps/server/src/module-host/governed-renderer-registration.test.ts +247 -0
- package/template/apps/server/src/module-host/governed-resource-routes.ts +331 -0
- package/template/apps/server/src/module-host/governed-resources.test.ts +344 -0
- package/template/apps/server/src/module-host/governed-resources.ts +203 -0
- package/template/apps/server/src/module-host/http-runtime.ts +95 -0
- package/template/apps/server/src/module-host/initialize-contracts.ts +14 -0
- package/template/apps/server/src/module-host/initialize.test.ts +49 -1
- package/template/apps/server/src/module-host/initialize.ts +39 -16
- package/template/apps/server/src/module-host/job-port.test.ts +262 -0
- package/template/apps/server/src/module-host/job-port.ts +334 -0
- package/template/apps/server/src/module-host/request-context.test.ts +88 -2
- package/template/apps/server/src/module-host/request-context.ts +56 -22
- package/template/apps/server/src/module-host/route-installer.test.ts +10 -0
- package/template/apps/server/src/module-host/route-installer.ts +36 -1
- package/template/apps/server/src/module-host/sandbox-tool-registration.ts +42 -0
- package/template/apps/server/src/module-host/tool-handlers.ts +67 -31
- package/template/apps/server/src/module-host.ts +1 -0
- package/template/apps/server/src/module-runtime-validation.ts +7 -3
- package/template/apps/server/src/speech/contracts.ts +76 -0
- package/template/apps/server/src/speech/facade.ts +316 -0
- package/template/apps/server/src/speech/remote-runtime.test.ts +88 -0
- package/template/apps/server/src/speech/remote-runtime.ts +227 -0
- package/template/apps/server/src/speech/routes.ts +180 -0
- package/template/apps/server/src/system/actor.ts +39 -0
- package/template/apps/server/src/system/route-helpers.ts +1 -0
- package/template/apps/server/src/workflow/service.ts +2 -1
- package/template/apps/speech-server/Dockerfile +22 -0
- package/template/apps/speech-server/pyproject.toml +43 -0
- package/template/apps/speech-server/src/southwind_speech_server/__init__.py +1 -0
- package/template/apps/speech-server/src/southwind_speech_server/adapter.py +249 -0
- package/template/apps/speech-server/src/southwind_speech_server/app.py +183 -0
- package/template/apps/speech-server/src/southwind_speech_server/config.py +100 -0
- package/template/apps/speech-server/src/southwind_speech_server/contracts.py +103 -0
- package/template/apps/speech-server/src/southwind_speech_server/errors.py +6 -0
- package/template/apps/speech-server/src/southwind_speech_server/normalizer.py +108 -0
- package/template/apps/speech-server/src/southwind_speech_server/output_validation.py +128 -0
- package/template/apps/speech-server/src/southwind_speech_server/service.py +162 -0
- package/template/apps/speech-server/src/southwind_speech_server/store.py +209 -0
- package/template/apps/speech-server/tests/__init__.py +1 -0
- package/template/apps/speech-server/tests/test_config.py +33 -0
- package/template/apps/speech-server/tests/test_service.py +154 -0
- package/template/apps/speech-server/uv.lock +430 -0
- package/template/apps/web/src/app/business-routes.ts +22 -0
- package/template/apps/web/src/components/common/AccessSnapshotBoundary.vue +112 -0
- package/template/apps/web/src/components/common/AccessSnapshotBoundary.webtest.ts +130 -0
- package/template/apps/web/src/components/common/AccessSnapshotNotice.vue +117 -0
- package/template/apps/web/src/components/common/FormDialog.vue +6 -0
- package/template/apps/web/src/components/common/ModalLayout.webtest.ts +13 -0
- package/template/apps/web/src/composables/access-snapshot-change.ts +131 -0
- package/template/apps/web/src/composables/access-snapshot-change.webtest.ts +103 -0
- package/template/apps/web/src/composables/useAccessSnapshot.ts +48 -2
- package/template/apps/web/src/composables/useAccessSnapshot.webtest.ts +54 -0
- package/template/apps/web/src/composables/useAccessSnapshotMonitor.ts +42 -0
- package/template/apps/web/src/layout/AppShell.vue +28 -25
- package/template/apps/web/src/layout/AppShell.webtest.ts +1 -0
- package/template/apps/web/src/router/business-routes.ts +68 -0
- package/template/apps/web/src/router/business-routes.webtest.ts +85 -0
- package/template/apps/web/src/router/index.ts +7 -0
- package/template/apps/web/src/router/shared-scaffold-neutrality.webtest.ts +12 -0
- package/template/apps/web/src/services/access-api.ts +5 -1
- package/template/apps/web/src/services/access-api.webtest.ts +35 -0
- package/template/docker-compose.yml +127 -0
- package/template/docs/architecture/ai-egress.md +12 -9
- package/template/docs/architecture/ai-runtime.md +23 -11
- package/template/docs/architecture/durable-jobs.md +25 -3
- package/template/docs/architecture/foundation-infrastructure.md +163 -0
- package/template/docs/architecture/module-host.md +115 -0
- package/template/docs/architecture/server-module-interface.md +39 -0
- package/template/docs/architecture/web-access-snapshot-resilience.md +60 -0
- package/template/docs/development/business-web-routes.md +66 -0
- package/template/docs/development/custom-login-page.md +3 -3
- package/template/docs/development/module-lifecycle.md +71 -0
- package/template/docs/operations/observability.md +5 -1
- package/template/docs/platform/agent-runtime.md +21 -11
- package/template/docs/platform/agent-tool-sandbox.md +58 -0
- package/template/docs/platform/agent-tools.md +5 -0
- package/template/docs/platform/document-ai-runtime.md +204 -0
- package/template/docs/platform/governed-export-renderers.md +132 -0
- package/template/docs/platform/navigation-registry.md +5 -0
- package/template/docs/platform/organization-membership.md +2 -1
- package/template/docs/platform/speech-ai-runtime.md +156 -0
- package/template/docs/platform/system-crud-api.md +7 -1
- package/template/docs/platform/vision-ai-runtime.md +97 -0
- package/template/docs/platform/web-system-crud.md +6 -0
- package/template/package.json +16 -2
- package/template/packages/ai-client/index.ts +4 -0
- package/template/packages/ai-client/package.json +5 -2
- package/template/packages/ai-client/src/agent/client/artifact.ts +26 -0
- package/template/packages/ai-client/src/agent/client/attach.test.ts +124 -0
- package/template/packages/ai-client/src/agent/client/client.ts +119 -7
- package/template/packages/ai-client/src/agent/client/run.ts +14 -0
- package/template/packages/ai-client/src/agent/client/types.ts +18 -0
- package/template/packages/ai-client/src/agent/client/vision.test.ts +53 -0
- package/template/packages/ai-client/src/agent/contracts/contracts.test.ts +1 -0
- package/template/packages/ai-client/src/agent/contracts/events.ts +33 -0
- package/template/packages/ai-client/src/agent/contracts/runs.ts +71 -0
- package/template/packages/ai-client/src/agent/index.ts +1 -0
- package/template/packages/ai-client/src/artifact-ref.ts +8 -0
- package/template/packages/ai-client/src/document/client.test.ts +114 -0
- package/template/packages/ai-client/src/document/client.ts +134 -0
- package/template/packages/ai-client/src/document/contracts.ts +152 -0
- package/template/packages/ai-client/src/document/error.ts +43 -0
- package/template/packages/ai-client/src/document/index.ts +3 -0
- package/template/packages/ai-client/src/document/run.ts +104 -0
- package/template/packages/ai-client/src/document/validation.ts +115 -0
- package/template/packages/ai-client/src/embedding/client.test.ts +77 -0
- package/template/packages/ai-client/src/embedding/client.ts +96 -0
- package/template/packages/ai-client/src/embedding/contracts.ts +46 -0
- package/template/packages/ai-client/src/embedding/error.ts +61 -0
- package/template/packages/ai-client/src/embedding/index.ts +3 -0
- package/template/packages/ai-client/src/embedding/validation.ts +117 -0
- package/template/packages/ai-client/src/speech/client.test.ts +135 -0
- package/template/packages/ai-client/src/speech/client.ts +104 -0
- package/template/packages/ai-client/src/speech/contracts.ts +129 -0
- package/template/packages/ai-client/src/speech/error.ts +43 -0
- package/template/packages/ai-client/src/speech/index.ts +3 -0
- package/template/packages/ai-client/src/speech/run.ts +133 -0
- package/template/packages/ai-client/src/speech/validation.ts +132 -0
- package/template/packages/config/package.json +2 -2
- package/template/packages/database/drizzle/0039_early_ezekiel_stane.sql +1 -0
- package/template/packages/database/drizzle/0040_colossal_baron_strucker.sql +63 -0
- package/template/packages/database/drizzle/0041_yummy_prowler.sql +21 -0
- package/template/packages/database/drizzle/0042_puzzling_rumiko_fujikawa.sql +27 -0
- package/template/packages/database/drizzle/meta/0039_snapshot.json +7755 -0
- package/template/packages/database/drizzle/meta/0040_snapshot.json +8150 -0
- package/template/packages/database/drizzle/meta/0041_snapshot.json +8323 -0
- package/template/packages/database/drizzle/meta/0042_snapshot.json +8541 -0
- package/template/packages/database/drizzle/meta/_journal.json +28 -0
- package/template/packages/database/package.json +2 -2
- package/template/packages/database/src/agent-runtime-schema.test.ts +54 -0
- package/template/packages/database/src/schema/agent-runtime.ts +149 -0
- package/template/packages/database/src/schema/common.ts +2 -14
- package/template/packages/database/src/schema/durable-jobs.ts +5 -0
- package/template/packages/database/src/schema/governed-exports.ts +17 -5
- package/template/packages/database/src/schema/index.ts +3 -0
- package/template/packages/database/src/schema-durable-recovery.test.ts +31 -0
- package/template/packages/database/src/schema-governed-exports.test.ts +21 -1
- package/template/packages/database/src/schema.test.ts +6 -23
- package/template/packages/jobs/package.json +3 -2
- package/template/packages/jobs/src/handlers.test.ts +13 -0
- package/template/packages/jobs/src/handlers.ts +7 -1
- package/template/packages/jobs/src/types.ts +4 -0
- package/template/packages/modules/package.json +2 -2
- package/template/packages/modules/src/ai-operation-composition.test-support.ts +165 -0
- package/template/packages/modules/src/ai-operation-composition.test.ts +91 -127
- package/template/packages/modules/src/ai-operation-composition.ts +59 -1
- package/template/packages/modules/src/manifest.ts +25 -1
- package/template/packages/modules/src/tool-composition.ts +18 -0
- package/template/packages/server-sdk/index.ts +50 -0
- package/template/packages/server-sdk/package.json +10 -4
- package/template/packages/server-sdk/src/ai-artifact-port.ts +34 -0
- package/template/packages/server-sdk/src/ai-operation-port.ts +65 -0
- package/template/packages/server-sdk/src/ai-operation-registration.ts +42 -1
- package/template/packages/server-sdk/src/background-ai-port.ts +43 -0
- package/template/packages/server-sdk/src/data-governance-registration.ts +116 -0
- package/template/packages/server-sdk/src/durable-handler.ts +29 -0
- package/template/packages/server-sdk/src/jobs-port.ts +69 -0
- package/template/packages/server-sdk/src/module-host.ts +16 -2
- package/template/packages/server-sdk/src/request-context.ts +6 -2
- package/template/packages/server-sdk/src/sandbox-tool.ts +21 -0
- package/template/packages/server-sdk/src/tool-registration.ts +2 -0
- package/template/packages/shared/package.json +1 -1
- package/template/packages/shared/src/rbac.ts +30 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@southwind-ai/server-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -9,14 +9,20 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"index.ts",
|
|
11
11
|
"src/actor.ts",
|
|
12
|
+
"src/ai-artifact-port.ts",
|
|
13
|
+
"src/ai-operation-port.ts",
|
|
12
14
|
"src/ai-operation-registration.ts",
|
|
13
15
|
"src/audit-port.ts",
|
|
16
|
+
"src/background-ai-port.ts",
|
|
17
|
+
"src/data-governance-registration.ts",
|
|
18
|
+
"src/durable-handler.ts",
|
|
14
19
|
"src/jobs-port.ts",
|
|
15
20
|
"src/module-host.ts",
|
|
16
21
|
"src/namespace.ts",
|
|
17
22
|
"src/request-context.ts",
|
|
18
23
|
"src/role-preset.ts",
|
|
19
24
|
"src/route-definition.ts",
|
|
25
|
+
"src/sandbox-tool.ts",
|
|
20
26
|
"src/search-provider-port.ts",
|
|
21
27
|
"src/storage-port.ts",
|
|
22
28
|
"src/task-registration.ts",
|
|
@@ -29,9 +35,9 @@
|
|
|
29
35
|
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
30
36
|
},
|
|
31
37
|
"dependencies": {
|
|
32
|
-
"@southwind-ai/jobs": "workspace
|
|
33
|
-
"@southwind-ai/shared": "workspace
|
|
34
|
-
"@southwind-ai/storage": "workspace
|
|
38
|
+
"@southwind-ai/jobs": "workspace:^",
|
|
39
|
+
"@southwind-ai/shared": "workspace:^",
|
|
40
|
+
"@southwind-ai/storage": "workspace:^"
|
|
35
41
|
},
|
|
36
42
|
"exports": {
|
|
37
43
|
".": "./index.ts"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ModuleResourceFileRequest } from "./storage-port.js";
|
|
2
|
+
|
|
3
|
+
export interface ModuleAiArtifactRef {
|
|
4
|
+
/** 平台签发的不透明短时引用;业务不得解析或拼接底层地址。 */
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly mediaType: string;
|
|
7
|
+
readonly byteSize: number;
|
|
8
|
+
readonly sha256: string;
|
|
9
|
+
readonly expiresAt: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ModuleAiArtifactPort {
|
|
13
|
+
/**
|
|
14
|
+
* 将已经过业务对象绑定和当前 Actor 授权的资源文件换成短时 ArtifactRef。
|
|
15
|
+
* Port 不暴露 Blob Key、宿主路径、平台 Repository 或 Provider 凭据。
|
|
16
|
+
*/
|
|
17
|
+
issue(
|
|
18
|
+
source: ModuleResourceFileRequest,
|
|
19
|
+
options?: { ttlSeconds?: number },
|
|
20
|
+
): Promise<ModuleAiArtifactRef>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class ModuleAiArtifactError extends Error {
|
|
24
|
+
constructor(
|
|
25
|
+
readonly code:
|
|
26
|
+
| "AI_ARTIFACT_UNAVAILABLE"
|
|
27
|
+
| "AI_ARTIFACT_FORBIDDEN"
|
|
28
|
+
| "AI_ARTIFACT_INVALID",
|
|
29
|
+
message: string,
|
|
30
|
+
) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "ModuleAiArtifactError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ModuleAiArtifactRef } from "./ai-artifact-port.js";
|
|
2
|
+
import type { ModuleAiJsonValue } from "./ai-operation-registration.js";
|
|
3
|
+
|
|
4
|
+
export interface ModuleAiRunReceipt {
|
|
5
|
+
readonly runId: string;
|
|
6
|
+
readonly status: string;
|
|
7
|
+
readonly eventsUrl: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ModuleEmbeddingItem =
|
|
11
|
+
| { readonly id: string; readonly text: string }
|
|
12
|
+
| { readonly id: string; readonly source: ModuleAiArtifactRef };
|
|
13
|
+
|
|
14
|
+
export interface ModuleAiOperationPort {
|
|
15
|
+
startAgent(input: {
|
|
16
|
+
operationKey: string;
|
|
17
|
+
input: ModuleAiJsonValue;
|
|
18
|
+
artifacts?: readonly ModuleAiArtifactRef[];
|
|
19
|
+
idempotencyKey: string;
|
|
20
|
+
}): Promise<ModuleAiRunReceipt>;
|
|
21
|
+
startDocument(input: {
|
|
22
|
+
operationKey: string;
|
|
23
|
+
sources: readonly ModuleAiArtifactRef[];
|
|
24
|
+
options: ModuleAiJsonValue;
|
|
25
|
+
idempotencyKey: string;
|
|
26
|
+
}): Promise<ModuleAiRunReceipt>;
|
|
27
|
+
startSpeech(input: {
|
|
28
|
+
operationKey: string;
|
|
29
|
+
source: ModuleAiArtifactRef;
|
|
30
|
+
options: ModuleAiJsonValue;
|
|
31
|
+
idempotencyKey: string;
|
|
32
|
+
}): Promise<ModuleAiRunReceipt>;
|
|
33
|
+
embed(input: {
|
|
34
|
+
operationKey: string;
|
|
35
|
+
items: readonly ModuleEmbeddingItem[];
|
|
36
|
+
options: ModuleAiJsonValue;
|
|
37
|
+
idempotencyKey: string;
|
|
38
|
+
}): Promise<ModuleAiJsonValue>;
|
|
39
|
+
result(input: {
|
|
40
|
+
kind: "agent" | "document" | "speech";
|
|
41
|
+
operationKey: string;
|
|
42
|
+
runId: string;
|
|
43
|
+
}): Promise<ModuleAiJsonValue>;
|
|
44
|
+
cancel(input: {
|
|
45
|
+
kind: "agent" | "document" | "speech";
|
|
46
|
+
operationKey: string;
|
|
47
|
+
runId: string;
|
|
48
|
+
reason?: string;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class ModuleAiOperationError extends Error {
|
|
53
|
+
constructor(
|
|
54
|
+
readonly code:
|
|
55
|
+
| "AI_OPERATION_UNAVAILABLE"
|
|
56
|
+
| "AI_OPERATION_FORBIDDEN"
|
|
57
|
+
| "AI_OPERATION_INVALID"
|
|
58
|
+
| "AI_OPERATION_PENDING"
|
|
59
|
+
| "AI_OPERATION_FAILED",
|
|
60
|
+
message: string,
|
|
61
|
+
) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.name = "ModuleAiOperationError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -16,12 +16,53 @@ export interface ModuleAiOperationContext {
|
|
|
16
16
|
export interface ModuleAiOperationPlan {
|
|
17
17
|
readonly instructions: string;
|
|
18
18
|
readonly userPrompt: string;
|
|
19
|
+
/**
|
|
20
|
+
* 可选 JSON Schema。宿主只把它交给受控 Runtime,并以 Manifest outputSchemaKey
|
|
21
|
+
* 关联审计;业务不能在此选择模型、Provider 或 Endpoint。
|
|
22
|
+
*/
|
|
23
|
+
readonly outputSchema?: ModuleAiJsonValue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ModuleDocumentOperationPlan {
|
|
27
|
+
/** 已由业务校验并经 Provider input allowlist/DLP 收窄的模型无关选项。 */
|
|
28
|
+
readonly options?: ModuleAiJsonValue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ModuleSpeechOperationPlan {
|
|
32
|
+
/** 领域校验后的批量转写选项;不包含 Provider、Endpoint、模型或 Secret。 */
|
|
33
|
+
readonly options?: ModuleAiJsonValue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ModuleEmbeddingOperationPlan {
|
|
37
|
+
/** 领域校验后的批量向量选项,不包含模型、维度、Provider 或向量库。 */
|
|
38
|
+
readonly options?: ModuleAiJsonValue;
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
export interface ModuleAiOperationHandlerRegistration {
|
|
22
42
|
readonly operationKey: string;
|
|
23
|
-
|
|
43
|
+
/**
|
|
44
|
+
* 不可变发布坐标。修改 Workflow、Prompt 或 Route 时必须提升对应版本;
|
|
45
|
+
* 宿主以这些坐标和 Manifest/Tool Schema 摘要固定每个 Run。
|
|
46
|
+
*/
|
|
47
|
+
readonly release?: {
|
|
48
|
+
readonly workflowVersion: string;
|
|
49
|
+
readonly promptVersion: string;
|
|
50
|
+
readonly routeVersion: string;
|
|
51
|
+
};
|
|
52
|
+
prepare?(
|
|
24
53
|
input: ModuleAiJsonValue,
|
|
25
54
|
context: ModuleAiOperationContext,
|
|
26
55
|
): Promise<ModuleAiOperationPlan> | ModuleAiOperationPlan;
|
|
56
|
+
prepareDocument?(
|
|
57
|
+
input: ModuleAiJsonValue,
|
|
58
|
+
context: ModuleAiOperationContext,
|
|
59
|
+
): Promise<ModuleDocumentOperationPlan> | ModuleDocumentOperationPlan;
|
|
60
|
+
prepareSpeech?(
|
|
61
|
+
input: ModuleAiJsonValue,
|
|
62
|
+
context: ModuleAiOperationContext,
|
|
63
|
+
): Promise<ModuleSpeechOperationPlan> | ModuleSpeechOperationPlan;
|
|
64
|
+
prepareEmbedding?(
|
|
65
|
+
input: ModuleAiJsonValue,
|
|
66
|
+
context: ModuleAiOperationContext,
|
|
67
|
+
): Promise<ModuleEmbeddingOperationPlan> | ModuleEmbeddingOperationPlan;
|
|
27
68
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ModuleAiJsonValue } from "./ai-operation-registration.js";
|
|
2
|
+
|
|
3
|
+
export interface ModuleBackgroundAiOperationInput {
|
|
4
|
+
readonly operationKey: string;
|
|
5
|
+
readonly input: ModuleAiJsonValue;
|
|
6
|
+
readonly idempotencyKey: string;
|
|
7
|
+
readonly timeoutSeconds?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ModuleBackgroundAiOperationResult {
|
|
11
|
+
readonly runId: string;
|
|
12
|
+
readonly output: ModuleAiJsonValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Durable Handler 内的 Actor-aware AI Operation 窄接口。
|
|
17
|
+
*
|
|
18
|
+
* Actor、模块命名空间、Guard、Provider 和 Execution Grant 均由宿主持有。
|
|
19
|
+
*/
|
|
20
|
+
export interface ModuleBackgroundAiPort {
|
|
21
|
+
enqueueOperation(
|
|
22
|
+
input: ModuleBackgroundAiOperationInput,
|
|
23
|
+
): Promise<ModuleBackgroundAiOperationResult>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type ModuleBackgroundAiErrorCode =
|
|
27
|
+
| "AI_OPERATION_UNAVAILABLE"
|
|
28
|
+
| "AI_OPERATION_DENIED"
|
|
29
|
+
| "AI_OPERATION_INVALID"
|
|
30
|
+
| "AI_OPERATION_FAILED"
|
|
31
|
+
| "AI_OPERATION_CANCELLED"
|
|
32
|
+
| "AI_OPERATION_TIMEOUT";
|
|
33
|
+
|
|
34
|
+
export class ModuleBackgroundAiError extends Error {
|
|
35
|
+
constructor(
|
|
36
|
+
readonly code: ModuleBackgroundAiErrorCode,
|
|
37
|
+
message: string,
|
|
38
|
+
readonly retryable: boolean,
|
|
39
|
+
) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "ModuleBackgroundAiError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ModuleActor } from "./actor.js";
|
|
2
|
+
import type { JsonValue } from "@southwind-ai/shared";
|
|
3
|
+
|
|
4
|
+
export interface ModuleGovernedResourceContext {
|
|
5
|
+
readonly actor: ModuleActor;
|
|
6
|
+
readonly requestId: string;
|
|
7
|
+
readonly signal: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ModuleGovernedRecord {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/** 已排除治理字段的普通业务投影。 */
|
|
13
|
+
readonly publicFields: Readonly<Record<string, unknown>>;
|
|
14
|
+
/** Key 必须全部来自 Manifest 对应 Data Policy。 */
|
|
15
|
+
readonly governedFields: Readonly<Record<string, unknown>>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type ModuleGovernedExportQuery = Readonly<
|
|
19
|
+
Record<string, JsonValue | undefined>
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export interface ModuleGovernedExportPageInput {
|
|
23
|
+
readonly query: ModuleGovernedExportQuery;
|
|
24
|
+
readonly cursor?: string;
|
|
25
|
+
readonly limit: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ModuleGovernedExportPage {
|
|
29
|
+
readonly records: readonly Readonly<Record<string, JsonValue>>[];
|
|
30
|
+
readonly nextCursor?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GovernedExportWatermarkContext {
|
|
34
|
+
readonly actorId: string;
|
|
35
|
+
readonly generatedAt: string;
|
|
36
|
+
readonly scopeHash: string;
|
|
37
|
+
readonly jobId: string;
|
|
38
|
+
readonly requestId: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface GovernedExportRenderedArtifact {
|
|
42
|
+
readonly body: ReadableStream<Uint8Array>;
|
|
43
|
+
/** 不得包含记录原文或敏感字段,仅用于受控 artifact 元数据与审计。 */
|
|
44
|
+
readonly contentMetadata?: Readonly<Record<string, JsonValue>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ModuleGovernedExportRendererRegistration {
|
|
48
|
+
readonly formatKey: string;
|
|
49
|
+
readonly templateKey: string;
|
|
50
|
+
readonly templateVersion: string;
|
|
51
|
+
readonly inputSchemaKey: string;
|
|
52
|
+
readonly contentType: string;
|
|
53
|
+
/** 不含点号,例如 pdf、docx、xlsx。 */
|
|
54
|
+
readonly filenameExtension: string;
|
|
55
|
+
readonly limits: {
|
|
56
|
+
readonly maxRecords: number;
|
|
57
|
+
readonly maxOutputBytes: number;
|
|
58
|
+
readonly timeoutSeconds: number;
|
|
59
|
+
};
|
|
60
|
+
render(
|
|
61
|
+
input: {
|
|
62
|
+
readonly records: AsyncIterable<Readonly<Record<string, JsonValue>>>;
|
|
63
|
+
readonly watermark: GovernedExportWatermarkContext;
|
|
64
|
+
},
|
|
65
|
+
context: {
|
|
66
|
+
readonly signal: AbortSignal;
|
|
67
|
+
readonly heartbeat: () => Promise<void>;
|
|
68
|
+
},
|
|
69
|
+
):
|
|
70
|
+
| Promise<GovernedExportRenderedArtifact>
|
|
71
|
+
| GovernedExportRenderedArtifact;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ModuleGovernedExportRegistration {
|
|
75
|
+
/** 四个导出端点的基路径,例如 /api/people/persons/exports。 */
|
|
76
|
+
readonly basePath: string;
|
|
77
|
+
/** 默认要求审批;只能显式关闭,不由客户端决定。 */
|
|
78
|
+
readonly approvalRequired?: boolean;
|
|
79
|
+
/** 产物保留时间;宿主还会施加平台上限。 */
|
|
80
|
+
readonly retentionSeconds?: number;
|
|
81
|
+
/**
|
|
82
|
+
* 服务端受治理 Renderer。声明后请求必须显式选择已注册 formatKey;
|
|
83
|
+
* 未声明时保持既有 NDJSON 行为。
|
|
84
|
+
*/
|
|
85
|
+
readonly renderers?: readonly ModuleGovernedExportRendererRegistration[];
|
|
86
|
+
validateQuery(query: unknown): ModuleGovernedExportQuery;
|
|
87
|
+
readPage(
|
|
88
|
+
input: ModuleGovernedExportPageInput,
|
|
89
|
+
context: ModuleGovernedResourceContext,
|
|
90
|
+
): Promise<ModuleGovernedExportPage> | ModuleGovernedExportPage;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 业务资源治理注册。
|
|
95
|
+
*
|
|
96
|
+
* authorize 与 read 分离,避免“能按 ID 查到”被误当作对象级授权。宿主在调用 read 前先
|
|
97
|
+
* 执行当前 Feature、Permission、Scope 与 authorize;未授权和不存在使用同形结果。
|
|
98
|
+
*/
|
|
99
|
+
export interface ModuleGovernedResourceRegistration {
|
|
100
|
+
readonly policyKey: string;
|
|
101
|
+
readonly readPath: string;
|
|
102
|
+
readonly revealPath: string;
|
|
103
|
+
readonly revealAuditAction: string;
|
|
104
|
+
readonly export?: ModuleGovernedExportRegistration;
|
|
105
|
+
authorize(
|
|
106
|
+
resourceId: string,
|
|
107
|
+
context: ModuleGovernedResourceContext,
|
|
108
|
+
): Promise<boolean> | boolean;
|
|
109
|
+
read(
|
|
110
|
+
resourceId: string,
|
|
111
|
+
context: ModuleGovernedResourceContext,
|
|
112
|
+
):
|
|
113
|
+
| Promise<ModuleGovernedRecord | undefined>
|
|
114
|
+
| ModuleGovernedRecord
|
|
115
|
+
| undefined;
|
|
116
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DurableHandlerContext, PayloadParser } from "@southwind-ai/jobs";
|
|
2
|
+
import type { ModuleActor } from "./actor.js";
|
|
3
|
+
import type { ModuleBackgroundAiPort } from "./background-ai-port.js";
|
|
4
|
+
import type {
|
|
5
|
+
ModuleOpenedResourceFile,
|
|
6
|
+
ModuleResourceFileRequest,
|
|
7
|
+
} from "./storage-port.js";
|
|
8
|
+
|
|
9
|
+
export interface ModuleDurableStoragePort {
|
|
10
|
+
openResourceFile(
|
|
11
|
+
input: ModuleResourceFileRequest,
|
|
12
|
+
): Promise<ModuleOpenedResourceFile>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ModuleDurableHandlerContext extends DurableHandlerContext {
|
|
16
|
+
readonly actor: ModuleActor;
|
|
17
|
+
readonly requestId: string;
|
|
18
|
+
readonly storage: ModuleDurableStoragePort;
|
|
19
|
+
readonly ai: ModuleBackgroundAiPort;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ModuleDurableHandlerDefinition<T> {
|
|
23
|
+
readonly key: string;
|
|
24
|
+
readonly payload: PayloadParser<T>;
|
|
25
|
+
execute(
|
|
26
|
+
payload: T,
|
|
27
|
+
context: ModuleDurableHandlerContext,
|
|
28
|
+
): Promise<void> | void;
|
|
29
|
+
}
|
|
@@ -22,3 +22,72 @@ export interface ModuleJobSubmitResult {
|
|
|
22
22
|
export interface ModuleJobSubmitter {
|
|
23
23
|
submit(input: ModuleJobSubmitInput): Promise<ModuleJobSubmitResult>;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
export type ModuleJobStatus =
|
|
27
|
+
| "queued"
|
|
28
|
+
| "running"
|
|
29
|
+
| "succeeded"
|
|
30
|
+
| "failed"
|
|
31
|
+
| "cancelled";
|
|
32
|
+
|
|
33
|
+
export interface ModuleJobProgressView {
|
|
34
|
+
readonly completedUnits: number;
|
|
35
|
+
readonly totalUnits?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ModuleJobView {
|
|
39
|
+
readonly jobId: string;
|
|
40
|
+
readonly handlerKey: string;
|
|
41
|
+
readonly status: ModuleJobStatus;
|
|
42
|
+
readonly progress?: ModuleJobProgressView;
|
|
43
|
+
readonly attempt: number;
|
|
44
|
+
readonly maxAttempts: number;
|
|
45
|
+
readonly createdAt: string;
|
|
46
|
+
readonly startedAt?: string;
|
|
47
|
+
readonly finishedAt?: string;
|
|
48
|
+
readonly failureCode?: string;
|
|
49
|
+
readonly canCancel: boolean;
|
|
50
|
+
readonly canRecover: boolean;
|
|
51
|
+
/** 当前持久化版本;控制操作必须回传该值以执行 CAS。 */
|
|
52
|
+
readonly version: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ModuleJobCancelInput {
|
|
56
|
+
readonly jobId: string;
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
readonly expectedStatus?: ModuleJobStatus;
|
|
59
|
+
readonly expectedVersion?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ModuleJobRecoverInput {
|
|
63
|
+
readonly jobId: string;
|
|
64
|
+
readonly reason: string;
|
|
65
|
+
readonly expectedAttempt: number;
|
|
66
|
+
readonly expectedStatus: ModuleJobStatus;
|
|
67
|
+
readonly expectedVersion: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type ModuleJobControlErrorCode =
|
|
71
|
+
| "JOB_NOT_AVAILABLE"
|
|
72
|
+
| "JOB_STATE_CONFLICT"
|
|
73
|
+
| "JOB_CONTROL_UNAVAILABLE"
|
|
74
|
+
| "JOB_REASON_INVALID";
|
|
75
|
+
|
|
76
|
+
export class ModuleJobControlError extends Error {
|
|
77
|
+
constructor(
|
|
78
|
+
readonly code: ModuleJobControlErrorCode,
|
|
79
|
+
message: string,
|
|
80
|
+
) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.name = "ModuleJobControlError";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 宿主绑定 Module、Queue、Actor 与授权范围的 Durable Job 受限控制 Port。
|
|
88
|
+
*/
|
|
89
|
+
export interface ModuleJobPort extends ModuleJobSubmitter {
|
|
90
|
+
get(jobId: string): Promise<ModuleJobView | undefined>;
|
|
91
|
+
cancel(input: ModuleJobCancelInput): Promise<ModuleJobView>;
|
|
92
|
+
recover(input: ModuleJobRecoverInput): Promise<ModuleJobView>;
|
|
93
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { DurableHandlerDefinition } from "@southwind-ai/jobs";
|
|
2
1
|
import type { ModuleAiOperationHandlerRegistration } from "./ai-operation-registration.js";
|
|
2
|
+
import type { ModuleDurableHandlerDefinition } from "./durable-handler.js";
|
|
3
|
+
import type { ModuleGovernedResourceRegistration } from "./data-governance-registration.js";
|
|
3
4
|
import type { ModuleRolePreset } from "./role-preset.js";
|
|
4
5
|
import type { ModuleRouteDefinition } from "./route-definition.js";
|
|
5
6
|
import type { ModuleSearchProvider } from "./search-provider-port.js";
|
|
7
|
+
import type { ModuleSandboxToolHost } from "./sandbox-tool.js";
|
|
6
8
|
import type { ModuleResourceFileAccessPolicy } from "./storage-port.js";
|
|
7
9
|
import type { ModuleTaskHandlerRegistration } from "./task-registration.js";
|
|
8
10
|
import type { ModuleToolHandlerRegistration } from "./tool-registration.js";
|
|
@@ -33,7 +35,13 @@ export interface ModuleHost {
|
|
|
33
35
|
registerResourceFileAccessPolicies(
|
|
34
36
|
policies: readonly ModuleResourceFileAccessPolicy[],
|
|
35
37
|
): void;
|
|
36
|
-
registerDurableHandler<T>(
|
|
38
|
+
registerDurableHandler<T>(
|
|
39
|
+
definition: ModuleDurableHandlerDefinition<T>,
|
|
40
|
+
): void;
|
|
41
|
+
/** 注册 Manifest Data Policy 对应的对象授权、脱敏读取与明文揭示入口。 */
|
|
42
|
+
registerGovernedResources(
|
|
43
|
+
registrations: readonly ModuleGovernedResourceRegistration[],
|
|
44
|
+
): void;
|
|
37
45
|
/** 注册 Guarded API 路由;须与 Manifest `apiPermissions` 声明一致。 */
|
|
38
46
|
registerRoutes(routes: readonly ModuleRouteDefinition[]): void;
|
|
39
47
|
/** 注册 Manifest `tasks` 已声明定时任务的执行体。 */
|
|
@@ -74,4 +82,10 @@ export interface ModuleInitializer {
|
|
|
74
82
|
export interface InstallableServerModule<TManifest> {
|
|
75
83
|
readonly manifest: TManifest;
|
|
76
84
|
setup(host: ModuleHost): Promise<void> | void;
|
|
85
|
+
/**
|
|
86
|
+
* 注册只能在无网络 Tool Worker 中执行的纯业务 Handler。
|
|
87
|
+
* 该入口不得闭包捕获 Repository、Secret、文件系统或平台运行时。
|
|
88
|
+
* 注册必须同步完成,避免 Worker 在定义尚未稳定时开始接收请求。
|
|
89
|
+
*/
|
|
90
|
+
setupSandbox?(host: ModuleSandboxToolHost): void;
|
|
77
91
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ModuleActor } from "./actor.js";
|
|
2
2
|
import type { ModuleAuditEmitter } from "./audit-port.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ModuleAiArtifactPort } from "./ai-artifact-port.js";
|
|
4
|
+
import type { ModuleAiOperationPort } from "./ai-operation-port.js";
|
|
5
|
+
import type { ModuleJobPort } from "./jobs-port.js";
|
|
4
6
|
import type { ModuleStoragePort } from "./storage-port.js";
|
|
5
7
|
import type { ModuleUserDirectoryPort } from "./user-directory-port.js";
|
|
6
8
|
|
|
@@ -17,7 +19,9 @@ export interface ModuleRequestContext {
|
|
|
17
19
|
readonly query: Record<string, string | undefined>;
|
|
18
20
|
readonly body?: unknown;
|
|
19
21
|
readonly audit: ModuleAuditEmitter;
|
|
20
|
-
readonly
|
|
22
|
+
readonly aiArtifacts: ModuleAiArtifactPort;
|
|
23
|
+
readonly aiOperations: ModuleAiOperationPort;
|
|
24
|
+
readonly jobs: ModuleJobPort;
|
|
21
25
|
readonly storage: ModuleStoragePort;
|
|
22
26
|
readonly userDirectory: ModuleUserDirectoryPort;
|
|
23
27
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ModuleToolInput, ModuleToolResult } from "./tool-registration.js";
|
|
2
|
+
|
|
3
|
+
export interface ModuleSandboxToolContext {
|
|
4
|
+
readonly idempotencyKey: string;
|
|
5
|
+
readonly signal: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ModuleSandboxToolHandlerRegistration {
|
|
9
|
+
readonly toolKey: string;
|
|
10
|
+
execute(
|
|
11
|
+
input: ModuleToolInput,
|
|
12
|
+
context: ModuleSandboxToolContext,
|
|
13
|
+
): Promise<ModuleToolResult> | ModuleToolResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ModuleSandboxToolHost {
|
|
17
|
+
readonly moduleName: string;
|
|
18
|
+
registerToolHandlers(
|
|
19
|
+
registrations: readonly ModuleSandboxToolHandlerRegistration[],
|
|
20
|
+
): void;
|
|
21
|
+
}
|
|
@@ -5,6 +5,8 @@ import type { ModuleStoragePort } from "./storage-port.js";
|
|
|
5
5
|
export interface ModuleToolContext {
|
|
6
6
|
readonly actor: ModuleActor;
|
|
7
7
|
readonly requestId: string;
|
|
8
|
+
/** 当前 Run 内稳定 Tool Call 标识;写 Tool 必须作为业务幂等键使用。 */
|
|
9
|
+
readonly idempotencyKey: string;
|
|
8
10
|
readonly signal: AbortSignal;
|
|
9
11
|
/**
|
|
10
12
|
* 与当前 Tool Actor、请求范围和模块命名空间绑定的受限存储 Port。
|
|
@@ -23,6 +23,7 @@ export type PermissionAction =
|
|
|
23
23
|
| "reveal"
|
|
24
24
|
| "approve"
|
|
25
25
|
| "execute"
|
|
26
|
+
| "retry"
|
|
26
27
|
| "manage";
|
|
27
28
|
|
|
28
29
|
export type PermissionAccessRisk =
|
|
@@ -40,6 +41,35 @@ export type DataScope =
|
|
|
40
41
|
| "self"
|
|
41
42
|
| "custom";
|
|
42
43
|
|
|
44
|
+
export type PersistedScopeGrant =
|
|
45
|
+
| { scope: "all" | "tenant" | "self" }
|
|
46
|
+
| {
|
|
47
|
+
scope: "department" | "department-and-children";
|
|
48
|
+
departmentId?: string;
|
|
49
|
+
}
|
|
50
|
+
| { scope: "custom"; dimension: string; values: string[] };
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 后台任务可持久化的最小授权范围快照。
|
|
54
|
+
*
|
|
55
|
+
* 不包含 Permission、凭据、Secret 或业务字段值;恢复执行时仍须重新解析当前 Actor
|
|
56
|
+
* 并重新执行 Feature、Permission、License 与对象绑定检查。
|
|
57
|
+
*/
|
|
58
|
+
export interface AuthorizationScopeSnapshot {
|
|
59
|
+
tenantId: "single-tenant";
|
|
60
|
+
actorId: string;
|
|
61
|
+
departmentId?: string;
|
|
62
|
+
grants: PersistedScopeGrant[];
|
|
63
|
+
roleIds: string[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface AgentRunAuthorizationSnapshot {
|
|
67
|
+
permissionKey: string;
|
|
68
|
+
featureKey: string;
|
|
69
|
+
allowedToolKeys: string[];
|
|
70
|
+
toolNetworkMode: "forbidden";
|
|
71
|
+
}
|
|
72
|
+
|
|
43
73
|
export type CredentialState = "active" | "must-change-password";
|
|
44
74
|
|
|
45
75
|
export interface PermissionDefinition {
|