@parcha/agentrun-computer 0.1.0-beta.35 → 0.1.0-beta.37

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.
Files changed (148) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +423 -323
  3. package/box/Dockerfile +3 -1
  4. package/box/agentrun-archil +59 -7
  5. package/box/build-agent37.mjs +177 -0
  6. package/box/build-daytona.py +20 -4
  7. package/dist/agent37.d.ts +165 -0
  8. package/dist/agent37.js +759 -0
  9. package/dist/attach.d.ts +146 -0
  10. package/dist/attach.js +469 -0
  11. package/dist/browser.d.ts +61 -10
  12. package/dist/browser.js +125 -3
  13. package/dist/browserbase.d.ts +46 -23
  14. package/dist/browserbase.js +162 -17
  15. package/dist/chrome.d.ts +3 -4
  16. package/dist/chrome.js +6 -11
  17. package/dist/client.d.ts +33 -1
  18. package/dist/client.js +53 -0
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/conformance/agent37.d.ts +96 -0
  22. package/dist/conformance/agent37.js +154 -0
  23. package/dist/conformance/cases/apps.d.ts +5 -0
  24. package/dist/conformance/cases/apps.js +160 -73
  25. package/dist/conformance/cases/health.js +14 -0
  26. package/dist/conformance/cases/index.js +2 -0
  27. package/dist/conformance/cases/provider.js +27 -1
  28. package/dist/conformance/cases/screen.d.ts +3 -0
  29. package/dist/conformance/cases/screen.js +18 -0
  30. package/dist/conformance/cases/settings.d.ts +29 -23
  31. package/dist/conformance/cases/settings.js +76 -58
  32. package/dist/conformance/cases/touch.js +19 -17
  33. package/dist/conformance/cases/ui.d.ts +2 -0
  34. package/dist/conformance/cases/ui.js +475 -0
  35. package/dist/conformance/cli.d.ts +9 -0
  36. package/dist/conformance/cli.js +28 -3
  37. package/dist/conformance/daytona.d.ts +4 -0
  38. package/dist/conformance/daytona.js +5 -0
  39. package/dist/conformance/e2b.d.ts +6 -0
  40. package/dist/conformance/e2b.js +9 -2
  41. package/dist/conformance/fixture.d.ts +1 -1
  42. package/dist/conformance/fixture.js +25 -1
  43. package/dist/conformance/modal.d.ts +17 -13
  44. package/dist/conformance/modal.js +18 -9
  45. package/dist/conformance/orgo.d.ts +3 -3
  46. package/dist/conformance/orgo.js +6 -8
  47. package/dist/conformance/phone-harness.d.ts +6 -2
  48. package/dist/conformance/phone-harness.js +21 -4
  49. package/dist/conformance/report.js +1 -1
  50. package/dist/conformance/runner.js +23 -4
  51. package/dist/conformance/sweep.d.ts +50 -0
  52. package/dist/conformance/sweep.js +187 -0
  53. package/dist/conformance/types.d.ts +11 -3
  54. package/dist/conformance/ui-fixture.d.ts +56 -0
  55. package/dist/conformance/ui-fixture.js +43 -0
  56. package/dist/create-requests.d.ts +51 -0
  57. package/dist/create-requests.js +121 -0
  58. package/dist/daytona.d.ts +15 -5
  59. package/dist/daytona.js +58 -38
  60. package/dist/descriptor.d.ts +29 -2
  61. package/dist/descriptor.js +13 -0
  62. package/dist/descriptors/agent37.d.ts +41 -0
  63. package/dist/descriptors/agent37.js +28 -0
  64. package/dist/descriptors/browserbase.d.ts +1 -0
  65. package/dist/descriptors/browserbase.js +2 -0
  66. package/dist/descriptors/daytona.d.ts +23 -2
  67. package/dist/descriptors/daytona.js +34 -2
  68. package/dist/descriptors/index.d.ts +66 -3
  69. package/dist/descriptors/index.js +5 -3
  70. package/dist/descriptors/kernel.d.ts +1 -0
  71. package/dist/descriptors/kernel.js +2 -0
  72. package/dist/descriptors/modal.d.ts +4 -0
  73. package/dist/descriptors/modal.js +11 -1
  74. package/dist/descriptors/orgo.d.ts +13 -1
  75. package/dist/descriptors/orgo.js +9 -3
  76. package/dist/descriptors/phone-harness.d.ts +6 -1
  77. package/dist/descriptors/phone-harness.js +5 -2
  78. package/dist/docker/egress.d.ts +4 -3
  79. package/dist/docker/egress.js +7 -6
  80. package/dist/docker.d.ts +7 -4
  81. package/dist/docker.js +278 -34
  82. package/dist/e2b.d.ts +9 -165
  83. package/dist/e2b.js +282 -1342
  84. package/dist/fake-ui-driver.d.ts +97 -0
  85. package/dist/fake-ui-driver.js +717 -0
  86. package/dist/host.d.ts +182 -0
  87. package/dist/host.js +1 -0
  88. package/dist/hosted/process.d.ts +67 -0
  89. package/dist/hosted/process.js +228 -0
  90. package/dist/hosted/provider.d.ts +146 -0
  91. package/dist/hosted/provider.js +1364 -0
  92. package/dist/hosted/scripts.d.ts +76 -0
  93. package/dist/{child.js → hosted/scripts.js} +93 -12
  94. package/dist/index.d.ts +11 -7
  95. package/dist/index.js +10 -7
  96. package/dist/janitor.d.ts +5 -4
  97. package/dist/janitor.js +1 -1
  98. package/dist/kernel.d.ts +17 -27
  99. package/dist/kernel.js +94 -18
  100. package/dist/kinds.d.ts +17 -5
  101. package/dist/kinds.js +20 -4
  102. package/dist/labels.d.ts +10 -2
  103. package/dist/labels.js +30 -7
  104. package/dist/local-chrome.d.ts +5 -5
  105. package/dist/local-chrome.js +10 -5
  106. package/dist/modal.d.ts +23 -181
  107. package/dist/modal.js +273 -1232
  108. package/dist/mount-archil.d.ts +25 -3
  109. package/dist/mount-archil.js +39 -8
  110. package/dist/orgo-channel.d.ts +3 -2
  111. package/dist/orgo-channel.js +5 -2
  112. package/dist/orgo-desktop.d.ts +23 -9
  113. package/dist/orgo-desktop.js +328 -66
  114. package/dist/orgo-names.d.ts +129 -3
  115. package/dist/orgo-names.js +211 -8
  116. package/dist/orgo-workspaces.d.ts +47 -0
  117. package/dist/orgo-workspaces.js +94 -0
  118. package/dist/orgo.d.ts +27 -10
  119. package/dist/orgo.js +411 -81
  120. package/dist/phone-harness.d.ts +31 -21
  121. package/dist/phone-harness.js +510 -681
  122. package/dist/png.d.ts +4 -0
  123. package/dist/png.js +27 -0
  124. package/dist/protocol.d.ts +338 -30
  125. package/dist/protocol.js +96 -3
  126. package/dist/provider.d.ts +97 -7
  127. package/dist/provider.js +24 -3
  128. package/dist/result.d.ts +1 -1
  129. package/dist/surface/api.d.ts +248 -0
  130. package/dist/surface/api.js +1 -0
  131. package/dist/surface/core.d.ts +42 -0
  132. package/dist/surface/core.js +393 -0
  133. package/dist/surface/index.d.ts +5 -0
  134. package/dist/surface/index.js +3 -0
  135. package/dist/surface/outline.d.ts +8 -0
  136. package/dist/surface/outline.js +50 -0
  137. package/dist/surface/script.d.ts +10 -0
  138. package/dist/surface/script.js +92 -0
  139. package/dist/ui-engine.d.ts +114 -0
  140. package/dist/ui-engine.js +798 -0
  141. package/package.json +17 -1
  142. package/dist/child.d.ts +0 -42
  143. package/dist/conformance/e2b-diagnose.d.ts +0 -16
  144. package/dist/conformance/e2b-diagnose.js +0 -61
  145. package/dist/conformance/e2b-sweep.d.ts +0 -18
  146. package/dist/conformance/e2b-sweep.js +0 -132
  147. package/dist/conformance/modal-sweep.d.ts +0 -22
  148. package/dist/conformance/modal-sweep.js +0 -213
