Give agents a capability-capped run path that stages workspace edits until commit, so generated .mq.md can be verified without polluting the real tree. Co-authored-by: Cursor <cursoragent@cursor.com>
2.0 KiB
title: ext/ai/sandbox
description: >-
CoW trial workspace for AI-generated Marqdo: open / run / diff / commit.
Native work lives in plugins/agent (sandbox_* → host_query).
import plugin:lib/plugin.mq.md
import sys:lib/sys.mq.md
Load the agent plugin once per call (same pattern as other ext/ai helpers).
ensure_plugin
p = plugin.native_path name="agent"
p
plugin.load path=
p
print text=ext/ai/sandbox: native agent plugin not found (build marqdo_plugin_agent or marqdo ext add agent) sys.exit code=1
open
+ `root`=None
Open a CoW session. Optional root= (directory). Default: entry file directory.
ensure_plugin
root> sandbox_open root=root-
> sandbox_open
write
+ `id`
+ `path`
+ `text`
Write text into the session upper layer (host tree unchanged until commit).
ensure_plugin > sandbox_write id=
idpath=pathtext=text
read
+ `id`
+ `path`
Read through CoW (upper, else lower; whiteout misses).
ensure_plugin > sandbox_read id=
idpath=path
remove
+ `id`
+ `path`
Logical delete (whiteout).
ensure_plugin > sandbox_remove id=
idpath=path
diff
+ `id`
List of { path, kind } pending changes (write | remove).
ensure_plugin > sandbox_diff id=
id
commit
+ `id`
Apply upper / whiteout to the real workspace root.
ensure_plugin > sandbox_commit id=
id
discard
+ `id`
Drop the session without writing the host tree.
ensure_plugin > sandbox_discard id=
id
run
+ `id`
+ `source`=None
+ `path`=None
Run Marqdo under sandbox caps (exec / net / plugin off; fs via CoW).
Pass source= or path= (relative to session root).
ensure_plugin
source> sandbox_run id=idsource=sourcepath> sandbox_run id=idpath=path-
print text=ext/ai/sandbox.run: need source= or path= sys.exit code=1
inspect
+ `id`
Caps defaults, change counts, and availability notes.
ensure_plugin > sandbox_inspect id=
id