@causyne/agent 1.14.0 → 1.17.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.
@@ -144,6 +144,14 @@ export class TokenTracker {
144
144
  if (provider === 'ollama') {
145
145
  return [0.00, 0.00];
146
146
  }
147
+
148
+ // Peer agents (ACP) and Antigravity bill through the user's own CLI login —
149
+ // a subscription or a free quota Causyne never sees an invoice for. Showing
150
+ // a BYOK rate here would invent a cost the user does not owe, and the cost
151
+ // counter is read as a bill.
152
+ if (provider === 'acp' || provider.startsWith('acp/') || provider === 'antigravity' || provider === 'agy') {
153
+ return [0.00, 0.00];
154
+ }
147
155
 
148
156
  return [5.00, 15.00]; // Unknown BYOK provider fallback
149
157
  }
@@ -242,6 +250,9 @@ export class TokenTracker {
242
250
  if (p === 'pollinations' || p === 'local') {
243
251
  return 0.00; // Free Mode D / Mode A
244
252
  }
253
+ if (p === 'acp' || p.startsWith('acp/') || p === 'antigravity' || p === 'agy') {
254
+ return 0.00; // billed by the peer's own subscription, not by Causyne
255
+ }
245
256
  return 0.03; // Default generic media cost
246
257
  }
247
258
 
