@parcha/agentrun-serve 0.0.0-stage → 0.1.0-beta.30
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 +748 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +2190 -2
- package/dist/adapters.d.ts +234 -0
- package/dist/adapters.js +585 -0
- package/dist/agents.d.ts +130 -0
- package/dist/agents.js +308 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +384 -0
- package/dist/background.d.ts +28 -0
- package/dist/background.js +376 -0
- package/dist/bound-files.d.ts +4 -0
- package/dist/bound-files.js +164 -0
- package/dist/box/record.d.ts +6 -0
- package/dist/box/record.js +41 -0
- package/dist/box/sweep.d.ts +53 -0
- package/dist/box/sweep.js +193 -0
- package/dist/box-egress.d.ts +98 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +98 -0
- package/dist/box-image.js +285 -0
- package/dist/box-relay-vm.d.ts +80 -0
- package/dist/box-relay-vm.js +389 -0
- package/dist/box-relay.d.ts +45 -0
- package/dist/box-relay.js +227 -0
- package/dist/boxes.d.ts +72 -0
- package/dist/boxes.js +189 -0
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +332 -0
- package/dist/cap.js +992 -0
- package/dist/catalog.d.ts +20 -0
- package/dist/catalog.js +53 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +167 -0
- package/dist/coding-tools.d.ts +35 -0
- package/dist/coding-tools.js +87 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +1721 -0
- package/dist/console/assets/index-34jfpIbQ.js +481 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
- package/dist/console/index.html +15 -0
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/daytona-api.d.ts +21 -0
- package/dist/daytona-api.js +101 -0
- package/dist/decision-rows.d.ts +19 -0
- package/dist/decision-rows.js +123 -0
- package/dist/decisions.d.ts +94 -0
- package/dist/decisions.js +184 -0
- package/dist/effort-guidance.d.ts +5 -0
- package/dist/effort-guidance.js +14 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +11 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.js +69 -0
- package/dist/exa-keyless.d.ts +35 -0
- package/dist/exa-keyless.js +202 -0
- package/dist/fetch-page.d.ts +114 -0
- package/dist/fetch-page.js +182 -0
- package/dist/files.d.ts +65 -0
- package/dist/files.js +158 -0
- package/dist/grade.d.ts +93 -0
- package/dist/grade.js +328 -0
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +102 -0
- package/dist/graph-view.js +219 -0
- package/dist/harness-app.d.ts +40 -0
- package/dist/harness-app.js +708 -0
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +56 -0
- package/dist/harness.js +77 -0
- package/dist/home-path.d.ts +27 -0
- package/dist/home-path.js +78 -0
- package/dist/host-tools.d.ts +30 -0
- package/dist/host-tools.js +154 -0
- package/dist/host.d.ts +39 -0
- package/dist/host.js +85 -0
- package/dist/hosted-search.d.ts +27 -0
- package/dist/hosted-search.js +133 -0
- package/dist/import-sources.d.ts +104 -0
- package/dist/import-sources.js +629 -0
- package/dist/import-summary.d.ts +25 -0
- package/dist/import-summary.js +75 -0
- package/dist/import-worker.d.ts +26 -0
- package/dist/import-worker.js +41 -0
- package/dist/import.d.ts +145 -0
- package/dist/import.js +1222 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/key-check.d.ts +37 -0
- package/dist/key-check.js +112 -0
- package/dist/key-refusal.d.ts +51 -0
- package/dist/key-refusal.js +191 -0
- package/dist/learn/check.d.ts +108 -0
- package/dist/learn/check.js +277 -0
- package/dist/learn/grade.d.ts +80 -0
- package/dist/learn/grade.js +445 -0
- package/dist/learn/index.d.ts +7 -0
- package/dist/learn/index.js +11 -0
- package/dist/learn/invisible.d.ts +5 -0
- package/dist/learn/invisible.js +42 -0
- package/dist/learn/notes.d.ts +59 -0
- package/dist/learn/notes.js +147 -0
- package/dist/learn/reflect.d.ts +49 -0
- package/dist/learn/reflect.js +213 -0
- package/dist/learn/secrets.d.ts +18 -0
- package/dist/learn/secrets.js +131 -0
- package/dist/learn/skills.d.ts +97 -0
- package/dist/learn/skills.js +271 -0
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-routes.d.ts +196 -0
- package/dist/learning-routes.js +609 -0
- package/dist/learning-run.d.ts +306 -0
- package/dist/learning-run.js +819 -0
- package/dist/learning-words.d.ts +76 -0
- package/dist/learning-words.js +174 -0
- package/dist/learning.d.ts +418 -0
- package/dist/learning.js +946 -0
- package/dist/llm.d.ts +40 -0
- package/dist/llm.js +37 -0
- package/dist/llms.txt +37 -0
- package/dist/mcp-servers.d.ts +118 -0
- package/dist/mcp-servers.js +450 -0
- package/dist/mcp.d.ts +51 -0
- package/dist/mcp.js +392 -0
- package/dist/model.d.ts +186 -0
- package/dist/model.js +485 -0
- package/dist/monid.d.ts +74 -0
- package/dist/monid.js +277 -0
- package/dist/openapi/agentrun-v2.openapi.json +4806 -0
- package/dist/openapi.d.ts +10 -0
- package/dist/openapi.js +1727 -0
- package/dist/owner.d.ts +55 -0
- package/dist/owner.js +222 -0
- package/dist/packs.d.ts +71 -0
- package/dist/packs.js +180 -0
- package/dist/page.d.ts +32 -0
- package/dist/page.js +133 -0
- package/dist/paid-calls.d.ts +50 -0
- package/dist/paid-calls.js +110 -0
- package/dist/pause.d.ts +70 -0
- package/dist/pause.js +97 -0
- package/dist/pdf-pages.d.ts +44 -0
- package/dist/pdf-pages.js +147 -0
- package/dist/place.d.ts +69 -0
- package/dist/place.js +137 -0
- package/dist/print.d.ts +20 -0
- package/dist/print.js +29 -0
- package/dist/propose.d.ts +40 -0
- package/dist/propose.js +112 -0
- package/dist/quiet-sqlite-warning.d.ts +1 -0
- package/dist/quiet-sqlite-warning.js +14 -0
- package/dist/request-start.d.ts +22 -0
- package/dist/request-start.js +350 -0
- package/dist/result.d.ts +3 -0
- package/dist/result.js +5 -0
- package/dist/rows.d.ts +46 -0
- package/dist/rows.js +121 -0
- package/dist/run-box.d.ts +186 -0
- package/dist/run-box.js +590 -0
- package/dist/run-manifest.d.ts +27 -0
- package/dist/run-manifest.js +60 -0
- package/dist/runnable.d.ts +83 -0
- package/dist/runnable.js +170 -0
- package/dist/runs.d.ts +1062 -0
- package/dist/runs.js +3020 -0
- package/dist/secret-cut.d.ts +27 -0
- package/dist/secret-cut.js +109 -0
- package/dist/secrets.d.ts +62 -0
- package/dist/secrets.js +158 -0
- package/dist/server-lock.d.ts +44 -0
- package/dist/server-lock.js +140 -0
- package/dist/server.d.ts +722 -0
- package/dist/server.js +2118 -0
- package/dist/sessions.d.ts +4 -0
- package/dist/sessions.js +105 -0
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +43 -0
- package/dist/skills.js +96 -0
- package/dist/stats.d.ts +106 -0
- package/dist/stats.js +103 -0
- package/dist/tool-gate.d.ts +266 -0
- package/dist/tool-gate.js +554 -0
- package/dist/tool-keys.d.ts +187 -0
- package/dist/tool-keys.js +315 -0
- package/dist/tool-plane.d.ts +228 -0
- package/dist/tool-plane.js +400 -0
- package/dist/tools.d.ts +202 -0
- package/dist/tools.js +372 -0
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +24 -0
- package/dist/turn-end.js +15 -0
- package/dist/turns.d.ts +34 -0
- package/dist/turns.js +202 -0
- package/dist/uploads.d.ts +104 -0
- package/dist/uploads.js +474 -0
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/usage.d.ts +29 -0
- package/dist/usage.js +58 -0
- package/dist/validate.d.ts +57 -0
- package/dist/validate.js +184 -0
- package/dist/web-fetch.d.ts +64 -0
- package/dist/web-fetch.js +262 -0
- package/dist/web-search.d.ts +54 -0
- package/dist/web-search.js +136 -0
- package/dist/webhooks.d.ts +189 -0
- package/dist/webhooks.js +503 -0
- package/dist/workspace-paths.d.ts +33 -0
- package/dist/workspace-paths.js +104 -0
- package/dist/workspace.d.ts +88 -0
- package/dist/workspace.js +369 -0
- package/launcher/agentrun-serve +109 -0
- package/package.json +100 -4
- package/skills/agentrun-serve/SKILL.md +128 -0
package/dist/stats.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { AnalyticsFilter, PendingEnd, StoreAnalytics, StoreStats } from "@parcha/pi-durable-agent";
|
|
2
|
+
import { type Runs } from "./runs.js";
|
|
3
|
+
/** The running rows this server holds as ended, by the state their end will have: a run reads ended as soon as its turn
|
|
4
|
+
* ends, and its end and metrics reach the store after its process has let it go. Counted by what the server holds; their
|
|
5
|
+
* metrics, cost and effort are left out until the store has their end (analytics' `pending`), never counted as running
|
|
6
|
+
* or as an unknown cost. */
|
|
7
|
+
export declare function pendingOf(running: readonly string[], runs: Runs): Record<string, PendingEnd>;
|
|
8
|
+
export declare function statsView(stats: StoreStats, runs: Runs, pending?: Readonly<Record<string, PendingEnd>>): {
|
|
9
|
+
agents: number;
|
|
10
|
+
runs: {
|
|
11
|
+
total: number;
|
|
12
|
+
active: number;
|
|
13
|
+
needs_input: number;
|
|
14
|
+
failed: number;
|
|
15
|
+
needs_review: number;
|
|
16
|
+
status_unknown: number;
|
|
17
|
+
};
|
|
18
|
+
per_agent: {
|
|
19
|
+
agent_id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
runs: number;
|
|
22
|
+
}[];
|
|
23
|
+
cost: {
|
|
24
|
+
usd: number | null;
|
|
25
|
+
basis: string | null;
|
|
26
|
+
unknown_runs: number;
|
|
27
|
+
};
|
|
28
|
+
archived: {
|
|
29
|
+
agents: number;
|
|
30
|
+
runs: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** The query's `from` and `to` (RFC 3339 date-times) and `agent` (an agent id): 400 for one that is not. Each absent is
|
|
34
|
+
* no bound. */
|
|
35
|
+
export declare function analyticsFilter(url: URL): AnalyticsFilter;
|
|
36
|
+
export declare function analyticsView(a: StoreAnalytics, filter: AnalyticsFilter): {
|
|
37
|
+
filter: {
|
|
38
|
+
from: string | null;
|
|
39
|
+
to: string | null;
|
|
40
|
+
agent: string | null;
|
|
41
|
+
};
|
|
42
|
+
totals: {
|
|
43
|
+
input: number;
|
|
44
|
+
cache_read: number;
|
|
45
|
+
cache_write: number;
|
|
46
|
+
output: number;
|
|
47
|
+
requests: number;
|
|
48
|
+
unmetered: number;
|
|
49
|
+
runs: number;
|
|
50
|
+
completed: number;
|
|
51
|
+
needs_review: number;
|
|
52
|
+
failed: number;
|
|
53
|
+
runs_with_metrics: number;
|
|
54
|
+
tokens: number;
|
|
55
|
+
cost_usd: number | null;
|
|
56
|
+
unknown_cost_runs: number;
|
|
57
|
+
};
|
|
58
|
+
time: {
|
|
59
|
+
ended_runs: number;
|
|
60
|
+
wall_ms: number;
|
|
61
|
+
active_runs: number;
|
|
62
|
+
active_ms: number;
|
|
63
|
+
};
|
|
64
|
+
by_harness_effort: {
|
|
65
|
+
runs: number;
|
|
66
|
+
completed: number;
|
|
67
|
+
needs_review: number;
|
|
68
|
+
failed: number;
|
|
69
|
+
runs_with_metrics: number;
|
|
70
|
+
tokens: number;
|
|
71
|
+
cost_usd: number | null;
|
|
72
|
+
unknown_cost_runs: number;
|
|
73
|
+
harness: string;
|
|
74
|
+
effort: string | null;
|
|
75
|
+
}[];
|
|
76
|
+
by_day: {
|
|
77
|
+
runs: number;
|
|
78
|
+
completed: number;
|
|
79
|
+
needs_review: number;
|
|
80
|
+
failed: number;
|
|
81
|
+
runs_with_metrics: number;
|
|
82
|
+
tokens: number;
|
|
83
|
+
cost_usd: number | null;
|
|
84
|
+
unknown_cost_runs: number;
|
|
85
|
+
day: string;
|
|
86
|
+
}[];
|
|
87
|
+
by_source: {
|
|
88
|
+
runs: number;
|
|
89
|
+
completed: number;
|
|
90
|
+
needs_review: number;
|
|
91
|
+
failed: number;
|
|
92
|
+
runs_with_metrics: number;
|
|
93
|
+
tokens: number;
|
|
94
|
+
cost_usd: number | null;
|
|
95
|
+
unknown_cost_runs: number;
|
|
96
|
+
source: "live" | import("@parcha/pi-durable-agent").ImportSource;
|
|
97
|
+
}[];
|
|
98
|
+
tools: {
|
|
99
|
+
tool: string;
|
|
100
|
+
label: string;
|
|
101
|
+
calls: number;
|
|
102
|
+
errors: number;
|
|
103
|
+
}[];
|
|
104
|
+
};
|
|
105
|
+
/** How the runs that tried to learn fared: learning-run.ts's, beside the counts that use it, and named here as before. */
|
|
106
|
+
export { learningStats } from "./learning-run.js";
|
package/dist/stats.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { nameOf } from "@parcha/pi-durable-agent/timeline";
|
|
2
|
+
import { ApiError } from "./errors.js";
|
|
3
|
+
import { statusOf } from "./runs.js";
|
|
4
|
+
import { ID } from "./validate.js";
|
|
5
|
+
/** Where a running row this server holds is counted, by its status (a paused workflow run is held, so active). One it
|
|
6
|
+
* holds as ended is pending (pendingOf), never here. */
|
|
7
|
+
const BUCKET = { queued: "active", working: "active", paused: "active", input_required: "needs_input" };
|
|
8
|
+
/** The state a held run's end will have in the store, by the status it reads (an escalation reads completed until then). */
|
|
9
|
+
const END_OF = { completed: "completed", failed: "failed", cancelled: "stopped" };
|
|
10
|
+
/** The running rows this server holds as ended, by the state their end will have: a run reads ended as soon as its turn
|
|
11
|
+
* ends, and its end and metrics reach the store after its process has let it go. Counted by what the server holds; their
|
|
12
|
+
* metrics, cost and effort are left out until the store has their end (analytics' `pending`), never counted as running
|
|
13
|
+
* or as an unknown cost. */
|
|
14
|
+
export function pendingOf(running, runs) {
|
|
15
|
+
const pending = {};
|
|
16
|
+
for (const id of running) {
|
|
17
|
+
const run = runs.held(id);
|
|
18
|
+
const end = run && END_OF[statusOf(run).status];
|
|
19
|
+
if (end)
|
|
20
|
+
pending[id] = end;
|
|
21
|
+
}
|
|
22
|
+
return pending;
|
|
23
|
+
}
|
|
24
|
+
/** As GET /usage rounds its sums; null stays null. */
|
|
25
|
+
const round = (usd) => (usd === null ? null : Math.round(usd * 1e6) / 1e6);
|
|
26
|
+
export function statsView(stats, runs, pending = pendingOf(stats.running, runs)) {
|
|
27
|
+
const running = { active: 0, needs_input: 0, status_unknown: 0 };
|
|
28
|
+
for (const id of stats.running) {
|
|
29
|
+
if (pending[id])
|
|
30
|
+
continue;
|
|
31
|
+
const run = runs.held(id);
|
|
32
|
+
running[(run && BUCKET[statusOf(run).status]) ?? "status_unknown"] += 1;
|
|
33
|
+
}
|
|
34
|
+
// Each pending run is one of the store's running rows, which its cost counts as unknown (stats.running and the cost's
|
|
35
|
+
// sums leave out the same archived runs and agents).
|
|
36
|
+
const ends = Object.values(pending);
|
|
37
|
+
const usd = round(stats.cost.usd);
|
|
38
|
+
return {
|
|
39
|
+
agents: stats.agents,
|
|
40
|
+
runs: { total: stats.runs.total, active: running.active, needs_input: running.needs_input, failed: stats.runs.failed + ends.filter((end) => end === "failed").length, needs_review: stats.runs.escalated, status_unknown: running.status_unknown },
|
|
41
|
+
per_agent: stats.byAgent.map((a) => ({ agent_id: a.id, name: a.name, runs: a.runs })),
|
|
42
|
+
cost: { usd, basis: usd === null ? null : "estimate", unknown_runs: stats.cost.unknown - ends.length },
|
|
43
|
+
archived: { agents: stats.archivedAgents, runs: stats.archivedRuns },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// ---- analytics: the runs' metrics summed (AgentStoreReader.analytics), over the runs `from`, `to` and `agent` pick ----
|
|
47
|
+
const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,3})?(Z|[+-](\d{2}):(\d{2}))$/;
|
|
48
|
+
/** The UTC time an RFC 3339 date-time names, to the millisecond, or undefined for anything else: an impossible date or
|
|
49
|
+
* time, which Date.parse would roll forward (02-30 to 03-02), and a finer fraction, which it would cut (a bound of
|
|
50
|
+
* .0005 would read .000), included. */
|
|
51
|
+
function utcOf(text) {
|
|
52
|
+
const m = DATE_TIME.exec(text.toUpperCase());
|
|
53
|
+
if (!m)
|
|
54
|
+
return undefined;
|
|
55
|
+
const [year, month, day, hour, minute, second] = m.slice(1, 7).map(Number);
|
|
56
|
+
const date = new Date(0);
|
|
57
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
58
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day || hour > 23 || minute > 59 || second > 59)
|
|
59
|
+
return undefined;
|
|
60
|
+
if (m[9] !== undefined && (Number(m[9]) > 23 || Number(m[10]) > 59))
|
|
61
|
+
return undefined;
|
|
62
|
+
const at = Date.parse(text.toUpperCase());
|
|
63
|
+
const iso = Number.isFinite(at) ? new Date(at).toISOString() : "";
|
|
64
|
+
return /^\d{4}-/.test(iso) ? iso : undefined;
|
|
65
|
+
}
|
|
66
|
+
/** The query's `from` and `to` (RFC 3339 date-times) and `agent` (an agent id): 400 for one that is not. Each absent is
|
|
67
|
+
* no bound. */
|
|
68
|
+
export function analyticsFilter(url) {
|
|
69
|
+
const filter = {};
|
|
70
|
+
for (const key of ["from", "to"]) {
|
|
71
|
+
const text = url.searchParams.get(key);
|
|
72
|
+
if (text === null)
|
|
73
|
+
continue;
|
|
74
|
+
const iso = utcOf(text);
|
|
75
|
+
if (iso === undefined)
|
|
76
|
+
throw new ApiError("bad_request", "from and to are RFC 3339 date-times that exist, to the millisecond");
|
|
77
|
+
filter[key] = iso;
|
|
78
|
+
}
|
|
79
|
+
const agent = url.searchParams.get("agent");
|
|
80
|
+
if (agent !== null) {
|
|
81
|
+
if (!ID.test(agent))
|
|
82
|
+
throw new ApiError("bad_request", "agent is an agent id");
|
|
83
|
+
filter.agent = agent;
|
|
84
|
+
}
|
|
85
|
+
return filter;
|
|
86
|
+
}
|
|
87
|
+
/** A group's counts: an escalated run is completed, and needs review; never failed. */
|
|
88
|
+
const group = (g) => ({ runs: g.runs, completed: g.completed, needs_review: g.needsReview, failed: g.failed, runs_with_metrics: g.runsWithMetrics, tokens: g.tokens, cost_usd: round(g.costUsd), unknown_cost_runs: g.unknownCostRuns });
|
|
89
|
+
export function analyticsView(a, filter) {
|
|
90
|
+
const t = a.totals;
|
|
91
|
+
return {
|
|
92
|
+
filter: { from: filter.from ?? null, to: filter.to ?? null, agent: filter.agent ?? null },
|
|
93
|
+
totals: { ...group(t), input: t.input, cache_read: t.cacheRead, cache_write: t.cacheWrite, output: t.output, requests: t.requests, unmetered: t.unmetered },
|
|
94
|
+
time: { ended_runs: a.time.endedRuns, wall_ms: a.time.wallMs, active_runs: a.time.activeRuns, active_ms: a.time.activeMs },
|
|
95
|
+
by_harness_effort: a.byHarnessEffort.map((g) => ({ harness: g.harness, effort: g.effort, ...group(g) })),
|
|
96
|
+
by_day: a.byDay.map((g) => ({ day: g.day, ...group(g) })),
|
|
97
|
+
by_source: a.bySource.map((g) => ({ source: g.source, ...group(g) })),
|
|
98
|
+
// Each tool by the name it was called (`tool`) and what a person calls it (`label`, the timeline's registry).
|
|
99
|
+
tools: a.tools.map((t) => ({ tool: t.tool, label: nameOf(t.tool), calls: t.calls, errors: t.errors })),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** How the runs that tried to learn fared: learning-run.ts's, beside the counts that use it, and named here as before. */
|
|
103
|
+
export { learningStats } from "./learning-run.js";
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import { type Extension, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { DurableRun } from "@parcha/pi-durable-disk";
|
|
4
|
+
import type { TurnOrigin } from "./learning-run.js";
|
|
5
|
+
/** What the gate does with a tool's calls. */
|
|
6
|
+
export declare const PERMISSIONS: readonly ["allow", "ask", "deny"];
|
|
7
|
+
export type Permission = (typeof PERMISSIONS)[number];
|
|
8
|
+
/** An MCP tool's gate name: `mcp:<server>/<tool>`. */
|
|
9
|
+
export declare const mcpToolName: (server: string, tool: string) => string;
|
|
10
|
+
/** Whether `name` is an MCP tool's gate name. */
|
|
11
|
+
export declare const isMcpTool: (name: string) => boolean;
|
|
12
|
+
/** A third-party catalog tool, by its name: monid's (`monid.<tool>`) or an MCP server's (`mcp:<server>/<tool>`). */
|
|
13
|
+
export declare const isCatalogTool: (name: string) => boolean;
|
|
14
|
+
/** The owner's defaults (11-01): a built-in kernel tool allow; a third-party catalog tool ask. */
|
|
15
|
+
export declare const defaultPermission: (name: string) => Permission;
|
|
16
|
+
/** The tools that run a command in the run's box (background.ts SHELL_TOOLS), each held to bash's setting: bash: deny
|
|
17
|
+
* refuses bash_background as it refuses bash, and none of them is a settings key of its own. */
|
|
18
|
+
export declare const SHELL_FAMILY: Readonly<Record<string, string>>;
|
|
19
|
+
/** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
|
|
20
|
+
* tool, its server's wildcard `mcp:<server>/*`. */
|
|
21
|
+
export declare function permissionKeys(name: string): string[];
|
|
22
|
+
/** The settings key a call named `name` on `harness` is held to: the one mapping from every name a call reaches the gate
|
|
23
|
+
* by. A settings key is itself (a table tool, `monid.<tool>`, `mcp:<server>/<tool>`); a CLI's own tool is the table's it
|
|
24
|
+
* is; an MCP alias, `mcp__<server>__<tool>` (claude-agent's host tools `mcp__hands__<wire name>`, mapped as their
|
|
25
|
+
* wire name) and on OpenCode `<server>_<tool>`, is `mcp:<server>/<tool>`; a catalog's wire name (`monid_run`) is its
|
|
26
|
+
* catalog name; the browser's registrations are `browser`. OpenCode's `<server>_<tool>` maps only for a server of
|
|
27
|
+
* `mcpServers` (the run's configured MCP servers), never by its shape, since a host tool's name has the same shape.
|
|
28
|
+
* Undefined: nothing maps it, and the gate asks. The key only: an MCP call enters the gate once, in the MCP gateway. */
|
|
29
|
+
export declare function settingsKeyOf(harness: string, name: string, mcpServers?: readonly string[]): string | undefined;
|
|
30
|
+
/** A layer of tool settings (the server's, PUT /v2/settings/tools, or an agent's own, definition.tool_settings) as the
|
|
31
|
+
* gate reads it: a permission by settings key. */
|
|
32
|
+
export type PermissionSettings = Readonly<Record<string, {
|
|
33
|
+
permission?: Permission;
|
|
34
|
+
} | undefined>>;
|
|
35
|
+
/** `name`'s permission in force and the layer it came from, most specific first: the agent's exact key, the agent's
|
|
36
|
+
* server wildcard, the server's exact key, the server's server wildcard, then the default. Rules over a call's
|
|
37
|
+
* arguments are not in V1. */
|
|
38
|
+
export declare function permissionFrom(name: string, server: PermissionSettings, agent?: PermissionSettings): {
|
|
39
|
+
permission: Permission;
|
|
40
|
+
from: "agent" | "server" | "default";
|
|
41
|
+
};
|
|
42
|
+
/** `name`'s permission in force (permissionFrom): the one rule every path reads, the gate's, the tool plane's and a
|
|
43
|
+
* workflow's call nodes'. */
|
|
44
|
+
export declare const permissionOf: (name: string, server: PermissionSettings, agent?: PermissionSettings) => Permission;
|
|
45
|
+
/** A call's answer as the model reads it: its text, and whether it failed. */
|
|
46
|
+
export type ToolAnswer = {
|
|
47
|
+
text: string;
|
|
48
|
+
isError: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** An approval's price for the person who answers it: USD where the tool declares one (booked through the spend cap's
|
|
51
|
+
* paidCall), else "not metered" (an unpriced MCP call, the owner's ruling of 11-04). */
|
|
52
|
+
export type ApprovalPrice = number | "not metered";
|
|
53
|
+
/** One pending approval, as the run's view shows it (`pending`) and the console's approval card reads it. */
|
|
54
|
+
export type PendingApproval = {
|
|
55
|
+
kind: "approval";
|
|
56
|
+
/** The approval's id, the answer route's `{approval_id}`; the same for the same call after a crash. */
|
|
57
|
+
id: string;
|
|
58
|
+
tool: string;
|
|
59
|
+
call_id: string;
|
|
60
|
+
/** The call's arguments as text, at most ARGS_PREVIEW_BYTES. */
|
|
61
|
+
args_preview: string;
|
|
62
|
+
requested_at: string;
|
|
63
|
+
price?: ApprovalPrice;
|
|
64
|
+
};
|
|
65
|
+
/** The run's journal commit for the call, which makes the request durable before the gate answers, and who is told it
|
|
66
|
+
* parked, so its turn ends (harness-app.ts endsTurn): by the call's id, or, where the caller cannot name it, by its tool
|
|
67
|
+
* and its arguments' digest. */
|
|
68
|
+
export type Park = {
|
|
69
|
+
commit<T>(change: (tx: unknown) => Promise<T>): Promise<T>;
|
|
70
|
+
parked?(callId: string): void;
|
|
71
|
+
parkedBy?(match: {
|
|
72
|
+
tool: string;
|
|
73
|
+
argsDigest: string;
|
|
74
|
+
}): void; /** The message the turn running the call took (harness-app's), kept with its request. */
|
|
75
|
+
turn?(): string | undefined;
|
|
76
|
+
};
|
|
77
|
+
/** What a call's ask carries beyond the call. */
|
|
78
|
+
export type EnterOptions = {
|
|
79
|
+
/** What the approval card shows the call costs. */
|
|
80
|
+
price?: ApprovalPrice;
|
|
81
|
+
};
|
|
82
|
+
/** enter's answer. `undefined`: run the call. Otherwise the answer the model reads instead: a refusal
|
|
83
|
+
* (`isError: true`), or the waiting text with `parked: true`, after which the caller ends the turn. */
|
|
84
|
+
export type Entered = undefined | (ToolAnswer & {
|
|
85
|
+
parked?: true;
|
|
86
|
+
});
|
|
87
|
+
/** Runs an APPROVED parked call of a tool family the gate does not own (the MCP gateway's), exactly once. It owns the
|
|
88
|
+
* call's deadline: the gate puts no wall-clock bound on it (only a stop or a cancel cuts it, through `signal`), so an
|
|
89
|
+
* executor bounds its own work and answers a timeout as an error result (`isError: true`), never by waiting on. */
|
|
90
|
+
export type Executor = (tool: string, args: unknown, callId: string, signal: AbortSignal) => Promise<ToolAnswer>;
|
|
91
|
+
/** The gate of one run, in the run's process. */
|
|
92
|
+
export interface Gate {
|
|
93
|
+
/** One model-initiated call at the gate: allow, deny, or ask, which parks (see the header). */
|
|
94
|
+
enter(tool: string, args: unknown, callId: string, park: Park, options?: EnterOptions): Promise<Entered>;
|
|
95
|
+
/** Registers how an approved parked call of tools named `prefix…` (e.g. "mcp:") runs; one per prefix and run. */
|
|
96
|
+
executor(prefix: string, run: Executor): void;
|
|
97
|
+
/** A call's result text as the model gets it: as it is, a host tool's result already cut by HOST_RESULT_MAX_CHARS. */
|
|
98
|
+
spill(callId: string, text: string): string;
|
|
99
|
+
}
|
|
100
|
+
/** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
|
|
101
|
+
* bash), naming the setting to change. */
|
|
102
|
+
export declare const deniedText: (tool: string, heldTo?: string) => string;
|
|
103
|
+
/** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
|
|
104
|
+
export declare const noApproverText: (tool: string) => string;
|
|
105
|
+
/** Set by the server in a run's environment when no one can approve here (accounts off): the gate refuses each ask. */
|
|
106
|
+
export declare const NO_APPROVER_ENV = "AGENTRUN_SERVE_NO_APPROVER";
|
|
107
|
+
/** A parked call's answer: the run pauses here. */
|
|
108
|
+
export declare const waitingText: (tool: string) => string;
|
|
109
|
+
/** A call a person denied, with their reason when they gave one. */
|
|
110
|
+
export declare const refusedText: (tool: string, note?: string) => string;
|
|
111
|
+
/** The Timeline row of a call that waits for an approval. */
|
|
112
|
+
export declare const APPROVAL_ROW: "tool_approval_requested";
|
|
113
|
+
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
114
|
+
export declare const ARGS_PREVIEW_BYTES = 2048;
|
|
115
|
+
/** A gate of `policy` (the run's permission of a tool now) with no run behind it: allow and deny are enforced and
|
|
116
|
+
* executors are kept; an ask throws, since nothing here can park a call (a run's is RunGate), and spill returns
|
|
117
|
+
* the text as it is. */
|
|
118
|
+
export declare function gateOf(policy: (tool: string) => Permission): Gate;
|
|
119
|
+
/** The file in a run's directory that names the origin of the turn it runs now: written by the server alone, as it sends
|
|
120
|
+
* the learning lane's reflect turn (runs.ts's toLiveDoor), and gone before a person's turn is sent (runs.ts's personsTurn).
|
|
121
|
+
* The gate refuses that turn's writes under work/.learning/ (NOTE_ONLY_TEXT). */
|
|
122
|
+
export declare const TURN_ORIGIN_FILE = "turn-origin.json";
|
|
123
|
+
/** The run's store's record of a call that waits for approval (`phase: "requested"`), and of its answer acted on
|
|
124
|
+
* (`phase: "resolved"`), on its root conversation. */
|
|
125
|
+
export declare const APPROVAL_ENTRY = "agentrun.tool_approval";
|
|
126
|
+
/** The refusal of the end-of-run turn's write or edit under work/.learning/: its notes are kept only from its answer's
|
|
127
|
+
* note blocks (learn/reflect.ts parseReflection), which the host merges in its own store; a file there is never kept. */
|
|
128
|
+
export declare const NOTE_ONLY_TEXT = "A note is kept only from your answer: write it in a ```note block, not to a file.";
|
|
129
|
+
/** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then lexically),
|
|
130
|
+
* names work/.learning/ or a path under it: by this machine's `work` or the box's (BOX_WORK). */
|
|
131
|
+
export declare function underLearning(work: string, args: unknown): boolean;
|
|
132
|
+
/** One call that waits for approval, as the run's store keeps it. */
|
|
133
|
+
export type ApprovalRequest = {
|
|
134
|
+
id: string;
|
|
135
|
+
tool: string;
|
|
136
|
+
call_id: string;
|
|
137
|
+
args: unknown;
|
|
138
|
+
args_preview: string;
|
|
139
|
+
requested_at: string; /** The message the turn that parked it took: a reopen settles that turn, answered or not. */
|
|
140
|
+
turn?: string;
|
|
141
|
+
price?: ApprovalPrice;
|
|
142
|
+
};
|
|
143
|
+
/** Resumes the session with `content` as one message of its own (`approval-<id>`), writing `mark` with it or after it. */
|
|
144
|
+
export type Resume = (id: string, content: string, mark: (tx: Tx) => Promise<unknown>) => Promise<void>;
|
|
145
|
+
/** `text` cut to at most ARGS_PREVIEW_BYTES. What is shown of a call's arguments is the whole of them redacted first, then
|
|
146
|
+
* cut (runs.ts), so a cut never leaves the head of a key no redaction recognizes. */
|
|
147
|
+
export declare function previewOf(text: string): string;
|
|
148
|
+
/** `args` as JSON, at most ARGS_PREVIEW_BYTES: the request's own record of them, never shown as it is. */
|
|
149
|
+
export declare const argsPreview: (args: unknown) => string;
|
|
150
|
+
/** How the gate's resume message starts: the server knows its row by it, and redacts the row whole (runs.ts). */
|
|
151
|
+
export declare const RESUME_PREFIX = "[tool approval] ";
|
|
152
|
+
/** The one message that resumes a session once a person answered: it names the call it answers (its tool, call id and
|
|
153
|
+
* arguments), so the model tells it from a person's new input, and carries the call's result, or the refusal. */
|
|
154
|
+
export declare function resumeText(request: Pick<ApprovalRequest, "tool" | "call_id">, shown: string, decision: "allow" | "deny", result: ToolAnswer): string;
|
|
155
|
+
/** The gate of the run `runId` at `where` (its directory, under the data directory's runs/), on its pinned revision:
|
|
156
|
+
* an agentic run's parks an asked call; a workflow's model node cannot. */
|
|
157
|
+
export declare function runGate(where: {
|
|
158
|
+
root: string;
|
|
159
|
+
work: string;
|
|
160
|
+
}, runId: string, revision: {
|
|
161
|
+
kind: string;
|
|
162
|
+
body: {
|
|
163
|
+
toolSettings?: unknown;
|
|
164
|
+
harness?: string;
|
|
165
|
+
};
|
|
166
|
+
}): RunGate;
|
|
167
|
+
/** The gate in a run's process, park mode: its policy, the turn's origin, the calls that wait, and the answers acted on. */
|
|
168
|
+
export declare class RunGate {
|
|
169
|
+
private readonly where;
|
|
170
|
+
private readonly overrides;
|
|
171
|
+
private readonly parks;
|
|
172
|
+
private readonly approvers;
|
|
173
|
+
private readonly requests;
|
|
174
|
+
private durable?;
|
|
175
|
+
private context?;
|
|
176
|
+
private coding?;
|
|
177
|
+
/** The run's own tools beyond the table (its learned_workflow), on which an approved call of one runs. */
|
|
178
|
+
private extra;
|
|
179
|
+
private resume?;
|
|
180
|
+
private drive?;
|
|
181
|
+
private timer?;
|
|
182
|
+
private settling;
|
|
183
|
+
private readonly stop;
|
|
184
|
+
/** `where.data`: the server's data directory, its tool settings beside the store; `overrides`: the pinned revision's
|
|
185
|
+
* own; `parks`: whether an asked call parks the run (an agentic run's), which a workflow's model node cannot;
|
|
186
|
+
* `approvers`: whether anyone can answer an ask here (the owner's password session: accounts on). */
|
|
187
|
+
constructor(where: {
|
|
188
|
+
root: string;
|
|
189
|
+
work: string;
|
|
190
|
+
data: string;
|
|
191
|
+
runId: string;
|
|
192
|
+
harness?: string;
|
|
193
|
+
mcpServers?: readonly string[];
|
|
194
|
+
}, overrides?: PermissionSettings, parks?: boolean, approvers?: boolean);
|
|
195
|
+
/** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
|
|
196
|
+
* reaches a live run at its next call. */
|
|
197
|
+
readonly policy: (tool: string) => Permission;
|
|
198
|
+
private lastGood?;
|
|
199
|
+
private readonly told;
|
|
200
|
+
/** The server's settings now: read at each call, so a change reaches a live run; a file that does not read keeps the
|
|
201
|
+
* last good (undefined: none read yet). Each problem is said once, by file and field, never a value. */
|
|
202
|
+
private serverSettings;
|
|
203
|
+
/** The origin of the turn running now: what the server's internal path wrote for it; none for a person's turn. */
|
|
204
|
+
turnOrigin(): TurnOrigin | undefined;
|
|
205
|
+
/** One model-initiated call at the gate: undefined when it may run; else its answer, refused at once (deny) or parked
|
|
206
|
+
* (ask). One call waits at a time: another asked meanwhile is answered so, not run. */
|
|
207
|
+
enter(name: string, args: unknown, callId: string, park: Park, options?: EnterOptions): Promise<Entered>;
|
|
208
|
+
/** pi's `tools` behind the gate: wraps, by name, for the run's registry, which apply wherever it is selected (every
|
|
209
|
+
* agent selects it: the root by default, a workflow's model node by name, app.ts). */
|
|
210
|
+
extension(tools: readonly ToolRegistration[]): Extension;
|
|
211
|
+
private wrap;
|
|
212
|
+
/** Reads the requests the run's store holds, as the run's process opens, before its turns go on. `coding`: the run's
|
|
213
|
+
* coding source (coding-tools.ts), on which an approved coding call runs, as the run's own would; `extra`, the run's
|
|
214
|
+
* own tools beyond the table (its learned_workflow), on which an approved call of one runs. */
|
|
215
|
+
load(durable: DurableRun, context: Context, coding?: readonly ToolRegistration[], extra?: readonly ToolRegistration[]): Promise<void>;
|
|
216
|
+
/** Whether a call waits for its answer, or for its answer to be acted on: a harness keeps the turn it ended closed. */
|
|
217
|
+
waiting(): boolean;
|
|
218
|
+
/** Whether a call of the turn that took `message` was parked, answered or not: that turn ended at the park, though a
|
|
219
|
+
* process that went before the next open settled it leaves it open in its session. */
|
|
220
|
+
parkedIn(message: string | undefined): boolean;
|
|
221
|
+
/** Acts on the answers from now on, resuming the session through `resume`; by default pi's root conversation. */
|
|
222
|
+
start(resume?: Resume): void;
|
|
223
|
+
private note;
|
|
224
|
+
/** Reads the run's serve.json for answers while a call waits. */
|
|
225
|
+
private watch;
|
|
226
|
+
/** pi's resume: an input to the root conversation under the request's own id, which pi takes once however often it
|
|
227
|
+
* is sent, then the mark. */
|
|
228
|
+
private readonly submit;
|
|
229
|
+
private settle;
|
|
230
|
+
/** The approved call in flight, and its own abort: a stop or a cancel of the run cuts it (cutIfWithdrawn). */
|
|
231
|
+
private inFlight?;
|
|
232
|
+
/** Cuts the approved call in flight when a stop or a cancel since withdrew its answer (runs.ts supersede). */
|
|
233
|
+
private cutIfWithdrawn;
|
|
234
|
+
/** A call withdrawn with its run: resolved in the run's store with nothing run and nothing resumed. */
|
|
235
|
+
private resolveSilently;
|
|
236
|
+
/** The approved call, run once by the kernel through the journal any host tool's call goes through, as an effect of
|
|
237
|
+
* the run's own `approvals:` session, on the run's coding source: its intent is durable before it runs, its outcome
|
|
238
|
+
* after; a replay-safe call a crash cut off runs again, any other is answered interrupted and never runs again. */
|
|
239
|
+
private run;
|
|
240
|
+
private readonly executors;
|
|
241
|
+
/** Registers how an approved call of tools named `prefix…` runs (the MCP gateway's, "mcp:"): one per prefix and run.
|
|
242
|
+
* The gate runs it exactly once on its journaled path, as it runs a kernel host tool, with no deadline of its own: the
|
|
243
|
+
* executor bounds the call (Executor). */
|
|
244
|
+
executor(prefix: string, run: Executor): void;
|
|
245
|
+
/** What runs an approved call: the executor its tool's prefix names, which may have effects anywhere, so a call a
|
|
246
|
+
* crash cut off is never run again; else the kernel's host tool of the name, as replay-safe as that tool is. Neither:
|
|
247
|
+
* refused, in words, and never run. */
|
|
248
|
+
private runnerOf;
|
|
249
|
+
}
|
|
250
|
+
/** A parked call: by its id, or, where the caller cannot name it (OpenCode's MCP calls carry none), by its tool, as the
|
|
251
|
+
* harness reports it, and its arguments' digest (argsDigest). */
|
|
252
|
+
export type ParkedCall = {
|
|
253
|
+
callId: string;
|
|
254
|
+
} | {
|
|
255
|
+
tool: string;
|
|
256
|
+
argsDigest: string;
|
|
257
|
+
};
|
|
258
|
+
/** The digest a park by tool and arguments is matched on: the sha256 of the arguments' canonical JSON, in hex. */
|
|
259
|
+
export declare const argsDigest: (args: unknown) => string;
|
|
260
|
+
/** Whether the tool result `result` ends the turn `parked` waits in (harness-app.ts asks it at each one): the parked
|
|
261
|
+
* call's own, by its id; or, for a park by tool and arguments, the next result of that tool with those arguments. */
|
|
262
|
+
export declare function endsTurn(parked: ParkedCall | undefined, result: {
|
|
263
|
+
callId: string;
|
|
264
|
+
tool: string;
|
|
265
|
+
args: unknown;
|
|
266
|
+
}): boolean;
|