@senpi-ai/runtime 3.0.77 → 3.0.80

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 (167) hide show
  1. package/README.md +76 -2
  2. package/dist/cli/deploy-render.d.ts +93 -0
  3. package/dist/cli/deploy-render.d.ts.map +1 -0
  4. package/dist/cli/deploy-render.js +438 -0
  5. package/dist/cli/deploy-render.js.map +1 -0
  6. package/dist/cli/guide-commands.d.ts.map +1 -1
  7. package/dist/cli/guide-commands.js +94 -9
  8. package/dist/cli/guide-commands.js.map +1 -1
  9. package/dist/cli/senpi-commands.d.ts +6 -1
  10. package/dist/cli/senpi-commands.d.ts.map +1 -1
  11. package/dist/cli/senpi-commands.js +290 -41
  12. package/dist/cli/senpi-commands.js.map +1 -1
  13. package/dist/cli/validate-command.d.ts.map +1 -1
  14. package/dist/cli/validate-command.js +10 -1
  15. package/dist/cli/validate-command.js.map +1 -1
  16. package/dist/deploy/deadlines.d.ts +107 -0
  17. package/dist/deploy/deadlines.d.ts.map +1 -0
  18. package/dist/deploy/deadlines.js +139 -0
  19. package/dist/deploy/deadlines.js.map +1 -0
  20. package/dist/deploy/error-text.d.ts +25 -0
  21. package/dist/deploy/error-text.d.ts.map +1 -0
  22. package/dist/deploy/error-text.js +42 -0
  23. package/dist/deploy/error-text.js.map +1 -0
  24. package/dist/deploy/funding.d.ts +125 -0
  25. package/dist/deploy/funding.d.ts.map +1 -0
  26. package/dist/deploy/funding.js +268 -0
  27. package/dist/deploy/funding.js.map +1 -0
  28. package/dist/deploy/install-gate-runner.d.ts +12 -0
  29. package/dist/deploy/install-gate-runner.d.ts.map +1 -0
  30. package/dist/deploy/install-gate-runner.js +17 -0
  31. package/dist/deploy/install-gate-runner.js.map +1 -0
  32. package/dist/deploy/job.d.ts +215 -0
  33. package/dist/deploy/job.d.ts.map +1 -0
  34. package/dist/deploy/job.js +484 -0
  35. package/dist/deploy/job.js.map +1 -0
  36. package/dist/deploy/messages.d.ts +603 -0
  37. package/dist/deploy/messages.d.ts.map +1 -0
  38. package/dist/deploy/messages.js +1388 -0
  39. package/dist/deploy/messages.js.map +1 -0
  40. package/dist/deploy/min-budget.d.ts +68 -0
  41. package/dist/deploy/min-budget.d.ts.map +1 -0
  42. package/dist/deploy/min-budget.js +297 -0
  43. package/dist/deploy/min-budget.js.map +1 -0
  44. package/dist/deploy/orchestrator.d.ts +314 -0
  45. package/dist/deploy/orchestrator.d.ts.map +1 -0
  46. package/dist/deploy/orchestrator.js +2171 -0
  47. package/dist/deploy/orchestrator.js.map +1 -0
  48. package/dist/deploy/package.d.ts +228 -0
  49. package/dist/deploy/package.d.ts.map +1 -0
  50. package/dist/deploy/package.js +542 -0
  51. package/dist/deploy/package.js.map +1 -0
  52. package/dist/deploy/proof-gate.d.ts +86 -0
  53. package/dist/deploy/proof-gate.d.ts.map +1 -0
  54. package/dist/deploy/proof-gate.js +278 -0
  55. package/dist/deploy/proof-gate.js.map +1 -0
  56. package/dist/deploy/python-float.d.ts +34 -0
  57. package/dist/deploy/python-float.d.ts.map +1 -0
  58. package/dist/deploy/python-float.js +46 -0
  59. package/dist/deploy/python-float.js.map +1 -0
  60. package/dist/deploy/recheck-commands.d.ts +50 -0
  61. package/dist/deploy/recheck-commands.d.ts.map +1 -0
  62. package/dist/deploy/recheck-commands.js +77 -0
  63. package/dist/deploy/recheck-commands.js.map +1 -0
  64. package/dist/deploy/register.d.ts +101 -0
  65. package/dist/deploy/register.d.ts.map +1 -0
  66. package/dist/deploy/register.js +714 -0
  67. package/dist/deploy/register.js.map +1 -0
  68. package/dist/deploy/taxonomy.d.ts +43 -0
  69. package/dist/deploy/taxonomy.d.ts.map +1 -0
  70. package/dist/deploy/taxonomy.js +59 -0
  71. package/dist/deploy/taxonomy.js.map +1 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +467 -222
  74. package/dist/index.js.map +1 -1
  75. package/dist/runtime/env-resolve.d.ts +13 -0
  76. package/dist/runtime/env-resolve.d.ts.map +1 -1
  77. package/dist/runtime/env-resolve.js +14 -1
  78. package/dist/runtime/env-resolve.js.map +1 -1
  79. package/dist/runtime/runtime-descriptor.d.ts +37 -0
  80. package/dist/runtime/runtime-descriptor.d.ts.map +1 -0
  81. package/dist/runtime/runtime-descriptor.js +163 -0
  82. package/dist/runtime/runtime-descriptor.js.map +1 -0
  83. package/dist/runtime/runtime-schema.d.ts +100 -100
  84. package/dist/runtime/strategy-registry.d.ts +8 -0
  85. package/dist/runtime/strategy-registry.d.ts.map +1 -1
  86. package/dist/runtime/strategy-registry.js +14 -1
  87. package/dist/runtime/strategy-registry.js.map +1 -1
  88. package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
  89. package/dist/runtime-api/intake/intake-mount.js +7 -4
  90. package/dist/runtime-api/intake/intake-mount.js.map +1 -1
  91. package/dist/scanners/external/scaffold/preflight.py +39 -0
  92. package/dist/scanners/implementations/market-regime.d.ts +1 -1
  93. package/dist/senpi/client.d.ts +58 -4
  94. package/dist/senpi/client.d.ts.map +1 -1
  95. package/dist/senpi/client.js +262 -18
  96. package/dist/senpi/client.js.map +1 -1
  97. package/dist/senpi/strategy-status.d.ts +32 -0
  98. package/dist/senpi/strategy-status.d.ts.map +1 -0
  99. package/dist/senpi/strategy-status.js +70 -0
  100. package/dist/senpi/strategy-status.js.map +1 -0
  101. package/dist/senpi/types.d.ts +65 -3
  102. package/dist/senpi/types.d.ts.map +1 -1
  103. package/dist/skills-manager/manifest.d.ts.map +1 -1
  104. package/dist/skills-manager/manifest.js +4 -3
  105. package/dist/skills-manager/manifest.js.map +1 -1
  106. package/dist/skills-manager/skills-manifest.json +4 -3
  107. package/dist/telemetry/metrics.d.ts +30 -0
  108. package/dist/telemetry/metrics.d.ts.map +1 -1
  109. package/dist/telemetry/metrics.js +72 -0
  110. package/dist/telemetry/metrics.js.map +1 -1
  111. package/dist/types/strategy.d.ts +9 -1
  112. package/dist/types/strategy.d.ts.map +1 -1
  113. package/dist/universe/package-universe.d.ts +97 -0
  114. package/dist/universe/package-universe.d.ts.map +1 -0
  115. package/dist/universe/package-universe.js +304 -0
  116. package/dist/universe/package-universe.js.map +1 -0
  117. package/dist/validate/codes.d.ts +30 -0
  118. package/dist/validate/codes.d.ts.map +1 -1
  119. package/dist/validate/codes.js +74 -1
  120. package/dist/validate/codes.js.map +1 -1
  121. package/dist/validate/index.d.ts +1 -1
  122. package/dist/validate/index.d.ts.map +1 -1
  123. package/dist/validate/index.js.map +1 -1
  124. package/dist/validate/install-gate.d.ts.map +1 -1
  125. package/dist/validate/install-gate.js +10 -2
  126. package/dist/validate/install-gate.js.map +1 -1
  127. package/dist/validate/live-instruments.d.ts +44 -0
  128. package/dist/validate/live-instruments.d.ts.map +1 -0
  129. package/dist/validate/live-instruments.js +71 -0
  130. package/dist/validate/live-instruments.js.map +1 -0
  131. package/dist/validate/live-stage.d.ts +8 -0
  132. package/dist/validate/live-stage.d.ts.map +1 -1
  133. package/dist/validate/live-stage.js +87 -18
  134. package/dist/validate/live-stage.js.map +1 -1
  135. package/dist/validate/package-gates-stage.d.ts +61 -0
  136. package/dist/validate/package-gates-stage.d.ts.map +1 -0
  137. package/dist/validate/package-gates-stage.js +215 -0
  138. package/dist/validate/package-gates-stage.js.map +1 -0
  139. package/dist/validate/proof.d.ts +11 -1
  140. package/dist/validate/proof.d.ts.map +1 -1
  141. package/dist/validate/proof.js +10 -6
  142. package/dist/validate/proof.js.map +1 -1
  143. package/dist/validate/recipe-checks.d.ts.map +1 -1
  144. package/dist/validate/recipe-checks.js +6 -4
  145. package/dist/validate/recipe-checks.js.map +1 -1
  146. package/dist/validate/run.d.ts +29 -1
  147. package/dist/validate/run.d.ts.map +1 -1
  148. package/dist/validate/run.js +65 -6
  149. package/dist/validate/run.js.map +1 -1
  150. package/dist/validate/target.d.ts +41 -0
  151. package/dist/validate/target.d.ts.map +1 -1
  152. package/dist/validate/target.js +192 -16
  153. package/dist/validate/target.js.map +1 -1
  154. package/dist/validate/taxonomy-finding.d.ts +22 -0
  155. package/dist/validate/taxonomy-finding.d.ts.map +1 -0
  156. package/dist/validate/taxonomy-finding.js +25 -0
  157. package/dist/validate/taxonomy-finding.js.map +1 -0
  158. package/dist/validate/universe-stage.d.ts +71 -0
  159. package/dist/validate/universe-stage.d.ts.map +1 -0
  160. package/dist/validate/universe-stage.js +165 -0
  161. package/dist/validate/universe-stage.js.map +1 -0
  162. package/dist/validate/wallet-binding-stage.d.ts +44 -0
  163. package/dist/validate/wallet-binding-stage.d.ts.map +1 -0
  164. package/dist/validate/wallet-binding-stage.js +92 -0
  165. package/dist/validate/wallet-binding-stage.js.map +1 -0
  166. package/openclaw.plugin.json +1 -1
  167. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Reading the text off a thrown value, for the deploy path.
