@parcha/agentrun-computer 0.1.0-beta.34 → 0.1.0-beta.35
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 +144 -26
- package/dist/browser.d.ts +12 -13
- package/dist/browser.js +16 -14
- package/dist/browserbase.d.ts +3 -5
- package/dist/browserbase.js +16 -13
- package/dist/chrome.js +1 -1
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/browserbase.js +1 -1
- package/dist/conformance/cases/provider.js +78 -3
- package/dist/conformance/daytona.js +2 -1
- package/dist/conformance/e2b.js +2 -1
- package/dist/conformance/fixture.js +24 -2
- package/dist/conformance/kernel.js +1 -1
- package/dist/conformance/kind.js +2 -1
- package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
- package/dist/conformance/{local.js → local-chrome.js} +11 -11
- package/dist/conformance/orgo.d.ts +11 -5
- package/dist/conformance/orgo.js +37 -8
- package/dist/conformance/phone-harness.js +2 -1
- package/dist/conformance/report.js +3 -2
- package/dist/conformance/runner.js +25 -7
- package/dist/conformance/types.d.ts +21 -8
- package/dist/conformance/types.js +10 -0
- package/dist/conformance/windows-fixture.d.ts +1 -0
- package/dist/conformance/windows-fixture.js +37 -0
- package/dist/daytona.d.ts +3 -34
- package/dist/daytona.js +34 -61
- package/dist/descriptor.d.ts +94 -0
- package/dist/descriptor.js +81 -0
- package/dist/descriptors/browserbase.d.ts +24 -0
- package/dist/descriptors/browserbase.js +18 -0
- package/dist/descriptors/daytona.d.ts +62 -0
- package/dist/descriptors/daytona.js +49 -0
- package/dist/descriptors/docker.d.ts +12 -0
- package/dist/descriptors/docker.js +17 -0
- package/dist/descriptors/e2b.d.ts +22 -0
- package/dist/descriptors/e2b.js +19 -0
- package/dist/descriptors/index.d.ts +229 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +20 -0
- package/dist/descriptors/kernel.js +15 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +50 -0
- package/dist/descriptors/modal.js +38 -0
- package/dist/descriptors/orgo.d.ts +88 -0
- package/dist/descriptors/orgo.js +44 -0
- package/dist/descriptors/phone-harness.d.ts +28 -0
- package/dist/descriptors/phone-harness.js +20 -0
- package/dist/descriptors/shared.d.ts +7 -0
- package/dist/descriptors/shared.js +6 -0
- package/dist/desktop.d.ts +4 -4
- package/dist/desktop.js +4 -4
- package/dist/docker/egress.d.ts +1 -1
- package/dist/docker/image.js +17 -15
- package/dist/docker/inspect.d.ts +147 -0
- package/dist/docker/inspect.js +335 -0
- package/dist/docker.d.ts +6 -6
- package/dist/docker.js +46 -42
- package/dist/drift.d.ts +3 -145
- package/dist/drift.js +5 -334
- package/dist/e2b.d.ts +2 -8
- package/dist/e2b.js +16 -22
- package/dist/index.d.ts +8 -11
- package/dist/index.js +13 -11
- package/dist/isolation.js +2 -2
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -5
- package/dist/kernel.js +19 -16
- package/dist/kinds.d.ts +54 -34
- package/dist/kinds.js +19 -117
- package/dist/labels.d.ts +12 -0
- package/dist/labels.js +39 -1
- package/dist/{local.d.ts → local-chrome.d.ts} +5 -8
- package/dist/{local.js → local-chrome.js} +19 -16
- package/dist/local-supervisor.d.ts +3 -3
- package/dist/local-supervisor.js +3 -3
- package/dist/modal.d.ts +3 -22
- package/dist/modal.js +15 -31
- package/dist/mount-archil.js +4 -4
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +153 -0
- package/dist/orgo-desktop.js +1614 -0
- package/dist/orgo-names.d.ts +52 -0
- package/dist/orgo-names.js +84 -0
- package/dist/orgo.d.ts +18 -15
- package/dist/orgo.js +46 -107
- package/dist/phone-harness.d.ts +4 -10
- package/dist/phone-harness.js +45 -46
- package/dist/provider.d.ts +91 -10
- package/dist/provider.js +42 -0
- package/dist/providers.d.ts +23 -24
- package/dist/providers.js +14 -17
- package/dist/result.d.ts +11 -1
- package/dist/result.js +11 -0
- package/dist/test-connection.js +2 -2
- package/package.json +42 -2
package/dist/janitor.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface SweepOptions {
|
|
|
5
5
|
labels?: Record<string, string>;
|
|
6
6
|
/** The time to compare deadlines with; default now. */
|
|
7
7
|
now?: Date;
|
|
8
|
+
/**
|
|
9
|
+
* Whether an agent is gone, by its id: the caller's answer (serve's agents). An agent's computer whose owner is gone
|
|
10
|
+
* is deleted; without this, no agent counts as gone.
|
|
11
|
+
*/
|
|
12
|
+
ownerGone?: (agent: string) => boolean | Promise<boolean>;
|
|
8
13
|
signal?: AbortSignal;
|
|
9
14
|
}
|
|
10
15
|
export interface Swept {
|
|
@@ -22,11 +27,20 @@ export interface Swept {
|
|
|
22
27
|
* "janitor"; a caller runs it on a schedule. A computer that cannot be deleted does not stop the sweep: the result is
|
|
23
28
|
* then an error naming it and what was deleted. A provider with sweepLeftovers then removes, with the same labels and
|
|
24
29
|
* time, what its computers left behind (Docker: egress proxies and volumes whose computer is gone).
|
|
30
|
+
*
|
|
31
|
+
* An agent's computer (an owner label, or an info the provider marks owned, of a provider that declares persistence: of
|
|
32
|
+
* one that does not, an owner label is a caller's and keeps nothing) is never deleted by a deadline: only when
|
|
33
|
+
* its owner is gone (ownerGone), or once it has been detached for longer than its owner's idle TTL. One whose owner
|
|
34
|
+
* the janitor cannot read is kept. A
|
|
35
|
+
* provider that declares persistence is swept for its agents' computers alone under lifetime "vendor", since no vendor
|
|
36
|
+
* ends them.
|
|
25
37
|
*/
|
|
26
|
-
export declare function sweep(provider: ComputerProvider, { labels, now, signal }?: SweepOptions): Promise<Result<Swept>>;
|
|
38
|
+
export declare function sweep(provider: ComputerProvider, { labels, now, ownerGone, signal }?: SweepOptions): Promise<Result<Swept>>;
|
|
27
39
|
export interface ReleasedOlder {
|
|
28
40
|
/** The run's computers deleted: each with a lower epoch, and each that carries no epoch it can read. */
|
|
29
41
|
released: ComputerRef[];
|
|
42
|
+
/** The agents' computers among them, detached instead of deleted: their state kept for the claim to attach. */
|
|
43
|
+
detached: ComputerRef[];
|
|
30
44
|
/** The run's computers of this very epoch, left as they are. */
|
|
31
45
|
kept: ComputerRef[];
|
|
32
46
|
/** Of those released, each whose epoch label was missing or not an epoch, with what was wrong: it could not prove it is current. */
|
|
@@ -46,5 +60,8 @@ export interface ReleasedOlder {
|
|
|
46
60
|
* released: a partial cleanup is never a success, so a caller revokes nothing and mounts nothing after it. An aborted
|
|
47
61
|
* call starts no further release and says which ran. It revokes no mount: that is the root helper's, inside the
|
|
48
62
|
* computer, and a deleted computer holds none.
|
|
63
|
+
*
|
|
64
|
+
* An agent's computer (an owner label, readable or not, or an info marked owned, of a provider that declares
|
|
65
|
+
* persistence) of a lower epoch is detached, never deleted: its state is the agent's, and the new claim attaches it.
|
|
49
66
|
*/
|
|
50
67
|
export declare function releaseOlder(provider: ComputerProvider, run: string, epoch: number, { signal }?: CallContext): Promise<Result<ReleasedOlder>>;
|
package/dist/janitor.js
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
// The janitor: ends computers whose deadline has passed, for a provider whose vendor does not end them itself; and, on a
|
|
2
2
|
// takeover, the run's computers of an older claim.
|
|
3
|
-
import { epochOf, epochProblem, RUN_LABEL, runProblem } from "./labels.js";
|
|
4
|
-
import { fail, ok } from "./result.js";
|
|
3
|
+
import { epochOf, epochProblem, ownerOf, RUN_LABEL, runProblem } from "./labels.js";
|
|
4
|
+
import { fail, failAs, ok } from "./result.js";
|
|
5
5
|
/** Clock skew a deadline may carry past now + maxLifetimeMs before it counts as unreadable. */
|
|
6
6
|
const SKEW_MS = 60_000;
|
|
7
|
+
/** Whether a run's computer's deadline is ahead of at, and readable: no later than at + cap. */
|
|
8
|
+
const alive = (deadline, at, cap) => {
|
|
9
|
+
const time = deadline instanceof Date ? deadline.getTime() : Number.NaN;
|
|
10
|
+
return !Number.isNaN(time) && time > at && time <= at + cap;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Whose a listed computer is. A provider that declares no persistence keeps no agent's computer, so all of its are runs',
|
|
14
|
+
* whatever their labels say: an owner label a caller put on a run's spec never keeps it from the janitor. Of a provider
|
|
15
|
+
* that declares persistence, an agent's: its owner label says so (an owner label that cannot be read too, with no owner
|
|
16
|
+
* known), or the provider marks it owned (its info's owned, with owner when the listing knows it). A run's otherwise.
|
|
17
|
+
*/
|
|
18
|
+
function tenureOf(info, persistence) {
|
|
19
|
+
if (persistence === undefined)
|
|
20
|
+
return { agent: false };
|
|
21
|
+
const label = ownerOf(info.labels);
|
|
22
|
+
if (!label.ok)
|
|
23
|
+
return { agent: true };
|
|
24
|
+
if (label.value !== undefined)
|
|
25
|
+
return { agent: true, owner: label.value };
|
|
26
|
+
if (info.owned === true)
|
|
27
|
+
return { agent: true, ...(info.owner === undefined ? {} : { owner: info.owner }) };
|
|
28
|
+
return { agent: false };
|
|
29
|
+
}
|
|
30
|
+
/** Whether an agent's computer ends: its owner is gone, or it has been detached for longer than its idle TTL. */
|
|
31
|
+
async function ownerEnds(info, owner, at, ownerGone) {
|
|
32
|
+
if (ownerGone !== undefined && (await ownerGone(owner.agent)) === true)
|
|
33
|
+
return true;
|
|
34
|
+
const since = info.detachedAt instanceof Date ? info.detachedAt.getTime() : Number.NaN;
|
|
35
|
+
return owner.idleTtlMs !== undefined && !Number.isNaN(since) && at - since >= owner.idleTtlMs;
|
|
36
|
+
}
|
|
7
37
|
/**
|
|
8
38
|
* Deletes every computer the provider lists whose deadline has passed, or whose deadline is missing or unreadable
|
|
9
39
|
* (fail closed); leaves the rest. A deadline more than the provider's maxLifetimeMs past now (with a minute for clock
|
|
@@ -11,10 +41,17 @@ const SKEW_MS = 60_000;
|
|
|
11
41
|
* "janitor"; a caller runs it on a schedule. A computer that cannot be deleted does not stop the sweep: the result is
|
|
12
42
|
* then an error naming it and what was deleted. A provider with sweepLeftovers then removes, with the same labels and
|
|
13
43
|
* time, what its computers left behind (Docker: egress proxies and volumes whose computer is gone).
|
|
44
|
+
*
|
|
45
|
+
* An agent's computer (an owner label, or an info the provider marks owned, of a provider that declares persistence: of
|
|
46
|
+
* one that does not, an owner label is a caller's and keeps nothing) is never deleted by a deadline: only when
|
|
47
|
+
* its owner is gone (ownerGone), or once it has been detached for longer than its owner's idle TTL. One whose owner
|
|
48
|
+
* the janitor cannot read is kept. A
|
|
49
|
+
* provider that declares persistence is swept for its agents' computers alone under lifetime "vendor", since no vendor
|
|
50
|
+
* ends them.
|
|
14
51
|
*/
|
|
15
|
-
export async function sweep(provider, { labels = {}, now, signal } = {}) {
|
|
16
|
-
const { lifetime, maxLifetimeMs } = provider.capabilities();
|
|
17
|
-
if (lifetime !== "janitor") {
|
|
52
|
+
export async function sweep(provider, { labels = {}, now, ownerGone, signal } = {}) {
|
|
53
|
+
const { lifetime, maxLifetimeMs, persistence } = provider.capabilities();
|
|
54
|
+
if (lifetime !== "janitor" && persistence === undefined) {
|
|
18
55
|
return fail("refused", `the ${provider.id} provider declares lifetime "${lifetime}": its vendor ends its computers itself, so the janitor does not sweep them`);
|
|
19
56
|
}
|
|
20
57
|
if (now !== undefined && !(now instanceof Date && !Number.isNaN(now.getTime())))
|
|
@@ -31,9 +68,13 @@ export async function sweep(provider, { labels = {}, now, signal } = {}) {
|
|
|
31
68
|
const failed = [];
|
|
32
69
|
let firstError;
|
|
33
70
|
let kept = 0;
|
|
34
|
-
for (const
|
|
35
|
-
const
|
|
36
|
-
|
|
71
|
+
for (const info of listed.value) {
|
|
72
|
+
const { ref, deadline } = info;
|
|
73
|
+
const tenure = tenureOf(info, persistence);
|
|
74
|
+
// An agent's computer goes by its owner's rules, never a deadline: one whose owner the janitor cannot read is kept.
|
|
75
|
+
// A run's goes by its deadline, and under lifetime "vendor" its vendor ends it.
|
|
76
|
+
const ends = tenure.agent ? tenure.owner !== undefined && (await ownerEnds(info, tenure.owner, at, ownerGone)) : lifetime === "janitor" && !alive(deadline, at, cap);
|
|
77
|
+
if (!ends) {
|
|
37
78
|
kept++;
|
|
38
79
|
continue;
|
|
39
80
|
}
|
|
@@ -64,7 +105,7 @@ export async function sweep(provider, { labels = {}, now, signal } = {}) {
|
|
|
64
105
|
}
|
|
65
106
|
if (firstError) {
|
|
66
107
|
const words = [...(failed.length > 0 ? [`could not delete ${failed.join("; ")}`] : []), ...(leftBehind === undefined ? [] : [`could not remove what its computers left behind: ${leftBehind}`])];
|
|
67
|
-
return
|
|
108
|
+
return failAs(firstError, `the sweep deleted ${deleted.join(", ") || "none"} but ${words.join(", and ")}`);
|
|
68
109
|
}
|
|
69
110
|
return ok({ deleted, kept, ...(leftovers === undefined ? {} : { leftovers }) });
|
|
70
111
|
}
|
|
@@ -79,6 +120,9 @@ export async function sweep(provider, { labels = {}, now, signal } = {}) {
|
|
|
79
120
|
* released: a partial cleanup is never a success, so a caller revokes nothing and mounts nothing after it. An aborted
|
|
80
121
|
* call starts no further release and says which ran. It revokes no mount: that is the root helper's, inside the
|
|
81
122
|
* computer, and a deleted computer holds none.
|
|
123
|
+
*
|
|
124
|
+
* An agent's computer (an owner label, readable or not, or an info marked owned, of a provider that declares
|
|
125
|
+
* persistence) of a lower epoch is detached, never deleted: its state is the agent's, and the new claim attaches it.
|
|
82
126
|
*/
|
|
83
127
|
export async function releaseOlder(provider, run, epoch, { signal } = {}) {
|
|
84
128
|
const problem = runProblem(run) ?? epochProblem(epoch);
|
|
@@ -89,21 +133,24 @@ export async function releaseOlder(provider, run, epoch, { signal } = {}) {
|
|
|
89
133
|
return fail("aborted", `${what} was aborted before it began`);
|
|
90
134
|
const listed = await provider.list({ [RUN_LABEL]: run }, { signal });
|
|
91
135
|
if (!listed.ok)
|
|
92
|
-
return
|
|
136
|
+
return failAs(listed.error, `could not list run ${JSON.stringify(run)}'s computers: ${listed.error.message}`);
|
|
137
|
+
const { persistence } = provider.capabilities();
|
|
93
138
|
const older = [];
|
|
94
139
|
const kept = [];
|
|
95
140
|
const unproven = [];
|
|
96
141
|
const newer = [];
|
|
97
|
-
for (const
|
|
142
|
+
for (const info of listed.value) {
|
|
143
|
+
const { ref, labels } = info;
|
|
98
144
|
if (labels?.[RUN_LABEL] !== run)
|
|
99
145
|
continue;
|
|
100
146
|
const read = epochOf(labels);
|
|
147
|
+
const owned = tenureOf(info, persistence).agent;
|
|
101
148
|
if (!read.ok) {
|
|
102
|
-
older.push({ ref });
|
|
149
|
+
older.push({ ref, owned });
|
|
103
150
|
unproven.push({ ref, problem: read.error.message });
|
|
104
151
|
}
|
|
105
152
|
else if (read.value < epoch)
|
|
106
|
-
older.push({ ref, epoch: read.value });
|
|
153
|
+
older.push({ ref, epoch: read.value, owned });
|
|
107
154
|
else if (read.value === epoch)
|
|
108
155
|
kept.push(ref);
|
|
109
156
|
else
|
|
@@ -113,23 +160,24 @@ export async function releaseOlder(provider, run, epoch, { signal } = {}) {
|
|
|
113
160
|
return fail("refused", `fenced: run ${JSON.stringify(run)} has ${newer.join(", ")}, above this claim's epoch ${epoch}; a later claim holds the run, so nothing was released`);
|
|
114
161
|
}
|
|
115
162
|
const released = [];
|
|
163
|
+
const detached = [];
|
|
116
164
|
const failed = [];
|
|
117
165
|
let firstError;
|
|
118
|
-
const done = () => `it released ${released.map((ref) => ref.name).join(", ") || "none"}${failed.length > 0 ? `, and could not release ${failed.join("; ")}` : ""}`;
|
|
119
|
-
for (const [at, { ref, epoch: was }] of older.entries()) {
|
|
166
|
+
const done = () => `it released ${released.map((ref) => ref.name).join(", ") || "none"}${detached.length > 0 ? `, detached the agents' ${detached.map((ref) => ref.name).join(", ")}` : ""}${failed.length > 0 ? `, and could not release ${failed.join("; ")}` : ""}`;
|
|
167
|
+
for (const [at, { ref, epoch: was, owned }] of older.entries()) {
|
|
120
168
|
if (signal?.aborted) {
|
|
121
169
|
const left = older.slice(at).map((one) => one.ref.name);
|
|
122
170
|
return fail("aborted", `${what} was aborted: ${done()}; it did not start ${left.join(", ")}`);
|
|
123
171
|
}
|
|
124
|
-
const result = await provider.release(ref, "delete");
|
|
172
|
+
const result = await provider.release(ref, owned ? "detach" : "delete");
|
|
125
173
|
if (result.ok)
|
|
126
|
-
released.push(ref);
|
|
174
|
+
(owned ? detached : released).push(ref);
|
|
127
175
|
else {
|
|
128
176
|
firstError ??= result.error;
|
|
129
177
|
failed.push(`${ref.name} (${was === undefined ? "no epoch" : `epoch ${was}`}): ${result.error.message}`);
|
|
130
178
|
}
|
|
131
179
|
}
|
|
132
180
|
if (firstError)
|
|
133
|
-
return
|
|
134
|
-
return ok({ released, kept, unproven });
|
|
181
|
+
return failAs(firstError, `${what} is incomplete: ${done()}`);
|
|
182
|
+
return ok({ released, detached, kept, unproven });
|
|
135
183
|
}
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BrowserStream, type ReleaseConfirm, type RestReply, type UrlStore } from "./browser.js";
|
|
2
2
|
import type { KindCapabilities } from "./kinds.js";
|
|
3
3
|
import type { MountKind } from "./mount.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
5
5
|
import { type Result } from "./result.js";
|
|
6
6
|
export declare const KERNEL_API_URL = "https://api.onkernel.com";
|
|
7
7
|
/** The domain a Kernel CDP URL is on (wss://<host>.kernel.sh:8443, read live 11-08; its API is onkernel.com): cdpUrlProblem holds it there. */
|
|
@@ -11,9 +11,7 @@ export declare const KERNEL_MIN_LIFETIME_MS = 10000;
|
|
|
11
11
|
export declare const KERNEL_MAX_LIFETIME_MS = 259200000;
|
|
12
12
|
/** A browser takes no mount. */
|
|
13
13
|
export declare const MOUNT: readonly MountKind[];
|
|
14
|
-
/** The
|
|
15
|
-
export declare const NETWORK: readonly NetworkForm[];
|
|
16
|
-
/** The one configuration it offers, the kind registry's entry (kinds.ts): a browser with a CDP target and a live view. */
|
|
14
|
+
/** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
|
|
17
15
|
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
18
16
|
/** A browser as Kernel answers it; only what the provider reads. */
|
|
19
17
|
export interface KernelBrowser {
|
|
@@ -100,7 +98,7 @@ export declare class KernelProvider implements ComputerProvider {
|
|
|
100
98
|
*/
|
|
101
99
|
connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
|
|
102
100
|
/** Deletes the browser and waits until Kernel reads it as gone; one already deleted or unknown is released. */
|
|
103
|
-
release(ref: ComputerRef, how:
|
|
101
|
+
release(ref: ComputerRef, how: ReleaseHow, { signal }?: CallContext): Promise<Result<void>>;
|
|
104
102
|
/** The browser's live view, which takes input: a view-only one is refused, never handed over as one. */
|
|
105
103
|
stream(ref: ComputerRef, options?: {
|
|
106
104
|
viewOnly?: boolean;
|
package/dist/kernel.js
CHANGED
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
// connection closes, and sets no wall clock. So lifetimeMs is the longest a browser lives unwatched, at most Kernel's
|
|
13
13
|
// largest idle timeout (72 h), and list reads no deadline.
|
|
14
14
|
import { readFileSync } from "node:fs";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { KERNEL } from "./descriptors/kernel.js";
|
|
16
|
+
import { BROWSER_IMAGE } from "./descriptors/shared.js";
|
|
17
|
+
import { cdpUrlProblem, browserClient, browserHello, BrowserVendorError, CREATE_LABEL, carries, causeOf, checkBrowser, createLabelValue, createUncertain, DEFAULT_CONFIRM, defaultSleep, httpsBase, idProblem, labelsOf, labelsProblem, memoryUrls, queryable, recoverCreate, releaseConfirmed, restCall, causedFail, vendorFailure, withoutCreateLabel, } from "./browser.js";
|
|
18
|
+
import { runLifetimeMs, } from "./provider.js";
|
|
19
|
+
import { failFor, ok, vendorFail } from "./result.js";
|
|
17
20
|
import { connectionError } from "./test-connection.js";
|
|
21
|
+
/** This module's failures: one with code vendor names Kernel. */
|
|
22
|
+
const fail = failFor("kernel");
|
|
18
23
|
const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
19
24
|
const NAME = "Kernel";
|
|
20
25
|
export const KERNEL_API_URL = "https://api.onkernel.com";
|
|
@@ -27,11 +32,9 @@ export const KERNEL_MAX_LIFETIME_MS = 259_200_000;
|
|
|
27
32
|
/** The most pages a list reads before it fails rather than run on. */
|
|
28
33
|
const MAX_PAGES = 100;
|
|
29
34
|
/** A browser takes no mount. */
|
|
30
|
-
export const MOUNT =
|
|
31
|
-
/** The
|
|
32
|
-
export const
|
|
33
|
-
/** The one configuration it offers, the kind registry's entry (kinds.ts): a browser with a CDP target and a live view. */
|
|
34
|
-
export const CAPABILITIES = [{ kind: "browser", groups: ["cdp", "stream"] }];
|
|
35
|
+
export const MOUNT = KERNEL.mounts;
|
|
36
|
+
/** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
|
|
37
|
+
export const CAPABILITIES = KERNEL.capabilities;
|
|
35
38
|
/** Kernel's REST API over fetch: the default request. */
|
|
36
39
|
export function kernelRest({ apiKey, apiUrl = KERNEL_API_URL, fetch: fetcher = fetch }) {
|
|
37
40
|
const o = { vendor: NAME, fetch: fetcher, base: httpsBase(apiUrl, "the Kernel API URL"), headers: { Authorization: `Bearer ${apiKey}` } };
|
|
@@ -68,7 +71,7 @@ export class KernelProvider {
|
|
|
68
71
|
return {
|
|
69
72
|
kind: "browser",
|
|
70
73
|
lifetime: "vendor",
|
|
71
|
-
network: [...
|
|
74
|
+
network: [...KERNEL.network],
|
|
72
75
|
isolation: "vm",
|
|
73
76
|
os: "linux",
|
|
74
77
|
daemon: "none",
|
|
@@ -91,7 +94,7 @@ export class KernelProvider {
|
|
|
91
94
|
if (signal?.aborted)
|
|
92
95
|
return fail("aborted", "create was aborted before Kernel was called");
|
|
93
96
|
const written = { [CREATE_LABEL]: createLabelValue(), ...spec.labels };
|
|
94
|
-
const body = { ...settings, timeout_seconds: Math.ceil(spec
|
|
97
|
+
const body = { ...settings, timeout_seconds: Math.ceil(runLifetimeMs(spec) / 1000), tags: written };
|
|
95
98
|
let made;
|
|
96
99
|
try {
|
|
97
100
|
made = await this.#request("POST", "/browsers", { body, ...(signal ? { signal } : {}) });
|
|
@@ -101,7 +104,7 @@ export class KernelProvider {
|
|
|
101
104
|
if (failed.ok || !createUncertain(error))
|
|
102
105
|
return failed;
|
|
103
106
|
// The browser may have been made though its answer never came: found by its create label, never made again.
|
|
104
|
-
return
|
|
107
|
+
return causedFail(failed.error.code, `${failed.error.message}; ${await this.#recover(written)}`, causeOf(failed), "kernel");
|
|
105
108
|
}
|
|
106
109
|
const browser = (made.json ?? {});
|
|
107
110
|
const id = text(browser.session_id);
|
|
@@ -116,7 +119,7 @@ export class KernelProvider {
|
|
|
116
119
|
if (unusable !== undefined) {
|
|
117
120
|
// The browser is made and billed until its idle timeout: deleted here, not left to a later sweep.
|
|
118
121
|
const released = await this.release(refOf(id), "delete");
|
|
119
|
-
return
|
|
122
|
+
return vendorFail("kernel", `Kernel POST /browsers made a browser with no CDP URL to hand over: ${unusable}; ${released.ok ? "the browser was released" : `the browser was not released (${released.error.code}), and its tags let a sweep find it`}`);
|
|
120
123
|
}
|
|
121
124
|
this.#urls.set(id, url);
|
|
122
125
|
const live = text(browser.browser_live_view_url);
|
|
@@ -155,9 +158,9 @@ export class KernelProvider {
|
|
|
155
158
|
return fail(reached ? connectionError(failed.error).code : "unreachable", failed.error.message);
|
|
156
159
|
}
|
|
157
160
|
if (page.status === 404)
|
|
158
|
-
return
|
|
161
|
+
return vendorFail("kernel", `Kernel ${call} answered 404: the API URL is not Kernel's`);
|
|
159
162
|
if (!Array.isArray(page.json))
|
|
160
|
-
return
|
|
163
|
+
return vendorFail("kernel", `Kernel ${call} answered ${page.status} (not_a_list)`);
|
|
161
164
|
const n = page.json.length;
|
|
162
165
|
const more = page.headers.get("x-has-more") === "true" ? " or more" : "";
|
|
163
166
|
return ok({ detail: `Kernel answered: ${n}${more} active ${n === 1 && more === "" ? "browser" : "browsers"} in the organization` });
|
|
@@ -252,10 +255,10 @@ export class KernelProvider {
|
|
|
252
255
|
return ok(found);
|
|
253
256
|
const next = Number(page.headers.get("x-next-offset"));
|
|
254
257
|
if (!Number.isInteger(next) || next <= offset)
|
|
255
|
-
return
|
|
258
|
+
return vendorFail("kernel", "Kernel reported more browsers without the next page's offset");
|
|
256
259
|
offset = next;
|
|
257
260
|
}
|
|
258
|
-
return
|
|
261
|
+
return vendorFail("kernel", `Kernel kept answering more pages of browsers past ${MAX_PAGES}`);
|
|
259
262
|
}
|
|
260
263
|
async list(labels, { signal } = {}) {
|
|
261
264
|
const found = await this.#browsers(labels, signal);
|
|
@@ -300,7 +303,7 @@ export class KernelProvider {
|
|
|
300
303
|
// Whatever held it (create, a read, a host's url store), a URL a driver would dial is wss: on Kernel's own domain.
|
|
301
304
|
const unusable = cdpUrlProblem(url, NAME, CDP_DOMAIN);
|
|
302
305
|
if (unusable !== undefined)
|
|
303
|
-
return
|
|
306
|
+
return vendorFail("kernel", `the Kernel browser ${id} is not handed over: ${unusable}`);
|
|
304
307
|
this.#urls.set(id, url);
|
|
305
308
|
const hello = browserHello(VERSION, this.capabilities().groups);
|
|
306
309
|
const client = browserClient(hello, (signal) => this.#alive(id, signal));
|
package/dist/kinds.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DescriptorKey, DescriptorSetting, ParkedConfiguration, ProviderDescriptor } from "./descriptor.js";
|
|
1
2
|
import type { MountKind } from "./mount.js";
|
|
2
3
|
import type { ComputerKind, Group } from "./protocol.js";
|
|
3
4
|
import type { ComputerCapabilities, NetworkForm } from "./provider.js";
|
|
@@ -20,54 +21,73 @@ export interface SettingKindSpec {
|
|
|
20
21
|
export declare const SETTING_KINDS: Readonly<Record<ComputerSettingKind, SettingKindSpec>>;
|
|
21
22
|
/** Every setting kind, in the table's order. */
|
|
22
23
|
export declare const SETTING_KIND_NAMES: ComputerSettingKind[];
|
|
23
|
-
/**
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The capabilities serves() and kindOf() read: one configuration a provider offers, with the GPUs it offers (Settings'
|
|
26
|
+
* GPU choice). In a descriptor, `image` is the name an agent's setting selects it by (Orgo's `windows`), the image its
|
|
27
|
+
* computer starts from, and `options` are what create() takes to build it ({ os: "windows" }), beside the keys. A
|
|
28
|
+
* configuration with no image is the one a setting that names none gets, as is the one whose image is the kind's
|
|
29
|
+
* defaultImage.
|
|
30
|
+
*/
|
|
31
|
+
export type KindCapabilities = Pick<ComputerCapabilities, "kind" | "groups" | "gpu"> & {
|
|
32
|
+
readonly image?: string;
|
|
33
|
+
readonly options?: Readonly<Record<string, unknown>>;
|
|
34
|
+
};
|
|
25
35
|
/** Why capabilities do not serve a setting kind, in words; none when they do. */
|
|
26
36
|
export declare function servingRefusals(capabilities: KindCapabilities, kind: ComputerSettingKind): string[];
|
|
27
37
|
/** Whether a provider with these capabilities serves the kind: its machine kind is one of the kind's, and it declares every required group. */
|
|
28
38
|
export declare function serves(capabilities: KindCapabilities, kind: ComputerSettingKind): boolean;
|
|
29
39
|
/** The setting kind these capabilities serve, or undefined when they serve none. Machine kinds are apart, so at most one. */
|
|
30
40
|
export declare function kindOf(capabilities: KindCapabilities): ComputerSettingKind | undefined;
|
|
31
|
-
/**
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
/** The images a kind's configurations offer by name (`serving`: those that serve it), the kind's default first when it is one. */
|
|
42
|
+
export declare function imagesOf(serving: readonly Pick<KindCapabilities, "image">[], defaultImage: string | undefined): string[];
|
|
43
|
+
/**
|
|
44
|
+
* The configuration a setting selects among a kind's (`serving`): the one its image names; with none named, the one
|
|
45
|
+
* whose image is the kind's default, else one with no image, else the first. Undefined when the image names none.
|
|
46
|
+
*/
|
|
47
|
+
export declare function configurationOf<Configuration extends Pick<KindCapabilities, "image">>(serving: readonly Configuration[], image: string | undefined, defaultImage: string | undefined): Configuration | undefined;
|
|
48
|
+
/** A provider as Settings shows it: its descriptor's data, and the setting kinds it serves. */
|
|
37
49
|
export interface ProviderEntry {
|
|
38
|
-
/** Its id: a line of the provider registry (providers.ts)
|
|
39
|
-
id: string;
|
|
40
|
-
label: string;
|
|
50
|
+
/** Its id: a line of the provider registry (providers.ts). */
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly label: string;
|
|
41
53
|
/** Derived: the setting kinds its capabilities serve (serves), never written by hand. */
|
|
42
|
-
kinds: readonly ComputerSettingKind[];
|
|
43
|
-
/** The serve-side key names
|
|
44
|
-
keys: readonly
|
|
45
|
-
/**
|
|
46
|
-
|
|
54
|
+
readonly kinds: readonly ComputerSettingKind[];
|
|
55
|
+
/** The serve-side key names and the options they fill; never a value. */
|
|
56
|
+
readonly keys: readonly DescriptorKey[];
|
|
57
|
+
/** Settings that are no key but go to its options. */
|
|
58
|
+
readonly settings?: readonly DescriptorSetting[];
|
|
59
|
+
/** The mount kinds its computers take; [] cannot mount the run's folder. */
|
|
60
|
+
readonly mounts: readonly MountKind[];
|
|
47
61
|
/**
|
|
48
|
-
* The network forms its computers make
|
|
49
|
-
*
|
|
50
|
-
* allowlist of this server reaches; Docker's makes all three.
|
|
62
|
+
* The network forms its computers make, its descriptor's: ["none"], a remote computer whose programs run in a network
|
|
63
|
+
* of their own; ["open"], the vendor's own network, which no allowlist of this server reaches; Docker's all three.
|
|
51
64
|
*/
|
|
52
|
-
network: readonly NetworkForm[];
|
|
65
|
+
readonly network: readonly NetworkForm[];
|
|
53
66
|
/** The vendor bills by time; prices are the vendor's page, not ours. */
|
|
54
|
-
metered: boolean;
|
|
67
|
+
readonly metered: boolean;
|
|
68
|
+
/** Its static capabilities: the machine kind and groups of each configuration it offers. */
|
|
69
|
+
readonly capabilities: readonly KindCapabilities[];
|
|
55
70
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
71
|
+
* The image a computer of each setting kind starts from when its setting names none. A kind with no entry has no
|
|
72
|
+
* default, and the caller refuses the setting in words. Docker's sandbox has none: its image is made (prepareImage).
|
|
58
73
|
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
readonly defaultImage?: Partial<Record<ComputerSettingKind, string>>;
|
|
75
|
+
/** Its built providers make or pull their image before the first create (prepareImage()). */
|
|
76
|
+
readonly prepareImage?: boolean;
|
|
77
|
+
/** Its computers run on this machine's container engine. */
|
|
78
|
+
readonly local?: boolean;
|
|
79
|
+
/** create() takes a ledger the server keeps for it, as this option. */
|
|
80
|
+
readonly ledger?: {
|
|
81
|
+
readonly option: string;
|
|
82
|
+
};
|
|
83
|
+
/** The server's environment variables its provider reads on this machine, passed as options.env (descriptor.ts). */
|
|
84
|
+
readonly hostEnv?: readonly string[];
|
|
85
|
+
/** Configurations it builds but does not offer yet, each with why: a setting naming one's image is refused as parked. */
|
|
86
|
+
readonly parked?: readonly ParkedConfiguration[];
|
|
66
87
|
}
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*/
|
|
88
|
+
/** A descriptor as Settings shows it: its data, and the setting kinds its capabilities serve, derived by serves(). */
|
|
89
|
+
export declare function entryOf(descriptor: ProviderDescriptor): ProviderEntry;
|
|
90
|
+
/** Every provider Settings offers: each built-in descriptor (descriptors/index.ts), as entryOf gives it. */
|
|
71
91
|
export declare const PROVIDERS: readonly ProviderEntry[];
|
|
72
92
|
/** What testConnection is given: the provider's keys by their serve-side names, and the caller's signal. */
|
|
73
93
|
export interface TestConnectionOptions {
|
package/dist/kinds.js
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// axes: the machine kind is the protocol's (capabilities().kind, KIND_SHAPES); the setting kind is what an agent is
|
|
3
|
-
// given in Settings, `computer: { kind, provider? }`, as machine kinds and capability groups. Whether a provider serves
|
|
4
|
-
// a setting kind is computed from its capabilities alone (serves), never kept beside them: a provider that drops a
|
|
5
|
-
// group stops serving the kind. The model's tools are not here: they live in the kernel's tool registry, keyed by
|
|
6
|
-
// these groups.
|
|
7
|
-
// The default images are values: each from the provider module that owns it. Those modules import this one for types
|
|
8
|
-
// alone, so this is no import cycle.
|
|
9
|
-
import { BROWSER_IMAGE } from "./browser.js";
|
|
10
|
-
import { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU } from "./daytona.js";
|
|
11
|
-
import { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
|
|
12
|
-
import { MODAL_DEFAULT_IMAGE, MODAL_GPU } from "./modal.js";
|
|
13
|
-
import { ORGO_BASE_IMAGE } from "./orgo.js";
|
|
14
|
-
import { PHONE_IMAGE } from "./phone-harness.js";
|
|
1
|
+
import { DESCRIPTORS } from "./descriptors/index.js";
|
|
15
2
|
export const SETTING_KINDS = {
|
|
16
3
|
none: { machineKinds: [], required: [], optional: [] },
|
|
17
4
|
sandbox: { machineKinds: ["linux"], required: ["exec", "files", "processes"], optional: [] },
|
|
@@ -45,109 +32,24 @@ export function serves(capabilities, kind) {
|
|
|
45
32
|
export function kindOf(capabilities) {
|
|
46
33
|
return SETTING_KIND_NAMES.find((kind) => serves(capabilities, kind));
|
|
47
34
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/** An entry with its kinds derived from its capabilities. */
|
|
53
|
-
function entry(fields) {
|
|
54
|
-
return { ...fields, kinds: SETTING_KIND_NAMES.filter((kind) => fields.capabilities.some((one) => serves(one, kind))) };
|
|
35
|
+
/** The images a kind's configurations offer by name (`serving`: those that serve it), the kind's default first when it is one. */
|
|
36
|
+
export function imagesOf(serving, defaultImage) {
|
|
37
|
+
const names = [...new Set(serving.flatMap((one) => (one.image === undefined ? [] : [one.image])))];
|
|
38
|
+
return defaultImage !== undefined && names.includes(defaultImage) ? [defaultImage, ...names.filter((name) => name !== defaultImage)] : names;
|
|
55
39
|
}
|
|
56
40
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
41
|
+
* The configuration a setting selects among a kind's (`serving`): the one its image names; with none named, the one
|
|
42
|
+
* whose image is the kind's default, else one with no image, else the first. Undefined when the image names none.
|
|
59
43
|
*/
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
metered: true,
|
|
73
|
-
capabilities: [{ ...SANDBOX, gpu: gpuOf(DAYTONA_GPU) }],
|
|
74
|
-
defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
|
|
75
|
-
}),
|
|
76
|
-
entry({
|
|
77
|
-
id: "modal",
|
|
78
|
-
label: "Modal",
|
|
79
|
-
keys: [
|
|
80
|
-
{ name: "MODAL_TOKEN_ID", required: true },
|
|
81
|
-
{ name: "MODAL_TOKEN_SECRET", required: true },
|
|
82
|
-
],
|
|
83
|
-
mounts: ["archil"],
|
|
84
|
-
network: ["none"],
|
|
85
|
-
metered: true,
|
|
86
|
-
capabilities: [{ ...SANDBOX, gpu: gpuOf(MODAL_GPU) }],
|
|
87
|
-
defaultImage: { sandbox: MODAL_DEFAULT_IMAGE },
|
|
88
|
-
}),
|
|
89
|
-
entry({
|
|
90
|
-
id: "e2b",
|
|
91
|
-
label: "E2B",
|
|
92
|
-
keys: [{ name: "E2B_API_KEY", required: true }],
|
|
93
|
-
mounts: ["archil"],
|
|
94
|
-
network: ["none"],
|
|
95
|
-
metered: true,
|
|
96
|
-
capabilities: [SANDBOX, LINUX_DESKTOP],
|
|
97
|
-
defaultImage: { sandbox: E2B_BASE_TEMPLATE, desktop: E2B_DESKTOP_TEMPLATE },
|
|
98
|
-
}),
|
|
99
|
-
entry({
|
|
100
|
-
id: "orgo",
|
|
101
|
-
label: "Orgo",
|
|
102
|
-
keys: [{ name: "ORGO_API_KEY", required: true }],
|
|
103
|
-
mounts: [],
|
|
104
|
-
network: ["none"],
|
|
105
|
-
metered: true,
|
|
106
|
-
capabilities: [LINUX_DESKTOP],
|
|
107
|
-
defaultImage: { desktop: ORGO_BASE_IMAGE },
|
|
108
|
-
}),
|
|
109
|
-
entry({
|
|
110
|
-
id: "phone-harness",
|
|
111
|
-
label: "Phone harness",
|
|
112
|
-
keys: [{ name: "PHONE_HARNESS_API_KEY", required: true }],
|
|
113
|
-
mounts: [],
|
|
114
|
-
network: ["open"],
|
|
115
|
-
metered: true,
|
|
116
|
-
capabilities: [{ kind: "android", groups: ["screen", "input.touch", "input.keys", "apps", "apps.ui_tree"] }],
|
|
117
|
-
defaultImage: { phone: PHONE_IMAGE },
|
|
118
|
-
}),
|
|
119
|
-
entry({
|
|
120
|
-
id: "browserbase",
|
|
121
|
-
label: "Browserbase",
|
|
122
|
-
keys: [
|
|
123
|
-
{ name: "BROWSERBASE_API_KEY", required: true },
|
|
124
|
-
{ name: "BROWSERBASE_PROJECT_ID", required: true },
|
|
125
|
-
],
|
|
126
|
-
mounts: [],
|
|
127
|
-
network: ["open"],
|
|
128
|
-
metered: true,
|
|
129
|
-
capabilities: [{ kind: "browser", groups: ["cdp", "stream"] }],
|
|
130
|
-
defaultImage: { browser: BROWSER_IMAGE },
|
|
131
|
-
}),
|
|
132
|
-
entry({
|
|
133
|
-
id: "kernel",
|
|
134
|
-
label: "Kernel",
|
|
135
|
-
keys: [{ name: "KERNEL_API_KEY", required: true }],
|
|
136
|
-
mounts: [],
|
|
137
|
-
network: ["open"],
|
|
138
|
-
metered: true,
|
|
139
|
-
capabilities: [{ kind: "browser", groups: ["cdp", "stream"] }],
|
|
140
|
-
defaultImage: { browser: BROWSER_IMAGE },
|
|
141
|
-
}),
|
|
142
|
-
// This machine's Chrome: no key, nothing billed, no live view (a person watching runs it headed).
|
|
143
|
-
entry({
|
|
144
|
-
id: "local",
|
|
145
|
-
label: "Local Chrome",
|
|
146
|
-
keys: [],
|
|
147
|
-
mounts: [],
|
|
148
|
-
network: ["open", "allow"],
|
|
149
|
-
metered: false,
|
|
150
|
-
capabilities: [{ kind: "browser", groups: ["cdp"] }],
|
|
151
|
-
defaultImage: { browser: BROWSER_IMAGE },
|
|
152
|
-
}),
|
|
153
|
-
];
|
|
44
|
+
export function configurationOf(serving, image, defaultImage) {
|
|
45
|
+
if (image !== undefined)
|
|
46
|
+
return serving.find((one) => one.image === image);
|
|
47
|
+
return serving.find((one) => defaultImage !== undefined && one.image === defaultImage) ?? serving.find((one) => one.image === undefined) ?? serving[0];
|
|
48
|
+
}
|
|
49
|
+
/** A descriptor as Settings shows it: its data, and the setting kinds its capabilities serve, derived by serves(). */
|
|
50
|
+
export function entryOf(descriptor) {
|
|
51
|
+
const { load: _load, ...data } = descriptor;
|
|
52
|
+
return { ...data, kinds: SETTING_KIND_NAMES.filter((kind) => descriptor.capabilities.some((one) => serves(one, kind))) };
|
|
53
|
+
}
|
|
54
|
+
/** Every provider Settings offers: each built-in descriptor (descriptors/index.ts), as entryOf gives it. */
|
|
55
|
+
export const PROVIDERS = DESCRIPTORS.map(entryOf);
|
package/dist/labels.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { epochProblem } from "./mount.js";
|
|
2
|
+
import { type ComputerOwner } from "./provider.js";
|
|
2
3
|
import { type Result } from "./result.js";
|
|
3
4
|
export { epochProblem };
|
|
4
5
|
/** The run a computer works for. */
|
|
@@ -11,6 +12,17 @@ export declare const RUN_HASH_LABEL = "agentrun.run.hash";
|
|
|
11
12
|
/** The run label's hash, as a provider keeps it where the run itself doesn't fit (a computer's name): base32 of its
|
|
12
13
|
* sha256, lower case, 16 letters. */
|
|
13
14
|
export declare function runHash(run: string): string;
|
|
15
|
+
/** The agent a persistent computer belongs to, as agent:<id>. */
|
|
16
|
+
export declare const OWNER_LABEL = "agentrun.owner";
|
|
17
|
+
/** The owner's idle TTL of a persistent computer, in milliseconds, in decimal: how long it may stay detached. */
|
|
18
|
+
export declare const IDLE_TTL_LABEL = "agentrun.idle-ttl-ms";
|
|
19
|
+
/** The labels of an agent's computer: its owner, and its idle TTL when the owner set one. Throws, in words, on an owner that is not one. */
|
|
20
|
+
export declare function ownerLabels(owner: ComputerOwner): Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* A computer's owner, read from its labels: undefined for a run's computer (no owner label). An owner label that is not
|
|
23
|
+
* agent:<id>, or an idle TTL that is not a decimal whole number above 0, is invalid, in words naming what it reads.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ownerOf(labels: Record<string, string> | undefined): Result<ComputerOwner | undefined>;
|
|
14
26
|
/**
|
|
15
27
|
* Why run is not a run id, in words, or undefined when it is one: a non-empty string with no NUL byte. That is the
|
|
16
28
|
* strictest rule the providers share for a label's value (Docker, Daytona and Modal each refuse only a NUL), so every
|