web-cortex-framework 2.0.1__tar.gz → 2.1.0__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 (40) hide show
  1. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/Cargo.lock +2 -2
  2. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/Cargo.toml +4 -2
  3. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/PKG-INFO +7 -2
  4. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/README.md +6 -1
  5. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/pyproject.toml +1 -1
  6. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/__init__.py +1 -1
  7. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/cli.py +27 -0
  8. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/starters.py +48 -0
  9. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/LICENSE +0 -0
  10. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/Cargo.toml +0 -0
  11. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/agent/provider.rs +0 -0
  12. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/agent/registry.rs +0 -0
  13. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/agent/session.rs +0 -0
  14. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/agent.rs +0 -0
  15. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/app.rs +0 -0
  16. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/audit.rs +0 -0
  17. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/auth.rs +0 -0
  18. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/bridge.rs +0 -0
  19. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/context.rs +0 -0
  20. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/db.rs +0 -0
  21. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/files.rs +0 -0
  22. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/flow.rs +0 -0
  23. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/http.rs +0 -0
  24. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/ledger.rs +0 -0
  25. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/lib.rs +0 -0
  26. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/manifest.rs +0 -0
  27. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/mcp.rs +0 -0
  28. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/middleware.rs +0 -0
  29. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/openapi.rs +0 -0
  30. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/router.rs +0 -0
  31. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/server.rs +0 -0
  32. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/templates.rs +0 -0
  33. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-core/src/typegen.rs +0 -0
  34. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-py/Cargo.toml +0 -0
  35. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-py/src/behaviour.rs +0 -0
  36. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/crates/webcortex-py/src/lib.rs +0 -0
  37. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/_bridge.py +0 -0
  38. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/app.py +0 -0
  39. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/contextpack.py +0 -0
  40. {web_cortex_framework-2.0.1 → web_cortex_framework-2.1.0}/python/webcortex/schema.py +0 -0
