create-workframe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +22 -0
- package/.gitignore +73 -0
- package/LICENSE +201 -0
- package/NOTICE +12 -0
- package/README.md +111 -0
- package/SECURITY.md +40 -0
- package/bin/create-workframe.js +2814 -0
- package/bin/workframe.js +329 -0
- package/docs/workspace-instructions/WORKFRAME_DISCORD.md +20 -0
- package/docs/workspace-instructions/WORKFRAME_DOCUMENTS_AND_ARTIFACTS.md +20 -0
- package/docs/workspace-instructions/WORKFRAME_KANBAN.md +20 -0
- package/docs/workspace-instructions/WORKFRAME_ONBOARDING.md +21 -0
- package/docs/workspace-instructions/WORKFRAME_ROUTING.md +29 -0
- package/docs/workspace-instructions/WORKFRAME_TELEGRAM.md +19 -0
- package/package.json +67 -0
- package/profiles/README.md +15 -0
- package/profiles/architect/AGENTS.md +29 -0
- package/profiles/architect/SOUL.md +44 -0
- package/profiles/architect/skills/devops/kanban-worker/SKILL.md +27 -0
- package/profiles/designer/AGENTS.md +26 -0
- package/profiles/designer/SOUL.md +31 -0
- package/profiles/designer/skills/devops/kanban-worker/SKILL.md +27 -0
- package/profiles/dev/AGENTS.md +28 -0
- package/profiles/dev/SOUL.md +31 -0
- package/profiles/dev/skills/devops/kanban-worker/SKILL.md +27 -0
- package/profiles/docs/AGENTS.md +27 -0
- package/profiles/docs/SOUL.md +30 -0
- package/profiles/docs/skills/devops/kanban-worker/SKILL.md +27 -0
- package/profiles/research/AGENTS.md +26 -0
- package/profiles/research/SOUL.md +31 -0
- package/profiles/research/skills/devops/kanban-worker/SKILL.md +27 -0
- package/profiles/visionary/AGENTS.md +25 -0
- package/profiles/visionary/SOUL.md +31 -0
- package/profiles/visionary/skills/devops/kanban-worker/SKILL.md +27 -0
- package/profiles/workframe-agent/AGENTS.md +37 -0
- package/profiles/workframe-agent/SETUP.md +185 -0
- package/profiles/workframe-agent/SOUL.md +61 -0
- package/profiles/workframe-agent/skills/devops/botfather/SKILL.md +85 -0
- package/profiles/workframe-agent/skills/devops/kanban-handoff-pattern/SKILL.md +58 -0
- package/profiles/workframe-agent/skills/devops/workframe-cohort/SKILL.md +54 -0
- package/prompts/WORKFRAME_PROMPT_TEMPLATES.md +16 -0
- package/rules/.hermes.md +11 -0
- package/rules/AGENTS.md +22 -0
- package/rules/workspace-README.md +5 -0
- package/scripts/apply-update-hermes.sh +17 -0
- package/scripts/apply-update-workframe.sh +77 -0
- package/scripts/bootstrap-workspace-link.sh +8 -0
- package/scripts/bundle-workframe-ui.mjs +77 -0
- package/scripts/compose-docker-host.sh +37 -0
- package/scripts/create_workframe_scaffold.py +648 -0
- package/scripts/ensure-compose-host-paths.mjs +51 -0
- package/scripts/fix-zk-encryption-key.sh +35 -0
- package/scripts/lib/install-identity.mjs +212 -0
- package/scripts/lib/workframe-registry.mjs +290 -0
- package/scripts/new-project.mjs +68 -0
- package/scripts/restart-gateway-hermes.sh +12 -0
- package/scripts/security_audit.py +156 -0
- package/scripts/select_agent_pack.py +31 -0
- package/scripts/set-compose-public-url.mjs +92 -0
- package/scripts/setup-stack-secrets.sh +50 -0
- package/scripts/sync-canonical-to-package.mjs +146 -0
- package/scripts/test-scaffold.mjs +390 -0
- package/scripts/verify-public-deploy.sh +105 -0
- package/shared/WORKFRAME_AGENT_LIBRARY.md +31 -0
- package/shared/WORKFRAME_AGENT_OPERATIONS.md +29 -0
- package/shared/WORKFRAME_AGENT_PACKS.json +64 -0
- package/shared/WORKFRAME_AGENT_PACKS.yaml +20 -0
- package/shared/WORKFRAME_CHAT_PERMISSION_MODEL.md +20 -0
- package/shared/WORKFRAME_HANDOFF_SCHEMA.md +25 -0
- package/shared/WORKFRAME_SKILL_CURATION.md +27 -0
- package/shared/agent-avatars/ada.png +0 -0
- package/shared/agent-avatars/aibert.png +0 -0
- package/shared/agent-avatars/amelia.png +0 -0
- package/shared/agent-avatars/andy.png +0 -0
- package/shared/agent-avatars/arc.png +0 -0
- package/shared/agent-avatars/bob.png +0 -0
- package/shared/agent-avatars/buzz.png +0 -0
- package/shared/agent-avatars/carl.png +0 -0
- package/shared/agent-avatars/catalog.json +171 -0
- package/shared/agent-avatars/corbu.png +0 -0
- package/shared/agent-avatars/diana.png +0 -0
- package/shared/agent-avatars/ella.png +0 -0
- package/shared/agent-avatars/elvis.png +0 -0
- package/shared/agent-avatars/f1.png +0 -0
- package/shared/agent-avatars/f2.png +0 -0
- package/shared/agent-avatars/f3.png +0 -0
- package/shared/agent-avatars/f4.png +0 -0
- package/shared/agent-avatars/f5.png +0 -0
- package/shared/agent-avatars/f6.png +0 -0
- package/shared/agent-avatars/frida.png +0 -0
- package/shared/agent-avatars/george.png +0 -0
- package/shared/agent-avatars/grace.png +0 -0
- package/shared/agent-avatars/hedy.png +0 -0
- package/shared/agent-avatars/hermes.png +0 -0
- package/shared/agent-avatars/isaac.png +0 -0
- package/shared/agent-avatars/jes.png +0 -0
- package/shared/agent-avatars/john.png +0 -0
- package/shared/agent-avatars/joni.png +0 -0
- package/shared/agent-avatars/leo.png +0 -0
- package/shared/agent-avatars/louis.png +0 -0
- package/shared/agent-avatars/ludwig.png +0 -0
- package/shared/agent-avatars/m1.png +0 -0
- package/shared/agent-avatars/m2.png +0 -0
- package/shared/agent-avatars/m3.png +0 -0
- package/shared/agent-avatars/m4.png +0 -0
- package/shared/agent-avatars/m5.png +0 -0
- package/shared/agent-avatars/m6.png +0 -0
- package/shared/agent-avatars/marie.png +0 -0
- package/shared/agent-avatars/marilyn.png +0 -0
- package/shared/agent-avatars/neil.png +0 -0
- package/shared/agent-avatars/nikola.png +0 -0
- package/shared/agent-avatars/nina.png +0 -0
- package/shared/agent-avatars/paul.png +0 -0
- package/shared/agent-avatars/ringo.png +0 -0
- package/shared/agent-avatars/rosie.png +0 -0
- package/shared/agent-avatars/ste.png +0 -0
- package/shared/agent-avatars/steve.png +0 -0
- package/shared/agent-avatars/sun.png +0 -0
- package/shared/agent-avatars/tom.png +0 -0
- package/shared/agent-avatars/warren.png +0 -0
- package/shared/agent-avatars/woz.png +0 -0
- package/shared/agent-avatars/zaha.png +0 -0
- package/workframe-api/Dockerfile +14 -0
- package/workframe-api/README.md +28 -0
- package/workframe-api/action_proxy.py +131 -0
- package/workframe-api/auth_rate_limit.py +49 -0
- package/workframe-api/catalog/avatar-catalog.json +171 -0
- package/workframe-api/catalog/logo-catalog.json +86 -0
- package/workframe-api/catalog/user-avatar-catalog.json +171 -0
- package/workframe-api/credential_vault.py +445 -0
- package/workframe-api/data/.gitkeep +0 -0
- package/workframe-api/data/avatar-catalog.json +41 -0
- package/workframe-api/data/logo-catalog.json +14 -0
- package/workframe-api/data/user-avatar-catalog.json +18 -0
- package/workframe-api/email_sender.py +220 -0
- package/workframe-api/google_auth.py +90 -0
- package/workframe-api/install_api.py +359 -0
- package/workframe-api/internal_proxy_auth.py +150 -0
- package/workframe-api/llm_proxy.py +277 -0
- package/workframe-api/oidc_jwt.py +108 -0
- package/workframe-api/package.json +13 -0
- package/workframe-api/platform_auth.py +194 -0
- package/workframe-api/profile_secret_policy.py +86 -0
- package/workframe-api/public/assets/index-DPXu_lGn.css +1 -0
- package/workframe-api/public/assets/index-DYnLrCZZ.js +9 -0
- package/workframe-api/public/assets/index-DglUqFB_.js +9 -0
- package/workframe-api/public/index.html +12 -0
- package/workframe-api/requirements.txt +2 -0
- package/workframe-api/server.py +19646 -0
- package/workframe-api/site_meta.py +271 -0
- package/workframe-api/stack_config.py +427 -0
- package/workframe-api/tests/__init__.py +0 -0
- package/workframe-api/tests/db_setup.py +13 -0
- package/workframe-api/tests/test_admin_updates_gated.py +30 -0
- package/workframe-api/tests/test_agent_dm_bootstrap.py +196 -0
- package/workframe-api/tests/test_agent_profile_sync.py +76 -0
- package/workframe-api/tests/test_auth_email.py +222 -0
- package/workframe-api/tests/test_auth_hole_fix_selfcheck.py +99 -0
- package/workframe-api/tests/test_auth_rate_limit.py +19 -0
- package/workframe-api/tests/test_avatar_resolve.py +77 -0
- package/workframe-api/tests/test_child_soul_template.py +71 -0
- package/workframe-api/tests/test_credential_canary.py +135 -0
- package/workframe-api/tests/test_credential_isolation.py +448 -0
- package/workframe-api/tests/test_credential_resolution.py +206 -0
- package/workframe-api/tests/test_device_oauth.py +108 -0
- package/workframe-api/tests/test_doctor_repair.py +103 -0
- package/workframe-api/tests/test_ensure_profile_api.py +77 -0
- package/workframe-api/tests/test_gateway_compose_security.py +136 -0
- package/workframe-api/tests/test_install_secure_host.py +39 -0
- package/workframe-api/tests/test_internal_proxy_auth.py +125 -0
- package/workframe-api/tests/test_invite_runtime_bootstrap.py +72 -0
- package/workframe-api/tests/test_kanban_delegation.py +185 -0
- package/workframe-api/tests/test_llm_proxy.py +155 -0
- package/workframe-api/tests/test_login_access_policy.py +183 -0
- package/workframe-api/tests/test_mvp_model_bootstrap.py +75 -0
- package/workframe-api/tests/test_onboarding_bootstrap.py +248 -0
- package/workframe-api/tests/test_platform_auth.py +47 -0
- package/workframe-api/tests/test_profile_config_path.py +56 -0
- package/workframe-api/tests/test_profile_config_yaml_repair.py +63 -0
- package/workframe-api/tests/test_profile_create.py +72 -0
- package/workframe-api/tests/test_profile_identity_overlay.py +61 -0
- package/workframe-api/tests/test_profile_install_health.py +45 -0
- package/workframe-api/tests/test_profile_secret_policy.py +57 -0
- package/workframe-api/tests/test_profile_workspace_cwd.py +34 -0
- package/workframe-api/tests/test_provider_bootstrap.py +75 -0
- package/workframe-api/tests/test_provider_connect.py +54 -0
- package/workframe-api/tests/test_room_crud.py +192 -0
- package/workframe-api/tests/test_room_tenancy.py +701 -0
- package/workframe-api/tests/test_runtime_identity_backfill.py +34 -0
- package/workframe-api/tests/test_site_meta.py +81 -0
- package/workframe-api/tests/test_soul_stub.py +42 -0
- package/workframe-api/tests/test_space_member_sync.py +99 -0
- package/workframe-api/tests/test_stripe_stack_config.py +37 -0
- package/workframe-api/tests/test_supervisor_lifecycle.py +52 -0
- package/workframe-api/tests/test_turn_credential_vault.py +125 -0
- package/workframe-api/tests/test_updates.py +176 -0
- package/workframe-api/tests/test_user_cohort.py +113 -0
- package/workframe-api/tests/test_vault_envelope.py +110 -0
- package/workframe-api/tests/test_workspace_members.py +183 -0
- package/workframe-api/tests/test_workspace_messaging_sync.py +125 -0
- package/workframe-api/tests/test_workspace_provider_list.py +57 -0
- package/workframe-api/time-bind-chat.py +99 -0
- package/workframe-api/turn_credentials.py +226 -0
- package/workframe-api/updates.py +417 -0
- package/workframe-api/vault_kek.py +159 -0
- package/workframe-api/zk_auth.py +633 -0
- package/workframe-supervisor/Dockerfile +11 -0
- package/workframe-supervisor/profile_secret_policy.py +76 -0
- package/workframe-supervisor/server.py +787 -0
- package/workframe-supervisor/tests/test_exec_guard.py +42 -0
- package/workframe-supervisor/tests/test_server_import.py +21 -0
- package/workframe-ui/docker/nginx.conf +85 -0
- package/workframe-ui/public/assets/1-DLJbBkOb.png +0 -0
- package/workframe-ui/public/assets/10-uwRwj5ce.png +0 -0
- package/workframe-ui/public/assets/11-5OuV9F_e.png +0 -0
- package/workframe-ui/public/assets/12-u_axjxW-.png +0 -0
- package/workframe-ui/public/assets/13-ldSvcMsH.png +0 -0
- package/workframe-ui/public/assets/14-xdcALEYD.png +0 -0
- package/workframe-ui/public/assets/15-aZ4snEFB.png +0 -0
- package/workframe-ui/public/assets/16-L_5-DttY.png +0 -0
- package/workframe-ui/public/assets/2-zOPZTppD.png +0 -0
- package/workframe-ui/public/assets/3-Dc3WoVu5.png +0 -0
- package/workframe-ui/public/assets/4-C50hk7_m.png +0 -0
- package/workframe-ui/public/assets/5-Eweetkq4.png +0 -0
- package/workframe-ui/public/assets/6-5sOXgfkw.png +0 -0
- package/workframe-ui/public/assets/7-BqRBCbiC.png +0 -0
- package/workframe-ui/public/assets/8-DEDKS94h.png +0 -0
- package/workframe-ui/public/assets/9-DNj34GW-.png +0 -0
- package/workframe-ui/public/assets/ada-DsvuOc9n.png +0 -0
- package/workframe-ui/public/assets/aibert-BCz8Lo8H.png +0 -0
- package/workframe-ui/public/assets/amelia-DUf3EBGu.png +0 -0
- package/workframe-ui/public/assets/andy-Cpymuhhx.png +0 -0
- package/workframe-ui/public/assets/arc-CBDYvkAF.js +1 -0
- package/workframe-ui/public/assets/architecture-7EHR7CIX-CtbQKTuT.js +1 -0
- package/workframe-ui/public/assets/architectureDiagram-3BPJPVTR-XnBRKeW0.js +36 -0
- package/workframe-ui/public/assets/array-BifhSqXX.js +1 -0
- package/workframe-ui/public/assets/avatars/ada.png +0 -0
- package/workframe-ui/public/assets/avatars/aibert.png +0 -0
- package/workframe-ui/public/assets/avatars/amelia.png +0 -0
- package/workframe-ui/public/assets/avatars/andy.png +0 -0
- package/workframe-ui/public/assets/avatars/bob.png +0 -0
- package/workframe-ui/public/assets/avatars/buzz.png +0 -0
- package/workframe-ui/public/assets/avatars/carl.png +0 -0
- package/workframe-ui/public/assets/avatars/catalog.json +171 -0
- package/workframe-ui/public/assets/avatars/corbu.png +0 -0
- package/workframe-ui/public/assets/avatars/diana.png +0 -0
- package/workframe-ui/public/assets/avatars/elvis.png +0 -0
- package/workframe-ui/public/assets/avatars/frida.png +0 -0
- package/workframe-ui/public/assets/avatars/george.png +0 -0
- package/workframe-ui/public/assets/avatars/grace.png +0 -0
- package/workframe-ui/public/assets/avatars/hedy.png +0 -0
- package/workframe-ui/public/assets/avatars/hermes.png +0 -0
- package/workframe-ui/public/assets/avatars/isaac.png +0 -0
- package/workframe-ui/public/assets/avatars/john.png +0 -0
- package/workframe-ui/public/assets/avatars/joni.png +0 -0
- package/workframe-ui/public/assets/avatars/leo.png +0 -0
- package/workframe-ui/public/assets/avatars/louis.png +0 -0
- package/workframe-ui/public/assets/avatars/ludwig.png +0 -0
- package/workframe-ui/public/assets/avatars/marie.png +0 -0
- package/workframe-ui/public/assets/avatars/marilyn.png +0 -0
- package/workframe-ui/public/assets/avatars/nikola.png +0 -0
- package/workframe-ui/public/assets/avatars/nina.png +0 -0
- package/workframe-ui/public/assets/avatars/paul.png +0 -0
- package/workframe-ui/public/assets/avatars/ringo.png +0 -0
- package/workframe-ui/public/assets/avatars/rosie.png +0 -0
- package/workframe-ui/public/assets/avatars/steve.png +0 -0
- package/workframe-ui/public/assets/avatars/sun.png +0 -0
- package/workframe-ui/public/assets/avatars/warren.png +0 -0
- package/workframe-ui/public/assets/avatars/woz.png +0 -0
- package/workframe-ui/public/assets/avatars/zaha.png +0 -0
- package/workframe-ui/public/assets/blockDiagram-GPEHLZMM-VYHUfVhd.js +132 -0
- package/workframe-ui/public/assets/bob-DRz-48Id.png +0 -0
- package/workframe-ui/public/assets/branding/banner.png +0 -0
- package/workframe-ui/public/assets/branding/og-default.png +0 -0
- package/workframe-ui/public/assets/branding/workframe'white.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-1.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-2.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-3.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-4.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-5.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-banner.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-logo-horizontal-mini.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-logo-horizontal-nano.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-logo-horizontal.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-logo-vertical-alt.png +0 -0
- package/workframe-ui/public/assets/branding/workframe-logo-vertical.png +0 -0
- package/workframe-ui/public/assets/branding/workframe.png +0 -0
- package/workframe-ui/public/assets/buzz-mC4PtMvC.png +0 -0
- package/workframe-ui/public/assets/c4Diagram-AAUBKEIU-BTjUcJpm.js +10 -0
- package/workframe-ui/public/assets/carl-CtE74db_.png +0 -0
- package/workframe-ui/public/assets/channel-Dy4Z4-jn.js +1 -0
- package/workframe-ui/public/assets/chunk-2J33WTMH-w7uu7R-b.js +1 -0
- package/workframe-ui/public/assets/chunk-3OPIFGDE-Cb9LtnDX.js +62 -0
- package/workframe-ui/public/assets/chunk-4BX2VUAB-DiQ-qCwH.js +1 -0
- package/workframe-ui/public/assets/chunk-55IACEB6-C-mLFr7z.js +1 -0
- package/workframe-ui/public/assets/chunk-5ZQYHXKU-DOesfiCI.js +2 -0
- package/workframe-ui/public/assets/chunk-727SXJPM-BJ3oBZuz.js +206 -0
- package/workframe-ui/public/assets/chunk-AQP2D5EJ-CCA6xpGs.js +231 -0
- package/workframe-ui/public/assets/chunk-BSJP7CBP-a0cMNFb2.js +1 -0
- package/workframe-ui/public/assets/chunk-CSCIHK7Q-kuqN8EIY.js +122 -0
- package/workframe-ui/public/assets/chunk-FMBD7UC4-DyPgYHCg.js +15 -0
- package/workframe-ui/public/assets/chunk-KSCS5N6A-CdUuvR0V.js +10 -0
- package/workframe-ui/public/assets/chunk-L5ZTLDWV-Dq9NoWmK.js +1 -0
- package/workframe-ui/public/assets/chunk-LZXEDZCA-p74rddlO.js +2 -0
- package/workframe-ui/public/assets/chunk-ND2GUHAM-DBD2u1Gz.js +1 -0
- package/workframe-ui/public/assets/chunk-NNHCCRGN-DlpIbxXb.js +159 -0
- package/workframe-ui/public/assets/chunk-NZK2D7GU-BeIeYFnd.js +1 -0
- package/workframe-ui/public/assets/chunk-O5CBEL6O-ClHc56ib.js +70 -0
- package/workframe-ui/public/assets/chunk-QZHKN3VN-CtBEchFK.js +1 -0
- package/workframe-ui/public/assets/chunk-WU5MYG2G-B9pBtriN.js +1 -0
- package/workframe-ui/public/assets/chunk-XPW4576I-EFr8R_1p.js +32 -0
- package/workframe-ui/public/assets/classDiagram-4FO5ZUOK-BMAEA8jI.js +1 -0
- package/workframe-ui/public/assets/classDiagram-v2-Q7XG4LA2-BMAEA8jI.js +1 -0
- package/workframe-ui/public/assets/corbu-KiaMXzXQ.png +0 -0
- package/workframe-ui/public/assets/cose-bilkent-S5V4N54A-C7aPBODd.js +1 -0
- package/workframe-ui/public/assets/cytoscape.esm-h6BdjjI9.js +321 -0
- package/workframe-ui/public/assets/dagre-BM42HDAG-BdU1Rv-H.js +4 -0
- package/workframe-ui/public/assets/dagre-Bx709z4p.js +1 -0
- package/workframe-ui/public/assets/defaultLocale-C8Fc0cco.js +1 -0
- package/workframe-ui/public/assets/diagram-2AECGRRQ-DWowSo85.js +43 -0
- package/workframe-ui/public/assets/diagram-5GNKFQAL-MnxBbceO.js +10 -0
- package/workframe-ui/public/assets/diagram-KO2AKTUF-DQaLRXFf.js +3 -0
- package/workframe-ui/public/assets/diagram-LMA3HP47-CQaBud9k.js +24 -0
- package/workframe-ui/public/assets/diagram-OG6HWLK6-D8bAXbY9.js +24 -0
- package/workframe-ui/public/assets/diana-DW0MsL38.png +0 -0
- package/workframe-ui/public/assets/dist-DGpTLHr_.js +1 -0
- package/workframe-ui/public/assets/elvis-LCFaZIcT.png +0 -0
- package/workframe-ui/public/assets/erDiagram-TEJ5UH35-1E-xSvBK.js +85 -0
- package/workframe-ui/public/assets/eventmodeling-FCH6USID-D75cstNT.js +1 -0
- package/workframe-ui/public/assets/flowDiagram-I6XJVG4X-CgOVD5hu.js +162 -0
- package/workframe-ui/public/assets/frida-CXFA0w3F.png +0 -0
- package/workframe-ui/public/assets/ganttDiagram-6RSMTGT7-JFYAIauo.js +292 -0
- package/workframe-ui/public/assets/george-DBSH2Sm2.png +0 -0
- package/workframe-ui/public/assets/gitGraph-WXDBUCRP-B9REenIl.js +1 -0
- package/workframe-ui/public/assets/gitGraphDiagram-PVQCEYII-BQ7NcMSn.js +106 -0
- package/workframe-ui/public/assets/grace-BhV0UPc0.png +0 -0
- package/workframe-ui/public/assets/graphlib-B8gBHxth.js +1 -0
- package/workframe-ui/public/assets/hedy-BR2IHift.png +0 -0
- package/workframe-ui/public/assets/hermes-CqCzcE0y.png +0 -0
- package/workframe-ui/public/assets/index-Dnw6vjqb.js +133 -0
- package/workframe-ui/public/assets/index-DpAGxump.css +1 -0
- package/workframe-ui/public/assets/info-J43DQDTF-CL6-eTjH.js +1 -0
- package/workframe-ui/public/assets/infoDiagram-5YYISTIA-LJTODW4W.js +2 -0
- package/workframe-ui/public/assets/init-D6jRqBbL.js +1 -0
- package/workframe-ui/public/assets/isaac-D1nhJAuv.png +0 -0
- package/workframe-ui/public/assets/ishikawaDiagram-YF4QCWOH-bchrQVuo.js +70 -0
- package/workframe-ui/public/assets/john-zSPWwNi4.png +0 -0
- package/workframe-ui/public/assets/joni-BFLoyfJP.png +0 -0
- package/workframe-ui/public/assets/journeyDiagram-JHISSGLW-DkrvYuxP.js +139 -0
- package/workframe-ui/public/assets/kanban-definition-UN3LZRKU-DFRbj0IG.js +89 -0
- package/workframe-ui/public/assets/katex-Vhh-h91d.js +257 -0
- package/workframe-ui/public/assets/leo-C_3IOL11.png +0 -0
- package/workframe-ui/public/assets/line-Vd48P7-O.js +1 -0
- package/workframe-ui/public/assets/linear-Ckizh2G7.js +1 -0
- package/workframe-ui/public/assets/louis-DEEECFSX.png +0 -0
- package/workframe-ui/public/assets/ludwig-_hoKhhyK.png +0 -0
- package/workframe-ui/public/assets/marie-DET6MsfO.png +0 -0
- package/workframe-ui/public/assets/marilyn-DTqwt8Yh.png +0 -0
- package/workframe-ui/public/assets/mermaid-parser.core-Bkimsnqj.js +4 -0
- package/workframe-ui/public/assets/mermaid.core-x0TvVuPo.js +9 -0
- package/workframe-ui/public/assets/mindmap-definition-RKZ34NQL-6ykAFPEz.js +96 -0
- package/workframe-ui/public/assets/nikola-B4PtHrJv.png +0 -0
- package/workframe-ui/public/assets/nina-BYbrOn0d.png +0 -0
- package/workframe-ui/public/assets/ordinal-hYBb2elL.js +1 -0
- package/workframe-ui/public/assets/packet-YPE3B663-Dw3xgMDt.js +1 -0
- package/workframe-ui/public/assets/path-BWPyau1x.js +1 -0
- package/workframe-ui/public/assets/paul-CGURYQIn.png +0 -0
- package/workframe-ui/public/assets/pie-LRSECV5Y-DATysawG.js +1 -0
- package/workframe-ui/public/assets/pieDiagram-4H26LBE5-SJKD1S0S.js +30 -0
- package/workframe-ui/public/assets/project-logos/1.png +0 -0
- package/workframe-ui/public/assets/project-logos/10.png +0 -0
- package/workframe-ui/public/assets/project-logos/11.png +0 -0
- package/workframe-ui/public/assets/project-logos/12.png +0 -0
- package/workframe-ui/public/assets/project-logos/13.png +0 -0
- package/workframe-ui/public/assets/project-logos/14.png +0 -0
- package/workframe-ui/public/assets/project-logos/15.png +0 -0
- package/workframe-ui/public/assets/project-logos/16.png +0 -0
- package/workframe-ui/public/assets/project-logos/2.png +0 -0
- package/workframe-ui/public/assets/project-logos/3.png +0 -0
- package/workframe-ui/public/assets/project-logos/4.png +0 -0
- package/workframe-ui/public/assets/project-logos/5.png +0 -0
- package/workframe-ui/public/assets/project-logos/6.png +0 -0
- package/workframe-ui/public/assets/project-logos/7.png +0 -0
- package/workframe-ui/public/assets/project-logos/8.png +0 -0
- package/workframe-ui/public/assets/project-logos/9.png +0 -0
- package/workframe-ui/public/assets/project-logos/catalog.json +86 -0
- package/workframe-ui/public/assets/quadrantDiagram-W4KKPZXB-BrYDZX8q.js +7 -0
- package/workframe-ui/public/assets/radar-GUYGQ44K-BmWYPCds.js +1 -0
- package/workframe-ui/public/assets/requirementDiagram-4Y6WPE33-DwL9Mc8e.js +84 -0
- package/workframe-ui/public/assets/ringo-WhfUNOyY.png +0 -0
- package/workframe-ui/public/assets/rosie-CAtcIf87.png +0 -0
- package/workframe-ui/public/assets/rough.esm-CSKSodPl.js +1 -0
- package/workframe-ui/public/assets/sankeyDiagram-5OEKKPKP-DYIFsL8h.js +40 -0
- package/workframe-ui/public/assets/sequenceDiagram-3UESZ5HK-0-FPkFk8.js +162 -0
- package/workframe-ui/public/assets/src-B_od6b6h.js +1 -0
- package/workframe-ui/public/assets/stateDiagram-AJRCARHV-BQCiBk6u.js +1 -0
- package/workframe-ui/public/assets/stateDiagram-v2-BHNVJYJU-B89jAMFF.js +1 -0
- package/workframe-ui/public/assets/steve-CgXXJ9EZ.png +0 -0
- package/workframe-ui/public/assets/sun-BLNAhoZd.png +0 -0
- package/workframe-ui/public/assets/timeline-definition-PNZ67QCA-DS3tFcXj.js +120 -0
- package/workframe-ui/public/assets/treeView-BLDUP644-DSyUCKLY.js +1 -0
- package/workframe-ui/public/assets/treemap-LRROVOQU-CEZaNh5Y.js +1 -0
- package/workframe-ui/public/assets/vennDiagram-CIIHVFJN-CD-Vc9NF.js +34 -0
- package/workframe-ui/public/assets/wardley-L42UT6IY-Drq5w1Mc.js +1 -0
- package/workframe-ui/public/assets/wardleyDiagram-YWT4CUSO-DouXDJoF.js +78 -0
- package/workframe-ui/public/assets/warren-DIH7UKMY.png +0 -0
- package/workframe-ui/public/assets/woz-D2yleG-V.png +0 -0
- package/workframe-ui/public/assets/xychartDiagram-2RQKCTM6-DDf_Lol5.js +7 -0
- package/workframe-ui/public/assets/zaha-wersOEq9.png +0 -0
- package/workframe-ui/public/favicon.ico +0 -0
- package/workframe-ui/public/favicon.svg +7 -0
- package/workframe-ui/public/icons.svg +24 -0
- package/workframe-ui/public/index.html +50 -0
- package/workframe-ui/public/manifest.webmanifest +18 -0
- package/workframe-ui/public/workframe-config.json +4 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
import unittest
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from unittest.mock import patch
|
|
5
|
+
|
|
6
|
+
import server
|
|
7
|
+
from db_setup import ensure_workframe_schemas
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class UserCohortTests(unittest.TestCase):
|
|
11
|
+
def setUp(self) -> None:
|
|
12
|
+
self._tmp = tempfile.TemporaryDirectory()
|
|
13
|
+
self.addCleanup(self._tmp.cleanup)
|
|
14
|
+
self._old_data_dir = server.DATA_DIR
|
|
15
|
+
self._old_auth_db_path = server.AUTH_DB_PATH
|
|
16
|
+
self._old_hermes_data = server.HERMES_DATA
|
|
17
|
+
server.DATA_DIR = Path(self._tmp.name)
|
|
18
|
+
server.AUTH_DB_PATH = Path(self._tmp.name) / "auth.db"
|
|
19
|
+
server.HERMES_DATA = Path(self._tmp.name) / "hermes"
|
|
20
|
+
(server.HERMES_DATA / "profiles").mkdir(parents=True)
|
|
21
|
+
ensure_workframe_schemas()
|
|
22
|
+
self.workspace_id = "ws-1"
|
|
23
|
+
self.user_id = "cb6a2db4-ac86-4c49-8aaa-user"
|
|
24
|
+
conn = server._workframe_db()
|
|
25
|
+
try:
|
|
26
|
+
now = "1"
|
|
27
|
+
conn.execute(
|
|
28
|
+
"INSERT INTO users (id, display_name, email, role, status, created_at, updated_at) VALUES (?,?,?,?,?,?,?)",
|
|
29
|
+
(self.user_id, "Fab", "fab@example.com", "member", "active", now, now),
|
|
30
|
+
)
|
|
31
|
+
conn.execute(
|
|
32
|
+
"INSERT INTO workspaces (id, slug, display_name, owner_id, status, created_at, updated_at) VALUES (?,?,?,?,?,?,?)",
|
|
33
|
+
(self.workspace_id, "proj", "Project", self.user_id, "active", now, now),
|
|
34
|
+
)
|
|
35
|
+
for slug, name, is_native in (
|
|
36
|
+
("workframe-agent", "Workframe Agent", 1),
|
|
37
|
+
("architect", "Architect", 0),
|
|
38
|
+
("dev", "Dev", 0),
|
|
39
|
+
):
|
|
40
|
+
conn.execute(
|
|
41
|
+
"""
|
|
42
|
+
INSERT INTO agent_profiles (id, workspace_id, slug, display_name, is_native, status, created_at, updated_at)
|
|
43
|
+
VALUES (?, ?, ?, ?, ?, 'available', ?, ?)
|
|
44
|
+
""",
|
|
45
|
+
(f"ap-{slug}", self.workspace_id, slug, name, is_native, now, now),
|
|
46
|
+
)
|
|
47
|
+
conn.commit()
|
|
48
|
+
finally:
|
|
49
|
+
conn.close()
|
|
50
|
+
|
|
51
|
+
def tearDown(self) -> None:
|
|
52
|
+
server.DATA_DIR = self._old_data_dir
|
|
53
|
+
server.AUTH_DB_PATH = self._old_auth_db_path
|
|
54
|
+
server.HERMES_DATA = self._old_hermes_data
|
|
55
|
+
|
|
56
|
+
def test_user_handle_from_display_name(self) -> None:
|
|
57
|
+
self.assertEqual(server._user_handle(self.user_id), "fab")
|
|
58
|
+
|
|
59
|
+
def test_cohort_alias(self) -> None:
|
|
60
|
+
self.assertEqual(server._cohort_alias(self.user_id, "architect"), "fab-architect")
|
|
61
|
+
|
|
62
|
+
def test_runtime_display_label_specialist(self) -> None:
|
|
63
|
+
label = server._runtime_display_label(self.user_id, "architect", self.workspace_id)
|
|
64
|
+
self.assertEqual(label, "Architect")
|
|
65
|
+
|
|
66
|
+
def test_runtime_display_label_concierge(self) -> None:
|
|
67
|
+
label = server._runtime_display_label(self.user_id, "workframe-agent", self.workspace_id)
|
|
68
|
+
self.assertEqual(label, "Workframe Agent")
|
|
69
|
+
|
|
70
|
+
def test_runtime_display_label_personalized_without_db_name(self) -> None:
|
|
71
|
+
label = server._runtime_display_label(self.user_id, "research", self.workspace_id)
|
|
72
|
+
self.assertEqual(label, "Fab's Research")
|
|
73
|
+
|
|
74
|
+
def test_resolve_runtime_assignee_slug(self) -> None:
|
|
75
|
+
with patch.object(server, "ensure_runtime_profile") as ensure:
|
|
76
|
+
slug = server.resolve_runtime_assignee("architect", self.user_id, self.workspace_id)
|
|
77
|
+
self.assertTrue(slug.startswith("u-"))
|
|
78
|
+
self.assertTrue(slug.endswith("-architect"))
|
|
79
|
+
ensure.assert_called_once()
|
|
80
|
+
|
|
81
|
+
@patch.object(server, "ensure_runtime_profile")
|
|
82
|
+
def test_ensure_user_agent_cohort_writes_manifest(self, _ensure: object) -> None:
|
|
83
|
+
cohort = server.ensure_user_agent_cohort(self.user_id, self.workspace_id)
|
|
84
|
+
self.assertEqual(len(cohort), 3)
|
|
85
|
+
assignees = {row["template_slug"]: row["runtime_slug"] for row in cohort}
|
|
86
|
+
self.assertTrue(assignees["architect"].startswith("u-"))
|
|
87
|
+
concierge = assignees["workframe-agent"]
|
|
88
|
+
manifest = server._profile_dir(concierge) / "WORKFRAME_COHORT.md"
|
|
89
|
+
self.assertTrue(manifest.is_file())
|
|
90
|
+
text = manifest.read_text(encoding="utf-8")
|
|
91
|
+
self.assertIn("Fab's Workframe cohort", text)
|
|
92
|
+
self.assertIn(assignees["architect"], text)
|
|
93
|
+
self.assertIn("fab-architect", text)
|
|
94
|
+
self.assertIn("workspace_kind", text)
|
|
95
|
+
|
|
96
|
+
def test_cohort_manifest_markdown_includes_rules(self) -> None:
|
|
97
|
+
body = server._cohort_manifest_markdown(
|
|
98
|
+
self.user_id,
|
|
99
|
+
[
|
|
100
|
+
{
|
|
101
|
+
"role": "Architect",
|
|
102
|
+
"display_name": "Fab's Architect",
|
|
103
|
+
"runtime_slug": "u-cb6a2db4-architect",
|
|
104
|
+
"alias": "fab-architect",
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
)
|
|
108
|
+
self.assertIn("never bare template names", body)
|
|
109
|
+
self.assertIn("`scratch`", body)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
unittest.main()
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Vault envelope encryption (KEK + per-secret DEK)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import tempfile
|
|
7
|
+
import unittest
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import credential_vault
|
|
11
|
+
import vault_kek
|
|
12
|
+
import zk_auth
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class VaultEnvelopeTests(unittest.TestCase):
|
|
16
|
+
def setUp(self) -> None:
|
|
17
|
+
self._tmp = tempfile.TemporaryDirectory()
|
|
18
|
+
self.addCleanup(self._tmp.cleanup)
|
|
19
|
+
self._old_data = credential_vault.DATA_DIR
|
|
20
|
+
self._old_db = credential_vault.VAULT_DB
|
|
21
|
+
self._old_kek_file = vault_kek.VAULT_KEK_FILE
|
|
22
|
+
credential_vault.DATA_DIR = Path(self._tmp.name)
|
|
23
|
+
credential_vault.VAULT_DB = credential_vault.DATA_DIR / "credential_vault.db"
|
|
24
|
+
vault_kek.DATA_DIR = credential_vault.DATA_DIR
|
|
25
|
+
vault_kek.VAULT_KEK_FILE = credential_vault.DATA_DIR / ".vault_kek"
|
|
26
|
+
vault_kek.clear_kek()
|
|
27
|
+
credential_vault.ensure_schema()
|
|
28
|
+
|
|
29
|
+
def tearDown(self) -> None:
|
|
30
|
+
vault_kek.clear_kek()
|
|
31
|
+
credential_vault.DATA_DIR = self._old_data
|
|
32
|
+
credential_vault.VAULT_DB = self._old_db
|
|
33
|
+
vault_kek.VAULT_KEK_FILE = self._old_kek_file
|
|
34
|
+
|
|
35
|
+
def test_v2_envelope_roundtrip(self) -> None:
|
|
36
|
+
credential_vault.unseal_for_tests()
|
|
37
|
+
credential_vault.store_secret("bid-1", "sk-live-secret", provider="openrouter")
|
|
38
|
+
conn = credential_vault._connect()
|
|
39
|
+
try:
|
|
40
|
+
row = conn.execute(
|
|
41
|
+
"SELECT encrypted_secret FROM credential_secrets WHERE binding_id = ?",
|
|
42
|
+
("bid-1",),
|
|
43
|
+
).fetchone()
|
|
44
|
+
blob = str(row["encrypted_secret"])
|
|
45
|
+
parsed = json.loads(blob)
|
|
46
|
+
self.assertEqual(parsed["v"], 2)
|
|
47
|
+
self.assertIn("wrapped_dek", parsed)
|
|
48
|
+
finally:
|
|
49
|
+
conn.close()
|
|
50
|
+
self.assertEqual(credential_vault.read_secret("bid-1"), "sk-live-secret")
|
|
51
|
+
|
|
52
|
+
def test_legacy_v1_readable_after_unseal(self) -> None:
|
|
53
|
+
legacy = json.dumps(zk_auth.encrypt_string("legacy-key", zk_auth.ZK_AUTH_ENCRYPTION_KEY))
|
|
54
|
+
conn = credential_vault._connect()
|
|
55
|
+
now = "1"
|
|
56
|
+
conn.execute(
|
|
57
|
+
"""
|
|
58
|
+
INSERT INTO credential_secrets (
|
|
59
|
+
binding_id, encrypted_secret, env_var, provider, scope,
|
|
60
|
+
user_id, workspace_id, created_at, updated_at
|
|
61
|
+
) VALUES (?,?,?,?,?,?,?,?,?)
|
|
62
|
+
""",
|
|
63
|
+
("legacy-1", legacy, "OPENROUTER_API_KEY", "openrouter", "user", "u1", None, now, now),
|
|
64
|
+
)
|
|
65
|
+
conn.commit()
|
|
66
|
+
conn.close()
|
|
67
|
+
credential_vault.unseal_for_tests()
|
|
68
|
+
self.assertEqual(credential_vault.read_secret("legacy-1"), "legacy-key")
|
|
69
|
+
conn = credential_vault._connect()
|
|
70
|
+
try:
|
|
71
|
+
row = conn.execute(
|
|
72
|
+
"SELECT encrypted_secret FROM credential_secrets WHERE binding_id = ?",
|
|
73
|
+
("legacy-1",),
|
|
74
|
+
).fetchone()
|
|
75
|
+
self.assertEqual(json.loads(str(row["encrypted_secret"]))["v"], 2)
|
|
76
|
+
finally:
|
|
77
|
+
conn.close()
|
|
78
|
+
|
|
79
|
+
def test_sealed_vault_blocks_store_without_passphrase_bootstrap(self) -> None:
|
|
80
|
+
credential_vault.unseal_for_tests()
|
|
81
|
+
credential_vault.init_vault_passphrase("long-passphrase-1")
|
|
82
|
+
credential_vault.seal_vault()
|
|
83
|
+
with self.assertRaises(RuntimeError):
|
|
84
|
+
credential_vault.store_secret("x", "secret")
|
|
85
|
+
|
|
86
|
+
def test_passphrase_unlock_restores_access(self) -> None:
|
|
87
|
+
credential_vault.unseal_for_tests()
|
|
88
|
+
credential_vault.store_secret("k1", "before-seal")
|
|
89
|
+
credential_vault.init_vault_passphrase("another-long-pass")
|
|
90
|
+
credential_vault.seal_vault()
|
|
91
|
+
status = credential_vault.unlock_vault("another-long-pass")
|
|
92
|
+
self.assertFalse(status["sealed"])
|
|
93
|
+
self.assertEqual(credential_vault.read_secret("k1"), "before-seal")
|
|
94
|
+
|
|
95
|
+
def test_wipe_deletes_ciphertext(self) -> None:
|
|
96
|
+
credential_vault.unseal_for_tests()
|
|
97
|
+
credential_vault.store_secret("w1", "to-delete")
|
|
98
|
+
deleted = credential_vault.wipe_all_secrets()
|
|
99
|
+
self.assertEqual(deleted, 1)
|
|
100
|
+
self.assertEqual(credential_vault.read_secret("w1"), "")
|
|
101
|
+
|
|
102
|
+
def test_bootstrap_generates_kek_file_for_local(self) -> None:
|
|
103
|
+
vault_kek.clear_kek()
|
|
104
|
+
status = credential_vault.bootstrap_vault(allow_generate_file=True)
|
|
105
|
+
self.assertFalse(status["sealed"])
|
|
106
|
+
self.assertTrue(vault_kek.VAULT_KEK_FILE.is_file())
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
unittest.main()
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib.util
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from types import SimpleNamespace
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
SERVER_PATH = Path(__file__).resolve().parents[1] / "server.py"
|
|
11
|
+
spec = importlib.util.spec_from_file_location("workframe_server", SERVER_PATH)
|
|
12
|
+
server = importlib.util.module_from_spec(spec)
|
|
13
|
+
assert spec.loader is not None
|
|
14
|
+
spec.loader.exec_module(server)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FakeHandler:
|
|
18
|
+
def __init__(self, auth_user: str = "u_owner", auth_role: str = "owner") -> None:
|
|
19
|
+
self.auth_user = auth_user
|
|
20
|
+
self.auth_role = auth_role
|
|
21
|
+
self.headers = {}
|
|
22
|
+
self.client_address = ("127.0.0.1", 12345)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@pytest.fixture(autouse=True)
|
|
26
|
+
def isolate_server(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
27
|
+
monkeypatch.setattr(server, "DATA_DIR", tmp_path)
|
|
28
|
+
monkeypatch.setattr(server, "AUTH_DB_PATH", tmp_path / "auth.db")
|
|
29
|
+
monkeypatch.setattr(server, "SECURE_MODE", False)
|
|
30
|
+
monkeypatch.setattr(server, "DEV_LOCAL_UNSAFE", True)
|
|
31
|
+
server._ensure_workframe_db_schema()
|
|
32
|
+
server._ensure_agent_runs_schema()
|
|
33
|
+
server._ensure_invites_schema()
|
|
34
|
+
server._ensure_memory_schema()
|
|
35
|
+
server._ensure_policies_schema()
|
|
36
|
+
server._ensure_budgets_grants_schema()
|
|
37
|
+
server._ensure_user_prefs_schema()
|
|
38
|
+
server._ensure_runtime_tokens_table()
|
|
39
|
+
seed_db(tmp_path)
|
|
40
|
+
yield
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def seed_db(tmp_path: Path) -> None:
|
|
44
|
+
conn = server._workframe_db()
|
|
45
|
+
try:
|
|
46
|
+
now = "1700000000"
|
|
47
|
+
conn.execute(
|
|
48
|
+
"INSERT INTO workspaces (id, slug, display_name, owner_id, created_at, updated_at) VALUES (?,?,?,?,?,?)",
|
|
49
|
+
("ws", "default", "Default", "u_owner", now, now),
|
|
50
|
+
)
|
|
51
|
+
conn.executemany(
|
|
52
|
+
"INSERT INTO users (id, email, display_name, avatar_url, role, status, created_at, updated_at) VALUES (?,?,?,?,?,?,?,?)",
|
|
53
|
+
[
|
|
54
|
+
("u_owner", "owner@example.com", "Owner", None, "owner", "active", now, now),
|
|
55
|
+
("u_bob", "bob@example.com", "Bob", None, "member", "active", now, now),
|
|
56
|
+
("u_carol", "carol@example.com", "Carol", None, "member", "active", now, now),
|
|
57
|
+
("u_outsider", "outsider@example.com", "Outsider", None, "member", "active", now, now),
|
|
58
|
+
],
|
|
59
|
+
)
|
|
60
|
+
conn.executemany(
|
|
61
|
+
"INSERT INTO workspace_memberships (id, workspace_id, user_id, role, status, invited_by, created_at, updated_at) VALUES (?,?,?,?,?,?,?,?)",
|
|
62
|
+
[
|
|
63
|
+
("m_owner", "ws", "u_owner", "owner", "active", None, now, now),
|
|
64
|
+
("m_bob", "ws", "u_bob", "member", "active", "u_owner", now, now),
|
|
65
|
+
("m_carol", "ws", "u_carol", "member", "active", "u_owner", now, now),
|
|
66
|
+
],
|
|
67
|
+
)
|
|
68
|
+
conn.commit()
|
|
69
|
+
finally:
|
|
70
|
+
conn.close()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def membership_by_user(payload: dict[str, Any], user_id: str) -> dict[str, Any]:
|
|
74
|
+
return next(item for item in payload["members"] if item["user_id"] == user_id)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_list_workspace_members_returns_active_memberships_with_user_fields() -> None:
|
|
78
|
+
status, payload = server._list_workspace_members("ws", FakeHandler())
|
|
79
|
+
|
|
80
|
+
assert status == 200
|
|
81
|
+
assert payload["ok"] is True
|
|
82
|
+
assert payload["workspace_id"] == "ws"
|
|
83
|
+
assert [item["user_id"] for item in payload["members"]] == ["u_bob", "u_carol", "u_owner"]
|
|
84
|
+
bob = membership_by_user(payload, "u_bob")
|
|
85
|
+
assert bob["membership_id"] == "m_bob"
|
|
86
|
+
assert bob["email"] == "bob@example.com"
|
|
87
|
+
assert bob["display_name"] == "Bob"
|
|
88
|
+
assert bob["role"] == "member"
|
|
89
|
+
assert bob["status"] == "active"
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_patch_updates_member_role_and_status() -> None:
|
|
93
|
+
status, payload = server._patch_workspace_members(
|
|
94
|
+
"ws",
|
|
95
|
+
{"user_id": "u_bob", "role": "admin", "status": "active"},
|
|
96
|
+
FakeHandler(),
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
assert status == 200
|
|
100
|
+
assert payload["membership"]["user_id"] == "u_bob"
|
|
101
|
+
assert payload["membership"]["role"] == "admin"
|
|
102
|
+
assert payload["membership"]["status"] == "active"
|
|
103
|
+
assert payload["membership"]["updated_at"] != "1700000000"
|
|
104
|
+
|
|
105
|
+
_, listed = server._list_workspace_members("ws", FakeHandler())
|
|
106
|
+
assert membership_by_user(listed, "u_bob")["role"] == "admin"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_patch_status_removed_soft_deletes_member() -> None:
|
|
110
|
+
status, payload = server._patch_workspace_members(
|
|
111
|
+
"ws",
|
|
112
|
+
{"user_id": "u_carol", "status": "removed"},
|
|
113
|
+
FakeHandler(),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
assert status == 200
|
|
117
|
+
assert payload["membership"]["status"] == "removed"
|
|
118
|
+
|
|
119
|
+
_, listed = server._list_workspace_members("ws", FakeHandler())
|
|
120
|
+
assert "u_carol" not in [item["user_id"] for item in listed["members"]]
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_patch_bulk_updates_memberships() -> None:
|
|
124
|
+
status, payload = server._patch_workspace_members(
|
|
125
|
+
"ws",
|
|
126
|
+
{
|
|
127
|
+
"memberships": [
|
|
128
|
+
{"user_id": "u_bob", "role": "admin"},
|
|
129
|
+
{"user_id": "u_carol", "role": "member"},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
FakeHandler(),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
assert status == 200
|
|
136
|
+
assert [item["user_id"] for item in payload["memberships"]] == ["u_bob", "u_carol"]
|
|
137
|
+
assert payload["memberships"][0]["role"] == "admin"
|
|
138
|
+
assert payload["memberships"][1]["role"] == "member"
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_patch_requires_owner_or_admin_when_secure(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
142
|
+
monkeypatch.setattr(server, "SECURE_MODE", True)
|
|
143
|
+
|
|
144
|
+
status, payload = server._patch_workspace_members(
|
|
145
|
+
"ws",
|
|
146
|
+
{"user_id": "u_bob", "role": "admin"},
|
|
147
|
+
FakeHandler(auth_user="u_bob", auth_role="member"),
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
assert status == 403
|
|
151
|
+
assert payload["error"] == "forbidden"
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_patch_rejects_invalid_role() -> None:
|
|
155
|
+
status, payload = server._patch_workspace_members(
|
|
156
|
+
"ws",
|
|
157
|
+
{"user_id": "u_bob", "role": "superadmin"},
|
|
158
|
+
FakeHandler(),
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
assert status == 400
|
|
162
|
+
assert payload["error"] == "invalid_role"
|
|
163
|
+
assert "superadmin" not in payload["allowed"]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_patch_prevents_removing_last_owner() -> None:
|
|
167
|
+
status, payload = server._patch_workspace_members(
|
|
168
|
+
"ws",
|
|
169
|
+
{"user_id": "u_owner", "status": "removed"},
|
|
170
|
+
FakeHandler(),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
assert status == 409
|
|
174
|
+
assert payload["error"] == "cannot_remove_last_owner"
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_list_workspace_members_requires_workspace_access_when_secure(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
178
|
+
monkeypatch.setattr(server, "SECURE_MODE", True)
|
|
179
|
+
|
|
180
|
+
status, payload = server._list_workspace_members("ws", FakeHandler(auth_user="u_outsider", auth_role="member"))
|
|
181
|
+
|
|
182
|
+
assert status == 403
|
|
183
|
+
assert payload["error"] == "forbidden"
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Workspace messaging: vault store, settings merge, gateway env overlay."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import tempfile
|
|
5
|
+
import unittest
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from unittest.mock import patch
|
|
8
|
+
|
|
9
|
+
import credential_vault
|
|
10
|
+
import server
|
|
11
|
+
import vault_kek
|
|
12
|
+
from db_setup import ensure_workframe_schemas
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class WorkspaceMessagingSyncTests(unittest.TestCase):
|
|
16
|
+
def setUp(self) -> None:
|
|
17
|
+
self._tmp = tempfile.TemporaryDirectory()
|
|
18
|
+
self.addCleanup(self._tmp.cleanup)
|
|
19
|
+
self._old_data_dir = server.DATA_DIR
|
|
20
|
+
self._old_auth_db_path = server.AUTH_DB_PATH
|
|
21
|
+
self._old_hermes_data = server.HERMES_DATA
|
|
22
|
+
self._old_vault_data_dir = credential_vault.DATA_DIR
|
|
23
|
+
self._old_vault_db = credential_vault.VAULT_DB
|
|
24
|
+
self._old_kek_data_dir = vault_kek.DATA_DIR
|
|
25
|
+
self._old_kek_file = vault_kek.VAULT_KEK_FILE
|
|
26
|
+
server.DATA_DIR = Path(self._tmp.name)
|
|
27
|
+
server.AUTH_DB_PATH = Path(self._tmp.name) / "auth.db"
|
|
28
|
+
server.HERMES_DATA = Path(self._tmp.name) / "hermes"
|
|
29
|
+
profile_dir = server._profile_dir("workframe-agent")
|
|
30
|
+
profile_dir.mkdir(parents=True, exist_ok=True)
|
|
31
|
+
credential_vault.DATA_DIR = server.DATA_DIR
|
|
32
|
+
credential_vault.VAULT_DB = server.DATA_DIR / "credential_vault.db"
|
|
33
|
+
vault_kek.DATA_DIR = server.DATA_DIR
|
|
34
|
+
vault_kek.VAULT_KEK_FILE = server.DATA_DIR / ".vault_kek"
|
|
35
|
+
credential_vault.ensure_schema()
|
|
36
|
+
credential_vault.unseal_for_tests()
|
|
37
|
+
ensure_workframe_schemas()
|
|
38
|
+
self.workspace_id = "ws-msg"
|
|
39
|
+
self.admin_id = "admin-msg-user"
|
|
40
|
+
conn = server._workframe_db()
|
|
41
|
+
try:
|
|
42
|
+
now = "1"
|
|
43
|
+
conn.execute(
|
|
44
|
+
"INSERT INTO workspaces (id, slug, display_name, owner_id, status, settings_json, created_at, updated_at) VALUES (?,?,?,?,?,?,?,?)",
|
|
45
|
+
(self.workspace_id, "default", "Default", self.admin_id, "active", "{}", now, now),
|
|
46
|
+
)
|
|
47
|
+
conn.execute(
|
|
48
|
+
"INSERT INTO users (id, display_name, platform_ids, role, status, created_at, updated_at) VALUES (?,?,?,?,?,?,?)",
|
|
49
|
+
(self.admin_id, "Admin", json.dumps({"discord": "999888777"}), "owner", "active", now, now),
|
|
50
|
+
)
|
|
51
|
+
conn.execute(
|
|
52
|
+
"""
|
|
53
|
+
INSERT INTO workspace_memberships (id, workspace_id, user_id, role, status, created_at, updated_at)
|
|
54
|
+
VALUES (?, ?, ?, 'owner', 'active', ?, ?)
|
|
55
|
+
""",
|
|
56
|
+
("wm-admin", self.workspace_id, self.admin_id, now, now),
|
|
57
|
+
)
|
|
58
|
+
conn.execute(
|
|
59
|
+
"""
|
|
60
|
+
INSERT INTO agent_profiles (id, workspace_id, slug, display_name, is_native, status, created_at, updated_at)
|
|
61
|
+
VALUES (?, ?, 'workframe-agent', 'Workframe Agent', 1, 'available', ?, ?)
|
|
62
|
+
""",
|
|
63
|
+
("ap-native", self.workspace_id, now, now),
|
|
64
|
+
)
|
|
65
|
+
conn.commit()
|
|
66
|
+
finally:
|
|
67
|
+
conn.close()
|
|
68
|
+
|
|
69
|
+
def tearDown(self) -> None:
|
|
70
|
+
server.DATA_DIR = self._old_data_dir
|
|
71
|
+
server.AUTH_DB_PATH = self._old_auth_db_path
|
|
72
|
+
server.HERMES_DATA = self._old_hermes_data
|
|
73
|
+
credential_vault.DATA_DIR = self._old_vault_data_dir
|
|
74
|
+
credential_vault.VAULT_DB = self._old_vault_db
|
|
75
|
+
vault_kek.DATA_DIR = self._old_kek_data_dir
|
|
76
|
+
vault_kek.VAULT_KEK_FILE = self._old_kek_file
|
|
77
|
+
|
|
78
|
+
@patch.object(server, "_primary_profile", return_value="workframe-agent")
|
|
79
|
+
@patch.object(server, "_restart_stack_gateway", return_value={"ok": True})
|
|
80
|
+
@patch.object(server, "_set_primary_messaging_platforms", return_value=(True, "ok"))
|
|
81
|
+
def test_store_and_sync_writes_gateway_env(self, _platforms, _restart, _primary) -> None:
|
|
82
|
+
server._store_workspace_credential(
|
|
83
|
+
self.workspace_id,
|
|
84
|
+
"discord",
|
|
85
|
+
"api_key",
|
|
86
|
+
"discord-bot-secret",
|
|
87
|
+
"DISCORD_BOT_TOKEN",
|
|
88
|
+
"Discord",
|
|
89
|
+
self.admin_id,
|
|
90
|
+
)
|
|
91
|
+
status, payload = server._patch_workspace_integrations(
|
|
92
|
+
self.workspace_id,
|
|
93
|
+
{
|
|
94
|
+
"messaging": {
|
|
95
|
+
"discord": {
|
|
96
|
+
"home_channel": "chan-123",
|
|
97
|
+
"allowed_users": "111",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
self.admin_id,
|
|
102
|
+
)
|
|
103
|
+
self.assertEqual(status, 200)
|
|
104
|
+
self.assertTrue(payload.get("ok"))
|
|
105
|
+
env = server._read_env_map(server._profile_dir("workframe-agent") / ".env")
|
|
106
|
+
self.assertEqual(env.get("DISCORD_BOT_TOKEN"), "discord-bot-secret")
|
|
107
|
+
self.assertEqual(env.get("DISCORD_HOME_CHANNEL"), "chan-123")
|
|
108
|
+
self.assertIn("111", env.get("DISCORD_ALLOWED_USERS", ""))
|
|
109
|
+
self.assertIn("999888777", env.get("DISCORD_ALLOWED_USERS", ""))
|
|
110
|
+
|
|
111
|
+
def test_workspace_store_rejects_user_only_providers(self) -> None:
|
|
112
|
+
with self.assertRaises(ValueError):
|
|
113
|
+
server._store_workspace_credential(
|
|
114
|
+
self.workspace_id,
|
|
115
|
+
"vercel",
|
|
116
|
+
"api_key",
|
|
117
|
+
"pat-secret",
|
|
118
|
+
"VERCEL_TOKEN",
|
|
119
|
+
"Vercel",
|
|
120
|
+
self.admin_id,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
unittest.main()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Workspace LLM keys surface in provider list for company-pay onboarding."""
|
|
2
|
+
import os
|
|
3
|
+
import tempfile
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from unittest import mock
|
|
7
|
+
|
|
8
|
+
import server
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class WorkspaceProviderListTests(unittest.TestCase):
|
|
12
|
+
def setUp(self) -> None:
|
|
13
|
+
self.tmp = tempfile.TemporaryDirectory()
|
|
14
|
+
self.addCleanup(self.tmp.cleanup)
|
|
15
|
+
data = Path(self.tmp.name) / "data"
|
|
16
|
+
agents = Path(self.tmp.name) / "Agents"
|
|
17
|
+
profiles = agents / "profiles" / "workframe-agent"
|
|
18
|
+
profiles.mkdir(parents=True)
|
|
19
|
+
(profiles / "profile.yaml").write_text("description: test\n", encoding="utf-8")
|
|
20
|
+
(profiles / ".env").write_text("OPENROUTER_API_KEY=sk-test-workspace\n", encoding="utf-8")
|
|
21
|
+
self.patches = [
|
|
22
|
+
mock.patch.object(server, "DATA_DIR", data),
|
|
23
|
+
mock.patch.object(server, "HERMES_DATA", agents),
|
|
24
|
+
mock.patch.object(server, "WORKSPACE", Path(self.tmp.name) / "Files"),
|
|
25
|
+
mock.patch.object(server, "_workframe_db_path", return_value=data / "workframe.db"),
|
|
26
|
+
mock.patch.dict(os.environ, {"WORKFRAME_PROJECT": "Workframe", "WORKFRAME_NATIVE_PROFILE": "workframe-agent"}, clear=False),
|
|
27
|
+
]
|
|
28
|
+
for patch in self.patches:
|
|
29
|
+
patch.start()
|
|
30
|
+
self.addCleanup(patch.stop)
|
|
31
|
+
server._ensure_workframe_db_schema()
|
|
32
|
+
server._ensure_default_workspace()
|
|
33
|
+
|
|
34
|
+
def test_list_user_providers_shows_workspace_llm_connected(self) -> None:
|
|
35
|
+
conn = server._workframe_db()
|
|
36
|
+
ws = conn.execute("SELECT id FROM workspaces WHERE slug='default'").fetchone()
|
|
37
|
+
now = server._utc_now()
|
|
38
|
+
conn.execute(
|
|
39
|
+
"""INSERT INTO credential_bindings
|
|
40
|
+
(id, workspace_id, user_id, agent_profile_id, provider, credential_type,
|
|
41
|
+
credential_ref, label, is_active, created_by, created_at, updated_at)
|
|
42
|
+
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)""",
|
|
43
|
+
(
|
|
44
|
+
"cred-ws-1", ws["id"], None, None, "openrouter", "api_key",
|
|
45
|
+
"env:OPENROUTER_API_KEY", "OpenRouter", 1, "admin", now, now,
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
conn.commit()
|
|
49
|
+
conn.close()
|
|
50
|
+
payload = server.list_user_providers("user-no-keys", str(ws["id"]))
|
|
51
|
+
row = next(p for p in payload["providers"] if p["id"] == "openrouter")
|
|
52
|
+
self.assertTrue(row["connected"])
|
|
53
|
+
self.assertEqual(row["source"], "workspace")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
unittest.main()
|