Skip to documentation
SLOP

tiny.acp.Modes

Reference tiny.acp Modes

Defined in protocol.

A caller uses this structure to learn which mode the session starts in, such as plan or act, and how many modes the agent offers.

API (5)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

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

zig
/// A caller uses this structure to learn which mode the session starts in, such as `plan` or `act`,/// and how many modes the agent offers. The structure holds the session's current mode id, the/// number of modes on offer, and a raw copy of the `modes` object from the `session/new` answer./// `Client.start` keeps the structure in `Client.modes`, and the value stays empty when the agent/// reports zero modes. The structure owns `current` and `raw`, and `deinit` frees them.pub const Modes = struct {    /// The current mode's id, from `modes.currentModeId`. The slice is owned, and empty by default.    current: []u8 = &.{},    /// The number of entries in `modes.availableModes`. The count is 0 by default and when the key    /// is absent.    available: usize = 0,    /// A minified JSON copy of the `modes` object. The slice is owned, and empty by default.    raw: []u8 = &.{},    /// A caller uses this function to free the modes once the caller is done with them. The    /// function frees the two owned strings with the given allocator and leaves the value    /// undefined. The call is safe on the default value, which owns zero allocations.    pub fn deinit(self: *Modes, allocator: Allocator) void {        if (self.current.len != 0) allocator.free(self.current);        if (self.raw.len != 0) allocator.free(self.raw);        self.* = undefined;    }    /// A caller uses this function to read the session's modes from a parsed `session/new`    /// response, as `Client.start` does. The function reads a parsed JSON-RPC response and returns    /// the modes in its result. The function returns null when the result lacks a `modes` object or    /// that object lacks a string `currentModeId`. The function fails with    /// `error.AgentProtocolError` when the value is a non-object, carries an `error` member, or    /// lacks an object `result`. The call copies the strings it keeps with the allocator, and the    /// caller frees them with `deinit`.    pub fn fromResponse(allocator: Allocator, value: std.json.Value) !?Modes {        const result = try responseResult(value);        const modes = json.objectObject(result, "modes") orelse return null;        const current = json.objectString(modes, "currentModeId") orelse return null;        const owned_current = try allocator.dupe(u8, current);        errdefer allocator.free(owned_current);        const raw = try rawJsonAlloc(allocator, modes);        errdefer if (raw.len != 0) allocator.free(raw);        return .{            .current = owned_current,            .available = arrayLength(modes, "availableModes"),            .raw = raw,        };    }};

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

zig
pub const Modes = protocol.Modes;
Called byCallsNo direct callsClientdeinitClientstartModesdeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsClientstarttest sourcelib.acp.src.protocoltest: protocol parses session modesprivate sourcelib.acp.src.jsonobjectObjectprivate sourcelib.acp.src.jsonobjectStringprivate sourcelib.acp.src.protocolarrayLengthprivate sourcelib.acp.src.protocolrawJsonAllocprivate sourcelib.acp.src.protocolresponseResultModesfromResponse
Static calls · unresolved targets: 0 · external targets: 2.

Audit

Definitions3
Public names6
Members3
Version26.7.0
Revisiondaab053ee433