@causyne/agent 1.20.0 → 1.20.7

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 (130) hide show
  1. package/README.md +13 -9
  2. package/SECURITY.md +1 -4
  3. package/package.json +1 -1
  4. package/src/acp/client.js +176 -26
  5. package/src/acp/client.ts +167 -25
  6. package/src/acp/protocol.js +116 -0
  7. package/src/acp/protocol.ts +163 -0
  8. package/src/acp/server.js +5 -6
  9. package/src/acp/server.ts +4 -6
  10. package/src/agentLoop.d.ts +1 -0
  11. package/src/agentLoop.js +681 -245
  12. package/src/agentLoop.ts +708 -262
  13. package/src/agentPolicy.js +9 -0
  14. package/src/agentPolicy.ts +9 -0
  15. package/src/approvalPolicy.js +55 -0
  16. package/src/approvalPolicy.ts +66 -0
  17. package/src/browser/browserRuntime.js +217 -14
  18. package/src/browser/browserRuntime.ts +255 -14
  19. package/src/browser/causyneBrowser.js +1215 -68
  20. package/src/browser/causyneBrowser.ts +1340 -72
  21. package/src/cliMode.js +52 -29
  22. package/src/commands.js +141 -17
  23. package/src/config.js +22 -12
  24. package/src/continuum/ui/continuumPicker.js +18 -1
  25. package/src/continuum/ui/continuumPicker.ts +19 -1
  26. package/src/dynamicCatalogue.js +87 -20
  27. package/src/dynamicCatalogue.ts +85 -15
  28. package/src/launchIntent.js +40 -0
  29. package/src/launchIntent.ts +49 -0
  30. package/src/memoryManager.js +26 -2
  31. package/src/modelCatalogue.js +2 -0
  32. package/src/planCache.js +320 -11
  33. package/src/planCache.ts +402 -13
  34. package/src/providers/acp.js +173 -18
  35. package/src/providers/acp.ts +169 -19
  36. package/src/providers/antigravity.d.ts +5 -1
  37. package/src/providers/antigravity.js +674 -34
  38. package/src/providers/antigravity.ts +707 -35
  39. package/src/providers/base.d.ts +10 -0
  40. package/src/providers/factory.js +2 -0
  41. package/src/providers/pi.js +161 -0
  42. package/src/providers/pi.ts +148 -0
  43. package/src/provisioning/capabilityProvisioner.js +17 -0
  44. package/src/provisioning/capabilityTools.js +1 -1
  45. package/src/sandbox.js +30 -39
  46. package/src/sessionJournal.js +53 -10
  47. package/src/sessionJournal.ts +64 -10
  48. package/src/taskShape.js +9 -9
  49. package/src/taskShape.ts +9 -9
  50. package/src/timeMachine.js +124 -0
  51. package/src/timeMachine.ts +141 -0
  52. package/src/toolPacks.js +4 -10
  53. package/src/tools/archive.js +196 -59
  54. package/src/tools/archive.ts +220 -0
  55. package/src/tools/browserAutomator.js +78 -9
  56. package/src/tools/browserAutomator.ts +90 -9
  57. package/src/tools/desktopOpen.js +114 -31
  58. package/src/tools/desktopOpen.ts +144 -0
  59. package/src/tools/gitExec.js +5 -3
  60. package/src/tools/nativeEngine.js +4 -3
  61. package/src/tools/nativeEngine.ts +5 -3
  62. package/src/tools/openSourceToolProvisioner.js +5 -4
  63. package/src/tools/openSourceToolProvisioner.ts +5 -4
  64. package/src/tools/registry.js +3 -0
  65. package/src/tools/screenshot.js +55 -71
  66. package/src/tools/screenshot.ts +70 -0
  67. package/src/tools/sysRun.js +284 -117
  68. package/src/tools/sysRun.ts +347 -0
  69. package/src/tools/toolSelfRepair.js +109 -2
  70. package/src/tools/toolSelfRepair.ts +100 -2
  71. package/src/tools/updatePlan.js +49 -1
  72. package/src/tools/updatePlan.ts +43 -1
  73. package/src/tools/viewImage.js +93 -78
  74. package/src/tools/viewImage.ts +116 -0
  75. package/src/tools/webFetch.js +20 -6
  76. package/src/tools/webFetch.ts +26 -6
  77. package/src/tui/activityLayout.js +9 -0
  78. package/src/tui/activityLayout.ts +10 -0
  79. package/src/tui/block.d.ts +1 -0
  80. package/src/tui/chatRenderer.d.ts +23 -0
  81. package/src/tui/chatRenderer.js +49 -49
  82. package/src/tui/clipboardSync.js +28 -1
  83. package/src/tui/clipboardSync.ts +26 -1
  84. package/src/tui/codeProgress.js +299 -0
  85. package/src/tui/codeProgress.ts +304 -0
  86. package/src/tui/codeStreamRenderer.js +132 -0
  87. package/src/tui/codeStreamRenderer.ts +141 -0
  88. package/src/tui/commandPresentation.js +11 -0
  89. package/src/tui/commandPresentation.ts +18 -0
  90. package/src/tui/completion.js +45 -13
  91. package/src/tui/composerControls.js +131 -0
  92. package/src/tui/composerControls.ts +184 -0
  93. package/src/tui/diff.d.ts +2 -0
  94. package/src/tui/home.js +4 -2
  95. package/src/tui/homeTransition.js +21 -0
  96. package/src/tui/homeTransition.ts +27 -0
  97. package/src/tui/homeView.js +62 -0
  98. package/src/tui/homeView.ts +91 -0
  99. package/src/tui/layout.js +46 -0
  100. package/src/tui/layout.ts +52 -0
  101. package/src/tui/messageActionPlacement.js +16 -0
  102. package/src/tui/messageActionPlacement.ts +25 -0
  103. package/src/tui/messageInteraction.js +221 -0
  104. package/src/tui/messageInteraction.ts +275 -0
  105. package/src/tui/modelPicker.js +4 -24
  106. package/src/tui/modelPicker.ts +4 -20
  107. package/src/tui/mouseHover.js +6 -0
  108. package/src/tui/mouseHover.ts +5 -0
  109. package/src/tui/prompt.js +175 -101
  110. package/src/tui/resizeRecovery.js +15 -0
  111. package/src/tui/resizeRecovery.ts +27 -0
  112. package/src/tui/scrollInteraction.js +97 -0
  113. package/src/tui/scrollInteraction.ts +189 -0
  114. package/src/tui/sessionLayout.js +12 -0
  115. package/src/tui/sessionLayout.ts +12 -0
  116. package/src/tui/sessionPicker.js +111 -16
  117. package/src/tui/sessionPicker.ts +121 -16
  118. package/src/tui/sessionSidebar.js +78 -0
  119. package/src/tui/sessionSidebar.ts +95 -0
  120. package/src/tui/setup.js +1 -1
  121. package/src/tui/setup.ts +1 -1
  122. package/src/tui/stageSurface.js +120 -58
  123. package/src/tui/text.d.ts +6 -0
  124. package/src/tui/textLayout.js +23 -0
  125. package/src/tui/textLayout.ts +28 -0
  126. package/src/tui/viewport.js +204 -279
  127. package/src/tui/viewport.ts +326 -0
  128. package/src/types/contracts.ts +54 -0
  129. package/src/utils/paths.js +5 -4
  130. package/src/utils/paths.ts +5 -5
