@thirdfy/agent-cli 0.2.15 → 0.2.17

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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to `@thirdfy/agent-cli` are documented here. The format is b
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.2.17] - 2026-07-02
8
+
9
+ ### Changed
10
+
11
+ - Lighter onboarding writes (`complete_lighter_onboarding`, `setup_lighter_api_key`, `register_lighter_api_key`) use a 180s HTTP timeout by default (`THIRDFY_CLI_LONG_TIMEOUT_MS` or `THIRDFY_API_LONG_TIMEOUT_MS`) so managed `run` / `wallet execute` does not abort before the API finishes CCTP or Ethereum legs. Long-action timeout never falls below the configured base timeout. Pairs with Thirdfy API Ireland `sendTx` egress and `thirdfy-mcp` **v0.0.66+**.
12
+
13
+ ## [0.2.16] - 2026-06-30
14
+
15
+ ### Added
16
+
17
+ - `credits` command group: `balance`, `transactions` (with `includeMetadata`), `usage`, `models list`, `models estimate`, and `pricing quote`. Passes `toolCallsList` into pricing estimate for action-tier line items. Pairs with Thirdfy API **v3.8.2+** and `thirdfy-mcp` **v0.0.65+**.
18
+
7
19
  ## [0.2.15] - 2026-06-26
8
20
 
9
21
  ### Added
package/README.md CHANGED
@@ -40,9 +40,9 @@ Run without global install:
40
40
  npx @thirdfy/agent-cli --help
