workgraph-agent-cli

Coding-agent nodes for workgraph

agent
coding-agent
graph
moonbit
moon add totto2727/workgraph-agent-cli@0.2.0
Download zip
Author
Version
0.2.0
License
MIT
Last updated
21 hours ago
Downloads
12
README

#workgraph-agent-cli

workgraph-agent-cli provides the Workgraph-owned coding-agent concepts: WorkspaceRef, approval and network policies, CodingAgentOpenContext, CodingAgentId, CodingAgent, CodingAgentNodeSpec, and coding_agent_node. The core package remains provider-neutral and exposes only node patches and optional values.

The breaking API delegates execution directly to totto2727/agent-sdk/cli: CodingAgent.open returns a configured Cli; a node creates a Prompt, selects an optional opaque Continuation, and decodes a FinalResponse. Workgraph no longer exposes mirror SessionId, CodingAgentRequest, CodingAgentStatus, CodingAgentResponse, or CodingAgentSession types.

Each node acquires one CliSession per agent identity and caller resource scope, starting a session when no continuation is selected or resuming one when a CodingAgentContinuation is supplied. Only the node can construct this opaque token from a successful FinalResponse; it binds the raw continuation to the configured CodingAgentId and raises CodingAgentContinuationError::AgentMismatch before provider open when another agent selects it. The node resolves relative prompt context files against CodingAgentOpenContext.workspace.root and leaves absolute Path values unchanged. A node-owned mutex serializes prompt calls. Resource finalization is intentionally a no-op because CliSession has no idle close operation; cancellation cleanup is owned by the provider call and cancellation is re-raised after that cleanup. A continuation is an in-process handle, not a serializable or durable checkpoint.

Graph execution is sequential. Multiple agents remain isolated even when callers reuse a visible resource key: Workgraph includes the agent ID in its internal key, so sessions, state slots, and continuations never cross agent boundaries.

The package intentionally has no standalone example. Use the runnable workgraph-codex-cli and workgraph-opencode-cli examples to see this node with concrete coding-agent implementations.

#Package

import {
"totto2727/workgraph-agent-cli"
}

Version 0.2.0 prefers the Wasm/WASI target and supports Wasm/WASI and native. JavaScript is not supported. The module resolves totto2727/agent-sdk@0.2.0 from the MoonBit registry. Wasm GC is excluded because moonbitlang/async does not support it.

#
CodingAgentContinuationError

pub suberror CodingAgentContinuationError {
AgentMismatch(expected~ : CodingAgentId, actual~ : CodingAgentId)
} derive(
Debug
)

Raised when a continuation is supplied to a different coding agent.

#
IdError

pub suberror IdError {
EmptyId(kind~ : String)
} derive(
Debug
)

#
ApprovalPolicy

pub(all) enum ApprovalPolicy {
Never
OnRequest
OnFailure
Untrusted
} derive(Eq,
Debug
)

#
CodingAgent

pub struct CodingAgent {
id : CodingAgentId
open : async (CodingAgentOpenContext) ->
Cli

}

#
CodingAgent::CodingAgent

Creates a coding-agent adapter.

#
CodingAgentContinuation

pub struct CodingAgentContinuation {
// private fields
}

In-process continuation bound to the coding agent that produced it.

Only a coding-agent node can create this value from a successful response.

#
CodingAgentId

pub struct CodingAgentId {
value : String
} derive(Eq, Hash,
Debug
)

#
CodingAgentId::CodingAgentId

fn CodingAgentId::CodingAgentId(value : String) -> CodingAgentId raise IdError

#
CodingAgentId::to_string

fn CodingAgentId::to_string(self : CodingAgentId) -> String

#
CodingAgentNodeSpec

#
CodingAgentNodeSpec::CodingAgentNodeSpec

Creates the callbacks and resource policy used by a coding-agent node.

#
CodingAgentOpenContext

pub struct CodingAgentOpenContext {
run_id :
RunId

task_group :
TaskGroup
[Unit]
workspace : WorkspaceRef
approval : ApprovalPolicy
network : NetworkPolicy
environment :
HashMap
[String, String]
events :
EventSink

}

#
CodingAgentOpenContext::CodingAgentOpenContext

Creates the runtime context used to open a coding-agent session.

#
NetworkPolicy

pub(all) enum NetworkPolicy {
Disabled
Enabled
} derive(Eq,
Debug
)

#
WorkspaceRef

pub struct WorkspaceRef {
root :
Path

additional_writable_roots : ReadOnlyArray[
Path
]
} derive(Eq,
Debug
)

#
WorkspaceRef::WorkspaceRef

fn WorkspaceRef::WorkspaceRef(root :
Path
, additional_writable_roots : ReadOnlyArray[
Path
]) -> WorkspaceRef

Creates a writable workspace description for a coding agent.

#
coding_agent_node

Create a graph node that acquires an agent SDK session, serializes a prompt, and decodes its final response.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io