@aeolus-fleet/common 0.25.0 → 0.25.2
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Inputs and outputs of the crew request procedures (decision 0029): a
|
|
4
|
-
* standing request that a ship be kept crewed, with settings the
|
|
5
|
-
*
|
|
4
|
+
* standing request that a ship be kept crewed, with crew settings the
|
|
5
|
+
* server checks but never acts on. A requester with fleet:manage sets and removes it.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* The most a crew request's settings may hold: 16 KB as the UTF-8 bytes of
|
|
@@ -13,8 +13,8 @@ export declare const CREW_REQUEST_SETTINGS_MAX_BYTES: number;
|
|
|
13
13
|
export declare function crewRequestSettingsBytes(settings: CrewRequestSettings): number;
|
|
14
14
|
/**
|
|
15
15
|
* A crew request's settings: one JSON object (harness, workspace, options, an
|
|
16
|
-
* optional first prompt, an optional squadron).
|
|
17
|
-
*
|
|
16
|
+
* optional first prompt, an optional squadron). The server reads their shape
|
|
17
|
+
* as crew settings (`readCrewSettings`) once their size fits.
|
|
18
18
|
*/
|
|
19
19
|
export declare const crewRequestSettingsSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
20
20
|
export type CrewRequestSettings = z.infer<typeof crewRequestSettingsSchema>;
|
|
@@ -2,8 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import { idSchema } from '../ids/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Inputs and outputs of the crew request procedures (decision 0029): a
|
|
5
|
-
* standing request that a ship be kept crewed, with settings the
|
|
6
|
-
*
|
|
5
|
+
* standing request that a ship be kept crewed, with crew settings the
|
|
6
|
+
* server checks but never acts on. A requester with fleet:manage sets and removes it.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* The most a crew request's settings may hold: 16 KB as the UTF-8 bytes of
|
|
@@ -17,8 +17,8 @@ export function crewRequestSettingsBytes(settings) {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* A crew request's settings: one JSON object (harness, workspace, options, an
|
|
20
|
-
* optional first prompt, an optional squadron).
|
|
21
|
-
*
|
|
20
|
+
* optional first prompt, an optional squadron). The server reads their shape
|
|
21
|
+
* as crew settings (`readCrewSettings`) once their size fits.
|
|
22
22
|
*/
|
|
23
23
|
export const crewRequestSettingsSchema = z.record(z.string(), z.json());
|
|
24
24
|
/**
|
|
@@ -15,7 +15,7 @@ export type TrierarchWorkspace = z.infer<typeof trierarchWorkspaceSchema>;
|
|
|
15
15
|
* A crew request's settings as a trierarch reads them (decision 0027): the
|
|
16
16
|
* fixed core of an optional harness, workspace, an optional squadron, an
|
|
17
17
|
* optional first prompt and options. Without a harness, the trierarch it
|
|
18
|
-
* goes to crews it with its default: the first in its configuration. The server
|
|
18
|
+
* goes to crews it with its default: the first in its configuration. The server refuses a request whose settings this schema refuses (#809) but never acts on them; the trierarch
|
|
19
19
|
* plugin and the trierarch parse them with this schema. Never a path or a
|
|
20
20
|
* command-line flag: a workspace names a repository or folder, options pick
|
|
21
21
|
* named settings, and a first prompt never starts with `-`.
|
|
@@ -41,3 +41,21 @@ export declare const crewSettingsSchema: z.ZodObject<{
|
|
|
41
41
|
*/
|
|
42
42
|
export declare const NO_MACHINE_MATCHES_REASON = "no machine matches its labels";
|
|
43
43
|
export type CrewSettings = z.infer<typeof crewSettingsSchema>;
|
|
44
|
+
/** Why settings are not crew settings: the settings field at fault, or `settings` when the issue has no field, and the reason as one line. */
|
|
45
|
+
export interface CrewSettingsRefusal {
|
|
46
|
+
field: string;
|
|
47
|
+
reason: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Settings read as crew settings, or why they are not: the first issue, as
|
|
51
|
+
* one line with its path. The one reading for the fleet, which refuses a
|
|
52
|
+
* request whose settings are not crew settings, and the trierarch plugin,
|
|
53
|
+
* which places them (#809).
|
|
54
|
+
*/
|
|
55
|
+
export declare function readCrewSettings(settings: unknown): {
|
|
56
|
+
settings: CrewSettings;
|
|
57
|
+
} | {
|
|
58
|
+
refusal: CrewSettingsRefusal;
|
|
59
|
+
};
|
|
60
|
+
/** Why settings are not crew settings, or undefined when they are. */
|
|
61
|
+
export declare function crewSettingsRefusal(settings: unknown): CrewSettingsRefusal | undefined;
|
|
@@ -16,7 +16,7 @@ export const trierarchWorkspaceSchema = z.discriminatedUnion('kind', [
|
|
|
16
16
|
* A crew request's settings as a trierarch reads them (decision 0027): the
|
|
17
17
|
* fixed core of an optional harness, workspace, an optional squadron, an
|
|
18
18
|
* optional first prompt and options. Without a harness, the trierarch it
|
|
19
|
-
* goes to crews it with its default: the first in its configuration. The server
|
|
19
|
+
* goes to crews it with its default: the first in its configuration. The server refuses a request whose settings this schema refuses (#809) but never acts on them; the trierarch
|
|
20
20
|
* plugin and the trierarch parse them with this schema. Never a path or a
|
|
21
21
|
* command-line flag: a workspace names a repository or folder, options pick
|
|
22
22
|
* named settings, and a first prompt never starts with `-`.
|
|
@@ -47,4 +47,28 @@ export const crewSettingsSchema = z.strictObject({
|
|
|
47
47
|
* every machine label of; it waits, and the console words it in full.
|
|
48
48
|
*/
|
|
49
49
|
export const NO_MACHINE_MATCHES_REASON = 'no machine matches its labels';
|
|
50
|
+
/**
|
|
51
|
+
* Settings read as crew settings, or why they are not: the first issue, as
|
|
52
|
+
* one line with its path. The one reading for the fleet, which refuses a
|
|
53
|
+
* request whose settings are not crew settings, and the trierarch plugin,
|
|
54
|
+
* which places them (#809).
|
|
55
|
+
*/
|
|
56
|
+
export function readCrewSettings(settings) {
|
|
57
|
+
const result = crewSettingsSchema.safeParse(settings);
|
|
58
|
+
if (result.success) {
|
|
59
|
+
return { settings: result.data };
|
|
60
|
+
}
|
|
61
|
+
const [issue] = result.error.issues;
|
|
62
|
+
if (issue === undefined) {
|
|
63
|
+
return { refusal: { field: 'settings', reason: 'settings are not valid crew settings: unreadable' } };
|
|
64
|
+
}
|
|
65
|
+
const path = issue.path.map(String);
|
|
66
|
+
const line = path.length === 0 ? issue.message : `${path.join('.')}: ${issue.message}`;
|
|
67
|
+
return { refusal: { field: path[0] ?? 'settings', reason: `settings are not valid crew settings: ${line}` } };
|
|
68
|
+
}
|
|
69
|
+
/** Why settings are not crew settings, or undefined when they are. */
|
|
70
|
+
export function crewSettingsRefusal(settings) {
|
|
71
|
+
const read = readCrewSettings(settings);
|
|
72
|
+
return 'refusal' in read ? read.refusal : undefined;
|
|
73
|
+
}
|
|
50
74
|
//# sourceMappingURL=crew-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crew-settings.js","sourceRoot":"","sources":["../../src/trierarch/crew-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;AAE/B,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C,gHAAgH;AAChH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACnE,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;IACnH,CAAC,CAAC,YAAY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