Polyman Documentation - v3.1.0
    Preparing search index...

    Type Alias AgentEvent

    AgentEvent:
        | { type: "turn_start"; turnId: string }
        | { type: "text_delta"; text: string }
        | { type: "reasoning_delta"; text: string }
        | {
            type: "tool_call";
            callId: string;
            name: string;
            args: unknown;
            risk: Risk;
            taskId?: string;
        }
        | {
            type: "approval_needed";
            approvalId: string;
            callId: string;
            title: string;
            command?: string;
            preview?: string;
        }
        | {
            type: "approval_resolved";
            approvalId: string;
            decision: ApprovalDecision;
        }
        | { type: "tool_progress"; callId: string; line: string; taskId?: string }
        | {
            type: "tool_result";
            callId: string;
            ok: boolean;
            summary: string;
            data?: unknown;
            taskId?: string;
        }
        | {
            type: "usage";
            inputTokens: number;
            outputTokens: number;
            costUsd?: number;
        }
        | { type: "notes_updated"; notes: string }
        | { type: "problem_dir_changed"; problemDir: string }
        | { type: "compacted"; removedMessages: number }
        | { type: "notice"; text: string; level?: "info" | "warn" | "error" }
        | {
            type: "turn_end";
            turnId: string;
            reason: "done" | "cancelled" | "max_steps" | "error";
            error?: string;
        }
        | { type: "plan_created"; plan: Plan }
        | { type: "plan_approval_needed"; approvalId: string; plan: Plan }
        | { type: "task_started"; taskId: string; attempt: number }
        | {
            type: "task_checkpoint";
            taskId: string;
            name: string;
            ok: boolean;
            digest: string;
        }
        | { type: "task_done"; taskId: string; result: TaskResult }
        | { type: "workflow_done"; ok: boolean; summary: string; costUsd: number }

    One event of the agent core.

    Type Declaration

    • { type: "turn_start"; turnId: string }

      A user message started a new turn.

    • { type: "text_delta"; text: string }

      A chunk of the answer text.

    • { type: "reasoning_delta"; text: string }

      A chunk of the model's reasoning.

    • {
          type: "tool_call";
          callId: string;
          name: string;
          args: unknown;
          risk: Risk;
          taskId?: string;
      }

      The model asked to run a tool.

      • type: "tool_call"
      • callId: string
      • name: string
      • args: unknown
      • risk: Risk
      • OptionaltaskId?: string

        The workflow task. Set only for events from a workflow worker.

    • {
          type: "approval_needed";
          approvalId: string;
          callId: string;
          title: string;
          command?: string;
          preview?: string;
      }

      A tool call waits for the user. Answer with resolveApproval().

    • { type: "approval_resolved"; approvalId: string; decision: ApprovalDecision }

      The user answered an approval prompt.

    • { type: "tool_progress"; callId: string; line: string; taskId?: string }

      A line of progress from a running tool (stderr of the CLI).

      • type: "tool_progress"
      • callId: string
      • line: string
      • OptionaltaskId?: string

        The workflow task. Set only for events from a workflow worker.

    • {
          type: "tool_result";
          callId: string;
          ok: boolean;
          summary: string;
          data?: unknown;
          taskId?: string;
      }

      A tool finished. data is the full data for the UI.

      • type: "tool_result"
      • callId: string
      • ok: boolean
      • summary: string
      • Optionaldata?: unknown
      • OptionaltaskId?: string

        The workflow task. Set only for events from a workflow worker.

    • { type: "usage"; inputTokens: number; outputTokens: number; costUsd?: number }

      Token counts of one model call, and its cost when known.

    • { type: "notes_updated"; notes: string }

      The problem spec (.polyman/agent/notes.md) changed.

    • { type: "problem_dir_changed"; problemDir: string }

      The session now works on another problem folder.

    • { type: "compacted"; removedMessages: number }

      Old messages were cut to stay under the context budget.

    • { type: "notice"; text: string; level?: "info" | "warn" | "error" }

      A line for the user from the session, not from the model, like "this model can only chat". It is never sent to the model.

    • {
          type: "turn_end";
          turnId: string;
          reason: "done" | "cancelled" | "max_steps" | "error";
          error?: string;
      }

      The turn is over, and why.

    • { type: "plan_created"; plan: Plan }

      The manager made a plan.

    • { type: "plan_approval_needed"; approvalId: string; plan: Plan }

      The plan waits for the user. Answer with PermissionGate.resolve().

    • { type: "task_started"; taskId: string; attempt: number }

      A workflow task started (or started again).

    • {
          type: "task_checkpoint";
          taskId: string;
          name: string;
          ok: boolean;
          digest: string;
      }

      The checkpoint of a task ran.

    • { type: "task_done"; taskId: string; result: TaskResult }

      A workflow task is over.

    • { type: "workflow_done"; ok: boolean; summary: string; costUsd: number }

      The whole workflow is over.