package/src/cliMode.js CHANGED
@@ -4,7 +4,7 @@ import { loadConfig, saveConfig } from './config.js';
4
4
  import readline from 'readline';
5
5
  import { ChatPrompt, isInteractive } from './tui/prompt.js';
6
6
  import { handleInput, listCommands, isCommandInput } from './commands.js';
7
- import { ChatRenderer } from './tui/chatRenderer.js';
7
+ import { CodeStreamRenderer as ChatRenderer } from './tui/codeStreamRenderer.js';
8
8
  import { paint, bold, dim, badge, GLYPHS, terminalWidth } from './tui/theme.js';
9
9
  import { wordmark } from './tui/banner.js';
10
10
  import { createStageSurface } from './tui/stageSurface.js';
@@ -12,12 +12,17 @@ import { wrapBlock } from './tui/text.js';
12
12
  import { getPackageVersion } from './version.js';
13
13
  import { resolveCharPool } from './contextManager.js';
14
14
  import { PRIMARY_ACTIONS, homeStatusLine, homeHint, moreLayer, configureInPrompt, mcpPicker, PROVIDERS } from './tui/home.js';
15
+ import { commandDialog } from './tui/commandPresentation.js';
16
+ import { HomeTransition } from './tui/homeTransition.js';
15
17
  import { SelectLayer } from './tui/dialogs.js';
18
+ import { openModeControl, openVariantControl } from './tui/composerControls.js';
19
+ import { runInteractiveModelPicker } from './tui/modelPicker.js';
16
20
  import { askSelect, askText, askConfirm, askDecision } from './tui/ask.js';
17
21
  import { renderReport } from './reporting.js';
18
22
  import { grantAlways } from './approvalGrants.js';
19
23
  import { auditLog } from './auditLog.js';
20
24
  import { isAcpProvider } from './providers/acp.js';
25
+ import { isPiProvider } from './providers/pi.js';
21
26
  import { isAntigravityProvider } from './providers/antigravity.js';
22
27
 
23
28
  // One themed source for the art.
