thinkwork-cli 0.12.12 → 0.12.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -38
- package/dist/{api-client-ASJWIG3Z.js → api-client-4VT3FWOH.js} +1 -1
- package/dist/{chunk-JEHV35EU.js → chunk-H7AB42ES.js} +340 -30
- package/dist/cli.js +22123 -9219
- package/dist/commands/enterprise/templates/deploy-repo/.github/workflows/deploy.yml +17 -6
- package/dist/commands/enterprise/templates/deploy-repo/docs/runbook.md +81 -9
- package/dist/commands/enterprise/templates/deploy-repo/scripts/apply-release.mjs +183 -21
- package/dist/commands/enterprise/templates/deploy-repo/scripts/smoke.mjs +1 -2
- package/dist/commands/enterprise/templates/deploy-repo/terraform/main.tf +286 -0
- package/dist/drizzle/0000_petite_marvel_apes.sql +1188 -0
- package/dist/drizzle/0001_milky_surge.sql +103 -0
- package/dist/drizzle/0002_aberrant_mattie_franklin.sql +41 -0
- package/dist/drizzle/0003_exotic_ogun.sql +3 -0
- package/dist/drizzle/0004_glamorous_magneto.sql +2 -0
- package/dist/drizzle/0005_ancient_nocturne.sql +2 -0
- package/dist/drizzle/0006_new_colonel_america.sql +2 -0
- package/dist/drizzle/0007_unique_external_task_id.sql +31 -0
- package/dist/drizzle/0008_external_task_id_column.sql +43 -0
- package/dist/drizzle/0009_evaluations.sql +64 -0
- package/dist/drizzle/0010_eval_agent_template.sql +2 -0
- package/dist/drizzle/0011_eval_run_template.sql +2 -0
- package/dist/drizzle/0012_eval_seed_unique.sql +16 -0
- package/dist/drizzle/0013_motionless_white_queen.sql +140 -0
- package/dist/drizzle/0014_wiki_aggregation.sql +11 -0
- package/dist/drizzle/0015_pg_trgm_alias_title_indexes.sql +9 -0
- package/dist/drizzle/0016_wiki_schema_drops.sql +24 -0
- package/dist/drizzle/0017_wiki_places.sql +46 -0
- package/dist/drizzle/0018_agent_workspace_overlay.sql +26 -0
- package/dist/drizzle/0018_cool_firebird.sql +24 -0
- package/dist/drizzle/0018_skill_runs.sql +84 -0
- package/dist/drizzle/0019_condemned_dragon_man.sql +95 -0
- package/dist/drizzle/0019_webhook_skill_runs.sql +58 -0
- package/dist/drizzle/0020_crazy_the_anarchist.sql +9 -0
- package/dist/drizzle/0020_mutation_idempotency.sql +64 -0
- package/dist/drizzle/0021_crm_work_links.sql +76 -0
- package/dist/drizzle/0021_skill_runs_completion_hmac.sql +33 -0
- package/dist/drizzle/0022_add_billing_tables.sql +70 -0
- package/dist/drizzle/0022_seed_thinkwork_admin_permissions.sql +160 -0
- package/dist/drizzle/0022_stripe_billing_indexes.sql +48 -0
- package/dist/drizzle/0023_tenants_deactivation.sql +27 -0
- package/dist/drizzle/0024_tenant_mcp_admin_keys.sql +63 -0
- package/dist/drizzle/0025_v1_agent_architecture.sql +182 -0
- package/dist/drizzle/0026_thread_turns_add_kind.sql +28 -0
- package/dist/drizzle/0027_capability_catalog_and_manifests.sql +219 -0
- package/dist/drizzle/0028_aws_s3_extension.sql +26 -0
- package/dist/drizzle/0029_collapse_execution_types.sql +42 -0
- package/dist/drizzle/0030_retire_composition_primitives.sql +48 -0
- package/dist/drizzle/0031_thread_cleanup_drops.sql +131 -0
- package/dist/drizzle/0032_add_browser_automation_template_config.sql +24 -0
- package/dist/drizzle/0033_agent_operation_leases.sql +32 -0
- package/dist/drizzle/0034_agent_workspace_events.sql +116 -0
- package/dist/drizzle/0035_workspace_review_decisions.sql +19 -0
- package/dist/drizzle/0036_user_scoped_memory_wiki.sql +152 -0
- package/dist/drizzle/0037_user_profile_operating_model.sql +34 -0
- package/dist/drizzle/0042_agent_runtime_selector.sql +41 -0
- package/dist/drizzle/0043_wiki_search_tsv_tokenization.sql +48 -0
- package/dist/drizzle/0044_add_web_search_template_config.sql +7 -0
- package/dist/drizzle/0045_add_send_email_template_config.sql +7 -0
- package/dist/drizzle/0046_tenant_mcp_context_tools.sql +26 -0
- package/dist/drizzle/0047_add_context_engine_template_config.sql +7 -0
- package/dist/drizzle/0048_tenant_context_provider_settings.sql +22 -0
- package/dist/drizzle/0050_brain_v0_entity_subtype.sql +29 -0
- package/dist/drizzle/0051_brain_v0_tenant_entity_pages.sql +170 -0
- package/dist/drizzle/0052_brain_v0_external_refs.sql +41 -0
- package/dist/drizzle/0053_brain_v0_unresolved_mentions_subtype.sql +48 -0
- package/dist/drizzle/0054_wiki_compile_jobs_input.sql +28 -0
- package/dist/drizzle/0055_routines_stepfunctions_substrate.sql +202 -0
- package/dist/drizzle/0056_routine_step_events_dedup_idx.sql +25 -0
- package/dist/drizzle/0057_archive_legacy_python_routines.sql +36 -0
- package/dist/drizzle/0058_routines_visibility_and_owning_agent.sql +61 -0
- package/dist/drizzle/0061_routine_execution_asl_version_id.sql +29 -0
- package/dist/drizzle/0062_migrate_pi_to_flue.sql +110 -0
- package/dist/drizzle/0063_threads_session_data.sql +23 -0
- package/dist/drizzle/0064_tenant_credentials.sql +65 -0
- package/dist/drizzle/0067_thinkwork_computers_phase_one.sql +174 -0
- package/dist/drizzle/0068_drop_system_workflows_and_activation.sql +115 -0
- package/dist/drizzle/0069_compliance_schema.sql +364 -0
- package/dist/drizzle/0070_compliance_aurora_roles.sql +171 -0
- package/dist/drizzle/0072_threads_computer_ownership.sql +24 -0
- package/dist/drizzle/0073_compliance_tenant_anchor_state.sql +105 -0
- package/dist/drizzle/0074_compliance_event_hash_index.sql +49 -0
- package/dist/drizzle/0075_scheduled_jobs_computer_ownership.sql +27 -0
- package/dist/drizzle/0076_scheduled_jobs_marco_backfill.sql +69 -0
- package/dist/drizzle/0077_computers_primary_agent_id.sql +38 -0
- package/dist/drizzle/0078_tenant_customize_catalog.sql +46 -0
- package/dist/drizzle/0079_seed_tenant_customize_catalog.sql +53 -0
- package/dist/drizzle/0081_routines_catalog_slug.sql +42 -0
- package/dist/drizzle/0082_messages_parts_jsonb.sql +52 -0
- package/dist/drizzle/0083_computer_runbooks.sql +103 -0
- package/dist/drizzle/0084_artifacts_favorited_at.sql +32 -0
- package/dist/drizzle/0085_seed_thinkwork_computer_default_template.sql +46 -0
- package/dist/drizzle/0086_update_default_template_models.sql +19 -0
- package/dist/drizzle/0087_retire_oss_connectors.sql +77 -0
- package/dist/drizzle/0088_compliance_event_types_finance_pilot.sql +37 -0
- package/dist/drizzle/0089_remove_maniflow_eval_seeds.sql +81 -0
- package/dist/drizzle/0089_wiki_schema_extraction.sql +315 -0
- package/dist/drizzle/0090_brain_schema_extraction.sql +274 -0
- package/dist/drizzle/0091_drop_wiki_brain_compat_views.sql +118 -0
- package/dist/drizzle/0092_finish_oss_connector_retirement.sql +97 -0
- package/dist/drizzle/0093_eval_runs_scheduled_job_id.sql +23 -0
- package/dist/drizzle/0094_slack_workspace_app.sql +140 -0
- package/dist/drizzle/0095_eval_runs_computer_id.sql +22 -0
- package/dist/drizzle/0096_true_redteam_eval_seed_cleanup.sql +67 -0
- package/dist/drizzle/0097_shared_computers.sql +191 -0
- package/dist/drizzle/0098_business_ontology.sql +587 -0
- package/dist/drizzle/0099_thread_idle_learning.sql +145 -0
- package/dist/drizzle/0100_ontology_gated_brain_dynamic_subtypes.sql +7 -0
- package/dist/drizzle/0101_ontology_gated_unresolved_mentions_dynamic_subtypes.sql +7 -0
- package/dist/drizzle/0102_wiki_brain_owner_repair.sql +87 -0
- package/dist/drizzle/0103_brain_section_source_trigger_repair.sql +75 -0
- package/dist/drizzle/0104_expand_seed_ontology_for_user_memory.sql +166 -0
- package/dist/drizzle/0105_spaces_domain.sql +349 -0
- package/dist/drizzle/0106_expand_seed_ontology_for_triples.sql +173 -0
- package/dist/drizzle/0106_space_threads_participants.sql +197 -0
- package/dist/drizzle/0107_linked_task_mirror.sql +245 -0
- package/dist/drizzle/0108_message_mentions.sql +95 -0
- package/dist/drizzle/0109_space_owned_threads.sql +217 -0
- package/dist/drizzle/0110_thread_participant_read_state.sql +21 -0
- package/dist/drizzle/0111_agents_tenant_name_unique.sql +38 -0
- package/dist/drizzle/0112_recast_spaces_as_contextual_workrooms.sql +138 -0
- package/dist/drizzle/0113_agents_own_runtime_fields.sql +48 -0
- package/dist/drizzle/0114_migrate_templates_to_agents_and_spaces.sql +361 -0
- package/dist/drizzle/0115_remove_computer_eval_template_dependencies.sql +69 -0
- package/dist/drizzle/0116_backfill_thread_participants_access.sql +126 -0
- package/dist/drizzle/0117_space_access_mode.sql +40 -0
- package/dist/drizzle/0118_normalize_tenant_member_principal_type.sql +41 -0
- package/dist/drizzle/0119_space_knowledge_bases.sql +126 -0
- package/dist/drizzle/0120_space_automations.sql +58 -0
- package/dist/drizzle/0121_drop_computer_runbooks.sql +26 -0
- package/dist/drizzle/0122_space_email_triggers.sql +24 -0
- package/dist/drizzle/0123_single_platform_agent_and_overrides.sql +58 -0
- package/dist/drizzle/0124_thread_turns_finalized_at.sql +17 -0
- package/dist/drizzle/0125_drop_space_agent_assignments.sql +42 -0
- package/dist/drizzle/0126_migrate_flue_to_pi.sql +42 -0
- package/dist/drizzle/0127_runtime_type_observability.sql +28 -0
- package/dist/drizzle/0128_drop_eval_test_cases_agent_id.sql +37 -0
- package/dist/drizzle/0129_drop_code_factory_tables.sql +43 -0
- package/dist/drizzle/0129_eval_results_system_prompt.sql +30 -0
- package/dist/drizzle/0130_drop_teams_and_team_id_columns.sql +54 -0
- package/dist/drizzle/0131_drop_skill_catalog_and_tenant_skills.sql +33 -0
- package/dist/drizzle/0132_drop_computer_tables.sql +31 -0
- package/dist/drizzle/0133_drop_seed_view_tombstones.sql +79 -0
- package/dist/drizzle/0133_thread_turns_system_prompt.sql +22 -0
- package/dist/drizzle/0134_drop_dead_agent_runtime_tables.sql +53 -0
- package/dist/drizzle/0135_native_checklist_linked_tasks.sql +48 -0
- package/dist/drizzle/0136_goal_ledger.sql +55 -0
- package/dist/drizzle/0136_space_email_trigger_status.sql +66 -0
- package/dist/drizzle/0137_thread_participant_pins.sql +25 -0
- package/dist/drizzle/0138_users_cognito_sub.sql +30 -0
- package/dist/drizzle/0139_mobile_turn_client_id.sql +23 -0
- package/dist/drizzle/0140_workspace_folder_names.sql +36 -0
- package/dist/drizzle/0141_eval_runs_desktop_pi_provenance.sql +31 -0
- package/dist/drizzle/0142_pi_only_agent_runtime.sql +61 -0
- package/dist/drizzle/0143_add_web_extract_builtin_config.sql +28 -0
- package/dist/drizzle/0144_skill_catalog_index.sql +40 -0
- package/dist/drizzle/0145_knowledge_graph_thread_ingest.sql +512 -0
- package/dist/drizzle/0146_knowledge_graph_source_scope.sql +413 -0
- package/dist/drizzle/0147_knowledge_graph_scope_trigger_qualification.sql +211 -0
- package/dist/drizzle/0148_user_cost_attribution.sql +171 -0
- package/dist/drizzle/0149_managed_mcp_servers.sql +64 -0
- package/dist/drizzle/0149_user_model_approvals.sql +89 -0
- package/dist/drizzle/0150_bootstrap_first_admin_claim.sql +11 -0
- package/dist/drizzle/0151_managed_deployments.sql +91 -0
- package/dist/drizzle/0152_agent_profiles.sql +81 -0
- package/dist/drizzle/0153_message_mentions_agent_profile.sql +9 -0
- package/dist/drizzle/0154_customer_deployment_sessions.sql +61 -0
- package/dist/drizzle/0155_tenant_model_catalog.sql +152 -0
- package/dist/drizzle/0156_bootstrap_credential_leases.sql +52 -0
- package/dist/drizzle/0157_knowledge_graph_observations_source.sql +79 -0
- package/dist/drizzle/0158_pending_user_questions.sql +80 -0
- package/dist/drizzle/0158_wiki_tenant_scope.sql +38 -0
- package/dist/drizzle/0159_agent_profiles_space_local.sql +49 -0
- package/dist/drizzle/0159_application_plugins.sql +193 -0
- package/dist/drizzle/0159_eval_scoring_version.sql +46 -0
- package/dist/drizzle/0160_compliance_event_types_plugins.sql +37 -0
- package/dist/drizzle/0160_eval_datasets.sql +75 -0
- package/dist/drizzle/0160_eval_results_thread_turn.sql +35 -0
- package/dist/drizzle/0161_eval_run_pinning.sql +54 -0
- package/dist/drizzle/0161_tenant_mcp_servers_plugin_source.sql +62 -0
- package/dist/drizzle/0162_eval_result_override.sql +49 -0
- package/dist/drizzle/0163_eval_replay_tool_allowlist.sql +50 -0
- package/dist/drizzle/0164_eval_replay_tool_override_mode.sql +52 -0
- package/dist/drizzle/0165_plugin_premium_entitlements.sql +153 -0
- package/dist/drizzle/0166_company_brain_substrate_contract.sql +386 -0
- package/dist/drizzle/0167_company_brain_artifact_manifest_runtime.sql +85 -0
- package/dist/drizzle/0168_eval_skill_gate.sql +44 -0
- package/dist/drizzle/0169_release_update_jobs.sql +67 -0
- package/dist/drizzle/0170_email_channel_plugin.sql +291 -0
- package/dist/drizzle/0171_linked_task_external_providers.sql +30 -0
- package/dist/drizzle/0172_email_channel_sendgrid_provider.sql +8 -0
- package/dist/drizzle/0173_auth_provider_resources.sql +83 -0
- package/dist/drizzle/0174_workos_auth_bridges.sql +37 -0
- package/dist/drizzle/0175_workos_auth_sessions.sql +38 -0
- package/dist/drizzle/0176_n8n_agent_step_runs.sql +107 -0
- package/dist/drizzle/0177_workflow_control_plane.sql +281 -0
- package/dist/drizzle/0178_workflow_backfill_existing_routines.sql +525 -0
- package/dist/drizzle/0179_tenant_goal_budget_settings.sql +21 -0
- package/dist/drizzle/0180_skill_drafts.sql +89 -0
- package/dist/drizzle/0181_skill_draft_publish_status.sql +21 -0
- package/dist/drizzle/0182_agent_loops.sql +260 -0
- package/dist/drizzle/0183_okf_artifact_manifests.sql +52 -0
- package/dist/drizzle/0184_skill_catalog_trust_cache.sql +35 -0
- package/dist/drizzle/0185_agent_loop_space.sql +16 -0
- package/dist/drizzle/0186_tenant_mcp_runtime_metadata.sql +10 -0
- package/dist/drizzle/0187_native_work_items.sql +220 -0
- package/dist/drizzle/0188_company_etl_plugin_rename.sql +99 -0
- package/dist/drizzle/0189_trace_cost_substrate.sql +247 -0
- package/dist/drizzle/0190_billing_export_reconciliation.sql +101 -0
- package/dist/drizzle/0191_open_engine_work_item_queue.sql +66 -0
- package/dist/drizzle/0192_work_item_labels.sql +44 -0
- package/dist/drizzle/0193_work_item_documents.sql +31 -0
- package/dist/drizzle/0194_memory_retain_attempts.sql +103 -0
- package/dist/drizzle/0194_work_item_comments.sql +35 -0
- package/dist/drizzle/0195_plugin_app_overlays.sql +45 -0
- package/dist/drizzle/0196_pi_extensions.sql +118 -0
- package/dist/drizzle/0197_eval_profiles.sql +150 -0
- package/dist/drizzle/0198_eval_runs_unstable.sql +27 -0
- package/dist/drizzle/0199_eval_runs_cost_partial.sql +27 -0
- package/dist/drizzle/meta/_journal.json +160 -0
- package/dist/plugins/README.md +162 -0
- package/dist/plugins/catalog/package.json +40 -0
- package/dist/plugins/catalog/scripts/build-catalog.ts +120 -0
- package/dist/plugins/catalog/scripts/generate-plugin-registry.ts +144 -0
- package/dist/plugins/catalog/src/__tests__/build-catalog.test.ts +86 -0
- package/dist/plugins/catalog/src/__tests__/catalog.test.ts +308 -0
- package/dist/plugins/catalog/src/__tests__/contracts.test.ts +861 -0
- package/dist/plugins/catalog/src/__tests__/plugin-package.test.ts +124 -0
- package/dist/plugins/catalog/src/__tests__/plugin-registry.test.ts +120 -0
- package/dist/plugins/catalog/src/catalog.ts +434 -0
- package/dist/plugins/catalog/src/contracts.ts +1498 -0
- package/dist/plugins/catalog/src/index.ts +4 -0
- package/dist/plugins/catalog/src/plugin-package.ts +171 -0
- package/dist/plugins/catalog/src/registry/generated-first-party.ts +76 -0
- package/dist/plugins/catalog/src/registry/index.ts +1 -0
- package/dist/plugins/catalog/tsconfig.json +8 -0
- package/dist/plugins/company-brain/README.md +37 -0
- package/dist/plugins/company-brain/package.json +33 -0
- package/dist/plugins/company-brain/runtime/cognee/Dockerfile +11 -0
- package/dist/plugins/company-brain/smoke/cognee-managed-app-smoke.mjs +458 -0
- package/dist/plugins/company-brain/smoke/cognee-memory-cutover-smoke.mjs +539 -0
- package/dist/plugins/company-brain/smoke/company-brain-context-engine-smoke.mjs +312 -0
- package/dist/plugins/company-brain/smoke/company-brain-operations-smoke.mjs +449 -0
- package/dist/plugins/company-brain/smoke/company-brain-plugin-smoke.mjs +655 -0
- package/dist/plugins/company-brain/smoke/hindsight-memory-isolation-smoke.mjs +474 -0
- package/dist/plugins/company-brain/src/api/cognee-client.ts +896 -0
- package/dist/plugins/company-brain/src/api/cognee-cluster-identity.ts +49 -0
- package/dist/plugins/company-brain/src/api/cognee-memory-scope.ts +84 -0
- package/dist/plugins/company-brain/src/api/context-engine-provider.ts +888 -0
- package/dist/plugins/company-brain/src/api/migration.ts +665 -0
- package/dist/plugins/company-brain/src/deployment/cognee-managed-app.ts +396 -0
- package/dist/plugins/company-brain/src/index.ts +62 -0
- package/dist/plugins/company-brain/src/manifest.ts +112 -0
- package/dist/plugins/company-brain/terraform/cognee/README.md +263 -0
- package/dist/plugins/company-brain/terraform/cognee/main.tf +766 -0
- package/dist/plugins/company-brain/terraform/cognee/outputs.tf +144 -0
- package/dist/plugins/company-brain/terraform/cognee/variables.tf +402 -0
- package/dist/plugins/company-brain/test/api/cognee-client.test.ts +562 -0
- package/dist/plugins/company-brain/test/api/cognee-memory-scope.test.ts +74 -0
- package/dist/plugins/company-brain/test/api/context-engine-provider.test.ts +447 -0
- package/dist/plugins/company-brain/test/api/migration.test.ts +465 -0
- package/dist/plugins/company-brain/test/manifest.test.ts +95 -0
- package/dist/plugins/company-brain/tsconfig.json +8 -0
- package/dist/plugins/company-data/README.md +49 -0
- package/dist/plugins/company-data/package.json +21 -0
- package/dist/plugins/company-data/src/index.ts +30 -0
- package/dist/plugins/company-data/src/manifest.ts +26 -0
- package/dist/plugins/company-data/test/manifest.test.ts +116 -0
- package/dist/plugins/company-data/tsconfig.json +8 -0
- package/dist/plugins/company-etl/README.md +46 -0
- package/dist/plugins/company-etl/package.json +21 -0
- package/dist/plugins/company-etl/src/index.ts +29 -0
- package/dist/plugins/company-etl/src/manifest.ts +26 -0
- package/dist/plugins/company-etl/test/manifest.test.ts +108 -0
- package/dist/plugins/company-etl/tsconfig.json +8 -0
- package/dist/plugins/email-channel/README.md +41 -0
- package/dist/plugins/email-channel/package.json +22 -0
- package/dist/plugins/email-channel/src/index.ts +36 -0
- package/dist/plugins/email-channel/src/manifest.ts +44 -0
- package/dist/plugins/email-channel/src/provider-contract.ts +36 -0
- package/dist/plugins/email-channel/test/manifest.test.ts +119 -0
- package/dist/plugins/email-channel/tsconfig.json +8 -0
- package/dist/plugins/lastmile/README.md +50 -0
- package/dist/plugins/lastmile/package.json +23 -0
- package/dist/plugins/lastmile/smoke/lastmile-plugin-smoke.mjs +661 -0
- package/dist/plugins/lastmile/src/api/tasks-adapter.ts +572 -0
- package/dist/plugins/lastmile/src/discovery.fixture.ts +64 -0
- package/dist/plugins/lastmile/src/index.ts +46 -0
- package/dist/plugins/lastmile/src/manifest.ts +139 -0
- package/dist/plugins/lastmile/test/api/tasks-adapter.test.ts +266 -0
- package/dist/plugins/lastmile/test/discovery.test.ts +88 -0
- package/dist/plugins/lastmile/tsconfig.json +8 -0
- package/dist/plugins/n8n/README.md +201 -0
- package/dist/plugins/n8n/n8n-app/README.md +33 -0
- package/dist/plugins/n8n/n8n-app/package.json +23 -0
- package/dist/plugins/n8n/n8n-app/src/application-config.ts +45 -0
- package/dist/plugins/n8n/n8n-app/src/front-components/thinkwork-workflows.front-component.tsx +970 -0
- package/dist/plugins/n8n/n8n-app/src/lib/n8n-app-data.ts +190 -0
- package/dist/plugins/n8n/n8n-app/src/vite-env.d.ts +7 -0
- package/dist/plugins/n8n/n8n-app/tsconfig.json +15 -0
- package/dist/plugins/n8n/package.json +35 -0
- package/dist/plugins/n8n/runtime/Dockerfile +18 -0
- package/dist/plugins/n8n/runtime/n8n-task-runners.json +14 -0
- package/dist/plugins/n8n/runtime/n8n-task-runners.json.template +14 -0
- package/dist/plugins/n8n/runtime/package-lock.json +13 -0
- package/dist/plugins/n8n/runtime/package.json +7 -0
- package/dist/plugins/n8n/scripts/sync-thinkwork-app.mjs +268 -0
- package/dist/plugins/n8n/smoke/README.md +95 -0
- package/dist/plugins/n8n/smoke/n8n-agent-step-bridge-smoke.mjs +866 -0
- package/dist/plugins/n8n/smoke/n8n-integrated-app-smoke.mjs +262 -0
- package/dist/plugins/n8n/smoke/n8n-managed-app-smoke.mjs +409 -0
- package/dist/plugins/n8n/smoke/n8n-mcp-smoke.mjs +624 -0
- package/dist/plugins/n8n/src/deployment/image-build.ts +172 -0
- package/dist/plugins/n8n/src/deployment/managed-app.ts +429 -0
- package/dist/plugins/n8n/src/index.ts +79 -0
- package/dist/plugins/n8n/src/manifest.ts +403 -0
- package/dist/plugins/n8n/src/package-config.ts +186 -0
- package/dist/plugins/n8n/src/skills/n8n-workflow-operator/SKILL.md +76 -0
- package/dist/plugins/n8n/src/skills/n8n-workflow-operator/references/mcp-tooling.md +40 -0
- package/dist/plugins/n8n/src/skills/n8n-workflow-operator/references/validation-and-handoff.md +40 -0
- package/dist/plugins/n8n/src/skills/n8n-workflow-operator/references/workflow-authoring.md +45 -0
- package/dist/plugins/n8n/terraform/n8n/README.md +113 -0
- package/dist/plugins/n8n/terraform/n8n/main.tf +918 -0
- package/dist/plugins/n8n/terraform/n8n/outputs.tf +124 -0
- package/dist/plugins/n8n/terraform/n8n/scripts/sync-database.py +250 -0
- package/dist/plugins/n8n/terraform/n8n/scripts/test_sync_database.py +55 -0
- package/dist/plugins/n8n/terraform/n8n/variables.tf +354 -0
- package/dist/plugins/n8n/test/image-build.test.ts +118 -0
- package/dist/plugins/n8n/test/integrated-app-contract.test.ts +353 -0
- package/dist/plugins/n8n/test/manifest.test.ts +278 -0
- package/dist/plugins/n8n/test/package-config.test.ts +57 -0
- package/dist/plugins/n8n/tsconfig.json +8 -0
- package/dist/plugins/sendgrid/README.md +30 -0
- package/dist/plugins/sendgrid/package.json +22 -0
- package/dist/plugins/sendgrid/src/index.ts +36 -0
- package/dist/plugins/sendgrid/src/manifest.ts +37 -0
- package/dist/plugins/sendgrid/src/provider-contract.ts +14 -0
- package/dist/plugins/sendgrid/test/manifest.test.ts +80 -0
- package/dist/plugins/sendgrid/tsconfig.json +8 -0
- package/dist/plugins/twenty/README.md +78 -0
- package/dist/plugins/twenty/package.json +27 -0
- package/dist/plugins/twenty/scripts/__tests__/sync-thinkwork-app.test.mjs +67 -0
- package/dist/plugins/twenty/scripts/sync-thinkwork-app.mjs +185 -0
- package/dist/plugins/twenty/scripts/wire-thinkwork-workflow.mjs +658 -0
- package/dist/plugins/twenty/smoke/twenty-managed-app-smoke.mjs +359 -0
- package/dist/plugins/twenty/smoke/twenty-mcp-oauth-smoke.mjs +574 -0
- package/dist/plugins/twenty/src/api/cutover.ts +209 -0
- package/dist/plugins/twenty/src/deployment/managed-app.ts +253 -0
- package/dist/plugins/twenty/src/index.ts +55 -0
- package/dist/plugins/twenty/src/manifest.ts +259 -0
- package/dist/plugins/twenty/terraform/twenty/README.md +97 -0
- package/dist/plugins/twenty/terraform/twenty/main.tf +829 -0
- package/dist/plugins/twenty/terraform/twenty/outputs.tf +79 -0
- package/dist/plugins/twenty/terraform/twenty/variables.tf +268 -0
- package/dist/plugins/twenty/test/api/cutover.test.ts +183 -0
- package/dist/plugins/twenty/test/manifest.test.ts +463 -0
- package/dist/plugins/twenty/tsconfig.json +9 -0
- package/dist/plugins/twenty/twenty-app/.nvmrc +1 -0
- package/dist/plugins/twenty/twenty-app/README.md +148 -0
- package/dist/plugins/twenty/twenty-app/package.json +30 -0
- package/dist/plugins/twenty/twenty-app/src/application-config.ts +44 -0
- package/dist/plugins/twenty/twenty-app/src/constants/universal-identifiers.ts +18 -0
- package/dist/plugins/twenty/twenty-app/src/default-role.ts +24 -0
- package/dist/plugins/twenty/twenty-app/src/front-components/thinkwork-settings.front-component.tsx +299 -0
- package/dist/plugins/twenty/twenty-app/src/logic-functions/thinkwork-webhook.logic-function.ts +354 -0
- package/dist/plugins/twenty/twenty-app/tsconfig.json +14 -0
- package/dist/plugins/twenty/twenty-app/yarn.lock +4144 -0
- package/dist/plugins/workos-auth/package.json +22 -0
- package/dist/plugins/workos-auth/src/index.ts +30 -0
- package/dist/plugins/workos-auth/src/manifest.ts +40 -0
- package/dist/plugins/workos-auth/src/provider-contract.ts +39 -0
- package/dist/plugins/workos-auth/test/manifest.test.ts +94 -0
- package/dist/plugins/workos-auth/tsconfig.json +8 -0
- package/dist/scripts/bootstrap-workspace.sh +162 -0
- package/dist/scripts/post-deploy.sh +290 -0
- package/dist/terraform/examples/greenfield/main.tf +903 -75
- package/dist/terraform/examples/greenfield/terraform.tfvars.example +67 -8
- package/dist/terraform/modules/app/agentcore-code-interpreter/Dockerfile.sandbox-base +2 -2
- package/dist/terraform/modules/app/agentcore-code-interpreter/README.md +8 -9
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/sitecustomize.py +227 -0
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/test_sitecustomize.py +277 -0
- package/dist/terraform/modules/app/agentcore-memory/README.md +6 -6
- package/dist/terraform/modules/app/agentcore-memory/main.tf +1 -1
- package/dist/terraform/modules/app/agentcore-memory/scripts/create_or_find_memory.sh +40 -9
- package/dist/terraform/modules/app/agentcore-pi/README.md +61 -0
- package/dist/terraform/modules/app/agentcore-pi/main.tf +453 -0
- package/dist/terraform/modules/app/agentcore-pi/outputs.tf +38 -0
- package/dist/terraform/modules/app/agentcore-pi/variables.tf +145 -0
- package/dist/terraform/modules/app/agentcore-platform/main.tf +83 -0
- package/dist/terraform/modules/app/agentcore-runtime/main.tf +9 -11
- package/dist/terraform/modules/app/appsync-subscriptions/main.tf +5 -1
- package/dist/terraform/modules/app/customer-domain/main.tf +483 -0
- package/dist/terraform/modules/app/deployment-control-plane/README.md +47 -0
- package/dist/terraform/modules/app/deployment-control-plane/buildspec.yml +24 -0
- package/dist/terraform/modules/app/deployment-control-plane/main.tf +614 -0
- package/dist/terraform/modules/app/deployment-control-plane/outputs.tf +54 -0
- package/dist/terraform/modules/app/deployment-control-plane/runner.py +4720 -0
- package/dist/terraform/modules/app/deployment-control-plane/test_runner_bundle.py +3026 -0
- package/dist/terraform/modules/app/deployment-control-plane/variables.tf +96 -0
- package/dist/terraform/modules/app/hindsight-memory/README.md +25 -23
- package/dist/terraform/modules/app/hindsight-memory/main.tf +26 -2
- package/dist/terraform/modules/app/lambda-api/eval-fanout.tf +17 -50
- package/dist/terraform/modules/app/lambda-api/handlers.tf +1290 -679
- package/dist/terraform/modules/app/lambda-api/iam-grouped.tf +933 -0
- package/dist/terraform/modules/app/lambda-api/main.tf +14 -527
- package/dist/terraform/modules/app/lambda-api/mcp-oauth.tf +3 -19
- package/dist/terraform/modules/app/lambda-api/outputs.tf +50 -6
- package/dist/terraform/modules/app/lambda-api/runtime-config.tf +163 -0
- package/dist/terraform/modules/app/lambda-api/slack-app-secrets.tf +3 -1
- package/dist/terraform/modules/app/lambda-api/stripe-secrets.tf +3 -1
- package/dist/terraform/modules/app/lambda-api/variables.tf +240 -53
- package/dist/terraform/modules/app/lambda-api/workspace-events.tf +2 -25
- package/dist/terraform/modules/app/ses-email/main.tf +143 -30
- package/dist/terraform/modules/app/static-site/main.tf +4 -3
- package/dist/terraform/modules/app/www-dns/main.tf +45 -5
- package/dist/terraform/modules/app/www-dns/outputs.tf +10 -0
- package/dist/terraform/modules/app/www-dns/variables.tf +24 -0
- package/dist/terraform/modules/data/aurora-postgres/main.tf +15 -1
- package/dist/terraform/modules/data/compliance-exports-bucket/main.tf +1 -1
- package/dist/terraform/modules/data/compliance-exports-bucket/variables.tf +6 -0
- package/dist/terraform/modules/foundation/cognito/main.tf +167 -11
- package/dist/terraform/modules/foundation/cognito/outputs.tf +5 -0
- package/dist/terraform/modules/foundation/cognito/variables.tf +110 -0
- package/dist/terraform/modules/foundation/vpc/main.tf +45 -3
- package/dist/terraform/modules/foundation/vpc/outputs.tf +20 -0
- package/dist/terraform/modules/foundation/vpc/variables.tf +18 -0
- package/dist/terraform/modules/thinkwork/README.md +71 -0
- package/dist/terraform/modules/thinkwork/main.tf +1325 -174
- package/dist/terraform/modules/thinkwork/outputs.tf +457 -24
- package/dist/terraform/modules/thinkwork/variables.tf +1169 -93
- package/dist/terraform/schema.graphql +82 -9
- package/dist/workspace-defaults/files/AGENTS.md +344 -0
- package/dist/workspace-defaults/files/CONTEXT.md +8 -0
- package/dist/workspace-defaults/files/GUARDRAILS.md +51 -0
- package/dist/workspace-defaults/files/MEMORY_GUIDE.md +65 -0
- package/dist/workspace-defaults/files/ROUTER.md +24 -0
- package/dist/workspace-defaults/files/SPACE.md +62 -0
- package/dist/workspace-defaults/files/TOOLS.md +65 -0
- package/dist/workspace-defaults/files/USER.md +40 -0
- package/dist/workspace-defaults/files/mcp.json +3 -0
- package/dist/workspace-defaults/files/memory/contacts.md +13 -0
- package/dist/workspace-defaults/files/memory/lessons.md +13 -0
- package/dist/workspace-defaults/files/memory/preferences.md +12 -0
- package/dist/workspace-defaults/files/skills/.gitkeep +1 -0
- package/dist/workspace-defaults/files/skills/artifact-builder/SKILL.md +79 -0
- package/dist/workspace-defaults/files/skills/artifact-builder/references/crm-dashboard.md +166 -0
- package/dist/workspace-defaults/files/skills/automation-loop-designer/SKILL.md +120 -0
- package/dist/workspace-defaults/files/skills/skill-creator/LICENSE.txt +202 -0
- package/dist/workspace-defaults/files/skills/skill-creator/SKILL.md +485 -0
- package/dist/workspace-defaults/files/skills/skill-creator/UPSTREAM.json +124 -0
- package/dist/workspace-defaults/files/skills/skill-creator/agents/analyzer.md +274 -0
- package/dist/workspace-defaults/files/skills/skill-creator/agents/comparator.md +202 -0
- package/dist/workspace-defaults/files/skills/skill-creator/agents/grader.md +223 -0
- package/dist/workspace-defaults/files/skills/skill-creator/assets/eval_review.html +146 -0
- package/dist/workspace-defaults/files/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/dist/workspace-defaults/files/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/dist/workspace-defaults/files/skills/skill-creator/references/schemas.md +430 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/__init__.py +0 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/generate_report.py +326 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/improve_description.py +247 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/package_skill.py +136 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/run_eval.py +310 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/run_loop.py +328 -0
- package/dist/workspace-defaults/files/skills/skill-creator/scripts/utils.py +47 -0
- package/package.json +1 -1
- package/dist/terraform/modules/app/agentcore-flue/README.md +0 -58
- package/dist/terraform/modules/app/agentcore-flue/main.tf +0 -323
- package/dist/terraform/modules/app/agentcore-flue/outputs.tf +0 -23
- package/dist/terraform/modules/app/agentcore-flue/variables.tf +0 -97
- package/dist/terraform/modules/app/computer-runtime/README.md +0 -15
- package/dist/terraform/modules/app/computer-runtime/main.tf +0 -406
- package/dist/terraform/modules/app/computer-runtime/outputs.tf +0 -75
- package/dist/terraform/modules/app/computer-runtime/variables.tf +0 -66
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- creates: public.tenant_mcp_context_tools
|
|
2
|
+
CREATE TABLE IF NOT EXISTS "tenant_mcp_context_tools" (
|
|
3
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
4
|
+
"tenant_id" uuid NOT NULL REFERENCES "tenants"("id"),
|
|
5
|
+
"mcp_server_id" uuid NOT NULL REFERENCES "tenant_mcp_servers"("id"),
|
|
6
|
+
"tool_name" text NOT NULL,
|
|
7
|
+
"display_name" text,
|
|
8
|
+
"declared_read_only" boolean NOT NULL DEFAULT false,
|
|
9
|
+
"declared_search_safe" boolean NOT NULL DEFAULT false,
|
|
10
|
+
"approved" boolean NOT NULL DEFAULT false,
|
|
11
|
+
"default_enabled" boolean NOT NULL DEFAULT false,
|
|
12
|
+
"approved_by" uuid,
|
|
13
|
+
"approved_at" timestamp with time zone,
|
|
14
|
+
"metadata" jsonb,
|
|
15
|
+
"created_at" timestamp with time zone NOT NULL DEFAULT now(),
|
|
16
|
+
"updated_at" timestamp with time zone NOT NULL DEFAULT now()
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "uq_tenant_mcp_context_tools_tool"
|
|
20
|
+
ON "tenant_mcp_context_tools" ("tenant_id", "mcp_server_id", "tool_name");
|
|
21
|
+
|
|
22
|
+
CREATE INDEX IF NOT EXISTS "idx_tenant_mcp_context_tools_tenant"
|
|
23
|
+
ON "tenant_mcp_context_tools" ("tenant_id");
|
|
24
|
+
|
|
25
|
+
CREATE INDEX IF NOT EXISTS "idx_tenant_mcp_context_tools_server"
|
|
26
|
+
ON "tenant_mcp_context_tools" ("mcp_server_id");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- creates-column: public.agent_templates.context_engine
|
|
2
|
+
ALTER TABLE public.agent_templates
|
|
3
|
+
ADD COLUMN IF NOT EXISTS "context_engine" jsonb DEFAULT '{"enabled": true}'::jsonb;
|
|
4
|
+
|
|
5
|
+
UPDATE public.agent_templates
|
|
6
|
+
SET "context_engine" = '{"enabled": true}'::jsonb
|
|
7
|
+
WHERE "context_engine" IS NULL;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- creates: public.tenant_context_provider_settings
|
|
2
|
+
CREATE TABLE IF NOT EXISTS "tenant_context_provider_settings" (
|
|
3
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
4
|
+
"tenant_id" uuid NOT NULL REFERENCES "tenants"("id"),
|
|
5
|
+
"provider_id" text NOT NULL,
|
|
6
|
+
"family" text NOT NULL,
|
|
7
|
+
"enabled" boolean DEFAULT true NOT NULL,
|
|
8
|
+
"default_enabled" boolean DEFAULT false NOT NULL,
|
|
9
|
+
"config" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
10
|
+
"last_tested_at" timestamp with time zone,
|
|
11
|
+
"last_test_state" text,
|
|
12
|
+
"last_test_latency_ms" integer,
|
|
13
|
+
"last_test_error" text,
|
|
14
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
15
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "uq_tenant_context_provider_settings_provider"
|
|
19
|
+
ON "tenant_context_provider_settings" ("tenant_id", "provider_id");
|
|
20
|
+
|
|
21
|
+
CREATE INDEX IF NOT EXISTS "idx_tenant_context_provider_settings_tenant"
|
|
22
|
+
ON "tenant_context_provider_settings" ("tenant_id");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- Brain v0 entity subtype foundation.
|
|
2
|
+
--
|
|
3
|
+
-- Plan:
|
|
4
|
+
-- docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md
|
|
5
|
+
--
|
|
6
|
+
-- Apply manually:
|
|
7
|
+
-- psql "$DATABASE_URL" -f packages/database-pg/drizzle/0050_brain_v0_entity_subtype.sql
|
|
8
|
+
--
|
|
9
|
+
-- Column path updated post-0089 (wiki schema extraction renamed parent table to wiki.pages).
|
|
10
|
+
-- creates-column: wiki.pages.entity_subtype
|
|
11
|
+
|
|
12
|
+
\set ON_ERROR_STOP on
|
|
13
|
+
|
|
14
|
+
BEGIN;
|
|
15
|
+
|
|
16
|
+
SET LOCAL lock_timeout = '5s';
|
|
17
|
+
SET LOCAL statement_timeout = '120s';
|
|
18
|
+
|
|
19
|
+
ALTER TABLE public.wiki_pages
|
|
20
|
+
ADD COLUMN IF NOT EXISTS entity_subtype text;
|
|
21
|
+
|
|
22
|
+
CREATE INDEX IF NOT EXISTS idx_wiki_pages_entity_subtype
|
|
23
|
+
ON public.wiki_pages (entity_subtype)
|
|
24
|
+
WHERE entity_subtype IS NOT NULL;
|
|
25
|
+
|
|
26
|
+
COMMENT ON COLUMN public.wiki_pages.entity_subtype
|
|
27
|
+
IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
28
|
+
|
|
29
|
+
COMMIT;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
-- Brain v0 tenant-shared entity pages.
|
|
2
|
+
--
|
|
3
|
+
-- Plan:
|
|
4
|
+
-- docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md
|
|
5
|
+
--
|
|
6
|
+
-- Apply manually:
|
|
7
|
+
-- psql "$DATABASE_URL" -f packages/database-pg/drizzle/0051_brain_v0_tenant_entity_pages.sql
|
|
8
|
+
--
|
|
9
|
+
-- creates: public.tenant_entity_pages
|
|
10
|
+
-- creates: public.tenant_entity_page_sections
|
|
11
|
+
-- creates: public.tenant_entity_page_links
|
|
12
|
+
-- creates: public.tenant_entity_page_aliases
|
|
13
|
+
-- creates: public.tenant_entity_section_sources
|
|
14
|
+
-- creates: public.uq_tenant_entity_pages_tenant_type_subtype_slug
|
|
15
|
+
-- creates: public.idx_tenant_entity_pages_search_tsv
|
|
16
|
+
-- creates: public.uq_tenant_entity_section_sources_section_kind_ref
|
|
17
|
+
-- creates-function: public.enforce_tenant_entity_section_source_tenant
|
|
18
|
+
-- creates-trigger: public.tenant_entity_section_sources.trg_tenant_entity_section_sources_tenant
|
|
19
|
+
|
|
20
|
+
\set ON_ERROR_STOP on
|
|
21
|
+
|
|
22
|
+
BEGIN;
|
|
23
|
+
|
|
24
|
+
SET LOCAL lock_timeout = '5s';
|
|
25
|
+
SET LOCAL statement_timeout = '120s';
|
|
26
|
+
|
|
27
|
+
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
|
28
|
+
|
|
29
|
+
CREATE TABLE IF NOT EXISTS public.tenant_entity_pages (
|
|
30
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
31
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
32
|
+
type text NOT NULL,
|
|
33
|
+
entity_subtype text NOT NULL,
|
|
34
|
+
slug text NOT NULL,
|
|
35
|
+
title text NOT NULL,
|
|
36
|
+
summary text,
|
|
37
|
+
body_md text,
|
|
38
|
+
search_tsv tsvector GENERATED ALWAYS AS (
|
|
39
|
+
to_tsvector(
|
|
40
|
+
'english'::regconfig,
|
|
41
|
+
regexp_replace(coalesce(title, '') || ' ' || coalesce(summary, '') || ' ' || coalesce(body_md, ''), '[^[:alnum:]]+', ' ', 'g')
|
|
42
|
+
)
|
|
43
|
+
) STORED,
|
|
44
|
+
status text DEFAULT 'active' NOT NULL,
|
|
45
|
+
parent_page_id uuid REFERENCES public.tenant_entity_pages(id) ON DELETE SET NULL,
|
|
46
|
+
hubness_score integer DEFAULT 0 NOT NULL,
|
|
47
|
+
tags text[] DEFAULT ARRAY[]::text[] NOT NULL,
|
|
48
|
+
last_compiled_at timestamp with time zone,
|
|
49
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
50
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
51
|
+
CONSTRAINT tenant_entity_pages_type_allowed CHECK (type IN ('entity','topic','decision')),
|
|
52
|
+
CONSTRAINT tenant_entity_pages_entity_subtype_allowed CHECK (entity_subtype IN ('customer','opportunity','order','person'))
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_tenant_entity_pages_tenant_type_subtype_slug
|
|
56
|
+
ON public.tenant_entity_pages (tenant_id, type, entity_subtype, slug);
|
|
57
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_pages_tenant_type_status
|
|
58
|
+
ON public.tenant_entity_pages (tenant_id, type, status);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_pages_subtype
|
|
60
|
+
ON public.tenant_entity_pages (entity_subtype);
|
|
61
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_pages_last_compiled
|
|
62
|
+
ON public.tenant_entity_pages (last_compiled_at);
|
|
63
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_pages_search_tsv
|
|
64
|
+
ON public.tenant_entity_pages USING gin (search_tsv);
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_pages_parent
|
|
66
|
+
ON public.tenant_entity_pages (parent_page_id);
|
|
67
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_pages_title_trgm
|
|
68
|
+
ON public.tenant_entity_pages USING gin (title gin_trgm_ops);
|
|
69
|
+
|
|
70
|
+
CREATE TABLE IF NOT EXISTS public.tenant_entity_page_sections (
|
|
71
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
72
|
+
page_id uuid NOT NULL REFERENCES public.tenant_entity_pages(id) ON DELETE CASCADE,
|
|
73
|
+
section_slug text NOT NULL,
|
|
74
|
+
heading text NOT NULL,
|
|
75
|
+
body_md text NOT NULL,
|
|
76
|
+
position integer NOT NULL,
|
|
77
|
+
last_source_at timestamp with time zone,
|
|
78
|
+
aggregation jsonb,
|
|
79
|
+
status text DEFAULT 'active' NOT NULL,
|
|
80
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
81
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
82
|
+
CONSTRAINT tenant_entity_page_sections_facet_type_allowed
|
|
83
|
+
CHECK (aggregation->>'facet_type' IS NULL OR aggregation->>'facet_type' IN ('operational','relationship','activity','compiled','kb_sourced','external'))
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_tenant_entity_page_sections_page_slug
|
|
87
|
+
ON public.tenant_entity_page_sections (page_id, section_slug);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_page_sections_page_position
|
|
89
|
+
ON public.tenant_entity_page_sections (page_id, position);
|
|
90
|
+
|
|
91
|
+
CREATE TABLE IF NOT EXISTS public.tenant_entity_page_links (
|
|
92
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
93
|
+
from_page_id uuid NOT NULL REFERENCES public.tenant_entity_pages(id) ON DELETE CASCADE,
|
|
94
|
+
to_page_id uuid NOT NULL REFERENCES public.tenant_entity_pages(id) ON DELETE CASCADE,
|
|
95
|
+
kind text DEFAULT 'reference' NOT NULL,
|
|
96
|
+
context text,
|
|
97
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_tenant_entity_page_links_from_to_kind
|
|
101
|
+
ON public.tenant_entity_page_links (from_page_id, to_page_id, kind);
|
|
102
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_page_links_to
|
|
103
|
+
ON public.tenant_entity_page_links (to_page_id);
|
|
104
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_page_links_kind
|
|
105
|
+
ON public.tenant_entity_page_links (kind);
|
|
106
|
+
|
|
107
|
+
CREATE TABLE IF NOT EXISTS public.tenant_entity_page_aliases (
|
|
108
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
109
|
+
page_id uuid NOT NULL REFERENCES public.tenant_entity_pages(id) ON DELETE CASCADE,
|
|
110
|
+
alias text NOT NULL,
|
|
111
|
+
source text NOT NULL,
|
|
112
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_tenant_entity_page_aliases_page_alias
|
|
116
|
+
ON public.tenant_entity_page_aliases (page_id, alias);
|
|
117
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_page_aliases_alias
|
|
118
|
+
ON public.tenant_entity_page_aliases (alias);
|
|
119
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_page_aliases_alias_trgm
|
|
120
|
+
ON public.tenant_entity_page_aliases USING gin (alias gin_trgm_ops);
|
|
121
|
+
|
|
122
|
+
CREATE TABLE IF NOT EXISTS public.tenant_entity_section_sources (
|
|
123
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
124
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
125
|
+
section_id uuid NOT NULL REFERENCES public.tenant_entity_page_sections(id) ON DELETE RESTRICT,
|
|
126
|
+
source_kind text NOT NULL,
|
|
127
|
+
source_ref text NOT NULL,
|
|
128
|
+
first_seen_at timestamp with time zone DEFAULT now() NOT NULL
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_tenant_entity_section_sources_section_kind_ref
|
|
132
|
+
ON public.tenant_entity_section_sources (section_id, source_kind, source_ref);
|
|
133
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_section_sources_tenant_kind_ref
|
|
134
|
+
ON public.tenant_entity_section_sources (tenant_id, source_kind, source_ref);
|
|
135
|
+
|
|
136
|
+
CREATE OR REPLACE FUNCTION public.enforce_tenant_entity_section_source_tenant()
|
|
137
|
+
RETURNS trigger
|
|
138
|
+
LANGUAGE plpgsql
|
|
139
|
+
AS $$
|
|
140
|
+
DECLARE
|
|
141
|
+
parent_tenant_id uuid;
|
|
142
|
+
BEGIN
|
|
143
|
+
SELECT p.tenant_id
|
|
144
|
+
INTO parent_tenant_id
|
|
145
|
+
FROM public.tenant_entity_page_sections s
|
|
146
|
+
INNER JOIN public.tenant_entity_pages p ON p.id = s.page_id
|
|
147
|
+
WHERE s.id = NEW.section_id;
|
|
148
|
+
|
|
149
|
+
IF parent_tenant_id IS NULL OR parent_tenant_id <> NEW.tenant_id THEN
|
|
150
|
+
RAISE EXCEPTION 'tenant_entity_section_sources tenant_id must match parent page tenant_id';
|
|
151
|
+
END IF;
|
|
152
|
+
|
|
153
|
+
RETURN NEW;
|
|
154
|
+
END;
|
|
155
|
+
$$;
|
|
156
|
+
|
|
157
|
+
DROP TRIGGER IF EXISTS trg_tenant_entity_section_sources_tenant
|
|
158
|
+
ON public.tenant_entity_section_sources;
|
|
159
|
+
CREATE TRIGGER trg_tenant_entity_section_sources_tenant
|
|
160
|
+
BEFORE INSERT OR UPDATE ON public.tenant_entity_section_sources
|
|
161
|
+
FOR EACH ROW
|
|
162
|
+
EXECUTE FUNCTION public.enforce_tenant_entity_section_source_tenant();
|
|
163
|
+
|
|
164
|
+
COMMENT ON TABLE public.tenant_entity_pages IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
165
|
+
COMMENT ON TABLE public.tenant_entity_page_sections IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
166
|
+
COMMENT ON TABLE public.tenant_entity_page_links IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
167
|
+
COMMENT ON TABLE public.tenant_entity_page_aliases IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
168
|
+
COMMENT ON TABLE public.tenant_entity_section_sources IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
169
|
+
|
|
170
|
+
COMMIT;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- Brain v0 operational snapshot cache for tenant entities.
|
|
2
|
+
--
|
|
3
|
+
-- Plan:
|
|
4
|
+
-- docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md
|
|
5
|
+
--
|
|
6
|
+
-- Apply manually:
|
|
7
|
+
-- psql "$DATABASE_URL" -f packages/database-pg/drizzle/0052_brain_v0_external_refs.sql
|
|
8
|
+
--
|
|
9
|
+
-- creates: public.tenant_entity_external_refs
|
|
10
|
+
|
|
11
|
+
\set ON_ERROR_STOP on
|
|
12
|
+
|
|
13
|
+
BEGIN;
|
|
14
|
+
|
|
15
|
+
SET LOCAL lock_timeout = '5s';
|
|
16
|
+
SET LOCAL statement_timeout = '120s';
|
|
17
|
+
|
|
18
|
+
CREATE TABLE IF NOT EXISTS public.tenant_entity_external_refs (
|
|
19
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
20
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
21
|
+
source_kind text NOT NULL,
|
|
22
|
+
external_id text,
|
|
23
|
+
source_payload jsonb,
|
|
24
|
+
as_of timestamp with time zone NOT NULL,
|
|
25
|
+
ttl_seconds integer NOT NULL,
|
|
26
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
27
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
28
|
+
CONSTRAINT tenant_entity_external_refs_kind_allowed
|
|
29
|
+
CHECK (source_kind IN ('erp_customer','crm_opportunity','erp_order','crm_person','support_case','bedrock_kb')),
|
|
30
|
+
CONSTRAINT tenant_entity_external_refs_ttl_positive CHECK (ttl_seconds > 0)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_tenant_entity_external_refs_source
|
|
34
|
+
ON public.tenant_entity_external_refs (tenant_id, source_kind, external_id)
|
|
35
|
+
WHERE external_id IS NOT NULL;
|
|
36
|
+
CREATE INDEX IF NOT EXISTS idx_tenant_entity_external_refs_tenant_source
|
|
37
|
+
ON public.tenant_entity_external_refs (tenant_id, source_kind);
|
|
38
|
+
|
|
39
|
+
COMMENT ON TABLE public.tenant_entity_external_refs IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
40
|
+
|
|
41
|
+
COMMIT;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
-- Brain v0 subtype suggestion for unresolved mentions.
|
|
2
|
+
--
|
|
3
|
+
-- Plan:
|
|
4
|
+
-- docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md
|
|
5
|
+
--
|
|
6
|
+
-- Apply manually:
|
|
7
|
+
-- psql "$DATABASE_URL" -f packages/database-pg/drizzle/0053_brain_v0_unresolved_mentions_subtype.sql
|
|
8
|
+
--
|
|
9
|
+
-- creates-column: wiki.unresolved_mentions.entity_subtype
|
|
10
|
+
-- creates-constraint: wiki.unresolved_mentions.unresolved_mentions_entity_subtype_allowed
|
|
11
|
+
-- Note: column + constraint were originally created on public.wiki_unresolved_mentions;
|
|
12
|
+
-- 0089_wiki_schema_extraction.sql moved the table to wiki.unresolved_mentions and renamed
|
|
13
|
+
-- the constraint. Markers updated to track post-0089 location so the drift reporter resolves
|
|
14
|
+
-- them via pg_class/pg_constraint in the new schema.
|
|
15
|
+
|
|
16
|
+
\set ON_ERROR_STOP on
|
|
17
|
+
|
|
18
|
+
BEGIN;
|
|
19
|
+
|
|
20
|
+
SET LOCAL lock_timeout = '5s';
|
|
21
|
+
SET LOCAL statement_timeout = '120s';
|
|
22
|
+
|
|
23
|
+
DO $$
|
|
24
|
+
BEGIN
|
|
25
|
+
IF to_regclass('public.tenant_entity_pages') IS NULL THEN
|
|
26
|
+
RAISE EXCEPTION '0053 requires public.tenant_entity_pages from 0051';
|
|
27
|
+
END IF;
|
|
28
|
+
END $$;
|
|
29
|
+
|
|
30
|
+
ALTER TABLE public.wiki_unresolved_mentions
|
|
31
|
+
ADD COLUMN IF NOT EXISTS entity_subtype text;
|
|
32
|
+
|
|
33
|
+
DO $$
|
|
34
|
+
BEGIN
|
|
35
|
+
IF NOT EXISTS (
|
|
36
|
+
SELECT 1 FROM pg_constraint
|
|
37
|
+
WHERE conname = 'wiki_unresolved_mentions_entity_subtype_allowed'
|
|
38
|
+
) THEN
|
|
39
|
+
ALTER TABLE public.wiki_unresolved_mentions
|
|
40
|
+
ADD CONSTRAINT wiki_unresolved_mentions_entity_subtype_allowed
|
|
41
|
+
CHECK (entity_subtype IS NULL OR entity_subtype IN ('customer','opportunity','order','person','concept','reflection'));
|
|
42
|
+
END IF;
|
|
43
|
+
END $$;
|
|
44
|
+
|
|
45
|
+
COMMENT ON COLUMN public.wiki_unresolved_mentions.entity_subtype
|
|
46
|
+
IS 'brain-v0: docs/plans/2026-04-29-004-feat-company-brain-v0-plan.md';
|
|
47
|
+
|
|
48
|
+
COMMIT;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Add `input` jsonb column to wiki_compile_jobs.
|
|
2
|
+
--
|
|
3
|
+
-- Drives per-trigger input payloads on top of the shared compile job ledger.
|
|
4
|
+
-- The first consumer is `trigger='enrichment_draft'` jobs, which carry
|
|
5
|
+
-- { pageId, pageTable, candidates } so the draft-compile module can run
|
|
6
|
+
-- against an explicit page and a synthesized candidate list rather than
|
|
7
|
+
-- the cluster-driven input the default compile reads from.
|
|
8
|
+
--
|
|
9
|
+
-- Plan:
|
|
10
|
+
-- docs/plans/2026-05-01-002-feat-brain-enrichment-draft-page-review-plan.md
|
|
11
|
+
--
|
|
12
|
+
-- Apply manually:
|
|
13
|
+
-- psql "$DATABASE_URL" -f packages/database-pg/drizzle/0054_wiki_compile_jobs_input.sql
|
|
14
|
+
--
|
|
15
|
+
-- Column path updated post-0089 (wiki schema extraction renamed parent table to wiki.compile_jobs).
|
|
16
|
+
-- creates-column: wiki.compile_jobs.input
|
|
17
|
+
|
|
18
|
+
\set ON_ERROR_STOP on
|
|
19
|
+
|
|
20
|
+
BEGIN;
|
|
21
|
+
|
|
22
|
+
SET LOCAL lock_timeout = '5s';
|
|
23
|
+
SET LOCAL statement_timeout = '120s';
|
|
24
|
+
|
|
25
|
+
ALTER TABLE wiki_compile_jobs
|
|
26
|
+
ADD COLUMN IF NOT EXISTS input jsonb;
|
|
27
|
+
|
|
28
|
+
COMMIT;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
-- Routines Step Functions substrate.
|
|
2
|
+
--
|
|
3
|
+
-- Adds the four new tables that back the Step Functions Routines runtime:
|
|
4
|
+
-- * routine_executions — execution-level state, mirrors SFN
|
|
5
|
+
-- * routine_step_events — per-step events (high-volume append)
|
|
6
|
+
-- * routine_asl_versions — published ASL snapshots for query/audit
|
|
7
|
+
-- * routine_approval_tokens — HITL task tokens with consume-once flag
|
|
8
|
+
--
|
|
9
|
+
-- And extends `routines` with the engine partition + Step-Functions-specific
|
|
10
|
+
-- columns (state_machine_arn, alias_arn, documentation_md, current_version).
|
|
11
|
+
-- Existing routine rows default to engine='legacy_python' so the new query
|
|
12
|
+
-- paths can filter without a join.
|
|
13
|
+
--
|
|
14
|
+
-- Plan:
|
|
15
|
+
-- docs/plans/2026-05-01-004-feat-routines-phase-a-substrate-plan.md
|
|
16
|
+
--
|
|
17
|
+
-- Apply manually:
|
|
18
|
+
-- psql "$DATABASE_URL" -f packages/database-pg/drizzle/0055_routines_stepfunctions_substrate.sql
|
|
19
|
+
--
|
|
20
|
+
-- creates: public.routine_executions
|
|
21
|
+
-- creates: public.routine_step_events
|
|
22
|
+
-- creates: public.routine_asl_versions
|
|
23
|
+
-- creates: public.routine_approval_tokens
|
|
24
|
+
-- creates-column: public.routines.engine
|
|
25
|
+
-- creates-column: public.routines.state_machine_arn
|
|
26
|
+
-- creates-column: public.routines.state_machine_alias_arn
|
|
27
|
+
-- creates-column: public.routines.documentation_md
|
|
28
|
+
-- creates-column: public.routines.current_version
|
|
29
|
+
-- creates-constraint: public.routines.routines_engine_enum
|
|
30
|
+
-- creates: public.idx_routine_executions_sfn_arn
|
|
31
|
+
-- creates: public.idx_routine_executions_tenant_status
|
|
32
|
+
-- creates: public.idx_routine_executions_routine_started
|
|
33
|
+
-- creates: public.idx_routine_executions_tenant_started
|
|
34
|
+
-- creates: public.idx_routine_step_events_execution
|
|
35
|
+
-- creates: public.idx_routine_step_events_tenant_recipe
|
|
36
|
+
-- creates: public.idx_routine_step_events_python_dashboard
|
|
37
|
+
-- creates: public.idx_routine_asl_versions_routine_version
|
|
38
|
+
-- creates: public.idx_routine_asl_versions_tenant_routine
|
|
39
|
+
-- creates: public.idx_routine_approval_tokens_inbox
|
|
40
|
+
-- creates: public.idx_routine_approval_tokens_pending
|
|
41
|
+
-- creates: public.idx_routine_approval_tokens_tenant_consumed
|
|
42
|
+
-- creates: public.idx_routines_engine
|
|
43
|
+
|
|
44
|
+
\set ON_ERROR_STOP on
|
|
45
|
+
|
|
46
|
+
BEGIN;
|
|
47
|
+
|
|
48
|
+
SET LOCAL lock_timeout = '5s';
|
|
49
|
+
SET LOCAL statement_timeout = '120s';
|
|
50
|
+
|
|
51
|
+
-- ---------------------------------------------------------------------------
|
|
52
|
+
-- routines: engine partition + Step Functions resource columns
|
|
53
|
+
-- ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
ALTER TABLE public.routines
|
|
56
|
+
ADD COLUMN IF NOT EXISTS engine text NOT NULL DEFAULT 'legacy_python',
|
|
57
|
+
ADD COLUMN IF NOT EXISTS state_machine_arn text,
|
|
58
|
+
ADD COLUMN IF NOT EXISTS state_machine_alias_arn text,
|
|
59
|
+
ADD COLUMN IF NOT EXISTS documentation_md text,
|
|
60
|
+
ADD COLUMN IF NOT EXISTS current_version integer;
|
|
61
|
+
|
|
62
|
+
ALTER TABLE public.routines
|
|
63
|
+
DROP CONSTRAINT IF EXISTS routines_engine_enum;
|
|
64
|
+
|
|
65
|
+
ALTER TABLE public.routines
|
|
66
|
+
ADD CONSTRAINT routines_engine_enum
|
|
67
|
+
CHECK (engine IN ('legacy_python', 'step_functions'));
|
|
68
|
+
|
|
69
|
+
CREATE INDEX IF NOT EXISTS idx_routines_engine
|
|
70
|
+
ON public.routines (engine);
|
|
71
|
+
|
|
72
|
+
-- ---------------------------------------------------------------------------
|
|
73
|
+
-- routine_executions
|
|
74
|
+
-- ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
CREATE TABLE IF NOT EXISTS public.routine_executions (
|
|
77
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
78
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id),
|
|
79
|
+
routine_id uuid NOT NULL REFERENCES public.routines(id),
|
|
80
|
+
state_machine_arn text NOT NULL,
|
|
81
|
+
alias_arn text,
|
|
82
|
+
version_arn text,
|
|
83
|
+
sfn_execution_arn text NOT NULL,
|
|
84
|
+
trigger_id uuid REFERENCES public.scheduled_jobs(id),
|
|
85
|
+
trigger_source text NOT NULL,
|
|
86
|
+
input_json jsonb,
|
|
87
|
+
output_json jsonb,
|
|
88
|
+
status text NOT NULL DEFAULT 'running',
|
|
89
|
+
started_at timestamp with time zone,
|
|
90
|
+
finished_at timestamp with time zone,
|
|
91
|
+
error_code text,
|
|
92
|
+
error_message text,
|
|
93
|
+
total_llm_cost_usd_cents bigint,
|
|
94
|
+
created_at timestamp with time zone NOT NULL DEFAULT now()
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_routine_executions_sfn_arn
|
|
98
|
+
ON public.routine_executions (sfn_execution_arn);
|
|
99
|
+
CREATE INDEX IF NOT EXISTS idx_routine_executions_tenant_status
|
|
100
|
+
ON public.routine_executions (tenant_id, status);
|
|
101
|
+
CREATE INDEX IF NOT EXISTS idx_routine_executions_routine_started
|
|
102
|
+
ON public.routine_executions (routine_id, started_at);
|
|
103
|
+
CREATE INDEX IF NOT EXISTS idx_routine_executions_tenant_started
|
|
104
|
+
ON public.routine_executions (tenant_id, started_at);
|
|
105
|
+
|
|
106
|
+
-- ---------------------------------------------------------------------------
|
|
107
|
+
-- routine_step_events
|
|
108
|
+
-- ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
CREATE TABLE IF NOT EXISTS public.routine_step_events (
|
|
111
|
+
id bigserial PRIMARY KEY NOT NULL,
|
|
112
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id),
|
|
113
|
+
execution_id uuid NOT NULL REFERENCES public.routine_executions(id),
|
|
114
|
+
node_id text NOT NULL,
|
|
115
|
+
recipe_type text NOT NULL,
|
|
116
|
+
status text NOT NULL,
|
|
117
|
+
started_at timestamp with time zone,
|
|
118
|
+
finished_at timestamp with time zone,
|
|
119
|
+
input_json jsonb,
|
|
120
|
+
output_json jsonb,
|
|
121
|
+
error_json jsonb,
|
|
122
|
+
llm_cost_usd_cents bigint,
|
|
123
|
+
retry_count integer NOT NULL DEFAULT 0,
|
|
124
|
+
stdout_s3_uri text,
|
|
125
|
+
stderr_s3_uri text,
|
|
126
|
+
stdout_preview text,
|
|
127
|
+
truncated boolean NOT NULL DEFAULT false,
|
|
128
|
+
created_at timestamp with time zone NOT NULL DEFAULT now()
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
CREATE INDEX IF NOT EXISTS idx_routine_step_events_execution
|
|
132
|
+
ON public.routine_step_events (execution_id, started_at);
|
|
133
|
+
CREATE INDEX IF NOT EXISTS idx_routine_step_events_tenant_recipe
|
|
134
|
+
ON public.routine_step_events (tenant_id, recipe_type);
|
|
135
|
+
CREATE INDEX IF NOT EXISTS idx_routine_step_events_python_dashboard
|
|
136
|
+
ON public.routine_step_events (tenant_id, recipe_type, created_at);
|
|
137
|
+
|
|
138
|
+
-- ---------------------------------------------------------------------------
|
|
139
|
+
-- routine_asl_versions
|
|
140
|
+
-- ---------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
CREATE TABLE IF NOT EXISTS public.routine_asl_versions (
|
|
143
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
144
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id),
|
|
145
|
+
routine_id uuid NOT NULL REFERENCES public.routines(id),
|
|
146
|
+
version_number integer NOT NULL,
|
|
147
|
+
state_machine_arn text NOT NULL,
|
|
148
|
+
version_arn text NOT NULL,
|
|
149
|
+
alias_was_pointing text,
|
|
150
|
+
asl_json jsonb NOT NULL,
|
|
151
|
+
markdown_summary text NOT NULL,
|
|
152
|
+
step_manifest_json jsonb NOT NULL,
|
|
153
|
+
validation_warnings_json jsonb,
|
|
154
|
+
published_by_actor_id uuid,
|
|
155
|
+
published_by_actor_type text,
|
|
156
|
+
created_at timestamp with time zone NOT NULL DEFAULT now()
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_routine_asl_versions_routine_version
|
|
160
|
+
ON public.routine_asl_versions (routine_id, version_number);
|
|
161
|
+
CREATE INDEX IF NOT EXISTS idx_routine_asl_versions_tenant_routine
|
|
162
|
+
ON public.routine_asl_versions (tenant_id, routine_id);
|
|
163
|
+
|
|
164
|
+
-- ---------------------------------------------------------------------------
|
|
165
|
+
-- routine_approval_tokens
|
|
166
|
+
-- ---------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
CREATE TABLE IF NOT EXISTS public.routine_approval_tokens (
|
|
169
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
170
|
+
tenant_id uuid NOT NULL REFERENCES public.tenants(id),
|
|
171
|
+
execution_id uuid NOT NULL REFERENCES public.routine_executions(id),
|
|
172
|
+
inbox_item_id uuid NOT NULL REFERENCES public.inbox_items(id),
|
|
173
|
+
node_id text NOT NULL,
|
|
174
|
+
task_token text NOT NULL,
|
|
175
|
+
heartbeat_seconds integer,
|
|
176
|
+
consumed boolean NOT NULL DEFAULT false,
|
|
177
|
+
decided_by_user_id uuid,
|
|
178
|
+
decision_value_json jsonb,
|
|
179
|
+
decided_at timestamp with time zone,
|
|
180
|
+
created_at timestamp with time zone NOT NULL DEFAULT now(),
|
|
181
|
+
expires_at timestamp with time zone
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_routine_approval_tokens_inbox
|
|
185
|
+
ON public.routine_approval_tokens (inbox_item_id);
|
|
186
|
+
|
|
187
|
+
-- Partial unique index: at most one pending decision per (execution, node).
|
|
188
|
+
-- Past decisions retain their rows for audit (consumed=true) without
|
|
189
|
+
-- conflicting with new pending decisions on the same node.
|
|
190
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_routine_approval_tokens_pending
|
|
191
|
+
ON public.routine_approval_tokens (execution_id, node_id)
|
|
192
|
+
WHERE consumed = false;
|
|
193
|
+
|
|
194
|
+
CREATE INDEX IF NOT EXISTS idx_routine_approval_tokens_tenant_consumed
|
|
195
|
+
ON public.routine_approval_tokens (tenant_id, consumed);
|
|
196
|
+
|
|
197
|
+
COMMENT ON TABLE public.routine_executions IS 'routines-phase-a: docs/plans/2026-05-01-004-feat-routines-phase-a-substrate-plan.md';
|
|
198
|
+
COMMENT ON TABLE public.routine_step_events IS 'routines-phase-a: docs/plans/2026-05-01-004-feat-routines-phase-a-substrate-plan.md';
|
|
199
|
+
COMMENT ON TABLE public.routine_asl_versions IS 'routines-phase-a: docs/plans/2026-05-01-004-feat-routines-phase-a-substrate-plan.md';
|
|
200
|
+
COMMENT ON TABLE public.routine_approval_tokens IS 'routines-phase-a: docs/plans/2026-05-01-004-feat-routines-phase-a-substrate-plan.md';
|
|
201
|
+
|
|
202
|
+
COMMIT;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Hand-rolled migration: routine_step_events dedup unique index
|
|
2
|
+
-- Plan: docs/plans/2026-05-01-005-feat-routines-phase-b-runtime-plan.md §U9
|
|
3
|
+
--
|
|
4
|
+
-- The routine-step-callback handler ingests events fired from two paths
|
|
5
|
+
-- that can both double-deliver:
|
|
6
|
+
-- * Task-wrapper Lambdas (routine-task-python, routine-resume) on
|
|
7
|
+
-- SFN Lambda-retry
|
|
8
|
+
-- * EventBridge → routine-step-callback for SFN execution-state-change
|
|
9
|
+
-- events on the agent_invoke recipe (no wrapper Lambda)
|
|
10
|
+
--
|
|
11
|
+
-- Idempotency relies on ON CONFLICT DO NOTHING against this unique index.
|
|
12
|
+
-- The 4-tuple (execution_id, node_id, status, started_at) matches the
|
|
13
|
+
-- schema's idempotency contract documented in
|
|
14
|
+
-- packages/database-pg/src/schema/routine-step-events.ts.
|
|
15
|
+
--
|
|
16
|
+
-- Partial-index `WHERE started_at IS NOT NULL` because Postgres treats
|
|
17
|
+
-- NULLs as distinct in unique indexes by default; events without a
|
|
18
|
+
-- started_at fall back to non-deduped insert (rare and harmless — UI
|
|
19
|
+
-- shows them as separate rows, not duplicates).
|
|
20
|
+
--
|
|
21
|
+
-- creates: public.idx_routine_step_events_dedup
|
|
22
|
+
|
|
23
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_routine_step_events_dedup
|
|
24
|
+
ON public.routine_step_events (execution_id, node_id, status, started_at)
|
|
25
|
+
WHERE started_at IS NOT NULL;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
-- Archive legacy Python routines (Plan 2026-05-01-008 §U15).
|
|
2
|
+
--
|
|
3
|
+
-- Phase A introduced an `engine` column on `routines` partitioning rows
|
|
4
|
+
-- between `legacy_python` (pre-Phase-A code-backed routines) and
|
|
5
|
+
-- `step_functions` (the new ASL substrate). Phase A through D shipped
|
|
6
|
+
-- with both engines coexisting so the cutover wouldn't break in-flight
|
|
7
|
+
-- legacy routines. Phase E archives the legacy partition.
|
|
8
|
+
--
|
|
9
|
+
-- Idempotent: re-running on a freshly migrated DB with zero
|
|
10
|
+
-- `legacy_python` rows is a no-op. Reversible via the rollback file
|
|
11
|
+
-- (status flips back to active for any rows that were active at the
|
|
12
|
+
-- time of archival). Capture audit timestamps in routines.updated_at
|
|
13
|
+
-- so the migration is observable downstream.
|
|
14
|
+
--
|
|
15
|
+
-- Pre-flight (dev): 0 routines exist. The migration is purely defensive
|
|
16
|
+
-- for prod parity and any future tenant whose legacy_python rows didn't
|
|
17
|
+
-- get migrated to ASL during the cutover.
|
|
18
|
+
--
|
|
19
|
+
-- creates-column: public.routines.archived_at_legacy_cutover
|
|
20
|
+
|
|
21
|
+
-- Add a marker column so a later "drop the engine column" migration can
|
|
22
|
+
-- distinguish "archived because legacy" from "archived for other
|
|
23
|
+
-- reasons" (operator action, tenant offboarding). Nullable so existing
|
|
24
|
+
-- rows aren't disrupted.
|
|
25
|
+
ALTER TABLE public.routines
|
|
26
|
+
ADD COLUMN IF NOT EXISTS archived_at_legacy_cutover timestamptz;
|
|
27
|
+
|
|
28
|
+
-- Archive every legacy_python routine that's not already archived.
|
|
29
|
+
-- The status flip is the only behavior the v1 admin surface checks
|
|
30
|
+
-- (Phase D filter); the marker column is for downstream observability.
|
|
31
|
+
UPDATE public.routines
|
|
32
|
+
SET status = 'archived',
|
|
33
|
+
archived_at_legacy_cutover = now(),
|
|
34
|
+
updated_at = now()
|
|
35
|
+
WHERE engine = 'legacy_python'
|
|
36
|
+
AND status <> 'archived';
|