@almyty/chat 0.2.0 → 1.3.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 +168 -25
- package/dist/app.d.ts +12 -2
- package/dist/app.js +448 -159
- package/dist/args.d.ts +64 -0
- package/dist/args.js +207 -0
- package/dist/commands.d.ts +41 -1
- package/dist/commands.js +91 -2
- package/dist/components.d.ts +33 -9
- package/dist/components.js +42 -26
- package/dist/errors.d.ts +49 -0
- package/dist/errors.js +144 -0
- package/dist/exit-codes.d.ts +32 -0
- package/dist/exit-codes.js +65 -0
- package/dist/headless.d.ts +44 -0
- package/dist/headless.js +106 -0
- package/dist/history.d.ts +51 -0
- package/dist/history.js +146 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +112 -40
- package/dist/stream.d.ts +95 -0
- package/dist/stream.js +276 -0
- package/dist/turn.d.ts +53 -0
- package/dist/turn.js +147 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +27 -0
- package/dist/viewport.d.ts +61 -0
- package/dist/viewport.js +118 -0
- package/package.json +23 -7
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @almyty/chat
|
|
2
2
|
|
|
3
|
-
Interactive chat REPL for almyty agents
|
|
3
|
+
Interactive chat REPL for almyty agents, and the terminal client the
|
|
4
|
+
`/apps` **tui** build target compiles. Built with
|
|
5
|
+
[ink](https://github.com/vadimdemedes/ink) (React for CLI).
|
|
4
6
|
|
|
5
7
|
## Quick start
|
|
6
8
|
|
|
@@ -12,38 +14,179 @@ $ npx @almyty/chat acme/support-bot
|
|
|
12
14
|
## Usage
|
|
13
15
|
|
|
14
16
|
```
|
|
15
|
-
|
|
16
|
-
npx @almyty/chat <org>/<agent-slug>
|
|
17
|
-
npx @almyty/chat <org>/<agent-slug> --resume <conversation-id>
|
|
18
|
-
npx @almyty/chat # interactive agent picker
|
|
19
|
-
|
|
20
|
-
Commands:
|
|
21
|
-
/agents browse and switch agents
|
|
22
|
-
/tools show available tools
|
|
23
|
-
/help show commands
|
|
24
|
-
/clear clear conversation
|
|
25
|
-
/quit exit (shows resume command)
|
|
17
|
+
almyty chat [<org>/<agent-slug>] [options]
|
|
26
18
|
```
|
|
27
19
|
|
|
20
|
+
With no agent reference it lists the agents you can reach and asks. A
|
|
21
|
+
bare slug uses the organization on your credentials.
|
|
22
|
+
|
|
23
|
+
### Options
|
|
24
|
+
|
|
25
|
+
| Option | What it does |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `-m, --message <text>` | Ask one question, print the answer, exit. |
|
|
28
|
+
| `--stdin` | Read the question from stdin, for pipes. |
|
|
29
|
+
| `--resume <id>` | Continue a previous conversation. |
|
|
30
|
+
| `--json` | One JSON object per answer. Implies non-interactive. |
|
|
31
|
+
| `--no-stream` | Wait for the whole answer instead of streaming it. |
|
|
32
|
+
| `--no-color` | Never colour the output. `NO_COLOR` is honoured too. |
|
|
33
|
+
| `--max-steps <n>` | Autonomous runs: cap the number of steps. |
|
|
34
|
+
| `--max-cost-cents <n>` | Autonomous runs: cap the spend, in cents. |
|
|
35
|
+
| `-h, --help` | Show the help. |
|
|
36
|
+
| `-v, --version` | Print the version. |
|
|
37
|
+
|
|
38
|
+
### Slash commands
|
|
39
|
+
|
|
40
|
+
| Command | What it does |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `/agents` | browse and switch agents |
|
|
43
|
+
| `/model` | show the model and routing policy in use |
|
|
44
|
+
| `/tools` | show available tools |
|
|
45
|
+
| `/cost` | show tokens and spend for this session |
|
|
46
|
+
| `/trace` | show the last run's steps |
|
|
47
|
+
| `/resume` | print the command that resumes this conversation |
|
|
48
|
+
| `/new` | start a fresh conversation with the same agent |
|
|
49
|
+
| `/runners` | list your runners + coding CLIs |
|
|
50
|
+
| `/code <task>` | run a coding task on a runner |
|
|
51
|
+
| `/code-stop` | stop the active coding session |
|
|
52
|
+
| `/esc` | leave coding mode (the session keeps running) |
|
|
53
|
+
| `/help` | show commands |
|
|
54
|
+
| `/clear` | clear the transcript on screen |
|
|
55
|
+
| `/quit` | exit |
|
|
56
|
+
|
|
57
|
+
Commands take unique prefixes and aliases: `/q` for `/quit`, `/sw` for
|
|
58
|
+
`/agents`, `/c` for `/clear`, `/r` for `/runners`. Tab completes.
|
|
59
|
+
|
|
60
|
+
`/clear` only clears what is on screen — the agent still has the
|
|
61
|
+
conversation. `/new` is the one that forgets.
|
|
62
|
+
|
|
63
|
+
`/runners` and `/code` dispatch coding tasks to a machine connected via
|
|
64
|
+
[`@almyty/runner`](https://www.npmjs.com/package/@almyty/runner).
|
|
65
|
+
|
|
66
|
+
### Keys
|
|
67
|
+
|
|
68
|
+
| Key | What it does |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `Ctrl-C` | Cancel the running answer, server-side too. Again to exit. |
|
|
71
|
+
| `Ctrl-D` | Exit. |
|
|
72
|
+
| `Enter` | Send. End a line with `\` to keep typing on the next one. |
|
|
73
|
+
| `↑` / `↓` | Walk your input history, across sessions. |
|
|
74
|
+
| `Tab` | Complete a slash command. |
|
|
75
|
+
|
|
76
|
+
## Non-interactive use
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# one question, one answer
|
|
80
|
+
almyty chat acme/support-bot -m "what is our refund window?"
|
|
81
|
+
|
|
82
|
+
# piped in
|
|
83
|
+
echo "summarise today's errors" | almyty chat acme/ops --stdin
|
|
84
|
+
|
|
85
|
+
# machine-readable, with the model, the cost and the ids to resume
|
|
86
|
+
almyty chat acme/ops -m "check the deploy" --json | jq -r .output
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The answer goes to stdout and the attribution line to stderr, so a pipe
|
|
90
|
+
stays clean. The exit code follows the table every almyty CLI shares:
|
|
91
|
+
|
|
92
|
+
| Code | Meaning |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| 0 | success |
|
|
95
|
+
| 1 | unexpected error |
|
|
96
|
+
| 2 | usage error (bad flags, unknown command) |
|
|
97
|
+
| 3 | not authenticated — run `npx @almyty/auth login` |
|
|
98
|
+
| 4 | not found (no such agent) |
|
|
99
|
+
| 5 | the run ran and failed |
|
|
100
|
+
|
|
101
|
+
So `almyty chat deploy-check -m "ok to ship?" && ./ship.sh` does not
|
|
102
|
+
ship on a failed answer, and `|| case $? in 3) ... ;; 5) ... ;; esac`
|
|
103
|
+
can tell a missing login from a failed run.
|
|
104
|
+
|
|
105
|
+
`--json` prints one object:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"status": "completed",
|
|
110
|
+
"output": "...",
|
|
111
|
+
"agent": { "id": "...", "name": "Ops", "slug": "ops", "mode": "autonomous" },
|
|
112
|
+
"model": "claude-sonnet-4",
|
|
113
|
+
"routing": { "model": "claude-sonnet-4", "rationale": "cheapest", "attempt": 1 },
|
|
114
|
+
"usage": { "cost": 0.0042, "tokens": 1284, "steps": 3 },
|
|
115
|
+
"runId": "...",
|
|
116
|
+
"conversationId": "..."
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## What you see while it runs
|
|
121
|
+
|
|
122
|
+
- **Tokens as they arrive.** Autonomous runs stream over SSE and the
|
|
123
|
+
answer is drawn as it is generated, not once the run has finished.
|
|
124
|
+
- **Tool calls, as they happen.** Each tool is announced when it starts
|
|
125
|
+
and marked ok or failed with its duration when it returns.
|
|
126
|
+
- **Pipeline nodes.** A workflow agent's graph is streamed node by node,
|
|
127
|
+
so a multi-node run is not a silent spinner.
|
|
128
|
+
- **Who answered and what it cost.** Every turn ends with the answering
|
|
129
|
+
model, the tokens and the spend; `/cost` totals the session.
|
|
130
|
+
- **A cancel that means it.** `Ctrl-C` cancels the run on the server
|
|
131
|
+
rather than killing the client and leaving the run spending money.
|
|
132
|
+
|
|
28
133
|
## Features
|
|
29
134
|
|
|
30
|
-
- **Gateway routing**
|
|
31
|
-
- **Resume conversations**
|
|
32
|
-
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
|
|
36
|
-
- **
|
|
37
|
-
|
|
135
|
+
- **Gateway routing** — agents addressed as `<org>/<agent-slug>`
|
|
136
|
+
- **Resume conversations** — `--resume <conversation-id>` picks up where
|
|
137
|
+
you left off; `/resume` and `/quit` print the command
|
|
138
|
+
- **Arrow-key agent picker** — run without arguments to browse and select
|
|
139
|
+
- **Slash commands** — tab autocomplete with fuzzy prefix matching, and
|
|
140
|
+
a command palette you can arrow through
|
|
141
|
+
- **Input history** — kept in `~/.almyty/chat-history`, so up-arrow
|
|
142
|
+
works in a fresh session and survives `/clear`
|
|
143
|
+
- **Markdown rendering** — bold, inline code, code blocks, lists, headers
|
|
144
|
+
- **Actionable errors** — a draft agent, a retired model, a spend cap and
|
|
145
|
+
an unreachable API each say what happened and what to do about it
|
|
146
|
+
- **Bounded to your terminal** — the transcript is drawn to fit, down to
|
|
147
|
+
a 40-column window, and redrawn on resize
|
|
148
|
+
|
|
149
|
+
### Not there yet
|
|
150
|
+
|
|
151
|
+
- The prompt is one line. A paragraph goes in with a trailing `\` per
|
|
152
|
+
line; there is no in-place multi-line editor, and no scrollback
|
|
153
|
+
keybinding for the transcript above the window.
|
|
154
|
+
- Only the tool-calling step of an autonomous run records which model
|
|
155
|
+
answered, so a single-step reply shows the cost without the model.
|
|
38
156
|
|
|
39
157
|
## Authentication
|
|
40
158
|
|
|
41
|
-
Requires `npx @almyty/auth login` first. Reads credentials from
|
|
159
|
+
Requires `npx @almyty/auth login` first. Reads credentials from
|
|
160
|
+
`~/.almyty/credentials.json`.
|
|
161
|
+
|
|
162
|
+
| Variable | What it does |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `ALMYTY_TOKEN` | Token override, instead of the credentials file. |
|
|
165
|
+
| `ALMYTY_URL` | API URL override. |
|
|
166
|
+
| `ALMYTY_AGENT` | Default agent reference, used when none is given. |
|
|
167
|
+
| `ALMYTY_APP_URL` | Dashboard URL used in error messages. |
|
|
168
|
+
| `ALMYTY_CHAT_HISTORY` | Input history file, instead of the default. |
|
|
169
|
+
| `NO_COLOR` | Set to anything to disable colour. |
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm run dev # tsx src/index.tsx
|
|
175
|
+
npm test # vitest
|
|
176
|
+
npm run typecheck # tsc --noEmit
|
|
177
|
+
npm run build # tsc, then chmod +x dist/index.js
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## About almyty
|
|
42
181
|
|
|
43
|
-
|
|
182
|
+
almyty is the full-stack platform for AI agents, agnostic by design: any LLM, any
|
|
183
|
+
API turned into tools, served over MCP, A2A, UTCP, and Agent Skills. Open source,
|
|
184
|
+
no lock-in.
|
|
44
185
|
|
|
45
|
-
https://almyty.com
|
|
186
|
+
- Website: https://almyty.com
|
|
187
|
+
- Docs: https://docs.almyty.com
|
|
188
|
+
- Source: https://github.com/almyty-inc/almyty
|
|
46
189
|
|
|
47
|
-
|
|
190
|
+
This CLI is part of the `@almyty/*` suite (versioned together at 1.x) and works with the almyty platform 0.1 and later.
|
|
48
191
|
|
|
49
|
-
|
|
192
|
+
Apache-2.0 © Almyty Inc.
|
package/dist/app.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { AlmytyClient, GatewayClient, AgentInfo } from '@almyty/client';
|
|
2
3
|
import type { Message } from './components.js';
|
|
4
|
+
import { type ErrorContext } from './errors.js';
|
|
3
5
|
export interface AppState {
|
|
4
6
|
agent: AgentInfo;
|
|
5
7
|
messages: Message[];
|
|
@@ -8,10 +10,18 @@ export interface AppState {
|
|
|
8
10
|
conversationId: string | null;
|
|
9
11
|
pendingRunId: string | null;
|
|
10
12
|
}
|
|
13
|
+
/** Active coding session driven from the REPL (chat-to-runner bridge). */
|
|
14
|
+
export interface CodingSessionState {
|
|
15
|
+
runnerId: string;
|
|
16
|
+
runnerName: string;
|
|
17
|
+
agent: string;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
}
|
|
11
20
|
export declare let exitMessage: string;
|
|
12
|
-
export declare function ChatApp({ client, initialAgent, gw, resumeConversationId }: {
|
|
21
|
+
export declare function ChatApp({ client, initialAgent, gw, resumeConversationId, errorContext }: {
|
|
13
22
|
client: AlmytyClient;
|
|
14
23
|
initialAgent: AgentInfo;
|
|
15
24
|
gw: GatewayClient;
|
|
16
25
|
resumeConversationId?: string;
|
|
17
|
-
|
|
26
|
+
errorContext?: ErrorContext;
|
|
27
|
+
}): React.JSX.Element;
|