@stateset/sandbox-cli 3.3.1 → 3.6.0
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/CHANGELOG.md +140 -0
- package/README.md +467 -41
- package/dist/client.d.ts +131 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +21 -0
- package/dist/client.js.map +1 -1
- package/dist/commands/billing.js +36 -2
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/config.js +8 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +48 -15
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +222 -17
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/swarm.d.ts +18 -0
- package/dist/commands/swarm.d.ts.map +1 -0
- package/dist/commands/swarm.js +379 -0
- package/dist/commands/swarm.js.map +1 -0
- package/dist/commands/terminal.d.ts +3 -1
- package/dist/commands/terminal.d.ts.map +1 -1
- package/dist/commands/terminal.js +58 -1
- package/dist/commands/terminal.js.map +1 -1
- package/dist/commands/workbench.d.ts +138 -0
- package/dist/commands/workbench.d.ts.map +1 -0
- package/dist/commands/workbench.js +531 -0
- package/dist/commands/workbench.js.map +1 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/ephemeral-storage.d.ts +12 -0
- package/dist/utils/ephemeral-storage.d.ts.map +1 -0
- package/dist/utils/ephemeral-storage.js +39 -0
- package/dist/utils/ephemeral-storage.js.map +1 -0
- package/dist/utils/swarm-dispatcher.d.ts +50 -0
- package/dist/utils/swarm-dispatcher.d.ts.map +1 -0
- package/dist/utils/swarm-dispatcher.js +137 -0
- package/dist/utils/swarm-dispatcher.js.map +1 -0
- package/dist/utils/swarm-plan.d.ts +69 -0
- package/dist/utils/swarm-plan.d.ts.map +1 -0
- package/dist/utils/swarm-plan.js +321 -0
- package/dist/utils/swarm-plan.js.map +1 -0
- package/dist/utils/template-create.d.ts +36 -0
- package/dist/utils/template-create.d.ts.map +1 -0
- package/dist/utils/template-create.js +118 -0
- package/dist/utils/template-create.js.map +1 -0
- package/dist/workbench/actions.d.ts +1 -1
- package/dist/workbench/actions.d.ts.map +1 -1
- package/dist/workbench/actions.js +1 -0
- package/dist/workbench/actions.js.map +1 -1
- package/dist/workbench/agents.d.ts +96 -0
- package/dist/workbench/agents.d.ts.map +1 -0
- package/dist/workbench/agents.js +370 -0
- package/dist/workbench/agents.js.map +1 -0
- package/dist/workbench/commands.d.ts.map +1 -1
- package/dist/workbench/commands.js +7 -1
- package/dist/workbench/commands.js.map +1 -1
- package/dist/workbench/model.d.ts +5 -1
- package/dist/workbench/model.d.ts.map +1 -1
- package/dist/workbench/model.js +15 -2
- package/dist/workbench/model.js.map +1 -1
- package/dist/workbench/terminal.d.ts +1 -1
- package/dist/workbench/terminal.d.ts.map +1 -1
- package/dist/workbench/terminal.js +108 -78
- package/dist/workbench/terminal.js.map +1 -1
- package/package.json +15 -7
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAA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AC,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;IACZ,wCAAwC;AAC1C,CAAC,CAAC,CAAC;AAEH,oFAAoF;AACpF,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC;AAErD,gEAAgE;AAEhE,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE;IAC3B,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,qDAAqD;AACrD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;IACvD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EphemeralStorageGrant } from '@stateset/sandbox-sdk';
|
|
2
|
+
/** The `ephemeral_storage` create field for the flag value; throws on anything but whole Gi from 1Gi to 50Gi. */
|
|
3
|
+
export declare function ephemeralStorageCreateField(value: unknown): {
|
|
4
|
+
ephemeral_storage?: string;
|
|
5
|
+
};
|
|
6
|
+
/** True when less was granted than asked for. */
|
|
7
|
+
export declare function isReducedGrant(grant: EphemeralStorageGrant): boolean;
|
|
8
|
+
/** One line saying what was granted, what was asked for and which limit applied. */
|
|
9
|
+
export declare function reducedGrantWarning(grant: EphemeralStorageGrant): string;
|
|
10
|
+
/** Warn on stderr, so stdout/JSON output stays clean, when the create was granted less than it asked for. */
|
|
11
|
+
export declare function warnIfReducedGrant(grant: EphemeralStorageGrant | undefined): void;
|
|
12
|
+
//# sourceMappingURL=ephemeral-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ephemeral-storage.d.ts","sourceRoot":"","sources":["../../src/utils/ephemeral-storage.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAKnE,iHAAiH;AACjH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAS1F;AAED,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAEpE;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAIxE;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GAAG,IAAI,CAEjF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sandbox create --ephemeral-storage <size>` and `--strict`.
|
|
3
|
+
*
|
|
4
|
+
* The API grants a size up to the lower of the platform's limit and the
|
|
5
|
+
* plan's, and its create response says what was asked for and what was
|
|
6
|
+
* granted (`ephemeral_storage_grant`). With `strict` it refuses the create
|
|
7
|
+
* (400) instead of granting less. A smaller grant is never left unsaid: it is
|
|
8
|
+
* a warning on stderr in every output format.
|
|
9
|
+
*/
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
const MIN_GIB = 1;
|
|
12
|
+
const MAX_GIB = 50;
|
|
13
|
+
/** The `ephemeral_storage` create field for the flag value; throws on anything but whole Gi from 1Gi to 50Gi. */
|
|
14
|
+
export function ephemeralStorageCreateField(value) {
|
|
15
|
+
if (value === undefined || value === null)
|
|
16
|
+
return {};
|
|
17
|
+
const size = String(value);
|
|
18
|
+
const gib = /^([1-9]\d*)Gi$/.exec(size);
|
|
19
|
+
if (!gib || Number(gib[1]) < MIN_GIB || Number(gib[1]) > MAX_GIB) {
|
|
20
|
+
throw new Error(`--ephemeral-storage must be a whole number of Gi from ${MIN_GIB}Gi to ${MAX_GIB}Gi, for example 10Gi (got "${size}")`);
|
|
21
|
+
}
|
|
22
|
+
return { ephemeral_storage: size };
|
|
23
|
+
}
|
|
24
|
+
/** True when less was granted than asked for. */
|
|
25
|
+
export function isReducedGrant(grant) {
|
|
26
|
+
return grant.reason !== undefined || grant.granted !== grant.requested;
|
|
27
|
+
}
|
|
28
|
+
/** One line saying what was granted, what was asked for and which limit applied. */
|
|
29
|
+
export function reducedGrantWarning(grant) {
|
|
30
|
+
const whose = grant.reason === undefined ? 'limit' : String(grant.reason).replace(/_/g, ' ');
|
|
31
|
+
const limit = grant.limit === undefined ? '' : ` (${whose} ${grant.limit})`;
|
|
32
|
+
return `Ephemeral storage: ${grant.granted} granted, ${grant.requested} requested${limit}. Use --strict to fail instead.`;
|
|
33
|
+
}
|
|
34
|
+
/** Warn on stderr, so stdout/JSON output stays clean, when the create was granted less than it asked for. */
|
|
35
|
+
export function warnIfReducedGrant(grant) {
|
|
36
|
+
if (grant && isReducedGrant(grant))
|
|
37
|
+
console.error(chalk.yellow(reducedGrantWarning(grant)));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ephemeral-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ephemeral-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AE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC;IAC5E,OAAO,sBAAsB,KAAK,CAAC,OAAO,aAAa,KAAK,CAAC,SAAS,aAAa,KAAK,iCAAiC,CAAC;AAC5H,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,kBAAkB,CAAC,KAAwC;IACzE,IAAI,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** The name of the status file in a dispatcher's home directory. */
|
|
2
|
+
export declare const STATUS_FILE = "status.json";
|
|
3
|
+
/** The largest status file that is read, in bytes: 16 MB. */
|
|
4
|
+
export declare const MAX_STATUS_BYTES: number;
|
|
5
|
+
/**
|
|
6
|
+
* What a status file says of its dispatcher: it is `waiting` (it runs, and
|
|
7
|
+
* says why it takes nothing), `running` (it runs, and says no such thing),
|
|
8
|
+
* `not-running` (none runs, or the process the file names is gone), or the
|
|
9
|
+
* file is `unreadable` (missing, not JSON, or not a dispatcher's status).
|
|
10
|
+
*/
|
|
11
|
+
export type DispatcherSituation = 'waiting' | 'running' | 'not-running' | 'unreadable';
|
|
12
|
+
/** The line to print for a dispatcher's home directory, and which of the four it is. */
|
|
13
|
+
export interface DispatcherLine {
|
|
14
|
+
situation: DispatcherSituation;
|
|
15
|
+
line: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether a process of this machine is alive. Signal 0 sends nothing and
|
|
19
|
+
* asks only whether it could be sent: `EPERM` means that the process is
|
|
20
|
+
* there and belongs to another user.
|
|
21
|
+
*/
|
|
22
|
+
export declare function processAlive(pid: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The line for the dispatcher with this home directory. `<home>` is the
|
|
25
|
+
* directory made absolute:
|
|
26
|
+
*
|
|
27
|
+
* - `Dispatcher <home>: waiting since <since> (<limit>): <reason>` when the
|
|
28
|
+
* file says a dispatcher is running, that process is alive, and `waiting`
|
|
29
|
+
* has a `reason`. These are the words of the dispatcher's own `status`.
|
|
30
|
+
* `since <since>` is left out without `since`, the brackets without
|
|
31
|
+
* `limit`. The reason is printed whole: it says what releases the limit.
|
|
32
|
+
* - `Dispatcher <home>: <state>.` when it is running and alive and `waiting`
|
|
33
|
+
* is `null` or absent, or has no reason.
|
|
34
|
+
* - `Dispatcher <home>: not running (status.json says "<state>", written
|
|
35
|
+
* <updated_at>).` when the file says no dispatcher is running, or the
|
|
36
|
+
* process it names is gone. A reason in the file is not shown: a
|
|
37
|
+
* dispatcher that is gone waits for nothing.
|
|
38
|
+
* - `Dispatcher <home>: no status could be read (<why>).` when the file is
|
|
39
|
+
* missing, cannot be read, is not JSON, or is no status: no object, no
|
|
40
|
+
* `state`, no `dispatcher` object, or a running dispatcher without a
|
|
41
|
+
* process id, which could not be looked for.
|
|
42
|
+
*
|
|
43
|
+
* Never throws. `options.alive` says whether a process is alive (default:
|
|
44
|
+
* `processAlive`); it is asked once, and only for a dispatcher the file calls
|
|
45
|
+
* running.
|
|
46
|
+
*/
|
|
47
|
+
export declare function dispatcherLine(home: string, options?: {
|
|
48
|
+
alive?: (pid: number) => boolean;
|
|
49
|
+
}): DispatcherLine;
|
|
50
|
+
//# sourceMappingURL=swarm-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-dispatcher.d.ts","sourceRoot":"","sources":["../../src/utils/swarm-dispatcher.ts"],"names":[],"mappings":"AAqBA,oEAAoE;AACpE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,QAAmB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;AAEvF,wFAAwF;AACxF,MAAM,WAAW,cAAc;IAAG,SAAS,EAAE,mBAAmB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAWhF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOjD;AAyBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAAO,GAAG,cAAc,CA2C/G"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the status file of a swarm dispatcher and say in one line what the
|
|
3
|
+
* dispatcher is doing, and why it takes nothing from its backlog if it waits
|
|
4
|
+
* (`--dispatcher <home-dir>` on `stateset swarm list|get|watch`).
|
|
5
|
+
*
|
|
6
|
+
* A swarm dispatcher (examples/claude-agent/swarm-dispatch.mjs,
|
|
7
|
+
* docs/guides/SWARM_DISPATCHER_GUIDE.md) is a local process that works through
|
|
8
|
+
* a home directory. It reports nothing to the service: what it does is in
|
|
9
|
+
* `<home-dir>/status.json`, which it replaces by a rename after every change
|
|
10
|
+
* and at every look. That file is the only one read here, and it is read on
|
|
11
|
+
* this machine: the process it names is looked for among this machine's.
|
|
12
|
+
*
|
|
13
|
+
* The file is another program's, and older and newer dispatchers write it:
|
|
14
|
+
* `limit` is any string, fields not named here are not looked at, and a
|
|
15
|
+
* `waiting` without `limit` or `since` is still a reason. Every text taken
|
|
16
|
+
* from the file is printed on one line, with nothing a terminal acts on.
|
|
17
|
+
*/
|
|
18
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
19
|
+
import { join, resolve } from 'node:path';
|
|
20
|
+
import { inertText } from '../workbench/text.js';
|
|
21
|
+
/** The name of the status file in a dispatcher's home directory. */
|
|
22
|
+
export const STATUS_FILE = 'status.json';
|
|
23
|
+
/** The largest status file that is read, in bytes: 16 MB. */
|
|
24
|
+
export const MAX_STATUS_BYTES = 16 * 1024 * 1024;
|
|
25
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
+
/** A text of the file on one line, without what a terminal acts on; undefined for what is no text, or a blank one. */
|
|
27
|
+
function oneLine(value) {
|
|
28
|
+
if (typeof value !== 'string')
|
|
29
|
+
return undefined;
|
|
30
|
+
return inertText(value.replace(/\s+/g, ' ').trim()) || undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether a process of this machine is alive. Signal 0 sends nothing and
|
|
34
|
+
* asks only whether it could be sent: `EPERM` means that the process is
|
|
35
|
+
* there and belongs to another user.
|
|
36
|
+
*/
|
|
37
|
+
export function processAlive(pid) {
|
|
38
|
+
try {
|
|
39
|
+
process.kill(pid, 0);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return error.code === 'EPERM';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** The status file as text, or why there is none to print: the words that go into the brackets of the line. */
|
|
47
|
+
function readStatusFile(home) {
|
|
48
|
+
const file = join(home, STATUS_FILE);
|
|
49
|
+
try {
|
|
50
|
+
// Asked before reading: what is not a file (a pipe would never end) or is over the limit is not read.
|
|
51
|
+
const stats = statSync(file);
|
|
52
|
+
if (!stats.isFile())
|
|
53
|
+
return { why: `${STATUS_FILE} in that directory is not a file` };
|
|
54
|
+
if (stats.size > MAX_STATUS_BYTES) {
|
|
55
|
+
return { why: `${STATUS_FILE} is ${stats.size} bytes; at most ${MAX_STATUS_BYTES} are read` };
|
|
56
|
+
}
|
|
57
|
+
return { text: readFileSync(file, 'utf8') };
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const { code } = error;
|
|
61
|
+
if (code === 'ENOENT') {
|
|
62
|
+
// Asked of the directory the line names: an empty value is the current directory, and `existsSync('')` is false.
|
|
63
|
+
return { why: existsSync(resolve(home)) ? `no ${STATUS_FILE} in that directory` : 'that directory does not exist' };
|
|
64
|
+
}
|
|
65
|
+
if (code === 'ENOTDIR')
|
|
66
|
+
return { why: 'that is not a directory' };
|
|
67
|
+
// The code and not the message, which names the path: the line has it already.
|
|
68
|
+
return { why: `${STATUS_FILE} cannot be read: ${code ?? 'unknown error'}` };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The line for the dispatcher with this home directory. `<home>` is the
|
|
73
|
+
* directory made absolute:
|
|
74
|
+
*
|
|
75
|
+
* - `Dispatcher <home>: waiting since <since> (<limit>): <reason>` when the
|
|
76
|
+
* file says a dispatcher is running, that process is alive, and `waiting`
|
|
77
|
+
* has a `reason`. These are the words of the dispatcher's own `status`.
|
|
78
|
+
* `since <since>` is left out without `since`, the brackets without
|
|
79
|
+
* `limit`. The reason is printed whole: it says what releases the limit.
|
|
80
|
+
* - `Dispatcher <home>: <state>.` when it is running and alive and `waiting`
|
|
81
|
+
* is `null` or absent, or has no reason.
|
|
82
|
+
* - `Dispatcher <home>: not running (status.json says "<state>", written
|
|
83
|
+
* <updated_at>).` when the file says no dispatcher is running, or the
|
|
84
|
+
* process it names is gone. A reason in the file is not shown: a
|
|
85
|
+
* dispatcher that is gone waits for nothing.
|
|
86
|
+
* - `Dispatcher <home>: no status could be read (<why>).` when the file is
|
|
87
|
+
* missing, cannot be read, is not JSON, or is no status: no object, no
|
|
88
|
+
* `state`, no `dispatcher` object, or a running dispatcher without a
|
|
89
|
+
* process id, which could not be looked for.
|
|
90
|
+
*
|
|
91
|
+
* Never throws. `options.alive` says whether a process is alive (default:
|
|
92
|
+
* `processAlive`); it is asked once, and only for a dispatcher the file calls
|
|
93
|
+
* running.
|
|
94
|
+
*/
|
|
95
|
+
export function dispatcherLine(home, options = {}) {
|
|
96
|
+
const start = `Dispatcher ${inertText(resolve(home))}:`;
|
|
97
|
+
const unreadable = (why) => ({ situation: 'unreadable', line: `${start} no status could be read (${why}).` });
|
|
98
|
+
const read = readStatusFile(home);
|
|
99
|
+
if ('why' in read)
|
|
100
|
+
return unreadable(read.why);
|
|
101
|
+
let status;
|
|
102
|
+
try {
|
|
103
|
+
status = JSON.parse(read.text);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return unreadable(`${STATUS_FILE} is not JSON`);
|
|
107
|
+
}
|
|
108
|
+
const state = isObject(status) ? oneLine(status.state) : undefined;
|
|
109
|
+
if (!isObject(status) || state === undefined || !isObject(status.dispatcher)) {
|
|
110
|
+
return unreadable(`${STATUS_FILE} is not a dispatcher's status`);
|
|
111
|
+
}
|
|
112
|
+
const { running, pid } = status.dispatcher;
|
|
113
|
+
if (running === true) {
|
|
114
|
+
// Nothing but a process id is asked about: 0 and a negative number name groups of processes.
|
|
115
|
+
if (typeof pid !== 'number' || !Number.isSafeInteger(pid) || pid <= 0) {
|
|
116
|
+
return unreadable(`${STATUS_FILE} says a dispatcher is running and names no process`);
|
|
117
|
+
}
|
|
118
|
+
if ((options.alive ?? processAlive)(pid)) {
|
|
119
|
+
const waiting = isObject(status.waiting) ? status.waiting : {};
|
|
120
|
+
const reason = oneLine(waiting.reason);
|
|
121
|
+
if (reason === undefined)
|
|
122
|
+
return { situation: 'running', line: `${start} ${state}.` };
|
|
123
|
+
const since = oneLine(waiting.since);
|
|
124
|
+
const limit = oneLine(waiting.limit);
|
|
125
|
+
return {
|
|
126
|
+
situation: 'waiting',
|
|
127
|
+
line: `${start} waiting${since === undefined ? '' : ` since ${since}`}${limit === undefined ? '' : ` (${limit})`}: ${reason}`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const written = oneLine(status.updated_at);
|
|
132
|
+
return {
|
|
133
|
+
situation: 'not-running',
|
|
134
|
+
line: `${start} not running (${STATUS_FILE} says "${state}"${written === undefined ? '' : `, written ${written}`}).`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=swarm-dispatcher.js.map
|
|
@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AAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,KAAK,GAAG,EAAE,CAAC;YACtF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACrC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACrC,OAAO;gBACL,SAAS,EAAE,SAAS;gBACpB,IAAI,EAAE,GAAG,KAAK,WAAW,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,KAAK,MAAM,EAAE;aAC9H,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO;QACL,SAAS,EAAE,aAAa;QACxB,IAAI,EAAE,GAAG,KAAK,iBAAiB,WAAW,UAAU,KAAK,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,OAAO,EAAE,IAAI;KACrH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CreateSwarmOptions } from '@stateset/sandbox-sdk';
|
|
2
|
+
/** The most tasks the API takes in one swarm. */
|
|
3
|
+
export declare const MAX_SWARM_TASKS = 50;
|
|
4
|
+
/** The most characters of a swarm's name and of a task's name, after trimming. */
|
|
5
|
+
export declare const MAX_NAME_LENGTH = 128;
|
|
6
|
+
/** The most characters of a swarm's goal, after trimming. */
|
|
7
|
+
export declare const MAX_GOAL_LENGTH = 16000;
|
|
8
|
+
/** The most characters of a task's objective, after trimming. */
|
|
9
|
+
export declare const MAX_OBJECTIVE_LENGTH = 16000;
|
|
10
|
+
/** The most characters of a task's id, which the API calls its key. */
|
|
11
|
+
export declare const MAX_TASK_ID_LENGTH = 64;
|
|
12
|
+
/** The most characters of `repository` and of `defaults`, each as JSON. */
|
|
13
|
+
export declare const MAX_SETTINGS_LENGTH = 16384;
|
|
14
|
+
/** The most problems one check lists; a closing line counts the others. */
|
|
15
|
+
export declare const MAX_PROBLEMS = 20;
|
|
16
|
+
/** The largest plan file that is read, in bytes: 4 MB. */
|
|
17
|
+
export declare const MAX_PLAN_BYTES: number;
|
|
18
|
+
/**
|
|
19
|
+
* Check a plan and build the body of `POST /swarms` from it, under the name
|
|
20
|
+
* the caller gives the swarm. Pure: reads nothing but its arguments, and
|
|
21
|
+
* never throws.
|
|
22
|
+
*
|
|
23
|
+
* `request` is null exactly when there are problems. They are listed in the
|
|
24
|
+
* order of a plan file (the name, the goal, `repository`, `defaults`, then
|
|
25
|
+
* the tasks one by one, then the cycles), each as one sentence that names
|
|
26
|
+
* its task: by its id, or by its place when the id is wrong or already
|
|
27
|
+
* another task's.
|
|
28
|
+
*
|
|
29
|
+
* The body has the name and the goal trimmed, `repository` and `defaults` as
|
|
30
|
+
* given when the plan has them, and of every task its id as `key`, its name
|
|
31
|
+
* trimmed, its objective as written and its dependencies once each. Nothing
|
|
32
|
+
* else of the plan is in it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkSwarmPlan(plan: unknown, name: string): {
|
|
35
|
+
request: CreateSwarmOptions | null;
|
|
36
|
+
problems: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The name of the swarm of a plan, before it is checked. Pure.
|
|
40
|
+
*
|
|
41
|
+
* It is the name asked for, `options.name`, when there is one: an empty or
|
|
42
|
+
* a blank one is kept, and `checkSwarmPlan` reports it. Else it is the
|
|
43
|
+
* plan's own `name` when that is a string, empty or not. Else it is the name
|
|
44
|
+
* of the plan file, `options.file`, without its directory and without a
|
|
45
|
+
* closing `.json`, when a file is given. Else it is undefined, which
|
|
46
|
+
* `checkSwarmPlan` reports as a name that is missing.
|
|
47
|
+
*
|
|
48
|
+
* An empty file name is a file name: the name it gives is empty, not
|
|
49
|
+
* undefined. A file named exactly `.json` gives an empty name as well when
|
|
50
|
+
* it is given without a directory, and the name `.json` when it is given
|
|
51
|
+
* with one (`plans/.json`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function swarmPlanName(plan: unknown, options?: {
|
|
54
|
+
name?: string;
|
|
55
|
+
file?: string;
|
|
56
|
+
}): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Read a plan file and return the body of `POST /swarms` for it. The swarm's
|
|
59
|
+
* name is `options.name`, else the plan's own `name`, else the name of the
|
|
60
|
+
* file without `.json`: see `swarmPlanName`.
|
|
61
|
+
*
|
|
62
|
+
* Throws a `CliError` that names the file as it was given when the file is
|
|
63
|
+
* missing, cannot be read, is over `MAX_PLAN_BYTES`, is not JSON, or holds a
|
|
64
|
+
* plan with problems: then the message has one line per problem.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readSwarmPlan(file: string, options?: {
|
|
67
|
+
name?: string;
|
|
68
|
+
}): CreateSwarmOptions;
|
|
69
|
+
//# sourceMappingURL=swarm-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-plan.d.ts","sourceRoot":"","sources":["../../src/utils/swarm-plan.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,iDAAiD;AACjD,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,kFAAkF;AAClF,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,6DAA6D;AAC7D,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,iEAAiE;AACjE,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAC1C,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAC1C,2EAA2E;AAC3E,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,0DAA0D;AAC1D,eAAO,MAAM,cAAc,QAAkB,CAAC;AA6L9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAGtH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,GAAG,SAAS,CAI/G;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,kBAAkB,CAwC/F"}
|