Skip to documentation
SLOP

tiny.acp.Initialize

Reference tiny.acp Initialize

Defined in protocol.

A caller uses this structure to learn which protocol version the agent speaks, which kinds of prompt block it accepts, and how it authenticates.

API (10)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

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

zig
/// A caller uses this structure to learn which protocol version the agent speaks, which kinds of/// prompt block it accepts, and how it authenticates. The structure holds the agent's answer to/// `initialize`: protocol version, capability flags, authentication methods, and a raw copy of the/// whole result. `Client.start` fills the structure and keeps it in `Client.initialize`. Every/// field has a default, and the default value stands for an absent answer. The structure owns its/// two strings, and `deinit` frees them.pub const Initialize = struct {    /// The protocol version the agent answered with, from `result.protocolVersion`. `Client.start`    /// accepts only 1. The field defaults to 0.    protocol_version: i64 = 0,    /// The agent's `agentCapabilities.loadSession` flag. The value is false when the key is absent.    load_session: bool = false,    /// The agent's `promptCapabilities.audio` flag, for prompts that carry audio blocks. The value    /// is false when the key is absent.    prompt_audio: bool = false,    /// The agent's `promptCapabilities.image` flag, for prompts that carry image blocks. The value    /// is false when the key is absent.    prompt_image: bool = false,    /// Reports true when `promptCapabilities` sets either `embeddedContent` or `embeddedContext` to    /// true. The value is false when both keys are absent.    prompt_embedded_content: bool = false,    /// The number of entries in the answer's `authMethods` list. The value is 0 when the key is    /// absent or holds a non-list value.    auth_methods: usize = 0,    /// The ids of the authentication methods as one minified JSON array of strings, such as    /// `["token"]`. A method lacking a string `id` is skipped, and the slice is empty when all    /// methods lack one. The slice is owned.    auth_method_ids: []u8 = &.{},    /// A minified JSON copy of the whole `result` object. The slice is owned.    raw: []u8 = &.{},    /// A caller uses this function to free the answer once the caller is done with it. 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. The caller provides the    /// allocator that `fromResponse` used.    pub fn deinit(self: *Initialize, allocator: Allocator) void {        if (self.auth_method_ids.len != 0) allocator.free(self.auth_method_ids);        if (self.raw.len != 0) allocator.free(self.raw);        self.* = undefined;    }    /// A caller uses this function to turn a parsed `initialize` response into typed fields, as    /// `Client.start` does. The function reads a parsed JSON-RPC response and returns its result as    /// an `Initialize`. The function fails with `error.AgentProtocolError` when the value is a    /// non-object, carries an `error` member, lacks an object `result`, or the result lacks an    /// integer `protocolVersion`. The parser reads a missing capability flag as false. The call    /// copies the strings it keeps with the allocator, so the result outlives the parsed JSON, and    /// the caller frees it with `deinit`. The function fails with `error.OutOfMemory` and leaves    /// zero allocations when a copy fails.    pub fn fromResponse(allocator: Allocator, value: std.json.Value) !Initialize {        const result = try responseResult(value);        const protocol_version = json.objectInteger(result, "protocolVersion") orelse return error.AgentProtocolError;        const raw = try rawJsonAlloc(allocator, result);        errdefer if (raw.len != 0) allocator.free(raw);        const auth_method_ids = try authMethodIdsAlloc(allocator, result);        errdefer if (auth_method_ids.len != 0) allocator.free(auth_method_ids);        var load_session = false;        var prompt_audio = false;        var prompt_image = false;        var prompt_embedded_content = false;        if (json.objectObject(result, "agentCapabilities")) |capabilities| {            load_session = json.objectBool(capabilities, "loadSession") orelse false;            if (json.objectObject(capabilities, "promptCapabilities")) |prompt| {                prompt_audio = json.objectBool(prompt, "audio") orelse false;                prompt_image = json.objectBool(prompt, "image") orelse false;                prompt_embedded_content = (json.objectBool(prompt, "embeddedContent") orelse false) or (json.objectBool(prompt, "embeddedContext") orelse false);            }        }        return .{            .protocol_version = protocol_version,            .load_session = load_session,            .prompt_audio = prompt_audio,            .prompt_image = prompt_image,            .prompt_embedded_content = prompt_embedded_content,            .auth_methods = arrayLength(result, "authMethods"),            .auth_method_ids = auth_method_ids,            .raw = raw,        };    }};

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

zig
pub const Initialize = protocol.Initialize;
Called byCallsNo direct callsClientdeinitClientstartInitializedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsClientstarttest sourcelib.acp.src.protocoltest: protocol parses initialize capa...private sourcelib.acp.src.jsonobjectBoolprivate sourcelib.acp.src.jsonobjectIntegerprivate sourcelib.acp.src.jsonobjectObjectprivate sourcelib.acp.src.protocolarrayLengthprivate sourcelib.acp.src.protocolauthMethodIdsAlloc+2 moreInitializefromResponse
Static calls · unresolved targets: 1 · external targets: 1.

Complete call list for Initialize.fromResponse

7 direct calls.

Audit

Definitions3
Public names6
Members8
Version26.7.0
Revisiondaab053ee433