@senpi-ai/runtime 3.0.13 → 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.
Files changed (198) hide show
  1. package/README.md +7 -4
  2. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  3. package/dist/actions/close-position/close-position.action.js +2 -7
  4. package/dist/actions/close-position/close-position.action.js.map +1 -1
  5. package/dist/actions/decision-error-notification.d.ts +35 -0
  6. package/dist/actions/decision-error-notification.d.ts.map +1 -0
  7. package/dist/actions/decision-error-notification.js +58 -0
  8. package/dist/actions/decision-error-notification.js.map +1 -0
  9. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  10. package/dist/actions/open-position/open-position.action.js +50 -7
  11. package/dist/actions/open-position/open-position.action.js.map +1 -1
  12. package/dist/actions/types.d.ts +2 -0
  13. package/dist/actions/types.d.ts.map +1 -1
  14. package/dist/approvals/approval-store.d.ts +35 -0
  15. package/dist/approvals/approval-store.d.ts.map +1 -0
  16. package/dist/approvals/approval-store.js +87 -0
  17. package/dist/approvals/approval-store.js.map +1 -0
  18. package/dist/approvals/manifest.d.ts +47 -0
  19. package/dist/approvals/manifest.d.ts.map +1 -0
  20. package/dist/approvals/manifest.js +90 -0
  21. package/dist/approvals/manifest.js.map +1 -0
  22. package/dist/approvals/telemetry.d.ts +41 -0
  23. package/dist/approvals/telemetry.d.ts.map +1 -0
  24. package/dist/approvals/telemetry.js +35 -0
  25. package/dist/approvals/telemetry.js.map +1 -0
  26. package/dist/approvals/tool-approval-gate.d.ts +96 -0
  27. package/dist/approvals/tool-approval-gate.d.ts.map +1 -0
  28. package/dist/approvals/tool-approval-gate.js +233 -0
  29. package/dist/approvals/tool-approval-gate.js.map +1 -0
  30. package/dist/approvals/tool-approvals-manifest.json +27 -0
  31. package/dist/cli/guide-commands.d.ts.map +1 -1
  32. package/dist/cli/guide-commands.js +6 -7
  33. package/dist/cli/guide-commands.js.map +1 -1
  34. package/dist/cli/senpi-cli-config.d.ts +0 -17
  35. package/dist/cli/senpi-cli-config.d.ts.map +1 -1
  36. package/dist/cli/senpi-cli-config.js +0 -30
  37. package/dist/cli/senpi-cli-config.js.map +1 -1
  38. package/dist/cli/senpi-config-commands.d.ts +1 -1
  39. package/dist/cli/senpi-config-commands.d.ts.map +1 -1
  40. package/dist/cli/senpi-config-commands.js +1 -16
  41. package/dist/cli/senpi-config-commands.js.map +1 -1
  42. package/dist/constants/dsl/index.d.ts +1 -5
  43. package/dist/constants/dsl/index.d.ts.map +1 -1
  44. package/dist/constants/dsl/index.js +1 -5
  45. package/dist/constants/dsl/index.js.map +1 -1
  46. package/dist/dsl/engine-client/event-mapping.d.ts +1 -1
  47. package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
  48. package/dist/dsl/engine-client/event-mapping.js +6 -0
  49. package/dist/dsl/engine-client/event-mapping.js.map +1 -1
  50. package/dist/dsl/events/build-closed-event.d.ts +1 -1
  51. package/dist/dsl/events/build-closed-event.js +1 -1
  52. package/dist/dsl/events/handlers.js +1 -1
  53. package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
  54. package/dist/dsl/monitor/process-one-position.js +5 -3
  55. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  56. package/dist/dsl/notifications/format-utils.d.ts +1 -11
  57. package/dist/dsl/notifications/format-utils.d.ts.map +1 -1
  58. package/dist/dsl/notifications/format-utils.js +1 -48
  59. package/dist/dsl/notifications/format-utils.js.map +1 -1
  60. package/dist/dsl/notifications/formatter.d.ts +17 -28
  61. package/dist/dsl/notifications/formatter.d.ts.map +1 -1
  62. package/dist/dsl/notifications/formatter.js +46 -129
  63. package/dist/dsl/notifications/formatter.js.map +1 -1
  64. package/dist/dsl/notifications/index.d.ts +2 -10
  65. package/dist/dsl/notifications/index.d.ts.map +1 -1
  66. package/dist/dsl/notifications/index.js +127 -50
  67. package/dist/dsl/notifications/index.js.map +1 -1
  68. package/dist/dsl/notifications/raise-correlator.d.ts +87 -0
  69. package/dist/dsl/notifications/raise-correlator.d.ts.map +1 -0
  70. package/dist/dsl/notifications/raise-correlator.js +136 -0
  71. package/dist/dsl/notifications/raise-correlator.js.map +1 -0
  72. package/dist/dsl/notifications/stop-raise-ratchet.d.ts +76 -0
  73. package/dist/dsl/notifications/stop-raise-ratchet.d.ts.map +1 -0
  74. package/dist/dsl/notifications/stop-raise-ratchet.js +113 -0
  75. package/dist/dsl/notifications/stop-raise-ratchet.js.map +1 -0
  76. package/dist/dsl/plugin/index.d.ts.map +1 -1
  77. package/dist/dsl/plugin/index.js +0 -27
  78. package/dist/dsl/plugin/index.js.map +1 -1
  79. package/dist/dsl/plugin/options.d.ts +3 -7
  80. package/dist/dsl/plugin/options.d.ts.map +1 -1
  81. package/dist/index.d.ts +15 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +70 -142
  84. package/dist/index.js.map +1 -1
  85. package/dist/prompt/session-context-seed-hook.d.ts +11 -0
  86. package/dist/prompt/session-context-seed-hook.d.ts.map +1 -0
  87. package/dist/prompt/session-context-seed-hook.js +99 -0
  88. package/dist/prompt/session-context-seed-hook.js.map +1 -0
  89. package/dist/runtime/auto-update/coordinator.d.ts +39 -15
  90. package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
  91. package/dist/runtime/auto-update/coordinator.js +152 -34
  92. package/dist/runtime/auto-update/coordinator.js.map +1 -1
  93. package/dist/runtime/auto-update/gateway-restart.d.ts +4 -4
  94. package/dist/runtime/auto-update/gateway-restart.js +4 -4
  95. package/dist/runtime/auto-update/types.d.ts +1 -0
  96. package/dist/runtime/auto-update/types.d.ts.map +1 -1
  97. package/dist/runtime/auto-update/types.js.map +1 -1
  98. package/dist/runtime/backend-pause-registry.d.ts +38 -0
  99. package/dist/runtime/backend-pause-registry.d.ts.map +1 -0
  100. package/dist/runtime/backend-pause-registry.js +51 -0
  101. package/dist/runtime/backend-pause-registry.js.map +1 -0
  102. package/dist/runtime/create-action-context.d.ts.map +1 -1
  103. package/dist/runtime/create-action-context.js +1 -0
  104. package/dist/runtime/create-action-context.js.map +1 -1
  105. package/dist/runtime/create-runtime-context.d.ts +1 -0
  106. package/dist/runtime/create-runtime-context.d.ts.map +1 -1
  107. package/dist/runtime/create-runtime-context.js +3 -0
  108. package/dist/runtime/create-runtime-context.js.map +1 -1
  109. package/dist/runtime/decision-errors.d.ts +46 -53
  110. package/dist/runtime/decision-errors.d.ts.map +1 -1
  111. package/dist/runtime/decision-errors.js +72 -111
  112. package/dist/runtime/decision-errors.js.map +1 -1
  113. package/dist/runtime/notifications.d.ts +37 -16
  114. package/dist/runtime/notifications.d.ts.map +1 -1
  115. package/dist/runtime/notifications.js +211 -67
  116. package/dist/runtime/notifications.js.map +1 -1
  117. package/dist/runtime/runtime.d.ts +16 -2
  118. package/dist/runtime/runtime.d.ts.map +1 -1
  119. package/dist/runtime/runtime.js +109 -31
  120. package/dist/runtime/runtime.js.map +1 -1
  121. package/dist/runtime/strategy-lifecycle.d.ts +23 -9
  122. package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
  123. package/dist/runtime/strategy-lifecycle.js +90 -38
  124. package/dist/runtime/strategy-lifecycle.js.map +1 -1
  125. package/dist/runtime/supervisor/long-running-supervisor.js +3 -3
  126. package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
  127. package/dist/runtime-api/lifecycle.d.ts +1 -1
  128. package/dist/runtime-api/lifecycle.js +1 -1
  129. package/dist/scanners/providers/client.d.ts.map +1 -1
  130. package/dist/scanners/providers/client.js +4 -1
  131. package/dist/scanners/providers/client.js.map +1 -1
  132. package/dist/scanners/providers/factory.d.ts.map +1 -1
  133. package/dist/scanners/providers/factory.js +43 -2
  134. package/dist/scanners/providers/factory.js.map +1 -1
  135. package/dist/scanners/runtime-module.d.ts.map +1 -1
  136. package/dist/scanners/runtime-module.js +35 -0
  137. package/dist/scanners/runtime-module.js.map +1 -1
  138. package/dist/scripts/run-dsl-standalone-live.d.ts +8 -6
  139. package/dist/scripts/run-dsl-standalone-live.d.ts.map +1 -1
  140. package/dist/scripts/run-dsl-standalone-live.js +26 -25
  141. package/dist/scripts/run-dsl-standalone-live.js.map +1 -1
  142. package/dist/senpi/client.d.ts.map +1 -1
  143. package/dist/senpi/client.js +10 -3
  144. package/dist/senpi/client.js.map +1 -1
  145. package/dist/senpi/tool-errors.d.ts +30 -0
  146. package/dist/senpi/tool-errors.d.ts.map +1 -0
  147. package/dist/senpi/tool-errors.js +87 -0
  148. package/dist/senpi/tool-errors.js.map +1 -0
  149. package/dist/senpi/types.d.ts +4 -0
  150. package/dist/senpi/types.d.ts.map +1 -1
  151. package/dist/skills-manager/coordinator.d.ts +2 -2
  152. package/dist/skills-manager/coordinator.js +2 -2
  153. package/dist/telemetry/metrics.d.ts +11 -0
  154. package/dist/telemetry/metrics.d.ts.map +1 -1
  155. package/dist/telemetry/metrics.js +22 -0
  156. package/dist/telemetry/metrics.js.map +1 -1
  157. package/dist/test-setup.d.ts +2 -0
  158. package/dist/test-setup.d.ts.map +1 -0
  159. package/dist/test-setup.js +21 -0
  160. package/dist/test-setup.js.map +1 -0
  161. package/dist/types/dsl/index.d.ts +14 -1
  162. package/dist/types/dsl/index.d.ts.map +1 -1
  163. package/dist/types/notification.d.ts +102 -1
  164. package/dist/types/notification.d.ts.map +1 -1
  165. package/dist/types/notification.js +80 -1
  166. package/dist/types/notification.js.map +1 -1
  167. package/dist/types/runtime.d.ts +13 -0
  168. package/dist/types/runtime.d.ts.map +1 -1
  169. package/dist/types/session-context.d.ts +19 -0
  170. package/dist/types/session-context.d.ts.map +1 -0
  171. package/dist/types/session-context.js +20 -0
  172. package/dist/types/session-context.js.map +1 -0
  173. package/dist/utils/event-catalog.d.ts +103 -2
  174. package/dist/utils/event-catalog.d.ts.map +1 -1
  175. package/dist/utils/event-catalog.js +28 -0
  176. package/dist/utils/event-catalog.js.map +1 -1
  177. package/dist/utils/logger.d.ts +2 -18
  178. package/dist/utils/logger.d.ts.map +1 -1
  179. package/dist/utils/logger.js +2 -40
  180. package/dist/utils/logger.js.map +1 -1
  181. package/openclaw.plugin.json +10 -1
  182. package/package.json +3 -2
  183. package/dist/actions/notifications/formatter.d.ts +0 -39
  184. package/dist/actions/notifications/formatter.d.ts.map +0 -1
  185. package/dist/actions/notifications/formatter.js +0 -68
  186. package/dist/actions/notifications/formatter.js.map +0 -1
  187. package/dist/actions/notifications/index.d.ts +0 -37
  188. package/dist/actions/notifications/index.d.ts.map +0 -1
  189. package/dist/actions/notifications/index.js +0 -89
  190. package/dist/actions/notifications/index.js.map +0 -1
  191. package/dist/dsl/notifications/close-resolver.d.ts +0 -92
  192. package/dist/dsl/notifications/close-resolver.d.ts.map +0 -1
  193. package/dist/dsl/notifications/close-resolver.js +0 -309
  194. package/dist/dsl/notifications/close-resolver.js.map +0 -1
  195. package/dist/dsl/notifications/types.d.ts +0 -27
  196. package/dist/dsl/notifications/types.d.ts.map +0 -1
  197. package/dist/dsl/notifications/types.js +0 -5
  198. package/dist/dsl/notifications/types.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-store.js","sourceRoot":"","sources":["../../src/approvals/approval-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAO1C,qEAAqE;AACrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAU/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,iBAAiB;IAMT;IALF,QAAQ,CAAS;IACjB,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEnE,YACE,QAAgB,EACC,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;QAEpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,yBAAyB,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;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,CAAC;YACb,IAAI,CAAC,MAAM,EAAE,IAAI,CACf,wFAAwF,IAAI,CAAC,QAAQ,QAAQ,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAChK,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Tool-approvals manifest — the single, codebase-controlled source of truth
