Add OKF soft match, CALL tool streaming, and lib whitelist dispatch.

Canonicalize/alias lookup and optional soft_match parent REUSE cut kb
fragmentation; stream tool_start/end for Plan-and-Move visibility; allow
safe CALL:lib.* without FC.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-11 09:26:59 +08:00
1 parent dbb2765553
commit ff84c43c10
16 files changed
+771 -89

No files matched your search

+29
View File
@@ -62,3 +62,32 @@ description: Promote resource; patch Task aliases; variant goal hits same resour
*`exact` = > agent_kb_lookup kb_dir=`kb` goal=`goal` *
*`mk2` = > json.get value=`exact` key=match *
> print text=`mk2`
*`g_trip` = 帮我规划明天的行程 *
*`wb2` = .marqdo/agent-runs/alias-trip.mq.md *
*`body2` = "---\ntitle: trip\n---\n\n# main\n\n**trip-ok**\n" *
> fs.write_text path=`wb2` text=`body2`
*`prom2` = > agent_kb_promote kb_dir=`kb` goal=`g_trip` workbook=`wb2` *
*`ok2` = > json.get value=`prom2` key=promoted *
1. `ok2`
> print text=trip-promoted
2. *
> print text=trip-promote-fail
*`g_canon` = 你是一个智能体,帮我规划明天的行程 *
*`c` = > agent_kb_canonicalize goal=`g_canon` *
> print text=`c`
*`hit_c` = > agent_kb_lookup kb_dir=`kb` goal=`g_canon` *
1. `hit_c`
> print text=canonical-ok
2. *
> print text=canonical-miss
*`mk3` = > json.get value=`hit_c` key=match *
> print text=`mk3`
*`listed` = > agent_kb_list_tasks kb_dir=`kb` *
*`tc` = > json.get value=`listed` key=count *
1. `tc` > 1
> print text=list-ok
2. *
> print text=list-bad
+45
View File
@@ -0,0 +1,45 @@
---
title: Parent CALL:lib whitelist (offline)
description: lib.fs.exists + ARGS; reject lib.net; catalog callable.
> ext/ai/agent.mq.md
> lib/json.mq.md
> lib/fs.mq.md
> lib/sys.mq.md
---
# main
*`parts` = > json.parse text={"a":"CALL:lib.fs.exists","b":"ARGS:{\"path\":\".\"}","nl":"\n"} *
*`a` = > json.get value=`parts` key=a *
*`b` = > json.get value=`parts` key=b *
*`nl` = > json.get value=`parts` key=nl *
*`t_ok` = `a` + `nl` + `b` + `nl` *
*`act` = > agent.extract_plan_act reply=`t_ok` *
*`kind` = > json.get value=`act` key=kind *
*`name` = > json.get value=`act` key=name *
> print text=`kind`
> print text=`name`
*`out` = > agent.run_parent_tool name=`name` path=. reply=`t_ok` *
1. `out`
> print text=exists-ok
2. *
> print text=exists-bad
*`deny` = > agent.run_parent_tool name=lib.net.get path=. reply=CALL:lib.net.get *
*`sep` = > json.parse text={"s":"not allowed"} *
*`s` = > json.get value=`sep` key=s *
*`dparts` = > split value=`deny` sep=`s` *
*`pn` = > len value=`dparts` *
1. `pn` > 1
> print text=deny-ok
2. *
> print text=deny-bad
*`cat` = > agent.lib_catalog *
*`callable` = > json.get value=`cat` key=callable *
*`cn` = > len value=`callable` *
1. `cn` > 3
> print text=callable-ok
2. *
> print text=callable-bad
+34
View File
@@ -0,0 +1,34 @@
---
title: OKF soft_match protocol parse (offline)
description: REUSE/NEW + SLUG extractors; no network.
> ext/ai/agent.mq.md
> lib/json.mq.md
---
# main
*`samples` = > json.parse text={"reuse":"DECISION: REUSE\nSLUG: trip-plan\n","new":"DECISION: NEW\n","zh":"决定:复用\n标识:行程-a\n"} *
*`r1` = > json.get value=`samples` key=reuse *
*`d1` = > agent.extract_plan_decision reply=`r1` *
> print text=`d1`
*`s1` = > agent.extract_soft_match_slug reply=`r1` *
> print text=`s1`
*`r2` = > json.get value=`samples` key=new *
*`d2` = > agent.extract_plan_decision reply=`r2` *
> print text=`d2`
*`r3` = > json.get value=`samples` key=zh *
*`d3` = > agent.extract_plan_decision reply=`r3` *
> print text=`d3`
*`s3` = > agent.extract_soft_match_slug reply=`r3` *
> print text=`s3`
*`tasks` = > json.parse text=[{"slug":"a","title":"Alpha"},{"slug":"b","title":"Beta"}] *
*`prompt` = > agent.build_soft_match_prompt goal=demo tasks=`tasks` *
*`has` = > split value=`prompt` sep=DECISION: REUSE *
*`n` = > len value=`has` *
1. `n` > 1
> print text=prompt-ok
2. *
> print text=prompt-bad
+31 -1
View File
@@ -1423,7 +1423,37 @@ alias-written
alias-ok
alias
same-slug
exact",
exact
trip-promoted
帮我规划明天的行程
canonical-ok
canonical
list-ok",
);
}
#[test]
fn ext_agent_soft_match() {
assert_out(
"tests/ext/agent-soft-match.mq.md",
"REUSE
trip-plan
NEW
REUSE
行程-a
prompt-ok",
);
}
#[test]
fn ext_agent_lib_call() {
assert_out(
"tests/ext/agent-lib-call.mq.md",
"call
lib.fs.exists
exists-ok
deny-ok
callable-ok",
);
}