Skip to documentation
SLOP

tiny.acp.Update

Reference tiny.acp Update

Defined in protocol.

One session/update notification from the agent, with the two numbers the client gave it, the exact line, and fields read from it, received by the observer so the caller records and inspects the agent's progress.

API (22)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callsprotocolUpdate
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/acp/src/protocol.zig:288

zig
/// One `session/update` notification from the agent, with the two numbers the client gave it, the/// exact line, and fields read from it, received by the observer so the caller records and inspects/// the agent's progress. The client builds one structure per notification, hands it to the/// observer, and frees it when the callback returns. The structure owns every `[]u8` field, and/// `deinit` frees them. A field the notification lacks is empty, null or 0.pub const Update = struct {    /// The caller's number for the client that received the notification.    transport_epoch: u64,    /// The notification's place among all the notifications the client has received, counting    /// from 1.    update_sequence: u64,    /// The exact line the agent sent, trimmed of surrounding whitespace. The client trims spaces,    /// tabs, carriage returns and newlines from both ends of the line. This slice is borrowed from    /// the reader's buffer and remains valid only until the observer's callback returns. The    /// `deinit` function leaves it alone.    envelope: []const u8,    /// The kind read from `sessionUpdate`.    kind: UpdateKind,    /// The `sessionUpdate` string as the agent sent it. The update owns this field.    name: []u8,    /// The notification's `params.sessionId`, empty when absent. The update owns this field.    session_id: []u8,    /// A summary text for the notification. For an `agent_message_chunk`, this field carries the    /// chunk's text, and the client adds it to the reply. The client picks the first of these the    /// update carries: the content text, the title, the mode id, the first plan entry's content,    /// the first command name, the usage as "used/size", and else the update's name. The update    /// owns this field.    text: []u8,    /// A minified JSON copy of the `params.update` object. The update owns this field.    raw: []u8,    /// The update's `toolCallId`, empty when absent. The update owns this field.    tool_call_id: []u8 = &.{},    /// The update's `status`, empty when absent. The update owns this field.    status: []u8 = &.{},    /// The update's `kind`, the tool call's kind, empty when absent. The update owns this field.    tool_kind: []u8 = &.{},    /// The update's `currentModeId`, empty when absent. The update owns this field.    mode_id: []u8 = &.{},    /// The update's integer `used`, or null when absent.    usage_used: ?i64 = null,    /// The update's integer `size`, or null when absent.    usage_size: ?i64 = null,    /// The number of entries in the update's `entries` list, 0 when absent.    plan_entries: usize = 0,    /// The number of entries in the update's `availableCommands` list, 0 when absent.    available_commands: usize = 0,    /// The number of entries in the update's `configOptions` list, 0 when absent.    config_options: usize = 0,    /// The update's `title`, empty when absent. The update owns this field.    title: []u8 = &.{},    /// The update's `updatedAt`, empty when absent. The update owns this field.    updated_at: []u8 = &.{},    /// Frees every owned string with the given allocator and leaves the value undefined, so the    /// caller frees an update built with `fromSessionNotification`. The call leaves the borrowed    /// line alone.    pub fn deinit(self: *Update, allocator: Allocator) void {        if (self.name.len != 0) allocator.free(self.name);        if (self.session_id.len != 0) allocator.free(self.session_id);        if (self.text.len != 0) allocator.free(self.text);        if (self.raw.len != 0) allocator.free(self.raw);        if (self.tool_call_id.len != 0) allocator.free(self.tool_call_id);        if (self.status.len != 0) allocator.free(self.status);        if (self.tool_kind.len != 0) allocator.free(self.tool_kind);        if (self.mode_id.len != 0) allocator.free(self.mode_id);        if (self.title.len != 0) allocator.free(self.title);        if (self.updated_at.len != 0) allocator.free(self.updated_at);        self.* = undefined;    }    /// Reads `params.update` from a parsed notification object, so the caller turns one parsed    /// `session/update` notification into an `Update`, as the client does for each one it reads.    /// The call returns null when `params`, `params.update` or its `sessionUpdate` string is    /// missing, and the client then fails its call with `error.AgentProtocolError`. The function    /// stores the given epoch, sequence and line, and keeps the line by reference. The call copies    /// every string it keeps with the allocator, and the caller frees them with `deinit`. The    /// function fails with `error.OutOfMemory` and leaves nothing allocated when a copy fails. The    /// call reads the object as given and does not look at `method`, because the client checks the    /// method name before it calls this.    pub fn fromSessionNotification(        allocator: Allocator,        object: std.json.ObjectMap,        transport_epoch: u64,        update_sequence: u64,        envelope: []const u8,    ) !?Update {        const params = json.objectObject(object, "params") orelse return null;        const update = json.objectObject(params, "update") orelse return null;        const name = json.objectString(update, "sessionUpdate") orelse return null;        const session_id = json.objectString(params, "sessionId") orelse "";        const owned_name = try allocator.dupe(u8, name);        errdefer allocator.free(owned_name);        const owned_session = try allocator.dupe(u8, session_id);        errdefer allocator.free(owned_session);        const text = try summaryTextAlloc(allocator, update, name);        errdefer if (text.len != 0) allocator.free(text);        const raw = try rawJsonAlloc(allocator, update);        errdefer if (raw.len != 0) allocator.free(raw);        const tool_call_id = try optionalStringAlloc(allocator, update, "toolCallId");        errdefer if (tool_call_id.len != 0) allocator.free(tool_call_id);        const status = try optionalStringAlloc(allocator, update, "status");        errdefer if (status.len != 0) allocator.free(status);        const tool_kind = try optionalStringAlloc(allocator, update, "kind");        errdefer if (tool_kind.len != 0) allocator.free(tool_kind);        const mode_id = try optionalStringAlloc(allocator, update, "currentModeId");        errdefer if (mode_id.len != 0) allocator.free(mode_id);        const title = try optionalStringAlloc(allocator, update, "title");        errdefer if (title.len != 0) allocator.free(title);        const updated_at = try optionalStringAlloc(allocator, update, "updatedAt");        errdefer if (updated_at.len != 0) allocator.free(updated_at);        return .{            .transport_epoch = transport_epoch,            .update_sequence = update_sequence,            .envelope = envelope,            .kind = kindFromName(name),            .name = owned_name,            .session_id = owned_session,            .text = text,            .raw = raw,            .tool_call_id = tool_call_id,            .status = status,            .tool_kind = tool_kind,            .mode_id = mode_id,            .usage_used = json.objectInteger(update, "used"),            .usage_size = json.objectInteger(update, "size"),            .plan_entries = arrayLength(update, "entries"),            .available_commands = arrayLength(update, "availableCommands"),            .config_options = arrayLength(update, "configOptions"),            .title = title,            .updated_at = updated_at,        };    }    /// Returns true for an `agent_message_chunk`, the only kind the client adds to a reply, so the    /// caller tells whether an update carries reply text.    pub fn assistantMessage(self: Update) bool {        return self.kind == .agent_message_chunk;    }};

Source: lib/acp/src/root.zig:92

zig
pub const Update = protocol.Update;
Called byCallsprivate sourcelib.acp.src.client.ClienthandleIncomingtest sourcelib.acp.src.protocoltest: protocol parses session update ...test sourcelib.acp.src.protocoltest: protocol parses session update ...private sourcelib.acp.src.jsonobjectIntegerprivate sourcelib.acp.src.jsonobjectObjectprivate sourcelib.acp.src.jsonobjectStringprivate sourcelib.acp.src.protocolarrayLengthprivate sourcelib.acp.src.protocolkindFromName+3 moreUpdatefromSessionNotification
Static calls · unresolved targets: 0 · external targets: 2.

Complete call list for Update.fromSessionNotification

8 direct calls.

Audit

Definitions4
Public names8
Members19
Version26.7.0
Revisiondaab053ee433