feat(web,agent): hosting H1–H4 — proxy, invoke, MCP stdio, cross-module db
Close GAP-01–05 with ext/web streaming reverse proxy and HTTP→## invoke, transitive object method lookup, corpus_search plugin ensure, and agent MCP server stdio so downstream apps can drop Python side relays. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2e068e66d4
commit
fc543f1ca5
31 files changed
+2765
-102
No files matched your search
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: agent mcp server smoke helpers
|
||||
description: Tool target for MCP server smoke.
|
||||
---
|
||||
|
||||
## ping
|
||||
+ `payload`=None
|
||||
|
||||
`out` =
|
||||
|
||||
| ok | via |
|
||||
|----|-----|
|
||||
| true | mcp |
|
||||
|
||||
**out**
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: agent mcp server smoke
|
||||
description: Offline assemble mcp_server + one tool (no serve).
|
||||
import agent:ext/ai/agent.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import demo:agent-mcp-server-helpers.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*p = > plugin.native_path name="agent"*
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> sys.exit code=1
|
||||
|
||||
*srv = > agent.mcp_server name="marqdo-test"*
|
||||
*srv = > `srv`.tool name="ping" fn="demo.ping" description="ping tool"*
|
||||
*tools = srv[^tools]*
|
||||
*n = > len value=`tools`*
|
||||
1. `n` == 1
|
||||
> print text=mcp-tool-ok
|
||||
2. *
|
||||
> print text=mcp-tool-fail
|
||||
|
||||
*t0 = tools[^1]*
|
||||
*fn = t0[^fn]*
|
||||
1. `fn` == "demo.ping"
|
||||
> print text=mcp-fn-ok
|
||||
2. *
|
||||
> print text=mcp-fn-fail
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: web db cross-module lib
|
||||
description: Opens sqlite, inits a tiny table, returns the db handle.
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
## open
|
||||
|
||||
*store = > web.db url="sqlite::memory:"*
|
||||
|
||||
`fields` =
|
||||
|
||||
| name | type |
|
||||
|------|------|
|
||||
| title | text |
|
||||
|
||||
> `store`.init name=items fields=`fields`
|
||||
|
||||
`seed` =
|
||||
|
||||
| @ | title |
|
||||
|---|-------|
|
||||
| 1 | hello |
|
||||
|
||||
> `store`.insert table=items rows=`seed`
|
||||
**store**
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: web db cross-module smoke
|
||||
description: Return a web.db handle from an imported module and call select in the entry module.
|
||||
import web:ext/web/web.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import storemod:web-db-cross-module-lib.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*p = > plugin.native_path name="web"*
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> sys.exit code=1
|
||||
|
||||
*store = > storemod.open*
|
||||
*rows = > `store`.select table="items" limit=10*
|
||||
*n = > len value=`rows`*
|
||||
1. `n` >= 1
|
||||
> print text=cross-db-ok
|
||||
2. *
|
||||
> print text=cross-db-fail
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: web hosting live helpers
|
||||
description: Tiny lib used by hosting live-server invoke route.
|
||||
---
|
||||
|
||||
## echo
|
||||
+ `msg`=""
|
||||
+ `payload`=None
|
||||
|
||||
`out` =
|
||||
|
||||
| ok | msg |
|
||||
|----|-----|
|
||||
| true | `msg` |
|
||||
|
||||
**out**
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: web hosting live server
|
||||
description: Listen with proxy (→ mock upstream) and invoke routes for gold.rs.
|
||||
import web:ext/web/web.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import demo:web-hosting-helpers.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*p = > plugin.native_path name="web"*
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> sys.exit code=1
|
||||
|
||||
*pg = > web.page title="hosting-live"*
|
||||
*app = > web.app page=`pg` host=127.0.0.1 port=18141*
|
||||
*app = > `app`.proxy path="/proxy/sse" upstream="http://127.0.0.1:18142/sse" stream=True methods="POST"*
|
||||
*app = > `app`.invoke path="/api/echo" fn="demo.echo" method="POST" body="json"*
|
||||
> `app`.listen
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: web proxy/invoke smoke
|
||||
description: Offline assemble of app.proxy and app.invoke routes (no listen).
|
||||
import web:ext/web/web.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*p = > plugin.native_path name="web"*
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> sys.exit code=1
|
||||
|
||||
`proxy_tbl` =
|
||||
|
||||
| path | upstream | stream | strip_prefix | methods | headers_from_env | timeout_ms |
|
||||
|------|----------|--------|--------------|---------|------------------|------------|
|
||||
| /proxy/chat | $OPENAI_BASE_URL | True | /proxy | POST | OPENAI_API_KEY=Authorization | 60000 |
|
||||
|
||||
`invoke_tbl` =
|
||||
|
||||
| path | method | fn | body | return |
|
||||
|------|--------|-----|------|--------|
|
||||
| /api/echo | POST | demo.echo | json | json |
|
||||
|
||||
*pg = > web.page title="proxy-invoke"*
|
||||
*app = > web.app page=`pg`*
|
||||
*app = > `app`.configure proxy=`proxy_tbl` invoke=`invoke_tbl`*
|
||||
*app = > `app`.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"*
|
||||
*app = > `app`.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"*
|
||||
|
||||
*proutes = app[^proxy_routes]*
|
||||
*chat = proutes[^proxy/chat]*
|
||||
*up = chat[^upstream]*
|
||||
1. `up` == "$OPENAI_BASE_URL"
|
||||
> print text=proxy-table-ok
|
||||
2. *
|
||||
> print text=proxy-table-fail
|
||||
|
||||
*stream = chat[^stream]*
|
||||
1. `stream`
|
||||
> print text=proxy-stream-ok
|
||||
2. *
|
||||
> print text=proxy-stream-fail
|
||||
|
||||
*hdr = chat[^headers_from_env]*
|
||||
1. `hdr` == "OPENAI_API_KEY=Authorization"
|
||||
> print text=proxy-env-ok
|
||||
2. *
|
||||
> print text=proxy-env-fail
|
||||
|
||||
*v1 = proutes[^v1/stream]*
|
||||
*v1u = v1[^upstream]*
|
||||
1. `v1u` == "https://example.com/v1/chat"
|
||||
> print text=proxy-method-ok
|
||||
2. *
|
||||
> print text=proxy-method-fail
|
||||
|
||||
*iroutes = app[^invoke_routes]*
|
||||
*echo = iroutes[^api/echo]*
|
||||
*efn = echo[^fn]*
|
||||
1. `efn` == "demo.echo"
|
||||
> print text=invoke-table-ok
|
||||
2. *
|
||||
> print text=invoke-table-fail
|
||||
|
||||
*ping = iroutes[^api/ping]*
|
||||
*pm = ping[^method]*
|
||||
1. `pm` == "GET"
|
||||
> print text=invoke-method-ok
|
||||
2. *
|
||||
> print text=invoke-method-fail
|
||||
Reference in new issue
Block a user