@retainer/cli 0.1.0 → 0.2.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.
@@ -0,0 +1,40 @@
1
+ import type { RetainerClient } from '@retainer/sdk';
2
+ export type RenderState = {
3
+ color: boolean;
4
+ /** What the last write ended with, so blocks start on their own line. */
5
+ at: 'start' | 'text' | 'reasoning' | 'line';
6
+ toolNames: Map<string, string>;
7
+ /** How the turn ended, from the stream. */
8
+ ended?: {
9
+ status: string;
10
+ code: string | null;
11
+ };
12
+ text: string;
13
+ };
14
+ export declare function renderState(color: boolean): RenderState;
15
+ /** What one UI message stream chunk prints, given what came before. */
16
+ export declare function renderChunk(state: RenderState, chunk: Record<string, unknown>): string;
17
+ /** Reads an SSE response into UI message stream chunks. */
18
+ export declare function sseChunks(body: ReadableStream<Uint8Array>): AsyncGenerator<Record<string, unknown>>;
19
+ export type ChatIo = {
20
+ write: (text: string) => void;
21
+ color: boolean;
22
+ /** Called with each chunk as JSON instead of rendering it (--json). */
23
+ json?: (chunk: Record<string, unknown>) => void;
24
+ };
25
+ /** Sends one message and renders the turn. Returns how it ended. */
26
+ export declare function sendMessage(api: RetainerClient, chatId: string, text: string, io: ChatIo, options?: {
27
+ signal?: AbortSignal;
28
+ fetch?: typeof fetch;
29
+ }): Promise<{
30
+ status: string;
31
+ code: string | null;
32
+ text: string;
33
+ }>;
34
+ /** Why a turn didn't start, in plain words. */
35
+ export declare function startFailure(code: string): string;
36
+ /**
37
+ * The interactive loop: one line per message. Ctrl-C during a turn stops the
38
+ * turn (the chat stays); Ctrl-C or Ctrl-D at the prompt leaves.
39
+ */
40
+ export declare function interactiveChat(api: RetainerClient, chatId: string, io: ChatIo): Promise<number>;
@@ -0,0 +1,223 @@
1
+ import { createInterface } from 'node:readline/promises';
2
+ /**
3
+ * `retainer agent chat` (docs/specs/agent.md §6.7): a chat with the workspace
4
+ * agent in the terminal. Reasoning is dimmed, tool calls and results are
5
+ * short lines. A CLI chat reads by default; the agent writes only while this
6
+ * login is elevated in the workspace.
7
+ */
8
+ const dim = (text, color) => (color ? `\x1b[2m${text}\x1b[22m` : text);
9
+ const short = (value, max = 80) => {
10
+ const text = typeof value === 'string' ? value : JSON.stringify(value);
11
+ if (text === undefined)
12
+ return '';
13
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
14
+ };
15
+ export function renderState(color) {
16
+ return { color, at: 'start', toolNames: new Map(), text: '' };
17
+ }
18
+ /** Turn-end statuses, in plain words (spec §3.4, §5.5, §10). */
19
+ const ENDINGS = {
20
+ refused: 'The agent declined to answer this.',
21
+ incomplete: 'The answer was cut short.',
22
+ context_limit_reached: 'This chat is too long to continue. Start a new chat.',
23
+ history_rejected: 'This chat can no longer continue. Start a new chat.',
24
+ model_unavailable: 'The model is unavailable right now. Send your message again shortly.',
25
+ limit_reached: 'The agent reached its limit for this turn or today.',
26
+ cancelled: 'Stopped.',
27
+ timed_out: 'The turn ran out of time.',
28
+ failed: 'Something went wrong in this turn.',
29
+ };
30
+ /** How a `data-turn-end` chunk says the turn ended. */
31
+ function turnEnd(chunk) {
32
+ const data = chunk.data;
33
+ return { status: data?.status ?? 'failed', code: data?.code ?? null };
34
+ }
35
+ /** What one UI message stream chunk prints, given what came before. */
36
+ export function renderChunk(state, chunk) {
37
+ const line = (text) => {
38
+ const prefix = state.at === 'start' || state.at === 'line' ? '' : '\n';
39
+ state.at = 'line';
40
+ return `${prefix}${text}\n`;
41
+ };
42
+ switch (chunk.type) {
43
+ case 'reasoning-delta': {
44
+ const delta = String(chunk.delta ?? '');
45
+ if (!delta)
46
+ return '';
47
+ const prefix = state.at === 'reasoning' || state.at === 'start' || state.at === 'line' ? '' : '\n';
48
+ state.at = 'reasoning';
49
+ return prefix + dim(delta, state.color);
50
+ }
51
+ case 'text-delta': {
52
+ const delta = String(chunk.delta ?? '');
53
+ if (!delta)
54
+ return '';
55
+ const prefix = state.at === 'text' || state.at === 'start' || state.at === 'line' ? '' : '\n\n';
56
+ state.at = 'text';
57
+ state.text += delta;
58
+ return prefix + delta;
59
+ }
60
+ case 'tool-input-start':
61
+ state.toolNames.set(String(chunk.toolCallId), String(chunk.toolName));
62
+ return '';
63
+ case 'tool-input-available':
64
+ state.toolNames.set(String(chunk.toolCallId), String(chunk.toolName));
65
+ return line(dim(`→ ${chunk.toolName} ${short(chunk.input)}`, state.color));
66
+ case 'tool-output-available': {
67
+ const name = state.toolNames.get(String(chunk.toolCallId)) ?? 'tool';
68
+ const output = chunk.output;
69
+ if (name === 'prepare_build' && output?.draftId && (output.previewUrl || output.previewPath))
70
+ return line(`Draft ${output.draftId}\nPreview in Retainer: ${output.previewUrl ?? output.previewPath}`);
71
+ if ((name === 'prepare_routine_run' || name === 'prepare_enrollment') &&
72
+ output?.actionId &&
73
+ (output.previewUrl || output.previewPath))
74
+ return line(`Review in Retainer: ${output.previewUrl ?? output.previewPath}`);
75
+ const error = output && typeof output === 'object' ? output.error : undefined;
76
+ return line(dim(error?.code ? `← ${name} error: ${error.code}` : `← ${name} ${short(chunk.output, 60)}`, state.color));
77
+ }
78
+ case 'tool-output-error': {
79
+ const name = state.toolNames.get(String(chunk.toolCallId)) ?? 'tool';
80
+ return line(dim(`← ${name} failed: ${short(chunk.errorText, 60)}`, state.color));
81
+ }
82
+ case 'error':
83
+ return line(`Error: ${short(chunk.errorText, 200)}`);
84
+ case 'data-turn-end': {
85
+ state.ended = turnEnd(chunk);
86
+ const { status } = state.ended;
87
+ return line(ENDINGS[status] ?? `The turn ended: ${status}.`);
88
+ }
89
+ default:
90
+ return '';
91
+ }
92
+ }
93
+ /** Reads an SSE response into UI message stream chunks. */
94
+ export async function* sseChunks(body) {
95
+ const decoder = new TextDecoder();
96
+ let buffer = '';
97
+ for await (const bytes of body) {
98
+ buffer += decoder.decode(bytes, { stream: true });
99
+ for (let end = buffer.indexOf('\n\n'); end !== -1; end = buffer.indexOf('\n\n')) {
100
+ const event = buffer.slice(0, end);
101
+ buffer = buffer.slice(end + 2);
102
+ const data = event
103
+ .split('\n')
104
+ .filter((l) => l.startsWith('data:'))
105
+ .map((l) => l.slice(5).trimStart())
106
+ .join('\n');
107
+ if (!data || data === '[DONE]')
108
+ continue;
109
+ try {
110
+ yield JSON.parse(data);
111
+ }
112
+ catch {
113
+ // A malformed event is skipped; the stream goes on.
114
+ }
115
+ }
116
+ }
117
+ }
118
+ /** Sends one message and renders the turn. Returns how it ended. */
119
+ export async function sendMessage(api, chatId, text, io, options = {}) {
120
+ const { token, streamUrl } = await api.agentChatToken(chatId, options.signal);
121
+ const response = await (options.fetch ?? fetch)(streamUrl, {
122
+ method: 'POST',
123
+ headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
124
+ body: JSON.stringify({ message: { parts: [{ type: 'text', text }] } }),
125
+ signal: options.signal,
126
+ redirect: 'error',
127
+ });
128
+ if (!response.ok || !response.body) {
129
+ let code = 'request_failed';
130
+ try {
131
+ const body = (await response.json());
132
+ code = body.code ?? body.error?.code ?? code;
133
+ }
134
+ catch { }
135
+ return { status: 'refused_to_start', code, text: '' };
136
+ }
137
+ const state = renderState(io.color);
138
+ let finished = false;
139
+ // How the turn ended is recorded whatever the output (--json included).
140
+ const emit = (chunk) => {
141
+ if (chunk.type === 'finish')
142
+ finished = true;
143
+ if (chunk.type === 'data-turn-end')
144
+ state.ended = turnEnd(chunk);
145
+ if (io.json)
146
+ io.json(chunk);
147
+ else
148
+ io.write(renderChunk(state, chunk));
149
+ };
150
+ for await (const chunk of sseChunks(response.body))
151
+ emit(chunk);
152
+ // A stream that ends without its `finish` was cut on the way (a proxy, a
153
+ // dropped connection): what arrived is never reported as a finished answer.
154
+ if (!finished && !state.ended)
155
+ emit({ type: 'data-turn-end', data: { status: 'incomplete', code: 'stream_cut' } });
156
+ if (!io.json && state.at !== 'start' && state.at !== 'line')
157
+ io.write('\n');
158
+ return { ...(state.ended ?? { status: 'completed', code: null }), text: state.text };
159
+ }
160
+ /** Why a turn didn't start, in plain words. */
161
+ export function startFailure(code) {
162
+ switch (code) {
163
+ case 'turn_running':
164
+ return 'The agent is still answering your last message.';
165
+ case 'turn_stopping':
166
+ return 'The last turn is still stopping. Try again in a few seconds.';
167
+ case 'limit_reached':
168
+ return "You've reached today's agent limit.";
169
+ case 'agent_unavailable':
170
+ return 'The agent is not available on this server.';
171
+ default:
172
+ return `The message could not be sent (${code}).`;
173
+ }
174
+ }
175
+ /**
176
+ * The interactive loop: one line per message. Ctrl-C during a turn stops the
177
+ * turn (the chat stays); Ctrl-C or Ctrl-D at the prompt leaves.
178
+ */
179
+ export async function interactiveChat(api, chatId, io) {
180
+ const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: true });
181
+ let turn;
182
+ const onSigint = () => {
183
+ if (turn) {
184
+ turn.abort();
185
+ void api.cancelAgentChat(chatId).catch(() => { });
186
+ }
187
+ else
188
+ rl.close();
189
+ };
190
+ rl.on('SIGINT', onSigint);
191
+ io.write(dim('Chat with the Retainer agent. Ctrl-C stops a turn; Ctrl-D leaves.\n', io.color));
192
+ try {
193
+ for (;;) {
194
+ let text;
195
+ try {
196
+ text = (await rl.question('> ')).trim();
197
+ }
198
+ catch {
199
+ return 0;
200
+ }
201
+ if (!text)
202
+ continue;
203
+ turn = new AbortController();
204
+ try {
205
+ const result = await sendMessage(api, chatId, text, io, { signal: turn.signal });
206
+ if (result.status === 'refused_to_start')
207
+ io.write(`${startFailure(result.code ?? '')}\n`);
208
+ }
209
+ catch (error) {
210
+ if (!turn.signal.aborted)
211
+ throw error;
212
+ io.write('\nStopped.\n');
213
+ }
214
+ finally {
215
+ turn = undefined;
216
+ }
217
+ }
218
+ }
219
+ finally {
220
+ rl.close();
221
+ }
222
+ }
223
+ //# sourceMappingURL=agent-chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../src/agent-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;GAKG;AAEH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,EAAE,CAAC,CAAC;gBACjF,IAAI,MAAM,CAAC,MAAM,KAAK,kBAAkB;oBAAE,EAAE,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;YAC7F,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;oBAAE,MAAM,KAAK,CAAC;gBACtC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC3B,CAAC;oBAAS,CAAC;gBACT,IAAI,GAAG,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare const commandGroups: readonly [{
2
+ readonly title: 'Sign-in and workspace selection';
3
+ readonly commands: readonly [readonly ['login', '[--server <url>]', 'Person · browser consent', 'login --server https://retainer.tamloot.cc'], readonly ['wait', '<id>', 'Person · waits for a response', 'wait 01900000-0000-7000-8000-000000000000'], readonly ['logout', '', 'Person · ends this login', 'logout'], readonly ['whoami', '', 'Person · read', 'whoami'], readonly ['elevate', '[--workspace <w> | --org <o>] [--minutes <n>] [--reason <text>] | --end', 'Workspace or organization · browser approval to start', 'elevate --workspace sales --reason "review duplicate deals"'], readonly ['workspaces', '', 'Person · read', 'workspaces'], readonly ['use', '<workspace>', 'Workspace · saves default on this machine', 'use sales']];
4
+ }, {
5
+ readonly title: 'Workspace administration';
6
+ readonly commands: readonly [readonly ['workspace create', '<name> [--org <o>] [--template <t>]', 'Organization · elevation', 'workspace create Support --org acme'], readonly ['workspace rename', '<name>', 'Workspace · elevation', 'workspace rename "Customer Support" --workspace support'], readonly ['workspace delete', '<workspace> [--approval <id>]', 'Workspace · click each time', 'workspace delete sandbox'], readonly ['mcp-address', '[<workspace>]', 'Workspace · read', 'mcp-address sales']];
7
+ }, {
8
+ readonly title: 'Members, keys, and connections';
9
+ readonly commands: readonly [readonly ['members', '', 'Workspace · read', 'members --workspace sales'], readonly ['invite', '<email> [--org <o>] [--org-role <member|admin|owner>] [--workspace <w> --role <viewer|editor|admin>]… [--approval <id>]', 'Organization · elevation, owner invitation needs a click', 'invite ben@example.com --org acme --workspace sales --role editor'], readonly ['invitations', '[--org <o>]', 'Organization · read', 'invitations --org acme'], readonly ['invitation revoke', '<id> [--org <o>]', 'Organization · elevation', 'invitation revoke <id> --org acme'], readonly ['role', '<email> --workspace <w> <viewer|editor|admin> | --org <o> <member|admin|owner>', 'Workspace or organization · elevation, owner changes need a click', 'role ben@example.com --workspace sales editor'], readonly ['remove', '<email> [--workspace <w> | --org <o>] [--approval <id>]', 'Workspace or organization · elevation, removing an owner needs a click', 'remove ben@example.com --workspace sales'], readonly ['keys', '', 'Workspace · read', 'keys --workspace sales'], readonly ['key create', '<name> --access <read|write|schema> [--approval <id>]', 'Workspace · click each time', 'key create "Inbox agent" --access read --workspace sales'], readonly ['key revoke', '<id>', 'Workspace · elevation', 'key revoke <id> --workspace sales'], readonly ['connections', '[--workspace <w>]', 'Person or workspace · read', 'connections'], readonly ['disconnect', '<id>', 'Workspace · elevation', 'disconnect <id> --workspace sales']];
10
+ }, {
11
+ readonly title: 'Review and schema changes';
12
+ readonly commands: readonly [readonly ['review', '', 'Person or workspace · read', 'review --workspace sales'], readonly ['review show', '<id>', 'Person or workspace · read', 'review show <id>'], readonly ['duplicates merge', '<suggestion> --keep <record>', 'Workspace · elevation', 'duplicates merge <suggestion> --keep <record> --workspace sales'], readonly ['duplicates dismiss', '<suggestion>', 'Workspace · elevation', 'duplicates dismiss <suggestion> --workspace sales'], readonly ['pending accept', '<id>', 'Workspace · elevation', 'pending accept <id> --workspace sales'], readonly ['pending reject', '<id>', 'Workspace · elevation', 'pending reject <id> --workspace sales'], readonly ['schema-changes', '', 'Workspace · read', 'schema-changes --workspace sales'], readonly ['schema-changes approve', '<id>', 'Workspace · elevation', 'schema-changes approve <id> --workspace sales'], readonly ['schema-changes reject', '<id>', 'Workspace · elevation', 'schema-changes reject <id> --workspace sales']];
13
+ }, {
14
+ readonly title: 'Extensions';
15
+ readonly commands: readonly [readonly ['extensions', '', 'Workspace · read', 'extensions --workspace sales'], readonly ['extension show', '<id>', 'Workspace · read', 'extension show <id> --workspace sales'], readonly ['extension install', '<name>', 'Workspace · finishes in the web app', 'extension install enrichment --workspace sales'], readonly ['extension configure', '<id>', 'Workspace · finishes in the web app', 'extension configure <id> --workspace sales'], readonly ['extension upgrade', '<id>', 'Workspace · finishes in the web app', 'extension upgrade <id> --workspace sales'], readonly ['extension disable', '<id>', 'Workspace · elevation', 'extension disable <id> --workspace sales'], readonly ['extension remove', '<id>', 'Workspace · elevation', 'extension remove <id> --workspace sales']];
16
+ }, {
17
+ readonly title: 'Workspace data';
18
+ readonly commands: readonly [readonly ['schema', '', 'Workspace · read', 'schema'], readonly ['search', '<query>', 'Workspace · read', 'search Acme'], readonly ['records query', '<object> [--file <path|->]', 'Workspace · read', 'records query deal --file filter.json'], readonly ['records aggregate', '<object> [--file <path|->]', 'Workspace · read', 'records aggregate deal'], readonly ['record show', '<id>', 'Workspace · read', 'record show <record>'], readonly ['record context', '<id|me|workspace>', 'Workspace · read', 'record context <record>'], readonly ['record timeline', '<id|me|workspace>', 'Workspace · read', 'record timeline <record>'], readonly ['record create', '<object> --file <path|->', 'Workspace · elevation', 'record create company --file record.json'], readonly ['record upsert', '<object> --file <path|->', 'Workspace · elevation', 'record upsert person --file record.json'], readonly ['record update', '<id> --file <path|->', 'Workspace · elevation', 'record update <record> --file patch.json'], readonly ['record delete', '<id>', 'Workspace · confirm in the web app', 'record delete <record>'], readonly ['record merge', '<keep-id> <merge-id>', 'Workspace · confirm in the web app', 'record merge <keep> <merge>'], readonly ['records delete-impact', '--record <id>…', 'Workspace · read', 'records delete-impact --record <record>'], readonly ['events query', '[--file <path|->]', 'Workspace · read', 'events query --file filter.json'], readonly ['event show', '<id>', 'Workspace · read', 'event show <event>'], readonly ['event content', '<id> [--after <id>]', 'Workspace · read', 'event content <event>'], readonly ['event log', '--file <path|->', 'Workspace · elevation', 'event log --file event.json'], readonly ['event link', '<id> --file <path|->', 'Workspace · elevation', 'event link <event> --file links.json'], readonly ['memory list', '<id|me|workspace> [--cursor <cursor>]', 'Workspace · read', 'memory list me'], readonly ['memory remember', '<id|me|workspace> --file <path|->', 'Workspace · elevation', 'memory remember workspace --file fact.json'], readonly ['views', '<object>', 'Workspace · read', 'views deal'], readonly ['view show', '<id>', 'Workspace · read', 'view show <view>'], readonly ['dashboards', '', 'Workspace · read', 'dashboards'], readonly ['dashboard show', '<id>', 'Workspace · read', 'dashboard show <dashboard>']];
19
+ }, {
20
+ readonly title: 'Prepared builds';
21
+ readonly commands: readonly [readonly ['build prepare', '--file <path|->', 'Workspace · review and keep in the web app', 'build prepare --file view.json'], readonly ['build status', '<draft-id>', 'Workspace · read', 'build status <draft-id>']];
22
+ }, {
23
+ readonly title: 'Routines and workspace agent';
24
+ readonly commands: readonly [readonly ['routines', '', 'Workspace · read', 'routines --workspace sales'], readonly ['routine capabilities', '', 'Workspace · read', 'routine capabilities'], readonly ['routine validate', '--file <path|->', 'Workspace · type-check a routine', 'routine validate --file source.json'], readonly ['routine check-status', '<job-id>', 'Workspace · read', 'routine check-status <job>'], readonly ['routine preview', '--file <path|->', 'Workspace · dry-run a routine', 'routine preview --file source.json'], readonly ['routine preview-status', '<preview-id>', 'Workspace · read', 'routine preview-status <preview>'], readonly ['routine propose', '--file <path|->', 'Workspace · elevation, submits an inactive proposal', 'routine propose --file proposal.json'], readonly ['routine show', '<id>', 'Workspace · read', 'routine show <routine>'], readonly ['routine run-show', '<routine> <run>', 'Workspace · read', 'routine run-show <routine> <run>'], readonly ['routine run', '<id> --record <id>… [--execute --expected-version <id> --idempotency-key <key>]', 'Workspace · review in the web app or execute with elevation', 'routine run <routine> --record <record>'], readonly ['enrollment start', '<routine> --record <id>… --file <path|-> [--execute --expected-version <id> --idempotency-key <key>]', 'Workspace · review in the web app or execute with elevation', 'enrollment start <routine> --record <record> --file input.json'], readonly ['enrollment list', '--routine <id> | --record <id>', 'Workspace · read', 'enrollment list --routine <routine>'], readonly ['enrollment show', '<id>', 'Workspace · read', 'enrollment show <id>'], readonly ['enrollment stop', '<id>', 'Workspace · elevation', 'enrollment stop <id>'], readonly ['routine approve', '<id> <version>', 'Workspace · finishes in the web app', 'routine approve <routine> <version> --workspace sales'], readonly ['routine reject', '<id> <version>', 'Workspace · elevation', 'routine reject <routine> <version> --workspace sales'], readonly ['agent chat', '[<chat>] [--message <text>]', 'Workspace · read; the agent writes while this login is elevated', 'agent chat --workspace sales'], readonly ['routine pause', '<id>', 'Workspace · elevation', 'routine pause <routine> --workspace sales'], readonly ['routine resume', '<id>', 'Workspace · elevation if the existing approval is still valid', 'routine resume <routine> --workspace sales']];
25
+ }];