@thirdfy/agent-cli 0.2.16 → 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 +6 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/commands/credits.mjs +12 -4
- package/src/commands/discovery.mjs +6 -1
- package/src/core/actionTimeouts.mjs +29 -0
- package/src/runtime/execution/runners.mjs +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ 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
|
+
|
|
7
13
|
## [0.2.16] - 2026-06-30
|
|
8
14
|
|
|
9
15
|
### 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.17
|
|
44
44
|
|
|
45
|
-
- `
|
|
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
package/src/commands/credits.mjs
CHANGED
|
@@ -67,12 +67,16 @@ export function createCreditsCommands({ printEnvelope, getAuthToken }) {
|
|
|
67
67
|
const response = await apiGet(ctx, '/api/v1/credits/pricing/models', {
|
|
68
68
|
Authorization: `Bearer ${authToken}`,
|
|
69
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`;
|
|
70
74
|
printEnvelope({
|
|
71
75
|
success: true,
|
|
72
76
|
code: 'OK',
|
|
73
|
-
message: 'Model pricing loaded'
|
|
77
|
+
message: flags.json ? 'Model pricing loaded' : `Model pricing loaded: ${summary}`,
|
|
74
78
|
data: response,
|
|
75
|
-
meta: { apiBase: ctx.apiBase },
|
|
79
|
+
meta: { apiBase: ctx.apiBase, ...(flags.json ? {} : { summary }) },
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
|
|
@@ -94,12 +98,16 @@ export function createCreditsCommands({ printEnvelope, getAuthToken }) {
|
|
|
94
98
|
},
|
|
95
99
|
{ Authorization: `Bearer ${authToken}` },
|
|
96
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`;
|
|
97
105
|
printEnvelope({
|
|
98
106
|
success: true,
|
|
99
107
|
code: 'OK',
|
|
100
|
-
message: 'Model estimate generated'
|
|
108
|
+
message: flags.json ? 'Model estimate generated' : `Model estimate for ${modelKey}: ${summary}`,
|
|
101
109
|
data: response,
|
|
102
|
-
meta: { apiBase: ctx.apiBase, modelKey },
|
|
110
|
+
meta: { apiBase: ctx.apiBase, modelKey, ...(flags.json ? {} : { summary }) },
|
|
103
111
|
});
|
|
104
112
|
}
|
|
105
113
|
|
|
@@ -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(
|
|
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);
|