@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,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: auth-security-review
|
|
3
|
+
description: >-
|
|
4
|
+
Review a module or platform change for authorization, tenancy, CSRF, input
|
|
5
|
+
bounds, secrets, and destructive CLI use, with the exact checks and tests the
|
|
6
|
+
platform relies on.
|
|
7
|
+
roles:
|
|
8
|
+
- reviewer
|
|
9
|
+
- backend-engineer
|
|
10
|
+
- module-executor
|
|
11
|
+
when: Any endpoint, scope, token, credential, or CLI capability is added or changed, or a review asks whether a change is safe.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Authentication and security review
|
|
15
|
+
|
|
16
|
+
## 1. Threat surface of a module endpoint
|
|
17
|
+
|
|
18
|
+
Check every route in `src/api/endpoints.ts` against `.ai/references/catalog/src/api/endpoints.ts`:
|
|
19
|
+
|
|
20
|
+
1. `defineEndpoint` (`packages/server/src/endpoint.ts`) with `access: { kind: 'permission', permission }` and `resolveIdentity: endpointIdentityFromContext`. `access: { kind: 'public' }` is allowed only with a written reason (health, sign-in). A raw `new ServerRoute` from `@octanejs/app-core` bypasses all of this; outside `modules/auth` and `packages/server` it is a finding.
|
|
21
|
+
2. Non-GET handlers call `sessionMutationDenial(octane, auth)` before any work. Order inside it (`modules/auth/src/server/session-security.ts`): API token principal (403 `TOKEN_MUTATION_DENIED`), `assertSameOrigin` (`sec-fetch-site`, then `origin`, then `referer`; 403 `CROSS_ORIGIN_REQUEST` or `ORIGIN_REQUIRED`), session cookie (401), `x-csrf-token` compared with `timingSafeEqual` (403 `CSRF_REJECTED`).
|
|
22
|
+
3. Body through `readJsonObject` (415 without `application/json`, 413 above 16 KB) and `requiredString`, `optionalString`, `requiredInteger` with `min` and `max`. A handler that calls `request.json()` itself has no size limit.
|
|
23
|
+
4. Tenant id only from `principalFromContext(octane)!.tenantId`. A `tenantId` read from the body, query or headers is a blocker (`.ai/examples/bad/tenant-from-body`).
|
|
24
|
+
5. Repository: every query on a tenant-owned table has `WHERE tenant_id = ?`; parameters are bound, never interpolated; unique constraints start with `tenant_id`.
|
|
25
|
+
6. Errors return `{ error: { code, message } }` with stable codes and safe messages; no stack, path, or SQL text reaches the client.
|
|
26
|
+
|
|
27
|
+
## 2. Scope model
|
|
28
|
+
|
|
29
|
+
`modules/auth/src/acl/scopes.ts`: `AUTH_SCOPES`, `PLATFORM_SCOPES` (`system.workspace.access` gates the shell in `platform/src/App.tsrx`; `system.settings.read` and `system.settings.manage` guard `GET /api/settings` and `POST /api/settings/update` in `modules/auth/src/server/settings-endpoints.ts`), `BUNDLED_MODULE_SCOPES`, `OWNER_SCOPES` (all of them), `MEMBER_SCOPES` (read scopes plus `agents.runs.execute`). Sign-up creates an owner with `OWNER_SCOPES`; member creation copies `OWNER_SCOPES` or `MEMBER_SCOPES` by role (`modules/auth/src/services/auth-service.ts`). A module's scopes reach existing owners through `pnpm flowdular module enable <id> --apply` (which runs the grant) or `pnpm flowdular auth sync-scopes --module <id> --apply` for a re-grant. Navigation in the `Development` group is owner-only in the client (`packages/client/src/shell/navigation.ts`); the server permission stays authoritative.
|
|
30
|
+
|
|
31
|
+
Review question: does every new scope appear in the spec `permissions`, in `src/acl/permissions.ts`, on the endpoint, and on the client contribution that exposes it?
|
|
32
|
+
|
|
33
|
+
### Unified audit read surface
|
|
34
|
+
|
|
35
|
+
Three tenant-scoped trails are readable over HTTP, each a GET behind a read scope with the tenant taken from the principal: `GET /api/auth/audit` (`auth.audit.read`), `GET /api/agent-audit` (`agents.runs.read`), and `GET /api/sandbox/audit` (`sandbox.sessions.read`). They are surfaced together in `auth.core`'s Administration > Audit view, whose source selector is derived from `ModuleClientContext.scopes` so a reader is never offered a source it cannot read. The agent and sandbox trails are hash-chained; `GET /api/agent-audit/verify` and `GET /api/sandbox/audit/verify` (same read scopes) recompute the chain and return `{ verified, brokenAt }` through the same repository walk the `flowdular <module> audit-verify` CLI uses, so CLI and endpoint cannot drift. Reviewing an audit change: the read scope guards both list and verify, the list cursor is `(occurred_at, sequence)` and the sequence is trusted from storage (never from input), and no chain field or metadata may carry a credential, token, or request body.
|
|
36
|
+
|
|
37
|
+
## 3. API tokens
|
|
38
|
+
|
|
39
|
+
`Authorization: Bearer clat_...` (`API_TOKEN_PREFIX` in `auth-service.ts`), 256-bit random, stored as SHA-256, scopes intersected with the live membership, max lifetime one year, resolved only when no session cookie is present (`modules/auth/src/middleware/authentication.ts`). Tokens are refused for session-guarded mutations. A module endpoint that should be callable by a token (read for the sandbox bridge) must be a GET behind a permission.
|
|
40
|
+
|
|
41
|
+
## 4. Secrets
|
|
42
|
+
|
|
43
|
+
Passwords: scrypt `N=2^17, r=8, p=1`, 64-byte key (`modules/auth/src/services/password.ts`). Sessions: 32 random bytes, CSRF 24 bytes, SHA-256 at rest. Cookies: `HttpOnly; SameSite=Strict; Path=/`, `Secure` and the `__Host-` prefix when `FD_AUTH_SECURE_COOKIE` is true (default in production), 12 hour TTL (`modules/auth/src/server/runtime.ts`). Provider credentials: AES-256-GCM in `modules/agents/src/services/credential-vault.ts`, key from `FD_AGENT_CREDENTIAL_KEY` (required in production). `redactSecrets` in `packages/ai-provider/src/errors.ts` scrubs provider messages; there is no general redacting logger, and a raw driver error can carry the failing statement, so a handler maps it to a Flowdular error code and logs that instead of `console.error(..., error)` with the driver message. A module never logs a principal, a token, or a request body.
|
|
44
|
+
|
|
45
|
+
## 5. Greps to run
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
grep -rn "new ServerRoute" modules/*/src | grep -v modules/auth # raw routes outside auth
|
|
49
|
+
grep -rn "tenantId" modules/*/src/api | grep -v principalFromContext # tenant from input
|
|
50
|
+
grep -rn "request.json()" modules/*/src # unbounded body reads
|
|
51
|
+
grep -rn "console\.\(log\|error\)" modules/*/src # logging of principals or bodies
|
|
52
|
+
grep -rn "kind: 'public'" modules/*/src # public endpoints need a reason
|
|
53
|
+
grep -rn "\${" modules/*/src/services/database-repository.ts # interpolation into SQL
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 6. Destructive and external CLI capabilities
|
|
57
|
+
|
|
58
|
+
`packages/cli/src/runner.ts`: `external` risk and non-local `destructive` capabilities fail with `APPROVAL_VERIFIER_REQUIRED`; `localOnly` runs only when `FD_ENV` or `NODE_ENV` is `development` or `test` (unset counts as development); `requiresApprovedSpec` needs `--spec` pointing at an approved spec; `destructive` with `--apply` needs `--confirm <token>` equal to the descriptor's `confirmation`. `setup quick` is `auth greenfield` (`--apply --confirm reset-local-auth`) and resets `.flowdular/data/auth.db`. Never point it at `FD_AUTH_DATABASE` of a deployment.
|
|
59
|
+
|
|
60
|
+
## 7. Required tests per endpoint
|
|
61
|
+
|
|
62
|
+
Recipe in `modules/auth/tests/endpoints.test.ts`: build the runtime with a `DatabaseAuthRepository` on a `createPgliteTestProvider()` lease, call `route.handler(createContext(new Request(...), {}))`.
|
|
63
|
+
|
|
64
|
+
- 401 without a cookie or token.
|
|
65
|
+
- 403 with a principal that lacks the permission.
|
|
66
|
+
- Cross-tenant read returns an empty list (service level, on the suite's test provider under the non-bypass `coreloom_runtime` role).
|
|
67
|
+
- Mutation without `x-csrf-token` returns 403 `CSRF_REJECTED`; without `origin` returns 403.
|
|
68
|
+
- Each validation bound returns 400 with its code.
|
|
69
|
+
|
|
70
|
+
## 7b. Compliance table and report
|
|
71
|
+
|
|
72
|
+
Fill one row per endpoint before writing findings; a blank cell is a finding.
|
|
73
|
+
|
|
74
|
+
| Endpoint | Permission | Identity | Tenant source | Mutation guard | Body bounds | Tests |
|
|
75
|
+
| ------------------------------- | ---------------------------- | ----------------------------- | ---------------------- | ----------------------------- | ----------------------------------------- | ------------------- |
|
|
76
|
+
| `POST /api/inventory/locations` | `inventory.locations.manage` | `endpointIdentityFromContext` | `principalFromContext` | `sessionMutationDenial` first | `readJsonObject`, `requiredString` max 32 | 401, 403, CSRF, 400 |
|
|
77
|
+
|
|
78
|
+
Report each finding as: severity (`blocker`, `should-fix`, `taste`), claim, `file:line`, the concrete scenario (who sends what, what happens), the rule (`AGENTS.md` number), the fix. Finish with a verdict: `approved` or `changes-required`. Do not fix code in the review run.
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
blocker Tenant id read from body modules/inventory/src/api/endpoints.ts:41
|
|
82
|
+
A member of tenant A posts { tenantId: "B" } and creates a location in B.
|
|
83
|
+
AGENTS.md 6. Fix: principalFromContext(octane)!.tenantId; drop the field.
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## 8. Known platform gaps to keep in mind (not module defects)
|
|
87
|
+
|
|
88
|
+
The sandbox server (`packages/sandbox/src/server/routes.ts`) has routes without authorization or CSRF, and the session id parameter is joined into paths unvalidated; the sign-in limiter is keyed on email plus `user-agent` (`modules/auth/src/server/endpoints.ts`, `limiterKey`); `users.members.manage` can create an owner because `role` comes from the body (`modules/users/src/api/endpoints.ts`); `emailConfirmation` does not gate sign-in; there are no security headers or a global body limit. A module review does not fix these; name them when a change touches the same area.
|
|
89
|
+
|
|
90
|
+
## Pitfalls
|
|
91
|
+
|
|
92
|
+
- `principalFromContext(octane)!` before `resolveIdentity` ran is a null dereference on a public route.
|
|
93
|
+
- A GET that mutates skips `sessionMutationDenial`; mutations are POST or PUT.
|
|
94
|
+
- A `secret: true` setting is write-only through `/api/settings/update`; a module never returns a setting value to the client unless its declaration says `client: true`.
|
|
95
|
+
- Matching a unique violation by message text is the accepted pattern, but the string must include the table name (`<table>.tenant_id`).
|
|
96
|
+
- An `Alert` with the raw server message is fine because the server already returns safe messages; never include the response body of a 500 verbatim.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: auto-review
|
|
3
|
+
description: >-
|
|
4
|
+
Review a finished core or module change against its requirements, public
|
|
5
|
+
contracts and executable regression evidence before delivery. Report defects
|
|
6
|
+
with failure scenarios; never approve an unverified change.
|
|
7
|
+
roles:
|
|
8
|
+
- module-executor
|
|
9
|
+
- reviewer
|
|
10
|
+
- backend-engineer
|
|
11
|
+
- frontend-engineer
|
|
12
|
+
- ux-designer
|
|
13
|
+
- agentic-engineer
|
|
14
|
+
when: Implementation is complete, before final handoff, sandbox eject, or a core PR.
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Auto-review
|
|
18
|
+
|
|
19
|
+
This is a separate review phase after implementation. Read the owning code, the
|
|
20
|
+
complete change including additions and deletions, its callers, requirements and
|
|
21
|
+
tests. Preserve unrelated edits. Do not load other skills during this phase.
|
|
22
|
+
Do not modify production code, tests, specifications or generated files. Findings
|
|
23
|
+
return to the implementation phase; every later edit requires another review.
|
|
24
|
+
Review is a model assessment, not a guarantee of correctness or spec approval.
|
|
25
|
+
|
|
26
|
+
## Required checks
|
|
27
|
+
|
|
28
|
+
For every check, cite the relevant files and concrete evidence. Use a reasoned
|
|
29
|
+
not-applicable explanation only after inspecting the change. Generic "looks good"
|
|
30
|
+
or "tests pass" is not evidence. A missing check blocks a passing verdict.
|
|
31
|
+
|
|
32
|
+
1. **Correctness:** map each requested behavior and acceptance scenario to code
|
|
33
|
+
and an observable test. Trace invalid inputs, empty results, boundaries and
|
|
34
|
+
failure paths. Check existing behavior outside the requested change. Find
|
|
35
|
+
sibling call sites and copies that need the same fix.
|
|
36
|
+
2. **Security:** trusted principal and tenant identity, explicit permissions,
|
|
37
|
+
denial tests, CSRF for mutations, input bounds, parameterized SQL, tenant
|
|
38
|
+
predicates and forced RLS, secret redaction and cross-module authority.
|
|
39
|
+
Test unauthenticated, denied and cross-tenant requests where applicable.
|
|
40
|
+
3. **Compatibility:** exports, signatures, optional fields, errors, dependency
|
|
41
|
+
direction and every consumer affected by the contract. Check manifests,
|
|
42
|
+
declared dependencies, spec/package versions and CLI-generated composition.
|
|
43
|
+
Applied migrations must remain byte-identical; check new migrations, fresh
|
|
44
|
+
apply, adoption and tenant isolation through the actual database provider.
|
|
45
|
+
4. **Lifecycle:** concurrency, cancellation, cleanup, bounded memory, resource
|
|
46
|
+
ownership, durable background work, retries, idempotency and recovery. State
|
|
47
|
+
the cost of changed loops or queries; investigate new unbounded work.
|
|
48
|
+
5. **Tests:** assertions must observe behavior, not duplicate implementation.
|
|
49
|
+
A regression test must fail with the defect restored and pass with the fix.
|
|
50
|
+
Cover relevant negative and failure cases. No skipped assertions, empty
|
|
51
|
+
suites, mocked-away ownership boundary or weakened existing checks. Record
|
|
52
|
+
actual commands, results and failures, and distinguish tests not yet run.
|
|
53
|
+
6. **UI:** when rendered behavior changes, inspect the rendered result, keyboard
|
|
54
|
+
interaction, shared components, translated copy and loading/empty/error/
|
|
55
|
+
populated/denied states. Record the inspected scenario; otherwise explain
|
|
56
|
+
why the diff has no rendered effect.
|
|
57
|
+
|
|
58
|
+
## Core and host module changes
|
|
59
|
+
|
|
60
|
+
Review only the requested change while accounting for existing workspace edits.
|
|
61
|
+
Run scoped checks first, then `pnpm verify`. For a core change also run `pnpm build`
|
|
62
|
+
(the CLI smoke and platform build exercise integration). Do not waive a failing,
|
|
63
|
+
missing or skipped required check; list unrelated existing failures separately
|
|
64
|
+
and leave verification incomplete. Re-read the final diff after generated output
|
|
65
|
+
or formatting changes. Save a concise report with files reviewed, scenario-to-test
|
|
66
|
+
mapping, commands/results, unresolved findings and remaining risks. Finish with
|
|
67
|
+
pass only when all applicable checks have evidence and no actionable defect
|
|
68
|
+
remains. Root instructions require this phase before declaring the work complete;
|
|
69
|
+
there is no host-side runtime enforcement of a model's review verdict.
|
|
70
|
+
|
|
71
|
+
## Sandbox
|
|
72
|
+
|
|
73
|
+
The orchestrator routes a failed `auto-review` gate to this skill. The turn is
|
|
74
|
+
read-only and retains the current role and active module. Inspect the whole module
|
|
75
|
+
change relative to `reference/auto-review-base/`, including deleted files, not
|
|
76
|
+
just your last edit. Preserve the intended next-specialist handoff from the
|
|
77
|
+
implementation turn after a passing review. Use the provided
|
|
78
|
+
reference code and recorded gate output. The orchestrator runs schema, dependency,
|
|
79
|
+
typecheck, tests and format gates; never claim you ran a command it ran later.
|
|
80
|
+
Report verification still pending when needed. Deterministic checks are independent
|
|
81
|
+
of your assessment and must all pass before eject.
|
|
82
|
+
|
|
83
|
+
Return exactly one fenced `auto-review` JSON object in the closing response,
|
|
84
|
+
followed by the normal handoff line. Each check is a string of 20 to 4000 characters
|
|
85
|
+
with actual evidence or a specific not-applicable explanation. Keep the response
|
|
86
|
+
under 32000 characters. The structure is:
|
|
87
|
+
|
|
88
|
+
```auto-review
|
|
89
|
+
{
|
|
90
|
+
"verdict": "fail",
|
|
91
|
+
"checks": {
|
|
92
|
+
"correctness": "Files, acceptance scenarios and observed behavior.",
|
|
93
|
+
"security": "Relevant authorization and tenant denial evidence.",
|
|
94
|
+
"compatibility": "Public consumers and migration or manifest evidence.",
|
|
95
|
+
"lifecycle": "Resource ownership and failure-path evidence.",
|
|
96
|
+
"tests": "Test paths, assertions, actual gate results or pending checks.",
|
|
97
|
+
"ui": "Rendered inspection evidence or a specific reason not applicable."
|
|
98
|
+
},
|
|
99
|
+
"findings": ["Severity; file:line; input/state; wrong outcome; required fix."]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use `pass` and an empty findings array only when no actionable defect remains.
|
|
104
|
+
Do not copy the example evidence. Include every actionable finding, not taste
|
|
105
|
+
preferences. A failing review returns to implementation; never repair files in
|
|
106
|
+
this turn. A passing record is written by the orchestrator outside the workspace
|
|
107
|
+
and bound to all module file bytes. Subsequent edits invalidate it. Old sessions
|
|
108
|
+
without a current report must run auto-review before eject. Eject rejects skipped
|
|
109
|
+
and missing gates as well as failures; a test suite with no tests fails.
|
|
110
|
+
|
|
111
|
+
Owning code: `packages/sandbox/src/server/auto-review.ts`, `turns.ts`, `gates.ts`,
|
|
112
|
+
`delivery/steps.ts`, and `packages/coding-agent/src/roles/skills.ts`.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-hunt
|
|
3
|
+
description: >-
|
|
4
|
+
Reproduce a defect with the gate runner, map the symptom to the owning layer,
|
|
5
|
+
fix it there with a failing test first, then hunt its siblings.
|
|
6
|
+
roles:
|
|
7
|
+
- backend-engineer
|
|
8
|
+
- frontend-engineer
|
|
9
|
+
- module-executor
|
|
10
|
+
when: A report, failing gate, wrong status code, blank screen, or unexpected 4xx/5xx needs a root cause rather than a patch.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Hunt a bug
|
|
14
|
+
|
|
15
|
+
## 1. Reproduce with the tools the gates use
|
|
16
|
+
|
|
17
|
+
- Server: a vitest case in `tests/module.test.ts` that builds the route and calls it directly. Recipe: `const routes = createXRoutes(auth, runtime); const route = routes.find(...)`, then `await route.handler(createContext(new Request('https://erp.example/api/x', { method: 'POST', headers: { 'content-type': 'application/json', origin: 'https://erp.example', cookie, 'x-csrf-token': csrf }, body }), {}))`. `createContext` comes from `@octanejs/app-core`; a full example with sign-up, cookie and CSRF is `modules/auth/tests/endpoints.test.ts`.
|
|
18
|
+
- Service or repository: `new XService((await createXTestDatabase()).repository)` from the module's `tests/support/database.ts` and await the method.
|
|
19
|
+
- Client logic: move the pure part into a `.ts` helper and test it; `.tsrx` files are outside `tests/**/*.ts`.
|
|
20
|
+
- Run: `pnpm --filter @flowdular/module-<dir> test` (repository root) or ask for the `tests` gate (sandbox). Keep the failing test; it becomes the regression test.
|
|
21
|
+
|
|
22
|
+
## 2. Symptom to layer
|
|
23
|
+
|
|
24
|
+
| Symptom | Where it is decided |
|
|
25
|
+
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| 401 `UNAUTHENTICATED` | `packages/server/src/endpoint.ts` (no identity from `resolveIdentity`) or `modules/auth/src/server/session-security.ts` (no session cookie on a mutation) |
|
|
27
|
+
| 403 `FORBIDDEN` | `endpoint.ts`: the permission string is not in the principal's scopes. Check `src/acl/permissions.ts` against the spec and whether `auth sync-scopes` ran |
|
|
28
|
+
| 403 `TOKEN_MUTATION_DENIED`, `CSRF_REJECTED`, `ORIGIN_REJECTED`, `CROSS_ORIGIN_REQUEST`, `ORIGIN_REQUIRED` | `sessionMutationDenial` order: API token, `assertSameOrigin` (`modules/auth/src/api/origin.ts`), cookie session, `x-csrf-token` |
|
|
29
|
+
| 415 `CONTENT_TYPE_REQUIRED`, 413 `PAYLOAD_TOO_LARGE`, 400 `INVALID_JSON` or `INVALID_INPUT` | `packages/server/src/http.ts` `readJsonObject` (16 KB cap) and `requiredString`, `requiredInteger`, `optionalString` |
|
|
30
|
+
| 409 on create | the repository maps the unique violation by SQLSTATE `23505` plus the constraint name (`.ai/references/catalog/src/services/database-repository.ts`, `create`); match the code, never the driver message text, and remember that renaming the unique index breaks the constraint check silently |
|
|
31
|
+
| 500 `INTERNAL_ERROR` | the handler threw; `endpoint.ts` logs `[requestId] endpoint <id> failed` with the error |
|
|
32
|
+
| 404 on a module route | route not mounted: `module.json` `platform.server`, `./platform` export, `src/platform.ts`, `flowdular.json` `modules.enabled`, `platform/src/generated/modules.server.ts` regenerated by `pnpm flowdular module sync --apply` |
|
|
33
|
+
| Blank shell or boot error | `packages/client/src/contributions.ts` throws on a duplicate contribution id, a navigation entry whose `viewId` has no view, or an unknown widget slot |
|
|
34
|
+
| Navigation entry missing | scope not granted (`navigationForIdentity` in `packages/client/src/shell/navigation.ts`), or `Development` group for a non-owner |
|
|
35
|
+
| View falls back to the dashboard | `ApplicationShell.tsrx` renders `overview` for a view id that no visible navigation or account menu entry reaches |
|
|
36
|
+
| Icon renders as a grid | `glyph` or `Icon name` is not an `ICON_PATHS` key (`packages/ui/src/icons/Icon.tsrx` falls back to `modules`) |
|
|
37
|
+
| Stale data after a change | each component owns a store instance (`useMemo(() => createXClientState(), [])`); check the `store.act` that should have written it. `store.commits(cb)` and `store.stats()` from `segment-state` show what was committed |
|
|
38
|
+
| Schema error on start | `runModuleMigrations`: `CHECKSUM_MISMATCH` means applied SQL bytes changed; `PARTIAL_OBJECTS` means only part of a pending migration exists. Never delete or bypass the database to hide either condition; restore the shipped bytes or diagnose the partial schema |
|
|
39
|
+
|
|
40
|
+
## 2b. Reproduction snippets
|
|
41
|
+
|
|
42
|
+
Service level, no HTTP:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { describe, expect, it } from 'vitest';
|
|
46
|
+
import { CatalogService } from '../src/services/catalog-service.ts';
|
|
47
|
+
import { createCatalogTestDatabase } from './support/database.ts';
|
|
48
|
+
|
|
49
|
+
it('rejects a sku above 64 characters with a stable code', async () => {
|
|
50
|
+
const service = new CatalogService(
|
|
51
|
+
(await createCatalogTestDatabase()).repository,
|
|
52
|
+
);
|
|
53
|
+
await expect(
|
|
54
|
+
service.create('tenant-a', {
|
|
55
|
+
sku: 'x'.repeat(70),
|
|
56
|
+
name: 'Too long',
|
|
57
|
+
kind: 'product',
|
|
58
|
+
unit: 'each',
|
|
59
|
+
basePriceMinor: 100,
|
|
60
|
+
currency: 'EUR',
|
|
61
|
+
}),
|
|
62
|
+
).rejects.toThrowError(/between 1 and 64/);
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
HTTP level, the denial path only needs the route and a bare request:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { createContext } from '@octanejs/app-core';
|
|
70
|
+
|
|
71
|
+
const [list] = createCatalogRoutes(auth, runtime);
|
|
72
|
+
const response = await list.handler(
|
|
73
|
+
createContext(new Request('https://erp.example/api/catalog/items'), {}),
|
|
74
|
+
);
|
|
75
|
+
expect(response.status).toBe(401);
|
|
76
|
+
expect(await response.json()).toMatchObject({
|
|
77
|
+
error: { code: 'UNAUTHENTICATED' },
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For a 403 or a mutation you need a principal; the recipe with sign-up, cookie and CSRF is in `test-hardening`.
|
|
82
|
+
|
|
83
|
+
## 2c. Reading gate output
|
|
84
|
+
|
|
85
|
+
- `typecheck`: the first error is usually the cause; later ones cascade. `TS2307 Cannot find module` inside a module means an undeclared package or a missing `.ts` extension.
|
|
86
|
+
- `tests`: vitest prints the failing assertion with `Expected` and `Received`; a driver error naming a column type is a value that does not fit the column (`Number.isSafeInteger` at the service boundary), and a comparison that fails on a count or a flag is usually a `BIGINT` returned as a string that skipped the repository's `integer()` helper.
|
|
87
|
+
- `format`: run `pnpm format` (or the sandbox format action); never hand-format.
|
|
88
|
+
- `dependencies`: the message lists the undeclared packages; add them to `package.json` dependencies (the session installs what `package.json` declares and nothing else). A failed `pnpm install` after a `package.json` change is reported under the same gate with the installer output.
|
|
89
|
+
- `module-schema`: `SCHEMA_ADDITIONALPROPERTIES` names a key `module.json` does not know; `MODULE_ENABLED_MISSING` means `flowdular.json` names a module without a manifest; `PLATFORM_SERVER_ENTRY_MISSING`, `PLATFORM_EXPORT_MISSING`, `PLATFORM_CLIENT_ENTRY_MISSING`, `PLATFORM_CLIENT_EXPORT_MISSING` name a composition entry the flags promise but the module lacks; `TRANSLATION_KEYS_MISMATCH` and `TRANSLATION_FILE_MISSING` are locale drift; `SPEC_VERSION_DRIFT` and `LOCALE_NOT_IN_PROJECT` are warnings.
|
|
90
|
+
|
|
91
|
+
## 3. Fix at the owning layer
|
|
92
|
+
|
|
93
|
+
Validation belongs to the HTTP helpers and the service, not to the client. Tenant scoping belongs to the repository query and the endpoint's `principalFromContext`. Presentation belongs to the view. A fix that adds a second check in a different layer hides the defect; move it instead.
|
|
94
|
+
|
|
95
|
+
Smallest change: write the failing test, make it pass, run `pnpm --filter @flowdular/module-<dir> typecheck` and `test`, and `pnpm format` when the format gate complains (the sandbox has a format action for that).
|
|
96
|
+
|
|
97
|
+
## 4. Hunt siblings
|
|
98
|
+
|
|
99
|
+
The bundled modules share one shape. After fixing `modules/<dir>`, grep the same pattern in `.ai/references/catalog`, `modules/users`, `modules/profile`, `modules/agents`, `modules/sandbox`: `grep -rn '<pattern>' modules/*/src`. Report siblings you did not fix.
|
|
100
|
+
|
|
101
|
+
## 5. Reporting
|
|
102
|
+
|
|
103
|
+
State the root cause (input and state to wrong outcome), the file and line, the regression test name, and the siblings. Do not claim a fix without the test passing where it failed before.
|
|
104
|
+
|
|
105
|
+
## Pitfalls
|
|
106
|
+
|
|
107
|
+
- The sandbox `tests` gate passes with zero tests; a green gate is not evidence.
|
|
108
|
+
- A test never points at a running deployment; it takes its database from `createPgliteTestProvider()` through the module's `tests/support/database.ts`, which runs PostgreSQL inside the test process.
|
|
109
|
+
- `principalFromContext(octane)!` is only safe after `resolveIdentity`; a public endpoint has no principal.
|
|
110
|
+
- Do not add `try/catch` that swallows the error to make a 500 disappear; map it to a stable code or let it surface.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: business-agent-design
|
|
3
|
+
description: >-
|
|
4
|
+
Ship a module-owned business agent with defineAgent, an exact tool ceiling,
|
|
5
|
+
tenant provider binding, retained revisions, and tests. Use for business
|
|
6
|
+
automation delivered by a module, not for sandbox coding specialists.
|
|
7
|
+
roles:
|
|
8
|
+
- agentic-engineer
|
|
9
|
+
- backend-engineer
|
|
10
|
+
- module-executor
|
|
11
|
+
when: A module should provide a ready business agent that tenants can configure and run.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Design a module-owned business agent
|
|
15
|
+
|
|
16
|
+
`defineAgent()` describes a business agent shipped by a module. It is the same
|
|
17
|
+
kind of business agent that appears in `agents.core`, but its behavior is owned
|
|
18
|
+
by module source. It is not a sandbox specialist, coding role, `.ai` skill, or
|
|
19
|
+
permission grant. Read `docs/adr/0007-module-owned-agents.md` and the approved
|
|
20
|
+
module spec before editing.
|
|
21
|
+
|
|
22
|
+
If a required tool is missing, pause this phase and hand it off as a separate
|
|
23
|
+
`agent-tool-design` task. A business agent can use only registered tools.
|
|
24
|
+
|
|
25
|
+
## Ownership split
|
|
26
|
+
|
|
27
|
+
The module owns:
|
|
28
|
+
|
|
29
|
+
- the stable module id and agent key;
|
|
30
|
+
- name, description, instructions, and positive definition revision;
|
|
31
|
+
- the maximum exact tool allowlist;
|
|
32
|
+
- maximum steps, timeout, temperature, and output-token limits.
|
|
33
|
+
|
|
34
|
+
The tenant owns a separate binding in `agents.core`:
|
|
35
|
+
|
|
36
|
+
- provider connection and model;
|
|
37
|
+
- active or paused state;
|
|
38
|
+
- an enabled-tool subset that can narrow the module allowlist;
|
|
39
|
+
- optimistic binding revision and the resulting executable revision.
|
|
40
|
+
|
|
41
|
+
Never put provider ids, model ids, credentials, tenant ids, or tenant-specific
|
|
42
|
+
instructions in module source. The Agents UI presents module behavior as
|
|
43
|
+
read-only and lets an authorized tenant manager configure only the binding.
|
|
44
|
+
|
|
45
|
+
## Define and register
|
|
46
|
+
|
|
47
|
+
Declare `agents.core` in both `spec/module.yaml` and `module.json` dependencies,
|
|
48
|
+
and add `"@flowdular/sdk/modules/agents": "workspace:*"` to `package.json`. Keep the
|
|
49
|
+
import server-only.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// src/agent/agents.ts
|
|
53
|
+
import { defineAgent } from '@flowdular/sdk/modules/agents/server';
|
|
54
|
+
|
|
55
|
+
export const catalogCurator = defineAgent({
|
|
56
|
+
moduleId: 'catalog.core',
|
|
57
|
+
key: 'catalog-curator',
|
|
58
|
+
definitionRevision: 1,
|
|
59
|
+
name: 'Catalog curator',
|
|
60
|
+
description: 'Reviews and normalizes catalog records.',
|
|
61
|
+
instructions:
|
|
62
|
+
'Review the requested catalog records. Use only the tools available to you.',
|
|
63
|
+
allowedTools: ['catalog.item.create', 'catalog.item.list'],
|
|
64
|
+
limits: {
|
|
65
|
+
maxSteps: 8,
|
|
66
|
+
timeoutMs: 120_000,
|
|
67
|
+
temperature: 0.2,
|
|
68
|
+
maxOutputTokens: 4_096,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const catalogBusinessAgents = [catalogCurator] as const;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// src/platform.ts, during createServerComposition
|
|
77
|
+
context.agentDefinitions.register(catalogBusinessAgents);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Registration happens during composition. The platform seals
|
|
81
|
+
`agentDefinitions` before any module `start()` hook. A malformed definition,
|
|
82
|
+
duplicate id, wildcard tool, registration after sealing, code downgrade, or
|
|
83
|
+
same-revision content drift fails boot. Do not catch and hide these errors.
|
|
84
|
+
|
|
85
|
+
`defineAgent()` derives the opaque id
|
|
86
|
+
`module-agent:<moduleId>:<key>`, validates the fields, sorts the exact tool ids,
|
|
87
|
+
and freezes the result. Callers do not construct or parse the derived id.
|
|
88
|
+
|
|
89
|
+
## Authority is an intersection
|
|
90
|
+
|
|
91
|
+
For a module-owned agent, the tools visible to a run are exactly:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
code allowedTools
|
|
95
|
+
intersect tenant binding enabledTools
|
|
96
|
+
intersect invocation toolGrants
|
|
97
|
+
intersect registered tools allowed by the actor's saved ceiling
|
|
98
|
+
intersect registered tools allowed by the actor's live permissions
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Every id is exact. An omitted grant means no tools. `*`, prefixes, and implicit
|
|
102
|
+
all-tools behavior are invalid. Every tool independently declares its
|
|
103
|
+
`requiredPermissions`; instructions and skills never grant authority. A scope
|
|
104
|
+
revoked after enqueue is rechecked before the tool body runs. The model never
|
|
105
|
+
receives `PlatformCapabilityRegistry` or direct service, repository, database,
|
|
106
|
+
shell, filesystem, or credential access.
|
|
107
|
+
|
|
108
|
+
The module allowlist is a permanent ceiling for that definition revision. The
|
|
109
|
+
tenant may reduce it, and each caller may reduce it again. A caller cannot
|
|
110
|
+
broaden it. Keep the list to the smallest surface needed for the stated job.
|
|
111
|
+
|
|
112
|
+
Mutating tools also follow the durable idempotency contract in
|
|
113
|
+
`agent-tool-design`. Do not add a write tool to a business agent until the tool
|
|
114
|
+
has its target-side ledger, transaction, replay test, and
|
|
115
|
+
`idempotencyProtection: 'target-ledger'` declaration.
|
|
116
|
+
|
|
117
|
+
## Revisions and workflows
|
|
118
|
+
|
|
119
|
+
Increase `definitionRevision` whenever any executable module-owned content
|
|
120
|
+
changes: instructions, display copy, allowed tools, or limits. Never reuse a
|
|
121
|
+
revision with different content and never decrement it.
|
|
122
|
+
|
|
123
|
+
Binding a provider or model, changing enabled tools, or reconciling a higher
|
|
124
|
+
module definition creates a new immutable tenant executable revision. Runs and
|
|
125
|
+
published workflows pin that executable revision, not the code definition or
|
|
126
|
+
mutable binding revision. Old retained revisions and audit evidence survive an
|
|
127
|
+
upgrade or module removal. A removed module-owned agent becomes unavailable for
|
|
128
|
+
new work.
|
|
129
|
+
|
|
130
|
+
An unconfigured module agent remains visible but cannot run or be published in
|
|
131
|
+
a workflow. Do not choose a provider or model automatically to make setup look
|
|
132
|
+
complete.
|
|
133
|
+
|
|
134
|
+
## Spec and files
|
|
135
|
+
|
|
136
|
+
The approved spec states:
|
|
137
|
+
|
|
138
|
+
- the business outcome and refusal conditions;
|
|
139
|
+
- each exact tool and required permission;
|
|
140
|
+
- that tenant binding cannot broaden the module ceiling;
|
|
141
|
+
- unavailable, unconfigured, revision, and module-removal behavior where
|
|
142
|
+
relevant.
|
|
143
|
+
|
|
144
|
+
Typical files are:
|
|
145
|
+
|
|
146
|
+
- `src/agent/agents.ts` for definitions;
|
|
147
|
+
- `src/agent/tools.ts` for module tools;
|
|
148
|
+
- `src/platform.ts` for both registry calls;
|
|
149
|
+
- `tests/business-agents.test.ts` and `tests/agent-tools.test.ts`;
|
|
150
|
+
- `spec/module.yaml`, `module.json`, and `package.json` for dependencies and
|
|
151
|
+
the coordinated version bump.
|
|
152
|
+
|
|
153
|
+
## Tests
|
|
154
|
+
|
|
155
|
+
The business module proves:
|
|
156
|
+
|
|
157
|
+
1. The definition has the expected derived id, ownership, revision, limits,
|
|
158
|
+
and exact sorted tool ceiling, and is frozen.
|
|
159
|
+
2. Every allowed tool is registered by the module or a declared dependency.
|
|
160
|
+
|
|
161
|
+
The shared `agents.core` integration suite proves:
|
|
162
|
+
|
|
163
|
+
1. A tenant binding can reduce tools but cannot add one outside the code
|
|
164
|
+
ceiling.
|
|
165
|
+
2. A run without an invocation grant or required live scope never calls the
|
|
166
|
+
tool body and records a denial.
|
|
167
|
+
3. Two tenants can bind different providers, models, and tool subsets without
|
|
168
|
+
seeing each other's binding or runs.
|
|
169
|
+
4. A higher definition revision retains the old executable revision; a
|
|
170
|
+
downgrade and same-revision drift refuse startup.
|
|
171
|
+
5. Module absence blocks new runs while retained run and workflow evidence
|
|
172
|
+
remains readable.
|
|
173
|
+
|
|
174
|
+
Use the module's isolated test provider for persistence tests. The end-to-end access intersection
|
|
175
|
+
belongs in `modules/agents/tests`, while a business module proves its own
|
|
176
|
+
definition and tool behavior locally. Do not edit `agents.core` merely to
|
|
177
|
+
duplicate its platform contract tests. Run the module tests, typecheck, spec
|
|
178
|
+
and module validation, then `pnpm verify` before delivery.
|
|
179
|
+
|
|
180
|
+
## Refuse
|
|
181
|
+
|
|
182
|
+
- Treating a sandbox coding specialist as a business agent definition.
|
|
183
|
+
- Letting a tenant edit module-owned instructions or the code tool ceiling.
|
|
184
|
+
- Wildcard tools, tenant ids in model input, or authority derived from prompts.
|
|
185
|
+
- Code-pinned provider connections, models, credentials, or secrets.
|
|
186
|
+
- Registration outside `createServerComposition` or after registry sealing.
|
|
187
|
+
- A write tool without target-side durable idempotency.
|
|
188
|
+
- Reusing a definition revision after changing executable content.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cli-extension
|
|
3
|
+
description: >-
|
|
4
|
+
Add a module-owned CLI command through commands.json and defineCliExtension,
|
|
5
|
+
with the namespace, risk, approval, and dry-run rules the runner enforces.
|
|
6
|
+
roles:
|
|
7
|
+
- backend-engineer
|
|
8
|
+
- module-executor
|
|
9
|
+
- reviewer
|
|
10
|
+
when: A module needs an operator command (status, export, grant, verify) reachable as pnpm flowdular <namespace> <action>.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Add a module CLI command
|
|
14
|
+
|
|
15
|
+
Examples to copy: `modules/agents/src/cli/{commands.json,index.ts}` (read plus a `localOnly` verifier) and `modules/auth/src/cli/{commands.json,index.ts}` (`process` with dry run, `destructive` with confirmation). Small template: `.ai/examples/customer-cli-extension`.
|
|
16
|
+
|
|
17
|
+
## 1. Declare the capability
|
|
18
|
+
|
|
19
|
+
`module.json`: add `"cli"` to `capabilities` and
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
"cli": { "catalog": "src/cli/commands.json", "entry": "src/cli/index.ts" }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`packages/contracts/schemas/module.schema.json` requires the `cli` block when the capability is present and the capability when the block is present. The spec `capabilities` list gets `cli` too.
|
|
26
|
+
|
|
27
|
+
## 2. Catalog: `src/cli/commands.json`
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"protocolVersion": 1,
|
|
32
|
+
"moduleId": "inventory.core",
|
|
33
|
+
"commands": [
|
|
34
|
+
{
|
|
35
|
+
"path": ["inventory", "export"],
|
|
36
|
+
"capability": {
|
|
37
|
+
"id": "inventory.export",
|
|
38
|
+
"version": 1,
|
|
39
|
+
"summary": "Export tenant-scoped stock locations to a workspace path.",
|
|
40
|
+
"risk": "workspace-write",
|
|
41
|
+
"requiresApprovedSpec": true,
|
|
42
|
+
"supportsDryRun": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Rules enforced by `packages/cli/src/extensions.ts` (`validateCliCatalog`, `loadCliExtensions`):
|
|
50
|
+
|
|
51
|
+
- `moduleId` equals `module.json` `id`; the module must be enabled in `flowdular.json`, otherwise its commands do not load.
|
|
52
|
+
- `path` has at least two segments matching `^[a-z][a-z0-9-]*$`; the first segment equals the first segment of the module id (`inventory` for `inventory.core`) and is not a reserved group (`help`, `doctor`, `capability`, `spec`, `blueprint`, `module`, `setup`).
|
|
53
|
+
- `capability.id` starts with `<namespace>.`, is unique across all enabled modules, `version` is an integer >= 1, `summary` 1 to 240 characters.
|
|
54
|
+
- `risk` is one of `read`, `workspace-write`, `process`, `external`, `destructive`. A `destructive` capability with `localOnly: true` must also set `confirmation` (`^[a-z][a-z0-9-]{2,63}$`) and `supportsDryRun: true` (schema `allOf` in `cli-extension.schema.json`).
|
|
55
|
+
|
|
56
|
+
## 3. Implementation: `src/cli/index.ts`
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { defineCliExtension } from '@flowdular/sdk/cli-protocol';
|
|
60
|
+
|
|
61
|
+
export const cliExtension = defineCliExtension({
|
|
62
|
+
protocolVersion: 1,
|
|
63
|
+
moduleId: 'inventory.core',
|
|
64
|
+
commands: [
|
|
65
|
+
{
|
|
66
|
+
path: ['inventory', 'export'],
|
|
67
|
+
capability: {
|
|
68
|
+
id: 'inventory.export',
|
|
69
|
+
version: 1,
|
|
70
|
+
summary: 'Export tenant-scoped stock locations to a workspace path.',
|
|
71
|
+
risk: 'workspace-write' as const,
|
|
72
|
+
requiresApprovedSpec: true,
|
|
73
|
+
supportsDryRun: true,
|
|
74
|
+
},
|
|
75
|
+
execute: async (context) => ({
|
|
76
|
+
data: {
|
|
77
|
+
applied: context.apply,
|
|
78
|
+
target: context.arguments[0] ?? 'json',
|
|
79
|
+
},
|
|
80
|
+
evidence: ['modules/inventory/spec/module.yaml'],
|
|
81
|
+
warnings: context.apply ? [] : ['Dry run only.'],
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export default cliExtension;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`execute(context: { workspaceRoot, moduleRoot, apply, flags: ReadonlyMap<string, string | boolean>, arguments: readonly string[] })` returns `{ data, evidence?, warnings? }` (`packages/cli-protocol/src/index.ts`). The loader (`loadCliCommand`) imports the entry only when the command runs, accepts a `default` or `cliExtension` export, and refuses when `path` or the whole `capability` object differs from the catalog (`commandKey` compares the JSON). Keep both files metadata-identical, down to the summary text. Declare `@flowdular/sdk/cli-protocol` in `package.json`. Read module data through the module's own runtime (`xRuntimeOptionsFromEnvironment(process.env, context.workspaceRoot)` then the service), as `modules/agents/src/cli/index.ts` does; never through another module's database.
|
|
91
|
+
|
|
92
|
+
## 4. What the runner does with the descriptor (`packages/cli/src/runner.ts`, `runExtensionCommand`)
|
|
93
|
+
|
|
94
|
+
- `risk: 'external'`: refused with `APPROVAL_VERIFIER_REQUIRED`. `risk: 'destructive'` without `localOnly`: the same.
|
|
95
|
+
- `localOnly: true`: refused with `LOCAL_ONLY_CAPABILITY` unless `FD_ENV` or `NODE_ENV` is `development` or `test` (unset counts as development).
|
|
96
|
+
- `requiresApprovedSpec: true`: needs `--spec <path>` to a schema-valid spec with `status: approved`, otherwise `APPROVED_SPEC_REQUIRED`, `SPEC_VALIDATION_FAILED` or `SPEC_NOT_APPROVED`.
|
|
97
|
+
- `destructive` with `--apply`: needs `--confirm <confirmation>` (`CONFIRMATION_REQUIRED`).
|
|
98
|
+
- Non-read without `supportsDryRun` and without `--apply`: `EXPLICIT_APPLY_REQUIRED`. Non-read with dry run support and no `--apply` runs with `apply: false` and appends the warning `Dry run only. No writes were authorized.`
|
|
99
|
+
- Invocation: `pnpm flowdular inventory export --apply` or `pnpm flowdular capability run inventory.export --apply`; `arguments` are the positionals after the path (or after `capability run <id>`); flags are `--name value`, `--name=value`, or `--flag` (`packages/cli/src/arguments.ts`). `pnpm flowdular capability list` and `describe <id>` show the descriptor; `pnpm flowdular help` lists module paths.
|
|
100
|
+
|
|
101
|
+
## 5. Tests
|
|
102
|
+
|
|
103
|
+
`packages/cli/tests/extensions.test.ts` shows the style: call `validateCliCatalog(catalog, manifest)` with a good catalog and with a path that claims a reserved group, assert the error text. In the module, test `execute` directly with a hand-built context (`apply: false` returns the dry-run shape, `apply: true` writes inside `context.workspaceRoot` only). Then `pnpm flowdular module validate --json` and `pnpm flowdular help` (the new path appears once the module is enabled).
|
|
104
|
+
|
|
105
|
+
## 6. Landing
|
|
106
|
+
|
|
107
|
+
Sandbox sessions strip `cli` from other modules' manifests and do not run module commands; the CLI parts of a module are exercised after eject or at the repository root. Both paths end with `pnpm verify` and a PR; `.ai/policies/capabilities.yaml` lists module capabilities, add yours.
|
|
108
|
+
|
|
109
|
+
## Pitfalls
|
|
110
|
+
|
|
111
|
+
- A `summary` edited in one file only: `CLI implementation for "inventory export" does not match its catalog.`
|
|
112
|
+
- Two enabled modules claiming the same `path` or capability id: `CLI command collision`.
|
|
113
|
+
- `risk: 'read'` commands run without `--apply`; anything that writes must not be `read`.
|
|
114
|
+
- Commands run in the developer's process with the full environment; never print secrets in `data`.
|