Move LLM and agent into ext/ai with host tool catalog and call_fn.

Consolidate official AI extensions under ext/ai/, add agent history/context host APIs, dynamic call_fn, and a first-pass TOOL:name loop so runbooks can list zero-arg tools in a table.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-06 15:28:39 +08:00
1 parent c4ffb9473f
commit 92d88fe761
29 files changed
+1019 -558

No files matched your search

-35
View File
@@ -1,35 +0,0 @@
---
title: ext/agent match and assign
description: Multi-column tables + skill match (needs MARQDO_AGENT_PLUGIN).
> ext/agent.mq.md
---
# main
> load_native
*`cwd` = > cwd *
*`bot` = > agent root=`cwd` *
`技能表` =
| 成员 | 技能 | 负载 |
|------|------|------|
| 张三 | Python, ML | 2 |
| 李四 | 前端, UX | 1 |
| 王五 | 后端, 运维 | 3 |
| 赵六 | 数据分析 | 0 |
*`m` = > `bot`.match_skill skill=Python members=`技能表` *
*`name` = > get value=`m` key=成员 *
> print text=`name`
*`m2` = > `bot`.match_skill skill=安全审计 members=`技能表` *
+ `m2`
> print text=unexpected-match
+ *
*`path` = > `bot`.create_ticket title=no_owner detail=security *
> print text=`path`
*`m3` = > `bot`.update_load member=`m` delta=1 *
*`load` = > get value=`m3` key=负载 *
> print text=`load`
+40
View File
@@ -0,0 +1,40 @@
---
title: ext/agent run live (DeepSeek)
description: Real 执行 via tests/ext/.env (gitignored). Skipped in CI when .env missing.
> ext/ai/agent.mq.md
> lib/time.mq.md
---
## 获取时间
*`u` = > now_unix *
**> format unix=`u` pattern=%Y%m%d **
# main
> load_env
*`模型` = > llm *
`工具表` =
| 工具 |
|------|
| 获取时间 |
*`助手` = > agent model=`模型` tools=`工具表` user_prompt=你是测试助手。需要工具时,必须只回复一行 TOOL:函数名,不要其它文字。 *
*`id` = > get value=`助手` key=id *
*`回复` = > `助手`.run extra=请调用获取时间工具,并把当前日期告诉用户。 *
> print text=`回复`
*`历史1` = > host_agent_history_get id=`id` *
*`条数1` = > len value=`历史1` *
> print text=`条数1`
> `助手`.clear_history
*`历史2` = > host_agent_history_get id=`id` *
*`条数2` = > len value=`历史2` *
> print text=`条数2`
-30
View File
@@ -1,30 +0,0 @@
---
title: ext/agent layout scaffold
description: Requires MARQDO_AGENT_PLUGIN (set by gold harness).
> ext/agent.mq.md
> lib/fs.mq.md
---
# main
> load_native
*`cwd` = > cwd *
*`ws` = > agent root=`cwd` *
*`_n` = > `ws`.ensure_layout *
*`info` = > `ws`.probe *
*`ok` = > get value=`info` key=has_agents *
> print text=`ok`
> write_text path=skel.mq.md text={{name}}
*`_p` = > `ws`.scaffold name=demo template=skel.mq.md dest=out-demo.mq.md *
*`body` = > read_text path=out-demo.mq.md *
> print text=`body`
+60
View File
@@ -0,0 +1,60 @@
---
title: ext/agent framework smoke (offline)
description: Ctor, context, clear_history — no network. Gold suite.
> ext/ai/agent.mq.md
---
# main
`工具表` =
| 工具 |
|------|
| 获取时间 |
*`占位模型` = > parse text={"_type":"llm"} *
*`助手` = > agent model=`占位模型` tools=`工具表` user_prompt=you are a dispatcher *
*`id` = > get value=`助手` key=id *
*`ctx` = > build_agent_context agent=`助手` extra=probe *
*`has_skill` = > split value=`ctx` sep=Marqdo *
*`sk_n` = > len value=`has_skill` *
+ `sk_n` > 1
> print text=skill-ok
+ *
> print text=skill-missing
*`has_tools` = > split value=`ctx` sep=获取时间 *
*`tool_n` = > len value=`has_tools` *
+ `tool_n` > 1
> print text=tools-ok
+ *
> print text=tools-missing
*`src` = > host_module_source *
*`has_src` = > split value=`src` sep=probe *
*`src_n` = > len value=`has_src` *
+ `src_n` > 1
> print text=source-ok
+ *
> print text=source-missing
*`turn` = > parse text={"role":"user","content":"one"} *
> host_agent_history_append id=`id` item=`turn`
*`turn2` = > parse text={"role":"assistant","content":"two"} *
> host_agent_history_append id=`id` item=`turn2`
*`h1` = > host_agent_history_get id=`id` *
*`n1` = > len value=`h1` *
> print text=`n1`
> `助手`.clear_history
*`h2` = > host_agent_history_get id=`id` *
*`n2` = > len value=`h2` *
> print text=`n2`
*`site` = > host_call_site *
*`fn` = > get value=`site` key=function *
> print text=`fn`
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: ext llm DeepSeek complete (live)
description: Live OpenAI-compatible chat via DeepSeek. Needs tests/ext/.env (gitignored). Not in gold suite.
> ext/llm.mq.md
> ext/ai/llm.mq.md
---
# main
+1 -1
View File
@@ -1,6 +1,6 @@
---
title: ext llm import
> ext/llm.mq.md
> ext/ai/llm.mq.md
---
# main