harn-modules 0.7.29

Cross-file module graph and import resolution utilities for Harn
Documentation
// std/acp — Canonical Agent Client Protocol envelope types.
//
// These type aliases match the ACP `sessionUpdate` schema
// byte-for-byte, so a pipeline that declares `-> SessionUpdate` (or
// one of the concrete variants below) can be validated at the
// Harn→ACP boundary by the Harn type checker instead of relying on
// the host bridge as the only enforcement point.
//
// Import with: `import "std/acp"`. See `docs/src/mcp-and-acp.md`
// ("Typed pipeline returns") for end-to-end usage.

type AgentMessageChunk = {
  sessionUpdate: string,
  content: {
    type: string,
    text: string | nil,
    annotations: dict | nil,
  },
}

type ToolCall = {
  sessionUpdate: string,
  toolCallId: string,
  title: string | nil,
  kind: string | nil,
  status: string | nil,
  content: list<dict> | nil,
  locations: list<dict> | nil,
  rawInput: dict | nil,
  rawOutput: dict | nil,
}

type ToolCallUpdate = {
  sessionUpdate: string,
  toolCallId: string,
  status: string | nil,
  title: string | nil,
  content: list<dict> | nil,
  locations: list<dict> | nil,
  rawOutput: dict | nil,
}

type Plan = {
  sessionUpdate: string,
  entries: list<{
    content: string,
    priority: string | nil,
    status: string | nil,
  }>,
}

type SessionUpdate = AgentMessageChunk | ToolCall | ToolCallUpdate | Plan

type PipelineResult = {
  text: string | nil,
  events: list<SessionUpdate> | nil,
  run_record: dict | nil,
}

pub fn agent_message_chunk(text) {
  return {
    sessionUpdate: "agent_message_chunk",
    content: {
      type: "text",
      text: text,
      annotations: nil,
    },
  }
}

pub fn tool_call(tool_call_id, title) {
  return {
    sessionUpdate: "tool_call",
    toolCallId: tool_call_id,
    title: title,
    kind: nil,
    status: "pending",
    content: nil,
    locations: nil,
    rawInput: nil,
    rawOutput: nil,
  }
}

pub fn tool_call_update(tool_call_id, status) {
  return {
    sessionUpdate: "tool_call_update",
    toolCallId: tool_call_id,
    status: status,
    title: nil,
    content: nil,
    locations: nil,
    rawOutput: nil,
  }
}

pub fn plan(entries) {
  return {
    sessionUpdate: "plan",
    entries: entries,
  }
}