@@ -298,7 +303,8 @@ export async function runTask(task) {
298
303
  */
299
304
  export async function chatMode({ home = false } = {}) {
300
305
 
301
- // One chat surface, and it renders in the NORMAL buffer.
306
+ // One chat surface in the normal buffer. Home fills the available stage;
307
+ // selecting or starting a session reuses it for transcript and input.
302
308
  //
303
309
  // There used to be a full-screen alternate-buffer shell here, chosen by
304
310
  // canRunShell(). It clears the terminal on entry (\x1b[?1049h + \x1b[2J) and
@@ -311,9 +317,9 @@ export async function chatMode({ home = false } = {}) {
311
317
  //
312
318
  // Neither reference does this. openclaw emits \x1b[?1049h nowhere at all and
313
319
  // repaints the normal buffer in place; opencode's --mini runs split-footer on
314
- // the main screen with clearOnShutdown false. So does this now: everything
315
- // printed is permanent terminal history, and only the prompt and its status
316
- // row are repainted. See UX-01 in .agents/rules.json.
320
+ // the main screen with clearOnShutdown false. The live stage also repaints
321
+ // in place and is flushed into terminal history on exit. See UX-01 in
322
+ // .agents/rules.json.
317
323
  const conn = new LocalCLIConnection();
318
324
  const taskId = `cli_chat_${Date.now()}`;
319
325
  const loop = new AgentLoop(conn, taskId, null);
@@ -322,7 +328,7 @@ export async function chatMode({ home = false } = {}) {
322
328
  // money, in which autonomy mode, over which paths. All of it was already
323
329
  // loaded — none of it was ever displayed.
324
330
  const config = loadConfig();
325
- const bannerWidth = conn.renderer.sessionHeader({
331
+ const headerInfo = {
326
332
  version: `v${getPackageVersion()}`,
327
333
  provider: config.provider,
328
334
  model: config.model,
@@ -336,7 +342,15 @@ export async function chatMode({ home = false } = {}) {
336
342
  // displayed once the header had scrolled away.
337
343
  cwd: process.cwd(),
338
344
  contextLimit: resolveCharPool(config.tier, config.maxCharPool)
339
- });
345
+ };
346
+ let surface = home && isInteractive() ? createStageSurface({ config }) : null;
347
+ const openedHome = Boolean(surface);
348
+ const bannerWidth = openedHome ? 0 : conn.renderer.sessionHeader(headerInfo);
349
+ if (openedHome) {
350
+ conn.renderer.status.setSession(headerInfo);
351
+ surface.enterHome(headerInfo);
352
+ }
353
+ const homeTransition = new HomeTransition(openedHome, surface);
340
354
 
341
355
  loop.waitForApproval = makeApprovalHandler(conn);
342
356
  loop.waitForDecision = makeDecisionHandler(conn);
@@ -351,20 +365,15 @@ export async function chatMode({ home = false } = {}) {
351
365
  try {
352
366
  // The Stage, if this terminal can hold one.
353
367
  //
354
- // It is opened AFTER the session header, deliberately: the wordmark stays
355
- // the first thing written to stdout and lands in the user's real history,
356
- // and the band opens below it. That keeps the UX-01 check literally true
357
- // and gives a seam the user can see — their shell prompt above, Causyne's
358
- // region below — instead of a screen that has silently become ours.
368
+ // Home creates its stage before drawing the first frame. Other chat
369
+ // invocations retain their printed header above the live region.
359
370
  //
360
371
  // Every null from here is a terminal that should keep the scrollback
361
372
  // renderer: not a TTY, TERM=dumb, CAUSYNE_STAGE=off, or too short to hold a
362
373
  // viewport. There is no degraded stage.
363
- // The banner reports the width it actually used. The opening composition
364
- // is laid out to it, so the input box ends where the banner's text ends
365
- // instead of stretching past it — and the banner itself is never narrowed,
366
- // because at 117 columns it already starts hiding the workspace paths.
367
- const surface = createStageSurface({ config, openingWidth: bannerWidth });
374
+ // The header reports the companion composer width. The Stage keeps that
375
+ // readable width throughout the session, including after history clears.
376
+ if (!surface) surface = createStageSurface({ config, openingWidth: bannerWidth });
368
377
  if (surface) conn.renderer.transcript = surface.transcript;
369
378
 
370
379
  prompt = new ChatPrompt({
@@ -375,7 +384,12 @@ export async function chatMode({ home = false } = {}) {
375
384
  // the conversation instead of drawing it as something the user said.
376
385
  isCommand: isCommandInput,
377
386
  surface,
387
+ messageActionLoop: loop,
378
388
  onInterrupt: () => loop.abort(),
389
+ getMode: () => loop.config?.autonomyMode || config.autonomyMode || 'B',
390
+ onOpenMode: () => openModeControl(prompt, loop),
391
+ onOpenModel: () => runInteractiveModelPicker(prompt, { loadConfig, saveConfig }, { loop }),
392
+ onOpenVariant: () => openVariantControl(prompt),
379
393
  onExit: () => { if (prompt) prompt.stop(); process.exit(0); },
380
394
  onExpand: () => conn.renderer.expandLastOutput()
381
395
  });
@@ -383,9 +397,9 @@ export async function chatMode({ home = false } = {}) {
383
397
  prompt.attach(conn.renderer);
384
398
  prompt.start();
385
399
 
386
- // If active session has prior conversation history, render it into the viewport (OpenCode architecture)
400
+ // Home is a clean route. History appears only after a session is chosen.
387
401
  const initialHistory = loop.memoryManager ? loop.memoryManager.loadHistory() : [];
388
- if (initialHistory.length > 0) {
402
+ if (!openedHome && initialHistory.length > 0) {
389
403
  conn.renderer.renderSessionHistory(initialHistory, {
390
404
  id: loop.memoryManager?.sessionId,
391
405
  title: loop.memoryManager?.sessionTitle,
@@ -416,12 +430,11 @@ export async function chatMode({ home = false } = {}) {
416
430
  // The key hints are part of the session header now — one hint row, not
417
431
  // three stacked lines of chrome above the first prompt.
418
432
 
419
- // Home is chat with the menu already open. Doing it here rather than in a
420
- // separate module is deliberate: a parallel home implementation would be a
421
- // second place for the live region, the completion picker and the approval
422
- // stack to be got wrong, and the two would drift on the first change.
423
- if (home) openHomeMenu(prompt, conn);
433
+ // On a Stage, bare `causyne` opens the centered composer directly;
434
+ // ctrl+p remains the command palette. Small terminals keep the home menu.
435
+ if (home && !surface) openHomeMenu(prompt, conn);
424
436
  } catch (e) {
437
+ if (surface) surface.close();
425
438
  process.stderr.write(`[tui] falling back to simple input: ${e.message}\n`);
426
439
  prompt = null;
427
440
  }
@@ -490,15 +503,18 @@ export async function chatMode({ home = false } = {}) {
490
503
  continue;
491
504
  }
492
505
 
506
+ if (commandResult.effect === 'silent') {
507
+ if (prompt && typeof prompt.draw === 'function') prompt.draw();
508
+ continue;
509
+ }
510
+
493
511
  if (commandResult.effect === 'pick-session' && prompt) {
494
512
  const { runInteractiveSessionPicker } = await import('./tui/sessionPicker.js');
495
- const outcome = await runInteractiveSessionPicker(prompt, {
513
+ await runInteractiveSessionPicker(prompt, {
496
514
  loop,
497
515
  workspace: loop?.workspaceRoot || process.cwd()
498
516
  });
499
- if (outcome) {
500
- conn.renderer.write(`\n${outcome}\n`);
501
- }
517
+ if (prompt && typeof prompt.draw === 'function') prompt.draw();
502
518
  continue;
503
519
  }
504
520
 
@@ -516,6 +532,12 @@ export async function chatMode({ home = false } = {}) {
516
532
  continue;
517
533
  }
518
534
 
535
+ const localDialog = prompt && commandDialog(task, commandResult);
536
+ if (localDialog) {
537
+ prompt.showText(localDialog.title, localDialog.text, { danger: localDialog.danger });
538
+ continue;
539
+ }
540
+
519
541
  // A skill was invoked: it becomes part of the REQUEST, not terminal output.
520
542
  //
521
543
  // This is the whole point. `/skills <id>` used to print the file and call
@@ -543,6 +565,7 @@ export async function chatMode({ home = false } = {}) {
543
565
  }
544
566
  }
545
567
 
568
+ homeTransition.beginTurn(loop);
546
569
  loop.userPrompt = task;
547
570
  // ONE USER REQUEST IS ONE TASK.
548
571
  //
@@ -563,7 +586,7 @@ export async function chatMode({ home = false } = {}) {
563
586
  const startedAt = Date.now();
564
587
  if (prompt) prompt.setBusy(true);
565
588
  try {
566
- const isNoKey = loop.config.provider === 'ollama' || loop.config.provider === 'acp' || isAcpProvider(loop.config.provider) || isAntigravityProvider(loop.config.provider);
589
+ const isNoKey = loop.config.provider === 'ollama' || loop.config.provider === 'acp' || isAcpProvider(loop.config.provider) || isAntigravityProvider(loop.config.provider) || isPiProvider(loop.config.provider);
567
590
  if (!loop.config.provider || (!loop.config.apiKey && !isNoKey)) {
568
591
  conn.renderer.write('\n' + paint('warn', ' No API provider or key configured.') + '\n' +
569
592
  paint('muted', ' Run /setup or select setup from the home menu to configure your provider.\n'));
package/src/commands.js CHANGED
@@ -651,7 +651,7 @@ export const COMMANDS = [
651
651
  loop: context.loop,
652
652
  workspace
653
653
  });
654
- return ok(message, { effect: 'inline' });
654
+ return ok(message, { effect: 'silent' });
655
655
  }
656
656
 
657
657
  if (verb === 'new') {
@@ -699,6 +699,48 @@ export const COMMANDS = [
699
699
  return ok(`Switched to "${next.title}" (${next.messages.length} messages, ${next.id}).`, { effect: 'inline' });
700
700
  }
701
701
 
702
+ if (verb === 'fork') {
703
+ const sourceId = args[1] || (memory ? memory.sessionId : store.getActiveSessionId());
704
+ if (!sourceId) return fail('No session specified to fork.');
705
+ const forked = memory && memory.sessionId === sourceId
706
+ ? memory.forkSession()
707
+ : store.forkSession(sourceId, { makeActive: true });
708
+ if (!forked) return fail(`Could not fork session "${sourceId}".`);
709
+
710
+ // CRITICAL TRUST INVARIANT (Claude Code Architecture, p. 24):
711
+ // Permissions and allowlists NEVER carry across forks.
712
+ const { revokeAllAlways } = await import('./approvalGrants.js');
713
+ revokeAllAlways();
714
+ if (context.loop && typeof context.loop.resetApprovalScope === 'function') {
715
+ context.loop.resetApprovalScope();
716
+ }
717
+
718
+ const historyMessages = memory ? memory.loadHistory() : forked.messages.filter(m => m.role !== 'system');
719
+ if (context.loop) {
720
+ context.loop.messages = historyMessages;
721
+ context.loop.taskId = `cli_chat_${Date.now()}`;
722
+ if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
723
+ context.loop.tokenTracker.reset();
724
+ }
725
+ }
726
+ const renderer = context.prompt?.renderer || context.loop?.connection?.renderer;
727
+ if (renderer && typeof renderer.renderSessionHistory === 'function') {
728
+ renderer.renderSessionHistory(historyMessages, {
729
+ id: forked.id,
730
+ title: forked.title,
731
+ messagesCount: forked.messages.length
732
+ });
733
+ }
734
+ if (context.prompt?.surface?.viewport && typeof context.prompt.surface.viewport.toBottom === 'function') {
735
+ context.prompt.surface.viewport.toBottom();
736
+ }
737
+ if (context.prompt?.editor?.clear) {
738
+ context.prompt.editor.clear();
739
+ if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
740
+ }
741
+ return ok(`Forked session into "${forked.title}" (${forked.messages.length} messages, ${forked.id}).\nPermissions and standing approvals were reset; any gated actions will request authorization anew.`, { effect: 'inline' });
742
+ }
743
+
702
744
  if (verb === 'delete' && args[1]) {
703
745
  return store.deleteSession(args[1]) ? ok(`Deleted session "${args[1]}".`) : fail(`No session "${args[1]}".`);
704
746
  }
@@ -720,12 +762,93 @@ export const COMMANDS = [
720
762
  return ok(
721
763
  `${rows.length} session${rows.length === 1 ? '' : 's'} (* = active):\n`
722
764
  + lines.join('\n')
723
- + '\n\nSwitch with /sessions switch <id>, or run /sessions to open interactive modal picker.',
765
+ + '\n\nSwitch with /sessions switch <id>, fork with /fork [id], or run /sessions to open interactive modal picker.',
724
766
  { effect: 'pick-session', items: rows, active }
725
767
  );
726
768
  }
727
769
  },
728
770
 
771
+ {
772
+ name: 'fork',
773
+ aliases: ['branch', 'fork-session'],
774
+ scope: 'local',
775
+ usage: '/fork [sessionId]',
776
+ description: 'Fork the conversation into a new session without copying permissions',
777
+ dialogTitle: 'Fork Session',
778
+ complete: () => {
779
+ try {
780
+ const rows = listSessions().slice(0, 15);
781
+ return rows.map(r => ({
782
+ value: r.id,
783
+ label: r.id,
784
+ description: `${r.title} (${r.messageCount} msgs)`
785
+ }));
786
+ } catch (e) {
787
+ return [];
788
+ }
789
+ },
790
+ run: async (args = [], context = {}) => {
791
+ const store = await import('./sessionStore.js');
792
+ const { revokeAllAlways } = await import('./approvalGrants.js');
793
+ const memory = context.loop && context.loop.memoryManager;
794
+
795
+ const sourceId = args[0] || (memory ? memory.sessionId : store.getActiveSessionId());
796
+ if (!sourceId) {
797
+ return fail('No active or specified session to fork.');
798
+ }
799
+
800
+ const sourceSession = store.getSession(sourceId);
801
+ if (!sourceSession) {
802
+ return fail(`Session "${sourceId}" not found.`);
803
+ }
804
+
805
+ const forked = memory && memory.sessionId === sourceId
806
+ ? memory.forkSession()
807
+ : store.forkSession(sourceId, { makeActive: true });
808
+
809
+ if (!forked) {
810
+ return fail(`Could not fork session "${sourceId}".`);
811
+ }
812
+
813
+ // CRITICAL SECURITY INVARIANT (Claude Code Architecture, p. 24):
814
+ // Permissions and allowlists MUST NOT be copied across the fork.
815
+ revokeAllAlways();
816
+ if (context.loop && typeof context.loop.resetApprovalScope === 'function') {
817
+ context.loop.resetApprovalScope();
818
+ }
819
+
820
+ if (memory) {
821
+ memory.session = forked;
822
+ }
823
+ const historyMessages = memory ? memory.loadHistory() : forked.messages.filter(m => m.role !== 'system');
824
+ if (context.loop) {
825
+ context.loop.messages = historyMessages;
826
+ context.loop.taskId = `cli_chat_${Date.now()}`;
827
+ if (context.loop.tokenTracker && typeof context.loop.tokenTracker.reset === 'function') {
828
+ context.loop.tokenTracker.reset();
829
+ }
830
+ }
831
+
832
+ const renderer = context.prompt?.renderer || context.loop?.connection?.renderer;
833
+ if (renderer && typeof renderer.renderSessionHistory === 'function') {
834
+ renderer.renderSessionHistory(historyMessages, {
835
+ id: forked.id,
836
+ title: forked.title,
837
+ messagesCount: forked.messages.length
838
+ });
839
+ }
840
+ if (context.prompt?.surface?.viewport && typeof context.prompt.surface.viewport.toBottom === 'function') {
841
+ context.prompt.surface.viewport.toBottom();
842
+ }
843
+ if (context.prompt?.editor?.clear) {
844
+ context.prompt.editor.clear();
845
+ if (typeof context.prompt.scheduleDraw === 'function') context.prompt.scheduleDraw();
846
+ }
847
+
848
+ return ok(`Forked session "${sourceSession.title}" into "${forked.title}" (${forked.id}) with ${forked.messages.length} messages.\nPermissions and allowlists reset: tools will request approval anew.`, { effect: 'inline' });
849
+ }
850
+ },
851
+
729
852
  {
730
853
  name: 'continuum',
731
854
  aliases: ['resume'],
@@ -749,7 +872,7 @@ export const COMMANDS = [
749
872
  const resultText = await runInteractiveContinuum(context.prompt, {
750
873
  loop: context.loop
751
874
  });
752
- return ok(resultText, { effect: 'inline' });
875
+ return ok(resultText, { effect: 'silent' });
753
876
  }
754
877
 
755
878
  const scanner = context.scanner || new ContinuumScanner();
@@ -959,7 +1082,7 @@ export const COMMANDS = [
959
1082
  ctx.loop.updateTierLimits();
960
1083
  }
961
1084
  }
962
- return ok(output, { effect: 'inline' });
1085
+ return ok(output, { effect: 'silent' });
963
1086
  }
964
1087
 
965
1088
  const lines = [
@@ -1064,7 +1187,7 @@ export const COMMANDS = [
1064
1187
  const activateModel = (nextProvider, nextModel, feedbackMessage) => {
1065
1188
  const isProviderChange = nextProvider !== config.provider;
1066
1189
  if (isProviderChange) {
1067
- if (nextProvider === 'antigravity' || nextProvider.startsWith('acp/')) {
1190
+ if (nextProvider === 'antigravity' || nextProvider === 'pi' || nextProvider.startsWith('acp/')) {
1068
1191
  config.apiKey = '';
1069
1192
  delete config.baseUrl;
1070
1193
  } else {
@@ -1093,16 +1216,17 @@ export const COMMANDS = [
1093
1216
  return ok(feedbackMessage || `Now using ${config.provider} / ${config.model}.`, { effect: 'inline' });
1094
1217
  };
1095
1218
 
1219
+ // 1. Antigravity provider (e.g. antigravity or antigravity/Gemini 3.8 Flash (High))
1096
1220
  // 1. Antigravity provider (e.g. antigravity or antigravity/Gemini 3.8 Flash (High))
1097
1221
  if (rawRequested.toLowerCase() === 'antigravity' || rawRequested.toLowerCase().startsWith('antigravity/')) {
1098
1222
  const agyModel = rawRequested.includes('/')
1099
1223
  ? rawRequested.slice(rawRequested.indexOf('/') + 1).trim()
1100
1224
  : (DEFAULT_MODEL_BY_PROVIDER['antigravity'] || 'Gemini 3.8 Flash (Low)');
1101
1225
  const agyPeer = overview.acp.find(p => p.id === 'antigravity');
1102
- const notice = agyPeer && !agyPeer.installed
1103
- ? `⚠️ Notice: Antigravity CLI (agy) is not installed on this machine.\nSetup: ${agyPeer.setupInstruction}\n\nNow using Google Antigravity / ${agyModel}.`
1104
- : `Now using Google Antigravity / ${agyModel}.`;
1105
- return activateModel('antigravity', agyModel, notice);
1226
+ if (agyPeer && !agyPeer.installed) {
1227
+ return fail(`Notice: Antigravity CLI (agy) is not installed on this machine.\nSetup: ${agyPeer.setupInstruction}\n\nModel was not changed.`);
1228
+ }
1229
+ return activateModel('antigravity', agyModel, `Now using Google Antigravity / ${agyModel}.`);
1106
1230
  }
1107
1231
 
1108
1232
  // 2. acp/<peer> or acp/<peer>/<model>
@@ -1112,10 +1236,10 @@ export const COMMANDS = [
1112
1236
  const nextProvider = `acp/${peer}`;
1113
1237
  const peerModel = acpTarget[2] ? acpTarget[2].trim() : (DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer);
1114
1238
  const peerInfo = overview.acp.find(p => p.id === peer);
1115
- const notice = peerInfo && !peerInfo.installed
1116
- ? `⚠️ Notice: "${peerInfo.label}" CLI is not installed on this machine.\nBinary "${peerInfo.id}" was not found on PATH.\nSetup: ${peerInfo.setupInstruction}\n\nNow using ${nextProvider} / ${peerModel}.`
1117
- : `Now using ${nextProvider} / ${peerModel}.`;
1118
- return activateModel(nextProvider, peerModel, notice);
1239
+ if (peerInfo && !peerInfo.installed) {
1240
+ return fail(`Notice: "${peerInfo.label}" CLI is not installed on this machine.\nBinary "${peerInfo.id}" was not found on PATH.\nSetup: ${peerInfo.setupInstruction}\n\nModel was not changed.`);
1241
+ }
1242
+ return activateModel(nextProvider, peerModel, `Now using ${nextProvider} / ${peerModel}.`);
1119
1243
  }
1120
1244
 
1121
1245
  // 3. Known ACP peer directly (e.g. opencode, opencode/deepseek-v4.1-flash-free, claude)
@@ -1124,6 +1248,9 @@ export const COMMANDS = [
1124
1248
  const acpPeer = overview.acp.find(p => p.id === prefix || p.providerKey === prefix);
1125
1249
  if (acpPeer && acpPeer.id !== 'antigravity') {
1126
1250
  const nextProvider = acpPeer.providerKey;
1251
+ if (!acpPeer.installed) {
1252
+ return fail(`Notice: "${acpPeer.label}" CLI is not installed on this machine.\nBinary "${acpPeer.id}" was not found on PATH.\nSetup: ${acpPeer.setupInstruction}\n\nModel was not changed.`);
1253
+ }
1127
1254
  let peerModel;
1128
1255
  if (slashIndex > 0) {
1129
1256
  const rest = rawRequested.slice(slashIndex + 1).trim();
@@ -1138,10 +1265,7 @@ export const COMMANDS = [
1138
1265
  } else {
1139
1266
  peerModel = DEFAULT_MODEL_BY_PROVIDER[nextProvider] || acpPeer.id;
1140
1267
  }
1141
- const notice = !acpPeer.installed
1142
- ? `⚠️ Notice: "${acpPeer.label}" CLI is not installed on this machine.\nBinary "${acpPeer.id}" was not found on PATH.\nSetup: ${acpPeer.setupInstruction}\n\nNow using ${nextProvider} / ${peerModel}.`
1143
- : `Now using ${nextProvider} / ${peerModel}.`;
1144
- return activateModel(nextProvider, peerModel, notice);
1268
+ return activateModel(nextProvider, peerModel, `Now using ${nextProvider} / ${peerModel}.`);
1145
1269
  }
1146
1270
 
1147
1271
  // 4. Known BYOK provider prefix (e.g. gemini/gemini-2.5-flash, anthropic/claude-3-7-sonnet)
package/src/config.js CHANGED
@@ -6,25 +6,33 @@ import { canonicalModelId } from './modelIds.js';
6
6
  import { DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
7
7
  import { causyneHome } from './utils/paths.js';
8
8
 
9
- const CONFIG_DIR = causyneHome();
10
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
11
- const KEY_FILE = path.join(CONFIG_DIR, '.vault_key');
9
+ function configDir() {
10
+ return causyneHome();
11
+ }
12
+ function configFile() {
13
+ return path.join(causyneHome(), 'config.json');
14
+ }
15
+ function keyFile() {
16
+ return path.join(causyneHome(), '.vault_key');
17
+ }
12
18
 
13
19
  function ensureConfigDir() {
14
- if (!fs.existsSync(CONFIG_DIR)) {
20
+ const dir = configDir();
21
+ if (!fs.existsSync(dir)) {
15
22
  // SECURITY: Directory must only be accessible by the owner
16
- fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
23
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
17
24
  }
18
25
  }
19
26
 
20
27
  function getVaultKey() {
21
28
  ensureConfigDir();
22
- if (!fs.existsSync(KEY_FILE)) {
29
+ const kf = keyFile();
30
+ if (!fs.existsSync(kf)) {
23
31
  const key = crypto.randomBytes(32);
24
- fs.writeFileSync(KEY_FILE, key, { mode: 0o600 });
32
+ fs.writeFileSync(kf, key, { mode: 0o600 });
25
33
  return key;
26
34
  }
27
- return fs.readFileSync(KEY_FILE);
35
+ return fs.readFileSync(kf);
28
36
  }
29
37
 
30
38
  function encryptString(text) {
@@ -61,9 +69,10 @@ function decryptString(encryptedText) {
61
69
 
62
70
  export function loadConfig() {
63
71
  ensureConfigDir();
64
- if (fs.existsSync(CONFIG_FILE)) {
72
+ const file = configFile();
73
+ if (fs.existsSync(file)) {
65
74
  try {
66
- const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
75
+ const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
67
76
 
68
77
  // Decrypt API key into memory
69
78
  if (parsed.apiKey) {
@@ -289,6 +298,7 @@ export function saveConfig(config) {
289
298
  }
290
299
 
291
300
  // SECURITY: Config file contains encrypted keys, must be 0600 (owner read/write only)
292
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(configToSave, null, 2), { encoding: 'utf8', mode: 0o600 });
293
- fs.chmodSync(CONFIG_FILE, 0o600); // Enforce on existing files
301
+ const file = configFile();
302
+ fs.writeFileSync(file, JSON.stringify(configToSave, null, 2), { encoding: 'utf8', mode: 0o600 });
303
+ fs.chmodSync(file, 0o600); // Enforce on existing files
294
304
  }
@@ -69,14 +69,31 @@ export async function runInteractiveContinuum(prompt, options = {}) {
69
69
  return `Failed to adopt session: ${adoptRes.error}`;
70
70
  }
71
71
  if (options.loop) {
72
+ options.loop.taskId = `cli_chat_${Date.now()}`;
72
73
  if (options.loop.memoryManager) {
73
74
  options.loop.memoryManager.useSession(adoptRes.sessionId);
74
75
  if (typeof options.loop.memoryManager.loadHistory === 'function') {
75
76
  options.loop.messages = options.loop.memoryManager.loadHistory();
76
77
  }
77
78
  }
79
+ const renderer = prompt.renderer || options.loop?.connection?.renderer;
80
+ if (renderer && typeof renderer.renderSessionHistory === 'function') {
81
+ renderer.renderSessionHistory(options.loop.messages || [], {
82
+ id: adoptRes.sessionId,
83
+ title: adoptRes.title,
84
+ messagesCount: adoptRes.messageCount
85
+ });
86
+ }
87
+ if (prompt.surface?.viewport && typeof prompt.surface.viewport.toBottom === 'function') {
88
+ prompt.surface.viewport.toBottom();
89
+ }
90
+ }
91
+ if (prompt.editor && typeof prompt.editor.clear === 'function') {
92
+ prompt.editor.clear();
93
+ if (typeof prompt.scheduleDraw === 'function')
94
+ prompt.scheduleDraw();
78
95
  }
79
- return `✓ Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\n New active Causyne session: ${adoptRes.sessionId}. Continue working seamlessly.`;
96
+ return `Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\nActive Causyne session: ${adoptRes.sessionId}.`;
80
97
  }
81
98
  /**
82
99
  * Open a preview text modal showing the full conversation transcript for a session.
@@ -44,6 +44,7 @@ export async function runInteractiveContinuum(
44
44
  options: {
45
45
  scanner?: ContinuumScanner;
46
46
  loop?: {
47
+ taskId?: string;
47
48
  messages: Array<{ role: string; content?: unknown }>;
48
49
  memoryManager?: {
49
50
  useSession: (id: string) => unknown;
@@ -92,15 +93,32 @@ export async function runInteractiveContinuum(
92
93
  }
93
94
 
94
95
  if (options.loop) {
96
+ options.loop.taskId = `cli_chat_${Date.now()}`;
95
97
  if (options.loop.memoryManager) {
96
98
  options.loop.memoryManager.useSession(adoptRes.sessionId);
97
99
  if (typeof options.loop.memoryManager.loadHistory === 'function') {
98
100
  options.loop.messages = options.loop.memoryManager.loadHistory();
99
101
  }
100
102
  }
103
+ const renderer = (prompt as any).renderer || (options.loop as any)?.connection?.renderer;
104
+ if (renderer && typeof renderer.renderSessionHistory === 'function') {
105
+ renderer.renderSessionHistory(options.loop.messages || [], {
106
+ id: adoptRes.sessionId,
107
+ title: adoptRes.title,
108
+ messagesCount: adoptRes.messageCount
109
+ });
110
+ }
111
+ if ((prompt as any).surface?.viewport && typeof (prompt as any).surface.viewport.toBottom === 'function') {
112
+ (prompt as any).surface.viewport.toBottom();
113
+ }
114
+ }
115
+
116
+ if ((prompt as any).editor && typeof (prompt as any).editor.clear === 'function') {
117
+ (prompt as any).editor.clear();
118
+ if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
101
119
  }
102
120
 
103
- return `✓ Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\n New active Causyne session: ${adoptRes.sessionId}. Continue working seamlessly.`;
121
+ return `Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\nActive Causyne session: ${adoptRes.sessionId}.`;
104
122
  }
105
123
 
106
124
  /**