greft 0.1.4__tar.gz

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.
Files changed (236) hide show
  1. greft-0.1.4/.codex/greft.example.toml +21 -0
  2. greft-0.1.4/.dockerignore +14 -0
  3. greft-0.1.4/.env.example +127 -0
  4. greft-0.1.4/.gcloudignore +17 -0
  5. greft-0.1.4/.github/workflows/ci.yml +132 -0
  6. greft-0.1.4/.github/workflows/release.yml +35 -0
  7. greft-0.1.4/.gitignore +52 -0
  8. greft-0.1.4/.python-version +1 -0
  9. greft-0.1.4/CONTRIBUTING.md +67 -0
  10. greft-0.1.4/Dockerfile +17 -0
  11. greft-0.1.4/LICENSE +191 -0
  12. greft-0.1.4/Makefile +59 -0
  13. greft-0.1.4/PHILOSOPHY.md +176 -0
  14. greft-0.1.4/PKG-INFO +741 -0
  15. greft-0.1.4/README.md +715 -0
  16. greft-0.1.4/adapters/__init__.py +0 -0
  17. greft-0.1.4/adapters/reference/__init__.py +0 -0
  18. greft-0.1.4/adapters/reference/dynamic_remote_server.py +243 -0
  19. greft-0.1.4/adapters/reference/remote_server.py +108 -0
  20. greft-0.1.4/adapters/reference/server.py +389 -0
  21. greft-0.1.4/adapters/tools.schema.json +17 -0
  22. greft-0.1.4/alembic.ini +36 -0
  23. greft-0.1.4/assets/logo.svg +5 -0
  24. greft-0.1.4/cli/__init__.py +0 -0
  25. greft-0.1.4/cli/main.py +2500 -0
  26. greft-0.1.4/docker-compose.yml +44 -0
  27. greft-0.1.4/docs/claude-mcp-internet-test.md +89 -0
  28. greft-0.1.4/docs/dashboard-architecture.md +109 -0
  29. greft-0.1.4/docs/decisions/ADR-001.md +19 -0
  30. greft-0.1.4/docs/decisions/ADR-002.md +43 -0
  31. greft-0.1.4/docs/package-install.md +309 -0
  32. greft-0.1.4/docs/protocol-v0.md +214 -0
  33. greft-0.1.4/docs/rulesets/README.md +15 -0
  34. greft-0.1.4/docs/rulesets/abuse-prevention.md +236 -0
  35. greft-0.1.4/docs/rulesets/before-go-live.md +107 -0
  36. greft-0.1.4/docs/rulesets/implementation-status.md +36 -0
  37. greft-0.1.4/docs/rulesets/landing-chat-and-pairing.md +79 -0
  38. greft-0.1.4/docs/runbook.md +223 -0
  39. greft-0.1.4/examples/two-agent-handoff/main.py +234 -0
  40. greft-0.1.4/examples/two-agent-mcp/agents.json +26 -0
  41. greft-0.1.4/examples/two-agent-mcp/continuous.py +284 -0
  42. greft-0.1.4/examples/two-agent-mcp/main.py +131 -0
  43. greft-0.1.4/examples/two-agent-mcp/runtime.py +241 -0
  44. greft-0.1.4/greft/__init__.py +5 -0
  45. greft-0.1.4/migrations/env.py +66 -0
  46. greft-0.1.4/migrations/script.py.mako +26 -0
  47. greft-0.1.4/migrations/versions/06db90c5e396_initial_schema.py +141 -0
  48. greft-0.1.4/migrations/versions/3f5d2c91a8b4_add_plan_notifications.py +41 -0
  49. greft-0.1.4/migrations/versions/7f6b2e8d4a12_add_account_projects.py +92 -0
  50. greft-0.1.4/migrations/versions/91e6524c71af_add_contacts.py +45 -0
  51. greft-0.1.4/migrations/versions/9d0c6a2f84b7_add_demo_message_recall.py +26 -0
  52. greft-0.1.4/migrations/versions/a2c7d9e4f103_add_ruleset_controls.py +86 -0
  53. greft-0.1.4/migrations/versions/b3e8f1d2c905_add_contact_requests.py +52 -0
  54. greft-0.1.4/migrations/versions/c8b41d2f7302_add_app_settings.py +39 -0
  55. greft-0.1.4/migrations/versions/d3b6a7e91f2c_add_quota_requests.py +54 -0
  56. greft-0.1.4/migrations/versions/d5f9a3c72e10_add_admin_and_plan_definitions.py +62 -0
  57. greft-0.1.4/migrations/versions/e4a9b2c71d30_add_plan_notification_context.py +27 -0
  58. greft-0.1.4/migrations/versions/e7a2c491ff01_add_agent_private_key.py +27 -0
  59. greft-0.1.4/migrations/versions/e8b9c6d1a402_add_demo_chat_sessions.py +80 -0
  60. greft-0.1.4/migrations/versions/f4d8b1c692aa_add_admin_roles.py +31 -0
  61. greft-0.1.4/packages/greft-sdk/README.md +26 -0
  62. greft-0.1.4/packages/greft-sdk/package-lock.json +50 -0
  63. greft-0.1.4/packages/greft-sdk/package.json +22 -0
  64. greft-0.1.4/packages/greft-sdk/src/client.ts +307 -0
  65. greft-0.1.4/packages/greft-sdk/src/index.ts +9 -0
  66. greft-0.1.4/packages/greft-sdk/src/types.ts +56 -0
  67. greft-0.1.4/packages/greft-sdk/tsconfig.json +15 -0
  68. greft-0.1.4/protocol/__init__.py +0 -0
  69. greft-0.1.4/protocol/canonical.py +19 -0
  70. greft-0.1.4/protocol/crypto.py +80 -0
  71. greft-0.1.4/protocol/envelope.py +58 -0
  72. greft-0.1.4/protocol/errors.py +103 -0
  73. greft-0.1.4/protocol/handoff.py +75 -0
  74. greft-0.1.4/protocol/ids.py +120 -0
  75. greft-0.1.4/protocol/schemas/artifact.json +22 -0
  76. greft-0.1.4/protocol/schemas/envelope.json +123 -0
  77. greft-0.1.4/protocol/schemas/handoff_payload.json +86 -0
  78. greft-0.1.4/protocol/schemas.py +39 -0
  79. greft-0.1.4/pyproject.toml +121 -0
  80. greft-0.1.4/sdk/__init__.py +0 -0
  81. greft-0.1.4/sdk/python/__init__.py +0 -0
  82. greft-0.1.4/sdk/python/client.py +779 -0
  83. greft-0.1.4/server/__init__.py +0 -0
  84. greft-0.1.4/server/auth.py +340 -0
  85. greft-0.1.4/server/authorization.py +84 -0
  86. greft-0.1.4/server/config.py +131 -0
  87. greft-0.1.4/server/database.py +76 -0
  88. greft-0.1.4/server/delivery.py +85 -0
  89. greft-0.1.4/server/email_templates.py +198 -0
  90. greft-0.1.4/server/greft_agent.py +298 -0
  91. greft-0.1.4/server/logging.py +109 -0
  92. greft-0.1.4/server/main.py +174 -0
  93. greft-0.1.4/server/models.py +551 -0
  94. greft-0.1.4/server/plan_limits.py +84 -0
  95. greft-0.1.4/server/presence.py +216 -0
  96. greft-0.1.4/server/rate_limit.py +134 -0
  97. greft-0.1.4/server/reaper.py +191 -0
  98. greft-0.1.4/server/routers/__init__.py +3 -0
  99. greft-0.1.4/server/routers/account.py +2579 -0
  100. greft-0.1.4/server/routers/agents.py +249 -0
  101. greft-0.1.4/server/routers/auth.py +78 -0
  102. greft-0.1.4/server/routers/contacts.py +648 -0
  103. greft-0.1.4/server/routers/conversations.py +168 -0
  104. greft-0.1.4/server/routers/dashboard.py +345 -0
  105. greft-0.1.4/server/routers/events.py +213 -0
  106. greft-0.1.4/server/routers/messages.py +854 -0
  107. greft-0.1.4/server/routers/permissions.py +267 -0
  108. greft-0.1.4/server/routers/public.py +733 -0
  109. greft-0.1.4/server/routers/sessions.py +360 -0
  110. greft-0.1.4/server/security.py +110 -0
  111. greft-0.1.4/server/user_auth.py +167 -0
  112. greft-0.1.4/supabase/.gitignore +1 -0
  113. greft-0.1.4/supabase/.temp/cli-latest +1 -0
  114. greft-0.1.4/supabase/.temp/gotrue-version +1 -0
  115. greft-0.1.4/supabase/.temp/pooler-url +1 -0
  116. greft-0.1.4/supabase/.temp/postgres-version +1 -0
  117. greft-0.1.4/supabase/.temp/project-ref +1 -0
  118. greft-0.1.4/supabase/.temp/rest-version +1 -0
  119. greft-0.1.4/supabase/.temp/storage-migration +1 -0
  120. greft-0.1.4/supabase/.temp/storage-version +1 -0
  121. greft-0.1.4/supabase/migrations/20260831124500_greft_relay_schema.sql +151 -0
  122. greft-0.1.4/supabase/migrations/20260903120000_add_contact_requests.sql +14 -0
  123. greft-0.1.4/test_phase.md +83 -0
  124. greft-0.1.4/tests/__init__.py +0 -0
  125. greft-0.1.4/tests/conftest.py +1 -0
  126. greft-0.1.4/tests/e2e/__init__.py +0 -0
  127. greft-0.1.4/tests/e2e/conftest.py +5 -0
  128. greft-0.1.4/tests/e2e/test_full_flow.py +213 -0
  129. greft-0.1.4/tests/fixtures/envelope_signatures.json +382 -0
  130. greft-0.1.4/tests/generate_fixtures.py +51 -0
  131. greft-0.1.4/tests/integration/__init__.py +0 -0
  132. greft-0.1.4/tests/integration/conftest.py +168 -0
  133. greft-0.1.4/tests/integration/test_auth.py +206 -0
  134. greft-0.1.4/tests/integration/test_contacts.py +97 -0
  135. greft-0.1.4/tests/integration/test_e2e.py +363 -0
  136. greft-0.1.4/tests/integration/test_handoff.py +251 -0
  137. greft-0.1.4/tests/integration/test_hardening.py +361 -0
  138. greft-0.1.4/tests/integration/test_isolation.py +201 -0
  139. greft-0.1.4/tests/integration/test_messaging.py +423 -0
  140. greft-0.1.4/tests/integration/test_presence.py +239 -0
  141. greft-0.1.4/tests/integration/test_sdk_cli.py +220 -0
  142. greft-0.1.4/tests/integration/test_sessions.py +261 -0
  143. greft-0.1.4/tests/integration/test_signatures.py +163 -0
  144. greft-0.1.4/tests/unit/__init__.py +0 -0
  145. greft-0.1.4/tests/unit/test_adapter.py +90 -0
  146. greft-0.1.4/tests/unit/test_crypto.py +185 -0
  147. greft-0.1.4/tests/unit/test_envelope.py +70 -0
  148. greft-0.1.4/tests/unit/test_errors.py +38 -0
  149. greft-0.1.4/tests/unit/test_fixtures.py +47 -0
  150. greft-0.1.4/tests/unit/test_handoff.py +73 -0
  151. greft-0.1.4/tests/unit/test_ids.py +109 -0
  152. greft-0.1.4/tests/unit/test_schemas.py +31 -0
  153. greft-0.1.4/tests/unit/test_skeleton.py +6 -0
  154. greft-0.1.4/ui/.env.example +3 -0
  155. greft-0.1.4/ui/.gitignore +1 -0
  156. greft-0.1.4/ui/.install-trash-20260831-105916/package-lock.json +1447 -0
  157. greft-0.1.4/ui/.vercel/.env.production.local +22 -0
  158. greft-0.1.4/ui/.vercel/README.txt +11 -0
  159. greft-0.1.4/ui/.vercel/node/package-manifest.json +1452 -0
  160. greft-0.1.4/ui/.vercel/output/builds.json +24 -0
  161. greft-0.1.4/ui/.vercel/output/config.json +26 -0
  162. greft-0.1.4/ui/.vercel/output/diagnostics/cli_traces.json +1 -0
  163. greft-0.1.4/ui/.vercel/output/diagnostics/deploy-manifest.json +1 -0
  164. greft-0.1.4/ui/.vercel/output/diagnostics/project-manifest.json +1 -0
  165. greft-0.1.4/ui/.vercel/output/static/.favicon-b64.txt +1 -0
  166. greft-0.1.4/ui/.vercel/output/static/apple-touch-icon.png +0 -0
  167. greft-0.1.4/ui/.vercel/output/static/assets/about-DEGLDc1z.jpeg +0 -0
  168. greft-0.1.4/ui/.vercel/output/static/assets/index-ywLfePHn.css +1 -0
  169. greft-0.1.4/ui/.vercel/output/static/assets/index-zmOz-oC8.js +5886 -0
  170. greft-0.1.4/ui/.vercel/output/static/favicon.jpeg +0 -0
  171. greft-0.1.4/ui/.vercel/output/static/favicon.png +0 -0
  172. greft-0.1.4/ui/.vercel/output/static/index.html +115 -0
  173. greft-0.1.4/ui/.vercel/output/static/logo-dark.jpeg +0 -0
  174. greft-0.1.4/ui/.vercel/output/static/logo-email.jpeg +0 -0
  175. greft-0.1.4/ui/.vercel/output/static/logo-light.jpeg +0 -0
  176. greft-0.1.4/ui/.vercel/output/static/logo-mark.png +0 -0
  177. greft-0.1.4/ui/.vercel/output/static/logo-text-dark.jpeg +0 -0
  178. greft-0.1.4/ui/.vercel/output/static/logo-text.png +0 -0
  179. greft-0.1.4/ui/.vercel/output/static/no_bg_logo_text_white.png +0 -0
  180. greft-0.1.4/ui/.vercel/output/static/no_bg_logo_white.png +0 -0
  181. greft-0.1.4/ui/.vercel/output/static/og-image.jpeg +0 -0
  182. greft-0.1.4/ui/.vercel/output/static/robots.txt +6 -0
  183. greft-0.1.4/ui/.vercel/output/static/sitemap.xml +33 -0
  184. greft-0.1.4/ui/.vercel/project.json +16 -0
  185. greft-0.1.4/ui/README.md +58 -0
  186. greft-0.1.4/ui/index.html +114 -0
  187. greft-0.1.4/ui/package-lock.json +2056 -0
  188. greft-0.1.4/ui/package.json +27 -0
  189. greft-0.1.4/ui/public/.favicon-b64.txt +1 -0
  190. greft-0.1.4/ui/public/apple-touch-icon.png +0 -0
  191. greft-0.1.4/ui/public/favicon.jpeg +0 -0
  192. greft-0.1.4/ui/public/favicon.png +0 -0
  193. greft-0.1.4/ui/public/logo-dark.jpeg +0 -0
  194. greft-0.1.4/ui/public/logo-email.jpeg +0 -0
  195. greft-0.1.4/ui/public/logo-light.jpeg +0 -0
  196. greft-0.1.4/ui/public/logo-mark.png +0 -0
  197. greft-0.1.4/ui/public/logo-text-dark.jpeg +0 -0
  198. greft-0.1.4/ui/public/logo-text.png +0 -0
  199. greft-0.1.4/ui/public/no_bg_logo_text_white.png +0 -0
  200. greft-0.1.4/ui/public/no_bg_logo_white.png +0 -0
  201. greft-0.1.4/ui/public/og-image.jpeg +0 -0
  202. greft-0.1.4/ui/public/robots.txt +6 -0
  203. greft-0.1.4/ui/public/sitemap.xml +33 -0
  204. greft-0.1.4/ui/scripts/README.md +60 -0
  205. greft-0.1.4/ui/scripts/responsive-sweep-auth.mjs +169 -0
  206. greft-0.1.4/ui/scripts/responsive-sweep.mjs +160 -0
  207. greft-0.1.4/ui/src/App.tsx +25 -0
  208. greft-0.1.4/ui/src/assets/logo/OG_TAG.png +0 -0
  209. greft-0.1.4/ui/src/assets/logo/about.jpeg +0 -0
  210. greft-0.1.4/ui/src/assets/logo/favicon.jpeg +0 -0
  211. greft-0.1.4/ui/src/assets/logo/logo_black.jpeg +0 -0
  212. greft-0.1.4/ui/src/assets/logo/logo_blue.jpeg +0 -0
  213. greft-0.1.4/ui/src/assets/logo/logo_white.jpeg +0 -0
  214. greft-0.1.4/ui/src/assets/logo/no_bg_logo.png +0 -0
  215. greft-0.1.4/ui/src/assets/logo/no_bg_logo_text.png +0 -0
  216. greft-0.1.4/ui/src/assets/logo/no_bg_logo_text_white.png +0 -0
  217. greft-0.1.4/ui/src/assets/logo/no_bg_logo_white.png +0 -0
  218. greft-0.1.4/ui/src/assets/logo/og_image.jpeg +0 -0
  219. greft-0.1.4/ui/src/greft-export.css +1110 -0
  220. greft-0.1.4/ui/src/greft-export.html +1150 -0
  221. greft-0.1.4/ui/src/greft-export.js +4881 -0
  222. greft-0.1.4/ui/src/lib/greft-api.ts +213 -0
  223. greft-0.1.4/ui/src/lib/greft-auth-bridge.ts +203 -0
  224. greft-0.1.4/ui/src/lib/supabase.ts +22 -0
  225. greft-0.1.4/ui/src/main.tsx +10 -0
  226. greft-0.1.4/ui/src/types/greft-auth.d.ts +85 -0
  227. greft-0.1.4/ui/src/vite-env.d.ts +1 -0
  228. greft-0.1.4/ui/tsconfig.json +21 -0
  229. greft-0.1.4/ui/tsconfig.node.json +10 -0
  230. greft-0.1.4/ui/tsconfig.node.tsbuildinfo +1 -0
  231. greft-0.1.4/ui/tsconfig.tsbuildinfo +1 -0
  232. greft-0.1.4/ui/vercel.json +5 -0
  233. greft-0.1.4/ui/vite.config.d.ts +2 -0
  234. greft-0.1.4/ui/vite.config.js +16 -0
  235. greft-0.1.4/ui/vite.config.ts +17 -0
  236. greft-0.1.4/uv.lock +1744 -0
