@aeolus-fleet/trierarch-plugin 0.31.0 → 0.33.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/README.md +2 -2
- package/dist/adapters/fleet/core-version.d.ts +12 -3
- package/dist/adapters/fleet/core-version.js +22 -6
- package/dist/adapters/fleet/core-version.js.map +1 -1
- package/dist/adapters/fleet/operator-fleet.d.ts +2 -0
- package/dist/adapters/fleet/operator-fleet.js +50 -0
- package/dist/adapters/fleet/operator-fleet.js.map +1 -0
- package/dist/adapters/fleet/rest-fleet-door.js +2 -1
- package/dist/adapters/fleet/rest-fleet-door.js.map +1 -1
- package/dist/adapters/prisma/enabled-models.d.ts +4 -0
- package/dist/adapters/prisma/enabled-models.js +14 -0
- package/dist/adapters/prisma/enabled-models.js.map +1 -0
- package/dist/adapters/prisma/fleet-forgetter.d.ts +1 -1
- package/dist/adapters/prisma/fleet-forgetter.js +2 -2
- package/dist/adapters/prisma/fleet-forgetter.js.map +1 -1
- package/dist/adapters/prisma/generated/browser.d.ts +7 -0
- package/dist/adapters/prisma/generated/client.d.ts +7 -0
- package/dist/adapters/prisma/generated/internal/class.d.ts +11 -0
- package/dist/adapters/prisma/generated/internal/class.js +4 -4
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +82 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +6 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +6 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +6 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/EnabledModel.d.ts +920 -0
- package/dist/adapters/prisma/generated/models/EnabledModel.js +2 -0
- package/dist/adapters/prisma/generated/models/EnabledModel.js.map +1 -0
- package/dist/adapters/prisma/generated/models.d.ts +1 -0
- package/dist/adapters/trpc/router.d.ts +145 -0
- package/dist/adapters/trpc/router.js +41 -1
- package/dist/adapters/trpc/router.js.map +1 -1
- package/dist/app.js +15 -2
- package/dist/app.js.map +1 -1
- package/dist/core/assignment/assign-crews.d.ts +4 -1
- package/dist/core/assignment/assign-crews.js +4 -2
- package/dist/core/assignment/assign-crews.js.map +1 -1
- package/dist/core/assignment/check-crew-settings.d.ts +4 -2
- package/dist/core/assignment/check-crew-settings.js +3 -3
- package/dist/core/assignment/check-crew-settings.js.map +1 -1
- package/dist/core/assignment/placement.d.ts +14 -3
- package/dist/core/assignment/placement.js +48 -11
- package/dist/core/assignment/placement.js.map +1 -1
- package/dist/core/connection/ports.d.ts +1 -0
- package/dist/core/installation/ports.d.ts +2 -1
- package/dist/core/machines/join-machine.js +2 -4
- package/dist/core/machines/join-machine.js.map +1 -1
- package/dist/core/machines/new-setup-line.d.ts +32 -0
- package/dist/core/machines/new-setup-line.js +45 -0
- package/dist/core/machines/new-setup-line.js.map +1 -0
- package/dist/core/machines/setup-line.d.ts +14 -0
- package/dist/core/machines/setup-line.js +13 -0
- package/dist/core/machines/setup-line.js.map +1 -0
- package/dist/core/models/list-enabled-models.d.ts +7 -0
- package/dist/core/models/list-enabled-models.js +5 -0
- package/dist/core/models/list-enabled-models.js.map +1 -0
- package/dist/core/models/ports.d.ts +11 -0
- package/dist/core/models/ports.js +2 -0
- package/dist/core/models/ports.js.map +1 -0
- package/dist/core/models/set-model-enabled.d.ts +15 -0
- package/dist/core/models/set-model-enabled.js +12 -0
- package/dist/core/models/set-model-enabled.js.map +1 -0
- package/dist/core/operator/authenticate-operator.d.ts +2 -2
- package/dist/core/operator/ports.d.ts +28 -3
- package/dist/core/shared/errors.d.ts +1 -1
- package/dist/core/shared/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/adapters/prisma/migrations/20261025100000_enabled_models/migration.sql +7 -0
- package/src/adapters/prisma/schema.prisma +13 -1
|
@@ -34,6 +34,29 @@ function offersWorkspace(details, workspace) {
|
|
|
34
34
|
function workspaceName(workspace) {
|
|
35
35
|
return workspace.kind === 'worktree' ? `repository ${workspace.repository}` : `folder ${workspace.name}`;
|
|
36
36
|
}
|
|
37
|
+
/** A harness options schema that reports a default model (`properties.model.default`). */
|
|
38
|
+
const defaultModelSchema = z.object({ properties: z.object({ model: z.object({ default: z.string() }) }) });
|
|
39
|
+
/** Whether the harness reports a default model and the fleet enabled it: a harness with no default or no model option does not. */
|
|
40
|
+
function isDefaultEnabled(schema, enabledModels) {
|
|
41
|
+
const read = defaultModelSchema.safeParse(schema);
|
|
42
|
+
return read.success && enabledModels.includes(read.data.properties.model.default);
|
|
43
|
+
}
|
|
44
|
+
/** Why a request waits on a model the fleet did not enable, within what a reason may hold. */
|
|
45
|
+
function modelDisabledReason(what) {
|
|
46
|
+
return `model disabled: ${what}`.slice(0, CREW_REQUEST_REASON_MAX_LENGTH);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Why a request naming a model the fleet did not enable waits, or undefined
|
|
50
|
+
* when the fleet has no rule or the model is enabled (M3): checked before any
|
|
51
|
+
* trierarch.
|
|
52
|
+
*/
|
|
53
|
+
function namedModelRefusal(settings, enabledModels) {
|
|
54
|
+
const named = settings.options.model;
|
|
55
|
+
if (enabledModels.length === 0 || named === undefined || (typeof named === 'string' && enabledModels.includes(named))) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return { reason: modelDisabledReason(typeof named === 'string' ? named : JSON.stringify(named)), field: 'options' };
|
|
59
|
+
}
|
|
37
60
|
/** Room left as a share of its cap: what placement compares. */
|
|
38
61
|
function roomShare(trierarch) {
|
|
39
62
|
return (trierarch.details.caps.ships - trierarch.assigned) / trierarch.details.caps.ships;
|
|
@@ -44,11 +67,17 @@ function givenBackReason(givenBack) {
|
|
|
44
67
|
return `given back by every trierarch that fits; last: ${last}`.slice(0, CREW_REQUEST_REASON_MAX_LENGTH);
|
|
45
68
|
}
|
|
46
69
|
/**
|
|
47
|
-
* The trierarch to claim for the settings, or why none fits:
|
|
48
|
-
*
|
|
49
|
-
*
|
|
70
|
+
* The trierarch to claim for the settings, or why none fits: a named model
|
|
71
|
+
* the fleet did not enable, first (M3); machine labels, harness (the named
|
|
72
|
+
* one, or each trierarch's default), workspace, options; an enabled default
|
|
73
|
+
* model for a request naming none; then the trierarchs that gave the request
|
|
74
|
+
* back (#382), then room.
|
|
50
75
|
*/
|
|
51
|
-
function fit(settings, { trierarchs, givenBack }) {
|
|
76
|
+
function fit(settings, { trierarchs, enabledModels, givenBack }) {
|
|
77
|
+
const disabled = namedModelRefusal(settings, enabledModels);
|
|
78
|
+
if (disabled !== undefined) {
|
|
79
|
+
return disabled;
|
|
80
|
+
}
|
|
52
81
|
if (trierarchs.length === 0) {
|
|
53
82
|
return { reason: 'no trierarch reports yet' };
|
|
54
83
|
}
|
|
@@ -72,13 +101,18 @@ function fit(settings, { trierarchs, givenBack }) {
|
|
|
72
101
|
if (withWorkspace.length === 0) {
|
|
73
102
|
return { reason: `no trierarch offering ${harnessWords} has ${workspaceName(settings.workspace)}`, field: 'workspace' };
|
|
74
103
|
}
|
|
75
|
-
const refusals = withWorkspace.map(({ trierarch, harness }) => ({ trierarch, refusal: optionsRefusal(harness.options, settings.options) }));
|
|
76
|
-
const taking = refusals.filter(({ refusal }) => refusal === undefined)
|
|
104
|
+
const refusals = withWorkspace.map(({ trierarch, harness }) => ({ trierarch, harness, refusal: optionsRefusal(harness.options, settings.options) }));
|
|
105
|
+
const taking = refusals.filter(({ refusal }) => refusal === undefined);
|
|
77
106
|
const [firstRefusal] = refusals;
|
|
78
107
|
if (taking.length === 0) {
|
|
79
108
|
return { reason: `no trierarch takes these options for ${harnessWords}: ${firstRefusal?.refusal ?? ''}`, field: 'options' };
|
|
80
109
|
}
|
|
81
|
-
|
|
110
|
+
// A request naming no model runs on the harness's default: only an enabled one fits (M3).
|
|
111
|
+
const allowed = enabledModels.length === 0 || settings.options.model !== undefined ? taking : taking.filter(({ harness }) => isDefaultEnabled(harness.options, enabledModels));
|
|
112
|
+
if (allowed.length === 0) {
|
|
113
|
+
return { reason: modelDisabledReason(`no enabled default model for ${harnessWords}`), field: 'options' };
|
|
114
|
+
}
|
|
115
|
+
const left = allowed.map(({ trierarch }) => trierarch).filter((trierarch) => !givenBack.some((back) => back.trierarchShipId === trierarch.shipId));
|
|
82
116
|
if (left.length === 0) {
|
|
83
117
|
return { reason: givenBackReason(givenBack) };
|
|
84
118
|
}
|
|
@@ -96,9 +130,9 @@ function parsed(settings) {
|
|
|
96
130
|
* Policy: whether settings would be placed now, before anything is requested
|
|
97
131
|
* (#245): by the same rules as placement, against the trierarchs as they are.
|
|
98
132
|
*/
|
|
99
|
-
export function checkPlacement(settings,
|
|
133
|
+
export function checkPlacement(settings, fleet) {
|
|
100
134
|
const read = parsed(settings);
|
|
101
|
-
const fitted = 'settings' in read ? fit(read.settings, {
|
|
135
|
+
const fitted = 'settings' in read ? fit(read.settings, { ...fleet, givenBack: [] }) : read;
|
|
102
136
|
if ('trierarch' in fitted) {
|
|
103
137
|
return { kind: 'fits' };
|
|
104
138
|
}
|
|
@@ -106,14 +140,16 @@ export function checkPlacement(settings, trierarchs) {
|
|
|
106
140
|
}
|
|
107
141
|
/**
|
|
108
142
|
* Policy: where each unassigned request goes (docs/trierarch.md,
|
|
109
|
-
* "Assignment"). Oldest request first
|
|
143
|
+
* "Assignment"). Oldest request first; in a fleet that enabled models, only
|
|
144
|
+
* a request whose model is enabled, or that names none and runs on an enabled
|
|
145
|
+
* default (model governance, M3). Each to a trierarch whose ship
|
|
110
146
|
* carries every machine label it names, that offers its harness and workspace, takes its options against the schema it reports for
|
|
111
147
|
* that harness, did not give it back (#382), and has room (its cap above the requests assigned to it);
|
|
112
148
|
* of those, the most room as a share of its cap, then the oldest. What it
|
|
113
149
|
* assigns counts against the room of later requests in the same pass. A
|
|
114
150
|
* request none fits gets the reason, unless that reason is written already.
|
|
115
151
|
*/
|
|
116
|
-
export function place(requests, trierarchs) {
|
|
152
|
+
export function place(requests, { trierarchs, enabledModels }) {
|
|
117
153
|
const assigned = new Map(trierarchs.map((trierarch) => [trierarch.shipId, trierarch.assigned]));
|
|
118
154
|
const placements = [];
|
|
119
155
|
const oldestFirst = [...requests].sort((first, second) => first.requestedAt.getTime() - second.requestedAt.getTime() || first.shipId.localeCompare(second.shipId));
|
|
@@ -121,6 +157,7 @@ export function place(requests, trierarchs) {
|
|
|
121
157
|
const read = parsed(request.settings);
|
|
122
158
|
const fitted = 'settings' in read
|
|
123
159
|
? fit(read.settings, {
|
|
160
|
+
enabledModels,
|
|
124
161
|
trierarchs: trierarchs.map((trierarch) => ({ ...trierarch, assigned: assigned.get(trierarch.shipId) ?? trierarch.assigned })),
|
|
125
162
|
givenBack: request.givenBack,
|
|
126
163
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../../src/core/assignment/placement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,gBAAgB,EAA+D,MAAM,sBAAsB,CAAC;AAChL,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../../src/core/assignment/placement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,gBAAgB,EAA+D,MAAM,sBAAsB,CAAC;AAChL,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoDxB,wEAAwE;AACxE,SAAS,MAAM,CAAC,KAAY,EAAE,SAAmB,EAAE;IACjD,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9D,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK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,CAAC;QACtF,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -35,7 +35,8 @@ export interface InstallationRequests {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Outbound port: forgets everything the trierarch plugin holds of a fleet,
|
|
38
|
-
* in one go: its connection, its switch and the requests
|
|
38
|
+
* in one go: its connection, its switch, its enabled models and the requests
|
|
39
|
+
* that name it.
|
|
39
40
|
*/
|
|
40
41
|
export interface FleetForgetter {
|
|
41
42
|
forget(fleetId: FleetId): Promise<void>;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { refuse } from '../shared/errors.js';
|
|
2
2
|
import { ok } from '../shared/result.js';
|
|
3
3
|
import { JOIN_SCOPE } from '../scopes/plugin-scopes.js';
|
|
4
|
+
import { setupLineOf } from './setup-line.js';
|
|
4
5
|
/** The type of every machine's ship: its trierarch's. */
|
|
5
6
|
export const TRIERARCH_TYPE = 'trierarch';
|
|
6
7
|
/** What a trierarch may do beyond sending and receiving: crew the ships assigned to it (decision 0030). */
|
|
7
8
|
const TRIERARCH_SCOPES = ['crew:run'];
|
|
8
|
-
/** The package a machine sets up its trierarch with. */
|
|
9
|
-
const TRIERARCH_PACKAGE = '@aeolus-fleet/trierarch';
|
|
10
9
|
/**
|
|
11
10
|
* Use case: an actor brings a machine into the fleet (decision 0055). It
|
|
12
11
|
* needs trierarch:join, which the trierarch plugin declares and
|
|
@@ -36,8 +35,7 @@ export function createJoinMachine(deps) {
|
|
|
36
35
|
: refuse('FLEET_UNAVAILABLE', `The fleet did not commission the machine's ship: ${commissioned.error.message}`);
|
|
37
36
|
}
|
|
38
37
|
const { shipId, prompt, crewLines, secret } = commissioned.value;
|
|
39
|
-
|
|
40
|
-
const setupLine = `npx ${TRIERARCH_PACKAGE} init --fleet-url ${deps.fleetUrl} --ship-id ${shipId} --plugin-ship-id ${crew.shipId} --secret ${secret}`;
|
|
38
|
+
const setupLine = setupLineOf({ fleetUrl: deps.fleetUrl, shipId, pluginShipId: crew.shipId, secret });
|
|
41
39
|
return ok({ shipId, name, prompt, crewLines, secret, setupLine });
|
|
42
40
|
};
|
|
43
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join-machine.js","sourceRoot":"","sources":["../../../src/core/machines/join-machine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"join-machine.js","sourceRoot":"","sources":["../../../src/core/machines/join-machine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAE1C,2GAA2G;AAC3G,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,CAAC;AA0BtC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAgG;IAChI,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QACxC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACpE,OAAO,MAAM,CAAC,aAAa,EAAE,2BAA2B,UAAU,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,MAAM,CAAC,eAAe,EAAE,gFAAgF,CAAC,CAAC;QACnH,CAAC;QACD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5J,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;YACvB,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;gBAC3C,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;gBAClD,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE,oDAAoD,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpH,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC;QACjE,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACtG,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FleetId, ShipId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { ConnectionStore, FleetDoor } from '../connection/ports.js';
|
|
3
|
+
import type { OperatorFleet, OperatorSession } from '../operator/ports.js';
|
|
4
|
+
import { type DomainError } from '../shared/errors.js';
|
|
5
|
+
import { type Result } from '../shared/result.js';
|
|
6
|
+
export type NewSetupLineRefusal = DomainError<'NOT_CONNECTED' | 'NOT_A_MACHINE' | 'FLEET_REFUSED' | 'FLEET_UNAVAILABLE'>;
|
|
7
|
+
/** A machine's new setup line, shown once like the secret it holds. */
|
|
8
|
+
export interface NewSetupLine {
|
|
9
|
+
shipId: ShipId;
|
|
10
|
+
setupLine: string;
|
|
11
|
+
}
|
|
12
|
+
export type MakeNewSetupLine = (input: {
|
|
13
|
+
fleetId: FleetId;
|
|
14
|
+
shipId: ShipId;
|
|
15
|
+
session: OperatorSession;
|
|
16
|
+
}) => Promise<Result<NewSetupLine, NewSetupLineRefusal>>;
|
|
17
|
+
/**
|
|
18
|
+
* Use case: a lost setup line got again (aeolus-fleet#1239). Its line is the
|
|
19
|
+
* one a join gives, with a new secret for the machine's ship: the old line
|
|
20
|
+
* stops working. A crewed machine's ship is released first, so a trierarch
|
|
21
|
+
* already running with it loses its crew; then it gets its new starting
|
|
22
|
+
* prompt. Both calls are the operator's, with the operator's console session,
|
|
23
|
+
* so the operator's own scopes and reach decide (decision 0057). The ship is
|
|
24
|
+
* read with the trierarch plugin's own ship first, so only a machine, a ship
|
|
25
|
+
* of type trierarch, gets a line. The secret is never kept or logged.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createNewSetupLine(deps: {
|
|
28
|
+
door: FleetDoor;
|
|
29
|
+
connections: ConnectionStore;
|
|
30
|
+
operatorFleet: OperatorFleet;
|
|
31
|
+
fleetUrl: string;
|
|
32
|
+
}): MakeNewSetupLine;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { refuse } from '../shared/errors.js';
|
|
2
|
+
import { ok } from '../shared/result.js';
|
|
3
|
+
import { TRIERARCH_TYPE } from './join-machine.js';
|
|
4
|
+
import { setupLineOf } from './setup-line.js';
|
|
5
|
+
/** The fleet's refusal of an operator's call, in its own words; no answer is said as such. */
|
|
6
|
+
function refusedBy(refusal) {
|
|
7
|
+
return refusal.code === 'UNAVAILABLE' ? refuse('FLEET_UNAVAILABLE', `The fleet did not answer: ${refusal.message}`) : refuse('FLEET_REFUSED', refusal.message);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Use case: a lost setup line got again (aeolus-fleet#1239). Its line is the
|
|
11
|
+
* one a join gives, with a new secret for the machine's ship: the old line
|
|
12
|
+
* stops working. A crewed machine's ship is released first, so a trierarch
|
|
13
|
+
* already running with it loses its crew; then it gets its new starting
|
|
14
|
+
* prompt. Both calls are the operator's, with the operator's console session,
|
|
15
|
+
* so the operator's own scopes and reach decide (decision 0057). The ship is
|
|
16
|
+
* read with the trierarch plugin's own ship first, so only a machine, a ship
|
|
17
|
+
* of type trierarch, gets a line. The secret is never kept or logged.
|
|
18
|
+
*/
|
|
19
|
+
export function createNewSetupLine(deps) {
|
|
20
|
+
return async ({ fleetId, shipId, session }) => {
|
|
21
|
+
const crew = await deps.connections.find(fleetId);
|
|
22
|
+
if (!crew) {
|
|
23
|
+
return refuse('NOT_CONNECTED', 'The trierarch plugin is not connected to this fleet: connect it in the console');
|
|
24
|
+
}
|
|
25
|
+
const ship = await deps.door.getShip(crew.crewToken, { shipId });
|
|
26
|
+
if (!ship.isOk) {
|
|
27
|
+
return ship.error.code === 'NOT_FOUND' ? refuse('NOT_A_MACHINE', `${shipId} is not a machine of this fleet`) : refusedBy(ship.error);
|
|
28
|
+
}
|
|
29
|
+
if (ship.value.type !== TRIERARCH_TYPE) {
|
|
30
|
+
return refuse('NOT_A_MACHINE', `${shipId} is not a machine of this fleet`);
|
|
31
|
+
}
|
|
32
|
+
if (ship.value.status === 'crewed') {
|
|
33
|
+
const released = await deps.operatorFleet.release(session, { shipId });
|
|
34
|
+
if (!released.isOk) {
|
|
35
|
+
return refusedBy(released.error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const issued = await deps.operatorFleet.getStartingPrompt(session, { shipId });
|
|
39
|
+
if (!issued.isOk) {
|
|
40
|
+
return refusedBy(issued.error);
|
|
41
|
+
}
|
|
42
|
+
return ok({ shipId, setupLine: setupLineOf({ fleetUrl: deps.fleetUrl, shipId, pluginShipId: crew.shipId, secret: issued.value.secret }) });
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=new-setup-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-setup-line.js","sourceRoot":"","sources":["../../../src/core/machines/new-setup-line.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAyB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAY9C,8FAA8F;AAC9F,SAAS,SAAS,CAAC,OAAqB;IACtC,OAAO,OAAO,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACjK,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAuG;IACxI,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,MAAM,CAAC,eAAe,EAAE,gFAAgF,CAAC,CAAC;QACnH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CA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The one ready-to-run line that sets a machine up: `aeolus-trierarch init`
|
|
4
|
+
* takes the fleet's URL, the machine's ship and its secret, and the trierarch
|
|
5
|
+
* plugin's own ship as flags and never parses a prompt. The trierarch takes
|
|
6
|
+
* the trusted repositories only from that ship (aeolus-fleet#384): a ship's
|
|
7
|
+
* type proves nothing. It holds the secret, so it is shown once, never kept.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setupLineOf(parts: {
|
|
10
|
+
fleetUrl: string;
|
|
11
|
+
shipId: ShipId;
|
|
12
|
+
pluginShipId: ShipId;
|
|
13
|
+
secret: string;
|
|
14
|
+
}): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The package a machine sets up its trierarch with. */
|
|
2
|
+
const TRIERARCH_PACKAGE = '@aeolus-fleet/trierarch';
|
|
3
|
+
/**
|
|
4
|
+
* The one ready-to-run line that sets a machine up: `aeolus-trierarch init`
|
|
5
|
+
* takes the fleet's URL, the machine's ship and its secret, and the trierarch
|
|
6
|
+
* plugin's own ship as flags and never parses a prompt. The trierarch takes
|
|
7
|
+
* the trusted repositories only from that ship (aeolus-fleet#384): a ship's
|
|
8
|
+
* type proves nothing. It holds the secret, so it is shown once, never kept.
|
|
9
|
+
*/
|
|
10
|
+
export function setupLineOf(parts) {
|
|
11
|
+
return `npx ${TRIERARCH_PACKAGE} init --fleet-url ${parts.fleetUrl} --ship-id ${parts.shipId} --plugin-ship-id ${parts.pluginShipId} --secret ${parts.secret}`;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=setup-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-line.js","sourceRoot":"","sources":["../../../src/core/machines/setup-line.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiF;IAC3G,OAAO,OAAO,iBAAiB,qBAAqB,KAAK,CAAC,QAAQ,cAAc,KAAK,CAAC,MAAM,qBAAqB,KAAK,CAAC,YAAY,aAAa,KAAK,CAAC,MAAM,EAAE,CAAC;AACjK,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FleetId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { EnabledModels } from './ports.js';
|
|
3
|
+
export type ListEnabledModels = (fleetId: FleetId) => Promise<string[]>;
|
|
4
|
+
/** Use case: the fleet's enabled models by id (model governance, M6); none while the fleet has no rule. */
|
|
5
|
+
export declare function createListEnabledModels(deps: {
|
|
6
|
+
models: EnabledModels;
|
|
7
|
+
}): ListEnabledModels;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Use case: the fleet's enabled models by id (model governance, M6); none while the fleet has no rule. */
|
|
2
|
+
export function createListEnabledModels(deps) {
|
|
3
|
+
return async (fleetId) => (await deps.models.list(fleetId)).toSorted();
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=list-enabled-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-enabled-models.js","sourceRoot":"","sources":["../../../src/core/models/list-enabled-models.ts"],"names":[],"mappings":"AAMA,2GAA2G;AAC3G,MAAM,UAAU,uBAAuB,CAAC,IAA+B;IACrE,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FleetId } from '@aeolus-fleet/common';
|
|
2
|
+
/**
|
|
3
|
+
* Outbound port: each fleet's enabled models (model governance, M1, M2), the
|
|
4
|
+
* exact model ids its agent ships may be crewed with; none is no rule.
|
|
5
|
+
* Enabling an enabled id or disabling one not held changes nothing.
|
|
6
|
+
*/
|
|
7
|
+
export interface EnabledModels {
|
|
8
|
+
list(fleetId: FleetId): Promise<string[]>;
|
|
9
|
+
enable(fleetId: FleetId, model: string): Promise<void>;
|
|
10
|
+
disable(fleetId: FleetId, model: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../../src/core/models/ports.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FleetId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { EnabledModels } from './ports.js';
|
|
3
|
+
export type SetModelEnabled = (input: {
|
|
4
|
+
fleetId: FleetId;
|
|
5
|
+
model: string;
|
|
6
|
+
isEnabled: boolean;
|
|
7
|
+
}) => Promise<string[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Use case: enables or disables one model for the fleet (model governance,
|
|
10
|
+
* M6) and answers the fleet's enabled models by id. Already so changes
|
|
11
|
+
* nothing; the next assignment pass places by the new set (M5).
|
|
12
|
+
*/
|
|
13
|
+
export declare function createSetModelEnabled(deps: {
|
|
14
|
+
models: EnabledModels;
|
|
15
|
+
}): SetModelEnabled;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use case: enables or disables one model for the fleet (model governance,
|
|
3
|
+
* M6) and answers the fleet's enabled models by id. Already so changes
|
|
4
|
+
* nothing; the next assignment pass places by the new set (M5).
|
|
5
|
+
*/
|
|
6
|
+
export function createSetModelEnabled(deps) {
|
|
7
|
+
return async ({ fleetId, model, isEnabled }) => {
|
|
8
|
+
await (isEnabled ? deps.models.enable(fleetId, model) : deps.models.disable(fleetId, model));
|
|
9
|
+
return (await deps.models.list(fleetId)).toSorted();
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=set-model-enabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-model-enabled.js","sourceRoot":"","sources":["../../../src/core/models/set-model-enabled.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA+B;IACnE,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;QAC7C,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7F,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ConsoleSessionOutput, FleetId,
|
|
1
|
+
import type { ConsoleSessionOutput, FleetId, ScopeName } from "@aeolus-fleet/common";
|
|
2
2
|
import { type DomainError } from "../shared/errors.js";
|
|
3
3
|
import { type Result } from "../shared/result.js";
|
|
4
4
|
import type { ConsoleSessions } from "./ports.js";
|
|
5
5
|
export type AuthenticateOperator = (cookie: string | undefined) => Promise<Result<{
|
|
6
6
|
fleetId: FleetId;
|
|
7
7
|
kind: ConsoleSessionOutput["kind"];
|
|
8
|
-
scopes: readonly
|
|
8
|
+
scopes: readonly ScopeName[];
|
|
9
9
|
}, DomainError<"NOT_THE_OPERATOR">>>;
|
|
10
10
|
/**
|
|
11
11
|
* Use case: whether a request comes from the operator. The trierarch plugin has no login
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConsoleSessionOutput, FleetId,
|
|
2
|
-
import type { FleetRefusal } from '../connection/ports.js';
|
|
1
|
+
import type { ConsoleSessionOutput, FleetId, ScopeName, ShipId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { FleetRefusal, IssuedPrompt } from '../connection/ports.js';
|
|
3
3
|
import type { Result } from '../shared/result.js';
|
|
4
4
|
/**
|
|
5
5
|
* Outbound port: asks the fleet whether a forwarded console session cookie is
|
|
@@ -10,6 +10,31 @@ export interface ConsoleSessions {
|
|
|
10
10
|
check(cookie: string): Promise<Result<{
|
|
11
11
|
fleetId: FleetId;
|
|
12
12
|
kind: ConsoleSessionOutput['kind'];
|
|
13
|
-
scopes: readonly
|
|
13
|
+
scopes: readonly ScopeName[];
|
|
14
14
|
}, FleetRefusal>>;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The operator's console session as the console's server forwarded it: its
|
|
18
|
+
* cookie and the console's Origin, which the fleet needs on a state-changing
|
|
19
|
+
* call made with the cookie. undefined when the request came with none, which
|
|
20
|
+
* the fleet then refuses.
|
|
21
|
+
*/
|
|
22
|
+
export interface OperatorSession {
|
|
23
|
+
cookie: string;
|
|
24
|
+
origin: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Outbound port: the fleet's calls the trierarch plugin makes on behalf of
|
|
28
|
+
* the operator, with the operator's console session, so the operator's own
|
|
29
|
+
* scopes and reach decide (decision 0057), never the plugin's ship's.
|
|
30
|
+
*/
|
|
31
|
+
export interface OperatorFleet {
|
|
32
|
+
/** Frees a crewed ship from its session: its crew token and secret stop working (`fleet.release`). */
|
|
33
|
+
release(session: OperatorSession, ship: {
|
|
34
|
+
shipId: ShipId;
|
|
35
|
+
}): Promise<Result<undefined, FleetRefusal>>;
|
|
36
|
+
/** A new starting prompt for a ship awaiting crew; its new secret stops any earlier one working (`fleet.getStartingPrompt`). */
|
|
37
|
+
getStartingPrompt(session: OperatorSession, ship: {
|
|
38
|
+
shipId: ShipId;
|
|
39
|
+
}): Promise<Result<IssuedPrompt, FleetRefusal>>;
|
|
40
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Err } from './result.js';
|
|
2
2
|
/** Every reason the trierarch plugin's core refuses a request. */
|
|
3
|
-
export type DomainErrorKind = 'ALREADY_CONNECTED' | 'SECRET_REFUSED' | 'OTHER_FLEET' | 'MISSING_SCOPES' | 'NOT_THE_OPERATOR' | 'REQUEST_ID_USED' | 'NOT_CONNECTED' | 'NAME_TAKEN' | 'NEEDS_SCOPE' | 'FLEET_UNAVAILABLE';
|
|
3
|
+
export type DomainErrorKind = 'ALREADY_CONNECTED' | 'SECRET_REFUSED' | 'OTHER_FLEET' | 'MISSING_SCOPES' | 'NOT_THE_OPERATOR' | 'REQUEST_ID_USED' | 'NOT_CONNECTED' | 'NAME_TAKEN' | 'NEEDS_SCOPE' | 'FLEET_UNAVAILABLE' | 'NOT_A_MACHINE' | 'FLEET_REFUSED';
|
|
4
4
|
/** Why the core refused a request. Adapters map the kind to their own error shape; the message is safe to show. */
|
|
5
5
|
export interface DomainError<K extends DomainErrorKind = DomainErrorKind> {
|
|
6
6
|
readonly kind: K;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;AAuB5C,qDAAqD;AACrD,MAAM,UAAU,MAAM,CAA4B,IAAO,EAAE,OAAe;IACxE,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeolus-fleet/trierarch-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Brings your machines into an Aeolus fleet and places crew requests on them.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aeolus",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"postpack": "rm LICENSE"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aeolus-fleet/common": "^0.
|
|
52
|
+
"@aeolus-fleet/common": "^0.32.0",
|
|
53
53
|
"@prisma/adapter-pg": "^7.10.0",
|
|
54
54
|
"@prisma/client": "^7.10.0",
|
|
55
55
|
"@trpc/server": "^11.19.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"zod": "^4.6.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@aeolus-fleet/core": "^0.
|
|
61
|
+
"@aeolus-fleet/core": "^0.32.0",
|
|
62
62
|
"@testcontainers/postgresql": "^12.2.0"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The trierarch plugin's tables, in its own small database (decision 0030): per
|
|
2
|
-
// fleet only its connection
|
|
2
|
+
// fleet only its connection, its switch and its enabled models (decision 0063),
|
|
3
|
+
// and the installation's requests.
|
|
3
4
|
// Everything else (crew requests, statuses, machines) lives in the fleet, which
|
|
4
5
|
// it reaches only through its public API, as the ship it crews.
|
|
5
6
|
//
|
|
@@ -56,3 +57,14 @@ model InstallationRequest {
|
|
|
56
57
|
@@index([fleetId])
|
|
57
58
|
@@map("installation_requests")
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
/// The models each fleet's agent ships may be crewed with (decision 0063): exact
|
|
62
|
+
/// model ids, one row each. None is no rule. Forgotten with the fleet; switching
|
|
63
|
+
/// the trierarch plugin off keeps them.
|
|
64
|
+
model EnabledModel {
|
|
65
|
+
fleetId String @map("fleet_id")
|
|
66
|
+
model String
|
|
67
|
+
|
|
68
|
+
@@id([fleetId, model])
|
|
69
|
+
@@map("enabled_models")
|
|
70
|
+
}
|