@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.33
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 +37 -0
- package/README.md +78 -46
- package/dist/adapters.d.ts +0 -3
- package/dist/adapters.js +0 -7
- package/dist/agents.d.ts +1 -1
- package/dist/api-only.d.ts +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +46 -0
- package/dist/box-settings.js +107 -0
- package/dist/boxes.d.ts +4 -1
- package/dist/browser-cost.js +2 -1
- package/dist/browser-person.d.ts +0 -2
- package/dist/browser-person.js +0 -2
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +0 -7
- package/dist/cap.js +0 -22
- package/dist/cli.js +23 -8
- package/dist/computers.d.ts +1 -1
- package/dist/console/assets/index-Dn0ngwG9.js +535 -0
- package/dist/console/assets/index-DvW6Aled.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- package/dist/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -0
- package/dist/files.d.ts +0 -8
- package/dist/files.js +0 -17
- package/dist/github-connection.d.ts +1 -1
- package/dist/github-connection.js +1 -1
- package/dist/harness-install.d.ts +23 -0
- package/dist/harness-install.js +99 -4
- package/dist/harness.d.ts +4 -3
- package/dist/harness.js +16 -1
- package/dist/import.js +52 -13
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +19 -6
- package/dist/learned-workflow.d.ts +5 -4
- package/dist/learned-workflow.js +6 -3
- package/dist/learning-routes.d.ts +9 -46
- package/dist/learning-routes.js +25 -29
- package/dist/learning-run.d.ts +4 -231
- package/dist/learning-run.js +7 -651
- package/dist/live/translate.js +1 -1
- package/dist/mcp-gateway.d.ts +0 -3
- package/dist/mcp-gateway.js +0 -13
- package/dist/mcp-probe.d.ts +2 -2
- package/dist/mcp-probe.js +2 -2
- package/dist/mcp-servers-store.js +1 -1
- package/dist/openapi.js +3 -3
- package/dist/page.js +3 -1
- package/dist/paid-calls.js +3 -2
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- package/dist/run-db.d.ts +0 -2
- package/dist/run-db.js +0 -4
- package/dist/run-learning-served.d.ts +38 -0
- package/dist/run-learning-served.js +9 -0
- package/dist/run-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +5 -9
- package/dist/run-view.js +4 -22
- package/dist/runner/adapter-loop.d.ts +8 -2
- package/dist/runner/adapter-loop.js +44 -12
- package/dist/runner/adapter-run-spec.d.ts +8 -0
- package/dist/runner/adapter-run-spec.js +6 -5
- package/dist/runner/adapters/pi.d.ts +4 -0
- package/dist/runner/adapters/pi.js +4 -1
- package/dist/runner/beside.js +19 -8
- package/dist/runner/claim-secrets.js +1 -1
- package/dist/runner/cli-run-spec.js +15 -1
- package/dist/runner/journal-kinds.d.ts +6 -0
- package/dist/runner/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +11 -4
- package/dist/runner/main.js +39 -10
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/model-route.js +21 -2
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- package/dist/runner/workflow-spec.js +5 -9
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/runs-over-store.js +16 -5
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +272 -84
- package/dist/sealed-settings.d.ts +2 -2
- package/dist/sealed-settings.js +3 -10
- package/dist/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- package/dist/server-secrets-store.js +1 -1
- package/dist/server-secrets.js +3 -0
- package/dist/server.d.ts +10 -6
- package/dist/server.js +89 -41
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/open.d.ts +12 -2
- package/dist/store/open.js +23 -3
- package/dist/store/postgres/migrate.js +18 -1
- package/dist/store/sqlite/store.js +23 -8
- package/dist/store/store.d.ts +3 -0
- package/dist/store-reads/journal.d.ts +16 -0
- package/dist/store-reads/journal.js +82 -6
- package/dist/store-view.js +38 -5
- package/dist/tool-keys.d.ts +4 -3
- package/dist/tool-keys.js +7 -4
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +4 -1
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- package/dist/workspace/computer-deps.d.ts +29 -0
- package/dist/workspace/computer-deps.js +48 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +1 -1
- package/dist/workspace/computer-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +0 -3
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- package/dist/console/assets/index-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- package/dist/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
package/dist/bounds.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// The bounds of a run's model requests (cap.ts BOUND_FIELD: the most a cache miss can make one cost beyond what its cap
|
|
2
|
-
// held it at), as its root's entries say them: what the run's cost serves as in flight (overshoot_bound_usd), and what the
|
|
3
|
-
// over-cap row and the run's end read as the bound of the requests that ended since its cost last fit its cap.
|
|
4
|
-
//
|
|
5
|
-
// The server reads a run's entries live and then again whole (a reconnect's snapshot, the settle's and a load's full read
|
|
6
|
-
// of the store): each entry changes the bounds once, by its id, as turns.ts reads them. A harness request (its start mark
|
|
7
|
-
// names its session `key` and `request`, harness-app.ts) closes when its own answer is booked, by the BOOKED marker that
|
|
8
|
-
// names it, in whatever order answers come; one booked before its cost came in stays open until its late cost does. pi's
|
|
9
|
-
// generation requests go one at a time on the root: one closes on its end mark or its answer (a second close, a stopped
|
|
10
|
-
// request's aborted entry after its end mark, closes nothing), never on a lost attempt's end mark (`lost`, written before
|
|
11
|
-
// pi-ai tries again within the same request: its answer, or its own end, still comes), and a start while one is still
|
|
12
|
-
// open says that one was cut
|
|
13
|
-
// (a crash: the next process sends the next request): pi-agent-core's loop awaits each answer before it runs that
|
|
14
|
-
// answer's tool calls and sends the next (agent-loop.js runLoop). pi's side requests (a label for `request`: a summary, a
|
|
15
|
-
// hosted search's, a learned workflow node's) run inside tool calls, which pi runs side by side (agent.js toolExecution
|
|
16
|
-
// "parallel"): each closes by its own `requestId`, on its end mark or its cost. A refusal's own start mark holds none.
|
|
17
|
-
//
|
|
18
|
-
// A request that will never end must not pin the bounds for the run's life. A pi side request is over once the run sends
|
|
19
|
-
// its next turn or harness request: pi-agent-core awaits the turn's tool calls (agent-loop.js:165, `await
|
|
20
|
-
// executeToolCalls`, inside which every side request runs) before it sends the next (:141), so one still open then died
|
|
21
|
-
// with its process (an OOM kill inside the tool call, before its cost mark): its hold is booked, it has no cost to come, and
|
|
22
|
-
// its bound is dropped, never summed. A harness request booked before its cost keeps its bound served as in flight (its
|
|
23
|
-
// cost may still be a miss), apart from the requests whose answers are still to come: it never holds the ended bounds
|
|
24
|
-
// back from starting afresh, since its bound joins them in the very entry that brings its late cost, so it counts when,
|
|
25
|
-
// and only when, its cost does, whatever came between (harness answers and late costs come in any order). That cost
|
|
26
|
-
// always comes while the run lives: in its process (harness-app.ts priceLate), or at the next open, which writes every
|
|
27
|
-
// booked request the root has at unknown cost before any new request; a run no process holds serves no bound (runs.ts).
|
|
28
|
-
//
|
|
29
|
-
// The bounds that ended count from the newest entry at which what the run had spent (the cap's own reading of an entry's
|
|
30
|
-
// cost, cap.ts costOf) fit its cap with no request in flight: read live or whole after a restart, the same entries keep
|
|
31
|
-
// the same bounds.
|
|
32
|
-
import { REQUEST_COST, REQUEST_COST_LATE, REQUEST_ENDED, REQUEST_STARTED } from "@parcha/pi-durable-agent/timeline";
|
|
33
|
-
import { BOUND_FIELD, CAP_REFUSED_FIELD, costOf, FIT_TOLERANCE } from "./cap.js";
|
|
34
|
-
import { ADAPTER_API, BOOKED } from "./turn-end.js";
|
|
35
|
-
import { isObject } from "./validate.js";
|
|
36
|
-
const boundOf = (value) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0);
|
|
37
|
-
export class RequestBounds {
|
|
38
|
-
/** The newest entry read, by id: an entry at or before it is read again, and changes nothing. */
|
|
39
|
-
seen = -Infinity;
|
|
40
|
-
/** Each request in flight that names itself: a harness request, by `<key>:<request>`, and a pi side request, by
|
|
41
|
-
* `side:<requestId>`; its bound. */
|
|
42
|
-
harness = new Map();
|
|
43
|
-
/** Each harness request booked before its cost, by `<key>:<request>`: its bound, served as in flight until its late
|
|
44
|
-
* cost comes, and never holding the ended bounds back. */
|
|
45
|
-
awaiting = new Map();
|
|
46
|
-
/** pi's one generation request in flight: its bound. */
|
|
47
|
-
pi;
|
|
48
|
-
/** The bounds of the requests that ended since the run's cost last fit its cap, together. */
|
|
49
|
-
since = 0;
|
|
50
|
-
/** What the run has spent by the entries read, as the cap reads each entry's cost. */
|
|
51
|
-
spent = 0;
|
|
52
|
-
/** Reads `entries` of the run's root, each once, against the run's `cap` (none: no overshoot to explain). */
|
|
53
|
-
note(entries, cap) {
|
|
54
|
-
for (const value of entries) {
|
|
55
|
-
if (!isObject(value))
|
|
56
|
-
continue;
|
|
57
|
-
if (typeof value.id === "number") {
|
|
58
|
-
if (value.id <= this.seen)
|
|
59
|
-
continue;
|
|
60
|
-
this.seen = value.id;
|
|
61
|
-
}
|
|
62
|
-
this.noteOne(value);
|
|
63
|
-
this.spent += costOf(value);
|
|
64
|
-
// The run's cost fits its cap here, and no request is in flight whose cost is still to come: the bounds that ended so
|
|
65
|
-
// far explain no overshoot to come.
|
|
66
|
-
if (cap === undefined || (this.spent <= cap + FIT_TOLERANCE && this.pi === undefined && this.harness.size === 0))
|
|
67
|
-
this.since = 0;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
noteOne(value) {
|
|
71
|
-
const data = isObject(value.data) ? value.data : {};
|
|
72
|
-
const side = typeof data.request === "string";
|
|
73
|
-
const harnessKey = typeof data.key === "string" && typeof data.request === "number" ? `${data.key}:${data.request}` : side && typeof data.requestId === "string" ? `side:${data.requestId}` : undefined;
|
|
74
|
-
const message = Array.isArray(value.model) && isObject(value.model[0]) ? value.model[0] : undefined;
|
|
75
|
-
if (value.kind === REQUEST_STARTED) {
|
|
76
|
-
if (data[CAP_REFUSED_FIELD] === true)
|
|
77
|
-
return;
|
|
78
|
-
// A turn or harness request: every side request still open died with its process (above).
|
|
79
|
-
// This assumes no harness runs a second request loop inside a tool call: Claude Code runs with its builtins off, or
|
|
80
|
-
// with CLAUDE_BUILTINS_OFF keeping Task and Agent off, and Codex with multi_agent and agents off. Should either get
|
|
81
|
-
// native subagents, a side request could still be live at a root start, and this drop rule needs another look.
|
|
82
|
-
if (!side)
|
|
83
|
-
for (const key of [...this.harness.keys()])
|
|
84
|
-
if (key.startsWith("side:"))
|
|
85
|
-
this.harness.delete(key);
|
|
86
|
-
if (harnessKey)
|
|
87
|
-
this.harness.set(harnessKey, boundOf(data[BOUND_FIELD]));
|
|
88
|
-
else if (side)
|
|
89
|
-
return;
|
|
90
|
-
// A pi request still open when the next starts was cut by a crash: booked at its hold, it ends with no cost of its own.
|
|
91
|
-
else
|
|
92
|
-
this.pi = boundOf(data[BOUND_FIELD]);
|
|
93
|
-
}
|
|
94
|
-
else if (value.kind === BOOKED && harnessKey) {
|
|
95
|
-
if (data.unpriced !== true)
|
|
96
|
-
this.closeHarness(harnessKey);
|
|
97
|
-
else if (this.harness.has(harnessKey)) {
|
|
98
|
-
this.awaiting.set(harnessKey, this.harness.get(harnessKey));
|
|
99
|
-
this.harness.delete(harnessKey);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (value.kind === REQUEST_COST_LATE && harnessKey && this.awaiting.has(harnessKey)) {
|
|
103
|
-
this.since += this.awaiting.get(harnessKey);
|
|
104
|
-
this.awaiting.delete(harnessKey);
|
|
105
|
-
}
|
|
106
|
-
else if ((value.kind === REQUEST_COST_LATE || value.kind === REQUEST_COST || value.kind === REQUEST_ENDED) && harnessKey)
|
|
107
|
-
this.closeHarness(harnessKey);
|
|
108
|
-
else if (value.kind === REQUEST_ENDED && !side && !harnessKey && data.lost !== true)
|
|
109
|
-
this.closePi();
|
|
110
|
-
// A harness answer is closed by its BOOKED marker; pi's answer (or pi's error for a request that never left, which
|
|
111
|
-
// finds none open) closes pi's.
|
|
112
|
-
else if (value.kind === "pi.assistant" && message && message.api !== ADAPTER_API)
|
|
113
|
-
this.closePi();
|
|
114
|
-
}
|
|
115
|
-
closeHarness(key) {
|
|
116
|
-
const bound = this.harness.get(key);
|
|
117
|
-
if (bound === undefined)
|
|
118
|
-
return;
|
|
119
|
-
this.harness.delete(key);
|
|
120
|
-
this.since += bound;
|
|
121
|
-
}
|
|
122
|
-
closePi() {
|
|
123
|
-
if (this.pi === undefined)
|
|
124
|
-
return;
|
|
125
|
-
this.since += this.pi;
|
|
126
|
-
this.pi = undefined;
|
|
127
|
-
}
|
|
128
|
-
/** The bounds of the requests in flight, together: those whose cost may still be a miss. */
|
|
129
|
-
inFlight() {
|
|
130
|
-
return [...this.harness.values(), ...this.awaiting.values()].reduce((sum, usd) => sum + usd, this.pi ?? 0);
|
|
131
|
-
}
|
|
132
|
-
/** The bounds of the requests that ended since the run's cost last fit its cap, together: how far a cache miss among
|
|
133
|
-
* them may have taken the run past its cap. */
|
|
134
|
-
ended() {
|
|
135
|
-
return this.since;
|
|
136
|
-
}
|
|
137
|
-
}
|