toolroll 0.9.116 → 0.9.118
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/CHANGELOG.md +46 -0
- package/README.md +43 -26
- package/dist/acp-agents.js +14 -1
- package/dist/acp-client.js +19 -1
- package/dist/agent-change-check.js +60 -0
- package/dist/agent-change-schema.js +19 -0
- package/dist/agent-detect.js +11 -1
- package/dist/agent-fence.js +93 -16
- package/dist/agent-network-request.js +108 -0
- package/dist/agent-requests.js +105 -0
- package/dist/approval-summary.js +3 -3
- package/dist/backup.js +17 -1
- package/dist/batch-checks.js +81 -18
- package/dist/browser/terminal.js +41 -41
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +36 -36
- package/dist/builder.js +12 -2
- package/dist/candidate-materialize.js +119 -0
- package/dist/central-enrollment-contract.js +156 -0
- package/dist/central-recovery-stage.js +329 -0
- package/dist/chat-actions.js +101 -2
- package/dist/chat-channel.js +40 -0
- package/dist/check-only-standing.js +13 -0
- package/dist/check-only.js +25 -13
- package/dist/check-recovery-hold.js +199 -0
- package/dist/check-recovery-index-schema.js +3 -0
- package/dist/check-screenshots.js +83 -0
- package/dist/cli.js +125 -6
- package/dist/codex-limits.js +4 -0
- package/dist/coding-context.js +16 -2
- package/dist/coding-provider.js +7 -3
- package/dist/coding-workspace.js +5 -5
- package/dist/connect-cli.js +257 -11
- package/dist/contracts/chat-actions.js +4 -0
- package/dist/contracts/console-api.js +14 -3
- package/dist/contracts/engine-api.js +331 -2
- package/dist/contracts/lead-tools.js +56 -2
- package/dist/contracts/provider.js +1 -1
- package/dist/contracts/route.js +1 -1
- package/dist/contracts/terminal-connection.js +50 -0
- package/dist/converse.js +80 -4
- package/dist/device-pair.js +280 -0
- package/dist/direct-chat-artifacts.js +347 -0
- package/dist/direct-chat-catalog.js +311 -0
- package/dist/direct-chat-fence.js +96 -0
- package/dist/direct-chat-git.js +343 -0
- package/dist/direct-chat-laptop.js +19 -0
- package/dist/direct-chat-schema.js +181 -0
- package/dist/direct-chat-ship.js +861 -0
- package/dist/direct-chat-workspace.js +389 -0
- package/dist/direct-chat.js +2107 -0
- package/dist/doctor.js +1 -1
- package/dist/easy-start.js +18 -0
- package/dist/egress.js +25 -4
- package/dist/engine-chat.js +454 -0
- package/dist/engine-reads.js +141 -13
- package/dist/exec.js +4 -3
- package/dist/flexible-agents.js +8 -16
- package/dist/flexible-session.js +91 -47
- package/dist/flexible-ship.js +87 -7
- package/dist/flexible-start.js +4 -1
- package/dist/flexible-thread.js +2 -3
- package/dist/flexible-turns.js +26 -5
- package/dist/flow-triggers.js +13 -4
- package/dist/flows-ui.js +54 -20
- package/dist/handoff-cli.js +630 -0
- package/dist/invoke.js +71 -17
- package/dist/lead-contract.js +5 -4
- package/dist/lead-doors.js +80 -1
- package/dist/lead-progress.js +9 -0
- package/dist/lead-tools.js +681 -10
- package/dist/lead.js +37 -9
- package/dist/live-bus.js +11 -0
- package/dist/live-terminal.js +132 -12
- package/dist/local-handoff.js +363 -0
- package/dist/local-owner-acts.js +264 -2
- package/dist/local-owner.js +16 -1
- package/dist/multiplayer-handoff.js +528 -0
- package/dist/multiplayer-presence.js +471 -0
- package/dist/names.js +17 -4
- package/dist/needs-you.js +10 -0
- package/dist/operate.js +280 -19
- package/dist/planner.js +6 -1
- package/dist/policy.js +2 -2
- package/dist/project-delete-ui.js +18 -11
- package/dist/project-delete.js +65 -4
- package/dist/project-skills.js +28 -13
- package/dist/project-tools.js +1 -1
- package/dist/prompt.js +1 -1
- package/dist/provider-connection.js +2 -0
- package/dist/provider-home.js +251 -8
- package/dist/provider.js +3 -2
- package/dist/publish.js +119 -64
- package/dist/pull-request-flow.js +35 -14
- package/dist/read-executor-worker.js +1 -1
- package/dist/read-executor.js +95 -1
- package/dist/restore-retirement.js +152 -0
- package/dist/result-follow-ups.js +116 -37
- package/dist/route-change.js +44 -4
- package/dist/scope.js +62 -5
- package/dist/scout.js +6 -2
- package/dist/serve.js +49 -5
- package/dist/server/chat.js +94 -13
- package/dist/server/direct-chat.js +583 -0
- package/dist/server/engine-api.js +219 -21
- package/dist/server/flows.js +43 -10
- package/dist/server/found-repos.js +25 -0
- package/dist/server/guards.js +20 -6
- package/dist/server/live.js +81 -23
- package/dist/server/pages.js +67 -13
- package/dist/server/people-tokens.js +47 -6
- package/dist/server/remote.js +29 -0
- package/dist/server/render-results.js +6 -2
- package/dist/server/render-settings.js +4 -2
- package/dist/server/render-tasks.js +18 -17
- package/dist/server/route-table.js +69 -2
- package/dist/server/settings.js +22 -7
- package/dist/server/task-views.js +15 -3
- package/dist/server/tasks.js +39 -2
- package/dist/server/terminals.js +185 -11
- package/dist/settings-proofs.js +1 -1
- package/dist/skills-manifest.js +57 -0
- package/dist/store.js +499 -56
- package/dist/subscription-chat.js +33 -6
- package/dist/subscription-usage.js +233 -0
- package/dist/task-live.js +2 -1
- package/dist/teardown-git.js +34 -4
- package/dist/terminal-connection.js +159 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-contract.js +1 -1
- package/dist/tui-launch.js +32 -1
- package/dist/workspace-identity-schema.js +21 -0
- package/package.json +4 -2
package/dist/connect-cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
1
2
|
import { constants, closeSync, existsSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { request as httpRequest } from 'node:http';
|
|
4
|
+
import { request as httpsRequest } from 'node:https';
|
|
2
5
|
import { homedir } from 'node:os';
|
|
3
6
|
import { dirname, join } from 'node:path';
|
|
4
7
|
import { savedLoginFile } from './login-secrets.js';
|
|
@@ -7,13 +10,19 @@ import { envelopeJson } from './envelope.js';
|
|
|
7
10
|
import { databasePath } from './store.js';
|
|
8
11
|
import { configBase, namedPath } from './names.js';
|
|
9
12
|
import { parseApiToken } from './api-tokens.js';
|
|
13
|
+
import { TERMINAL_CONNECTION_PROTOCOL, terminalConnectionSchema } from './contracts/terminal-connection.js';
|
|
14
|
+
import { RECOVERY_GENERATION_PATTERN, WORKSPACE_ID_PATTERN } from './workspace-identity-schema.js';
|
|
10
15
|
import { deprecationWarning } from './deprecations.js';
|
|
11
16
|
import { PASSWORD_PROFILE_WARNING } from './password-bearer.js';
|
|
12
|
-
const HELP = `toolroll connect <HTTPS-origin> --
|
|
17
|
+
const HELP = `toolroll connect <HTTPS-origin> --browser [--profile <name>]
|
|
18
|
+
Opens your browser to confirm an 8-character code and mint a personal API token automatically.
|
|
19
|
+
toolroll connect <HTTPS-origin> --as <account> --token-stdin
|
|
13
20
|
Pipe your API token (so_…, from Settings → API tokens) or use --token-file <private-file>;
|
|
14
21
|
--local-login uses your existing local sign-in.
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
toolroll connect --list
|
|
23
|
+
List saved central profiles (never prints tokens).
|
|
24
|
+
toolroll connect --use <name>
|
|
25
|
+
Switch the active central profile.`;
|
|
17
26
|
export class UsageError extends Error {
|
|
18
27
|
}
|
|
19
28
|
export function serviceOrigin(raw) {
|
|
@@ -75,6 +84,12 @@ function profiles(options) {
|
|
|
75
84
|
for (const [name, one] of Object.entries(parsed.profiles)) {
|
|
76
85
|
if (!/^[A-Za-z0-9_-]{1,64}$/.test(name) || !record(one) || typeof one.origin !== 'string' || serviceOrigin(one.origin) !== one.origin || typeof one.account !== 'string' || !accountValid(one.account) || typeof one.token !== 'string' || !tokenValid(one.token))
|
|
77
86
|
throw new Error();
|
|
87
|
+
if (one.workspaceId !== undefined && (typeof one.workspaceId !== 'string' || !WORKSPACE_ID_PATTERN.test(one.workspaceId)))
|
|
88
|
+
throw new Error();
|
|
89
|
+
if (one.recoveryGeneration !== undefined && (typeof one.recoveryGeneration !== 'string' || !RECOVERY_GENERATION_PATTERN.test(one.recoveryGeneration)))
|
|
90
|
+
throw new Error();
|
|
91
|
+
if (one.label !== undefined && (typeof one.label !== 'string' || one.label.length === 0 || one.label.length > 200))
|
|
92
|
+
throw new Error();
|
|
78
93
|
}
|
|
79
94
|
if (!Object.hasOwn(parsed.profiles, parsed.active))
|
|
80
95
|
throw new Error();
|
|
@@ -131,6 +146,89 @@ export function centralProfile(options, name) {
|
|
|
131
146
|
const profile = saved.profiles[chosen];
|
|
132
147
|
return { name: chosen, ...profile, apiToken: parseApiToken(profile.token) !== null };
|
|
133
148
|
}
|
|
149
|
+
export async function probeTerminalConnection(profile, options = {}) {
|
|
150
|
+
if (parseApiToken(profile.token) === null)
|
|
151
|
+
return null;
|
|
152
|
+
try {
|
|
153
|
+
const headers = {
|
|
154
|
+
authorization: `Bearer ${profile.token}`,
|
|
155
|
+
'x-toolroll-client': 'terminal-remote',
|
|
156
|
+
accept: 'application/json',
|
|
157
|
+
};
|
|
158
|
+
let payload;
|
|
159
|
+
if (options.fetch !== undefined) {
|
|
160
|
+
const response = await options.fetch(`${profile.origin}/engine/connection`, {
|
|
161
|
+
method: 'GET',
|
|
162
|
+
redirect: 'manual',
|
|
163
|
+
credentials: 'omit',
|
|
164
|
+
signal: options.signal ? AbortSignal.any([options.signal, AbortSignal.timeout(15_000)]) : AbortSignal.timeout(15_000),
|
|
165
|
+
headers,
|
|
166
|
+
});
|
|
167
|
+
if (response.status !== 200) {
|
|
168
|
+
await response.body?.cancel();
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
payload = await responseBody(response);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const url = new URL('/engine/connection', profile.origin);
|
|
175
|
+
const reqFn = url.protocol === 'https:' ? httpsRequest : httpRequest;
|
|
176
|
+
payload = await new Promise((resolve, reject) => {
|
|
177
|
+
const req = reqFn(url, { method: 'GET', headers, timeout: 15_000 }, res => {
|
|
178
|
+
if (res.statusCode !== 200) {
|
|
179
|
+
res.resume();
|
|
180
|
+
resolve(null);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const chunks = [];
|
|
184
|
+
let size = 0;
|
|
185
|
+
res.on('data', (chunk) => {
|
|
186
|
+
size += chunk.length;
|
|
187
|
+
if (size > 64 * 1024) {
|
|
188
|
+
req.destroy();
|
|
189
|
+
resolve(null);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
chunks.push(chunk);
|
|
193
|
+
});
|
|
194
|
+
res.on('end', () => {
|
|
195
|
+
try {
|
|
196
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString('utf8')));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
resolve(null);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
req.on('error', reject);
|
|
204
|
+
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
205
|
+
req.end();
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
const parsed = terminalConnectionSchema.safeParse(payload);
|
|
209
|
+
if (!parsed.success || parsed.data.protocol !== TERMINAL_CONNECTION_PROTOCOL)
|
|
210
|
+
return null;
|
|
211
|
+
if (parsed.data.principal.account !== profile.account)
|
|
212
|
+
return null;
|
|
213
|
+
return parsed.data;
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
export function saveCentralBinding(options, name, binding) {
|
|
220
|
+
const existing = centralProfile(options, name);
|
|
221
|
+
if (existing === null)
|
|
222
|
+
throw new UsageError(`No saved connection named ${name}.`);
|
|
223
|
+
saveProfile(options, name, {
|
|
224
|
+
origin: existing.origin,
|
|
225
|
+
account: existing.account,
|
|
226
|
+
token: existing.token,
|
|
227
|
+
workspaceId: binding.workspaceId,
|
|
228
|
+
recoveryGeneration: binding.recoveryGeneration,
|
|
229
|
+
label: binding.label,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
134
232
|
async function stdinSecret() {
|
|
135
233
|
if (process.stdin.isTTY)
|
|
136
234
|
throw new UsageError('Pipe your sign-in secret into --token-stdin, or use --token-file.');
|
|
@@ -174,8 +272,8 @@ async function responseBody(response) {
|
|
|
174
272
|
return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)));
|
|
175
273
|
}
|
|
176
274
|
function parse(argv) {
|
|
177
|
-
const allowed = new Set(['profile', 'json', 'help', 'as', 'token-stdin', 'token-file', 'local-login', 'login-file']);
|
|
178
|
-
const switches = new Set(['json', 'help', 'token-stdin', 'local-login']);
|
|
275
|
+
const allowed = new Set(['profile', 'json', 'help', 'as', 'token-stdin', 'token-file', 'local-login', 'login-file', 'browser', 'list', 'use']);
|
|
276
|
+
const switches = new Set(['json', 'help', 'token-stdin', 'local-login', 'browser', 'list']);
|
|
179
277
|
const flags = {}, positions = [];
|
|
180
278
|
for (let index = 1; index < argv.length; index++) {
|
|
181
279
|
const arg = argv[index];
|
|
@@ -197,10 +295,107 @@ function parse(argv) {
|
|
|
197
295
|
flags[name] = next;
|
|
198
296
|
}
|
|
199
297
|
}
|
|
200
|
-
if (positions.length !== 1 && !flags.help)
|
|
298
|
+
if (positions.length !== 1 && !flags.help && !flags.list && !flags.use)
|
|
201
299
|
throw new UsageError('Name one service origin.');
|
|
202
300
|
return { flags, positions };
|
|
203
301
|
}
|
|
302
|
+
function pairPostJson(origin, path, body) {
|
|
303
|
+
const safeOrigin = serviceOrigin(origin);
|
|
304
|
+
const url = new URL(path, safeOrigin);
|
|
305
|
+
const reqFn = url.protocol === 'https:' ? httpsRequest : httpRequest;
|
|
306
|
+
const serialized = body === undefined ? '' : JSON.stringify(body);
|
|
307
|
+
return new Promise((resolve, reject) => {
|
|
308
|
+
const req = reqFn(url, {
|
|
309
|
+
method: 'POST',
|
|
310
|
+
timeout: 15_000,
|
|
311
|
+
headers: {
|
|
312
|
+
accept: 'application/json',
|
|
313
|
+
...(serialized === '' ? {} : { 'content-type': 'application/json', 'content-length': String(Buffer.byteLength(serialized)) }),
|
|
314
|
+
},
|
|
315
|
+
}, res => {
|
|
316
|
+
const status = res.statusCode ?? 0;
|
|
317
|
+
if (status >= 300 && status < 400) {
|
|
318
|
+
res.resume();
|
|
319
|
+
resolve({ status, json: null });
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const chunks = [];
|
|
323
|
+
let size = 0;
|
|
324
|
+
res.on('data', (chunk) => {
|
|
325
|
+
size += chunk.length;
|
|
326
|
+
if (size > 64 * 1024) {
|
|
327
|
+
req.destroy();
|
|
328
|
+
resolve({ status, json: null });
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
chunks.push(chunk);
|
|
332
|
+
});
|
|
333
|
+
res.on('end', () => {
|
|
334
|
+
try {
|
|
335
|
+
resolve({ status, json: JSON.parse(Buffer.concat(chunks).toString('utf8')) });
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
resolve({ status, json: null });
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
req.on('error', reject);
|
|
343
|
+
req.on('timeout', () => { req.destroy(); reject(new Error('Request timed out.')); });
|
|
344
|
+
if (serialized !== '')
|
|
345
|
+
req.write(serialized);
|
|
346
|
+
req.end();
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function launchBrowserUrl(url) {
|
|
350
|
+
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
351
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
352
|
+
try {
|
|
353
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
354
|
+
child.unref();
|
|
355
|
+
}
|
|
356
|
+
catch { }
|
|
357
|
+
}
|
|
358
|
+
async function pairViaBrowser(origin, stderr, options) {
|
|
359
|
+
const started = await pairPostJson(origin, '/api/connect/pair/start');
|
|
360
|
+
if (started.status !== 200 || started.json === null || started.json['ok'] !== true
|
|
361
|
+
|| typeof started.json['userCode'] !== 'string' || typeof started.json['pollSecret'] !== 'string'
|
|
362
|
+
|| typeof started.json['verificationPath'] !== 'string') {
|
|
363
|
+
const msg = typeof started.json?.['message'] === 'string' ? started.json['message'] : `Central server refused browser pairing (status ${started.status}).`;
|
|
364
|
+
throw new UsageError(msg);
|
|
365
|
+
}
|
|
366
|
+
const userCode = started.json['userCode'];
|
|
367
|
+
const pollSecret = started.json['pollSecret'];
|
|
368
|
+
const verifyUrl = `${origin}${started.json['verificationPath']}`;
|
|
369
|
+
stderr(`Confirm code ${userCode} in your browser:`);
|
|
370
|
+
stderr(` ${verifyUrl}`);
|
|
371
|
+
if (options.openBrowser)
|
|
372
|
+
options.openBrowser(verifyUrl);
|
|
373
|
+
else
|
|
374
|
+
launchBrowserUrl(verifyUrl);
|
|
375
|
+
const deadline = Date.now() + 5 * 60_000;
|
|
376
|
+
const intervalMs = Math.max(10, Math.min(5_000, options.pollIntervalMs ?? 1_500));
|
|
377
|
+
while (Date.now() < deadline) {
|
|
378
|
+
if (options.signal?.aborted)
|
|
379
|
+
throw new UsageError('Browser pairing cancelled.');
|
|
380
|
+
const polled = await pairPostJson(origin, '/api/connect/pair/poll', { pollSecret });
|
|
381
|
+
if (polled.status === 200 && polled.json !== null) {
|
|
382
|
+
if (polled.json['status'] === 'approved' && typeof polled.json['account'] === 'string' && typeof polled.json['token'] === 'string') {
|
|
383
|
+
return { account: polled.json['account'], token: polled.json['token'] };
|
|
384
|
+
}
|
|
385
|
+
if (polled.json['status'] === 'pending') {
|
|
386
|
+
await new Promise(resolve => {
|
|
387
|
+
const timer = setTimeout(resolve, intervalMs);
|
|
388
|
+
if (options.signal)
|
|
389
|
+
options.signal.addEventListener('abort', () => { clearTimeout(timer); resolve(); }, { once: true });
|
|
390
|
+
});
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const msg = typeof polled.json?.['message'] === 'string' ? polled.json['message'] : 'Browser pairing expired or was cancelled.';
|
|
395
|
+
throw new UsageError(msg);
|
|
396
|
+
}
|
|
397
|
+
throw new UsageError('Browser pairing timed out. Run toolroll connect --browser again.');
|
|
398
|
+
}
|
|
204
399
|
function isMessage(one) {
|
|
205
400
|
return record(one) && Number.isSafeInteger(one.id) && typeof one.author === 'string' && ['operator', 'assistant'].includes(String(one.role)) && typeof one.text === 'string' && ['queued', 'running', 'answered', 'failed', 'cancelled', 'uncertain'].includes(String(one.status)) && Number.isSafeInteger(one.revision) && typeof one.createdAt === 'string' && (one.requestId === null || typeof one.requestId === 'string') && (one.turnId === null || Number.isSafeInteger(one.turnId)) && (one.error === null || typeof one.error === 'string');
|
|
206
401
|
}
|
|
@@ -265,6 +460,41 @@ export async function maybeRunConnectCommand(argv, write, options = {}) {
|
|
|
265
460
|
write(HELP);
|
|
266
461
|
return 0;
|
|
267
462
|
}
|
|
463
|
+
if (flags.list) {
|
|
464
|
+
const saved = profiles(options);
|
|
465
|
+
const list = saved === null ? [] : Object.entries(saved.profiles).map(([name, one]) => ({
|
|
466
|
+
name,
|
|
467
|
+
active: name === saved.active,
|
|
468
|
+
origin: one.origin,
|
|
469
|
+
account: one.account,
|
|
470
|
+
...(one.label === undefined ? {} : { label: one.label }),
|
|
471
|
+
...(one.workspaceId === undefined ? {} : { workspaceId: one.workspaceId }),
|
|
472
|
+
}));
|
|
473
|
+
if (json) {
|
|
474
|
+
write(envelopeJson({ version: 1, ok: true, code: 'ok', message: `${list.length} saved profile${list.length === 1 ? '' : 's'}.`, command: 'team connect', result: { profiles: list } }));
|
|
475
|
+
}
|
|
476
|
+
else if (list.length === 0) {
|
|
477
|
+
write('No saved central profiles. Run: toolroll connect <https://origin> --browser');
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
for (const item of list) {
|
|
481
|
+
const mark = item.active ? '*' : ' ';
|
|
482
|
+
const label = item.label ? ` (${item.label})` : '';
|
|
483
|
+
write(`${mark} ${item.name} ${item.account}@${item.origin}${label}`);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return 0;
|
|
487
|
+
}
|
|
488
|
+
if (flags.use) {
|
|
489
|
+
const chosen = value(flags, 'use');
|
|
490
|
+
const saved = profiles(options);
|
|
491
|
+
if (saved === null || !/^[A-Za-z0-9_-]{1,64}$/.test(chosen) || !Object.hasOwn(saved.profiles, chosen)) {
|
|
492
|
+
throw new UsageError(`No saved connection named ${chosen}. Run toolroll connect --list to see saved profiles.`);
|
|
493
|
+
}
|
|
494
|
+
saveProfile(options, chosen, saved.profiles[chosen]);
|
|
495
|
+
emit({ version: 1, ok: true, code: 'switched', message: `Active profile switched to ${chosen} (${saved.profiles[chosen].origin}).`, result: { profile: chosen, origin: saved.profiles[chosen].origin, account: saved.profiles[chosen].account } });
|
|
496
|
+
return 0;
|
|
497
|
+
}
|
|
268
498
|
const profileName = value(flags, 'profile') || 'default';
|
|
269
499
|
if (!/^[A-Za-z0-9_-]{1,64}$/.test(profileName))
|
|
270
500
|
throw new UsageError('Profile names use 1–64 letters, digits, underscores or hyphens.');
|
|
@@ -275,12 +505,19 @@ export async function maybeRunConnectCommand(argv, write, options = {}) {
|
|
|
275
505
|
catch {
|
|
276
506
|
throw new UsageError('Use an HTTPS service origin (loopback HTTP is allowed), without credentials, paths, query or fragment.');
|
|
277
507
|
}
|
|
278
|
-
if (['token-stdin', 'token-file', 'local-login'].filter(name => flags[name]).length !== 1)
|
|
279
|
-
throw new UsageError('Choose one credential source: --token-stdin, --token-file or --local-login.');
|
|
508
|
+
if (['browser', 'token-stdin', 'token-file', 'local-login'].filter(name => flags[name]).length !== 1)
|
|
509
|
+
throw new UsageError('Choose one credential source: --browser, --token-stdin, --token-file or --local-login.');
|
|
280
510
|
if (flags['login-file'] && !flags['local-login'])
|
|
281
511
|
throw new UsageError('--login-file requires --local-login.');
|
|
282
512
|
let account = value(flags, 'as');
|
|
283
|
-
if (flags
|
|
513
|
+
if (flags.browser) {
|
|
514
|
+
const paired = await pairViaBrowser(origin, stderr, options);
|
|
515
|
+
if (account && account !== paired.account)
|
|
516
|
+
throw new UsageError(`Browser signed in as ${paired.account}, not ${account}.`);
|
|
517
|
+
account = paired.account;
|
|
518
|
+
secret = paired.token;
|
|
519
|
+
}
|
|
520
|
+
else if (flags['local-login']) {
|
|
284
521
|
const login = privateFile(value(flags, 'login-file') || savedLoginFile(dirname(databasePath(options.env ?? process.env, options.home ?? homedir()))), 8192).trim().split(/\s+/);
|
|
285
522
|
if (login.length !== 2 || account && account !== login[0])
|
|
286
523
|
throw new UsageError('The local sign-in does not match the requested account.');
|
|
@@ -293,13 +530,22 @@ export async function maybeRunConnectCommand(argv, write, options = {}) {
|
|
|
293
530
|
throw new UsageError('Provide an account name and a valid sign-in secret from your selected source.');
|
|
294
531
|
if (parseApiToken(secret) === null)
|
|
295
532
|
stderr(PASSWORD_PROFILE_WARNING);
|
|
296
|
-
const profile = { origin, account, token: secret }
|
|
533
|
+
const profile = { origin, account, token: secret };
|
|
534
|
+
const connection = await probeTerminalConnection(profile, options);
|
|
535
|
+
if (connection !== null) {
|
|
536
|
+
profile.workspaceId = connection.workspace.id;
|
|
537
|
+
profile.recoveryGeneration = connection.workspace.recoveryGeneration;
|
|
538
|
+
profile.label = connection.workspace.label;
|
|
539
|
+
}
|
|
540
|
+
const checked = connection !== null
|
|
541
|
+
? { version: 1, ok: true, code: 'connected', message: `Connected to ${origin} as ${account}.` }
|
|
542
|
+
: await verify(profile, options);
|
|
297
543
|
if (!checked.ok) {
|
|
298
544
|
emit(checked);
|
|
299
545
|
return 1;
|
|
300
546
|
}
|
|
301
547
|
saveProfile(options, profileName, profile);
|
|
302
|
-
emit({ version: 1, ok: true, code: 'connected', message: `Connected to ${origin} as ${account}.`, result: { profile: profileName, origin, account } });
|
|
548
|
+
emit({ version: 1, ok: true, code: 'connected', message: `Connected to ${origin} as ${account}.`, result: { profile: profileName, origin, account, ...(profile.workspaceId === undefined ? {} : { workspaceId: profile.workspaceId }) } });
|
|
303
549
|
return 0;
|
|
304
550
|
}
|
|
305
551
|
catch (error) {
|
|
@@ -84,6 +84,10 @@ export const chatActionRequestSchemas = {
|
|
|
84
84
|
task_cancel: z.strictObject({ task: words }),
|
|
85
85
|
task_resume: z.strictObject({ task: words, run: id }),
|
|
86
86
|
task_start: z.strictObject({ repo: words, preview: words }),
|
|
87
|
+
direct_chat_start: z.strictObject({ repo: words, prompt: words, provider: words, model: words, effort: words.nullable().optional() }),
|
|
88
|
+
direct_chat_reply: z.strictObject({ repo: words, chat: words, prompt: words }),
|
|
89
|
+
direct_chat_promote: z.strictObject({ repo: words, chat: words, title: words, goal: words, planning: z.enum(["auto", "required", "skip"]).optional() }),
|
|
90
|
+
direct_chat_ship: z.strictObject({ repo: words, chat: words, mode: z.enum(["ship", "keep-branch"]).optional(), title: words.optional(), goal: words.optional() }),
|
|
87
91
|
};
|
|
88
92
|
export const CHAT_ACTION_OPERATIONS = Object.keys(chatActionRequestSchemas);
|
|
89
93
|
export const CHAT_ACTION_FIELDS = Object.fromEntries(CHAT_ACTION_OPERATIONS.map(operation => [operation, Object.keys(chatActionRequestSchemas[operation].shape)]));
|
|
@@ -75,7 +75,7 @@ export const CONSOLE_FORMS = {
|
|
|
75
75
|
spendBudget: formContract("POST /spend/budget", ["password", "target", "action", "usd", "stop"]),
|
|
76
76
|
projectConcurrency: formContract("POST /settings/project/concurrency", ["repo", "concurrency"]),
|
|
77
77
|
projectLiveView: formContract("POST /settings/project/live-view", ["repo", "act", "password", "nonce"]),
|
|
78
|
-
projectNetwork: formContract("POST /settings/project/network", ["repo", "mode", "local", "hosts", "password"]),
|
|
78
|
+
projectNetwork: formContract("POST /settings/project/network", ["repo", "mode", "local", "hosts", "request", "digest", "password"]),
|
|
79
79
|
projectFallback: formContract("POST /settings/project/fallback", ["repo", "agents", "paid", "password"]),
|
|
80
80
|
projectWrites: formContract("POST /settings/project/writes", ["repo", "writes", "password"]),
|
|
81
81
|
projectCheckAccess: formContract("POST /settings/project/check-access", ["repo", "level", "confirm-open", "password"]),
|
|
@@ -173,7 +173,7 @@ export const CONSOLE_FORMS = {
|
|
|
173
173
|
agentWatch: formContract("POST /agents/watch", ["run", "view", "op"]),
|
|
174
174
|
leadProposal: formContract("POST /chat/proposal/<id>/confirm|dismiss", ["return", "nonce", "confirm", "token"]),
|
|
175
175
|
coordinatorProposal: formContract("POST /proposals/<id>/confirm|dismiss", ["return", "confirm"]),
|
|
176
|
-
chat: formContract("POST /chat", ["task", "project", "result", "mode", "request", "request-session", "message", "token"]),
|
|
176
|
+
chat: formContract("POST /chat", ["task", "project", "result", "mode", "request", "request-session", "message", "images", "instant", "token"]),
|
|
177
177
|
chatFile: formContract("POST /chat/file/<id>", ["token"]),
|
|
178
178
|
chatAck: formContract("POST /chat/ack/<id>", ["token", "nonce"]),
|
|
179
179
|
recipes: formContract("POST /recipes/prepare, /recipes/preview, /recipes/import, /recipes/launch, /recipes/save", ["repo", "projectRevision", "recipe", "recipeRevision", "document", "purpose", "source", "sourceRevision", "preview", "next"]),
|
|
@@ -200,7 +200,7 @@ export const CONSOLE_FORMS = {
|
|
|
200
200
|
taskPlanEdit: formContract("POST /t/<task>/plan-edit", ["saw-plan", "plan-document"]),
|
|
201
201
|
taskRevision: formContract("POST /t/<task>/accept-revision|reject-revision", ["revision-id", "token"]),
|
|
202
202
|
taskCancel: formContract("POST /t/<task>/cancel", ["reason", "state", "run"]),
|
|
203
|
-
taskRoute: formContract("POST /t/<task>/route", ["size", "risky", "phase", "clear-phase", "agent", "provider", "model", "sawDigest", "return"]),
|
|
203
|
+
taskRoute: formContract("POST /t/<task>/route", ["size", "risky", "phase", "clear-phase", "agent", "provider", "model", "sawDigest", "when", "return"]),
|
|
204
204
|
taskScope: formContract("POST /t/<task>/scope", ["sawDigest", "permission-mode", "quality-mode", "budget-usd", "budget-microusd", "requirement", "requirement-new", "requirement-how", "requirement-new-how", "goal-brief", "goal", "not", "touches", "acceptance"]),
|
|
205
205
|
taskApprove: formContract("POST /t/<task>/approve", ["return", "digest", "token", "nonce", "rebuild", "sheet"]),
|
|
206
206
|
taskAcceptProof: formContract("POST /t/<task>/accept-proof", ["run", "note", "return"]),
|
|
@@ -208,6 +208,14 @@ export const CONSOLE_FORMS = {
|
|
|
208
208
|
taskStop: formContract("POST /t/<task>/stop", ["run", "return"]),
|
|
209
209
|
taskPause: formContract("POST /t/<task>/pause", ["run", "request", "note", "mode", "return", "key"]),
|
|
210
210
|
taskResume: formContract("POST /t/<task>/resume|resume-arm", ["run", "token", "nonce", "return"]),
|
|
211
|
+
directChatStart: formContract("POST /engine/direct-chats", ["project", "prompt", "provider", "model", "effort", "request"]),
|
|
212
|
+
directChatSend: formContract("POST /engine/direct-chats/<id>/messages", ["prompt", "request"]),
|
|
213
|
+
directChatModel: formContract("POST /engine/direct-chats/<id>/model", ["provider", "model", "effort"]),
|
|
214
|
+
directChatDelete: formContract("POST /engine/direct-chats/<id>/delete", ["discard", "keepBranch"]),
|
|
215
|
+
directChatAttach: formContract("POST /engine/direct-chats/<id>/attachments", ["filename", "mimeType", "dataBase64"]),
|
|
216
|
+
directChatShipPreview: formContract("POST /engine/direct-chats/<id>/ship-preview", ["mode", "title", "goal"]),
|
|
217
|
+
directChatShip: formContract("POST /engine/direct-chats/<id>/ship", ["mode", "title", "goal", "termsDigest", "password"]),
|
|
218
|
+
directChatShipCancel: formContract("POST /engine/direct-chats/<id>/ship-cancel", ["shipId"]),
|
|
211
219
|
};
|
|
212
220
|
export const BODILESS_POSTS = [
|
|
213
221
|
"POST /settings/models/<unknown action>",
|
|
@@ -224,6 +232,9 @@ export const BODILESS_POSTS = [
|
|
|
224
232
|
"POST /settings/storage/check",
|
|
225
233
|
"POST /projects/github",
|
|
226
234
|
"POST /code/<session>/ship/preview",
|
|
235
|
+
"POST /engine/direct-chats/<id>/stop",
|
|
236
|
+
"POST /engine/direct-chats/<id>/apply-main-edits",
|
|
237
|
+
"POST /engine/direct-chats/<id>/repair",
|
|
227
238
|
];
|
|
228
239
|
const ledgerEntrySchema = z.looseObject({
|
|
229
240
|
id: z.number(), at: z.string(), actor: z.string(), repo: z.string().nullable(), taskId: z.string().nullable(), runId: z.number().nullable(),
|