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.
deinit: A caller uses this function to free the modes once the caller is done with them.fromResponse: A caller uses this function to read the session's modes from a parsedsession/newresponse, asClient.startdoes.
Fields and members
Public fields and members.
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;Audit
| Definitions | 3 |
|---|---|
| Public names | 6 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |