Skip to documentation
SLOP

tiny.acp.Observer

Reference tiny.acp Observer

Defined in client.

The caller keeps the lasting record of the conversation and may answer permission requests itself, so the client calls out to it before it acts on each message.

API (4)

Fields and members

Public fields and members.

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

Source

Source: lib/acp/src/client.zig:275

zig
/// The caller keeps the lasting record of the conversation and may answer permission requests/// itself, so the client calls out to it before it acts on each message. The structure provides a/// context pointer and three optional callbacks. The client calls them from inside `start` and the/// prompt calls, in the order the messages arrive. Each update goes to `updateFn` before its text/// joins the reply and before the client reads the next line. For a permission request,/// `permissionFn` may answer first, and `permissionCommitFn` then receives the decision before the/// client sends the answer to the agent. An error from `updateFn` or `permissionCommitFn` fails the/// client call that read the message. When `updateFn` or `permissionCommitFn` is null, the first/// message that needs it fails the call with `error.MissingDurableObserver`. The package README/// asks the observer to commit each exact update line before it returns.pub const Observer = struct {    /// The caller's context, passed as the first argument to every callback.    ptr: *anyopaque,    /// A callback called once per update, in arrival order, with the update's numbers, its exact    /// line and the fields read from it. The client frees the update and every string in it when    /// the call returns, so the callback copies what it keeps. Null, the default, fails the call    /// with `error.MissingDurableObserver` at the first update.    updateFn: ?*const fn (*anyopaque, protocol.Update) anyerror!void = null,    /// A callback asked first when the agent requests permission: a returned reply is used, and    /// null leaves the decision to the permission policy. The callback sees the request with    /// outcome `pending`, empty option fields and an empty line. Null, the default, leaves every    /// decision to the permission policy.    permissionFn: ?*const fn (*anyopaque, protocol.PermissionRequest) ?PermissionReply = null,    /// A callback called with the full request, the decision and the exact line, before the client    /// sends the answer to the agent. An error stops the answer from being sent and fails the call.    /// The client frees the request when the call returns, so the callback copies what it keeps.    /// Null, the default, fails the call with `error.MissingDurableObserver` at the first    /// permission request.    permissionCommitFn: ?*const fn (*anyopaque, protocol.PermissionRequest) anyerror!void = null,    fn update(self: Observer, value: protocol.Update) !void {        const callback = self.updateFn orelse return error.MissingDurableObserver;        try callback(self.ptr, value);    }    fn permission(self: Observer, request: protocol.PermissionRequest) ?PermissionReply {        const callback = self.permissionFn orelse return null;        return callback(self.ptr, request);    }    fn commitPermission(self: Observer, request: protocol.PermissionRequest) !void {        const callback = self.permissionCommitFn orelse            return error.MissingDurableObserver;        try callback(self.ptr, request);    }};

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

zig
pub const Observer = client.Observer;

Audit

Definitions1
Public names2
Members4
Version26.7.0
Revisiondaab053ee433