@0gfoundation/0g-agentdna 0.2.1 → 0.2.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.
Files changed (86) hide show
  1. package/GUIDE.md +67 -18
  2. package/MIGRATION.md +8 -0
  3. package/MIGRATION.zh.md +5 -0
  4. package/PROVIDERS.md +6 -4
  5. package/PROVIDERS.zh.md +4 -3
  6. package/README.md +20 -4
  7. package/dist/AgentClient.d.ts +175 -2
  8. package/dist/AgentClient.d.ts.map +1 -1
  9. package/dist/AgentClient.js +166 -7
  10. package/dist/AgentClient.js.map +1 -1
  11. package/dist/AgenticID.d.ts +47 -7
  12. package/dist/AgenticID.d.ts.map +1 -1
  13. package/dist/AgenticID.js +44 -13
  14. package/dist/AgenticID.js.map +1 -1
  15. package/dist/AgenticIDClient.d.ts +1 -1
  16. package/dist/AgenticIDClient.js +1 -1
  17. package/dist/AttestorClient.d.ts +67 -2
  18. package/dist/AttestorClient.d.ts.map +1 -1
  19. package/dist/AttestorClient.js +162 -33
  20. package/dist/AttestorClient.js.map +1 -1
  21. package/dist/ReputationClient.d.ts +1 -1
  22. package/dist/ReputationClient.js +1 -1
  23. package/dist/SandboxClient.d.ts +1 -1
  24. package/dist/SandboxClient.js +1 -1
  25. package/dist/cli/commands/doctor.d.ts.map +1 -1
  26. package/dist/cli/commands/doctor.js +8 -2
  27. package/dist/cli/commands/doctor.js.map +1 -1
  28. package/dist/cli/commands/interactive.d.ts +71 -2
  29. package/dist/cli/commands/interactive.d.ts.map +1 -1
  30. package/dist/cli/commands/interactive.js +423 -46
  31. package/dist/cli/commands/interactive.js.map +1 -1
  32. package/dist/cli/commands/settings.d.ts.map +1 -1
  33. package/dist/cli/commands/settings.js +23 -0
  34. package/dist/cli/commands/settings.js.map +1 -1
  35. package/dist/cli/config.d.ts +10 -0
  36. package/dist/cli/config.d.ts.map +1 -1
  37. package/dist/cli/config.js +38 -0
  38. package/dist/cli/config.js.map +1 -1
  39. package/dist/cli/env.js +1 -1
  40. package/dist/cli/env.js.map +1 -1
  41. package/dist/cli/inference.d.ts +25 -0
  42. package/dist/cli/inference.d.ts.map +1 -1
  43. package/dist/cli/inference.js +67 -6
  44. package/dist/cli/inference.js.map +1 -1
  45. package/dist/cli/main.js +12 -2
  46. package/dist/cli/main.js.map +1 -1
  47. package/dist/cli/sdk.d.ts +1 -1
  48. package/dist/cli/sdk.js +1 -1
  49. package/dist/cli/settings.d.ts +20 -0
  50. package/dist/cli/settings.d.ts.map +1 -1
  51. package/dist/cli/settings.js +40 -1
  52. package/dist/cli/settings.js.map +1 -1
  53. package/dist/constants.d.ts +3 -3
  54. package/dist/constants.js +2 -2
  55. package/dist/context.d.ts +2 -2
  56. package/dist/context.d.ts.map +1 -1
  57. package/dist/context.js +1 -1
  58. package/dist/index.d.ts +4 -3
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +6 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/secretEnv.js +1 -1
  63. package/dist/secretEnv.js.map +1 -1
  64. package/dist/types.d.ts +1 -1
  65. package/dist/types.js +1 -1
  66. package/package.json +1 -1
  67. package/src/AgentClient.ts +326 -9
  68. package/src/AgenticID.ts +66 -11
  69. package/src/AgenticIDClient.ts +1 -1
  70. package/src/AttestorClient.ts +207 -51
  71. package/src/ReputationClient.ts +1 -1
  72. package/src/SandboxClient.ts +1 -1
  73. package/src/cli/commands/doctor.ts +8 -2
  74. package/src/cli/commands/interactive.ts +405 -51
  75. package/src/cli/commands/settings.ts +22 -1
  76. package/src/cli/config.ts +36 -0
  77. package/src/cli/env.ts +1 -1
  78. package/src/cli/inference.ts +82 -5
  79. package/src/cli/main.ts +13 -3
  80. package/src/cli/sdk.ts +1 -1
  81. package/src/cli/settings.ts +41 -0
  82. package/src/constants.ts +3 -3
  83. package/src/context.ts +2 -2
  84. package/src/index.ts +7 -3
  85. package/src/secretEnv.ts +1 -1
  86. package/src/types.ts +1 -1
@@ -19,7 +19,7 @@ import { join } from 'node:path';
19
19
  import { SDK_VERSION } from '../../constants';
20
20
  import { parseEther, keccak256, isAddress, ContractFunctionRevertedError, type Address } from 'viem';
21
21
  import type { AgenticID } from '../../AgenticID';
22
- import type { AgentClient, ChatMessage } from '../../AgentClient';
22
+ import type { AgentClient, AgentInboxMessage, AgentSchedule, AgentTaskInfo, AgentTaskStop, ChatMessage } from '../../AgentClient';
23
23
  import type { ServeProof, TaskReveal } from '../../types';
24
24
  import { taskHashOf, requestUriCandidates } from '../../taskHash';
25
25
  import { buildClient } from '../sdk';
@@ -28,17 +28,17 @@ import { CliError } from '../errors';
28
28
  import { requireAttestorUrl } from '../env';
29
29
  import { loadKey, saveKey, normalizeKey, saveApiKey, loadConfig, saveConfig, configPaths } from '../config';
30
30
  import { parseAgentRef, refMatchesSeal, type AgentRef } from '../ref';
31
- import { applyAssignments, assertModelPresent, parseAssignments, renderSettings } from '../settings';
31
+ import { applyAssignments, assertModelPresent, assertOthersFitFramework, isHarnessFramework, parseAssignments, renderSettings } from '../settings';
32
32
  import { SettingsConflictError, THINKING_LEVELS, type SettingsDoc, type ThinkingLevel } from '../../Settings';
33
33
  import { splitHead, tokenize } from '../tokenize';
34
34
  import { pandaLines, svgPixelLines } from '../logo';
35
35
  import { listInferenceProviders, type InferenceProvider, changesProvider } from '../../Providers';
