Implement streaming S0-S2: SSE complete, step/plan events.

Add net/llm SSE primitives and optional stream/echo/trace on step and plan so callers can watch deltas and rounds without changing final return values.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-10 11:03:04 +08:00
1 parent 5456d9ff83
commit b6bb42e460
18 files changed
+809 -64

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
---
title: agent plan stream helpers + confirm (offline)
description: plan_append_*/plan_finish_stream; confirm=True with stream attaches done event.
> ext/ai/llm.mq.md
> ext/ai/agent.mq.md
> lib/json.mq.md
> lib/fs.mq.md
---
# main
*`events` = > json.parse text=[] *
*`events` = > agent.plan_append_round events=`events` round=1 workbook=wb.mq.md exit_code=0 stream=True *
*`from` = > json.parse text=[{"type":"delta","text":"Hi"},{"type":"done","result":"Hi"}] *
*`events` = > agent.plan_merge_deltas events=`events` from=`from` stream=True *
*`events` = > agent.plan_append_decision events=`events` decision=DONE stream=True summary=ok *
*`out` = > json.parse text={"status":"ok"} *
*`out` = > agent.plan_finish_stream out=`out` events=`events` stream=True result=child *
*`evs` = > json.get value=`out` key=events *
*`n` = > len value=`evs` *
> print text=`n`
*`e0` = > at value=`evs` index=0 *
*`t0` = > json.get value=`e0` key=type *
> print text=`t0`
*`e1` = > at value=`evs` index=1 *
*`t1` = > json.get value=`e1` key=type *
*`x1` = > json.get value=`e1` key=text *
> print text=`t1`
> print text=`x1`
*`e2` = > at value=`evs` index=2 *
*`t2` = > json.get value=`e2` key=type *
> print text=`t2`
*`e3` = > at value=`evs` index=3 *
*`t3` = > json.get value=`e3` key=type *
*`r3` = > json.get value=`e3` key=result *
> print text=`t3`
> print text=`r3`
> llm.load_env path=.env
*`model` = > llm.llm *
*`tools` = > json.parse text=[] *
*`助手` = > agent.agent model=`model` tools=`tools` standing=offline plan stream *
*`pout` = > `助手`.plan goal=say hi confirm=True workbook_dir=".marqdo/agent-runs" writeback=False stream=True *
*`st` = > json.get value=`pout` key=status *
> print text=`st`
*`pevs` = > json.get value=`pout` key=events *
*`pn` = > len value=`pevs` *
> print text=`pn`
*`plast` = > at value=`pevs` index=0 *
*`pt` = > json.get value=`plast` key=type *
> print text=`pt`
+14
View File
@@ -0,0 +1,14 @@
---
title: llm stream_result offline
description: No network — SSE fixture via net.openai_sse_parse + llm.stream_result
> ext/ai/llm.mq.md
> lib/net.mq.md
---
# main
*`fixture` = "data: {\"choices\":[{\"delta\":{\"content\":\"Hi\"}}]}\n\ndata: {\"choices\":[{\"delta\":{\"content\":\"!\"}}]}\n\ndata: [DONE]\n" *
*`events` = > net.openai_sse_parse text=`fixture` *
*`answer` = > llm.stream_result events=`events` *
> print text=`answer`