@@ -258,15 +269,16 @@ export class TokenTracker {
258
269
  this.taskTokens += equivalentTokens;
259
270
  this.taskCostUsd += cost;
260
271
 
261
-
262
-
272
+ // Read the cumulative total before writing today's file. getCumulativeUsage()
273
+ // backfills from the daily files when its own file is missing, so loading it
274
+ // after the daily increment counted this same call twice.
275
+ const cumulative = await this.getCumulativeUsage();
263
276
  const daily = await this.getDailyUsage();
264
277
  daily.totalTokens += equivalentTokens;
265
278
  daily.totalCalls += 1;
266
279
  daily.totalCostUsd = (daily.totalCostUsd || 0) + cost;
267
280
  await this.saveDailyUsage(daily);
268
281
 
269
- const cumulative = await this.getCumulativeUsage();
270
282
  cumulative.totalTokens += equivalentTokens;
271
283
  cumulative.totalCalls += 1;
272
284
  cumulative.totalCostUsd = (cumulative.totalCostUsd || 0) + cost;
@@ -500,13 +512,16 @@ export class TokenTracker {
500
512
  // pass firing concurrently with the loop silently subtracts its own tokens
501
513
  // from the day's total.
502
514
  const { daily, cumulative } = await withUsageLock(async () => {
515
+ // getCumulativeUsage() backfills from the daily files when its own file is
516
+ // missing, so it must be read before today's increment is written or the
517
+ // very first call of a fresh install is counted twice.
518
+ const cumulative = await this.getCumulativeUsage();
503
519
  const daily = await this.getDailyUsage();
504
520
  daily.totalTokens += total;
505
521
  daily.totalCalls += 1;
506
522
  daily.totalCostUsd = (daily.totalCostUsd || 0) + cost;
507
523
  await this.saveDailyUsage(daily);
508
524
 
509
- const cumulative = await this.getCumulativeUsage();
510
525
  cumulative.totalTokens += total;
511
526
  cumulative.totalCalls += 1;
512
527
  cumulative.totalCostUsd = (cumulative.totalCostUsd || 0) + cost;
@@ -7,9 +7,12 @@
7
7
  * Those come from the catalog presets or the user's `~/.causyne/peers.json`.
8
8
  */
9
9
  import path from 'node:path';
10
+ import { execFile } from 'node:child_process';
11
+ import { promisify } from 'node:util';
10
12
  import { AcpClient } from '../acp/client.js';
11
13
  import { getPeerProfile, listAllPeers, peerEnvironment } from '../acp/peerProfiles.js';
12
14
  import { BUILTIN_PEER_PRESETS } from '../acp/agentCatalog.js';
15
+ const execFileAsync = promisify(execFile);
13
16
  const MAX_PROMPT_CHARS = 100_000;
14
17
  const READ_ONLY_KINDS = new Set(['read', 'search', 'fetch', 'think']);
15
18
  function selectPermission(profile, request, workspaceRoot) {
@@ -123,6 +126,38 @@ export const peerAgentTool = {
123
126
  : profile.timeoutSeconds;
124
127
  const timeoutSeconds = Math.max(5, Math.min(Math.min(profile.timeoutSeconds, requestedTimeout), 1800));
125
128
  const workspaceRoot = profile.cwd || process.cwd();
129
+ if (peerId.toLowerCase() === 'antigravity') {
130
+ try {
131
+ const agyModel = args.model || 'Gemini 3.8 Flash (Low)';
132
+ const { stdout } = await execFileAsync(profile.command, [
133
+ '--output-format',
134
+ 'json',
135
+ `--model=${agyModel}`,
136
+ `-p=${prompt}`
137
+ ], {
138
+ cwd: workspaceRoot,
139
+ timeout: timeoutSeconds * 1000
140
+ });
141
+ let outputText = stdout.trim();
142
+ try {
143
+ const parsed = JSON.parse(outputText);
144
+ if (parsed.response)
145
+ outputText = parsed.response.trim();
146
+ }
147
+ catch {
148
+ // keep raw stdout
149
+ }
150
+ return {
151
+ success: true,
152
+ agent: 'Google Antigravity',
153
+ output: outputText
154
+ };
155
+ }
156
+ catch (err) {
157
+ const msg = err instanceof Error ? err.message : String(err);
158
+ return { success: false, agent: 'Google Antigravity', error: msg };
159
+ }
160
+ }
126
161
  const client = new AcpClient({
127
162
  command: profile.command,
128
163
  args: profile.args,
@@ -8,12 +8,16 @@
8
8
  */
9
9
 
10
10
  import path from 'node:path';
11
+ import { execFile } from 'node:child_process';
12
+ import { promisify } from 'node:util';
11
13
  import { AcpClient } from '../acp/client.js';
12
14
  import type { RequestPermissionRequest, RequestPermissionResponse } from '../acp/protocol.js';
13
15
  import { getPeerProfile, listAllPeers, peerEnvironment } from '../acp/peerProfiles.js';
14
16
  import type { PeerProfile } from '../acp/peerProfiles.js';
15
17
  import { BUILTIN_PEER_PRESETS } from '../acp/agentCatalog.js';
16
18
 
19
+ const execFileAsync = promisify(execFile);
20
+
17
21
  export interface PeerAgentArgs {
18
22
  action?: 'delegate' | 'list' | 'status';
19
23
  peer?: string;
@@ -162,6 +166,36 @@ export const peerAgentTool = {
162
166
 
163
167
  const workspaceRoot = profile.cwd || process.cwd();
164
168
 
169
+ if (peerId.toLowerCase() === 'antigravity') {
170
+ try {
171
+ const agyModel = args.model || 'Gemini 3.8 Flash (Low)';
172
+ const { stdout } = await execFileAsync(profile.command, [
173
+ '--output-format',
174
+ 'json',
175
+ `--model=${agyModel}`,
176
+ `-p=${prompt}`
177
+ ], {
178
+ cwd: workspaceRoot,
179
+ timeout: timeoutSeconds * 1000
180
+ });
181
+ let outputText = stdout.trim();
182
+ try {
183
+ const parsed = JSON.parse(outputText);
184
+ if (parsed.response) outputText = parsed.response.trim();
185
+ } catch {
186
+ // keep raw stdout
187
+ }
188
+ return {
189
+ success: true,
190
+ agent: 'Google Antigravity',
191
+ output: outputText
192
+ };
193
+ } catch (err: unknown) {
194
+ const msg = err instanceof Error ? err.message : String(err);
195
+ return { success: false, agent: 'Google Antigravity', error: msg };
196
+ }
197
+ }
198
+
165
199
  const client = new AcpClient({
166
200
  command: profile.command,
167
201
  args: profile.args,
package/src/tui/banner.js CHANGED
@@ -315,7 +315,13 @@ export function providerLabel(provider) {
315
315
  openai: 'OpenAI', anthropic: 'Anthropic', gemini: 'Gemini', ollama: 'Ollama',
316
316
  deepseek: 'DeepSeek', dashscope: 'DashScope', 'dashscope-byok': 'DashScope',
317
317
  qwen: 'Qwen', xai: 'xAI', grok: 'xAI', moonshot: 'Moonshot', kimi: 'Moonshot',
318
- muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible'
318
+ muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible',
319
+ acp: 'ACP', antigravity: 'Antigravity', agy: 'Antigravity',
320
+ 'acp/opencode': 'OpenCode (ACP)', 'acp/claude': 'Claude Code (ACP)',
321
+ 'acp/codex': 'Codex (ACP)', 'acp/gemini': 'Gemini CLI (ACP)',
322
+ 'acp/cursor': 'Cursor (ACP)', 'acp/qwen': 'Qwen Code (ACP)',
323
+ 'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
324
+ 'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
319
325
  };
320
326
  return known[raw.toLowerCase()] ?? raw;
321
327
  }
package/src/tui/banner.ts CHANGED
@@ -313,7 +313,13 @@ export function providerLabel(provider: unknown): string {
313
313
  openai: 'OpenAI', anthropic: 'Anthropic', gemini: 'Gemini', ollama: 'Ollama',
314
314
  deepseek: 'DeepSeek', dashscope: 'DashScope', 'dashscope-byok': 'DashScope',
315
315
  qwen: 'Qwen', xai: 'xAI', grok: 'xAI', moonshot: 'Moonshot', kimi: 'Moonshot',
316
- muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible'
316
+ muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible',
317
+ acp: 'ACP', antigravity: 'Antigravity', agy: 'Antigravity',
318
+ 'acp/opencode': 'OpenCode (ACP)', 'acp/claude': 'Claude Code (ACP)',
319
+ 'acp/codex': 'Codex (ACP)', 'acp/gemini': 'Gemini CLI (ACP)',
320
+ 'acp/cursor': 'Cursor (ACP)', 'acp/qwen': 'Qwen Code (ACP)',
321
+ 'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
322
+ 'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
317
323
  };
318
324
  return known[raw.toLowerCase()] ?? raw;
319
325
  }
package/src/tui/home.js CHANGED
@@ -4,14 +4,17 @@ import { SelectLayer, InputLayer } from './dialogs.js';
4
4
  import { paint, dim, bold, badge, GLYPHS } from './theme.js';
5
5
  import { runSetup } from './setup.js';
6
6
  import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
7
+ import { isAcpProvider } from '../providers/acp.js';
8
+ import { isAntigravityProvider } from '../providers/antigravity.js';
7
9
 
8
10
  /** Local runtime and provider summary. */
9
- export function homeStatusLine({ config = {} } = {}) {
11
+ export function homeStatusLine(arg = {}) {
12
+ const config = arg?.config || arg || {};
10
13
  const hasProvider = Boolean(config.provider && config.provider !== 'unconfigured');
11
14
  const model = hasProvider
12
15
  ? (config.model ? `${config.provider}/${config.model}` : config.provider)
13
16
  : 'no provider configured';
14
- const configured = Boolean((hasProvider && config.apiKey) || config.provider === 'ollama');
17
+ const configured = Boolean((hasProvider && config.apiKey) || config.provider === 'ollama' || isAcpProvider(config.provider) || isAntigravityProvider(config.provider));
15
18
  return ' ' + [
16
19
  paint('success', `${GLYPHS.bullet} local desktop`),
17
20
  configured
@@ -142,7 +145,19 @@ export const PROVIDERS = [
142
145
  { id: 'moonshot', label: 'Moonshot', hint: 'Kimi' },
143
146
  { id: 'xai', label: 'xAI', hint: 'Grok' },
144
147
  { id: 'openai-compatible', label: 'OpenAI-compatible endpoint', hint: 'custom base URL' },
145
- { id: 'ollama', label: 'Ollama', hint: 'local / offline' }
148
+ { id: 'ollama', label: 'Ollama', hint: 'local / offline' },
149
+ { id: 'antigravity', label: 'Google Antigravity (AGY)', hint: 'local AGY · Gemini & Claude models' },
150
+ { id: 'acp/opencode', label: 'OpenCode', hint: 'ACP · free models available' },
151
+ { id: 'acp/claude', label: 'Claude Code', hint: 'ACP · your Anthropic subscription' },
152
+ { id: 'acp/codex', label: 'Codex CLI', hint: 'ACP · your OpenAI login' },
153
+ { id: 'acp/gemini', label: 'Gemini CLI', hint: 'ACP · free tier / Google login' },
154
+ { id: 'acp/cursor', label: 'Cursor CLI', hint: 'ACP · your Cursor subscription' },
155
+ { id: 'acp/qwen', label: 'Qwen Code', hint: 'ACP · DashScope login' },
156
+ { id: 'acp/copilot', label: 'GitHub Copilot CLI', hint: 'ACP · your Copilot subscription' },
157
+ { id: 'acp/kimi', label: 'Kimi CLI', hint: 'ACP · Moonshot login' },
158
+ { id: 'acp/goose', label: 'Goose', hint: 'ACP · your configured providers' },
159
+ { id: 'acp/hermes', label: 'Hermes Agent', hint: 'ACP · Nous Research' },
160
+ { id: 'acp', label: 'ACP peer agent (custom)', hint: 'any ACP-compatible CLI' }
146
161
  ].map((entry) => ({ ...entry, model: DEFAULT_MODEL_BY_PROVIDER[entry.id] ?? '' }));
147
162
 
148
163
  /** Run the shared setup transaction inside the existing prompt. */
package/src/tui/setup.js CHANGED
@@ -1,5 +1,12 @@
1
+ /** Shared setup transaction for the home panel and standalone CLI. */
2
+ import { resolveAvailableModels } from '../dynamicCatalogue.js';
1
3
  const string = (value) => typeof value === 'string' ? value : '';
2
4
  const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
5
+ /** Peers and Antigravity authenticate through their own CLI, not a stored key. */
6
+ function isLocalAgent(providerId) {
7
+ return providerId === 'acp' || providerId.startsWith('acp/')
8
+ || providerId === 'antigravity' || providerId === 'agy';
9
+ }
3
10
  const defaults = {
4
11
  ollama: 'http://localhost:11434/api/chat',
5
12
  'dashscope-byok': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions'
@@ -52,14 +59,39 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
52
59
  return null;
53
60
  baseUrl = answer;
54
61
  }
55
- const model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'], (sameProvider ? string(draft.model) : '') || provider.model, false, value => value ? null : 'A model ID is required.');
62
+ const suggestedModel = (sameProvider ? string(draft.model) : '') || provider.model;
63
+ let model;
64
+ if (isLocalAgent(provider.id)) {
65
+ // The peer already knows which models its account can reach. Listing them
66
+ // is the whole point of treating it as a provider; a blank text box would
67
+ // make the user guess ids the CLI could have told us for free.
68
+ const known = (await resolveAvailableModels(provider.id, {}, false)).models;
69
+ if (known.length === 0) {
70
+ model = await text('Setup 3/5 · model', ['Enter a model ID published by the installed CLI.',
71
+ 'Leave the default to let the peer choose its own model.'], suggestedModel, false, value => value ? null : 'A model ID is required.');
72
+ }
73
+ else {
74
+ const picked = await ui.select({ title: 'Setup 3/5 · model', items: [
75
+ ...known.map((id) => ({ id, label: id, description: provider.label })),
76
+ { id: '__custom__', label: 'Other model ID…', description: 'enter one manually' }
77
+ ] });
78
+ if (!picked)
79
+ return null;
80
+ model = picked.id === '__custom__'
81
+ ? await text('Setup 3/5 · model', ['Enter the model ID published by the installed CLI.'], suggestedModel, false, value => value ? null : 'A model ID is required.')
82
+ : picked.id;
83
+ }
84
+ }
85
+ else {
86
+ model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'], suggestedModel, false, value => value ? null : 'A model ID is required.');
87
+ }
56
88
  if (model === null)
57
89
  return null;
58
90
  const unchangedEndpoint = sameProvider && (string(draft.baseUrl) || defaults[provider.id] || '') === baseUrl;
59
91
  // Fixed endpoints have no editable URL. A changed endpoint never inherits a key.
60
92
  const keepKey = sameProvider && (!customProviders.has(provider.id) || unchangedEndpoint);
61
93
  let apiKey = '';
62
- if (provider.id !== 'ollama') {
94
+ if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
63
95
  const oldKey = keepKey ? string(draft.apiKey) : '';
64
96
  const answer = await text('Setup 3/5 · credentials', ['Stored encrypted locally; used to authenticate with your selected provider.',
65
97
  oldKey ? 'Blank keeps the key for this same provider and endpoint.' : 'Enter a key for this provider.',
package/src/tui/setup.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  /** Shared setup transaction for the home panel and standalone CLI. */
2
+ import { resolveAvailableModels } from '../dynamicCatalogue.js';
3
+
2
4
  export interface SetupChoice { id: string; label: string; description?: string }
3
5
  export interface SetupProvider { id: string; label: string; hint: string; model: string }
4
6
  export interface SetupUI {
@@ -8,6 +10,12 @@ export interface SetupUI {
8
10
  type Config = Record<string, unknown>;
9
11
  const string = (value: unknown): string => typeof value === 'string' ? value : '';
10
12
  const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
13
+
14
+ /** Peers and Antigravity authenticate through their own CLI, not a stored key. */
15
+ function isLocalAgent(providerId: string): boolean {
16
+ return providerId === 'acp' || providerId.startsWith('acp/')
17
+ || providerId === 'antigravity' || providerId === 'agy';
18
+ }
11
19
  const defaults: Record<string, string> = {
12
20
  ollama: 'http://localhost:11434/api/chat',
13
21
  'dashscope-byok': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions'
@@ -56,14 +64,39 @@ export async function runSetup(ui: SetupUI, providers: SetupProvider[], store: {
56
64
  if (answer === null) return null;
57
65
  baseUrl = answer;
58
66
  }
59
- const model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'],
60
- (sameProvider ? string(draft.model) : '') || provider.model, false, value => value ? null : 'A model ID is required.');
67
+ const suggestedModel = (sameProvider ? string(draft.model) : '') || provider.model;
68
+ let model: string | null;
69
+ if (isLocalAgent(provider.id)) {
70
+ // The peer already knows which models its account can reach. Listing them
71
+ // is the whole point of treating it as a provider; a blank text box would
72
+ // make the user guess ids the CLI could have told us for free.
73
+ const known = (await resolveAvailableModels(provider.id, {}, false)).models;
74
+ if (known.length === 0) {
75
+ model = await text('Setup 3/5 · model',
76
+ ['Enter a model ID published by the installed CLI.',
77
+ 'Leave the default to let the peer choose its own model.'],
78
+ suggestedModel, false, value => value ? null : 'A model ID is required.');
79
+ } else {
80
+ const picked = await ui.select({ title: 'Setup 3/5 · model', items: [
81
+ ...known.map((id) => ({ id, label: id, description: provider.label })),
82
+ { id: '__custom__', label: 'Other model ID…', description: 'enter one manually' }
83
+ ] });
84
+ if (!picked) return null;
85
+ model = picked.id === '__custom__'
86
+ ? await text('Setup 3/5 · model', ['Enter the model ID published by the installed CLI.'], suggestedModel, false,
87
+ value => value ? null : 'A model ID is required.')
88
+ : picked.id;
89
+ }
90
+ } else {
91
+ model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'],
92
+ suggestedModel, false, value => value ? null : 'A model ID is required.');
93
+ }
61
94
  if (model === null) return null;
62
95
  const unchangedEndpoint = sameProvider && (string(draft.baseUrl) || defaults[provider.id] || '') === baseUrl;
63
96
  // Fixed endpoints have no editable URL. A changed endpoint never inherits a key.
64
97
  const keepKey = sameProvider && (!customProviders.has(provider.id) || unchangedEndpoint);
65
98
  let apiKey = '';
66
- if (provider.id !== 'ollama') {
99
+ if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
67
100
  const oldKey = keepKey ? string(draft.apiKey) : '';
68
101
  const answer = await text('Setup 3/5 · credentials', ['Stored encrypted locally; used to authenticate with your selected provider.',
69
102
  oldKey ? 'Blank keeps the key for this same provider and endpoint.' : 'Enter a key for this provider.',