3
+ *
4
+ * Its own module because both consumers are on the money path and neither may import the other:
5
+ * `orchestrator.ts` already imports `../universe/package-universe.ts`, so putting it in either would
6
+ * make a cycle, and a second hand-rolled copy is how the two drifted in the first place.
7
+ */
8
+ /** What a value with no readable text is called, so the report says so instead of inventing one. */
9
+ export declare const UNREADABLE_ERROR = "an error whose message could not be read";
10
+ /**
11
+ * The text of a thrown value — TOTAL, because every caller is a catch block whose job is to keep the
12
+ * deploy report alive.
13
+ *
14
+ * Reading a thrown value is itself an operation that can throw: a `message` getter that raises, a
15
+ * null-prototype object `String()` cannot convert to a primitive, a hostile `toString`. Those come
16
+ * off the wire like any other error, and a throw here happens INSIDE the catch — so it discards the
17
+ * original error, escapes `runDeploy` and costs the whole report the deploy just earned. An error
18
+ * we cannot name is still an error we must report, so it degrades rather than raising.
19
+ *
20
+ * The degraded form still says everything it can: the constructor name usually survives a hostile
21
+ * `message`, and on an error with nothing else readable it is the only diagnostic left — a
22
+ * `TimeoutError` and a `ZodError` send a reader to different places.
23
+ */
24
+ export declare function errorText(err: unknown): string;
25
+ //# sourceMappingURL=error-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-text.d.ts","sourceRoot":"","sources":["../../src/deploy/error-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oGAAoG;AACpG,eAAO,MAAM,gBAAgB,6CAA6C,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAM9C"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Reading the text off a thrown value, for the deploy path.
3
+ *
4
+ * Its own module because both consumers are on the money path and neither may import the other:
5
+ * `orchestrator.ts` already imports `../universe/package-universe.ts`, so putting it in either would
6
+ * make a cycle, and a second hand-rolled copy is how the two drifted in the first place.
7
+ */
8
+ /** What a value with no readable text is called, so the report says so instead of inventing one. */
9
+ export const UNREADABLE_ERROR = "an error whose message could not be read";
10
+ /**
11
+ * The text of a thrown value — TOTAL, because every caller is a catch block whose job is to keep the
12
+ * deploy report alive.
13
+ *
14
+ * Reading a thrown value is itself an operation that can throw: a `message` getter that raises, a
15
+ * null-prototype object `String()` cannot convert to a primitive, a hostile `toString`. Those come
16
+ * off the wire like any other error, and a throw here happens INSIDE the catch — so it discards the
17
+ * original error, escapes `runDeploy` and costs the whole report the deploy just earned. An error
18
+ * we cannot name is still an error we must report, so it degrades rather than raising.
19
+ *
20
+ * The degraded form still says everything it can: the constructor name usually survives a hostile
21
+ * `message`, and on an error with nothing else readable it is the only diagnostic left — a
22
+ * `TimeoutError` and a `ZodError` send a reader to different places.
23
+ */
24
+ export function errorText(err) {
25
+ try {
26
+ return err instanceof Error ? String(err.message) : String(err);
27
+ }
28
+ catch {
29
+ return `${UNREADABLE_ERROR}${errorTypeSuffix(err)}`;
30
+ }
31
+ }
32
+ /** ` (TimeoutError)` when the thrown value's constructor name is readable, else nothing. */
33
+ function errorTypeSuffix(err) {
34
+ try {
35
+ const name = err?.constructor?.name;
36
+ return typeof name === "string" && name.length > 0 ? ` (${name})` : "";
37
+ }
38
+ catch {
39
+ return "";
40
+ }
41
+ }
42
+ //# sourceMappingURL=error-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-text.js","sourceRoot":"","sources":["../../src/deploy/error-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oGAAoG;AACpG,MAAM,CAAC,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,IAAI,CAAC;QACH,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,gBAAgB,GAAG,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;IACtD,CAAC;AACH,CAAC;AAED,4FAA4F;AAC5F,SAAS,eAAe,CAAC,GAAY;IACnC,IAAI,CAAC;QACH,MAAM,IAAI,GAAI,GAA4C,EAAE,WAAW,EAAE,IAAI,CAAC;QAC9E,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,125 @@
1
+ /** The platform per-wallet floor, under this module's own long-standing name. */
2
+ export { WALLET_FLOOR as MIN_WALLET, FEE_BUFFER } from "./min-budget.js";
3
+ /** Lifecycle-relevant per-instance funding inputs — the only fields this module reads. */
4
+ export interface FundingInstance {
5
+ name: string;
6
+ fundingShare: number | null;
7
+ }
8
+ export interface Shortfall {
9
+ requested: number;
10
+ available: number;
11
+ usable: number;
12
+ shortBy: number;
13
+ wallets: number;
14
+ shares: number[];
15
+ }
16
+ export interface FundingPlan {
17
+ /** instance name → initialBudget for the create call. */
18
+ amounts: Map<string, number>;
19
+ /** Non-null means HALT: the budget is a hard target, never silently scaled down. */
20
+ shortfall: Shortfall | null;
21
+ }
22
+ /**
23
+ * Total USDC `strategy_create_custom_strategy` can fund from — its whole
24
+ * waterfall, in order: HL perps → HL spot USDC → EVM USDC (auto-bridged).
25
+ *
26
+ * These are DISJOINT buckets, so reading one reads a FRACTION of the fundable
27
+ * balance. `total_withdrawable` is deliberately EXCLUDED: it is free margin
28
+ * sitting inside OTHER strategy wallets, not spendable here.
29
+ *
30
+ * Returns null when no bucket key is present at all — an unknown shape must
31
+ * never halt a deploy the backend would have funded.
32
+ */
33
+ export declare function accessibleUsd(payload: Record<string, unknown> | null): number | null;
34
+ /** A sleeve's effective share, as the funding plan will use it. */
35
+ export interface InstanceShare {
36
+ name: string;
37
+ share: number;
38
+ }
39
+ /** The shares allocate more than the whole budget — {@link sharesOverAuthorization}. */
40
+ export interface ShareOverrun {
41
+ sum: number;
42
+ shares: InstanceShare[];
43
+ }
44
+ /**
45
+ * Do the effective funding shares allocate MORE than the budget authorizes?
46
+ *
47
+ * `planFunding` checks its total against the accessible BALANCE and nothing else — it never
48
+ * compares the plan to `--budget`. And `loadDeployPackage` deliberately does not validate
49
+ * `funding_share` (the skills-side `_pkg.validate` does, and the verb is a direct path that never
50
+ * runs it), so shares summing above 1 reach funding intact: `0.6` on both sleeves of a `--budget
51
+ * 500` deploy requests $600, the balance check passes against a larger wallet, and no step, note or
52
+ * `overall` in the report ever says the funded total exceeded the ask. The bigger the balance, the
53
+ * bigger the silent overrun.
54
+ *
55
+ * Keyed on the SHARES, not on `requested > budget`, and the difference is load-bearing:
56
+ * `planFunding` floors every wallet at {@link MIN_WALLET}, so two half-share sleeves at
57
+ * `--budget 10` legitimately request $20. That is the floor doing its documented job — it has its
58
+ * own surfaces and its own soft tier — and a gate keyed on the funded total would refuse every
59
+ * correct low-budget multi-sleeve deploy. What is never legitimate is a plan that hands out more
60
+ * than the whole authorization before the floor is applied at all.
61
+ *
62
+ * Reads the EFFECTIVE shares through the same {@link sharesOf} the plan uses, so a partly-declared
63
+ * manifest (one sleeve at `0.8`, one undeclared and therefore `1/n`) is judged on what will
64
+ * actually be funded rather than on the declared subset. One producer: a second reading of this
65
+ * arithmetic is how the two sides of a split come to disagree.
66
+ *
67
+ * Returns null when the shares fit — the tolerance absorbs the float error an even split carries
68
+ * (three sleeves at `1/3` sum to 1.0000000000000002), never a real overrun, which is at minimum a
69
+ * whole extra percentage point.
70
+ */
71
+ export declare function sharesOverAuthorization(instances: FundingInstance[]): ShareOverrun | null;
72
+ /**
73
+ * Per-instance `initialBudget` for the instances still needing a wallet, split
74
+ * by `fundingShare` and floored at {@link MIN_WALLET}.
75
+ *
76
+ * The requested budget is a HARD TARGET: on shortfall the caller HALTS. Scaling
77
+ * every wallet down to fit turned a "$1,000 across 2 wallets" request into two
78
+ * floor wallets, silently — that is the bug this shape exists to prevent.
79
+ */
80
+ export declare function planFunding(instances: FundingInstance[], budget: number, available: number | null): FundingPlan;
81
+ /**
82
+ * The largest budget `b` whose funding plan still fits within `usable`:
83
+ * `b* = max { b : Σᵢ max(MIN_WALLET, round2(b·shareᵢ)) ≤ usable }`.
84
+ *
85
+ * Bisected in integer cents with the SAME per-wallet rounding `planFunding`
86
+ * uses, so re-running deploy at the hinted budget round-trips with no shortfall
87
+ * even for uneven shares — where the bare `usable` over-hints, because a floored
88
+ * small leg pushes the funded total above the budget.
89
+ */
90
+ export declare function maxFeasibleBudget(instances: Array<{
91
+ fundingShare: number | null;
92
+ }>, usable: number): number;
93
+ /** Money in agent-facing prose: comma-grouped, two decimals, never scientific notation. */
94
+ export declare function usd(value: number): string;
95
+ /**
96
+ * A dollar amount as the `--budget` flag accepts it: bare digits, no `$`, no
97
+ * comma grouping. {@link usd}'s commas would not parse as a number, so a hinted
98
+ * command an agent copies verbatim must render the flag value with this.
99
+ */
100
+ export declare function budgetArg(value: number): string;
101
+ /**
102
+ * The re-run command every deploy surface emits — ONE producer, because the same report prints it
103
+ * more than once (a refusal's copy and the report's `next` line) and two copies drifting would hand
104
+ * the reader two different commands for one situation. `budget` undefined renders the placeholder
105
+ * the caller must fill in, never a fabricated number.
106
+ *
107
+ * The path is single-quoted for the same reason `pkg.id` is wherever it is emitted: these strings
108
+ * are copied into a shell verbatim, and a real workspace path with a space in it
109
+ * ("/data/My Strategies/spider") would otherwise render a command that cannot run. Quoting is
110
+ * unconditional — a conditional quote is a second rule to get wrong, and the quoted form is
111
+ * correct for every path.
112
+ */
113
+ export declare function resumeCommand(packageDir: string, budget?: number): string;
114
+ /**
115
+ * Agent-facing halt text for a funding shortfall.
116
+ *
117
+ * The lower-budget escape renders ONLY when the usable balance can still fund
118
+ * every wallet at the {@link MIN_WALLET} floor. Below that no budget is valid,
119
+ * and suggesting one produces nonsense the agent then follows ("--budget ≤ $0",
120
+ * the M381223 churn). Codes: senpi-skills `docs/error-code-taxonomy.md`.
121
+ */
122
+ export declare function underfundedNote(shortfall: Shortfall, instances: Array<{
123
+ fundingShare: number | null;
124
+ }>, packageDir: string): string;
125
+ //# sourceMappingURL=funding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../../src/deploy/funding.ts"],"names":[],"mappings":"AAqBA,iFAAiF;AACjF,OAAO,EAAE,YAAY,IAAI,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzE,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,OAAO,EAA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AAS,EACpB,SAAS,EAAE,KAAK,CAAC;IAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,EACjD,UAAU,EAAE,MAAM,GACjB,MAAM,CA6BR"}
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Funding preflight for `senpi deploy` — a 1:1 TS port of deploy.py v2.11.0's
3
+ * `available_usd` / `plan_funding` / `max_feasible_budget` / `underfunded_note`.
4
+ *
5
+ * This layer is UX, not enforcement: the backend funds from its own waterfall
6
+ * during `strategy_create_custom_strategy` and remains the authority on
7
+ * sufficiency. So it refuses only on POSITIVE evidence of a shortfall — an
8
+ * unreadable or unrecognised portfolio shape yields `null` and the deploy
9
+ * proceeds (create fails loudly if the balance really is short). Under-counting
10
+ * is the dangerous direction: it produced the Starling false refusal, where
11
+ * ~$248 of idle Base USDC was invisible to a single-bucket read.
12
+ *
13
+ * The two platform constants it runs on live in `min-budget.ts`, which mirrors
14
+ * `senpi-strategy-ops/scripts/min_budget.py` in Senpi-ai/senpi-skills — ONE source of truth for the
15
+ * physics on each side: a **$10** per-wallet floor (`WALLET_FLOOR`, itself mirroring the backend's
16
+ * `MINIMUM_STRATEGY_BUDGET` default) and a **$1.50** per-wallet fee buffer. Change them there, never
17
+ * here, and never against a remembered number: the floor was $100 until the skills $10-minimum
18
+ * rollout (#519/#521), and every refusal below quotes whatever the constant says.
19
+ */
20
+ import { FEE_BUFFER, WALLET_FLOOR as MIN_WALLET } from "./min-budget.js";
21
+ /** The platform per-wallet floor, under this module's own long-standing name. */
22
+ export { WALLET_FLOOR as MIN_WALLET, FEE_BUFFER } from "./min-budget.js";
23
+ function round2(value) {
24
+ return Math.round(value * 100) / 100;
25
+ }
26
+ function isRecord(value) {
27
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28
+ }
29
+ /**
30
+ * First of `values` that parses as a finite number, else 0.
31
+ *
32
+ * The payload mixes numbers, numeric strings (`spot_balances` rows carry
33
+ * `"5.46"`) and nulls — a null must fall THROUGH to the next candidate rather
34
+ * than zero the row, because an under-count here is a false `underfunded` halt.
35
+ */
36
+ function firstNumber(...values) {
37
+ for (const value of values) {
38
+ if (typeof value === "number" && Number.isFinite(value))
39
+ return value;
40
+ if (typeof value === "string" && value.trim() !== "") {
41
+ const parsed = Number(value);
42
+ if (Number.isFinite(parsed))
43
+ return parsed;
44
+ }
45
+ }
46
+ return 0;
47
+ }
48
+ /**
49
+ * USD held as USDC in a balance list (`spot_balances` / `token_balances`).
50
+ * Filtered by symbol because the funding waterfall pulls USDC, while the
51
+ * `total_*` scalars lump in every other token — a spot HYPE bag or EVM WETH is
52
+ * not fundable balance. Deliberately chain-agnostic: hardcoding the bridgeable
53
+ * chain list is how this gate would start refusing fundable deploys the day a
54
+ * chain is added.
55
+ */
56
+ function usdcUsd(rows, ...keys) {
57
+ if (!Array.isArray(rows))
58
+ return 0;
59
+ return rows.reduce((sum, row) => {
60
+ if (!isRecord(row))
61
+ return sum;
62
+ if (String(row.tokenSymbol ?? "").trim().toUpperCase() !== "USDC")
63
+ return sum;
64
+ return sum + firstNumber(...keys.map((key) => row[key]));
65
+ }, 0);
66
+ }
67
+ /** The bucket keys whose presence proves the payload is a portfolio we understand. */
68
+ const BUCKET_KEYS = [
69
+ "total_in_hyperliquid",
70
+ "total_spot_usd_in_hyperliquid",
71
+ "spot_balances",
72
+ "token_balances",
73
+ ];
74
+ /**
75
+ * Total USDC `strategy_create_custom_strategy` can fund from — its whole
76
+ * waterfall, in order: HL perps → HL spot USDC → EVM USDC (auto-bridged).
77
+ *
78
+ * These are DISJOINT buckets, so reading one reads a FRACTION of the fundable
79
+ * balance. `total_withdrawable` is deliberately EXCLUDED: it is free margin
80
+ * sitting inside OTHER strategy wallets, not spendable here.
81
+ *
82
+ * Returns null when no bucket key is present at all — an unknown shape must
83
+ * never halt a deploy the backend would have funded.
84
+ */
85
+ export function accessibleUsd(payload) {
86
+ const portfolio = isRecord(payload?.portfolio) ? payload.portfolio : null;
87
+ if (!portfolio)
88
+ return null;
89
+ if (!BUCKET_KEYS.some((key) => portfolio[key] !== undefined && portfolio[key] !== null))
90
+ return null;
91
+ const perps = firstNumber(portfolio.total_in_hyperliquid);
92
+ const spotRows = portfolio.spot_balances;
93
+ const spot = Array.isArray(spotRows) && spotRows.length > 0
94
+ ? usdcUsd(spotRows, "usdValue", "total")
95
+ : firstNumber(portfolio.total_spot_usd_in_hyperliquid);
96
+ const evm = usdcUsd(portfolio.token_balances, "balanceInUSD", "formattedBalance");
97
+ return round2(perps + spot + evm);
98
+ }
99
+ function sharesOf(instances) {
100
+ return instances.map((inst) => inst.fundingShare ?? 1 / instances.length);
101
+ }
102
+ /**
103
+ * Do the effective funding shares allocate MORE than the budget authorizes?
104
+ *
105
+ * `planFunding` checks its total against the accessible BALANCE and nothing else — it never
106
+ * compares the plan to `--budget`. And `loadDeployPackage` deliberately does not validate
107
+ * `funding_share` (the skills-side `_pkg.validate` does, and the verb is a direct path that never
108
+ * runs it), so shares summing above 1 reach funding intact: `0.6` on both sleeves of a `--budget
109
+ * 500` deploy requests $600, the balance check passes against a larger wallet, and no step, note or
110
+ * `overall` in the report ever says the funded total exceeded the ask. The bigger the balance, the
111
+ * bigger the silent overrun.
112
+ *
113
+ * Keyed on the SHARES, not on `requested > budget`, and the difference is load-bearing:
114
+ * `planFunding` floors every wallet at {@link MIN_WALLET}, so two half-share sleeves at
115
+ * `--budget 10` legitimately request $20. That is the floor doing its documented job — it has its
116
+ * own surfaces and its own soft tier — and a gate keyed on the funded total would refuse every
117
+ * correct low-budget multi-sleeve deploy. What is never legitimate is a plan that hands out more
118
+ * than the whole authorization before the floor is applied at all.
119
+ *
120
+ * Reads the EFFECTIVE shares through the same {@link sharesOf} the plan uses, so a partly-declared
121
+ * manifest (one sleeve at `0.8`, one undeclared and therefore `1/n`) is judged on what will
122
+ * actually be funded rather than on the declared subset. One producer: a second reading of this
123
+ * arithmetic is how the two sides of a split come to disagree.
124
+ *
125
+ * Returns null when the shares fit — the tolerance absorbs the float error an even split carries
126
+ * (three sleeves at `1/3` sum to 1.0000000000000002), never a real overrun, which is at minimum a
127
+ * whole extra percentage point.
128
+ */
129
+ export function sharesOverAuthorization(instances) {
130
+ if (instances.length === 0)
131
+ return null;
132
+ const shares = sharesOf(instances);
133
+ const sum = shares.reduce((total, share) => total + share, 0);
134
+ if (sum <= 1 + 1e-9)
135
+ return null;
136
+ return {
137
+ sum,
138
+ shares: instances.map((inst, i) => ({ name: inst.name, share: shares[i] })),
139
+ };
140
+ }
141
+ /**
142
+ * Per-instance `initialBudget` for the instances still needing a wallet, split
143
+ * by `fundingShare` and floored at {@link MIN_WALLET}.
144
+ *
145
+ * The requested budget is a HARD TARGET: on shortfall the caller HALTS. Scaling
146
+ * every wallet down to fit turned a "$1,000 across 2 wallets" request into two
147
+ * floor wallets, silently — that is the bug this shape exists to prevent.
148
+ */
149
+ export function planFunding(instances, budget, available) {
150
+ const shares = sharesOf(instances);
151
+ const amounts = new Map(instances.map((inst, i) => [inst.name, Math.max(MIN_WALLET, round2((budget || 0) * shares[i]))]));
152
+ const requested = round2([...amounts.values()].reduce((sum, amount) => sum + amount, 0));
153
+ let shortfall = null;
154
+ if (available !== null) {
155
+ const usable = Math.max(0, round2(available - FEE_BUFFER * instances.length));
156
+ if (requested > usable) {
157
+ shortfall = {
158
+ requested,
159
+ available: round2(available),
160
+ usable,
161
+ shortBy: round2(requested - usable),
162
+ wallets: instances.length,
163
+ shares,
164
+ };
165
+ }
166
+ }
167
+ return { amounts, shortfall };
168
+ }
169
+ /**
170
+ * The largest budget `b` whose funding plan still fits within `usable`:
171
+ * `b* = max { b : Σᵢ max(MIN_WALLET, round2(b·shareᵢ)) ≤ usable }`.
172
+ *
173
+ * Bisected in integer cents with the SAME per-wallet rounding `planFunding`
174
+ * uses, so re-running deploy at the hinted budget round-trips with no shortfall
175
+ * even for uneven shares — where the bare `usable` over-hints, because a floored
176
+ * small leg pushes the funded total above the budget.
177
+ */
178
+ export function maxFeasibleBudget(instances, usable) {
179
+ const shares = sharesOf(instances);
180
+ const totalCents = (cents) => {
181
+ const budget = cents / 100;
182
+ const total = shares.reduce((sum, share) => sum + Math.max(MIN_WALLET, round2(budget * share)), 0);
183
+ return Math.round(total * 100);
184
+ };
185
+ const usableCents = Math.round(usable * 100);
186
+ if (totalCents(0) > usableCents)
187
+ return 0; // even the all-floor minimum cannot fit
188
+ let lo = 0;
189
+ let hi = usableCents + shares.length * Math.round(MIN_WALLET * 100) + 100;
190
+ while (totalCents(hi) <= usableCents)
191
+ hi *= 2; // keep hi a true upper bound (defensive vs Σshare < 1)
192
+ while (lo < hi) {
193
+ const mid = Math.floor((lo + hi + 1) / 2);
194
+ if (totalCents(mid) <= usableCents)
195
+ lo = mid;
196
+ else
197
+ hi = mid - 1;
198
+ }
199
+ return lo / 100;
200
+ }
201
+ /** Money in agent-facing prose: comma-grouped, two decimals, never scientific notation. */
202
+ export function usd(value) {
203
+ return `$${value.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
204
+ }
205
+ /**
206
+ * A dollar amount as the `--budget` flag accepts it: bare digits, no `$`, no
207
+ * comma grouping. {@link usd}'s commas would not parse as a number, so a hinted
208
+ * command an agent copies verbatim must render the flag value with this.
209
+ */
210
+ export function budgetArg(value) {
211
+ return String(Number(value.toFixed(2)));
212
+ }
213
+ /**
214
+ * The re-run command every deploy surface emits — ONE producer, because the same report prints it
215
+ * more than once (a refusal's copy and the report's `next` line) and two copies drifting would hand
216
+ * the reader two different commands for one situation. `budget` undefined renders the placeholder
217
+ * the caller must fill in, never a fabricated number.
218
+ *
219
+ * The path is single-quoted for the same reason `pkg.id` is wherever it is emitted: these strings
220
+ * are copied into a shell verbatim, and a real workspace path with a space in it
221
+ * ("/data/My Strategies/spider") would otherwise render a command that cannot run. Quoting is
222
+ * unconditional — a conditional quote is a second rule to get wrong, and the quoted form is
223
+ * correct for every path.
224
+ */
225
+ export function resumeCommand(packageDir, budget) {
226
+ const budgetFlag = budget === undefined ? "--budget <usd>" : `--budget ${budgetArg(budget)}`;
227
+ return `openclaw senpi deploy -p '${packageDir}' ${budgetFlag}`;
228
+ }
229
+ /** The requested/available/usable/short-by facts both refusal branches lead with. */
230
+ function shortfallFacts(shortfall) {
231
+ return (`Requested ${usd(shortfall.requested)} across ${shortfall.wallets} wallet(s) ` +
232
+ `(min ${usd(MIN_WALLET)}/wallet), but only ${usd(shortfall.available)} is accessible ` +
233
+ `(${usd(shortfall.usable)} after fees) — short by ${usd(shortfall.shortBy)}. ` +
234
+ `NOT funding; no wallet was created. `);
235
+ }
236
+ /**
237
+ * Agent-facing halt text for a funding shortfall.
238
+ *
239
+ * The lower-budget escape renders ONLY when the usable balance can still fund
240
+ * every wallet at the {@link MIN_WALLET} floor. Below that no budget is valid,
241
+ * and suggesting one produces nonsense the agent then follows ("--budget ≤ $0",
242
+ * the M381223 churn). Codes: senpi-skills `docs/error-code-taxonomy.md`.
243
+ */
244
+ export function underfundedNote(shortfall, instances, packageDir) {
245
+ const floorNeeded = shortfall.wallets * MIN_WALLET;
246
+ const facts = shortfallFacts(shortfall);
247
+ if (shortfall.usable < floorNeeded) {
248
+ // Computed from `available`, not `usable`: usable is clamped to 0 when the balance does not
249
+ // even cover the fee reserve, and `floor - usable` would then understate the deposit by up to
250
+ // FEE_BUFFER × wallets — depositing the hinted amount must always clear the floor check.
251
+ const missing = round2(floorNeeded + FEE_BUFFER * shortfall.wallets - shortfall.available);
252
+ return (`[E_FUNDS_BELOW_FLOOR] ${facts}` +
253
+ `No budget can fund ${shortfall.wallets} wallet(s) below the ${usd(MIN_WALLET)}/wallet floor — ` +
254
+ `at least ${usd(missing)} more USDC is needed. Deposit USDC first (the ` +
255
+ `\`senpi-deposit-withdraw-transfer\` skill has the flow), then re-run: ` +
256
+ `\`${resumeCommand(packageDir)}\`. ` +
257
+ `Do NOT retry with a lower --budget: no lower budget is valid.`);
258
+ }
259
+ const best = maxFeasibleBudget(instances, shortfall.usable);
260
+ return (`[E_FUNDS_SHORT] ${facts}` +
261
+ `Two ways forward: deposit at least ${usd(shortfall.shortBy)} more USDC (the ` +
262
+ `\`senpi-deposit-withdraw-transfer\` skill has the flow) and re-run the same command, or ` +
263
+ `confirm a lower amount with the user and re-run: ` +
264
+ `\`${resumeCommand(packageDir, best)}\` — ${usd(best)} is the largest ` +
265
+ `budget your accessible balance can fully fund across these ${shortfall.wallets} wallet(s) at ` +
266
+ `the ${usd(MIN_WALLET)}/wallet floor.`);
267
+ }
268
+ //# sourceMappingURL=funding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"funding.js","sourceRoot":"","sources":["../../src/deploy/funding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzE,iFAAiF;AACjF,OAAO,EAAE,YAAY,IAAI,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAwBzE,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,GAAG,MAAiB;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACtE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;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AC,SAAS,CAAC,CAAC;IAExC,IAAI,SAAS,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;QACnC,4FAA4F;QAC5F,8FAA8F;QAC9F,yFAAyF;QACzF,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3F,OAAO,CACL,yBAAyB,KAAK,EAAE;YAChC,sBAAsB,SAAS,CAAC,OAAO,wBAAwB,GAAG,CAAC,UAAU,CAAC,kBAAkB;YAChG,YAAY,GAAG,CAAC,OAAO,CAAC,gDAAgD;YACxE,wEAAwE;YACxE,KAAK,aAAa,CAAC,UAAU,CAAC,MAAM;YACpC,+DAA+D,CAChE,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5D,OAAO,CACL,mBAAmB,KAAK,EAAE;QAC1B,sCAAsC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,kBAAkB;QAC9E,0FAA0F;QAC1F,mDAAmD;QACnD,KAAK,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,kBAAkB;QACvE,8DAA8D,SAAS,CAAC,OAAO,gBAAgB;QAC/F,OAAO,GAAG,CAAC,UAAU,CAAC,gBAAgB,CACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * One instance → one install-gate verdict.
3
+ *
4
+ * The gate predicate lives in `validate/install-gate.ts` and is not duplicated here; this module
5
+ * only supplies the findings it decides over, from the instance's own recipe. Deploy calls it
6
+ * BEFORE money so a refusal costs nothing; `installRuntimeCore` calls the same predicate at the
7
+ * gateway boundary for installs that never went through deploy.
8
+ */
9
+ import { type InstallGateResult } from "../validate/index.js";
10
+ import type { DeployInstance } from "./package.js";
11
+ export declare function gateInstance(inst: DeployInstance): Promise<InstallGateResult>;
12
+ //# sourceMappingURL=install-gate-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-gate-runner.d.ts","sourceRoot":"","sources":["../../src/deploy/install-gate-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAA2C,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAsB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMnF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * One instance → one install-gate verdict.
3
+ *
4
+ * The gate predicate lives in `validate/install-gate.ts` and is not duplicated here; this module
5
+ * only supplies the findings it decides over, from the instance's own recipe. Deploy calls it
6
+ * BEFORE money so a refusal costs nothing; `installRuntimeCore` calls the same predicate at the
7
+ * gateway boundary for installs that never went through deploy.
8
+ */
9
+ import { checkInstallGate, collectRecipeFindings } from "../validate/index.js";
10
+ export async function gateInstance(inst) {
11
+ const validation = await collectRecipeFindings({
12
+ path: inst.runtimeYamlPath,
13
+ baseDir: inst.runtimeYamlDir,
14
+ });
15
+ return checkInstallGate(validation.findings);
16
+ }
17
+ //# sourceMappingURL=install-gate-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-gate-runner.js","sourceRoot":"","sources":["../../src/deploy/install-gate-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAA0B,MAAM,sBAAsB,CAAC;AAGvG,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAoB;IACrD,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC;QAC7C,IAAI,EAAE,IAAI,CAAC,eAAe;QAC1B,OAAO,EAAE,IAAI,CAAC,cAAc;KAC7B,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC"}