@senpi/runtime 3.0.238 → 3.0.240
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/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +11 -7
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.js +1 -1
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/deploy/messages.d.ts +1 -1
- package/dist/deploy/messages.d.ts.map +1 -1
- package/dist/deploy/messages.js +21 -14
- package/dist/deploy/messages.js.map +1 -1
- package/dist/deploy/orchestrator.d.ts.map +1 -1
- package/dist/deploy/orchestrator.js +34 -10
- package/dist/deploy/orchestrator.js.map +1 -1
- package/dist/deploy/scanner-class.d.ts +16 -1
- package/dist/deploy/scanner-class.d.ts.map +1 -1
- package/dist/deploy/scanner-class.js +49 -0
- package/dist/deploy/scanner-class.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/live-class-backfill.d.ts +10 -0
- package/dist/runtime/live-class-backfill.d.ts.map +1 -0
- package/dist/runtime/live-class-backfill.js +65 -0
- package/dist/runtime/live-class-backfill.js.map +1 -0
- package/dist/runtime/strategy-registry.d.ts +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import { externalScannerNames, liveScannerClasses, proofObservations } from "../deploy/scanner-class.js";
|
|
5
|
+
import { isSimulationAddress } from "../senpi/simulation.js";
|
|
6
|
+
import { resolveEnvInString } from "./env-resolve.js";
|
|
7
|
+
import { readRegistry, withRegistryLock, writeRegistry, } from "./strategy-registry.js";
|
|
8
|
+
/**
|
|
9
|
+
* Live runtimes installed before live scanners were classed count 0 MB toward the box's memory.
|
|
10
|
+
* Give each such row the class its recipe's proof measured, else the 128 MB floor, and persist it.
|
|
11
|
+
* The class only counts: the launcher never holds a live scanner to it. Returns the registry as written.
|
|
12
|
+
*/
|
|
13
|
+
export async function backfillLiveScannerClasses(stateDir, log) {
|
|
14
|
+
return withRegistryLock(stateDir, async () => {
|
|
15
|
+
const registry = await readRegistry(stateDir);
|
|
16
|
+
let changed = false;
|
|
17
|
+
const runtimes = [];
|
|
18
|
+
for (const entry of registry.runtimes) {
|
|
19
|
+
const backfilled = entry.scannerClassesMb === undefined ? await liveClassesFor(entry) : undefined;
|
|
20
|
+
if (backfilled === undefined) {
|
|
21
|
+
runtimes.push(entry);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
changed = true;
|
|
25
|
+
runtimes.push({ ...entry, scannerClassesMb: backfilled.classes });
|
|
26
|
+
log("[senpi-runtime] live runtime scanner classes backfilled", {
|
|
27
|
+
runtimeId: entry.id,
|
|
28
|
+
classesMb: backfilled.classes,
|
|
29
|
+
source: [...new Set(Object.values(backfilled.sources))].sort().join("+"),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (!changed)
|
|
33
|
+
return registry;
|
|
34
|
+
const next = { ...registry, runtimes };
|
|
35
|
+
await writeRegistry(stateDir, next);
|
|
36
|
+
return next;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function liveClassesFor(entry) {
|
|
40
|
+
const hasPath = typeof entry.runtimeYamlPath === "string" && entry.runtimeYamlPath.length > 0;
|
|
41
|
+
let yaml;
|
|
42
|
+
try {
|
|
43
|
+
yaml = hasPath ? await readFile(entry.runtimeYamlPath, "utf8") : (entry.runtimeYamlContent ?? "");
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const wallet = entry.wallet ?? recipeWallet(yaml);
|
|
49
|
+
if (wallet !== undefined && isSimulationAddress(wallet))
|
|
50
|
+
return undefined;
|
|
51
|
+
const recipeDir = hasPath ? dirname(entry.runtimeYamlPath) : entry.runtimeYamlDir;
|
|
52
|
+
const observations = proofObservations(recipeDir);
|
|
53
|
+
const live = liveScannerClasses(externalScannerNames(yaml, observations), observations, {});
|
|
54
|
+
return Object.keys(live.classes).length > 0 ? live : undefined;
|
|
55
|
+
}
|
|
56
|
+
function recipeWallet(yaml) {
|
|
57
|
+
try {
|
|
58
|
+
const wallet = parseYaml(yaml)?.strategy?.wallet;
|
|
59
|
+
return typeof wallet === "string" ? resolveEnvInString(wallet) : undefined;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=live-class-backfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-class-backfill.js","sourceRoot":"","sources":["../../src/runtime/live-class-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,GAGd,MAAM,wBAAwB,CAAC;AAIhC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,QAAgB,EAAE,GAAQ;IACzE,OAAO,gBAAgB,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB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|
23
23
|
/**
|
|
24
|
-
* Each external scanner's memory class in MB
|
|
25
|
-
* at create
|
|
24
|
+
* Each external scanner's memory class in MB. A simulation's is the class `senpi deploy --simulation`
|
|
25
|
+
* declared to the server at create; a live runtime's only counts toward the box's memory.
|
|
26
26
|
*/
|
|
27
27
|
scannerClassesMb?: Record<string, ScannerClassMb>;
|
|
28
28
|
}
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "runtime",
|
|
3
3
|
"name": "Senpi Runtime",
|
|
4
4
|
"description": "Senpi runtime plugin for OpenClaw. Orchestrates scanners, LLM-based trade decisions, and a DSL trailing stop-loss exit engine.",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.240",
|
|
6
6
|
"commandAliases": [
|
|
7
7
|
{
|
|
8
8
|
"name": "senpi"
|