@flowdular/sdk 0.2.4 → 0.3.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/sandbox/business-manager.md +5 -1
- package/.ai/blueprints/author-spec/README.md +1 -1
- package/.ai/blueprints/author-spec/spec-requirements.yaml +44 -0
- package/.ai/blueprints/author-spec/steps.yaml +5 -5
- package/.ai/blueprints/author-spec/templates/module.yaml +99 -3
- package/.ai/blueprints/edit-module/gates.yaml +4 -0
- package/.ai/blueprints/edit-module/required-files.yaml +9 -0
- package/.ai/blueprints/new-module/gates.yaml +4 -0
- package/.ai/blueprints/new-module/spec-requirements.yaml +2 -2
- package/.ai/blueprints/release/gates.yaml +4 -0
- package/.ai/platform-capabilities.md +128 -0
- package/.ai/policies/capabilities.yaml +100 -0
- package/.ai/policies/path-ownership.yaml +5 -2
- package/.ai/policies/task-budgets.yaml +5 -3
- package/.ai/references/catalog/module.json +4 -4
- package/.ai/references/catalog/package.json +2 -2
- package/.ai/references/catalog/spec/module.yaml +5 -3
- package/.ai/references/catalog/src/platform.ts +2 -0
- package/.ai/references/catalog/src/services/catalog-service.ts +89 -1
- package/.ai/references/catalog/src/services/data-classes.ts +47 -0
- package/.ai/references/catalog/src/services/database-repository.ts +98 -1
- package/.ai/references/catalog/src/services/repository.ts +22 -1
- package/.ai/references/catalog/tests/data-classes.test.ts +157 -0
- package/.ai/references/catalog.provenance.json +12 -10
- package/.ai/skills/README.md +10 -0
- package/.ai/skills/agent-tool-design/SKILL.md +1 -2
- package/.ai/skills/auth-security-review/SKILL.md +1 -1
- package/.ai/skills/business-agent-design/SKILL.md +0 -1
- package/.ai/skills/deploy-operate/SKILL.md +114 -0
- package/.ai/skills/module-new/SKILL.md +29 -3
- package/.ai/skills/module-update/SKILL.md +9 -3
- package/.ai/skills/perf-audit/SKILL.md +0 -1
- package/.ai/skills/release-eject-pr/SKILL.md +0 -1
- package/.ai/skills/spec-interview/SKILL.md +120 -0
- package/.ai/skills/test-hardening/SKILL.md +1 -0
- package/.ai/skills/ux-design/SKILL.md +34 -3
- package/.ai/skills/variables/SKILL.md +0 -2
- package/.ai/skills/workflow-development/SKILL.md +0 -1
- package/AGENTS.md +4 -0
- package/docs/agent-contract.md +2 -2
- package/docs/design-system.md +185 -31
- package/modules/access/migrations/0001_access_core.down.sql +1 -0
- package/modules/access/migrations/0001_access_core.up.sql +28 -0
- package/modules/access/migrations/README.md +3 -0
- package/modules/access/module.json +33 -0
- package/modules/access/package.json +43 -0
- package/modules/access/spec/module.yaml +225 -0
- package/modules/access/src/acl/permissions.ts +6 -0
- package/modules/access/src/api/endpoints.ts +244 -0
- package/modules/access/src/client/ActivityView.tsrx +245 -0
- package/modules/access/src/client/AttestationsView.tsrx +176 -0
- package/modules/access/src/client/ReviewView.tsrx +586 -0
- package/modules/access/src/client/api.ts +132 -0
- package/modules/access/src/client/contribution.tsrx +41 -0
- package/modules/access/src/client/index.ts +41 -0
- package/modules/access/src/client/navigation.ts +57 -0
- package/modules/access/src/client/presentation.ts +69 -0
- package/modules/access/src/client/state.ts +72 -0
- package/modules/access/src/domain/types.ts +189 -0
- package/modules/access/src/index.ts +38 -0
- package/modules/access/src/platform.ts +60 -0
- package/modules/access/src/server/index.ts +42 -0
- package/modules/access/src/server/runtime.ts +105 -0
- package/modules/access/src/services/access-service.ts +298 -0
- package/modules/access/src/services/audit-window.ts +78 -0
- package/modules/access/src/services/auth-directory.ts +72 -0
- package/modules/access/src/services/changes.ts +91 -0
- package/modules/access/src/services/data-classes.ts +28 -0
- package/modules/access/src/services/database-repository.ts +185 -0
- package/modules/access/src/services/directory.ts +102 -0
- package/modules/access/src/services/index.ts +33 -0
- package/modules/access/src/services/list-exports.ts +150 -0
- package/modules/access/src/services/migration.ts +54 -0
- package/modules/access/src/services/repository.ts +30 -0
- package/modules/access/src/services/review.ts +178 -0
- package/modules/access/translations/en.json +155 -0
- package/modules/access/translations/pl.json +155 -0
- package/modules/agents/migrations/0022_credential_rotation_inventory.down.sql +2 -0
- package/modules/agents/migrations/0022_credential_rotation_inventory.up.sql +7 -0
- package/modules/agents/migrations/0023_agents_retention_indexes.down.sql +2 -0
- package/modules/agents/migrations/0023_agents_retention_indexes.up.sql +9 -0
- package/modules/agents/migrations/0024_agent_meter_refusals.down.sql +3 -0
- package/modules/agents/migrations/0024_agent_meter_refusals.up.sql +22 -0
- package/modules/agents/migrations/0025_agent_list_indexes.down.sql +3 -0
- package/modules/agents/migrations/0025_agent_list_indexes.up.sql +11 -0
- package/modules/agents/module.json +30 -4
- package/modules/agents/package.json +2 -1
- package/modules/agents/spec/module.yaml +63 -5
- package/modules/agents/src/api/endpoints.ts +291 -33
- package/modules/agents/src/cli/commands.json +11 -0
- package/modules/agents/src/cli/index.ts +45 -0
- package/modules/agents/src/client/AgentDashboardWidget.tsrx +19 -11
- package/modules/agents/src/client/AgentDefinitionList.tsrx +53 -10
- package/modules/agents/src/client/AgentPlaygroundView.tsrx +4 -4
- package/modules/agents/src/client/AgentProceduresView.tsrx +2 -2
- package/modules/agents/src/client/AgentRunsView.tsrx +143 -40
- package/modules/agents/src/client/AgentsView.tsrx +109 -33
- package/modules/agents/src/client/api.ts +99 -21
- package/modules/agents/src/client/state.ts +97 -0
- package/modules/agents/src/domain/types.ts +44 -4
- package/modules/agents/src/platform.ts +42 -0
- package/modules/agents/src/server/action-execution.ts +201 -106
- package/modules/agents/src/server/runtime.ts +32 -0
- package/modules/agents/src/services/agent-service.ts +158 -30
- package/modules/agents/src/services/credential-rotation.ts +185 -0
- package/modules/agents/src/services/credential-vault.ts +71 -46
- package/modules/agents/src/services/data-classes.ts +176 -0
- package/modules/agents/src/services/database-repository.ts +393 -101
- package/modules/agents/src/services/metering.ts +111 -0
- package/modules/agents/src/services/migration.ts +109 -0
- package/modules/agents/src/services/module-agent-preflight.ts +17 -9
- package/modules/agents/src/services/notifications.ts +98 -0
- package/modules/agents/src/services/provider-repository.ts +9 -18
- package/modules/agents/src/services/provider-service.ts +1 -9
- package/modules/agents/src/services/reports.ts +107 -0
- package/modules/agents/src/services/repository.ts +86 -6
- package/modules/agents/src/services/usage-service.ts +2 -0
- package/modules/agents/src/services/worker.ts +114 -4
- package/modules/agents/src/settings.ts +14 -3
- package/modules/agents/translations/en.json +14 -4
- package/modules/agents/translations/pl.json +14 -4
- package/modules/approvals/migrations/0001_approvals_core.down.sql +3 -0
- package/modules/approvals/migrations/0001_approvals_core.up.sql +78 -0
- package/modules/approvals/migrations/0002_approvals_expiry_routing_role.down.sql +2 -0
- package/modules/approvals/migrations/0002_approvals_expiry_routing_role.up.sql +19 -0
- package/modules/approvals/migrations/0003_approvals_retention_indexes.down.sql +6 -0
- package/modules/approvals/migrations/0003_approvals_retention_indexes.up.sql +14 -0
- package/modules/approvals/migrations/0004_approvals_inbox_keyset_indexes.down.sql +5 -0
- package/modules/approvals/migrations/0004_approvals_inbox_keyset_indexes.up.sql +12 -0
- package/modules/approvals/migrations/README.md +3 -0
- package/modules/approvals/module.json +34 -0
- package/modules/approvals/package.json +43 -0
- package/modules/approvals/spec/module.yaml +318 -0
- package/modules/approvals/src/acl/permissions.ts +7 -0
- package/modules/approvals/src/api/endpoints.ts +457 -0
- package/modules/approvals/src/client/ApprovalRequestDrawer.tsrx +138 -0
- package/modules/approvals/src/client/ApprovalsView.tsrx +562 -0
- package/modules/approvals/src/client/PendingCountWidget.tsrx +52 -0
- package/modules/approvals/src/client/api.ts +203 -0
- package/modules/approvals/src/client/approvals.css +51 -0
- package/modules/approvals/src/client/contribution.tsrx +44 -0
- package/modules/approvals/src/client/index.ts +26 -0
- package/modules/approvals/src/client/navigation.ts +39 -0
- package/modules/approvals/src/client/pending-count.ts +26 -0
- package/modules/approvals/src/client/presentation.ts +52 -0
- package/modules/approvals/src/client/state.ts +141 -0
- package/modules/approvals/src/domain/capability.ts +95 -0
- package/modules/approvals/src/domain/types.ts +154 -0
- package/modules/approvals/src/index.ts +52 -0
- package/modules/approvals/src/platform.ts +128 -0
- package/modules/approvals/src/server/index.ts +42 -0
- package/modules/approvals/src/server/runtime.ts +181 -0
- package/modules/approvals/src/services/approvals-service.ts +557 -0
- package/modules/approvals/src/services/callbacks.ts +75 -0
- package/modules/approvals/src/services/data-classes.ts +167 -0
- package/modules/approvals/src/services/database-repository.ts +724 -0
- package/modules/approvals/src/services/eligibility.ts +121 -0
- package/modules/approvals/src/services/expiry-runner.ts +81 -0
- package/modules/approvals/src/services/index.ts +31 -0
- package/modules/approvals/src/services/migration.ts +222 -0
- package/modules/approvals/src/services/notifications.ts +95 -0
- package/modules/approvals/src/services/repository.ts +161 -0
- package/modules/approvals/src/services/service-error.ts +70 -0
- package/modules/approvals/src/settings.ts +102 -0
- package/modules/approvals/translations/en.json +104 -0
- package/modules/approvals/translations/pl.json +104 -0
- package/modules/audit/migrations/0001_audit_core.down.sql +8 -0
- package/modules/audit/migrations/0001_audit_core.up.sql +107 -0
- package/modules/audit/migrations/0002_audit_sweep_routing_role.down.sql +2 -0
- package/modules/audit/migrations/0002_audit_sweep_routing_role.up.sql +21 -0
- package/modules/audit/migrations/0003_audit_export_request.down.sql +12 -0
- package/modules/audit/migrations/0003_audit_export_request.up.sql +40 -0
- package/modules/audit/migrations/0004_audit_hold_seal_erasure.down.sql +17 -0
- package/modules/audit/migrations/0004_audit_hold_seal_erasure.up.sql +192 -0
- package/modules/audit/migrations/0005_audit_event_format.down.sql +17 -0
- package/modules/audit/migrations/0005_audit_event_format.up.sql +60 -0
- package/modules/audit/migrations/0006_audit_own_class_walks.down.sql +3 -0
- package/modules/audit/migrations/0006_audit_own_class_walks.up.sql +14 -0
- package/modules/audit/migrations/README.md +3 -0
- package/modules/audit/module.json +32 -0
- package/modules/audit/package.json +49 -0
- package/modules/audit/spec/module.yaml +809 -0
- package/modules/audit/src/acl/permissions.ts +7 -0
- package/modules/audit/src/api/endpoints.ts +315 -0
- package/modules/audit/src/cli/commands.json +95 -0
- package/modules/audit/src/cli/index.ts +658 -0
- package/modules/audit/src/client/DataClassesView.tsrx +420 -0
- package/modules/audit/src/client/ExportsView.tsrx +256 -0
- package/modules/audit/src/client/HoldsView.tsrx +604 -0
- package/modules/audit/src/client/SweepsView.tsrx +251 -0
- package/modules/audit/src/client/api.ts +185 -0
- package/modules/audit/src/client/contribution.tsrx +52 -0
- package/modules/audit/src/client/index.ts +23 -0
- package/modules/audit/src/client/navigation.ts +74 -0
- package/modules/audit/src/client/presentation.ts +105 -0
- package/modules/audit/src/client/state.ts +86 -0
- package/modules/audit/src/domain/data-classes.ts +16 -0
- package/modules/audit/src/domain/types.ts +339 -0
- package/modules/audit/src/index.ts +76 -0
- package/modules/audit/src/platform.ts +44 -0
- package/modules/audit/src/server/index.ts +177 -0
- package/modules/audit/src/server/runtime.ts +303 -0
- package/modules/audit/src/services/anchor-key.ts +143 -0
- package/modules/audit/src/services/anchor-rotation.ts +147 -0
- package/modules/audit/src/services/audit-runners.ts +278 -0
- package/modules/audit/src/services/backup-guard.ts +95 -0
- package/modules/audit/src/services/database-repository.ts +1946 -0
- package/modules/audit/src/services/declared-classes.ts +64 -0
- package/modules/audit/src/services/erasure-port.ts +126 -0
- package/modules/audit/src/services/erasure-service.ts +770 -0
- package/modules/audit/src/services/export-directory.ts +106 -0
- package/modules/audit/src/services/export-service.ts +714 -0
- package/modules/audit/src/services/hold-service.ts +295 -0
- package/modules/audit/src/services/index.ts +17 -0
- package/modules/audit/src/services/migration.ts +658 -0
- package/modules/audit/src/services/own-classes.ts +318 -0
- package/modules/audit/src/services/platform-version.ts +23 -0
- package/modules/audit/src/services/repository.ts +495 -0
- package/modules/audit/src/services/retention-service.ts +191 -0
- package/modules/audit/src/services/seal-service.ts +769 -0
- package/modules/audit/src/services/service-error.ts +61 -0
- package/modules/audit/src/services/subject-keys.ts +90 -0
- package/modules/audit/src/services/sweep-service.ts +298 -0
- package/modules/audit/src/services/zip.ts +217 -0
- package/modules/audit/src/settings.ts +69 -0
- package/modules/audit/translations/en.json +210 -0
- package/modules/audit/translations/pl.json +210 -0
- package/modules/auth/README.md +77 -29
- package/modules/auth/migrations/0016_external_identities.up.sql +16 -0
- package/modules/auth/migrations/0017_mfa_key_id.up.sql +8 -0
- package/modules/auth/migrations/0018_retire_bundled_module_scopes.up.sql +29 -0
- package/modules/auth/migrations/0019_notifications_member_scopes.up.sql +44 -0
- package/modules/auth/migrations/0020_identity_providers.up.sql +61 -0
- package/modules/auth/migrations/0021_membership_status.up.sql +19 -0
- package/modules/auth/migrations/0022_auth_provider_scopes.up.sql +45 -0
- package/modules/auth/migrations/0023_enterprise_module_scopes.down.sql +19 -0
- package/modules/auth/migrations/0023_enterprise_module_scopes.up.sql +71 -0
- package/modules/auth/migrations/0024_approvals_member_scopes.down.sql +22 -0
- package/modules/auth/migrations/0024_approvals_member_scopes.up.sql +48 -0
- package/modules/auth/migrations/0025_audit_holds_owner_scope.down.sql +21 -0
- package/modules/auth/migrations/0025_audit_holds_owner_scope.up.sql +47 -0
- package/modules/auth/migrations/0026_auth_export_keyset_indexes.down.sql +6 -0
- package/modules/auth/migrations/0026_auth_export_keyset_indexes.up.sql +15 -0
- package/modules/auth/migrations/0027_workflow_automation_profile_scopes.down.sql +34 -0
- package/modules/auth/migrations/0027_workflow_automation_profile_scopes.up.sql +72 -0
- package/modules/auth/migrations/0028_auth_member_search_prefix_indexes.down.sql +6 -0
- package/modules/auth/migrations/0028_auth_member_search_prefix_indexes.up.sql +21 -0
- package/modules/auth/migrations/0029_reports_exports_access_scopes.down.sql +22 -0
- package/modules/auth/migrations/0029_reports_exports_access_scopes.up.sql +56 -0
- package/modules/auth/migrations/0030_auth_membership_keyset_index.down.sql +4 -0
- package/modules/auth/migrations/0030_auth_membership_keyset_index.up.sql +10 -0
- package/modules/auth/migrations/0031_membership_scope_backfills_under_rls.down.sql +4 -0
- package/modules/auth/migrations/0031_membership_scope_backfills_under_rls.up.sql +31 -0
- package/modules/auth/migrations/0032_audit_actor_service.down.sql +9 -0
- package/modules/auth/migrations/0032_audit_actor_service.up.sql +10 -0
- package/modules/auth/migrations/0033_auth_account_keyset_indexes.down.sql +5 -0
- package/modules/auth/migrations/0033_auth_account_keyset_indexes.up.sql +23 -0
- package/modules/auth/module.json +3 -3
- package/modules/auth/package.json +2 -1
- package/modules/auth/spec/module.yaml +372 -3
- package/modules/auth/src/acl/scopes.ts +50 -6
- package/modules/auth/src/cli/commands.json +11 -0
- package/modules/auth/src/cli/greenfield.ts +2 -2
- package/modules/auth/src/cli/index.ts +14 -0
- package/modules/auth/src/cli/secrets.ts +114 -0
- package/modules/auth/src/client/AuthenticationCore.tsrx +61 -8
- package/modules/auth/src/client/api.ts +72 -6
- package/modules/auth/src/client/contribution.tsrx +23 -0
- package/modules/auth/src/client/index.ts +6 -0
- package/modules/auth/src/client/providers/IdentityProviderForm.tsrx +191 -0
- package/modules/auth/src/client/providers/IdentityProvidersView.tsrx +358 -0
- package/modules/auth/src/client/providers/api.ts +128 -0
- package/modules/auth/src/client/providers/provider-columns.tsrx +60 -0
- package/modules/auth/src/client/providers/state.ts +35 -0
- package/modules/auth/src/client/security/SecurityView.tsrx +9 -1
- package/modules/auth/src/client/state.ts +15 -1
- package/modules/auth/src/domain/types.ts +55 -0
- package/modules/auth/src/index.ts +11 -1
- package/modules/auth/src/middleware/authentication.ts +4 -0
- package/modules/auth/src/server/endpoints.ts +467 -171
- package/modules/auth/src/server/http.ts +3 -2
- package/modules/auth/src/server/index.ts +22 -1
- package/modules/auth/src/server/membership-endpoints.ts +62 -0
- package/modules/auth/src/server/mfa-enforcement.ts +156 -0
- package/modules/auth/src/server/oidc.ts +389 -0
- package/modules/auth/src/server/provider-endpoints.ts +246 -0
- package/modules/auth/src/server/provider-host.ts +77 -0
- package/modules/auth/src/server/runtime.ts +231 -55
- package/modules/auth/src/services/auth-service-error.ts +7 -2
- package/modules/auth/src/services/auth-service.ts +948 -51
- package/modules/auth/src/services/data-classes.ts +236 -0
- package/modules/auth/src/services/database-repository.ts +853 -71
- package/modules/auth/src/services/identity-provider-service.ts +571 -0
- package/modules/auth/src/services/mail-delivery.ts +16 -16
- package/modules/auth/src/services/mail-message.ts +54 -0
- package/modules/auth/src/services/mail-port.ts +24 -0
- package/modules/auth/src/services/mail-smtp.ts +85 -0
- package/modules/auth/src/services/mfa-rotation.ts +144 -0
- package/modules/auth/src/services/migration.ts +810 -0
- package/modules/auth/src/services/password.ts +14 -0
- package/modules/auth/src/services/provider-secret-rotation.ts +169 -0
- package/modules/auth/src/services/provider-secrets.ts +136 -0
- package/modules/auth/src/services/repository.ts +321 -5
- package/modules/auth/src/services/session-sweep-runner.ts +73 -0
- package/modules/auth/src/services/settings-store.ts +10 -83
- package/modules/auth/src/services/totp.ts +88 -62
- package/modules/auth/src/services/validation.ts +194 -7
- package/modules/auth/src/settings.ts +18 -0
- package/modules/auth/translations/en.json +84 -1
- package/modules/auth/translations/pl.json +84 -1
- package/modules/automations/migrations/0005_secret_rotation_inventory.down.sql +1 -0
- package/modules/automations/migrations/0005_secret_rotation_inventory.up.sql +6 -0
- package/modules/automations/migrations/0006_automations_list_sort_indexes.down.sql +4 -0
- package/modules/automations/migrations/0006_automations_list_sort_indexes.up.sql +11 -0
- package/modules/automations/module.json +24 -6
- package/modules/automations/package.json +4 -1
- package/modules/automations/spec/module.yaml +81 -7
- package/modules/automations/src/api/endpoints.ts +202 -28
- package/modules/automations/src/cli/commands.json +17 -0
- package/modules/automations/src/cli/index.ts +114 -0
- package/modules/automations/src/client/AutomationScheduleForm.tsrx +77 -19
- package/modules/automations/src/client/AutomationSchedulesView.tsrx +144 -40
- package/modules/automations/src/client/AutomationTriggersView.tsrx +131 -32
- package/modules/automations/src/client/api.ts +62 -19
- package/modules/automations/src/client/presentation.ts +20 -2
- package/modules/automations/src/client/state.ts +84 -0
- package/modules/automations/src/domain/cadence.ts +99 -3
- package/modules/automations/src/domain/cron.ts +366 -0
- package/modules/automations/src/domain/time-zone.ts +61 -0
- package/modules/automations/src/platform.ts +38 -4
- package/modules/automations/src/server/index.ts +11 -0
- package/modules/automations/src/server/runtime.ts +46 -22
- package/modules/{automations-workflows-integration/src/server/adapter.ts → automations/src/server/workflow-target.ts} +13 -14
- package/modules/{automations-workflows-integration/src/server/tools.ts → automations/src/server/workflow-tools.ts} +0 -0
- package/modules/automations/src/services/data-classes.ts +62 -0
- package/modules/automations/src/services/database-repository.ts +152 -38
- package/modules/automations/src/services/migration.ts +119 -9
- package/modules/automations/src/services/repository.ts +52 -1
- package/modules/automations/src/services/schedule-runner.ts +84 -0
- package/modules/automations/src/services/schedule-service.ts +152 -26
- package/modules/automations/src/services/secret-rotation.ts +176 -0
- package/modules/automations/src/services/secret-vault.ts +68 -41
- package/modules/automations/src/services/trigger-service.ts +13 -10
- package/modules/automations/translations/en.json +15 -2
- package/modules/automations/translations/pl.json +15 -2
- package/modules/connectors/migrations/0001_connectors_core.down.sql +3 -0
- package/modules/connectors/migrations/0001_connectors_core.up.sql +72 -0
- package/modules/connectors/migrations/0002_connectors_call_keys.down.sql +3 -0
- package/modules/connectors/migrations/0002_connectors_call_keys.up.sql +18 -0
- package/modules/connectors/migrations/README.md +3 -0
- package/modules/connectors/module.json +28 -0
- package/modules/{automations-workflows-integration → connectors}/package.json +27 -26
- package/modules/connectors/spec/module.yaml +447 -0
- package/modules/connectors/src/acl/permissions.ts +6 -0
- package/modules/connectors/src/agent/tools.ts +180 -0
- package/modules/connectors/src/api/endpoints.ts +572 -0
- package/modules/connectors/src/client/ConnectorCallsView.tsrx +358 -0
- package/modules/connectors/src/client/ConnectorForm.tsrx +424 -0
- package/modules/connectors/src/client/ConnectorsView.tsrx +711 -0
- package/modules/connectors/src/client/api.ts +281 -0
- package/modules/connectors/src/client/consent.ts +48 -0
- package/modules/connectors/src/client/contribution.tsrx +37 -0
- package/modules/connectors/src/client/index.ts +22 -0
- package/modules/connectors/src/client/navigation.ts +42 -0
- package/modules/connectors/src/client/presentation.ts +38 -0
- package/modules/connectors/src/client/state.ts +175 -0
- package/modules/connectors/src/domain/calls.ts +70 -0
- package/modules/connectors/src/domain/definitions.ts +190 -0
- package/modules/connectors/src/domain/http-json.ts +68 -0
- package/modules/connectors/src/domain/types.ts +185 -0
- package/modules/connectors/src/index.ts +64 -0
- package/modules/connectors/src/platform.ts +56 -0
- package/modules/connectors/src/server/index.ts +66 -0
- package/modules/connectors/src/server/runtime.ts +163 -0
- package/modules/connectors/src/services/call-service.ts +903 -0
- package/modules/connectors/src/services/connectors-service.ts +653 -0
- package/modules/connectors/src/services/credential-vault.ts +188 -0
- package/modules/connectors/src/services/data-classes.ts +158 -0
- package/modules/connectors/src/services/database-repository.ts +897 -0
- package/modules/connectors/src/services/egress.ts +261 -0
- package/modules/connectors/src/services/index.ts +19 -0
- package/modules/connectors/src/services/migration.ts +166 -0
- package/modules/connectors/src/services/repository.ts +175 -0
- package/modules/connectors/src/services/service-error.ts +46 -0
- package/modules/connectors/src/settings.ts +69 -0
- package/modules/connectors/translations/en.json +191 -0
- package/modules/connectors/translations/pl.json +191 -0
- package/modules/directory/migrations/0001_directory_core.down.sql +5 -0
- package/modules/directory/migrations/0001_directory_core.up.sql +111 -0
- package/modules/directory/migrations/README.md +3 -0
- package/modules/directory/module.json +27 -0
- package/modules/directory/package.json +46 -0
- package/modules/directory/spec/module.yaml +351 -0
- package/modules/directory/src/acl/permissions.ts +7 -0
- package/modules/directory/src/api/endpoints.ts +478 -0
- package/modules/directory/src/api/scim-endpoints.ts +516 -0
- package/modules/directory/src/client/GroupMappingsView.tsrx +430 -0
- package/modules/directory/src/client/ProvisioningLogView.tsrx +248 -0
- package/modules/directory/src/client/ScimTokensView.tsrx +587 -0
- package/modules/directory/src/client/api.ts +222 -0
- package/modules/directory/src/client/contribution.tsrx +46 -0
- package/modules/directory/src/client/index.ts +22 -0
- package/modules/directory/src/client/navigation.ts +57 -0
- package/modules/directory/src/client/presentation.ts +143 -0
- package/modules/directory/src/client/state.ts +173 -0
- package/modules/directory/src/domain/scim.ts +346 -0
- package/modules/directory/src/domain/types.ts +166 -0
- package/modules/directory/src/index.ts +44 -0
- package/modules/directory/src/platform.ts +43 -0
- package/modules/directory/src/server/index.ts +17 -0
- package/modules/directory/src/server/runtime.ts +124 -0
- package/modules/directory/src/services/auth-port.ts +127 -0
- package/modules/directory/src/services/data-classes.ts +41 -0
- package/modules/directory/src/services/database-repository.ts +1067 -0
- package/modules/directory/src/services/directory-service.ts +311 -0
- package/modules/directory/src/services/index.ts +43 -0
- package/modules/directory/src/services/migration.ts +146 -0
- package/modules/directory/src/services/provisioning-service.ts +1420 -0
- package/modules/directory/src/services/rate-limiter.ts +103 -0
- package/modules/directory/src/services/repository.ts +208 -0
- package/modules/directory/src/services/service-error.ts +42 -0
- package/modules/directory/src/services/token-service.ts +215 -0
- package/modules/directory/src/settings.ts +86 -0
- package/modules/directory/translations/en.json +185 -0
- package/modules/directory/translations/pl.json +185 -0
- package/modules/documents/migrations/0001_documents_core.down.sql +1 -0
- package/modules/documents/migrations/0001_documents_core.up.sql +35 -0
- package/modules/documents/migrations/0002_documents_files_page.down.sql +1 -0
- package/modules/documents/migrations/0002_documents_files_page.up.sql +6 -0
- package/modules/documents/migrations/README.md +3 -0
- package/modules/documents/module.json +28 -0
- package/modules/documents/package.json +49 -0
- package/modules/documents/spec/module.yaml +247 -0
- package/modules/documents/src/acl/permissions.ts +6 -0
- package/modules/documents/src/api/endpoints.ts +401 -0
- package/modules/documents/src/client/DocumentUploader.tsrx +148 -0
- package/modules/documents/src/client/DocumentsView.tsrx +540 -0
- package/modules/documents/src/client/api.ts +209 -0
- package/modules/documents/src/client/contribution.tsrx +29 -0
- package/modules/documents/src/client/download.ts +70 -0
- package/modules/documents/src/client/index.ts +22 -0
- package/modules/documents/src/client/navigation.ts +25 -0
- package/modules/documents/src/client/presentation.ts +110 -0
- package/modules/documents/src/client/state.ts +117 -0
- package/modules/documents/src/domain/attachments.ts +84 -0
- package/modules/documents/src/domain/types.ts +80 -0
- package/modules/documents/src/index.ts +46 -0
- package/modules/documents/src/platform.ts +61 -0
- package/modules/documents/src/server/index.ts +30 -0
- package/modules/documents/src/server/runtime.ts +107 -0
- package/modules/documents/src/services/attachments.ts +39 -0
- package/modules/documents/src/services/data-classes.ts +25 -0
- package/modules/documents/src/services/database-repository.ts +259 -0
- package/modules/documents/src/services/documents-service.ts +586 -0
- package/modules/documents/src/services/index.ts +18 -0
- package/modules/documents/src/services/migration.ts +82 -0
- package/modules/documents/src/services/repository.ts +48 -0
- package/modules/documents/src/settings.ts +107 -0
- package/modules/documents/translations/en.json +111 -0
- package/modules/documents/translations/pl.json +111 -0
- package/modules/exports/migrations/0001_exports_core.down.sql +2 -0
- package/modules/exports/migrations/0001_exports_core.up.sql +28 -0
- package/modules/exports/migrations/0002_exports_job_routing_role.down.sql +4 -0
- package/modules/exports/migrations/0002_exports_job_routing_role.up.sql +21 -0
- package/modules/exports/migrations/README.md +3 -0
- package/modules/exports/module.json +28 -0
- package/modules/exports/package.json +44 -0
- package/modules/exports/spec/module.yaml +229 -0
- package/modules/exports/src/acl/permissions.ts +6 -0
- package/modules/exports/src/api/endpoints.ts +211 -0
- package/modules/exports/src/client/ExportsView.tsrx +327 -0
- package/modules/exports/src/client/api.ts +133 -0
- package/modules/exports/src/client/contribution.tsrx +31 -0
- package/modules/exports/src/client/index.ts +20 -0
- package/modules/exports/src/client/navigation.ts +25 -0
- package/modules/exports/src/client/presentation.ts +53 -0
- package/modules/exports/src/client/state.ts +56 -0
- package/modules/exports/src/domain/lists.ts +29 -0
- package/modules/exports/src/domain/types.ts +120 -0
- package/modules/exports/src/index.ts +41 -0
- package/modules/exports/src/platform.ts +80 -0
- package/modules/exports/src/server/index.ts +51 -0
- package/modules/exports/src/server/runtime.ts +160 -0
- package/modules/exports/src/services/data-classes.ts +56 -0
- package/modules/exports/src/services/database-repository.ts +405 -0
- package/modules/exports/src/services/export-runner.ts +123 -0
- package/modules/exports/src/services/export-service.ts +356 -0
- package/modules/exports/src/services/index.ts +6 -0
- package/modules/exports/src/services/list-registry.ts +105 -0
- package/modules/exports/src/services/migration.ts +89 -0
- package/modules/exports/src/services/repository.ts +97 -0
- package/modules/exports/src/settings.ts +70 -0
- package/modules/exports/translations/en.json +69 -0
- package/modules/exports/translations/pl.json +69 -0
- package/modules/import/migrations/0001_import_core.down.sql +6 -0
- package/modules/import/migrations/0001_import_core.up.sql +61 -0
- package/modules/import/migrations/0002_import_job_routing_role.down.sql +4 -0
- package/modules/import/migrations/0002_import_job_routing_role.up.sql +20 -0
- package/modules/import/migrations/0003_import_jobs_export_index.down.sql +1 -0
- package/modules/import/migrations/0003_import_jobs_export_index.up.sql +7 -0
- package/modules/import/migrations/0004_import_jobs_traceparent.down.sql +1 -0
- package/modules/import/migrations/0004_import_jobs_traceparent.up.sql +7 -0
- package/modules/import/migrations/README.md +3 -0
- package/modules/import/module.json +37 -0
- package/modules/import/package.json +50 -0
- package/modules/import/spec/module.yaml +335 -0
- package/modules/import/src/acl/permissions.ts +6 -0
- package/modules/import/src/api/endpoints.ts +400 -0
- package/modules/import/src/client/ImportJobDrawer.tsrx +229 -0
- package/modules/import/src/client/ImportsView.tsrx +455 -0
- package/modules/import/src/client/NewImportForm.tsrx +274 -0
- package/modules/import/src/client/api.ts +243 -0
- package/modules/import/src/client/contribution.tsrx +29 -0
- package/modules/import/src/client/index.ts +23 -0
- package/modules/import/src/client/navigation.ts +25 -0
- package/modules/import/src/client/presentation.ts +59 -0
- package/modules/import/src/client/state.ts +43 -0
- package/modules/import/src/domain/csv.ts +258 -0
- package/modules/import/src/domain/ports.ts +157 -0
- package/modules/import/src/domain/types.ts +179 -0
- package/modules/import/src/index.ts +58 -0
- package/modules/import/src/platform.ts +60 -0
- package/modules/import/src/server/index.ts +49 -0
- package/modules/import/src/server/runtime.ts +158 -0
- package/modules/import/src/services/csv-source.ts +121 -0
- package/modules/import/src/services/data-classes.ts +63 -0
- package/modules/import/src/services/database-repository.ts +780 -0
- package/modules/import/src/services/import-runner.ts +127 -0
- package/modules/import/src/services/import-service.ts +872 -0
- package/modules/import/src/services/index.ts +6 -0
- package/modules/import/src/services/migration.ts +156 -0
- package/modules/import/src/services/port-registry.ts +158 -0
- package/modules/import/src/services/repository.ts +147 -0
- package/modules/import/src/settings.ts +70 -0
- package/modules/import/translations/en.json +175 -0
- package/modules/import/translations/pl.json +175 -0
- package/modules/metering/migrations/0001_metering_core.down.sql +6 -0
- package/modules/metering/migrations/0001_metering_core.up.sql +119 -0
- package/modules/metering/migrations/0002_metering_bucket_export.down.sql +3 -0
- package/modules/metering/migrations/0002_metering_bucket_export.up.sql +5 -0
- package/modules/metering/migrations/README.md +3 -0
- package/modules/metering/module.json +46 -0
- package/modules/metering/package.json +50 -0
- package/modules/metering/spec/module.yaml +269 -0
- package/modules/metering/src/acl/permissions.ts +5 -0
- package/modules/metering/src/api/endpoints.ts +104 -0
- package/modules/metering/src/cli/commands.json +28 -0
- package/modules/metering/src/cli/index.ts +246 -0
- package/modules/metering/src/client/LimitsView.tsrx +170 -0
- package/modules/metering/src/client/UsageSummaryWidget.tsrx +63 -0
- package/modules/metering/src/client/UsageView.tsrx +205 -0
- package/modules/metering/src/client/api.ts +91 -0
- package/modules/metering/src/client/contribution.tsrx +42 -0
- package/modules/metering/src/client/index.ts +26 -0
- package/modules/metering/src/client/navigation.ts +54 -0
- package/modules/metering/src/client/presentation.ts +63 -0
- package/modules/metering/src/client/state.ts +31 -0
- package/modules/metering/src/domain/meters.ts +100 -0
- package/modules/metering/src/domain/types.ts +71 -0
- package/modules/metering/src/index.ts +51 -0
- package/modules/metering/src/platform.ts +84 -0
- package/modules/metering/src/server/index.ts +40 -0
- package/modules/metering/src/server/runtime.ts +165 -0
- package/modules/metering/src/services/data-classes.ts +34 -0
- package/modules/metering/src/services/database-repository.ts +574 -0
- package/modules/metering/src/services/index.ts +9 -0
- package/modules/metering/src/services/meter-registry.ts +145 -0
- package/modules/metering/src/services/metering-service.ts +441 -0
- package/modules/metering/src/services/migration.ts +183 -0
- package/modules/metering/src/services/notifications.ts +75 -0
- package/modules/metering/src/services/reports.ts +105 -0
- package/modules/metering/src/services/repository.ts +132 -0
- package/modules/metering/src/services/service-error.ts +46 -0
- package/modules/metering/src/settings.ts +47 -0
- package/modules/metering/translations/en.json +68 -0
- package/modules/metering/translations/pl.json +68 -0
- package/modules/notifications/migrations/0001_notifications_core.down.sql +1 -0
- package/modules/notifications/migrations/0001_notifications_core.up.sql +26 -0
- package/modules/notifications/migrations/0002_notifications_preferences.down.sql +1 -0
- package/modules/notifications/migrations/0002_notifications_preferences.up.sql +17 -0
- package/modules/notifications/migrations/0003_notifications_webhook_subscriptions.down.sql +1 -0
- package/modules/notifications/migrations/0003_notifications_webhook_subscriptions.up.sql +30 -0
- package/modules/notifications/migrations/0004_notifications_deliveries.down.sql +1 -0
- package/modules/notifications/migrations/0004_notifications_deliveries.up.sql +35 -0
- package/modules/notifications/migrations/0005_notifications_delivery_routing_role.down.sql +2 -0
- package/modules/notifications/migrations/0005_notifications_delivery_routing_role.up.sql +17 -0
- package/modules/notifications/migrations/0006_notifications_delivery_title.down.sql +1 -0
- package/modules/notifications/migrations/0006_notifications_delivery_title.up.sql +11 -0
- package/modules/notifications/migrations/0007_notifications_secret_rotation_inventory.down.sql +2 -0
- package/modules/notifications/migrations/0007_notifications_secret_rotation_inventory.up.sql +19 -0
- package/modules/notifications/migrations/0008_notifications_delivery_claim.down.sql +8 -0
- package/modules/notifications/migrations/0008_notifications_delivery_claim.up.sql +19 -0
- package/modules/notifications/migrations/0009_notifications_kind_approvals.down.sql +16 -0
- package/modules/notifications/migrations/0009_notifications_kind_approvals.up.sql +18 -0
- package/modules/notifications/migrations/0010_notifications_kind_meter_threshold.down.sql +16 -0
- package/modules/notifications/migrations/0010_notifications_kind_meter_threshold.up.sql +18 -0
- package/modules/notifications/migrations/0011_notifications_retention_keyset.down.sql +5 -0
- package/modules/notifications/migrations/0011_notifications_retention_keyset.up.sql +15 -0
- package/modules/notifications/migrations/0012_notifications_email_channel.down.sql +12 -0
- package/modules/notifications/migrations/0012_notifications_email_channel.up.sql +38 -0
- package/modules/notifications/migrations/0013_notifications_list_pages.down.sql +5 -0
- package/modules/notifications/migrations/0013_notifications_list_pages.up.sql +13 -0
- package/modules/notifications/migrations/README.md +3 -0
- package/modules/notifications/module.json +32 -0
- package/modules/notifications/package.json +49 -0
- package/modules/notifications/spec/module.yaml +718 -0
- package/modules/notifications/src/acl/permissions.ts +11 -0
- package/modules/notifications/src/api/endpoints.ts +814 -0
- package/modules/notifications/src/cli/commands.json +17 -0
- package/modules/notifications/src/cli/index.ts +126 -0
- package/modules/notifications/src/client/DeliveriesView.tsrx +483 -0
- package/modules/notifications/src/client/FactList.tsrx +24 -0
- package/modules/notifications/src/client/NotificationPreferencesView.tsrx +240 -0
- package/modules/notifications/src/client/NotificationsInboxView.tsrx +592 -0
- package/modules/notifications/src/client/UnreadCountWidget.tsrx +62 -0
- package/modules/notifications/src/client/WebhookForm.tsrx +297 -0
- package/modules/notifications/src/client/WebhooksView.tsrx +637 -0
- package/modules/notifications/src/client/api.ts +382 -0
- package/modules/notifications/src/client/contribution.tsrx +83 -0
- package/modules/notifications/src/client/inbox.ts +41 -0
- package/modules/notifications/src/client/index.ts +29 -0
- package/modules/notifications/src/client/navigation.ts +92 -0
- package/modules/notifications/src/client/notifications.css +70 -0
- package/modules/notifications/src/client/presentation.ts +81 -0
- package/modules/notifications/src/client/state.ts +246 -0
- package/modules/notifications/src/client/unread-count.ts +26 -0
- package/modules/notifications/src/domain/locale.ts +47 -0
- package/modules/notifications/src/domain/publish.ts +46 -0
- package/modules/notifications/src/domain/types.ts +186 -0
- package/modules/notifications/src/index.ts +62 -0
- package/modules/notifications/src/platform.ts +85 -0
- package/modules/notifications/src/server/index.ts +82 -0
- package/modules/notifications/src/server/runtime.ts +251 -0
- package/modules/notifications/src/services/data-classes.ts +139 -0
- package/modules/notifications/src/services/database-repository.ts +1334 -0
- package/modules/notifications/src/services/delivery-payload.ts +93 -0
- package/modules/notifications/src/services/delivery-runner.ts +170 -0
- package/modules/notifications/src/services/delivery-service.ts +811 -0
- package/modules/notifications/src/services/egress.ts +239 -0
- package/modules/notifications/src/services/email-channel.ts +93 -0
- package/modules/notifications/src/services/index.ts +23 -0
- package/modules/notifications/src/services/migration.ts +572 -0
- package/modules/notifications/src/services/notifications-service.ts +297 -0
- package/modules/notifications/src/services/paging.ts +60 -0
- package/modules/notifications/src/services/publish-service.ts +133 -0
- package/modules/notifications/src/services/repository.ts +342 -0
- package/modules/notifications/src/services/secret-rotation.ts +177 -0
- package/modules/notifications/src/services/secret-vault.ts +168 -0
- package/modules/notifications/src/services/service-error.ts +67 -0
- package/modules/notifications/src/services/signature.ts +81 -0
- package/modules/notifications/src/services/webhook-service.ts +307 -0
- package/modules/notifications/src/settings.ts +130 -0
- package/modules/notifications/translations/en.json +255 -0
- package/modules/notifications/translations/pl.json +255 -0
- package/modules/profile/module.json +3 -3
- package/modules/profile/package.json +1 -1
- package/modules/profile/spec/module.yaml +3 -3
- package/modules/profile/src/services/database-repository.ts +3 -13
- package/modules/reports/module.json +28 -0
- package/modules/reports/package.json +42 -0
- package/modules/reports/spec/module.yaml +231 -0
- package/modules/reports/src/acl/permissions.ts +5 -0
- package/modules/reports/src/api/endpoints.ts +72 -0
- package/modules/reports/src/client/ReportsSummaryWidget.tsrx +52 -0
- package/modules/reports/src/client/ReportsView.tsrx +246 -0
- package/modules/reports/src/client/api.ts +65 -0
- package/modules/reports/src/client/contribution.tsrx +36 -0
- package/modules/reports/src/client/index.ts +18 -0
- package/modules/reports/src/client/navigation.ts +39 -0
- package/modules/reports/src/client/presentation.ts +123 -0
- package/modules/reports/src/client/state.ts +28 -0
- package/modules/reports/src/domain/providers.ts +115 -0
- package/modules/reports/src/domain/types.ts +44 -0
- package/modules/reports/src/index.ts +47 -0
- package/modules/reports/src/platform.ts +37 -0
- package/modules/reports/src/server/index.ts +21 -0
- package/modules/reports/src/server/runtime.ts +40 -0
- package/modules/reports/src/services/index.ts +17 -0
- package/modules/reports/src/services/provider-registry.ts +144 -0
- package/modules/reports/src/services/range.ts +65 -0
- package/modules/reports/src/services/reports-service.ts +316 -0
- package/modules/reports/src/services/service-error.ts +26 -0
- package/modules/reports/src/settings.ts +49 -0
- package/modules/reports/translations/en.json +35 -0
- package/modules/reports/translations/pl.json +35 -0
- package/modules/sandbox/module.json +4 -4
- package/modules/sandbox/package.json +1 -1
- package/modules/sandbox/spec/module.yaml +3 -3
- package/modules/sandbox/src/services/database-repository.ts +14 -23
- package/modules/sandbox/src/services/directory.ts +16 -0
- package/modules/sandbox/src/services/sandbox-service.ts +13 -11
- package/modules/search/migrations/0001_search_core.down.sql +1 -0
- package/modules/search/migrations/0001_search_core.up.sql +22 -0
- package/modules/search/migrations/0002_search_recent_export.down.sql +3 -0
- package/modules/search/migrations/0002_search_recent_export.up.sql +5 -0
- package/modules/search/migrations/README.md +3 -0
- package/modules/search/module.json +28 -0
- package/modules/search/package.json +43 -0
- package/modules/search/spec/module.yaml +177 -0
- package/modules/search/src/acl/permissions.ts +5 -0
- package/modules/search/src/api/endpoints.ts +221 -0
- package/modules/search/src/client/SearchView.tsrx +346 -0
- package/modules/search/src/client/api.ts +157 -0
- package/modules/search/src/client/contribution.tsrx +31 -0
- package/modules/search/src/client/index.ts +17 -0
- package/modules/search/src/client/navigation.ts +97 -0
- package/modules/search/src/client/search.css +56 -0
- package/modules/search/src/client/state.ts +113 -0
- package/modules/search/src/domain/data-classes.ts +73 -0
- package/modules/search/src/domain/providers.ts +88 -0
- package/modules/search/src/domain/types.ts +56 -0
- package/modules/search/src/index.ts +46 -0
- package/modules/search/src/platform.ts +42 -0
- package/modules/search/src/server/index.ts +25 -0
- package/modules/search/src/server/runtime.ts +123 -0
- package/modules/search/src/services/database-repository.ts +163 -0
- package/modules/search/src/services/index.ts +21 -0
- package/modules/search/src/services/migration.ts +65 -0
- package/modules/search/src/services/provider-registry.ts +137 -0
- package/modules/search/src/services/repository.ts +43 -0
- package/modules/search/src/services/search-service.ts +442 -0
- package/modules/search/src/services/service-error.ts +35 -0
- package/modules/search/src/settings.ts +68 -0
- package/modules/search/translations/en.json +45 -0
- package/modules/search/translations/pl.json +45 -0
- package/modules/system/module.json +2 -2
- package/modules/system/package.json +1 -1
- package/modules/system/spec/module.yaml +30 -3
- package/modules/system/src/client/FlagsPanel.tsrx +127 -0
- package/modules/system/src/client/ModuleSettingRow.tsrx +17 -7
- package/modules/system/src/client/ModuleSettingsSection.tsrx +10 -71
- package/modules/system/src/client/ModulesView.tsrx +91 -65
- package/modules/system/src/client/flags.ts +35 -0
- package/modules/system/src/client/index.ts +8 -0
- package/modules/system/src/client/navigation.ts +8 -0
- package/modules/system/src/client/settings-state.ts +159 -0
- package/modules/system/src/client/state.ts +2 -0
- package/modules/system/src/domain/time-zone.ts +105 -0
- package/modules/system/src/index.ts +12 -0
- package/modules/system/src/platform.ts +5 -1
- package/modules/system/src/server/endpoints.ts +72 -21
- package/modules/system/src/settings.ts +28 -0
- package/modules/system/translations/en.json +17 -0
- package/modules/system/translations/pl.json +17 -0
- package/modules/users/module.json +30 -4
- package/modules/users/package.json +4 -1
- package/modules/users/spec/module.yaml +290 -7
- package/modules/users/src/api/endpoints.ts +228 -15
- package/modules/users/src/client/InviteMemberForm.tsrx +2 -2
- package/modules/users/src/client/MemberDrawer.tsrx +142 -26
- package/modules/users/src/client/UserAccountForm.tsrx +2 -2
- package/modules/users/src/client/UsersView.tsrx +432 -71
- package/modules/users/src/client/api.ts +106 -12
- package/modules/users/src/client/contribution.tsrx +5 -0
- package/modules/users/src/client/member-columns.tsrx +22 -9
- package/modules/users/src/client/state.ts +172 -7
- package/modules/users/src/domain/lists.ts +9 -0
- package/modules/users/src/index.ts +11 -0
- package/modules/users/src/platform.ts +50 -1
- package/modules/users/src/services/member-export.ts +51 -0
- package/modules/users/src/services/member-import.ts +249 -0
- package/modules/users/src/services/member-search.ts +145 -0
- package/modules/users/src/services/users-service.ts +117 -4
- package/modules/users/translations/en.json +57 -8
- package/modules/users/translations/pl.json +57 -8
- package/modules/workflows/migrations/0004_payload_rotation_inventory.up.sql +17 -0
- package/modules/workflows/migrations/0005_workflows_human_approval.up.sql +28 -0
- package/modules/workflows/migrations/0006_workflows_retention_indexes.up.sql +11 -0
- package/modules/workflows/migrations/0007_workflows_erasure_subject_indexes.up.sql +17 -0
- package/modules/workflows/migrations/0008_workflows_subject_account.up.sql +24 -0
- package/modules/workflows/migrations/0009_workflows_definition_list_indexes.up.sql +9 -0
- package/modules/workflows/module.json +34 -6
- package/modules/workflows/package.json +2 -1
- package/modules/workflows/spec/module.yaml +26 -9
- package/modules/workflows/src/api/endpoints.ts +131 -25
- package/modules/workflows/src/cli/commands.json +17 -0
- package/modules/workflows/src/cli/index.ts +114 -0
- package/modules/workflows/src/client/WorkflowExecutionHistory.tsrx +36 -27
- package/modules/workflows/src/client/WorkflowInspector.tsrx +116 -0
- package/modules/workflows/src/client/WorkflowNodePalette.tsrx +1 -0
- package/modules/workflows/src/client/WorkflowsView.tsrx +236 -99
- package/modules/workflows/src/client/api.ts +54 -34
- package/modules/workflows/src/client/canvas-model.ts +12 -0
- package/modules/workflows/src/client/state.ts +95 -0
- package/modules/workflows/src/domain/events.ts +25 -11
- package/modules/workflows/src/domain/graph.ts +135 -1
- package/modules/workflows/src/domain/types.ts +91 -4
- package/modules/workflows/src/platform.ts +12 -0
- package/modules/workflows/src/server/runtime.ts +78 -5
- package/modules/workflows/src/services/approvals.ts +62 -0
- package/modules/workflows/src/services/cursors.ts +37 -0
- package/modules/workflows/src/services/data-classes.ts +232 -0
- package/modules/workflows/src/services/database-repository.ts +660 -171
- package/modules/workflows/src/services/migration.ts +240 -0
- package/modules/workflows/src/services/notifications.ts +98 -0
- package/modules/workflows/src/services/payload-codec.ts +51 -28
- package/modules/workflows/src/services/payload-rotation.ts +171 -0
- package/modules/workflows/src/services/repository.ts +123 -8
- package/modules/workflows/src/services/simulation.ts +7 -0
- package/modules/workflows/src/services/worker.ts +446 -25
- package/modules/workflows/src/services/workflows-service.ts +264 -103
- package/modules/workflows/translations/en.json +12 -4
- package/modules/workflows/translations/pl.json +12 -4
- package/modules.json +48 -4
- package/package.json +64 -6
- package/packages/client/package.json +1 -0
- package/packages/client/src/ApplicationShell.tsrx +43 -0
- package/packages/client/src/contributions.ts +55 -0
- package/packages/client/src/i18n/locales/en.json +5 -0
- package/packages/client/src/i18n/locales/pl.json +5 -0
- package/packages/client/src/index.ts +13 -1
- package/packages/client/src/routing.ts +22 -0
- package/packages/client/src/shell/CommandPalette.tsrx +223 -11
- package/packages/client/src/shell/command-search.ts +126 -0
- package/packages/client/src/shell/command.ts +30 -0
- package/packages/client/src/shell/navigation.ts +12 -0
- package/packages/client/src/shell/palette-keys.ts +27 -0
- package/packages/client/src/shell/shell.css +7 -0
- package/packages/contracts/schemas/module-spec.schema.json +287 -1
- package/packages/contracts/schemas/module.schema.json +25 -0
- package/packages/contracts/src/index.ts +144 -1
- package/packages/database/src/backup.ts +179 -0
- package/packages/database/src/decoders.ts +25 -0
- package/packages/database/src/index.ts +17 -0
- package/packages/database/src/record-history.ts +5 -14
- package/packages/harness/src/index.ts +2 -0
- package/packages/harness/src/runtime.ts +218 -1
- package/packages/harness/src/tool-adapters.ts +19 -1
- package/packages/kernel/src/acl.ts +179 -0
- package/packages/kernel/src/capability-registry.ts +69 -2
- package/packages/kernel/src/data-class-registry.ts +354 -0
- package/packages/kernel/src/index.ts +65 -4
- package/packages/kernel/src/keyring.ts +208 -0
- package/packages/kernel/src/module-compatibility.ts +35 -4
- package/packages/kernel/src/module-registry.ts +49 -2
- package/packages/kernel/src/module-settings.ts +189 -27
- package/packages/server/package.json +2 -1
- package/packages/server/src/composition.ts +38 -0
- package/packages/server/src/endpoint.ts +104 -47
- package/packages/server/src/export/csv.ts +34 -0
- package/packages/server/src/export/definition.ts +346 -0
- package/packages/server/src/export/index.ts +61 -0
- package/packages/server/src/export/run.ts +116 -0
- package/packages/server/src/index.ts +155 -0
- package/packages/server/src/jobs/index.ts +93 -0
- package/packages/server/src/jobs/runner.ts +486 -0
- package/packages/server/src/log.ts +291 -0
- package/packages/server/src/mail/config.ts +184 -0
- package/packages/server/src/mail/contracts.ts +251 -0
- package/packages/server/src/mail/index.ts +31 -0
- package/packages/server/src/mail/port.ts +101 -0
- package/packages/server/src/mail/smtp.ts +191 -0
- package/packages/server/src/mail/template.ts +105 -0
- package/packages/server/src/metrics.ts +447 -0
- package/packages/server/src/pagination.ts +246 -0
- package/packages/server/src/trace/context.ts +103 -0
- package/packages/server/src/trace/egress.ts +66 -0
- package/packages/server/src/trace/error-sink.ts +296 -0
- package/packages/server/src/trace/exporter.ts +295 -0
- package/packages/server/src/trace/index.ts +60 -0
- package/packages/server/src/trace/job-sink.ts +172 -0
- package/packages/server/src/trace/tracer.ts +338 -0
- package/packages/server/src/web.ts +5 -1
- package/packages/storage/package.json +40 -0
- package/packages/storage/src/config.ts +189 -0
- package/packages/storage/src/content-type.ts +124 -0
- package/packages/storage/src/contracts.ts +112 -0
- package/packages/storage/src/envelope.ts +189 -0
- package/packages/storage/src/index.ts +43 -0
- package/packages/storage/src/local.ts +75 -0
- package/packages/storage/src/port.ts +251 -0
- package/packages/storage/src/read-token.ts +130 -0
- package/packages/storage/src/s3.ts +144 -0
- package/packages/storage/src/scanner.ts +22 -0
- package/packages/storage/src/sigv4.ts +104 -0
- package/packages/storage/src/store.ts +13 -0
- package/packages/ui/package.json +1 -0
- package/packages/ui/src/components/Button.tsrx +3 -0
- package/packages/ui/src/components/ConfirmDialog.tsrx +13 -2
- package/packages/ui/src/components/DateField.tsrx +92 -0
- package/packages/ui/src/components/DatePicker.tsrx +525 -0
- package/packages/ui/src/components/DateRangeField.tsrx +93 -0
- package/packages/ui/src/components/Drawer.tsrx +10 -1
- package/packages/ui/src/components/FileUpload.tsrx +158 -0
- package/packages/ui/src/components/Pagination.tsrx +130 -0
- package/packages/ui/src/components/Select.tsrx +78 -0
- package/packages/ui/src/components/Table.tsrx +498 -81
- package/packages/ui/src/components/Tabs.tsrx +53 -0
- package/packages/ui/src/components/ToastHost.tsrx +48 -0
- package/packages/ui/src/components/calendar.ts +243 -0
- package/packages/ui/src/components/date-field.ts +62 -0
- package/packages/ui/src/components/file-upload.ts +49 -0
- package/packages/ui/src/components/focus-trap.ts +62 -0
- package/packages/ui/src/components/pagination.ts +68 -0
- package/packages/ui/src/components/table-sorting.ts +49 -0
- package/packages/ui/src/components/tabs.ts +61 -0
- package/packages/ui/src/components/toast-store.ts +116 -0
- package/packages/ui/src/icons/Icon.tsrx +5 -0
- package/packages/ui/src/index.ts +45 -0
- package/packages/ui/src/styles/components.css +598 -0
- package/modules/automations-workflows-integration/module.json +0 -27
- package/modules/automations-workflows-integration/spec/module.yaml +0 -93
- package/modules/automations-workflows-integration/src/index.ts +0 -14
- package/modules/automations-workflows-integration/src/platform.ts +0 -24
- package/modules/automations-workflows-integration/src/server/index.ts +0 -11
- package/modules/automations-workflows-integration/translations/en.json +0 -21
- package/modules/automations-workflows-integration/translations/pl.json +0 -21
- package/modules/workflows/src/services/cursor-codec.ts +0 -62
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import {
|
|
3
|
+
integer,
|
|
3
4
|
runDatabaseMigrations,
|
|
4
5
|
type DatabaseHandle,
|
|
5
6
|
type DatabaseTransaction,
|
|
@@ -14,10 +15,13 @@ import type {
|
|
|
14
15
|
JsonValue,
|
|
15
16
|
} from '@flowdular/sdk/harness';
|
|
16
17
|
import { usageCostMicros } from '@flowdular/sdk/harness/catalog';
|
|
18
|
+
import { keysetWhere } from '@flowdular/sdk/server';
|
|
17
19
|
import type {
|
|
18
20
|
AgentAuditEvent,
|
|
19
|
-
|
|
21
|
+
AgentAuditListQuery,
|
|
20
22
|
AgentDefinition,
|
|
23
|
+
AgentListPage,
|
|
24
|
+
AgentListQuery,
|
|
21
25
|
AgentDefinitionRevision,
|
|
22
26
|
AgentActionInvocation,
|
|
23
27
|
AgentRevisionProcedure,
|
|
@@ -28,6 +32,7 @@ import type {
|
|
|
28
32
|
AgentRun,
|
|
29
33
|
AgentRunDetail,
|
|
30
34
|
AgentRunExecution,
|
|
35
|
+
AgentRunListQuery,
|
|
31
36
|
AgentUsageAgent,
|
|
32
37
|
AgentUsageBucket,
|
|
33
38
|
AgentUsageDay,
|
|
@@ -41,7 +46,10 @@ import {
|
|
|
41
46
|
DuplicateActionIdempotencyKeyError,
|
|
42
47
|
DuplicateRunIdempotencyKeyError,
|
|
43
48
|
ModuleAgentBindingConflictError,
|
|
49
|
+
type AgentReadOptions,
|
|
44
50
|
type AgentRepository,
|
|
51
|
+
type AgentRunExportCursor,
|
|
52
|
+
type ExportedAgentRun,
|
|
45
53
|
type PendingAgentAuditEvent,
|
|
46
54
|
type RecoverableRun,
|
|
47
55
|
} from './repository.ts';
|
|
@@ -192,6 +200,11 @@ interface RunEventRow {
|
|
|
192
200
|
occurred_at: number | string;
|
|
193
201
|
}
|
|
194
202
|
|
|
203
|
+
/** The run id a page of events carries, so one query can serve many runs. */
|
|
204
|
+
interface RunEventPageRow extends RunEventRow {
|
|
205
|
+
run_id: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
195
208
|
interface AuditRow {
|
|
196
209
|
id: string;
|
|
197
210
|
tenant_id: string;
|
|
@@ -243,7 +256,7 @@ interface UsageRow {
|
|
|
243
256
|
input_tokens: number | string;
|
|
244
257
|
output_tokens: number | string;
|
|
245
258
|
cost_micro_usd: number | string | null;
|
|
246
|
-
unpriced_runs: number | string;
|
|
259
|
+
unpriced_runs: number | string | null;
|
|
247
260
|
}
|
|
248
261
|
|
|
249
262
|
function stringArray(value: string): readonly string[] {
|
|
@@ -296,15 +309,15 @@ function fromAgentRow(row: AgentRow): AgentDefinition {
|
|
|
296
309
|
allowedTools: stringArray(row.allowed_tools_json),
|
|
297
310
|
procedureIds: [],
|
|
298
311
|
maxSteps: row.max_steps,
|
|
299
|
-
timeoutMs: integer(row.timeout_ms),
|
|
312
|
+
timeoutMs: integer(row.timeout_ms, 'timeout_ms'),
|
|
300
313
|
temperature: row.temperature_milli / 1_000,
|
|
301
|
-
maxOutputTokens: integer(row.max_output_tokens),
|
|
314
|
+
maxOutputTokens: integer(row.max_output_tokens, 'max_output_tokens'),
|
|
302
315
|
status: row.status,
|
|
303
316
|
revision: row.revision,
|
|
304
317
|
createdBy: row.created_by,
|
|
305
|
-
createdAt: integer(row.created_at),
|
|
318
|
+
createdAt: integer(row.created_at, 'created_at'),
|
|
306
319
|
updatedBy: row.updated_by,
|
|
307
|
-
updatedAt: integer(row.updated_at),
|
|
320
|
+
updatedAt: integer(row.updated_at, 'updated_at'),
|
|
308
321
|
};
|
|
309
322
|
}
|
|
310
323
|
|
|
@@ -343,10 +356,10 @@ function fromRunRow(row: RunRow): AgentRun {
|
|
|
343
356
|
failureCode: row.failure_code,
|
|
344
357
|
failureMessage: row.failure_message,
|
|
345
358
|
attempt: row.attempt,
|
|
346
|
-
queuedAt: integer(row.queued_at),
|
|
347
|
-
startedAt: integerOrNull(row.started_at),
|
|
348
|
-
completedAt: integerOrNull(row.completed_at),
|
|
349
|
-
leaseExpiresAt: integerOrNull(row.lease_expires_at),
|
|
359
|
+
queuedAt: integer(row.queued_at, 'queued_at'),
|
|
360
|
+
startedAt: integerOrNull(row.started_at, 'started_at'),
|
|
361
|
+
completedAt: integerOrNull(row.completed_at, 'completed_at'),
|
|
362
|
+
leaseExpiresAt: integerOrNull(row.lease_expires_at, 'lease_expires_at'),
|
|
350
363
|
};
|
|
351
364
|
}
|
|
352
365
|
|
|
@@ -364,9 +377,9 @@ function fromRevisionRow(row: AgentRevisionRow): AgentDefinitionRevision {
|
|
|
364
377
|
allowedTools: stringArray(row.allowed_tools_json),
|
|
365
378
|
procedures: JSON.parse(row.skills_json) as AgentRevisionProcedure[],
|
|
366
379
|
maxSteps: row.max_steps,
|
|
367
|
-
timeoutMs: integer(row.timeout_ms),
|
|
380
|
+
timeoutMs: integer(row.timeout_ms, 'timeout_ms'),
|
|
368
381
|
temperature: row.temperature_milli / 1_000,
|
|
369
|
-
maxOutputTokens: integer(row.max_output_tokens),
|
|
382
|
+
maxOutputTokens: integer(row.max_output_tokens, 'max_output_tokens'),
|
|
370
383
|
status: row.status,
|
|
371
384
|
ownership:
|
|
372
385
|
row.module_id === null
|
|
@@ -378,7 +391,7 @@ function fromRevisionRow(row: AgentRevisionRow): AgentDefinitionRevision {
|
|
|
378
391
|
},
|
|
379
392
|
moduleDefinitionRevision: row.module_definition_revision,
|
|
380
393
|
retainedBy: row.retained_by,
|
|
381
|
-
retainedAt: integer(row.retained_at),
|
|
394
|
+
retainedAt: integer(row.retained_at, 'retained_at'),
|
|
382
395
|
};
|
|
383
396
|
}
|
|
384
397
|
|
|
@@ -394,7 +407,7 @@ function fromModuleBindingRow(row: ModuleAgentBindingRow): ModuleAgentBinding {
|
|
|
394
407
|
executableRevision: row.executable_revision,
|
|
395
408
|
revision: row.revision,
|
|
396
409
|
updatedBy: row.updated_by,
|
|
397
|
-
updatedAt: integer(row.updated_at),
|
|
410
|
+
updatedAt: integer(row.updated_at, 'updated_at'),
|
|
398
411
|
};
|
|
399
412
|
}
|
|
400
413
|
|
|
@@ -421,10 +434,10 @@ function fromActionRow(row: ActionRow): AgentActionInvocation {
|
|
|
421
434
|
output: jsonValue(row.output_json),
|
|
422
435
|
code: row.failure_code,
|
|
423
436
|
attempt: row.attempt,
|
|
424
|
-
queuedAt: integer(row.queued_at),
|
|
425
|
-
startedAt: integerOrNull(row.started_at),
|
|
426
|
-
completedAt: integerOrNull(row.completed_at),
|
|
427
|
-
leaseExpiresAt: integerOrNull(row.lease_expires_at),
|
|
437
|
+
queuedAt: integer(row.queued_at, 'queued_at'),
|
|
438
|
+
startedAt: integerOrNull(row.started_at, 'started_at'),
|
|
439
|
+
completedAt: integerOrNull(row.completed_at, 'completed_at'),
|
|
440
|
+
leaseExpiresAt: integerOrNull(row.lease_expires_at, 'lease_expires_at'),
|
|
428
441
|
};
|
|
429
442
|
}
|
|
430
443
|
|
|
@@ -440,9 +453,9 @@ function fromSkillRow(row: SkillRow): AgentProcedure {
|
|
|
440
453
|
status: row.status,
|
|
441
454
|
revision: row.revision,
|
|
442
455
|
createdBy: row.created_by,
|
|
443
|
-
createdAt: integer(row.created_at),
|
|
456
|
+
createdAt: integer(row.created_at, 'created_at'),
|
|
444
457
|
updatedBy: row.updated_by,
|
|
445
|
-
updatedAt: integer(row.updated_at),
|
|
458
|
+
updatedAt: integer(row.updated_at, 'updated_at'),
|
|
446
459
|
};
|
|
447
460
|
}
|
|
448
461
|
|
|
@@ -456,32 +469,29 @@ function executionFromRow(row: RunRow): AgentRunExecution {
|
|
|
456
469
|
model: row.model,
|
|
457
470
|
allowedTools: stringArray(row.allowed_tools_json),
|
|
458
471
|
maxSteps: row.max_steps,
|
|
459
|
-
timeoutMs: integer(row.timeout_ms),
|
|
472
|
+
timeoutMs: integer(row.timeout_ms, 'timeout_ms'),
|
|
460
473
|
temperature: row.temperature_milli / 1_000,
|
|
461
|
-
maxOutputTokens: integer(row.max_output_tokens),
|
|
474
|
+
maxOutputTokens: integer(row.max_output_tokens, 'max_output_tokens'),
|
|
462
475
|
};
|
|
463
476
|
return { run: fromRunRow(row), definition };
|
|
464
477
|
}
|
|
465
478
|
|
|
466
|
-
/* SUM() over BIGINT is NUMERIC in PostgreSQL, and the driver hands NUMERIC
|
|
467
|
-
back as a string. Aggregates leave this repository as numbers. */
|
|
468
|
-
function integer(value: number | string | null): number {
|
|
469
|
-
return typeof value === 'number' ? value : Number(value ?? 0);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
479
|
/* A nullable BIGINT must stay null: coercing it to 0 would turn "never started"
|
|
473
480
|
into "started at the epoch". */
|
|
474
|
-
function integerOrNull(
|
|
475
|
-
|
|
481
|
+
function integerOrNull(
|
|
482
|
+
value: number | string | null,
|
|
483
|
+
field: string,
|
|
484
|
+
): number | null {
|
|
485
|
+
return value === null ? null : integer(value, field);
|
|
476
486
|
}
|
|
477
487
|
|
|
478
488
|
function fromUsageRow(row: UsageRow): AgentUsageBucket {
|
|
479
489
|
return {
|
|
480
|
-
runs: integer(row.runs),
|
|
481
|
-
inputTokens: integer(row.input_tokens),
|
|
482
|
-
outputTokens: integer(row.output_tokens),
|
|
483
|
-
costMicroUsd: integer(row.cost_micro_usd),
|
|
484
|
-
unpricedRuns: integer(row.unpriced_runs),
|
|
490
|
+
runs: integer(row.runs, 'runs'),
|
|
491
|
+
inputTokens: integer(row.input_tokens, 'input_tokens'),
|
|
492
|
+
outputTokens: integer(row.output_tokens, 'output_tokens'),
|
|
493
|
+
costMicroUsd: integer(row.cost_micro_usd ?? 0, 'cost_micro_usd'),
|
|
494
|
+
unpricedRuns: integer(row.unpriced_runs ?? 0, 'unpriced_runs'),
|
|
485
495
|
};
|
|
486
496
|
}
|
|
487
497
|
|
|
@@ -491,17 +501,27 @@ const USAGE_COLUMNS = `COUNT(*) AS runs,
|
|
|
491
501
|
COALESCE(SUM(cost_micro_usd), 0) AS cost_micro_usd,
|
|
492
502
|
SUM(CASE WHEN cost_micro_usd IS NULL THEN 1 ELSE 0 END) AS unpriced_runs`;
|
|
493
503
|
|
|
504
|
+
function fromRunEventRow(row: RunEventRow): AgentExecutionEvent {
|
|
505
|
+
return {
|
|
506
|
+
sequence: integer(row.sequence, 'sequence'),
|
|
507
|
+
type: row.event_type,
|
|
508
|
+
timestamp: integer(row.occurred_at, 'occurred_at'),
|
|
509
|
+
message: row.message,
|
|
510
|
+
metadata: metadata(row.metadata_json),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
494
514
|
function fromAuditRow(row: AuditRow): AgentAuditEvent {
|
|
495
515
|
return {
|
|
496
516
|
id: row.id,
|
|
497
517
|
tenantId: row.tenant_id,
|
|
498
|
-
sequence: integer(row.sequence),
|
|
518
|
+
sequence: integer(row.sequence, 'sequence'),
|
|
499
519
|
actorId: row.actor_id,
|
|
500
520
|
action: row.action,
|
|
501
521
|
subjectType: row.subject_type,
|
|
502
522
|
subjectId: row.subject_id,
|
|
503
523
|
metadata: metadata(row.metadata_json),
|
|
504
|
-
occurredAt: integer(row.occurred_at),
|
|
524
|
+
occurredAt: integer(row.occurred_at, 'occurred_at'),
|
|
505
525
|
previousHash: row.previous_hash,
|
|
506
526
|
eventHash: row.event_hash,
|
|
507
527
|
};
|
|
@@ -558,15 +578,75 @@ const RUN_FROM = `agent_runs LEFT JOIN agent_run_execution_limits
|
|
|
558
578
|
LEFT JOIN agent_run_contracts ON agent_run_contracts.run_id = agent_runs.id
|
|
559
579
|
JOIN agent_run_actors ON agent_run_actors.run_id = agent_runs.id
|
|
560
580
|
AND agent_run_actors.tenant_id = agent_runs.tenant_id`;
|
|
561
|
-
const
|
|
581
|
+
const AGENT_COLUMNS = `agent_definitions.*,
|
|
562
582
|
COALESCE(agent_definition_execution_limits.timeout_ms,
|
|
563
583
|
agent_definitions.timeout_ms) AS timeout_ms,
|
|
564
584
|
COALESCE(agent_definition_output_limits.max_output_tokens,
|
|
565
|
-
${DEFAULT_MAX_OUTPUT_TOKENS}) AS max_output_tokens
|
|
566
|
-
|
|
585
|
+
${DEFAULT_MAX_OUTPUT_TOKENS}) AS max_output_tokens`;
|
|
586
|
+
const AGENT_FROM = `agent_definitions LEFT JOIN agent_definition_execution_limits
|
|
567
587
|
ON agent_definition_execution_limits.agent_id = agent_definitions.id
|
|
568
588
|
LEFT JOIN agent_definition_output_limits
|
|
569
589
|
ON agent_definition_output_limits.agent_id = agent_definitions.id`;
|
|
590
|
+
const AGENT_SELECT = `SELECT ${AGENT_COLUMNS} FROM ${AGENT_FROM}`;
|
|
591
|
+
|
|
592
|
+
/* The term is matched as a substring, so the three characters LIKE reads as
|
|
593
|
+
syntax are escaped with PostgreSQL's default backslash. */
|
|
594
|
+
function likePattern(term: string): string {
|
|
595
|
+
return '%' + term.replace(/[\\%_]/g, (character) => '\\' + character) + '%';
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/* The page order and the keyset predicate are one decision, so the planner
|
|
599
|
+
walks agent_definitions_tenant_name_key_idx or _tenant_updated_idx from the
|
|
600
|
+
cursor; tests/list-plan.test.ts reads the plan. A subquery names the collation key, since a keyset column must be a
|
|
601
|
+
plain identifier; PostgreSQL pulls it up and reads the expression index. */
|
|
602
|
+
const AGENT_PAGE_FROM = `(SELECT ${AGENT_COLUMNS},
|
|
603
|
+
lower(agent_definitions.name) AS name_key
|
|
604
|
+
FROM ${AGENT_FROM}
|
|
605
|
+
WHERE agent_definitions.tenant_id = $1
|
|
606
|
+
AND ($2::text IS NULL OR agent_definitions.name ILIKE $2
|
|
607
|
+
OR agent_definitions.agent_key ILIKE $2
|
|
608
|
+
OR agent_definitions.description ILIKE $2)) AS agents`;
|
|
609
|
+
|
|
610
|
+
export function agentPageStatement(query: AgentListQuery): string {
|
|
611
|
+
const column = query.sort === 'name' ? 'name_key' : 'updated_at';
|
|
612
|
+
const order = query.direction === 'asc' ? 'ASC' : 'DESC';
|
|
613
|
+
const keyset =
|
|
614
|
+
query.after === null
|
|
615
|
+
? ''
|
|
616
|
+
: ' WHERE ' +
|
|
617
|
+
keysetWhere([column, 'id'], ['', ''], {
|
|
618
|
+
direction: query.direction,
|
|
619
|
+
parameterOffset: 2,
|
|
620
|
+
}).text;
|
|
621
|
+
return `SELECT * FROM ${AGENT_PAGE_FROM}${keyset}
|
|
622
|
+
ORDER BY ${column} ${order}, id ${order} LIMIT $${query.after === null ? 3 : 5}`;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const RUN_LIST_FILTERS = `agent_runs.tenant_id = $1
|
|
626
|
+
AND ($2::text IS NULL OR status = $2)
|
|
627
|
+
AND ($3::text IS NULL OR agent_id = $3)
|
|
628
|
+
AND ($4::text IS NULL OR trigger = $4)
|
|
629
|
+
AND ($5::text IS NULL OR agent_name ILIKE $5 OR agent_runs.id = $6)`;
|
|
630
|
+
|
|
631
|
+
export function runPageStatement(query: AgentRunListQuery): string {
|
|
632
|
+
const order = query.direction === 'asc' ? 'ASC' : 'DESC';
|
|
633
|
+
const keyset =
|
|
634
|
+
query.after === null
|
|
635
|
+
? ''
|
|
636
|
+
: ' AND ' +
|
|
637
|
+
keysetWhere(['queued_at', 'id'], ['', ''], {
|
|
638
|
+
direction: query.direction,
|
|
639
|
+
parameterOffset: 6,
|
|
640
|
+
}).text;
|
|
641
|
+
return `SELECT ${RUN_COLUMNS} FROM ${RUN_FROM} WHERE ${RUN_LIST_FILTERS}${keyset}
|
|
642
|
+
ORDER BY queued_at ${order}, agent_runs.id ${order} LIMIT $${query.after === null ? 7 : 9}`;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/* Newest first over the order agent_audit_v4_tenant_time_idx carries. */
|
|
646
|
+
const AUDIT_PAGE_KEYSET = keysetWhere(['occurred_at', 'sequence'], ['', ''], {
|
|
647
|
+
direction: 'desc',
|
|
648
|
+
parameterOffset: 1,
|
|
649
|
+
}).text;
|
|
570
650
|
const AGENT_REVISION_SELECT = `SELECT agent_definition_revisions.*,
|
|
571
651
|
agent_revision_ownership.module_id,
|
|
572
652
|
agent_revision_ownership.module_definition_revision
|
|
@@ -618,7 +698,6 @@ export interface AgentsPersistenceStatements {
|
|
|
618
698
|
readonly updateProcedure: string;
|
|
619
699
|
readonly procedureUsage: string;
|
|
620
700
|
readonly deleteProcedure: string;
|
|
621
|
-
readonly listRuns: string;
|
|
622
701
|
readonly getRun: string;
|
|
623
702
|
readonly listRunEvents: string;
|
|
624
703
|
readonly findRunByIdempotencyKey: string;
|
|
@@ -648,12 +727,21 @@ export interface AgentsPersistenceStatements {
|
|
|
648
727
|
readonly listRecoverableActions: string;
|
|
649
728
|
readonly claimAction: string;
|
|
650
729
|
readonly renewActionLease: string;
|
|
730
|
+
readonly releaseAction: string;
|
|
651
731
|
readonly completeAction: string;
|
|
652
732
|
readonly failAction: string;
|
|
653
733
|
readonly cancelAction: string;
|
|
734
|
+
readonly exportRunsPage1: string;
|
|
735
|
+
readonly exportRunsPage2: string;
|
|
736
|
+
readonly exportRunEvents: string;
|
|
737
|
+
readonly deleteSettledRunsBefore: string;
|
|
738
|
+
readonly deleteRunsRequestedBy: string;
|
|
654
739
|
readonly appendAuditEvent1: string;
|
|
655
740
|
readonly appendAuditEvent2: string;
|
|
741
|
+
readonly pruneMeterRefusals: string;
|
|
742
|
+
readonly claimMeterRefusal: string;
|
|
656
743
|
readonly listAuditEvents: string;
|
|
744
|
+
readonly exportAuditEventsPage: string;
|
|
657
745
|
readonly pageAuditEvents1: string;
|
|
658
746
|
readonly pageAuditEvents2: string;
|
|
659
747
|
readonly verifyAuditChainDetailed: string;
|
|
@@ -822,8 +910,6 @@ export const AGENTS_SQL: AgentsPersistenceStatements = Object.freeze({
|
|
|
822
910
|
WHERE agent_skill_assignments.tenant_id = $1
|
|
823
911
|
AND agent_skill_assignments.skill_id = $2`,
|
|
824
912
|
deleteProcedure: `DELETE FROM agent_skills WHERE tenant_id = $1 AND id = $2`,
|
|
825
|
-
listRuns: `SELECT ${RUN_COLUMNS} FROM ${RUN_FROM} WHERE agent_runs.tenant_id = $1
|
|
826
|
-
ORDER BY queued_at DESC, agent_runs.id DESC LIMIT $2`,
|
|
827
913
|
getRun: `SELECT ${RUN_COLUMNS} FROM ${RUN_FROM} WHERE agent_runs.tenant_id = $1 AND agent_runs.id = $2`,
|
|
828
914
|
listRunEvents: `SELECT sequence, event_type, message, metadata_json, occurred_at
|
|
829
915
|
FROM agent_run_events WHERE tenant_id = $1 AND run_id = $2
|
|
@@ -930,6 +1016,13 @@ export const AGENTS_SQL: AgentsPersistenceStatements = Object.freeze({
|
|
|
930
1016
|
renewActionLease: `UPDATE agent_action_invocations SET lease_expires_at = $1
|
|
931
1017
|
WHERE tenant_id = $2 AND id = $3 AND status = 'running'
|
|
932
1018
|
AND lease_owner = $4`,
|
|
1019
|
+
/* The claim handed back by the worker that took it, so the queue offers the
|
|
1020
|
+
invocation again at once instead of waiting out a lease nothing renews.
|
|
1021
|
+
`started_at` keeps the first claim instant, as a reclaim does. */
|
|
1022
|
+
releaseAction: `UPDATE agent_action_invocations SET status = 'queued',
|
|
1023
|
+
lease_owner = NULL, lease_expires_at = NULL
|
|
1024
|
+
WHERE tenant_id = $1 AND id = $2 AND status = 'running'
|
|
1025
|
+
AND lease_owner = $3`,
|
|
933
1026
|
completeAction: `UPDATE agent_action_invocations SET status = 'succeeded',
|
|
934
1027
|
output_json = $1, completed_at = $2, lease_owner = NULL,
|
|
935
1028
|
lease_expires_at = NULL WHERE tenant_id = $3 AND id = $4
|
|
@@ -948,11 +1041,46 @@ export const AGENTS_SQL: AgentsPersistenceStatements = Object.freeze({
|
|
|
948
1041
|
(id, tenant_id, sequence, actor_id, action, subject_type,
|
|
949
1042
|
subject_id, metadata_json, occurred_at, previous_hash, event_hash)
|
|
950
1043
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)`,
|
|
1044
|
+
/* The order agent_runs_tenant_queued_idx already carries, so the walk is an
|
|
1045
|
+
index range scan and a run queued during it lands ahead of the cursor
|
|
1046
|
+
rather than being visited twice. */
|
|
1047
|
+
exportRunsPage1: `SELECT ${RUN_COLUMNS} FROM ${RUN_FROM}
|
|
1048
|
+
WHERE agent_runs.tenant_id = $1
|
|
1049
|
+
ORDER BY queued_at DESC, agent_runs.id LIMIT $2`,
|
|
1050
|
+
exportRunsPage2: `SELECT ${RUN_COLUMNS} FROM ${RUN_FROM}
|
|
1051
|
+
WHERE agent_runs.tenant_id = $1
|
|
1052
|
+
AND (queued_at < $2 OR (queued_at = $3 AND agent_runs.id > $4))
|
|
1053
|
+
ORDER BY queued_at DESC, agent_runs.id LIMIT $5`,
|
|
1054
|
+
exportRunEvents: `SELECT run_id, sequence, event_type, message, metadata_json,
|
|
1055
|
+
occurred_at FROM agent_run_events
|
|
1056
|
+
WHERE tenant_id = $1 AND run_id = ANY($2::text[])
|
|
1057
|
+
ORDER BY run_id, sequence`,
|
|
1058
|
+
/* The inner select applies the batch limit; the child tables of a run go
|
|
1059
|
+
with it through their own cascade. */
|
|
1060
|
+
deleteSettledRunsBefore: `DELETE FROM agent_runs WHERE id IN (
|
|
1061
|
+
SELECT id FROM agent_runs
|
|
1062
|
+
WHERE tenant_id = $1 AND completed_at < $2
|
|
1063
|
+
AND status IN ('succeeded', 'failed', 'cancelled')
|
|
1064
|
+
ORDER BY completed_at LIMIT $3)`,
|
|
1065
|
+
deleteRunsRequestedBy: `DELETE FROM agent_runs WHERE id IN (
|
|
1066
|
+
SELECT id FROM agent_runs
|
|
1067
|
+
WHERE tenant_id = $1 AND requested_by = $2
|
|
1068
|
+
ORDER BY id LIMIT $3)`,
|
|
1069
|
+
pruneMeterRefusals: `DELETE FROM agent_meter_refusals
|
|
1070
|
+
WHERE tenant_id = $1 AND meter = $2 AND period <> $3`,
|
|
1071
|
+
claimMeterRefusal: `INSERT INTO agent_meter_refusals
|
|
1072
|
+
(tenant_id, meter, period, first_refused_at)
|
|
1073
|
+
VALUES ($1, $2, $3, $4)
|
|
1074
|
+
ON CONFLICT (tenant_id, meter, period) DO NOTHING
|
|
1075
|
+
RETURNING tenant_id`,
|
|
951
1076
|
listAuditEvents: `SELECT * FROM agent_audit_events_v4 WHERE tenant_id = $1
|
|
952
1077
|
ORDER BY sequence DESC LIMIT $2`,
|
|
1078
|
+
exportAuditEventsPage: `SELECT * FROM agent_audit_events_v4
|
|
1079
|
+
WHERE tenant_id = $1 AND sequence > $2
|
|
1080
|
+
ORDER BY sequence LIMIT $3`,
|
|
953
1081
|
pageAuditEvents1: `SELECT * FROM agent_audit_events_v4 WHERE tenant_id = $1
|
|
954
|
-
AND
|
|
955
|
-
ORDER BY occurred_at DESC, sequence DESC LIMIT $
|
|
1082
|
+
AND ${AUDIT_PAGE_KEYSET}
|
|
1083
|
+
ORDER BY occurred_at DESC, sequence DESC LIMIT $4`,
|
|
956
1084
|
pageAuditEvents2: `SELECT * FROM agent_audit_events_v4 WHERE tenant_id = $1
|
|
957
1085
|
ORDER BY occurred_at DESC, sequence DESC LIMIT $2`,
|
|
958
1086
|
verifyAuditChainDetailed: `SELECT * FROM agent_audit_events_v4 WHERE tenant_id = $1
|
|
@@ -999,9 +1127,16 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
999
1127
|
tenantId: string,
|
|
1000
1128
|
access: 'read' | 'write',
|
|
1001
1129
|
body: (transaction: DatabaseTransaction) => Promise<T>,
|
|
1130
|
+
options?: AgentReadOptions,
|
|
1002
1131
|
): Promise<T> {
|
|
1003
1132
|
await this.readyPromise;
|
|
1004
|
-
return this.handles.runtime.transaction(body, {
|
|
1133
|
+
return this.handles.runtime.transaction(body, {
|
|
1134
|
+
access,
|
|
1135
|
+
tenantId,
|
|
1136
|
+
/* The caller's budget reaches the statement, so a read nobody waits
|
|
1137
|
+
for stops holding a connection open. */
|
|
1138
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
1139
|
+
});
|
|
1005
1140
|
}
|
|
1006
1141
|
|
|
1007
1142
|
/* The recovery polls have to find work before they know whose it is. They
|
|
@@ -1533,22 +1668,57 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
1533
1668
|
const rows = (await this.#query(transaction, AGENTS_SQL.listAgents, [
|
|
1534
1669
|
tenantId,
|
|
1535
1670
|
])) as unknown as AgentRow[];
|
|
1536
|
-
|
|
1537
|
-
for (const row of rows) {
|
|
1538
|
-
const agent = fromAgentRow(row);
|
|
1539
|
-
agents.push({
|
|
1540
|
-
...agent,
|
|
1541
|
-
procedureIds: await this.#procedureIds(
|
|
1542
|
-
transaction,
|
|
1543
|
-
agent.tenantId,
|
|
1544
|
-
agent.id,
|
|
1545
|
-
),
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
return agents;
|
|
1671
|
+
return await this.#withProcedureIds(transaction, rows);
|
|
1549
1672
|
});
|
|
1550
1673
|
}
|
|
1551
1674
|
|
|
1675
|
+
async listAgentsPage(
|
|
1676
|
+
tenantId: string,
|
|
1677
|
+
query: AgentListQuery,
|
|
1678
|
+
): Promise<AgentListPage> {
|
|
1679
|
+
return this.#tx(tenantId, 'read', async (transaction) => {
|
|
1680
|
+
const rows = (await this.#query(transaction, agentPageStatement(query), [
|
|
1681
|
+
tenantId,
|
|
1682
|
+
query.search === null ? null : likePattern(query.search),
|
|
1683
|
+
...(query.after === null
|
|
1684
|
+
? []
|
|
1685
|
+
: [query.after.sortValue, query.after.id]),
|
|
1686
|
+
query.limit,
|
|
1687
|
+
])) as unknown as (AgentRow & { name_key: string })[];
|
|
1688
|
+
const agents = await this.#withProcedureIds(transaction, rows);
|
|
1689
|
+
const last = agents.at(-1);
|
|
1690
|
+
return {
|
|
1691
|
+
agents,
|
|
1692
|
+
last: last
|
|
1693
|
+
? {
|
|
1694
|
+
nameKey: rows[rows.length - 1]!.name_key,
|
|
1695
|
+
updatedAt: last.updatedAt,
|
|
1696
|
+
id: last.id,
|
|
1697
|
+
}
|
|
1698
|
+
: null,
|
|
1699
|
+
};
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
async #withProcedureIds(
|
|
1704
|
+
transaction: DatabaseTransaction,
|
|
1705
|
+
rows: readonly AgentRow[],
|
|
1706
|
+
): Promise<readonly AgentDefinition[]> {
|
|
1707
|
+
const agents: AgentDefinition[] = [];
|
|
1708
|
+
for (const row of rows) {
|
|
1709
|
+
const agent = fromAgentRow(row);
|
|
1710
|
+
agents.push({
|
|
1711
|
+
...agent,
|
|
1712
|
+
procedureIds: await this.#procedureIds(
|
|
1713
|
+
transaction,
|
|
1714
|
+
agent.tenantId,
|
|
1715
|
+
agent.id,
|
|
1716
|
+
),
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
return agents;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1552
1722
|
providerUsage(
|
|
1553
1723
|
tenantId: string,
|
|
1554
1724
|
providerId: string,
|
|
@@ -1569,8 +1739,8 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
1569
1739
|
])
|
|
1570
1740
|
)[0] as unknown as { count: number | string };
|
|
1571
1741
|
return {
|
|
1572
|
-
definitions: integer(definitions.count),
|
|
1573
|
-
pendingRuns: integer(pendingRuns.count),
|
|
1742
|
+
definitions: integer(definitions.count, 'count'),
|
|
1743
|
+
pendingRuns: integer(pendingRuns.count, 'count'),
|
|
1574
1744
|
};
|
|
1575
1745
|
});
|
|
1576
1746
|
}
|
|
@@ -1881,12 +2051,18 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
1881
2051
|
|
|
1882
2052
|
async listRuns(
|
|
1883
2053
|
tenantId: string,
|
|
1884
|
-
|
|
2054
|
+
query: AgentRunListQuery,
|
|
1885
2055
|
): Promise<readonly AgentRun[]> {
|
|
1886
2056
|
return this.#tx(tenantId, 'read', async (transaction) => {
|
|
1887
|
-
const rows = (await this.#query(transaction,
|
|
2057
|
+
const rows = (await this.#query(transaction, runPageStatement(query), [
|
|
1888
2058
|
tenantId,
|
|
1889
|
-
|
|
2059
|
+
query.status,
|
|
2060
|
+
query.agentId,
|
|
2061
|
+
query.trigger,
|
|
2062
|
+
query.search === null ? null : likePattern(query.search),
|
|
2063
|
+
query.search,
|
|
2064
|
+
...(query.after === null ? [] : [query.after.queuedAt, query.after.id]),
|
|
2065
|
+
query.limit,
|
|
1890
2066
|
])) as unknown as RunRow[];
|
|
1891
2067
|
const runs: AgentRun[] = [];
|
|
1892
2068
|
for (const row of rows) {
|
|
@@ -1939,15 +2115,7 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
1939
2115
|
runId,
|
|
1940
2116
|
afterSequence,
|
|
1941
2117
|
])) as unknown as RunEventRow[]
|
|
1942
|
-
).map(
|
|
1943
|
-
(event): AgentExecutionEvent => ({
|
|
1944
|
-
sequence: integer(event.sequence),
|
|
1945
|
-
type: event.event_type,
|
|
1946
|
-
timestamp: integer(event.occurred_at),
|
|
1947
|
-
message: event.message,
|
|
1948
|
-
metadata: metadata(event.metadata_json),
|
|
1949
|
-
}),
|
|
1950
|
-
);
|
|
2118
|
+
).map(fromRunEventRow);
|
|
1951
2119
|
}
|
|
1952
2120
|
}
|
|
1953
2121
|
|
|
@@ -2482,6 +2650,22 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
2482
2650
|
});
|
|
2483
2651
|
}
|
|
2484
2652
|
|
|
2653
|
+
async releaseAction(
|
|
2654
|
+
tenantId: string,
|
|
2655
|
+
invocationId: string,
|
|
2656
|
+
workerId: string,
|
|
2657
|
+
): Promise<boolean> {
|
|
2658
|
+
return this.#tx(tenantId, 'write', async (transaction) => {
|
|
2659
|
+
return (
|
|
2660
|
+
(await this.#exec(transaction, AGENTS_SQL.releaseAction, [
|
|
2661
|
+
tenantId,
|
|
2662
|
+
invocationId,
|
|
2663
|
+
workerId,
|
|
2664
|
+
])) === 1
|
|
2665
|
+
);
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2485
2669
|
async completeAction(
|
|
2486
2670
|
tenantId: string,
|
|
2487
2671
|
invocationId: string,
|
|
@@ -2587,7 +2771,7 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
2587
2771
|
/* count and every BIGINT arrive as a string from the server driver, so the
|
|
2588
2772
|
next sequence must be added as a number. Without this the chain reads
|
|
2589
2773
|
1, then "11", then "111". */
|
|
2590
|
-
const sequence = integer(previous?.sequence ?? 0) + 1;
|
|
2774
|
+
const sequence = integer(previous?.sequence ?? 0, 'sequence') + 1;
|
|
2591
2775
|
const previousHash = previous?.event_hash ?? null;
|
|
2592
2776
|
const metadataJson = stableMetadata(event.metadata);
|
|
2593
2777
|
const eventHash = auditHash({
|
|
@@ -2632,6 +2816,29 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
2632
2816
|
);
|
|
2633
2817
|
}
|
|
2634
2818
|
|
|
2819
|
+
async claimMeterRefusal(
|
|
2820
|
+
tenantId: string,
|
|
2821
|
+
meter: string,
|
|
2822
|
+
period: string,
|
|
2823
|
+
at: number,
|
|
2824
|
+
): Promise<boolean> {
|
|
2825
|
+
return this.#tx(tenantId, 'write', async (transaction) => {
|
|
2826
|
+
/* The earlier month goes in the same transaction as the claim, so the
|
|
2827
|
+
workspace holds one row per meter however long it keeps refusing. */
|
|
2828
|
+
await this.#exec(transaction, AGENTS_SQL.pruneMeterRefusals, [
|
|
2829
|
+
tenantId,
|
|
2830
|
+
meter,
|
|
2831
|
+
period,
|
|
2832
|
+
]);
|
|
2833
|
+
const claimed = await this.#query<{ tenant_id: string }>(
|
|
2834
|
+
transaction,
|
|
2835
|
+
AGENTS_SQL.claimMeterRefusal,
|
|
2836
|
+
[tenantId, meter, period, at],
|
|
2837
|
+
);
|
|
2838
|
+
return claimed.length > 0;
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2635
2842
|
async listAuditEvents(
|
|
2636
2843
|
tenantId: string,
|
|
2637
2844
|
limit: number,
|
|
@@ -2648,31 +2855,21 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
2648
2855
|
|
|
2649
2856
|
async pageAuditEvents(
|
|
2650
2857
|
tenantId: string,
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
): Promise<AgentAuditPage> {
|
|
2858
|
+
query: AgentAuditListQuery,
|
|
2859
|
+
): Promise<readonly AgentAuditEvent[]> {
|
|
2654
2860
|
return this.#tx(tenantId, 'read', async (transaction) => {
|
|
2655
|
-
const rows = (
|
|
2861
|
+
const rows = (query.after
|
|
2656
2862
|
? await this.#query(transaction, AGENTS_SQL.pageAuditEvents1, [
|
|
2657
2863
|
tenantId,
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
limit + 1,
|
|
2864
|
+
query.after.occurredAt,
|
|
2865
|
+
query.after.sequence,
|
|
2866
|
+
query.limit,
|
|
2662
2867
|
])
|
|
2663
2868
|
: await this.#query(transaction, AGENTS_SQL.pageAuditEvents2, [
|
|
2664
2869
|
tenantId,
|
|
2665
|
-
limit
|
|
2870
|
+
query.limit,
|
|
2666
2871
|
])) as unknown as AuditRow[];
|
|
2667
|
-
|
|
2668
|
-
const last = page[page.length - 1];
|
|
2669
|
-
return {
|
|
2670
|
-
events: page,
|
|
2671
|
-
nextCursor:
|
|
2672
|
-
rows.length > limit && last
|
|
2673
|
-
? `${last.occurredAt}:${last.sequence}`
|
|
2674
|
-
: null,
|
|
2675
|
-
};
|
|
2872
|
+
return rows.map(fromAuditRow);
|
|
2676
2873
|
});
|
|
2677
2874
|
}
|
|
2678
2875
|
|
|
@@ -2718,16 +2915,22 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
2718
2915
|
tenantId: string,
|
|
2719
2916
|
fromDay: string,
|
|
2720
2917
|
toDay: string,
|
|
2918
|
+
options?: AgentReadOptions,
|
|
2721
2919
|
): Promise<readonly AgentUsageDay[]> {
|
|
2722
|
-
return this.#tx(
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2920
|
+
return this.#tx(
|
|
2921
|
+
tenantId,
|
|
2922
|
+
'read',
|
|
2923
|
+
async (transaction) => {
|
|
2924
|
+
return (
|
|
2925
|
+
(await this.#query(transaction, AGENTS_SQL.usageByDay, [
|
|
2926
|
+
tenantId,
|
|
2927
|
+
fromDay,
|
|
2928
|
+
toDay,
|
|
2929
|
+
])) as unknown as UsageRow[]
|
|
2930
|
+
).map((row) => ({ day: row.day, ...fromUsageRow(row) }));
|
|
2931
|
+
},
|
|
2932
|
+
options,
|
|
2933
|
+
);
|
|
2731
2934
|
}
|
|
2732
2935
|
|
|
2733
2936
|
async usageByAgent(
|
|
@@ -2782,5 +2985,94 @@ export class DatabaseAgentRepository implements AgentRepository {
|
|
|
2782
2985
|
});
|
|
2783
2986
|
}
|
|
2784
2987
|
|
|
2988
|
+
/* The operations behind the declared data classes. Each runs on this
|
|
2989
|
+
module's own lease, inside its own tenant-scoped transaction. */
|
|
2990
|
+
|
|
2991
|
+
async exportRunsPage(
|
|
2992
|
+
tenantId: string,
|
|
2993
|
+
after: AgentRunExportCursor | null,
|
|
2994
|
+
limit: number,
|
|
2995
|
+
): Promise<readonly ExportedAgentRun[]> {
|
|
2996
|
+
return this.#tx(tenantId, 'read', async (transaction) => {
|
|
2997
|
+
const runs = (after === null
|
|
2998
|
+
? await this.#query(transaction, AGENTS_SQL.exportRunsPage1, [
|
|
2999
|
+
tenantId,
|
|
3000
|
+
limit,
|
|
3001
|
+
])
|
|
3002
|
+
: await this.#query(transaction, AGENTS_SQL.exportRunsPage2, [
|
|
3003
|
+
tenantId,
|
|
3004
|
+
after.queuedAt,
|
|
3005
|
+
after.queuedAt,
|
|
3006
|
+
after.id,
|
|
3007
|
+
limit,
|
|
3008
|
+
])) as unknown as RunRow[];
|
|
3009
|
+
if (runs.length === 0) return [];
|
|
3010
|
+
/* One query for the steps of the whole page: a run is a row, not a
|
|
3011
|
+
round trip. */
|
|
3012
|
+
const events = (await this.#query(
|
|
3013
|
+
transaction,
|
|
3014
|
+
AGENTS_SQL.exportRunEvents,
|
|
3015
|
+
[tenantId, runs.map((run) => run.id)],
|
|
3016
|
+
)) as unknown as RunEventPageRow[];
|
|
3017
|
+
const steps = new Map<string, AgentExecutionEvent[]>();
|
|
3018
|
+
for (const event of events) {
|
|
3019
|
+
const existing = steps.get(event.run_id);
|
|
3020
|
+
if (existing) existing.push(fromRunEventRow(event));
|
|
3021
|
+
else steps.set(event.run_id, [fromRunEventRow(event)]);
|
|
3022
|
+
}
|
|
3023
|
+
return runs.map((run) => ({
|
|
3024
|
+
run: fromRunRow(run),
|
|
3025
|
+
events: steps.get(run.id) ?? [],
|
|
3026
|
+
}));
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
async deleteSettledRunsBefore(
|
|
3031
|
+
tenantId: string,
|
|
3032
|
+
before: number,
|
|
3033
|
+
limit: number,
|
|
3034
|
+
): Promise<number> {
|
|
3035
|
+
return this.#tx(tenantId, 'write', (transaction) =>
|
|
3036
|
+
this.#exec(transaction, AGENTS_SQL.deleteSettledRunsBefore, [
|
|
3037
|
+
tenantId,
|
|
3038
|
+
before,
|
|
3039
|
+
limit,
|
|
3040
|
+
]),
|
|
3041
|
+
);
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
/* A run this removes while a worker holds it takes its lease with it: the
|
|
3045
|
+
next renewal finds no row, the worker stops the execution as it does for
|
|
3046
|
+
any lost lease, and its settle write reaches nothing. */
|
|
3047
|
+
async deleteRunsRequestedBy(
|
|
3048
|
+
tenantId: string,
|
|
3049
|
+
accountId: string,
|
|
3050
|
+
limit: number,
|
|
3051
|
+
): Promise<number> {
|
|
3052
|
+
return this.#tx(tenantId, 'write', (transaction) =>
|
|
3053
|
+
this.#exec(transaction, AGENTS_SQL.deleteRunsRequestedBy, [
|
|
3054
|
+
tenantId,
|
|
3055
|
+
accountId,
|
|
3056
|
+
limit,
|
|
3057
|
+
]),
|
|
3058
|
+
);
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
async exportAuditEventsPage(
|
|
3062
|
+
tenantId: string,
|
|
3063
|
+
afterSequence: number,
|
|
3064
|
+
limit: number,
|
|
3065
|
+
): Promise<readonly AgentAuditEvent[]> {
|
|
3066
|
+
return this.#tx(tenantId, 'read', async (transaction) =>
|
|
3067
|
+
(
|
|
3068
|
+
(await this.#query(transaction, AGENTS_SQL.exportAuditEventsPage, [
|
|
3069
|
+
tenantId,
|
|
3070
|
+
afterSequence,
|
|
3071
|
+
limit,
|
|
3072
|
+
])) as unknown as AuditRow[]
|
|
3073
|
+
).map(fromAuditRow),
|
|
3074
|
+
);
|
|
3075
|
+
}
|
|
3076
|
+
|
|
2785
3077
|
async close(): Promise<void> {}
|
|
2786
3078
|
}
|