@drakkar.software/octobot-client 0.4.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.
- package/README.md +140 -0
- package/dist/client/adapters/accounts.d.ts +66 -0
- package/dist/client/adapters/accounts.d.ts.map +1 -0
- package/dist/client/adapters/accounts.js +214 -0
- package/dist/client/adapters/accounts.js.map +1 -0
- package/dist/client/adapters/actionHandle.d.ts +29 -0
- package/dist/client/adapters/actionHandle.d.ts.map +1 -0
- package/dist/client/adapters/actionHandle.js +34 -0
- package/dist/client/adapters/actionHandle.js.map +1 -0
- package/dist/client/adapters/automations.d.ts +31 -0
- package/dist/client/adapters/automations.d.ts.map +1 -0
- package/dist/client/adapters/automations.js +79 -0
- package/dist/client/adapters/automations.js.map +1 -0
- package/dist/client/adapters/documents.d.ts +55 -0
- package/dist/client/adapters/documents.d.ts.map +1 -0
- package/dist/client/adapters/documents.js +66 -0
- package/dist/client/adapters/documents.js.map +1 -0
- package/dist/client/adapters/nodeApi.d.ts +25 -0
- package/dist/client/adapters/nodeApi.d.ts.map +1 -0
- package/dist/client/adapters/nodeApi.js +81 -0
- package/dist/client/adapters/nodeApi.js.map +1 -0
- package/dist/client/adapters/settings.d.ts +16 -0
- package/dist/client/adapters/settings.d.ts.map +1 -0
- package/dist/client/adapters/settings.js +43 -0
- package/dist/client/adapters/settings.js.map +1 -0
- package/dist/client/adapters/strategies.d.ts +17 -0
- package/dist/client/adapters/strategies.d.ts.map +1 -0
- package/dist/client/adapters/strategies.js +75 -0
- package/dist/client/adapters/strategies.js.map +1 -0
- package/dist/client/connect/connect.d.ts +40 -0
- package/dist/client/connect/connect.d.ts.map +1 -0
- package/dist/client/connect/connect.js +133 -0
- package/dist/client/connect/connect.js.map +1 -0
- package/dist/client/connect/readOnly.d.ts +97 -0
- package/dist/client/connect/readOnly.d.ts.map +1 -0
- package/dist/client/connect/readOnly.js +167 -0
- package/dist/client/connect/readOnly.js.map +1 -0
- package/dist/client/core/errors.d.ts +80 -0
- package/dist/client/core/errors.d.ts.map +1 -0
- package/dist/client/core/errors.js +154 -0
- package/dist/client/core/errors.js.map +1 -0
- package/dist/client/core/options.d.ts +44 -0
- package/dist/client/core/options.d.ts.map +1 -0
- package/dist/client/core/options.js +2 -0
- package/dist/client/core/options.js.map +1 -0
- package/dist/client/core/session.d.ts +90 -0
- package/dist/client/core/session.d.ts.map +1 -0
- package/dist/client/core/session.js +72 -0
- package/dist/client/core/session.js.map +1 -0
- package/dist/client/core/views.d.ts +40 -0
- package/dist/client/core/views.d.ts.map +1 -0
- package/dist/client/core/views.js +32 -0
- package/dist/client/core/views.js.map +1 -0
- package/dist/client/index.d.ts +16 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/mirror/collections.d.ts +125 -0
- package/dist/client/mirror/collections.d.ts.map +1 -0
- package/dist/client/mirror/collections.js +118 -0
- package/dist/client/mirror/collections.js.map +1 -0
- package/dist/client/mirror/index.d.ts +4 -0
- package/dist/client/mirror/index.d.ts.map +1 -0
- package/dist/client/mirror/index.js +4 -0
- package/dist/client/mirror/index.js.map +1 -0
- package/dist/client/mirror/writer.d.ts +39 -0
- package/dist/client/mirror/writer.d.ts.map +1 -0
- package/dist/client/mirror/writer.js +50 -0
- package/dist/client/mirror/writer.js.map +1 -0
- package/dist/client/pairing/mirrorGrant.d.ts +91 -0
- package/dist/client/pairing/mirrorGrant.d.ts.map +1 -0
- package/dist/client/pairing/mirrorGrant.js +99 -0
- package/dist/client/pairing/mirrorGrant.js.map +1 -0
- package/dist/client/pairing/mirrorReader.d.ts +99 -0
- package/dist/client/pairing/mirrorReader.d.ts.map +1 -0
- package/dist/client/pairing/mirrorReader.js +117 -0
- package/dist/client/pairing/mirrorReader.js.map +1 -0
- package/dist/client/pairing/pairingGrantExchange.d.ts +135 -0
- package/dist/client/pairing/pairingGrantExchange.d.ts.map +1 -0
- package/dist/client/pairing/pairingGrantExchange.js +186 -0
- package/dist/client/pairing/pairingGrantExchange.js.map +1 -0
- package/dist/client/pairing/pairingRequest.d.ts +82 -0
- package/dist/client/pairing/pairingRequest.d.ts.map +1 -0
- package/dist/client/pairing/pairingRequest.js +120 -0
- package/dist/client/pairing/pairingRequest.js.map +1 -0
- package/dist/client/strategy.d.ts +36 -0
- package/dist/client/strategy.d.ts.map +1 -0
- package/dist/client/strategy.js +26 -0
- package/dist/client/strategy.js.map +1 -0
- package/dist/collections/index.d.ts +3 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +3 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/nodeCollections.d.ts +57 -0
- package/dist/collections/nodeCollections.d.ts.map +1 -0
- package/dist/collections/nodeCollections.js +40 -0
- package/dist/collections/nodeCollections.js.map +1 -0
- package/dist/collections/paths.d.ts +7 -0
- package/dist/collections/paths.d.ts.map +1 -0
- package/dist/collections/paths.js +13 -0
- package/dist/collections/paths.js.map +1 -0
- package/dist/crypto/collectionKeys.d.ts +28 -0
- package/dist/crypto/collectionKeys.d.ts.map +1 -0
- package/dist/crypto/collectionKeys.js +53 -0
- package/dist/crypto/collectionKeys.js.map +1 -0
- package/dist/crypto/hkdf.d.ts +14 -0
- package/dist/crypto/hkdf.d.ts.map +1 -0
- package/dist/crypto/hkdf.js +19 -0
- package/dist/crypto/hkdf.js.map +1 -0
- package/dist/crypto/index.d.ts +5 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +5 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/secretEncryptor.d.ts +20 -0
- package/dist/crypto/secretEncryptor.d.ts.map +1 -0
- package/dist/crypto/secretEncryptor.js +82 -0
- package/dist/crypto/secretEncryptor.js.map +1 -0
- package/dist/crypto/wireConstants.d.ts +14 -0
- package/dist/crypto/wireConstants.d.ts.map +1 -0
- package/dist/crypto/wireConstants.js +17 -0
- package/dist/crypto/wireConstants.js.map +1 -0
- package/dist/identity/address.d.ts +3 -0
- package/dist/identity/address.d.ts.map +1 -0
- package/dist/identity/address.js +17 -0
- package/dist/identity/address.js.map +1 -0
- package/dist/identity/bip39-wordlist.d.ts +2 -0
- package/dist/identity/bip39-wordlist.d.ts.map +1 -0
- package/dist/identity/bip39-wordlist.js +2051 -0
- package/dist/identity/bip39-wordlist.js.map +1 -0
- package/dist/identity/capProvider.d.ts +45 -0
- package/dist/identity/capProvider.d.ts.map +1 -0
- package/dist/identity/capProvider.js +80 -0
- package/dist/identity/capProvider.js.map +1 -0
- package/dist/identity/derivationSchemes.d.ts +25 -0
- package/dist/identity/derivationSchemes.d.ts.map +1 -0
- package/dist/identity/derivationSchemes.js +34 -0
- package/dist/identity/derivationSchemes.js.map +1 -0
- package/dist/identity/evm.d.ts +8 -0
- package/dist/identity/evm.d.ts.map +1 -0
- package/dist/identity/evm.js +78 -0
- package/dist/identity/evm.js.map +1 -0
- package/dist/identity/index.d.ts +10 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +10 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/keys.d.ts +17 -0
- package/dist/identity/keys.d.ts.map +1 -0
- package/dist/identity/keys.js +36 -0
- package/dist/identity/keys.js.map +1 -0
- package/dist/identity/mnemonic.d.ts +4 -0
- package/dist/identity/mnemonic.d.ts.map +1 -0
- package/dist/identity/mnemonic.js +93 -0
- package/dist/identity/mnemonic.js.map +1 -0
- package/dist/identity/pairing.d.ts +45 -0
- package/dist/identity/pairing.d.ts.map +1 -0
- package/dist/identity/pairing.js +91 -0
- package/dist/identity/pairing.js.map +1 -0
- package/dist/identity/pairingRequest.d.ts +99 -0
- package/dist/identity/pairingRequest.d.ts.map +1 -0
- package/dist/identity/pairingRequest.js +217 -0
- package/dist/identity/pairingRequest.js.map +1 -0
- package/dist/identity/secret.d.ts +32 -0
- package/dist/identity/secret.d.ts.map +1 -0
- package/dist/identity/secret.js +54 -0
- package/dist/identity/secret.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/bytes.d.ts +11 -0
- package/dist/internal/bytes.d.ts.map +1 -0
- package/dist/internal/bytes.js +38 -0
- package/dist/internal/bytes.js.map +1 -0
- package/dist/node-api/dexPair.d.ts +24 -0
- package/dist/node-api/dexPair.d.ts.map +1 -0
- package/dist/node-api/dexPair.js +39 -0
- package/dist/node-api/dexPair.js.map +1 -0
- package/dist/node-api/dsl.d.ts +10 -0
- package/dist/node-api/dsl.d.ts.map +1 -0
- package/dist/node-api/dsl.js +7 -0
- package/dist/node-api/dsl.js.map +1 -0
- package/dist/node-api/exchanges.d.ts +49 -0
- package/dist/node-api/exchanges.d.ts.map +1 -0
- package/dist/node-api/exchanges.js +32 -0
- package/dist/node-api/exchanges.js.map +1 -0
- package/dist/node-api/index.d.ts +12 -0
- package/dist/node-api/index.d.ts.map +1 -0
- package/dist/node-api/index.js +12 -0
- package/dist/node-api/index.js.map +1 -0
- package/dist/node-api/marketMaking.d.ts +39 -0
- package/dist/node-api/marketMaking.d.ts.map +1 -0
- package/dist/node-api/marketMaking.js +44 -0
- package/dist/node-api/marketMaking.js.map +1 -0
- package/dist/node-api/octobots.d.ts +14 -0
- package/dist/node-api/octobots.d.ts.map +1 -0
- package/dist/node-api/octobots.js +16 -0
- package/dist/node-api/octobots.js.map +1 -0
- package/dist/node-api/orderBookPreview.d.ts +11 -0
- package/dist/node-api/orderBookPreview.d.ts.map +1 -0
- package/dist/node-api/orderBookPreview.js +7 -0
- package/dist/node-api/orderBookPreview.js.map +1 -0
- package/dist/node-api/pairing.d.ts +39 -0
- package/dist/node-api/pairing.d.ts.map +1 -0
- package/dist/node-api/pairing.js +61 -0
- package/dist/node-api/pairing.js.map +1 -0
- package/dist/node-api/pairs.d.ts +32 -0
- package/dist/node-api/pairs.d.ts.map +1 -0
- package/dist/node-api/pairs.js +72 -0
- package/dist/node-api/pairs.js.map +1 -0
- package/dist/node-api/requiredFunds.d.ts +11 -0
- package/dist/node-api/requiredFunds.d.ts.map +1 -0
- package/dist/node-api/requiredFunds.js +7 -0
- package/dist/node-api/requiredFunds.js.map +1 -0
- package/dist/node-api/setup.d.ts +25 -0
- package/dist/node-api/setup.d.ts.map +1 -0
- package/dist/node-api/setup.js +13 -0
- package/dist/node-api/setup.js.map +1 -0
- package/dist/node-api/wallet.d.ts +55 -0
- package/dist/node-api/wallet.d.ts.map +1 -0
- package/dist/node-api/wallet.js +87 -0
- package/dist/node-api/wallet.js.map +1 -0
- package/dist/protocol/actions.d.ts +40 -0
- package/dist/protocol/actions.d.ts.map +1 -0
- package/dist/protocol/actions.js +118 -0
- package/dist/protocol/actions.js.map +1 -0
- package/dist/protocol/documents.d.ts +25 -0
- package/dist/protocol/documents.d.ts.map +1 -0
- package/dist/protocol/documents.js +2 -0
- package/dist/protocol/documents.js.map +1 -0
- package/dist/protocol/index.d.ts +10 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +12 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/orchestration/createAutomation.d.ts +61 -0
- package/dist/protocol/orchestration/createAutomation.d.ts.map +1 -0
- package/dist/protocol/orchestration/createAutomation.js +71 -0
- package/dist/protocol/orchestration/createAutomation.js.map +1 -0
- package/dist/protocol/poll.d.ts +4 -0
- package/dist/protocol/poll.d.ts.map +1 -0
- package/dist/protocol/poll.js +4 -0
- package/dist/protocol/poll.js.map +1 -0
- package/dist/protocol/proposal.d.ts +36 -0
- package/dist/protocol/proposal.d.ts.map +1 -0
- package/dist/protocol/proposal.js +39 -0
- package/dist/protocol/proposal.js.map +1 -0
- package/dist/protocol/state.d.ts +87 -0
- package/dist/protocol/state.d.ts.map +1 -0
- package/dist/protocol/state.js +303 -0
- package/dist/protocol/state.js.map +1 -0
- package/dist/protocol/strategy/build.d.ts +44 -0
- package/dist/protocol/strategy/build.d.ts.map +1 -0
- package/dist/protocol/strategy/build.js +50 -0
- package/dist/protocol/strategy/build.js.map +1 -0
- package/dist/protocol/strategy/builders.d.ts +252 -0
- package/dist/protocol/strategy/builders.d.ts.map +1 -0
- package/dist/protocol/strategy/builders.js +382 -0
- package/dist/protocol/strategy/builders.js.map +1 -0
- package/dist/protocol/strategy/index.d.ts +5 -0
- package/dist/protocol/strategy/index.d.ts.map +1 -0
- package/dist/protocol/strategy/index.js +4 -0
- package/dist/protocol/strategy/index.js.map +1 -0
- package/dist/protocol/strategy/kinds.d.ts +2 -0
- package/dist/protocol/strategy/kinds.d.ts.map +1 -0
- package/dist/protocol/strategy/kinds.js +2 -0
- package/dist/protocol/strategy/kinds.js.map +1 -0
- package/dist/protocol/strategy/patch.d.ts +59 -0
- package/dist/protocol/strategy/patch.d.ts.map +1 -0
- package/dist/protocol/strategy/patch.js +253 -0
- package/dist/protocol/strategy/patch.js.map +1 -0
- package/dist/protocol/symbols.d.ts +8 -0
- package/dist/protocol/symbols.d.ts.map +1 -0
- package/dist/protocol/symbols.js +11 -0
- package/dist/protocol/symbols.js.map +1 -0
- package/dist/transport/constants.d.ts +8 -0
- package/dist/transport/constants.d.ts.map +1 -0
- package/dist/transport/constants.js +8 -0
- package/dist/transport/constants.js.map +1 -0
- package/dist/transport/documents.d.ts +27 -0
- package/dist/transport/documents.d.ts.map +1 -0
- package/dist/transport/documents.js +34 -0
- package/dist/transport/documents.js.map +1 -0
- package/dist/transport/index.d.ts +8 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/probe.d.ts +44 -0
- package/dist/transport/probe.d.ts.map +1 -0
- package/dist/transport/probe.js +121 -0
- package/dist/transport/probe.js.map +1 -0
- package/dist/transport/rendezvous.d.ts +116 -0
- package/dist/transport/rendezvous.d.ts.map +1 -0
- package/dist/transport/rendezvous.js +139 -0
- package/dist/transport/rendezvous.js.map +1 -0
- package/dist/transport/rest.d.ts +35 -0
- package/dist/transport/rest.d.ts.map +1 -0
- package/dist/transport/rest.js +58 -0
- package/dist/transport/rest.js.map +1 -0
- package/dist/transport/syncClient.d.ts +14 -0
- package/dist/transport/syncClient.d.ts.map +1 -0
- package/dist/transport/syncClient.js +30 -0
- package/dist/transport/syncClient.js.map +1 -0
- package/dist/transport/urls.d.ts +35 -0
- package/dist/transport/urls.d.ts.map +1 -0
- package/dist/transport/urls.js +126 -0
- package/dist/transport/urls.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { NodeHttpError } from '../transport/rest.js';
|
|
2
|
+
import { fetchNodeTradedPairs, } from './exchanges.js';
|
|
3
|
+
function numberOrUndefined(value) {
|
|
4
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
5
|
+
}
|
|
6
|
+
function symbolToPair(symbol) {
|
|
7
|
+
const isSwap = symbol.includes(':');
|
|
8
|
+
const [pairPart] = symbol.split(':', 1);
|
|
9
|
+
const slashIdx = pairPart.indexOf('/');
|
|
10
|
+
const base = slashIdx >= 0 ? pairPart.slice(0, slashIdx) : pairPart;
|
|
11
|
+
const quote = slashIdx >= 0 ? pairPart.slice(slashIdx + 1) : '';
|
|
12
|
+
return { symbol, base, quote, type: isSwap ? 'swap' : 'spot', active: true };
|
|
13
|
+
}
|
|
14
|
+
/** Node's `traded-pairs` payload is untyped JSON — validate its actual shape
|
|
15
|
+
* here rather than trusting the declared type at the call site, so a
|
|
16
|
+
* mismatched/unexpected response throws a clear error instead of a bare "X
|
|
17
|
+
* is not a function" once a non-string symbol reaches `symbolToPair`.
|
|
18
|
+
*
|
|
19
|
+
* Two per-exchange shapes are accepted: the current symbol → volume map, and
|
|
20
|
+
* the bare symbol array older nodes still answer. Anything else is a payload
|
|
21
|
+
* we don't understand — throwing beats silently returning an empty list.
|
|
22
|
+
*
|
|
23
|
+
* A symbol listed by more than one exchange yields one pair (the list is
|
|
24
|
+
* keyed by symbol downstream), keeping the first volumes reported for it. */
|
|
25
|
+
export function extractPairs(byExchange) {
|
|
26
|
+
if (byExchange == null || typeof byExchange !== 'object' || Array.isArray(byExchange)) {
|
|
27
|
+
throw new Error('Unexpected traded-pairs payload from node');
|
|
28
|
+
}
|
|
29
|
+
const bySymbol = new Map();
|
|
30
|
+
const add = (symbol, volume) => {
|
|
31
|
+
const known = bySymbol.get(symbol);
|
|
32
|
+
const pair = known ?? symbolToPair(symbol);
|
|
33
|
+
if (volume != null && typeof volume === 'object') {
|
|
34
|
+
const raw = volume;
|
|
35
|
+
pair.baseVolume = pair.baseVolume ?? numberOrUndefined(raw.baseVolume);
|
|
36
|
+
pair.quoteVolume = pair.quoteVolume ?? numberOrUndefined(raw.quoteVolume);
|
|
37
|
+
}
|
|
38
|
+
if (!known)
|
|
39
|
+
bySymbol.set(symbol, pair);
|
|
40
|
+
};
|
|
41
|
+
for (const value of Object.values(byExchange)) {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
for (const entry of value) {
|
|
44
|
+
if (typeof entry === 'string')
|
|
45
|
+
add(entry);
|
|
46
|
+
}
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (value == null || typeof value !== 'object')
|
|
50
|
+
continue;
|
|
51
|
+
for (const [symbol, volume] of Object.entries(value))
|
|
52
|
+
add(symbol, volume);
|
|
53
|
+
}
|
|
54
|
+
return [...bySymbol.values()];
|
|
55
|
+
}
|
|
56
|
+
/** Fetch and normalize the traded pairs for one exchange on one node. Falls
|
|
57
|
+
* back to the volume-less request when the node can't fetch tickers for
|
|
58
|
+
* this exchange (501) rather than surfacing no pairs at all. */
|
|
59
|
+
export async function fetchPairsFromNode(node, providerId, signal) {
|
|
60
|
+
const exchange = { id: providerId, name: providerId, exchange: providerId };
|
|
61
|
+
let byExchange;
|
|
62
|
+
try {
|
|
63
|
+
byExchange = await fetchNodeTradedPairs(node, exchange, { withVolume: true, signal });
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (!(err instanceof NodeHttpError) || err.status !== 501)
|
|
67
|
+
throw err;
|
|
68
|
+
byExchange = await fetchNodeTradedPairs(node, exchange, { signal });
|
|
69
|
+
}
|
|
70
|
+
return extractPairs(byExchange).sort((a, b) => a.symbol.localeCompare(b.symbol));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=pairs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairs.js","sourceRoot":"","sources":["../../src/node-api/pairs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EACL,oBAAoB,GAGrB,MAAM,gBAAgB,CAAA;AAgBvB,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAChF,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IACvC,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;IACnE,MAAM,KAAK,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,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point } from '../transport/urls.js';
|
|
3
|
+
import type { ExchangeConfigParams } from './exchanges.js';
|
|
4
|
+
import { type RequiredFundsResponse } from './marketMaking.js';
|
|
5
|
+
export type { RequiredFundsResponse };
|
|
6
|
+
/** `POST /api/v1/tentacles/market-making/` with `type: 'market_making_volume'`. */
|
|
7
|
+
export declare function fetchRequiredFunds(node: NodeEndpoint, exchangeConfig: ExchangeConfigParams, marketMakingConfig: MarketMakingConfiguration, options?: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
}): Promise<RequiredFundsResponse>;
|
|
11
|
+
//# sourceMappingURL=requiredFunds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredFunds.d.ts","sourceRoot":"","sources":["../../src/node-api/requiredFunds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAoD,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEhH,YAAY,EAAE,qBAAqB,EAAE,CAAA;AAErC,mFAAmF;AACnF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,YAAY,EAClB,cAAc,EAAE,oBAAoB,EACpC,kBAAkB,EAAE,yBAAyB,EAC7C,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CAAO,GAC3D,OAAO,CAAC,qBAAqB,CAAC,CAGhC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { marketMakingRequestBody, postMarketMakingRequest } from './marketMaking.js';
|
|
2
|
+
/** `POST /api/v1/tentacles/market-making/` with `type: 'market_making_volume'`. */
|
|
3
|
+
export async function fetchRequiredFunds(node, exchangeConfig, marketMakingConfig, options = {}) {
|
|
4
|
+
const body = marketMakingRequestBody('market_making_volume', exchangeConfig, marketMakingConfig);
|
|
5
|
+
return postMarketMakingRequest(node, body, options);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=requiredFunds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredFunds.js","sourceRoot":"","sources":["../../src/node-api/requiredFunds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAA8B,MAAM,mBAAmB,CAAA;AAIhH,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAkB,EAClB,cAAoC,EACpC,kBAA6C,EAC7C,UAA0D,EAAE;IAE5D,MAAM,IAAI,GAAG,uBAAuB,CAAC,sBAAsB,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAA;IAChG,OAAO,uBAAuB,CAAwB,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAC5E,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NodeEndpoint } from '../transport/urls.js';
|
|
2
|
+
import { type NodeCredentials } from '../transport/rest.js';
|
|
3
|
+
/** A node's own copy of the wallet it runs on. `seed` is only set when that
|
|
4
|
+
* wallet was created from a mnemonic; a node set up from a raw key has the
|
|
5
|
+
* private key alone. Declared here rather than imported from
|
|
6
|
+
* `@drakkar.software/octobot-protocol` because the node's setup routes are
|
|
7
|
+
* not part of its generated model set. */
|
|
8
|
+
export type NodeWalletExport = {
|
|
9
|
+
address: string;
|
|
10
|
+
private_key: string;
|
|
11
|
+
seed?: string | null;
|
|
12
|
+
};
|
|
13
|
+
/** `GET /api/v1/setup/wallet/export` — the wallet behind the credentials being
|
|
14
|
+
* presented. Only a node paired by an older QR needs this: that code carried a
|
|
15
|
+
* password rather than the wallet, so the wallet had to be fetched. A current
|
|
16
|
+
* pairing code is read offline and never reaches here.
|
|
17
|
+
*
|
|
18
|
+
* `NodeHttpError` statuses worth telling apart: 401 (wrong password, or the
|
|
19
|
+
* node has no wallet for that address), 403 (asking for someone else's wallet
|
|
20
|
+
* without being the admin), 503 (node not configured yet). */
|
|
21
|
+
export declare function fetchNodeWalletExport(node: NodeEndpoint, credentials: NodeCredentials, options?: {
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
fetch?: typeof fetch;
|
|
24
|
+
}): Promise<NodeWalletExport>;
|
|
25
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/node-api/setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE5E;;;;2CAI2C;AAC3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA;AAED;;;;;;;+DAO+D;AAC/D,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CAAO,GAC3D,OAAO,CAAC,gBAAgB,CAAC,CAE3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { nodeAuthRequest } from '../transport/rest.js';
|
|
2
|
+
/** `GET /api/v1/setup/wallet/export` — the wallet behind the credentials being
|
|
3
|
+
* presented. Only a node paired by an older QR needs this: that code carried a
|
|
4
|
+
* password rather than the wallet, so the wallet had to be fetched. A current
|
|
5
|
+
* pairing code is read offline and never reaches here.
|
|
6
|
+
*
|
|
7
|
+
* `NodeHttpError` statuses worth telling apart: 401 (wrong password, or the
|
|
8
|
+
* node has no wallet for that address), 403 (asking for someone else's wallet
|
|
9
|
+
* without being the admin), 503 (node not configured yet). */
|
|
10
|
+
export async function fetchNodeWalletExport(node, credentials, options = {}) {
|
|
11
|
+
return nodeAuthRequest(node, credentials, '/setup/wallet/export', options);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/node-api/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAwB,MAAM,sBAAsB,CAAA;AAa5E;;;;;;;+DAO+D;AAC/D,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAkB,EAClB,WAA4B,EAC5B,UAA0D,EAAE;IAE5D,OAAO,eAAe,CAAmB,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAA;AAC9F,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type NodePairingPayload } from './pairing.js';
|
|
2
|
+
import type { NodeWalletExport } from './setup.js';
|
|
3
|
+
import { type ReadOnlyPairingPayload } from '../identity/pairing.js';
|
|
4
|
+
import { type ActionProposal } from '../protocol/proposal.js';
|
|
5
|
+
/** A wallet resolved from a node, ready to be stored.
|
|
6
|
+
*
|
|
7
|
+
* `seed` is what the user backs up; `key` is what the app signs and encrypts
|
|
8
|
+
* with. They differ whenever the phrase needs a derivation the app does not use
|
|
9
|
+
* natively, which `derivation` records. */
|
|
10
|
+
export type NodeWalletImport = {
|
|
11
|
+
seed: string;
|
|
12
|
+
keySource: 'mnemonic' | 'privateKey';
|
|
13
|
+
derivation: 'legacy' | 'bip44';
|
|
14
|
+
key?: string;
|
|
15
|
+
};
|
|
16
|
+
/** From a pairing QR's secret, which is the wallet itself — a BIP39 phrase, or a
|
|
17
|
+
* 0x private key when the node was set up from a raw key and has no mnemonic.
|
|
18
|
+
* Null when it is neither, which has to fail the scan rather than quietly
|
|
19
|
+
* produce a wallet nobody owns. */
|
|
20
|
+
export declare function nodeWalletFromSecret(secret: string): Promise<NodeWalletImport | null>;
|
|
21
|
+
/** From an older node's HTTP wallet export, which hands over both halves. The
|
|
22
|
+
* node's own `private_key` is authoritative for the identity — nothing has to be
|
|
23
|
+
* derived to get that right — but its mnemonic is worth keeping as the thing the
|
|
24
|
+
* user backs up. Null when the export carries no usable key, which is a node
|
|
25
|
+
* with nothing to import rather than a code that failed to decode. */
|
|
26
|
+
export declare function nodeWalletFromExport(wallet: NodeWalletExport): Promise<NodeWalletImport | null>;
|
|
27
|
+
/** The key material a resolved wallet is identified by. */
|
|
28
|
+
export declare function nodeWalletKey(wallet: NodeWalletImport): string;
|
|
29
|
+
/** What a code held up to a wallet scanner turned out to be. */
|
|
30
|
+
export type ScannedCode = {
|
|
31
|
+
kind: 'node';
|
|
32
|
+
payload: NodePairingPayload;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'octobotReadOnlyPairing';
|
|
35
|
+
payload: ReadOnlyPairingPayload;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'octobotActionProposal';
|
|
38
|
+
payload: ActionProposal;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'privateKey';
|
|
41
|
+
value: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'seed';
|
|
44
|
+
value: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'unknown';
|
|
47
|
+
};
|
|
48
|
+
/** Classify a scanned code. Node pairing JSON and the two octobot-client JSON
|
|
49
|
+
* shapes (read-only pairing, action proposal) are checked first because
|
|
50
|
+
* they're the most specific — each has its own `v`/`kind` discriminator and
|
|
51
|
+
* throws immediately on anything else. A standalone envelope next, since its
|
|
52
|
+
* field name says the value is key material; a bare code last, where the
|
|
53
|
+
* shape is all there is to go on. */
|
|
54
|
+
export declare function classifyScannedCode(data: string): Promise<ScannedCode>;
|
|
55
|
+
//# sourceMappingURL=wallet.d.ts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EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAEvB;;;;;sCAKsC;AACtC,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAoB5E"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Turning what a node hands over into a wallet an app can hold.
|
|
2
|
+
//
|
|
3
|
+
// A node's mnemonic is real BIP44 (`web3.Account.create_with_mnemonic`),
|
|
4
|
+
// which is also this package's only derivation scheme today — so importing
|
|
5
|
+
// one is unambiguous. This file exists for the two cases that still need
|
|
6
|
+
// their own handling: a raw key (no derivation at all — `derivation:
|
|
7
|
+
// 'legacy'` here just means "the key IS the identity," not any specific
|
|
8
|
+
// scheme) and an older node's HTTP export, which hands over both the phrase
|
|
9
|
+
// and the key it must actually agree with.
|
|
10
|
+
import { classifyBareSecret, classifySecret, readSecretEnvelope } from '../identity/secret.js';
|
|
11
|
+
import { deriveBip44PrivateKey, isEvmPrivateKey, normalizeEvmPrivateKey } from '../identity/evm.js';
|
|
12
|
+
import { parseNodePairingQr } from './pairing.js';
|
|
13
|
+
import { parseReadOnlyPairing } from '../identity/pairing.js';
|
|
14
|
+
import { decodeActionProposal } from '../protocol/proposal.js';
|
|
15
|
+
/** From a pairing QR's secret, which is the wallet itself — a BIP39 phrase, or a
|
|
16
|
+
* 0x private key when the node was set up from a raw key and has no mnemonic.
|
|
17
|
+
* Null when it is neither, which has to fail the scan rather than quietly
|
|
18
|
+
* produce a wallet nobody owns. */
|
|
19
|
+
export async function nodeWalletFromSecret(secret) {
|
|
20
|
+
const classified = await classifySecret(secret);
|
|
21
|
+
if (classified.kind === 'privateKey') {
|
|
22
|
+
// No derivation to get wrong: the key is the identity.
|
|
23
|
+
return { seed: classified.value, keySource: 'privateKey', derivation: 'legacy' };
|
|
24
|
+
}
|
|
25
|
+
if (classified.kind === 'seed') {
|
|
26
|
+
return {
|
|
27
|
+
seed: classified.value,
|
|
28
|
+
keySource: 'mnemonic',
|
|
29
|
+
derivation: 'bip44',
|
|
30
|
+
key: await deriveBip44PrivateKey(classified.value),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/** From an older node's HTTP wallet export, which hands over both halves. The
|
|
36
|
+
* node's own `private_key` is authoritative for the identity — nothing has to be
|
|
37
|
+
* derived to get that right — but its mnemonic is worth keeping as the thing the
|
|
38
|
+
* user backs up. Null when the export carries no usable key, which is a node
|
|
39
|
+
* with nothing to import rather than a code that failed to decode. */
|
|
40
|
+
export async function nodeWalletFromExport(wallet) {
|
|
41
|
+
const key = normalizeEvmPrivateKey(wallet.private_key);
|
|
42
|
+
if (!isEvmPrivateKey(key))
|
|
43
|
+
return null;
|
|
44
|
+
// The phrase is only kept if it really does derive to the key the node signs
|
|
45
|
+
// with. Both come from one wallet object on the node, so they should always
|
|
46
|
+
// agree — but a phrase offered as a backup that restores a *different* account
|
|
47
|
+
// in another wallet is worse than offering no phrase at all, and this is the
|
|
48
|
+
// only place that can check rather than assume.
|
|
49
|
+
if (wallet.seed) {
|
|
50
|
+
const fromSeed = await nodeWalletFromSecret(wallet.seed);
|
|
51
|
+
if (fromSeed?.key === key)
|
|
52
|
+
return fromSeed;
|
|
53
|
+
}
|
|
54
|
+
return { seed: key, keySource: 'privateKey', derivation: 'legacy' };
|
|
55
|
+
}
|
|
56
|
+
/** The key material a resolved wallet is identified by. */
|
|
57
|
+
export function nodeWalletKey(wallet) {
|
|
58
|
+
return wallet.key ?? wallet.seed;
|
|
59
|
+
}
|
|
60
|
+
/** Classify a scanned code. Node pairing JSON and the two octobot-client JSON
|
|
61
|
+
* shapes (read-only pairing, action proposal) are checked first because
|
|
62
|
+
* they're the most specific — each has its own `v`/`kind` discriminator and
|
|
63
|
+
* throws immediately on anything else. A standalone envelope next, since its
|
|
64
|
+
* field name says the value is key material; a bare code last, where the
|
|
65
|
+
* shape is all there is to go on. */
|
|
66
|
+
export async function classifyScannedCode(data) {
|
|
67
|
+
const payload = parseNodePairingQr(data);
|
|
68
|
+
if (payload)
|
|
69
|
+
return { kind: 'node', payload };
|
|
70
|
+
try {
|
|
71
|
+
return { kind: 'octobotReadOnlyPairing', payload: parseReadOnlyPairing(data) };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// not a read-only pairing payload — fall through
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
return { kind: 'octobotActionProposal', payload: decodeActionProposal(data) };
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// not an action proposal payload — fall through
|
|
81
|
+
}
|
|
82
|
+
const enveloped = readSecretEnvelope(data);
|
|
83
|
+
if (enveloped !== null)
|
|
84
|
+
return classifySecret(enveloped);
|
|
85
|
+
return classifyBareSecret(data);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/node-api/wallet.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,qEAAqE;AACrE,wEAAwE;AACxE,4EAA4E;AAC5E,2CAA2C;AAC3C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC9F,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAA;AAE1E,OAAO,EAAE,oBAAoB,EAA+B,MAAM,wBAAwB,CAAA;AAC1F,OAAO,EAAE,oBAAoB,EAAuB,MAAM,yBAAyB,CAAA;AAcnF;;;oCAGoC;AACpC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc;IACvD,MAAM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;sCAKsC;AACtC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAY;IACpD,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACxC,IAAI,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;IAE7C,IAAI,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAA;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,iDAAiD;IACnD,CAAC;IAED,IAAI,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAA;IAC/E,CAAC;IAAC,MAAM,CAAC;QACP,gDAAgD;IAClD,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;IAC1C,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,cAAc,CAAC,SAAS,CAAC,CAAA;IAExD,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Strategy as ProtocolStrategy, CreateAutomationConfiguration, EditAutomationConfiguration, StopAutomationConfiguration, AutomationConfiguration, AccountAuthentication, ExchangeConfig, Account as ProtocolAccount, CreateAccountConfiguration, EditAccountConfiguration, DeleteAccountConfiguration, RefreshAccountsConfiguration, CreateAccountAuthConfiguration, EditAccountAuthConfiguration, DeleteAccountAuthConfiguration, CreateExchangeConfigConfiguration, EditExchangeConfigConfiguration, DeleteExchangeConfigConfiguration, CreateStrategyConfiguration, EditStrategyConfiguration, DeleteStrategyConfiguration } from '@drakkar.software/octobot-protocol';
|
|
2
|
+
export type AutomationBuildInput = {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
strategy: ProtocolStrategy;
|
|
6
|
+
accountIds: string[];
|
|
7
|
+
};
|
|
8
|
+
/** A locally-generated id for a queued user action. Not the node's own id
|
|
9
|
+
* scheme — just a client-side correlation handle for the outbox. */
|
|
10
|
+
export declare function newUserActionId(): string;
|
|
11
|
+
export declare function buildAutomationConfiguration(input: AutomationBuildInput): AutomationConfiguration;
|
|
12
|
+
export declare function buildCreateAutomationConfig(input: AutomationBuildInput): CreateAutomationConfiguration;
|
|
13
|
+
export declare function buildEditAutomationConfig(input: AutomationBuildInput & {
|
|
14
|
+
automationId: string;
|
|
15
|
+
}): EditAutomationConfiguration;
|
|
16
|
+
export declare function buildStopAutomationConfig(automationId: string): StopAutomationConfiguration;
|
|
17
|
+
export declare function buildCreateStrategyConfig(strategy: ProtocolStrategy): CreateStrategyConfiguration;
|
|
18
|
+
export declare function buildEditStrategyConfig(strategy: ProtocolStrategy): EditStrategyConfiguration;
|
|
19
|
+
export declare function buildDeleteStrategyConfig(id: string): DeleteStrategyConfiguration;
|
|
20
|
+
export declare function accountAuthIdFor(accountId: string): string;
|
|
21
|
+
export declare function exchangeConfigIdFor(accountId: string): string;
|
|
22
|
+
/** Reverse of `accountAuthIdFor` — recovers the account id an
|
|
23
|
+
* account_auth_* action's own id refers to. Safe because that helper is the
|
|
24
|
+
* only producer of `auth_*` ids. */
|
|
25
|
+
export declare function accountIdFromAuthId(authId: string): string;
|
|
26
|
+
/** Reverse of `exchangeConfigIdFor` — recovers the account id an
|
|
27
|
+
* exchange_config_* action's own id refers to. Safe because that helper is
|
|
28
|
+
* the only producer of `cfg_*` ids. */
|
|
29
|
+
export declare function accountIdFromExchangeConfigId(configId: string): string;
|
|
30
|
+
export declare function buildCreateAccountConfig(account: ProtocolAccount): CreateAccountConfiguration;
|
|
31
|
+
export declare function buildEditAccountConfig(id: string, account?: ProtocolAccount): EditAccountConfiguration;
|
|
32
|
+
export declare function buildDeleteAccountConfig(id: string): DeleteAccountConfiguration;
|
|
33
|
+
export declare function buildRefreshAccountsConfig(accountIds?: string[]): RefreshAccountsConfiguration;
|
|
34
|
+
export declare function buildCreateAccountAuthConfig(auth: AccountAuthentication): CreateAccountAuthConfiguration;
|
|
35
|
+
export declare function buildEditAccountAuthConfig(auth: AccountAuthentication): EditAccountAuthConfiguration;
|
|
36
|
+
export declare function buildDeleteAccountAuthConfig(id: string): DeleteAccountAuthConfiguration;
|
|
37
|
+
export declare function buildCreateExchangeConfigConfig(config: ExchangeConfig): CreateExchangeConfigConfiguration;
|
|
38
|
+
export declare function buildEditExchangeConfigConfig(config: ExchangeConfig): EditExchangeConfigConfiguration;
|
|
39
|
+
export declare function buildDeleteExchangeConfigConfig(id: string): DeleteExchangeConfigConfiguration;
|
|
40
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/protocol/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,IAAI,gBAAgB,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,OAAO,IAAI,eAAe,EAC1B,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,8BAA8B,EAC9B,4BAA4B,EAC5B,8BAA8B,EAC9B,iCAAiC,EACjC,+BAA+B,EAC/B,iCAAiC,EACjC,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,oCAAoC,CAAA;AAE3C,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;qEACqE;AACrE,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,oBAAoB,GAAG,uBAAuB,CAUjG;AAED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,EAAE,MAAM,GAAG,8BAA8B,CAEvF;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,cAAc,GAAG,iCAAiC,CAEzG;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,cAAc,GAAG,+BAA+B,CAErG;AAED,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,MAAM,GAAG,iCAAiC,CAE7F"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** A locally-generated id for a queued user action. Not the node's own id
|
|
2
|
+
* scheme — just a client-side correlation handle for the outbox. */
|
|
3
|
+
export function newUserActionId() {
|
|
4
|
+
return `ua_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
5
|
+
}
|
|
6
|
+
export function buildAutomationConfiguration(input) {
|
|
7
|
+
const now = new Date().toISOString();
|
|
8
|
+
return {
|
|
9
|
+
name: input.name,
|
|
10
|
+
description: input.description,
|
|
11
|
+
created_at: now,
|
|
12
|
+
updated_at: now,
|
|
13
|
+
strategy: { id: input.strategy.id, version: input.strategy.version, emit_signals: false },
|
|
14
|
+
accounts: input.accountIds.map((id) => ({ id })),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function buildCreateAutomationConfig(input) {
|
|
18
|
+
return {
|
|
19
|
+
action_type: 'automation_create',
|
|
20
|
+
configuration: buildAutomationConfiguration(input),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function buildEditAutomationConfig(input) {
|
|
24
|
+
return {
|
|
25
|
+
id: input.automationId,
|
|
26
|
+
action_type: 'automation_edit',
|
|
27
|
+
configuration: buildAutomationConfiguration(input),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function buildStopAutomationConfig(automationId) {
|
|
31
|
+
return {
|
|
32
|
+
id: automationId,
|
|
33
|
+
action_type: 'automation_stop',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// ── Strategy user-actions (protocol 0.4.0) ───────────────────────────────────
|
|
37
|
+
// The node's StrategyProvider is populated ONLY by strategy user actions — a
|
|
38
|
+
// client push of the strategies collection is opaque dead data to it, and
|
|
39
|
+
// automation_create loads the strategy from the provider by (id, version).
|
|
40
|
+
export function buildCreateStrategyConfig(strategy) {
|
|
41
|
+
return { action_type: 'strategy_create', configuration: strategy };
|
|
42
|
+
}
|
|
43
|
+
export function buildEditStrategyConfig(strategy) {
|
|
44
|
+
return { id: strategy.id, action_type: 'strategy_edit', configuration: strategy };
|
|
45
|
+
}
|
|
46
|
+
export function buildDeleteStrategyConfig(id) {
|
|
47
|
+
return { id, action_type: 'strategy_delete' };
|
|
48
|
+
}
|
|
49
|
+
// ── Account user-actions (protocol 0.4.0 graph) ──────────────────────────────
|
|
50
|
+
// 0.4.0 splits an account across three node-side items: credentials live in
|
|
51
|
+
// AccountAuthentication (account_auth_* actions), the venue in ExchangeConfig
|
|
52
|
+
// (exchange_config_* actions), and the Account itself only references them
|
|
53
|
+
// (authentication_id + specifics.exchange_config_ids). Ids are DERIVED from
|
|
54
|
+
// the account id so edits and deletes can address the graph without storing
|
|
55
|
+
// extra local fields. The node does not cascade deletes — the client emits
|
|
56
|
+
// the auth/config deletes itself.
|
|
57
|
+
export function accountAuthIdFor(accountId) {
|
|
58
|
+
return `auth_${accountId}`;
|
|
59
|
+
}
|
|
60
|
+
export function exchangeConfigIdFor(accountId) {
|
|
61
|
+
return `cfg_${accountId}`;
|
|
62
|
+
}
|
|
63
|
+
/** Reverse of `accountAuthIdFor` — recovers the account id an
|
|
64
|
+
* account_auth_* action's own id refers to. Safe because that helper is the
|
|
65
|
+
* only producer of `auth_*` ids. */
|
|
66
|
+
export function accountIdFromAuthId(authId) {
|
|
67
|
+
return authId.startsWith('auth_') ? authId.slice('auth_'.length) : authId;
|
|
68
|
+
}
|
|
69
|
+
/** Reverse of `exchangeConfigIdFor` — recovers the account id an
|
|
70
|
+
* exchange_config_* action's own id refers to. Safe because that helper is
|
|
71
|
+
* the only producer of `cfg_*` ids. */
|
|
72
|
+
export function accountIdFromExchangeConfigId(configId) {
|
|
73
|
+
return configId.startsWith('cfg_') ? configId.slice('cfg_'.length) : configId;
|
|
74
|
+
}
|
|
75
|
+
export function buildCreateAccountConfig(account) {
|
|
76
|
+
return {
|
|
77
|
+
action_type: 'account_create',
|
|
78
|
+
configuration: account,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function buildEditAccountConfig(id, account) {
|
|
82
|
+
return {
|
|
83
|
+
id,
|
|
84
|
+
action_type: 'account_edit',
|
|
85
|
+
configuration: account,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function buildDeleteAccountConfig(id) {
|
|
89
|
+
return {
|
|
90
|
+
id,
|
|
91
|
+
action_type: 'account_delete',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function buildRefreshAccountsConfig(accountIds) {
|
|
95
|
+
return {
|
|
96
|
+
action_type: 'accounts_refresh',
|
|
97
|
+
...(accountIds ? { account_ids: accountIds } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function buildCreateAccountAuthConfig(auth) {
|
|
101
|
+
return { action_type: 'account_auth_create', configuration: auth };
|
|
102
|
+
}
|
|
103
|
+
export function buildEditAccountAuthConfig(auth) {
|
|
104
|
+
return { id: auth.id, action_type: 'account_auth_edit', configuration: auth };
|
|
105
|
+
}
|
|
106
|
+
export function buildDeleteAccountAuthConfig(id) {
|
|
107
|
+
return { id, action_type: 'account_auth_delete' };
|
|
108
|
+
}
|
|
109
|
+
export function buildCreateExchangeConfigConfig(config) {
|
|
110
|
+
return { action_type: 'exchange_config_create', configuration: config };
|
|
111
|
+
}
|
|
112
|
+
export function buildEditExchangeConfigConfig(config) {
|
|
113
|
+
return { id: config.id, action_type: 'exchange_config_edit', configuration: config };
|
|
114
|
+
}
|
|
115
|
+
export function buildDeleteExchangeConfigConfig(id) {
|
|
116
|
+
return { id, action_type: 'exchange_config_delete' };
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=actions.js.map
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C,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AACtF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,EAAU;IACxD,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AutomationState, UserAction, AccountTradingWithAccountId } from '@drakkar.software/octobot-protocol';
|
|
2
|
+
/** What the node computes at `users/{identity}/data` on every pull. A caller
|
|
3
|
+
* with its own local document that stores additional fields in the same
|
|
4
|
+
* blob (a dashboard cache, say) should intersect its own type with this
|
|
5
|
+
* one rather than redeclaring `automations`/`user_actions`. */
|
|
6
|
+
export type UserDataState = {
|
|
7
|
+
automations: AutomationState[];
|
|
8
|
+
user_actions: UserAction[];
|
|
9
|
+
};
|
|
10
|
+
/** What the node returns at `users/{identity}/accounts` — pull-only, the
|
|
11
|
+
* node never accepts a push for this document. */
|
|
12
|
+
export type AccountsState = {
|
|
13
|
+
accounts?: unknown[];
|
|
14
|
+
exchange_configs?: unknown[];
|
|
15
|
+
};
|
|
16
|
+
/** `users/{identity}/actions` — append-only, push-only. Wire elements only;
|
|
17
|
+
* a caller's own local queue mirror is a different, larger shape. */
|
|
18
|
+
export type UserActionsDocument = {
|
|
19
|
+
version?: string;
|
|
20
|
+
items: UserAction[];
|
|
21
|
+
};
|
|
22
|
+
/** `users/{identity}/accounts/{accountId}/trading` — one document per
|
|
23
|
+
* account; there is no single "list every account's trading doc" pull. */
|
|
24
|
+
export type AccountTradingDocument = AccountTradingWithAccountId;
|
|
25
|
+
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/protocol/documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,2BAA2B,EAC5B,MAAM,oCAAoC,CAAA;AAE3C;;;gEAGgE;AAChE,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,eAAe,EAAE,CAAA;IAC9B,YAAY,EAAE,UAAU,EAAE,CAAA;CAC3B,CAAA;AAED;mDACmD;AACnD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAA;CAC7B,CAAA;AAED;sEACsE;AACtE,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB,CAAA;AAED;2EAC2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/protocol/documents.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { protocolStrategyKind, parseNodeAutomationStates, parseNodeUserActions, workflowStatusToAutomationStatus, automationErrorOf, normalizeNodeAssets, automationHoldings, parseNodeAccounts, parseNodeExchangeConfigs, accountHoldingsFromNodeState, automationResultOf, accountResultOf, actionErrorDetails, createdAutomationIdOf, createdAccountIdOf, actionDomainOf, targetAutomationIdOf, targetAccountIdsOf, actionTargetsAccount, automationStrategyRefOf, actionDisplayName, isRecord, cachedByDoc, type AutomationRunStatus, type Holding, type UserActionDomain, } from './state.js';
|
|
2
|
+
export { newUserActionId, buildAutomationConfiguration, buildCreateAutomationConfig, buildEditAutomationConfig, buildStopAutomationConfig, buildCreateStrategyConfig, buildEditStrategyConfig, buildDeleteStrategyConfig, accountAuthIdFor, exchangeConfigIdFor, accountIdFromAuthId, accountIdFromExchangeConfigId, buildCreateAccountConfig, buildEditAccountConfig, buildDeleteAccountConfig, buildRefreshAccountsConfig, buildCreateAccountAuthConfig, buildEditAccountAuthConfig, buildDeleteAccountAuthConfig, buildCreateExchangeConfigConfig, buildEditExchangeConfigConfig, buildDeleteExchangeConfigConfig, type AutomationBuildInput, } from './actions.js';
|
|
3
|
+
export * as strategy from './strategy/index.js';
|
|
4
|
+
export * from './strategy/index.js';
|
|
5
|
+
export { baseCurrencyOf } from './symbols.js';
|
|
6
|
+
export { sleep, pollDelay } from './poll.js';
|
|
7
|
+
export { type UserDataState, type AccountsState, type UserActionsDocument, type AccountTradingDocument, } from './documents.js';
|
|
8
|
+
export { runCreateAutomation, AutomationActionFailedError, AutomationTimeoutError, type ActionEmitter, type CreateAutomationInput, type CreateAutomationProgress, } from './orchestration/createAutomation.js';
|
|
9
|
+
export { encodeActionProposal, decodeActionProposal, type ActionProposal, type ProposedActionEntry, } from './proposal.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,6BAA6B,EAC7B,+BAA+B,EAC/B,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAI/C,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,sBAAsB,EACtB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,GAC9B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { protocolStrategyKind, parseNodeAutomationStates, parseNodeUserActions, workflowStatusToAutomationStatus, automationErrorOf, normalizeNodeAssets, automationHoldings, parseNodeAccounts, parseNodeExchangeConfigs, accountHoldingsFromNodeState, automationResultOf, accountResultOf, actionErrorDetails, createdAutomationIdOf, createdAccountIdOf, actionDomainOf, targetAutomationIdOf, targetAccountIdsOf, actionTargetsAccount, automationStrategyRefOf, actionDisplayName, isRecord, cachedByDoc, } from './state.js';
|
|
2
|
+
export { newUserActionId, buildAutomationConfiguration, buildCreateAutomationConfig, buildEditAutomationConfig, buildStopAutomationConfig, buildCreateStrategyConfig, buildEditStrategyConfig, buildDeleteStrategyConfig, accountAuthIdFor, exchangeConfigIdFor, accountIdFromAuthId, accountIdFromExchangeConfigId, buildCreateAccountConfig, buildEditAccountConfig, buildDeleteAccountConfig, buildRefreshAccountsConfig, buildCreateAccountAuthConfig, buildEditAccountAuthConfig, buildDeleteAccountAuthConfig, buildCreateExchangeConfigConfig, buildEditExchangeConfigConfig, buildDeleteExchangeConfigConfig, } from './actions.js';
|
|
3
|
+
export * as strategy from './strategy/index.js';
|
|
4
|
+
// Flat re-exports of every symbol the `strategy` namespace above holds — for
|
|
5
|
+
// a caller that wants `buildStrategy(...)` directly rather than
|
|
6
|
+
// `strategy.buildStrategy(...)`.
|
|
7
|
+
export * from './strategy/index.js';
|
|
8
|
+
export { baseCurrencyOf } from './symbols.js';
|
|
9
|
+
export { sleep, pollDelay } from './poll.js';
|
|
10
|
+
export { runCreateAutomation, AutomationActionFailedError, AutomationTimeoutError, } from './orchestration/createAutomation.js';
|
|
11
|
+
export { encodeActionProposal, decodeActionProposal, } from './proposal.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,QAAQ,EACR,WAAW,GAIZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,6BAA6B,EAC7B,+BAA+B,GAEhC,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,6EAA6E;AAC7E,gEAAgE;AAChE,iCAAiC;AACjC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAO5C,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,sBAAsB,GAIvB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAGrB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { UserAction, UserActionConfiguration } from '@drakkar.software/octobot-protocol';
|
|
2
|
+
import { type AutomationBuildInput } from '../actions.js';
|
|
3
|
+
/** What `runCreateAutomation` needs from its caller: a way to push one action
|
|
4
|
+
* onto the node's queue, and a way to learn the node's current view of
|
|
5
|
+
* every queued action (draining any outbox first, if the caller has one).
|
|
6
|
+
* `connectOctoBot()`'s facade wires this to a direct append + pull;
|
|
7
|
+
* `octobot-sdk`'s offline engine wires it to its outbox + CRDT store — same
|
|
8
|
+
* state machine, two very different delivery mechanisms underneath. */
|
|
9
|
+
export type ActionEmitter = {
|
|
10
|
+
/** Emit one action's wire configuration. Returns its (client-assigned) id. */
|
|
11
|
+
emit: (configuration: UserActionConfiguration) => Promise<string>;
|
|
12
|
+
/** Deliver anything not yet sent, then return the node's current view of
|
|
13
|
+
* every user action (from the latest `user-data` pull). Called once per
|
|
14
|
+
* poll tick. */
|
|
15
|
+
poll: () => Promise<UserAction[]>;
|
|
16
|
+
};
|
|
17
|
+
export type CreateAutomationInput = AutomationBuildInput;
|
|
18
|
+
export type CreateAutomationProgress = {
|
|
19
|
+
phase: 'strategy' | 'automation';
|
|
20
|
+
done: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type CreateAutomationOptions = {
|
|
23
|
+
/** Total budget across BOTH phases. Default 60_000. */
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
/** Default: the node's own confirmed cadence, min(2000 + n*1500, 8000). */
|
|
26
|
+
pollDelay?: (attempt: number) => number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
onProgress?: (p: CreateAutomationProgress) => void;
|
|
29
|
+
};
|
|
30
|
+
/** A specific action the node executed and rejected. Not retriable by
|
|
31
|
+
* resubmitting the same configuration unchanged. */
|
|
32
|
+
export declare class AutomationActionFailedError extends Error {
|
|
33
|
+
readonly phase: 'strategy' | 'automation';
|
|
34
|
+
readonly detail: string | null;
|
|
35
|
+
constructor(phase: 'strategy' | 'automation', detail: string | null);
|
|
36
|
+
}
|
|
37
|
+
/** Neither phase failed outright — the node just never confirmed within the
|
|
38
|
+
* budget. Worth a fresh `runCreateAutomation` call, not a resubmit. */
|
|
39
|
+
export declare class AutomationTimeoutError extends Error {
|
|
40
|
+
readonly phase: 'strategy' | 'automation';
|
|
41
|
+
constructor(phase: 'strategy' | 'automation');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Two-phase sequenced automation creation: emits `strategy_create`, polls the
|
|
45
|
+
* node until it confirms, then emits `automation_create` and polls until the
|
|
46
|
+
* node reports a result.
|
|
47
|
+
*
|
|
48
|
+
* This eliminates a concurrent-execution race: the node executes queued
|
|
49
|
+
* actions concurrently, and `automation_create` resolves its strategy by
|
|
50
|
+
* (id, version) — if it ran before `strategy_create` registered that
|
|
51
|
+
* strategy in the node's StrategyProvider, it would fail non-retriably with
|
|
52
|
+
* `strategy_not_found`. Sequencing guarantees the strategy exists first.
|
|
53
|
+
*
|
|
54
|
+
* Callers enforcing an account's automation cap (a product policy the node
|
|
55
|
+
* itself does not know about) must check it BEFORE calling this — it is not
|
|
56
|
+
* part of the protocol and this function does not re-derive it.
|
|
57
|
+
*/
|
|
58
|
+
export declare function runCreateAutomation(io: ActionEmitter, input: CreateAutomationInput, opts?: CreateAutomationOptions): Promise<{
|
|
59
|
+
automationId: string | null;
|
|
60
|
+
}>;
|
|
61
|
+
//# sourceMappingURL=createAutomation.d.ts.map
|