Agent lifecycle (5 functions)
xworkAgentConfigInit / Create / Destroy lifecycle
Zero the config (workspace root, explore mode, budget) → create an opaque agent handle → destroy releases everything. The explore mode picks internal implementations (zero external deps) or delegates to rg/fd.
xworkAgentWorkspaceRoot query
Returns the agent's workspace root path (borrowed pointer) — the read/write sandbox boundary.
Run control (6 functions)
xworkAgentRunBegin / Run / RunEnd turn
Three-phase turns: Begin starts a task, Run drives until it returns false (turn complete), RunEnd frees turn state. Run internally calls xllm, parses tool invocations, executes tools and feeds results back.
xworkAgentCancel / Resume control
Cancel an in-flight turn (tool execution interrupted, state saved); resume a cancelled turn.
Tool registration (10 functions)
xworkAgentRegisterBuiltinTools / RegisterBuiltinReadOnlyTools built-ins
One-call registration of the built-in tool set (file read/write, directory listing, glob); the ReadOnly variant includes the read-only subset only (subagent / exploration scenarios).
xworkAgentRegisterTool / UnregisterTool / UnregisterToolsBySource custom
Register a custom tool (name, description, parameter schema, callback); unregister by handle or in bulk by source. The registry has a generation number (ToolRegistryGeneration) — hot-updating the tool set never interrupts an in-flight turn.
xworkAgentToolAt / ToolCount / ToolRegistryGeneration query
Enumerate registered tools (for approval UIs); the generation number detects hot updates.
Subagent types (5 functions)
xworkAgentRegisterSubagentType / UnregisterSubagentType / SubagentTypeCount type system
Register / unregister / enumerate subagent types — each type binds its own tool set and permission tier. Combine with RunReadOnlySubagent to form multi-agent topologies.
xworkAgentRunReadOnlySubagent spawn
Spawn a read-only subagent of the given type and run a single turn (exploration / retrieval).
Notices & queries (8 functions)
xworkAgentTakeTaskNotices notices
Drain accumulated task notices (tool call start/end, artifact creation, state changes) — the data source for approval UIs and front-end trails; up to N per batch.
Compaction (3 functions)
xworkAgentCompact / MaybeCompact / CommitCompaction context
Manual or automatic (MaybeCompact on budget thresholds) context compaction, integrated with xllm-session operators; Commit confirms the result (read markers preserve tool artifacts).
xworkAgentDefaultCompactionOps config
Get the default compaction configuration (75%/95% two-tier thresholds).
release/agent-demo/ (xwork + xllm + xllm-session + site VFS). Full source at lib/xwork.