@@ -2616,7 +2616,7 @@ dependencies = [
2616
2616
 
2617
2617
  [[package]]
2618
2618
  name = "webcortex-core"
2619
- version = "2.0.1"
2619
+ version = "2.1.0"
2620
2620
  dependencies = [
2621
2621
  "base64 0.23.1",
2622
2622
  "bytes",
@@ -2643,7 +2643,7 @@ dependencies = [
2643
2643
 
2644
2644
  [[package]]
2645
2645
  name = "webcortex-py"
2646
- version = "2.0.1"
2646
+ version = "2.1.0"
2647
2647
  dependencies = [
2648
2648
  "bytes",
2649
2649
  "futures",
@@ -3,7 +3,7 @@ members = ["crates/webcortex-core", "crates/webcortex-py"]
3
3
  resolver = "3"
4
4
 
5
5
  [workspace.package]
6
- version = "2.0.1"
6
+ version = "2.1.0"
7
7
  edition = "2024"
8
8
  license = "Apache-2.0"
9
9
  rust-version = "1.85"
@@ -42,7 +42,9 @@ mime_guess = "2"
42
42
 
43
43
  [profile.release]
44
44
  opt-level = 3
45
- lto = "thin"
45
+ # Fat LTO: the whole program is optimised as one unit at release time. Slower to build
46
+ # in CI, a little faster and smaller in every wheel that ships.
47
+ lto = "fat"
46
48
  codegen-units = 1
47
49
  # Deliberately not `panic = "abort"`: a panic inside one request handler must
48
50
  # unwind and fail that request, not take the whole server down with it.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: web-cortex-framework
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -370,6 +370,11 @@ TypeScript client** for SPA frontends, generated from the same route table by
370
370
 
371
371
  ## AI-native development
372
372
 
373
+ `webcortex new` writes an `AGENTS.md` (read by Codex, Cursor and most agents) and a
374
+ `CLAUDE.md` that imports it, so the rules travel with the project; `webcortex context`
375
+ describes the running app for the model extending it; `webcortex mcp-config` prints the
376
+ one command that plugs the app into Claude Code, Claude Desktop or Cursor.
377
+
373
378
  ```
374
379
  $ webcortex context # the app, described for a coding model
375
380
  $ webcortex evolve "add reviews tied to books and a behaviour that summarises them" --model fast
@@ -427,7 +432,7 @@ tested, the known limits, and what v2 added to the surface.
427
432
 
428
433
  ## Status
429
434
 
430
- v2.0.1. Working and tested: the manifest IR, router, native ops (static /
435
+ v2.1.0. Working and tested: the manifest IR, router, native ops (static /
431
436
  query / proxy / page / files / flow), the free-threaded Python bridge,
432
437
  authentication and scopes, rate limiting, CORS, security headers, graceful
433
438
  shutdown, Behaviours with concurrent leaves, the agent runtime with handoffs,
@@ -342,6 +342,11 @@ TypeScript client** for SPA frontends, generated from the same route table by
342
342
 
343
343
  ## AI-native development
344
344
 
345
+ `webcortex new` writes an `AGENTS.md` (read by Codex, Cursor and most agents) and a
346
+ `CLAUDE.md` that imports it, so the rules travel with the project; `webcortex context`
347
+ describes the running app for the model extending it; `webcortex mcp-config` prints the
348
+ one command that plugs the app into Claude Code, Claude Desktop or Cursor.
349
+
345
350
  ```
346
351
  $ webcortex context # the app, described for a coding model
347
352
  $ webcortex evolve "add reviews tied to books and a behaviour that summarises them" --model fast
@@ -399,7 +404,7 @@ tested, the known limits, and what v2 added to the surface.
399
404
 
400
405
  ## Status
401
406
 
402
- v2.0.1. Working and tested: the manifest IR, router, native ops (static /
407
+ v2.1.0. Working and tested: the manifest IR, router, native ops (static /
403
408
  query / proxy / page / files / flow), the free-threaded Python bridge,
404
409
  authentication and scopes, rate limiting, CORS, security headers, graceful
405
410
  shutdown, Behaviours with concurrent leaves, the agent runtime with handoffs,
@@ -7,7 +7,7 @@ build-backend = "maturin"
7
7
  # The split is for ergonomics, the same way djangorestframework imports as
8
8
  # `rest_framework`.
9
9
  name = "web-cortex-framework"
10
- version = "2.0.1"
10
+ version = "2.1.0"
11
11
  description = "A Rust-cored Python web framework where every route is also an agent tool."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.12"
@@ -17,7 +17,7 @@ server exposing six tools — from nine lines.
17
17
  from ._bridge import HTTPError, Request, Response, free_threaded
18
18
  from .app import WebCortex, Resource
19
19
 
20
- __version__ = "2.0.1"
20
+ __version__ = "2.1.0"
21
21
 
22
22
  __all__ = [
23
23
  "WebCortex",
@@ -183,6 +183,20 @@ def _strip_fence(text: str) -> str:
183
183
  return t
184
184
 
185
185
 
186
+ def mcp_config(app: Any, key: str | None = None) -> dict:
187
+ """The `mcpServers` entry an MCP client needs to reach this app.
188
+
189
+ Streamable HTTP at the app's MCP endpoint; the API key travels as the same
190
+ `x-api-key` header the REST side uses, so the client gets exactly the scopes
191
+ that key has and nothing more.
192
+ """
193
+ host = os.environ.get("WEBCORTEX_HOST", app.host)
194
+ port = int(os.environ.get("WEBCORTEX_PORT", app.port))
195
+ url = f"http://{host}:{port}/_webcortex/mcp"
196
+ name = getattr(app, "name", None) or "webcortex"
197
+ return {"mcpServers": {name: {"type": "http", "url": url, "headers": {"x-api-key": key} if key else {}}}}
198
+
199
+
186
200
  def _cmd_new(args: argparse.Namespace) -> int:
187
201
  from . import starters
188
202
 
@@ -241,6 +255,7 @@ def main(argv: list[str] | None = None) -> int:
241
255
  ("security", "report the public attack surface"),
242
256
  ("typegen", "generate a typed TypeScript client"),
243
257
  ("context", "print the context pack: the app described for an AI coding tool"),
258
+ ("mcp-config", "print the MCP client configuration for this app (Claude Code, Claude Desktop, Cursor)"),
244
259
  ("evolve", "ask a model to propose an extension, anchored on the context pack"),
245
260
  ]:
246
261
  p = sub.add_parser(name, help=help_text)
@@ -338,6 +353,18 @@ def main(argv: list[str] | None = None) -> int:
338
353
  print(app.context_pack(), end="")
339
354
  return 0
340
355
 
356
+ if args.command == "mcp-config":
357
+ key = os.environ.get("WEBCORTEX_API_KEY")
358
+ cfg = mcp_config(app, key)
359
+ name = next(iter(cfg["mcpServers"]))
360
+ url = cfg["mcpServers"][name]["url"]
361
+ header = f'"x-api-key: {key}"' if key else '"x-api-key: $WEBCORTEX_API_KEY"'
362
+ print(json.dumps(cfg, indent=2))
363
+ print(f"\n# Claude Code:\nclaude mcp add --transport http {name} {url} --header {header}")
364
+ if not key:
365
+ print("# (set WEBCORTEX_API_KEY to fill the header in)", file=sys.stderr)
366
+ return 0
367
+
341
368
  if args.command == "evolve":
342
369
  return _cmd_evolve(app, args)
343
370
 
@@ -34,6 +34,50 @@ WEBCORTEX_JWT_SECRET=replace-me-at-least-32-bytes-long-abcdefgh
34
34
  # OLLAMA_HOST=http://127.0.0.1:11434
35
35
  """
36
36
 
37
+ AGENTS_MD = """\
38
+ # {name} — notes for coding agents
39
+
40
+ This is a [WebCortex](https://github.com/slimboi34/web_cortex_framework) app: a Python web
41
+ framework with a Rust core where every declaration is a REST route, an OpenAPI operation and
42
+ an MCP tool at once. Python declares; the Rust runtime executes what it can without waking
43
+ Python (queries, static responses, proxies, agent runs); typed Python handlers run on a
44
+ worker pool.
45
+
46
+ ## Commands
47
+
48
+ | | |
49
+ |---|---|
50
+ | `webcortex context` | the whole app described for an AI coding tool: routes with their engine and scopes, tools with signatures, agents with budgets, security posture. **Run this before you start.** |
51
+ | `webcortex check` | validate the manifest and print the route table, tool list and security report as JSON. **Run this after every change**; a boot error is a bug. |
52
+ | `webcortex security` | what is reachable without a credential |
53
+ | `webcortex tools` | the agent tool manifest |
54
+ | `webcortex dev` | run it (`export WEBCORTEX_API_KEY=$(webcortex keygen)` first) |
55
+ | `webcortex mcp-config` | the MCP client configuration for this app, and the `claude mcp add` line |
56
+ | `pytest` | the tests; `WEBCORTEX_FAKE_PROVIDER=1` runs agents against an offline provider |
57
+
58
+ ## The rules that matter most
59
+
60
+ - **Declare, don't compute.** A route whose work is data — a query, a static response, a
61
+ proxy, an agent run — belongs in `app.query`, `app.static`, `app.proxy`, `app.agent`, so
62
+ Rust serves it. Write a Python handler only when there is real logic; its type hints are the
63
+ tool schema, so annotate every parameter.
64
+ - **`tool=True` makes a route an agent tool** with a schema derived from the route itself, so
65
+ the two cannot drift. Give every route `scopes=[...]`; everything is deny-by-default.
66
+ - **Dangerous tools wait for a human.** `approval="required"` suspends an agent's run and is
67
+ refused outright over MCP. Use it on anything destructive.
68
+ - **Agents cannot exceed their caller.** Scopes intersect, budgets (`max_steps`,
69
+ `token_budget`) are enforced by the runtime, and a flow shares one budget across its tree.
70
+ Do not try to widen authority from inside an agent.
71
+ - **Keep it to one file** (`api.py`) unless it is genuinely large, and do not add a second web
72
+ framework, an ORM, or a dependency for something the runtime already does (auth, rate
73
+ limiting, CORS, security headers, OpenAPI, MCP, TypeScript generation, the ledger).
74
+
75
+ Everything else — every route, tool, agent and budget of this app — is in the output of
76
+ `webcortex context`.
77
+ """
78
+
79
+ CLAUDE_MD = "@AGENTS.md\n"
80
+
37
81
  README = """\
38
82
  # {name}
39
83
 
@@ -324,6 +368,10 @@ def files_for(template: str, name: str, description: str) -> dict[str, str]:
324
368
  ".gitignore": BASE_GITIGNORE,
325
369
  ".env.example": ENV_EXAMPLE,
326
370
  "README.md": README.format(name=name),
371
+ # The rules travel with the project: AGENTS.md is what Codex, Cursor and most agents
372
+ # read; CLAUDE.md imports it with Claude Code's @file syntax.
373
+ "AGENTS.md": AGENTS_MD.format(name=name),
374
+ "CLAUDE.md": CLAUDE_MD,
327
375
  }
328
376
 
329
377
  if template == "api":