@senpi/runtime 3.0.59 → 3.0.63
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 +73 -2
- package/dist/actions/decision-engine.d.ts +0 -2
- package/dist/actions/decision-engine.d.ts.map +1 -1
- package/dist/actions/decision-engine.js +1 -79
- package/dist/actions/decision-engine.js.map +1 -1
- package/dist/cli/deploy-render.d.ts +91 -0
- package/dist/cli/deploy-render.d.ts.map +1 -0
- package/dist/cli/deploy-render.js +216 -0
- package/dist/cli/deploy-render.js.map +1 -0
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +78 -6
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts +6 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +244 -8
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/cli/validate-command.d.ts.map +1 -1
- package/dist/cli/validate-command.js +32 -1
- package/dist/cli/validate-command.js.map +1 -1
- package/dist/deploy/deadlines.d.ts +47 -0
- package/dist/deploy/deadlines.d.ts.map +1 -0
- package/dist/deploy/deadlines.js +56 -0
- package/dist/deploy/deadlines.js.map +1 -0
- package/dist/deploy/error-text.d.ts +25 -0
- package/dist/deploy/error-text.d.ts.map +1 -0
- package/dist/deploy/error-text.js +42 -0
- package/dist/deploy/error-text.js.map +1 -0
- package/dist/deploy/funding.d.ts +87 -0
- package/dist/deploy/funding.d.ts.map +1 -0
- package/dist/deploy/funding.js +229 -0
- package/dist/deploy/funding.js.map +1 -0
- package/dist/deploy/install-gate-runner.d.ts +12 -0
- package/dist/deploy/install-gate-runner.d.ts.map +1 -0
- package/dist/deploy/install-gate-runner.js +17 -0
- package/dist/deploy/install-gate-runner.js.map +1 -0
- package/dist/deploy/job.d.ts +199 -0
- package/dist/deploy/job.d.ts.map +1 -0
- package/dist/deploy/job.js +463 -0
- package/dist/deploy/job.js.map +1 -0
- package/dist/deploy/min-budget.d.ts +68 -0
- package/dist/deploy/min-budget.d.ts.map +1 -0
- package/dist/deploy/min-budget.js +297 -0
- package/dist/deploy/min-budget.js.map +1 -0
- package/dist/deploy/orchestrator.d.ts +305 -0
- package/dist/deploy/orchestrator.d.ts.map +1 -0
- package/dist/deploy/orchestrator.js +2910 -0
- package/dist/deploy/orchestrator.js.map +1 -0
- package/dist/deploy/package.d.ts +130 -0
- package/dist/deploy/package.d.ts.map +1 -0
- package/dist/deploy/package.js +351 -0
- package/dist/deploy/package.js.map +1 -0
- package/dist/deploy/proof-gate.d.ts +82 -0
- package/dist/deploy/proof-gate.d.ts.map +1 -0
- package/dist/deploy/proof-gate.js +269 -0
- package/dist/deploy/proof-gate.js.map +1 -0
- package/dist/deploy/python-float.d.ts +34 -0
- package/dist/deploy/python-float.d.ts.map +1 -0
- package/dist/deploy/python-float.js +46 -0
- package/dist/deploy/python-float.js.map +1 -0
- package/dist/deploy/recheck-commands.d.ts +50 -0
- package/dist/deploy/recheck-commands.d.ts.map +1 -0
- package/dist/deploy/recheck-commands.js +59 -0
- package/dist/deploy/recheck-commands.js.map +1 -0
- package/dist/deploy/register.d.ts +99 -0
- package/dist/deploy/register.d.ts.map +1 -0
- package/dist/deploy/register.js +689 -0
- package/dist/deploy/register.js.map +1 -0
- package/dist/deploy/taxonomy.d.ts +24 -0
- package/dist/deploy/taxonomy.d.ts.map +1 -0
- package/dist/deploy/taxonomy.js +31 -0
- package/dist/deploy/taxonomy.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +244 -132
- package/dist/index.js.map +1 -1
- package/dist/runtime/strategy-registry.d.ts +8 -0
- package/dist/runtime/strategy-registry.d.ts.map +1 -1
- package/dist/runtime/strategy-registry.js +14 -1
- package/dist/runtime/strategy-registry.js.map +1 -1
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +7 -4
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/scanners/implementations/market-regime.d.ts +1 -1
- package/dist/senpi/client.d.ts +58 -4
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +192 -15
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/strategy-status.d.ts +32 -0
- package/dist/senpi/strategy-status.d.ts.map +1 -0
- package/dist/senpi/strategy-status.js +70 -0
- package/dist/senpi/strategy-status.js.map +1 -0
- package/dist/senpi/types.d.ts +47 -3
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/skills-manager/manifest.js +1 -1
- package/dist/skills-manager/skills-manifest.json +1 -1
- package/dist/telemetry/metrics.d.ts +23 -0
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +65 -0
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/types/strategy.d.ts +9 -1
- package/dist/types/strategy.d.ts.map +1 -1
- package/dist/universe/package-universe.d.ts +97 -0
- package/dist/universe/package-universe.d.ts.map +1 -0
- package/dist/universe/package-universe.js +275 -0
- package/dist/universe/package-universe.js.map +1 -0
- package/dist/validate/codes.d.ts +20 -0
- package/dist/validate/codes.d.ts.map +1 -1
- package/dist/validate/codes.js +36 -0
- package/dist/validate/codes.js.map +1 -1
- package/dist/validate/import-stage.js +5 -5
- package/dist/validate/import-stage.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/install-gate.d.ts.map +1 -1
- package/dist/validate/install-gate.js +10 -2
- package/dist/validate/install-gate.js.map +1 -1
- package/dist/validate/live-instruments.d.ts +44 -0
- package/dist/validate/live-instruments.d.ts.map +1 -0
- package/dist/validate/live-instruments.js +71 -0
- package/dist/validate/live-instruments.js.map +1 -0
- package/dist/validate/live-stage.js +5 -5
- package/dist/validate/live-stage.js.map +1 -1
- package/dist/validate/proof.d.ts +11 -1
- package/dist/validate/proof.d.ts.map +1 -1
- package/dist/validate/proof.js +7 -6
- package/dist/validate/proof.js.map +1 -1
- package/dist/validate/recipe-checks.d.ts.map +1 -1
- package/dist/validate/recipe-checks.js +6 -4
- package/dist/validate/recipe-checks.js.map +1 -1
- package/dist/validate/run.d.ts +5 -0
- package/dist/validate/run.d.ts.map +1 -1
- package/dist/validate/run.js +10 -1
- package/dist/validate/run.js.map +1 -1
- package/dist/validate/target.d.ts +41 -0
- package/dist/validate/target.d.ts.map +1 -1
- package/dist/validate/target.js +192 -16
- package/dist/validate/target.js.map +1 -1
- package/dist/validate/universe-stage.d.ts +71 -0
- package/dist/validate/universe-stage.d.ts.map +1 -0
- package/dist/validate/universe-stage.js +183 -0
- package/dist/validate/universe-stage.js.map +1 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/runtime/managed-wallet-guard.d.ts +0 -47
- package/dist/runtime/managed-wallet-guard.d.ts.map +0 -1
- package/dist/runtime/managed-wallet-guard.js +0 -106
- package/dist/runtime/managed-wallet-guard.js.map +0 -1
- package/dist/runtime/protection-nudge.d.ts +0 -67
- package/dist/runtime/protection-nudge.d.ts.map +0 -1
- package/dist/runtime/protection-nudge.js +0 -244
- package/dist/runtime/protection-nudge.js.map +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Managed-wallet hard block: a `before_tool_call` hook that vetoes agent-issued
|
|
3
|
-
* `create_position` calls targeting a wallet an installed trading runtime
|
|
4
|
-
* manages — the runtime's DSL treats a manually-opened position as foreign and
|
|
5
|
-
* flattens it.
|
|
6
|
-
*
|
|
7
|
-
* The runtime's own trading is direct HTTP from the plugin and never enters the
|
|
8
|
-
* agent tool loop, so this hook cannot affect autonomous execution.
|
|
9
|
-
*/
|
|
10
|
-
import type { Logger } from "../utils/logger.js";
|
|
11
|
-
export interface ManagedWalletGuardOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Resolve the state dir holding `installed_runtimes.json` — must be the
|
|
14
|
-
* plugin's resolved base dir (the one the runtime CRUD path writes), not the
|
|
15
|
-
* raw openclaw stateDir.
|
|
16
|
-
*/
|
|
17
|
-
resolveStateDir: () => string;
|
|
18
|
-
/**
|
|
19
|
-
* Wallets currently managed by live runtime handles, whose wallet is parsed
|
|
20
|
-
* from the YAML at start. Covers registry entries with a missing wallet
|
|
21
|
-
* (pre-2026-03-26 installs migrate without one) or a stale wallet (on-disk
|
|
22
|
-
* YAML edited after a path-based install).
|
|
23
|
-
*/
|
|
24
|
-
getLiveWallets?: () => Iterable<{
|
|
25
|
-
id: string;
|
|
26
|
-
wallet: string;
|
|
27
|
-
}>;
|
|
28
|
-
logger: Logger;
|
|
29
|
-
}
|
|
30
|
-
/** Veto shape understood by OpenClaw's before_tool_call dispatcher. */
|
|
31
|
-
export interface ManagedWalletGuardBlock {
|
|
32
|
-
block: true;
|
|
33
|
-
blockReason: string;
|
|
34
|
-
}
|
|
35
|
-
export type ManagedWalletGuardHandler = (event: unknown) => Promise<ManagedWalletGuardBlock | undefined>;
|
|
36
|
-
/**
|
|
37
|
-
* Reduce a tool name to the fragment after its last `__` (bare names pass
|
|
38
|
-
* through). Exported so sibling hooks (e.g. the protection gate/nudge) match
|
|
39
|
-
* the bare and MCP-prefixed forms identically instead of re-deriving it.
|
|
40
|
-
*/
|
|
41
|
-
export declare function baseToolName(name: string): string;
|
|
42
|
-
/**
|
|
43
|
-
* Build the `before_tool_call` handler. The hook fires on EVERY tool call, so
|
|
44
|
-
* the non-gated fast path is a string check only — no file I/O.
|
|
45
|
-
*/
|
|
46
|
-
export declare function createManagedWalletGuard(options: ManagedWalletGuardOptions): ManagedWalletGuardHandler;
|
|
47
|
-
//# sourceMappingURL=managed-wallet-guard.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-wallet-guard.d.ts","sourceRoot":"","sources":["../../src/runtime/managed-wallet-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAYjD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,eAAe,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,QAAQ,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,yBAAyB,GAAG,CACtC,KAAK,EAAE,OAAO,KACX,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAsBD;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,yBAAyB,CAgE3B"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Managed-wallet hard block: a `before_tool_call` hook that vetoes agent-issued
|
|
3
|
-
* `create_position` calls targeting a wallet an installed trading runtime
|
|
4
|
-
* manages — the runtime's DSL treats a manually-opened position as foreign and
|
|
5
|
-
* flattens it.
|
|
6
|
-
*
|
|
7
|
-
* The runtime's own trading is direct HTTP from the plugin and never enters the
|
|
8
|
-
* agent tool loop, so this hook cannot affect autonomous execution.
|
|
9
|
-
*/
|
|
10
|
-
import { readRegistry } from "./strategy-registry.js";
|
|
11
|
-
/**
|
|
12
|
-
* Matched by base name (the fragment after the last `__`) so both the bare and
|
|
13
|
-
* MCP-prefixed (`<server>__create_position`) forms are covered.
|
|
14
|
-
*/
|
|
15
|
-
const GATED_TOOLS = new Set(["create_position"]);
|
|
16
|
-
/** The MCP tool-name namespace separator OpenClaw stamps: `<server>__<tool>`. */
|
|
17
|
-
const TOOL_NAME_SEPARATOR = "__";
|
|
18
|
-
/**
|
|
19
|
-
* Reduce a tool name to the fragment after its last `__` (bare names pass
|
|
20
|
-
* through). Exported so sibling hooks (e.g. the protection gate/nudge) match
|
|
21
|
-
* the bare and MCP-prefixed forms identically instead of re-deriving it.
|
|
22
|
-
*/
|
|
23
|
-
export function baseToolName(name) {
|
|
24
|
-
const idx = name.lastIndexOf(TOOL_NAME_SEPARATOR);
|
|
25
|
-
return idx >= 0 ? name.slice(idx + TOOL_NAME_SEPARATOR.length) : name;
|
|
26
|
-
}
|
|
27
|
-
/** True when the (lowercased) tool name is one of the gated position tools. */
|
|
28
|
-
function isGatedTool(toolName) {
|
|
29
|
-
const lower = toolName.toLowerCase();
|
|
30
|
-
return GATED_TOOLS.has(lower) || GATED_TOOLS.has(baseToolName(lower));
|
|
31
|
-
}
|
|
32
|
-
function buildBlockReason(wallet, runtimeId) {
|
|
33
|
-
return [
|
|
34
|
-
`Blocked ${wallet}: this wallet is managed by an installed trading runtime (${runtimeId}); ` +
|
|
35
|
-
`its DSL will treat a manually-opened position as foreign and flatten it — the trade is ` +
|
|
36
|
-
`doomed and will lose the round-trip.`,
|
|
37
|
-
`Do NOT retry this order into this wallet.`,
|
|
38
|
-
`Instead: open one-off positions in a wallet with NO installed runtime — use an existing ` +
|
|
39
|
-
`runtime-free strategy wallet, or create one with strategy_create_custom_strategy ` +
|
|
40
|
-
`(positions may be empty) and fund it with strategy_top_up. Flat SL/TP and ` +
|
|
41
|
-
`ratchet_stop_add trailing protection work there.`,
|
|
42
|
-
`To trade under this strategy, edit and redeploy its runtime.`,
|
|
43
|
-
].join(" ");
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Build the `before_tool_call` handler. The hook fires on EVERY tool call, so
|
|
47
|
-
* the non-gated fast path is a string check only — no file I/O.
|
|
48
|
-
*/
|
|
49
|
-
export function createManagedWalletGuard(options) {
|
|
50
|
-
const { resolveStateDir, getLiveWallets, logger } = options;
|
|
51
|
-
return async (event) => {
|
|
52
|
-
const ev = (event ?? {});
|
|
53
|
-
const toolName = typeof ev.toolName === "string" ? ev.toolName : "";
|
|
54
|
-
if (!toolName || !isGatedTool(toolName)) {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
const params = ev.params;
|
|
58
|
-
const wallet = params && typeof params === "object"
|
|
59
|
-
? params.strategyWalletAddress
|
|
60
|
-
: undefined;
|
|
61
|
-
// Absent/non-string wallet: allow through — the MCP server's schema owns that error.
|
|
62
|
-
if (typeof wallet !== "string" || wallet.length === 0) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const normalizedWallet = wallet.toLowerCase();
|
|
66
|
-
let match;
|
|
67
|
-
try {
|
|
68
|
-
// Live handles first: no file I/O, and their wallet comes from the parsed
|
|
69
|
-
// YAML, so they catch runtimes the registry's wallet field misses.
|
|
70
|
-
if (getLiveWallets) {
|
|
71
|
-
for (const live of getLiveWallets()) {
|
|
72
|
-
if (live.wallet && live.wallet.toLowerCase() === normalizedWallet) {
|
|
73
|
-
match = live;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (!match) {
|
|
79
|
-
const registry = await readRegistry(resolveStateDir());
|
|
80
|
-
// Block on ANY registered runtime for this wallet, running or stopped:
|
|
81
|
-
// a stopped runtime still owns the wallet's DSL config and can resume.
|
|
82
|
-
match = registry.runtimes.find((entry) => typeof entry.wallet === "string" && entry.wallet.toLowerCase() === normalizedWallet);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
// Fail open: a lookup failure must not block a legitimate trade. (A
|
|
87
|
-
// throw from this handler would fail closed — the host blocks on hook
|
|
88
|
-
// errors — so everything after the fast path stays inside this try.)
|
|
89
|
-
logger.warn("[managed-wallet-guard] managed-wallet lookup failed; allowing tool call", err, {
|
|
90
|
-
toolName,
|
|
91
|
-
wallet: normalizedWallet,
|
|
92
|
-
});
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
if (!match) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
logger.warn("[managed-wallet-guard] blocked position tool on runtime-managed wallet", {
|
|
99
|
-
toolName,
|
|
100
|
-
wallet: normalizedWallet,
|
|
101
|
-
runtimeId: match.id,
|
|
102
|
-
});
|
|
103
|
-
return { block: true, blockReason: buildBlockReason(wallet, match.id) };
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=managed-wallet-guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-wallet-guard.js","sourceRoot":"","sources":["../../src/runtime/managed-wallet-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAEjD,iFAAiF;AACjF,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAsCjC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAClD,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC;AAED,+EAA+E;AAC/E,SAAS,WAAW,CAAC,QAAgB;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,SAAiB;IACzD,OAAO;QACL,WAAW,MA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AI,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,gBAAgB,EAAE,CAAC;wBAClE,KAAK,GAAG,IAAI,CAAC;wBACb,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;gBACvD,uEAAuE;gBACvE,uEAAuE;gBACvE,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAC5B,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,gBAAgB,CACtF,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,oEAAoE;YACpE,sEAAsE;YACtE,qEAAqE;YACrE,MAAM,CAAC,IAAI,CAAC,yEAAyE,EAAE,GAAG,EAAE;gBAC1F,QAAQ;gBACR,MAAM,EAAE,gBAAgB;aACzB,CAAC,CAAC;YACH,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,wEAAwE,EAAE;YACpF,QAAQ;YACR,MAAM,EAAE,gBAAgB;YACxB,SAAS,EAAE,KAAK,CAAC,EAAE;SACpB,CAAC,CAAC;QACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;IAC1E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manual-trade protection: a `before_tool_call` gate plus a
|
|
3
|
-
* `tool_result_persist` nudge for agent-issued position tools on non-runtime
|
|
4
|
-
* (manual) wallets — the only wallets where `create_position` succeeds, since
|
|
5
|
-
* runtime-managed wallets are vetoed upstream by the managed-wallet guard.
|
|
6
|
-
*
|
|
7
|
-
* Gate (veto-until-protected): a manual `create_position` must carry a stop
|
|
8
|
-
* loss on every order, or an explicit top-level `protection: "none"` marker
|
|
9
|
-
* showing the agent means it. `edit_position` is gated narrowly — only an
|
|
10
|
-
* explicit stop-loss cancel is blocked, because the hook cannot see current
|
|
11
|
-
* server-side state and must not demand a stop on every edit.
|
|
12
|
-
*
|
|
13
|
-
* Nudge: after a successful `create_position`, a message is appended to the
|
|
14
|
-
* tool result telling the agent what protection the order carries, to attach
|
|
15
|
-
* `ratchet_stop_add` (server-side trailing protection that takes over driving
|
|
16
|
-
* the stop) unless the user opted out, and to report active protection to the
|
|
17
|
-
* user and offer to adjust it.
|
|
18
|
-
*
|
|
19
|
-
* The `protection` marker is stripped harmlessly by the MCP server's zod schema
|
|
20
|
-
* (plain `z.object`, no `.strict()`/`.passthrough()`), so it is visible to this
|
|
21
|
-
* hook but never reaches execution.
|
|
22
|
-
*/
|
|
23
|
-
import type { Logger } from "../utils/logger.js";
|
|
24
|
-
/**
|
|
25
|
-
* Correlates the gate and the nudge across the two hook events. The
|
|
26
|
-
* `tool_result_persist` event carries tool identity (toolName/toolCallId) and
|
|
27
|
-
* the result, but NOT the call params — so the gate (which sees params) stashes
|
|
28
|
-
* the computed protection summary keyed by toolCallId and the nudge reads it
|
|
29
|
-
* back. Bounded: a `create_position` the gate allowed but whose result is never
|
|
30
|
-
* persisted (an aborted turn) would otherwise leak an entry forever.
|
|
31
|
-
*/
|
|
32
|
-
export interface ProtectionSummaryCapture {
|
|
33
|
-
record(toolCallId: string, summary: string): void;
|
|
34
|
-
take(toolCallId: string): string | undefined;
|
|
35
|
-
}
|
|
36
|
-
export declare function createProtectionSummaryCapture(maxEntries?: number): ProtectionSummaryCapture;
|
|
37
|
-
export interface ProtectionGateOptions {
|
|
38
|
-
logger: Logger;
|
|
39
|
-
capture?: ProtectionSummaryCapture;
|
|
40
|
-
}
|
|
41
|
-
export interface ProtectionNudgeOptions {
|
|
42
|
-
logger: Logger;
|
|
43
|
-
capture?: ProtectionSummaryCapture;
|
|
44
|
-
}
|
|
45
|
-
/** Veto shape understood by OpenClaw's before_tool_call dispatcher. */
|
|
46
|
-
export interface ProtectionGateBlock {
|
|
47
|
-
block: true;
|
|
48
|
-
blockReason: string;
|
|
49
|
-
}
|
|
50
|
-
/** Result shape understood by OpenClaw's tool_result_persist dispatcher. */
|
|
51
|
-
export interface ProtectionNudgeResult {
|
|
52
|
-
message: Record<string, unknown>;
|
|
53
|
-
}
|
|
54
|
-
export type ProtectionGateHandler = (event: unknown) => Promise<ProtectionGateBlock | undefined>;
|
|
55
|
-
export type ProtectionNudgeHandler = (event: unknown) => ProtectionNudgeResult | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Build the `before_tool_call` gate. The hook fires on EVERY tool call, so the
|
|
58
|
-
* non-gated fast path is a string check only.
|
|
59
|
-
*/
|
|
60
|
-
export declare function createProtectionGate(options: ProtectionGateOptions): ProtectionGateHandler;
|
|
61
|
-
/**
|
|
62
|
-
* Build the `tool_result_persist` nudge. Synchronous by contract — the host
|
|
63
|
-
* runs this on the transcript-append hot path and warns-and-ignores any handler
|
|
64
|
-
* that returns a Promise.
|
|
65
|
-
*/
|
|
66
|
-
export declare function createProtectionNudge(options: ProtectionNudgeOptions): ProtectionNudgeHandler;
|
|
67
|
-
//# sourceMappingURL=protection-nudge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protection-nudge.d.ts","sourceRoot":"","sources":["../../src/runtime/protection-nudge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAQjD;;;;;;;GAOG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED,wBAAgB,8BAA8B,CAAC,UAAU,SAAM,GAAG,wBAAwB,CAiBzF;AAUD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AAED,uEAAuE;AACvE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAClC,KAAK,EAAE,OAAO,KACX,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG,CACnC,KAAK,EAAE,OAAO,KACX,qBAAqB,GAAG,SAAS,CAAC;AAwGvC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,CAoE1F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB,CAwC7F"}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manual-trade protection: a `before_tool_call` gate plus a
|
|
3
|
-
* `tool_result_persist` nudge for agent-issued position tools on non-runtime
|
|
4
|
-
* (manual) wallets — the only wallets where `create_position` succeeds, since
|
|
5
|
-
* runtime-managed wallets are vetoed upstream by the managed-wallet guard.
|
|
6
|
-
*
|
|
7
|
-
* Gate (veto-until-protected): a manual `create_position` must carry a stop
|
|
8
|
-
* loss on every order, or an explicit top-level `protection: "none"` marker
|
|
9
|
-
* showing the agent means it. `edit_position` is gated narrowly — only an
|
|
10
|
-
* explicit stop-loss cancel is blocked, because the hook cannot see current
|
|
11
|
-
* server-side state and must not demand a stop on every edit.
|
|
12
|
-
*
|
|
13
|
-
* Nudge: after a successful `create_position`, a message is appended to the
|
|
14
|
-
* tool result telling the agent what protection the order carries, to attach
|
|
15
|
-
* `ratchet_stop_add` (server-side trailing protection that takes over driving
|
|
16
|
-
* the stop) unless the user opted out, and to report active protection to the
|
|
17
|
-
* user and offer to adjust it.
|
|
18
|
-
*
|
|
19
|
-
* The `protection` marker is stripped harmlessly by the MCP server's zod schema
|
|
20
|
-
* (plain `z.object`, no `.strict()`/`.passthrough()`), so it is visible to this
|
|
21
|
-
* hook but never reaches execution.
|
|
22
|
-
*/
|
|
23
|
-
import { baseToolName } from "./managed-wallet-guard.js";
|
|
24
|
-
/** Base tool name whose orders must be protected (or explicitly opted out). */
|
|
25
|
-
const CREATE_POSITION = "create_position";
|
|
26
|
-
/** Base tool name gated only against an explicit stop-loss cancel. */
|
|
27
|
-
const EDIT_POSITION = "edit_position";
|
|
28
|
-
export function createProtectionSummaryCapture(maxEntries = 256) {
|
|
29
|
-
const store = new Map();
|
|
30
|
-
return {
|
|
31
|
-
record(toolCallId, summary) {
|
|
32
|
-
if (store.size >= maxEntries) {
|
|
33
|
-
// Map preserves insertion order — evicting the first key drops the oldest.
|
|
34
|
-
const oldest = store.keys().next().value;
|
|
35
|
-
if (oldest !== undefined)
|
|
36
|
-
store.delete(oldest);
|
|
37
|
-
}
|
|
38
|
-
store.set(toolCallId, summary);
|
|
39
|
-
},
|
|
40
|
-
take(toolCallId) {
|
|
41
|
-
const summary = store.get(toolCallId);
|
|
42
|
-
if (summary !== undefined)
|
|
43
|
-
store.delete(toolCallId);
|
|
44
|
-
return summary;
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Default shared capture, used when a factory is called with `{ logger }` only.
|
|
50
|
-
* Lets the gate and nudge correlate without the caller threading a capture, but
|
|
51
|
-
* the plugin registration passes one explicit instance to both (and tests pass
|
|
52
|
-
* their own) so the coupling is visible rather than global.
|
|
53
|
-
*/
|
|
54
|
-
const sharedCapture = createProtectionSummaryCapture();
|
|
55
|
-
function asObject(value) {
|
|
56
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
57
|
-
? value
|
|
58
|
-
: undefined;
|
|
59
|
-
}
|
|
60
|
-
/** True when the base tool name (after the last `__`) equals `expected`. */
|
|
61
|
-
function isTool(toolName, expected) {
|
|
62
|
-
return typeof toolName === "string" && baseToolName(toolName.toLowerCase()) === expected;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* True when a stop-loss value is zero — numeric `0` or a string that parses to
|
|
66
|
-
* it (`"0"`, `"0.0"`). Zero is the cancel sentinel (see the `edit_position`
|
|
67
|
-
* gate), not real protection, so both gates read it as "no stop" via this one
|
|
68
|
-
* helper. An empty/absent value is not zero.
|
|
69
|
-
*/
|
|
70
|
-
function isZeroStop(value) {
|
|
71
|
-
if (value == null)
|
|
72
|
-
return false;
|
|
73
|
-
if (typeof value === "number")
|
|
74
|
-
return value === 0;
|
|
75
|
-
if (typeof value === "string")
|
|
76
|
-
return value.trim() !== "" && Number(value) === 0;
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* An exit object counts as a real stop loss when it carries a non-zero
|
|
81
|
-
* `percentage` or `price`. A zero value is the cancel sentinel (`isZeroStop`),
|
|
82
|
-
* not protection — so a `create_position` with `stopLoss: { percentage: 0 }` or
|
|
83
|
-
* `{ price: 0 }` is rejected, matching how the `edit_position` gate reads 0.
|
|
84
|
-
*/
|
|
85
|
-
function hasStopLoss(order) {
|
|
86
|
-
const sl = asObject(order.stopLoss);
|
|
87
|
-
if (sl == null)
|
|
88
|
-
return false;
|
|
89
|
-
const hasPct = sl.percentage != null && !isZeroStop(sl.percentage);
|
|
90
|
-
const hasPrice = sl.price != null && !isZeroStop(sl.price);
|
|
91
|
-
return hasPct || hasPrice;
|
|
92
|
-
}
|
|
93
|
-
/** One order's protection, e.g. `#1 SL 5% TP 10%` or `#2 SL @42000`. */
|
|
94
|
-
function summarizeOrder(order, index) {
|
|
95
|
-
const sl = describeExit("SL", asObject(order.stopLoss));
|
|
96
|
-
const tp = describeExit("TP", asObject(order.takeProfit));
|
|
97
|
-
return `#${index + 1} ${sl ?? "no SL"}${tp ? ` ${tp}` : ""}`;
|
|
98
|
-
}
|
|
99
|
-
function describeExit(label, exit) {
|
|
100
|
-
if (!exit)
|
|
101
|
-
return undefined;
|
|
102
|
-
if (exit.percentage != null)
|
|
103
|
-
return `${label} ${String(exit.percentage)}%`;
|
|
104
|
-
if (exit.price != null)
|
|
105
|
-
return `${label} @${String(exit.price)}`;
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
function buildCreateBlockReason() {
|
|
109
|
-
return [
|
|
110
|
-
`Blocked create_position: every manual order needs a flat stop loss (a "stopLoss" with either "percentage" or "price") — the safety floor from the first fill.`,
|
|
111
|
-
`Resubmit with a stopLoss on each order.`,
|
|
112
|
-
`After the fill, attach ratchet_stop_add — server-side trailing protection that takes over driving the stop loss as price moves in your favor.`,
|
|
113
|
-
`Take profit ("takeProfit") is optional.`,
|
|
114
|
-
`If the user explicitly wants no protection, resubmit the identical call with a top-level "protection": "none".`,
|
|
115
|
-
].join(" ");
|
|
116
|
-
}
|
|
117
|
-
function buildEditBlockReason() {
|
|
118
|
-
return [
|
|
119
|
-
`Blocked edit_position: this edit cancels the stop loss (stopLoss.percentage: 0), leaving the position unprotected.`,
|
|
120
|
-
`Keep a stop loss, or hand the stop to ratchet_stop_add for server-side trailing protection.`,
|
|
121
|
-
`If the user explicitly wants to remove all protection, resubmit the identical call with a top-level "protection": "none".`,
|
|
122
|
-
].join(" ");
|
|
123
|
-
}
|
|
124
|
-
function buildNudge(summary) {
|
|
125
|
-
return [
|
|
126
|
-
`[senpi] Manual position opened. Protection on this order: ${summary}.`,
|
|
127
|
-
`A flat stop loss is only the initial safety floor — now attach server-side trailing protection: call ratchet_stop_add for this wallet so the runtime drives the stop as price moves in your favor, unless the user has explicitly opted out of protection.`,
|
|
128
|
-
`Then tell the user exactly what protection is active on the position and offer to adjust it.`,
|
|
129
|
-
].join(" ");
|
|
130
|
-
}
|
|
131
|
-
const UNPROTECTED_SUMMARY = `explicitly unprotected (protection: "none")`;
|
|
132
|
-
/**
|
|
133
|
-
* Build the `before_tool_call` gate. The hook fires on EVERY tool call, so the
|
|
134
|
-
* non-gated fast path is a string check only.
|
|
135
|
-
*/
|
|
136
|
-
export function createProtectionGate(options) {
|
|
137
|
-
const { logger, capture = sharedCapture } = options;
|
|
138
|
-
return async (event) => {
|
|
139
|
-
const ev = (event ?? {});
|
|
140
|
-
const gatesCreate = isTool(ev.toolName, CREATE_POSITION);
|
|
141
|
-
const gatesEdit = isTool(ev.toolName, EDIT_POSITION);
|
|
142
|
-
if (!gatesCreate && !gatesEdit) {
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
try {
|
|
146
|
-
const params = asObject(ev.params);
|
|
147
|
-
// Malformed/missing params: allow — the MCP server's schema owns that error.
|
|
148
|
-
if (!params) {
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
const optedOut = params.protection === "none";
|
|
152
|
-
const toolCallId = typeof ev.toolCallId === "string" ? ev.toolCallId : undefined;
|
|
153
|
-
if (gatesEdit) {
|
|
154
|
-
// Narrow gate: block ONLY an explicit stop-loss cancel. The hook can't
|
|
155
|
-
// see current server-side state, so an edit touching other fields (or a
|
|
156
|
-
// take-profit-only edit) must pass.
|
|
157
|
-
const sl = asObject(params.stopLoss);
|
|
158
|
-
if (sl != null && isZeroStop(sl.percentage) && !optedOut) {
|
|
159
|
-
logger.warn("[protection-gate] blocked edit_position stop-loss cancel without protection:none", {
|
|
160
|
-
toolName: ev.toolName,
|
|
161
|
-
});
|
|
162
|
-
return { block: true, blockReason: buildEditBlockReason() };
|
|
163
|
-
}
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
// create_position: require a stop loss on every order unless opted out.
|
|
167
|
-
const orders = Array.isArray(params.orders) ? params.orders.map(asObject) : undefined;
|
|
168
|
-
// Missing/empty/malformed orders: allow — the server schema owns those.
|
|
169
|
-
if (!orders || orders.length === 0 || orders.some((o) => o === undefined)) {
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
172
|
-
if (optedOut) {
|
|
173
|
-
if (toolCallId)
|
|
174
|
-
capture.record(toolCallId, UNPROTECTED_SUMMARY);
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
if (orders.some((o) => !hasStopLoss(o))) {
|
|
178
|
-
logger.warn("[protection-gate] blocked create_position without a stop loss on every order", {
|
|
179
|
-
toolName: ev.toolName,
|
|
180
|
-
});
|
|
181
|
-
return { block: true, blockReason: buildCreateBlockReason() };
|
|
182
|
-
}
|
|
183
|
-
// All orders protected: allow, and stash the per-order summary so the
|
|
184
|
-
// nudge (which never sees params) can report it after the fill.
|
|
185
|
-
if (toolCallId) {
|
|
186
|
-
capture.record(toolCallId, orders.map((o, i) => summarizeOrder(o, i)).join("; "));
|
|
187
|
-
}
|
|
188
|
-
return undefined;
|
|
189
|
-
}
|
|
190
|
-
catch (err) {
|
|
191
|
-
// Fail open: a gate error must never block a legitimate trade. (A throw
|
|
192
|
-
// would fail closed — the host blocks on hook errors.)
|
|
193
|
-
logger.warn("[protection-gate] gate check failed; allowing tool call", err, {
|
|
194
|
-
toolName: ev.toolName,
|
|
195
|
-
});
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Build the `tool_result_persist` nudge. Synchronous by contract — the host
|
|
202
|
-
* runs this on the transcript-append hot path and warns-and-ignores any handler
|
|
203
|
-
* that returns a Promise.
|
|
204
|
-
*/
|
|
205
|
-
export function createProtectionNudge(options) {
|
|
206
|
-
const { logger, capture = sharedCapture } = options;
|
|
207
|
-
return (event) => {
|
|
208
|
-
try {
|
|
209
|
-
const ev = (event ?? {});
|
|
210
|
-
// A synthetic result is a host placeholder, not a real create_position fill.
|
|
211
|
-
if (ev.isSynthetic === true || !isTool(ev.toolName, CREATE_POSITION)) {
|
|
212
|
-
return undefined;
|
|
213
|
-
}
|
|
214
|
-
const message = asObject(ev.message);
|
|
215
|
-
if (!message) {
|
|
216
|
-
return undefined;
|
|
217
|
-
}
|
|
218
|
-
// Silent on failed results: no position was opened, nothing to protect.
|
|
219
|
-
if (message.isError === true) {
|
|
220
|
-
return undefined;
|
|
221
|
-
}
|
|
222
|
-
// Append a text block to the existing content; never replace it, so the
|
|
223
|
-
// real tool result reaches the model intact. If content isn't an array we
|
|
224
|
-
// can't append safely — leave the result untouched.
|
|
225
|
-
const content = message.content;
|
|
226
|
-
if (!Array.isArray(content)) {
|
|
227
|
-
return undefined;
|
|
228
|
-
}
|
|
229
|
-
const toolCallId = typeof ev.toolCallId === "string" ? ev.toolCallId : undefined;
|
|
230
|
-
const summary = (toolCallId ? capture.take(toolCallId) : undefined) ?? "see the order you just submitted";
|
|
231
|
-
return {
|
|
232
|
-
message: {
|
|
233
|
-
...message,
|
|
234
|
-
content: [...content, { type: "text", text: buildNudge(summary) }],
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
catch (err) {
|
|
239
|
-
logger.warn("[protection-nudge] nudge build failed; leaving tool result unchanged", err);
|
|
240
|
-
return undefined;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=protection-nudge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protection-nudge.js","sourceRoot":"","sources":["../../src/runtime/protection-nudge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,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