@yanzc/claude-pro 0.7.1 → 0.7.3
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/.env.example +24 -36
- package/README.md +317 -372
- package/package.json +2 -2
- package/src/agent.js +14 -2
- package/src/api.js +40 -173
- package/src/attach.js +14 -0
- package/src/background.js +102 -12
- package/src/checkpoints.js +4 -2
- package/src/commands.js +20 -85
- package/src/config.js +40 -151
- package/src/gateway.js +9 -3
- package/src/history.js +69 -0
- package/src/host.js +71 -14
- package/src/main.js +19 -2
- package/src/peers.js +3 -6
- package/src/print.js +1 -1
- package/src/prompts.js +1 -4
- package/src/ratelimit.js +6 -19
- package/src/remote.js +6 -40
- package/src/runtime.js +4 -2
- package/src/tools/peers.js +5 -9
- package/src/ui/repl.js +43 -215
- package/src/claude-code.js +0 -60
- package/src/codex/client.js +0 -310
- package/src/codex/translate-request.js +0 -239
- package/src/codex/translate-stream.js +0 -328
- package/src/oauth.js +0 -287
- package/src/transfer.js +0 -260
- package/src/utils/downloads.js +0 -83
package/src/main.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { VERSION, KNOWN_KEYS, loadConfig, settingsFiles, updateSettingsFile, applyRememberedChoices } from './config.js';
|
|
3
|
+
import { resolvePath } from './utils/paths.js';
|
|
3
4
|
import { SessionStore } from './session.js';
|
|
4
5
|
import { takeRestartState } from './restart.js';
|
|
5
6
|
|
|
6
7
|
const HELP = `Usage: claude-pro [options] [prompt]
|
|
7
8
|
|
|
8
|
-
A
|
|
9
|
+
A command line coding agent using the codex-gateway.
|
|
9
10
|
Starts an interactive session by default; use -p for non-interactive output.
|
|
10
11
|
|
|
11
12
|
Options:
|
|
12
13
|
-p, --print Print the response and exit (useful for pipes)
|
|
13
14
|
-c, --continue Continue the most recent conversation in this directory
|
|
14
15
|
-r, --resume [sessionId] Resume a conversation (picker if no id given)
|
|
15
|
-
--provider <backend>
|
|
16
|
+
--provider <backend> gateway only (the codex-gateway account)
|
|
16
17
|
--model <model> Model for this session (name or alias: opus, sonnet, haiku)
|
|
17
18
|
--effort <level> Reasoning effort: none|minimal|low|medium|high|xhigh|max
|
|
18
19
|
--output-format <format> text | json | stream-json (with --print)
|
|
19
20
|
--verify <command> After the agent edits files, run this (e.g. "npm test") and send failures back to fix
|
|
20
21
|
--append-system-prompt <text> Append text to the system prompt
|
|
21
22
|
--system-prompt <text> Replace the system prompt
|
|
23
|
+
--system-prompt-file <file> Replace the system prompt with the contents of a file
|
|
22
24
|
--verbose Show thinking and full tool output
|
|
23
25
|
--no-mcp Do not start MCP servers
|
|
24
26
|
--name <name> Name this session, as /rename does (other sessions reach it with &name)
|
|
@@ -78,6 +80,7 @@ function parseArgs(argv) {
|
|
|
78
80
|
case '--verify': flags.verify = next(); break;
|
|
79
81
|
case '--append-system-prompt': flags.appendSystemPrompt = next(); break;
|
|
80
82
|
case '--system-prompt': flags.systemPrompt = next(); break;
|
|
83
|
+
case '--system-prompt-file': flags.systemPromptFile = next(); break;
|
|
81
84
|
case '--verbose': flags.verbose = true; break;
|
|
82
85
|
case '--no-mcp': flags.noMcp = true; break;
|
|
83
86
|
case '--remote-control': case '--rc': break; // online by default now
|
|
@@ -175,6 +178,20 @@ export async function main(argv) {
|
|
|
175
178
|
if (flags.version) { console.log(`${VERSION} (claude-pro)`); return 0; }
|
|
176
179
|
if (flags.help) { process.stdout.write(HELP); return 0; }
|
|
177
180
|
|
|
181
|
+
if (flags.systemPromptFile !== undefined) {
|
|
182
|
+
if (!flags.systemPromptFile || flags.systemPromptFile.startsWith('-')) {
|
|
183
|
+
process.stderr.write('--system-prompt-file requires a file path\n');
|
|
184
|
+
return 2;
|
|
185
|
+
}
|
|
186
|
+
const file = resolvePath(flags.systemPromptFile, cwd);
|
|
187
|
+
try {
|
|
188
|
+
flags.systemPrompt = fs.readFileSync(file, 'utf8');
|
|
189
|
+
} catch (e) {
|
|
190
|
+
process.stderr.write(`Cannot read system prompt file ${file}: ${e.message}\n`);
|
|
191
|
+
return 2;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
178
195
|
let prompt = positional.join(' ');
|
|
179
196
|
|
|
180
197
|
// Started by a restart of a running session: that session is picked up again, whatever the command line
|
package/src/peers.js
CHANGED
|
@@ -203,10 +203,7 @@ export class PeerNode {
|
|
|
203
203
|
if (typeof msg?.text !== 'string' || !msg.from?.name) return reply(400, { error: 'text and from are required' });
|
|
204
204
|
const id = crypto.randomBytes(4).toString('hex');
|
|
205
205
|
reply(200, { ok: true, id, name: this.name });
|
|
206
|
-
|
|
207
|
-
const files = (Array.isArray(msg.files) ? msg.files : []).filter((f) => f && typeof f.path === 'string' && path.isAbsolute(f.path))
|
|
208
|
-
.map((f) => ({ path: f.path, name: String(f.name || path.basename(f.path)), size: Number(f.size) || 0 }));
|
|
209
|
-
try { this.onMessage?.({ id, kind: msg.kind === 'reply' ? 'reply' : 'task', text: msg.text, inReplyTo: msg.inReplyTo || null, from: msg.from, ...(files.length ? { files } : {}) }); } catch { /* the receiver's problem */ }
|
|
206
|
+
try { this.onMessage?.({ id, kind: msg.kind === 'reply' ? 'reply' : 'task', text: msg.text, inReplyTo: msg.inReplyTo || null, from: msg.from }); } catch { /* the receiver's problem */ }
|
|
210
207
|
});
|
|
211
208
|
}
|
|
212
209
|
|
|
@@ -228,10 +225,10 @@ export class PeerNode {
|
|
|
228
225
|
}
|
|
229
226
|
|
|
230
227
|
// Send to a peer (an entry of peers(), or its name). Resolves with {id} (the id the receiver gave the message).
|
|
231
|
-
async send(target, { text, kind = 'task', inReplyTo = null
|
|
228
|
+
async send(target, { text, kind = 'task', inReplyTo = null }) {
|
|
232
229
|
const peer = typeof target === 'string' ? findPeer(this.peers(), target) : target;
|
|
233
230
|
if (!peer) throw new Error(`No running session called "${target}". /peers lists them.`);
|
|
234
|
-
const body = JSON.stringify({ kind, text, inReplyTo, from: { id: this.id, name: this.name, cwd: this.cwd }
|
|
231
|
+
const body = JSON.stringify({ kind, text, inReplyTo, from: { id: this.id, name: this.name, cwd: this.cwd } });
|
|
235
232
|
return await new Promise((resolve, reject) => {
|
|
236
233
|
const req = http.request({
|
|
237
234
|
host: '127.0.0.1', port: peer.port, path: '/message', method: 'POST', timeout: 10_000,
|
package/src/print.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function runPrint({ prompt, flags, cwd, stdout = process.stdout, st
|
|
|
17
17
|
return (ev) => {
|
|
18
18
|
if (ev.type === 'rate_limit_wait') {
|
|
19
19
|
if (shouldAnnounce(paused, ev)) err(c.yellow(who + describePause(ev)));
|
|
20
|
-
paused = { resumeAt: ev.resumeAt
|
|
20
|
+
paused = { resumeAt: ev.resumeAt };
|
|
21
21
|
}
|
|
22
22
|
if (ev.type === 'rate_limit_resume') {
|
|
23
23
|
paused = null;
|
package/src/prompts.js
CHANGED
|
@@ -50,10 +50,7 @@ export function mainSystemPrompt({ cwd, model, shellName, extra = '', autoMemory
|
|
|
50
50
|
? `\n\n# Memory\nProject and user instructions are shown below: the facts of this project (its environment, mechanisms, commands) and how the user wants to work in it. Where they differ from the defaults above, they win.\n\n${files}`
|
|
51
51
|
: '';
|
|
52
52
|
|
|
53
|
-
return `You are ${APP_NAME}, an interactive command line agent
|
|
54
|
-
|
|
55
|
-
IMPORTANT: Assist with authorized security testing, defensive security, CTF challenges, and educational contexts. Refuse requests for destructive techniques, DoS attacks, mass targeting, supply chain compromise, or detection evasion for malicious purposes. Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases.
|
|
56
|
-
Do not make up URLs. Give a URL only when it came from the user, a file or a tool result, or when you know it exists; when you are not sure of an address, look it up with WebSearch or say that you are not sure.
|
|
53
|
+
return `You are ${APP_NAME}, an interactive command line agent. You help the user with software engineering tasks (solving bugs, adding functionality, refactoring, explaining code, running builds and tests) and with anything else they ask that you can do with your knowledge and the tools on this machine. Use the instructions below and the tools available to you to assist the user.
|
|
57
54
|
|
|
58
55
|
# Communication
|
|
59
56
|
- Your output is shown in a terminal, rendered as GitHub-flavored markdown in a monospace font: keep it scannable.
|
package/src/ratelimit.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// Rate limits: reading when a limit resets from the response headers, deciding how long to wait
|
|
2
2
|
// before retrying, and the wording shown to the user.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// few quick retries used for transient errors.
|
|
4
|
+
// Gateway requests can be limited by rolling windows, 5 hours and 7 days. When one is used up the
|
|
5
|
+
// gateway answers 429, and the anthropic-ratelimit-unified-* headers say which window it was and when it
|
|
6
|
+
// resets (epoch seconds). Waiting for such a reset takes hours, so it is a pause that ends by itself
|
|
7
|
+
// rather than one of the few quick retries used for transient errors.
|
|
9
8
|
|
|
10
9
|
export const LONG_WAIT_MS = 30_000; // waits this long or longer are shown as "rate limit reached, resuming at ..."
|
|
11
10
|
export const MAX_RETRY_AFTER_MS = 5 * 60_000; // when waiting for limits is off, a longer Retry-After is reported instead
|
|
@@ -235,34 +234,22 @@ export function planRetry(err, state, config, { now = Date.now(), rand = Math.ra
|
|
|
235
234
|
|
|
236
235
|
// Words for the pause notice, shared by the interactive and the print mode.
|
|
237
236
|
export function describePause(ev, now = Date.now()) {
|
|
238
|
-
// The limit is over but the subscription login has expired meanwhile (its token lives 8 hours) and could
|
|
239
|
-
// not be renewed by this program: the request goes on as soon as there is a valid login in the file.
|
|
240
|
-
if (ev.waitingForLogin) {
|
|
241
|
-
const until = ev.giveUpAt ? ` Giving up at ${formatClock(ev.giveUpAt, now)}.` : '';
|
|
242
|
-
if (ev.renewError) return `The limit has reset, but the login could not be renewed: ${ev.renewError} Trying again every 5 minutes, and this continues by itself as soon as the login is valid.${until}`;
|
|
243
|
-
return `The limit has reset, but the Claude Code login has expired and cannot be renewed from here. Waiting for it to be renewed: run claude once, and this continues by itself.${until}`;
|
|
244
|
-
}
|
|
245
237
|
const label = capitalize(ev.label || 'rate limit');
|
|
246
238
|
const left = humanDuration(Math.max(0, ev.resumeAt - now));
|
|
247
239
|
if (ev.overloaded) return `The API is overloaded and kept refusing the request. Trying again at ${formatClock(ev.resumeAt, now)} (in ${left}), and every so often after that, then continuing automatically.`;
|
|
248
240
|
const text = ev.polling
|
|
249
241
|
? `${label} reached and the server gave no reset time. Checking again at ${formatClock(ev.resumeAt, now)} (in ${left}), and every few minutes after that, then continuing automatically.`
|
|
250
242
|
: `${label} reached. Pausing until ${formatClock(ev.resumeAt, now)} (in ${left}), then continuing automatically.`;
|
|
251
|
-
|
|
252
|
-
? ` The Claude Code login expires at ${formatClock(ev.loginExpiresAt, now)}, before that, and it cannot be renewed from here. If no Claude Code session is running to renew it, run claude once after the reset: this continues by itself once the login is valid again.`
|
|
253
|
-
: '';
|
|
254
|
-
return text + warning;
|
|
243
|
+
return text;
|
|
255
244
|
}
|
|
256
245
|
|
|
257
246
|
// Whether a rate_limit_wait event should be announced to the user. `prev` is the wait that was last
|
|
258
247
|
// announced for the same pause (null at the first one). Polling repeats every few minutes and the
|
|
259
248
|
// announced reset moves a little between waits: those only continue the pause already announced,
|
|
260
|
-
// unless the reset moved by more than two minutes.
|
|
261
|
-
// kind of wait from waiting for the limit, and always worth saying when it begins.
|
|
249
|
+
// unless the reset moved by more than two minutes.
|
|
262
250
|
export const resumeText = (ev) => (ev?.overloaded ? 'The API is answering again; continuing.' : 'The limit has cleared; continuing.');
|
|
263
251
|
|
|
264
252
|
export function shouldAnnounce(prev, ev) {
|
|
265
253
|
if (!prev) return true;
|
|
266
|
-
if (Boolean(prev.waitingForLogin) !== Boolean(ev.waitingForLogin)) return true;
|
|
267
254
|
return !ev.polling && Math.abs(ev.resumeAt - prev.resumeAt) > 120_000;
|
|
268
255
|
}
|
package/src/remote.js
CHANGED
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
// calls, other terminal output) that events update. The same reducer (applyEvent) runs here, to send a snapshot
|
|
10
10
|
// when one is needed, and in the page, which carries a copy of it.
|
|
11
11
|
|
|
12
|
-
import fs from 'node:fs';
|
|
13
12
|
import os from 'node:os';
|
|
14
13
|
import crypto from 'node:crypto';
|
|
15
14
|
import { stripAnsi } from './ui/ansi.js';
|
|
16
15
|
import { toolHeader, renderToolResult, bashModeLines } from './ui/render.js';
|
|
17
|
-
import { uploadFile, downloadFile } from './transfer.js';
|
|
18
16
|
|
|
19
17
|
export const REMOTE_WIDTH = 100; // columns that tool headers and results are laid out for on the page
|
|
20
18
|
const MAX_ITEMS = 800; // kept for a snapshot; the oldest are dropped beyond that
|
|
@@ -220,7 +218,6 @@ export class RemoteControl {
|
|
|
220
218
|
this.streamAbort = null;
|
|
221
219
|
this.registered = false;
|
|
222
220
|
this.seenPeer = new Set(); // ids of the messages from other sessions already handled (the gateway sends again what was not acknowledged)
|
|
223
|
-
this.peerPending = new Set(); // messages being handled now, acknowledged when done
|
|
224
221
|
this.replying = new Set(); // answers to the page's commands on their way
|
|
225
222
|
}
|
|
226
223
|
|
|
@@ -373,35 +370,22 @@ export class RemoteControl {
|
|
|
373
370
|
// A message from a session on another computer: handed to the App once, then acknowledged, so that the gateway
|
|
374
371
|
// drops it from the session's mailbox (it sends what was not acknowledged again when the stream reconnects).
|
|
375
372
|
peerMessage(cmd) {
|
|
376
|
-
if (this.peerPending.has(cmd.cid)) return; // still being handled (files on their way): acknowledged when done
|
|
377
373
|
const ack = () => this.request('POST', `/v1/remote/sessions/${encodeURIComponent(this.id)}/results`, { cid: cmd.cid, ok: true }).catch(() => { /* sent again on reconnect, and dropped here as seen */ });
|
|
378
|
-
let handling = null;
|
|
379
374
|
try {
|
|
380
|
-
if (this.seenPeer.has(cmd.cid)) return;
|
|
375
|
+
if (this.seenPeer.has(cmd.cid)) { ack(); return; }
|
|
381
376
|
this.seenPeer.add(cmd.cid);
|
|
382
377
|
if (this.seenPeer.size > 500) this.seenPeer.delete(this.seenPeer.values().next().value);
|
|
383
378
|
const f = cmd.from || {};
|
|
384
379
|
const machine = f.machine || f.host || 'computer';
|
|
385
|
-
|
|
386
|
-
.filter((x) => x && typeof x.id === 'string')
|
|
387
|
-
.map((x) => ({ id: x.id, name: String(x.name || 'file'), size: Number(x.size) || 0, sha256: typeof x.sha256 === 'string' ? x.sha256 : null }));
|
|
388
|
-
handling = this.handlers.peerMessage?.({
|
|
380
|
+
this.handlers.peerMessage?.({
|
|
389
381
|
id: cmd.cid,
|
|
390
382
|
kind: cmd.kind === 'reply' ? 'reply' : 'task',
|
|
391
383
|
text: String(cmd.text ?? ''),
|
|
392
384
|
inReplyTo: cmd.inReplyTo || null,
|
|
393
385
|
from: { id: f.id, name: `${machine}/${f.name || 'session'}`, cwd: f.cwd || '', machine, remote: true },
|
|
394
|
-
...(files.length ? { files } : {}),
|
|
395
386
|
});
|
|
396
|
-
} catch { /* the App's problem: the message is acknowledged anyway, or it would come back forever */ }
|
|
397
|
-
|
|
398
|
-
// until it is done the gateway keeps it: a session that ends meanwhile gets it again, and continues
|
|
399
|
-
this.peerPending.add(cmd.cid);
|
|
400
|
-
handling.catch(() => {}).finally(() => { this.peerPending.delete(cmd.cid); if (!this.closed) ack(); });
|
|
401
|
-
} else {
|
|
402
|
-
ack();
|
|
403
|
-
}
|
|
404
|
-
}
|
|
387
|
+
} catch { /* the App's problem: the message is acknowledged anyway, or it would come back forever */ }
|
|
388
|
+
ack();
|
|
405
389
|
}
|
|
406
390
|
|
|
407
391
|
// The sessions of this gateway account, on every computer, as the gateway lists them (this one included).
|
|
@@ -411,31 +395,13 @@ export class RemoteControl {
|
|
|
411
395
|
}
|
|
412
396
|
|
|
413
397
|
// A message to another session of the account: resolves with {id} (the message's id, which a reply names).
|
|
414
|
-
|
|
415
|
-
async sendPeer(targetId, { kind = 'task', text, inReplyTo = null, files = [] }) {
|
|
398
|
+
async sendPeer(targetId, { kind = 'task', text, inReplyTo = null }) {
|
|
416
399
|
if (!this.registered) await this.register();
|
|
417
|
-
const body = { from: this.id, kind, text, ...(inReplyTo ? { inReplyTo } : {})
|
|
400
|
+
const body = { from: this.id, kind, text, ...(inReplyTo ? { inReplyTo } : {}) };
|
|
418
401
|
const data = await this.request('POST', `/v1/remote/sessions/${encodeURIComponent(targetId)}/messages`, body, { retry: false });
|
|
419
402
|
return { id: data.id, delivered: data.delivered !== false };
|
|
420
403
|
}
|
|
421
404
|
|
|
422
|
-
// ------------------------------------------------------------ files (for another computer's session)
|
|
423
|
-
|
|
424
|
-
get client() { return { base: this.base, apiKey: this.apiKey, fetch: this.fetch }; }
|
|
425
|
-
|
|
426
|
-
// A file of this computer (`{path, name, size}`) onto the gateway, resumably (see transfer.js): resolves with
|
|
427
|
-
// {id, name, size, sha256}, which a message's files refer to.
|
|
428
|
-
uploadFile(file, options) { return uploadFile(this.client, file, options); }
|
|
429
|
-
|
|
430
|
-
// A file another session sent (`{id, name, size, sha256}`) into `dir`: resolves with the path it got.
|
|
431
|
-
downloadFile(file, dir, options) { return downloadFile(this.client, file, dir, options); }
|
|
432
|
-
|
|
433
|
-
deleteFile(id) {
|
|
434
|
-
return this.fetch(`${this.base}/v1/remote/files/${encodeURIComponent(id)}`, {
|
|
435
|
-
method: 'DELETE', headers: { authorization: `Bearer ${this.apiKey}` }, signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
436
|
-
}).then(() => {}, () => {});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
405
|
// ------------------------------------------------------------ events
|
|
440
406
|
|
|
441
407
|
emit(ev) {
|
package/src/runtime.js
CHANGED
|
@@ -59,7 +59,9 @@ export async function createRuntime({ cwd, flags = {}, io }) {
|
|
|
59
59
|
runtime.systemPrompt = () => {
|
|
60
60
|
if (!promptCache) {
|
|
61
61
|
const autoMemory = config.autoMemoryEnabled ? { dir: memoryDir, index: loadAutoMemoryIndex(memoryDir) } : null;
|
|
62
|
-
promptCache = flags.systemPrompt
|
|
62
|
+
promptCache = flags.systemPrompt !== undefined
|
|
63
|
+
? flags.systemPrompt
|
|
64
|
+
: mainSystemPrompt({ cwd, model: config.mainModel, shellName: shell.name, extra: flags.appendSystemPrompt || '', autoMemory, selfRestart: selfEdit, installedCopy: !SOURCE_CHECKOUT, autoCompact: config.autoCompactEnabled, snapshot: snapshotFor(cwd) });
|
|
63
65
|
promptStale = false;
|
|
64
66
|
}
|
|
65
67
|
return promptCache;
|
|
@@ -76,7 +78,7 @@ export async function createRuntime({ cwd, flags = {}, io }) {
|
|
|
76
78
|
// it was saved): the new code's prompt is wanted then, e.g. after a Restart for an edit to the prompt. The date in
|
|
77
79
|
// it is brought up to date by a note to the model, which comes after everything that is cached.
|
|
78
80
|
runtime.resumeSystemPrompt = (saved, code) => {
|
|
79
|
-
if (flags.systemPrompt || typeof saved !== 'string' || !saved.trim()) return false;
|
|
81
|
+
if (flags.systemPrompt !== undefined || flags.systemPromptFile !== undefined || typeof saved !== 'string' || !saved.trim()) return false;
|
|
80
82
|
if (code !== PROMPT_CODE_VERSION) return false;
|
|
81
83
|
// --append-system-prompt is the last thing in the prompt: one built with other text is not what this run asked for
|
|
82
84
|
const extra = flags.appendSystemPrompt || '';
|
package/src/tools/peers.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// ListPeers and MessagePeer: talk to the other claude-pro sessions, on this machine and, through the gateway, on the
|
|
2
2
|
// user's other computers (see peers.js and remote.js).
|
|
3
3
|
|
|
4
|
-
import { resolvePath } from '../utils/paths.js';
|
|
5
|
-
|
|
6
4
|
const unavailable = { isError: true, content: 'Talking to other sessions is only available in an interactive session.' };
|
|
7
5
|
|
|
8
6
|
export const ListPeersTool = {
|
|
@@ -32,20 +30,18 @@ Send it once and wait for the answer: do not send reminders or "please report" f
|
|
|
32
30
|
type: 'object',
|
|
33
31
|
properties: {
|
|
34
32
|
to: { type: 'string', description: 'The name of the session as ListPeers shows it (computer/name for one on another computer)' },
|
|
35
|
-
message: { type: 'string', description: 'The task or question
|
|
36
|
-
files: { type: 'array', items: { type: 'string' }, description: 'Paths of files on this computer to send along (at most 20, 5 GB each; large ones go in the background and continue after a network outage). The other session saves them in its computer\'s Downloads folder, and is told where. With files and no message it only saves them and confirms, without working on anything.' },
|
|
33
|
+
message: { type: 'string', description: 'The task or question to send, written so it stands on its own' },
|
|
37
34
|
},
|
|
38
|
-
required: ['to'],
|
|
35
|
+
required: ['to', 'message'],
|
|
39
36
|
},
|
|
40
37
|
summarize(input) { return `@${input.to}`; },
|
|
41
38
|
async call(input, ctx) {
|
|
42
39
|
if (!ctx.io?.sendToPeer) return unavailable;
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
40
|
+
const message = String(input.message || '').trim();
|
|
41
|
+
if (!message) return { isError: true, content: 'Give a message to send.' };
|
|
45
42
|
try {
|
|
46
|
-
const { peer
|
|
43
|
+
const { peer } = await ctx.io.sendToPeer(input.to, message, { byModel: true });
|
|
47
44
|
const name = peer.label || peer.name;
|
|
48
|
-
if (background) return { content: `Sending ${files.length} file${files.length === 1 ? '' : 's'} to ${name} in the background (the user sees the progress); the message goes out once they are uploaded, and the answer of ${name} comes back later as a message. Carry on meanwhile, or end your turn.`, display: { summary: `Sending ${files.length} file${files.length === 1 ? '' : 's'} to ${name}` } };
|
|
49
45
|
return { content: `Sent to ${name}. Its answer will arrive later as a message; carry on meanwhile, or end your turn if you need the answer first.`, display: { summary: `Sent to ${name}` } };
|
|
50
46
|
} catch (e) {
|
|
51
47
|
return { isError: true, content: e.message };
|