@causyne/agent 1.17.0 → 1.19.0
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/package.json +1 -1
- package/src/agentLoop.js +2348 -2518
- package/src/agentLoop.ts +2865 -0
- package/src/checkpoints.d.ts +4 -0
- package/src/cliMode.js +10 -3
- package/src/commands.js +274 -25
- package/src/config.js +22 -0
- package/src/contextManager.d.ts +10 -0
- package/src/continuum/adapters/antigravity.js +193 -0
- package/src/continuum/adapters/antigravity.ts +204 -0
- package/src/continuum/adapters/base.js +48 -0
- package/src/continuum/adapters/base.ts +57 -0
- package/src/continuum/adapters/causyne.js +66 -0
- package/src/continuum/adapters/causyne.ts +72 -0
- package/src/continuum/adapters/claudeCode.js +171 -0
- package/src/continuum/adapters/claudeCode.ts +179 -0
- package/src/continuum/adapters/codex.js +181 -0
- package/src/continuum/adapters/codex.ts +193 -0
- package/src/continuum/adapters/opencode.js +134 -0
- package/src/continuum/adapters/opencode.ts +153 -0
- package/src/continuum/compactor.js +54 -0
- package/src/continuum/compactor.ts +83 -0
- package/src/continuum/index.js +8 -0
- package/src/continuum/index.ts +9 -0
- package/src/continuum/ingest.js +63 -0
- package/src/continuum/ingest.ts +89 -0
- package/src/continuum/sanitizer.js +55 -0
- package/src/continuum/sanitizer.ts +59 -0
- package/src/continuum/scanner.js +86 -0
- package/src/continuum/scanner.ts +106 -0
- package/src/continuum/types.js +3 -0
- package/src/continuum/types.ts +51 -0
- package/src/continuum/ui/continuumPicker.js +111 -0
- package/src/continuum/ui/continuumPicker.ts +145 -0
- package/src/cortex/autoCondenser.d.ts +2 -0
- package/src/cortex/vectorDb.d.ts +1 -0
- package/src/designPalettes.d.ts +2 -0
- package/src/devMode.d.ts +1 -0
- package/src/dynamicCatalogue.js +140 -1
- package/src/dynamicCatalogue.ts +179 -1
- package/src/embodimentSession.d.ts +2 -0
- package/src/entrypoint.js +12 -0
- package/src/memory.d.ts +1 -0
- package/src/memoryManager.d.ts +1 -0
- package/src/modelIds.d.ts +2 -0
- package/src/outputStore.d.ts +4 -0
- package/src/providers/acp.js +321 -267
- package/src/providers/acp.ts +360 -0
- package/src/providers/antigravity.js +389 -239
- package/src/providers/antigravity.ts +450 -0
- package/src/providers/base.d.ts +68 -0
- package/src/providers/factory.d.ts +1 -0
- package/src/provisioning/capabilityProvisioner.d.ts +2 -0
- package/src/sandbox.d.ts +1 -0
- package/src/skillsManager.d.ts +3 -0
- package/src/slopDetector.d.ts +3 -0
- package/src/taskBuffer.d.ts +1 -0
- package/src/tokenTracker.d.ts +1 -0
- package/src/toolPacks.d.ts +8 -0
- package/src/tools/registry.d.ts +4 -0
- package/src/tui/chatRenderer.js +71 -12
- package/src/tui/clipboardSync.js +36 -0
- package/src/tui/clipboardSync.ts +36 -0
- package/src/tui/dialogs.js +15 -2
- package/src/tui/home.js +27 -25
- package/src/tui/modelPicker.js +221 -0
- package/src/tui/modelPicker.ts +290 -0
- package/src/tui/prompt.js +17 -6
- package/src/tui/selectList.js +20 -0
- package/src/tui/theme.js +4 -0
package/src/cliMode.js
CHANGED
|
@@ -192,7 +192,7 @@ function openHomeMenu(prompt, conn) {
|
|
|
192
192
|
* terminal over after stopping the prompt. That is what keeps the menu from
|
|
193
193
|
* becoming a second, subtly different CLI.
|
|
194
194
|
*/
|
|
195
|
-
async function runHomeAction(action, { prompt, conn, finish }) {
|
|
195
|
+
async function runHomeAction(action, { prompt, conn, finish, loop }) {
|
|
196
196
|
const reopen = () => { if (prompt) openHomeMenu(prompt, conn); };
|
|
197
197
|
|
|
198
198
|
switch (action.kind) {
|
|
@@ -217,11 +217,15 @@ async function runHomeAction(action, { prompt, conn, finish }) {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
case 'command': {
|
|
220
|
-
const result = await handleInput(action.command, { surface: 'terminal', prompt });
|
|
220
|
+
const result = await handleInput(action.command, { surface: 'terminal', prompt, loop });
|
|
221
221
|
if (result) {
|
|
222
222
|
const wrapped = wrapBlock(result.output, conn.renderer.width()).join('\n');
|
|
223
223
|
conn.renderer.write('\n' + (result.ok ? wrapped : paint('danger', wrapped)) + '\n');
|
|
224
224
|
}
|
|
225
|
+
if (action.id === 'model' || action.id === 'continuum' || action.id === 'sessions') {
|
|
226
|
+
conn.renderer.write(homeStatusLine({ config: loadConfig() }) + '\n');
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
225
229
|
reopen();
|
|
226
230
|
return null;
|
|
227
231
|
}
|
|
@@ -428,7 +432,7 @@ export async function chatMode({ home = false } = {}) {
|
|
|
428
432
|
// A menu pick arrives through the same read() a typed line does, so there
|
|
429
433
|
// is one place the loop waits and one place it dispatches.
|
|
430
434
|
if (task && typeof task === 'object' && task.homeAction) {
|
|
431
|
-
const outcome = await runHomeAction(task.homeAction, { prompt, conn, finish });
|
|
435
|
+
const outcome = await runHomeAction(task.homeAction, { prompt, conn, finish, loop });
|
|
432
436
|
if (outcome === 'exit') break;
|
|
433
437
|
continue;
|
|
434
438
|
}
|
|
@@ -525,6 +529,9 @@ export async function chatMode({ home = false } = {}) {
|
|
|
525
529
|
const wrapped = wrapBlock(commandResult.output, width).join('\n');
|
|
526
530
|
const body = commandResult.ok ? wrapped : paint('danger', wrapped);
|
|
527
531
|
conn.renderer.write('\n' + body + '\n');
|
|
532
|
+
if (commandResult.output && (commandResult.output.includes('Now using') || commandResult.output.includes('Active model switched') || commandResult.output.includes('Saved API key'))) {
|
|
533
|
+
conn.renderer.write(homeStatusLine({ config: loadConfig() }) + '\n');
|
|
534
|
+
}
|
|
528
535
|
if (commandResult.effect === 'exit') { finish(); break; }
|
|
529
536
|
continue;
|
|
530
537
|
}
|
package/src/commands.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from './userSkills.js';
|
|
21
21
|
import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
|
|
22
22
|
import { loadConfig, saveConfig } from './config.js';
|
|
23
|
-
import { resolveAvailableModels, getCuratedModels } from './dynamicCatalogue.js';
|
|
23
|
+
import { resolveAvailableModels, getCuratedModels, getAvailableProvidersOverview } from './dynamicCatalogue.js';
|
|
24
24
|
import { DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
25
25
|
import { isAcpProvider } from './providers/acp.js';
|
|
26
26
|
import {
|
|
@@ -630,6 +630,80 @@ export const COMMANDS = [
|
|
|
630
630
|
}
|
|
631
631
|
},
|
|
632
632
|
|
|
633
|
+
{
|
|
634
|
+
name: 'continuum',
|
|
635
|
+
aliases: ['resume'],
|
|
636
|
+
scope: 'local',
|
|
637
|
+
usage: '/continuum [list | read <id> | adopt <id>]',
|
|
638
|
+
description: 'Cross-agent session extraction and resumption (Antigravity, OpenCode, Codex, Claude Code)',
|
|
639
|
+
dialogTitle: 'Continuum',
|
|
640
|
+
run: async (args = [], context = {}) => {
|
|
641
|
+
const {
|
|
642
|
+
ContinuumScanner,
|
|
643
|
+
adoptContinuumSession,
|
|
644
|
+
runInteractiveContinuum,
|
|
645
|
+
openContinuumPreview
|
|
646
|
+
} = await import('./continuum/index.js');
|
|
647
|
+
|
|
648
|
+
const verb = String(args[0] || '').toLowerCase();
|
|
649
|
+
const targetId = args[1];
|
|
650
|
+
|
|
651
|
+
// If interactive modal prompt is available and no subverb is passed
|
|
652
|
+
if (!verb && context.prompt && typeof context.prompt.openLayer === 'function') {
|
|
653
|
+
const resultText = await runInteractiveContinuum(context.prompt, {
|
|
654
|
+
loop: context.loop
|
|
655
|
+
});
|
|
656
|
+
return ok(resultText, { effect: 'inline' });
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const scanner = context.scanner || new ContinuumScanner();
|
|
660
|
+
|
|
661
|
+
if (verb === 'read' && targetId) {
|
|
662
|
+
if (context.prompt && typeof context.prompt.openLayer === 'function') {
|
|
663
|
+
const opened = await openContinuumPreview(targetId, context.prompt, scanner);
|
|
664
|
+
if (opened) return ok(`Displaying preview for ${targetId}.`);
|
|
665
|
+
}
|
|
666
|
+
const detail = await scanner.fetchSession(targetId);
|
|
667
|
+
if (!detail) return fail(`No peer session found with ID "${targetId}".`);
|
|
668
|
+
const transcriptText = detail.messages.map(m => `[${m.role.toUpperCase()}] ${m.content}`).join('\n\n');
|
|
669
|
+
return ok(`=== ${detail.title} (${detail.sourceLabel}) ===\nWorkspace: ${detail.workspacePath}\n\n${transcriptText}`);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (verb === 'adopt' && targetId) {
|
|
673
|
+
const adoptRes = await adoptContinuumSession(targetId, {
|
|
674
|
+
scanner,
|
|
675
|
+
currentLoopMessages: context.loop?.messages
|
|
676
|
+
});
|
|
677
|
+
if (!adoptRes.ok) return fail(adoptRes.error || `Failed to adopt session "${targetId}".`);
|
|
678
|
+
if (context.loop?.memoryManager) {
|
|
679
|
+
context.loop.memoryManager.useSession(adoptRes.sessionId);
|
|
680
|
+
if (typeof context.loop.memoryManager.loadHistory === 'function') {
|
|
681
|
+
context.loop.messages = context.loop.memoryManager.loadHistory();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
return ok(`Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\nActive Causyne session: ${adoptRes.sessionId}.`);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// Default or 'list':
|
|
688
|
+
const sessions = await scanner.scanAllSessions({ limit: 40 });
|
|
689
|
+
if (sessions.length === 0) {
|
|
690
|
+
return ok('No peer agent sessions discovered across Antigravity, OpenCode, Codex, or Claude Code.');
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const lines = sessions.map(s => {
|
|
694
|
+
const when = new Date(s.updatedAt).toISOString().slice(0, 16).replace('T', ' ');
|
|
695
|
+
const ws = s.workspacePath ? path.basename(s.workspacePath) : '(default)';
|
|
696
|
+
return ` [${s.sourceLabel.padEnd(12)}] ${s.id.padEnd(38)} ${when} ${String(s.messageCount).padStart(3)} msgs ${ws}\n ${s.title}`;
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
return ok(
|
|
700
|
+
`Discovered ${sessions.length} cross-agent sessions:\n`
|
|
701
|
+
+ lines.join('\n')
|
|
702
|
+
+ '\n\nUsage:\n /continuum — open interactive picker\n /continuum adopt <id> — adopt & resume session\n /continuum read <id> — preview full transcript'
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
|
|
633
707
|
{
|
|
634
708
|
name: 'approvals',
|
|
635
709
|
scope: 'local',
|
|
@@ -710,79 +784,254 @@ export const COMMANDS = [
|
|
|
710
784
|
complete: () => {
|
|
711
785
|
const config = loadConfig();
|
|
712
786
|
const currentProvider = config.provider || '';
|
|
713
|
-
const
|
|
787
|
+
const overview = getAvailableProvidersOverview(config);
|
|
714
788
|
const items = [
|
|
715
|
-
{ value: 'list', label: 'list', description: '
|
|
789
|
+
{ value: 'list', label: 'list', description: 'overview of all BYOK and ACP models' },
|
|
716
790
|
{ value: 'refresh', label: 'refresh', description: 'poll provider API for live models' }
|
|
717
791
|
];
|
|
792
|
+
|
|
793
|
+
// 1. Models for the active provider
|
|
794
|
+
const curated = getCuratedModels(currentProvider);
|
|
718
795
|
for (const m of curated) {
|
|
719
|
-
items.push({ value: m, label: m, description: currentProvider
|
|
796
|
+
items.push({ value: m, label: m, description: `[active] ${currentProvider}` });
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// 2. ACP Peer Agents (with live auto-detected status)
|
|
800
|
+
for (const peer of overview.acp) {
|
|
801
|
+
const statusTag = peer.installed ? '(ready)' : '(not installed)';
|
|
802
|
+
items.push({
|
|
803
|
+
value: peer.providerKey,
|
|
804
|
+
label: peer.providerKey,
|
|
805
|
+
description: `[ACP: ${peer.label}] ${statusTag}`
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
if (peer.installed && Array.isArray(peer.models)) {
|
|
809
|
+
for (const m of peer.models.slice(0, 3)) {
|
|
810
|
+
if (peer.isCurrent && curated.includes(m)) continue;
|
|
811
|
+
const targetVal = m.includes('/') ? m : `${peer.providerKey}/${m}`;
|
|
812
|
+
items.push({
|
|
813
|
+
value: targetVal,
|
|
814
|
+
label: targetVal,
|
|
815
|
+
description: `[ACP: ${peer.label}]`
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
}
|
|
720
819
|
}
|
|
820
|
+
|
|
821
|
+
// 3. BYOK Providers (Cloud & Local)
|
|
822
|
+
for (const p of overview.byok) {
|
|
823
|
+
const configTag = p.isConfigured ? '(configured)' : '(needs key)';
|
|
824
|
+
items.push({
|
|
825
|
+
value: p.id,
|
|
826
|
+
label: p.id,
|
|
827
|
+
description: `[BYOK: ${p.label}] ${configTag}`
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
if (p.isConfigured && Array.isArray(p.models)) {
|
|
831
|
+
for (const m of p.models.slice(0, 2)) {
|
|
832
|
+
if (p.isCurrent && curated.includes(m)) continue;
|
|
833
|
+
items.push({
|
|
834
|
+
value: `${p.id}/${m}`,
|
|
835
|
+
label: `${p.id}/${m}`,
|
|
836
|
+
description: `[BYOK: ${p.label}]`
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
721
842
|
return items;
|
|
722
843
|
},
|
|
723
|
-
run: async (argv) => {
|
|
844
|
+
run: async (argv, ctx = {}) => {
|
|
724
845
|
const config = loadConfig();
|
|
846
|
+
const overview = getAvailableProvidersOverview(config);
|
|
847
|
+
|
|
725
848
|
if (argv.length === 0) {
|
|
726
|
-
|
|
849
|
+
if (ctx.prompt) {
|
|
850
|
+
const { runInteractiveModelPicker } = await import('./tui/modelPicker.js');
|
|
851
|
+
const output = await runInteractiveModelPicker(ctx.prompt, { loadConfig, saveConfig }, { loop: ctx.loop });
|
|
852
|
+
if (ctx.loop) {
|
|
853
|
+
ctx.loop.config = loadConfig();
|
|
854
|
+
if (typeof ctx.loop.updateTierLimits === 'function') {
|
|
855
|
+
ctx.loop.updateTierLimits();
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return ok(output, { effect: 'inline' });
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const lines = [
|
|
862
|
+
`Active Provider : ${config.provider || 'no provider configured'}`,
|
|
863
|
+
`Active Model : ${config.model || 'none'}`,
|
|
864
|
+
'',
|
|
865
|
+
'────────────────────────────────────────────────────────────',
|
|
866
|
+
'BYOK PROVIDERS (Cloud & Local API)',
|
|
867
|
+
'────────────────────────────────────────────────────────────'
|
|
868
|
+
];
|
|
869
|
+
for (const p of overview.byok) {
|
|
870
|
+
const status = p.isConfigured ? (p.isCurrent ? '● Configured (Active)' : '○ Configured') : '─ Not configured (run /setup)';
|
|
871
|
+
lines.push(` • ${p.label.padEnd(26)} [${status}]`);
|
|
872
|
+
}
|
|
873
|
+
lines.push('');
|
|
874
|
+
lines.push('────────────────────────────────────────────────────────────');
|
|
875
|
+
lines.push('ACP PEER AGENTS (Local Coding Agents & CLI Engines)');
|
|
876
|
+
lines.push('────────────────────────────────────────────────────────────');
|
|
877
|
+
for (const peer of overview.acp) {
|
|
878
|
+
const icon = peer.installed ? '✅' : '❌';
|
|
879
|
+
const status = peer.installed ? (peer.isCurrent ? 'READY (Active)' : 'READY') : 'NOT INSTALLED';
|
|
880
|
+
lines.push(` ${icon} ${peer.label.padEnd(24)} — ${status}`);
|
|
881
|
+
}
|
|
882
|
+
lines.push('');
|
|
883
|
+
lines.push('Use /model list to see all models in each category.');
|
|
884
|
+
lines.push('Use /model <name> or /model acp/<peer> to switch model.');
|
|
885
|
+
lines.push('Use /setup to configure credentials and endpoints.');
|
|
886
|
+
return ok(lines.join('\n'));
|
|
727
887
|
}
|
|
888
|
+
|
|
728
889
|
const first = argv[0].toLowerCase();
|
|
729
890
|
if (first === 'list' || first === 'ls') {
|
|
730
|
-
const targetProvider = argv[1]
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
891
|
+
const targetProvider = argv[1];
|
|
892
|
+
|
|
893
|
+
// Specific provider requested (e.g. /model list gemini)
|
|
894
|
+
if (targetProvider && targetProvider !== 'all') {
|
|
895
|
+
const result = await resolveAvailableModels(targetProvider, config);
|
|
896
|
+
const active = config.model;
|
|
897
|
+
const lines = [
|
|
898
|
+
`Available models for ${targetProvider} (source: ${result.source}):`,
|
|
899
|
+
''
|
|
900
|
+
];
|
|
901
|
+
for (const m of result.models) {
|
|
902
|
+
const isCurrent = m === active && config.provider === targetProvider;
|
|
903
|
+
lines.push(` ${isCurrent ? '• ' : ' '}${m}${isCurrent ? ' (active)' : ''}`);
|
|
904
|
+
}
|
|
905
|
+
if (result.models.length === 0) {
|
|
906
|
+
lines.push(' (this peer CLI publishes no model list; enter one with /model <name>)');
|
|
907
|
+
}
|
|
908
|
+
lines.push('');
|
|
909
|
+
lines.push('Use /model <name> to select, or /model refresh to poll the provider API.');
|
|
910
|
+
return ok(lines.join('\n'));
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// Comprehensive categorized listing
|
|
734
914
|
const lines = [
|
|
735
|
-
|
|
736
|
-
''
|
|
915
|
+
'============================================================',
|
|
916
|
+
'BYOK PROVIDERS (Cloud APIs & Local Endpoints)',
|
|
917
|
+
'============================================================'
|
|
737
918
|
];
|
|
738
|
-
for (const
|
|
739
|
-
const
|
|
740
|
-
lines.push(`
|
|
919
|
+
for (const p of overview.byok) {
|
|
920
|
+
const badge = p.isConfigured ? (p.isCurrent ? '● ACTIVE' : '○ CONFIGURED') : 'NEEDS KEY';
|
|
921
|
+
lines.push(` • ${p.label} [${badge}]`);
|
|
922
|
+
const modelSample = p.models.slice(0, 5).join(', ');
|
|
923
|
+
lines.push(` Models: ${modelSample}${p.models.length > 5 ? `, ... (${p.models.length} total)` : ''}`);
|
|
924
|
+
lines.push(` Switch: /model ${p.id}/${p.defaultModel}`);
|
|
925
|
+
lines.push('');
|
|
741
926
|
}
|
|
742
|
-
|
|
743
|
-
|
|
927
|
+
|
|
928
|
+
lines.push('============================================================');
|
|
929
|
+
lines.push('ACP PEER AGENTS (Local Agents & CLI Engines)');
|
|
930
|
+
lines.push('============================================================');
|
|
931
|
+
for (const peer of overview.acp) {
|
|
932
|
+
const icon = peer.installed ? '✅' : '❌';
|
|
933
|
+
const status = peer.installed ? (peer.isCurrent ? 'READY (Active)' : 'READY') : 'NOT INSTALLED';
|
|
934
|
+
lines.push(` ${icon} ${peer.label} — ${status}`);
|
|
935
|
+
lines.push(` Command: ${peer.command}`);
|
|
936
|
+
if (peer.installed) {
|
|
937
|
+
lines.push(` Models: ${peer.models.join(', ')}`);
|
|
938
|
+
lines.push(` Switch: /model ${peer.providerKey}`);
|
|
939
|
+
} else {
|
|
940
|
+
lines.push(` Setup: ${peer.setupInstruction}`);
|
|
941
|
+
}
|
|
942
|
+
lines.push('');
|
|
744
943
|
}
|
|
745
|
-
|
|
746
|
-
lines.push('
|
|
944
|
+
|
|
945
|
+
lines.push('------------------------------------------------------------');
|
|
946
|
+
lines.push('Use /model <name> or /model acp/<peer> to select.');
|
|
947
|
+
lines.push('Use /setup to configure credentials or endpoints.');
|
|
747
948
|
return ok(lines.join('\n'));
|
|
748
949
|
}
|
|
950
|
+
|
|
749
951
|
if (first === 'refresh') {
|
|
750
952
|
if (!config.provider) return fail('No provider configured. Run /setup first.');
|
|
751
953
|
const result = await resolveAvailableModels(config.provider, config, true);
|
|
752
954
|
return ok(`Refreshed ${config.provider} models (${result.models.length} available, source: ${result.source}). Run /model list to view.`);
|
|
753
955
|
}
|
|
956
|
+
|
|
754
957
|
const requested = argv.join(' ').trim();
|
|
755
958
|
|
|
756
|
-
//
|
|
757
|
-
// `<peer>/<model>` while an ACP provider is active is a model id, because
|
|
758
|
-
// peer models are namespaced too (opencode/beam-free).
|
|
959
|
+
// Check if user requested an ACP peer
|
|
759
960
|
const acpTarget = requested.match(/^acp\/([a-z0-9_-]+)(?:\/(.+))?$/i);
|
|
760
961
|
if (acpTarget) {
|
|
761
962
|
const peer = acpTarget[1].toLowerCase();
|
|
762
963
|
const nextProvider = `acp/${peer}`;
|
|
964
|
+
const peerInfo = overview.acp.find(p => p.id === peer);
|
|
965
|
+
|
|
763
966
|
if (nextProvider !== config.provider) { config.apiKey = ''; delete config.baseUrl; }
|
|
764
967
|
config.provider = nextProvider;
|
|
765
968
|
config.model = acpTarget[2] || DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer;
|
|
766
969
|
saveConfig(config);
|
|
970
|
+
if (ctx.loop) ctx.loop.config = loadConfig();
|
|
971
|
+
|
|
972
|
+
if (peerInfo && !peerInfo.installed) {
|
|
973
|
+
return ok(
|
|
974
|
+
`⚠️ Notice: "${peerInfo.label}" CLI is not installed on this machine.\n` +
|
|
975
|
+
`Binary "${peerInfo.id}" was not found on PATH.\n` +
|
|
976
|
+
`Setup: ${peerInfo.setupInstruction}\n\n` +
|
|
977
|
+
`Now using ${config.provider} / ${config.model}.`
|
|
978
|
+
);
|
|
979
|
+
}
|
|
767
980
|
return ok(`Now using ${config.provider} / ${config.model}.`);
|
|
768
981
|
}
|
|
982
|
+
|
|
983
|
+
// If peer model is set while in ACP
|
|
769
984
|
if (isAcpProvider(config.provider) && requested.includes('/')) {
|
|
770
985
|
config.model = requested;
|
|
771
986
|
saveConfig(config);
|
|
772
|
-
|
|
987
|
+
if (ctx.loop) {
|
|
988
|
+
ctx.loop.config = loadConfig();
|
|
989
|
+
if (typeof ctx.loop.updateTierLimits === 'function') ctx.loop.updateTierLimits();
|
|
990
|
+
}
|
|
991
|
+
return ok(`Now using ${config.provider} / ${config.model}.`, { effect: 'inline' });
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// If user typed bare 'antigravity' or 'antigravity/model'
|
|
995
|
+
if (requested === 'antigravity' || requested.startsWith('antigravity/')) {
|
|
996
|
+
const agyModel = requested.includes('/') ? requested.split('/')[1] : (DEFAULT_MODEL_BY_PROVIDER['antigravity'] || 'Gemini 3.8 Flash (Low)');
|
|
997
|
+
if (config.provider !== 'antigravity') { config.apiKey = ''; delete config.baseUrl; }
|
|
998
|
+
config.provider = 'antigravity';
|
|
999
|
+
config.model = agyModel;
|
|
1000
|
+
saveConfig(config);
|
|
1001
|
+
if (ctx.loop) {
|
|
1002
|
+
ctx.loop.config = loadConfig();
|
|
1003
|
+
if (typeof ctx.loop.updateTierLimits === 'function') ctx.loop.updateTierLimits();
|
|
1004
|
+
}
|
|
1005
|
+
const agyPeer = overview.acp.find(p => p.id === 'antigravity');
|
|
1006
|
+
if (agyPeer && !agyPeer.installed) {
|
|
1007
|
+
return ok(
|
|
1008
|
+
`⚠️ Notice: Antigravity CLI (agy) is not installed on this machine.\n` +
|
|
1009
|
+
`Setup: ${agyPeer.setupInstruction}\n\n` +
|
|
1010
|
+
`Now using antigravity / ${config.model}.`,
|
|
1011
|
+
{ effect: 'inline' }
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
return ok(`Now using antigravity / ${config.model}.`, { effect: 'inline' });
|
|
773
1015
|
}
|
|
774
1016
|
|
|
775
1017
|
const separator = requested.indexOf('/');
|
|
776
1018
|
if (separator > 0) {
|
|
777
1019
|
const provider = requested.slice(0, separator);
|
|
778
|
-
if (provider !== config.provider) {
|
|
1020
|
+
if (provider !== config.provider) {
|
|
1021
|
+
config.apiKey = config.providerKeys?.[provider] || '';
|
|
1022
|
+
delete config.baseUrl;
|
|
1023
|
+
}
|
|
779
1024
|
config.provider = provider;
|
|
780
1025
|
config.model = requested.slice(separator + 1);
|
|
781
1026
|
} else {
|
|
782
1027
|
config.model = requested;
|
|
783
1028
|
}
|
|
784
1029
|
saveConfig(config);
|
|
785
|
-
|
|
1030
|
+
if (ctx.loop) {
|
|
1031
|
+
ctx.loop.config = loadConfig();
|
|
1032
|
+
if (typeof ctx.loop.updateTierLimits === 'function') ctx.loop.updateTierLimits();
|
|
1033
|
+
}
|
|
1034
|
+
return ok(`Now using ${config.provider} / ${config.model}.`, { effect: 'inline' });
|
|
786
1035
|
}
|
|
787
1036
|
},
|
|
788
1037
|
|
package/src/config.js
CHANGED
|
@@ -78,6 +78,21 @@ export function loadConfig() {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
// Decrypt provider-specific API keys if stored
|
|
82
|
+
if (parsed.providerKeys && typeof parsed.providerKeys === 'object') {
|
|
83
|
+
for (const [provider, keyVal] of Object.entries(parsed.providerKeys)) {
|
|
84
|
+
if (typeof keyVal === 'string' && keyVal) {
|
|
85
|
+
parsed.providerKeys[provider] = decryptString(keyVal);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (parsed.apiKey && parsed.provider) {
|
|
90
|
+
parsed.providerKeys = parsed.providerKeys || {};
|
|
91
|
+
if (!parsed.providerKeys[parsed.provider]) {
|
|
92
|
+
parsed.providerKeys[parsed.provider] = parsed.apiKey;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
// Self-heal a model id written before src/modelIds.js existed.
|
|
82
97
|
const canonicalModel = canonicalModelId(parsed.model);
|
|
83
98
|
if (canonicalModel !== parsed.model) {
|
|
@@ -265,6 +280,13 @@ export function saveConfig(config) {
|
|
|
265
280
|
if (configToSave.apiKey) {
|
|
266
281
|
configToSave.apiKey = encryptString(configToSave.apiKey);
|
|
267
282
|
}
|
|
283
|
+
if (configToSave.providerKeys && typeof configToSave.providerKeys === 'object') {
|
|
284
|
+
for (const [provider, keyVal] of Object.entries(configToSave.providerKeys)) {
|
|
285
|
+
if (typeof keyVal === 'string' && keyVal) {
|
|
286
|
+
configToSave.providerKeys[provider] = encryptString(keyVal);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
268
290
|
|
|
269
291
|
// SECURITY: Config file contains encrypted keys, must be 0600 (owner read/write only)
|
|
270
292
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(configToSave, null, 2), { encoding: 'utf8', mode: 0o600 });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function resolveCharPool(...args: any[]): any;
|
|
2
|
+
export function measureMessages(...args: any[]): any;
|
|
3
|
+
export function resultCapFor(...args: any[]): any;
|
|
4
|
+
export function decayToolResults(...args: any[]): any;
|
|
5
|
+
export function buildWindow(...args: any[]): any;
|
|
6
|
+
export function compactInPlace(...args: any[]): any;
|
|
7
|
+
export function describeDroppedMessages(...args: any[]): any;
|
|
8
|
+
export function sanitizeSequences(...args: any[]): any;
|
|
9
|
+
export function applyProgressiveCompaction(...args: any[]): any;
|
|
10
|
+
export function snipOversizedToolOutputs(...args: any[]): any;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Antigravity Continuum Adapter: scans Antigravity IDE and CLI session brains.
|
|
2
|
+
// Authorship: Strict TypeScript (Causyne Agent).
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
7
|
+
import { BaseContinuumAdapter, isSafeIdentifier, readBoundedLines } from './base.js';
|
|
8
|
+
import { cleanUserText, cleanAssistantText } from '../sanitizer.js';
|
|
9
|
+
export class AntigravityAdapter extends BaseContinuumAdapter {
|
|
10
|
+
platform = 'antigravity';
|
|
11
|
+
label = 'Antigravity';
|
|
12
|
+
home = os.homedir();
|
|
13
|
+
cliSummaryDb = path.join(this.home, '.gemini/antigravity-cli/conversation_summaries.db');
|
|
14
|
+
ideBrainDir = path.join(this.home, '.gemini/antigravity-ide/brain');
|
|
15
|
+
cliBrainDir = path.join(this.home, '.gemini/antigravity-cli/brain');
|
|
16
|
+
isAvailable() {
|
|
17
|
+
return fs.existsSync(this.cliSummaryDb) || fs.existsSync(this.ideBrainDir) || fs.existsSync(this.cliBrainDir);
|
|
18
|
+
}
|
|
19
|
+
async listSessions(limit = 100) {
|
|
20
|
+
const map = new Map();
|
|
21
|
+
// 1. Ingest summaries from SQLite index if present
|
|
22
|
+
if (fs.existsSync(this.cliSummaryDb)) {
|
|
23
|
+
let db = null;
|
|
24
|
+
try {
|
|
25
|
+
db = new DatabaseSync(this.cliSummaryDb, { readOnly: true });
|
|
26
|
+
const rows = db.prepare(`
|
|
27
|
+
SELECT conversation_id, title, preview, step_count, last_modified_time, workspace_uris
|
|
28
|
+
FROM conversation_summaries
|
|
29
|
+
ORDER BY last_modified_time DESC
|
|
30
|
+
LIMIT ?
|
|
31
|
+
`).all(limit);
|
|
32
|
+
for (const row of rows) {
|
|
33
|
+
if (!row.conversation_id)
|
|
34
|
+
continue;
|
|
35
|
+
let ws = '';
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(row.workspace_uris);
|
|
38
|
+
ws = Array.isArray(parsed) && parsed[0] ? String(parsed[0]).replace('file://', '') : '';
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
ws = row.workspace_uris || '';
|
|
42
|
+
}
|
|
43
|
+
map.set(row.conversation_id, {
|
|
44
|
+
id: `antigravity:${row.conversation_id}`,
|
|
45
|
+
sourcePlatform: this.platform,
|
|
46
|
+
sourceLabel: this.label,
|
|
47
|
+
title: row.title || 'Untitled Session',
|
|
48
|
+
workspacePath: ws,
|
|
49
|
+
updatedAt: new Date(row.last_modified_time).getTime() || Date.now(),
|
|
50
|
+
messageCount: row.step_count || 1,
|
|
51
|
+
snippet: row.preview || ''
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Best-effort read
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
if (db) {
|
|
60
|
+
try {
|
|
61
|
+
db.close();
|
|
62
|
+
}
|
|
63
|
+
catch { /* ignore */ }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// 2. Scan IDE and CLI brain transcripts for active sessions
|
|
68
|
+
const scanDirs = [
|
|
69
|
+
{ dir: this.ideBrainDir, label: 'IDE' },
|
|
70
|
+
{ dir: this.cliBrainDir, label: 'CLI' }
|
|
71
|
+
];
|
|
72
|
+
for (const { dir } of scanDirs) {
|
|
73
|
+
if (!fs.existsSync(dir))
|
|
74
|
+
continue;
|
|
75
|
+
try {
|
|
76
|
+
const entries = fs.readdirSync(dir);
|
|
77
|
+
for (const cid of entries) {
|
|
78
|
+
if (!isSafeIdentifier(cid))
|
|
79
|
+
continue;
|
|
80
|
+
const tpath = path.join(dir, cid, '.system_generated/logs/transcript.jsonl');
|
|
81
|
+
if (!fs.existsSync(tpath))
|
|
82
|
+
continue;
|
|
83
|
+
if (map.has(cid))
|
|
84
|
+
continue;
|
|
85
|
+
try {
|
|
86
|
+
const stat = fs.statSync(tpath);
|
|
87
|
+
map.set(cid, {
|
|
88
|
+
id: `antigravity:${cid}`,
|
|
89
|
+
sourcePlatform: this.platform,
|
|
90
|
+
sourceLabel: this.label,
|
|
91
|
+
title: `Session ${cid.slice(0, 8)}`,
|
|
92
|
+
workspacePath: '',
|
|
93
|
+
updatedAt: stat.mtimeMs,
|
|
94
|
+
messageCount: 1,
|
|
95
|
+
snippet: 'Antigravity conversation transcript'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Skip unreadable
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Skip unreadable
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return Array.from(map.values())
|
|
108
|
+
.sort((a, b) => b.updatedAt - a.updatedAt)
|
|
109
|
+
.slice(0, limit);
|
|
110
|
+
}
|
|
111
|
+
async getSession(id) {
|
|
112
|
+
const rawId = id.startsWith('antigravity:') ? id.slice('antigravity:'.length) : id;
|
|
113
|
+
if (!isSafeIdentifier(rawId)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
// Search for transcript in ide brain, cli brain, or legacy
|
|
117
|
+
const bases = [
|
|
118
|
+
this.ideBrainDir,
|
|
119
|
+
this.cliBrainDir,
|
|
120
|
+
path.join(this.home, '.gemini/antigravity/brain')
|
|
121
|
+
];
|
|
122
|
+
let tpath = null;
|
|
123
|
+
for (const base of bases) {
|
|
124
|
+
const candidate = path.join(base, rawId, '.system_generated/logs/transcript.jsonl');
|
|
125
|
+
if (path.resolve(candidate).startsWith(base) && fs.existsSync(candidate)) {
|
|
126
|
+
tpath = candidate;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (!tpath)
|
|
131
|
+
return null;
|
|
132
|
+
const messages = [];
|
|
133
|
+
let title = `Antigravity Session ${rawId.slice(0, 8)}`;
|
|
134
|
+
const workspace = '';
|
|
135
|
+
try {
|
|
136
|
+
const lines = readBoundedLines(tpath);
|
|
137
|
+
for (const line of lines) {
|
|
138
|
+
if (!line.trim())
|
|
139
|
+
continue;
|
|
140
|
+
try {
|
|
141
|
+
const data = JSON.parse(line);
|
|
142
|
+
const type = data.type;
|
|
143
|
+
const text = data.content || '';
|
|
144
|
+
if (type === 'USER_INPUT') {
|
|
145
|
+
const cleaned = cleanUserText(text);
|
|
146
|
+
if (cleaned) {
|
|
147
|
+
if (messages.length === 0) {
|
|
148
|
+
const firstLine = cleaned.split('\n')[0] || '';
|
|
149
|
+
if (firstLine.trim())
|
|
150
|
+
title = firstLine.trim().slice(0, 60);
|
|
151
|
+
}
|
|
152
|
+
messages.push({
|
|
153
|
+
role: 'user',
|
|
154
|
+
content: cleaned,
|
|
155
|
+
timestamp: data.created_at ? new Date(data.created_at).getTime() : Date.now()
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if (type === 'PLANNER_RESPONSE') {
|
|
160
|
+
const cleaned = cleanAssistantText(text);
|
|
161
|
+
if (cleaned) {
|
|
162
|
+
messages.push({
|
|
163
|
+
role: 'assistant',
|
|
164
|
+
content: cleaned,
|
|
165
|
+
timestamp: data.created_at ? new Date(data.created_at).getTime() : Date.now()
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// Skip torn JSON line
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
if (messages.length === 0)
|
|
179
|
+
return null;
|
|
180
|
+
const stat = fs.statSync(tpath);
|
|
181
|
+
return {
|
|
182
|
+
id: `antigravity:${rawId}`,
|
|
183
|
+
sourcePlatform: this.platform,
|
|
184
|
+
sourceLabel: this.label,
|
|
185
|
+
title,
|
|
186
|
+
workspacePath: workspace,
|
|
187
|
+
updatedAt: stat.mtimeMs,
|
|
188
|
+
messageCount: messages.length,
|
|
189
|
+
snippet: messages[0]?.content.slice(0, 100) || '',
|
|
190
|
+
messages
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|