@@ -1,6 +1,129 @@
1
- import type { ComputerRef } from "./provider.js";
1
+ import type { ComputerClaim, ComputerOwner, ComputerRef } from "./provider.js";
2
+ import { type Result } from "./result.js";
2
3
  /** The longest name Orgo holds. */
3
4
  export declare const NAME_MAX = 80;
5
+ /** The labels file's deadline, and its most, for an agent's own computer: it has none. */
6
+ export declare const NO_DEADLINE = "none";
7
+ /**
8
+ * The hash an agent's own computer's name carries: of its owner label's value, agent:<id>, and of its server's after a
9
+ * NUL (which neither may hold) when the owner names one, so one agent id on two servers has two hashes.
10
+ */
11
+ export declare const ownerHashOf: (owner: ComputerOwner) => string;
12
+ /** The owner hash these labels say (its owner's and server's, ownerHashOf), or "" when they carry no readable owner. */
13
+ export declare function ownerHashOfLabels(labels: Record<string, string>): string;
14
+ /**
15
+ * An agent's own computer as the provider's ledger keeps it (the server's computer ledger, as the phone harness's
16
+ * sessions are kept): its labels, the owner's and the claim's among them, and when it was detached. Orgo holds no label
17
+ * of a computer, and a detached one is never woken to read its labels file, so list reads these instead.
18
+ */
19
+ export interface OrgoLedgerEntry {
20
+ /** Orgo's computer id. */
21
+ id: string;
22
+ labels: Record<string, string>;
23
+ /** When the computer was detached, ISO time; absent while a run holds it. */
24
+ detachedAt?: string;
25
+ /**
26
+ * While an attach or detach holds the computer (takeEntry to settleEntry), when its current step began, ISO time, and
27
+ * what it is doing: no other attach or detach takes it meanwhile.
28
+ */
29
+ busy?: {
30
+ since: string;
31
+ doing: string;
32
+ };
33
+ }
34
+ /** Where the provider keeps its agents' computers' labels. Each call may be sync or async. */
35
+ export interface OrgoLedger {
36
+ put(entry: OrgoLedgerEntry): void | Promise<void>;
37
+ get(id: string): OrgoLedgerEntry | undefined | Promise<OrgoLedgerEntry | undefined>;
38
+ list(): OrgoLedgerEntry[] | Promise<OrgoLedgerEntry[]>;
39
+ remove(id: string): void | Promise<void>;
40
+ /**
41
+ * entry put in place of `was` only while the kept entry is still `was` as it was read, in one step no other writer
42
+ * splits: true when it was put; false, with nothing written, when the entry changed since or is gone. Attach takes an
43
+ * agent's computer under a claim with it (takeEntry), so two claims that read one entry never both write it.
44
+ */
45
+ swap(was: OrgoLedgerEntry, entry: OrgoLedgerEntry): boolean | Promise<boolean>;
46
+ }
47
+ /** Whether two ledger entries hold the same: the same id, labels and fields, in any order. */
48
+ export declare const sameEntry: (a: OrgoLedgerEntry, b: OrgoLedgerEntry) => boolean;
49
+ /** The run and epoch these labels say, in words, for a claim that lost its computer to another. */
50
+ export declare const holderOf: (labels: Record<string, string>) => string;
51
+ /** How long a busy marker keeps every other attach and detach off the computer: the most one step of an attach or detach
52
+ * (a resume, a suspend, a stop, a daemon's replacement) is waited on, since each step renews it. A marker older is an
53
+ * attach or detach that died, and is taken over. */
54
+ export declare const BUSY_MS: number;
55
+ /**
56
+ * An agent's computer's ledger entry as one attach, detach or delete under a claim holds it, from takeEntry to
57
+ * settleEntry (a delete: until it forgets the entry): the entry as last written by it, its busy marker in force. One rule
58
+ * keeps them all apart: nothing is done to the computer but under this marker, renewed (renewEntry) right before each
59
+ * step that wakes, stops, suspends or replaces what runs in it, and only its holder settles the entry, every write a swap
60
+ * from the entry it last wrote. A holder whose swap finds the entry changed (its marker went stale and another took it,
61
+ * or it was removed) has lost it: it does nothing more to the computer, and its settle is an error, never a success.
62
+ */
63
+ export interface EntryLease {
64
+ entry: OrgoLedgerEntry;
65
+ }
66
+ /**
67
+ * An agent's computer's ledger entry taken, before anything is done to the computer, for an attach (under `claim`, held
68
+ * to it, claimProblem) or a detach (no claim): read, refused while another holds it busy, then swapped to carry a busy
69
+ * marker saying `doing` (and the claim's run and epoch) only while it is still the entry read. Two claims of one run that
70
+ * read the same entry never both write it: the one whose swap finds it changed reads it again and is held to the claim
71
+ * again, so a lower epoch never writes over a higher one and is refused (fenced). When it was detached is kept until the
72
+ * holder settles it (settleEntry), so an attach that fails leaves it detached. `only`: the entry is taken only while it
73
+ * carries exactly the claim's run and epoch (a delete under a claim, which never takes a computer another claim has).
74
+ */
75
+ export declare function takeEntry(ledger: OrgoLedger, ref: ComputerRef, ownerHash: string, claim: ComputerClaim | undefined, doing: string, { only }?: {
76
+ only?: boolean | undefined;
77
+ }): Promise<Result<EntryLease>>;
78
+ /**
79
+ * The held entry's busy marker renewed, saying `doing` from now, only while the entry is still the one this holder last
80
+ * wrote: right before each step that wakes, stops, suspends or replaces what runs in the computer, so a holder that lost
81
+ * the entry never does that step to a computer another holds.
82
+ */
83
+ export declare function renewEntry(ledger: OrgoLedger, ref: ComputerRef, lease: EntryLease, doing: string): Promise<Result<void>>;
84
+ /**
85
+ * The held entry settled by its holder alone: its busy marker cleared, with `settle` applied (an attach marks it held, no
86
+ * longer detached; a detach marks it detached), swapped only while the entry is still the one this holder last wrote. A
87
+ * swap that finds it changed is an error: the holder lost the entry, and its attach or detach does not answer ok.
88
+ */
89
+ export declare function settleEntry(ledger: OrgoLedger, ref: ComputerRef, lease: EntryLease, settle?: (entry: OrgoLedgerEntry) => OrgoLedgerEntry): Promise<Result<void>>;
90
+ /** `done`, or, where the settle after it failed, that failure: with done's own words first when done had failed too. */
91
+ export declare function andSettled<T>(done: Result<T>, settled: Result<void>): Result<T>;
92
+ /**
93
+ * `work` for one computer, taken in turn with every other of this process's for the same key (`turns` keeps each key's
94
+ * last): one starts once the one before it has settled, whatever its outcome. `work` is told whether it waited for one,
95
+ * so it reads again what that one may have changed.
96
+ */
97
+ export declare function inTurn<T>(turns: Map<string, Promise<unknown>>, key: string, work: (waited: boolean) => Promise<T>): Promise<T>;
98
+ /**
99
+ * What list() gives an agent's own computer, with nothing run inside, by filter: owned, with its ledger entry's labels
100
+ * (the owner's and the claim's run and epoch among them), its owner, and when it was detached. With no entry its labels
101
+ * are unknown: it is listed owned with no labels and no owner, to an unfiltered list alone, and the janitor, which never
102
+ * deletes a computer whose owner it cannot read, keeps it. undefined when the computer does not carry every label of
103
+ * the filter.
104
+ */
105
+ export declare function ownedListing(entry: OrgoLedgerEntry | undefined, filter: Record<string, string>): {
106
+ labels: Record<string, string>;
107
+ owned: true;
108
+ owner?: ComputerOwner;
109
+ detachedAt?: Date;
110
+ } | undefined;
111
+ /** { owner } when these labels carry a readable owner label, else nothing: for a listing or attach's read-back. */
112
+ export declare function ownerReadBack(labels: Record<string, string>): {
113
+ owner?: ComputerOwner;
114
+ };
115
+ /** Why an agent's computer is neither attached nor detached with no ledger entry, in words: its labels are unknown. */
116
+ export declare const lostEntry: (name: string) => string;
117
+ /**
118
+ * Why a run cannot take this computer under claim, in words, or undefined when it can: a run's computer (no owner) is
119
+ * its run's, never claimed; a claim of the same run below the epoch the computer carries is fenced. Nothing changes.
120
+ */
121
+ export declare function claimProblem(name: string, ownerHash: string | undefined, entry: OrgoLedgerEntry | undefined, claim: {
122
+ run: string;
123
+ epoch: number;
124
+ }): string | undefined;
125
+ /** A ledger in this process's memory: the default, enough for one process that makes and ends its computers. */
126
+ export declare function orgoMemoryLedger(): OrgoLedger;
4
127
  /** An Orgo computer's id. */
