@senpi-ai/runtime 3.0.30 → 3.0.35
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 +7 -4
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +2 -7
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/decision-error-notification.d.ts +35 -0
- package/dist/actions/decision-error-notification.d.ts.map +1 -0
- package/dist/actions/decision-error-notification.js +58 -0
- package/dist/actions/decision-error-notification.js.map +1 -0
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +50 -7
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/types.d.ts +2 -0
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +6 -7
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-cli-config.d.ts +0 -17
- package/dist/cli/senpi-cli-config.d.ts.map +1 -1
- package/dist/cli/senpi-cli-config.js +0 -30
- package/dist/cli/senpi-cli-config.js.map +1 -1
- package/dist/cli/senpi-config-commands.d.ts +1 -1
- package/dist/cli/senpi-config-commands.d.ts.map +1 -1
- package/dist/cli/senpi-config-commands.js +1 -16
- package/dist/cli/senpi-config-commands.js.map +1 -1
- package/dist/constants/dsl/index.d.ts +1 -5
- package/dist/constants/dsl/index.d.ts.map +1 -1
- package/dist/constants/dsl/index.js +1 -5
- package/dist/constants/dsl/index.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +6 -0
- package/dist/dsl/engine-client/event-mapping.js.map +1 -1
- package/dist/dsl/events/build-closed-event.d.ts +1 -1
- package/dist/dsl/events/build-closed-event.js +1 -1
- package/dist/dsl/events/handlers.js +1 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +5 -3
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/notifications/format-utils.d.ts +1 -11
- package/dist/dsl/notifications/format-utils.d.ts.map +1 -1
- package/dist/dsl/notifications/format-utils.js +1 -48
- package/dist/dsl/notifications/format-utils.js.map +1 -1
- package/dist/dsl/notifications/formatter.d.ts +17 -28
- package/dist/dsl/notifications/formatter.d.ts.map +1 -1
- package/dist/dsl/notifications/formatter.js +46 -129
- package/dist/dsl/notifications/formatter.js.map +1 -1
- package/dist/dsl/notifications/index.d.ts +2 -10
- package/dist/dsl/notifications/index.d.ts.map +1 -1
- package/dist/dsl/notifications/index.js +127 -50
- package/dist/dsl/notifications/index.js.map +1 -1
- package/dist/dsl/notifications/raise-correlator.d.ts +87 -0
- package/dist/dsl/notifications/raise-correlator.d.ts.map +1 -0
- package/dist/dsl/notifications/raise-correlator.js +136 -0
- package/dist/dsl/notifications/raise-correlator.js.map +1 -0
- package/dist/dsl/notifications/stop-raise-ratchet.d.ts +76 -0
- package/dist/dsl/notifications/stop-raise-ratchet.d.ts.map +1 -0
- package/dist/dsl/notifications/stop-raise-ratchet.js +113 -0
- package/dist/dsl/notifications/stop-raise-ratchet.js.map +1 -0
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +0 -27
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/dsl/plugin/options.d.ts +3 -7
- package/dist/dsl/plugin/options.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -123
- package/dist/index.js.map +1 -1
- package/dist/prompt/session-context-seed-hook.d.ts +11 -0
- package/dist/prompt/session-context-seed-hook.d.ts.map +1 -0
- package/dist/prompt/session-context-seed-hook.js +99 -0
- package/dist/prompt/session-context-seed-hook.js.map +1 -0
- package/dist/runtime/auto-update/coordinator.d.ts +4 -5
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +18 -19
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/backend-pause-registry.d.ts +38 -0
- package/dist/runtime/backend-pause-registry.d.ts.map +1 -0
- package/dist/runtime/backend-pause-registry.js +51 -0
- package/dist/runtime/backend-pause-registry.js.map +1 -0
- package/dist/runtime/create-action-context.d.ts.map +1 -1
- package/dist/runtime/create-action-context.js +1 -0
- package/dist/runtime/create-action-context.js.map +1 -1
- package/dist/runtime/create-runtime-context.d.ts +1 -0
- package/dist/runtime/create-runtime-context.d.ts.map +1 -1
- package/dist/runtime/create-runtime-context.js +3 -0
- package/dist/runtime/create-runtime-context.js.map +1 -1
- package/dist/runtime/decision-errors.d.ts +46 -53
- package/dist/runtime/decision-errors.d.ts.map +1 -1
- package/dist/runtime/decision-errors.js +72 -111
- package/dist/runtime/decision-errors.js.map +1 -1
- package/dist/runtime/notifications.d.ts +37 -16
- package/dist/runtime/notifications.d.ts.map +1 -1
- package/dist/runtime/notifications.js +211 -67
- package/dist/runtime/notifications.js.map +1 -1
- package/dist/runtime/runtime.d.ts +16 -2
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +109 -31
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-lifecycle.d.ts +23 -9
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
- package/dist/runtime/strategy-lifecycle.js +90 -38
- package/dist/runtime/strategy-lifecycle.js.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.js +3 -3
- package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
- package/dist/runtime-api/lifecycle.d.ts +1 -1
- package/dist/runtime-api/lifecycle.js +1 -1
- package/dist/scanners/providers/client.d.ts.map +1 -1
- package/dist/scanners/providers/client.js +4 -1
- package/dist/scanners/providers/client.js.map +1 -1
- package/dist/scanners/providers/factory.d.ts.map +1 -1
- package/dist/scanners/providers/factory.js +43 -2
- package/dist/scanners/providers/factory.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +35 -0
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/scripts/run-dsl-standalone-live.d.ts +8 -6
- package/dist/scripts/run-dsl-standalone-live.d.ts.map +1 -1
- package/dist/scripts/run-dsl-standalone-live.js +26 -25
- package/dist/scripts/run-dsl-standalone-live.js.map +1 -1
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +10 -3
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/tool-errors.d.ts +30 -0
- package/dist/senpi/tool-errors.d.ts.map +1 -0
- package/dist/senpi/tool-errors.js +87 -0
- package/dist/senpi/tool-errors.js.map +1 -0
- package/dist/senpi/types.d.ts +4 -0
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/skills-manager/coordinator.d.ts +2 -2
- package/dist/skills-manager/coordinator.js +2 -2
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +21 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/types/dsl/index.d.ts +14 -1
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/notification.d.ts +102 -1
- package/dist/types/notification.d.ts.map +1 -1
- package/dist/types/notification.js +80 -1
- package/dist/types/notification.js.map +1 -1
- package/dist/types/runtime.d.ts +13 -0
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/session-context.d.ts +19 -0
- package/dist/types/session-context.d.ts.map +1 -0
- package/dist/types/session-context.js +20 -0
- package/dist/types/session-context.js.map +1 -0
- package/dist/utils/logger.d.ts +2 -18
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +2 -40
- package/dist/utils/logger.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/actions/notifications/formatter.d.ts +0 -39
- package/dist/actions/notifications/formatter.d.ts.map +0 -1
- package/dist/actions/notifications/formatter.js +0 -68
- package/dist/actions/notifications/formatter.js.map +0 -1
- package/dist/actions/notifications/index.d.ts +0 -37
- package/dist/actions/notifications/index.d.ts.map +0 -1
- package/dist/actions/notifications/index.js +0 -89
- package/dist/actions/notifications/index.js.map +0 -1
- package/dist/dsl/notifications/close-resolver.d.ts +0 -92
- package/dist/dsl/notifications/close-resolver.d.ts.map +0 -1
- package/dist/dsl/notifications/close-resolver.js +0 -309
- package/dist/dsl/notifications/close-resolver.js.map +0 -1
- package/dist/dsl/notifications/types.d.ts +0 -27
- package/dist/dsl/notifications/types.d.ts.map +0 -1
- package/dist/dsl/notifications/types.js +0 -5
- package/dist/dsl/notifications/types.js.map +0 -1
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plain-text messages for DSL lifecycle
|
|
2
|
+
* Plain-text messages for DSL lifecycle notifications.
|
|
3
3
|
*/
|
|
4
|
-
import type { DslCreatedEvent, DslTierAdvancedEvent, DslSlUpdatedEvent
|
|
5
|
-
import type {
|
|
4
|
+
import type { DslCreatedEvent, DslTierAdvancedEvent, DslSlUpdatedEvent } from "../../types/dsl/index.js";
|
|
5
|
+
import type { NotificationCopy } from "../../types/notification.js";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* DSL-activated notification: fired when the runtime attaches a trailing DSL at
|
|
8
|
+
* position open. Label-free — the DSL subscriber applies the `[strategy]` prefix
|
|
9
|
+
* (and push-title truncation) before it ships. Every value comes from the event.
|
|
10
|
+
*
|
|
11
|
+
* The title carries the position and opts out of the label: the label plus the
|
|
12
|
+
* position would not fit the 32-unit push-title budget, and the position is what
|
|
13
|
+
* a glance needs. The body still ships the label.
|
|
9
14
|
*/
|
|
10
|
-
export declare function formatDslCreated(e: DslCreatedEvent):
|
|
15
|
+
export declare function formatDslCreated(e: DslCreatedEvent): NotificationCopy;
|
|
11
16
|
/**
|
|
12
|
-
* Tier / profit-lock notification.
|
|
17
|
+
* Tier / profit-lock notification. Label-free — the DSL subscriber applies the
|
|
18
|
+
* `[strategy]` prefix (and push-title truncation) before it ships.
|
|
13
19
|
*/
|
|
14
|
-
export declare function formatDslTierAdvanced(e: DslTierAdvancedEvent):
|
|
15
|
-
export declare function formatDslSlUpdated(e: DslSlUpdatedEvent): string;
|
|
16
|
-
export declare function formatDslClosePending(e: {
|
|
17
|
-
asset: string;
|
|
18
|
-
attempt: number;
|
|
19
|
-
}): string;
|
|
20
|
-
export declare function plainEnglishCloseReason(closeReason: string): string;
|
|
21
|
-
export interface CloseEnrichment {
|
|
22
|
-
realizedPnl: number;
|
|
23
|
-
closePx: number;
|
|
24
|
-
totalFees: number;
|
|
25
|
-
}
|
|
20
|
+
export declare function formatDslTierAdvanced(e: DslTierAdvancedEvent): NotificationCopy;
|
|
26
21
|
/**
|
|
27
|
-
*
|
|
22
|
+
* Stop-raise notification. Label-free — the DSL subscriber applies the
|
|
23
|
+
* `[strategy]` prefix (and push-title truncation) before it ships.
|
|
28
24
|
*/
|
|
29
|
-
export declare function
|
|
30
|
-
/** Timeout path: no reliable exit PnL from history. */
|
|
31
|
-
export declare function formatDslClosedFallback(p: PendingCloseNotification): string;
|
|
32
|
-
export declare function formatDslDeleted(e: {
|
|
33
|
-
asset: string;
|
|
34
|
-
dex?: string;
|
|
35
|
-
}): string;
|
|
36
|
-
export declare function formatDslHeartbeat(e: DslHeartbeatEvent): string;
|
|
25
|
+
export declare function formatDslSlUpdated(e: DslSlUpdatedEvent): NotificationCopy;
|
|
37
26
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/dsl/notifications/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/dsl/notifications/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAOpE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,GAAG,gBAAgB,CAsBrE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,oBAAoB,GAAG,gBAAgB,CAgB/E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAOzE"}
|
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plain-text messages for DSL lifecycle
|
|
2
|
+
* Plain-text messages for DSL lifecycle notifications.
|
|
3
3
|
*/
|
|
4
|
-
import { fmtUsdPrice, fmtUsdPnl, fmtRoe,
|
|
5
|
-
function fmtDex(dex) {
|
|
6
|
-
return dex ? ` (${dex})` : "";
|
|
7
|
-
}
|
|
8
|
-
function fmtLeverage(leverage) {
|
|
9
|
-
const n = Number.isFinite(leverage) && leverage > 0 ? leverage : 1;
|
|
10
|
-
return `${Number.isInteger(n) ? n : n.toFixed(1)}x`;
|
|
11
|
-
}
|
|
4
|
+
import { fmtUsdPrice, fmtUsdPnl, fmtRoe, } from "./format-utils.js";
|
|
12
5
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
6
|
+
* DSL-activated notification: fired when the runtime attaches a trailing DSL at
|
|
7
|
+
* position open. Label-free — the DSL subscriber applies the `[strategy]` prefix
|
|
8
|
+
* (and push-title truncation) before it ships. Every value comes from the event.
|
|
9
|
+
*
|
|
10
|
+
* The title carries the position and opts out of the label: the label plus the
|
|
11
|
+
* position would not fit the 32-unit push-title budget, and the position is what
|
|
12
|
+
* a glance needs. The body still ships the label.
|
|
15
13
|
*/
|
|
16
14
|
export function formatDslCreated(e) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const asset = e.asset;
|
|
16
|
+
// Ticker as the app renders it; the raw symbol still drives price decimals.
|
|
17
|
+
const ticker = `$${asset}`;
|
|
18
|
+
const direction = e.direction;
|
|
19
|
+
const leverage = e.leverage;
|
|
20
|
+
// % gap between entry and the initial stop floor; abs so LONG (floor below) and
|
|
21
|
+
// SHORT (floor above) both read as a positive distance "away".
|
|
22
|
+
const distPct = Number.isFinite(e.entryPrice) && e.entryPrice !== 0
|
|
23
|
+
? Math.abs((e.entryPrice - e.floorPrice) / e.entryPrice) * 100
|
|
24
|
+
: 0;
|
|
25
|
+
const dist = fmtRoe(distPct);
|
|
26
|
+
const position = `${ticker} ${direction} ${leverage}×`;
|
|
27
|
+
return {
|
|
28
|
+
pushTitle: `DSL activated on ${position}`,
|
|
29
|
+
skipTitleLabel: true,
|
|
30
|
+
pushBody: `DSL activated on ${position}`,
|
|
31
|
+
inApp: `DSL activated on ${position} — ` +
|
|
32
|
+
`stop at ${fmtUsdPrice(e.floorPrice, asset)} (${dist} away) — trails up as the trade gains.`,
|
|
33
|
+
};
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
|
-
* Tier / profit-lock notification.
|
|
36
|
+
* Tier / profit-lock notification. Label-free — the DSL subscriber applies the
|
|
37
|
+
* `[strategy]` prefix (and push-title truncation) before it ships.
|
|
28
38
|
*/
|
|
29
39
|
export function formatDslTierAdvanced(e) {
|
|
30
|
-
const
|
|
31
|
-
const tierNum = e.tier + 1;
|
|
32
|
-
const label = `T${tierNum}`;
|
|
40
|
+
const asset = e.asset;
|
|
33
41
|
const margin = e.margin ?? 0;
|
|
34
42
|
const lockedPct = e.lockedProfitPct ?? 0;
|
|
35
43
|
const lockedUsd = margin * (lockedPct / 100);
|
|
@@ -37,114 +45,23 @@ export function formatDslTierAdvanced(e) {
|
|
|
37
45
|
const hw = e.highWaterRoe ?? 0;
|
|
38
46
|
const currentPnl = margin * (curRoe / 100);
|
|
39
47
|
const direction = e.direction ?? "LONG";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const dex = fmtDex(e.dex ?? "");
|
|
47
|
-
return `DSL SL updated: ${e.asset}${dex} — ${fmtUsdPrice(e.newSLPrice, e.asset)}`;
|
|
48
|
-
}
|
|
49
|
-
export function formatDslClosePending(e) {
|
|
50
|
-
return `DSL close pending: ${e.asset} (attempt ${e.attempt})`;
|
|
51
|
-
}
|
|
52
|
-
const CLOSE_REASON_LABEL = {
|
|
53
|
-
exchange_sl_hit: "Exchange SL hit",
|
|
54
|
-
dsl_breach: "DSL breach",
|
|
55
|
-
hard_timeout: "DSL hard timeout",
|
|
56
|
-
weak_peak_cut: "DSL weak peak cut",
|
|
57
|
-
dead_weight_cut: "DSL dead weight cut",
|
|
58
|
-
close_position_failed: "DSL close failed",
|
|
59
|
-
backend_sl_triggered: "Exchange SL hit",
|
|
60
|
-
backend_manually_closed: "Position manually closed",
|
|
61
|
-
backend_liquidated: "Position liquidated",
|
|
62
|
-
backend_adl: "Position auto-deleveraged",
|
|
63
|
-
backend_deleted: "DSL deleted",
|
|
64
|
-
backend_closed: "Position closed",
|
|
65
|
-
manual_close: "Manual close",
|
|
66
|
-
closed_externally: "Closed externally",
|
|
67
|
-
flipped: "Position flipped",
|
|
68
|
-
manual: "Manual close",
|
|
69
|
-
dsl_deleted: "DSL removed",
|
|
70
|
-
position_increased: "Position increased",
|
|
71
|
-
position_decreased: "Position decreased",
|
|
72
|
-
};
|
|
73
|
-
export function plainEnglishCloseReason(closeReason) {
|
|
74
|
-
return CLOSE_REASON_LABEL[closeReason] ?? closeReason.replace(/_/g, " ");
|
|
48
|
+
return {
|
|
49
|
+
pushTitle: "🔒 Profit locked",
|
|
50
|
+
pushBody: `DSL locked ${fmtUsdPnl(lockedUsd)} on ${asset}`,
|
|
51
|
+
inApp: `🔒 ${asset} ${direction} — DSL locked in ${fmtUsdPnl(lockedUsd)} (${fmtRoe(lockedPct)}) ` +
|
|
52
|
+
`Stop raised to ${fmtUsdPrice(e.newFloorPrice, asset)} · now ${fmtUsdPnl(currentPnl)} (${fmtRoe(curRoe)}) · peak ${fmtRoe(hw)} · still running, trailing for more`,
|
|
53
|
+
};
|
|
75
54
|
}
|
|
76
55
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* a plain-English explanation rather than a generic label.
|
|
56
|
+
* Stop-raise notification. Label-free — the DSL subscriber applies the
|
|
57
|
+
* `[strategy]` prefix (and push-title truncation) before it ships.
|
|
80
58
|
*/
|
|
81
|
-
function
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
if (closeReason === "hard_timeout") {
|
|
90
|
-
const startMs = Date.parse(p.createdAt);
|
|
91
|
-
const endMs = Date.parse(p.closedAt);
|
|
92
|
-
const hours = Number.isFinite(startMs) && Number.isFinite(endMs)
|
|
93
|
-
? Math.round((endMs - startMs) / (60 * 60 * 1000))
|
|
94
|
-
: 0;
|
|
95
|
-
const inProfit = (realizedPnl != null ? realizedPnl : p.currentROE) >= 0;
|
|
96
|
-
const suffix = inProfit ? " Closed in profit." : " Closed at a loss.";
|
|
97
|
-
return `DSL timeout at ${hours}h.${suffix}`;
|
|
98
|
-
}
|
|
99
|
-
if (closeReason === "dead_weight_cut") {
|
|
100
|
-
return "DSL cut — position stalled with no momentum.";
|
|
101
|
-
}
|
|
102
|
-
if (closeReason === "weak_peak_cut") {
|
|
103
|
-
return `DSL cut — peaked at +${(peakROE ?? 0).toFixed(1)}% ROE then faded.`;
|
|
104
|
-
}
|
|
105
|
-
return plainEnglishCloseReason(closeReason);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Full three-line close when trade history matched.
|
|
109
|
-
*/
|
|
110
|
-
export function formatDslClosedEnriched(p, x) {
|
|
111
|
-
const roePct = p.margin > 0 ? (x.realizedPnl / p.margin) * 100 : (p.currentROE ?? 0);
|
|
112
|
-
const pnlLine = `${p.asset} ${p.direction} closed — ${fmtUsdPnl(x.realizedPnl)} (${fmtRoe(roePct)})`;
|
|
113
|
-
const entryExit = `Entry ${fmtUsdPrice(p.entryPrice, p.asset)} → Exit ${fmtUsdPrice(x.closePx, p.asset)} · ${fmtLeverage(p.leverage)} · Held ${fmtDuration(p.createdAt, p.closedAt)}`;
|
|
114
|
-
const feeUsd = `$${Math.abs(x.totalFees).toFixed(2)}`;
|
|
115
|
-
const fees = `Fees: ${feeUsd} · ${buildCloseReasonText(p, x.realizedPnl)}`;
|
|
116
|
-
return `${pnlLine}\n${entryExit}\n${fees}`;
|
|
117
|
-
}
|
|
118
|
-
/** Timeout path: no reliable exit PnL from history. */
|
|
119
|
-
export function formatDslClosedFallback(p) {
|
|
120
|
-
const line1 = `${p.asset} ${p.direction} closed`;
|
|
121
|
-
const line2 = `Entry ${fmtUsdPrice(p.entryPrice, p.asset)} · ${fmtLeverage(p.leverage)} · Held ${fmtDuration(p.createdAt, p.closedAt)}`;
|
|
122
|
-
const line3 = buildCloseReasonText(p);
|
|
123
|
-
return `${line1}\n${line2}\n${line3}`;
|
|
124
|
-
}
|
|
125
|
-
export function formatDslDeleted(e) {
|
|
126
|
-
const dex = fmtDex(e.dex ?? "");
|
|
127
|
-
return `DSL deleted: ${e.asset}${dex}`;
|
|
128
|
-
}
|
|
129
|
-
function fmtElapsedOpen(mins) {
|
|
130
|
-
if (!Number.isFinite(mins) || mins < 0)
|
|
131
|
-
return "—";
|
|
132
|
-
if (mins < 60)
|
|
133
|
-
return `${Math.round(mins)}m`;
|
|
134
|
-
const h = Math.floor(mins / 60);
|
|
135
|
-
const m = Math.round(mins % 60);
|
|
136
|
-
return m > 0 ? `${h}h ${m}m` : `${h}h`;
|
|
137
|
-
}
|
|
138
|
-
export function formatDslHeartbeat(e) {
|
|
139
|
-
const dex = fmtDex(e.dex);
|
|
140
|
-
const margin = e.margin ?? 0;
|
|
141
|
-
const currentPnl = margin * (e.currentROE / 100);
|
|
142
|
-
const line1 = `${e.asset}${dex} ${e.direction} active for ${fmtElapsedOpen(e.elapsedMinutes)} — ${fmtUsdPnl(currentPnl)} (${fmtRoe(e.currentROE)})`;
|
|
143
|
-
const lockedPnl = margin * ((e.lockedProfitPct ?? 0) / 100);
|
|
144
|
-
const lockedStatus = (e.lockedProfitPct ?? 0) > 0
|
|
145
|
-
? `${fmtUsdPnl(lockedPnl)} profit locked`
|
|
146
|
-
: "No profit locked yet";
|
|
147
|
-
const line2 = `Stop at ${fmtUsdPrice(e.floorPrice, e.asset)} · ${lockedStatus}`;
|
|
148
|
-
return [line1, line2].join("\n");
|
|
59
|
+
export function formatDslSlUpdated(e) {
|
|
60
|
+
const asset = e.asset;
|
|
61
|
+
return {
|
|
62
|
+
pushTitle: "📈 Stop raised",
|
|
63
|
+
pushBody: `${asset} stop → ${fmtUsdPrice(e.newSLPrice, asset)}`,
|
|
64
|
+
inApp: `${asset} — DSL stop raised to ${fmtUsdPrice(e.newSLPrice, asset)} Locking in more of your gain.`,
|
|
65
|
+
};
|
|
149
66
|
}
|
|
150
67
|
//# sourceMappingURL=formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/dsl/notifications/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/dsl/notifications/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EACL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IACjD,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACtB,4EAA4E;IAC5E,MAAM,MAAM,GAAG,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,CAAC;IAC/B,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC;IACxC,OAAO;QACL,SAAS,EAAE,kBAAkB;QAC7B,QAAQ,EAAE,cAAc,SAAS,CAAC,SAAS,CAAC,OAAO,KAAK,EAAE;QAC1D,KAAK,EACH,MAAM,KAAK,IAAI,SAAS,oBAAoB,SAAS,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,IAAI;YAC1F,kBAAkB,WAAW,CAAC,CAAC,CAAC,aAAa,EAAE,KAAK,CAAC,UAAU,SAAS,CAAC,UAAU,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,YAAY,MAAM,CAAC,EAAE,CAAC,qCAAqC;KACrK,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAoB;IACrD,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACtB,OAAO;QACL,SAAS,EAAE,gBAAgB;QAC3B,QAAQ,EAAE,GAAG,KAAK,WAAW,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE;QAC/D,KAAK,EAAE,GAAG,KAAK,yBAAyB,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,gCAAgC;KACzG,CAAC;AACJ,CAAC"}
|
|
@@ -2,25 +2,17 @@
|
|
|
2
2
|
* Subscribes to DSL_EVENTS on the bus and forwards formatted strings to NotificationService.
|
|
3
3
|
*/
|
|
4
4
|
import type { SenpiEventBus } from "../events/index.js";
|
|
5
|
-
import type { NotificationService } from "../../types/notification.js";
|
|
6
|
-
import { type CloseNotificationResolver } from "./close-resolver.js";
|
|
7
|
-
export type { CloseNotificationResolver } from "./close-resolver.js";
|
|
5
|
+
import type { NotificationPayload, NotificationService } from "../../types/notification.js";
|
|
8
6
|
export interface DslNotificationOptions {
|
|
9
|
-
/** Also notify when the exchange SL price is updated (can fire every tick; default: false). */
|
|
10
|
-
notifySlUpdates?: boolean;
|
|
11
7
|
/**
|
|
12
8
|
* Recipe name to prefix every notification message (e.g. "[my-recipe] DSL started: ...").
|
|
13
9
|
* When omitted, no prefix is added.
|
|
14
10
|
*/
|
|
15
11
|
strategyName?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Resolves deferred close lines from trade history; when set, `dsl.closed` is enqueued instead of
|
|
18
|
-
* notifying immediately.
|
|
19
|
-
*/
|
|
20
|
-
closeResolver?: CloseNotificationResolver | null;
|
|
21
12
|
}
|
|
22
13
|
export interface DslNotificationSubscriber {
|
|
23
14
|
dispose(): void;
|
|
24
15
|
}
|
|
16
|
+
export declare function safeNotify(notifier: NotificationService, input: string | NotificationPayload): void;
|
|
25
17
|
export declare function createDslNotificationSubscriber(bus: SenpiEventBus, notifier: NotificationService, options?: DslNotificationOptions): DslNotificationSubscriber;
|
|
26
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dsl/notifications/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dsl/notifications/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAoB,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA+B9G,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,MAAM,GAAG,mBAAmB,GAClC,IAAI,CAWN;AAwDD,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,yBAAyB,CAuG3B"}
|
|
@@ -1,22 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Subscribes to DSL_EVENTS on the bus and forwards formatted strings to NotificationService.
|
|
3
3
|
*/
|
|
4
|
+
import { applyMessagePrefix, labelPrefix } from "../../types/notification.js";
|
|
4
5
|
import { DSL_EVENTS } from "../../constants/dsl/index.js";
|
|
5
6
|
import { createLogger } from "../../utils/logger.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import { formatDslCreated, formatDslTierAdvanced, formatDslSlUpdated, } from "./formatter.js";
|
|
9
|
+
import { RaiseCorrelator, raiseKey } from "./raise-correlator.js";
|
|
10
|
+
import { StopRaiseRatchet } from "./stop-raise-ratchet.js";
|
|
11
|
+
/**
|
|
12
|
+
* Baseline key for the favorable-floor ratchet. Prefer the instance-scoped
|
|
13
|
+
* `correlationId` (fresh per DSL rebuild → auto-resets the baseline); fall back
|
|
14
|
+
* to the cross-flow position key so a missing id never collapses distinct
|
|
15
|
+
* positions onto one bucket.
|
|
16
|
+
*/
|
|
17
|
+
function ratchetKey(ev) {
|
|
18
|
+
if (ev.correlationId != null && ev.correlationId !== "")
|
|
19
|
+
return ev.correlationId;
|
|
20
|
+
return raiseKey(ev);
|
|
21
|
+
}
|
|
8
22
|
const logger = createLogger("[senpi-core][dsl-notifications]");
|
|
9
|
-
function safeNotify(notifier,
|
|
23
|
+
export function safeNotify(notifier, input) {
|
|
10
24
|
try {
|
|
11
|
-
const result = notifier.notify(
|
|
25
|
+
const result = notifier.notify(input);
|
|
12
26
|
if (result != null && typeof result.then === "function") {
|
|
13
|
-
void result.catch((err) => logger.warn("[dsl-notifications] notify rejected", { err,
|
|
27
|
+
void result.catch((err) => logger.warn("[dsl-notifications] notify rejected", { err, input }));
|
|
14
28
|
}
|
|
15
29
|
}
|
|
16
30
|
catch (err) {
|
|
17
|
-
logger.warn("[dsl-notifications] notify threw synchronously", { err,
|
|
31
|
+
logger.warn("[dsl-notifications] notify threw synchronously", { err, input });
|
|
18
32
|
}
|
|
19
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds the notification payload for a runtime-emitted trailing-stop event
|
|
36
|
+
* (profit-lock / stop-raise). Because the runtime holds the strategy context for
|
|
37
|
+
* the position, these open an agent chat by category alone — no order id and no
|
|
38
|
+
* lifecycle reason is consulted. The generic seed lives inside `context` (the
|
|
39
|
+
* notification service persists `context` verbatim and reads `context.contextText`
|
|
40
|
+
* from it; a sibling on the payload root is dropped before the wire).
|
|
41
|
+
*
|
|
42
|
+
* Fail-safe: without a strategy address the chat has nothing to key on (a dead
|
|
43
|
+
* tap), so we WARN and ship the message non-openable rather than an empty seed.
|
|
44
|
+
*/
|
|
45
|
+
function buildOpenablePayload(copy, subtype, address, createdAt, asset, dex) {
|
|
46
|
+
const message = copy.inApp;
|
|
47
|
+
// A blank (empty or whitespace-only) address is as unusable a chat key as a
|
|
48
|
+
// missing one, so it takes the same non-openable path.
|
|
49
|
+
if (!address || address.trim() === "") {
|
|
50
|
+
logger.warn("[dsl-notifications] openable notification missing strategy address; delivering non-openable", {
|
|
51
|
+
subtype,
|
|
52
|
+
});
|
|
53
|
+
return { message, canOpenAgentChat: false, subtype, copy };
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
message,
|
|
57
|
+
canOpenAgentChat: true,
|
|
58
|
+
subtype,
|
|
59
|
+
copy,
|
|
60
|
+
context: {
|
|
61
|
+
notificationId: randomUUID(),
|
|
62
|
+
subtype,
|
|
63
|
+
createdAt,
|
|
64
|
+
address,
|
|
65
|
+
asset,
|
|
66
|
+
dex,
|
|
67
|
+
contextText: message,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
20
71
|
/** Ensures formatter + notify never throw back into `bus.emit` (would break DSL callers). */
|
|
21
72
|
function runNotificationHandler(fn) {
|
|
22
73
|
try {
|
|
@@ -27,75 +78,101 @@ function runNotificationHandler(fn) {
|
|
|
27
78
|
}
|
|
28
79
|
}
|
|
29
80
|
export function createDslNotificationSubscriber(bus, notifier, options) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function notify(message) {
|
|
34
|
-
safeNotify(notifier, `${prefix}${message}`);
|
|
81
|
+
const prefix = labelPrefix(options?.strategyName);
|
|
82
|
+
function notify(input) {
|
|
83
|
+
safeNotify(notifier, applyMessagePrefix(input, prefix));
|
|
35
84
|
}
|
|
85
|
+
// PF-2: a single DSL raise must yield EITHER "Profit locked" OR "Stop raised",
|
|
86
|
+
// never both. When a tier advance locks profit (lockedProfitPct > 0) it emits
|
|
87
|
+
// Profit locked and records intent here; the paired SL_UPDATED for the same
|
|
88
|
+
// raise is then suppressed. A tier that locks nothing (<= 0) emits no
|
|
89
|
+
// Profit-locked message and lets its stop-raise through. See RaiseCorrelator.
|
|
90
|
+
const correlator = new RaiseCorrelator();
|
|
91
|
+
// Gate "Stop raised" to GENUINE raises only. Keeps, per position instance, the
|
|
92
|
+
// most-favorable exchange-SL floor seen; fires only when a new floor beats it
|
|
93
|
+
// in the favorable direction. Suppresses the initial placement and every
|
|
94
|
+
// non-raise SL_UPDATED (tier-reset / lock_hw_pct retreat / backend re-anchor).
|
|
95
|
+
// Sits alongside the PF-2 correlator; the two gates are independent (this one
|
|
96
|
+
// is additional).
|
|
97
|
+
const stopRaiseRatchet = new StopRaiseRatchet();
|
|
98
|
+
// DSL attached at position open → "DSL activated". Gated to fresh opens only:
|
|
99
|
+
// resize/flip/rebuild (position_increased/decreased/flipped/adopted) re-emit
|
|
100
|
+
// dsl.created for bookkeeping but must not re-announce activation.
|
|
36
101
|
const onCreated = (e) => {
|
|
37
102
|
runNotificationHandler(() => {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
103
|
+
const ev = e;
|
|
104
|
+
if (ev.triggerReason !== "position_opened") {
|
|
105
|
+
logger.debug("[dsl-notifications] dsl.created ignored: not a fresh open", {
|
|
106
|
+
asset: ev.asset,
|
|
107
|
+
triggerReason: ev.triggerReason,
|
|
108
|
+
});
|
|
40
109
|
return;
|
|
41
|
-
|
|
110
|
+
}
|
|
111
|
+
const copy = formatDslCreated(ev);
|
|
112
|
+
notify(buildOpenablePayload(copy, "DSL_ACTIVATED", ev.address, ev.timestamp, ev.asset, ev.dex));
|
|
42
113
|
});
|
|
43
114
|
};
|
|
44
115
|
const onTierAdvanced = (e) => {
|
|
45
116
|
runNotificationHandler(() => {
|
|
46
|
-
|
|
117
|
+
const ev = e;
|
|
118
|
+
const key = raiseKey(ev);
|
|
119
|
+
// lockedUSD > 0 ⟺ lockedProfitPct > 0 (lockedUSD = margin * pct/100, margin >= 0).
|
|
120
|
+
if ((ev.lockedProfitPct ?? 0) > 0) {
|
|
121
|
+
correlator.recordProfitLock(key, ev.timestamp);
|
|
122
|
+
const copy = formatDslTierAdvanced(ev);
|
|
123
|
+
notify(buildOpenablePayload(copy, "DSL_PROFIT_LOCK", ev.address, ev.timestamp, ev.asset, ev.dex));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Else branch: nothing locked ("+$0.00"). Suppress the Profit-locked
|
|
127
|
+
// message and clear any stale marker so the paired stop-raise emits.
|
|
128
|
+
correlator.clear(key);
|
|
129
|
+
logger.debug("[dsl-notifications] tier advance locked no profit; deferring to stop-raise", {
|
|
130
|
+
asset: ev.asset,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
47
133
|
});
|
|
48
134
|
};
|
|
49
135
|
const onSlUpdated = (e) => {
|
|
50
|
-
if (!notifySlUpdates)
|
|
51
|
-
return;
|
|
52
|
-
runNotificationHandler(() => {
|
|
53
|
-
notify(formatDslSlUpdated(e));
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const onClosePending = (e) => {
|
|
57
|
-
runNotificationHandler(() => {
|
|
58
|
-
notify(formatDslClosePending(e));
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const onClosed = (e) => {
|
|
62
136
|
runNotificationHandler(() => {
|
|
63
137
|
const ev = e;
|
|
64
|
-
|
|
65
|
-
|
|
138
|
+
// Ratchet the per-instance baseline FIRST — unconditionally, before any
|
|
139
|
+
// suppression — so a correlator-suppressed profit-lock still advances the
|
|
140
|
+
// most-favorable floor. `isGenuineRaise` is judged against the PRIOR
|
|
141
|
+
// baseline (before this advance).
|
|
142
|
+
const isGenuineRaise = stopRaiseRatchet.evaluate(ratchetKey(ev), ev.newSLPrice, ev.direction);
|
|
143
|
+
if (correlator.shouldSuppressStopRaise(raiseKey(ev), ev.timestamp)) {
|
|
144
|
+
logger.debug("[dsl-notifications] stop-raise suppressed: same raise already sent Profit locked", {
|
|
145
|
+
asset: ev.asset,
|
|
146
|
+
});
|
|
66
147
|
return;
|
|
67
148
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
notify(formatDslHeartbeat(e));
|
|
149
|
+
if (!isGenuineRaise) {
|
|
150
|
+
logger.debug("[dsl-notifications] stop-raise suppressed: placement or non-raise SL_UPDATED", {
|
|
151
|
+
asset: ev.asset,
|
|
152
|
+
newSLPrice: ev.newSLPrice,
|
|
153
|
+
direction: ev.direction,
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const copy = formatDslSlUpdated(ev);
|
|
158
|
+
// The SL-updated event carries no book, so the seed omits `dex`.
|
|
159
|
+
notify(buildOpenablePayload(copy, "DSL_STOP_RAISE", ev.address, ev.timestamp, ev.asset));
|
|
80
160
|
});
|
|
81
161
|
};
|
|
162
|
+
// DSL_EVENTS.DELETED and DSL_EVENTS.HEARTBEAT are intentionally not
|
|
163
|
+
// subscribed here: both were pure lifecycle/periodic pings with no
|
|
164
|
+
// notification subtype (unroutable to a preference bucket). The bus events
|
|
165
|
+
// themselves still fire for other consumers (e.g. dev/telemetry logging in
|
|
166
|
+
// src/scripts/run-dsl-standalone-*.ts); only the notify() forwarding was
|
|
167
|
+
// removed.
|
|
82
168
|
bus.on(DSL_EVENTS.CREATED, onCreated);
|
|
83
169
|
bus.on(DSL_EVENTS.TIER_ADVANCED, onTierAdvanced);
|
|
84
170
|
bus.on(DSL_EVENTS.SL_UPDATED, onSlUpdated);
|
|
85
|
-
bus.on(DSL_EVENTS.CLOSE_PENDING, onClosePending);
|
|
86
|
-
bus.on(DSL_EVENTS.CLOSED, onClosed);
|
|
87
|
-
bus.on(DSL_EVENTS.DELETED, onDeleted);
|
|
88
|
-
bus.on(DSL_EVENTS.HEARTBEAT, onHeartbeat);
|
|
89
171
|
return {
|
|
90
172
|
dispose() {
|
|
91
173
|
bus.off(DSL_EVENTS.CREATED, onCreated);
|
|
92
174
|
bus.off(DSL_EVENTS.TIER_ADVANCED, onTierAdvanced);
|
|
93
175
|
bus.off(DSL_EVENTS.SL_UPDATED, onSlUpdated);
|
|
94
|
-
bus.off(DSL_EVENTS.CLOSE_PENDING, onClosePending);
|
|
95
|
-
bus.off(DSL_EVENTS.CLOSED, onClosed);
|
|
96
|
-
bus.off(DSL_EVENTS.DELETED, onDeleted);
|
|
97
|
-
bus.off(DSL_EVENTS.HEARTBEAT, onHeartbeat);
|
|
98
|
-
closeResolver?.stop();
|
|
99
176
|
},
|
|
100
177
|
};
|
|
101
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dsl/notifications/index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"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