@shardflux/cli 0.24.0 → 0.24.1

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +227 -1
  3. package/dist/account-args.js +5 -0
  4. package/dist/account-pool.js +5 -1
  5. package/dist/acp-permission-elsewhere.d.ts +38 -0
  6. package/dist/acp-permission-elsewhere.js +85 -0
  7. package/dist/acp-rpc.d.ts +2 -1
  8. package/dist/acp-rpc.js +11 -2
  9. package/dist/acp.js +95 -22
  10. package/dist/agent-credentials.d.ts +3 -0
  11. package/dist/agent-credentials.js +7 -0
  12. package/dist/args.d.ts +1 -1
  13. package/dist/args.js +143 -8
  14. package/dist/board-args.d.ts +6 -0
  15. package/dist/board-args.js +155 -0
  16. package/dist/board-commands.d.ts +62 -0
  17. package/dist/board-commands.js +395 -0
  18. package/dist/codex-cloud.d.ts +30 -3
  19. package/dist/codex-cloud.js +86 -12
  20. package/dist/conversation-commands.d.ts +30 -0
  21. package/dist/conversation-commands.js +312 -9
  22. package/dist/conversation-transcript.d.ts +44 -0
  23. package/dist/conversation-transcript.js +206 -0
  24. package/dist/conversations.d.ts +5 -2
  25. package/dist/conversations.js +20 -10
  26. package/dist/device-approvals.js +4 -3
  27. package/dist/device-bridge.d.ts +42 -1
  28. package/dist/device-bridge.js +223 -12
  29. package/dist/device-folders.d.ts +58 -0
  30. package/dist/device-folders.js +228 -0
  31. package/dist/device-helper.d.ts +6 -0
  32. package/dist/device-helper.js +87 -14
  33. package/dist/drive-commands.d.ts +25 -0
  34. package/dist/drive-commands.js +201 -0
  35. package/dist/handlers.js +6 -1
  36. package/dist/main.js +3 -0
  37. package/dist/move-files.d.ts +39 -0
  38. package/dist/move-files.js +167 -0
  39. package/dist/move.js +12 -11
  40. package/dist/onboarding.d.ts +6 -2
  41. package/dist/onboarding.js +24 -6
  42. package/dist/project-git.d.ts +7 -1
  43. package/dist/project-git.js +16 -3
  44. package/dist/project-preparation.d.ts +7 -0
  45. package/dist/project-preparation.js +14 -0
  46. package/dist/project-template-setup.js +32 -11
  47. package/dist/router-commands.d.ts +22 -0
  48. package/dist/router-commands.js +179 -0
  49. package/package.json +2 -2
package/dist/acp.js CHANGED
@@ -6,6 +6,8 @@ import { AcpRpc, RpcError, objectValue } from "./acp-rpc.js";
6
6
  import { ACP_PROBE_CATALOG, nativeCurrentModel, nativeModelOptions, withoutNativeModel } from "./acp-catalog.js";
7
7
  import { ACP_LIFECYCLE, AcpModelCache, acpScope } from "./acp-models.js";
8
8
  import { AcpJournal } from "./acp-journal.js";
9
+ import { answeredElsewhere, outcomeFor } from "./acp-permission-elsewhere.js";
10
+ import { conversationClient } from "./conversation-commands.js";
9
11
  import { getConversation, conversationWorkspace, preparedInFlight, rememberConversation, resumeConversation, restoreConversationBinding } from "./conversations.js";
10
12
  import { seedEvent } from "./seed-phases.js";
11
13
  import { projectIdentity } from "./project-identity.js";
@@ -45,6 +47,35 @@ export function acpModelOptions(catalog) {
45
47
  });
46
48
  }
47
49
  const SIGN_IN = 'Sign in to Shardflux from your editor (or run shard acp --login).';
