@senpi/runtime 3.0.252 → 3.0.254
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 +2 -1
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/daemon/errors.d.ts.map +1 -1
- package/dist/daemon/errors.js +2 -1
- package/dist/daemon/errors.js.map +1 -1
- package/dist/daemon/http-routes.d.ts +1 -1
- package/dist/daemon/http-routes.d.ts.map +1 -1
- package/dist/daemon/http-routes.js +27 -22
- package/dist/daemon/http-routes.js.map +1 -1
- package/dist/daemon/mcp-endpoint.d.ts +12 -8
- package/dist/daemon/mcp-endpoint.d.ts.map +1 -1
- package/dist/daemon/mcp-endpoint.js +51 -8
- package/dist/daemon/mcp-endpoint.js.map +1 -1
- package/dist/daemon/route-table.d.ts.map +1 -1
- package/dist/daemon/route-table.js +3 -0
- package/dist/daemon/route-table.js.map +1 -1
- package/dist/deploy/batch/batch.d.ts +157 -0
- package/dist/deploy/batch/batch.d.ts.map +1 -0
- package/dist/deploy/batch/batch.js +567 -0
- package/dist/deploy/batch/batch.js.map +1 -0
- package/dist/deploy/batch/catalog-fetch.d.ts +18 -0
- package/dist/deploy/batch/catalog-fetch.d.ts.map +1 -0
- package/dist/deploy/batch/catalog-fetch.js +66 -0
- package/dist/deploy/batch/catalog-fetch.js.map +1 -0
- package/dist/deploy/box-fit.d.ts +11 -0
- package/dist/deploy/box-fit.d.ts.map +1 -1
- package/dist/deploy/box-fit.js +14 -1
- package/dist/deploy/box-fit.js.map +1 -1
- package/dist/deploy/funding.d.ts +1 -1
- package/dist/deploy/funding.d.ts.map +1 -1
- package/dist/deploy/job.d.ts +20 -1
- package/dist/deploy/job.d.ts.map +1 -1
- package/dist/deploy/job.js +79 -20
- package/dist/deploy/job.js.map +1 -1
- package/dist/deploy/orchestrator.d.ts +1 -0
- package/dist/deploy/orchestrator.d.ts.map +1 -1
- package/dist/deploy/orchestrator.js +6 -5
- package/dist/deploy/orchestrator.js.map +1 -1
- package/dist/deploy/package.d.ts +1 -0
- package/dist/deploy/package.d.ts.map +1 -1
- package/dist/deploy/package.js +2 -2
- package/dist/deploy/package.js.map +1 -1
- package/dist/deploy/register.d.ts +12 -0
- package/dist/deploy/register.d.ts.map +1 -1
- package/dist/deploy/register.js +84 -7
- package/dist/deploy/register.js.map +1 -1
- package/dist/deploy/sim-admission.d.ts +64 -72
- package/dist/deploy/sim-admission.d.ts.map +1 -1
- package/dist/deploy/sim-admission.js +109 -116
- package/dist/deploy/sim-admission.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/integrity-manifest.json +67 -59
- package/dist/runtime/process-state.d.ts +3 -0
- package/dist/runtime/process-state.d.ts.map +1 -1
- package/dist/runtime/process-state.js.map +1 -1
- package/dist/runtime/update-register.d.ts +2 -2
- package/dist/senpi/client.d.ts +8 -0
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +19 -0
- package/dist/senpi/client.js.map +1 -1
- package/dist/strategy/settings.d.ts +17 -0
- package/dist/strategy/settings.d.ts.map +1 -1
- package/dist/strategy/settings.js +67 -0
- package/dist/strategy/settings.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `senpi.simulations.startBatch` / `senpi.simulations.batchStatus`: many simulations of one strategy,
|
|
3
|
+
* each with its own settings, started from one call.
|
|
4
|
+
*
|
|
5
|
+
* One start fetches the strategy once (a catalog id, or the package of the simulation named by
|
|
6
|
+
* `parentId`), writes each variant's settings into its own package, admits the variants on the two
|
|
7
|
+
* limits of {@link SimAdmission} (credits for the next hour, and the box fit with its grow ladder)
|
|
8
|
+
* and answers at once, one row per variant. The admitted variants are then validated and started one
|
|
9
|
+
* after another through the deploy job, each a simulation in the batch's group and batch; the deploy
|
|
10
|
+
* jobs run side by side. `batchStatus` follows each row to its job's outcome.
|
|
11
|
+
*
|
|
12
|
+
* The batch's `requestId` names it: a repeat (also after a restart) answers the stored batch and
|
|
13
|
+
* starts nothing. A `dryRun` fetches and admits, and keeps, validates and starts nothing.
|
|
14
|
+
*/
|
|
15
|
+
import { type BoxFitSettings } from "../box-fit.js";
|
|
16
|
+
import type { BoxGrowOutcome } from "../box-grow.js";
|
|
17
|
+
import type { JobSnapshot } from "../job.js";
|
|
18
|
+
import { SimAdmission, type SimLimitsReading, type SimRefusalCode } from "../sim-admission.js";
|
|
19
|
+
/** What simulation-service bills: 3906 µ¢ per MB-hour at 20 credits a cent, 10 credits an hour for 128 MB. */
|
|
20
|
+
export declare const SIM_CREDITS_PER_MB_HOUR: number;
|
|
21
|
+
export type BatchRowStatus = "started" | SimRefusalCode;
|
|
22
|
+
export type DryRunRowStatus = "would_start" | "would_refuse";
|
|
23
|
+
/** Where a started variant is: before its job, in its job, or the job's outcome. */
|
|
24
|
+
export type VariantPhase = "queued" | "validating" | "deploying" | "live" | "refused" | "failed" | "interrupted";
|
|
25
|
+
export interface BatchRow {
|
|
26
|
+
label: string;
|
|
27
|
+
status: BatchRowStatus | DryRunRowStatus;
|
|
28
|
+
/** Dry runs: why it would be refused. */
|
|
29
|
+
reason?: SimRefusalCode;
|
|
30
|
+
phase?: VariantPhase;
|
|
31
|
+
simulationId?: string;
|
|
32
|
+
deployId?: string;
|
|
33
|
+
detail: string;
|
|
34
|
+
}
|
|
35
|
+
export interface BatchAnswer {
|
|
36
|
+
requestId: string;
|
|
37
|
+
batchId: string;
|
|
38
|
+
dryRun: boolean;
|
|
39
|
+
strategy?: string;
|
|
40
|
+
parentId?: string;
|
|
41
|
+
groupName?: string;
|
|
42
|
+
budgetUsd: number;
|
|
43
|
+
rows: BatchRow[];
|
|
44
|
+
/** The box's memory limit now, and the size the admitted variants need. Empty when unreadable. */
|
|
45
|
+
box: {
|
|
46
|
+
beforeMb?: number;
|
|
47
|
+
beforeGb?: number;
|
|
48
|
+
afterMb?: number;
|
|
49
|
+
afterGb?: number;
|
|
50
|
+
};
|
|
51
|
+
/** Credits an hour once every admitted variant runs, with what already runs. */
|
|
52
|
+
creditsPerHourAfter: number;
|
|
53
|
+
/** This answer describes a batch an earlier call with the same requestId started. */
|
|
54
|
+
repeated?: true;
|
|
55
|
+
}
|
|
56
|
+
export type BatchResult = {
|
|
57
|
+
ok: true;
|
|
58
|
+
answer: BatchAnswer;
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
code: string;
|
|
62
|
+
message: string;
|
|
63
|
+
};
|
|
64
|
+
export type ValidateOutcome = {
|
|
65
|
+
ok: true;
|
|
66
|
+
} | {
|
|
67
|
+
ok: false;
|
|
68
|
+
detail: string;
|
|
69
|
+
};
|
|
70
|
+
export type StartOutcome = {
|
|
71
|
+
ok: true;
|
|
72
|
+
deployId: string;
|
|
73
|
+
} | {
|
|
74
|
+
ok: false;
|
|
75
|
+
code: string;
|
|
76
|
+
message: string;
|
|
77
|
+
};
|
|
78
|
+
export interface SimulationBatchDeps {
|
|
79
|
+
/** One directory per batch: its record and its variants' packages, which the simulations run from. */
|
|
80
|
+
batchesDir: string;
|
|
81
|
+
/** Fetch catalog strategy `strategy` under `destRoot`; returns the package dir. */
|
|
82
|
+
fetchTemplate(strategy: string, destRoot: string): Promise<string>;
|
|
83
|
+
/** The package dir the simulation `parentId` runs from on this box, or undefined when it runs elsewhere. */
|
|
84
|
+
parentPackageDir(parentId: string): Promise<string | undefined>;
|
|
85
|
+
/** Validate one instance dir in-process and write its proof. */
|
|
86
|
+
validate(instanceDir: string): Promise<ValidateOutcome>;
|
|
87
|
+
/** `senpi.deploy.startSimulation` with these params. */
|
|
88
|
+
startSimulation(params: Record<string, unknown>): Promise<StartOutcome>;
|
|
89
|
+
jobStatus(deployId: string): Promise<JobSnapshot | null>;
|
|
90
|
+
/** The job's snapshot once it has ended. */
|
|
91
|
+
jobEnded(deployId: string): Promise<JobSnapshot | null>;
|
|
92
|
+
/** One read of the credits and the box for the admission (see {@link SimAdmission}). */
|
|
93
|
+
readLimits(): Promise<SimLimitsReading>;
|
|
94
|
+
boxFitSettings(): BoxFitSettings;
|
|
95
|
+
boxLimitMb(): Promise<number | undefined>;
|
|
96
|
+
growBox(): Promise<BoxGrowOutcome>;
|
|
97
|
+
creditsPerMbHour: number;
|
|
98
|
+
now(): number;
|
|
99
|
+
sleep(ms: number): Promise<void>;
|
|
100
|
+
log(line: string): void;
|
|
101
|
+
}
|
|
102
|
+
/** The batch id simulation-service groups the variants by: the requestId's hash, so a repeat names the same batch. */
|
|
103
|
+
export declare function batchIdFor(requestId: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* A variant's package id: the strategy's id cut to fit, a tag of the batch and its number. Unique per
|
|
106
|
+
* batch and short enough for `<id>-<instance>-simulation`. Undefined when the instance name leaves no room.
|
|
107
|
+
*/
|
|
108
|
+
export declare function variantPackageId(templateId: string, instance: string, batchId: string, n: number): string | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* The admission's one read: the credits left, what the simulations on the box burn an hour (each
|
|
111
|
+
* billed for its scanner classes, at least 128 MB, as simulation-service bills it), and the box's
|
|
112
|
+
* limit and reserves.
|
|
113
|
+
*/
|
|
114
|
+
export declare function readSimulationLimits(src: {
|
|
115
|
+
creditsLeft(): Promise<number | null>;
|
|
116
|
+
runtimes(): Promise<Array<{
|
|
117
|
+
id: string;
|
|
118
|
+
classesMb: number[];
|
|
119
|
+
}>>;
|
|
120
|
+
boxLimitMb(): Promise<number | undefined>;
|
|
121
|
+
boxFitSettings(): BoxFitSettings;
|
|
122
|
+
creditsPerMbHour: number;
|
|
123
|
+
}): Promise<SimLimitsReading>;
|
|
124
|
+
export declare class SimulationBatches {
|
|
125
|
+
private deps;
|
|
126
|
+
private readonly starting;
|
|
127
|
+
private readonly unanswered;
|
|
128
|
+
private readonly runners;
|
|
129
|
+
/** Admitted and not yet running, across every batch here: one admission lock for all of them. */
|
|
130
|
+
readonly admission: SimAdmission;
|
|
131
|
+
constructor(deps: SimulationBatchDeps);
|
|
132
|
+
/**
|
|
133
|
+
* The collaborators of a newer plugin registration. The batches, the reservations and the runners
|
|
134
|
+
* already going stay; every step from here on calls the new ones.
|
|
135
|
+
*/
|
|
136
|
+
rebind(deps: SimulationBatchDeps): void;
|
|
137
|
+
/** Resolves once every admitted variant of every batch started here has been started or refused. */
|
|
138
|
+
settled(): Promise<void>;
|
|
139
|
+
start(params: Record<string, unknown> | undefined): Promise<BatchResult>;
|
|
140
|
+
status(params: Record<string, unknown> | undefined): Promise<BatchResult>;
|
|
141
|
+
private repeatedBatch;
|
|
142
|
+
private repeatOf;
|
|
143
|
+
private batchDir;
|
|
144
|
+
private readStored;
|
|
145
|
+
private save;
|
|
146
|
+
private refreshed;
|
|
147
|
+
private create;
|
|
148
|
+
private template;
|
|
149
|
+
private admit;
|
|
150
|
+
private follow;
|
|
151
|
+
private run;
|
|
152
|
+
/** Returns the box's refusal when the box cannot hold this variant, which every later variant then shares. */
|
|
153
|
+
private startVariant;
|
|
154
|
+
private holdReservationUntilJobEnds;
|
|
155
|
+
private growBoxTo;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/deploy/batch/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EAAS,YAAY,EAAE,KAAK,gBAAgB,EAA8B,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGlI,8GAA8G;AAC9G,eAAO,MAAM,uBAAuB,QAAW,CAAC;AAUhD,MAAM,M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