36
- import { configuredInferenceKey, requireConfiguredInferenceKey, agentInferenceProvider, requiresProviderReset, deployWithInference } from '../inference';
36
+ import { configuredInferenceKey, requireConfiguredInferenceKey, resetInferencePlan, applyResetInference, readDeploymentFacts, requiresProviderReset, deployWithInference } from '../inference';
37
37
 
38
38
  // Tab-completion candidates for the active REPL level (canonical names only —
39
39
  // aliases like link//unuse still work typed out but don't clutter the list).
40
40
  const L1_WORDS = ['list', 'use ', 'hello ', 'call ', 'rate ', 'deploy', 'start ', 'stop ', 'reset ', 'retry ', 'settings ', 'clone ', 'transfer ', 'authorizer ', 'grant ', 'revoke ', 'balance', 'deposit', 'withdraw', 'ack', 'login', 'whoami', 'help', 'quit'];
41
- const L2_WORDS = ['/hello', '/balance', '/topup', '/start', '/stop', '/reset', '/settings', '/think', '/clear', '/compact', '/tasks', '/result', '/cancel', '/agentlog', '/startuplog', '/back', '/help', '/quit'];
41
+ const L2_WORDS = ['/hello', '/balance', '/topup', '/start', '/stop', '/reset', '/settings', '/think', '/clear', '/compact', '/tasks', '/result', '/cancel', '/inbox', '/schedules', '/agentlog', '/startuplog', '/back', '/help', '/quit'];
42
42
  let activeCompletions: string[] = L1_WORDS;
43
43
  // First-argument completion per command (Tab after the command word).
44
44
  // Static lists inline; AGENT resolves to the ids seen in the latest