50
+ const CONVERSATION_ID = /^conv_[a-z2-7]{26}$/;
51
+ /** A remote session has no local folder to keep in step: its files stay in the conversation's computer. */
52
+ const NO_FILES = { root: '', conflicts: () => [], reconcile: () => Promise.resolve(), settled: () => true };
53
+ /** The last sequence number in a conversation's ACP journal: a session loaded by id follows from there (its history comes
54
+ * from the agent's own session/load replay, not from the journal). */
55
+ async function journalEnd(cell, conversationId) {
56
+ const path = `/home/user/.local/share/shardflux/acp/${conversationId}/journal.ndjson`;
57
+ let size;
58
+ try {
59
+ size = (await cell.files.stat(path)).size;
60
+ }
61
+ catch (error) {
62
+ if (error.status === 404)
63
+ return 0;
64
+ throw error;
65
+ }
66
+ for (let want = 64 << 10;; want *= 4) {
67
+ const start = Math.max(0, size - want), text = Buffer.from(await cell.files.read(path, { offset: start, length: size - start })).toString('utf8');
68
+ const lines = text.split('\n').filter(Boolean), last = start > 0 && lines.length < 2 ? undefined : lines.at(-1);
69
+ if (last !== undefined) {
70
+ const seq = JSON.parse(last).seq;
71
+ if (Number.isSafeInteger(seq))
72
+ return seq;
73
+ throw new Error('Invalid ACP journal entry');
74
+ }
75
+ if (start === 0)
76
+ return 0;
77
+ }
78
+ }
48
79
  function supervisorOwner(workspaceId, conversationId, app, text) {
49
80
  const status = JSON.parse(text);
50
81
  if (status.conversation_id !== conversationId || status.harness !== app || !Number.isSafeInteger(status.pid) || status.pid <= 0 || !status.start)
@@ -125,7 +156,7 @@ export class ShardfluxAcp {
125
156
  if (!this.#initialized)
126
157
  throw new RpcError(-32600, 'Initialize first');
127
158
  if (method === 'session/list') {
128
- const sessions = Object.values(this.#records()).filter(r => r.apiUrl === this.#ctx.apiUrl && (!params.cwd || r.folder === params.cwd));
159
+ const sessions = Object.values(this.#records()).filter(r => r.apiUrl === this.#ctx.apiUrl && !r.remote && (!params.cwd || r.folder === params.cwd));
129
160
  return { sessions: sessions.map(r => ({ sessionId: r.id, cwd: r.folder, updatedAt: r.updatedAt })) };
130
161
  }
131
162
  if (method === 'session/new') {
@@ -163,12 +194,14 @@ export class ShardfluxAcp {
163
194
  throw new RpcError(-32601, 'The provider probe has no conversation.');
164
195
  if (typeof params.sessionId !== 'string')
165
196
  throw new RpcError(-32602, 'A conversation is required');
166
- const session = this.#session(params.sessionId, params.cwd);
197
+ const session = this.#session(params.sessionId, params.cwd, method);
167
198
  const { record } = session;
168
199
  if (method === 'session/close') {
169
200
  await this.#close(session);
170
201
  return {};
171
202
  }
203
+ if (record.remote && !record.model)
204
+ await this.#remoteHarness(record);
172
205
  if (method === 'session/set_model' || (method === 'session/set_config_option' && params.configId === 'model')) {
173
206
  const model = String(method === 'session/set_model' ? params.modelId : params.value), selected = parseAcpModel(model);
174
207
  if (!record.catalog && record.conversationId)
@@ -272,11 +305,17 @@ export class ShardfluxAcp {
272
305
  record.scope = acpScope(ctx.apiUrl, view);
273
306
  this.#cache.remember(ctx, record.folder, record.scope);
274
307
  if (previous && JSON.stringify(previous) !== JSON.stringify(record.scope)) {
275
- record.catalog = this.#cache.read(record.scope);
276
- const app = record.catalog.claude ? 'claude' : 'codex';
277
- record.model = record.catalog[app] ? acpModel(app, nativeCurrentModel(record.catalog[app])) : '';
278
- if (session.announced)
279
- void this.#modelUpdate(session).catch(() => { });
308
+ const cached = this.#cache.read(record.scope);
309
+ // A newer template of the same account has no cached models yet: the models this session offered stay
310
+ // until its live discovery replaces them, so an editor's first choice is not refused (0.25.0+). Before, the
311
+ // list went empty for those seconds and set_model failed with "no longer available".
312
+ if (Object.keys(cached).length || previous.organizationId !== record.scope.organizationId) {
313
+ record.catalog = cached;
314
+ const app = record.catalog.claude ? 'claude' : 'codex';
315
+ record.model = record.catalog[app] ? acpModel(app, nativeCurrentModel(record.catalog[app])) : '';
316
+ if (session.announced)
317
+ void this.#modelUpdate(session).catch(() => { });
318
+ }
280
319
  }
281
320
  this.#save(record);
282
321
  },
@@ -354,9 +393,15 @@ export class ShardfluxAcp {
354
393
  this.#save(record);
355
394
  await this.#modelUpdate(session);
356
395
  }
357
- #session(id, cwd) {
358
- const record = this.#records()[id];
359
- if (!record || record.apiUrl !== this.#ctx.apiUrl || (cwd !== undefined && (typeof cwd !== 'string' || projectIdentity(cwd).folder !== record.folder)))
396
+ #session(id, cwd, method) {
397
+ let record = this.#records()[id];
398
+ // Any client can open a conversation it knows by id (session/load or session/resume with a conv_ id): it relays to
399
+ // the conversation's own ACP session in its computer, with no folder of this computer to sync.
400
+ if (!record && CONVERSATION_ID.test(id) && (method === 'session/load' || method === 'session/resume')) {
401
+ record = { id, apiUrl: this.#ctx.apiUrl, folder: typeof cwd === 'string' ? cwd : '', conversationId: id, model: '', from_seq: 0, prompted: true, remote: true, updatedAt: new Date().toISOString() };
402
+ this.#save(record);
403
+ }
404
+ if (!record || record.apiUrl !== this.#ctx.apiUrl || (cwd !== undefined && (typeof cwd !== 'string' || (record.remote ? cwd !== record.folder : projectIdentity(cwd).folder !== record.folder))))
360
405
  throw new RpcError(-32000, 'Conversation not found.');
361
406
  let session = this.#sessions.get(id);
362
407
  if (!session) {
@@ -365,6 +410,17 @@ export class ShardfluxAcp {
365
410
  }
366
411
  return session;
367
412
  }
413
+ /** A conversation loaded by id: its harness from the API. Only an ACP conversation has a session to relay to. */
414
+ async #remoteHarness(record) {
415
+ const c = await getConversation(this.#ctx, record.conversationId);
416
+ if (c.route !== 'acp')
417
+ throw new RpcError(-32602, `This conversation runs in ${c.route === 'terminal' ? 'a terminal' : c.route}; open it there.`);
418
+ if (!c.harness_session_id)
419
+ throw new RpcError(-32602, 'This conversation has not started its session yet. Try again in a moment.');
420
+ record.app = c.harness;
421
+ record.model = acpModel(c.harness, DEFAULT_MODEL);
422
+ this.#save(record);
423
+ }
368
424
  /** True when this call started the connection (and so reconciled the project files just now). */
369
425
  async #connect(session) {
370
426
  await session.prepared;
@@ -428,20 +484,21 @@ export class ShardfluxAcp {
428
484
  const current = await getConversation(ctx, record.conversationId);
429
485
  session.conversation = await resumeConversation(ctx, current);
430
486
  session.ws = await conversationWorkspace(ctx, session.conversation);
431
- rememberConversation(ctx, session.conversation, record.folder);
487
+ if (!record.remote)
488
+ rememberConversation(ctx, session.conversation, record.folder);
432
489
  mark('conversation');
433
490
  }
434
491
  await signIn;
435
492
  mark('signed_in');
436
493
  let c = session.conversation;
437
494
  const cell = session.ws.cell();
438
- const menubar = ensureMenubar(ctx.store.dir, ctx.apiUrl, new MenubarManager({ home: ctx.io.env.HOME, signal: ctx.signal }));
495
+ const menubar = record.remote ? Promise.resolve() : ensureMenubar(ctx.store.dir, ctx.apiUrl, new MenubarManager({ home: ctx.io.env.HOME, signal: ctx.signal }));
439
496
  await restoreConversationBinding(ctx, c, session.ws);
440
497
  mark('binding');
441
498
  // The project files are reconciled, device approvals served and the supervisor launched side by side; the native
442
499
  // session starts once the supervisor is up, and the connection is done (the prompt goes) once the files are
443
500
  // reconciled too (0.21.1+).
444
- const files = (async () => {
501
+ const files = record.remote ? Promise.resolve(NO_FILES) : (async () => {
445
502
  const boundary = await projectSyncBoundary({ ...ctx, signal: AbortSignal.any([ctx.signal, session.stop.signal]) }, session.ws, projectIdentity(record.folder), {
446
503
  root: c.worktree_path, agent: record.id.replace(/^sf-/, 'acp-'), seed: false,
447
504
  stateKey: `acp:${ctx.apiUrl}:${record.id}:${record.folder}`, ...(session.hashes ? { cache: session.hashes } : {}),
@@ -464,7 +521,7 @@ export class ShardfluxAcp {
464
521
  session.approvals ??= await serveAcpDeviceApprovals(ctx.store.dir, c.id, async (approval) => {
465
522
  const result = objectValue(await this.#client.request('session/request_permission', { sessionId: record.id,
466
523
  toolCall: { toolCallId: approval.request_id, title: approval.summary, kind: 'execute', status: 'pending' },
467
- options: [{ optionId: 'once', name: 'Allow once', kind: 'allow_once' }, ...(!approval.outside ? [{ optionId: 'always', name: 'Always for this project', kind: 'allow_always' }] : []), { optionId: 'deny', name: 'Deny', kind: 'reject_once' }] }, 0, AbortSignal.any([ctx.signal, session.stop.signal])));
524
+ options: [{ optionId: 'once', name: 'Allow once', kind: 'allow_once' }, ...(approval.scope === 'folder' ? [{ optionId: 'always', name: 'Always for this folder', kind: 'allow_always' }] : !approval.outside ? [{ optionId: 'always', name: 'Always for this project', kind: 'allow_always' }] : []), { optionId: 'deny', name: 'Deny', kind: 'reject_once' }] }, 0, AbortSignal.any([ctx.signal, session.stop.signal])));
468
525
  const outcome = objectValue(result.outcome);
469
526
  return outcome.outcome === 'selected' && (outcome.optionId === 'once' || outcome.optionId === 'always') ? outcome.optionId : 'deny';
470
527
  });
@@ -480,7 +537,8 @@ export class ShardfluxAcp {
480
537
  if (c.harness !== app)
481
538
  throw new Error('The guest did not claim this conversation harness.');
482
539
  session.conversation = c;
483
- rememberConversation(ctx, c, record.folder);
540
+ if (!record.remote)
541
+ rememberConversation(ctx, c, record.folder);
484
542
  const owner = supervisorOwner(session.ws.id, c.id, app, statusText);
485
543
  if (owner === null)
486
544
  throw new Error('ACP supervisor identity does not match this conversation.');
@@ -488,7 +546,8 @@ export class ShardfluxAcp {
488
546
  // A cold restore can replace the journal owner without changing the VM id.
489
547
  // Its sequence starts at zero; an old cursor would drop initialize/load replies.
490
548
  if (record.workspaceId !== session.ws.id || record.owner !== owner) {
491
- record.from_seq = 0;
549
+ // A conversation loaded by id follows its journal from now: the agent's session/load replays its history.
550
+ record.from_seq = record.remote ? await journalEnd(cell, c.id) : 0;
492
551
  delete record.prompt_id;
493
552
  }
494
553
  record.workspaceId = session.ws.id;
@@ -508,17 +567,28 @@ export class ShardfluxAcp {
508
567
  mapped.update = { ...update, ...this.#configuration(record.model, native, record.catalog) };
509
568
  }
510
569
  }
511
- if (request) {
512
- if (method === 'session/request_permission')
513
- transport.pause();
570
+ if (request && method === 'session/request_permission') {
571
+ // The journal relay pauses while the editor shows the prompt (a parked VM stays parked). The person can answer
572
+ // the same request through the API meanwhile (0.25.0+): then the editor's prompt is withdrawn and the turn goes on.
573
+ transport.pause();
574
+ const stop = new AbortController(), signal = AbortSignal.any([ctx.signal, session.stop.signal]);
514
575
  try {
515
- return acpReferences(await this.#client.request(method, mapped, 0, AbortSignal.any([ctx.signal, session.stop.signal])), record, c.worktree_path, true);
576
+ const asked = this.#client.request(method, mapped, 0, AbortSignal.any([signal, stop.signal]), true).then(result => ({ result }));
577
+ const elsewhere = answeredElsewhere(conversationClient(ctx), c.id, params, Date.now(), AbortSignal.any([signal, stop.signal]))
578
+ .then(p => p ? { p } : new Promise(() => undefined));
579
+ const first = await Promise.race([asked, elsewhere]);
580
+ if ('result' in first)
581
+ return acpReferences(first.result, record, c.worktree_path, true);
582
+ asked.catch(() => undefined);
583
+ return outcomeFor(first.p, mapped);
516
584
  }
517
585
  finally {
518
- if (method === 'session/request_permission')
519
- transport.resume();
586
+ stop.abort();
587
+ transport.resume();
520
588
  }
521
589
  }
590
+ if (request)
591
+ return acpReferences(await this.#client.request(method, mapped, 0, AbortSignal.any([ctx.signal, session.stop.signal])), record, c.worktree_path, true);
522
592
  await this.#client.notify(method, mapped);
523
593
  };
524
594
  session.transport = transport;
@@ -530,6 +600,9 @@ export class ShardfluxAcp {
530
600
  throw new Error('Agent protocol version changed');
531
601
  mark('initialized');
532
602
  const nativeId = c.harness_session_id ?? record.nativeId;
603
+ // The history a load replays (session/update notifications) reaches the editor under its own session id.
604
+ if (nativeId)
605
+ record.nativeId = nativeId;
533
606
  const result = objectValue(await transport.rpc.request(nativeId ? 'session/load' : 'session/new', { cwd: c.worktree_path, mcpServers: [{ name: 'shardflux', command: '/usr/local/bin/sf-agent', args: ['conversation', 'mcp'], env: [{ name: 'SF_CONVERSATION_ID', value: c.id }] }], ...(nativeId ? { sessionId: nativeId } : {}) }));
534
607
  const id = result.sessionId ?? nativeId;
535
608
  mark('session');
@@ -9,6 +9,9 @@ export declare function readAgentCredentials(opts?: CredentialSources): Promise<
9
9
  app: AgentCredentialApp;
10
10
  files: AgentCredentialFile[];
11
11
  }>>;
12
+ /** The API's fingerprint of a login as this CLI copies it (the API hashes the same canonical file list), so a login on
13
+ * this computer can be told apart from the copy in the cloud without uploading it. */
14
+ export declare function credentialFingerprint(files: readonly AgentCredentialFile[]): string;
12
15
  /** Reusable by the path launcher (L4). Returns metadata only. */
13
16
  export declare function syncAgentCredentials(cloud: Shardflux, opts?: CredentialSources): Promise<import("@shardflux/sdk").AgentCredentialMetadata[]>;
14
17
  export declare const AGENT_CREDENTIAL_HANDLERS: Record<string, Handler>;
@@ -1,3 +1,4 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { readFile } from 'node:fs/promises';
2
3
  import { homedir } from 'node:os';
3
4
  import { join } from 'node:path';
@@ -55,6 +56,12 @@ export async function readAgentCredentials(opts = {}) {
55
56
  out.push({ app: 'codex', files: [file('~/.codex/auth.json', object(codex, opts.redact), opts.redact)] });
56
57
  return out;
57
58
  }
59
+ /** The API's fingerprint of a login as this CLI copies it (the API hashes the same canonical file list), so a login on
60
+ * this computer can be told apart from the copy in the cloud without uploading it. */
61
+ export function credentialFingerprint(files) {
62
+ const canonical = [...files].sort((a, b) => a.path.localeCompare(b.path)).map(({ path, content_b64, mode }) => ({ path, content_b64, mode }));
63
+ return createHash('sha256').update(JSON.stringify(canonical)).digest('hex');
64
+ }
58
65
  /** Reusable by the path launcher (L4). Returns metadata only. */
59
66
  export async function syncAgentCredentials(cloud, opts = {}) {
60
67
  const sessions = await readAgentCredentials(opts);
package/dist/args.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const CLI_VERSION = "0.24.0";
1
+ export declare const CLI_VERSION = "0.24.1";
2
2
  export interface OptionSpec {
3
3
  type: 'string' | 'boolean';
4
4
  short?: string;
package/dist/args.js CHANGED
@@ -11,9 +11,10 @@
11
11
  */
12
12
  import { parseArgs } from 'node:util';
13
13
  import { ACCOUNT_COMMANDS } from "./account-args.js";
14
+ import { BOARD_COMMANDS } from "./board-args.js";
14
15
  import { UsageError } from "./errors.js";
15
16
  import { DEFAULT_CHOICE, MODEL_CHOICES } from "./agent-models.js";
16
- export const CLI_VERSION = '0.24.0';
17
+ export const CLI_VERSION = '0.24.1';
17
18
  export const GLOBAL_OPTIONS = {
18
19
  'api-url': { type: 'string', value: '<url>', description: 'API base URL (default $SHARDFLUX_API_URL, else https://api.shardflux.dev).' },
19
20
  json: { type: 'boolean', description: 'Print machine-readable JSON on stdout (errors as JSON on stderr).' },
@@ -147,15 +148,52 @@ const LAYER_HELP = {
147
148
  };
148
149
  const KEY_COMMANDS = [
149
150
  { path: ['conversations', 'list'], summary: 'List project conversations', positionals: [], options: { all: { type: 'boolean', description: 'Fetch every page.' },
150
- project: { type: 'string', value: '<id>', description: 'Project ID for a user session.' }, state: { type: 'string', value: '<state>', description: 'Conversation state.' },
151
- parent: { type: 'string', value: '<id>', description: 'Children of this conversation.' }, limit: { type: 'string', value: '<count>', description: 'Page size.' }, cursor: { type: 'string', value: '<cursor>', description: 'Next page cursor.' } } },
151
+ project: { type: 'string', value: '<id>', description: 'Project ID for a user session.' }, org: { type: 'string', value: '<id|slug>', description: 'Signed in: the conversations of every project of this organization you work in (0.25.0+).' }, state: { type: 'string', value: '<state>', description: 'Conversation state.' },
152
+ parent: { type: 'string', value: '<id>', description: 'Children of this conversation.' }, 'updated-after': { type: 'string', value: '<time>', description: 'Only conversations changed after this time (RFC 3339).' },
153
+ limit: { type: 'string', value: '<count>', description: 'Page size.' }, cursor: { type: 'string', value: '<cursor>', description: 'Next page cursor.' } },
154
+ description: 'With an API key: its project’s conversations. Signed in (shard auth login) without a key: the conversations of every project you work in, across your organizations (0.25.0+); --org narrows them to one organization and --project to one project. --org uses your sign-in when you have one.',
155
+ examples: ['shard c list --state needs_you', 'shard c list --org acme --all --json'] },
156
+ { path: ['conversations', 'feed'], summary: 'Print project conversations as they change', positionals: [], options: {
157
+ project: { type: 'string', value: '<id>', description: 'Project ID for a user session.' }, org: { type: 'string', value: '<id|slug>', description: 'Signed in: every project of this organization you work in (0.25.0+).' }, cursor: { type: 'string', value: '<cursor>', description: 'Continue after this feed cursor (--json prints it with each change).' }
158
+ },
159
+ description: 'Prints each conversation the moment it changes, until interrupted: "<id> <title> <state>", and why it needs you when it does; --json prints one {conversation, cursor} object per line. With an API key: its project. Signed in without a key: every project you work in, on one cursor (0.25.0+); --org follows one organization’s projects and uses your sign-in when you have one.',
160
+ examples: ['shard c feed', 'shard c feed --org acme --json'] },
152
161
  { path: ['conversations', 'resume'], summary: 'Resume a saved conversation in a fresh VM', positionals: [{ name: 'id', required: true }], options: {} },
153
162
  { path: ['conversations', 'reader'], summary: 'Open a read-only project space reader', positionals: [{ name: 'project_id', required: true }], options: {} },
154
- { path: ['conversations', 'get'], summary: 'Show a conversation and its current VM', positionals: [{ name: 'id', required: true }], options: {} },
155
- { path: ['conversations', 'send'], summary: 'Send the next user turn', positionals: [{ name: 'id', required: true }, { name: 'text', required: true, variadic: true, words: true }], options: {} },
163
+ { path: ['conversations', 'get'], summary: 'Show a conversation and its current VM', positionals: [{ name: 'id', required: true }], options: {},
164
+ description: 'Prints its title, state and branch, why it needs you when it does, then one line per port a process listens on in its computer: the port, the program, and its URL once exposed (or 127.0.0.1 only). --json returns the conversation with pty_id, listening_ports and listening_ports_at.' },
165
+ { path: ['conversations', 'watch'], summary: 'Watch a conversation’s terminal live, read-only', positionals: [{ name: 'id', required: true }], options: {},
166
+ description: 'Shows the terminal the conversation’s agent runs in (its pty_id, terminal conversations) as the agent works: its last 256 KiB, then live output, until the agent’s session exits or you press Ctrl-C. Nothing you type reaches it. Watching never keeps the computer awake while the agent is idle, and ends when the computer sleeps. The output is the terminal’s own bytes, so there is no --json form; shard agents logs <id> --json returns recent output as JSON.',
167
+ examples: ['shard conversations watch conv_a7k2m4q6s3t5v7x2z4b6d3f5h7'] },
168
+ { path: ['conversations', 'send'], summary: 'Send the next user turn', positionals: [{ name: 'id', required: true }, { name: 'text', variadic: true, words: true }], options: {
169
+ file: { type: 'string', multiple: true, value: '<path>', description: 'Attach a file (repeatable, up to 20 of 64 MiB each): it lands in the conversation’s computer before the message, which lists its path there (0.25.0+).' }
170
+ },
171
+ description: 'Text and files reach the conversation’s agent as its next turn. A conversation that ended is restored into a fresh computer first. Attached files keep their names under /home/user/.shardflux/attachments/<conversation id>/; each stored path is printed.',
172
+ examples: ['shard conversations send conv_6qz2dmu4kd3xa7v5l2hgmfnpjy "Fix the failing export test"', 'shard conversations send conv_6qz2dmu4kd3xa7v5l2hgmfnpjy "Why does this page break?" --file screenshot.png --file console.log'] },
156
173
  { path: ['conversations', 'wait'], summary: 'Wait for a result or question', positionals: [{ name: 'id', required: true }], options: {
157
174
  until: { type: 'string', value: '<states>', description: 'Comma-separated conversation states.' }, timeout: { type: 'string', value: '<seconds>', description: 'Wait for 0..900 seconds (default 900).' }
158
175
  } },
176
+ { path: ['conversations', 'permissions'], summary: 'List what a conversation’s agent asked permission for, oldest first', positionals: [{ name: 'id', required: true }], options: {
177
+ state: { type: 'string', value: '<state>', description: 'pending, answered or canceled (default every state).' }, all: { type: 'boolean', description: 'Fetch every page.' },
178
+ limit: { type: 'string', value: '<count>', description: 'Page size (1..200, default 50).' }, cursor: { type: 'string', value: '<cursor>', description: 'Next page cursor.' }
179
+ },
180
+ description: 'A conversation is needs_you while its agent waits on a permission request: to run a command, edit a file or fetch a URL. Each line is the request id, its state, what the agent wants to do, the command, path or URL, and the decision once answered. Answer a pending one with shard conversations answer (0.25.0+).',
181
+ examples: ['shard conversations permissions <conversation-id> --state pending', 'shard c permissions <conversation-id> --all --json'] },
182
+ { path: ['conversations', 'answer'], summary: 'Answer a permission request (allow, always or deny) or the agent’s question (--pick)', positionals: [{ name: 'id', required: true }, { name: 'permission_id', required: true }, { name: 'decision' }], options: {
183
+ pick: { type: 'string', multiple: true, value: '<option|question=option>', description: 'The option you pick for the agent’s question (0.25.0+): its label or your own words; repeat it for a multi-select question; "<question>=<option>" when it asks several.' }
184
+ },
185
+ description: 'allow lets the agent run the tool this once, always also lets its harness stop asking for this kind of call, deny refuses it (allow_once, allow_always and deny work too). The agent’s question (a request with questions, such as Claude Code’s AskUserQuestion) takes --pick, or deny to decline it; the agent gets exactly what you picked. The agent goes on with its turn, and a parked computer wakes to take the answer. A request answered already, here or where the agent runs, is refused with permission_answered (0.25.0+).',
186
+ examples: ['shard conversations answer <conversation-id> <permission-id> allow', 'shard c answer <conversation-id> <permission-id> --pick Blue', 'shard c answer <conversation-id> <permission-id> deny'] },
187
+ { path: ['conversations', 'transcript'], summary: 'Print a conversation’s transcript: its agent’s own JSONL (0.25.0+)', positionals: [{ name: 'id', required: true }], options: {
188
+ offset: { type: 'string', value: '<bytes>', description: 'Start at this byte offset, such as the next_offset of an earlier read.' },
189
+ session: { type: 'string', value: '<id>', description: 'An earlier session of the conversation (default: the latest).' },
190
+ follow: { type: 'boolean', short: 'f', description: 'Keep printing new lines as they are stored, until Ctrl-C.' }
191
+ },
192
+ description: 'Prints the Claude Code or Codex transcript byte for byte, as the agent wrote it, for working, parked and finished conversations alike, without waking a VM. With --json: one object (session_id, file, offset, next_offset, size, data); with --follow, one object per line.',
193
+ examples: ['shard c transcript conv_k3m5q7s2u4w6y3b5d7f2h4j6ln > session.jsonl', 'shard c transcript conv_k3m5q7s2u4w6y3b5d7f2h4j6ln --follow | jq -c \'select(.type=="assistant")\''] },
194
+ { path: ['conversations', 'events'], summary: 'Follow a conversation live: state, transcript, reply text and tool calls (0.25.0+)', positionals: [{ name: 'id', required: true }], options: {},
195
+ description: 'Streams the conversation until Ctrl-C, one line per event: state changes, new transcript lines and tool calls, with the reply written as the agent streams it. With --json: one event per line, {"type":"conversation"|"transcript"|"delta","id":…} with the conversation, the transcript lines or the ACP session updates.',
196
+ examples: ['shard c events conv_k3m5q7s2u4w6y3b5d7f2h4j6ln', 'shard c events conv_k3m5q7s2u4w6y3b5d7f2h4j6ln --json | jq -c \'select(.type=="delta")\''] },
159
197
  { path: ['conversations', 'land'], summary: 'Record the landing action performed by the agent', positionals: [{ name: 'id', required: true }, { name: 'action', required: true }], options: { into: { type: 'string', value: '<ref>', description: 'Destination branch or PR URL.' } } },
160
198
  { path: ['conversations', 'move'], summary: 'Move at the end of the turn', positionals: [{ name: 'id', required: true }, { name: 'to', required: true }], options: {} },
161
199
  { path: ['conversations', 'landing'], summary: 'Show or set how finished conversations reach this checkout', positionals: [{ name: 'mode' }, { name: 'backup' }], options: {
@@ -1296,7 +1334,19 @@ const AGENT_COMMANDS = [
1296
1334
  detach: { type: 'boolean', description: 'Start it in the cloud without opening it here.' },
1297
1335
  }, examples: ['shard move --last', 'shard move --list', 'shard move --session 3d085e35-aa66-4866-9a53-f09719d6767c --detach --json'] },
1298
1336
  { path: ['device', 'requests'], summary: 'Review local device requests waiting for approval', positionals: [], options: {} },
1299
- ...['approve', 'deny'].map((action) => ({ path: ['device', action], summary: `${action} a local device request`, positionals: [{ name: 'id', required: true }], options: action === 'approve' ? { always: { type: 'boolean', description: 'Allow matching requests for this project; never for outside-folder access.' } } : {} })),
1337
+ ...['approve', 'deny'].map((action) => ({ path: ['device', action], summary: `${action} a local device request`, positionals: [{ name: 'id', required: true }], options: action === 'approve' ? { always: { type: 'boolean', description: 'Allow matching requests for this project, or for a folder request (0.25.0+) that folder and what is inside it; never for other access outside the conversation folder.' } } : {} })),
1338
+ { path: ['conversations', 'start'], summary: 'Start a conversation from the project or on your machine, no folder needed (0.25.0+)', positionals: [], options: {
1339
+ project: { type: 'string', value: '<id>', description: 'The project (default: the API key’s, or this computer’s selected project).' },
1340
+ home: { type: 'boolean', description: 'Start on your machine’s home, without a repository: the agent runs in /home/user and starts threads in the project’s repositories.' },
1341
+ repo: { type: 'string', value: '<remote>', description: 'The repository (default: the project’s most recently active one).' },
1342
+ branch: { type: 'string', value: '<name>', description: 'Start from this branch’s newest saved point in the project (default main, then master).' },
1343
+ app: { type: 'string', value: '<claude|codex>', description: 'Agent app (default claude).' },
1344
+ title: { type: 'string', value: '<text>', description: 'The conversation’s title (default: named by its first message).' },
1345
+ ...MODEL_OPTIONS,
1346
+ prompt: { type: 'string', value: '<text>', description: 'The first message.' },
1347
+ file: { type: 'string', multiple: true, value: '<path>', description: 'Attach a file to the first message (repeatable, up to 20 of 64 MiB each; needs --prompt).' },
1348
+ }, description: 'Starts a Claude Code or Codex conversation in its own cloud computer straight from the project: the repository is checked out from the project’s saved branches, so no local folder is needed. --home starts a coordinator on your machine instead, which spawns threads in the project’s repositories. Prints the conversation id, key and state; open it with shard agents open <id>.',
1349
+ examples: ['shard conversations start --prompt "Add CSV export to the invoices page"', 'shard conversations start --repo https://github.com/acme/app.git --branch main --app codex --prompt "Fix the flaky login test" --file trace.log', 'shard conversations start --home --title "Plan the billing work" --json'] },
1300
1350
  { path: ['conversations', 'try'], summary: 'Try a conversation in a synced local worktree', positionals: [{ name: 'conversation', required: true }], options: { path: { type: 'string', value: '<path>', description: 'Local project checkout.' }, stop: { type: 'boolean', description: 'Stop the device helper’s local sync and ports.' } } },
1301
1351
  { path: ['agents', 'targets'], summary: 'Detect apps or configure managed desktop connections', positionals: [{ name: 'agent' }], options: {
1302
1352
  remove: { type: 'boolean', description: 'Remove this agent’s managed entries, or all entries for this API URL.' },
@@ -1374,12 +1424,97 @@ const SETTINGS_COMMANDS = [{
1374
1424
  description: 'Shows the title marker, where new conversations open and the terminal app (change those two with "shard agents targets --open-in" and "--terminal"). The menu bar and desktop apps change the same settings.',
1375
1425
  examples: ['shard settings', 'shard settings --title-prefix SF', 'shard settings --title-prefix none', 'shard settings --title-prefix default --json'],
1376
1426
  }];
1377
- export const COMMANDS = [...ACCOUNT_COMMANDS.filter((c) => c.path[0] !== 'templates'), ...AGENT_COMMANDS, ...AGENT_CREDENTIAL_COMMANDS, ...AGENT_ACCOUNT_COMMANDS, ...ACCOUNT_ALIASES, ...CLI_PROXY_COMMANDS, ...MENUBAR_COMMANDS, ...SETTINGS_COMMANDS, ...KEY_COMMANDS, ...ACCOUNT_COMMANDS.filter((c) => c.path[0] === 'templates')];
1427
+ /** The board's input bar from a terminal (0.25.0+): route a line of input, ask a quick question about the work. */
1428
+ const BOARD_SCOPE = {
1429
+ org: { type: 'string', value: '<id|slug>', description: 'Organization whose board to read (default: the saved one, shard orgs use, else your only organization). Slugs need your signed-in session.' },
1430
+ project: { type: 'string', value: '<id|slug>', description: 'A project of it: the input leans to it when nothing else decides.' },
1431
+ };
1432
+ const BOARD_SCOPE_HELP = 'Reads your organization’s projects and open tasks with your signed-in session; with SHARDFLUX_API_KEY set (or only a saved project API key), that key’s project. It never starts work and never wakes a computer.';
1433
+ const ROUTER_COMMANDS = [
1434
+ {
1435
+ path: ['route'],
1436
+ summary: 'Route input like the board’s input bar: its project, task, question or steer, split per task (0.25.0+)',
1437
+ description: [
1438
+ 'Decides which project the input belongs to (or your home, for personal work), whether it is a new task, a question or a steer for an open task, and splits input that asks for several tasks into your own words per task, each with a title. "?" or "quick question" at the start makes it a question.',
1439
+ BOARD_SCOPE_HELP,
1440
+ 'Prints the kind and where it goes, then each part. With --json: the RouterResult (kind, parts with text, title, project_id and home, task_ref, confidence, uncertain, forced, routed_by, latency_ms).',
1441
+ ].join('\n\n'),
1442
+ positionals: [{ name: 'text', variadic: true, words: true, required: true }],
1443
+ options: {
1444
+ task: { type: 'string', value: '<task-id>', description: 'The open task you point at (task_…): input about it steers it, unless it asks about it.' },
1445
+ ...BOARD_SCOPE,
1446
+ },
1447
+ examples: ['shard route "fix the hero image on the landing page and add a GPU row to the pricing table"', 'shard route --task task_healthzhealthzhealthzhealt return 503 instead of 500 when the database is down', 'shard route "? is the deploy done" --json'],
1448
+ },
1449
+ {
1450
+ path: ['ask'],
1451
+ summary: 'Ask a quick question about your work, answered from the board as it is written (0.25.0+)',
1452
+ description: [
1453
+ 'Answers from your tasks, their plans and states, sealed reports, the conversations behind them and what their agents last wrote. The answer streams to standard output as it is written; one that needs work ends with "Make it a task?".',
1454
+ BOARD_SCOPE_HELP,
1455
+ 'With --json: the whole answer as one object (text, needs_work, sources, answered_by, first_token_ms, total_ms).',
1456
+ ].join('\n\n'),
1457
+ positionals: [{ name: 'question', variadic: true, words: true, required: true }],
1458
+ options: {
1459
+ task: { type: 'string', value: '<task-id>', description: 'The task the question is about (task_…).' },
1460
+ ...BOARD_SCOPE,
1461
+ },
1462
+ examples: ['shard ask what is the healthz work doing right now', 'shard ask --task task_healthzhealthzhealthzhealt "is it done?"', 'shard ask "what is blocking the pricing page?" --json'],
1463
+ },
1464
+ ];
1465
+ /** The project a drive or models command acts in (0.25.0+). */
1466
+ const PROJECT_SCOPE = {
1467
+ project: { type: 'string', value: '<id|slug>', description: 'The project (default: the API key’s, else your default project). Signed in, any of your projects, by id or slug.' },
1468
+ };
1469
+ const DRIVE_HELP = 'The project drive keeps a project’s files: the screenshots, logs, reports and notes your agents and people save and read by path, the same from a phone, a script or another agent whether the project’s computers are working, asleep or gone. Paths are relative to the project space root, the names agents see under /shardflux/project (tasks/t_ab12/evidence/healthz.png, BOARD.md). Every save is a new version named by the SHA-256 of its bytes, and every version stays readable by its sha256, also after the path is overwritten or removed.';
1470
+ const DRIVE_COMMANDS = [
1471
+ { path: ['drive', 'ls'], summary: 'List the project drive’s files: size, saved time, type and path (0.25.0+)', positionals: [{ name: 'prefix' }], options: {
1472
+ ...PROJECT_SCOPE,
1473
+ all: { type: 'boolean', description: 'Fetch every page.' },
1474
+ limit: { type: 'string', value: '<n>', description: 'Page size (1 to 1000, default 200).' },
1475
+ cursor: { type: 'string', value: '<cursor>', description: 'Continue from a previous page.' },
1476
+ }, description: `${DRIVE_HELP} Lists the current version of each file, by path; a prefix such as tasks/t_ab12/ lists only that folder. --json returns data (each file with its sha256) and next_cursor.`,
1477
+ examples: ['shard drive ls', 'shard drive ls tasks/t_ab12/evidence/', 'shard drive ls --all --json'] },
1478
+ { path: ['drive', 'get'], summary: 'Read a file from the project drive: its bytes to standard output, or to a file with -o (0.25.0+)', positionals: [{ name: 'path', required: true }], options: {
1479
+ ...PROJECT_SCOPE,
1480
+ sha256: { type: 'string', value: '<hex>', description: 'Read exactly this version (the current one or an earlier one).' },
1481
+ out: { type: 'string', short: 'o', value: '<file>', description: 'Write the bytes to this file.' },
1482
+ }, description: `${DRIVE_HELP} The bytes are checked against their SHA-256 before they are written. --json without -o returns the file as content_base64 with its sha256, size and content_type.`,
1483
+ examples: ['shard drive get BOARD.md', 'shard drive get tasks/t_ab12/evidence/healthz.png -o healthz.png', 'shard drive get BOARD.md --sha256 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'] },
1484
+ { path: ['drive', 'put'], summary: 'Save a file to the project drive as a new version, and print its path and sha256 (0.25.0+)', positionals: [{ name: 'local-file', required: true }, { name: 'drive-path' }], options: {
1485
+ ...PROJECT_SCOPE,
1486
+ 'content-type': { type: 'string', value: '<type>', description: 'Stored with the file (default: from its extension, e.g. .png image/png, .md text/markdown).' },
1487
+ }, description: `${DRIVE_HELP} The drive path defaults to the file’s name; - reads the file from standard input (name the drive path). Saving the bytes that are already current keeps that version.`,
1488
+ examples: ['shard drive put BOARD.md', 'shard drive put ./out/healthz.png tasks/t_ab12/evidence/healthz.png', 'git diff | shard drive put - tasks/t_ab12/review.diff --json'] },
1489
+ { path: ['drive', 'rm'], summary: 'Remove a file from the project drive; its versions stay readable by sha256 (0.25.0+)', positionals: [{ name: 'path', required: true }], options: { ...PROJECT_SCOPE },
1490
+ description: `${DRIVE_HELP} After rm the path no longer lists or reads; shard drive get <path> --sha256 <hex> still reads each of its versions.`,
1491
+ examples: ['shard drive rm tasks/t_ab12/notes/draft.md'] },
1492
+ ];
1493
+ const MODELS_HELP = 'The model template: which agent app (harness), model and effort each role of a task runs with, from the Claude and Codex accounts your organization connected. master plans and coordinates, builder does the work, hard takes the hardest parts, light the small ones, and reviewer reviews with a fresh context. The primary provider runs master, builder and hard; the other one, light and reviewer. A role whose account waits for its next usage window shows until when, and what the other provider would run now.';
1494
+ const MODEL_COMMANDS = [
1495
+ { path: ['models'], summary: 'Show which harness, model and effort each role of a task runs with (0.25.0+)', positionals: [], options: {
1496
+ ...PROJECT_SCOPE,
1497
+ harness: { type: 'string', value: '<claude|codex>', description: 'The provider the task runs on: keeps master, builder and hard work on it.' },
1498
+ attempt: { type: 'string', value: '<n>', description: 'A retry after a failure (1 to 10): retries move to the other provider, or one tier up when only one is connected.' },
1499
+ }, description: `${MODELS_HELP} --json returns the template: primary, secondary, connected and roles, with each role’s harness, model and effort exactly as shard conversations start --app, --model and --effort take them.`,
1500
+ examples: ['shard models', 'shard models --harness codex --attempt 1', 'shard models --json'] },
1501
+ { path: ['models', 'primary'], summary: 'Make Claude or Codex the primary provider of this project or your organization, or clear it (0.25.0+)', positionals: [{ name: 'claude|codex|clear', required: true }], options: {
1502
+ ...PROJECT_SCOPE,
1503
+ org: { type: 'string', value: '<id|slug>', description: 'Set the organization’s default for every project instead (owners and admins, signed in).' },
1504
+ }, description: `${MODELS_HELP} The primary is this project’s choice when it has one, else the organization’s, else the provider connected first; clear removes the choice. Prints the template with the new primary.`,
1505
+ examples: ['shard models primary codex', 'shard models primary claude --org acme', 'shard models primary clear --project web'] },
1506
+ ];
1507
+ export const COMMANDS = [...ACCOUNT_COMMANDS.filter((c) => c.path[0] !== 'templates'), ...AGENT_COMMANDS, ...ROUTER_COMMANDS, ...AGENT_CREDENTIAL_COMMANDS, ...AGENT_ACCOUNT_COMMANDS, ...ACCOUNT_ALIASES, ...CLI_PROXY_COMMANDS, ...MENUBAR_COMMANDS, ...SETTINGS_COMMANDS, ...KEY_COMMANDS, ...BOARD_COMMANDS, ...DRIVE_COMMANDS, ...MODEL_COMMANDS, ...ACCOUNT_COMMANDS.filter((c) => c.path[0] === 'templates')];
1378
1508
  const GROUPS = {
1379
1509
  device: 'Local device approvals',
1380
1510
  'cli-proxy': 'Your hosted CLIProxyAPI, reachable at http://127.0.0.1:8317 on this computer and in every VM',
1381
1511
  menubar: 'macOS menu bar app',
1382
1512
  conversations: 'Project conversations, branches and messages',
1513
+ task: 'Tasks on the board, in your own words: add, show, edit, move, steer, delete and clear them (0.25.0+)',
1514
+ 'needs-you': 'Everything your agents wait on, oldest first, and one answer command for each (0.25.0+)',
1515
+ approvals: 'The approval mode and always-allow rules your agents work under (0.25.0+)',
1516
+ drive: 'The project drive: files every agent, phone and person of the project reads and writes, each version kept by its SHA-256 (0.25.0+)',
1517
+ models: 'The model template: which harness, model and effort each role of a task runs with, and the primary provider (0.25.0+)',
1383
1518
  agents: 'Cloud agent sessions and copied credentials',
1384
1519
  auth: 'Create an account and sign in (the session is saved in the credentials file); passwords, email, two-factor authentication and sessions',
1385
1520
  'auth password': 'Change or reset your password',
@@ -1792,7 +1927,7 @@ export const EXIT_CODE_HELP = [
1792
1927
  /** The top help's sections: every command's group (first word) is in exactly one (args.test.ts checks). */
1793
1928
  export const HELP_SECTIONS = [
1794
1929
  { title: 'Account (a user session: shard signup or shard auth login)', groups: ['signup', 'verify', 'auth', 'setup', 'env', 'orgs', 'projects', 'api-keys', 'members', 'invitations', 'billing', 'audit', 'account'] },
1795
- { title: 'Cloud agents (shard ./ starts one; a project API key)', groups: ['conversations', 'move', 'machine', 'template', 'agents', 'settings', 'accounts', 'device', 'cli-proxy', 'ssh-proxy'] },
1930
+ { title: 'Cloud agents (shard ./ starts one; a project API key)', groups: ['conversations', 'board', 'task', 'needs-you', 'approvals', 'route', 'ask', 'drive', 'models', 'move', 'machine', 'template', 'agents', 'settings', 'accounts', 'device', 'cli-proxy', 'ssh-proxy'] },
1796
1931
  { title: 'Workspaces for your app (a project API key: SHARDFLUX_API_KEY, else the one shard setup saved)', groups: ['login', 'whoami', 'status', 'usage', 'workspaces', 'files', 'operations', 'executions', 'secrets', 'credentials', 'volumes', 'egress'] },
1797
1932
  { title: 'Templates for your app’s workspaces (not for cloud agents; publish and archive use the session, the rest the API key)', groups: ['templates'] },
1798
1933
  { title: 'Other', groups: ['menubar', 'update', 'feedback', 'version'] },
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The Orchestrator board's command table (0.25.0+, SDK 0.28.0): `shard board`, `shard task …`, `shard needs-you …` and
3
+ * `shard approvals …`. Pure data like args.ts, which merges it into COMMANDS; board-commands.ts has the handlers.
4
+ */
5
+ import type { CommandSpec } from './args.js';
6
+ export declare const BOARD_COMMANDS: CommandSpec[];