3
+ * for which senpi MCP tools the approval gate treats as trades (gated in the
4
+ * default mode) and for the gate's defaults (mode, prompt timeout).
5
+ *
6
+ * The manifest is a checked-in JSON file (`tool-approvals-manifest.json`,
7
+ * copied into `dist/` at build time) shipped *with the runtime*, so changing
8
+ * the gated tool set or the fleet default is one reviewable diff — no env
9
+ * vars, no scattered constants. Mirrors the skills-manager manifest pattern
10
+ * (`src/skills-manager/manifest.ts`).
11
+ *
12
+ * Runtime overrides still win over the manifest default for the mode:
13
+ * env `SENPI_TOOL_APPROVALS` > plugin config `toolApprovals` > manifest
14
+ * `defaults.mode` (see `resolveToolApprovalsMode` in tool-approval-gate.ts).
15
+ */
16
+ export type ToolApprovalsMode = "off" | "trades" | "all";
17
+ /** Parsed + validated manifest shape. */
18
+ export interface ToolApprovalsManifest {
19
+ schemaVersion: number;
20
+ defaults: {
21
+ mode: ToolApprovalsMode;
22
+ /** Prompt timeout; gateway clamps plugin approvals to max 600_000 ms. */
23
+ timeoutMs: number;
24
+ };
25
+ /** Bare senpi MCP tool names (no `senpi__` prefix) gated in `trades` mode. */
26
+ tradeTools: string[];
27
+ }
28
+ /**
29
+ * Hardcoded fallback used only when the checked-in JSON cannot be read or
30
+ * parsed (corrupt file, missing from dist). Keeps the plugin from crashing at
31
+ * import time; logged loudly by {@link loadToolApprovalsManifest}. Kept in
32
+ * sync with `tool-approvals-manifest.json` (a test asserts this).
33
+ */
34
+ export declare const FALLBACK_TOOL_APPROVALS_MANIFEST: ToolApprovalsManifest;
35
+ /**
36
+ * Load + validate the manifest from disk, cached after first read. Resolves
37
+ * the JSON path relative to this module so it works both from `src/` (vitest)
38
+ * and `dist/` (the build copies the JSON next to the compiled module).
39
+ *
40
+ * On any read/parse/validation failure, logs a warning and returns
41
+ * {@link FALLBACK_TOOL_APPROVALS_MANIFEST} — the gate must not fail to start
42
+ * because of a packaging mistake.
43
+ */
44
+ export declare function loadToolApprovalsManifest(): ToolApprovalsManifest;
45
+ /** Reset the manifest cache. Test-only. */
46
+ export declare function resetToolApprovalsManifestCacheForTests(): void;
47
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/approvals/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEzD,yCAAyC;AACzC,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE;QACR,IAAI,EAAE,iBAAiB,CAAC;QACxB,yEAAyE;QACzE,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,8EAA8E;IAC9E,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAWD;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,EAAE,qBA0B9C,CAAC;AAIF;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,IAAI,qBAAqB,CAcjE;AAED,2CAA2C;AAC3C,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Tool-approvals manifest — the single, codebase-controlled source of truth
3
+ * for which senpi MCP tools the approval gate treats as trades (gated in the
4
+ * default mode) and for the gate's defaults (mode, prompt timeout).
5
+ *
6
+ * The manifest is a checked-in JSON file (`tool-approvals-manifest.json`,
7
+ * copied into `dist/` at build time) shipped *with the runtime*, so changing
8
+ * the gated tool set or the fleet default is one reviewable diff — no env
9
+ * vars, no scattered constants. Mirrors the skills-manager manifest pattern
10
+ * (`src/skills-manager/manifest.ts`).
11
+ *
12
+ * Runtime overrides still win over the manifest default for the mode:
13
+ * env `SENPI_TOOL_APPROVALS` > plugin config `toolApprovals` > manifest
14
+ * `defaults.mode` (see `resolveToolApprovalsMode` in tool-approval-gate.ts).
15
+ */
16
+ import { readFileSync } from "node:fs";
17
+ import { fileURLToPath } from "node:url";
18
+ import { z } from "zod";
19
+ import { createLogger } from "../utils/logger.js";
20
+ const manifestSchema = z.object({
21
+ schemaVersion: z.number(),
22
+ defaults: z.object({
23
+ mode: z.union([z.literal("off"), z.literal("trades"), z.literal("all")]),
24
+ timeoutMs: z.number().int().positive().max(600_000),
25
+ }),
26
+ tradeTools: z.array(z.string().min(1)).min(1),
27
+ });
28
+ /**
29
+ * Hardcoded fallback used only when the checked-in JSON cannot be read or
30
+ * parsed (corrupt file, missing from dist). Keeps the plugin from crashing at
31
+ * import time; logged loudly by {@link loadToolApprovalsManifest}. Kept in
32
+ * sync with `tool-approvals-manifest.json` (a test asserts this).
33
+ */
34
+ export const FALLBACK_TOOL_APPROVALS_MANIFEST = {
35
+ schemaVersion: 1,
36
+ defaults: { mode: "trades", timeoutMs: 600_000 },
37
+ tradeTools: [
38
+ "create_position",
39
+ "close_position",
40
+ "edit_position",
41
+ "cancel_order",
42
+ "strategy_create",
43
+ "strategy_create_custom_strategy",
44
+ "strategy_close",
45
+ "strategy_close_positions",
46
+ "strategy_update",
47
+ "strategy_pause",
48
+ "strategy_top_up",
49
+ "strategy_withdraw_funds",
50
+ "strategy_bridge_funds_from_hyperliquid_to_evm",
51
+ "transfer_spot_to_perps",
52
+ // Not currently exposed by the senpi MCP server, but senpi-web's permission
53
+ // registry lists it — gating a tool that does not exist is a no-op, and it
54
+ // must not slip through unapproved if it ever ships.
55
+ "send_usdc",
56
+ "ratchet_stop_add",
57
+ "ratchet_stop_edit",
58
+ "ratchet_stop_delete",
59
+ ],
60
+ };
61
+ let cached = null;
62
+ /**
63
+ * Load + validate the manifest from disk, cached after first read. Resolves
64
+ * the JSON path relative to this module so it works both from `src/` (vitest)
65
+ * and `dist/` (the build copies the JSON next to the compiled module).
66
+ *
67
+ * On any read/parse/validation failure, logs a warning and returns
68
+ * {@link FALLBACK_TOOL_APPROVALS_MANIFEST} — the gate must not fail to start
69
+ * because of a packaging mistake.
70
+ */
71
+ export function loadToolApprovalsManifest() {
72
+ if (cached)
73
+ return cached;
74
+ try {
75
+ const jsonPath = fileURLToPath(new URL("./tool-approvals-manifest.json", import.meta.url));
76
+ const parsed = JSON.parse(readFileSync(jsonPath, "utf8"));
77
+ cached = manifestSchema.parse(parsed);
78
+ }
79
+ catch (err) {
80
+ const message = err instanceof Error ? err.message : String(err);
81
+ createLogger("[senpi-tool-approvals][manifest]").warn(`failed to load tool-approvals-manifest.json, using built-in fallback: ${message}`);
82
+ cached = FALLBACK_TOOL_APPROVALS_MANIFEST;
83
+ }
84
+ return cached;
85
+ }
86
+ /** Reset the manifest cache. Test-only. */
87
+ export function resetToolApprovalsManifestCacheForTests() {
88
+ cached = null;
89
+ }
90
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/approvals/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgBlD,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,C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QACnE,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,YAAY,CAAC,kCAAkC,CAAC,CAAC,IAAI,CACnD,yEAAyE,OAAO,EAAE,CACnF,CAAC;QACF,MAAM,GAAG,gCAAgC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,uCAAuC;IACrD,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,41 @@
1
+ /** Terminal user choice at the approval gate. */
2
+ export type ApprovalDecision = "allow-once" | "allow-always" | "deny" | "timeout";
3
+ /**
4
+ * Telemetry seam for the MCP tool approval gate.
5
+ *
6
+ * Injected into {@link registerToolApprovalGate} so the gate stays unit-testable
7
+ * (tests pass a fake and assert on it) while production wires the real event/
8
+ * metric planes. Mirrors how `span-hooks` reaches `emitToolCalled` /
9
+ * `recordToolCall` directly, and how `index.ts` emits `runtime.scanners_unwired`
10
+ * through a dedicated OTel-backed `createLogger` (the plugin's own
11
+ * `PluginLogger` has no `event()`).
12
+ */
13
+ export interface GateTelemetry {
14
+ /**
15
+ * Audit EVERY gate decision — the only place the approve path is recorded, so
16
+ * we know whether the user chose `allow-once` vs `allow-always` (and, for the
17
+ * deny path, `deny` vs `timeout`). Emits the `tool_approval.resolved` event
18
+ * (info for allows, warn for deny/timeout) + `tool_approval.decisions` metric,
19
+ * so allow-always adoption and deny/timeout rates per tool are chartable.
20
+ */
21
+ resolved(toolName: string, decision: ApprovalDecision, isTrade: boolean): void;
22
+ /**
23
+ * A user deny or a 10-minute timeout — a state-changing tool the user did NOT
24
+ * authorize, so it did not run. Recorded on the origin-uniform `tool.called`
25
+ * event + `tool.calls` metric with the reserved `denied` outcome, so
26
+ * deny-rate and timeout-deny-rate land on the existing tool dashboards. A
27
+ * timeout-deny is a product signal (the user missed the prompt and their
28
+ * trade silently didn't execute). Complements {@link resolved}, which lives
29
+ * on the separate gate-decision plane.
30
+ */
31
+ denied(toolName: string, reason: "user_denied" | "approval_timeout"): void;
32
+ /**
33
+ * The gate's fail-open catch fired: the gate hit an internal bug and let the
34
+ * tool through ungated. Catalogued as `tool_approval.gate_error` at error
35
+ * level so it can sit behind an alert instead of a log grep.
36
+ */
37
+ gateError(err: unknown, toolName: string | undefined): void;
38
+ }
39
+ /** Production wiring: real event + metric planes. */
40
+ export declare const defaultGateTelemetry: GateTelemetry;
41
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/approvals/telemetry.ts"],"names":[],"mappings":"AAKA,iDAAiD;AACjD,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AAElF;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/E;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,IAAI,CAAC;IAC3E;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC7D;AAID,qDAAqD;AACrD,eAAO,MAAM,oBAAoB,EAAE,aA2BlC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { recordApprovalDecision, recordToolCall } from "../telemetry/metrics.js";
2
+ import { emitToolCalled } from "../telemetry/tool-plane.js";
3
+ import { EVENT_NAME, eventAttrs } from "../utils/event-catalog.js";
4
+ import { createLogger } from "../utils/logger.js";
5
+ const eventLogger = createLogger("[senpi-tool-approvals]");
6
+ /** Production wiring: real event + metric planes. */
7
+ export const defaultGateTelemetry = {
8
+ resolved(toolName, decision, isTrade) {
9
+ const denyish = decision === "deny" || decision === "timeout";
10
+ eventLogger.event(EVENT_NAME.toolApprovalResolved, denyish ? "warn" : "info", {
11
+ body: `tool approval ${decision} for ${toolName}`,
12
+ attributes: eventAttrs({
13
+ "gen_ai.tool.name": toolName,
14
+ "senpi.tool_approval.decision": decision,
15
+ "senpi.tool.is_trade": String(isTrade),
16
+ }),
17
+ });
18
+ recordApprovalDecision({ toolName, decision, isTrade });
19
+ },
20
+ denied(toolName, reason) {
21
+ emitToolCalled({ name: toolName, origin: "agent", outcome: "denied", errorType: reason });
22
+ recordToolCall({ toolName, origin: "agent", outcome: "denied", errorType: reason });
23
+ },
24
+ gateError(err, toolName) {
25
+ eventLogger.event(EVENT_NAME.toolApprovalGateError, "error", {
26
+ body: `tool approval gate failed open${toolName ? ` for ${toolName}` : ""}`,
27
+ attributes: eventAttrs({
28
+ "gen_ai.tool.name": toolName,
29
+ "error.type": err instanceof Error ? err.name : "unknown",
30
+ }),
31
+ redact: { error_message: err instanceof Error ? err.message : String(err) },
32
+ });
33
+ },
34
+ };
35
+ //# sourceMappingURL=telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/approvals/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAiB,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0ClD,MAAM,WAAW,GAAG,YAAY,CAAC,wBAAwB,CA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,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;aAC1D,CAAC;YACF,MAAM,EAAE,EAAE,aAAa,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SAC5E,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { ToolApprovalStore } from "./approval-store.js";
2
+ import { type ToolApprovalsManifest, type ToolApprovalsMode } from "./manifest.js";
3
+ import { type GateTelemetry } from "./telemetry.js";
4
+ /**
5
+ * Tool approval gate: requires an interactive user approval before
6
+ * state-changing senpi MCP tools execute.
7
+ *
8
+ * OpenClaw v2026.5.x has no declarative "ask" policy for MCP tools (only the
9
+ * exec tool has `tools.exec.ask`); the supported mechanism is a plugin
10
+ * `before_tool_call` hook returning `requireApproval`, which the gateway
11
+ * drives via `plugin.approval.request` / `plugin.approval.resolve`
12
+ * (decisions: allow-once / allow-always / deny; timeout → deny). Approval
13
+ * prompts are broadcast to gateway clients holding the `operator.approvals`
14
+ * scope — the senpi agent-bridge connection — and surface in senpi-web.
15
+ *
16
+ * The gated tool set and the defaults (mode, prompt timeout) come from the
17
+ * checked-in manifest (`tool-approvals-manifest.json`, see manifest.ts) — the
18
+ * reviewed, fleet-wide control surface. Mode precedence: env
19
+ * {@link TOOL_APPROVALS_ENV_VAR} > plugin config `toolApprovals` > manifest
20
+ * `defaults.mode`.
21
+ *
22
+ * `allow-always` decisions are persisted per tool via {@link ToolApprovalStore}
23
+ * (OpenClaw treats them as one-shot for plugin approvals).
24
+ *
25
+ * Design doc: docs/mcp-tool-approvals-design.md
26
+ */
27
+ interface LoggerLike {
28
+ info(...args: unknown[]): void;
29
+ warn(...args: unknown[]): void;
30
+ }
31
+ /** Minimal shape of the OpenClaw plugin API surface the gate needs. */
32
+ export interface ToolApprovalGatePluginApi {
33
+ on(hookName: string, handler: (...args: unknown[]) => unknown, opts?: {
34
+ priority?: number;
35
+ }): void;
36
+ }
37
+ export type { ToolApprovalsMode };
38
+ /** Env var that overrides the `toolApprovals` plugin config and the manifest default. */
39
+ export declare const TOOL_APPROVALS_ENV_VAR = "SENPI_TOOL_APPROVALS";
40
+ /**
41
+ * Match a tool-registry name against the senpi MCP server and return the bare
42
+ * tool name. Covers the embedded-MCP shape (`senpi__create_position`), the
43
+ * CLI-runner backend shape (`mcp__senpi__create_position`), and openclaw's
44
+ * server-name dedupe suffix (`senpi-2__…`).
45
+ */
46
+ export declare function matchSenpiTool(toolName: unknown): string | null;
47
+ export declare function isToolApprovalsMode(value: unknown): value is ToolApprovalsMode;
48
+ /**
49
+ * Resolve the gate mode: env {@link TOOL_APPROVALS_ENV_VAR} > plugin config
50
+ * `toolApprovals` > manifest `defaults.mode`. Unrecognized values warn and
51
+ * fall through to the manifest default rather than silently disabling the gate.
52
+ */
53
+ export declare function resolveToolApprovalsMode(params: {
54
+ pluginConfig?: Record<string, unknown>;
55
+ env?: NodeJS.ProcessEnv;
56
+ logger?: LoggerLike;
57
+ manifest?: ToolApprovalsManifest;
58
+ }): ToolApprovalsMode;
59
+ /**
60
+ * Human sentence for a senpi trade tool call, mirroring senpi-web's own
61
+ * per-tool phrasing (its `getDescription` registry).
62
+ *
63
+ * Why the plugin builds this rather than leaving it to the UI: senpi-web keys
64
+ * that registry by the **bare** tool name and feeds it the call `args`, but for
65
+ * plugin approvals openclaw sends the prefixed registry name
66
+ * (`senpi__create_position`) and has **no `args` field at all` in
67
+ * `PluginApprovalRequestParamsSchema` (additionalProperties: false). So the UI
68
+ * takes its fallback branch and renders `description` verbatim, with no args
69
+ * block — meaning this string is the *only* place the user sees what they are
70
+ * approving. It must therefore carry the numbers, not just the intent.
71
+ */
72
+ export declare function describeSenpiToolCall(tool: string, params: unknown): string | undefined;
73
+ /**
74
+ * Prompt body: the human sentence when we know the tool, plus the compact raw
75
+ * args so the exact numbers are always visible (senpi-web renders no args block
76
+ * for plugin approvals — see {@link describeSenpiToolCall}). Capped to the
77
+ * gateway's description limit, which rejects (not truncates) anything longer.
78
+ */
79
+ export declare function buildApprovalDescription(tool: string, params: unknown): string;
80
+ export interface RegisterToolApprovalGateOptions {
81
+ api: ToolApprovalGatePluginApi;
82
+ mode: ToolApprovalsMode;
83
+ /** Base plugin state dir; the store file lives directly under it. */
84
+ stateDir: string;
85
+ logger?: LoggerLike;
86
+ /** Injectable for tests; defaults to the checked-in manifest. */
87
+ manifest?: ToolApprovalsManifest;
88
+ /** Injectable for tests; defaults to the real event/metric planes. */
89
+ telemetry?: GateTelemetry;
90
+ }
91
+ /**
92
+ * Register the `before_tool_call` approval gate. No-op in `off` mode.
93
+ * Returns the store (for tests/introspection) when registered.
94
+ */
95
+ export declare function registerToolApprovalGate(options: RegisterToolApprovalGateOptions): ToolApprovalStore | undefined;
96
+ //# sourceMappingURL=tool-approval-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-approval-gate.d.ts","sourceRoot":"","sources":["../../src/approvals/tool-approval-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,UAAU,UAAU;IAClB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAChC;AAED,uEAAuE;AACvE,MAAM,WAAW,yBAAyB;IACxC,EAAE,CACA,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACxC,IAAI,CAAC,EAAE;QA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+1,233 @@
1
+ import { ToolApprovalStore } from "./approval-store.js";
2
+ import { loadToolApprovalsManifest, } from "./manifest.js";
3
+ import { defaultGateTelemetry } from "./telemetry.js";
4
+ /** Env var that overrides the `toolApprovals` plugin config and the manifest default. */
5
+ export const TOOL_APPROVALS_ENV_VAR = "SENPI_TOOL_APPROVALS";
6
+ // Gateway schema hard limits (plugin.approval.request rejects, not truncates,
7
+ // beyond these — openclaw PLUGIN_APPROVAL_TITLE_MAX_LENGTH / _DESCRIPTION_).
8
+ const TITLE_MAX_LENGTH = 80;
9
+ const DESCRIPTION_MAX_LENGTH = 256;
10
+ /**
11
+ * Match a tool-registry name against the senpi MCP server and return the bare
12
+ * tool name. Covers the embedded-MCP shape (`senpi__create_position`), the
13
+ * CLI-runner backend shape (`mcp__senpi__create_position`), and openclaw's
14
+ * server-name dedupe suffix (`senpi-2__…`).
15
+ */
16
+ export function matchSenpiTool(toolName) {
17
+ if (typeof toolName !== "string") {
18
+ return null;
19
+ }
20
+ const match = /^(?:mcp__)?senpi(?:-\d+)?__(.+)$/.exec(toolName);
21
+ return match ? match[1] : null;
22
+ }
23
+ export function isToolApprovalsMode(value) {
24
+ return value === "off" || value === "trades" || value === "all";
25
+ }
26
+ /**
27
+ * Resolve the gate mode: env {@link TOOL_APPROVALS_ENV_VAR} > plugin config
28
+ * `toolApprovals` > manifest `defaults.mode`. Unrecognized values warn and
29
+ * fall through to the manifest default rather than silently disabling the gate.
30
+ */
31
+ export function resolveToolApprovalsMode(params) {
32
+ const manifestDefault = (params.manifest ?? loadToolApprovalsManifest()).defaults.mode;
33
+ const candidates = [
34
+ { source: `env ${TOOL_APPROVALS_ENV_VAR}`, value: params.env?.[TOOL_APPROVALS_ENV_VAR] },
35
+ { source: 'plugin config "toolApprovals"', value: params.pluginConfig?.toolApprovals },
36
+ ];
37
+ for (const candidate of candidates) {
38
+ if (candidate.value === undefined || candidate.value === null || candidate.value === "") {
39
+ continue;
40
+ }
41
+ const normalized = typeof candidate.value === "string" ? candidate.value.trim().toLowerCase() : candidate.value;
42
+ if (isToolApprovalsMode(normalized)) {
43
+ return normalized;
44
+ }
45
+ params.logger?.warn(`[senpi-tool-approvals] unrecognized ${candidate.source} value ${JSON.stringify(candidate.value)}; using manifest default "${manifestDefault}" (expected off|trades|all)`);
46
+ return manifestDefault;
47
+ }
48
+ return manifestDefault;
49
+ }
50
+ function truncate(value, maxLength) {
51
+ return value.length <= maxLength ? value : `${value.slice(0, maxLength - 1)}…`;
52
+ }
53
+ function str(value) {
54
+ if (typeof value === "string" && value.trim())
55
+ return value.trim();
56
+ if (typeof value === "number" && Number.isFinite(value))
57
+ return String(value);
58
+ return undefined;
59
+ }
60
+ /**
61
+ * Human sentence for a senpi trade tool call, mirroring senpi-web's own
62
+ * per-tool phrasing (its `getDescription` registry).
63
+ *
64
+ * Why the plugin builds this rather than leaving it to the UI: senpi-web keys
65
+ * that registry by the **bare** tool name and feeds it the call `args`, but for
66
+ * plugin approvals openclaw sends the prefixed registry name
67
+ * (`senpi__create_position`) and has **no `args` field at all` in
68
+ * `PluginApprovalRequestParamsSchema` (additionalProperties: false). So the UI
69
+ * takes its fallback branch and renders `description` verbatim, with no args
70
+ * block — meaning this string is the *only* place the user sees what they are
71
+ * approving. It must therefore carry the numbers, not just the intent.
72
+ */
73
+ export function describeSenpiToolCall(tool, params) {
74
+ const p = (params ?? {});
75
+ const asset = str(p.asset) ?? str(p.coin) ?? str(p.symbol);
76
+ const strategyId = str(p.strategyId) ?? str(p.strategy_id);
77
+ const amount = str(p.amount) ?? str(p.usdAmount) ?? str(p.margin);
78
+ const leverage = str(p.leverage);
79
+ const direction = str(p.direction) ?? str(p.side);
80
+ const parts = [];
81
+ switch (tool) {
82
+ case "create_position": {
83
+ parts.push(`Open a ${direction ?? ""} position on ${asset ?? "?"}`.replace(/\s+/g, " "));
84
+ if (amount)
85
+ parts.push(`margin $${amount}`);
86
+ if (leverage)
87
+ parts.push(`${leverage}x`);
88
+ break;
89
+ }
90
+ case "close_position":
91
+ parts.push(`Close position ${str(p.positionId) ?? asset ?? ""}`.trim());
92
+ break;
93
+ case "edit_position":
94
+ parts.push(`Edit position ${str(p.positionId) ?? asset ?? ""}`.trim());
95
+ break;
96
+ case "cancel_order":
97
+ parts.push(`Cancel order ${str(p.orderId) ?? ""}`.trim());
98
+ break;
99
+ case "strategy_create":
100
+ case "strategy_create_custom_strategy":
101
+ parts.push(`Create strategy ${str(p.name) ?? asset ?? ""}`.trim());
102
+ break;
103
+ case "strategy_close":
104
+ case "strategy_close_positions":
105
+ parts.push(`Close strategy ${strategyId ?? ""}`.trim());
106
+ break;
107
+ case "strategy_update":
108
+ parts.push(`Update strategy ${strategyId ?? ""}`.trim());
109
+ break;
110
+ case "strategy_pause":
111
+ parts.push(`Pause strategy ${strategyId ?? ""}`.trim());
112
+ break;
113
+ case "strategy_top_up":
114
+ parts.push(`Add ${amount ? `$${amount} ` : ""}funds to strategy ${strategyId ?? ""}`.trim());
115
+ break;
116
+ case "strategy_withdraw_funds":
117
+ parts.push(`Withdraw ${amount ? `$${amount} ` : ""}from strategy ${strategyId ?? ""}`.trim());
118
+ break;
119
+ case "strategy_bridge_funds_from_hyperliquid_to_evm":
120
+ parts.push(`Bridge ${amount ? `$${amount} ` : ""}from Hyperliquid to EVM`.trim());
121
+ break;
122
+ case "transfer_spot_to_perps":
123
+ parts.push(`Transfer ${amount ? `$${amount} ` : ""}from spot to perps`.trim());
124
+ break;
125
+ case "send_usdc":
126
+ parts.push(`Send ${amount ? `$${amount} ` : ""}USDC to ${str(p.to) ?? "?"}`.trim());
127
+ break;
128
+ default:
129
+ return undefined;
130
+ }
131
+ return parts.filter(Boolean).join(" · ");
132
+ }
133
+ /**
134
+ * Prompt body: the human sentence when we know the tool, plus the compact raw
135
+ * args so the exact numbers are always visible (senpi-web renders no args block
136
+ * for plugin approvals — see {@link describeSenpiToolCall}). Capped to the
137
+ * gateway's description limit, which rejects (not truncates) anything longer.
138
+ */
139
+ export function buildApprovalDescription(tool, params) {
140
+ let args = "";
141
+ try {
142
+ args = params === undefined ? "" : JSON.stringify(params);
143
+ }
144
+ catch {
145
+ args = "[unserializable params]";
146
+ }
147
+ const hasArgs = Boolean(args) && args !== "{}";
148
+ const sentence = describeSenpiToolCall(tool, params);
149
+ const head = sentence ?? tool;
150
+ const base = hasArgs ? `${head} — ${args}` : head;
151
+ return truncate(base, DESCRIPTION_MAX_LENGTH);
152
+ }
153
+ /**
154
+ * Register the `before_tool_call` approval gate. No-op in `off` mode.
155
+ * Returns the store (for tests/introspection) when registered.
156
+ */
157
+ export function registerToolApprovalGate(options) {
158
+ const { api, mode, stateDir, logger } = options;
159
+ if (mode === "off") {
160
+ logger?.info("[senpi-tool-approvals] disabled (mode=off)");
161
+ return undefined;
162
+ }
163
+ const manifest = options.manifest ?? loadToolApprovalsManifest();
164
+ const telemetry = options.telemetry ?? defaultGateTelemetry;
165
+ const tradeTools = new Set(manifest.tradeTools);
166
+ const timeoutMs = manifest.defaults.timeoutMs;
167
+ const store = new ToolApprovalStore(stateDir, logger);
168
+ logger?.info(`[senpi-tool-approvals] enabled | mode=${mode} tradeTools=${tradeTools.size} allowAlways=${store.size} timeoutMs=${timeoutMs}`);
169
+ api.on("before_tool_call", (event) => {
170
+ // The registry name openclaw uses on the wire (e.g. `senpi__create_position`).
171
+ // Telemetry keys on it for consistency with the span/tool.called stream,
172
+ // which use the prefixed name too. Set inside the try so a hostile event
173
+ // shape can't escape the fail-open catch.
174
+ let wireName;
175
+ try {
176
+ const ev = event;
177
+ wireName = typeof ev?.toolName === "string" ? ev.toolName : undefined;
178
+ const tool = matchSenpiTool(ev?.toolName);
179
+ if (!tool) {
180
+ return undefined;
181
+ }
182
+ const isTrade = tradeTools.has(tool);
183
+ if (mode === "trades" && !isTrade) {
184
+ return undefined;
185
+ }
186
+ if (store.isAllowedAlways(tool)) {
187
+ return undefined;
188
+ }
189
+ return {
190
+ requireApproval: {
191
+ title: truncate(`Senpi trade approval: ${tool}`, TITLE_MAX_LENGTH),
192
+ description: buildApprovalDescription(tool, ev?.params),
193
+ severity: isTrade ? "critical" : "warning",
194
+ timeoutMs,
195
+ timeoutBehavior: "deny",
196
+ onResolution: (decision) => {
197
+ const name = wireName ?? `senpi__${tool}`;
198
+ if (decision === "allow-always") {
199
+ store.rememberAllowAlways(tool);
200
+ logger?.info(`[senpi-tool-approvals] allow-always persisted | tool=${tool}`);
201
+ }
202
+ else if (decision === "deny") {
203
+ telemetry.denied(name, "user_denied");
204
+ }
205
+ else if (decision === "timeout") {
206
+ // The user missed the prompt: a state-changing tool the gateway
207
+ // fails closed. A real product signal, and otherwise invisible.
208
+ telemetry.denied(name, "approval_timeout");
209
+ }
210
+ // Audit every terminal decision — the only record of the approve
211
+ // path (allow-once vs allow-always). `cancelled` (run aborted) is
212
+ // not a user decision, so it's excluded.
213
+ if (decision === "allow-once" ||
214
+ decision === "allow-always" ||
215
+ decision === "deny" ||
216
+ decision === "timeout") {
217
+ telemetry.resolved(name, decision, isTrade);
218
+ }
219
+ },
220
+ },
221
+ };
222
+ }
223
+ catch (err) {
224
+ // Never break the tool pipeline on a gate bug — fail OPEN, but make it
225
+ // loud: this is the one place a money-safety gate stops protecting.
226
+ logger?.warn(`[senpi-tool-approvals] gate handler failed; tool proceeds ungated | err=${err instanceof Error ? err.message : String(err)}`);
227
+ telemetry.gateError(err, wireName);
228
+ return undefined;
229
+ }
230
+ });
231
+ return store;
232
+ }
233
+ //# sourceMappingURL=tool-approval-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-approval-gate.js","sourceRoot":"","sources":["../../src/approvals/tool-approval-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,yBAAyB,GAG1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAsB,MAAM,gBAAgB,CAAC;AA0C1E,yFAAyF;AACzF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBA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AAM;4BACnB,QAAQ,KAAK,SAAS,EACtB,CAAC;4BACD,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;wBAC9C,CAAC;oBACH,CAAC;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,uEAAuE;YACvE,oEAAoE;YACpE,MAAM,EAAE,IAAI,CACV,2EAA2E,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC9H,CAAC;YACF,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,27 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "defaults": {
4
+ "mode": "trades",
5
+ "timeoutMs": 600000
6
+ },
7
+ "tradeTools": [
8
+ "create_position",
9
+ "close_position",
10
+ "edit_position",
11
+ "cancel_order",
12
+ "strategy_create",
13
+ "strategy_create_custom_strategy",
14
+ "strategy_close",
15
+ "strategy_close_positions",
16
+ "strategy_update",
17
+ "strategy_pause",
18
+ "strategy_top_up",
19
+ "strategy_withdraw_funds",
20
+ "strategy_bridge_funds_from_hyperliquid_to_evm",
21
+ "transfer_spot_to_perps",
22
+ "send_usdc",
23
+ "ratchet_stop_add",
24
+ "ratchet_stop_edit",
25
+ "ratchet_stop_delete"
26
+ ]
27
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"guide-commands.d.ts","sourceRoot":"","sources":["../../src/cli/guide-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA6cH,eAAO,MAAM,eAAe,QAqLpB,CAAC;AAIT,kFAAkF;AAClF,UAAU,gBAAgB;IACxB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAA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