@@ -0,0 +1,21 @@
1
+ # Copy one block into a trusted project's .codex/config.toml or ~/.codex/config.toml.
2
+ # Every independent runtime must use a different GREFT_HOME.
3
+
4
+ [mcp_servers.greft_planner]
5
+ command = "uv"
6
+ args = ["run", "python", "-m", "adapters.reference.server"]
7
+ cwd = "/Users/tm/Desktop/intera/greft-imp"
8
+
9
+ [mcp_servers.greft_planner.env]
10
+ GREFT_HOME = "/Users/tm/.greft/planner"
11
+ GREFT_API_URL = "http://localhost:8000"
12
+
13
+ # A second Codex session can use this identity.
14
+ [mcp_servers.greft_developer]
15
+ command = "uv"
16
+ args = ["run", "python", "-m", "adapters.reference.server"]
17
+ cwd = "/Users/tm/Desktop/intera/greft-imp"
18
+
19
+ [mcp_servers.greft_developer.env]
20
+ GREFT_HOME = "/Users/tm/.greft/developer"
21
+ GREFT_API_URL = "http://localhost:8000"
@@ -0,0 +1,14 @@
1
+ .git/
2
+ .venv/
3
+ .env
4
+ *.key
5
+ __pycache__/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ .coverage
10
+ htmlcov/
11
+ .hypothesis/
12
+ *.egg-info/
13
+ dist/
14
+ build/
@@ -0,0 +1,127 @@
1
+ # Greft V0 Configuration
2
+ # Copy this file to .env and fill in the values.
3
+
4
+ # === Database ===
5
+ # PostgreSQL connection URL.
6
+ # For the prototype, use the Supabase Postgres connection string from:
7
+ # Supabase Dashboard > Project Settings > Database > Connection string.
8
+ # Accepted forms: postgresql+asyncpg://..., postgresql://..., or postgres://...
9
+ GREFT_DATABASE_URL=
10
+
11
+ # Optional only if you run `docker compose --profile local-db up`.
12
+ GREFT_POSTGRES_PORT=15432
13
+
14
+ # === Server ===
15
+ # Host and port for the relay server
16
+ GREFT_HOST=0.0.0.0
17
+ GREFT_PORT=8000
18
+
19
+ # Environment: "development" or "production"
20
+ # In production, TLS is required unless GREFT_ALLOW_INSECURE is set.
21
+ GREFT_ENV=development
22
+
23
+ # Set to "true" to allow running in production without TLS (NOT RECOMMENDED)
24
+ # GREFT_ALLOW_INSECURE=false
25
+
26
+ # === JWT ===
27
+ # Ed25519 private key for signing JWTs (PEM-encoded, base64-wrapped for env var)
28
+ # Generate with: python -c "from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey; from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption; import base64; k = Ed25519PrivateKey.generate(); print(base64.b64encode(k.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())).decode())"
29
+ GREFT_JWT_PRIVATE_KEY=
30
+
31
+ # JWT token time-to-live in seconds (default: 900 = 15 minutes)
32
+ GREFT_JWT_TTL=900
33
+
34
+ # === Sessions ===
35
+ # Heartbeat interval expected from clients (seconds)
36
+ GREFT_HEARTBEAT_INTERVAL=15
37
+
38
+ # Heartbeat timeout before session expiry (seconds)
39
+ GREFT_HEARTBEAT_TIMEOUT=300
40
+
41
+ # Session reaper interval (seconds)
42
+ GREFT_REAPER_INTERVAL=10
43
+
44
+ # === Rate Limits ===
45
+ # Max messages per minute per sending agent
46
+ GREFT_MSG_RATE_LIMIT=60
47
+
48
+ # Max API requests per minute per agent
49
+ GREFT_API_RATE_LIMIT=600
50
+
51
+ # === Message Limits ===
52
+ # Max envelope size in bytes (default: 262144 = 256 KiB)
53
+ GREFT_MAX_ENVELOPE_SIZE=262144
54
+
55
+ # Default message retention in days
56
+ GREFT_MESSAGE_RETENTION_DAYS=30
57
+
58
+ # Max artifacts per handoff
59
+ GREFT_MAX_HANDOFF_ARTIFACTS=64
60
+
61
+ # Max URI length in characters
62
+ GREFT_MAX_URI_LENGTH=2048
63
+
64
+ # === Logging ===
65
+ # Log level: DEBUG, INFO, WARNING, ERROR
66
+ GREFT_LOG_LEVEL=INFO
67
+
68
+ # Set to "true" to include message payloads in logs (NEVER in production)
69
+ GREFT_LOG_PAYLOADS=false
70
+
71
+ # === Dashboard ===
72
+ # Admin token for dashboard access
73
+ GREFT_ADMIN_TOKEN=
74
+
75
+ # === Optional transactional email ===
76
+ # Used for plan notification confirmations. If unset, requests are still stored
77
+ # and shown in Admin with email_status=skipped_no_provider.
78
+ GREFT_SMTP_HOST=
79
+ GREFT_SMTP_PORT=587
80
+ GREFT_SMTP_USERNAME=
81
+ GREFT_SMTP_PASSWORD=
82
+ GREFT_SMTP_FROM=
83
+ GREFT_SMTP_TLS=true
84
+
85
+ # === Nonce ===
86
+ # Nonce TTL in seconds (default: 60)
87
+ GREFT_NONCE_TTL=60
88
+
89
+ # === Client (SDK/CLI) ===
90
+ # Override the default agent state directory (~/.greft)
91
+ # GREFT_HOME=~/.greft
92
+ # Relay URL for the SDK/CLI (not used by the server)
93
+ # GREFT_API_URL=http://localhost:8000
94
+
95
+ # === Hosted deployment ===
96
+ # Supabase provides Auth + Postgres. It does not host this FastAPI/WebSocket
97
+ # relay as-is. Put the public URL of the chosen backend host here after deploy.
98
+ GREFT_PUBLIC_RELAY_URL=
99
+ GREFT_DYNAMIC_MCP_BASE_URL=
100
+ GREFT_DYNAMIC_MCP_URL_PATTERN=
101
+
102
+ # === Greft frontend / Supabase ===
103
+ # Browser-safe values from Supabase Project Settings > API.
104
+ VITE_SUPABASE_URL=
105
+ VITE_SUPABASE_ANON_KEY=
106
+ GREFT_SUPABASE_URL=
107
+ GREFT_SUPABASE_ANON_KEY=
108
+ # Optional. Enables full Supabase Auth user deletion from DELETE /v0/account/me.
109
+ GREFT_SUPABASE_SERVICE_ROLE_KEY=
110
+ GREFT_SITE_URL=https://greft.ai
111
+ GREFT_CORS_ORIGINS=https://greft.ai,https://www.greft.ai
112
+ VITE_GREFT_API_URL=
113
+
114
+ # === Resend email ===
115
+ GREFT_RESEND_API_KEY=
116
+ GREFT_RESEND_FROM="Greft <notify@greft.ai>"
117
+ GREFT_EMAIL_FOOTER="Greft — agent messaging over the internet."
118
+
119
+ # === Server-owned @greft AI agent ===
120
+ # "scripted" works with no key. Use "vercel" for Vercel AI Gateway,
121
+ # "openrouter" for OpenRouter, or "openai_compatible" for another
122
+ # /chat/completions-compatible gateway.
123
+ GREFT_AGENT_PROVIDER=scripted
124
+ GREFT_AGENT_API_KEY=
125
+ GREFT_AGENT_BASE_URL=https://ai-gateway.vercel.sh/v1
126
+ GREFT_AGENT_MODEL=
127
+ GREFT_AGENT_TIMEOUT=20
@@ -0,0 +1,17 @@
1
+ .git/
2
+ .venv/
3
+ .env
4
+ *.key
5
+ __pycache__/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ .coverage
10
+ htmlcov/
11
+ .hypothesis/
12
+ *.egg-info/
13
+ dist/
14
+ build/
15
+ ui/node_modules/
16
+ ui/dist/
17
+ node_modules/
@@ -0,0 +1,132 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ env:
10
+ PYTHON_VERSION: "3.12"
11
+ GREFT_DATABASE_URL: postgresql+asyncpg://greft:greft@localhost:5432/greft
12
+ GREFT_TEST_DATABASE_URL: postgresql+asyncpg://greft:greft@localhost:5432/greft
13
+
14
+ jobs:
15
+ lint:
16
+ name: Lint & Format
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: astral-sh/setup-uv@v7
21
+ with:
22
+ version: ">=0.4"
23
+ - run: uv python install ${{ env.PYTHON_VERSION }}
24
+ - run: uv sync
25
+ - run: uv run ruff check .
26
+ - run: uv run ruff format --check .
27
+
28
+ types:
29
+ name: Type Check
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: astral-sh/setup-uv@v7
34
+ with:
35
+ version: ">=0.4"
36
+ - run: uv python install ${{ env.PYTHON_VERSION }}
37
+ - run: uv sync
38
+ - run: uv run mypy --strict server/ protocol/ sdk/ cli/ adapters/
39
+
40
+ test:
41
+ name: Unit & Integration Tests
42
+ runs-on: ubuntu-latest
43
+ services:
44
+ postgres:
45
+ image: postgres:16
46
+ env:
47
+ POSTGRES_USER: greft
48
+ POSTGRES_PASSWORD: greft
49
+ POSTGRES_DB: greft
50
+ ports:
51
+ - 5432:5432
52
+ options: >-
53
+ --health-cmd "pg_isready -U greft"
54
+ --health-interval 2s
55
+ --health-timeout 5s
56
+ --health-retries 10
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+ - uses: astral-sh/setup-uv@v7
60
+ with:
61
+ version: ">=0.4"
62
+ - run: uv python install ${{ env.PYTHON_VERSION }}
63
+ - run: uv sync
64
+ - name: Generate JWT key
65
+ run: |
66
+ KEY=$(uv run python -c "from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey; from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption; import base64; k = Ed25519PrivateKey.generate(); print(base64.b64encode(k.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())).decode())")
67
+ echo "GREFT_JWT_PRIVATE_KEY=$KEY" >> "$GITHUB_ENV"
68
+ - name: Run migrations
69
+ run: uv run alembic upgrade head
70
+ - name: Run tests
71
+ run: uv run pytest tests/unit tests/integration -q --tb=short
72
+
73
+ e2e:
74
+ name: End-to-End Tests
75
+ runs-on: ubuntu-latest
76
+ needs: [test]
77
+ services:
78
+ postgres:
79
+ image: postgres:16
80
+ env:
81
+ POSTGRES_USER: greft
82
+ POSTGRES_PASSWORD: greft
83
+ POSTGRES_DB: greft
84
+ ports:
85
+ - 5432:5432
86
+ options: >-
87
+ --health-cmd "pg_isready -U greft"
88
+ --health-interval 2s
89
+ --health-timeout 5s
90
+ --health-retries 10
91
+ steps:
92
+ - uses: actions/checkout@v4
93
+ - uses: astral-sh/setup-uv@v7
94
+ with:
95
+ version: ">=0.4"
96
+ - run: uv python install ${{ env.PYTHON_VERSION }}
97
+ - run: uv sync
98
+ - name: Generate JWT key
99
+ run: |
100
+ KEY=$(uv run python -c "from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey; from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption; import base64; k = Ed25519PrivateKey.generate(); print(base64.b64encode(k.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())).decode())")
101
+ echo "GREFT_JWT_PRIVATE_KEY=$KEY" >> "$GITHUB_ENV"
102
+ - name: Run migrations
103
+ run: uv run alembic upgrade head
104
+ - name: Run e2e tests
105
+ run: uv run pytest tests/e2e -q --tb=short
106
+
107
+ security:
108
+ name: Security Audit
109
+ runs-on: ubuntu-latest
110
+ steps:
111
+ - uses: actions/checkout@v4
112
+ - uses: astral-sh/setup-uv@v7
113
+ with:
114
+ version: ">=0.4"
115
+ - run: uv python install ${{ env.PYTHON_VERSION }}
116
+ - run: uv sync
117
+ - name: pip-audit
118
+ run: uv run pip-audit --require-hashes --disable-pip -r <(uv pip compile pyproject.toml 2>/dev/null) || uv run pip-audit
119
+ continue-on-error: true
120
+ - name: Bandit (via ruff S rules)
121
+ run: uv run ruff check --select S server/ protocol/ sdk/ cli/ adapters/
122
+
123
+ docker:
124
+ name: Docker Build
125
+ runs-on: ubuntu-latest
126
+ needs: [lint, types]
127
+ steps:
128
+ - uses: actions/checkout@v4
129
+ - name: Build relay image
130
+ run: docker build -t greft-relay .
131
+ - name: Build CLI image
132
+ run: docker build -t greft-cli .
@@ -0,0 +1,35 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ release:
10
+ name: Build & Publish
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: astral-sh/setup-uv@v7
18
+ with:
19
+ version: ">=0.4"
20
+
21
+ - run: uv python install 3.12
22
+
23
+ - name: Build package
24
+ run: uv build
25
+
26
+ - name: Build Docker images
27
+ run: |
28
+ docker build -t greft-relay:${{ github.ref_name }} .
29
+ docker build -t greft-cli:${{ github.ref_name }} .
30
+
31
+ - name: Create GitHub Release
32
+ uses: softprops/action-gh-release@v2
33
+ with:
34
+ generate_release_notes: true
35
+ files: dist/*
greft-0.1.4/.gitignore ADDED
@@ -0,0 +1,52 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.so
5
+ .Python
6
+ build/
7
+ dist/
8
+ *.egg-info/
9
+ *.egg
10
+ .eggs/
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ node_modules/
16
+
17
+ # Environment
18
+ .env
19
+
20
+ # IDE
21
+ .idea/
22
+ .vscode/
23
+ *.swp
24
+ *.swo
25
+
26
+ # Testing
27
+ .coverage
28
+ htmlcov/
29
+ .pytest_cache/
30
+
31
+ # mypy
32
+ .mypy_cache/
33
+
34
+ # ruff
35
+ .ruff_cache/
36
+
37
+ # OS
38
+ .DS_Store
39
+ Thumbs.db
40
+
41
+ # Keys (never commit private keys)
42
+ *.key
43
+ *.pem
44
+
45
+ # Hypothesis (property-based testing cache)
46
+ .hypothesis/
47
+
48
+ # Local working files
49
+ *.backup
50
+ *.working
51
+ *.bak
52
+ server/routers/*.bak
@@ -0,0 +1 @@
1
+ 3.12.11
@@ -0,0 +1,67 @@
1
+ # Contributing to Greft
2
+
3
+ Thanks for your interest. This guide covers everything you need.
4
+
5
+ ## Setup
6
+
7
+ Requires Docker with Compose v2, Python 3.12, `uv`, and `make`. Linux or macOS; on Windows use WSL2.
8
+
9
+ ```bash
10
+ git clone https://github.com/STEIDd/greft-imp.git && cd greft-imp
11
+ make bootstrap # install dependencies, create .env
12
+ make up # start PostgreSQL and the relay
13
+ make migrate # apply migrations
14
+ make verify-all # lint, types, and the full test suite
15
+ ```
16
+
17
+ If `make verify-all` does not pass on a clean checkout, that is a bug. Please open an issue rather than working around it.
18
+
19
+ ## Before you open a pull request
20
+
21
+ - `make verify-all` passes locally.
22
+ - Your change has a test that fails without it. This is not negotiable for bug fixes — every defect we have found by hand has become an automated test, and that is why they stay fixed.
23
+ - `ruff check`, `ruff format --check` and `mypy --strict` are clean. `make lint` and `make types` run these.
24
+ - No new `TODO`, `FIXME`, or skipped tests.
25
+
26
+ ## Commits
27
+
28
+ Conventional commits, imperative mood, describing the change:
29
+
30
+ ```
31
+ feat: resolve agent addresses server-side
32
+ fix: surface server error messages in CLI output
33
+ docs: clarify heartbeat behaviour for detached sessions
34
+ ```
35
+
36
+ One logical change per commit. Keep documentation and code changes separate unless the code change requires the documentation change.
37
+
38
+ Never commit `.env`, anything under `keys/`, `*.key`, `*.pem`, or database dumps.
39
+
40
+ ## Pull requests
41
+
42
+ - Branch from `main`.
43
+ - Push and open a PR describing what changed and why.
44
+ - All CI checks must pass. Do not disable a job or bypass a failing check to go green.
45
+ - A maintainer reviews and merges. Please do not force-push after review has started.
46
+
47
+ ## What to work on
48
+
49
+ Issues labelled **good first issue** are a reasonable start. Before building something substantial, open an issue first — Greft V0 is deliberately narrow, and some things are excluded on purpose. The scope section of the README lists what is out of scope and why.
50
+
51
+ ## Project layout
52
+
53
+ ```
54
+ server/ the relay: API, auth, routing, sessions, storage
55
+ protocol/ envelope and handoff models, schemas, canonicalization
56
+ sdk/python/ the client library
57
+ cli/ the agent command, built on the SDK
58
+ adapters/ MCP reference adapter
59
+ tests/ unit, integration, e2e, regression
60
+ docs/ protocol and operations documentation
61
+ ```
62
+
63
+ The CLI is a client of the SDK. If you add a capability, add it to the SDK and expose it through the CLI, rather than implementing it twice.
64
+
65
+ ## Security
66
+
67
+ Do not open a public issue for a security vulnerability. See [SECURITY.md](SECURITY.md).
greft-0.1.4/Dockerfile ADDED
@@ -0,0 +1,17 @@
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /app
4
+
5
+ ENV UV_PYTHON_DOWNLOADS=never
6
+
7
+ RUN pip install --no-cache-dir uv
8
+
9
+ COPY pyproject.toml uv.lock ./
10
+ RUN uv sync --frozen --no-dev --no-install-project --python /usr/local/bin/python
11
+
12
+ COPY . .
13
+ RUN uv sync --frozen --no-dev --python /usr/local/bin/python
14
+
15
+ EXPOSE 8000
16
+
17
+ CMD ["/app/.venv/bin/uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "8000"]
greft-0.1.4/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2024 Courage Lahban
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.