@agentshouse/kit 0.1.0-alpha.10 → 0.1.0-alpha.11
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 +4 -5
- package/bootstrap.json +3 -3
- package/package.json +1 -1
- package/src/host.js +6 -2
- package/src/house.js +2 -8
- package/src/source.js +34 -24
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ On Linux `amd64` or `arm64` with a working Docker Engine, run the published,
|
|
|
10
10
|
versioned bootstrap once:
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.
|
|
13
|
+
bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.11/connect-linux.sh)
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The release asset pins one immutable multi-architecture image digest. It creates
|
|
@@ -1130,10 +1130,9 @@ retained references still waiting to be saved.
|
|
|
1130
1130
|
Every command that changes or reads installation state takes this
|
|
1131
1131
|
installation's exclusive Environment control lease for the length of its run
|
|
1132
1132
|
and renews it before it expires, so two Kit commands never work against the
|
|
1133
|
-
same installation at once. A command that ends, or is interrupted
|
|
1134
|
-
has stopped
|
|
1135
|
-
|
|
1136
|
-
that lease.
|
|
1133
|
+
same installation at once. A command that ends, is refused, or is interrupted
|
|
1134
|
+
once its work has stopped releases that exact lease so the next command acquires
|
|
1135
|
+
at once. A `kit login` credential is presented only to take that lease.
|
|
1137
1136
|
|
|
1138
1137
|
While `kit resident` holds that lease, a command runs through it instead: the
|
|
1139
1138
|
command presents no credential, the resident confirms its current lease with
|
package/bootstrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.11",
|
|
4
4
|
"hosts": {
|
|
5
5
|
"linux": {
|
|
6
|
-
"command": "bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.
|
|
6
|
+
"command": "bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.11/connect-linux.sh)",
|
|
7
7
|
"asset": {
|
|
8
8
|
"name": "connect-linux.sh",
|
|
9
|
-
"url": "https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.
|
|
9
|
+
"url": "https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.11/connect-linux.sh"
|
|
10
10
|
},
|
|
11
11
|
"workspace": {
|
|
12
12
|
"argument": "--workspace",
|
package/package.json
CHANGED
package/src/host.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, statfs } from "node:fs/promises";
|
|
2
2
|
import { readConfiguration } from "./configuration.js";
|
|
3
3
|
import { HOST_CPU_SAMPLE_MS } from "./contract.js";
|
|
4
|
-
import { openSession, reportHostCapacity } from "./house.js";
|
|
4
|
+
import { maintainControl, openSession, reportHostCapacity } from "./house.js";
|
|
5
5
|
import { KitRefusal } from "./refusal.js";
|
|
6
6
|
|
|
7
7
|
const PROC_STAT = "/proc/stat";
|
|
@@ -116,6 +116,10 @@ export async function reportHost(options, dependencies = {}) {
|
|
|
116
116
|
? observed
|
|
117
117
|
: { ...observed, maxima: declaredMaxima(configuration.host.maxima) };
|
|
118
118
|
const session = await openSession(options, dependencies);
|
|
119
|
-
await
|
|
119
|
+
await maintainControl(
|
|
120
|
+
session,
|
|
121
|
+
(signal) => reportHostCapacity(session, declaration, signal),
|
|
122
|
+
options.signal,
|
|
123
|
+
);
|
|
120
124
|
return declaration;
|
|
121
125
|
}
|
package/src/house.js
CHANGED
|
@@ -438,20 +438,14 @@ export async function maintainControl(session, operation, signal, { release = tr
|
|
|
438
438
|
}
|
|
439
439
|
})();
|
|
440
440
|
const running = Promise.resolve().then(() => operation(operationSignal));
|
|
441
|
-
let ended = false;
|
|
442
441
|
try {
|
|
443
|
-
|
|
444
|
-
ended = true;
|
|
445
|
-
return answer;
|
|
446
|
-
} catch (error) {
|
|
447
|
-
ended = error instanceof KitRefusal && error.code === "kit_command_cancelled";
|
|
448
|
-
throw error;
|
|
442
|
+
return await Promise.race([running, failure, cancellation]);
|
|
449
443
|
} finally {
|
|
450
444
|
stopped = true;
|
|
451
445
|
maintenance.abort();
|
|
452
446
|
signal?.removeEventListener("abort", cancelOperation);
|
|
453
447
|
await Promise.all([renewal, running.catch(() => undefined)]);
|
|
454
|
-
if (
|
|
448
|
+
if (release) await releaseControl(session);
|
|
455
449
|
}
|
|
456
450
|
}
|
|
457
451
|
|
package/src/source.js
CHANGED
|
@@ -204,18 +204,24 @@ export async function captureSource(options, dependencies = {}) {
|
|
|
204
204
|
const googleOAuthClient =
|
|
205
205
|
instance.preset === "google" ? dependencies.googleOAuthClient() : null;
|
|
206
206
|
const session = await openSession(options, dependencies);
|
|
207
|
-
|
|
208
|
-
instance,
|
|
207
|
+
return maintainControl(
|
|
209
208
|
session,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
209
|
+
async (signal) => {
|
|
210
|
+
const context = {
|
|
211
|
+
instance,
|
|
212
|
+
session,
|
|
213
|
+
directory: options.directory,
|
|
214
|
+
signal,
|
|
215
|
+
now: session.now,
|
|
216
|
+
dependencies,
|
|
217
|
+
googleOAuthClient,
|
|
218
|
+
};
|
|
219
|
+
const delivered = [];
|
|
220
|
+
for (const service of services) delivered.push(await deliverService(context, service));
|
|
221
|
+
return { instance: instance.id, services: delivered };
|
|
222
|
+
},
|
|
223
|
+
options.signal,
|
|
224
|
+
);
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
export async function sourceStatus(options) {
|
|
@@ -255,23 +261,27 @@ export async function retrySourceOriginals(options, dependencies = {}) {
|
|
|
255
261
|
const configuration = await readConfiguration(options.configuration);
|
|
256
262
|
const instance = sourceInstance(configuration, options.instance);
|
|
257
263
|
const services = declaredServices(instance, options.service ?? null);
|
|
258
|
-
const context = { instance, directory: options.directory, signal: options.signal };
|
|
259
264
|
const outstanding = [];
|
|
260
265
|
for (const service of services) {
|
|
261
266
|
outstanding.push((await readSourceOriginals(options.directory, instance.id, service.service)).length);
|
|
262
267
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
268
|
+
const retry = async (context) => {
|
|
269
|
+
const retried = [];
|
|
270
|
+
for (const [position, service] of services.entries()) {
|
|
271
|
+
retried.push({
|
|
272
|
+
service: service.service,
|
|
273
|
+
originals:
|
|
274
|
+
outstanding[position] === 0
|
|
275
|
+
? []
|
|
276
|
+
: await saveSourceOriginals(context, serviceBinding(context, service)),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return { instance: instance.id, services: retried };
|
|
280
|
+
};
|
|
281
|
+
const context = { instance, directory: options.directory, signal: options.signal };
|
|
282
|
+
if (outstanding.every((count) => count === 0)) return retry(context);
|
|
283
|
+
const session = await openSession(options, dependencies);
|
|
284
|
+
return maintainControl(session, (signal) => retry({ ...context, session, signal }), options.signal);
|
|
275
285
|
}
|
|
276
286
|
|
|
277
287
|
export async function resetSource(options, dependencies = {}) {
|