@parcha/agentrun-serve 0.1.0-beta.39 → 0.1.0-beta.41
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/CHANGELOG.md +114 -0
- package/README.md +129 -16
- package/dist/api-only.d.ts +3 -1
- package/dist/api-only.js +4 -2
- package/dist/api-token.d.ts +30 -0
- package/dist/api-token.js +89 -0
- package/dist/cli.js +19 -5
- package/dist/composio-made.d.ts +54 -0
- package/dist/composio-made.js +83 -0
- package/dist/composio-preset.d.ts +16 -8
- package/dist/composio-preset.js +106 -43
- package/dist/composio-triggers.d.ts +7 -2
- package/dist/composio-triggers.js +13 -7
- package/dist/computer-attach.d.ts +29 -11
- package/dist/computer-attach.js +141 -47
- package/dist/computer-keys.d.ts +4 -0
- package/dist/computer-keys.js +5 -0
- package/dist/computers.d.ts +11 -1
- package/dist/computers.js +21 -12
- package/dist/console/assets/index-C3gNPz58.css +1 -0
- package/dist/console/assets/index-COGhx_2Z.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +9 -2
- package/dist/email/account.d.ts +0 -1
- package/dist/email/account.js +3 -3
- package/dist/email/answer.d.ts +5 -0
- package/dist/email/answer.js +35 -0
- package/dist/email/mail.js +19 -26
- package/dist/email/names.d.ts +30 -0
- package/dist/email/names.js +34 -0
- package/dist/email/routes.d.ts +1 -0
- package/dist/email/routes.js +1 -1
- package/dist/email/tools.d.ts +11 -4
- package/dist/email/tools.js +91 -46
- package/dist/eval-feed.d.ts +26 -0
- package/dist/eval-feed.js +68 -0
- package/dist/eval-mailbox.d.ts +5 -2
- package/dist/eval-mailbox.js +14 -6
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/feed/feed-faux.d.ts +62 -0
- package/dist/feed/feed-faux.js +123 -0
- package/dist/feed/fetch.d.ts +41 -0
- package/dist/feed/fetch.js +128 -0
- package/dist/feed/parse.d.ts +41 -0
- package/dist/feed/parse.js +300 -0
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +57 -2
- package/dist/learn/compile.d.ts +3 -2
- package/dist/learn/compile.js +7 -6
- package/dist/learn/promote.d.ts +25 -14
- package/dist/learn/promote.js +32 -14
- package/dist/learned-nodes.d.ts +21 -4
- package/dist/learned-nodes.js +21 -8
- package/dist/learned-workflow.d.ts +3 -3
- package/dist/learned-workflow.js +14 -5
- package/dist/learning-cost.d.ts +17 -8
- package/dist/learning-cost.js +12 -4
- package/dist/local-models.d.ts +7 -1
- package/dist/local-models.js +11 -5
- package/dist/mcp-oauth.d.ts +15 -1
- package/dist/mcp-oauth.js +39 -5
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +4 -3
- package/dist/mcp-servers-store.d.ts +58 -5
- package/dist/mcp-servers-store.js +136 -17
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/observation/http.d.ts +4 -1
- package/dist/observation/http.js +5 -4
- package/dist/openapi.d.ts +1 -1
- package/dist/openapi.js +63 -27
- package/dist/port-models.d.ts +4 -1
- package/dist/port-models.js +1 -0
- package/dist/print.d.ts +6 -3
- package/dist/print.js +4 -2
- package/dist/refusal-words.d.ts +3 -0
- package/dist/refusal-words.js +3 -0
- package/dist/run-labels.d.ts +23 -0
- package/dist/run-labels.js +79 -0
- package/dist/run-launch.d.ts +2 -0
- package/dist/run-launch.js +2 -0
- package/dist/run-secrets.js +12 -4
- package/dist/run-view.d.ts +3 -4
- package/dist/run-view.js +26 -24
- package/dist/runner/adapter-loop.d.ts +6 -2
- package/dist/runner/adapter-loop.js +136 -22
- package/dist/runner/adapter-run-spec.d.ts +5 -0
- package/dist/runner/adapter-run-spec.js +75 -32
- package/dist/runner/beside.d.ts +6 -3
- package/dist/runner/beside.js +9 -7
- package/dist/runner/cli-run-spec.js +33 -26
- package/dist/runner/conformance/harness.js +69 -14
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/journal-kinds.d.ts +22 -0
- package/dist/runner/journal-kinds.js +39 -0
- package/dist/runner/main.d.ts +1 -1
- package/dist/runner/main.js +2 -2
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +4 -0
- package/dist/runner/mcp-run.js +5 -3
- package/dist/runner/model-route.d.ts +7 -3
- package/dist/runner/model-route.js +24 -9
- package/dist/runner/promotion.d.ts +16 -8
- package/dist/runner/promotion.js +178 -55
- package/dist/runner/workflow-first.d.ts +6 -5
- package/dist/runner/workflow-first.js +9 -7
- package/dist/runs-over-store.js +5 -2
- package/dist/sdk/runs.d.ts +7 -1
- package/dist/sdk/runs.js +19 -6
- package/dist/secret-cut.js +3 -1
- package/dist/secrets.js +3 -1
- package/dist/server.d.ts +27 -2
- package/dist/server.js +181 -56
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +2 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/postgres/connection.d.ts +11 -5
- package/dist/store/postgres/connection.js +44 -17
- package/dist/store/postgres/dialect.js +6 -0
- package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
- package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
- package/dist/store/postgres/store.d.ts +7 -3
- package/dist/store/postgres/store.js +1 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +26 -2
- package/dist/store/sqlite/connection.js +80 -8
- package/dist/store/sqlite/run-launch.d.ts +11 -0
- package/dist/store/sqlite/run-launch.js +8 -0
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +3 -2
- package/dist/store/sqlite/store.js +101 -26
- package/dist/store/sqlite/worker.d.ts +2 -0
- package/dist/store/sqlite/worker.js +13 -10
- package/dist/store/store.d.ts +53 -1
- package/dist/store-reads/journal.js +2 -1
- package/dist/store-reads/learning.d.ts +30 -13
- package/dist/store-reads/learning.js +130 -51
- package/dist/store-reads/runs.d.ts +4 -3
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +4 -2
- package/dist/template-eval.d.ts +4 -0
- package/dist/template-eval.js +127 -50
- package/dist/templates.d.ts +24 -1
- package/dist/templates.js +129 -21
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/tool-gate.d.ts +5 -3
- package/dist/tool-gate.js +5 -2
- package/dist/tools.d.ts +13 -0
- package/dist/tools.js +15 -10
- package/dist/trigger-adapter.d.ts +12 -36
- package/dist/trigger-adapters.js +2 -1
- package/dist/trigger-email.js +30 -77
- package/dist/trigger-feed.d.ts +12 -0
- package/dist/trigger-feed.js +371 -0
- package/dist/triggers.d.ts +27 -14
- package/dist/triggers.js +121 -80
- package/dist/webhooks.js +9 -5
- package/dist/workflow/decision-recovery.js +5 -2
- package/dist/workflow/decisions.d.ts +7 -0
- package/dist/workspace/computer-deps.d.ts +5 -1
- package/dist/workspace/computer-deps.js +2 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.js +2 -0
- package/dist/workspace/resolve-computer.d.ts +32 -3
- package/dist/workspace/resolve-computer.js +47 -9
- package/launcher/agentrun-serve +6 -1
- package/package.json +10 -9
- package/templates/README.md +27 -2
- package/dist/console/assets/index-BNhZs-jp.css +0 -1
- package/dist/console/assets/index-BQv5aOGB.js +0 -700
package/dist/triggers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type MessageOrigin } from "./timeline/index.js";
|
|
2
2
|
import { ApiError, type InputIssue } from "./errors.js";
|
|
3
3
|
import { type FiringRow, type Store } from "./store/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { type Source, type TriggerAdapter } from "./trigger-adapter.js";
|
|
5
5
|
import { type Json } from "./validate.js";
|
|
6
6
|
export { MAX_EVERY_S, MIN_EVERY_S } from "./trigger-schedule.js";
|
|
7
7
|
/** The firings each trigger keeps in its history, newest first; a firing still due is never dropped, nor a failure whose
|
|
@@ -15,7 +15,6 @@ export declare const SOURCE_KINDS: readonly string[];
|
|
|
15
15
|
export declare const TARGET_KINDS: readonly ["start_run", "message_run"];
|
|
16
16
|
export declare const FIRING_STATUSES: readonly ["due", "started", "sent", "skipped", "failed", "missed"];
|
|
17
17
|
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start (trigger-adapter.ts). */
|
|
18
|
-
export { PAYLOAD_KEPT_BYTES };
|
|
19
18
|
/** How late a missed time may be and still fire once, by default: an hour. */
|
|
20
19
|
export declare const CATCHUP_WINDOW_S = 3600;
|
|
21
20
|
/** The failed tries in a row that turn a trigger off. */
|
|
@@ -34,9 +33,9 @@ export declare const MAX_ACTIVE_RUNS = 100;
|
|
|
34
33
|
export declare const LAST_CHECK = "last_check";
|
|
35
34
|
/** The sign-ins a polled source's server refuses in a row that turn its trigger off. */
|
|
36
35
|
export declare const REFUSALS_TO_STOP = 3;
|
|
37
|
-
/** How long a
|
|
38
|
-
*
|
|
39
|
-
export declare const
|
|
36
|
+
/** How long a create or a turn-on of a polled source waits for its first poll (where it starts watching) before it
|
|
37
|
+
* answers: past it, the answer goes out and the poll carries on. */
|
|
38
|
+
export declare const FIRST_POLL_WAIT_MS = 10000;
|
|
40
39
|
/** What a source's sender keeps of a trigger, set up from here (composio-triggers.ts: Composio's trigger instance): made
|
|
41
40
|
* before the trigger is kept and undone when it is not, kept in step as the owner turns the trigger on and off (and as
|
|
42
41
|
* the server turns it off itself: offThere), removed after it. What it could not do there is answered beside the change (`said`, by its source's name: `{composio: {done:
|
|
@@ -181,10 +180,17 @@ export declare class Triggers {
|
|
|
181
180
|
private waiting;
|
|
182
181
|
/** The triggers whose day-kept keys are at their cap, said once until they are under it again. */
|
|
183
182
|
private readonly seenFull;
|
|
184
|
-
/** The polled triggers whose poll is running
|
|
183
|
+
/** The polled triggers whose poll is running, one at a time each: true when it is a kick's (kick), which a time come
|
|
184
|
+
* meanwhile waits for (the first poll, the watching start, is never the reason a time is lost); false for a time's own,
|
|
185
|
+
* which a time come meanwhile skips (a server slower than every_s is never polled back to back). */
|
|
185
186
|
private readonly polling;
|
|
186
|
-
/**
|
|
187
|
-
|
|
187
|
+
/** The polled triggers kicked (kick), or whose time came during a kick's poll, while their poll ran: polled again once
|
|
188
|
+
* it is done, as a kick's poll (true) when a kick asked for it, else as a time's. */
|
|
189
|
+
private readonly pollAgain;
|
|
190
|
+
/** Who waits on the poll after the one running (a kick made while it ran): told when that one is done. */
|
|
191
|
+
private readonly pollWaiters;
|
|
192
|
+
/** Each polled trigger's count of turn-ons: a poll that sees it changed keeps nothing, its cursor read before. */
|
|
193
|
+
private readonly restarts;
|
|
188
194
|
private closed;
|
|
189
195
|
constructor(deps: TriggerDeps);
|
|
190
196
|
/** At the server's start: every enabled trigger whose source no longer reads turned off, each failure's trigger.failed
|
|
@@ -433,10 +439,6 @@ export declare class Triggers {
|
|
|
433
439
|
} | null | undefined;
|
|
434
440
|
hook_url?: string | undefined;
|
|
435
441
|
}>;
|
|
436
|
-
/** Trigger `trigger`'s polled source started from now (its adapter's start, waited on at most START_WAIT_MS): its old
|
|
437
|
-
* cursor and last check forgotten, the start's cursor and check kept (no refusal counted), its note a skipped history
|
|
438
|
-
* line. A start not taken leaves no cursor, so its first poll takes it. Never throws: the create or edit stands. */
|
|
439
|
-
private takeStart;
|
|
440
442
|
/** The trigger deleted, and what its sender keeps of it removed after (said, when it could not be: the delete holds). */
|
|
441
443
|
remove(id: string): Promise<Json | undefined>;
|
|
442
444
|
/** Run now: one firing per Idempotency-Key, driven before the answer. `created` false: the key's firing, as it stands. */
|
|
@@ -458,13 +460,24 @@ export declare class Triggers {
|
|
|
458
460
|
* turned off. */
|
|
459
461
|
private advance;
|
|
460
462
|
/** A polled source's time come: its next time moved on from the latest that has come (a time it was not there for is no
|
|
461
|
-
* `missed` row: what came meanwhile is still there to read), then its poll,
|
|
462
|
-
*
|
|
463
|
+
* `missed` row: what came meanwhile is still there to read), then its poll, off the timer, so a slow server never
|
|
464
|
+
* holds the other triggers. With one still running for it: once that one is done when it is a kick's (pollDone),
|
|
465
|
+
* else skipped. */
|
|
463
466
|
private pollDue;
|
|
467
|
+
/** A poll of `trigger` now, answered once the poll that answers it is done: its own, or, when an edit of its source
|
|
468
|
+
* drops its result (polled), the one after it, which it asks for at once; when one is running, the one after that. */
|
|
469
|
+
private kick;
|
|
470
|
+
/** `trigger`'s first poll (made, or turned on again) kicked and waited on, FIRST_POLL_WAIT_MS at most. */
|
|
471
|
+
private firstPoll;
|
|
472
|
+
/** `id`'s poll done: a kick, or a time come during a kick's poll, polls now, once however many came, the trigger read
|
|
473
|
+
* again (on, and as it is now). A time come during this one skips, as during a time's own. */
|
|
474
|
+
private pollDone;
|
|
464
475
|
/** One poll of `trigger`'s source for its time `nominalAt`: each event it found recorded in order (its note a skipped
|
|
465
476
|
* history line; one it leaves, skipped and said; one its accept does not take, an ignored row kept for its day; any
|
|
466
477
|
* other due, and driven), its cursor kept once they are, then its last check, and at the REFUSALS_TO_STOPth refused
|
|
467
478
|
* sign-in in a row the trigger turned off. A poll that throws is a failed check. */
|
|
479
|
+
/** False when an edit of its source while it polled dropped what it found, or landed while its cursor was written and
|
|
480
|
+
* left its stop and its check unwritten (the edit's poll comes after it); else true. */
|
|
468
481
|
private polled;
|
|
469
482
|
/** A firing taken from due to its end: skipped when its trigger's last run is active, else its run started (or its
|
|
470
483
|
* message sent). A failed try keeps it due under the backoff table, or ends it failed. Each step reads the trigger and
|
package/dist/triggers.js
CHANGED
|
@@ -44,7 +44,6 @@ export const SOURCE_KINDS = TRIGGER_ADAPTERS.map((a) => a.id);
|
|
|
44
44
|
export const TARGET_KINDS = ["start_run", "message_run"];
|
|
45
45
|
export const FIRING_STATUSES = ["due", "started", "sent", "skipped", "failed", "missed"];
|
|
46
46
|
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start (trigger-adapter.ts). */
|
|
47
|
-
export { PAYLOAD_KEPT_BYTES };
|
|
48
47
|
/** How late a missed time may be and still fire once, by default: an hour. */
|
|
49
48
|
export const CATCHUP_WINDOW_S = 3600;
|
|
50
49
|
/** The failed tries in a row that turn a trigger off. */
|
|
@@ -74,9 +73,9 @@ const ENDED = new Set(["completed", "failed", "cancelled"]);
|
|
|
74
73
|
export const LAST_CHECK = "last_check";
|
|
75
74
|
/** The sign-ins a polled source's server refuses in a row that turn its trigger off. */
|
|
76
75
|
export const REFUSALS_TO_STOP = 3;
|
|
77
|
-
/** How long a
|
|
78
|
-
*
|
|
79
|
-
export const
|
|
76
|
+
/** How long a create or a turn-on of a polled source waits for its first poll (where it starts watching) before it
|
|
77
|
+
* answers: past it, the answer goes out and the poll carries on. */
|
|
78
|
+
export const FIRST_POLL_WAIT_MS = 10_000;
|
|
80
79
|
/** Whether `adapter`'s firings are events from outside (pushed, or found by a poll), each its own, never a time. */
|
|
81
80
|
const eventful = (adapter) => adapter?.delivery === "push" || adapter?.poll !== undefined;
|
|
82
81
|
/** A polled trigger's last check as kept (LAST_CHECK), when it reads. */
|
|
@@ -220,10 +219,17 @@ export class Triggers {
|
|
|
220
219
|
waiting = false;
|
|
221
220
|
/** The triggers whose day-kept keys are at their cap, said once until they are under it again. */
|
|
222
221
|
seenFull = new Set();
|
|
223
|
-
/** The polled triggers whose poll is running
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
/** The polled triggers whose poll is running, one at a time each: true when it is a kick's (kick), which a time come
|
|
223
|
+
* meanwhile waits for (the first poll, the watching start, is never the reason a time is lost); false for a time's own,
|
|
224
|
+
* which a time come meanwhile skips (a server slower than every_s is never polled back to back). */
|
|
225
|
+
polling = new Map();
|
|
226
|
+
/** The polled triggers kicked (kick), or whose time came during a kick's poll, while their poll ran: polled again once
|
|
227
|
+
* it is done, as a kick's poll (true) when a kick asked for it, else as a time's. */
|
|
228
|
+
pollAgain = new Map();
|
|
229
|
+
/** Who waits on the poll after the one running (a kick made while it ran): told when that one is done. */
|
|
230
|
+
pollWaiters = new Map();
|
|
231
|
+
/** Each polled trigger's count of turn-ons: a poll that sees it changed keeps nothing, its cursor read before. */
|
|
232
|
+
restarts = new Map();
|
|
227
233
|
closed = false;
|
|
228
234
|
constructor(deps) {
|
|
229
235
|
this.deps = deps;
|
|
@@ -297,11 +303,12 @@ export class Triggers {
|
|
|
297
303
|
// there when it is not saved (the sender's own steps, one project's at a time).
|
|
298
304
|
const upstream = this.deps.upstream?.(source.kind);
|
|
299
305
|
const { row, minted } = upstream ? await upstream.make(source, id, enabled, keep) : await keep(source);
|
|
300
|
-
// Where a polled source starts watching: from now, taken before its first time is armed.
|
|
301
|
-
if (enabled)
|
|
302
|
-
await this.takeStart(asTrigger(row), "created");
|
|
303
306
|
// Armed before the answer: a create that answered is in effect, its first time on the timer (arm reads the store).
|
|
304
307
|
await this.arm();
|
|
308
|
+
// A polled source polls at once, and is answered once it has (FIRST_POLL_WAIT_MS at most): its first poll, with no
|
|
309
|
+
// cursor, is where it starts watching, so mail after the answer starts runs, and the answer says the check.
|
|
310
|
+
if (enabled)
|
|
311
|
+
await this.firstPoll(asTrigger(row));
|
|
305
312
|
// What it minted, shown this once, by field: a webhook's `secret`.
|
|
306
313
|
return { ...(await this.view(asTrigger(row))), ...minted };
|
|
307
314
|
}
|
|
@@ -480,6 +487,10 @@ export class Triggers {
|
|
|
480
487
|
// Turned on, or aimed elsewhere while on: never for an archived agent (the store's own refusal is the backstop).
|
|
481
488
|
if (enabled && (!trigger.enabled || target))
|
|
482
489
|
await this.needAgentOn(agentId);
|
|
490
|
+
// A polled source turned on again starts over: a poll still running from before is not its own any more.
|
|
491
|
+
const polls = enabled && adapter.poll !== undefined && (!trigger.enabled || source !== undefined);
|
|
492
|
+
if (polls && !trigger.enabled)
|
|
493
|
+
this.restarts.set(id, (this.restarts.get(id) ?? 0) + 1);
|
|
483
494
|
const patch = {
|
|
484
495
|
...(agentId !== trigger.agentId ? { agentId } : {}),
|
|
485
496
|
...(typeof body.name === "string" ? { name: body.name.trim() } : {}), ...(source ? { source } : {}), ...(target ? { target } : {}),
|
|
@@ -491,63 +502,20 @@ export class Triggers {
|
|
|
491
502
|
});
|
|
492
503
|
if (!row)
|
|
493
504
|
throw new ApiError("not_found", `no trigger ${id}`);
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
const moved = edited !== undefined && start !== undefined && start.on.some((field) => JSON.stringify(edited[field]) !== JSON.stringify(trigger.source[field]));
|
|
499
|
-
if (enabled && start && (!trigger.enabled || moved))
|
|
500
|
-
await this.takeStart(asTrigger(row), trigger.enabled ? "edited" : "enabled");
|
|
501
|
-
else if (enabled && !start && (!trigger.enabled || source) && adapter.poll)
|
|
505
|
+
// Turned on again, a polled source forgets its cursor and last check, so its first poll watches from now, and is
|
|
506
|
+
// answered once it has (as a create is); an edit of its source keeps the cursor (a poll whose cursor was read on
|
|
507
|
+
// another mailbox or account starts over itself) and polls at once, unawaited: that poll may start runs.
|
|
508
|
+
if (polls && !trigger.enabled)
|
|
502
509
|
await this.deps.settings(adapter.id)?.remove(id);
|
|
503
510
|
await this.arm();
|
|
511
|
+
if (polls && !trigger.enabled)
|
|
512
|
+
await this.firstPoll(asTrigger(row));
|
|
513
|
+
else if (polls)
|
|
514
|
+
void this.kick(asTrigger(row));
|
|
504
515
|
// Turned on or off by the owner: the same at its sender, once it holds here; what could not be done there is said.
|
|
505
516
|
const said = upstream && enabled !== trigger.enabled ? await upstream.turned(row.source, id, enabled) : undefined;
|
|
506
517
|
return { ...(await this.view(asTrigger(row))), ...said };
|
|
507
518
|
}
|
|
508
|
-
/** Trigger `trigger`'s polled source started from now (its adapter's start, waited on at most START_WAIT_MS): its old
|
|
509
|
-
* cursor and last check forgotten, the start's cursor and check kept (no refusal counted), its note a skipped history
|
|
510
|
-
* line. A start not taken leaves no cursor, so its first poll takes it. Never throws: the create or edit stands. */
|
|
511
|
-
async takeStart(trigger, why) {
|
|
512
|
-
const adapter = this.adapter(trigger.source);
|
|
513
|
-
const start = adapter.start;
|
|
514
|
-
if (!start)
|
|
515
|
-
return;
|
|
516
|
-
const generation = (this.starts.get(trigger.id) ?? 0) + 1;
|
|
517
|
-
this.starts.set(trigger.id, generation);
|
|
518
|
-
const now = this.clock.now();
|
|
519
|
-
try {
|
|
520
|
-
const settings = this.deps.settings(adapter.id);
|
|
521
|
-
await settings?.remove(trigger.id);
|
|
522
|
-
let timer;
|
|
523
|
-
const late = new Promise((done) => {
|
|
524
|
-
timer = setTimeout(() => done({ check: { ok: false, message: start.unchecked(trigger.source, why) }, note: start.unchecked(trigger.source, why) }), START_WAIT_MS);
|
|
525
|
-
timer.unref?.();
|
|
526
|
-
});
|
|
527
|
-
const taken = start.take(trigger.source, { trigger: trigger.id, why, credentials: async () => this.deps.credentials?.(adapter.id) }).catch((error) => {
|
|
528
|
-
const message = String(error?.message ?? error);
|
|
529
|
-
return { check: { ok: false, message }, note: start.unchecked(trigger.source, why) };
|
|
530
|
-
});
|
|
531
|
-
const result = await Promise.race([taken, late]).finally(() => clearTimeout(timer));
|
|
532
|
-
// Turned off, deleted, moved (an edit of where it reads: start.on) or started again meanwhile: this start is not its
|
|
533
|
-
// own any more. An edit of anything else (accept, every_s) keeps it: that edit took no start of its own, and the
|
|
534
|
-
// cursor removed above would otherwise stay gone, its first poll starting from then and skipping the mail between.
|
|
535
|
-
const current = await this.find(trigger.id);
|
|
536
|
-
const readsAt = (source) => [source.kind, ...start.on.map((field) => source[field])];
|
|
537
|
-
if (this.closed || this.starts.get(trigger.id) !== generation || !current?.enabled || JSON.stringify(readsAt(current.source)) !== JSON.stringify(readsAt(trigger.source)))
|
|
538
|
-
return;
|
|
539
|
-
for (const [field, value] of Object.entries(result.cursor ?? {}))
|
|
540
|
-
await settings?.set(trigger.id, field, value);
|
|
541
|
-
await settings?.set(trigger.id, LAST_CHECK, JSON.stringify({ at: iso(now), ok: result.check.ok, message: result.check.message, refused: 0 }));
|
|
542
|
-
const at = Math.floor(now / 1000) * 1000;
|
|
543
|
-
await this.record(current, { key: firingKey(adapter.id, trigger.id, `start\n${second(now)}\n${why}\n${generation}`), by: adapter.id, nominalAt: at, status: "skipped", reason: result.note });
|
|
544
|
-
if (!result.check.ok)
|
|
545
|
-
this.deps.say({ condition: "trigger_check_failed", trigger: trigger.id, error: result.check.message });
|
|
546
|
-
}
|
|
547
|
-
catch (error) {
|
|
548
|
-
this.deps.say({ condition: "trigger_start_unrecorded", trigger: trigger.id, error: String(error?.message ?? error) });
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
519
|
/** The trigger deleted, and what its sender keeps of it removed after (said, when it could not be: the delete holds). */
|
|
552
520
|
async remove(id) {
|
|
553
521
|
const trigger = await this.need(id);
|
|
@@ -682,26 +650,79 @@ export class Triggers {
|
|
|
682
650
|
await this.prune(trigger);
|
|
683
651
|
}
|
|
684
652
|
/** A polled source's time come: its next time moved on from the latest that has come (a time it was not there for is no
|
|
685
|
-
* `missed` row: what came meanwhile is still there to read), then its poll,
|
|
686
|
-
*
|
|
653
|
+
* `missed` row: what came meanwhile is still there to read), then its poll, off the timer, so a slow server never
|
|
654
|
+
* holds the other triggers. With one still running for it: once that one is done when it is a kick's (pollDone),
|
|
655
|
+
* else skipped. */
|
|
687
656
|
async pollDue(trigger, adapter, clock, now) {
|
|
688
657
|
const last = clock.latest(trigger.nextAt, now);
|
|
689
658
|
const next = clock.next(last);
|
|
690
659
|
await this.store.triggers.update(trigger.id, { nextAt: next !== null && Number.isFinite(next) && Math.abs(next) <= DATE_MAX_MS ? next : null });
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
660
|
+
const running = this.polling.get(trigger.id);
|
|
661
|
+
if (running !== undefined)
|
|
662
|
+
return void (running && !this.pollAgain.has(trigger.id) && this.pollAgain.set(trigger.id, false));
|
|
663
|
+
this.polling.set(trigger.id, false);
|
|
664
|
+
void this.polled(trigger, adapter, last, now).finally(() => this.pollDone(trigger.id));
|
|
665
|
+
}
|
|
666
|
+
/** A poll of `trigger` now, answered once the poll that answers it is done: its own, or, when an edit of its source
|
|
667
|
+
* drops its result (polled), the one after it, which it asks for at once; when one is running, the one after that. */
|
|
668
|
+
kick(trigger, waitedFor = true) {
|
|
669
|
+
const adapter = this.adapter(trigger.source);
|
|
670
|
+
if (!adapter.poll || this.closed)
|
|
671
|
+
return Promise.resolve();
|
|
672
|
+
if (this.polling.has(trigger.id)) {
|
|
673
|
+
this.pollAgain.set(trigger.id, true);
|
|
674
|
+
return new Promise((done) => this.pollWaiters.set(trigger.id, [...(this.pollWaiters.get(trigger.id) ?? []), done]));
|
|
675
|
+
}
|
|
676
|
+
const now = this.clock.now();
|
|
677
|
+
this.polling.set(trigger.id, waitedFor);
|
|
678
|
+
return this.polled(trigger, adapter, now, now).then((kept) => {
|
|
679
|
+
// Dropped for an edit of its source: the poll after it (the edit's) runs at once, and is the one this answers by.
|
|
680
|
+
const after = kept || this.closed ? undefined : new Promise((done) => this.pollWaiters.set(trigger.id, [...(this.pollWaiters.get(trigger.id) ?? []), done]));
|
|
681
|
+
if (after)
|
|
682
|
+
this.pollAgain.set(trigger.id, true);
|
|
683
|
+
this.pollDone(trigger.id);
|
|
684
|
+
return after;
|
|
685
|
+
}, (error) => {
|
|
686
|
+
this.deps.say({ condition: "trigger_poll_unrecorded", trigger: trigger.id, error: String(error?.message ?? error) });
|
|
687
|
+
this.pollDone(trigger.id);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
/** `trigger`'s first poll (made, or turned on again) kicked and waited on, FIRST_POLL_WAIT_MS at most. */
|
|
691
|
+
async firstPoll(trigger) {
|
|
692
|
+
let timer;
|
|
693
|
+
const bound = new Promise((done) => {
|
|
694
|
+
timer = setTimeout(done, FIRST_POLL_WAIT_MS);
|
|
695
|
+
timer.unref?.();
|
|
696
|
+
});
|
|
697
|
+
await Promise.race([this.kick(trigger), bound]).finally(() => clearTimeout(timer));
|
|
698
|
+
}
|
|
699
|
+
/** `id`'s poll done: a kick, or a time come during a kick's poll, polls now, once however many came, the trigger read
|
|
700
|
+
* again (on, and as it is now). A time come during this one skips, as during a time's own. */
|
|
701
|
+
pollDone(id) {
|
|
702
|
+
this.polling.delete(id);
|
|
703
|
+
const again = this.pollAgain.get(id);
|
|
704
|
+
this.pollAgain.delete(id);
|
|
705
|
+
const waiters = this.pollWaiters.get(id) ?? [];
|
|
706
|
+
this.pollWaiters.delete(id);
|
|
707
|
+
const told = () => waiters.forEach((done) => done());
|
|
708
|
+
if (again === undefined || this.closed)
|
|
709
|
+
return told();
|
|
710
|
+
void this.find(id).then((trigger) => (trigger?.enabled ? this.kick(trigger, again) : undefined)).then(told, (error) => {
|
|
711
|
+
this.deps.say({ condition: "trigger_poll_unrecorded", trigger: id, error: String(error?.message ?? error) });
|
|
712
|
+
told();
|
|
713
|
+
});
|
|
695
714
|
}
|
|
696
715
|
/** One poll of `trigger`'s source for its time `nominalAt`: each event it found recorded in order (its note a skipped
|
|
697
716
|
* history line; one it leaves, skipped and said; one its accept does not take, an ignored row kept for its day; any
|
|
698
717
|
* other due, and driven), its cursor kept once they are, then its last check, and at the REFUSALS_TO_STOPth refused
|
|
699
718
|
* sign-in in a row the trigger turned off. A poll that throws is a failed check. */
|
|
719
|
+
/** False when an edit of its source while it polled dropped what it found, or landed while its cursor was written and
|
|
720
|
+
* left its stop and its check unwritten (the edit's poll comes after it); else true. */
|
|
700
721
|
async polled(trigger, adapter, nominalAt, now) {
|
|
701
722
|
const settings = this.deps.settings(adapter.id);
|
|
702
|
-
//
|
|
703
|
-
const generation = this.
|
|
704
|
-
const restarted = () => this.
|
|
723
|
+
// Turned on again while it polled (off and on): its cursor was forgotten, and nothing this poll found is its own.
|
|
724
|
+
const generation = this.restarts.get(trigger.id);
|
|
725
|
+
const restarted = () => this.restarts.get(trigger.id) !== generation;
|
|
705
726
|
let result;
|
|
706
727
|
try {
|
|
707
728
|
result = await adapter.poll(trigger.source, { trigger: trigger.id, setting: (field) => settings?.get(trigger.id, field), credentials: async () => this.deps.credentials?.(adapter.id) });
|
|
@@ -710,18 +731,22 @@ export class Triggers {
|
|
|
710
731
|
result = { check: { ok: false, message: String(error?.message ?? error) } };
|
|
711
732
|
}
|
|
712
733
|
if (this.closed)
|
|
713
|
-
return;
|
|
734
|
+
return true;
|
|
714
735
|
try {
|
|
715
|
-
// Edited, turned off or deleted while it polled: nothing it found is kept.
|
|
736
|
+
// Edited, turned off or deleted while it polled: nothing it found is kept. An edit of its source polls again.
|
|
716
737
|
const current = await this.find(trigger.id);
|
|
717
|
-
if (!current || !current.enabled ||
|
|
718
|
-
return;
|
|
738
|
+
if (!current || !current.enabled || restarted())
|
|
739
|
+
return true;
|
|
740
|
+
if (JSON.stringify(current.source) !== JSON.stringify(trigger.source))
|
|
741
|
+
return false;
|
|
719
742
|
const by = adapter.id;
|
|
720
743
|
const at = Math.floor(nominalAt / 1000) * 1000;
|
|
721
744
|
if (result.note)
|
|
722
745
|
await this.record(current, { key: firingKey(by, trigger.id, `note\n${second(nominalAt)}`), by, nominalAt: at, status: "skipped", reason: result.note });
|
|
723
746
|
const events = result.events ?? [];
|
|
724
|
-
|
|
747
|
+
// The last event recorded: the cursor is its once they are (each event's is read only here, once: a source may make
|
|
748
|
+
// it when asked, as the feed's does).
|
|
749
|
+
let last;
|
|
725
750
|
let full = false;
|
|
726
751
|
for (const event of events) {
|
|
727
752
|
const key = firingKey(by, trigger.id, event.key);
|
|
@@ -745,20 +770,35 @@ export class Triggers {
|
|
|
745
770
|
full = true;
|
|
746
771
|
break;
|
|
747
772
|
}
|
|
748
|
-
|
|
773
|
+
last = event;
|
|
749
774
|
}
|
|
750
|
-
|
|
751
|
-
cursor = result.cursor ?? cursor;
|
|
775
|
+
const cursor = !events.length ? result.cursor : full ? last?.cursor : (result.cursor ?? last?.cursor);
|
|
752
776
|
if (restarted())
|
|
753
|
-
return;
|
|
777
|
+
return true;
|
|
754
778
|
for (const [field, value] of Object.entries(cursor ?? {}))
|
|
755
779
|
await settings?.set(trigger.id, field, value);
|
|
780
|
+
// Edited, turned off or on again while its cursor was written: its stop, a refusal's turn-off and its check were read
|
|
781
|
+
// on the source as it was. None is applied; an edit's poll, after this one, says what holds now.
|
|
782
|
+
const still = await this.find(trigger.id);
|
|
783
|
+
if (!still || !still.enabled || restarted())
|
|
784
|
+
return true;
|
|
785
|
+
if (JSON.stringify(still.source) !== JSON.stringify(trigger.source))
|
|
786
|
+
return false;
|
|
756
787
|
const refusals = result.refused ? (checkOf(settings?.get(trigger.id, LAST_CHECK))?.refused ?? 0) + 1 : 0;
|
|
757
788
|
if (result.refused && refusals >= REFUSALS_TO_STOP) {
|
|
758
789
|
await this.store.triggers.update(trigger.id, { enabled: false, nextAt: null, disabled: { at: iso(this.clock.now()), reason: "sign_in_refused", detail: result.refused.detail } });
|
|
759
790
|
this.deps.say({ condition: "trigger_sign_in_refused", trigger: trigger.id, refused: refusals });
|
|
760
791
|
await this.arm();
|
|
761
792
|
}
|
|
793
|
+
// Its source can't be read again as it is (every feed gone): off now, in its words, until an owner edits it and
|
|
794
|
+
// turns it on again. Before its last check is written, as a refused sign-in's is: a check that says so is never read
|
|
795
|
+
// beside a trigger still on.
|
|
796
|
+
if (result.stop && !result.refused) {
|
|
797
|
+
await this.store.triggers.update(trigger.id, { enabled: false, nextAt: null, disabled: { at: iso(this.clock.now()), reason: "source_unreadable", detail: result.stop.detail } });
|
|
798
|
+
this.deps.say({ condition: "trigger_source_unreadable", trigger: trigger.id, error: result.stop.detail });
|
|
799
|
+
await this.offThere([current]);
|
|
800
|
+
await this.arm();
|
|
801
|
+
}
|
|
762
802
|
const message = full ? `${result.check.message} ${DUE_KEPT} firings are still waiting for their runs: the rest wait for the next check.` : result.check.message;
|
|
763
803
|
await settings?.set(trigger.id, LAST_CHECK, JSON.stringify({ at: iso(now), ok: result.check.ok, message, refused: refusals }));
|
|
764
804
|
if (!result.check.ok)
|
|
@@ -767,6 +807,7 @@ export class Triggers {
|
|
|
767
807
|
catch (error) {
|
|
768
808
|
this.deps.say({ condition: "trigger_poll_unrecorded", trigger: trigger.id, error: String(error?.message ?? error) });
|
|
769
809
|
}
|
|
810
|
+
return true;
|
|
770
811
|
}
|
|
771
812
|
/** A firing taken from due to its end: skipped when its trigger's last run is active, else its run started (or its
|
|
772
813
|
* message sent). A failed try keeps it due under the backoff table, or ends it failed. Each step reads the trigger and
|
package/dist/webhooks.js
CHANGED
|
@@ -73,12 +73,15 @@ const WAIT = "wait:";
|
|
|
73
73
|
* read of the run) needs its mark, and that is one of its last few. */
|
|
74
74
|
const WAITS_KEPT = 20;
|
|
75
75
|
const iso = (ms) => new Date(ms).toISOString();
|
|
76
|
-
/** `work`'s result, or `signal`'s reason the moment it aborts: a lookup that never answers is given up on, not waited out.
|
|
76
|
+
/** `work`'s result, or `signal`'s reason the moment it aborts: a lookup that never answers is given up on, not waited out.
|
|
77
|
+
* `work` is always followed to its end, so one that fails after the abort (a name that answers NXDOMAIN once the server
|
|
78
|
+
* is stopping) is no unhandled rejection. */
|
|
77
79
|
const abortable = (work, signal) => new Promise((resolve, reject) => {
|
|
78
|
-
if (signal.aborted)
|
|
79
|
-
return reject(signal.reason);
|
|
80
80
|
const onAbort = () => reject(signal.reason);
|
|
81
|
-
signal.
|
|
81
|
+
if (signal.aborted)
|
|
82
|
+
onAbort();
|
|
83
|
+
else
|
|
84
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
82
85
|
work.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
83
86
|
});
|
|
84
87
|
export { signatureOf } from "./standard-webhooks.js";
|
|
@@ -627,6 +630,8 @@ export class Webhooks {
|
|
|
627
630
|
}
|
|
628
631
|
attempt.latency_ms = Math.round(performance.now() - started);
|
|
629
632
|
}
|
|
633
|
+
// In its words, written or not: a try the server's stop cut short still says why it ended.
|
|
634
|
+
attempt.error = failure ?? null;
|
|
630
635
|
if (this.closed)
|
|
631
636
|
return attempt;
|
|
632
637
|
// What the try found is settled against the webhook as it stands once every change asked for before it (a PUT, a
|
|
@@ -644,7 +649,6 @@ export class Webhooks {
|
|
|
644
649
|
async settleTry(id, how, now, tryId, claimed, config, failure, attempt) {
|
|
645
650
|
if (this.closed)
|
|
646
651
|
return attempt;
|
|
647
|
-
attempt.error = failure ?? null;
|
|
648
652
|
// The schedule counts the message's own tries, from the count its claim took it at; a redelivery counts none.
|
|
649
653
|
const attempts = claimed ? claimed.attempts + 1 : undefined;
|
|
650
654
|
// A 410 turns off the webhook as this try found it: one set again or removed while the try waited is not its to turn
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
import { DECISION_RECEIPT_VERSION } from "@parcha/agentrun-dsl";
|
|
7
7
|
import { appendDecision, DECISION_ROW_VERSION, readDecisionsFrom } from "./decisions.js";
|
|
8
8
|
/** What a receipt says of its provider beside its answers, each only when present: who answered, the sources, the
|
|
9
|
-
* questions refused, where each confidence came from, the images it carried
|
|
9
|
+
* questions refused, where each confidence came from, the images it carried, the state the judge saw and the values its
|
|
10
|
+
* provider cut from it. A replay gives the run all of it again. */
|
|
10
11
|
const kept = (from) => ({
|
|
11
12
|
...(from.provider !== undefined ? { provider: from.provider } : {}),
|
|
12
13
|
...(from.images !== undefined ? { images: from.images } : {}),
|
|
13
14
|
...(from.cost_basis !== undefined ? { cost_basis: from.cost_basis } : {}),
|
|
14
15
|
...(from.state !== undefined ? { state: from.state, state_truncated: from.state_truncated === true } : {}),
|
|
16
|
+
...(from.state_cut !== undefined ? { state_cut: from.state_cut } : {}),
|
|
15
17
|
...(from.evidence !== undefined ? { evidence: from.evidence } : {}),
|
|
16
18
|
...(from.refused !== undefined ? { refused: from.refused } : {}),
|
|
17
19
|
...(from.confidence_source !== undefined ? { confidence_source: from.confidence_source } : {}),
|
|
@@ -21,7 +23,8 @@ function rowOf(receipt, exchange, key) {
|
|
|
21
23
|
return {
|
|
22
24
|
v: DECISION_ROW_VERSION, at: receipt.at, node: receipt.node, kind: receipt.kind, item: receipt.item, execution_path: receipt.execution_path,
|
|
23
25
|
request_sha256: receipt.request_sha256,
|
|
24
|
-
|
|
26
|
+
// The request as sent: a state its provider cut to fit is counted cut.
|
|
27
|
+
request_bytes: Buffer.byteLength(JSON.stringify({ state: exchange.result?.state_sent ? exchange.result.state_sent.state : exchange.request.state, questions: exchange.request.questions })),
|
|
25
28
|
model: receipt.model, questions: receipt.questions, answers: receipt.answers, rule: receipt.rule, action: receipt.action,
|
|
26
29
|
usage: receipt.usage, cost_usd: receipt.cost_usd, latency_ms: receipt.latency_ms,
|
|
27
30
|
// An error the receipt kept cut says so, and the row keeps saying it: a host holds its tail back (serve graph-served.ts).
|
|
@@ -98,6 +98,13 @@ export type DecisionRow = {
|
|
|
98
98
|
/** The state the judge saw, or past 64 KB of JSON the first 64 KB of its text, with `state_truncated` saying which. */
|
|
99
99
|
state?: unknown;
|
|
100
100
|
state_truncated?: boolean;
|
|
101
|
+
/** The state values the provider cut to fit its model's context before sending (`state` holds them cut): where each
|
|
102
|
+
* sits (a JSON Pointer) and its UTF-8 bytes as asked and as sent. Absent when it sent the state as asked. */
|
|
103
|
+
state_cut?: Array<{
|
|
104
|
+
path: string;
|
|
105
|
+
bytes: number;
|
|
106
|
+
sent_bytes: number;
|
|
107
|
+
}>;
|
|
101
108
|
/** The request's spend is on its frozen driver's state, so a cost fold counts it there, not here. */
|
|
102
109
|
driver_spend?: true;
|
|
103
110
|
/** The receipt's id, its place among its node's requests, the digest of the state it was asked with, and the key of
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AttachHub, type ComputerSpec, type DockerVolume } from "@parcha/agentrun-computer";
|
|
1
|
+
import { type AttachHub, type ComputerSpec, type DockerVolume, type HostedDial } from "@parcha/agentrun-computer";
|
|
2
2
|
import type { DockerPaths } from "../box-paths.js";
|
|
3
3
|
import { type HostRead } from "../docker-host-addresses.js";
|
|
4
4
|
import { type ProviderFactories } from "../computer-keys.js";
|
|
@@ -56,6 +56,10 @@ export interface ComputerDepsOptions {
|
|
|
56
56
|
/** The server's AttachHub, where this runner shares the server's process (runner/beside.ts): a paired computer's
|
|
57
57
|
* socket is there. Absent: a runner of its own process, which refuses a paired computer in words. */
|
|
58
58
|
readonly hub?: AttachHub;
|
|
59
|
+
/** The server's dial (Serve.dial), where this runner shares the server's process: every remote provider's create
|
|
60
|
+
* takes it, and one whose host dials the server (facts.connect "dial") mints its machine's token there. Absent: a
|
|
61
|
+
* runner of its own process, where such a provider's create refuses in words. */
|
|
62
|
+
readonly dial?: HostedDial;
|
|
59
63
|
/** The server's seal key: absent, no saved key is opened (a key from the environment still is). */
|
|
60
64
|
readonly sealKey: Buffer | undefined;
|
|
61
65
|
/** The kind registry: the computer package's unless given (a test's fixture). */
|
|
@@ -293,11 +293,11 @@ export function computerDepsFrom(options) {
|
|
|
293
293
|
* Chrome's, where it finds Chrome), and no other variable of the server's. */
|
|
294
294
|
const hostEnvOf = (names) => Object.fromEntries(names.flatMap((name) => (env[name] === undefined ? [] : [[name, String(env[name])]])));
|
|
295
295
|
/** The options a provider takes beside its keys, by what its descriptor declares, never by its id: for a local one,
|
|
296
|
-
* its image source and its host options; the host environment it reads. */
|
|
296
|
+
* its image source and its host options; for a remote one, the server's dial; the host environment it reads. */
|
|
297
297
|
const declaredOptions = async (id, boxAllow) => {
|
|
298
298
|
const entry = kinds.PROVIDERS.find((one) => one.id === id);
|
|
299
299
|
return {
|
|
300
|
-
...(entry?.local ? { image: preparedImage, ...(await localHostOptions(boxAllow)) } : {}),
|
|
300
|
+
...(entry?.local ? { image: preparedImage, ...(await localHostOptions(boxAllow)) } : options.dial ? { dial: options.dial } : {}),
|
|
301
301
|
...(entry?.hostEnv ? { env: hostEnvOf(entry.hostEnv) } : {}),
|
|
302
302
|
};
|
|
303
303
|
};
|
|
@@ -15,6 +15,7 @@ export { type LearningPlace, type LearningWorkspace, learningWorkspace, type Lea
|
|
|
15
15
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
16
16
|
export { type AgentComputer, type RunComputer, type RunHold, runTools, type RunTools, type ScriptComputer, withKindTools } from "./run-tools.js";
|
|
17
17
|
export { NO_PROGRAMS_WORDS, portOf } from "./computer-ports.js";
|
|
18
|
+
export { registryHere } from "./resolve-computer.js";
|
|
18
19
|
export { COMPUTER_MCP_NAME, computerMcp, type ComputerMcpAnswer, mcpAnswerOf } from "./computer-mcp.js";
|
|
19
20
|
export { type ClaimSide, computerReadiness, type ComputerSetting, type KindRegistry, type LaunchedComputer, type Port, resolveComputer, type ResolvedComputer, runShellOf, type ShellPlace, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
|
|
20
21
|
export { computerProviderFactories, computerProviderMakers, type ProviderLoad } from "./computer-providers.js";
|
package/dist/workspace/index.js
CHANGED
|
@@ -16,6 +16,8 @@ export { learningWorkspace } from "./learning-workspace.js";
|
|
|
16
16
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
17
17
|
export { runTools, withKindTools } from "./run-tools.js";
|
|
18
18
|
export { NO_PROGRAMS_WORDS, portOf } from "./computer-ports.js";
|
|
19
|
+
// Each provider as this server has it (the mounts its keys turn on), on a line of its own.
|
|
20
|
+
export { registryHere } from "./resolve-computer.js";
|
|
19
21
|
export { COMPUTER_MCP_NAME, computerMcp, mcpAnswerOf } from "./computer-mcp.js";
|
|
20
22
|
export { computerReadiness, resolveComputer, runShellOf, shellPlaceOf, } from "./resolve-computer.js";
|
|
21
23
|
export { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
|
|
@@ -121,6 +121,33 @@ export type Port = "files" | "exec" | "processes" | "screen" | "input" | "phone"
|
|
|
121
121
|
/** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
|
|
122
122
|
* key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
|
|
123
123
|
export declare const providerKeys: (registry: Pick<KindRegistry, "PROVIDERS">, keyOf: (name: string) => Promise<string | undefined>) => ClaimSide["keysOf"];
|
|
124
|
+
/** What a provider is on this server beside its descriptor: the mounts the operator's keys turn on, and whether the
|
|
125
|
+
* operator names its image here. */
|
|
126
|
+
type HereFields = {
|
|
127
|
+
readonly mounts: readonly string[];
|
|
128
|
+
readonly unmounted?: Readonly<Partial<Record<string, string>>>;
|
|
129
|
+
readonly mountsWith?: Readonly<Partial<Record<string, string>>>;
|
|
130
|
+
readonly imageEnv?: string;
|
|
131
|
+
readonly prepareImage?: boolean;
|
|
132
|
+
/** Its descriptor's imageEnv has a value here: the operator names the image every computer of it starts from. */
|
|
133
|
+
readonly imageNamed?: true;
|
|
134
|
+
};
|
|
135
|
+
/** `entry` as this server has it, by `set` (whether a key, or a setting of this server, has a value here): with the
|
|
136
|
+
* mounts the operator's keys turn on (its descriptor's mountsWith, by the computer package's mountsOf: Daytona's Archil
|
|
137
|
+
* mount where DAYTONA_ARCHIL_EGRESS names a self-hosted target's Archil egress relay), and imageNamed where its
|
|
138
|
+
* descriptor's imageEnv names its image here (Daytona's AGENTRUN_DAYTONA_SNAPSHOT). Any other entry as it is. Every
|
|
139
|
+
* reader of an entry's mounts (Settings → Computers, the claim, a run's start, its shell) reads this, so the
|
|
140
|
+
* provider made with those keys and the server agree on what it mounts. */
|
|
141
|
+
export declare function entryHere<Entry extends HereFields>(entry: Entry, set: (name: string) => boolean): Entry;
|
|
142
|
+
/** `registry` with each provider as this server has it (entryHere), reading only the names an entry's mountsWith or
|
|
143
|
+
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key). A value of
|
|
144
|
+
* whitespace alone is none. */
|
|
145
|
+
export declare function registryHere<Registry extends {
|
|
146
|
+
readonly PROVIDERS: readonly ProviderEntry[];
|
|
147
|
+
}>(registry: Registry, valueOf: (name: string) => Promise<string | undefined>): Promise<Registry>;
|
|
148
|
+
/** Whether a computer of `entry` that mounts the owner's Archil disk has Archil's image in the owner's vendor account:
|
|
149
|
+
* its provider prepares it (prepareImage), or the operator names it here (imageNamed, entryHere). */
|
|
150
|
+
export declare const archilImageHere: (entry: HereFields) => boolean;
|
|
124
151
|
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
125
152
|
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
126
153
|
export declare const vendorNetworkOnly: (network: readonly string[] | undefined) => boolean;
|
|
@@ -133,8 +160,10 @@ export declare const aLabel: (label: string, start?: boolean) => string;
|
|
|
133
160
|
/** Why a sandbox or a desktop that would mount the owner's Archil disk can't start in Mode 2: the mount needs Archil's
|
|
134
161
|
* image in the owner's own vendor account, and this server can't put it there yet. A provider that prepares its image
|
|
135
162
|
* (prepareImage: Agent37 registers the box image in the owner's workspace, Modal pulls it, E2B starts its public
|
|
136
|
-
* template) is never refused so
|
|
137
|
-
|
|
163
|
+
* template) is never refused so, nor one whose image the operator names here (archilImageHere: Daytona's
|
|
164
|
+
* AGENTRUN_DAYTONA_SNAPSHOT). For such a one, `imageEnv` says where to name it. Settings (computers.ts modeRefusal)
|
|
165
|
+
* and a run's start (computerReadiness) say it. */
|
|
166
|
+
export declare const mode2ArchilWhy: (label: string, kind: "sandbox" | "desktop", imageEnv?: string) => string;
|
|
138
167
|
/** Why a computer that needs a network is refused where this server's AGENTRUN_BOX_ALLOW is none, in words that name the
|
|
139
168
|
* fix: the operator said no network at all, and the computer can't run without one. */
|
|
140
169
|
export declare const noNetworkRefusal: (label: string, kind: string) => string;
|
|
@@ -153,7 +182,7 @@ export declare const noNetworkRefusal: (label: string, kind: string) => string;
|
|
|
153
182
|
*
|
|
154
183
|
* `hostWhy`: why this machine cannot run a provider's computers, in words that say how to fix it (computers.ts
|
|
155
184
|
* hostCommandRefusals, read at the server's start: the phone's adb not on PATH), or undefined. Absent: not asked. */
|
|
156
|
-
export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2,
|
|
185
|
+
export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2, given: KindRegistry, keyOf: (name: string) => Promise<string | undefined>, answers?: (provider: string) => DockerDaemon | Promise<DockerDaemon>, boxAllow?: readonly string[] | "none", hostWhy?: (provider: string) => string | undefined): Promise<{
|
|
157
186
|
readonly ok: true;
|
|
158
187
|
} | {
|
|
159
188
|
readonly refused: string;
|