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.
deinit: A caller uses this function to free the answer once the caller is done with it.fromResponse: A caller uses this function to turn a parsedinitializeresponse into typed fields, asClient.startdoes.
Fields and members
Public fields and members.
auth_method_idsauth_methodsload_sessionprompt_audioprompt_embedded_contentprompt_imageprotocol_versionraw
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;Complete call list for Initialize.fromResponse
7 direct calls.
lib.acp.src.json.objectBool[function] — private source atlib/acp/src/json.zig:41in nearest public ownerlib.acp.src.jsonlib.acp.src.json.objectInteger[function] — private source atlib/acp/src/json.zig:36in nearest public ownerlib.acp.src.jsonlib.acp.src.json.objectObject[function] — private source atlib/acp/src/json.zig:46in nearest public ownerlib.acp.src.jsonlib.acp.src.protocol.arrayLength[function] — private source atlib/acp/src/protocol.zig:579in nearest public ownertiny.acp.protocollib.acp.src.protocol.authMethodIdsAlloc[function] — private source atlib/acp/src/protocol.zig:650in nearest public ownertiny.acp.protocollib.acp.src.protocol.rawJsonAlloc[function] — private source atlib/acp/src/protocol.zig:676in nearest public ownertiny.acp.protocollib.acp.src.protocol.responseResult[function] — private source atlib/acp/src/protocol.zig:572in nearest public ownertiny.acp.protocol
Audit
| Definitions | 3 |
|---|---|
| Public names | 6 |
| Members | 8 |
| Version | 26.7.0 |
| Revision | daab053ee433 |