Skip to content

chat

Chat: threads where people and agents talk.

On this page 7
TypeScript
import { chat } from "copilotz/plugins/agents";

What it keeps

It keeps 7 collections, 4 of them on the record.

CollectionKept asFields
filedocumentsname, type, size, data, draft, voice, transcript, thread, in, private, at
intentdocumentsthread, agent, step, text, state, told, calls, outputs, asks, again, at
livein memory, gone on restartthread, agent, turn, text, calls, retry, open, in, at
messagedocumentsthread, from, to, text, toolCalls, private, replyTo, expectReply, subthread, hops, turn, failed, in, files, sources, stopped, tap, via, back, state, told, knew, at; private: state, told
shownrecords, appended and never changedthread, in, key, after, medium, fallback, note, at
threaddocumentstitle, renamable, agents, parent, fork, in, messages, opened, latest, at
waitdocumentsagent, thread, trigger, hops, waitingFor, received, step, at

The access rules cover file, live, message, shown and thread: each document is in a space, and only those who reach the space reach it.

Its named queries read for callers, as the rules let them:

QueryWho outside runs it
file.aboutpeople, agents for a person, contacts, keys and routines
message.conversationpeople, agents for a person, keys and routines
message.historypeople, agents for a person, keys and routines
message.questionspeople, keys or routines, depending on input
message.visiblethe app's code
thread.agentspeople, agents for a person, keys and routines
thread.promptpeople, keys and routines; agents for a person, depending on input
thread.recentpeople, agents for a person, keys and routines

What it lets callers do

Of its 12 Actions, people may call 6; agents may call 3; contacts may call 2; someone signed out may call none.

ActionPersonAgentContactAnyoneKeyRoutineWhat it does
chat.attachyesnoyesnoyesyesUploads a file to send: a draft that a message of yours sends, by its id.
chat.forkyesyesnonoyesyes
chat.moveyesnononononoMoves a conversation, with everything in it, to another space.
chat.openyesyesnonoyesyesOpens an empty chat in a space.
chat.sendyesnoyesnoyesyes
chat.stopyesyesnonoyesyesStops agents' turns in a conversation (and its subthreads).

An agent works for a person, and calls what both may. A key calls only what its scope names. A routine is work done for a person, which they set going.

Only the app's own code calls chat.erase, chat.import, chat.prune, chat.quiet, chat.say and chat.shown: its plugins, its schedules and the system.

It answers 1 route over HTTP:

MethodPath
GET, HEAD/files/*

It also adds rules every read and write keeps to (guard).

Where it shows

Its Views show to the model and elsewhere.

  • To the model: llm.message, llm.thread.
  • Elsewhere: context, history, participants.
  • Front ends: chat-terminal and chat-web.
  • What it adds to resources: usageNames (thread).

What it needs

You set it in resources.chat.

SettingTypeRequiredWhat it is
chat.maxHopsnumbernoHow many agent messages in a row, after a person's, may start another agent's turn.
chat.maxStepsnumbernoHow many steps (model calls) one agent turn may take before it fails, so a runaway agent stops.
chat.transcriberModelRefnoThe model that transcribes audio sent with a message (default: the transcribe alias, from resources.model).

It also reads agentModel, agentSources, agents, contactSend, context, roster and tools, resource kinds the app and other plugins fill.

What it requires

The runtime doesn't start without models: add it too.

It ships with copilotz@1.0.0-rc.34.

What it does on its own

Some of its work starts without a caller: an event, or the time.

  • chat.failed runs on processor.failed.
  • chat.turn runs on turn.requested or wait.updated.
  • chat.prune calls chat.prune, every 1h. Drops files uploaded to send that no message sent within a day.
  • It emits turn.requested. An agent is to take a turn in a thread, because of a message.

Listing

It breaks 1 listing rule as it is:

  • Route "/files/*" isn't under /chat.

And before adding it, know this:

  • Action "chat.fork" has no description.
  • Action "chat.send" has no description.