5
128
  export declare const COMPUTER_ID: RegExp;
6
129
  /** What the labels file holds. */
@@ -29,14 +152,17 @@ export declare const show: (value: unknown) => string;
29
152
  * The name of a computer with these labels: computer-<hex>, then -r<the run label's hash> and -e<the epoch label> when
30
153
  * the labels carry a run and an epoch that is one, then -d<the deadline> when given: whole seconds since the epoch,
31
154
  * rounded up (never before init's own), in base 36, the janitor's deadline. Only those: a name is no place for a label's
32
- * value. Everything but the deadline is the name's stable part, which a rename on extend keeps.
155
+ * value. Everything but the deadline is the name's stable part, which a rename on extend keeps. An agent's own computer
156
+ * (owner) is computer-<hex>-o<the owner label's hash> alone, with no deadline for the janitor to end it by: the run and
157
+ * the epoch of the claim that holds it change with each attach, so they are in the ledger (OrgoLedger), not the name.
33
158
  */
34
- export declare function orgoName(labels: Record<string, string>, hex: string, deadline?: Date): string;
159
+ export declare function orgoName(labels: Record<string, string>, hex: string, deadline?: Date, owner?: ComputerOwner): string;
35
160
  /** A name's stable part with this deadline. */
36
161
  export declare function withDeadline(stable: string, deadline: Date): string;
37
162
  /** What a name of this provider's making says, or undefined for any other name: its stable part, and its deadline. */
38
163
  export declare function nameParts(name: unknown): {
39
164
  hex: string;
165
+ owner?: string;
40
166
  run?: string;
41
167
  epoch?: string;
42
168
  stable: string;
@@ -3,11 +3,207 @@
3
3
  // epoch and the janitor's deadline; the labels a spec may give; Orgo's record of a computer; and the labels file each
4
4
  // keeps in the computer, the truth attach reads.
5
5
  import { COMPUTER_LABEL } from "./drift.js";
6
- import { EPOCH_LABEL, RUN_LABEL, runHash } from "./labels.js";
6
+ import { EPOCH_LABEL, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerLabels, ownerOf, RUN_LABEL, runHash } from "./labels.js";
7
+ import { failFor, ok, vendorFail } from "./result.js";
8
+ const fail = failFor("orgo");
7
9
  /** The longest name Orgo holds. */
8
10
  export const NAME_MAX = 80;
9
- /** A name of this provider's making: computer-<12 hex>, the run label's hash, the epoch label, the deadline (base 36 s). */
10
- const NAME = /^computer-([0-9a-f]{12})(?:-r([a-z2-7]{16}))?(?:-e(0|[1-9][0-9]{0,15}))?(?:-d([0-9a-z]{1,11}))?$/;
11
+ /**
12
+ * A name of this provider's making: computer-<12 hex>, then either -o<the owner's hash> (an agent's own computer, which
13
+ * outlives runs and has no deadline) or the run label's hash, the epoch label and the deadline (base 36 s).
14
+ */
15
+ const NAME = /^computer-([0-9a-f]{12})(?:-o([a-z2-7]{16})|(?:-r([a-z2-7]{16}))?(?:-e(0|[1-9][0-9]{0,15}))?(?:-d([0-9a-z]{1,11}))?)$/;
16
+ /** The labels file's deadline, and its most, for an agent's own computer: it has none. */
17
+ export const NO_DEADLINE = "none";
18
+ /**
19
+ * The hash an agent's own computer's name carries: of its owner label's value, agent:<id>, and of its server's after a
20
+ * NUL (which neither may hold) when the owner names one, so one agent id on two servers has two hashes.
21
+ */
22
+ export const ownerHashOf = (owner) => {
23
+ const labels = ownerLabels(owner);
24
+ const server = labels[OWNER_SERVER_LABEL];
25
+ return runHash(server === undefined ? labels[OWNER_LABEL] : `${labels[OWNER_LABEL]}\0${server}`);
26
+ };
27
+ /** The owner hash these labels say (its owner's and server's, ownerHashOf), or "" when they carry no readable owner. */
28
+ export function ownerHashOfLabels(labels) {
29
+ const owner = ownerOf(labels);
30
+ return owner.ok && owner.value !== undefined ? ownerHashOf(owner.value) : "";
31
+ }
32
+ /** An entry as one string, its keys and its labels' keys sorted, so two entries compare by what they hold alone. */
33
+ const canonical = (entry) => JSON.stringify(entry, (_key, value) => (value !== null && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) : value));
34
+ /** Whether two ledger entries hold the same: the same id, labels and fields, in any order. */
35
+ export const sameEntry = (a, b) => canonical(a) === canonical(b);
36
+ /** How often an attach reads an agent's computer's ledger entry again when another writer changed it under its swap. */
37
+ const SWAP_TRIES = 5;
38
+ /** A ledger call's value, or the ledger's failure in words: a provider's calls answer, never throw. */
39
+ async function ledgerCall(what, call) {
40
+ try {
41
+ return ok(await call());
42
+ }
43
+ catch (error) {
44
+ return vendorFail("orgo", `the ledger of agents' computers could not be ${what}: ${error instanceof Error ? error.message : String(error)}`);
45
+ }
46
+ }
47
+ /** The run and epoch these labels say, in words, for a claim that lost its computer to another. */
48
+ export const holderOf = (labels) => `run ${JSON.stringify(labels[RUN_LABEL] ?? "")} at epoch ${labels[EPOCH_LABEL] ?? "none"}`;
49
+ /** How long a busy marker keeps every other attach and detach off the computer: the most one step of an attach or detach
50
+ * (a resume, a suspend, a stop, a daemon's replacement) is waited on, since each step renews it. A marker older is an
51
+ * attach or detach that died, and is taken over. */
52
+ export const BUSY_MS = 15 * 60_000;
53
+ /** Whether an entry carries a busy marker still in force. */
54
+ const busyNow = (entry) => entry.busy !== undefined && Date.now() - Date.parse(entry.busy.since) < BUSY_MS;
55
+ /**
56
+ * An agent's computer's ledger entry taken, before anything is done to the computer, for an attach (under `claim`, held
57
+ * to it, claimProblem) or a detach (no claim): read, refused while another holds it busy, then swapped to carry a busy
58
+ * marker saying `doing` (and the claim's run and epoch) only while it is still the entry read. Two claims of one run that
59
+ * read the same entry never both write it: the one whose swap finds it changed reads it again and is held to the claim
60
+ * again, so a lower epoch never writes over a higher one and is refused (fenced). When it was detached is kept until the
61
+ * holder settles it (settleEntry), so an attach that fails leaves it detached. `only`: the entry is taken only while it
62
+ * carries exactly the claim's run and epoch (a delete under a claim, which never takes a computer another claim has).
63
+ */
64
+ export async function takeEntry(ledger, ref, ownerHash, claim, doing, { only = false } = {}) {
65
+ for (let tries = 1;; tries++) {
66
+ const read = await ledgerCall("read", () => ledger.get(ref.id));
67
+ if (!read.ok)
68
+ return read;
69
+ const entry = read.value;
70
+ if (entry === undefined)
71
+ return fail("refused", lostEntry(ref.name));
72
+ if (busyNow(entry))
73
+ return fail("refused", `${ref.name} is busy (${entry.busy?.doing}): try again in a moment`);
74
+ if (claim !== undefined) {
75
+ const fenced = only ? notClaims(ref.name, entry, claim) : claimProblem(ref.name, ownerHash, entry, claim);
76
+ if (fenced !== undefined)
77
+ return fail("refused", fenced);
78
+ }
79
+ // A busy marker older than BUSY_MS is an attach or detach that died: this one takes the entry over.
80
+ const { busy: _stale, ...unmarked } = entry;
81
+ const taken = {
82
+ ...unmarked,
83
+ ...(claim === undefined ? {} : { labels: { ...entry.labels, [RUN_LABEL]: claim.run, [EPOCH_LABEL]: String(claim.epoch) } }),
84
+ busy: { since: new Date().toISOString(), doing },
85
+ };
86
+ const swapped = await ledgerCall("written", () => ledger.swap(entry, taken));
87
+ if (!swapped.ok)
88
+ return swapped;
89
+ if (swapped.value)
90
+ return ok({ entry: taken });
91
+ if (tries >= SWAP_TRIES)
92
+ return fail("refused", `${ref.name}'s ledger entry changed under each of ${SWAP_TRIES} tries to take it; nothing changed`);
93
+ }
94
+ }
95
+ /** Why an entry that does not carry exactly `claim`'s run and epoch is not that claim's to delete, in words; else undefined. */
96
+ const notClaims = (name, entry, claim) => entry.labels[RUN_LABEL] === claim.run && entry.labels[EPOCH_LABEL] === String(claim.epoch)
97
+ ? undefined
98
+ : `fenced: ${name} carries ${holderOf(entry.labels)}, not this claim's (${holderOf({ [RUN_LABEL]: claim.run, [EPOCH_LABEL]: String(claim.epoch) })}): another claim has it, so it is left as it is`;
99
+ /** Why a holder's swap found its entry changed, in words: it has lost the computer, which it leaves as it is. */
100
+ const lostLease = (ref, lease) => `fenced: ${ref.name}'s ledger entry changed while this ${lease.entry.busy?.doing ?? "attach"} (${holderOf(lease.entry.labels)}) held it (its busy marker went stale and another took it, or it was removed): the computer is left as it is`;
101
+ /**
102
+ * The held entry's busy marker renewed, saying `doing` from now, only while the entry is still the one this holder last
103
+ * wrote: right before each step that wakes, stops, suspends or replaces what runs in the computer, so a holder that lost
104
+ * the entry never does that step to a computer another holds.
105
+ */
106
+ export async function renewEntry(ledger, ref, lease, doing) {
107
+ const renewed = { ...lease.entry, busy: { since: new Date().toISOString(), doing } };
108
+ const swapped = await ledgerCall("written", () => ledger.swap(lease.entry, renewed));
109
+ if (!swapped.ok)
110
+ return swapped;
111
+ if (!swapped.value)
112
+ return fail("refused", lostLease(ref, lease));
113
+ lease.entry = renewed;
114
+ return ok(undefined);
115
+ }
116
+ /**
117
+ * The held entry settled by its holder alone: its busy marker cleared, with `settle` applied (an attach marks it held, no
118
+ * longer detached; a detach marks it detached), swapped only while the entry is still the one this holder last wrote. A
119
+ * swap that finds it changed is an error: the holder lost the entry, and its attach or detach does not answer ok.
120
+ */
121
+ export async function settleEntry(ledger, ref, lease, settle = (entry) => entry) {
122
+ const { busy: _done, ...cleared } = lease.entry;
123
+ const settled = settle(cleared);
124
+ const swapped = await ledgerCall("written", () => ledger.swap(lease.entry, settled));
125
+ if (!swapped.ok)
126
+ return swapped;
127
+ if (!swapped.value)
128
+ return fail("refused", lostLease(ref, lease));
129
+ lease.entry = settled;
130
+ return ok(undefined);
131
+ }
132
+ /** `done`, or, where the settle after it failed, that failure: with done's own words first when done had failed too. */
133
+ export function andSettled(done, settled) {
134
+ if (settled.ok)
135
+ return done;
136
+ return done.ok ? settled : fail(done.error.code, `${done.error.message}; and ${settled.error.message}`);
137
+ }
138
+ /**
139
+ * `work` for one computer, taken in turn with every other of this process's for the same key (`turns` keeps each key's
140
+ * last): one starts once the one before it has settled, whatever its outcome. `work` is told whether it waited for one,
141
+ * so it reads again what that one may have changed.
142
+ */
143
+ export function inTurn(turns, key, work) {
144
+ const waiting = turns.get(key);
145
+ const turn = (waiting ?? Promise.resolve()).then(() => work(waiting !== undefined));
146
+ const settled = turn.then(() => undefined, () => undefined);
147
+ turns.set(key, settled);
148
+ void settled.then(() => {
149
+ if (turns.get(key) === settled)
150
+ turns.delete(key);
151
+ });
152
+ return turn;
153
+ }
154
+ /**
155
+ * What list() gives an agent's own computer, with nothing run inside, by filter: owned, with its ledger entry's labels
156
+ * (the owner's and the claim's run and epoch among them), its owner, and when it was detached. With no entry its labels
157
+ * are unknown: it is listed owned with no labels and no owner, to an unfiltered list alone, and the janitor, which never
158
+ * deletes a computer whose owner it cannot read, keeps it. undefined when the computer does not carry every label of
159
+ * the filter.
160
+ */
161
+ export function ownedListing(entry, filter) {
162
+ if (entry === undefined)
163
+ return Object.keys(filter).length === 0 ? { labels: {}, owned: true } : undefined;
164
+ if (!Object.entries(filter).every(([key, value]) => entry.labels[key] === value))
165
+ return undefined;
166
+ const detached = entry.detachedAt === undefined ? Number.NaN : Date.parse(entry.detachedAt);
167
+ return { labels: { ...entry.labels }, owned: true, ...ownerReadBack(entry.labels), ...(Number.isNaN(detached) ? {} : { detachedAt: new Date(detached) }) };
168
+ }
169
+ /** { owner } when these labels carry a readable owner label, else nothing: for a listing or attach's read-back. */
170
+ export function ownerReadBack(labels) {
171
+ const owner = ownerOf(labels);
172
+ return owner.ok && owner.value !== undefined ? { owner: owner.value } : {};
173
+ }
174
+ /** Why an agent's computer is neither attached nor detached with no ledger entry, in words: its labels are unknown. */
175
+ export const lostEntry = (name) => `${name} is an agent's computer with no entry in the provider's ledger, so its owner and labels are unknown: it is neither attached nor detached; release it with delete`;
176
+ /**
177
+ * Why a run cannot take this computer under claim, in words, or undefined when it can: a run's computer (no owner) is
178
+ * its run's, never claimed; a claim of the same run below the epoch the computer carries is fenced. Nothing changes.
179
+ */
180
+ export function claimProblem(name, ownerHash, entry, claim) {
181
+ if (ownerHash === undefined)
182
+ return `${name} is a run's computer, which belongs to its run: no other run takes it under a claim`;
183
+ const carried = entry?.labels ?? {};
184
+ const epoch = Number(carried[EPOCH_LABEL]);
185
+ if (carried[RUN_LABEL] === claim.run && Number.isSafeInteger(epoch) && claim.epoch < epoch) {
186
+ return `fenced: ${name} is held by run ${JSON.stringify(claim.run)} at epoch ${epoch}, above this claim's ${claim.epoch}; nothing changed`;
187
+ }
188
+ return undefined;
189
+ }
190
+ /** A ledger in this process's memory: the default, enough for one process that makes and ends its computers. */
191
+ export function orgoMemoryLedger() {
192
+ const entries = new Map();
193
+ return {
194
+ put: (entry) => void entries.set(entry.id, structuredClone(entry)),
195
+ get: (id) => structuredClone(entries.get(id)),
196
+ list: () => [...entries.values()].map((entry) => structuredClone(entry)),
197
+ remove: (id) => void entries.delete(id),
198
+ swap: (was, entry) => {
199
+ const kept = entries.get(entry.id);
200
+ if (kept === undefined || was.id !== entry.id || !sameEntry(kept, was))
201
+ return false;
202
+ entries.set(entry.id, structuredClone(entry));
203
+ return true;
204
+ },
205
+ };
206
+ }
11
207
  /** An Orgo computer's id. */
12
208
  export const COMPUTER_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
13
209
  export const show = (value) => (value === undefined ? "nothing" : JSON.stringify(value));
@@ -15,9 +211,13 @@ export const show = (value) => (value === undefined ? "nothing" : JSON.stringify
15
211
  * The name of a computer with these labels: computer-<hex>, then -r<the run label's hash> and -e<the epoch label> when
16
212
  * the labels carry a run and an epoch that is one, then -d<the deadline> when given: whole seconds since the epoch,
17
213
  * rounded up (never before init's own), in base 36, the janitor's deadline. Only those: a name is no place for a label's
18
- * value. Everything but the deadline is the name's stable part, which a rename on extend keeps.
214
+ * value. Everything but the deadline is the name's stable part, which a rename on extend keeps. An agent's own computer
215
+ * (owner) is computer-<hex>-o<the owner label's hash> alone, with no deadline for the janitor to end it by: the run and
216
+ * the epoch of the claim that holds it change with each attach, so they are in the ledger (OrgoLedger), not the name.
19
217
  */
20
- export function orgoName(labels, hex, deadline) {
218
+ export function orgoName(labels, hex, deadline, owner) {
219
+ if (owner !== undefined)
220
+ return `computer-${hex}-o${ownerHashOf(owner)}`;
21
221
  const run = labels[RUN_LABEL];
22
222
  const epoch = labels[EPOCH_LABEL];
23
223
  const stable = `computer-${hex}${typeof run === "string" && run !== "" ? `-r${runHash(run)}` : ""}${typeof epoch === "string" && /^(?:0|[1-9][0-9]{0,15})$/.test(epoch) ? `-e${epoch}` : ""}`;
@@ -32,11 +232,12 @@ export function nameParts(name) {
32
232
  const match = typeof name === "string" ? NAME.exec(name) : null;
33
233
  if (match === null)
34
234
  return undefined;
35
- const seconds = match[4] === undefined ? Number.NaN : Number.parseInt(match[4], 36);
235
+ const seconds = match[5] === undefined ? Number.NaN : Number.parseInt(match[5], 36);
36
236
  return {
37
237
  hex: match[1],
38
- ...(match[2] ? { run: match[2] } : {}),
39
- ...(match[3] !== undefined ? { epoch: match[3] } : {}),
238
+ ...(match[2] ? { owner: match[2] } : {}),
239
+ ...(match[3] ? { run: match[3] } : {}),
240
+ ...(match[4] !== undefined ? { epoch: match[4] } : {}),
40
241
  stable: name.replace(/-d[0-9a-z]+$/, ""),
41
242
  ...(Number.isSafeInteger(seconds) ? { deadline: new Date(seconds * 1000) } : {}),
42
243
  };
@@ -50,6 +251,8 @@ export function labelProblem(key, value) {
50
251
  return `the label ${JSON.stringify(key)} must be a non-empty name, and neither holds a NUL byte`;
51
252
  if (key === COMPUTER_LABEL || key.startsWith(`${COMPUTER_LABEL}.`))
52
253
  return `the label ${key} is in the provider's own namespace (${COMPUTER_LABEL})`;
254
+ if (key === OWNER_LABEL || key === OWNER_SERVER_LABEL || key === IDLE_TTL_LABEL)
255
+ return `the label ${key} is the provider's own: a spec gives its owner, and the provider labels the computer`;
53
256
  return undefined;
54
257
  }
55
258
  export function filterProblem(labels) {
@@ -0,0 +1,47 @@
1
+ import type { OrgoRest } from "./orgo-channel.js";
2
+ import type { KeyChoice } from "./provider.js";
3
+ import { type Result } from "./result.js";
4
+ /** One workspace a key's account sees: its id, its name, and its status where Orgo says one other than active. */
5
+ export interface OrgoWorkspace {
6
+ readonly id: string;
7
+ readonly name: string;
8
+ readonly status?: string;
9
+ }
10
+ /** What a person reads for a key whose account has no workspace. */
11
+ export declare const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
12
+ /** A workspace in words: its name, and its status when it is not active. */
13
+ export declare const workspaceWords: (workspace: OrgoWorkspace) => string;
14
+ /** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
15
+ export declare function orgoWorkspaces(rest: OrgoRest, { timeoutMs, signal }: {
16
+ timeoutMs: number;
17
+ signal?: AbortSignal;
18
+ }): Promise<Result<OrgoWorkspace[]>>;
19
+ /**
20
+ * The workspace a provider whose settings name none uses: the key's account's one workspace. Several are refused in
21
+ * words naming them and pointing at Settings, where a person picks one; none is refused saying to make one.
22
+ */
23
+ export declare function soleWorkspace(rest: OrgoRest, context: {
24
+ timeoutMs: number;
25
+ signal?: AbortSignal;
26
+ }): Promise<Result<string>>;
27
+ /**
28
+ * keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
29
+ * name; none is refused saying to make one. Orgo's descriptor picks no other option.
30
+ */
31
+ export declare function workspaceChoices(rest: OrgoRest, option: string, context: {
32
+ timeoutMs: number;
33
+ signal?: AbortSignal;
34
+ }): Promise<Result<KeyChoice[]>>;
35
+ /** A provider's workspace: `read()` the one its computers live in, and `id`, that id once a read found it. */
36
+ export interface WorkspaceHolder {
37
+ read(signal?: AbortSignal): Promise<Result<string>>;
38
+ readonly id: string | undefined;
39
+ }
40
+ /**
41
+ * The workspace a provider's computers live in: `given` when its settings name one; else the key's account's sole one
42
+ * (soleWorkspace), read on the first call that needs it and kept. A read that fails is not kept: the next call reads again.
43
+ * Calls that come while a read is under way share it. The shared read is bounded by timeoutMs alone, never by one
44
+ * caller's signal, so one caller giving up never fails the others: a caller whose signal fires stops waiting, answered
45
+ * "aborted", and the read goes on for the rest.
46
+ */
47
+ export declare function workspaceHolder(given: string | undefined, rest: OrgoRest, timeoutMs: number): WorkspaceHolder;
@@ -0,0 +1,94 @@
1
+ import { failAs, failFor, ok } from "./result.js";
2
+ const fail = failFor("orgo");
3
+ /** What a person reads for a key whose account has no workspace. */
4
+ export const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
5
+ /** A workspace in words: its name, and its status when it is not active. */
6
+ export const workspaceWords = (workspace) => (workspace.status === undefined ? workspace.name : `${workspace.name} (${workspace.status})`);
7
+ /** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
8
+ export async function orgoWorkspaces(rest, { timeoutMs, signal }) {
9
+ const read = await rest.request("GET", "/workspaces", { timeoutMs, ...(signal ? { signal } : {}) });
10
+ if (!read.ok)
11
+ return failAs(read.error, `Orgo's workspaces could not be read: ${read.error.message}`);
12
+ const listed = read.value?.workspaces;
13
+ if (!Array.isArray(listed))
14
+ return fail("vendor", "Orgo's GET /workspaces answered no workspaces list");
15
+ const workspaces = [];
16
+ for (const one of listed) {
17
+ if (typeof one?.id !== "string" || one.id === "" || (one.deleted_at !== null && one.deleted_at !== undefined))
18
+ continue;
19
+ const name = typeof one.name === "string" && one.name.trim() !== "" ? one.name.trim() : one.id;
20
+ const status = typeof one.status === "string" && one.status !== "active" ? one.status : undefined;
21
+ workspaces.push({ id: one.id, name, ...(status === undefined ? {} : { status }) });
22
+ }
23
+ return ok(workspaces);
24
+ }
25
+ /**
26
+ * The workspace a provider whose settings name none uses: the key's account's one workspace. Several are refused in
27
+ * words naming them and pointing at Settings, where a person picks one; none is refused saying to make one.
28
+ */
29
+ export async function soleWorkspace(rest, context) {
30
+ const listed = await orgoWorkspaces(rest, context);
31
+ if (!listed.ok)
32
+ return listed;
33
+ const [only, ...more] = listed.value;
34
+ if (only === undefined)
35
+ return fail("not_found", NO_WORKSPACE);
36
+ if (more.length === 0)
37
+ return ok(only.id);
38
+ return fail("invalid", `this Orgo key's account has ${listed.value.length} workspaces (${listed.value.map(workspaceWords).join(", ")}): pick the one its computers live in, in Settings → Computers (ORGO_WORKSPACE_ID)`);
39
+ }
40
+ /**
41
+ * keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
42
+ * name; none is refused saying to make one. Orgo's descriptor picks no other option.
43
+ */
44
+ export async function workspaceChoices(rest, option, context) {
45
+ if (option !== "workspaceId")
46
+ return fail("unsupported", `an Orgo provider offers choices for workspaceId alone, not ${JSON.stringify(option)}`);
47
+ const listed = await orgoWorkspaces(rest, context);
48
+ if (!listed.ok)
49
+ return listed;
50
+ if (listed.value.length === 0)
51
+ return fail("not_found", NO_WORKSPACE);
52
+ return ok(listed.value.map((workspace) => ({ value: workspace.id, label: workspaceWords(workspace) })));
53
+ }
54
+ /**
55
+ * The workspace a provider's computers live in: `given` when its settings name one; else the key's account's sole one
56
+ * (soleWorkspace), read on the first call that needs it and kept. A read that fails is not kept: the next call reads again.
57
+ * Calls that come while a read is under way share it. The shared read is bounded by timeoutMs alone, never by one
58
+ * caller's signal, so one caller giving up never fails the others: a caller whose signal fires stops waiting, answered
59
+ * "aborted", and the read goes on for the rest.
60
+ */
61
+ export function workspaceHolder(given, rest, timeoutMs) {
62
+ let id = given;
63
+ let reading;
64
+ const shared = () => (reading ??= soleWorkspace(rest, { timeoutMs }).then((found) => {
65
+ reading = undefined;
66
+ if (found.ok)
67
+ id = found.value;
68
+ return found;
69
+ }));
70
+ return {
71
+ get id() {
72
+ return id;
73
+ },
74
+ async read(signal) {
75
+ if (id !== undefined)
76
+ return ok(id);
77
+ if (signal?.aborted)
78
+ return fail("aborted", "the Orgo workspace read was aborted before it was sent");
79
+ if (!signal)
80
+ return shared();
81
+ let stop = () => { };
82
+ const stopped = new Promise((resolve) => {
83
+ stop = () => resolve(fail("aborted", "the Orgo workspace read was aborted; it goes on for other callers"));
84
+ signal.addEventListener("abort", stop, { once: true });
85
+ });
86
+ try {
87
+ return await Promise.race([shared(), stopped]);
88
+ }
89
+ finally {
90
+ signal.removeEventListener("abort", stop);
91
+ }
92
+ },
93
+ };
94
+ }
package/dist/orgo.d.ts CHANGED
@@ -2,7 +2,8 @@ import type { KindCapabilities } from "./kinds.js";
2
2
  import { type MountKind } from "./mount.js";
3
3
  import { type OrgoChannel, type OrgoStart, type OrgoWebSocketFactory } from "./orgo-channel.js";
4
4
  import { OrgoDesktopProvider, type OrgoDesktopOptions } from "./orgo-desktop.js";
5
- 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
+ import { type OrgoLedger } from "./orgo-names.js";
6
+ import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type KeyChoice, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
6
7
  import { type Result } from "./result.js";
7
8
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
8
9
  /** The mount kinds an Orgo computer takes: none yet (an Archil mount needs an Orgo template that bakes the helper). */
@@ -38,8 +39,12 @@ export interface OrgoTimeouts {
38
39
  export interface OrgoProviderOptions {
39
40
  /** The Orgo API key. Serve passes ORGO_API_KEY's value; the provider never reads the environment or logs it. */
40
41
  apiKey: string;
41
- /** The workspace this deployment's computers live in; the provider lists, attaches and releases only there. */
42
- workspaceId: string;
42
+ /**
43
+ * The workspace this deployment's computers live in; the provider lists, attaches and releases only there. Absent:
44
+ * the key's account's one workspace, read from Orgo when first needed; with several or none, every call that needs
45
+ * it is refused in words (orgo-workspaces.ts soleWorkspace).
46
+ */
47
+ workspaceId?: string;
43
48
  /** Orgo's API, https; default https://www.orgo.ai/api. */
44
49
  apiUrl?: string;
45
50
  /** For tests: every REST call goes through it. Default the global fetch. */
@@ -61,6 +66,11 @@ export interface OrgoProviderOptions {
61
66
  timeouts?: Partial<OrgoTimeouts>;
62
67
  /** The addresses the probe tries, host:port over TCP or host:port/udp, to show none of them answers. */
63
68
  probeTargets?: string[];
69
+ /**
70
+ * Where agents' own computers' labels are kept (the server's computer ledger, as its descriptor declares): a detached
71
+ * one is never woken to read its labels file. Default one in this process's memory.
72
+ */
73
+ ledger?: OrgoLedger;
64
74
  }
65
75
  /** The labels file: every label, the deadline and its most, the image and sizes, root's, readable by all. */
66
76
  export declare const LABELS_FILE = "/opt/agentrun/labels.json";
@@ -82,17 +92,18 @@ export declare class OrgoProvider implements ComputerProvider {
82
92
  #private;
83
93
  readonly id = "orgo";
84
94
  readonly version: string;
85
- constructor({ apiKey, workspaceId, apiUrl, fetch, webSocket, channel, daemonPath, maxLifetimeMs, user, start, display, timeouts, probeTargets }: OrgoProviderOptions);
95
+ constructor({ apiKey, workspaceId, apiUrl, fetch, webSocket, channel, daemonPath, maxLifetimeMs, user, start, display, timeouts, probeTargets, ledger }: OrgoProviderOptions);
86
96
  /**
87
97
  * daemon child: Orgo's own agent is the VM's first process, and init is a command it ran. lifetime janitor: Orgo ends
88
98
  * a computer only in whole hours (ends_in_hours, the backstop), so the janitor deletes it at its exact deadline, which
89
99
  * its name carries (list() reads it with nothing run inside); init ends its programs at that deadline inside. network
90
- * none alone, read back by the probe from inside (Orgo reads no policy back). release delete alone: Orgo's stop
91
- * freezes a computer, which nothing here needs.
100
+ * none alone, read back by the probe from inside (Orgo reads no policy back). release delete, and detach for an
101
+ * agent's own computer: Orgo's suspend saves its memory and disk, so it resumes where it was (persistence resume),
102
+ * computerd init with it.
92
103
  */
93
104
  capabilities(): ComputerCapabilities;
94
105
  check(spec: ComputerSpec): Refusal[];
95
- create(spec: ComputerSpec, { signal }?: CallContext): Promise<Result<CreatedComputer>>;
106
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
96
107
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch), never Orgo's VNC (proxy only). */
97
108
  watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
98
109
  connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
@@ -100,7 +111,7 @@ export declare class OrgoProvider implements ComputerProvider {
100
111
  id: string;
101
112
  } | {
102
113
  labels: Record<string, string>;
103
- }, { signal }?: CallContext): Promise<Result<AttachedComputer>>;
114
+ }, { signal, claim }?: AttachContext): Promise<Result<AttachedComputer>>;
104
115
  /**
105
116
  * Every computer of this provider in the workspace that carries all of these labels. The run and the epoch are read
106
117
  * from the name, with nothing run in a computer, so a stopped one is listed too; any other label is read from the
@@ -112,9 +123,15 @@ export declare class OrgoProvider implements ComputerProvider {
112
123
  testConnection(context?: CallContext): Promise<Result<{
113
124
  detail: string;
114
125
  }>>;
126
+ /** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
127
+ keyChoices(option: string, { signal }?: CallContext): Promise<Result<KeyChoice[]>>;
115
128
  network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
116
- /** delete: idempotent, a computer Orgo no longer has is done; it waits until Orgo no longer has it. No stop. */
117
- release(ref: ComputerRef, how: ReleaseHow, { signal }?: CallContext): Promise<Result<void>>;
129
+ /**
130
+ * delete: idempotent, a computer Orgo no longer has is done; it waits until Orgo no longer has it. detach, for an
131
+ * agent's own computer alone: Orgo's suspend, its memory and disk saved, read back suspended. No stop: a run's
132
+ * computer is deleted.
133
+ */
134
+ release(ref: ComputerRef, how: ReleaseHow, { signal, claim }?: ReleaseContext): Promise<Result<void>>;
118
135
  /**
119
136
  * Moves the deadline to now + ttlMs, never earlier and never past the most the labels file holds (create's time plus
120
137
  * the cap): Orgo's end first, in whole hours with an Idempotency-Key, so it never ends the computer before init does;