@parcha/agentrun-serve 0.0.0-bootstrap.0 → 0.1.0-beta.29
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 +560 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +1724 -0
- package/dist/adapters.d.ts +205 -0
- package/dist/adapters.js +459 -0
- package/dist/agents.d.ts +124 -0
- package/dist/agents.js +302 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +324 -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-image.d.ts +98 -0
- package/dist/box-image.js +283 -0
- package/dist/box-relay.d.ts +42 -0
- package/dist/box-relay.js +222 -0
- package/dist/boxes.d.ts +54 -0
- package/dist/boxes.js +182 -0
- package/dist/cap.d.ts +224 -0
- package/dist/cap.js +721 -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 +31 -0
- package/dist/coding-tools.js +81 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +1141 -0
- package/dist/console/assets/index-BN7oVcO4.js +445 -0
- package/dist/console/assets/index-By-jkqki.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/daytona-api.d.ts +21 -0
- package/dist/daytona-api.js +101 -0
- package/dist/decision-rows.d.ts +11 -0
- package/dist/decision-rows.js +116 -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 +72 -0
- package/dist/errors.js +66 -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 +60 -0
- package/dist/files.js +153 -0
- package/dist/grade.d.ts +96 -0
- package/dist/grade.js +348 -0
- package/dist/graph-view.d.ts +100 -0
- package/dist/graph-view.js +212 -0
- package/dist/harness-app.d.ts +38 -0
- package/dist/harness-app.js +626 -0
- package/dist/harness.d.ts +53 -0
- package/dist/harness.js +74 -0
- package/dist/home-path.d.ts +27 -0
- package/dist/home-path.js +78 -0
- package/dist/host-tools.d.ts +20 -0
- package/dist/host-tools.js +140 -0
- package/dist/host.d.ts +39 -0
- package/dist/host.js +81 -0
- package/dist/hosted-search.d.ts +27 -0
- package/dist/hosted-search.js +129 -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 +1221 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/key-check.d.ts +36 -0
- package/dist/key-check.js +108 -0
- package/dist/key-refusal.d.ts +51 -0
- package/dist/key-refusal.js +187 -0
- package/dist/learn/check.d.ts +99 -0
- package/dist/learn/check.js +259 -0
- package/dist/learn/grade.d.ts +79 -0
- package/dist/learn/grade.js +433 -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 +146 -0
- package/dist/learn/reflect.d.ts +49 -0
- package/dist/learn/reflect.js +167 -0
- package/dist/learn/secrets.d.ts +18 -0
- package/dist/learn/secrets.js +111 -0
- package/dist/learn/skills.d.ts +84 -0
- package/dist/learn/skills.js +198 -0
- package/dist/learning-routes.d.ts +196 -0
- package/dist/learning-routes.js +609 -0
- package/dist/learning-run.d.ts +304 -0
- package/dist/learning-run.js +797 -0
- package/dist/learning-words.d.ts +73 -0
- package/dist/learning-words.js +171 -0
- package/dist/learning.d.ts +377 -0
- package/dist/learning.js +801 -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 +115 -0
- package/dist/mcp-servers.js +445 -0
- package/dist/mcp.d.ts +51 -0
- package/dist/mcp.js +392 -0
- package/dist/model.d.ts +184 -0
- package/dist/model.js +484 -0
- package/dist/monid.d.ts +74 -0
- package/dist/monid.js +277 -0
- package/dist/openapi/agentrun-v2.openapi.json +4805 -0
- package/dist/openapi.d.ts +10 -0
- package/dist/openapi.js +1417 -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 +46 -0
- package/dist/paid-calls.js +110 -0
- package/dist/pause.d.ts +68 -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 +46 -0
- package/dist/place.js +105 -0
- package/dist/print.d.ts +20 -0
- package/dist/print.js +29 -0
- package/dist/propose.d.ts +38 -0
- package/dist/propose.js +82 -0
- package/dist/quiet-sqlite-warning.d.ts +1 -0
- package/dist/quiet-sqlite-warning.js +14 -0
- package/dist/request-start.d.ts +14 -0
- package/dist/request-start.js +226 -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 +134 -0
- package/dist/run-box.js +440 -0
- package/dist/run-manifest.d.ts +27 -0
- package/dist/run-manifest.js +60 -0
- package/dist/runnable.d.ts +80 -0
- package/dist/runnable.js +162 -0
- package/dist/runs.d.ts +840 -0
- package/dist/runs.js +2279 -0
- package/dist/secret-cut.d.ts +27 -0
- package/dist/secret-cut.js +109 -0
- package/dist/secrets.d.ts +50 -0
- package/dist/secrets.js +140 -0
- package/dist/server-lock.d.ts +44 -0
- package/dist/server-lock.js +140 -0
- package/dist/server.d.ts +626 -0
- package/dist/server.js +1756 -0
- package/dist/sessions.d.ts +4 -0
- package/dist/sessions.js +105 -0
- package/dist/skills.d.ts +31 -0
- package/dist/skills.js +68 -0
- package/dist/stats.d.ts +101 -0
- package/dist/stats.js +82 -0
- package/dist/tool-keys.d.ts +151 -0
- package/dist/tool-keys.js +273 -0
- package/dist/tool-plane.d.ts +143 -0
- package/dist/tool-plane.js +242 -0
- package/dist/tools.d.ts +147 -0
- package/dist/tools.js +253 -0
- package/dist/turn-end.d.ts +23 -0
- package/dist/turn-end.js +14 -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.d.ts +29 -0
- package/dist/usage.js +58 -0
- package/dist/validate.d.ts +55 -0
- package/dist/validate.js +175 -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 +182 -0
- package/dist/webhooks.js +487 -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 +96 -1
- package/skills/agentrun-serve/SKILL.md +128 -0
package/dist/runnable.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// What keeps a revision from running on this host, checked when a definition is saved and again before each run, so
|
|
2
|
+
// the two cannot drift. A blocker no setting of this host fixes (a tool it does not bind, a model pi-ai does not know,
|
|
3
|
+
// no instructions, a workflow needing what it does not give) refuses the save, 422 by field; one a setting fixes (a
|
|
4
|
+
// provider's key, a default model, a tier's model) saves as a warning. Either refuses a run, 409 agent_not_runnable.
|
|
5
|
+
import { WORKFLOW_ADAPTERS } from "./app.js";
|
|
6
|
+
import { DECISION_ADAPTER, providerMissing, providersNamed } from "./decisions.js";
|
|
7
|
+
import { REPLAY } from "./host-tools.js";
|
|
8
|
+
import { sentence } from "./errors.js";
|
|
9
|
+
import { DEFAULT_HARNESS, FAUX_HARNESS_ENV, harnessOffers } from "./harness.js";
|
|
10
|
+
import { chooseModel, llmTiers, nodeTiers, workflowNodes } from "./model.js";
|
|
11
|
+
import { boxAvailability, placeFix, RUN_BOXES } from "./place.js";
|
|
12
|
+
import { allows, BOUND_TOOLS, CALL_TOOLS, grantedTools, missingEnv, NODE_TOOLS, toolOf, workflowTools } from "./tools.js";
|
|
13
|
+
import { capabilityOf, isUnavailable, NO_PARALLEL_KEY, planeFor, whyUnavailable } from "./tool-plane.js";
|
|
14
|
+
import { PARALLEL_KEY_ENV } from "./decisions.js";
|
|
15
|
+
/**
|
|
16
|
+
* The model `harness` runs an agentic revision on here: `ref`, its own `provider/model-id`, or with none this host's
|
|
17
|
+
* default for that harness. `why`: the model itself is the problem (`host`, a setting of this host could fix it);
|
|
18
|
+
* `refused`: the harness runs here but refuses that model. Undefined when claude-agent does not run here: its model is
|
|
19
|
+
* its own, and the harness says why. A save, a run and capabilities' `harnesses[].default_model` all ask this, so they
|
|
20
|
+
* cannot drift.
|
|
21
|
+
*/
|
|
22
|
+
export async function harnessModel(env, harness, ref, available) {
|
|
23
|
+
// claude-agent's model is its own (adapters.ts), never routed through the other harnesses' gateway; on the faux
|
|
24
|
+
// harness every harness takes the run's usual model.
|
|
25
|
+
const own = harness === "claude-agent" && !env[FAUX_HARNESS_ENV];
|
|
26
|
+
if (own && !available)
|
|
27
|
+
return undefined;
|
|
28
|
+
// codex's is the run's usual model, but an OpenAI model it reaches through OpenRouter alone is OpenRouter's (codexRef).
|
|
29
|
+
const chosen = own ? (await import("./adapters.js")).claudeModel(env, ref) : harness === "codex" ? await (await import("./adapters.js")).codexModel(env, ref) : await chooseModel(env, ref, "default", harness);
|
|
30
|
+
if ("why" in chosen)
|
|
31
|
+
return chosen;
|
|
32
|
+
// The harness runs here; whether it runs this model (the revision's, or the default) is checked on it.
|
|
33
|
+
if (harness !== DEFAULT_HARNESS && available) {
|
|
34
|
+
const { harnessReason } = await import("./adapters.js");
|
|
35
|
+
const refused = await harnessReason(harness, env, { model: chosen.model, models: { getModel: () => undefined } });
|
|
36
|
+
if (refused !== undefined)
|
|
37
|
+
return { refused };
|
|
38
|
+
}
|
|
39
|
+
return { model: chosen.model };
|
|
40
|
+
}
|
|
41
|
+
/** The reason a warning gives: the revision runs once this host has what it names. */
|
|
42
|
+
export const NOT_SET_UP = "not_set_up_here";
|
|
43
|
+
/** Set to 1 (`--allow-code-nodes`), this server runs workflows' `code` nodes: in the run's process, through the DSL's
|
|
44
|
+
* `new Function` transform, which is no sandbox. Off by default. */
|
|
45
|
+
export const CODE_NODES_ENV = "AGENTRUN_SERVE_CODE_NODES";
|
|
46
|
+
/** What keeps `revision` from running in `env` under the server's tool `settings` (tool-plane.ts). `boxes`: what this
|
|
47
|
+
* server's box registry set up at its start (boxes.ts); none, every box is unavailable. `offers`: the harnesses' offers
|
|
48
|
+
* the server already holds (its reading); none given, they are probed here. */
|
|
49
|
+
export async function blockersOf(env, revision, settings = {}, { capped = false, boxes = [], offers } = {}) {
|
|
50
|
+
const out = [];
|
|
51
|
+
/** A web tool its run would resolve unavailable (tool-plane.ts): a warning at save, a 409 at a run, never another
|
|
52
|
+
* provider in its place. */
|
|
53
|
+
const unavailable = (field, tools, tool) => {
|
|
54
|
+
const resolved = planeFor(env, { tools, harness, ...(revision.kind === "workflow" ? { workflow: true } : {}), ...(revision.kind === "agentic" && revision.model ? { model: revision.model } : {}), ...(revision.toolSettings ? { overrides: revision.toolSettings } : {}) }, settings, { capped })[capabilityOf(tool)];
|
|
55
|
+
if (isUnavailable(resolved))
|
|
56
|
+
out.push({ field, reason: NOT_SET_UP, message: `The tool ${tool} does not run here on ${harness}: ${whyUnavailable(resolved)}.`, host: true, ...(resolved === NO_PARALLEL_KEY ? { missing: { tool, vars: [PARALLEL_KEY_ENV] } } : {}) });
|
|
57
|
+
};
|
|
58
|
+
/** A bound tool whose variables this host does not set: a warning at save, a 409 at a run. */
|
|
59
|
+
const unset = (field, tool) => {
|
|
60
|
+
const vars = missingEnv(toolOf(tool), env);
|
|
61
|
+
if (vars.length)
|
|
62
|
+
out.push({ field, reason: NOT_SET_UP, message: `This server's environment does not set what the tool needs: the tool ${tool} needs ${vars.join(" and ")}.`, host: true, missing: { tool, vars } });
|
|
63
|
+
};
|
|
64
|
+
const harness = revision.harness ?? DEFAULT_HARNESS;
|
|
65
|
+
const offer = (offers ?? (await harnessOffers(env))).find((h) => h.id === harness);
|
|
66
|
+
if (!offer?.available)
|
|
67
|
+
out.push({ field: "definition.harness", reason: NOT_SET_UP, message: offer?.reason ?? `This server does not run ${harness}.`, host: true, harness });
|
|
68
|
+
const { place } = revision;
|
|
69
|
+
// A workflow's model and call nodes run on the runner here; in a box they do not run yet. Its fix names the runner: an
|
|
70
|
+
// edit that leaves the place out keeps the agent's (agents.ts), so removing the field would change nothing.
|
|
71
|
+
if (revision.kind === "workflow" && place && place.mode !== "runner")
|
|
72
|
+
out.push({ field: "definition.place", reason: "not_an_option", message: `A workflow runs on the runner here: its place is runner (or none), not ${place.mode} on ${place.box ?? "no box"}.`, fix: placeFix({ mode: "runner" }), host: false });
|
|
73
|
+
else if (place && place.mode !== "runner") {
|
|
74
|
+
const box = boxAvailability(boxes).find((b) => b.id === place.box);
|
|
75
|
+
// A box's reason says what to do, with no full stop of its own: the sentence ends in one, whatever the reason ends in.
|
|
76
|
+
if (!box?.available)
|
|
77
|
+
out.push({ field: "definition.place", reason: NOT_SET_UP, message: sentence(`This agent's place is ${place.mode} on ${place.box ?? "no box"}, and this server cannot run it there: ${box?.reason ?? "that is not a box this server has"}`), host: true, ...(place.box ? { box: place.box } : {}) });
|
|
78
|
+
}
|
|
79
|
+
if (revision.kind === "agentic") {
|
|
80
|
+
if (!revision.instructions.trim())
|
|
81
|
+
out.push({ field: "definition.instructions", reason: "too_short", message: "definition.instructions is empty: an agentic revision needs instructions.", host: false });
|
|
82
|
+
(revision.tools ?? []).forEach((tool, index) => {
|
|
83
|
+
if (!allows(BOUND_TOOLS, tool))
|
|
84
|
+
out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `agentrun-serve binds the tools ${BOUND_TOOLS.join(", ")}; ${tool} is not one of them.`, host: false, tool });
|
|
85
|
+
// A shell runs only in a box: no place, or the runner, has none.
|
|
86
|
+
else if (toolOf(tool).sandboxOnly && (place?.mode ?? "runner") === "runner")
|
|
87
|
+
out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `${tool} runs only in a box, and ${place ? "this agent's place is the runner" : "this agent names no place, so it runs on the runner"}, which has no shell: give it a sandbox place.`, fix: placeFix({ mode: "sandbox", box: RUN_BOXES[0] }), host: false, tool });
|
|
88
|
+
// Its writes into work/ go by path from this machine, and a box's command could swap a link in on their way.
|
|
89
|
+
else if (toolOf(tool).runnerOnly && place?.mode === "sandbox")
|
|
90
|
+
out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `${tool} does not run in a sandbox place yet: it saves files into the run's work/ from this server, outside the box, and a command in the box could point those writes elsewhere on this server. Give it to an agent whose place is the runner.`, fix: `Remove "${tool}" from definition.tools.`, host: false, tool });
|
|
91
|
+
// Another harness gets the host tools only (host-tools.ts: the file tools, fetch_page, web_fetch, web_search and
|
|
92
|
+
// monid's): any other tool this host binds, ask_person among them, is pi's here and refuses the run, never runs
|
|
93
|
+
// without it.
|
|
94
|
+
else if (harness !== DEFAULT_HARNESS && !(tool in REPLAY))
|
|
95
|
+
out.push({ field: `definition.tools[${index}]`, reason: NOT_SET_UP, message: `${tool} runs on pi here; on ${harness} it is not bound yet.`, host: true, tool });
|
|
96
|
+
else {
|
|
97
|
+
unset(`definition.tools[${index}]`, tool);
|
|
98
|
+
unavailable(`definition.tools[${index}]`, revision.tools ?? [], tool);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const resolved = await harnessModel(env, harness, revision.model, offer?.available === true);
|
|
102
|
+
if (!resolved)
|
|
103
|
+
return out;
|
|
104
|
+
if ("why" in resolved)
|
|
105
|
+
out.push({ field: "definition.model", reason: resolved.host ? NOT_SET_UP : "not_an_option", message: resolved.why, host: resolved.host });
|
|
106
|
+
else if ("refused" in resolved)
|
|
107
|
+
out.push({ field: revision.model ? "definition.model" : "definition.harness", reason: NOT_SET_UP, message: resolved.refused, host: true, harness });
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
// A workflow's model nodes run on pi here; on another harness they are not bound yet, and never run on pi instead.
|
|
111
|
+
if (harness !== DEFAULT_HARNESS)
|
|
112
|
+
out.push({ field: "definition.workflow", reason: NOT_SET_UP, message: `A workflow runs on pi here; on ${harness} its model nodes are not bound yet.`, host: true, harness });
|
|
113
|
+
const { inspectWorkflow } = await import("@parcha/agentrun-dsl");
|
|
114
|
+
const inspection = inspectWorkflow(revision.workflow);
|
|
115
|
+
const { requires } = inspection;
|
|
116
|
+
const nodes = workflowNodes(revision.workflow, inspection);
|
|
117
|
+
const runs = "agentrun-serve runs a workflow's model nodes (agent, decide, extract, report)";
|
|
118
|
+
for (const adapter of requires.adapters.filter((name) => !WORKFLOW_ADAPTERS.includes(name))) {
|
|
119
|
+
// Typed questions run on the provider each node names (Jev for one that names none) once this host sets its key:
|
|
120
|
+
// until then a warning at save, a 409 at a run. A provider this server does not have refuses the save.
|
|
121
|
+
if (adapter === DECISION_ADAPTER) {
|
|
122
|
+
for (const provider of providersNamed(nodes)) {
|
|
123
|
+
const missing = providerMissing(env, provider);
|
|
124
|
+
if (!missing)
|
|
125
|
+
continue;
|
|
126
|
+
out.push(missing.needs
|
|
127
|
+
? { field: "definition.workflow", reason: NOT_SET_UP, message: missing.message, host: true, adapter, decision: { provider, needs: missing.needs } }
|
|
128
|
+
: { field: "definition.workflow", reason: "not_an_option", message: missing.message, host: false, adapter });
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
out.push({ field: "definition.workflow", reason: "not_an_option", message: `${runs}; this workflow also needs ${adapter}.`, host: false, adapter });
|
|
133
|
+
}
|
|
134
|
+
// `code` nodes run here (the DSL's pure transform) when the server allows them; a call through a shell or the executor never does.
|
|
135
|
+
const shells = nodes.some((node) => node.node === "call" && (node.via === "shell" || node.via === "executor"));
|
|
136
|
+
if (requires.executableCode && shells)
|
|
137
|
+
out.push({ field: "definition.workflow", reason: "not_an_option", message: `${runs}, code nodes and calls via tool; this workflow also calls a shell or the executor.`, host: false, shell: true });
|
|
138
|
+
else if (requires.executableCode && env[CODE_NODES_ENV] !== "1")
|
|
139
|
+
out.push({ field: "definition.workflow", reason: NOT_SET_UP, message: `This server runs no code nodes: start it with --allow-code-nodes (or ${CODE_NODES_ENV}=1) to run this workflow's.`, host: true, codeNodes: true });
|
|
140
|
+
const named = workflowTools(nodes);
|
|
141
|
+
for (const tool of named.nodes) {
|
|
142
|
+
if (!allows(NODE_TOOLS, tool))
|
|
143
|
+
out.push({ field: "definition.workflow", reason: "not_an_option", message: `A workflow's model nodes get the tools ${NODE_TOOLS.join(", ")} here; this workflow also names ${tool}.`, host: false, tool });
|
|
144
|
+
}
|
|
145
|
+
for (const tool of named.calls) {
|
|
146
|
+
if (!allows(CALL_TOOLS, tool))
|
|
147
|
+
out.push({ field: "definition.workflow", reason: "not_an_option", message: `A workflow's call nodes run the tools ${CALL_TOOLS.join(", ")} here; this workflow also calls ${tool}.`, host: false, tool });
|
|
148
|
+
}
|
|
149
|
+
const granted = await grantedTools(revision);
|
|
150
|
+
for (const tool of new Set([...named.nodes.filter((name) => allows(NODE_TOOLS, name)), ...named.calls.filter((name) => allows(CALL_TOOLS, name))])) {
|
|
151
|
+
unset("definition.workflow", tool);
|
|
152
|
+
unavailable("definition.workflow", granted, tool);
|
|
153
|
+
}
|
|
154
|
+
for (const tier of llmTiers(nodes, nodeTiers(nodes))) {
|
|
155
|
+
const chosen = await chooseModel(env, undefined, tier);
|
|
156
|
+
if ("why" in chosen)
|
|
157
|
+
out.push({ field: "definition.workflow", reason: NOT_SET_UP, message: chosen.why, host: true, tier });
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
/** A blocker as a field issue, for a 422 or a warning. */
|
|
162
|
+
export const issueOf = ({ field, reason, message, fix }) => ({ field, reason, message, ...(fix ? { fix } : {}) });
|