@causyne/agent 1.19.0 → 1.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -18
- package/package.json +1 -1
- package/src/acp/client.js +2 -1
- package/src/acp/client.ts +2 -1
- package/src/acp/server.js +5 -6
- package/src/acp/server.ts +4 -6
- package/src/agentLoop.d.ts +1 -0
- package/src/agentLoop.js +505 -241
- package/src/agentLoop.ts +527 -258
- package/src/agentPolicy.js +9 -0
- package/src/agentPolicy.ts +9 -0
- package/src/approvalPolicy.js +55 -0
- package/src/approvalPolicy.ts +66 -0
- package/src/browser/browserRuntime.js +217 -14
- package/src/browser/browserRuntime.ts +255 -14
- package/src/browser/causyneBrowser.js +1215 -68
- package/src/browser/causyneBrowser.ts +1340 -72
- package/src/cliMode.js +66 -37
- package/src/commands.js +343 -72
- package/src/config.js +22 -12
- package/src/continuum/ingest.js +1 -1
- package/src/continuum/ingest.ts +1 -1
- package/src/continuum/ui/continuumPicker.js +18 -1
- package/src/continuum/ui/continuumPicker.ts +19 -1
- package/src/dynamicCatalogue.js +87 -20
- package/src/dynamicCatalogue.ts +85 -15
- package/src/launchIntent.js +40 -0
- package/src/launchIntent.ts +49 -0
- package/src/memoryManager.js +36 -8
- package/src/modelCatalogue.js +2 -0
- package/src/planCache.js +320 -11
- package/src/planCache.ts +402 -13
- package/src/providers/acp.js +67 -1
- package/src/providers/acp.ts +65 -2
- package/src/providers/antigravity.d.ts +5 -1
- package/src/providers/antigravity.js +643 -32
- package/src/providers/antigravity.ts +671 -33
- package/src/providers/base.d.ts +9 -0
- package/src/providers/factory.js +2 -0
- package/src/providers/pi.js +157 -0
- package/src/providers/pi.ts +144 -0
- package/src/provisioning/capabilityProvisioner.js +17 -0
- package/src/provisioning/capabilityTools.js +1 -1
- package/src/sandbox.js +30 -39
- package/src/sessionJournal.js +66 -10
- package/src/sessionJournal.ts +84 -10
- package/src/taskShape.js +9 -9
- package/src/taskShape.ts +9 -9
- package/src/timeMachine.js +124 -0
- package/src/timeMachine.ts +141 -0
- package/src/toolPacks.js +4 -10
- package/src/tools/archive.js +196 -59
- package/src/tools/archive.ts +220 -0
- package/src/tools/browserAutomator.js +78 -9
- package/src/tools/browserAutomator.ts +90 -9
- package/src/tools/desktopOpen.js +114 -31
- package/src/tools/desktopOpen.ts +144 -0
- package/src/tools/gitExec.js +5 -3
- package/src/tools/nativeEngine.js +4 -3
- package/src/tools/nativeEngine.ts +5 -3
- package/src/tools/openSourceToolProvisioner.js +5 -4
- package/src/tools/openSourceToolProvisioner.ts +5 -4
- package/src/tools/registry.js +3 -0
- package/src/tools/screenshot.js +55 -71
- package/src/tools/screenshot.ts +70 -0
- package/src/tools/sysRun.js +284 -117
- package/src/tools/sysRun.ts +347 -0
- package/src/tools/toolSelfRepair.js +109 -2
- package/src/tools/toolSelfRepair.ts +100 -2
- package/src/tools/updatePlan.js +49 -1
- package/src/tools/updatePlan.ts +43 -1
- package/src/tools/viewImage.js +93 -78
- package/src/tools/viewImage.ts +116 -0
- package/src/tools/webFetch.js +20 -6
- package/src/tools/webFetch.ts +26 -6
- package/src/tui/block.d.ts +1 -0
- package/src/tui/chatRenderer.d.ts +21 -0
- package/src/tui/chatRenderer.js +118 -45
- package/src/tui/clipboardSync.js +28 -1
- package/src/tui/clipboardSync.ts +26 -1
- package/src/tui/codeProgress.js +299 -0
- package/src/tui/codeProgress.ts +304 -0
- package/src/tui/codeStreamRenderer.js +116 -0
- package/src/tui/codeStreamRenderer.ts +124 -0
- package/src/tui/commandPresentation.js +11 -0
- package/src/tui/commandPresentation.ts +18 -0
- package/src/tui/completion.js +45 -13
- package/src/tui/composerControls.js +66 -0
- package/src/tui/composerControls.ts +78 -0
- package/src/tui/diff.d.ts +2 -0
- package/src/tui/home.js +4 -2
- package/src/tui/homeTransition.js +21 -0
- package/src/tui/homeTransition.ts +27 -0
- package/src/tui/homeView.js +62 -0
- package/src/tui/homeView.ts +91 -0
- package/src/tui/layout.js +46 -0
- package/src/tui/layout.ts +52 -0
- package/src/tui/messageActionPlacement.js +16 -0
- package/src/tui/messageActionPlacement.ts +25 -0
- package/src/tui/messageInteraction.js +221 -0
- package/src/tui/messageInteraction.ts +275 -0
- package/src/tui/modelPicker.js +13 -0
- package/src/tui/modelPicker.ts +12 -0
- package/src/tui/mouseHover.js +6 -0
- package/src/tui/mouseHover.ts +5 -0
- package/src/tui/prompt.js +199 -52
- package/src/tui/resizeRecovery.js +15 -0
- package/src/tui/resizeRecovery.ts +27 -0
- package/src/tui/scrollInteraction.js +97 -0
- package/src/tui/scrollInteraction.ts +189 -0
- package/src/tui/sessionLayout.js +12 -0
- package/src/tui/sessionLayout.ts +12 -0
- package/src/tui/sessionPicker.js +280 -0
- package/src/tui/sessionPicker.ts +364 -0
- package/src/tui/sessionSidebar.js +78 -0
- package/src/tui/sessionSidebar.ts +95 -0
- package/src/tui/setup.js +1 -1
- package/src/tui/setup.ts +1 -1
- package/src/tui/stageSurface.js +128 -57
- package/src/tui/statusLine.js +5 -5
- package/src/tui/text.d.ts +5 -0
- package/src/tui/textLayout.js +23 -0
- package/src/tui/textLayout.ts +28 -0
- package/src/tui/viewport.js +204 -279
- package/src/tui/viewport.ts +326 -0
- package/src/types/contracts.ts +54 -0
- package/src/utils/paths.js +5 -4
- 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/
|
|
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
|
|
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.
|
|
315
|
-
//
|
|
316
|
-
//
|
|
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
|
|
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
|
-
//
|
|
355
|
-
//
|
|
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
|
|
364
|
-
//
|
|
365
|
-
|
|
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,13 +384,30 @@ 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
|
});
|
|
382
396
|
if (surface) prompt.attachSurface(surface);
|
|
383
397
|
prompt.attach(conn.renderer);
|
|
384
398
|
prompt.start();
|
|
399
|
+
|
|
400
|
+
// Home is a clean route. History appears only after a session is chosen.
|
|
401
|
+
const initialHistory = loop.memoryManager ? loop.memoryManager.loadHistory() : [];
|
|
402
|
+
if (!openedHome && initialHistory.length > 0) {
|
|
403
|
+
conn.renderer.renderSessionHistory(initialHistory, {
|
|
404
|
+
id: loop.memoryManager?.sessionId,
|
|
405
|
+
title: loop.memoryManager?.sessionTitle,
|
|
406
|
+
messagesCount: initialHistory.length
|
|
407
|
+
});
|
|
408
|
+
if (surface?.viewport) surface.viewport.toBottom();
|
|
409
|
+
}
|
|
410
|
+
|
|
385
411
|
// The band is blank until something paints it, so the Stage needs a first
|
|
386
412
|
// frame here. The scrollback path deliberately does NOT get one: there it
|
|
387
413
|
// has always waited for the first keystroke, and changing that as a side
|
|
@@ -404,12 +430,11 @@ export async function chatMode({ home = false } = {}) {
|
|
|
404
430
|
// The key hints are part of the session header now — one hint row, not
|
|
405
431
|
// three stacked lines of chrome above the first prompt.
|
|
406
432
|
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
|
|
410
|
-
// stack to be got wrong, and the two would drift on the first change.
|
|
411
|
-
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);
|
|
412
436
|
} catch (e) {
|
|
437
|
+
if (surface) surface.close();
|
|
413
438
|
process.stderr.write(`[tui] falling back to simple input: ${e.message}\n`);
|
|
414
439
|
prompt = null;
|
|
415
440
|
}
|
|
@@ -478,21 +503,18 @@ export async function chatMode({ home = false } = {}) {
|
|
|
478
503
|
continue;
|
|
479
504
|
}
|
|
480
505
|
|
|
506
|
+
if (commandResult.effect === 'silent') {
|
|
507
|
+
if (prompt && typeof prompt.draw === 'function') prompt.draw();
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
|
|
481
511
|
if (commandResult.effect === 'pick-session' && prompt) {
|
|
482
|
-
const
|
|
483
|
-
prompt
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
label: `${session.id === active ? `${GLYPHS.bullet} ` : ''}${session.title}`,
|
|
489
|
-
description: `${session.messageCount} messages ${GLYPHS.dot} ${session.workspace || 'no workspace'}`,
|
|
490
|
-
value: session
|
|
491
|
-
})),
|
|
492
|
-
onPick: (item) => {
|
|
493
|
-
if (item) prompt.deliver(`/sessions switch ${item.value.id}`);
|
|
494
|
-
}
|
|
495
|
-
}));
|
|
512
|
+
const { runInteractiveSessionPicker } = await import('./tui/sessionPicker.js');
|
|
513
|
+
await runInteractiveSessionPicker(prompt, {
|
|
514
|
+
loop,
|
|
515
|
+
workspace: loop?.workspaceRoot || process.cwd()
|
|
516
|
+
});
|
|
517
|
+
if (prompt && typeof prompt.draw === 'function') prompt.draw();
|
|
496
518
|
continue;
|
|
497
519
|
}
|
|
498
520
|
|
|
@@ -510,6 +532,12 @@ export async function chatMode({ home = false } = {}) {
|
|
|
510
532
|
continue;
|
|
511
533
|
}
|
|
512
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
|
+
|
|
513
541
|
// A skill was invoked: it becomes part of the REQUEST, not terminal output.
|
|
514
542
|
//
|
|
515
543
|
// This is the whole point. `/skills <id>` used to print the file and call
|
|
@@ -537,6 +565,7 @@ export async function chatMode({ home = false } = {}) {
|
|
|
537
565
|
}
|
|
538
566
|
}
|
|
539
567
|
|
|
568
|
+
homeTransition.beginTurn(loop);
|
|
540
569
|
loop.userPrompt = task;
|
|
541
570
|
// ONE USER REQUEST IS ONE TASK.
|
|
542
571
|
//
|
|
@@ -557,7 +586,7 @@ export async function chatMode({ home = false } = {}) {
|
|
|
557
586
|
const startedAt = Date.now();
|
|
558
587
|
if (prompt) prompt.setBusy(true);
|
|
559
588
|
try {
|
|
560
|
-
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);
|
|
561
590
|
if (!loop.config.provider || (!loop.config.apiKey && !isNoKey)) {
|
|
562
591
|
conn.renderer.write('\n' + paint('warn', ' No API provider or key configured.') + '\n' +
|
|
563
592
|
paint('muted', ' Run /setup or select setup from the home menu to configure your provider.\n'));
|