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 10 collections, 7 of them on the record.

CollectionKept asFields
approvaldocumentsowner, for, agent, thread, in, work, on, detail, text, covers, name, people, preview, answers, origin, call, question, reply, status, grant, at, decided
filedocumentsname, type, size, data, draft, voice, transcript, thread, in, private, at
grantdocumentsowner, agent, work, on, thread, once, origin, rev, at
intentdocumentsthread, agent, step, text, state, told, calls, outputs, asks, again, at
livein memory, gone on restartthread, agent, turn, text, calls, retry, waking, open, in, at
messagedocumentsthread, from, to, text, toolCalls, private, replyTo, expectReply, subthread, hops, turn, failed, in, files, drew, held, 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, about, held, archived, messages, opened, latest, at
waitdocumentsagent, thread, trigger, hops, waitingFor, received, step, at
welcomedocumentsat

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
approval.pendingpeople, agents for a person, keys and routines
file.aboutpeople, agents for a person, contacts, keys and routines
grant.forOriginpeople, agents for a person, keys and routines
grant.minepeople, agents for a person, 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.movingpeople, 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
welcome.seenpeople, agents for a person, keys and routines

What it lets callers do

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

ActionPersonAgentContactAnyoneKeyRoutineMaintenanceWhat it does
chat.approveyesnonononononoAnswers what an agent waits on you for.
chat.archiveyesnonononononoArchives a conversation, or brings it back.
chat.attachyesnoyesnoyesyesnoUploads a file to send: a draft that a message of yours sends, by its id.
chat.forgetGrantyesnonononononoTakes back what you let an agent do without asking.
chat.forkyesyesnonoyesyesno
chat.moveyesnonononononoMoves a conversation, with everything in it, to another space.
chat.notesyesyesnonoyesyesnoThe notes beside a chat shared outside its space, made the first time.
chat.openyesyesnonoyesyesnoOpens an empty chat in a space.
chat.renameyesnonononononoRenames a conversation.
chat.sendyesnoyesnoyesyesno
chat.stopyesyesnonoyesyesnoStops agents' turns in a conversation (and its subthreads).
chat.unmarknonononononoyesTakes the old marks off messages: each goes where only those who could read it see it.
chat.welcomedyesnonononononoMarks that you've seen the app's welcome.

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.

Agents act through its 2 tools, as whoever they work for:

ToolWhat it doesCalls
list_conversationsList the other conversations in this space, latest first: each one's id, how it opened, where it is now, and how many messages it has.
read_conversationRead what was said in another conversation (by its id, from list_conversations): its messages, oldest first, the latest limit of them, or those before before (a time from a previous read) to go further back.

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.
  • Agents' tools: list_conversations, read_conversation.
  • 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.66.

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.
  • chat.unmark calls chat.unmark, once, when the runtime first starts with it. Takes the old marks off messages: each goes where only those who could read it see it.
  • 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.