@thirdfy/agent-cli 0.2.16 → 0.2.18
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 +12 -0
- package/README.md +2 -2
- package/package.json +2 -1
- package/src/commands/credits.mjs +11 -4
- package/src/commands/discovery.mjs +4 -1
- package/src/core/actionTimeouts.mjs +29 -0
- package/src/lib/creditsUsdSummary.mjs +21 -0
- package/src/runtime/execution/runners.mjs +6 -3
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.18] - 2026-07-02
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- `credits balance`, `credits models list`, and `credits models estimate` human-readable summaries lead with USD when the API returns `availableUsd`, `estimatedUsdPerTurn`, or `chargedUsd` (Thirdfy API **v3.9.5+** USD credits Phase 1). JSON output unchanged. Pairs with `thirdfy-mcp` **v0.0.67+**.
|
|
12
|
+
|
|
13
|
+
## [0.2.17] - 2026-07-02
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- 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+**.
|
|
18
|
+
|
|
7
19
|
## [0.2.16] - 2026-06-30
|
|
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.
|
|
43
|
+
## What's new in v0.2.18
|
|
44
44
|
|
|
45
|
-
-
|
|
45
|
+
- Credits commands show USD-first summaries when the API returns Phase 1 display fields: balance (`availableUsd`), model list (`estimatedUsdPerTurn`), and estimates (`chargedUsd`). Use `--json` for the full API payload. Pairs with Thirdfy API **v3.9.5+** and `thirdfy-mcp` **v0.0.67+**.
|
|
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.
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"description": "Thirdfy Agent CLI for onboarding, governance preflight, execute-intent, and status polling.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"src/core/",
|
|
12
12
|
"src/commands/",
|
|
13
13
|
"src/cli/",
|
|
14
|
+
"src/lib/",
|
|
14
15
|
"src/runtime/",
|
|
15
16
|
"src/utils/cli/",
|
|
16
17
|
"src/contracts/cli/schemas/",
|
package/src/commands/credits.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { requireFlag } from '../core/args.mjs';
|
|
2
2
|
import { apiGet, apiPost } from '../core/http.mjs';
|
|
3
|
+
import {
|
|
4
|
+
formatCreditsEstimateSummary,
|
|
5
|
+
formatCreditsModelsSummary,
|
|
6
|
+
} from '../lib/creditsUsdSummary.mjs';
|
|
3
7
|
|
|
4
8
|
function resolveToolCallsEstimate(flags) {
|
|
5
9
|
const raw = flags.toolCalls ?? flags.toolCallsList;
|
|
@@ -67,12 +71,13 @@ export function createCreditsCommands({ printEnvelope, getAuthToken }) {
|
|
|
67
71
|
const response = await apiGet(ctx, '/api/v1/credits/pricing/models', {
|
|
68
72
|
Authorization: `Bearer ${authToken}`,
|
|
69
73
|
});
|
|
74
|
+
const summary = formatCreditsModelsSummary(response);
|
|
70
75
|
printEnvelope({
|
|
71
76
|
success: true,
|
|
72
77
|
code: 'OK',
|
|
73
|
-
message: 'Model pricing loaded'
|
|
78
|
+
message: flags.json ? 'Model pricing loaded' : `Model pricing loaded: ${summary}`,
|
|
74
79
|
data: response,
|
|
75
|
-
meta: { apiBase: ctx.apiBase },
|
|
80
|
+
meta: { apiBase: ctx.apiBase, ...(flags.json ? {} : { summary }) },
|
|
76
81
|
});
|
|
77
82
|
}
|
|
78
83
|
|
|
@@ -94,12 +99,14 @@ export function createCreditsCommands({ printEnvelope, getAuthToken }) {
|
|
|
94
99
|
},
|
|
95
100
|
{ Authorization: `Bearer ${authToken}` },
|
|
96
101
|
);
|
|
102
|
+
const estimate = response?.estimate;
|
|
103
|
+
const summary = formatCreditsEstimateSummary(estimate);
|
|
97
104
|
printEnvelope({
|
|
98
105
|
success: true,
|
|
99
106
|
code: 'OK',
|
|
100
|
-
message: 'Model estimate generated'
|
|
107
|
+
message: flags.json ? 'Model estimate generated' : `Model estimate for ${modelKey}: ${summary}`,
|
|
101
108
|
data: response,
|
|
102
|
-
meta: { apiBase: ctx.apiBase, modelKey },
|
|
109
|
+
meta: { apiBase: ctx.apiBase, modelKey, ...(flags.json ? {} : { summary }) },
|
|
103
110
|
});
|
|
104
111
|
}
|
|
105
112
|
|
|
@@ -2,6 +2,7 @@ import { requireFlag, parseJsonFlag } from '../core/args.mjs';
|
|
|
2
2
|
import { apiGet, apiPost } from '../core/http.mjs';
|
|
3
3
|
import { extractActions, getCachedActionsCatalog } from '../core/context.mjs';
|
|
4
4
|
import { getEffectiveRunMode } from '../core/runMode.mjs';
|
|
5
|
+
import { formatCreditsBalanceSummary } from '../lib/creditsUsdSummary.mjs';
|
|
5
6
|
export function createDiscoveryCommands({ printEnvelope, applyActionFilters, getTradingProviderHint, resolveChainSupport, getAuthToken, resolveAgentApiKey }) {
|
|
6
7
|
async function commandCatalogsList(ctx, flags, capabilities) {
|
|
7
8
|
const response = await apiGet(ctx, '/api/v1/agent/actions/catalog');
|
|
@@ -57,14 +58,16 @@ async function commandCreditsBalance(ctx, flags, capabilities) {
|
|
|
57
58
|
const response = await apiGet(ctx, '/api/v1/credits/balance', {
|
|
58
59
|
Authorization: `Bearer ${authToken}`,
|
|
59
60
|
});
|
|
61
|
+
const summary = formatCreditsBalanceSummary(response);
|
|
60
62
|
printEnvelope({
|
|
61
63
|
success: true,
|
|
62
64
|
code: 'OK',
|
|
63
|
-
message: 'Credits balance loaded'
|
|
65
|
+
message: flags.json ? 'Credits balance loaded' : `Credits balance loaded: ${summary}`,
|
|
64
66
|
data: response,
|
|
65
67
|
meta: {
|
|
66
68
|
apiBase: ctx.apiBase,
|
|
67
69
|
capabilitiesVersion: capabilities?.contractVersion || null,
|
|
70
|
+
...(flags.json ? {} : { summary }),
|
|
68
71
|
},
|
|
69
72
|
});
|
|
70
73
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function formatCreditsBalanceSummary(response) {
|
|
2
|
+
if (typeof response?.availableUsd === 'number') {
|
|
3
|
+
return `$${response.availableUsd.toFixed(2)} available (${response.balance ?? 0} credits)`;
|
|
4
|
+
}
|
|
5
|
+
return `${response?.balance ?? 0} credits`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function formatCreditsModelsSummary(response) {
|
|
9
|
+
const firstModel = response?.models?.[0];
|
|
10
|
+
if (firstModel?.estimatedUsdPerTurn != null) {
|
|
11
|
+
return `${response?.models?.length ?? 0} models · e.g. ${firstModel.modelKey} ~$${Number(firstModel.estimatedUsdPerTurn).toFixed(2)}/turn`;
|
|
12
|
+
}
|
|
13
|
+
return `${response?.models?.length ?? 0} models loaded`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function formatCreditsEstimateSummary(estimate) {
|
|
17
|
+
if (estimate?.chargedUsd != null) {
|
|
18
|
+
return `~$${Number(estimate.chargedUsd).toFixed(2)} charged (${estimate.chargedCredits ?? estimate.totalCredits} credits)`;
|
|
19
|
+
}
|
|
20
|
+
return `${estimate?.chargedCredits ?? estimate?.totalCredits ?? '?'} credits`;
|
|
21
|
+
}
|
|
@@ -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(
|
|
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(
|
|
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
|
|
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);
|