@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +170 -0
- package/README.md +158 -52
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -17
- package/dist/cap.js +0 -91
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-view.d.ts +13 -0
- package/dist/computer-view.js +50 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +33 -7
- package/dist/computers.js +50 -8
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +53 -25
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +1 -1
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/learn/check.d.ts +4 -1
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +4 -2
- package/dist/learn/commit.js +5 -5
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +22 -1
- package/dist/learn/reflect.d.ts +10 -1
- package/dist/learn/reflect.js +14 -4
- package/dist/learn/skills.d.ts +33 -5
- package/dist/learn/skills.js +53 -7
- package/dist/learned-workflow.d.ts +24 -0
- package/dist/learned-workflow.js +66 -3
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +25 -2
- package/dist/learning-routes.js +39 -6
- package/dist/learning-words.d.ts +6 -0
- package/dist/learning-words.js +6 -0
- package/dist/learning.d.ts +28 -15
- package/dist/learning.js +84 -44
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +19 -2
- package/dist/mcp-probe.js +44 -9
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +112 -20
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.js +23 -10
- package/dist/openapi.js +386 -21
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +13 -5
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-launch.d.ts +14 -2
- package/dist/run-launch.js +9 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-view.d.ts +3 -3
- package/dist/run-view.js +14 -7
- package/dist/runner/adapter-loop.d.ts +23 -7
- package/dist/runner/adapter-loop.js +648 -62
- package/dist/runner/adapter-run-spec.d.ts +11 -3
- package/dist/runner/adapter-run-spec.js +77 -22
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +9 -4
- package/dist/runner/adapters/pi.js +76 -14
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +20 -3
- package/dist/runner/cli-run-spec.js +113 -43
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.js +80 -14
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +20 -1
- package/dist/runner/journal-kinds.js +14 -0
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +22 -1
- package/dist/runner/learning-end.js +92 -12
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +67 -7
- package/dist/runner/learning-loop.js +173 -21
- package/dist/runner/learning-seed.d.ts +7 -0
- package/dist/runner/learning-seed.js +13 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +8 -1
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +2 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +10 -7
- package/dist/runner/mcp-claim.js +113 -24
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +5 -5
- package/dist/runner/mcp-run.js +15 -3
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +12 -2
- package/dist/runner/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/reflect-hook.d.ts +18 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +184 -15
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.js +3 -1
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-spec.d.ts +14 -2
- package/dist/runner/workflow-spec.js +56 -20
- package/dist/runs-over-store.d.ts +6 -1
- package/dist/runs-over-store.js +38 -9
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +43 -14
- package/dist/server.js +472 -126
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +1 -1
- package/dist/store/schema.js +77 -8
- package/dist/store/sqlite/run-patch.d.ts +7 -5
- package/dist/store/sqlite/run-patch.js +28 -13
- package/dist/store/sqlite/store.js +272 -54
- package/dist/store/store.d.ts +268 -9
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +73 -15
- package/dist/store-reads/learning.d.ts +20 -4
- package/dist/store-reads/learning.js +74 -18
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +26 -11
- package/dist/template-eval.js +6 -4
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/timeline/timeline.d.ts +27 -0
- package/dist/timeline/timeline.js +10 -9
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-budget.d.ts +19 -7
- package/dist/tool-budget.js +14 -8
- package/dist/tool-gate.d.ts +16 -9
- package/dist/tool-gate.js +53 -42
- package/dist/tool-plane.d.ts +16 -12
- package/dist/tool-plane.js +9 -4
- package/dist/tools.d.ts +13 -4
- package/dist/tools.js +13 -4
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +25 -6
- package/dist/trigger-signatures.js +41 -7
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.js +11 -1
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +16 -9
- package/dist/workspace/computer-deps.js +19 -7
- package/dist/workspace/computer-for-claim.d.ts +17 -8
- package/dist/workspace/computer-for-claim.js +62 -21
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +3 -0
- package/dist/workspace/resolve-computer.js +8 -2
- package/dist/workspace/run-tools.d.ts +32 -15
- package/dist/workspace/run-tools.js +23 -30
- package/package.json +19 -16
- package/templates/market-monitor/agent.md +1 -1
- package/dist/console/assets/index-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
package/dist/run-repo.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The repository a run a person starts reaches (the start body's `repo`): what an agent is bound to, and which one a start
|
|
2
|
+
// may name. A run a GitHub trigger starts has its repository from the signed event; a run started by hand has none unless
|
|
3
|
+
// the start gives it, since the GitHub App's token is made for one repository and never for all it covers.
|
|
4
|
+
//
|
|
5
|
+
// An agent is bound to the repositories its GitHub triggers take events from: each rule's `where` condition on
|
|
6
|
+
// /repository/full_name, its `in` list. A start's `repo` must be one of them, so a start never reaches a repository the
|
|
7
|
+
// agent's own triggers do not; naming one the agent is not bound to is refused in words. A start that names none takes the
|
|
8
|
+
// agent's repository when it is bound to exactly one. A trigger rule with no such condition takes every repository the App
|
|
9
|
+
// is installed on: the agent is then bound to all of them (`open`), a start may name any, and none is taken by default.
|
|
10
|
+
import { isObject } from "./validate.js";
|
|
11
|
+
/** `owner/name`, as github.ts githubTargetOf reads a repository. */
|
|
12
|
+
export const REPO_NAME = /^[^/\s]+\/[^/\s]+$/;
|
|
13
|
+
const FULL_NAME = "/repository/full_name";
|
|
14
|
+
/** `agentId`'s binding, from the triggers (their source and target as stored): none (no repos, not open) for an agent no
|
|
15
|
+
* GitHub trigger starts. */
|
|
16
|
+
export function bindingOf(triggers, agentId) {
|
|
17
|
+
const repos = [];
|
|
18
|
+
let open = false;
|
|
19
|
+
for (const { source, target } of triggers) {
|
|
20
|
+
if (!isObject(target) || target.kind !== "start_run" || target.agent_id !== agentId)
|
|
21
|
+
continue;
|
|
22
|
+
if (!isObject(source) || source.kind !== "github")
|
|
23
|
+
continue;
|
|
24
|
+
const rules = Array.isArray(source.accept) ? source.accept : [];
|
|
25
|
+
// A github trigger with no accept takes every event the App sends, from any repository.
|
|
26
|
+
if (!rules.length)
|
|
27
|
+
open = true;
|
|
28
|
+
for (const rule of rules) {
|
|
29
|
+
// A rule's conditions all hold: each `in` list on the repository narrows the rule, so they are intersected; rules
|
|
30
|
+
// are alternatives, so what they name is joined.
|
|
31
|
+
let named;
|
|
32
|
+
for (const c of isObject(rule) && Array.isArray(rule.where) ? rule.where : []) {
|
|
33
|
+
if (!isObject(c) || c.pointer !== FULL_NAME || !Array.isArray(c.in))
|
|
34
|
+
continue;
|
|
35
|
+
const list = c.in.filter((v) => typeof v === "string" && REPO_NAME.test(v));
|
|
36
|
+
named = named === undefined ? list : named.filter((r) => list.some((l) => l.toLowerCase() === r.toLowerCase()));
|
|
37
|
+
}
|
|
38
|
+
if (named === undefined)
|
|
39
|
+
open = true;
|
|
40
|
+
for (const repo of named ?? [])
|
|
41
|
+
if (!repos.some((r) => r.toLowerCase() === repo.toLowerCase()))
|
|
42
|
+
repos.push(repo);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { repos, open };
|
|
46
|
+
}
|
|
47
|
+
/** The repository a manual start runs against: `named` (the body's `repo`) when it is one the agent is bound to, else the
|
|
48
|
+
* agent's one repository when `named` is absent and the first message names none (`words`: it names its own). Undefined
|
|
49
|
+
* when the run is to have none. `refused`: why a named one is not allowed, in words for the 422. */
|
|
50
|
+
export function repoOf(binding, named, words) {
|
|
51
|
+
if (named === undefined)
|
|
52
|
+
return !binding.open && binding.repos.length === 1 && !words ? { repo: binding.repos[0] } : {};
|
|
53
|
+
const bound = binding.repos.find((r) => r.toLowerCase() === named.toLowerCase());
|
|
54
|
+
if (bound)
|
|
55
|
+
return { repo: bound };
|
|
56
|
+
if (binding.open)
|
|
57
|
+
return { repo: named };
|
|
58
|
+
return {
|
|
59
|
+
refused: binding.repos.length
|
|
60
|
+
? `This agent is bound to ${binding.repos.join(", ")}, not ${named}: start the run with one of those, or leave repo out.`
|
|
61
|
+
: `This agent is bound to no GitHub repository, so a run of it cannot name ${named}: bind it with a GitHub trigger whose accept names the repository, or write the repository's URL in the run's first message.`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type TimelineEvent } from "./timeline/index.js";
|
|
3
3
|
import { type ItemStatus } from "./learning.js";
|
|
4
4
|
import { type SignInReader } from "./run-view.js";
|
package/dist/run-view.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export type Approval = {
|
|
|
65
65
|
resolved?: true;
|
|
66
66
|
};
|
|
67
67
|
/** `args_shown`: the call's arguments as the server shows them (shownArgs), which the gate's resume message names. */
|
|
68
|
-
/** `by`: "message", a deny a person's message gave while the call waited (Runs.message). */
|
|
68
|
+
/** `by`: "message", a deny a person's message gave while the call waited (Runs.message); "setting", the allow the tool's setting gave an ask that waited (the person flipped the tool to allow). */
|
|
69
69
|
/** `superseded`: the answer a stop or a cancel overrode before the run's process acted on it, kept as it was given. */
|
|
70
70
|
/** `ended`: a withdrawal by a run that ended (completed or failed) with the call waiting, which nobody stopped. */
|
|
71
71
|
export type ApprovalAnswer = {
|
|
@@ -73,12 +73,12 @@ export type ApprovalAnswer = {
|
|
|
73
73
|
note?: string;
|
|
74
74
|
answered_at: string;
|
|
75
75
|
args_shown?: string;
|
|
76
|
-
by?: "message";
|
|
76
|
+
by?: "message" | "setting";
|
|
77
77
|
superseded?: {
|
|
78
78
|
decision: string;
|
|
79
79
|
answered_at: string;
|
|
80
80
|
note?: string;
|
|
81
|
-
by?: "message";
|
|
81
|
+
by?: "message" | "setting";
|
|
82
82
|
};
|
|
83
83
|
ended?: true;
|
|
84
84
|
};
|
package/dist/run-view.js
CHANGED
|
@@ -170,7 +170,7 @@ export function answersOf(entries, { final } = {}) {
|
|
|
170
170
|
continue;
|
|
171
171
|
const superseded = given ? { superseded: { decision: given.decision, answered_at: given.answered_at, ...(given.note !== undefined ? { note: given.note } : {}), ...(given.by ? { by: given.by } : {}) } } : {};
|
|
172
172
|
// A deny a person's message gave keeps that it was (`by`): its row reads "Declined by your message".
|
|
173
|
-
out[d.callId] = { decision, ...(d.note !== undefined ? { note: d.note } : {}), answered_at: d.answeredAt ?? "", ...(decision === "deny" && d.by === "message" ? { by: "message" } : {}), ...superseded };
|
|
173
|
+
out[d.callId] = { decision, ...(d.note !== undefined ? { note: d.note } : {}), answered_at: d.answeredAt ?? "", ...(decision === "deny" && d.by === "message" ? { by: "message" } : decision === "allow" && d.by === "setting" ? { by: "setting" } : {}), ...superseded };
|
|
174
174
|
}
|
|
175
175
|
// How the run ended after each entry: the state of the first agentrun.end at or after it, else the final row's.
|
|
176
176
|
let endedAs = final;
|
|
@@ -569,14 +569,15 @@ export function outcomeSays(tool, answer, failed, redact) {
|
|
|
569
569
|
const note = noteShown(answer.note, redact);
|
|
570
570
|
return note ? `AgentRun: You declined ${tool}: ${note}` : `AgentRun: You declined ${tool}.`;
|
|
571
571
|
}
|
|
572
|
-
|
|
572
|
+
const ran = answer.by === "setting" ? "ran, as its setting allows it" : "ran once you allowed it";
|
|
573
|
+
return `AgentRun: ${tool} ${ran}${failed ? ", and failed" : "; its result went to the agent"}`;
|
|
573
574
|
}
|
|
574
575
|
/** What a person reads when they open the outcome row: the outcome, then the call's result (`rest`), or the refusal's words.
|
|
575
576
|
* An empty result says so: "Its result: (no output)", never "Its result:" and nothing. */
|
|
576
577
|
export function outcomeShows(tool, answer, rest, failed) {
|
|
577
578
|
if (answer.decision === "deny")
|
|
578
579
|
return `${answer.by === "message" ? `Your message declined ${tool}.` : `You declined ${tool}.`}${rest.trim() ? `\n${rest.trim()}` : ""}`;
|
|
579
|
-
const head = `${tool} ran once you allowed it${failed ? ", and failed" : ""}.`;
|
|
580
|
+
const head = `${tool} ${answer.by === "setting" ? "ran, as its setting allows it" : "ran once you allowed it"}${failed ? ", and failed" : ""}.`;
|
|
580
581
|
return rest.trim() ? `${head} Its result:\n${rest}` : `${head} Its result: (no output)`;
|
|
581
582
|
}
|
|
582
583
|
/** A call's own rows (its call's, its result's) before its outcome shows: what came of the approval so far. */
|
|
@@ -589,6 +590,12 @@ function callSays(answer) {
|
|
|
589
590
|
return answer.ended ? ENDED_WHILE_WAITING : STOPPED_WHILE_WAITING;
|
|
590
591
|
return "Allowed: it runs now";
|
|
591
592
|
}
|
|
593
|
+
/** A row without the `refused` mark: it says a call was refused before it ran, so only that call's own tool_result row has it;
|
|
594
|
+
* the approval, message and outcome rows made from a result keep their own status. */
|
|
595
|
+
const unrefused = (row) => {
|
|
596
|
+
const { refused: _refused, ...rest } = row;
|
|
597
|
+
return rest;
|
|
598
|
+
};
|
|
592
599
|
/** A synthesized row's id: the approval's own, so a pass over rows this function gave drops and remakes it. */
|
|
593
600
|
const approvalRowId = (callId) => `approval:${callId}`;
|
|
594
601
|
/** The rows of a run whose calls waited for approval, as the runner writes it (store-view.ts): the gate's ask
|
|
@@ -630,18 +637,18 @@ export function withApprovalRows(rows, asks, answers, redact) {
|
|
|
630
637
|
// writes none), so the approval and outcome rows take a new id once it is there: served anew below the result, the
|
|
631
638
|
// call's own rows, then its approval, then what came of it, as a person reads it.
|
|
632
639
|
const at = result ? `${approvalRowId(approval.call_id)}:after` : approvalRowId(approval.call_id);
|
|
633
|
-
const head = !answer ? "Waiting for your approval" : answer.decision === "canceled" ? "Withdrawn when the run was cancelled" : answer.decision === "withdrawn" ? (answer.ended ? "Withdrawn when the run ended" : "Withdrawn when the run was stopped") : answer.by === "message" ? "Declined by your message" : "Asked your approval";
|
|
634
|
-
const asked = { ...row, id: at, kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
|
|
640
|
+
const head = !answer ? "Waiting for your approval" : answer.decision === "canceled" ? "Withdrawn when the run was cancelled" : answer.decision === "withdrawn" ? (answer.ended ? "Withdrawn when the run ended" : "Withdrawn when the run was stopped") : answer.by === "message" ? "Declined by your message" : answer.by === "setting" ? "Allowed by the tool's setting" : "Asked your approval";
|
|
641
|
+
const asked = { ...unrefused(row), id: at, kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
|
|
635
642
|
if (!outcome)
|
|
636
643
|
return [own, asked];
|
|
637
644
|
const failed = answer.decision === "allow" && result?.tool_status === "failed";
|
|
638
645
|
// The result's words: a tool_result row keeps them as its preview (the renderer's, redacted and cut), its text empty.
|
|
639
|
-
const told = { ...(result ?? row), id: `${at}:outcome`, kind: "phase", origin: "server", summary: outcomeSays(approval.tool, answer, failed, redact), text: outcomeShows(approval.tool, answer, redact(result?.text || result?.tool_result_preview || ""), failed), tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
|
|
646
|
+
const told = { ...unrefused(result ?? row), id: `${at}:outcome`, kind: "phase", origin: "server", summary: outcomeSays(approval.tool, answer, failed, redact), text: outcomeShows(approval.tool, answer, redact(result?.text || result?.tool_result_preview || ""), failed), tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
|
|
640
647
|
// A person's message that declined the call (runs-over-store.ts message: a deny carrying their words) is theirs as any
|
|
641
648
|
// message is: its own row, between the approval and what came of it, as main's declineBy kept it.
|
|
642
649
|
if (answer.decision === "deny" && answer.by === "message" && answer.note) {
|
|
643
650
|
const words = redact(answer.note);
|
|
644
|
-
const { origin: _origin, ...base } = result ?? row;
|
|
651
|
+
const { origin: _origin, ...base } = unrefused(result ?? row);
|
|
645
652
|
const theirs = { ...base, id: `${at}:message`, kind: "user_message", summary: clip(`You: ${words.split("\n", 1)[0]}`, 500), text: words, tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
|
|
646
653
|
return [own, asked, theirs, told];
|
|
647
654
|
}
|
|
@@ -6,12 +6,21 @@ import { type MessageOrigin } from "../timeline/index.js";
|
|
|
6
6
|
import { type Claim, type EndOfRunTurn, type LoopFactory } from "./loop-contract.js";
|
|
7
7
|
import { Parked } from "./loop.js";
|
|
8
8
|
import type { PiRun } from "./adapters/pi.js";
|
|
9
|
-
import { type
|
|
9
|
+
import { type HeldSpec } from "./held-run.js";
|
|
10
|
+
import { type LoopComputer } from "./computer-channel.js";
|
|
10
11
|
import { type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
|
|
11
12
|
import { type PortModels } from "../port-models.js";
|
|
12
|
-
/** The run's cap as its spec gives it: the kernel runCap's options but its sessions
|
|
13
|
-
|
|
13
|
+
/** The run's cap's config, as its spec gives it: the kernel runCap's options but its sessions (the loop's own), and
|
|
14
|
+
* `beside`, what was spent beside the run's sessions on its behalf (Store.learning.spentBeside: its learning runs'
|
|
15
|
+
* grades), which every gate of the run reads with its sessions' spend (runBooking's sessions.beside, overCap, the
|
|
16
|
+
* wrap-ups). None: nothing is. */
|
|
17
|
+
export type RunCapConfig = Omit<RunCapOptions, "sessions"> & {
|
|
18
|
+
beside?(): Promise<number | null>;
|
|
19
|
+
};
|
|
14
20
|
import { type ClaimMcp } from "./mcp-run.js";
|
|
21
|
+
/** The end of a harness's own call (Claude Code's WebSearch) the gate held and then let run: the host ran nothing of it,
|
|
22
|
+
* and the harness's next call runs it. */
|
|
23
|
+
export declare const OWN_TOOL_RELEASED = "Allowed after it waited; the agent's own tool runs it on its next call.";
|
|
15
24
|
/** A pause or resume row on an agentic run, refused in main's words (runs.ts pause): only a workflow run pauses. */
|
|
16
25
|
export declare const AGENTIC_PAUSE_REFUSED = "Only a workflow run pauses here: an agentic run's turn is stopped with POST /runs/{id}/stop.";
|
|
17
26
|
/** What a raise meets, as the kernel cap's checkRaise reads it (run-adapters/src/kernel/cap/park.ts): the run's cap, the
|
|
@@ -58,6 +67,9 @@ export type SpecGate = ((call: ToolCall, options?: {
|
|
|
58
67
|
/** The revision's tool-call budget (definition.max_tool_calls, tool-budget.ts): the calls each conversation may make. A
|
|
59
68
|
* call past it is refused before anything else is asked; one the adapter counts no calls for (a CLI's) is not held. */
|
|
60
69
|
readonly toolCalls?: number;
|
|
70
|
+
/** A tool's setting now, by any name a call reaches the gate by (a harness's own, Codex's `web_search`), read again at
|
|
71
|
+
* each ask: what the session reads (SessionIO.permission) for a tool no call of which reaches the gate before it runs. */
|
|
72
|
+
readonly permission?: (tool: string) => Promise<"allow" | "ask" | "deny">;
|
|
61
73
|
};
|
|
62
74
|
/** What one claimed run's adapter loop runs. */
|
|
63
75
|
export interface AdapterRunSpec {
|
|
@@ -139,10 +151,14 @@ export interface AdapterRunSpec {
|
|
|
139
151
|
/** Handed the run's own Harness commit once it opens (and after each restart's re-open): what a mark of the run's
|
|
140
152
|
* commits through, so a commit after the claim is lost is refused by the fence like any other. */
|
|
141
153
|
readonly harnessReady?: (commit: Harness["commit"]) => void;
|
|
142
|
-
/** The run's
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
|
|
154
|
+
/** The run's computer when it speaks the protocol (a sandbox, a desktop or a phone): the loop answers the computer call
|
|
155
|
+
* channel's rows on it (runner/computer-channel.ts). On a desktop or a phone, with the person's hold on it
|
|
156
|
+
* (workspace/computer-hold.ts): the loop commits the hold's changes to the run's journal, which the server reads
|
|
157
|
+
* (computer-routes.ts), and applies the person's take-over and hand-back rows to it (runner/computer-journal.ts). */
|
|
158
|
+
readonly computer?: LoopComputer;
|
|
159
|
+
/** The run's computer held for its owner (a run started with `hold: true`, computer-held.ts): the agent's first input
|
|
160
|
+
* waits for the owner's start, and the run's end waits for the owner's release (runner/held-run.ts). */
|
|
161
|
+
readonly held?: HeldSpec;
|
|
146
162
|
/** Lets this spec's resources go once the loop writes nothing more through them: called once, after its Session and
|
|
147
163
|
* Harness are closed, when its pass ends (a restart's included) and at the run's end. Never throws out: a failure is
|
|
148
164
|
* logged, and the end stands. */
|