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,135 @@
|
|
|
1
|
+
"""Canary / red-team tests: cross-profile reads, exec guards, public tool gating."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tempfile
|
|
6
|
+
import unittest
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from unittest.mock import patch
|
|
9
|
+
|
|
10
|
+
import server
|
|
11
|
+
from db_setup import ensure_workframe_schemas
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CredentialCanaryTests(unittest.TestCase):
|
|
15
|
+
def setUp(self) -> None:
|
|
16
|
+
self._tmp = tempfile.TemporaryDirectory()
|
|
17
|
+
self.addCleanup(self._tmp.cleanup)
|
|
18
|
+
self._old_data_dir = server.DATA_DIR
|
|
19
|
+
self._old_auth_db_path = server.AUTH_DB_PATH
|
|
20
|
+
self._old_hermes_data = server.HERMES_DATA
|
|
21
|
+
server.DATA_DIR = Path(self._tmp.name)
|
|
22
|
+
server.AUTH_DB_PATH = Path(self._tmp.name) / "auth.db"
|
|
23
|
+
server.HERMES_DATA = Path(self._tmp.name) / "hermes"
|
|
24
|
+
(server.HERMES_DATA / "profiles").mkdir(parents=True)
|
|
25
|
+
ensure_workframe_schemas()
|
|
26
|
+
self.workspace_id = "ws-canary"
|
|
27
|
+
self.user_a = "cb6a2db4-ac86-4c49-8247-14a1d68aca72"
|
|
28
|
+
self.user_b = "44fb344c-0954-47b6-a19a-ebbcf20e9680"
|
|
29
|
+
conn = server._workframe_db()
|
|
30
|
+
try:
|
|
31
|
+
now = "1"
|
|
32
|
+
conn.execute(
|
|
33
|
+
"INSERT INTO workspaces (id, slug, display_name, owner_id, status, created_at, updated_at) VALUES (?,?,?,?,?,?,?)",
|
|
34
|
+
(self.workspace_id, "canary", "Canary", self.user_a, "active", now, now),
|
|
35
|
+
)
|
|
36
|
+
for uid, name, role in (
|
|
37
|
+
(self.user_a, "Alice", "owner"),
|
|
38
|
+
(self.user_b, "Bob", "member"),
|
|
39
|
+
):
|
|
40
|
+
conn.execute(
|
|
41
|
+
"INSERT INTO users (id, display_name, role, status, created_at, updated_at) VALUES (?,?,?,?,?,?)",
|
|
42
|
+
(uid, name, "member", "active", now, now),
|
|
43
|
+
)
|
|
44
|
+
conn.execute(
|
|
45
|
+
"""
|
|
46
|
+
INSERT INTO workspace_memberships (id, workspace_id, user_id, role, status, created_at, updated_at)
|
|
47
|
+
VALUES (?, ?, ?, ?, 'active', ?, ?)
|
|
48
|
+
""",
|
|
49
|
+
(f"wm-{uid}", self.workspace_id, uid, role, now, now),
|
|
50
|
+
)
|
|
51
|
+
conn.execute(
|
|
52
|
+
"""
|
|
53
|
+
INSERT INTO agent_profiles (id, workspace_id, slug, display_name, is_native, status, created_at, updated_at)
|
|
54
|
+
VALUES (?, ?, ?, ?, ?, 'available', ?, ?)
|
|
55
|
+
""",
|
|
56
|
+
("ap-architect", self.workspace_id, "architect", "Architect", 0, now, now),
|
|
57
|
+
)
|
|
58
|
+
conn.commit()
|
|
59
|
+
finally:
|
|
60
|
+
conn.close()
|
|
61
|
+
self.runtime_a = server._runtime_profile_slug(self.user_a, "architect")
|
|
62
|
+
self.runtime_b = server._runtime_profile_slug(self.user_b, "architect")
|
|
63
|
+
|
|
64
|
+
def tearDown(self) -> None:
|
|
65
|
+
server.DATA_DIR = self._old_data_dir
|
|
66
|
+
server.AUTH_DB_PATH = self._old_auth_db_path
|
|
67
|
+
server.HERMES_DATA = self._old_hermes_data
|
|
68
|
+
|
|
69
|
+
def test_member_cannot_access_peer_runtime_profile_public_mode(self) -> None:
|
|
70
|
+
with patch.object(server, "DEPLOYMENT_MODE", "public_multi_user"):
|
|
71
|
+
self.assertFalse(
|
|
72
|
+
server._user_may_access_runtime_profile(self.user_b, self.runtime_a, self.workspace_id)
|
|
73
|
+
)
|
|
74
|
+
self.assertTrue(
|
|
75
|
+
server._user_may_access_runtime_profile(self.user_a, self.runtime_a, self.workspace_id)
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
def test_owner_can_access_peer_runtime_in_trusted_team(self) -> None:
|
|
79
|
+
with patch.object(server, "DEPLOYMENT_MODE", "trusted_team"):
|
|
80
|
+
self.assertTrue(
|
|
81
|
+
server._user_may_access_runtime_profile(self.user_a, self.runtime_b, self.workspace_id)
|
|
82
|
+
)
|
|
83
|
+
self.assertFalse(
|
|
84
|
+
server._user_may_access_runtime_profile(self.user_b, self.runtime_a, self.workspace_id)
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
def test_gateway_exec_blocks_cross_profile_env_cat(self) -> None:
|
|
88
|
+
victim_env = f"/opt/data/profiles/{self.runtime_a}/.env"
|
|
89
|
+
with patch.object(server, "DEPLOYMENT_MODE", "trusted_team"):
|
|
90
|
+
self.assertTrue(
|
|
91
|
+
server._exec_targets_runtime_profile_secrets(["sh", "-lc", f"cat {victim_env}"])
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
def test_gateway_exec_denies_foreign_runtime_profile(self) -> None:
|
|
95
|
+
with patch.object(server, "DEPLOYMENT_MODE", "public_multi_user"), patch.object(
|
|
96
|
+
server, "resolve_validated_profile", return_value=self.runtime_a
|
|
97
|
+
), patch.object(server, "_gateway_exec") as gateway_exec:
|
|
98
|
+
out = server.hermes_gateway_exec(
|
|
99
|
+
"/help",
|
|
100
|
+
self.runtime_a,
|
|
101
|
+
user_id=self.user_b,
|
|
102
|
+
workspace_id=self.workspace_id,
|
|
103
|
+
)
|
|
104
|
+
gateway_exec.assert_not_called()
|
|
105
|
+
self.assertFalse(out.get("ok"))
|
|
106
|
+
self.assertEqual(out.get("error"), "profile_access_denied")
|
|
107
|
+
|
|
108
|
+
def test_docker_exec_guard_returns_blocked_without_running(self) -> None:
|
|
109
|
+
victim_env = f"/opt/data/profiles/{self.runtime_b}/.env"
|
|
110
|
+
with patch.object(server, "DEPLOYMENT_MODE", "trusted_team"), patch.object(
|
|
111
|
+
server, "_docker_request"
|
|
112
|
+
) as docker_request:
|
|
113
|
+
code, out = server._docker_exec("workframe-gateway", ["cat", victim_env])
|
|
114
|
+
docker_request.assert_not_called()
|
|
115
|
+
self.assertEqual(code, 1)
|
|
116
|
+
self.assertIn("blocked", out)
|
|
117
|
+
|
|
118
|
+
def test_public_mode_toolsets_include_terminal(self) -> None:
|
|
119
|
+
with patch.object(server, "DEPLOYMENT_MODE", "public_multi_user"):
|
|
120
|
+
self.assertEqual(server._chat_toolsets_for_profile("architect"), ("hermes-cli", "terminal"))
|
|
121
|
+
|
|
122
|
+
def test_public_mode_ensure_toolsets_enables_terminal(self) -> None:
|
|
123
|
+
prof_dir = server._profile_dir("architect")
|
|
124
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
125
|
+
cfg_path = prof_dir / "config.yaml"
|
|
126
|
+
cfg_path.write_text("toolsets: []\n", encoding="utf-8")
|
|
127
|
+
with patch.object(server, "DEPLOYMENT_MODE", "public_multi_user"):
|
|
128
|
+
server._ensure_profile_toolsets("architect")
|
|
129
|
+
text = cfg_path.read_text(encoding="utf-8")
|
|
130
|
+
self.assertIn("hermes-cli", text)
|
|
131
|
+
self.assertIn("terminal", text)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if __name__ == "__main__":
|
|
135
|
+
unittest.main()
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"""Red-team oriented tests: credential resolution, cohort assignee boundaries, runtime ownership."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import tempfile
|
|
5
|
+
import unittest
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from unittest.mock import patch
|
|
8
|
+
|
|
9
|
+
import internal_proxy_auth
|
|
10
|
+
import server
|
|
11
|
+
from db_setup import ensure_workframe_schemas
|
|
12
|
+
import credential_vault
|
|
13
|
+
import turn_credentials
|
|
14
|
+
import vault_kek
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CredentialIsolationTests(unittest.TestCase):
|
|
18
|
+
def setUp(self) -> None:
|
|
19
|
+
self._tmp = tempfile.TemporaryDirectory()
|
|
20
|
+
self.addCleanup(self._tmp.cleanup)
|
|
21
|
+
self._old_data_dir = server.DATA_DIR
|
|
22
|
+
self._old_auth_db_path = server.AUTH_DB_PATH
|
|
23
|
+
self._old_hermes_data = server.HERMES_DATA
|
|
24
|
+
server.DATA_DIR = Path(self._tmp.name)
|
|
25
|
+
server.AUTH_DB_PATH = Path(self._tmp.name) / "auth.db"
|
|
26
|
+
server.HERMES_DATA = Path(self._tmp.name) / "hermes"
|
|
27
|
+
(server.HERMES_DATA / "profiles").mkdir(parents=True)
|
|
28
|
+
(server._profile_dir("workframe-agent")).mkdir(parents=True, exist_ok=True)
|
|
29
|
+
credential_vault.DATA_DIR = server.DATA_DIR
|
|
30
|
+
credential_vault.VAULT_DB = server.DATA_DIR / "credential_vault.db"
|
|
31
|
+
vault_kek.DATA_DIR = server.DATA_DIR
|
|
32
|
+
vault_kek.VAULT_KEK_FILE = server.DATA_DIR / ".vault_kek"
|
|
33
|
+
credential_vault.ensure_schema()
|
|
34
|
+
credential_vault.unseal_for_tests()
|
|
35
|
+
turn_credentials.DATA_DIR = server.DATA_DIR
|
|
36
|
+
turn_credentials.WORKFRAME_DB = server.DATA_DIR / "workframe.db"
|
|
37
|
+
turn_credentials.ensure_schema()
|
|
38
|
+
ensure_workframe_schemas()
|
|
39
|
+
self.workspace_id = "ws-iso"
|
|
40
|
+
self.user_a = "cb6a2db4-ac86-4c49-8247-14a1d68aca72"
|
|
41
|
+
self.user_b = "44fb344c-0954-47b6-a19a-ebbcf20e9680"
|
|
42
|
+
conn = server._workframe_db()
|
|
43
|
+
try:
|
|
44
|
+
now = "1"
|
|
45
|
+
conn.execute(
|
|
46
|
+
"INSERT INTO workspaces (id, slug, display_name, owner_id, status, created_at, updated_at) VALUES (?,?,?,?,?,?,?)",
|
|
47
|
+
(self.workspace_id, "iso", "Iso", self.user_a, "active", now, now),
|
|
48
|
+
)
|
|
49
|
+
for uid, name in ((self.user_a, "Fab"), (self.user_b, "Alan Borger")):
|
|
50
|
+
conn.execute(
|
|
51
|
+
"INSERT INTO users (id, display_name, role, status, created_at, updated_at) VALUES (?,?,?,?,?,?)",
|
|
52
|
+
(uid, name, "member", "active", now, now),
|
|
53
|
+
)
|
|
54
|
+
conn.execute(
|
|
55
|
+
"""
|
|
56
|
+
INSERT INTO workspace_memberships (id, workspace_id, user_id, role, status, created_at, updated_at)
|
|
57
|
+
VALUES (?, ?, ?, 'member', 'active', ?, ?)
|
|
58
|
+
""",
|
|
59
|
+
(f"wm-{uid}", self.workspace_id, uid, now, now),
|
|
60
|
+
)
|
|
61
|
+
for slug, name in (("workframe-agent", "Workframe Agent"), ("architect", "Architect")):
|
|
62
|
+
conn.execute(
|
|
63
|
+
"""
|
|
64
|
+
INSERT INTO agent_profiles (id, workspace_id, slug, display_name, is_native, status, created_at, updated_at)
|
|
65
|
+
VALUES (?, ?, ?, ?, ?, 'available', ?, ?)
|
|
66
|
+
""",
|
|
67
|
+
(f"ap-{slug}", self.workspace_id, slug, name, slug == "workframe-agent", now, now),
|
|
68
|
+
)
|
|
69
|
+
conn.executemany(
|
|
70
|
+
"""
|
|
71
|
+
INSERT INTO credential_bindings (
|
|
72
|
+
id, workspace_id, user_id, agent_profile_id, provider,
|
|
73
|
+
credential_type, credential_ref, label, is_active,
|
|
74
|
+
expires_at, created_by, created_at, updated_at, deleted_at
|
|
75
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
76
|
+
""",
|
|
77
|
+
[
|
|
78
|
+
(
|
|
79
|
+
"fab-or", None, self.user_a, None, "openrouter",
|
|
80
|
+
"api_key", credential_vault.vault_ref("fab-or"), "Fab OR", 1, None, self.user_a,
|
|
81
|
+
now, now, None,
|
|
82
|
+
),
|
|
83
|
+
(
|
|
84
|
+
"alan-or", None, self.user_b, None, "openrouter",
|
|
85
|
+
"api_key", credential_vault.vault_ref("alan-or"), "Alan OR", 1, None, self.user_b,
|
|
86
|
+
now, now, None,
|
|
87
|
+
),
|
|
88
|
+
],
|
|
89
|
+
)
|
|
90
|
+
conn.commit()
|
|
91
|
+
finally:
|
|
92
|
+
conn.close()
|
|
93
|
+
credential_vault.store_secret("fab-or", "sk-fab-only", env_var="OPENROUTER_API_KEY", provider="openrouter", user_id=self.user_a)
|
|
94
|
+
credential_vault.store_secret("alan-or", "sk-alan-only", env_var="OPENROUTER_API_KEY", provider="openrouter", user_id=self.user_b)
|
|
95
|
+
|
|
96
|
+
def tearDown(self) -> None:
|
|
97
|
+
server.DATA_DIR = self._old_data_dir
|
|
98
|
+
server.AUTH_DB_PATH = self._old_auth_db_path
|
|
99
|
+
server.HERMES_DATA = self._old_hermes_data
|
|
100
|
+
|
|
101
|
+
def test_runtime_slug_ownership_is_distinct_per_user(self) -> None:
|
|
102
|
+
fab_arch = server._runtime_profile_slug(self.user_a, "architect")
|
|
103
|
+
alan_arch = server._runtime_profile_slug(self.user_b, "architect")
|
|
104
|
+
self.assertNotEqual(fab_arch, alan_arch)
|
|
105
|
+
self.assertEqual(server._user_id_for_runtime_slug(fab_arch, self.workspace_id), self.user_a)
|
|
106
|
+
self.assertEqual(server._user_id_for_runtime_slug(alan_arch, self.workspace_id), self.user_b)
|
|
107
|
+
|
|
108
|
+
def test_user_a_cannot_assign_kanban_to_user_b_runtime(self) -> None:
|
|
109
|
+
alan_arch = server._runtime_profile_slug(self.user_b, "architect")
|
|
110
|
+
ok, reason = server.validate_kanban_assignee(alan_arch, self.user_a, self.workspace_id)
|
|
111
|
+
self.assertFalse(ok)
|
|
112
|
+
self.assertEqual(reason, "assignee_owner_forbidden")
|
|
113
|
+
|
|
114
|
+
def test_user_a_can_assign_to_own_runtime(self) -> None:
|
|
115
|
+
fab_arch = server._runtime_profile_slug(self.user_a, "architect")
|
|
116
|
+
ok, owner = server.validate_kanban_assignee(fab_arch, self.user_a, self.workspace_id)
|
|
117
|
+
self.assertTrue(ok)
|
|
118
|
+
self.assertEqual(owner, self.user_a)
|
|
119
|
+
|
|
120
|
+
def test_template_assignee_rejected_by_default(self) -> None:
|
|
121
|
+
ok, reason = server.validate_kanban_assignee("architect", self.user_a, self.workspace_id)
|
|
122
|
+
self.assertFalse(ok)
|
|
123
|
+
self.assertEqual(reason, "template_assignee_forbidden")
|
|
124
|
+
|
|
125
|
+
def test_delegate_grant_allows_partner_assignee(self) -> None:
|
|
126
|
+
alan_arch = server._runtime_profile_slug(self.user_b, "architect")
|
|
127
|
+
ok, owner = server.validate_kanban_assignee(
|
|
128
|
+
alan_arch,
|
|
129
|
+
self.user_a,
|
|
130
|
+
self.workspace_id,
|
|
131
|
+
delegate_user_ids=frozenset({self.user_b}),
|
|
132
|
+
)
|
|
133
|
+
self.assertTrue(ok)
|
|
134
|
+
self.assertEqual(owner, self.user_b)
|
|
135
|
+
|
|
136
|
+
@patch.object(server, "_wait_profile_api_healthy", return_value=True)
|
|
137
|
+
def test_overlay_writes_only_acting_user_secret(self, _wait_mock) -> None:
|
|
138
|
+
cred_id = "fab-or"
|
|
139
|
+
credential_vault.store_secret(cred_id, "sk-fab-only", env_var="OPENROUTER_API_KEY", provider="openrouter", user_id=self.user_a)
|
|
140
|
+
conn = server._workframe_db()
|
|
141
|
+
try:
|
|
142
|
+
conn.execute(
|
|
143
|
+
"UPDATE credential_bindings SET credential_ref = ? WHERE id = ?",
|
|
144
|
+
(credential_vault.vault_ref(cred_id), cred_id),
|
|
145
|
+
)
|
|
146
|
+
conn.commit()
|
|
147
|
+
finally:
|
|
148
|
+
conn.close()
|
|
149
|
+
runtime = server._runtime_profile_slug(self.user_a, "architect")
|
|
150
|
+
prof_dir = server._profile_dir(runtime)
|
|
151
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
152
|
+
env_path = prof_dir / ".env"
|
|
153
|
+
run_id = "run-iso-1"
|
|
154
|
+
server._overlay_turn_provider_env(runtime, self.user_a, self.workspace_id, "openrouter", run_id)
|
|
155
|
+
text = env_path.read_text(encoding="utf-8")
|
|
156
|
+
self.assertIn("wf_rt_", text)
|
|
157
|
+
self.assertNotIn("sk-fab-only", text)
|
|
158
|
+
self.assertNotIn("sk-alan-only", text)
|
|
159
|
+
token = next(
|
|
160
|
+
line.split("=", 1)[1].strip()
|
|
161
|
+
for line in text.splitlines()
|
|
162
|
+
if line.startswith("OPENAI_API_KEY=") or line.startswith("OPENROUTER_API_KEY=")
|
|
163
|
+
)
|
|
164
|
+
server._revoke_turn_credential_lease(run_id, runtime)
|
|
165
|
+
self.assertIsNone(turn_credentials.validate_lease(token))
|
|
166
|
+
|
|
167
|
+
def test_sync_runtime_strips_foreign_llm_key_and_sets_proxy(self) -> None:
|
|
168
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
169
|
+
prof_dir = server._profile_dir(runtime)
|
|
170
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
171
|
+
(prof_dir / "config.yaml").write_text("model:\n default: openrouter/x\n", encoding="utf-8")
|
|
172
|
+
server._upsert_env_secret(prof_dir / ".env", "OPENROUTER_API_KEY", "sk-fab-only")
|
|
173
|
+
server._prepare_runtime_profile_credentials(runtime, self.user_b, self.workspace_id)
|
|
174
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8") if (prof_dir / ".env").is_file() else ""
|
|
175
|
+
self.assertNotIn("sk-fab-only", text)
|
|
176
|
+
self.assertIn("base_url: http://workframe-api:8080/internal/llm/openrouter/v1", (prof_dir / "config.yaml").read_text(encoding="utf-8"))
|
|
177
|
+
|
|
178
|
+
def test_sync_runtime_strips_foreign_key_when_owner_has_none(self) -> None:
|
|
179
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
180
|
+
prof_dir = server._profile_dir(runtime)
|
|
181
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
182
|
+
server._upsert_env_secret(prof_dir / ".env", "OPENROUTER_API_KEY", "sk-fab-only")
|
|
183
|
+
server._prepare_runtime_profile_credentials(runtime, self.user_b, self.workspace_id)
|
|
184
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8")
|
|
185
|
+
self.assertNotIn("sk-fab-only", text)
|
|
186
|
+
self.assertNotIn("OPENROUTER_API_KEY=", text)
|
|
187
|
+
|
|
188
|
+
def test_runtime_profile_rejects_stack_operator_key_bleed(self) -> None:
|
|
189
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
190
|
+
prof_dir = server._profile_dir(runtime)
|
|
191
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
192
|
+
primary = server._primary_profile() or "workframe-agent"
|
|
193
|
+
primary_dir = server._profile_dir(primary)
|
|
194
|
+
primary_dir.mkdir(parents=True, exist_ok=True)
|
|
195
|
+
server._upsert_env_secret(primary_dir / ".env", "OPENROUTER_API_KEY", "sk-stack-only")
|
|
196
|
+
server._upsert_env_secret(prof_dir / ".env", "OPENROUTER_API_KEY", "sk-stack-only")
|
|
197
|
+
server._prepare_runtime_profile_credentials(runtime, self.user_b, self.workspace_id)
|
|
198
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8")
|
|
199
|
+
self.assertNotIn("sk-stack-only", text)
|
|
200
|
+
self.assertNotIn("OPENROUTER_API_KEY=", text)
|
|
201
|
+
|
|
202
|
+
@patch.object(server, "ensure_runtime_profile")
|
|
203
|
+
def test_cohort_slugs_are_user_scoped(self, _ensure: object) -> None:
|
|
204
|
+
fab_cohort = server.cohort_runtime_slugs(self.user_a, self.workspace_id)
|
|
205
|
+
alan_cohort = server.cohort_runtime_slugs(self.user_b, self.workspace_id)
|
|
206
|
+
self.assertTrue(fab_cohort.isdisjoint(alan_cohort))
|
|
207
|
+
|
|
208
|
+
def test_resolve_credential_user_only_never_crosses_users(self) -> None:
|
|
209
|
+
fab = server._resolve_credential(self.user_a, self.workspace_id, "openrouter", user_only=True)
|
|
210
|
+
alan = server._resolve_credential(self.user_b, self.workspace_id, "openrouter", user_only=True)
|
|
211
|
+
assert fab and alan
|
|
212
|
+
self.assertEqual(fab["credential_ref"], credential_vault.vault_ref("fab-or"))
|
|
213
|
+
self.assertEqual(alan["credential_ref"], credential_vault.vault_ref("alan-or"))
|
|
214
|
+
self.assertNotEqual(
|
|
215
|
+
server._credential_secret(fab, self.user_a),
|
|
216
|
+
server._credential_secret(alan, self.user_b),
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def test_stack_install_key_does_not_show_admin_connected(self) -> None:
|
|
221
|
+
primary = server._primary_profile() or "workframe-agent"
|
|
222
|
+
primary_dir = server._profile_dir(primary)
|
|
223
|
+
primary_dir.mkdir(parents=True, exist_ok=True)
|
|
224
|
+
server._upsert_env_secret(primary_dir / ".env", "OPENROUTER_API_KEY", "sk-install-only")
|
|
225
|
+
alan_home = server._user_hermes_home(self.user_b)
|
|
226
|
+
alan_home.mkdir(parents=True, exist_ok=True)
|
|
227
|
+
server._remove_env_secret(server._user_hermes_env_path(self.user_b), "OPENROUTER_API_KEY")
|
|
228
|
+
conn = server._workframe_db()
|
|
229
|
+
try:
|
|
230
|
+
conn.execute("DELETE FROM credential_bindings WHERE user_id = ?", (self.user_b,))
|
|
231
|
+
conn.execute(
|
|
232
|
+
"UPDATE workspace_memberships SET role = 'owner' WHERE workspace_id = ? AND user_id = ?",
|
|
233
|
+
(self.workspace_id, self.user_b),
|
|
234
|
+
)
|
|
235
|
+
conn.commit()
|
|
236
|
+
finally:
|
|
237
|
+
conn.close()
|
|
238
|
+
openrouter = next(
|
|
239
|
+
row for row in server.list_user_providers(self.user_b, self.workspace_id)["providers"]
|
|
240
|
+
if row["id"] == "openrouter"
|
|
241
|
+
)
|
|
242
|
+
self.assertFalse(openrouter["connected"])
|
|
243
|
+
|
|
244
|
+
def test_migrate_adopts_primary_install_key_to_owner(self) -> None:
|
|
245
|
+
primary = server._primary_profile() or "workframe-agent"
|
|
246
|
+
primary_dir = server._profile_dir(primary)
|
|
247
|
+
primary_dir.mkdir(parents=True, exist_ok=True)
|
|
248
|
+
server._upsert_env_secret(primary_dir / ".env", "OPENROUTER_API_KEY", "sk-install-adopt")
|
|
249
|
+
alan_home = server._user_hermes_home(self.user_b)
|
|
250
|
+
alan_home.mkdir(parents=True, exist_ok=True)
|
|
251
|
+
server._remove_env_secret(server._user_hermes_env_path(self.user_b), "OPENROUTER_API_KEY")
|
|
252
|
+
conn = server._workframe_db()
|
|
253
|
+
try:
|
|
254
|
+
conn.execute("DELETE FROM credential_bindings WHERE user_id = ?", (self.user_b,))
|
|
255
|
+
conn.execute("DELETE FROM schema_migrations WHERE version = '12'")
|
|
256
|
+
conn.execute(
|
|
257
|
+
"UPDATE workspaces SET owner_id = ? WHERE id = ?",
|
|
258
|
+
(self.user_b, self.workspace_id),
|
|
259
|
+
)
|
|
260
|
+
conn.commit()
|
|
261
|
+
server._migrate_v12_adopt_install_keys_to_owners(conn)
|
|
262
|
+
conn.commit()
|
|
263
|
+
finally:
|
|
264
|
+
conn.close()
|
|
265
|
+
spec = server._catalog_provider("openrouter") or {"id": "openrouter", "category": "llm"}
|
|
266
|
+
self.assertTrue(server._user_provider_connected(self.user_b, spec))
|
|
267
|
+
binding = server._resolve_credential(self.user_b, self.workspace_id, "openrouter", user_only=True)
|
|
268
|
+
assert binding
|
|
269
|
+
self.assertEqual(server._credential_secret(binding, self.user_b), "sk-install-adopt")
|
|
270
|
+
self.assertFalse(server._user_hermes_env_path(self.user_b).is_file())
|
|
271
|
+
|
|
272
|
+
def test_strip_profile_llm_env_preserves_turn_lease(self) -> None:
|
|
273
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
274
|
+
prof_dir = server._profile_dir(runtime)
|
|
275
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
276
|
+
server._upsert_env_secret(prof_dir / ".env", "OPENROUTER_API_KEY", "sk-fab-only")
|
|
277
|
+
server._upsert_env_secret(
|
|
278
|
+
prof_dir / ".env",
|
|
279
|
+
"OPENROUTER_API_KEY",
|
|
280
|
+
f"{turn_credentials.LEASE_PREFIX}abc123",
|
|
281
|
+
)
|
|
282
|
+
server._strip_profile_llm_env(runtime)
|
|
283
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8")
|
|
284
|
+
self.assertIn(f"{turn_credentials.LEASE_PREFIX}abc123", text)
|
|
285
|
+
self.assertNotIn("sk-fab-only", text)
|
|
286
|
+
|
|
287
|
+
def test_publish_gateway_secrets_makes_runtime_auth_readable(self) -> None:
|
|
288
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
289
|
+
prof_dir = server._profile_dir(runtime)
|
|
290
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
291
|
+
auth_path = prof_dir / "auth.json"
|
|
292
|
+
auth_path.write_text('{"version":1}\n', encoding="utf-8")
|
|
293
|
+
os.chmod(auth_path, 0o600)
|
|
294
|
+
server._publish_profile_gateway_secrets(runtime)
|
|
295
|
+
mode = auth_path.stat().st_mode & 0o777
|
|
296
|
+
self.assertTrue(mode & 0o444, f"auth.json not world-readable: {oct(mode)}")
|
|
297
|
+
|
|
298
|
+
def test_ensure_profile_api_keeps_lease_after_overlay(self) -> None:
|
|
299
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
300
|
+
prof_dir = server._profile_dir(runtime)
|
|
301
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
302
|
+
(prof_dir / "config.yaml").write_text(
|
|
303
|
+
"model:\n provider: openrouter\n default: openrouter/x\n",
|
|
304
|
+
encoding="utf-8",
|
|
305
|
+
)
|
|
306
|
+
run_id = "stream-order-test"
|
|
307
|
+
server._apply_turn_credential_lease(
|
|
308
|
+
runtime, self.user_b, self.workspace_id, "openrouter", run_id,
|
|
309
|
+
)
|
|
310
|
+
with patch.object(server, "_ensure_profile_toolsets"), patch.object(
|
|
311
|
+
server, "_profile_api_healthy", return_value=True,
|
|
312
|
+
):
|
|
313
|
+
server.ensure_profile_api(runtime, self.user_b, self.workspace_id)
|
|
314
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8")
|
|
315
|
+
self.assertIn(turn_credentials.LEASE_PREFIX, text)
|
|
316
|
+
server._revoke_turn_credential_lease(run_id, runtime)
|
|
317
|
+
|
|
318
|
+
@patch.object(server, "_restart_runtime_profile_gateway")
|
|
319
|
+
def test_runtime_lease_writes_config_and_reloads_gateway(self, restart_mock) -> None:
|
|
320
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
321
|
+
prof_dir = server._profile_dir(runtime)
|
|
322
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
323
|
+
(prof_dir / "config.yaml").write_text(
|
|
324
|
+
"model:\n provider: custom\n default: openrouter/x\n"
|
|
325
|
+
" base_url: http://workframe-api:8080/internal/llm/openrouter/v1\n"
|
|
326
|
+
" api_key: wf_rt_deadbeef\n",
|
|
327
|
+
encoding="utf-8",
|
|
328
|
+
)
|
|
329
|
+
token = server._apply_turn_credential_lease(
|
|
330
|
+
runtime, self.user_b, self.workspace_id, "openrouter", "lease-sync-1",
|
|
331
|
+
)
|
|
332
|
+
self.assertTrue(token.startswith(turn_credentials.LEASE_PREFIX))
|
|
333
|
+
self.assertEqual(server._read_config_model_api_key(runtime), token)
|
|
334
|
+
restart_mock.assert_called()
|
|
335
|
+
|
|
336
|
+
@patch.object(server, "_restart_runtime_profile_gateway")
|
|
337
|
+
def test_revoke_clears_stale_lease_from_config(self, restart_mock) -> None:
|
|
338
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
339
|
+
prof_dir = server._profile_dir(runtime)
|
|
340
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
341
|
+
token = turn_credentials.issue_lease(
|
|
342
|
+
"revoke-clear",
|
|
343
|
+
self.user_b,
|
|
344
|
+
self.workspace_id,
|
|
345
|
+
"openrouter",
|
|
346
|
+
runtime,
|
|
347
|
+
"alan-or",
|
|
348
|
+
)
|
|
349
|
+
(prof_dir / "config.yaml").write_text(
|
|
350
|
+
f"model:\n provider: custom\n api_key: {token}\n",
|
|
351
|
+
encoding="utf-8",
|
|
352
|
+
)
|
|
353
|
+
server._revoke_turn_credential_lease("revoke-clear", runtime)
|
|
354
|
+
self.assertEqual(server._read_config_model_api_key(runtime), "")
|
|
355
|
+
restart_mock.assert_called()
|
|
356
|
+
|
|
357
|
+
def test_ensure_profile_proxy_headers_writes_profile_slug(self) -> None:
|
|
358
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
359
|
+
prof_dir = server._profile_dir(runtime)
|
|
360
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
361
|
+
(prof_dir / "config.yaml").write_text(
|
|
362
|
+
"model:\n provider: custom\n default: openrouter/x\n",
|
|
363
|
+
encoding="utf-8",
|
|
364
|
+
)
|
|
365
|
+
server._ensure_profile_proxy_headers(runtime)
|
|
366
|
+
text = (prof_dir / "config.yaml").read_text(encoding="utf-8")
|
|
367
|
+
self.assertIn(f"X-Workframe-Profile: {runtime}", text)
|
|
368
|
+
|
|
369
|
+
def test_ensure_profile_proxy_headers_appends_proxy_token_to_existing_block(self) -> None:
|
|
370
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
371
|
+
prof_dir = server._profile_dir(runtime)
|
|
372
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
373
|
+
(prof_dir / "config.yaml").write_text(
|
|
374
|
+
"model:\n"
|
|
375
|
+
" provider: custom\n"
|
|
376
|
+
" base_url: http://workframe-api:8080/internal/llm/openrouter/v1\n"
|
|
377
|
+
" default_headers:\n"
|
|
378
|
+
f" X-Workframe-Profile: {runtime}\n"
|
|
379
|
+
"fallback_providers:\n"
|
|
380
|
+
" model: openrouter/x\n",
|
|
381
|
+
encoding="utf-8",
|
|
382
|
+
)
|
|
383
|
+
with patch.dict(os.environ, {"WORKFRAME_PROXY_TOKEN": "proxy-test-token"}, clear=False):
|
|
384
|
+
internal_proxy_auth.reset_proxy_token_for_tests()
|
|
385
|
+
server._ensure_profile_proxy_headers(runtime)
|
|
386
|
+
text = (prof_dir / "config.yaml").read_text(encoding="utf-8")
|
|
387
|
+
self.assertEqual(text.count("default_headers:"), 1)
|
|
388
|
+
self.assertIn(f"X-Workframe-Profile: {runtime}", text)
|
|
389
|
+
self.assertIn("X-Workframe-Proxy-Token: ${WORKFRAME_PROXY_TOKEN}", text)
|
|
390
|
+
profile_pos = text.index("X-Workframe-Profile:")
|
|
391
|
+
proxy_pos = text.index("X-Workframe-Proxy-Token:")
|
|
392
|
+
fallback_pos = text.index("fallback_providers:")
|
|
393
|
+
self.assertLess(profile_pos, proxy_pos)
|
|
394
|
+
self.assertLess(proxy_pos, fallback_pos)
|
|
395
|
+
|
|
396
|
+
@patch.object(server, "_wait_profile_api_healthy", return_value=True)
|
|
397
|
+
def test_overlay_with_custom_routing_provider(self, _wait_mock) -> None:
|
|
398
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
399
|
+
prof_dir = server._profile_dir(runtime)
|
|
400
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
401
|
+
(prof_dir / "config.yaml").write_text(
|
|
402
|
+
"model:\n provider: custom\n default: openrouter/owl-alpha\n"
|
|
403
|
+
" base_url: http://workframe-api:8080/internal/llm/openrouter/v1\n",
|
|
404
|
+
encoding="utf-8",
|
|
405
|
+
)
|
|
406
|
+
ready = server._overlay_chat_llm_env(
|
|
407
|
+
runtime, self.user_b, self.workspace_id, "custom",
|
|
408
|
+
)
|
|
409
|
+
self.assertTrue(ready)
|
|
410
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8")
|
|
411
|
+
self.assertIn(turn_credentials.LEASE_PREFIX, text)
|
|
412
|
+
server._strip_profile_llm_env(runtime, include_leases=True)
|
|
413
|
+
server._clear_profile_model_api_key(runtime)
|
|
414
|
+
|
|
415
|
+
def test_strip_profile_llm_env_drops_custom_provider_lease(self) -> None:
|
|
416
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
417
|
+
prof_dir = server._profile_dir(runtime)
|
|
418
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
419
|
+
(prof_dir / ".env").write_text(
|
|
420
|
+
"OPENAI_API_KEY=wf_rt_expired_lease_token\nWORKFRAME_PROXY_TOKEN=proxy\n",
|
|
421
|
+
encoding="utf-8",
|
|
422
|
+
)
|
|
423
|
+
server._strip_profile_llm_env(runtime, include_leases=True)
|
|
424
|
+
text = (prof_dir / ".env").read_text(encoding="utf-8")
|
|
425
|
+
self.assertNotIn("wf_rt_", text)
|
|
426
|
+
self.assertIn("WORKFRAME_PROXY_TOKEN=proxy", text)
|
|
427
|
+
|
|
428
|
+
def test_ensure_profile_llm_proxy_rewrites_scalar_fallback_when_ready(self) -> None:
|
|
429
|
+
runtime = server._runtime_profile_slug(self.user_b, "architect")
|
|
430
|
+
prof_dir = server._profile_dir(runtime)
|
|
431
|
+
prof_dir.mkdir(parents=True, exist_ok=True)
|
|
432
|
+
(prof_dir / "config.yaml").write_text(
|
|
433
|
+
"model:\n"
|
|
434
|
+
" provider: custom\n"
|
|
435
|
+
" default: openrouter/owl-alpha\n"
|
|
436
|
+
" base_url: http://workframe-api:8080/internal/llm/openrouter/v1\n"
|
|
437
|
+
"fallback_providers:\n"
|
|
438
|
+
" model: openrouter/nvidia/nemotron-3-ultra-550b-a55b:free\n",
|
|
439
|
+
encoding="utf-8",
|
|
440
|
+
)
|
|
441
|
+
server._ensure_profile_llm_proxy(runtime, "openrouter")
|
|
442
|
+
text = (prof_dir / "config.yaml").read_text(encoding="utf-8")
|
|
443
|
+
self.assertIn("- provider: custom", text)
|
|
444
|
+
self.assertNotRegex(text, r"fallback_providers:\n model:")
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
if __name__ == "__main__":
|
|
448
|
+
unittest.main()
|