@@ -232,8 +232,9 @@ export async function routeTaskFailure(
232
232
 
233
233
  /**
234
234
  * The tasks bare `/cancel` stops: everything still in flight, NEWEST FIRST
235
- * (stopping only the newest would leave an older running turn alive; dsh/
236
- * prime serialize turns, so a queued one is waiting on the running one).
235
+ * (stopping only the newest would leave an older running turn alive;
236
+ * 0g-harness and prime serialize turns, so a queued one is waiting on the
237
+ * running one).
237
238
  * Statuses arrive live from the agent; "unknown" (evicted or agent
238
239
  * restarted, 404) counts as not in flight — cancelling an unknown record
239
240
  * would claim to stop something nobody can see. Exported for the tests:
@@ -247,6 +248,148 @@ export function inFlightIds(rows: Array<{ id: string; status: string }>): string
247
248
  return out;
248
249
  }
249
250
 
251
+ /** A span of seconds, short: 12s, 4m, 3h, 2d. */
252
+ function span(seconds: number): string {
253
+ const s = Math.max(0, Math.round(seconds));
254
+ if (s < 60) return `${s}s`;
255
+ if (s < 3600) return `${Math.floor(s / 60)}m`;
256
+ if (s < 86400) return `${Math.floor(s / 3600)}h`;
257
+ return `${Math.floor(s / 86400)}d`;
258
+ }
259
+
260
+ /** Who asked for a task, as /tasks shows it. */
261
+ const ASKED_BY: Record<string, string> = { user: 'you', job: 'job', schedule: 'reminder', plugin: 'plugin', agent: 'agent' };
262
+
263
+ /**
264
+ * The /tasks table over the agent's own task list: BY is who does the work
265
+ * (the main agent or a subagent), FOR is who asked (you, a finished job, a
266
+ * reminder, the agent itself). Ids print whole: they are what /result and
267
+ * /cancel take. Exported for the tests.
268
+ */
269
+ export function renderTaskTable(tasks: AgentTaskInfo[], nowMs: number): string[] {
270
+ const idw = Math.max(2, ...tasks.map((t) => cleanCell(t.id).length)) + 2;
271
+ const head = ` ${'ID'.padEnd(idw)}${'STATUS'.padEnd(13)}${'BY'.padEnd(10)}${'FOR'.padEnd(10)}${'AGE'.padEnd(6)}WHAT`;
272
+ return [
273
+ head,
274
+ ...tasks.map((t) =>
275
+ ` ${cleanCell(t.id).padEnd(idw)}${cellText(t.status, 13)}${cellText(t.actor, 10)}` +
276
+ `${cellText(ASKED_BY[t.trigger] ?? t.trigger, 10)}${span(nowMs / 1000 - t.created_at).padEnd(6)}` +
277
+ `${[...cleanCell(t.label)].slice(0, 70).join('')}`),
278
+ ];
279
+ }
280
+
281
+ /**
282
+ * One inbox message as the session prints it: why the agent spoke up, then
283
+ * what it said. Exported for the tests.
284
+ */
285
+ export function renderInboxMessage(m: AgentInboxMessage): string {
286
+ const label = cleanCell(m.label);
287
+ const why = m.trigger === 'job' ? `job finished · ${label}`
288
+ : m.trigger === 'schedule' ? `reminder · ${label}`
289
+ : label || cleanCell(m.trigger);
290
+ const lines = [`◆ agent · ${why}`];
291
+ if (m.text?.trim()) lines.push(m.text.replace(/\s+$/, ''));
292
+ if (m.status === 'failed') lines.push(`(that turn failed: ${cleanCell(m.error ?? 'no reason given')})`);
293
+ else if (m.status === 'cancelled') lines.push('(that turn was cancelled)');
294
+ return `${lines.join('\n')}\n`;
295
+ }
296
+
297
+ /** The /schedules lines: id, how often, when next, the reminder's text.
298
+ * Exported for the tests. */
299
+ export function renderSchedules(list: AgentSchedule[], nowMs: number): string[] {
300
+ const idw = Math.max(2, ...list.map((r) => cleanCell(r.id).length)) + 2;
301
+ return list.map((r) => {
302
+ const how = r.kind === 'every' && r.everySeconds ? `every ${span(r.everySeconds)}` : 'once';
303
+ const due = r.state === 'overdue' ? 'due now' : `in ${span((Date.parse(r.scheduledAt) - nowMs) / 1000)}`;
304
+ return ` ${cleanCell(r.id).padEnd(idw)}${how.padEnd(12)}${due.padEnd(12)}${cleanCell(r.prompt)}`;
305
+ });
306
+ }
307
+
308
+ /** What stopping a task did, in words. */
309
+ const STOP_OUTCOME: Record<AgentTaskStop['outcome'], string> = {
310
+ cancelled: 'stopped',
311
+ 'already-finished': 'already finished',
312
+ 'not-running': 'not running',
313
+ };
314
+
315
+ /**
316
+ * Follows one agent's inbox for a session: first the messages that came in
317
+ * while nobody was looking, then each new one as the agent's live feed
318
+ * announces it. `show` prints a rendered message, now or at the next prompt,
319
+ * and calls `shown` once it is on screen; the message is acked then, so
320
+ * another window does not show it again. A message is shown once per feed.
321
+ * `follow` is called with the session's current client before every prompt
322
+ * and restarts the feed when the client changed (/start, /reset); an agent
323
+ * without an inbox gets no feed. Exported for the tests.
324
+ */
325
+ export function makeInboxFeed(show: (text: string, shown: () => void) => void): {
326
+ follow(client: AgentClient | undefined): void;
327
+ stop(): void;
328
+ } {
329
+ let current: AgentClient | undefined;
330
+ let ac: AbortController | null = null;
331
+
332
+ async function run(client: AgentClient, signal: AbortSignal): Promise<void> {
333
+ const seen = new Set<number>();
334
+ let acked = 0;
335
+ const present = (msgs: AgentInboxMessage[], away: boolean): void => {
336
+ const fresh = msgs.filter((m) => !seen.has(m.seq));
337
+ if (!fresh.length || signal.aborted) return;
338
+ for (const m of fresh) seen.add(m.seq);
339
+ const through = Math.max(...fresh.map((m) => m.seq));
340
+ const text = (away ? `\nwhile you were away (${fresh.length}):\n` : '\n') + fresh.map(renderInboxMessage).join('\n');
341
+ show(text, () => {
342
+ if (through <= acked) return;
343
+ acked = through;
344
+ // Best-effort: a window that lost the seat cannot ack (409), and the
345
+ // owner's next window shows the message again.
346
+ client.ackInbox?.(through).catch(() => undefined);
347
+ });
348
+ };
349
+ const readUnread = async (away: boolean): Promise<number | undefined> => {
350
+ const page = await client.inbox!();
351
+ present(page.data, away);
352
+ return page.cursor;
353
+ };
354
+ let cursor: number | undefined;
355
+ try {
356
+ cursor = await readUnread(true);
357
+ } catch {
358
+ // The feed still runs; its first event, or a reset, catches up.
359
+ }
360
+ if (signal.aborted || !client.events) return;
361
+ try {
362
+ for await (const e of client.events({ after: cursor, signal })) {
363
+ // An inbox message's seq is its event's.
364
+ if (e.type === 'inbox.message') present([{ ...(e.data as unknown as AgentInboxMessage), seq: e.seq }], false);
365
+ // The agent could not serve our position: what we may have missed
366
+ // is in the inbox itself.
367
+ else if (e.type === 'reset') await readUnread(false).catch(() => undefined);
368
+ }
369
+ } catch {
370
+ // A 4xx: this agent no longer serves the feed. Nothing to say at the
371
+ // prompt about it; /inbox still reads the inbox.
372
+ }
373
+ }
374
+
375
+ const stop = (): void => {
376
+ ac?.abort();
377
+ ac = null;
378
+ current = undefined;
379
+ };
380
+ return {
381
+ follow(client) {
382
+ if (client === current) return;
383
+ stop();
384
+ if (!client?.inbox) return;
385
+ current = client;
386
+ ac = new AbortController();
387
+ void run(client, ac.signal);
388
+ },
389
+ stop,
390
+ };
391
+ }
392
+
250
393
  let knownAgentIds: string[] = [];
251
394
  const rememberAgentIds = (rows: Array<{ agentId?: unknown }>): void => {
252
395
  const ids = rows.map((r) => String(r.agentId ?? '')).filter((x) => x && x !== 'undefined');
@@ -285,6 +428,8 @@ const L1_ARGS: Record<string, string[] | (() => string[])> = {
285
428
  const L2_ARGS: Record<string, string[] | (() => string[])> = {
286
429
  '/think': ['low', 'high', 'max'],
287
430
  '/reset': ['pick'],
431
+ '/cancel': ['all'],
432
+ '/inbox': ['all'],
288
433
  '/settings': ['provider=', 'model=', 'thinking=', 'others='],
289
434
  };
290
435
  let activeArgs: Record<string, string[] | (() => string[])> = L1_ARGS;
@@ -356,6 +501,34 @@ export function completeLine(
356
501
  // The live readline interface — askSecret scrubs submitted secrets out of
357
502
  // its history (display masking alone leaves the plaintext one ↑ away).
358
503
  let activeRl: readline.Interface | null = null;
504
+
505
+ /**
506
+ * Print a block above the live prompt, keeping what the user has typed. The
507
+ * prompt and its input are erased from their first row down, the block is
508
+ * written, and readline redraws the prompt below it. Its redraw first moves
509
+ * up as many rows as the cursor sat below the prompt's first row (the
510
+ * prompt's own leading newline counts), so that many blank rows are left for
511
+ * it to land on. Without a terminal there is no prompt to keep: the block is
512
+ * just written. `rl`/`output` are the session's; exported for the tests,
513
+ * which pass a readline over a captured stream.
514
+ */
515
+ export function printAbovePrompt(
516
+ text: string,
517
+ rl: readline.Interface | null = activeRl,
518
+ output: NodeJS.WritableStream = process.stdout,
519
+ ): void {
520
+ if (!rl || !rl.terminal) {
521
+ output.write(text.startsWith('\n') ? text : `\n${text}`);
522
+ return;
523
+ }
524
+ const { rows } = rl.getCursorPos();
525
+ readline.moveCursor(output, 0, -rows);
526
+ readline.cursorTo(output, 0);
527
+ readline.clearScreenDown(output);
528
+ output.write(text.endsWith('\n') ? text : `${text}\n`);
529
+ output.write('\n'.repeat(rows));
530
+ rl.prompt(true);
531
+ }
359
532
  import type { CommandContext } from '../types';
360
533
  import { cellText, cleanCell, ownerCellText, sealToAgentMap, shortAddr, trustedCell } from './cells';
361
534
 
@@ -512,19 +685,63 @@ async function refreshSession(s: Session, quiet = false): Promise<void> {
512
685
  if (reason) out(` last error: ${reason}\n`);
513
686
  }
514
687
 
688
+ /** An agent's container state just before a lifecycle request was sent. */
689
+ export interface LifecycleBaseline {
690
+ /** The container stage's `at`, in ms (server clock); undefined when it has none. */
691
+ at?: number;
692
+ state?: string;
693
+ sandboxId?: string;
694
+ }
695
+
696
+ /**
697
+ * Read the row a lifecycle request is about to change. The attestor answers
698
+ * `/reset` and `/start` with 202 before its worker touches the row, so the
699
+ * wait compares against this. undefined when the row cannot be read; the wait
700
+ * then takes the row as it finds it.
701
+ */
702
+ export async function lifecycleBaseline(attestorUrl: string, sealId: `0x${string}`): Promise<LifecycleBaseline | undefined> {
703
+ try {
704
+ const d = (await (await fetch(`${attestorUrl}/deployment/${sealId}`, { signal: AbortSignal.timeout(10_000) })).json()) as {
705
+ sandbox_id?: string; container_stage?: { state?: string; at?: string };
706
+ };
707
+ const at = Date.parse(d.container_stage?.at ?? '');
708
+ return { at: Number.isFinite(at) ? at : undefined, state: d.container_stage?.state, sandboxId: d.sandbox_id };
709
+ } catch {
710
+ return undefined;
711
+ }
712
+ }
713
+
515
714
  /**
516
715
  * Wait for a deployment to reach `running` by polling the attestor's public
517
716
  * /deployment/:sealId — and FAIL LOUD instead of hanging: a `failed`/`offline`
518
717
  * phase (or a failed container_stage) surfaces its recorded reason
519
718
  * immediately, and the timeout produces an error naming the last phase seen.
719
+ *
720
+ * With a `baseline` (the row read before a reset or start was sent), the row
721
+ * as it was then is not this request's outcome: until the worker moves the
722
+ * container on (a new start or create, a new sandbox, a stage written after
723
+ * the baseline), the wait shows `queued` and neither a still-running old
724
+ * container nor an earlier failure ends it.
520
725
  */
521
726
  class WaitCancelled extends Error { constructor() { super('wait cancelled'); } }
522
727
 
523
- async function pollRunning(attestorUrl: string, sealId: `0x${string}`, agentId: string, timeoutMs = 360000, signal?: AbortSignal): Promise<{ url: string }> {
728
+ export async function pollRunning(
729
+ attestorUrl: string,
730
+ sealId: `0x${string}`,
731
+ agentId: string,
732
+ timeoutMs = 360000,
733
+ signal?: AbortSignal,
734
+ opts: { baseline?: LifecycleBaseline; intervalMs?: number } = {},
735
+ ): Promise<{ url: string }> {
736
+ const { baseline, intervalMs = 4000 } = opts;
524
737
  const deadline = Date.now() + timeoutMs;
525
738
  const t0 = Date.now();
526
739
  let lastPhase = 'contacting attestor';
527
740
  let lastShown = '';
741
+ // Whether the request has visibly started: a fresh `submitted` stage, a new
742
+ // sandbox, or a stage written after the baseline other than the old
743
+ // container's own running reports.
744
+ let progressed = !baseline;
528
745
  // Transient progress line between phase changes — a deploy sits minutes in
529
746
  // one phase with zero output otherwise. Repainted each second; phase-change
530
747
  // lines and the final result overwrite it. TTY only.
@@ -550,15 +767,22 @@ async function pollRunning(attestorUrl: string, sealId: `0x${string}`, agentId:
550
767
  const d = (await (await fetch(`${attestorUrl}/deployment/${sealId}`)).json()) as {
551
768
  phase?: string; url?: string; sandbox_id?: string;
552
769
  agent_card?: { url?: string };
553
- container_stage?: { state?: string; reason?: string };
770
+ container_stage?: { state?: string; reason?: string; at?: string };
554
771
  };
555
- lastPhase = d.phase ?? lastPhase;
772
+ if (!progressed && baseline) {
773
+ const at = Date.parse(d.container_stage?.at ?? '');
774
+ const fresh = Number.isFinite(at) && (baseline.at === undefined || at > baseline.at);
775
+ const state = d.container_stage?.state;
776
+ progressed = (fresh && !(state === 'confirmed' && baseline.state === 'confirmed'))
777
+ || (d.sandbox_id !== undefined && d.sandbox_id !== baseline.sandboxId);
778
+ }
779
+ lastPhase = progressed ? (d.phase ?? lastPhase) : 'queued';
556
780
  if (lastPhase !== lastShown) { clearSpinner(); out(` … ${lastPhase}\n`); lastShown = lastPhase; }
557
781
  const cardBase = d.agent_card?.url?.replace(/\/hello$/, '');
558
782
  const url = d.url ?? cardBase ?? (d.sandbox_id && cfg.sandbox_proxy_addr ? containerUrl(d.sandbox_id, cfg.sandbox_proxy_addr) : undefined);
559
- if (d.phase === 'running' && url) return { url };
783
+ if (progressed && d.phase === 'running' && url) return { url };
560
784
  const reason = d.container_stage?.state === 'failed' ? d.container_stage?.reason : undefined;
561
- if (d.phase === 'failed' || reason) {
785
+ if (progressed && (d.phase === 'failed' || reason)) {
562
786
  throw new CliError('UNKNOWN', `agent ${agentId} did not start: ${reason ?? `phase=${d.phase}`}`, {
563
787
  remedy: `run \`reset ${agentId}\` to recreate the container once the cause is fixed`,
564
788
  });
@@ -568,12 +792,17 @@ async function pollRunning(attestorUrl: string, sealId: `0x${string}`, agentId:
568
792
  // transient fetch error — keep polling until the deadline
569
793
  }
570
794
  if (Date.now() > deadline) {
795
+ if (!progressed) {
796
+ throw new CliError('UNKNOWN', `agent ${agentId} did not come online: the attestor had not started this request after ${Math.round(timeoutMs / 1000)}s`, {
797
+ remedy: 'a request that waits too long in the attestor\'s queue expires and leaves the agent as it was — run the command again',
798
+ });
799
+ }
571
800
  throw new CliError('UNKNOWN', `timed out after ${Math.round(timeoutMs / 1000)}s waiting for agent ${agentId} (last phase: ${lastPhase})`, {
572
801
  remedy: 'check `status` — provisioning can lag; retry the command when the phase moves',
573
802
  });
574
803
  }
575
804
  if (signal?.aborted) throw new WaitCancelled();
576
- await new Promise((r) => setTimeout(r, 4000));
805
+ await new Promise((r) => setTimeout(r, intervalMs));
577
806
  if (signal?.aborted) throw new WaitCancelled();
578
807
  }
579
808
  } finally {
@@ -584,11 +813,11 @@ async function pollRunning(attestorUrl: string, sealId: `0x${string}`, agentId:
584
813
 
585
814
  /** pollRunning wired to the Esc/Ctrl-C interrupt: cancelling abandons the
586
815
  * WAIT only — the lifecycle operation keeps going server-side. */
587
- async function waitRunningInterruptible(irq: Interrupt, attestorUrl: string, sealId: `0x${string}`, agentId: string): Promise<{ url: string } | null> {
816
+ async function waitRunningInterruptible(irq: Interrupt, attestorUrl: string, sealId: `0x${string}`, agentId: string, baseline?: LifecycleBaseline): Promise<{ url: string } | null> {
588
817
  const ac = new AbortController();
589
818
  irq.streaming = ac;
590
819
  try {
591
- return await pollRunning(attestorUrl, sealId, agentId, 360000, ac.signal);
820
+ return await pollRunning(attestorUrl, sealId, agentId, 360000, ac.signal, { baseline });
592
821
  } catch (e) {
593
822
  if (e instanceof WaitCancelled || ac.signal.aborted) {
594
823
  out('\n(wait cancelled — the operation continues server-side; check with `list` or re-enter with `use`)\n');
@@ -1102,8 +1331,9 @@ async function managerRepl(ctx: CommandContext, ask: (q: string) => Promise<stri
1102
1331
  if (row.phase !== 'stopped' || !row.sandboxId) { out(`agent ${row.agentId} is ${row.phase} — a plain start cannot revive it; run: reset ${row.agentId}\n`); continue; }
1103
1332
  if (!(await ensureOwnerReady(ag, ask))) { out('start cancelled — prepaid balance too low\n'); continue; }
1104
1333
  out(`starting agent ${row.agentId}… (Esc cancels the wait)\n`);
1334
+ const baseline = await lifecycleBaseline(attestorUrl, row.sealId);
1105
1335
  await ag.agent.start(row.sealId, row.sandboxId);
1106
- const r = await waitRunningInterruptible(irq, attestorUrl, row.sealId, row.agentId);
1336
+ const r = await waitRunningInterruptible(irq, attestorUrl, row.sealId, row.agentId, baseline);
1107
1337
  if (r) out(`running at ${r.url} — enter with: use ${row.agentId}\n`);
1108
1338
  continue;
1109
1339
  }
@@ -1117,13 +1347,16 @@ async function managerRepl(ctx: CommandContext, ask: (q: string) => Promise<stri
1117
1347
  } else {
1118
1348
  framework = await pickFramework(attestorUrl, ask, row.framework ?? undefined);
1119
1349
  }
1120
- const provider = await agentInferenceProvider(ag, row.sealId);
1350
+ const plan = await resetInferencePlan(ag, row.sealId, await readDeploymentFacts(attestorUrl, row.sealId));
1351
+ const provider = plan.provider;
1121
1352
  await ag.agent.assertProviderSupported(provider, { sealId: row.sealId, framework });
1122
1353
  const apiKey = await inferenceKey(ctx, ask, provider);
1123
1354
  if (!(await ensureOwnerReady(ag, ask))) { out('reset cancelled — prepaid balance too low\n'); continue; }
1355
+ await applyResetInference(ag, row.sealId, plan, out);
1124
1356
  out(`resetting agent ${row.agentId} as ${framework}… (Esc cancels the wait)\n`);
1357
+ const baseline = await lifecycleBaseline(attestorUrl, row.sealId);
1125
1358
  await ag.agent.reset(row.sealId, { provider, framework, apiKey });
1126
- const r = await waitRunningInterruptible(irq, attestorUrl, row.sealId, row.agentId);
1359
+ const r = await waitRunningInterruptible(irq, attestorUrl, row.sealId, row.agentId, baseline);
1127
1360
  if (r) out(`running at ${r.url} — enter with: use ${row.agentId}\n`);
1128
1361
  continue;
1129
1362
  }
@@ -1158,7 +1391,7 @@ async function managerRepl(ctx: CommandContext, ask: (q: string) => Promise<stri
1158
1391
  const ag = await withWallet(ctx);
1159
1392
  const row = await findAgentRow(ag, args[0]);
1160
1393
  if (!row) { out(`no agent matching ${args[0]} on this attestor\n`); continue; }
1161
- await settingsOp(ag, row.sealId, args.slice(1), row.phase === 'running' && row.url ? row.url : undefined);
1394
+ await settingsOp(ag, row.sealId, args.slice(1), row.phase === 'running' && row.url ? row.url : undefined, row.framework);
1162
1395
  continue;
1163
1396
  }
1164
1397
 
@@ -1480,8 +1713,9 @@ let cachedClient: { key: string; ag: AgenticID } | null = null;
1480
1713
  * Returns the document now in force (unchanged on a bare show), so a caller
1481
1714
  * like /think can report the level that actually landed.
1482
1715
  */
1483
- async function settingsOp(ag: AgenticID, sealId: `0x${string}`, args: string[], serveBase?: string): Promise<SettingsDoc | null> {
1716
+ async function settingsOp(ag: AgenticID, sealId: `0x${string}`, args: string[], serveBase?: string, framework?: string | null): Promise<SettingsDoc | null> {
1484
1717
  const assignments = parseAssignments(args); // throws CliError on a bad key/level
1718
+ assertOthersFitFramework(assignments, framework);
1485
1719
  const { settings: current, version } = await ag.agent.getSettings(sealId);
1486
1720
  if (!assignments.length) {
1487
1721
  for (const l of renderSettings(current)) out(` ${l}\n`);
@@ -1866,6 +2100,15 @@ async function ensureOwnerReady(ag: AgenticID, ask: (q: string) => Promise<strin
1866
2100
  return true;
1867
2101
  }
1868
2102
 
2103
+ /**
2104
+ * Whether the deploy wizard offers `framework` only models with tool use: the
2105
+ * tool-driven frameworks, the harness under either of its names (`dsh` on a
2106
+ * network still on AgentDNA 1.3, see `isHarnessFramework`).
2107
+ */
2108
+ export function frameworkNeedsToolModels(framework: string): boolean {
2109
+ return framework === 'openclaw' || framework === 'prime-agent' || isHarnessFramework(framework);
2110
+ }
2111
+
1869
2112
  async function deployWizard(ag: AgenticID, attestorUrl: string, ask: (q: string) => Promise<string>, ctx: CommandContext, irq: Interrupt): Promise<Session | null> {
1870
2113
  const cfg = (await fetch(`${attestorUrl}/config`, { signal: AbortSignal.timeout(10_000) })
1871
2114
  .then((r) => r.json())
@@ -1889,10 +2132,9 @@ async function deployWizard(ag: AgenticID, attestorUrl: string, ask: (q: string)
1889
2132
  const provider = await pickInferenceProvider(ask, loadConfig().inferenceProvider ?? '0g-compute');
1890
2133
  const definition = knownProviders.find((entry) => entry.id === provider)!;
1891
2134
  await ag.agent.assertProviderSupported(provider, { framework });
1892
- const NEEDS_TOOLS = new Set(['openclaw', 'dsh', 'prime-agent']);
1893
2135
  const caps = await ag.agent.listModelCaps({ provider });
1894
2136
  const models = caps.filter((model) => model.chat)
1895
- .filter((model) => !NEEDS_TOOLS.has(framework) || model.tools)
2137
+ .filter((model) => !frameworkNeedsToolModels(framework) || model.tools)
1896
2138
  .filter((model) => framework !== 'hermes' || definition.native || model.formats.includes('openai') || (!model.formats.length && !model.id.startsWith('claude')))
1897
2139
  .map((model) => model.id);
1898
2140
  let model: string;
@@ -2036,7 +2278,7 @@ async function pickFramework(attestorUrl: string, ask: (q: string) => Promise<st
2036
2278
  // ── L2: session REPL ─────────────────────────────────────────────────────────
2037
2279
 
2038
2280
  const L2_HELP =
2039
- 'chat, or: /hello /balance /topup /stop /start /reset /settings /think /clear /compact /tasks /result /cancel /agentlog /startuplog /back /quit — Esc interrupts a turn (help: /help)';
2281
+ 'chat, or: /hello /balance /topup /stop /start /reset /settings /think /clear /compact /tasks /result /cancel /inbox /schedules /agentlog /startuplog /back /quit — Esc interrupts a turn (help: /help)';
2040
2282
 
2041
2283
  const L2_HELP_FULL = `session commands
2042
2284
  <anything else> chat with the agent — Esc or Ctrl-C interrupts the
@@ -2067,24 +2309,40 @@ const L2_HELP_FULL = `session commands
2067
2309
  is untouched; that is the difference from /reset
2068
2310
  /compact compact the agent's conversation in place — older
2069
2311
  history becomes a summary, the newest part stays
2070
- as it is (openclaw ~20K tokens, dsh its newest
2071
- item), and the conversation goes on (unlike
2312
+ as it is (openclaw ~20K tokens, 0g-harness its
2313
+ newest item), and the conversation goes on (unlike
2072
2314
  /clear). One or more model calls; can take
2073
- minutes. dsh, and openclaw 2026.7.1 or later
2074
- /tasks this session's long tasks with live status — on
2075
- agents with the responses transport a chat turn
2076
- survives dropped connections and keeps running
2315
+ minutes. 0g-harness, and openclaw 2026.7.1 or later
2316
+ /tasks on 0g-harness: everything that runs or ran on the
2317
+ agent — your turns, the turns it opened itself,
2318
+ background commands and subagents — with who did
2319
+ each (BY) and who asked (FOR). Elsewhere: this
2320
+ session's long tasks with live status — on agents
2321
+ with the responses transport a chat turn survives
2322
+ dropped connections and keeps running
2077
2323
  /result [id] re-attach to a task (default: latest): prints a
2078
- finished one, follows a running one live
2079
- /cancel [id] stop tasks — the brake for orphaned turns: Esc only
2080
- cancels a turn THIS connection started (on dsh/prime
2081
- it interrupts the bridge-wide current turn), so after
2082
- a dropped stream /cancel is the way to stop what
2083
- survived. Bare form stops everything this session
2084
- knows to be in flight (newest first); with an id,
2085
- just that one — /result <id> adopts an id into the
2086
- session first. Session memory starts empty after a
2087
- CLI restart or /back + use
2324
+ finished one, follows a running one live; on
2325
+ 0g-harness also a subagent's answer or a command's
2326
+ status
2327
+ /cancel [id|all] stop tasks — the brake for orphaned turns: Esc only
2328
+ cancels a turn THIS connection started (on
2329
+ 0g-harness and prime it interrupts the agent-wide
2330
+ current turn), so after a dropped stream /cancel
2331
+ is the way to stop what survived. Bare form stops
2332
+ everything this session knows to be in flight
2333
+ (newest first); with an id, just that one —
2334
+ /result <id> adopts an id into the session first.
2335
+ Session memory starts empty after a CLI restart or
2336
+ /back + use. On 0g-harness an id can be any task
2337
+ /tasks lists, and /cancel all stops everything
2338
+ running on the agent
2339
+ /inbox [all] what the agent said on its own (0g-harness): a
2340
+ background job finished, a reminder came due. It
2341
+ prints above the prompt as it arrives, and what
2342
+ came while you were away prints when you enter.
2343
+ Bare: unread messages; all: the read ones too
2344
+ /schedules the reminders the agent set for itself
2345
+ (0g-harness)
2088
2346
  /agentlog [n] agent process log, last n lines (owner-only)
2089
2347
  /startuplog [n] sealed runtime startup log, last n lines
2090
2348
  /back (or /unuse) return to the manager
@@ -2145,6 +2403,20 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2145
2403
  };
2146
2404
 
2147
2405
  irq.brake = makeBrake(() => s.client, out, displacedSeat, () => seatPromptPending);
2406
+ // What the agent says on its own (a background job finished, a reminder
2407
+ // came due) arrives at any time. At the session prompt it prints above the
2408
+ // prompt; during a command, a chat turn or any other question it waits for
2409
+ // the next session prompt, so it never lands inside a reply.
2410
+ let atPrompt = false;
2411
+ const held: Array<{ text: string; shown: () => void }> = [];
2412
+ const inbox = makeInboxFeed((text, shown) => {
2413
+ if (atPrompt) {
2414
+ printAbovePrompt(text);
2415
+ shown();
2416
+ } else {
2417
+ held.push({ text, shown });
2418
+ }
2419
+ });
2148
2420
  // A friendly message that hides WHICH failure happened costs a whole
2149
2421
  // debugging round trip: "no headers ever arrived" and "the stream was cut
2150
2422
  // mid-way" have different causes and used to print identically. Append the
@@ -2165,7 +2437,18 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2165
2437
  // connecting the moment it reaches running). Once connected, skip: no
2166
2438
  // per-chat-line attestor round-trip; bare Enter stays the manual refresh.
2167
2439
  if (!s.client) { try { await refreshSession(s, true); } catch { /* prompt anyway */ } }
2168
- const line = (await ask(`\nagent ${s.agentId} › `)).trim();
2440
+ inbox.follow(s.client);
2441
+ for (const h of held.splice(0)) {
2442
+ out(h.text);
2443
+ h.shown();
2444
+ }
2445
+ atPrompt = true;
2446
+ let line: string;
2447
+ try {
2448
+ line = (await ask(`\nagent ${s.agentId} › `)).trim();
2449
+ } finally {
2450
+ atPrompt = false;
2451
+ }
2169
2452
  if (!line) {
2170
2453
  // Bare Enter = live status refresh (phase moves on its own during
2171
2454
  // deploying/provisioning; the entry card only showed the initial one).
@@ -2244,8 +2527,10 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2244
2527
  if (s.phase === 'running') { out('already running\n'); continue; }
2245
2528
  if (s.phase !== 'stopped' || !s.sandboxId) { out(`agent is ${s.phase} — a plain start cannot revive it; use /reset\n`); continue; }
2246
2529
  if (!(await ensureOwnerReady(s.ag, ask))) { out('start cancelled — prepaid balance too low\n'); continue; }
2247
- out('starting… (Esc cancels the wait)\n'); await s.ag.agent.start(s.sealId, s.sandboxId);
2248
- const r = await waitRunningInterruptible(irq, s.attestorUrl, s.sealId, s.agentId);
2530
+ out('starting… (Esc cancels the wait)\n');
2531
+ const baseline = await lifecycleBaseline(s.attestorUrl, s.sealId);
2532
+ await s.ag.agent.start(s.sealId, s.sandboxId);
2533
+ const r = await waitRunningInterruptible(irq, s.attestorUrl, s.sealId, s.agentId, baseline);
2249
2534
  if (!r) continue;
2250
2535
  await connectSession(s, r.url);
2251
2536
  out(`running at ${s.url}\n`); continue;
@@ -2260,13 +2545,16 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2260
2545
  } else {
2261
2546
  s.framework = await pickFramework(s.attestorUrl, ask, s.framework);
2262
2547
  }
2263
- const provider = await agentInferenceProvider(s.ag, s.sealId);
2548
+ const plan = await resetInferencePlan(s.ag, s.sealId, await readDeploymentFacts(s.attestorUrl, s.sealId));
2549
+ const provider = plan.provider;
2264
2550
  await s.ag.agent.assertProviderSupported(provider, { sealId: s.sealId, framework: s.framework });
2265
2551
  const apiKey = await inferenceKey(ctx, ask, provider);
2266
2552
  if (!(await ensureOwnerReady(s.ag, ask))) { out('reset cancelled — prepaid balance too low\n'); continue; }
2553
+ await applyResetInference(s.ag, s.sealId, plan, out);
2267
2554
  out(`resetting as ${s.framework}… (Esc cancels the wait)\n`);
2555
+ const baseline = await lifecycleBaseline(s.attestorUrl, s.sealId);
2268
2556
  await s.ag.agent.reset(s.sealId, { provider, framework: s.framework, apiKey });
2269
- const r = await waitRunningInterruptible(irq, s.attestorUrl, s.sealId, s.agentId);
2557
+ const r = await waitRunningInterruptible(irq, s.attestorUrl, s.sealId, s.agentId, baseline);
2270
2558
  if (!r) continue;
2271
2559
  await connectSession(s, r.url);
2272
2560
  messages.length = 0; out(`back up at ${s.url}\n`); continue;
@@ -2352,7 +2640,7 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2352
2640
  // with, and how hard. Bare shows it; key=value writes it (merged).
2353
2641
  // Owner-signed in both directions, so it needs the wallet client and
2354
2642
  // not the session's (possibly keyless) one.
2355
- await settingsOp(await withWallet(ctx), s.sealId, tokenize(line).slice(1), s.client && s.url ? s.url : undefined);
2643
+ await settingsOp(await withWallet(ctx), s.sealId, tokenize(line).slice(1), s.client && s.url ? s.url : undefined, s.framework);
2356
2644
  continue;
2357
2645
  }
2358
2646
  if (line === '/think' || line.startsWith('/think ')) {
@@ -2383,6 +2671,16 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2383
2671
  continue;
2384
2672
  }
2385
2673
  if (line === '/tasks') {
2674
+ // An agent with its own task list (0g-harness) answers for everything that
2675
+ // runs on it: every turn, yours and the ones it opened itself, and
2676
+ // every background command and subagent, with who did each.
2677
+ if (s.client?.tasks) {
2678
+ const list = await s.client.tasks({ limit: 30 });
2679
+ if (!list.length) { out('nothing has run on this agent yet\n'); continue; }
2680
+ for (const l of renderTaskTable(list, Date.now())) out(`${l}\n`);
2681
+ out('/result <id> shows one · /cancel <id> stops one · /cancel all stops everything running\n');
2682
+ continue;
2683
+ }
2386
2684
  // Long-task surface (responses transport). The list is this session's
2387
2685
  // memory of submitted ids; status is fetched live from the agent.
2388
2686
  if (!s.client?.task) { out('(this agent has no task surface — chat turns are connection-bound here)\n'); continue; }
@@ -2407,8 +2705,21 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2407
2705
  continue;
2408
2706
  }
2409
2707
  if (line === '/result' || line.startsWith('/result ')) {
2708
+ // A background command or a subagent is not a turn: its record is
2709
+ // the task list's, and it has no stream to follow.
2710
+ const named = line.split(/\s+/)[1];
2711
+ if (named && s.client?.taskInfo) {
2712
+ const t = await s.client.taskInfo(named).catch(() => null);
2713
+ if (t && t.type !== 'turn') {
2714
+ out(`${cleanCell(t.id)} — ${t.status} · by ${t.actor} · ${cleanCell(t.label)}\n`);
2715
+ if (t.output_text) out(`${t.output_text}\n`);
2716
+ else if (t.type === 'command') out('(a command\'s output goes to the agent, which reports on it when the command finishes — /inbox)\n');
2717
+ if (t.error) out(`error: ${cleanCell(t.error)}\n`);
2718
+ continue;
2719
+ }
2720
+ }
2410
2721
  if (!s.client?.task || !s.client.followTask) { out('(this agent has no task surface)\n'); continue; }
2411
- const id = line.split(/\s+/)[1] ?? s.tasks?.[s.tasks.length - 1]?.id;
2722
+ const id = named ?? s.tasks?.[s.tasks.length - 1]?.id;
2412
2723
  if (!id) { out('no task to show — /result <id>, or start one by chatting\n'); continue; }
2413
2724
  // Adopt an explicitly-named id into this session's task memory: the
2414
2725
  // id may come from another window, a /tasks listing before a restart,
@@ -2457,6 +2768,27 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2457
2768
  // survival is the feature). /cancel is the explicit brake: by id, or
2458
2769
  // everything in flight this session knows.
2459
2770
  let id = line.split(/\s+/)[1];
2771
+ // An agent with its own task list (0g-harness) stops any of its tasks by id
2772
+ // (a turn, a background command, a subagent), and all of them at once.
2773
+ if (id && s.client.stopTask && s.client.stopAllTasks) {
2774
+ for (;;) {
2775
+ try {
2776
+ const stopped = id === 'all' ? await s.client.stopAllTasks() : [await s.client.stopTask(id)];
2777
+ if (!stopped.length) out('nothing running\n');
2778
+ for (const x of stopped) out(`⏹ ${cleanCell(x.id)} — ${STOP_OUTCOME[x.outcome] ?? x.outcome}\n`);
2779
+ break;
2780
+ } catch (e) {
2781
+ const d = await routeTaskFailure(out, displacedSeat, e, `(cancel failed: ${(e as Error).message})\n`, `retry /cancel ${id}`);
2782
+ if (d === 'reclaimed') continue; // seat is back — retry
2783
+ break;
2784
+ }
2785
+ }
2786
+ continue;
2787
+ }
2788
+ if (id === 'all') {
2789
+ out('(this agent has no task list: bare /cancel stops what this session started, /stop stops the whole container)\n');
2790
+ continue;
2791
+ }
2460
2792
  if (!id && s.client?.task) {
2461
2793
  if (!s.tasks?.length) { out('no task id given and none started from this session — /cancel <id>, or /tasks to list (after a CLI restart or /back+use, this session starts empty)\n'); continue; }
2462
2794
  // Fetch live statuses; a fetch FAILURE is not "not in flight" —
@@ -2484,8 +2816,8 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2484
2816
  continue;
2485
2817
  }
2486
2818
  // A brake stops everything in flight, newest first — stopping only
2487
- // the newest would leave an older running turn alive (dsh/prime
2488
- // serialize turns, so a queued one is waiting on the running one).
2819
+ // the newest would leave an older running turn alive (0g-harness and
2820
+ // prime serialize turns, so a queued one is waiting on the running one).
2489
2821
  const inFlight = inFlightIds(rows);
2490
2822
  if (!inFlight.length) { out('nothing in flight from this session — /tasks to list; a finished task cannot be cancelled\n'); continue; }
2491
2823
  if (s.client?.cancelTask) {
@@ -2528,7 +2860,7 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2528
2860
  if (id && !s.client?.cancelTask) {
2529
2861
  // An id was asked for but this image has no task-level cancel: do
2530
2862
  // NOT silently interrupt "whatever is running" instead — but on
2531
- // dsh/prime the bridge-wide interrupt DOES stop the running turn,
2863
+ // 0g-harness and prime the agent-wide interrupt DOES stop the running turn,
2532
2864
  // so point there instead of claiming nothing can be done.
2533
2865
  out(s.client?.interrupt
2534
2866
  ? '(this agent image has no per-task cancel — the bridge interrupt stops the current running turn; try /cancel with no id)\n'
@@ -2546,6 +2878,27 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2546
2878
  if (r) out(r.aborted ? '⏹ stopped the running turn\n' : `(nothing to stop, or: ${r.note ?? 'not supported'})\n`);
2547
2879
  continue;
2548
2880
  }
2881
+ if (line === '/inbox' || line === '/inbox all') {
2882
+ if (!s.client) { out(`agent is ${s.phase} — /start or /reset first\n`); continue; }
2883
+ if (!s.client.inbox) { out('(no inbox on this agent: its framework does not run work in the background)\n'); continue; }
2884
+ const all = line === '/inbox all';
2885
+ const page = await s.client.inbox(all ? { after: 0 } : {});
2886
+ if (!page.data.length) { out(all ? 'the inbox is empty\n' : 'no new messages — /inbox all shows the ones already read\n'); continue; }
2887
+ out(page.data.map(renderInboxMessage).join('\n'));
2888
+ const through = Math.max(...page.data.map((m) => m.seq));
2889
+ if (through > page.read_through) await s.client.ackInbox?.(through).catch(() => undefined);
2890
+ continue;
2891
+ }
2892
+ if (line === '/schedules') {
2893
+ if (!s.client) { out(`agent is ${s.phase} — /start or /reset first\n`); continue; }
2894
+ if (!s.client.schedules) { out('(no reminders on this agent: its framework does not support them)\n'); continue; }
2895
+ const r = await s.client.schedules();
2896
+ if (!r.enabled) { out('reminders are off on this agent (the "schedule" switch in /settings others)\n'); continue; }
2897
+ if (!r.data.length) { out('no reminders set — the agent sets one when you ask it to remind you of something\n'); continue; }
2898
+ for (const l of renderSchedules(r.data, Date.now())) out(`${l}\n`);
2899
+ out('to remove one, ask the agent to\n');
2900
+ continue;
2901
+ }
2549
2902
  if (line.startsWith('/')) { out(`unknown command ${line}\n${L2_HELP}\n`); continue; }
2550
2903
  } catch (e) {
2551
2904
  // Show the remedy too: an error whose whole point is "do this instead"
@@ -2559,7 +2912,7 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2559
2912
  if (!s.client.chatStream) { out('(chat unavailable on this agent)\n'); continue; }
2560
2913
  messages.push({ role: 'user', content: line });
2561
2914
  // `model` is a per-framework selector some gateways require (openclaw
2562
- // does; the dsh/prime bridges ignore it). Send it when known, omit it
2915
+ // does; 0g-harness and the prime bridge ignore it). Send it when known, omit it
2563
2916
  // otherwise — and only if the framework rejects that, ask once and retry.
2564
2917
  let retriedWithPick = false;
2565
2918
  for (;;) {
@@ -2599,7 +2952,7 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2599
2952
  const onActivity = process.stdout.isTTY
2600
2953
  ? (label: string): void => {
2601
2954
  // "did work this turn" detector, across bridges' label dialects:
2602
- // dsh "tool/call bash", prime "tool_execution_start — bash" /
2955
+ // 0g-harness "tool/call bash", prime "tool_execution_start — bash" /
2603
2956
  // "bash_command_start", hermes "tool/call web_search". Thinking
2604
2957
  // alone doesn't count — a think-only turn with no output is still
2605
2958
  // a failure worth reporting.
@@ -2704,7 +3057,7 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2704
3057
  continue; // retry the same user message once with the selector
2705
3058
  }
2706
3059
  // A turn that ran tools but produced no text is WORK, not failure —
2707
- // dsh agents legitimately end tool-only turns silently. Say what
3060
+ // 0g-harness agents legitimately end tool-only turns silently. Say what
2708
3061
  // happened instead of crying wolf (the true-failure path — no deltas,
2709
3062
  // no activity — still reports as an error).
2710
3063
  // Displaced by another window (occupancy.go): WeChat semantics — this
@@ -2734,5 +3087,6 @@ async function sessionRepl(s: Session, ask: (q: string) => Promise<string>, irq:
2734
3087
  }
2735
3088
  } finally {
2736
3089
  irq.brake = null; // leaving the session: idle-Esc no longer targets this agent
3090
+ inbox.stop();
2737
3091
  }
2738
3092
  }