41
41
  ```
42
42
 
43
- ## What's new in v0.2.15
43
+ ## What's new in v0.2.17
44
44
 
45
- - `hummingbot` command group for governed Condor CEX executor ops: `status`, `connectors`, `executor-schema`, `executor-create`. Provider runbook at [`docs/providers/hummingbot.md`](./docs/providers/hummingbot.md). Pairs with Thirdfy API **v3.6.0+** and `thirdfy-mcp` **v0.0.64+**.
45
+ - Lighter onboarding writes (`complete_lighter_onboarding`, `setup_lighter_api_key`, `register_lighter_api_key`) use a 180s HTTP timeout by default so `run` and `wallet execute` do not abort before CCTP credit or Ethereum `changePubKey` completes. Override with `THIRDFY_CLI_LONG_TIMEOUT_MS`. Pairs with Thirdfy API **v3.9.4+** and `thirdfy-mcp` **v0.0.66+**.
46
46
 
47
47
  Older versions: see [CHANGELOG.md](./CHANGELOG.md) and [GitHub Releases](https://github.com/thirdfy/agent-cli/releases).
48
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirdfy/agent-cli",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "description": "Thirdfy Agent CLI for onboarding, governance preflight, execute-intent, and status polling.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli/help.mjs CHANGED
@@ -68,6 +68,11 @@ Core commands:
68
68
  thirdfy-agent prompt "<natural language prompt>" [--json]
69
69
  thirdfy-agent intent-status --intent-id <id> [--json]
70
70
  thirdfy-agent credits balance --auth-token <token> [--json]
71
+ thirdfy-agent credits transactions --auth-token <token> [--page <n>] [--limit <n>] [--include-metadata] [--json]
72
+ thirdfy-agent credits usage --auth-token <token> [--range 7d|30d|90d] [--json]
73
+ thirdfy-agent models list --auth-token <token> [--json]
74
+ thirdfy-agent models estimate --auth-token <token> --model <key> [--input-tokens <n>] [--output-tokens <n>] [--json]
75
+ thirdfy-agent pricing quote --auth-token <token> --action <action-key> [--chain-id <id>] [--json]
71
76
 
72
77
  Global flags:
73
78
  --api-base <url> default: https://api.thirdfy.com
@@ -161,6 +161,41 @@ export const CLI_MANIFEST = [
161
161
  options: ['auth'],
162
162
  description: 'Credits balance',
163
163
  },
164
+ {
165
+ path: ['credits', 'transactions'],
166
+ handler: 'commandCreditsTransactions',
167
+ tier: 'online',
168
+ options: ['auth', 'credits'],
169
+ description: 'Paginated credit transactions with optional billing metadata',
170
+ },
171
+ {
172
+ path: ['credits', 'usage'],
173
+ handler: 'commandCreditsUsage',
174
+ tier: 'online',
175
+ options: ['auth', 'credits'],
176
+ description: 'Credits usage summary by model, provider, and action',
177
+ },
178
+ {
179
+ path: ['models', 'list'],
180
+ handler: 'commandModelsList',
181
+ tier: 'online',
182
+ options: ['auth'],
183
+ description: 'List model pricing from chat_model_catalog',
184
+ },
185
+ {
186
+ path: ['models', 'estimate'],
187
+ handler: 'commandModelsEstimate',
188
+ tier: 'online',
189
+ options: ['auth', 'credits', 'execution'],
190
+ description: 'Estimate model and action credits before execution',
191
+ },
192
+ {
193
+ path: ['pricing', 'quote'],
194
+ handler: 'commandPricingQuote',
195
+ tier: 'online',
196
+ options: ['auth', 'execution'],
197
+ description: 'Quote action-tier credits for a catalog action',
198
+ },
164
199
  {
165
200
  path: ['data', 'summary'],
166
201
  handler: 'commandDataSummary',
@@ -0,0 +1,15 @@
1
+ export function attachCreditsOptions(cmd) {
2
+ return cmd
3
+ .option('--page <n>', 'page number for transactions', '1')
4
+ .option('--limit <n>', 'page size for transactions', '20')
5
+ .option('--include-metadata', 'include unified billing metadata on transactions')
6
+ .option('--range <range>', 'usage summary range (7d, 30d, 90d)', '7d')
7
+ .option('--model <key>', 'chat model key for pricing estimate')
8
+ .option('--input-tokens <n>', 'estimated input tokens for pricing estimate', '0')
9
+ .option('--output-tokens <n>', 'estimated output tokens for pricing estimate', '0')
10
+ .option(
11
+ '--tool-calls <value>',
12
+ 'tool call count or comma-separated AgentKit tool names for pricing estimate',
13
+ )
14
+ .option('--surface <surface>', 'billing surface (console, automation, cli, agent_api)', 'cli');
15
+ }
@@ -11,6 +11,7 @@ import { attachPolymarketOptions } from './polymarket.mjs';
11
11
  import { attachHummingbotOptions } from './hummingbot.mjs';
12
12
  import { attachAgentRegisterOptions } from './agent.mjs';
13
13
  import { attachChainOptions } from './chains.mjs';
14
+ import { attachCreditsOptions } from './credits.mjs';
14
15
 
15
16
  const BUNDLES = {
16
17
  auth: attachAuthOptions,
@@ -25,6 +26,7 @@ const BUNDLES = {
25
26
  hummingbot: attachHummingbotOptions,
26
27
  agent: attachAgentRegisterOptions,
27
28
  chains: attachChainOptions,
29
+ credits: attachCreditsOptions,
28
30
  };
29
31
 
30
32
  /** @param {import('commander').Command} cmd */
@@ -0,0 +1,142 @@
1
+ import { requireFlag } from '../core/args.mjs';
2
+ import { apiGet, apiPost } from '../core/http.mjs';
3
+
4
+ function resolveToolCallsEstimate(flags) {
5
+ const raw = flags.toolCalls ?? flags.toolCallsList;
6
+ if (raw == null || raw === '') {
7
+ return { toolCalls: 0, toolCallsList: undefined };
8
+ }
9
+
10
+ const value = String(raw).trim();
11
+ if (!value) {
12
+ return { toolCalls: 0, toolCallsList: undefined };
13
+ }
14
+
15
+ if (/^\d+$/.test(value)) {
16
+ return { toolCalls: Number(value), toolCallsList: undefined };
17
+ }
18
+
19
+ const toolCallsList = value
20
+ .split(',')
21
+ .map((entry) => entry.trim())
22
+ .filter(Boolean);
23
+
24
+ return {
25
+ toolCalls: toolCallsList.length,
26
+ toolCallsList,
27
+ };
28
+ }
29
+
30
+ export function createCreditsCommands({ printEnvelope, getAuthToken }) {
31
+ async function commandCreditsTransactions(ctx, flags) {
32
+ const authToken = getAuthToken(flags, 'Missing --auth-token (or THIRDFY_AUTH_TOKEN) for credits transactions');
33
+ const page = Number(flags.page || 1);
34
+ const limit = Number(flags.limit || 20);
35
+ const includeMetadata = flags.includeMetadata === true || flags.includeMetadata === 'true';
36
+ const response = await apiGet(
37
+ ctx,
38
+ `/api/v1/credits/transactions?page=${page}&limit=${limit}&includeMetadata=${includeMetadata}`,
39
+ { Authorization: `Bearer ${authToken}` },
40
+ );
41
+ printEnvelope({
42
+ success: true,
43
+ code: 'OK',
44
+ message: 'Credit transactions loaded',
45
+ data: response,
46
+ meta: { apiBase: ctx.apiBase, page, limit, includeMetadata },
47
+ });
48
+ }
49
+
50
+ async function commandCreditsUsage(ctx, flags) {
51
+ const authToken = getAuthToken(flags, 'Missing --auth-token (or THIRDFY_AUTH_TOKEN) for credits usage');
52
+ const range = String(flags.range || '7d');
53
+ const response = await apiGet(ctx, `/api/v1/credits/usage/summary?range=${encodeURIComponent(range)}`, {
54
+ Authorization: `Bearer ${authToken}`,
55
+ });
56
+ printEnvelope({
57
+ success: true,
58
+ code: 'OK',
59
+ message: 'Credits usage summary loaded',
60
+ data: response,
61
+ meta: { apiBase: ctx.apiBase, range },
62
+ });
63
+ }
64
+
65
+ async function commandModelsList(ctx, flags) {
66
+ const authToken = getAuthToken(flags, 'Missing --auth-token (or THIRDFY_AUTH_TOKEN) for models list');
67
+ const response = await apiGet(ctx, '/api/v1/credits/pricing/models', {
68
+ Authorization: `Bearer ${authToken}`,
69
+ });
70
+ const firstModel = response?.models?.[0];
71
+ const summary = firstModel?.estimatedUsdPerTurn != null
72
+ ? `${response?.models?.length ?? 0} models · e.g. ${firstModel.modelKey} ~$${Number(firstModel.estimatedUsdPerTurn).toFixed(2)}/turn`
73
+ : `${response?.models?.length ?? 0} models loaded`;
74
+ printEnvelope({
75
+ success: true,
76
+ code: 'OK',
77
+ message: flags.json ? 'Model pricing loaded' : `Model pricing loaded: ${summary}`,
78
+ data: response,
79
+ meta: { apiBase: ctx.apiBase, ...(flags.json ? {} : { summary }) },
80
+ });
81
+ }
82
+
83
+ async function commandModelsEstimate(ctx, flags) {
84
+ const authToken = getAuthToken(flags, 'Missing --auth-token (or THIRDFY_AUTH_TOKEN) for models estimate');
85
+ const modelKey = requireFlag(flags, 'model', 'Missing --model for models estimate');
86
+ const { toolCalls, toolCallsList } = resolveToolCallsEstimate(flags);
87
+ const response = await apiPost(
88
+ ctx,
89
+ '/api/v1/credits/pricing/estimate',
90
+ {
91
+ modelKey,
92
+ inputTokens: Number(flags.inputTokens || 0),
93
+ outputTokens: Number(flags.outputTokens || 0),
94
+ toolCalls,
95
+ toolCallsList,
96
+ chainId: Number(flags.chainId || 0) || undefined,
97
+ surface: flags.surface || 'cli',
98
+ },
99
+ { Authorization: `Bearer ${authToken}` },
100
+ );
101
+ const estimate = response?.estimate;
102
+ const summary = estimate?.chargedUsd != null
103
+ ? `~$${Number(estimate.chargedUsd).toFixed(2)} charged (${estimate.chargedCredits ?? estimate.totalCredits} credits)`
104
+ : `${estimate?.chargedCredits ?? estimate?.totalCredits ?? '?'} credits`;
105
+ printEnvelope({
106
+ success: true,
107
+ code: 'OK',
108
+ message: flags.json ? 'Model estimate generated' : `Model estimate for ${modelKey}: ${summary}`,
109
+ data: response,
110
+ meta: { apiBase: ctx.apiBase, modelKey, ...(flags.json ? {} : { summary }) },
111
+ });
112
+ }
113
+
114
+ async function commandPricingQuote(ctx, flags) {
115
+ const authToken = getAuthToken(flags, 'Missing --auth-token (or THIRDFY_AUTH_TOKEN) for pricing quote');
116
+ const action = requireFlag(flags, 'action', 'Missing --action for pricing quote');
117
+ const response = await apiPost(
118
+ ctx,
119
+ '/api/v1/credits/pricing/quote',
120
+ {
121
+ actionKey: action,
122
+ chainId: Number(flags.chainId || 8453),
123
+ },
124
+ { Authorization: `Bearer ${authToken}` },
125
+ );
126
+ printEnvelope({
127
+ success: true,
128
+ code: 'OK',
129
+ message: 'Action pricing quote generated',
130
+ data: response,
131
+ meta: { apiBase: ctx.apiBase, action },
132
+ });
133
+ }
134
+
135
+ return {
136
+ commandCreditsTransactions,
137
+ commandCreditsUsage,
138
+ commandModelsList,
139
+ commandModelsEstimate,
140
+ commandPricingQuote,
141
+ };
142
+ }
@@ -57,14 +57,19 @@ async function commandCreditsBalance(ctx, flags, capabilities) {
57
57
  const response = await apiGet(ctx, '/api/v1/credits/balance', {
58
58
  Authorization: `Bearer ${authToken}`,
59
59
  });
60
+ const summary =
61
+ typeof response?.availableUsd === 'number'
62
+ ? `$${response.availableUsd.toFixed(2)} available (${response.balance ?? 0} credits)`
63
+ : `${response?.balance ?? 0} credits`;
60
64
  printEnvelope({
61
65
  success: true,
62
66
  code: 'OK',
63
- message: 'Credits balance loaded',
67
+ message: flags.json ? 'Credits balance loaded' : `Credits balance loaded: ${summary}`,
64
68
  data: response,
65
69
  meta: {
66
70
  apiBase: ctx.apiBase,
67
71
  capabilitiesVersion: capabilities?.contractVersion || null,
72
+ ...(flags.json ? {} : { summary }),
68
73
  },
69
74
  });
70
75
  }
@@ -0,0 +1,29 @@
1
+ import { DEFAULT_TIMEOUT_MS } from './constants.mjs';
2
+
3
+ const LONG_RUNNING_ACTIONS = new Set([
4
+ 'complete_lighter_onboarding',
5
+ 'setup_lighter_api_key',
6
+ 'register_lighter_api_key',
7
+ ]);
8
+
9
+ function normalizeActionId(action) {
10
+ return String(action || '')
11
+ .trim()
12
+ .replace(/-/g, '_')
13
+ .toLowerCase();
14
+ }
15
+
16
+ /** Longer HTTP timeout for Lighter onboarding writes that poll CCTP credit or Ethereum changePubKey. */
17
+ export function resolveActionTimeoutMs(action, baseTimeoutMs = DEFAULT_TIMEOUT_MS) {
18
+ const base = Number.isFinite(baseTimeoutMs) && baseTimeoutMs > 0 ? baseTimeoutMs : DEFAULT_TIMEOUT_MS;
19
+ if (!LONG_RUNNING_ACTIONS.has(normalizeActionId(action))) return base;
20
+ const longMs = Number(
21
+ process.env.THIRDFY_CLI_LONG_TIMEOUT_MS || process.env.THIRDFY_API_LONG_TIMEOUT_MS || 180_000,
22
+ );
23
+ const resolvedLong = Number.isFinite(longMs) && longMs > 0 ? longMs : 180_000;
24
+ return Math.max(base, resolvedLong);
25
+ }
26
+
27
+ export function withActionTimeout(ctx, action) {
28
+ return { ...ctx, timeoutMs: resolveActionTimeoutMs(action, ctx.timeoutMs) };
29
+ }
@@ -10,6 +10,7 @@ import {
10
10
  parseBooleanFlag,
11
11
  } from '../../core/runMode.mjs';
12
12
  import { apiGet, apiPost } from '../../core/http.mjs';
13
+ import { withActionTimeout } from '../../core/actionTimeouts.mjs';
13
14
  import { createRequire } from 'module';
14
15
 
15
16
  const require = createRequire(import.meta.url);
@@ -269,6 +270,7 @@ async function runExecutionByMode(runMode, ctx, flags, resolved, options) {
269
270
 
270
271
  async function executeThirdfyRun(ctx, flags, resolved, options, runMode = 'thirdfy') {
271
272
  const skipPreflight = Boolean(options?.skipPreflight);
273
+ const actionCtx = withActionTimeout(ctx, resolved.resolvedAction);
272
274
  if (!skipPreflight) {
273
275
  const preflightPayload = buildIntentPayload(flags, {
274
276
  validationOnly: true,
@@ -278,7 +280,7 @@ async function executeThirdfyRun(ctx, flags, resolved, options, runMode = 'third
278
280
  mirrorOnly: false,
279
281
  hybridWalletMode: options?.hybridWalletMode,
280
282
  });
281
- const preflight = await apiPost(ctx, '/api/v1/agent/execute-intent', preflightPayload);
283
+ const preflight = await apiPost(actionCtx, '/api/v1/agent/execute-intent', preflightPayload);
282
284
  const preflightNormalized = normalizeIntentResponse(preflight);
283
285
  const blockedCount = preflightNormalized.blocked || 0;
284
286
  if (!preflightNormalized.success || blockedCount > 0) {
@@ -296,7 +298,7 @@ async function executeThirdfyRun(ctx, flags, resolved, options, runMode = 'third
296
298
  mirrorOnly: false,
297
299
  hybridWalletMode: options?.hybridWalletMode,
298
300
  });
299
- const response = await apiPost(ctx, '/api/v1/agent/execute-intent', payload);
301
+ const response = await apiPost(actionCtx, '/api/v1/agent/execute-intent', payload);
300
302
  const normalized = normalizeIntentResponse(response);
301
303
  normalized.idempotencyKey = payload.idempotencyKey;
302
304
  return normalized;
@@ -333,7 +335,8 @@ async function executeManagedWalletRun(ctx, flags, resolved, options) {
333
335
  runMode: 'agent_wallet',
334
336
  forceIdempotency: true,
335
337
  });
336
- const response = await apiPost(ctx, '/api/v1/agent/execute', payload);
338
+ const actionCtx = withActionTimeout(ctx, resolved.resolvedAction);
339
+ const response = await apiPost(actionCtx, '/api/v1/agent/execute', payload);
337
340
  if (shouldFallbackAgentWalletToExecuteIntent(resolved, response)) {
338
341
  const userDid = resolveEffectiveUserDid(flags);
339
342
  const chainId = Number(flags.chainId || 8453);
@@ -8,6 +8,7 @@ import { createWalletCommands } from '../commands/wallet.mjs';
8
8
  import { createDelegationCommands } from '../commands/delegation.mjs';
9
9
  import { createBootstrapCommands } from '../commands/bootstrap.mjs';
10
10
  import { createDiscoveryCommands } from '../commands/discovery.mjs';
11
+ import { createCreditsCommands } from '../commands/credits.mjs';
11
12
  import { createTelemetryCommands } from '../commands/telemetry.mjs';
12
13
  import { createCredentialsCommands } from '../commands/credentials.mjs';
13
14
  import { createAgentCommands } from '../commands/agent.mjs';
@@ -56,6 +57,11 @@ export function createRuntimeHandlers(deps) {
56
57
  resolveAgentApiKey,
57
58
  });
58
59
 
60
+ const __credits = createCreditsCommands({
61
+ printEnvelope,
62
+ getAuthToken,
63
+ });
64
+
59
65
  const __telemetry = createTelemetryCommands({
60
66
  printEnvelope,
61
67
  resolveAgentApiKey,
@@ -179,6 +185,11 @@ export function createRuntimeHandlers(deps) {
179
185
  commandCatalogsList: __discovery.commandCatalogsList,
180
186
  commandActions: __discovery.commandActions,
181
187
  commandCreditsBalance: __discovery.commandCreditsBalance,
188
+ commandCreditsTransactions: __credits.commandCreditsTransactions,
189
+ commandCreditsUsage: __credits.commandCreditsUsage,
190
+ commandModelsList: __credits.commandModelsList,
191
+ commandModelsEstimate: __credits.commandModelsEstimate,
192
+ commandPricingQuote: __credits.commandPricingQuote,
182
193
  commandDataSummary: __telemetry.commandDataSummary,
183
194
  commandTrackList: __telemetry.commandTrackList,
184
195
  commandTrackAction: __telemetry.commandTrackAction,