@flowdular/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai/agents/README.md +27 -0
- package/.ai/agents/module-executor.md +36 -0
- package/.ai/agents/reviewer.md +23 -0
- package/.ai/agents/sandbox/agentic-engineer.md +31 -0
- package/.ai/agents/sandbox/backend-engineer.md +36 -0
- package/.ai/agents/sandbox/business-manager.md +23 -0
- package/.ai/agents/sandbox/frontend-engineer.md +27 -0
- package/.ai/agents/sandbox/ux-designer.md +23 -0
- package/.ai/agents/spec-author.md +29 -0
- package/.ai/blueprints/add-migration/README.md +5 -0
- package/.ai/blueprints/add-migration/allowed-paths.yaml +23 -0
- package/.ai/blueprints/add-migration/blueprint.json +14 -0
- package/.ai/blueprints/add-migration/examples/invalid/input-destructive.json +6 -0
- package/.ai/blueprints/add-migration/examples/invalid/plan-unnumbered-file.json +9 -0
- package/.ai/blueprints/add-migration/examples/valid/input.json +6 -0
- package/.ai/blueprints/add-migration/examples/valid/plan.json +9 -0
- package/.ai/blueprints/add-migration/gates.yaml +30 -0
- package/.ai/blueprints/add-migration/input.schema.json +23 -0
- package/.ai/blueprints/add-migration/plan.schema.json +54 -0
- package/.ai/blueprints/add-migration/required-files.yaml +18 -0
- package/.ai/blueprints/add-migration/spec-requirements.yaml +13 -0
- package/.ai/blueprints/add-migration/steps.yaml +62 -0
- package/.ai/blueprints/author-spec/README.md +5 -0
- package/.ai/blueprints/author-spec/allowed-paths.yaml +7 -0
- package/.ai/blueprints/author-spec/blueprint.json +14 -0
- package/.ai/blueprints/author-spec/examples/invalid/input-missing-outcome.json +5 -0
- package/.ai/blueprints/author-spec/examples/valid/input.json +6 -0
- package/.ai/blueprints/author-spec/gates.yaml +13 -0
- package/.ai/blueprints/author-spec/input.schema.json +20 -0
- package/.ai/blueprints/author-spec/plan.schema.json +14 -0
- package/.ai/blueprints/author-spec/required-files.yaml +6 -0
- package/.ai/blueprints/author-spec/spec-requirements.yaml +35 -0
- package/.ai/blueprints/author-spec/steps.yaml +28 -0
- package/.ai/blueprints/author-spec/templates/module.yaml +45 -0
- package/.ai/blueprints/bug-fix/README.md +5 -0
- package/.ai/blueprints/bug-fix/allowed-paths.yaml +29 -0
- package/.ai/blueprints/bug-fix/blueprint.json +14 -0
- package/.ai/blueprints/bug-fix/examples/invalid/input-no-symptom.json +4 -0
- package/.ai/blueprints/bug-fix/examples/invalid/plan-no-test.json +8 -0
- package/.ai/blueprints/bug-fix/examples/valid/input.json +6 -0
- package/.ai/blueprints/bug-fix/examples/valid/plan.json +8 -0
- package/.ai/blueprints/bug-fix/gates.yaml +30 -0
- package/.ai/blueprints/bug-fix/input.schema.json +25 -0
- package/.ai/blueprints/bug-fix/plan.schema.json +53 -0
- package/.ai/blueprints/bug-fix/required-files.yaml +7 -0
- package/.ai/blueprints/bug-fix/spec-requirements.yaml +7 -0
- package/.ai/blueprints/bug-fix/steps.yaml +51 -0
- package/.ai/blueprints/core-extend/README.md +5 -0
- package/.ai/blueprints/core-extend/allowed-paths.yaml +49 -0
- package/.ai/blueprints/core-extend/blueprint.json +14 -0
- package/.ai/blueprints/core-extend/examples/invalid/input-unknown-package.json +5 -0
- package/.ai/blueprints/core-extend/examples/invalid/plan-missing-gates.json +7 -0
- package/.ai/blueprints/core-extend/examples/valid/input.json +6 -0
- package/.ai/blueprints/core-extend/examples/valid/plan.json +10 -0
- package/.ai/blueprints/core-extend/gates.yaml +16 -0
- package/.ai/blueprints/core-extend/input.schema.json +54 -0
- package/.ai/blueprints/core-extend/plan.schema.json +39 -0
- package/.ai/blueprints/core-extend/required-files.yaml +36 -0
- package/.ai/blueprints/core-extend/spec-requirements.yaml +17 -0
- package/.ai/blueprints/core-extend/steps.yaml +54 -0
- package/.ai/blueprints/edit-module/README.md +9 -0
- package/.ai/blueprints/edit-module/allowed-paths.yaml +27 -0
- package/.ai/blueprints/edit-module/blueprint.json +20 -0
- package/.ai/blueprints/edit-module/examples/invalid/input-unknown-change.json +5 -0
- package/.ai/blueprints/edit-module/examples/invalid/plan-touches-platform.json +15 -0
- package/.ai/blueprints/edit-module/examples/valid/input.json +5 -0
- package/.ai/blueprints/edit-module/examples/valid/plan.json +25 -0
- package/.ai/blueprints/edit-module/gates.yaml +30 -0
- package/.ai/blueprints/edit-module/input.schema.json +31 -0
- package/.ai/blueprints/edit-module/plan.schema.json +65 -0
- package/.ai/blueprints/edit-module/required-files.yaml +80 -0
- package/.ai/blueprints/edit-module/spec-requirements.yaml +15 -0
- package/.ai/blueprints/edit-module/steps.yaml +115 -0
- package/.ai/blueprints/new-module/README.md +7 -0
- package/.ai/blueprints/new-module/allowed-paths.yaml +27 -0
- package/.ai/blueprints/new-module/blueprint.json +20 -0
- package/.ai/blueprints/new-module/examples/invalid/input-spec-outside-modules.json +4 -0
- package/.ai/blueprints/new-module/examples/invalid/plan-unknown-gate.json +8 -0
- package/.ai/blueprints/new-module/examples/valid/input.json +5 -0
- package/.ai/blueprints/new-module/examples/valid/plan.json +22 -0
- package/.ai/blueprints/new-module/gates.yaml +30 -0
- package/.ai/blueprints/new-module/input.schema.json +21 -0
- package/.ai/blueprints/new-module/plan.schema.json +58 -0
- package/.ai/blueprints/new-module/required-files.yaml +73 -0
- package/.ai/blueprints/new-module/spec-requirements.yaml +30 -0
- package/.ai/blueprints/new-module/steps.yaml +138 -0
- package/.ai/blueprints/release/README.md +5 -0
- package/.ai/blueprints/release/allowed-paths.yaml +19 -0
- package/.ai/blueprints/release/blueprint.json +14 -0
- package/.ai/blueprints/release/examples/invalid/input-bad-version.json +4 -0
- package/.ai/blueprints/release/examples/invalid/plan-bad-branch.json +7 -0
- package/.ai/blueprints/release/examples/valid/input.json +5 -0
- package/.ai/blueprints/release/examples/valid/plan.json +20 -0
- package/.ai/blueprints/release/gates.yaml +20 -0
- package/.ai/blueprints/release/input.schema.json +24 -0
- package/.ai/blueprints/release/plan.schema.json +46 -0
- package/.ai/blueprints/release/required-files.yaml +19 -0
- package/.ai/blueprints/release/spec-requirements.yaml +8 -0
- package/.ai/blueprints/release/steps.yaml +47 -0
- package/.ai/blueprints/security-review/README.md +5 -0
- package/.ai/blueprints/security-review/allowed-paths.yaml +6 -0
- package/.ai/blueprints/security-review/blueprint.json +14 -0
- package/.ai/blueprints/security-review/examples/invalid/input-unknown-kind.json +4 -0
- package/.ai/blueprints/security-review/examples/invalid/plan-finding-without-scenario.json +14 -0
- package/.ai/blueprints/security-review/examples/valid/input.json +4 -0
- package/.ai/blueprints/security-review/examples/valid/plan.json +19 -0
- package/.ai/blueprints/security-review/gates.yaml +22 -0
- package/.ai/blueprints/security-review/input.schema.json +20 -0
- package/.ai/blueprints/security-review/plan.schema.json +65 -0
- package/.ai/blueprints/security-review/required-files.yaml +6 -0
- package/.ai/blueprints/security-review/spec-requirements.yaml +9 -0
- package/.ai/blueprints/security-review/steps.yaml +38 -0
- package/.ai/policies/capabilities.yaml +164 -0
- package/.ai/policies/model-routing.yaml +72 -0
- package/.ai/policies/path-ownership.yaml +65 -0
- package/.ai/policies/task-budgets.yaml +37 -0
- package/.ai/references/catalog/LICENSE +21 -0
- package/.ai/references/catalog/migrations/0001_catalog_core.down.sql +2 -0
- package/.ai/references/catalog/migrations/0001_catalog_core.up.sql +21 -0
- package/.ai/references/catalog/migrations/0002_catalog_history.down.sql +3 -0
- package/.ai/references/catalog/migrations/0002_catalog_history.up.sql +20 -0
- package/.ai/references/catalog/migrations/0003_catalog_history_service_actors.down.sql +3 -0
- package/.ai/references/catalog/migrations/0003_catalog_history_service_actors.up.sql +36 -0
- package/.ai/references/catalog/migrations/0004_catalog_idempotency_ledger.down.sql +3 -0
- package/.ai/references/catalog/migrations/0004_catalog_idempotency_ledger.up.sql +19 -0
- package/.ai/references/catalog/migrations/README.md +3 -0
- package/.ai/references/catalog/module.json +27 -0
- package/.ai/references/catalog/package.json +49 -0
- package/.ai/references/catalog/spec/module.yaml +86 -0
- package/.ai/references/catalog/src/acl/permissions.ts +6 -0
- package/.ai/references/catalog/src/agent/tools.ts +164 -0
- package/.ai/references/catalog/src/api/endpoints.ts +243 -0
- package/.ai/references/catalog/src/client/CatalogHistoryDrawer.tsrx +123 -0
- package/.ai/references/catalog/src/client/CatalogItemForm.tsrx +190 -0
- package/.ai/references/catalog/src/client/CatalogView.tsrx +473 -0
- package/.ai/references/catalog/src/client/api.ts +111 -0
- package/.ai/references/catalog/src/client/contribution.tsrx +61 -0
- package/.ai/references/catalog/src/client/index.ts +18 -0
- package/.ai/references/catalog/src/client/navigation-copy.ts +9 -0
- package/.ai/references/catalog/src/client/state.ts +24 -0
- package/.ai/references/catalog/src/domain/types.ts +32 -0
- package/.ai/references/catalog/src/domain/variables.ts +111 -0
- package/.ai/references/catalog/src/index.ts +31 -0
- package/.ai/references/catalog/src/platform.ts +35 -0
- package/.ai/references/catalog/src/server/index.ts +4 -0
- package/.ai/references/catalog/src/server/runtime.ts +86 -0
- package/.ai/references/catalog/src/services/catalog-service.ts +306 -0
- package/.ai/references/catalog/src/services/database-repository.ts +440 -0
- package/.ai/references/catalog/src/services/index.ts +4 -0
- package/.ai/references/catalog/src/services/migration.ts +171 -0
- package/.ai/references/catalog/src/services/repository.ts +36 -0
- package/.ai/references/catalog/src/services/target-idempotency.ts +59 -0
- package/.ai/references/catalog/tests/agent-tools.test.ts +277 -0
- package/.ai/references/catalog/tests/endpoints.test.ts +320 -0
- package/.ai/references/catalog/tests/idempotency.test.ts +297 -0
- package/.ai/references/catalog/tests/migrations.test.ts +149 -0
- package/.ai/references/catalog/tests/module.test.ts +271 -0
- package/.ai/references/catalog/tests/support/database.ts +76 -0
- package/.ai/references/catalog/translations/en.json +101 -0
- package/.ai/references/catalog/translations/pl.json +101 -0
- package/.ai/references/catalog/tsconfig.json +15 -0
- package/.ai/references/catalog/vitest.config.ts +16 -0
- package/.ai/references/catalog.provenance.json +55 -0
- package/.ai/skills/README.md +36 -0
- package/.ai/skills/agent-tool-design/SKILL.md +209 -0
- package/.ai/skills/auth-security-review/SKILL.md +96 -0
- package/.ai/skills/auto-review/SKILL.md +112 -0
- package/.ai/skills/bug-hunt/SKILL.md +110 -0
- package/.ai/skills/business-agent-design/SKILL.md +188 -0
- package/.ai/skills/cli-extension/SKILL.md +114 -0
- package/.ai/skills/core-extend/SKILL.md +104 -0
- package/.ai/skills/database-adapter/SKILL.md +204 -0
- package/.ai/skills/database-adapter/references/first-run-and-matrix.md +105 -0
- package/.ai/skills/migration-authoring/SKILL.md +167 -0
- package/.ai/skills/module-new/SKILL.md +180 -0
- package/.ai/skills/module-update/SKILL.md +100 -0
- package/.ai/skills/perf-audit/SKILL.md +105 -0
- package/.ai/skills/release-eject-pr/SKILL.md +113 -0
- package/.ai/skills/spec-approval/SKILL.md +112 -0
- package/.ai/skills/test-hardening/SKILL.md +86 -0
- package/.ai/skills/translations-i18n/SKILL.md +85 -0
- package/.ai/skills/ux-design/SKILL.md +97 -0
- package/.ai/skills/variables/SKILL.md +164 -0
- package/.ai/skills/workflow-development/SKILL.md +199 -0
- package/AGENTS.md +59 -0
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/docs/agent-contract.md +45 -0
- package/docs/design-system.md +217 -0
- package/modules/agents/migrations/0001_agents_core.down.sql +4 -0
- package/modules/agents/migrations/0001_agents_core.up.sql +106 -0
- package/modules/agents/migrations/0002_provider_connections.down.sql +1 -0
- package/modules/agents/migrations/0002_provider_connections.up.sql +34 -0
- package/modules/agents/migrations/0003_resource_audit.down.sql +1 -0
- package/modules/agents/migrations/0003_resource_audit.up.sql +25 -0
- package/modules/agents/migrations/0004_run_grants.down.sql +1 -0
- package/modules/agents/migrations/0004_run_grants.up.sql +19 -0
- package/modules/agents/migrations/0005_long_running_limits.down.sql +2 -0
- package/modules/agents/migrations/0005_long_running_limits.up.sql +14 -0
- package/modules/agents/migrations/0006_agent_skills.down.sql +3 -0
- package/modules/agents/migrations/0006_agent_skills.up.sql +44 -0
- package/modules/agents/migrations/0007_model_readiness.down.sql +1 -0
- package/modules/agents/migrations/0007_model_readiness.up.sql +18 -0
- package/modules/agents/migrations/0008_output_limits.down.sql +2 -0
- package/modules/agents/migrations/0008_output_limits.up.sql +8 -0
- package/modules/agents/migrations/0009_agent_audit_v3.down.sql +1 -0
- package/modules/agents/migrations/0009_agent_audit_v3.up.sql +25 -0
- package/modules/agents/migrations/0012_agent_run_costs.down.sql +3 -0
- package/modules/agents/migrations/0012_agent_run_costs.up.sql +32 -0
- package/modules/agents/migrations/0013_workflow_prerequisites.down.sql +3 -0
- package/modules/agents/migrations/0013_workflow_prerequisites.up.sql +97 -0
- package/modules/agents/migrations/0014_agent_action_audit.down.sql +1 -0
- package/modules/agents/migrations/0014_agent_action_audit.up.sql +25 -0
- package/modules/agents/migrations/0015_agent_run_actors.down.sql +1 -0
- package/modules/agents/migrations/0015_agent_run_actors.up.sql +17 -0
- package/modules/agents/migrations/0016_module_owned_agents.down.sql +6 -0
- package/modules/agents/migrations/0016_module_owned_agents.up.sql +68 -0
- package/modules/agents/migrations/0017_agent_authorization_subjects.down.sql +2 -0
- package/modules/agents/migrations/0017_agent_authorization_subjects.up.sql +18 -0
- package/modules/agents/migrations/0018_agent_child_tenant_isolation.down.sql +12 -0
- package/modules/agents/migrations/0018_agent_child_tenant_isolation.up.sql +88 -0
- package/modules/agents/migrations/0019_background_recovery_grants.down.sql +6 -0
- package/modules/agents/migrations/0019_background_recovery_grants.up.sql +17 -0
- package/modules/agents/migrations/0020_provider_summary_role.down.sql +2 -0
- package/modules/agents/migrations/0020_provider_summary_role.up.sql +17 -0
- package/modules/agents/migrations/0021_agents_agent_reconciliation_role.down.sql +4 -0
- package/modules/agents/migrations/0021_agents_agent_reconciliation_role.up.sql +7 -0
- package/modules/agents/migrations/README.md +39 -0
- package/modules/agents/module.json +38 -0
- package/modules/agents/package.json +56 -0
- package/modules/agents/spec/module.yaml +271 -0
- package/modules/agents/spec/procedures-compatibility.md +63 -0
- package/modules/agents/src/acl/permissions.ts +13 -0
- package/modules/agents/src/api/endpoints.ts +1122 -0
- package/modules/agents/src/cli/commands.json +29 -0
- package/modules/agents/src/cli/index.ts +162 -0
- package/modules/agents/src/client/AgentDashboardWidget.tsrx +32 -0
- package/modules/agents/src/client/AgentDefinitionForm.tsrx +362 -0
- package/modules/agents/src/client/AgentDefinitionList.tsrx +127 -0
- package/modules/agents/src/client/AgentPlaygroundView.tsrx +246 -0
- package/modules/agents/src/client/AgentProcedureForm.tsrx +182 -0
- package/modules/agents/src/client/AgentProcedureList.tsrx +118 -0
- package/modules/agents/src/client/AgentProceduresView.tsrx +253 -0
- package/modules/agents/src/client/AgentProvidersView.tsrx +248 -0
- package/modules/agents/src/client/AgentRunsView.tsrx +304 -0
- package/modules/agents/src/client/AgentUsageView.tsrx +233 -0
- package/modules/agents/src/client/AgentsView.tsrx +339 -0
- package/modules/agents/src/client/ModuleAgentBindingForm.tsrx +239 -0
- package/modules/agents/src/client/ModuleAgentList.tsrx +122 -0
- package/modules/agents/src/client/ProviderConnectionForm.tsrx +273 -0
- package/modules/agents/src/client/ProviderConnectionList.tsrx +229 -0
- package/modules/agents/src/client/ProviderModelEditor.tsrx +313 -0
- package/modules/agents/src/client/RunTimeline.tsrx +212 -0
- package/modules/agents/src/client/agents.css +349 -0
- package/modules/agents/src/client/api.ts +373 -0
- package/modules/agents/src/client/contribution.tsrx +181 -0
- package/modules/agents/src/client/index.ts +21 -0
- package/modules/agents/src/client/presentation.ts +162 -0
- package/modules/agents/src/client/state.ts +100 -0
- package/modules/agents/src/domain/context-variables.ts +58 -0
- package/modules/agents/src/domain/run-timeline.ts +145 -0
- package/modules/agents/src/domain/types.ts +481 -0
- package/modules/agents/src/index.ts +88 -0
- package/modules/agents/src/platform.ts +82 -0
- package/modules/agents/src/server/action-execution.ts +811 -0
- package/modules/agents/src/server/define-agent.ts +170 -0
- package/modules/agents/src/server/index.ts +67 -0
- package/modules/agents/src/server/run-execution.ts +231 -0
- package/modules/agents/src/server/run-queue.ts +96 -0
- package/modules/agents/src/server/runtime.ts +448 -0
- package/modules/agents/src/server/tools.ts +18 -0
- package/modules/agents/src/services/agent-service.ts +2167 -0
- package/modules/agents/src/services/credential-vault.ts +133 -0
- package/modules/agents/src/services/database-repository.ts +2786 -0
- package/modules/agents/src/services/index.ts +33 -0
- package/modules/agents/src/services/migration.ts +1152 -0
- package/modules/agents/src/services/module-agent-preflight.ts +76 -0
- package/modules/agents/src/services/outbound-policy.ts +136 -0
- package/modules/agents/src/services/provider-broker.ts +80 -0
- package/modules/agents/src/services/provider-repository.ts +589 -0
- package/modules/agents/src/services/provider-service.ts +968 -0
- package/modules/agents/src/services/repository.ts +294 -0
- package/modules/agents/src/services/run-grant.ts +305 -0
- package/modules/agents/src/services/usage-service.ts +119 -0
- package/modules/agents/src/services/worker.ts +442 -0
- package/modules/agents/src/settings.ts +244 -0
- package/modules/agents/translations/en.json +403 -0
- package/modules/agents/translations/pl.json +403 -0
- package/modules/auth/README.md +215 -0
- package/modules/auth/migrations/0001_auth_core.up.sql +108 -0
- package/modules/auth/migrations/0002_bundled_module_scopes.up.sql +26 -0
- package/modules/auth/migrations/0003_agent_core_scopes.up.sql +12 -0
- package/modules/auth/migrations/0004_owner_only_development_scopes.up.sql +8 -0
- package/modules/auth/migrations/0005_agent_provider_scopes.up.sql +13 -0
- package/modules/auth/migrations/0006_tenant_slug.up.sql +6 -0
- package/modules/auth/migrations/0007_sandbox_scopes.up.sql +13 -0
- package/modules/auth/migrations/0008_api_tokens.up.sql +43 -0
- package/modules/auth/migrations/0009_module_settings.up.sql +24 -0
- package/modules/auth/migrations/0010_sign_in_lockout.up.sql +11 -0
- package/modules/auth/migrations/0011_session_ids_and_password_reset.up.sql +7 -0
- package/modules/auth/migrations/0012_roles.up.sql +31 -0
- package/modules/auth/migrations/0013_audit.up.sql +27 -0
- package/modules/auth/migrations/0014_audit_actor.up.sql +4 -0
- package/modules/auth/migrations/0015_account_security.up.sql +81 -0
- package/modules/auth/module.json +26 -0
- package/modules/auth/package.json +61 -0
- package/modules/auth/spec/module.yaml +190 -0
- package/modules/auth/src/acl/scopes.ts +86 -0
- package/modules/auth/src/api/attempt-limiter.ts +42 -0
- package/modules/auth/src/api/client-address.ts +14 -0
- package/modules/auth/src/api/cookies.ts +52 -0
- package/modules/auth/src/api/origin.ts +40 -0
- package/modules/auth/src/cli/commands.json +74 -0
- package/modules/auth/src/cli/database.ts +51 -0
- package/modules/auth/src/cli/greenfield.ts +173 -0
- package/modules/auth/src/cli/index.ts +184 -0
- package/modules/auth/src/cli/provisioning.ts +211 -0
- package/modules/auth/src/client/AuthBackdrop.tsrx +137 -0
- package/modules/auth/src/client/AuthenticationCore.tsrx +630 -0
- package/modules/auth/src/client/PasswordChangeRequired.tsrx +145 -0
- package/modules/auth/src/client/PublicAuthFlows.tsrx +379 -0
- package/modules/auth/src/client/api.ts +464 -0
- package/modules/auth/src/client/audit/AuditView.tsrx +357 -0
- package/modules/auth/src/client/audit/api.ts +164 -0
- package/modules/auth/src/client/audit/audit-columns.tsrx +47 -0
- package/modules/auth/src/client/audit/audit-row.ts +38 -0
- package/modules/auth/src/client/auth.css +483 -0
- package/modules/auth/src/client/contribution.tsrx +100 -0
- package/modules/auth/src/client/index.ts +32 -0
- package/modules/auth/src/client/security/SecurityView.tsrx +253 -0
- package/modules/auth/src/client/settings/PreferencesCard.tsrx +65 -0
- package/modules/auth/src/client/settings/SettingsView.tsrx +212 -0
- package/modules/auth/src/client/settings/WorkspaceCard.tsrx +59 -0
- package/modules/auth/src/client/settings/api.ts +115 -0
- package/modules/auth/src/client/slug.ts +26 -0
- package/modules/auth/src/client/state.ts +115 -0
- package/modules/auth/src/client/tokens/ApiTokenForm.tsrx +153 -0
- package/modules/auth/src/client/tokens/ApiTokenSecret.tsrx +35 -0
- package/modules/auth/src/client/tokens/ApiTokensView.tsrx +216 -0
- package/modules/auth/src/client/tokens/api.ts +59 -0
- package/modules/auth/src/client/tokens/state.ts +26 -0
- package/modules/auth/src/client/tokens/token-columns.tsrx +64 -0
- package/modules/auth/src/client/translations.ts +23 -0
- package/modules/auth/src/domain/types.ts +152 -0
- package/modules/auth/src/index.ts +42 -0
- package/modules/auth/src/middleware/authentication.ts +97 -0
- package/modules/auth/src/platform.ts +0 -0
- package/modules/auth/src/server/actor.ts +12 -0
- package/modules/auth/src/server/audit-endpoints.ts +51 -0
- package/modules/auth/src/server/composition.ts +9 -0
- package/modules/auth/src/server/endpoints.ts +893 -0
- package/modules/auth/src/server/http.ts +153 -0
- package/modules/auth/src/server/index.ts +37 -0
- package/modules/auth/src/server/roles-endpoints.ts +120 -0
- package/modules/auth/src/server/runtime.ts +705 -0
- package/modules/auth/src/server/session-endpoints.ts +86 -0
- package/modules/auth/src/server/session-security.ts +62 -0
- package/modules/auth/src/server/token-endpoints.ts +106 -0
- package/modules/auth/src/services/auth-service-error.ts +11 -0
- package/modules/auth/src/services/auth-service.ts +2309 -0
- package/modules/auth/src/services/database-repository.ts +1825 -0
- package/modules/auth/src/services/mail-delivery.ts +27 -0
- package/modules/auth/src/services/migration.ts +591 -0
- package/modules/auth/src/services/password.ts +115 -0
- package/modules/auth/src/services/repository.ts +395 -0
- package/modules/auth/src/services/settings-store.ts +92 -0
- package/modules/auth/src/services/totp.ts +135 -0
- package/modules/auth/src/services/validation.ts +186 -0
- package/modules/auth/src/settings.ts +150 -0
- package/modules/auth/translations/en.json +263 -0
- package/modules/auth/translations/pl.json +263 -0
- package/modules/automations/migrations/0001_automations_core.down.sql +10 -0
- package/modules/automations/migrations/0001_automations_core.up.sql +76 -0
- package/modules/automations/migrations/0002_automations_targets.down.sql +9 -0
- package/modules/automations/migrations/0002_automations_targets.up.sql +37 -0
- package/modules/automations/migrations/0003_automations_scheduler_role.down.sql +3 -0
- package/modules/automations/migrations/0003_automations_scheduler_role.up.sql +19 -0
- package/modules/automations/migrations/0004_automations_trigger_routing_role.down.sql +3 -0
- package/modules/automations/migrations/0004_automations_trigger_routing_role.up.sql +18 -0
- package/modules/automations/migrations/README.md +3 -0
- package/modules/automations/module.json +31 -0
- package/modules/automations/package.json +55 -0
- package/modules/automations/spec/module.yaml +93 -0
- package/modules/automations/src/acl/permissions.ts +10 -0
- package/modules/automations/src/api/endpoints.ts +480 -0
- package/modules/automations/src/client/AutomationScheduleForm.tsrx +218 -0
- package/modules/automations/src/client/AutomationSchedulesView.tsrx +339 -0
- package/modules/automations/src/client/AutomationTriggerForm.tsrx +190 -0
- package/modules/automations/src/client/AutomationTriggersView.tsrx +329 -0
- package/modules/automations/src/client/api.ts +148 -0
- package/modules/automations/src/client/contribution.tsrx +70 -0
- package/modules/automations/src/client/index.ts +20 -0
- package/modules/automations/src/client/presentation.ts +38 -0
- package/modules/automations/src/client/state.ts +40 -0
- package/modules/automations/src/client/target-selection.ts +44 -0
- package/modules/automations/src/domain/cadence.ts +44 -0
- package/modules/automations/src/domain/types.ts +110 -0
- package/modules/automations/src/domain/variables.ts +178 -0
- package/modules/automations/src/index.ts +39 -0
- package/modules/automations/src/platform.ts +73 -0
- package/modules/automations/src/server/execution.ts +77 -0
- package/modules/automations/src/server/index.ts +39 -0
- package/modules/automations/src/server/runtime.ts +218 -0
- package/modules/automations/src/server/targets.ts +116 -0
- package/modules/automations/src/services/automations-service.ts +10 -0
- package/modules/automations/src/services/database-repository.ts +763 -0
- package/modules/automations/src/services/index.ts +5 -0
- package/modules/automations/src/services/migration.ts +223 -0
- package/modules/automations/src/services/repository.ts +119 -0
- package/modules/automations/src/services/schedule-service.ts +837 -0
- package/modules/automations/src/services/secret-vault.ts +124 -0
- package/modules/automations/src/services/trigger-service.ts +648 -0
- package/modules/automations/src/settings.ts +69 -0
- package/modules/automations/translations/en.json +126 -0
- package/modules/automations/translations/pl.json +126 -0
- package/modules/automations-workflows-integration/module.json +27 -0
- package/modules/automations-workflows-integration/package.json +48 -0
- package/modules/automations-workflows-integration/spec/module.yaml +93 -0
- package/modules/automations-workflows-integration/src/index.ts +14 -0
- package/modules/automations-workflows-integration/src/platform.ts +24 -0
- package/modules/automations-workflows-integration/src/server/adapter.ts +272 -0
- package/modules/automations-workflows-integration/src/server/index.ts +11 -0
- package/modules/automations-workflows-integration/src/server/tools.ts +0 -0
- package/modules/automations-workflows-integration/translations/en.json +21 -0
- package/modules/automations-workflows-integration/translations/pl.json +21 -0
- package/modules/profile/migrations/0001_profile_core.down.sql +1 -0
- package/modules/profile/migrations/0001_profile_core.up.sql +13 -0
- package/modules/profile/migrations/0002_profile_language.down.sql +1 -0
- package/modules/profile/migrations/0002_profile_language.up.sql +12 -0
- package/modules/profile/migrations/README.md +3 -0
- package/modules/profile/module.json +23 -0
- package/modules/profile/package.json +55 -0
- package/modules/profile/spec/module.yaml +136 -0
- package/modules/profile/src/acl/permissions.ts +5 -0
- package/modules/profile/src/api/endpoints.ts +184 -0
- package/modules/profile/src/client/DisplayNameCard.tsrx +59 -0
- package/modules/profile/src/client/LanguageCard.tsrx +89 -0
- package/modules/profile/src/client/PasswordCard.tsrx +79 -0
- package/modules/profile/src/client/ProfileView.tsrx +192 -0
- package/modules/profile/src/client/SessionsCard.tsrx +158 -0
- package/modules/profile/src/client/api.ts +134 -0
- package/modules/profile/src/client/contribution.tsrx +61 -0
- package/modules/profile/src/client/index.ts +15 -0
- package/modules/profile/src/client/password.ts +41 -0
- package/modules/profile/src/client/sessions-api.ts +52 -0
- package/modules/profile/src/client/state.ts +23 -0
- package/modules/profile/src/domain/types.ts +21 -0
- package/modules/profile/src/index.ts +21 -0
- package/modules/profile/src/platform.ts +23 -0
- package/modules/profile/src/server/index.ts +7 -0
- package/modules/profile/src/server/runtime.ts +84 -0
- package/modules/profile/src/services/database-repository.ts +154 -0
- package/modules/profile/src/services/index.ts +6 -0
- package/modules/profile/src/services/migration.ts +58 -0
- package/modules/profile/src/services/profile-service.ts +114 -0
- package/modules/profile/src/services/repository.ts +13 -0
- package/modules/profile/translations/en.json +58 -0
- package/modules/profile/translations/pl.json +58 -0
- package/modules/sandbox/migrations/0001_sandbox_core.down.sql +6 -0
- package/modules/sandbox/migrations/0001_sandbox_core.up.sql +70 -0
- package/modules/sandbox/migrations/0002_sandbox_session_lifecycle.down.sql +36 -0
- package/modules/sandbox/migrations/0002_sandbox_session_lifecycle.up.sql +37 -0
- package/modules/sandbox/migrations/README.md +7 -0
- package/modules/sandbox/module.json +31 -0
- package/modules/sandbox/package.json +56 -0
- package/modules/sandbox/spec/module.yaml +111 -0
- package/modules/sandbox/src/acl/permissions.ts +18 -0
- package/modules/sandbox/src/api/endpoints.ts +439 -0
- package/modules/sandbox/src/cli/commands.json +84 -0
- package/modules/sandbox/src/cli/index.ts +450 -0
- package/modules/sandbox/src/client/SandboxAccessView.tsrx +191 -0
- package/modules/sandbox/src/client/SandboxGrantForm.tsrx +134 -0
- package/modules/sandbox/src/client/SandboxGrantList.tsrx +83 -0
- package/modules/sandbox/src/client/SandboxSessionList.tsrx +56 -0
- package/modules/sandbox/src/client/api.ts +87 -0
- package/modules/sandbox/src/client/contribution.tsrx +47 -0
- package/modules/sandbox/src/client/index.ts +18 -0
- package/modules/sandbox/src/client/presentation.ts +47 -0
- package/modules/sandbox/src/client/state.ts +20 -0
- package/modules/sandbox/src/domain/types.ts +125 -0
- package/modules/sandbox/src/index.ts +33 -0
- package/modules/sandbox/src/platform.ts +28 -0
- package/modules/sandbox/src/server/index.ts +20 -0
- package/modules/sandbox/src/server/runtime.ts +119 -0
- package/modules/sandbox/src/services/database-repository.ts +567 -0
- package/modules/sandbox/src/services/directory.ts +33 -0
- package/modules/sandbox/src/services/index.ts +19 -0
- package/modules/sandbox/src/services/migration.ts +145 -0
- package/modules/sandbox/src/services/repository.ts +55 -0
- package/modules/sandbox/src/services/sandbox-service-error.ts +10 -0
- package/modules/sandbox/src/services/sandbox-service.ts +533 -0
- package/modules/sandbox/translations/en.json +77 -0
- package/modules/sandbox/translations/pl.json +77 -0
- package/modules/system/module.json +18 -0
- package/modules/system/package.json +56 -0
- package/modules/system/spec/module.yaml +104 -0
- package/modules/system/src/acl/permissions.ts +10 -0
- package/modules/system/src/client/ModuleSettingRow.tsrx +191 -0
- package/modules/system/src/client/ModuleSettingsSection.tsrx +155 -0
- package/modules/system/src/client/ModulesView.tsrx +241 -0
- package/modules/system/src/client/api.ts +36 -0
- package/modules/system/src/client/contribution.tsrx +48 -0
- package/modules/system/src/client/index.ts +26 -0
- package/modules/system/src/client/module-columns.tsrx +66 -0
- package/modules/system/src/client/overview-api.ts +30 -0
- package/modules/system/src/client/setting-copy.ts +30 -0
- package/modules/system/src/client/settings-api.ts +57 -0
- package/modules/system/src/client/state.ts +16 -0
- package/modules/system/src/index.ts +11 -0
- package/modules/system/src/platform.ts +11 -0
- package/modules/system/src/server/endpoints.ts +372 -0
- package/modules/system/src/server/index.ts +11 -0
- package/modules/system/src/server/module-catalog.ts +117 -0
- package/modules/system/translations/en.json +64 -0
- package/modules/system/translations/pl.json +64 -0
- package/modules/users/migrations/README.md +3 -0
- package/modules/users/module.json +27 -0
- package/modules/users/package.json +54 -0
- package/modules/users/spec/module.yaml +79 -0
- package/modules/users/src/acl/permissions.ts +6 -0
- package/modules/users/src/api/endpoints.ts +222 -0
- package/modules/users/src/client/InviteMemberForm.tsrx +62 -0
- package/modules/users/src/client/MemberDrawer.tsrx +298 -0
- package/modules/users/src/client/RoleForm.tsrx +140 -0
- package/modules/users/src/client/RolesView.tsrx +288 -0
- package/modules/users/src/client/UserAccountForm.tsrx +86 -0
- package/modules/users/src/client/UsersView.tsrx +486 -0
- package/modules/users/src/client/api.ts +172 -0
- package/modules/users/src/client/contribution.tsrx +92 -0
- package/modules/users/src/client/index.ts +19 -0
- package/modules/users/src/client/member-columns.tsrx +52 -0
- package/modules/users/src/client/roles-api.ts +90 -0
- package/modules/users/src/client/state.ts +42 -0
- package/modules/users/src/index.ts +27 -0
- package/modules/users/src/platform.ts +11 -0
- package/modules/users/src/services/index.ts +2 -0
- package/modules/users/src/services/users-service.ts +142 -0
- package/modules/users/translations/en.json +133 -0
- package/modules/users/translations/pl.json +133 -0
- package/modules/workflows/migrations/0001_workflows_core.down.sql +19 -0
- package/modules/workflows/migrations/0001_workflows_core.up.sql +228 -0
- package/modules/workflows/migrations/0002_workflows_authorization_subject.down.sql +1 -0
- package/modules/workflows/migrations/0002_workflows_authorization_subject.up.sql +9 -0
- package/modules/workflows/migrations/0003_workflows_worker_role.up.sql +34 -0
- package/modules/workflows/migrations/README.md +7 -0
- package/modules/workflows/module.json +31 -0
- package/modules/workflows/package.json +55 -0
- package/modules/workflows/spec/module.yaml +227 -0
- package/modules/workflows/src/acl/permissions.ts +10 -0
- package/modules/workflows/src/api/endpoints.ts +852 -0
- package/modules/workflows/src/client/WorkflowCanvas.tsrx +819 -0
- package/modules/workflows/src/client/WorkflowCreateForm.tsrx +111 -0
- package/modules/workflows/src/client/WorkflowEditor.tsrx +443 -0
- package/modules/workflows/src/client/WorkflowExecutionHistory.tsrx +169 -0
- package/modules/workflows/src/client/WorkflowFixtureDrawer.tsrx +206 -0
- package/modules/workflows/src/client/WorkflowInputForm.tsrx +125 -0
- package/modules/workflows/src/client/WorkflowInputSchemaEditor.tsrx +185 -0
- package/modules/workflows/src/client/WorkflowInspector.tsrx +471 -0
- package/modules/workflows/src/client/WorkflowLiveConfirmation.tsrx +67 -0
- package/modules/workflows/src/client/WorkflowMappingEditor.tsrx +283 -0
- package/modules/workflows/src/client/WorkflowNodePalette.tsrx +50 -0
- package/modules/workflows/src/client/WorkflowPointerField.tsrx +178 -0
- package/modules/workflows/src/client/WorkflowRevisionReview.tsrx +49 -0
- package/modules/workflows/src/client/WorkflowRunInspector.tsrx +143 -0
- package/modules/workflows/src/client/WorkflowTestPanel.tsrx +109 -0
- package/modules/workflows/src/client/WorkflowValidationPanel.tsrx +139 -0
- package/modules/workflows/src/client/WorkflowsView.tsrx +1060 -0
- package/modules/workflows/src/client/api.ts +312 -0
- package/modules/workflows/src/client/canvas-model.ts +472 -0
- package/modules/workflows/src/client/connected-node.ts +71 -0
- package/modules/workflows/src/client/contribution.tsrx +57 -0
- package/modules/workflows/src/client/create-model.ts +15 -0
- package/modules/workflows/src/client/draft-repair.ts +86 -0
- package/modules/workflows/src/client/index.ts +19 -0
- package/modules/workflows/src/client/input-model.ts +124 -0
- package/modules/workflows/src/client/mapping-model.ts +110 -0
- package/modules/workflows/src/client/pointer-model.ts +123 -0
- package/modules/workflows/src/client/presentation.ts +62 -0
- package/modules/workflows/src/client/run-actions.ts +19 -0
- package/modules/workflows/src/client/state.ts +57 -0
- package/modules/workflows/src/client/viewport.ts +107 -0
- package/modules/workflows/src/client/workflows.css +899 -0
- package/modules/workflows/src/domain/events.ts +399 -0
- package/modules/workflows/src/domain/graph.ts +1136 -0
- package/modules/workflows/src/domain/types.ts +563 -0
- package/modules/workflows/src/index.ts +27 -0
- package/modules/workflows/src/platform.ts +49 -0
- package/modules/workflows/src/server/index.ts +13 -0
- package/modules/workflows/src/server/runtime.ts +266 -0
- package/modules/workflows/src/services/cursor-codec.ts +62 -0
- package/modules/workflows/src/services/database-repository.ts +2407 -0
- package/modules/workflows/src/services/index.ts +6 -0
- package/modules/workflows/src/services/migration.ts +375 -0
- package/modules/workflows/src/services/payload-codec.ts +264 -0
- package/modules/workflows/src/services/repository.ts +285 -0
- package/modules/workflows/src/services/simulation.ts +359 -0
- package/modules/workflows/src/services/worker.ts +1196 -0
- package/modules/workflows/src/services/workflows-service.ts +1395 -0
- package/modules/workflows/translations/en.json +348 -0
- package/modules/workflows/translations/pl.json +348 -0
- package/modules.json +41 -0
- package/package.json +125 -0
- package/packages/ai-provider/package.json +46 -0
- package/packages/ai-provider/src/catalog.ts +102 -0
- package/packages/ai-provider/src/errors.ts +110 -0
- package/packages/ai-provider/src/index.ts +33 -0
- package/packages/ai-provider/src/model.ts +198 -0
- package/packages/ai-provider/src/pricing.ts +73 -0
- package/packages/cli-protocol/package.json +40 -0
- package/packages/cli-protocol/src/index.ts +113 -0
- package/packages/client/package.json +46 -0
- package/packages/client/src/ApplicationShell.tsrx +374 -0
- package/packages/client/src/contributions.ts +172 -0
- package/packages/client/src/i18n/index.ts +30 -0
- package/packages/client/src/i18n/locale.ts +25 -0
- package/packages/client/src/i18n/locales/en.json +66 -0
- package/packages/client/src/i18n/locales/pl.json +66 -0
- package/packages/client/src/i18n/runtime.ts +201 -0
- package/packages/client/src/i18n/translations.ts +88 -0
- package/packages/client/src/index.ts +55 -0
- package/packages/client/src/routing.ts +9 -0
- package/packages/client/src/shell/BrandMark.tsrx +10 -0
- package/packages/client/src/shell/CommandPalette.tsrx +79 -0
- package/packages/client/src/shell/ContributionOutlets.tsrx +31 -0
- package/packages/client/src/shell/DashboardView.tsrx +60 -0
- package/packages/client/src/shell/MobileHeader.tsrx +24 -0
- package/packages/client/src/shell/OrganizationSwitcher.tsrx +100 -0
- package/packages/client/src/shell/OverviewCharts.tsrx +167 -0
- package/packages/client/src/shell/PrimaryNavigation.tsrx +75 -0
- package/packages/client/src/shell/Sidebar.tsrx +76 -0
- package/packages/client/src/shell/Topbar.tsrx +44 -0
- package/packages/client/src/shell/UserMenu.tsrx +103 -0
- package/packages/client/src/shell/WorkspaceContent.tsrx +30 -0
- package/packages/client/src/shell/identity.ts +12 -0
- package/packages/client/src/shell/navigation.ts +68 -0
- package/packages/client/src/shell/shell.css +734 -0
- package/packages/client/src/shell/types.ts +29 -0
- package/packages/client/src/state.ts +63 -0
- package/packages/client/src/web.ts +39 -0
- package/packages/coding-agent/package.json +44 -0
- package/packages/coding-agent/src/drivers/byok.ts +322 -0
- package/packages/coding-agent/src/drivers/claude-code.ts +290 -0
- package/packages/coding-agent/src/drivers/codex.ts +281 -0
- package/packages/coding-agent/src/index.ts +56 -0
- package/packages/coding-agent/src/registry.ts +119 -0
- package/packages/coding-agent/src/roles/contract.ts +60 -0
- package/packages/coding-agent/src/roles/defaults.ts +134 -0
- package/packages/coding-agent/src/roles/handoff.ts +41 -0
- package/packages/coding-agent/src/roles/registry.ts +156 -0
- package/packages/coding-agent/src/roles/skills.ts +72 -0
- package/packages/coding-agent/src/roles/sync.ts +88 -0
- package/packages/coding-agent/src/types.ts +102 -0
- package/packages/coding-agent/src/workspace.ts +275 -0
- package/packages/contracts/package.json +38 -0
- package/packages/contracts/schemas/blueprint.schema.json +48 -0
- package/packages/contracts/schemas/cli-extension.schema.json +90 -0
- package/packages/contracts/schemas/module-artifact.schema.json +82 -0
- package/packages/contracts/schemas/module-catalog.schema.json +48 -0
- package/packages/contracts/schemas/module-spec.schema.json +111 -0
- package/packages/contracts/schemas/module.schema.json +156 -0
- package/packages/contracts/schemas/platform-spec.schema.json +17 -0
- package/packages/contracts/schemas/project.schema.json +270 -0
- package/packages/contracts/src/index.ts +191 -0
- package/packages/contracts/src/module-distribution.ts +47 -0
- package/packages/contracts/src/schemas.ts +18 -0
- package/packages/contracts/src/variables.ts +156 -0
- package/packages/contracts/src/web.ts +60 -0
- package/packages/database/package.json +43 -0
- package/packages/database/src/contracts.ts +399 -0
- package/packages/database/src/index.ts +112 -0
- package/packages/database/src/migrations.ts +444 -0
- package/packages/database/src/postgresql.ts +517 -0
- package/packages/database/src/provider.ts +639 -0
- package/packages/database/src/record-history.ts +201 -0
- package/packages/database/src/registry.ts +265 -0
- package/packages/database/src/reset.ts +87 -0
- package/packages/database-pglite/package.json +42 -0
- package/packages/database-pglite/src/driver.ts +168 -0
- package/packages/database-pglite/src/index.ts +2 -0
- package/packages/database-testing/package.json +44 -0
- package/packages/database-testing/src/index.ts +8 -0
- package/packages/database-testing/src/pglite.ts +124 -0
- package/packages/database-testing/src/postgres.ts +184 -0
- package/packages/database-testing/src/provider.ts +43 -0
- package/packages/database-testing/src/vitest-preset.ts +23 -0
- package/packages/dev-console/README.md +6 -0
- package/packages/dev-console/package.json +38 -0
- package/packages/dev-console/src/index.mjs +220 -0
- package/packages/harness/package.json +47 -0
- package/packages/harness/schemas/task-packet.schema.json +48 -0
- package/packages/harness/src/catalog.ts +24 -0
- package/packages/harness/src/errors.ts +9 -0
- package/packages/harness/src/index.ts +53 -0
- package/packages/harness/src/preamble.ts +31 -0
- package/packages/harness/src/runtime.ts +833 -0
- package/packages/harness/src/task-packet.ts +86 -0
- package/packages/harness/src/tool-adapters.ts +106 -0
- package/packages/harness/src/tool-contract.ts +242 -0
- package/packages/harness/src/vercel-ai-provider.ts +198 -0
- package/packages/kernel/package.json +44 -0
- package/packages/kernel/src/acl.ts +20 -0
- package/packages/kernel/src/actor.ts +139 -0
- package/packages/kernel/src/agent-registry.ts +81 -0
- package/packages/kernel/src/capability-registry.ts +28 -0
- package/packages/kernel/src/errors.ts +9 -0
- package/packages/kernel/src/index.ts +90 -0
- package/packages/kernel/src/legacy-local-state.ts +103 -0
- package/packages/kernel/src/module-compatibility.ts +70 -0
- package/packages/kernel/src/module-registry.ts +124 -0
- package/packages/kernel/src/module-settings.ts +403 -0
- package/packages/kernel/src/record-history.ts +146 -0
- package/packages/kernel/src/runtime-config.ts +51 -0
- package/packages/kernel/src/tool-registry.ts +25 -0
- package/packages/kernel/src/variable-registry.ts +339 -0
- package/packages/sandbox/README.md +691 -0
- package/packages/sandbox/bin/flowdular-sandbox.mjs +393 -0
- package/packages/sandbox/dist/client/assets/App-ClMOrpyg.js +11 -0
- package/packages/sandbox/dist/client/assets/PreviewHost-BHiHrfbQ.js +1 -0
- package/packages/sandbox/dist/client/assets/auto-buGEq6de.js +3 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/index-CvwhlQ87.js +4 -0
- package/packages/sandbox/dist/client/assets/styles-BPWaGf55.js +3 -0
- package/packages/sandbox/dist/client/assets/styles-Dx1_KOag.css +1 -0
- package/packages/sandbox/dist/client/favicon.svg +1 -0
- package/packages/sandbox/dist/server/assets/auto-CVGNYyb3.js +12785 -0
- package/packages/sandbox/dist/server/assets/chunk-DDJLRBDX-3OUNo51g.js +4125 -0
- package/packages/sandbox/dist/server/assets/nodefs-DVSI7kG0.js +24 -0
- package/packages/sandbox/dist/server/assets/opfs-ahp-D56iokt1.js +388 -0
- package/packages/sandbox/dist/server/assets/token-Bvaq7Anz.js +55 -0
- package/packages/sandbox/dist/server/assets/token-util-BqSvdIPQ.js +3 -0
- package/packages/sandbox/dist/server/assets/token-util-CktFFT4z.js +494 -0
- package/packages/sandbox/dist/server/entry.js +91671 -0
- package/packages/sandbox/dist/server/favicon.svg +1 -0
- package/packages/sandbox/dist/server/index.html +161 -0
- package/packages/sandbox/index.html +159 -0
- package/packages/sandbox/octane.config.ts +36 -0
- package/packages/sandbox/package.json +83 -0
- package/packages/sandbox/public/favicon.svg +1 -0
- package/packages/sandbox/public/og.png +0 -0
- package/packages/sandbox/src/App.tsrx +924 -0
- package/packages/sandbox/src/client/ApprovalHandoff.tsrx +39 -0
- package/packages/sandbox/src/client/ChatPane.tsrx +694 -0
- package/packages/sandbox/src/client/ConnectView.tsrx +86 -0
- package/packages/sandbox/src/client/DiffPane.tsrx +150 -0
- package/packages/sandbox/src/client/EjectModal.tsrx +571 -0
- package/packages/sandbox/src/client/GateResults.tsrx +60 -0
- package/packages/sandbox/src/client/GitHubSettingsModal.tsrx +219 -0
- package/packages/sandbox/src/client/NewSessionForm.tsrx +214 -0
- package/packages/sandbox/src/client/SessionBar.tsrx +151 -0
- package/packages/sandbox/src/client/SessionPicker.tsrx +472 -0
- package/packages/sandbox/src/client/SpecEditor.tsrx +109 -0
- package/packages/sandbox/src/client/SpecReviewCard.tsrx +321 -0
- package/packages/sandbox/src/client/WorkCard.tsrx +128 -0
- package/packages/sandbox/src/client/WorkbenchModal.tsrx +161 -0
- package/packages/sandbox/src/client/WorkspaceMenu.tsrx +100 -0
- package/packages/sandbox/src/client/api.ts +797 -0
- package/packages/sandbox/src/client/attachments.ts +73 -0
- package/packages/sandbox/src/client/dashboard.ts +46 -0
- package/packages/sandbox/src/client/github-settings.ts +48 -0
- package/packages/sandbox/src/client/highlight.ts +105 -0
- package/packages/sandbox/src/client/i18n.ts +32 -0
- package/packages/sandbox/src/client/locales/en.json +466 -0
- package/packages/sandbox/src/client/locales/pl.json +466 -0
- package/packages/sandbox/src/client/session-labels.ts +77 -0
- package/packages/sandbox/src/client/state.ts +108 -0
- package/packages/sandbox/src/index.ts +10 -0
- package/packages/sandbox/src/preview/PreviewHost.tsrx +373 -0
- package/packages/sandbox/src/preview/load-module.ts +16 -0
- package/packages/sandbox/src/server/attachments.ts +308 -0
- package/packages/sandbox/src/server/auto-review.ts +181 -0
- package/packages/sandbox/src/server/checkpoints.ts +90 -0
- package/packages/sandbox/src/server/config.ts +460 -0
- package/packages/sandbox/src/server/dashboard.ts +245 -0
- package/packages/sandbox/src/server/delivery/configuration.ts +193 -0
- package/packages/sandbox/src/server/delivery/git-pr.ts +1473 -0
- package/packages/sandbox/src/server/delivery/index.ts +83 -0
- package/packages/sandbox/src/server/delivery/local.ts +151 -0
- package/packages/sandbox/src/server/delivery/official-modules.ts +516 -0
- package/packages/sandbox/src/server/delivery/plan.ts +218 -0
- package/packages/sandbox/src/server/delivery/policies.ts +239 -0
- package/packages/sandbox/src/server/delivery/record.ts +41 -0
- package/packages/sandbox/src/server/delivery/steps.ts +464 -0
- package/packages/sandbox/src/server/delivery/types.ts +158 -0
- package/packages/sandbox/src/server/dependencies.ts +88 -0
- package/packages/sandbox/src/server/diff.ts +230 -0
- package/packages/sandbox/src/server/gates.ts +388 -0
- package/packages/sandbox/src/server/index.ts +139 -0
- package/packages/sandbox/src/server/path-guard.ts +282 -0
- package/packages/sandbox/src/server/planning.ts +749 -0
- package/packages/sandbox/src/server/platform-client.ts +189 -0
- package/packages/sandbox/src/server/preview-database-host.ts +340 -0
- package/packages/sandbox/src/server/preview-database-protocol.ts +163 -0
- package/packages/sandbox/src/server/preview-database-proxy.ts +356 -0
- package/packages/sandbox/src/server/preview-database.ts +109 -0
- package/packages/sandbox/src/server/preview-ipc.ts +15 -0
- package/packages/sandbox/src/server/preview-modules.ts +83 -0
- package/packages/sandbox/src/server/preview-revision.ts +44 -0
- package/packages/sandbox/src/server/preview-runtime.ts +467 -0
- package/packages/sandbox/src/server/preview-worker-manager.ts +436 -0
- package/packages/sandbox/src/server/preview-worker.ts +168 -0
- package/packages/sandbox/src/server/reference.ts +251 -0
- package/packages/sandbox/src/server/routes.ts +2258 -0
- package/packages/sandbox/src/server/runtime.ts +188 -0
- package/packages/sandbox/src/server/session-owner.ts +23 -0
- package/packages/sandbox/src/server/sessions.ts +849 -0
- package/packages/sandbox/src/server/spec.ts +471 -0
- package/packages/sandbox/src/server/turn-lifecycle.ts +56 -0
- package/packages/sandbox/src/server/turns.ts +993 -0
- package/packages/sandbox/src/server/workspace-install.ts +266 -0
- package/packages/sandbox/src/server/workspace-root.ts +73 -0
- package/packages/sandbox/src/styles.css +1573 -0
- package/packages/sandbox/vite.config.ts +133 -0
- package/packages/server/package.json +43 -0
- package/packages/server/src/application-routes.ts +21 -0
- package/packages/server/src/composition.ts +48 -0
- package/packages/server/src/endpoint.ts +142 -0
- package/packages/server/src/http.ts +128 -0
- package/packages/server/src/index.ts +46 -0
- package/packages/server/src/response-lifetime.ts +56 -0
- package/packages/server/src/security-headers.ts +130 -0
- package/packages/server/src/web-html.ts +55 -0
- package/packages/server/src/web.ts +361 -0
- package/packages/ui/package.json +46 -0
- package/packages/ui/src/brand/BrandMark.tsrx +66 -0
- package/packages/ui/src/brand/mark.ts +44 -0
- package/packages/ui/src/components/Alert.tsrx +17 -0
- package/packages/ui/src/components/Avatar.tsrx +18 -0
- package/packages/ui/src/components/Button.tsrx +29 -0
- package/packages/ui/src/components/Chart.tsrx +274 -0
- package/packages/ui/src/components/CheckGrid.tsrx +93 -0
- package/packages/ui/src/components/ConfirmDialog.tsrx +63 -0
- package/packages/ui/src/components/Drawer.tsrx +71 -0
- package/packages/ui/src/components/EmptyState.tsrx +26 -0
- package/packages/ui/src/components/Filters.tsrx +39 -0
- package/packages/ui/src/components/FormField.tsrx +27 -0
- package/packages/ui/src/components/Kpi.tsrx +36 -0
- package/packages/ui/src/components/PageHeader.tsrx +26 -0
- package/packages/ui/src/components/ScopeSummary.tsrx +76 -0
- package/packages/ui/src/components/SearchField.tsrx +24 -0
- package/packages/ui/src/components/SettingRow.tsrx +50 -0
- package/packages/ui/src/components/Switch.tsrx +21 -0
- package/packages/ui/src/components/Table.tsrx +267 -0
- package/packages/ui/src/components/TableCard.tsrx +52 -0
- package/packages/ui/src/components/Tag.tsrx +28 -0
- package/packages/ui/src/components/VariableField.tsrx +284 -0
- package/packages/ui/src/components/VariableInput.tsrx +7 -0
- package/packages/ui/src/components/VariableSelect.tsrx +72 -0
- package/packages/ui/src/components/VariableTextarea.tsrx +9 -0
- package/packages/ui/src/components/variable-field.ts +61 -0
- package/packages/ui/src/components/variable-select.ts +69 -0
- package/packages/ui/src/icons/Icon.tsrx +56 -0
- package/packages/ui/src/index.ts +81 -0
- package/packages/ui/src/initials.ts +10 -0
- package/packages/ui/src/styles/base.css +71 -0
- package/packages/ui/src/styles/components.css +1859 -0
- package/packages/ui/src/styles/index.css +3 -0
- package/packages/ui/src/styles/tokens.css +124 -0
- package/tsconfig.base.json +18 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Delivery is deliberately an injected port. auth.core creates opaque links but
|
|
2
|
+
never selects an SMTP, transactional-email, or provider SDK on its own. */
|
|
3
|
+
export interface AuthMailDelivery {
|
|
4
|
+
send(message: {
|
|
5
|
+
readonly to: string;
|
|
6
|
+
readonly kind: 'password-reset' | 'tenant-invitation';
|
|
7
|
+
readonly url: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class DevelopmentMailDelivery implements AuthMailDelivery {
|
|
12
|
+
readonly messages: {
|
|
13
|
+
to: string;
|
|
14
|
+
kind: 'password-reset' | 'tenant-invitation';
|
|
15
|
+
url: string;
|
|
16
|
+
}[] = [];
|
|
17
|
+
|
|
18
|
+
async send(message: {
|
|
19
|
+
readonly to: string;
|
|
20
|
+
readonly kind: 'password-reset' | 'tenant-invitation';
|
|
21
|
+
readonly url: string;
|
|
22
|
+
}): Promise<void> {
|
|
23
|
+
/* Local-only evidence for tests and the dev composition. It is intentionally
|
|
24
|
+
in memory, never exposed over HTTP or written to logs. */
|
|
25
|
+
this.messages.push({ ...message });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import type { DatabaseMigration } from '@flowdular/sdk/database';
|
|
2
|
+
import {
|
|
3
|
+
migrationObjectState,
|
|
4
|
+
postgresTenantTableState,
|
|
5
|
+
} from '@flowdular/sdk/database';
|
|
6
|
+
|
|
7
|
+
/* Every constant mirrors its migrations/<id>.up.sql file byte for byte;
|
|
8
|
+
tests/migrations.test.ts fails on drift. */
|
|
9
|
+
|
|
10
|
+
export const AUTH_MIGRATION_001 = `CREATE TABLE IF NOT EXISTS auth_tenants (
|
|
11
|
+
id TEXT PRIMARY KEY,
|
|
12
|
+
name TEXT NOT NULL,
|
|
13
|
+
created_at BIGINT NOT NULL
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
-- An account is one global identity that may hold memberships in several
|
|
17
|
+
-- workspaces, and sign-in reaches it before any workspace is known. It carries
|
|
18
|
+
-- no tenant column, so it carries no tenant policy either; the workspace
|
|
19
|
+
-- boundary is expressed by the membership tables below.
|
|
20
|
+
CREATE TABLE IF NOT EXISTS auth_accounts (
|
|
21
|
+
id TEXT PRIMARY KEY,
|
|
22
|
+
email TEXT NOT NULL,
|
|
23
|
+
email_normalized TEXT NOT NULL UNIQUE,
|
|
24
|
+
password_hash TEXT NOT NULL,
|
|
25
|
+
display_name TEXT NOT NULL,
|
|
26
|
+
status TEXT NOT NULL CHECK (status IN ('active', 'disabled')),
|
|
27
|
+
created_at BIGINT NOT NULL
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE IF NOT EXISTS auth_memberships (
|
|
31
|
+
account_id TEXT NOT NULL REFERENCES auth_accounts(id) ON DELETE CASCADE,
|
|
32
|
+
tenant_id TEXT NOT NULL REFERENCES auth_tenants(id) ON DELETE CASCADE,
|
|
33
|
+
role TEXT NOT NULL,
|
|
34
|
+
created_at BIGINT NOT NULL,
|
|
35
|
+
PRIMARY KEY (account_id, tenant_id)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
CREATE TABLE IF NOT EXISTS auth_membership_scopes (
|
|
39
|
+
account_id TEXT NOT NULL,
|
|
40
|
+
tenant_id TEXT NOT NULL,
|
|
41
|
+
scope TEXT NOT NULL,
|
|
42
|
+
PRIMARY KEY (account_id, tenant_id, scope),
|
|
43
|
+
FOREIGN KEY (account_id, tenant_id)
|
|
44
|
+
REFERENCES auth_memberships(account_id, tenant_id)
|
|
45
|
+
ON DELETE CASCADE
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
CREATE TABLE IF NOT EXISTS auth_sessions (
|
|
49
|
+
token_hash TEXT PRIMARY KEY,
|
|
50
|
+
account_id TEXT NOT NULL REFERENCES auth_accounts(id) ON DELETE CASCADE,
|
|
51
|
+
tenant_id TEXT NOT NULL REFERENCES auth_tenants(id) ON DELETE CASCADE,
|
|
52
|
+
csrf_token TEXT NOT NULL,
|
|
53
|
+
created_at BIGINT NOT NULL,
|
|
54
|
+
expires_at BIGINT NOT NULL,
|
|
55
|
+
last_seen_at BIGINT NOT NULL
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE INDEX IF NOT EXISTS auth_sessions_account_idx
|
|
59
|
+
ON auth_sessions(account_id, expires_at);
|
|
60
|
+
|
|
61
|
+
CREATE INDEX IF NOT EXISTS auth_sessions_expiry_idx
|
|
62
|
+
ON auth_sessions(expires_at);
|
|
63
|
+
|
|
64
|
+
-- A workspace row is its own tenant, so the policy binds the primary key and a
|
|
65
|
+
-- runtime connection reads or renames only the workspace it entered.
|
|
66
|
+
ALTER TABLE auth_tenants ENABLE ROW LEVEL SECURITY;
|
|
67
|
+
ALTER TABLE auth_tenants FORCE ROW LEVEL SECURITY;
|
|
68
|
+
CREATE POLICY auth_tenants_tenant_policy ON auth_tenants
|
|
69
|
+
USING (id = current_setting('coreloom.tenant_id', true))
|
|
70
|
+
WITH CHECK (id = current_setting('coreloom.tenant_id', true));
|
|
71
|
+
|
|
72
|
+
ALTER TABLE auth_memberships ENABLE ROW LEVEL SECURITY;
|
|
73
|
+
ALTER TABLE auth_memberships FORCE ROW LEVEL SECURITY;
|
|
74
|
+
CREATE POLICY auth_memberships_tenant_policy ON auth_memberships
|
|
75
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
76
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
77
|
+
|
|
78
|
+
ALTER TABLE auth_membership_scopes ENABLE ROW LEVEL SECURITY;
|
|
79
|
+
ALTER TABLE auth_membership_scopes FORCE ROW LEVEL SECURITY;
|
|
80
|
+
CREATE POLICY auth_membership_scopes_tenant_policy ON auth_membership_scopes
|
|
81
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
82
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
83
|
+
|
|
84
|
+
ALTER TABLE auth_sessions ENABLE ROW LEVEL SECURITY;
|
|
85
|
+
ALTER TABLE auth_sessions FORCE ROW LEVEL SECURITY;
|
|
86
|
+
CREATE POLICY auth_sessions_tenant_policy ON auth_sessions
|
|
87
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
88
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
89
|
+
|
|
90
|
+
-- A session cookie, a workspace list and a sign-in all arrive with a key that
|
|
91
|
+
-- names no workspace, so auth.core resolves the owning tenant on the read-only
|
|
92
|
+
-- background role and then does the work under that tenant. The key is the
|
|
93
|
+
-- whole predicate such a read can have, so these policies narrow by column
|
|
94
|
+
-- grant: everything outside the grant stays unreadable on that connection,
|
|
95
|
+
-- inside a WHERE clause too.
|
|
96
|
+
DO $$
|
|
97
|
+
BEGIN
|
|
98
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'coreloom_background') THEN
|
|
99
|
+
RAISE EXCEPTION 'The coreloom_background role must exist before this migration.';
|
|
100
|
+
END IF;
|
|
101
|
+
END
|
|
102
|
+
$$;
|
|
103
|
+
CREATE POLICY auth_tenants_background_policy ON auth_tenants
|
|
104
|
+
FOR SELECT TO coreloom_background
|
|
105
|
+
USING (true);
|
|
106
|
+
REVOKE SELECT ON auth_tenants FROM coreloom_background;
|
|
107
|
+
GRANT SELECT (id, name) ON auth_tenants TO coreloom_background;
|
|
108
|
+
CREATE POLICY auth_memberships_background_policy ON auth_memberships
|
|
109
|
+
FOR SELECT TO coreloom_background
|
|
110
|
+
USING (true);
|
|
111
|
+
REVOKE SELECT ON auth_memberships FROM coreloom_background;
|
|
112
|
+
GRANT SELECT (account_id, tenant_id, role, created_at) ON auth_memberships TO coreloom_background;
|
|
113
|
+
CREATE POLICY auth_sessions_background_policy ON auth_sessions
|
|
114
|
+
FOR SELECT TO coreloom_background
|
|
115
|
+
USING (true);
|
|
116
|
+
REVOKE SELECT ON auth_sessions FROM coreloom_background;
|
|
117
|
+
GRANT SELECT (token_hash, tenant_id, account_id, expires_at) ON auth_sessions TO coreloom_background;
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
export const AUTH_MIGRATION_002 = `INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
121
|
+
SELECT account_id, tenant_id, 'users.members.read' FROM auth_memberships
|
|
122
|
+
ON CONFLICT DO NOTHING;
|
|
123
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
124
|
+
SELECT account_id, tenant_id, 'parties.records.read' FROM auth_memberships
|
|
125
|
+
ON CONFLICT DO NOTHING;
|
|
126
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
127
|
+
SELECT account_id, tenant_id, 'catalog.items.read' FROM auth_memberships
|
|
128
|
+
ON CONFLICT DO NOTHING;
|
|
129
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
130
|
+
SELECT account_id, tenant_id, 'users.members.manage' FROM auth_memberships WHERE role = 'owner'
|
|
131
|
+
ON CONFLICT DO NOTHING;
|
|
132
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
133
|
+
SELECT account_id, tenant_id, 'parties.records.manage' FROM auth_memberships WHERE role = 'owner'
|
|
134
|
+
ON CONFLICT DO NOTHING;
|
|
135
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
136
|
+
SELECT account_id, tenant_id, 'catalog.items.manage' FROM auth_memberships WHERE role = 'owner'
|
|
137
|
+
ON CONFLICT DO NOTHING;
|
|
138
|
+
DELETE FROM auth_membership_scopes
|
|
139
|
+
WHERE scope = 'system.modules.read'
|
|
140
|
+
AND EXISTS (
|
|
141
|
+
SELECT 1 FROM auth_memberships
|
|
142
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
143
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
144
|
+
AND auth_memberships.role = 'member'
|
|
145
|
+
);
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
export const AUTH_MIGRATION_003 = `INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
149
|
+
SELECT account_id, tenant_id, 'agents.definitions.read' FROM auth_memberships
|
|
150
|
+
ON CONFLICT DO NOTHING;
|
|
151
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
152
|
+
SELECT account_id, tenant_id, 'agents.runs.read' FROM auth_memberships
|
|
153
|
+
ON CONFLICT DO NOTHING;
|
|
154
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
155
|
+
SELECT account_id, tenant_id, 'agents.runs.execute' FROM auth_memberships
|
|
156
|
+
ON CONFLICT DO NOTHING;
|
|
157
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope)
|
|
158
|
+
SELECT account_id, tenant_id, 'agents.definitions.manage' FROM auth_memberships WHERE role = 'owner'
|
|
159
|
+
ON CONFLICT DO NOTHING;
|
|
160
|
+
`;
|
|
161
|
+
|
|
162
|
+
export const AUTH_MIGRATION_004 = `DELETE FROM auth_membership_scopes
|
|
163
|
+
WHERE scope IN ('system.modules.read', 'system.specs.read', 'system.runs.read')
|
|
164
|
+
AND EXISTS (
|
|
165
|
+
SELECT 1 FROM auth_memberships
|
|
166
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
167
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
168
|
+
AND auth_memberships.role <> 'owner'
|
|
169
|
+
);
|
|
170
|
+
`;
|
|
171
|
+
|
|
172
|
+
export const AUTH_MIGRATION_005 = `INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'agents.skills.read' FROM auth_memberships ON CONFLICT DO NOTHING;
|
|
173
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'agents.providers.read' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
174
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'agents.providers.manage' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
175
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'agents.providers.test' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
176
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'agents.skills.manage' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
177
|
+
DELETE FROM auth_membership_scopes
|
|
178
|
+
WHERE scope IN ('agents.providers.read', 'agents.providers.manage', 'agents.providers.test', 'agents.skills.manage')
|
|
179
|
+
AND EXISTS (
|
|
180
|
+
SELECT 1 FROM auth_memberships
|
|
181
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
182
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
183
|
+
AND auth_memberships.role <> 'owner'
|
|
184
|
+
);
|
|
185
|
+
`;
|
|
186
|
+
|
|
187
|
+
export const AUTH_MIGRATION_006_TENANT_SLUG = `ALTER TABLE auth_tenants ADD COLUMN IF NOT EXISTS slug TEXT;
|
|
188
|
+
UPDATE auth_tenants SET slug = lower(id) WHERE slug IS NULL;
|
|
189
|
+
CREATE UNIQUE INDEX IF NOT EXISTS auth_tenants_slug_idx ON auth_tenants(slug);
|
|
190
|
+
-- A slug is how a workspace is addressed before one is entered, so the
|
|
191
|
+
-- cross-tenant lookup that resolves it reads this column too.
|
|
192
|
+
GRANT SELECT (slug) ON auth_tenants TO coreloom_background;
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
export const AUTH_MIGRATION_007_SANDBOX_SCOPES = `INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'sandbox.access.use' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
196
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'sandbox.access.manage' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
197
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'sandbox.sessions.read' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
198
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'sandbox.preview.data' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
199
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'sandbox.modules.eject' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
200
|
+
DELETE FROM auth_membership_scopes
|
|
201
|
+
WHERE scope IN ('sandbox.access.use', 'sandbox.access.manage', 'sandbox.sessions.read', 'sandbox.preview.data', 'sandbox.modules.eject')
|
|
202
|
+
AND EXISTS (
|
|
203
|
+
SELECT 1 FROM auth_memberships
|
|
204
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
205
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
206
|
+
AND auth_memberships.role <> 'owner'
|
|
207
|
+
);
|
|
208
|
+
`;
|
|
209
|
+
|
|
210
|
+
export const AUTH_MIGRATION_008_API_TOKENS = `CREATE TABLE IF NOT EXISTS auth_api_tokens (
|
|
211
|
+
id TEXT PRIMARY KEY,
|
|
212
|
+
tenant_id TEXT NOT NULL,
|
|
213
|
+
account_id TEXT NOT NULL,
|
|
214
|
+
label TEXT NOT NULL,
|
|
215
|
+
prefix TEXT NOT NULL,
|
|
216
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
217
|
+
scopes_json TEXT NOT NULL,
|
|
218
|
+
created_by TEXT NOT NULL,
|
|
219
|
+
created_at BIGINT NOT NULL,
|
|
220
|
+
expires_at BIGINT,
|
|
221
|
+
last_used_at BIGINT,
|
|
222
|
+
revoked_at BIGINT,
|
|
223
|
+
revoked_by TEXT,
|
|
224
|
+
FOREIGN KEY (account_id, tenant_id)
|
|
225
|
+
REFERENCES auth_memberships(account_id, tenant_id)
|
|
226
|
+
ON DELETE CASCADE
|
|
227
|
+
);
|
|
228
|
+
CREATE INDEX IF NOT EXISTS auth_api_tokens_tenant_idx
|
|
229
|
+
ON auth_api_tokens (tenant_id, revoked_at, created_at DESC);
|
|
230
|
+
ALTER TABLE auth_api_tokens ENABLE ROW LEVEL SECURITY;
|
|
231
|
+
ALTER TABLE auth_api_tokens FORCE ROW LEVEL SECURITY;
|
|
232
|
+
CREATE POLICY auth_api_tokens_tenant_policy ON auth_api_tokens
|
|
233
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
234
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
235
|
+
-- A bearer token names no workspace. The routing read stops at the revoked
|
|
236
|
+
-- flag; the scopes, label and account are read again under the tenant it named.
|
|
237
|
+
CREATE POLICY auth_api_tokens_background_policy ON auth_api_tokens
|
|
238
|
+
FOR SELECT TO coreloom_background
|
|
239
|
+
USING (revoked_at IS NULL);
|
|
240
|
+
REVOKE SELECT ON auth_api_tokens FROM coreloom_background;
|
|
241
|
+
GRANT SELECT (token_hash, tenant_id, id, revoked_at) ON auth_api_tokens TO coreloom_background;
|
|
242
|
+
|
|
243
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'auth.tokens.read' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
244
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'auth.tokens.manage' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
245
|
+
DELETE FROM auth_membership_scopes
|
|
246
|
+
WHERE scope IN ('auth.tokens.read', 'auth.tokens.manage')
|
|
247
|
+
AND EXISTS (
|
|
248
|
+
SELECT 1 FROM auth_memberships
|
|
249
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
250
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
251
|
+
AND auth_memberships.role <> 'owner'
|
|
252
|
+
);
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
export const AUTH_MIGRATION_009_MODULE_SETTINGS = `CREATE TABLE IF NOT EXISTS module_settings (
|
|
256
|
+
tenant_id TEXT NOT NULL,
|
|
257
|
+
module_id TEXT NOT NULL,
|
|
258
|
+
key TEXT NOT NULL,
|
|
259
|
+
value_json TEXT NOT NULL,
|
|
260
|
+
updated_at BIGINT NOT NULL,
|
|
261
|
+
updated_by TEXT NOT NULL,
|
|
262
|
+
PRIMARY KEY (tenant_id, module_id, key)
|
|
263
|
+
);
|
|
264
|
+
ALTER TABLE module_settings ENABLE ROW LEVEL SECURITY;
|
|
265
|
+
ALTER TABLE module_settings FORCE ROW LEVEL SECURITY;
|
|
266
|
+
CREATE POLICY module_settings_tenant_policy ON module_settings
|
|
267
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
268
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
269
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'system.settings.read' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
270
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'system.settings.manage' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
271
|
+
DELETE FROM auth_membership_scopes
|
|
272
|
+
WHERE scope IN ('system.settings.read', 'system.settings.manage')
|
|
273
|
+
AND EXISTS (
|
|
274
|
+
SELECT 1 FROM auth_memberships
|
|
275
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
276
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
277
|
+
AND auth_memberships.role <> 'owner'
|
|
278
|
+
);
|
|
279
|
+
`;
|
|
280
|
+
|
|
281
|
+
export const AUTH_MIGRATION_010_SIGN_IN_LOCKOUT = `-- Failures are counted per email address before a workspace, and usually before
|
|
282
|
+
-- an account, is known, so this table carries no tenant column and no policy.
|
|
283
|
+
-- locked_until holds an epoch in milliseconds, which overflows INTEGER.
|
|
284
|
+
CREATE TABLE IF NOT EXISTS auth_sign_in_failures (
|
|
285
|
+
email_normalized TEXT PRIMARY KEY,
|
|
286
|
+
failures INTEGER NOT NULL,
|
|
287
|
+
locked_until BIGINT,
|
|
288
|
+
updated_at BIGINT NOT NULL
|
|
289
|
+
);
|
|
290
|
+
CREATE INDEX IF NOT EXISTS auth_sign_in_failures_updated_idx
|
|
291
|
+
ON auth_sign_in_failures (updated_at);
|
|
292
|
+
`;
|
|
293
|
+
|
|
294
|
+
export const AUTH_MIGRATION_011_SESSION_IDS_AND_PASSWORD_RESET = `ALTER TABLE auth_sessions ADD COLUMN IF NOT EXISTS id TEXT;
|
|
295
|
+
ALTER TABLE auth_accounts ADD COLUMN IF NOT EXISTS password_change_required INTEGER NOT NULL DEFAULT 0;
|
|
296
|
+
UPDATE auth_sessions SET id = replace(gen_random_uuid()::text, '-', '') WHERE id IS NULL;
|
|
297
|
+
CREATE UNIQUE INDEX IF NOT EXISTS auth_sessions_id_idx ON auth_sessions (id);
|
|
298
|
+
-- Revoking one session of an account names it by this id and no workspace, so
|
|
299
|
+
-- the cross-tenant lookup that routes it reads this column too.
|
|
300
|
+
GRANT SELECT (id) ON auth_sessions TO coreloom_background;
|
|
301
|
+
`;
|
|
302
|
+
|
|
303
|
+
export const AUTH_MIGRATION_012_ROLES = `CREATE TABLE IF NOT EXISTS auth_roles (
|
|
304
|
+
id TEXT PRIMARY KEY,
|
|
305
|
+
tenant_id TEXT NOT NULL REFERENCES auth_tenants(id) ON DELETE CASCADE,
|
|
306
|
+
key TEXT NOT NULL,
|
|
307
|
+
name TEXT NOT NULL,
|
|
308
|
+
description TEXT NOT NULL,
|
|
309
|
+
scopes_json TEXT NOT NULL,
|
|
310
|
+
builtin INTEGER NOT NULL DEFAULT 0,
|
|
311
|
+
created_at BIGINT NOT NULL,
|
|
312
|
+
updated_at BIGINT NOT NULL,
|
|
313
|
+
UNIQUE (tenant_id, key)
|
|
314
|
+
);
|
|
315
|
+
ALTER TABLE auth_roles ENABLE ROW LEVEL SECURITY;
|
|
316
|
+
ALTER TABLE auth_roles FORCE ROW LEVEL SECURITY;
|
|
317
|
+
CREATE POLICY auth_roles_tenant_policy ON auth_roles
|
|
318
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
319
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
320
|
+
ALTER TABLE auth_memberships ADD COLUMN IF NOT EXISTS role_id TEXT;
|
|
321
|
+
-- Built-in owner and member rows are inserted per tenant by the repository from the static scope lists.
|
|
322
|
+
UPDATE auth_memberships SET role_id = tenant_id || ':' || role
|
|
323
|
+
WHERE role_id IS NULL AND role IN ('owner', 'member');
|
|
324
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'auth.roles.read' FROM auth_memberships ON CONFLICT DO NOTHING;
|
|
325
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'auth.roles.manage' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
326
|
+
DELETE FROM auth_membership_scopes
|
|
327
|
+
WHERE scope = 'auth.roles.manage'
|
|
328
|
+
AND EXISTS (
|
|
329
|
+
SELECT 1 FROM auth_memberships
|
|
330
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
331
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
332
|
+
AND auth_memberships.role <> 'owner'
|
|
333
|
+
);
|
|
334
|
+
`;
|
|
335
|
+
|
|
336
|
+
export const AUTH_MIGRATION_013_AUDIT = `CREATE TABLE IF NOT EXISTS auth_audit (
|
|
337
|
+
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
338
|
+
tenant_id TEXT NOT NULL,
|
|
339
|
+
actor_account_id TEXT,
|
|
340
|
+
actor_label TEXT NOT NULL,
|
|
341
|
+
action TEXT NOT NULL,
|
|
342
|
+
subject_type TEXT NOT NULL,
|
|
343
|
+
subject_id TEXT NOT NULL,
|
|
344
|
+
metadata_json TEXT NOT NULL,
|
|
345
|
+
occurred_at BIGINT NOT NULL
|
|
346
|
+
);
|
|
347
|
+
CREATE INDEX IF NOT EXISTS auth_audit_tenant_time_idx
|
|
348
|
+
ON auth_audit (tenant_id, occurred_at DESC, id DESC);
|
|
349
|
+
ALTER TABLE auth_audit ENABLE ROW LEVEL SECURITY;
|
|
350
|
+
ALTER TABLE auth_audit FORCE ROW LEVEL SECURITY;
|
|
351
|
+
CREATE POLICY auth_audit_tenant_policy ON auth_audit
|
|
352
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
353
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
354
|
+
INSERT INTO auth_membership_scopes (account_id, tenant_id, scope) SELECT account_id, tenant_id, 'auth.audit.read' FROM auth_memberships WHERE role = 'owner' ON CONFLICT DO NOTHING;
|
|
355
|
+
DELETE FROM auth_membership_scopes
|
|
356
|
+
WHERE scope = 'auth.audit.read'
|
|
357
|
+
AND EXISTS (
|
|
358
|
+
SELECT 1 FROM auth_memberships
|
|
359
|
+
WHERE auth_memberships.account_id = auth_membership_scopes.account_id
|
|
360
|
+
AND auth_memberships.tenant_id = auth_membership_scopes.tenant_id
|
|
361
|
+
AND auth_memberships.role <> 'owner'
|
|
362
|
+
);
|
|
363
|
+
`;
|
|
364
|
+
|
|
365
|
+
export const AUTH_MIGRATION_014_AUDIT_ACTOR = `ALTER TABLE auth_audit ADD COLUMN IF NOT EXISTS actor_kind TEXT NOT NULL DEFAULT 'user'
|
|
366
|
+
CHECK (actor_kind IN ('user', 'agent'));
|
|
367
|
+
ALTER TABLE auth_audit ADD COLUMN IF NOT EXISTS actor_run_id TEXT
|
|
368
|
+
CHECK (actor_run_id IS NULL OR length(actor_run_id) BETWEEN 1 AND 128);
|
|
369
|
+
`;
|
|
370
|
+
|
|
371
|
+
export const AUTH_MIGRATION_015_ACCOUNT_SECURITY = `-- A reset token, a TOTP secret and a recovery code belong to the account, not
|
|
372
|
+
-- to one of its workspaces, and each is presented before a workspace is chosen.
|
|
373
|
+
-- They carry no tenant column and no policy; the membership tables remain the
|
|
374
|
+
-- only place the workspace boundary is expressed.
|
|
375
|
+
CREATE TABLE IF NOT EXISTS auth_password_reset_tokens (
|
|
376
|
+
token_hash TEXT PRIMARY KEY,
|
|
377
|
+
account_id TEXT NOT NULL REFERENCES auth_accounts(id) ON DELETE CASCADE,
|
|
378
|
+
expires_at BIGINT NOT NULL,
|
|
379
|
+
used_at BIGINT,
|
|
380
|
+
created_at BIGINT NOT NULL
|
|
381
|
+
);
|
|
382
|
+
CREATE INDEX IF NOT EXISTS auth_password_reset_tokens_account_expiry_idx
|
|
383
|
+
ON auth_password_reset_tokens (account_id, expires_at, token_hash);
|
|
384
|
+
|
|
385
|
+
CREATE TABLE IF NOT EXISTS auth_tenant_invitations (
|
|
386
|
+
id TEXT PRIMARY KEY,
|
|
387
|
+
tenant_id TEXT NOT NULL REFERENCES auth_tenants(id) ON DELETE CASCADE,
|
|
388
|
+
email TEXT NOT NULL,
|
|
389
|
+
email_normalized TEXT NOT NULL,
|
|
390
|
+
role_key TEXT NOT NULL,
|
|
391
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
392
|
+
expires_at BIGINT NOT NULL,
|
|
393
|
+
accepted_at BIGINT,
|
|
394
|
+
created_by TEXT NOT NULL,
|
|
395
|
+
created_at BIGINT NOT NULL,
|
|
396
|
+
UNIQUE (tenant_id, email_normalized)
|
|
397
|
+
);
|
|
398
|
+
CREATE INDEX IF NOT EXISTS auth_tenant_invitations_tenant_expiry_idx
|
|
399
|
+
ON auth_tenant_invitations (tenant_id, expires_at, id);
|
|
400
|
+
|
|
401
|
+
CREATE TABLE IF NOT EXISTS auth_mfa_totp (
|
|
402
|
+
account_id TEXT PRIMARY KEY REFERENCES auth_accounts(id) ON DELETE CASCADE,
|
|
403
|
+
secret_ciphertext TEXT NOT NULL,
|
|
404
|
+
confirmed_at BIGINT,
|
|
405
|
+
created_at BIGINT NOT NULL
|
|
406
|
+
);
|
|
407
|
+
CREATE TABLE IF NOT EXISTS auth_mfa_recovery_codes (
|
|
408
|
+
code_hash TEXT PRIMARY KEY,
|
|
409
|
+
account_id TEXT NOT NULL REFERENCES auth_accounts(id) ON DELETE CASCADE,
|
|
410
|
+
used_at BIGINT,
|
|
411
|
+
created_at BIGINT NOT NULL
|
|
412
|
+
);
|
|
413
|
+
CREATE INDEX IF NOT EXISTS auth_mfa_recovery_codes_account_idx
|
|
414
|
+
ON auth_mfa_recovery_codes (account_id, used_at, code_hash);
|
|
415
|
+
|
|
416
|
+
CREATE TABLE IF NOT EXISTS auth_mfa_challenges (
|
|
417
|
+
token_hash TEXT PRIMARY KEY,
|
|
418
|
+
account_id TEXT NOT NULL REFERENCES auth_accounts(id) ON DELETE CASCADE,
|
|
419
|
+
tenant_id TEXT NOT NULL REFERENCES auth_tenants(id) ON DELETE CASCADE,
|
|
420
|
+
expires_at BIGINT NOT NULL,
|
|
421
|
+
used_at BIGINT,
|
|
422
|
+
created_at BIGINT NOT NULL
|
|
423
|
+
);
|
|
424
|
+
CREATE INDEX IF NOT EXISTS auth_mfa_challenges_expiry_idx
|
|
425
|
+
ON auth_mfa_challenges (expires_at, token_hash);
|
|
426
|
+
|
|
427
|
+
ALTER TABLE auth_tenant_invitations ENABLE ROW LEVEL SECURITY;
|
|
428
|
+
ALTER TABLE auth_tenant_invitations FORCE ROW LEVEL SECURITY;
|
|
429
|
+
CREATE POLICY auth_tenant_invitations_tenant_policy ON auth_tenant_invitations
|
|
430
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
431
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
432
|
+
ALTER TABLE auth_mfa_challenges ENABLE ROW LEVEL SECURITY;
|
|
433
|
+
ALTER TABLE auth_mfa_challenges FORCE ROW LEVEL SECURITY;
|
|
434
|
+
CREATE POLICY auth_mfa_challenges_tenant_policy ON auth_mfa_challenges
|
|
435
|
+
USING (tenant_id = current_setting('coreloom.tenant_id', true))
|
|
436
|
+
WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
|
|
437
|
+
|
|
438
|
+
-- An invitation link and a pending multi-factor challenge name their workspace
|
|
439
|
+
-- only inside the row, so the routing read runs on the background role and the
|
|
440
|
+
-- acceptance that follows runs under the tenant it returned. An invitation that
|
|
441
|
+
-- was already accepted and a challenge that was already spent route nothing.
|
|
442
|
+
CREATE POLICY auth_tenant_invitations_background_policy ON auth_tenant_invitations
|
|
443
|
+
FOR SELECT TO coreloom_background
|
|
444
|
+
USING (accepted_at IS NULL);
|
|
445
|
+
REVOKE SELECT ON auth_tenant_invitations FROM coreloom_background;
|
|
446
|
+
GRANT SELECT (token_hash, tenant_id, expires_at, accepted_at) ON auth_tenant_invitations TO coreloom_background;
|
|
447
|
+
CREATE POLICY auth_mfa_challenges_background_policy ON auth_mfa_challenges
|
|
448
|
+
FOR SELECT TO coreloom_background
|
|
449
|
+
USING (used_at IS NULL);
|
|
450
|
+
REVOKE SELECT ON auth_mfa_challenges FROM coreloom_background;
|
|
451
|
+
GRANT SELECT (token_hash, tenant_id, account_id, expires_at, used_at) ON auth_mfa_challenges TO coreloom_background;
|
|
452
|
+
`;
|
|
453
|
+
|
|
454
|
+
/* The scope backfills carry no schema, so they have nothing to adopt. They also
|
|
455
|
+
reach no rows: row security is forced on both tables they read, and the
|
|
456
|
+
migration role is subject to it like any other, so the SELECT they insert
|
|
457
|
+
from is empty on every PostgreSQL database. They stay because a migration id
|
|
458
|
+
is immutable history; a workspace receives these scopes when it is created,
|
|
459
|
+
from the static role lists in acl/scopes.ts. */
|
|
460
|
+
export const databaseMigrations: readonly DatabaseMigration[] = [
|
|
461
|
+
{
|
|
462
|
+
id: '0001_auth_core',
|
|
463
|
+
sql: { postgresql: AUTH_MIGRATION_001 },
|
|
464
|
+
inspectExisting: (database) =>
|
|
465
|
+
postgresTenantTableState(
|
|
466
|
+
database,
|
|
467
|
+
'auth_tenants',
|
|
468
|
+
'auth_tenants_tenant_policy',
|
|
469
|
+
[
|
|
470
|
+
() => database.schema.hasTable('auth_accounts'),
|
|
471
|
+
() => database.schema.hasTable('auth_memberships'),
|
|
472
|
+
() => database.schema.hasTable('auth_membership_scopes'),
|
|
473
|
+
() => database.schema.hasTable('auth_sessions'),
|
|
474
|
+
() => database.schema.hasIndex('auth_sessions_account_idx'),
|
|
475
|
+
() => database.schema.hasIndex('auth_sessions_expiry_idx'),
|
|
476
|
+
],
|
|
477
|
+
),
|
|
478
|
+
},
|
|
479
|
+
{ id: '0002_bundled_module_scopes', sql: { postgresql: AUTH_MIGRATION_002 } },
|
|
480
|
+
{ id: '0003_agent_core_scopes', sql: { postgresql: AUTH_MIGRATION_003 } },
|
|
481
|
+
{
|
|
482
|
+
id: '0004_owner_only_development_scopes',
|
|
483
|
+
sql: { postgresql: AUTH_MIGRATION_004 },
|
|
484
|
+
},
|
|
485
|
+
{ id: '0005_agent_provider_scopes', sql: { postgresql: AUTH_MIGRATION_005 } },
|
|
486
|
+
{
|
|
487
|
+
id: '0006_tenant_slug',
|
|
488
|
+
sql: { postgresql: AUTH_MIGRATION_006_TENANT_SLUG },
|
|
489
|
+
inspectExisting: (database) =>
|
|
490
|
+
migrationObjectState([
|
|
491
|
+
() => database.schema.hasColumn('auth_tenants', 'slug'),
|
|
492
|
+
() => database.schema.hasIndex('auth_tenants_slug_idx'),
|
|
493
|
+
]),
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: '0007_sandbox_scopes',
|
|
497
|
+
sql: { postgresql: AUTH_MIGRATION_007_SANDBOX_SCOPES },
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: '0008_api_tokens',
|
|
501
|
+
sql: { postgresql: AUTH_MIGRATION_008_API_TOKENS },
|
|
502
|
+
inspectExisting: (database) =>
|
|
503
|
+
postgresTenantTableState(
|
|
504
|
+
database,
|
|
505
|
+
'auth_api_tokens',
|
|
506
|
+
'auth_api_tokens_tenant_policy',
|
|
507
|
+
[() => database.schema.hasIndex('auth_api_tokens_tenant_idx')],
|
|
508
|
+
),
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: '0009_module_settings',
|
|
512
|
+
sql: { postgresql: AUTH_MIGRATION_009_MODULE_SETTINGS },
|
|
513
|
+
inspectExisting: (database) =>
|
|
514
|
+
postgresTenantTableState(
|
|
515
|
+
database,
|
|
516
|
+
'module_settings',
|
|
517
|
+
'module_settings_tenant_policy',
|
|
518
|
+
),
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
id: '0010_sign_in_lockout',
|
|
522
|
+
sql: { postgresql: AUTH_MIGRATION_010_SIGN_IN_LOCKOUT },
|
|
523
|
+
inspectExisting: (database) =>
|
|
524
|
+
migrationObjectState([
|
|
525
|
+
() => database.schema.hasTable('auth_sign_in_failures'),
|
|
526
|
+
() => database.schema.hasIndex('auth_sign_in_failures_updated_idx'),
|
|
527
|
+
]),
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
id: '0011_session_ids_and_password_reset',
|
|
531
|
+
sql: { postgresql: AUTH_MIGRATION_011_SESSION_IDS_AND_PASSWORD_RESET },
|
|
532
|
+
inspectExisting: (database) =>
|
|
533
|
+
migrationObjectState([
|
|
534
|
+
() => database.schema.hasColumn('auth_sessions', 'id'),
|
|
535
|
+
() =>
|
|
536
|
+
database.schema.hasColumn(
|
|
537
|
+
'auth_accounts',
|
|
538
|
+
'password_change_required',
|
|
539
|
+
),
|
|
540
|
+
() => database.schema.hasIndex('auth_sessions_id_idx'),
|
|
541
|
+
]),
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
id: '0012_roles',
|
|
545
|
+
sql: { postgresql: AUTH_MIGRATION_012_ROLES },
|
|
546
|
+
inspectExisting: (database) =>
|
|
547
|
+
postgresTenantTableState(
|
|
548
|
+
database,
|
|
549
|
+
'auth_roles',
|
|
550
|
+
'auth_roles_tenant_policy',
|
|
551
|
+
[() => database.schema.hasColumn('auth_memberships', 'role_id')],
|
|
552
|
+
),
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
id: '0013_audit',
|
|
556
|
+
sql: { postgresql: AUTH_MIGRATION_013_AUDIT },
|
|
557
|
+
inspectExisting: (database) =>
|
|
558
|
+
postgresTenantTableState(
|
|
559
|
+
database,
|
|
560
|
+
'auth_audit',
|
|
561
|
+
'auth_audit_tenant_policy',
|
|
562
|
+
[() => database.schema.hasIndex('auth_audit_tenant_time_idx')],
|
|
563
|
+
),
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
id: '0014_audit_actor',
|
|
567
|
+
sql: { postgresql: AUTH_MIGRATION_014_AUDIT_ACTOR },
|
|
568
|
+
inspectExisting: (database) =>
|
|
569
|
+
migrationObjectState([
|
|
570
|
+
() => database.schema.hasColumn('auth_audit', 'actor_kind'),
|
|
571
|
+
() => database.schema.hasColumn('auth_audit', 'actor_run_id'),
|
|
572
|
+
]),
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
id: '0015_account_security',
|
|
576
|
+
sql: { postgresql: AUTH_MIGRATION_015_ACCOUNT_SECURITY },
|
|
577
|
+
inspectExisting: (database) =>
|
|
578
|
+
postgresTenantTableState(
|
|
579
|
+
database,
|
|
580
|
+
'auth_tenant_invitations',
|
|
581
|
+
'auth_tenant_invitations_tenant_policy',
|
|
582
|
+
[
|
|
583
|
+
() => database.schema.hasTable('auth_password_reset_tokens'),
|
|
584
|
+
() => database.schema.hasTable('auth_mfa_totp'),
|
|
585
|
+
() => database.schema.hasTable('auth_mfa_recovery_codes'),
|
|
586
|
+
() => database.schema.hasTable('auth_mfa_challenges'),
|
|
587
|
+
() => database.schema.hasIndex('auth_mfa_challenges_expiry_idx'),
|
|
588
|
+
],
|
|
589
|
+
),
|
|
590
|
+
},
|
|
591
|
+
];
|