chat

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package chat provides the `ana chat` verb tree: new/list/show/history/send (streaming) plus rename, bookmark/unbookmark, duplicate, delete, and share. Like the other verb packages it avoids importing internal/transport and internal/config — consumers inject a narrow Deps struct that adapts a real transport client to two function fields plus a UUID generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(deps Deps) *cli.Group

New returns the `chat` verb group. Safe to register under any name in the root verb table — the group holds no state of its own, only a handful of *<verb>Cmd structs that capture the shared Deps.

Types

type Deps

type Deps struct {
	Unary  func(ctx context.Context, path string, req, resp any) error
	Stream func(ctx context.Context, path string, req any) (StreamSession, error)
	UUIDFn func() string
}

Deps is the injection boundary for the chat package.

  • Unary JSON-encodes req, POSTs it to path, and JSON-decodes into *resp.
  • Stream opens a server-streaming call and returns a StreamSession the caller drains frame-by-frame.
  • UUIDFn returns a fresh v4 UUID string. Injected so tests can assert on a deterministic cellId rather than a random one per run.

type StreamSession

type StreamSession interface {
	Next(out any) (bool, error)
	Close() error
}

StreamSession is the minimum surface the `send` subcommand needs from a streaming RPC call: pull the next frame, decode into an arbitrary value, and close the underlying body. transport.StreamReader satisfies this at the call site; tests supply an in-memory fake (see chat_test.go).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL