@parcha/agentrun-serve 0.1.0-beta.50 → 0.1.0-beta.51
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 +147 -0
- package/README.md +142 -17
- package/dist/agents-store.js +7 -3
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -2
- package/dist/capacity.d.ts +50 -0
- package/dist/capacity.js +49 -0
- package/dist/cli-learning/claude-wire.d.ts +41 -0
- package/dist/cli-learning/claude-wire.js +258 -0
- package/dist/cli-learning/cli.d.ts +11 -0
- package/dist/cli-learning/cli.js +241 -0
- package/dist/cli-learning/codex-worktree.d.ts +10 -0
- package/dist/cli-learning/codex-worktree.js +119 -0
- package/dist/cli-learning/connections.d.ts +62 -0
- package/dist/cli-learning/connections.js +87 -0
- package/dist/cli-learning/entry.d.ts +1 -0
- package/dist/cli-learning/entry.js +4 -0
- package/dist/cli-learning/evidence.d.ts +78 -0
- package/dist/cli-learning/evidence.js +492 -0
- package/dist/cli-learning/hook.d.ts +33 -0
- package/dist/cli-learning/hook.js +544 -0
- package/dist/cli-learning/install.d.ts +33 -0
- package/dist/cli-learning/install.js +335 -0
- package/dist/cli-learning/observation-proof.d.ts +14 -0
- package/dist/cli-learning/observation-proof.js +10 -0
- package/dist/cli-learning/policy.d.ts +48 -0
- package/dist/cli-learning/policy.js +363 -0
- package/dist/cli-learning/schema.d.ts +16 -0
- package/dist/cli-learning/schema.js +27 -0
- package/dist/cli-learning/state.d.ts +23 -0
- package/dist/cli-learning/state.js +61 -0
- package/dist/cli.js +24 -2
- package/dist/console/assets/index-Bt1B51b7.js +733 -0
- package/dist/console/assets/index-sVftE9Ht.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/email/email-faux.d.ts +3 -1
- package/dist/email/email-faux.js +3 -2
- package/dist/email/routes.js +22 -12
- package/dist/harness-install.d.ts +6 -2
- package/dist/harness-install.js +40 -8
- package/dist/harness.d.ts +1 -1
- package/dist/harness.js +2 -2
- package/dist/learn/secrets.js +14 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +1 -1
- package/dist/mcp-pin-first.js +2 -1
- package/dist/mcp-private-hosts.d.ts +24 -3
- package/dist/mcp-private-hosts.js +53 -3
- package/dist/model-gateway.d.ts +2 -0
- package/dist/model-gateway.js +3 -1
- package/dist/native/runtimes.d.ts +2 -0
- package/dist/native/runtimes.js +2 -0
- package/dist/observation/learning.d.ts +32 -0
- package/dist/observation/learning.js +66 -0
- package/dist/observation/observer.d.ts +8 -1
- package/dist/observation/observer.js +89 -9
- package/dist/observation/schema.js +12 -4
- package/dist/observation/usage-identity.d.ts +9 -0
- package/dist/observation/usage-identity.js +11 -0
- package/dist/openapi.js +89 -13
- package/dist/run-launch.d.ts +14 -0
- package/dist/run-launch.js +4 -0
- package/dist/run-view.d.ts +2 -0
- package/dist/run-view.js +12 -7
- package/dist/runner/adapter-loop.js +29 -26
- package/dist/runner/adapter-run-spec.js +2 -2
- package/dist/runner/beside.d.ts +13 -0
- package/dist/runner/beside.js +27 -8
- package/dist/runner/cli-run-spec.js +2 -2
- package/dist/runner/disk-free.d.ts +44 -0
- package/dist/runner/disk-free.js +96 -0
- package/dist/runner/feedback-round.d.ts +12 -8
- package/dist/runner/feedback-round.js +16 -30
- package/dist/runner/harness-loops.js +3 -1
- package/dist/runner/journal-kinds.d.ts +1 -1
- package/dist/runner/learning-end.js +4 -0
- package/dist/runner/main.d.ts +17 -6
- package/dist/runner/main.js +187 -45
- package/dist/runner/presence.d.ts +11 -2
- package/dist/runner/presence.js +31 -3
- package/dist/runner/run-child-host.d.ts +12 -15
- package/dist/runner/run-child-host.js +46 -108
- package/dist/runner/run-errors.js +2 -0
- package/dist/runner/runner-check.d.ts +51 -0
- package/dist/runner/runner-check.js +206 -0
- package/dist/runner/runner-metrics.d.ts +19 -0
- package/dist/runner/runner-metrics.js +49 -0
- package/dist/runner/runner.d.ts +37 -0
- package/dist/runner/runner.js +43 -3
- package/dist/runner/sdk-loop.js +34 -22
- package/dist/runs-over-store.d.ts +8 -1
- package/dist/runs-over-store.js +57 -9
- package/dist/sdk/runs.d.ts +22 -2
- package/dist/sdk/runs.js +103 -34
- package/dist/server.d.ts +3 -0
- package/dist/server.js +149 -26
- package/dist/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/start-switches.js +2 -0
- package/dist/stats.d.ts +4 -0
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +12 -0
- package/dist/store/agent-body.js +16 -2
- package/dist/store/dialect.d.ts +2 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/postgres/connection.d.ts +5 -2
- package/dist/store/postgres/connection.js +19 -7
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrate.d.ts +30 -0
- package/dist/store/postgres/migrate.js +72 -5
- package/dist/store/postgres/migration-lint.d.ts +8 -0
- package/dist/store/postgres/migration-lint.js +119 -0
- package/dist/store/postgres/migrations/0024_runner_capacity.sql +28 -0
- package/dist/store/postgres/store.d.ts +8 -3
- package/dist/store/postgres/store.js +31 -11
- package/dist/store/schema.d.ts +18 -1
- package/dist/store/schema.js +33 -2
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +44 -0
- package/dist/store/sqlite/store.d.ts +17 -0
- package/dist/store/sqlite/store.js +87 -10
- package/dist/store/store-schema.d.ts +34 -0
- package/dist/store/store-schema.js +125 -0
- package/dist/store/store.d.ts +53 -1
- package/dist/store/store.js +13 -0
- package/dist/store-reads/analytics.d.ts +3 -2
- package/dist/store-reads/analytics.js +20 -8
- package/dist/store-view.d.ts +4 -3
- package/dist/store-view.js +11 -7
- package/dist/templates.d.ts +3 -2
- package/dist/tool-gate.d.ts +4 -2
- package/dist/unified-usage.d.ts +24 -0
- package/dist/unified-usage.js +400 -0
- package/dist/uploads-archil.d.ts +100 -0
- package/dist/uploads-archil.js +430 -0
- package/dist/uploads.d.ts +55 -1
- package/dist/uploads.js +185 -98
- package/dist/validate.js +1 -1
- package/dist/workspace/archil-disk.d.ts +6 -5
- package/dist/workspace/archil-disk.js +27 -12
- package/dist/workspace/archil.js +3 -2
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/console/assets/index-D0mr9wfZ.css +0 -1
- package/dist/console/assets/index-D7G6o-1E.js +0 -720
package/dist/openapi.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CLI_LEARNING_BINDING, CLI_LEARNING_RUN, CLI_LEARNING_PATHS } from "./cli-learning/schema.js";
|
|
1
2
|
import { OBSERVATION_PATHS } from './observation/schema.js';
|
|
2
3
|
import { SDK_BINDING, SDK_PATHS, SDK_RUN } from "./sdk/schema.js";
|
|
3
4
|
import { NATIVE_BINDING, NATIVE_RUN, NATIVE_PATHS } from "./native/schema.js";
|
|
@@ -132,11 +133,25 @@ const GROUP = {
|
|
|
132
133
|
needs_review: { ...COUNT, description: "Of `completed`, the escalated runs, which wait for a person's review.", "x-agentrun-serve": "stats/3" },
|
|
133
134
|
failed: { ...COUNT, description: "Failed: never an escalated run." },
|
|
134
135
|
runs_with_metrics: { ...COUNT, description: "Of `runs`, those that ended with metrics: a running run, and a run whose end wrote none, has none." },
|
|
135
|
-
|
|
136
|
+
runs_with_token_metrics: { ...COUNT, description: "Of `runs`, those that ended with all four token counters reported. Metrics objects with missing or null counters do not count." },
|
|
137
|
+
tokens: { ...COUNT, type: ["integer", "null"], description: "Input, cache read, cache write and output tokens, summed only over `runs_with_token_metrics`. A partial total remains visible when other runs have unknown usage. Null when runs exist but none has a complete token count; zero for an empty scope." },
|
|
136
138
|
cost_usd: USD, unknown_cost_runs: { ...COUNT, description: "Runs with no known cost: running, or ended without one." },
|
|
137
139
|
};
|
|
138
140
|
/** GET /stats's `analytics` (stats.ts analyticsView). */
|
|
139
141
|
const ANALYTICS = closed({
|
|
142
|
+
usage: closed({
|
|
143
|
+
tokens: { ...COUNT, type: ["integer", "null"], description: "Known token lower bound across recorded runs and connected source sessions. Ambiguous overlapping aggregates retain the larger coherent view; distinct immutable CLI prompt windows can sum. Null when no included source reports a total." },
|
|
144
|
+
input: { ...COUNT, type: ["integer", "null"], description: "Uncached input; null when a counted source cannot split cached input." },
|
|
145
|
+
output: { ...COUNT, type: ["integer", "null"] },
|
|
146
|
+
cache_read: { ...COUNT, type: ["integer", "null"] }, cache_write: { ...COUNT, type: ["integer", "null"] },
|
|
147
|
+
known_runs: { ...COUNT, description: "Runs contributing known usage to the selected lower bound." }, unknown_runs: { ...COUNT, description: "Runs with missing counters or unresolved overlap. A run can contribute a known lower bound and also have incomplete coverage." },
|
|
148
|
+
observed_sessions: { ...COUNT, description: "Distinct source session identities with usable reported tokens in scope, including when a larger captured view supplies the selected total." },
|
|
149
|
+
unknown_sessions: { ...COUNT, description: "Source session identities with missing reports or unresolved overlap between report copies. A session may have known usage and also incomplete coverage." },
|
|
150
|
+
partial_days: { ...COUNT, description: "UTC boundary days whose source aggregates cannot be split exactly and were excluded." },
|
|
151
|
+
retention_limited: { type: "boolean", description: "The requested observed range extends beyond the retained 90 days; older source usage is unavailable." },
|
|
152
|
+
by_day: { type: "array", items: closed({ day: { type: "string", format: "date" }, tokens: { ...COUNT, type: ["integer", "null"] } }) },
|
|
153
|
+
by_harness: { type: "array", items: closed({ harness: { type: "string" }, tokens: { ...COUNT, type: ["integer", "null"] } }) },
|
|
154
|
+
}, "Unified reported token usage. Runs use their server start date; connected usage uses its retained observation UTC day. Verified session identity groups potentially overlapping views, independently of learning state. Server receipt dates do not prove native execution intervals: unknown coverage remains explicit. Daily source buckets are included only when fully inside the requested range."),
|
|
140
155
|
filter: closed({ from: { type: ["string", "null"], format: "date-time" }, to: { type: ["string", "null"], format: "date-time" }, agent: { type: ["string", "null"] } }, "The query's bounds, each null when not given: runs started at or after `from` and before `to`, of `agent`."),
|
|
141
156
|
totals: closed({
|
|
142
157
|
...GROUP, input: { ...COUNT, type: ["integer", "null"] }, cache_read: { ...COUNT, type: ["integer", "null"] }, cache_write: { ...COUNT, type: ["integer", "null"] }, output: { ...COUNT, type: ["integer", "null"] },
|
|
@@ -149,6 +164,31 @@ const ANALYTICS = closed({
|
|
|
149
164
|
tools: { type: "array", maxItems: 20, description: "The 20 tools with the most calls, by name on a tie; `errors` counts the calls that failed (an error, a result the tool reads as failed such as a refused fetch, or no result at all).", items: closed({ tool: { type: "string", description: "The name the tool was called by." }, label: { type: "string", description: "What a person calls the tool, from the timeline's label registry; the name it was called by when it has none.", "x-agentrun-serve": "stats/3" }, calls: COUNT, errors: COUNT }) },
|
|
150
165
|
}, "The runs' tokens, requests, time and tool calls from their metrics, over the runs not archived that the query picks; a run with no metrics counts in `runs` alone.");
|
|
151
166
|
/** GET /stats's answer (stats.ts). */
|
|
167
|
+
/** GET /capacity's answer (capacity.ts CapacityView). */
|
|
168
|
+
const CAPACITY = closed({
|
|
169
|
+
at: { type: "string", format: "date-time", description: "When it was read, on the store's clock (the database's on Postgres)." },
|
|
170
|
+
runs: closed({
|
|
171
|
+
queued: { ...COUNT, description: "Runs waiting for a runner now: queued, handed back or with their claim run out (past any backoff), or parked with something to wake them. The backlog a scaler reads." },
|
|
172
|
+
executing: { ...COUNT, description: "Runs a live claim holds now, on any runner." },
|
|
173
|
+
}, "The store's runs, by whether a runner holds them."),
|
|
174
|
+
runners: {
|
|
175
|
+
type: "array", description: "Each live runner (it said it was there within the last 30 s), by name.",
|
|
176
|
+
items: closed({
|
|
177
|
+
id: { type: "string", description: "The runner's name." },
|
|
178
|
+
version: { type: ["string", "null"], description: "Its build's version; null for a runner of an earlier build." },
|
|
179
|
+
slots: { type: ["integer", "null"], minimum: 0, description: "The most runs it holds at once; null when it did not say (an earlier build, or a runner that refused to claim)." },
|
|
180
|
+
executing: { ...COUNT, description: "The runs its live claims hold now." },
|
|
181
|
+
free_slots: { type: ["integer", "null"], minimum: 0, description: "`slots` less `executing`, never below 0; 0 for a runner that refused to claim, null with no `slots`. A runner also claims by its host's memory, so a free slot is the most it may take." },
|
|
182
|
+
refused: { type: "boolean", description: "It refused to claim any run; capabilities' `runner_refused` has its words." },
|
|
183
|
+
seen_at: { type: "string", format: "date-time", description: "When it last said it was there." },
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
free_slots: { ...COUNT, description: "The free slots of every live runner that said its slots." },
|
|
187
|
+
hand_backs: closed({
|
|
188
|
+
window_minutes: { type: "integer", minimum: 1, maximum: 1440, description: "The window asked for (`window`)." },
|
|
189
|
+
count: { ...COUNT, description: "Runs a runner gave back still running within the window: a drain, a loop that closed itself, a claim given back. A claim whose lease ran out is not counted here." },
|
|
190
|
+
}, "The hand-backs within the window."),
|
|
191
|
+
});
|
|
152
192
|
const STATS = closed({
|
|
153
193
|
agents: { ...COUNT, description: "Agents not archived." },
|
|
154
194
|
runs: closed({ total: COUNT, active: COUNT, needs_input: COUNT, failed: COUNT, needs_review: { ...COUNT, "x-agentrun-serve": "stats/3" }, status_unknown: COUNT }, "Runs not archived. `total` counts them all; a completed or cancelled run is counted in `total` alone, but for an escalated one, which completed and waits for a person's review: it is in `needs_review`, never in `failed`. Each running run is in exactly one of `active` (this server holds it, queued, working or paused), `needs_input` (it holds it, input_required) and `status_unknown` (it does not hold it, or holds it as ended before its end is written)."),
|
|
@@ -1301,7 +1341,7 @@ const TEMPLATE = closed({
|
|
|
1301
1341
|
toolkit: { type: "string", description: "The toolkit its tools are: the package names them `mcp:<toolkit>/<tool>`, and apply maps it to a saved MCP server whose `source` and `toolkit` match, rewriting the name to `mcp:<server>/<tool>` in the agent it makes." },
|
|
1302
1342
|
required: { type: "boolean" },
|
|
1303
1343
|
reason: { type: ["string", "null"], description: "Why the agent needs these tools, one line, for the apply screen." },
|
|
1304
|
-
tools: { type: "array", items: closedWith({ name: { type: "string" }, tool: { type: "string", description: "Its name in the package, `mcp:<toolkit>/<tool>`: what apply's `grants` name." }, asks: { enum: ["allow", "ask"], description: "
|
|
1344
|
+
tools: { type: "array", items: closedWith({ name: { type: "string" }, tool: { type: "string", description: "Its name in the package, `mcp:<toolkit>/<tool>`: what apply's `grants` name." }, asks: { enum: ["allow", "ask"], description: "Every listed tool is one the package uses and asks the owner to grant (a consent screen shows each): only the owner's `grants` at apply grant it, with no permission written; one left out is not granted. `asks` says only how its calls run once granted: `allow`, a tool the package's manifest lists under `allow`, expected to run without asking (a read); `ask`, each call waits for the owner's OK (a write) unless the owner allowed it in tool settings or chose approvals `never`." } }, { pin: { type: "object", additionalProperties: { anyOf: [{ type: ["string", "number", "boolean", "null"] }, { type: "array", items: { type: ["string", "number", "boolean", "null"] } }, PIN_KEYS] }, description: "The arguments (each a value, a list one of which, or {keys: [...]}, the keys an object argument may hold) each call of the tool must carry, `${parameters.<name>}` unfilled: apply writes them, filled, as the tool's pin in the agent's tool_settings, so the tool gate refuses a call with any other (a send goes only to the destination the owner sets), and a call carrying an argument the tool's listing does not declare (an alias of a pinned one). A pin whose parameter apply is not given sets the tool to deny instead, with a `pins.<tool>` warning.", "x-agentrun-serve": "pins/1" } }) },
|
|
1305
1345
|
}),
|
|
1306
1346
|
description: "The MCP servers it uses, by source and toolkit, and the tools of each it may be granted: apply maps each to a saved server whose `source` and `toolkit` match (`servers` picks when several do) and grants there only those the apply's `grants` name, with no permission written (each call follows this server's tool settings: under approvals ask a write asks unless the owner allowed it there, and a read runs unasked only where the server's Allow reads is on); a tool left out of `grants` is not the agent's at all, whatever its approvals, and the owner can grant it later in the agent's tools. One no saved server matches is skipped with an `mcp.<toolkit>` warning saying how to set it up, or, `required`, refuses the apply (409, nothing made).",
|
|
1307
1347
|
},
|
|
@@ -1346,9 +1386,20 @@ const TEMPLATE_APPLIED = closedWith({
|
|
|
1346
1386
|
template: { type: "string" },
|
|
1347
1387
|
version: { type: "string" },
|
|
1348
1388
|
agent_id: { type: "string", description: "The agent made, or the one updated (GET /agents/{agent_id})." },
|
|
1349
|
-
revision_version: { type: "integer", minimum: 1, description: "The number of the agent's revision this apply wrote, its current one now (its `definition.version`): 1 for an agent it made; on an update with agent_id, the new revision's." },
|
|
1350
|
-
servers: { type: "object", additionalProperties: { type: ["string", "null"] }, description: "The saved MCP server each of the package's toolkits runs on, by toolkit; null: none here matches it (said under `mcp.<toolkit>`)." },
|
|
1389
|
+
revision_version: { type: "integer", minimum: 1, description: "The number of the agent's revision this apply wrote, its current one now (its `definition.version`): 1 for an agent it made; on an update with agent_id, the new revision's; on one that changed nothing (`agent_change` unchanged), the current revision it kept." },
|
|
1390
|
+
agent_change: { enum: ["made", "updated", "unchanged"], description: "What the apply did to the agent: `made` it (201); `updated` it, a new revision written (an update with agent_id); or left it `unchanged`: an update whose package and parameters its current revision already holds writes no revision, and `revision_version` is that current one. Its triggers are reconciled either way (`triggers`)." }, servers: { type: "object", additionalProperties: { type: ["string", "null"] }, description: "The saved MCP server each of the package's toolkits runs on, by toolkit; null: none here matches it (said under `mcp.<toolkit>`)." },
|
|
1351
1391
|
trigger_ids: { type: "array", items: { type: "string" }, description: "Its triggers, in the package's order (GET /triggers/{trigger_id})." },
|
|
1392
|
+
triggers: {
|
|
1393
|
+
type: "array",
|
|
1394
|
+
description: "The same triggers, in the same order, each as the apply left it: every one it made or kept, of any kind. A trigger the apply skipped (said in `warnings`) is not here.",
|
|
1395
|
+
items: closed({
|
|
1396
|
+
trigger_id: { type: "string" },
|
|
1397
|
+
name: { type: "string", description: "Its name: the package's name for it." },
|
|
1398
|
+
kind: { enum: [...SOURCE_KINDS], description: "Its source's kind (GET /triggers/{trigger_id} `source.kind`)." },
|
|
1399
|
+
enabled: { type: "boolean", description: "Whether it is on: made off where the package says so, or where the owner turned off the one it replaced; one changed in place keeps the owner's on or off." },
|
|
1400
|
+
}),
|
|
1401
|
+
"x-agentrun-serve": "template-triggers/1",
|
|
1402
|
+
},
|
|
1352
1403
|
warnings: { type: "array", items: ref("schemas/InputIssue"), description: "What this host still lacks for the agent to run, as POST /agents answers it; a webhook trigger the apply made adds a warning pointing to the console for its signing secret, never the secret itself (the first answer to the owner's signed-in session shows it once, under `webhook_secrets`)." },
|
|
1353
1404
|
}, {
|
|
1354
1405
|
webhook_secrets: {
|
|
@@ -1994,12 +2045,23 @@ const EXTENSIONS = {
|
|
|
1994
2045
|
parameters: [
|
|
1995
2046
|
{ name: "from", in: "query", required: false, description: "Runs started at or after this RFC 3339 date-time, to the millisecond (a finer fraction is a 400). Default no bound.", schema: { type: "string", format: "date-time" }, "x-agentrun-serve": "stats/2" },
|
|
1996
2047
|
{ name: "to", in: "query", required: false, description: "Runs started before this RFC 3339 date-time, to the millisecond (a finer fraction is a 400). Default no bound.", schema: { type: "string", format: "date-time" }, "x-agentrun-serve": "stats/2" },
|
|
1997
|
-
{ name: "agent", in: "query", required: false, description: "One agent's runs.", schema: ref("schemas/Id"), "x-agentrun-serve": "stats/2" },
|
|
2048
|
+
{ name: "agent", in: "query", required: false, description: "One agent's runs and associated source usage, or a connected session id to select that session's usage (with no recorded runs).", schema: ref("schemas/Id"), "x-agentrun-serve": "stats/2" },
|
|
1998
2049
|
],
|
|
1999
2050
|
responses: { "200": json(STATS, "The counts and the cost."), ...errors(400, 401, 429, 500) },
|
|
2000
2051
|
"x-agentrun-serve": "stats/1",
|
|
2001
2052
|
},
|
|
2002
2053
|
},
|
|
2054
|
+
"/capacity": {
|
|
2055
|
+
get: {
|
|
2056
|
+
operationId: "getCapacity", tags: ["capabilities"], summary: "The runs waiting and held, the live runners and the recent hand-backs",
|
|
2057
|
+
description: "Read from the store alone, so a server with no runner beside it (`--no-runner`, `AGENTRUN_API_ONLY=1`) answers for every runner on its store: what an operator or a scaler reads to size the runners. Counts, runner names and versions only, never a run, an agent or an address.",
|
|
2058
|
+
parameters: [
|
|
2059
|
+
{ name: "window", in: "query", required: false, description: "The hand-back window in minutes, from 1 to 1440. Default 15.", schema: { type: "integer", minimum: 1, maximum: 1440 } },
|
|
2060
|
+
],
|
|
2061
|
+
responses: { "200": json(CAPACITY, "The capacity, read now."), ...errors(400, 401, 429, 500) },
|
|
2062
|
+
"x-agentrun-serve": "capacity/1",
|
|
2063
|
+
},
|
|
2064
|
+
},
|
|
2003
2065
|
"/runs/{run_id}/graph": {
|
|
2004
2066
|
get: {
|
|
2005
2067
|
operationId: "getRunGraph", tags: ["runs"], summary: "A workflow run's graph, live",
|
|
@@ -2362,11 +2424,11 @@ const EXTENSIONS = {
|
|
|
2362
2424
|
},
|
|
2363
2425
|
put: {
|
|
2364
2426
|
operationId: "saveEmailAccount", tags: ["local"], summary: "Save this server's email account, its password sealed",
|
|
2365
|
-
description: "Replaces the account. A preset fills the servers (gmail: imap.gmail.com:993 and smtp.gmail.com:465; fastmail: imap.fastmail.com:993 and smtp.fastmail.com:465; icloud: imap.mail.me.com:993 and smtp.mail.me.com:587); `other` takes both. Every connection is TLS (993 and 465 from the start, any other port with STARTTLS required), never in the clear. The password is sealed under the server's seal key and is in no answer, event or log line.
|
|
2427
|
+
description: "Replaces the account. A preset fills the servers (gmail: imap.gmail.com:993 and smtp.gmail.com:465; fastmail: imap.fastmail.com:993 and smtp.fastmail.com:465; icloud: imap.mail.me.com:993 and smtp.mail.me.com:587); `other` takes both. Every connection is TLS (993 and 465 from the start, any other port with STARTTLS required), never in the clear. The password is sealed under the server's seal key and is in no answer, event or log line. Saved only once it signs in: the save signs in to IMAP and to SMTP as POST /settings/email/test does, sending nothing, and a sign-in either server refuses, or a server not reached, is 424 with nothing saved and the account kept before as it was. 422 by field for a body that does not read (before any sign-in), and outlook is refused in words. A secret write: the owner's signed-in session alone (ownerSession), never the token, which is 403 forbidden in words.",
|
|
2366
2428
|
"x-agentrun-secret": true,
|
|
2367
2429
|
security: [{ ownerSession: [] }],
|
|
2368
2430
|
requestBody: { required: true, content: { "application/json": { schema: { ...EMAIL_ACCOUNT_BODY, required: ["address", "password"] } } } },
|
|
2369
|
-
responses: { "200": json(EMAIL_ACCOUNT, "Saved."), ...errors(400, 401, 403, 415, 422, 429, 500, 503) },
|
|
2431
|
+
responses: { "200": json(EMAIL_ACCOUNT, "Saved: both servers signed in."), ...errors(400, 401, 403, 415, 422, 429, 500, 503), "424": { description: "`upstream_failed`: the account did not sign in (IMAP or SMTP refused it, or was not reached): nothing was saved, and the account kept before is as it was. The message says why in the test's words; `details.imap` and `details.smtp` are each half as POST /settings/email/test answers it ({ok, message}).", content: { "application/json": { schema: ref("schemas/Error") } } } },
|
|
2370
2432
|
"x-agentrun-serve": "email/1",
|
|
2371
2433
|
},
|
|
2372
2434
|
delete: {
|
|
@@ -3101,7 +3163,7 @@ const LEARNING_NULL = "Null for a run that does not learn: its agent's `learning
|
|
|
3101
3163
|
const LEARNING = {
|
|
3102
3164
|
oneOf: [
|
|
3103
3165
|
closedWith({
|
|
3104
|
-
state: { enum: [...LEARNING_STATES], description: "`seeded` when the run started from what its agent learned
|
|
3166
|
+
state: { enum: [...LEARNING_STATES], description: "`seeded` when the run started from what its agent learned. `reflecting` while its end-of-run step runs and until what it wrote is checked; a run reflecting after its job ended reads that end (`status`, `ended_at`, `result`), with `poll_after_ms` above 0 until its learning settles. `merged` once what it kept is on the folder's main; `dropped` when learning was skipped or refused, with `reason`." },
|
|
3105
3167
|
reason: LEARNING_REASON,
|
|
3106
3168
|
detail: { type: ["string", "null"], maxLength: 300, description: "Where the run's learning stands, in one sentence in a person's words (at most 300 characters, ending in an ellipsis when cut; a workflow's name in it is cut of the host's secrets as they are now before it is cut short, so none is shown in part), the same as its timeline row says: \"Started from 2 corrections and 1 workflow.\", \"Keeping what this run learned…\", \"Learned the workflow <name>.\", \"Kept your correction.\", \"Waiting for your OK: workflow <name>.\", \"Nothing new to keep from this run.\", \"Not kept: it didn't pass the checks (<rules>).\", \"Not kept: learning stopped (<why>).\" and so on. Never a secret or a value from the input, cut of the host's secrets as they are now. For a person: a client that acts on it reads `state` and `reason`, whose codes do not change." },
|
|
3107
3169
|
at: { type: "string", format: "date-time", description: "When the state last changed." },
|
|
@@ -3161,8 +3223,9 @@ const PENDING = {
|
|
|
3161
3223
|
id: { type: "string", description: "Answered at POST /runs/{run_id}/approvals/{id}; the same for the same call after a restart." },
|
|
3162
3224
|
tool: { type: "string" },
|
|
3163
3225
|
call_id: { type: "string", description: "The call's id, as its tool_result row's tool_use_id." },
|
|
3164
|
-
args_preview: { type: "string", maxLength: ARGS_PREVIEW_BYTES, description: `The call's arguments as JSON, cut at ${ARGS_PREVIEW_BYTES} bytes.` },
|
|
3165
|
-
summary: { type: "string", description: `What the call does, in words, where its tool says: email_send's "Send email to <to>, cc <cc>: <subject>", a blank line, then the text's first 300 characters; email_file's "File <message_id> under <to>".
|
|
3226
|
+
args_preview: { type: "string", maxLength: ARGS_PREVIEW_BYTES, description: `The call's arguments as JSON, cut at ${ARGS_PREVIEW_BYTES} bytes: the model's alone (why the call asks is asks_because).` },
|
|
3227
|
+
summary: { type: "string", description: `What the call does, in words, where its tool says: email_send's "Send email to <to>, cc <cc>: <subject>", a blank line, then the text's first 300 characters; email_file's "File <message_id> under <to>". Redacted as args_preview is.`, "x-agentrun-serve": "email/1" },
|
|
3228
|
+
asks_because: { type: "string", description: `Why the call asks though its setting allows it, a clause to say as "Asks because <why>.": its tool's own ask, email_send past ${SEND_CAP} sends in a run ("this run has sent 5 emails") or to anyone outside the thread of the email that started the run ("<address> is outside this email's thread"). Redacted as args_preview is. Absent on a call that asks by its setting.`, "x-agentrun-serve": "email/1" },
|
|
3166
3229
|
requested_at: { type: "string", format: "date-time" },
|
|
3167
3230
|
price: { oneOf: [{ type: "number", minimum: 0 }, { const: "not metered" }, { const: "priced by usage" }], description: "What the call costs, in USD, where its tool declares a price; \"not metered\" for an unpriced MCP call; \"priced by usage\" for a monid endpoint priced by usage: monid estimates its cost only when the call runs, after the allow (the call is held at that estimate, and a charge above it stops the run), so nothing is sent to monid while it waits. Absent when the tool names none." },
|
|
3168
3231
|
destructive: { const: true, description: `Present on an MCP tool's call that is destructive by the annotations the run pinned (destructiveHint true, readOnlyHint not true), and on a call whose allow lets such a tool run (a learned workflow's, its card naming the tool in \`mcp_calls\`): its allow needs \`confirm_destructive: true\`. Absent on every other call.`, "x-agentrun-serve": "allowreads/1" },
|
|
@@ -3349,6 +3412,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3349
3412
|
UsageLine: { unpriced_runs: { type: "integer", minimum: 0, description: "How many of the runs counted on this line have a cost no one knows on it: they add no dollars to `usd`, so no sum passes them off as $0.", "x-agentrun-serve": "costsofar/1" }, not_metered_calls: { type: "integer", minimum: 1, description: "On the `tools` meter's line, set when the runs counted made tool calls with no price (an MCP tool its owner set none for): how many. They are outside `usd`.", "x-agentrun-serve": "mcpservers/1" } },
|
|
3350
3413
|
Run: {
|
|
3351
3414
|
sdk: SDK_RUN,
|
|
3415
|
+
cli_learning: CLI_LEARNING_RUN,
|
|
3352
3416
|
native: NATIVE_RUN,
|
|
3353
3417
|
...RUN_FIELDS,
|
|
3354
3418
|
approvals: { enum: ["ask", "never"], description: "Whether the run runs unattended: its revision's approvals, as it started (a run keeps the revision it started on). never: each tool that would ask was allowed at its gate, a deny still refused; ask: a tool set to ask parks it for an approval.", "x-agentrun-serve": "unattended/1" },
|
|
@@ -3412,6 +3476,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3412
3476
|
},
|
|
3413
3477
|
RunSummary: {
|
|
3414
3478
|
sdk: SDK_RUN,
|
|
3479
|
+
cli_learning: CLI_LEARNING_RUN,
|
|
3415
3480
|
native: NATIVE_RUN,
|
|
3416
3481
|
...RUN_FIELDS,
|
|
3417
3482
|
effort: { $ref: "#/components/schemas/Effort", description: "The effort the run was started with, as the run shows it; absent when it was started with none.", "x-agentrun-serve": "effort/1" },
|
|
@@ -3533,6 +3598,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3533
3598
|
unreadable: { type: "boolean", const: true, description: "Present when this server cannot read the file: a tool in the run's box created it private (owner-only). Reading it answers 403 `system_file_forbidden` with `details.reason` `unreadable`.", "x-agentrun-serve": "unreadable/1" },
|
|
3534
3599
|
},
|
|
3535
3600
|
DefinitionInput: {
|
|
3601
|
+
cli_learning: CLI_LEARNING_BINDING,
|
|
3536
3602
|
sdk: { ...SDK_BINDING, "x-agentrun-serve": "sdk/1", description: "An existing backend SDK agent. Execution stays in its application; register tasks through /agents/{agent_id}/sdk-runs." },
|
|
3537
3603
|
native: NATIVE_BINDING,
|
|
3538
3604
|
model: { type: "string", description: "`provider/model-id`, the model an agentic revision runs on; absent, this host's default. A workflow revision keeps none.", "x-agentrun-serve": "model/1" },
|
|
@@ -3658,6 +3724,16 @@ const FIELD_EXTENSIONS = {
|
|
|
3658
3724
|
},
|
|
3659
3725
|
Capabilities: {
|
|
3660
3726
|
learning_model: { ...LEARNING_MODEL, "x-agentrun-serve": "learningmodel/1" },
|
|
3727
|
+
store_schema: {
|
|
3728
|
+
type: "object", additionalProperties: false, required: ["version", "runner_floor", "known"],
|
|
3729
|
+
properties: {
|
|
3730
|
+
version: { type: ["integer", "null"], description: "The store's schema version now, read at this answer; null when none is set up." },
|
|
3731
|
+
runner_floor: { type: ["integer", "null"], description: "The oldest schema version a runner's build must know to run on this store: the newest migration that breaks earlier runners (on SQLite, the version itself). A runner whose build knows less claims nothing more, hands its runs back and exits 3." },
|
|
3732
|
+
known: { type: "integer", description: "The schema version this server's build knows. A build that knows less than `version` cannot be deployed on this store: its server refuses it." },
|
|
3733
|
+
},
|
|
3734
|
+
description: "The store's schema and runner floor beside this server's own, for a deploy's check that refuses a build older than the store. `agentrun-serve store-schema --build` prints a build's `known` without a store.",
|
|
3735
|
+
"x-agentrun-serve": "runnerfloor/1",
|
|
3736
|
+
},
|
|
3661
3737
|
learning: {
|
|
3662
3738
|
type: "object", additionalProperties: false, required: ["pending", "approve"],
|
|
3663
3739
|
properties: {
|
|
@@ -3755,7 +3831,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3755
3831
|
allows: { type: "string", description: "What it allows, in an operator's words, with where it is safe to set." },
|
|
3756
3832
|
},
|
|
3757
3833
|
},
|
|
3758
|
-
description: "The switches only the server's operator sets, as environment variables at its start, by name: AGENTRUN_MCP_ALLOW_LOOPBACK (an MCP server on this machine's loopback), AGENTRUN_WEBHOOK_PRIVATE_TARGETS (the outbound webhook to a private network or this machine), AGENTRUN_BOX_ALLOW (the hosts a run's computer may reach) and AGENTRUN_BOX_CPUS, AGENTRUN_BOX_MEMORY and AGENTRUN_BOX_PIDS (a Docker computer's size). No route and no console page sets them, so no caller of the API can widen what the server reaches; each takes a restart. A refusal one of them causes names it, the value that allows it and the restart (`restart the server with AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1 to allow it, only on a machine you alone use`), its error code unchanged.",
|
|
3834
|
+
description: "The switches only the server's operator sets, as environment variables at its start, by name: AGENTRUN_MCP_ALLOW_LOOPBACK (an MCP server on this machine's loopback), AGENTRUN_WEBHOOK_PRIVATE_TARGETS (the outbound webhook to a private network or this machine), AGENTRUN_PRIVATE_HOSTS (the private-network hosts an owner may allow an MCP server or a calendar on: unset the owner's list, none, or address ranges), AGENTRUN_BOX_ALLOW (the hosts a run's computer may reach) and AGENTRUN_BOX_CPUS, AGENTRUN_BOX_MEMORY and AGENTRUN_BOX_PIDS (a Docker computer's size). No route and no console page sets them, so no caller of the API can widen what the server reaches; each takes a restart. A refusal one of them causes names it, the value that allows it and the restart (`restart the server with AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1 to allow it, only on a machine you alone use`), its error code unchanged.",
|
|
3759
3835
|
"x-agentrun-serve": "switches/1",
|
|
3760
3836
|
},
|
|
3761
3837
|
},
|
|
@@ -4418,8 +4494,8 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4418
4494
|
withAdapters(doc, adapters);
|
|
4419
4495
|
// Every server-wide pushed source's own hook, the registry's as a test's: this server's own, and listed so.
|
|
4420
4496
|
const hooks = serverHooks(adapters);
|
|
4421
|
-
Object.assign(doc.paths, hooks, NATIVE_PATHS, SDK_PATHS, OBSERVATION_PATHS);
|
|
4422
|
-
doc.info["x-agentrun-serve"].extensions.push(...Object.entries({ ...NATIVE_PATHS, ...SDK_PATHS, ...OBSERVATION_PATHS }).flatMap(([path, item]) => Object.keys(item).map(method => `${method.toUpperCase()} ${path}`)));
|
|
4497
|
+
Object.assign(doc.paths, hooks, NATIVE_PATHS, SDK_PATHS, CLI_LEARNING_PATHS, OBSERVATION_PATHS);
|
|
4498
|
+
doc.info["x-agentrun-serve"].extensions.push(...Object.entries({ ...NATIVE_PATHS, ...SDK_PATHS, ...CLI_LEARNING_PATHS, ...OBSERVATION_PATHS }).flatMap(([path, item]) => Object.keys(item).map(method => `${method.toUpperCase()} ${path}`)));
|
|
4423
4499
|
doc.info["x-agentrun-serve"].extensions.push(...Object.keys(hooks).map((path) => `POST ${path}`));
|
|
4424
4500
|
// purge/1, on every operation there is by now (each rewritten, never a shared constant's own object changed); `changed`
|
|
4425
4501
|
// is info's own list. Every route of a purged run or agent, and each that writes to an agent its body names (a trigger
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -19,6 +19,16 @@ export interface RunLaunch {
|
|
|
19
19
|
workflow_tools?: SdkWorkflowTool[];
|
|
20
20
|
workflow_adapters?: SdkWorkflowAdapter[];
|
|
21
21
|
};
|
|
22
|
+
readonly cli_learning?: {
|
|
23
|
+
runtime: "codex-cli" | "claude-code-cli";
|
|
24
|
+
connection_id: string;
|
|
25
|
+
connection_generation: string;
|
|
26
|
+
session_id: string;
|
|
27
|
+
turn_id: string;
|
|
28
|
+
instructions: string;
|
|
29
|
+
policy_complete: boolean;
|
|
30
|
+
model?: string;
|
|
31
|
+
};
|
|
22
32
|
readonly native?: NativeBinding;
|
|
23
33
|
/** The start request's body, as the person or trigger gave it, or an object a built-in run names. */
|
|
24
34
|
readonly input: unknown;
|
|
@@ -50,6 +60,10 @@ export interface RunLaunch {
|
|
|
50
60
|
/** The uploaded file ids the run was started with, in order (the create body's file_ids, already checked ready): the
|
|
51
61
|
* runner copies them into the run's work/inputs/ at its claim, as the old start copied them before the process ran. */
|
|
52
62
|
readonly files?: readonly string[];
|
|
63
|
+
/** The server copied `files` into the run's folder (work/inputs/) when it started the run, before its row was written:
|
|
64
|
+
* a run on an Archil disk (Mode 2, uploads-archil.ts placeRunFiles). Its claim reads no upload (uploads.ts
|
|
65
|
+
* filesToCopy). Absent: the claim copies them from the server's data directory, as before. */
|
|
66
|
+
readonly filesPlaced?: true;
|
|
53
67
|
/** The run's learning start, when its agent learns and the server's learning is on, decided once here so the runner reads
|
|
54
68
|
* no learning folder or git: `seed`, the learning commit's sha (or null when the seed could not be read); `section`,
|
|
55
69
|
* the exact # Learned text to lay into the prompt (its owner's corrections, learning.ts learnedSection); `workflows`,
|
package/dist/run-launch.js
CHANGED
|
@@ -54,6 +54,7 @@ export function launchBody(launch) {
|
|
|
54
54
|
return {
|
|
55
55
|
input: launch.input,
|
|
56
56
|
...(launch.sdk ? { sdk: launch.sdk } : {}),
|
|
57
|
+
...(launch.cli_learning ? { cli_learning: launch.cli_learning } : {}),
|
|
57
58
|
...(launch.native ? { native: launch.native } : {}),
|
|
58
59
|
title: launch.title,
|
|
59
60
|
...(launch.repo !== undefined ? { repo: launch.repo } : {}),
|
|
@@ -68,6 +69,7 @@ export function launchBody(launch) {
|
|
|
68
69
|
...(launch.boxAllow !== undefined ? { box_allow: launch.boxAllow } : {}),
|
|
69
70
|
...(launch.boxAllowSet ? { box_allow_set: true } : {}),
|
|
70
71
|
...(launch.files?.length ? { files: launch.files } : {}),
|
|
72
|
+
...(launch.filesPlaced ? { files_placed: true } : {}),
|
|
71
73
|
...(launch.learning ? { learning: { seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.noWorkflows ? { noWorkflows: true } : {}), ...(launch.learning.model ? { model: launch.learning.model } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}), ...(launch.learning.use ? { use: true } : {}) } } : {}),
|
|
72
74
|
...(launch.workflowFirst === false ? { workflow_first: false } : {}),
|
|
73
75
|
...(launch.replay ? { replay: { of: launch.replay.of, workflow: launch.replay.workflow, digest: launch.replay.digest } } : {}),
|
|
@@ -107,6 +109,7 @@ export function readLaunchBody(stored) {
|
|
|
107
109
|
input: stored.input,
|
|
108
110
|
...(isObject(stored.sdk) && sdkBindingOf(stored.sdk) && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
|
|
109
111
|
...(nativeOf(stored) ? { native: nativeOf(stored) } : {}),
|
|
112
|
+
...(isObject(stored.cli_learning) && ["codex-cli", "claude-code-cli"].includes(String(stored.cli_learning.runtime)) && typeof stored.cli_learning.instructions === "string" ? { cli_learning: stored.cli_learning } : {}),
|
|
110
113
|
title: typeof stored.title === "string" ? stored.title : "",
|
|
111
114
|
...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
|
|
112
115
|
place,
|
|
@@ -120,6 +123,7 @@ export function readLaunchBody(stored) {
|
|
|
120
123
|
...(boxAllow !== undefined ? { boxAllow } : {}),
|
|
121
124
|
...(stored.box_allow_set === true ? { boxAllowSet: true } : {}),
|
|
122
125
|
...(Array.isArray(stored.files) && stored.files.every((id) => typeof id === "string") ? { files: stored.files } : {}),
|
|
126
|
+
...(stored.files_placed === true ? { filesPlaced: true } : {}),
|
|
123
127
|
...(stored.learning !== undefined ? { learning: readLearning(stored.learning) ?? { seed: null, section: "" } } : {}),
|
|
124
128
|
...(stored.workflow_first === false ? { workflowFirst: false } : {}),
|
|
125
129
|
...(readReplay(stored.replay) ? { replay: readReplay(stored.replay) } : {}),
|
package/dist/run-view.d.ts
CHANGED
|
@@ -55,11 +55,13 @@ export type Status = "queued" | "working" | "paused" | "input_required" | "compl
|
|
|
55
55
|
export type State = "working" | "waiting" | "idle";
|
|
56
56
|
/** A tool call that waited for a person's approval, as the run's store has it (tool-gate.ts): `resolved` once the run's
|
|
57
57
|
* process acted on the answer. */
|
|
58
|
+
/** `asks_because`: why the gate asked a call its setting allows (its card's ASKED_BECAUSE), kept out of `args_json`. */
|
|
58
59
|
export type Approval = {
|
|
59
60
|
id: string;
|
|
60
61
|
tool: string;
|
|
61
62
|
call_id: string;
|
|
62
63
|
args_json: string;
|
|
64
|
+
asks_because?: string;
|
|
63
65
|
requested_at: string;
|
|
64
66
|
price?: ApprovalPrice;
|
|
65
67
|
destructive?: true;
|
package/dist/run-view.js
CHANGED
|
@@ -18,6 +18,7 @@ import { MIN_SECRET } from "./learn/secrets.js";
|
|
|
18
18
|
import { costWordsOf, usageParts } from "./runner/metrics.js";
|
|
19
19
|
import { KINDS } from "./runner/journal-kinds.js";
|
|
20
20
|
import { ASKED_BECAUSE, ENDED_WHILE_WAITING, STOPPED_WHILE_WAITING } from "./refusal-words.js";
|
|
21
|
+
import { isObject } from "./validate.js";
|
|
21
22
|
/** The run's newest usage row, which carries its cost. */
|
|
22
23
|
const usageOf = (rows) => rows.findLast((r) => r.kind === "usage");
|
|
23
24
|
/** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
|
|
@@ -135,11 +136,15 @@ export function asksOf(entries) {
|
|
|
135
136
|
if (typeof d?.callId !== "string" || map.has(d.callId))
|
|
136
137
|
continue;
|
|
137
138
|
const price = priceOfAsk(d.price);
|
|
139
|
+
// The card's reason for asking a call its setting allows is the gate's, never one of the call's arguments.
|
|
140
|
+
const raw = d.args ?? {};
|
|
141
|
+
const { [ASKED_BECAUSE]: because, ...args } = isObject(raw) ? raw : {};
|
|
138
142
|
map.set(d.callId, {
|
|
139
143
|
id: d.callId,
|
|
140
144
|
tool: d.tool,
|
|
141
145
|
call_id: d.callId,
|
|
142
|
-
args_json: JSON.stringify(
|
|
146
|
+
args_json: JSON.stringify(isObject(raw) ? args : raw) ?? "{}",
|
|
147
|
+
...(typeof because === "string" ? { asks_because: because } : {}),
|
|
143
148
|
requested_at: d.requestedAt,
|
|
144
149
|
...(price !== undefined ? { price } : {}),
|
|
145
150
|
...(d.destructive === true ? { destructive: true } : {}),
|
|
@@ -372,10 +377,11 @@ export const pendingOf = (rows) => {
|
|
|
372
377
|
return last?.kind === "waiting" ? { kind: "question", question: last.text ?? last.summary ?? "", asked_at: last.timestamp } : null;
|
|
373
378
|
};
|
|
374
379
|
/** The run's pending approval (`pending`, kind approval): the call that waits; else undefined. */
|
|
375
|
-
/** A call's approval summary, where its tool has one (tools.ts ToolEntry.approvalSummary),
|
|
376
|
-
* asked about it itself (the card's ASKED_BECAUSE, the gate's), redacted as its arguments are. */
|
|
380
|
+
/** A call's approval summary, where its tool has one (tools.ts ToolEntry.approvalSummary), redacted as its arguments are. */
|
|
377
381
|
function summaryOf(approval, redact) {
|
|
378
382
|
const summarize = toolOf(approval.tool)?.approvalSummary;
|
|
383
|
+
if (!summarize)
|
|
384
|
+
return {};
|
|
379
385
|
let args;
|
|
380
386
|
try {
|
|
381
387
|
args = JSON.parse(approval.args_json);
|
|
@@ -383,13 +389,12 @@ function summaryOf(approval, redact) {
|
|
|
383
389
|
catch {
|
|
384
390
|
return {};
|
|
385
391
|
}
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
return parts.length ? { summary: redact(parts.join("\n\n")) } : {};
|
|
392
|
+
const summary = summarize(args);
|
|
393
|
+
return summary === undefined ? {} : { summary: redact(summary) };
|
|
389
394
|
}
|
|
390
395
|
export const approvalOf = (run, redact) => {
|
|
391
396
|
const waiting = waitingApproval(run);
|
|
392
|
-
return waiting ? { kind: "approval", id: waiting.id, tool: waiting.tool, call_id: waiting.call_id, args_preview: shownArgs(waiting, redact), ...summaryOf(waiting, redact), requested_at: waiting.requested_at, ...(waiting.price !== undefined ? { price: waiting.price } : {}), ...(waiting.destructive ? { destructive: true } : {}) } : undefined;
|
|
397
|
+
return waiting ? { kind: "approval", id: waiting.id, tool: waiting.tool, call_id: waiting.call_id, args_preview: shownArgs(waiting, redact), ...summaryOf(waiting, redact), ...(waiting.asks_because !== undefined ? { asks_because: redact(waiting.asks_because) } : {}), requested_at: waiting.requested_at, ...(waiting.price !== undefined ? { price: waiting.price } : {}), ...(waiting.destructive ? { destructive: true } : {}) } : undefined;
|
|
393
398
|
};
|
|
394
399
|
/** A run whose agent asked for the person in its browser waits on their hand-back: what it asked them to do, when it is
|
|
395
400
|
* done, and when the ask expires. Never the session's tag or the live view's link. The two texts are the model's, so
|
|
@@ -1101,13 +1101,19 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1101
1101
|
return { later: "the run is waiting on a person: the message runs as a turn of its own after the answer" };
|
|
1102
1102
|
// A grade's feedback round (feedback-round.ts): the run opened again on the grade's words, which are never a turn of
|
|
1103
1103
|
// the job's. Kept on the root as a FEEDBACK entry, whose commit takes the row; the claim goes to its end-of-run turn.
|
|
1104
|
+
// The same commit keeps the end the run had when the grade opened it as its job's end (KINDS.jobEnd): from the taking
|
|
1105
|
+
// on, the round is a look-back with its job's end kept, which every reader serves and its claim ends on (jobEndKept).
|
|
1104
1106
|
const fed = reopen && !reopen.sent && (session.state === "idle" || session.state === "new") ? feedbackOf(command.body) : undefined;
|
|
1105
1107
|
if (fed && reopen && harness && root) {
|
|
1106
1108
|
const [on, theRoot, mine] = [harness, root, reopen];
|
|
1107
1109
|
const taken = gate.expect(writesEntry(KINDS.feedback, (data) => data.requestId === requestId), { take: [command.id] });
|
|
1108
1110
|
taken.catch(() => undefined);
|
|
1109
|
-
|
|
1110
|
-
mine.
|
|
1111
|
+
const { kept: { endedAt, ...end }, ...round } = fed;
|
|
1112
|
+
mine.feedback = round;
|
|
1113
|
+
mine.sent = on.commit(async (tx) => {
|
|
1114
|
+
await tx.appendEntry(theRoot.id, { kind: KINDS.feedback, data: { ...round, requestId, at: now() } });
|
|
1115
|
+
await tx.appendEntry(theRoot.id, { kind: KINDS.jobEnd, data: jobEndOf(end, undefined, endedAt) });
|
|
1116
|
+
}, context).then(() => undefined);
|
|
1111
1117
|
mine.placed?.();
|
|
1112
1118
|
try {
|
|
1113
1119
|
await mine.sent;
|
|
@@ -2756,16 +2762,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2756
2762
|
let parkOn;
|
|
2757
2763
|
/** The ask_person call the run waits on in its claim, while it does. */
|
|
2758
2764
|
let waitingOn;
|
|
2759
|
-
/** When the job's end was, once it is kept (keepJobEnd
|
|
2760
|
-
*
|
|
2765
|
+
/** When the job's end was, once it is kept (keepJobEnd; a grade's round's, by its steer's taking): the look-back
|
|
2766
|
+
* after it never moves it, and its end is written at that time. */
|
|
2761
2767
|
let keptAt;
|
|
2762
|
-
if (alone && lookingBack)
|
|
2768
|
+
if (alone && (lookingBack || feedbackNow))
|
|
2763
2769
|
({ end: data, failedWith, endedAt: keptAt } = await jobEndKept(root));
|
|
2764
|
-
else if (alone && feedbackNow?.kept) {
|
|
2765
|
-
const { endedAt, ...end } = feedbackNow.kept;
|
|
2766
|
-
data = end;
|
|
2767
|
-
keptAt = endedAt;
|
|
2768
|
-
}
|
|
2769
2770
|
else if (alone)
|
|
2770
2771
|
data = { state: "ended" };
|
|
2771
2772
|
else
|
|
@@ -3001,15 +3002,14 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3001
3002
|
// takes the run past its cap is the learning's (askEndOfRun reads overCap after each of its turns), never the run's.
|
|
3002
3003
|
// That end is kept before the step's first ask, so a claim that finds its turn open ends the run on it (jobEndKept).
|
|
3003
3004
|
// Kept with its time: from then on every reader serves it, and the run's end is written at it (writeEnd `keptAt`).
|
|
3004
|
-
if (!lookingBack)
|
|
3005
|
-
keptAt = await keepJobEnd(harness, root, spec, data, failedWith
|
|
3005
|
+
if (!lookingBack && !feedbackNow)
|
|
3006
|
+
keptAt = await keepJobEnd(harness, root, spec, data, failedWith);
|
|
3006
3007
|
const step = await endOfRunStep(claim, spec, data.state === "failed" ? "failed" : "completed", overCap, keptAt);
|
|
3007
3008
|
// A stop or cancel the runner took during the step (one that raced the read refusing it, its row written while the
|
|
3008
3009
|
// run still read as going on) cuts the look-back alone: the run ends on its job's end, the row taken by that end.
|
|
3009
|
-
|
|
3010
|
-
return await writeEnd(harness, root, gate, data, [step.commandId], await cutRows(claim, spec, "stopped-looking"), failedWith, keptAt);
|
|
3010
|
+
// A step that runs always has its job's end kept (`keptAt`), so a stop there never ends the run stopped.
|
|
3011
3011
|
if (step.kind === "stopped")
|
|
3012
|
-
return await writeEnd(harness, root, gate,
|
|
3012
|
+
return await writeEnd(harness, root, gate, data, [step.commandId], await cutRows(claim, spec, "stopped-looking"), failedWith, keptAt);
|
|
3013
3013
|
if (step.kind === "interrupted")
|
|
3014
3014
|
return await interrupted(stopReason?.kind ?? "its claim's signal aborted");
|
|
3015
3015
|
return await writeEnd(harness, root, gate, data, [], step.also, failedWith, keptAt);
|
|
@@ -3396,20 +3396,23 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3396
3396
|
return turnOfRequest(on, conversation, last.requestId);
|
|
3397
3397
|
}
|
|
3398
3398
|
/** How the job's own turn ended (`data`, and a CLI's error answer `failedWith`), as this claim decided it, kept on the
|
|
3399
|
-
* root before the end-of-run step asks its first turn (KINDS.jobEnd), for a run with a step to ask (stepOf).
|
|
3400
|
-
*
|
|
3401
|
-
|
|
3402
|
-
async function keepJobEnd(on, conversation, spec, data, failedWith, at) {
|
|
3399
|
+
* root before the end-of-run step asks its first turn (KINDS.jobEnd), for a run with a step to ask (stepOf). Kept with
|
|
3400
|
+
* its time, now, which it answers; with no step to ask, nothing is kept. */
|
|
3401
|
+
async function keepJobEnd(on, conversation, spec, data, failedWith) {
|
|
3403
3402
|
if (!stepOf(spec))
|
|
3404
|
-
return
|
|
3405
|
-
const
|
|
3406
|
-
const endedAt = at ?? now();
|
|
3407
|
-
const kept = { end, ...(failedWith !== undefined ? { failedWith } : {}), endedAt };
|
|
3403
|
+
return undefined;
|
|
3404
|
+
const kept = jobEndOf(data, failedWith, now());
|
|
3408
3405
|
await on.commit((tx) => tx.appendEntry(conversation.id, { kind: KINDS.jobEnd, data: kept }), context);
|
|
3409
|
-
return endedAt;
|
|
3406
|
+
return kept.endedAt;
|
|
3407
|
+
}
|
|
3408
|
+
/** A job's end as KINDS.jobEnd keeps it: its summary cut of every secret the runner holds, as every summary is when
|
|
3409
|
+
* served. */
|
|
3410
|
+
function jobEndOf(data, failedWith, endedAt) {
|
|
3411
|
+
const end = data.summary !== undefined && deps.redact ? { ...data, summary: deps.redact(data.summary) } : data;
|
|
3412
|
+
return { end, ...(failedWith !== undefined ? { failedWith } : {}), endedAt };
|
|
3410
3413
|
}
|
|
3411
|
-
/** The job's end for a claim that found the end-of-run turn open (lookingBackOpen)
|
|
3412
|
-
* follow-up's round keeps its own), never worked out again. */
|
|
3414
|
+
/** The job's end for a claim that found the end-of-run turn open (lookingBackOpen), or a grade's round (its steer's
|
|
3415
|
+
* taking kept it): the newest one kept (a follow-up's round keeps its own), never worked out again. */
|
|
3413
3416
|
async function jobEndKept(conversation) {
|
|
3414
3417
|
const kept = (await entriesOf(gate.journal, conversation.id, context)).filter((entry) => entry.kind === KINDS.jobEnd).at(-1);
|
|
3415
3418
|
if (!kept)
|
|
@@ -46,7 +46,7 @@ import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
|
46
46
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
47
47
|
import { COMPUTER_ROOT, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
48
48
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
49
|
-
import { placeRunInputs } from "../uploads.js";
|
|
49
|
+
import { filesToCopy, placeRunInputs } from "../uploads.js";
|
|
50
50
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
51
51
|
import { UNREADABLE_SIGN_IN } from "../run-view.js";
|
|
52
52
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
@@ -311,7 +311,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
311
311
|
// a copy that fails ends the run failed, saying why. A run's own process copies nothing: its runner placed them before
|
|
312
312
|
// the process started (run-child-host.ts), as the server's held uploads are never the run's to read.
|
|
313
313
|
if (!(deps.sealKey === undefined && runnerSeam()))
|
|
314
|
-
await placeRunInputs(deps.data, claim.runId, ws.workspace, launch
|
|
314
|
+
await placeRunInputs(deps.data, claim.runId, ws.workspace, filesToCopy(launch), messageText(launch.input));
|
|
315
315
|
// The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
|
|
316
316
|
// turn, with the GitHub App's read-only token for that one repository (or none); the run is told what it holds, or why
|
|
317
317
|
// there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
|
package/dist/runner/beside.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RunnerEvent } from "./runner.js";
|
|
1
2
|
/** How long a busy run may finish its turn when the server stops, unless --drain-timeout says (cli.ts). */
|
|
2
3
|
export declare const DRAIN_TIMEOUT = "30s";
|
|
3
4
|
/** The runner beside a server holds what the server's own flags say (cli.ts): at most --max-runs runs at once (the same
|
|
@@ -51,6 +52,18 @@ export declare function runnerBeside(dataDir: string, { loops, loopsTold, drainM
|
|
|
51
52
|
runner: Awaited<ReturnType<typeof import("./runner.js")["startRunner"]>>;
|
|
52
53
|
close: () => Promise<void>;
|
|
53
54
|
}>;
|
|
55
|
+
/** The lines runner `name` beside a server says for `event`, in order, each with whether it goes to stderr (`error`): its
|
|
56
|
+
* metric line (runner-metrics.ts metricLine: a claim, a hand-back by cause, a lost claim, the drain), then its trouble
|
|
57
|
+
* (main.ts troubleLine: a lost claim, an error) or else its run's start or end (print.ts runLine). A lost claim says
|
|
58
|
+
* both its metric and its trouble. The three are handed in, as runnerBeside imports them on its start. */
|
|
59
|
+
export declare function besideLines(name: string, event: RunnerEvent, say: {
|
|
60
|
+
metricLine: (name: string, event: RunnerEvent) => string | undefined;
|
|
61
|
+
troubleLine: (name: string, event: RunnerEvent) => string | undefined;
|
|
62
|
+
runLine: (event: RunnerEvent) => string | undefined;
|
|
63
|
+
}): {
|
|
64
|
+
line: string;
|
|
65
|
+
error: boolean;
|
|
66
|
+
}[];
|
|
54
67
|
/** A server and one runner beside it, both in this process, as the CLI's start composes them (cli.ts): the runner holds
|
|
55
68
|
* what the server's options say (besideRunnerOptions) and sees the server's test switches (fauxEnvOf), so a --faux
|
|
56
69
|
* server's runs reach its fakes. For a launcher that starts serve in-process (a demo, a smoke): a server alone leaves
|
package/dist/runner/beside.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the template eval's in-process server (template-eval.ts), which would otherwise leave every run it starts queued.
|
|
3
3
|
import { maxRunsOf } from "../host.js";
|
|
4
4
|
import { durationMs } from "../print.js";
|
|
5
|
-
import { runnerCloseBoundMs } from "./runner.js";
|
|
5
|
+
import { RUNNER_LOOPS, runnerCloseBoundMs } from "./runner.js";
|
|
6
6
|
/** How long a busy run may finish its turn when the server stops, unless --drain-timeout says (cli.ts). */
|
|
7
7
|
export const DRAIN_TIMEOUT = "30s";
|
|
8
8
|
/** The runner beside a server holds what the server's own flags say (cli.ts): at most --max-runs runs at once (the same
|
|
@@ -107,14 +107,11 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
|
|
|
107
107
|
// are said in its name as the runner subcommand says them (main.ts troubleLine: a lost claim on stdout, an error on
|
|
108
108
|
// stderr), so a lapse of its claims shows its cause.
|
|
109
109
|
const { runLine } = await import("../print.js");
|
|
110
|
+
const { metricLine, startRunnerGauge } = await import("./runner-metrics.js");
|
|
110
111
|
const name = runnerName();
|
|
111
112
|
const said = (event) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
return void (onLine ?? (event.type === "error" ? console.error : console.log))(trouble);
|
|
115
|
-
const line = runLine(event);
|
|
116
|
-
if (line)
|
|
117
|
-
(onLine ?? console.log)(line);
|
|
113
|
+
for (const { line, error } of besideLines(name, event, { metricLine, troubleLine, runLine }))
|
|
114
|
+
(onLine ?? (error ? console.error : console.log))(line);
|
|
118
115
|
// The server's anonymous counts (telemetry.ts) hear a run's end: its state alone, never which run or agent.
|
|
119
116
|
if (event.type === "ended")
|
|
120
117
|
onRunEnded?.(event.status);
|
|
@@ -130,7 +127,29 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
|
|
|
130
127
|
// Its close waits for any first-use install its claims let go of to stop (its npm ended) before it lets go of the data.
|
|
131
128
|
const { claimInstallsStopped } = await import("../harness-install.js");
|
|
132
129
|
// The janitor's sweep is cut and waited for on a bound of its own, beside the runner's close, never before it.
|
|
133
|
-
|
|
130
|
+
// Its gauge (runner-metrics.ts): the runs it holds of its loops, and the process's memory (the server's with it), every
|
|
131
|
+
// minute until its close.
|
|
132
|
+
const gauge = startRunnerGauge({ runner: name, held: () => runner.held().length, slots: held ?? RUNNER_LOOPS, write: (line) => (onLine ?? console.log)(line) });
|
|
133
|
+
return { runner, close: async () => { gauge.stop(); await Promise.all([swept?.close(), runner.close()]); await claimInstallsStopped(); await store.close(); seal.release(); } };
|
|
134
|
+
}
|
|
135
|
+
/** The lines runner `name` beside a server says for `event`, in order, each with whether it goes to stderr (`error`): its
|
|
136
|
+
* metric line (runner-metrics.ts metricLine: a claim, a hand-back by cause, a lost claim, the drain), then its trouble
|
|
137
|
+
* (main.ts troubleLine: a lost claim, an error) or else its run's start or end (print.ts runLine). A lost claim says
|
|
138
|
+
* both its metric and its trouble. The three are handed in, as runnerBeside imports them on its start. */
|
|
139
|
+
export function besideLines(name, event, say) {
|
|
140
|
+
const lines = [];
|
|
141
|
+
const metric = say.metricLine(name, event);
|
|
142
|
+
if (metric)
|
|
143
|
+
lines.push({ line: metric, error: false });
|
|
144
|
+
const trouble = say.troubleLine(name, event);
|
|
145
|
+
if (trouble)
|
|
146
|
+
lines.push({ line: trouble, error: event.type === "error" });
|
|
147
|
+
else {
|
|
148
|
+
const line = say.runLine(event);
|
|
149
|
+
if (line)
|
|
150
|
+
lines.push({ line, error: false });
|
|
151
|
+
}
|
|
152
|
+
return lines;
|
|
134
153
|
}
|
|
135
154
|
/** A server and one runner beside it, both in this process, as the CLI's start composes them (cli.ts): the runner holds
|
|
136
155
|
* what the server's options say (besideRunnerOptions) and sees the server's test switches (fauxEnvOf), so a --faux
|
|
@@ -38,7 +38,7 @@ import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
|
|
|
38
38
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
39
39
|
import { readsFiles, systemOf } from "../skills.js";
|
|
40
40
|
import { DATA_ENV } from "../server-fs.js";
|
|
41
|
-
import { placeRunInputs } from "../uploads.js";
|
|
41
|
+
import { filesToCopy, placeRunInputs } from "../uploads.js";
|
|
42
42
|
import { recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
43
43
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
44
44
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
@@ -361,7 +361,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
361
361
|
holds.hold({ checkout });
|
|
362
362
|
// A run's own process copies nothing: its runner placed them before the process started (run-child-host.ts).
|
|
363
363
|
if (!(deps.sealKey === undefined && runnerSeam()))
|
|
364
|
-
await placeRunInputs(deps.data, claim.runId, ws.workspace, launch
|
|
364
|
+
await placeRunInputs(deps.data, claim.runId, ws.workspace, filesToCopy(launch), messageText(launch.input));
|
|
365
365
|
// The run's skills and its learning seed laid before its computer exists, as the pi spec lays them (adapter-run-spec.ts):
|
|
366
366
|
// on Archil the computer's mount takes the disk's write delegation, and a lay over the disk's file API after it is
|
|
367
367
|
// refused (409) while the mount holds it.
|