@thirdfy/agent-cli 0.4.0 → 0.4.2
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 +35 -0
- package/README.md +5 -8
- package/package.json +3 -3
- package/scripts/validate-cli-contract-schemas.mjs +1 -0
- package/src/cli/help.mjs +1 -1
- package/src/cli/manifest.mjs +8 -1
- package/src/cli/options/index.mjs +11 -11
- package/src/cli/program.mjs +1 -1
- package/src/commands/{agent.mjs → account/agent.mjs} +5 -5
- package/src/commands/{credits.mjs → account/credits.mjs} +73 -17
- package/src/commands/{wallet.mjs → account/wallet.mjs} +136 -21
- package/src/commands/{walletControl.mjs → account/walletControl.mjs} +3 -3
- package/src/commands/discovery.mjs +9 -9
- package/src/commands/execute.mjs +2 -2
- package/src/commands/index.mjs +9 -9
- package/src/commands/{bootstrap.mjs → onboarding/bootstrap.mjs} +8 -8
- package/src/commands/{consoleMandate.mjs → onboarding/consoleMandate.mjs} +2 -2
- package/src/commands/{credentials.mjs → onboarding/credentials.mjs} +6 -6
- package/src/commands/{delegation.mjs → onboarding/delegation.mjs} +5 -5
- package/src/commands/{avantis.mjs → venues/avantis.mjs} +1 -1
- package/src/commands/{condor.mjs → venues/condor.mjs} +4 -4
- package/src/commands/{hummingbot.mjs → venues/hummingbot.mjs} +4 -4
- package/src/commands/{hyperliquid.mjs → venues/hyperliquid.mjs} +1 -1
- package/src/commands/{lighter.mjs → venues/lighter.mjs} +1 -1
- package/src/commands/{polymarket.mjs → venues/polymarket.mjs} +4 -4
- package/src/commands/{venue.mjs → venues/venue.mjs} +3 -3
- package/src/contracts/cli/schemas/wallet-profile.response.schema.json +127 -0
- package/src/core/context.mjs +20 -0
- package/src/core/earnclawAttribution.mjs +1 -1
- package/src/core/{actionTimeouts.mjs → execution/actionTimeouts.mjs} +2 -2
- package/src/core/{walletExecuteChainId.mjs → execution/walletExecuteChainId.mjs} +1 -1
- package/src/core/http.mjs +1 -1
- package/src/runtime/execution/hostedRuntimeWriteGate.mjs +1 -1
- package/src/runtime/execution/payloads.mjs +4 -4
- package/src/runtime/execution/runners/agentWalletLane.mjs +109 -0
- package/src/runtime/execution/runners/createExecutionRunners.mjs +315 -0
- package/src/runtime/execution/runners/fallbackHints.mjs +54 -0
- package/src/runtime/execution/runners/hybridLane.mjs +88 -0
- package/src/runtime/execution/runners/managedPreflight.mjs +253 -0
- package/src/runtime/execution/runners/managedResponse.mjs +119 -0
- package/src/runtime/execution/runners/selfLane.mjs +232 -0
- package/src/runtime/execution/runners/thirdfyLane.mjs +97 -0
- package/src/runtime/execution/svmLane.mjs +1 -1
- package/src/runtime/handlers.mjs +17 -16
- package/src/runtime/main.mjs +1 -1
- package/src/runtime/risk/notional.mjs +1 -1
- package/src/runtime/validation/actionParamsGate.mjs +1 -1
- package/src/runtime/execution/runners.mjs +0 -1134
- /package/src/cli/options/{agent.mjs → account/agent.mjs} +0 -0
- /package/src/cli/options/{credits.mjs → account/credits.mjs} +0 -0
- /package/src/cli/options/{wallet.mjs → account/wallet.mjs} +0 -0
- /package/src/cli/options/{walletControl.mjs → account/walletControl.mjs} +0 -0
- /package/src/cli/options/{bootstrap.mjs → onboarding/bootstrap.mjs} +0 -0
- /package/src/cli/options/{credentials.mjs → onboarding/credentials.mjs} +0 -0
- /package/src/cli/options/{delegation.mjs → onboarding/delegation.mjs} +0 -0
- /package/src/cli/options/{condor.mjs → venues/condor.mjs} +0 -0
- /package/src/cli/options/{hummingbot.mjs → venues/hummingbot.mjs} +0 -0
- /package/src/cli/options/{polymarket.mjs → venues/polymarket.mjs} +0 -0
- /package/src/cli/options/{venue.mjs → venues/venue.mjs} +0 -0
- /package/src/core/{executionContext.mjs → execution/executionContext.mjs} +0 -0
- /package/src/core/{fundingTokenIn.mjs → execution/fundingTokenIn.mjs} +0 -0
- /package/src/core/{hostedRuntimeIdempotency.mjs → execution/hostedRuntimeIdempotency.mjs} +0 -0
- /package/src/core/{readOnlyActions.mjs → execution/readOnlyActions.mjs} +0 -0
- /package/src/core/{signedTx.mjs → execution/signedTx.mjs} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { apiPost, responseHeadersFor } from '../../../core/http.mjs';
|
|
2
|
+
import { idempotentReplayFields } from '../../../core/execution/hostedRuntimeIdempotency.mjs';
|
|
3
|
+
import { withActionTimeout } from '../../../core/execution/actionTimeouts.mjs';
|
|
4
|
+
import { actionNameForApi } from '../../actions/selection.mjs';
|
|
5
|
+
import { isReadOnlyAction } from './managedResponse.mjs';
|
|
6
|
+
import { createRequire } from 'module';
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const { normalizeIntentResponse } = require('../../../utils/cli/intentNormalization.cjs');
|
|
10
|
+
|
|
11
|
+
/** The thirdfy lane (execute intent), also the rail read-only actions use from the other lanes. */
|
|
12
|
+
export function createThirdfyLane(deps) {
|
|
13
|
+
const {
|
|
14
|
+
buildIntentPayload,
|
|
15
|
+
resolveEffectiveUserDid,
|
|
16
|
+
} = deps;
|
|
17
|
+
|
|
18
|
+
async function executeThirdfyRun(ctx, flags, resolved, options, runMode = 'thirdfy') {
|
|
19
|
+
const skipPreflight = Boolean(options?.skipPreflight);
|
|
20
|
+
const actionCtx = withActionTimeout(ctx, resolved);
|
|
21
|
+
if (!skipPreflight) {
|
|
22
|
+
const preflightPayload = buildIntentPayload(flags, {
|
|
23
|
+
validationOnly: true,
|
|
24
|
+
forceIdempotency: false,
|
|
25
|
+
resolvedAction: resolved.resolvedAction,
|
|
26
|
+
apiAction: actionNameForApi(resolved),
|
|
27
|
+
runMode,
|
|
28
|
+
mirrorOnly: false,
|
|
29
|
+
hybridWalletMode: options?.hybridWalletMode,
|
|
30
|
+
});
|
|
31
|
+
// validationOnly never writes, so a timed-out preflight is safe to resend.
|
|
32
|
+
const preflight = await apiPost(
|
|
33
|
+
{ ...actionCtx, writeAction: false },
|
|
34
|
+
'/api/v1/agent/execute-intent',
|
|
35
|
+
preflightPayload,
|
|
36
|
+
);
|
|
37
|
+
const preflightNormalized = normalizeIntentResponse(preflight);
|
|
38
|
+
const blockedCount = preflightNormalized.blocked || 0;
|
|
39
|
+
if (!preflightNormalized.success || blockedCount > 0) {
|
|
40
|
+
preflightNormalized.success = false;
|
|
41
|
+
preflightNormalized.error = preflightNormalized.error || 'Preflight blocked execution';
|
|
42
|
+
preflightNormalized.preflightBlocked = true;
|
|
43
|
+
return preflightNormalized;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const payload = buildIntentPayload(flags, {
|
|
47
|
+
validationOnly: false,
|
|
48
|
+
forceIdempotency: true,
|
|
49
|
+
resolvedAction: resolved.resolvedAction,
|
|
50
|
+
apiAction: actionNameForApi(resolved),
|
|
51
|
+
runMode,
|
|
52
|
+
mirrorOnly: false,
|
|
53
|
+
hybridWalletMode: options?.hybridWalletMode,
|
|
54
|
+
});
|
|
55
|
+
const response = await apiPost(actionCtx, '/api/v1/agent/execute-intent', payload);
|
|
56
|
+
const normalized = normalizeIntentResponse(response);
|
|
57
|
+
normalized.idempotencyKey = payload.idempotencyKey;
|
|
58
|
+
if (!isReadOnlyAction(resolved)) {
|
|
59
|
+
Object.assign(normalized, idempotentReplayFields(response, responseHeadersFor(response), 'idempotencyKey'));
|
|
60
|
+
}
|
|
61
|
+
return normalized;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function runReadOnlyActionViaIntentRail(ctx, flags, resolved, options, preflight, reportedMode = 'agent_wallet') {
|
|
65
|
+
const userDid = resolveEffectiveUserDid(flags, {
|
|
66
|
+
runMode: 'agent_wallet',
|
|
67
|
+
hybridWalletMode: options?.hybridWalletMode,
|
|
68
|
+
preferDelegationIdentity: options?.preferDelegationIdentity,
|
|
69
|
+
});
|
|
70
|
+
const intentResult = await executeThirdfyRun(
|
|
71
|
+
ctx,
|
|
72
|
+
{
|
|
73
|
+
...flags,
|
|
74
|
+
chainId: Number(flags.chainId || 8453),
|
|
75
|
+
runMode: 'thirdfy',
|
|
76
|
+
userDid: userDid || flags.userDid,
|
|
77
|
+
executionScope: flags.executionScope || 'solo_owner_mirror',
|
|
78
|
+
},
|
|
79
|
+
resolved,
|
|
80
|
+
{ ...options, skipPreflight: true },
|
|
81
|
+
'thirdfy'
|
|
82
|
+
);
|
|
83
|
+
intentResult.mode = reportedMode;
|
|
84
|
+
intentResult.routeFallback = 'execute_intent_read_only';
|
|
85
|
+
if (preflight) {
|
|
86
|
+
intentResult.executionWalletPreflight = preflight;
|
|
87
|
+
intentResult.executionWalletAddress = preflight.executionWalletAddress || intentResult.executionWalletAddress || null;
|
|
88
|
+
}
|
|
89
|
+
intentResult.signerMethod = 'managed_wallet_server';
|
|
90
|
+
return intentResult;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
executeThirdfyRun,
|
|
95
|
+
runReadOnlyActionViaIntentRail,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -4,7 +4,7 @@ import { chainRegistrySource, configuredSvmChainIds, getChainInfo, isSvmChainId,
|
|
|
4
4
|
import {
|
|
5
5
|
inferChainIdFromCatalogRow,
|
|
6
6
|
resolveWalletExecuteChainId,
|
|
7
|
-
} from '../../core/walletExecuteChainId.mjs';
|
|
7
|
+
} from '../../core/execution/walletExecuteChainId.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Solana (svm) lane rules. Solana actions run only with run mode `agent_wallet` on the managed
|
package/src/runtime/handlers.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { negotiateCapabilities } from '../core/http.mjs';
|
|
2
|
-
import { createPolymarketCommands } from '../commands/polymarket.mjs';
|
|
3
|
-
import { createHummingbotCommands } from '../commands/hummingbot.mjs';
|
|
4
|
-
import { createCondorCommands } from '../commands/condor.mjs';
|
|
5
|
-
import { createHyperliquidHelpers } from '../commands/hyperliquid.mjs';
|
|
6
|
-
import { createLighterHelpers } from '../commands/lighter.mjs';
|
|
7
|
-
import { createAvantisHelpers } from '../commands/avantis.mjs';
|
|
2
|
+
import { createPolymarketCommands } from '../commands/venues/polymarket.mjs';
|
|
3
|
+
import { createHummingbotCommands } from '../commands/venues/hummingbot.mjs';
|
|
4
|
+
import { createCondorCommands } from '../commands/venues/condor.mjs';
|
|
5
|
+
import { createHyperliquidHelpers } from '../commands/venues/hyperliquid.mjs';
|
|
6
|
+
import { createLighterHelpers } from '../commands/venues/lighter.mjs';
|
|
7
|
+
import { createAvantisHelpers } from '../commands/venues/avantis.mjs';
|
|
8
8
|
import { createExecuteCommands } from '../commands/execute.mjs';
|
|
9
|
-
import { createWalletCommands } from '../commands/wallet.mjs';
|
|
10
|
-
import { createDelegationCommands } from '../commands/delegation.mjs';
|
|
11
|
-
import { createConsoleMandateCommands } from '../commands/consoleMandate.mjs';
|
|
12
|
-
import { createBootstrapCommands } from '../commands/bootstrap.mjs';
|
|
9
|
+
import { createWalletCommands } from '../commands/account/wallet.mjs';
|
|
10
|
+
import { createDelegationCommands } from '../commands/onboarding/delegation.mjs';
|
|
11
|
+
import { createConsoleMandateCommands } from '../commands/onboarding/consoleMandate.mjs';
|
|
12
|
+
import { createBootstrapCommands } from '../commands/onboarding/bootstrap.mjs';
|
|
13
13
|
import { createDiscoveryCommands } from '../commands/discovery.mjs';
|
|
14
14
|
import { createSignalsCommands } from '../commands/signals/command.mjs';
|
|
15
|
-
import { createCreditsCommands } from '../commands/credits.mjs';
|
|
15
|
+
import { createCreditsCommands } from '../commands/account/credits.mjs';
|
|
16
16
|
import { createChatCommands } from '../commands/chat.mjs';
|
|
17
17
|
import { createBrainCommands } from '../commands/brain.mjs';
|
|
18
18
|
import { createTelemetryCommands } from '../commands/telemetry.mjs';
|
|
19
|
-
import { createCredentialsCommands } from '../commands/credentials.mjs';
|
|
20
|
-
import { createAgentCommands } from '../commands/agent.mjs';
|
|
21
|
-
import { createWalletControlCommands } from '../commands/walletControl.mjs';
|
|
19
|
+
import { createCredentialsCommands } from '../commands/onboarding/credentials.mjs';
|
|
20
|
+
import { createAgentCommands } from '../commands/account/agent.mjs';
|
|
21
|
+
import { createWalletControlCommands } from '../commands/account/walletControl.mjs';
|
|
22
22
|
import { createDoctorCommands } from '../commands/doctor.mjs';
|
|
23
23
|
import { createPromptCommands } from '../commands/prompt.mjs';
|
|
24
|
-
import { createVenueCommands } from '../commands/venue.mjs';
|
|
24
|
+
import { createVenueCommands } from '../commands/venues/venue.mjs';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Wire command-module factories and local handlers for Commander manifest registration.
|
|
@@ -66,7 +66,7 @@ export function createRuntimeHandlers(deps) {
|
|
|
66
66
|
applyActionFilters,
|
|
67
67
|
getProviderHintForActions,
|
|
68
68
|
resolveChainSupport,
|
|
69
|
-
|
|
69
|
+
buildOwnerAuthHeaders,
|
|
70
70
|
resolveAgentApiKey,
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -75,6 +75,7 @@ export function createRuntimeHandlers(deps) {
|
|
|
75
75
|
const __credits = createCreditsCommands({
|
|
76
76
|
printEnvelope,
|
|
77
77
|
getAuthToken,
|
|
78
|
+
buildOwnerAuthHeaders,
|
|
78
79
|
// __wallet is created further down; resolve it when the command runs.
|
|
79
80
|
commandWalletExecute: (...args) => __wallet.commandWalletExecute(...args),
|
|
80
81
|
});
|
package/src/runtime/main.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import { createAuthHelpers } from './authHelpers.mjs';
|
|
|
23
23
|
import { createExecutionAmounts } from './execution/amounts.mjs';
|
|
24
24
|
import { createExecutionLanes } from './execution/lanes.mjs';
|
|
25
25
|
import { createExecutionPayloads } from './execution/payloads.mjs';
|
|
26
|
-
import { createExecutionRunners } from './execution/runners.mjs';
|
|
26
|
+
import { createExecutionRunners } from './execution/runners/createExecutionRunners.mjs';
|
|
27
27
|
import { createActionSelection } from './actions/selection.mjs';
|
|
28
28
|
import { createBitfinexProbe } from './bitfinexProbe.mjs';
|
|
29
29
|
import { createOwsSigning } from './owsSigning.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createCliError } from '../../core/envelope.mjs';
|
|
2
|
-
import { isReadOnlyResolvedAction } from '../../core/readOnlyActions.mjs';
|
|
2
|
+
import { isReadOnlyResolvedAction } from '../../core/execution/readOnlyActions.mjs';
|
|
3
3
|
import { resolveExecuteEstimatedAmountUsd } from '../execution/payloads.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createCliError } from '../../core/envelope.mjs';
|
|
2
|
-
import { isReadOnlyResolvedAction } from '../../core/readOnlyActions.mjs';
|
|
2
|
+
import { isReadOnlyResolvedAction } from '../../core/execution/readOnlyActions.mjs';
|
|
3
3
|
import {
|
|
4
4
|
sanitizeParamsForSchemaValidation,
|
|
5
5
|
validateParamsSchema,
|