@operad-io/chat 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,96 +1,13 @@
1
- # `@operad-io/chat`
1
+ # @operad-io/chat
2
2
 
3
- The `chat` plugin: a long conversation with an agent, and how a message is
4
- answered. It comes with operad. It knows nothing of repositories or bots:
5
- the plugin that opens a chat gives every field (`createChat`).
3
+ **The chat plugin.** A long conversation with an agent, and how a message is answered. It comes with operad.
6
4
 
7
- ## The object
5
+ This package is part of [operad](https://github.com/operad-io/operad). Most people install only [`@operad-io/cli`](https://www.npmjs.com/package/@operad-io/cli).
8
6
 
9
- A chat has a parent (a full object id), an agent (the name of a harness plugin,
10
- fixed once the chat exists), a working directory, an access profile, skills, a
11
- title, the agent's own session reference (never shown), bound channels, and
12
- whether it is closed. Its ids are `C-0001` upward. Messages are not fields: each
13
- is a `chat.message` fact on the chat (who, when, text, attachment paths, the
14
- source and its reference). An assistant message also names the messages it answers
15
- (`replyTo`), the run it belongs to (`runId`) and the session after it. Closing a
16
- chat appends a `chat.closed` fact and marks the object closed; the messages stay
17
- in its transcript.
7
+ ## Documentation
18
8
 
19
- What the agent did during an answer is recorded too, as `chat.entry` facts with
20
- the same `runId` as the reply: intermediate text, thinking, a tool call (its call
21
- id, name, input summary, result, start, duration, the first 4 KB of its output,
22
- the file holding the whole output and the first line of an error) and the
23
- half-written reply of a run that was stopped. Increments are not stored. Output
24
- longer than 4 KB goes to a file under the chat's own directory (under
25
- `attachments/chat/<id>/tool-output/`), and secret values are masked before a
26
- fact or a file is written. A rerun skips a tool call whose id was already recorded and does not add
27
- the same unfinished text again.
9
+ - User guide: [docs/user/chats-and-bots.md](https://github.com/operad-io/operad/blob/main/docs/user/chats-and-bots.md)
10
+ - Website: <https://operad.io>
11
+ - Developer reference: `REFERENCE.md` in this directory
28
12
 
29
- Each reply run also records a `chat.run` fact with its run id, so the transcript
30
- can find the log of the step that runs the agent. While that run lasts, the
31
- `transcript` section returns a `tail`: the text and thinking being written and
32
- the tool calls that started and did not end, read from the appended part of that
33
- log, with secrets masked. It also returns `mark`, and a read with `after: <mark>`
34
- returns only what was recorded later.
35
-
36
- ## `chat:send <chat> --note <text>`
37
-
38
- Records the message and sends the event `message` from the source named by the
39
- client (`ios`, `telegram`, `cli`; any other client counts as `cli`), keyed by the
40
- message id and about the chat. Three default rules start `chat:reply` with `auto`
41
- on that event. A closed chat refuses the action and adds no message.
42
-
43
- ## `chat:model <chat> --model <name>`
44
-
45
- Changes the model the chat's next reply uses. The argument is one of the models the chat's agent lists (its plugin declares them); a closed chat, or an agent that lists none, does not offer the action. A `chat.model` fact records who changed it, from what and to what. A chat whose model its agent cannot take fails the reply with a message naming the model; it never falls back to another one.
46
-
47
- ## `chat:effort <chat> --effort <level>`
48
-
49
- Changes the effort the chat's next reply uses. The argument is one of the levels the chat's agent lists (its plugin declares them; pi's thinking levels are its efforts); a closed chat, or an agent that lists none, does not offer the action. A `chat.effort` fact records who changed it, from what and to what. A chat whose effort its agent cannot take fails the reply with a message naming it; it never falls back to another one. The row shows the effort when it is not the agent's default.
50
-
51
- ## `chat:close <chat>`
52
-
53
- Asks for confirmation and records a `chat.closed` fact naming who closed it. A
54
- closed chat's row reads `closed` and is final; it offers no actions, and a
55
- message is refused with a short line saying the chat is closed. The transcript
56
- stays readable. Chats have the filters `open` (the default) and `closed`, with
57
- the kernel's `all` after `open`, so lists hide closed chats unless asked.
58
-
59
- ## `chat:reply`
60
-
61
- One step, `chat/reply`, and a loop in the flow. The step builds the prompt from
62
- the unanswered messages in the facts (never from the event), continues the
63
- chat's session, records the reply as a fact before it counts as done, updates the
64
- session reference and looks again for messages that arrived meanwhile: if there
65
- are some its result is `more` and the flow runs it again. The flow's `maxVisits`
66
- (20) ends a loop that never catches up. A question that ran out of grace ends the
67
- step `waiting`; the answer comes back with the session.
68
-
69
- The agent gets `operadTools: { home }`, so it calls operad through MCP tools and
70
- never through a shell.
71
-
72
- In a chat whose access profile is `readOnly`, an agent question about a
73
- command, a write or an edit becomes the worktree question (`yes`/`no`) and
74
- never a one-time permission. The question names the call: the command, or the
75
- path and whether it is a write or an edit; a long command is cut, and the ask
76
- keeps the whole call. A `yes` sends the event `chat.worktree`; the plugin that
77
- owns the working directory acts on it (`dev` opens `work/chat-<id>`). A `no`
78
- tells the agent the call was refused because the chat is read-only, and that it
79
- should answer in the chat or use read-only commands.
80
-
81
- ## The `transcript` section
82
-
83
- A live section that pages over the message and entry facts, so the command line,
84
- the TUI and the app show a chat with no client change. A turn's entries show
85
- before its reply: one line per tool call with what ran and how long it took, how
86
- a failed, blocked or denied call ended, the agent's text with its speaker, and
87
- thinking as a block quote. Tool output is not shown. Radian chats show the tool
88
- lines only. Pages count messages, and a turn's entries stay on the page of its
89
- reply.
90
-
91
- ## The speaker
92
-
93
- The transcript labels the model's messages with a speaker name, read each time
94
- it is drawn: `plugins.chat.settings.speaker`, `Operad Bot` when not set. A
95
- chat's parent object may carry a `speaker` of its own (a bot does), and that
96
- name is used instead. Messages already recorded get a changed name too.
13
+ MIT licensed.
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@operad-io/chat",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
7
7
  },
8
8
  "dependencies": {
9
- "@operad-io/engine": "0.0.1",
10
- "@operad-io/harness-process": "0.0.1"
9
+ "@operad-io/engine": "0.1.0",
10
+ "@operad-io/harness-process": "0.1.0"
11
11
  },
12
- "description": "operad: the chat plugin (in development)",
12
+ "description": "operad: the chat plugin",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/operad-io/operad.git",
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** The chat plugin: a long conversation with an agent, and how a message is answered. */
2
2
 
3
+ import pkg from "../package.json" with { type: "json" };
3
4
  import { defineFlow, definePlugin, type ActionArgsSchema, type ActionContext, type ActionTypeDefinition } from "@operad-io/engine";
4
5
  import {
5
6
  CHAT_FILTERS,
@@ -320,7 +321,7 @@ export function createChatPlugin() {
320
321
  return definePlugin({
321
322
  name: "chat",
322
323
  kind: "domain",
323
- version: "0.0.0",
324
+ version: pkg.version,
324
325
  objects: [{ name: CHAT_TYPE, index: ["parent"], filters: CHAT_FILTERS }],
325
326
  settings: {
326
327
  type: "object",