@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.61
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 +58 -0
- package/README.md +42 -14
- package/dist/acp-package.d.ts +4 -0
- package/dist/api-only.d.ts +19 -1
- package/dist/api-only.js +38 -3
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/cli.js +42 -10
- package/dist/console/assets/{backend-QnwGVBeU.js → backend-C9ffXUR5.js} +1 -1
- package/dist/console/assets/index-BnZV3lvW.js +639 -0
- package/dist/console/assets/{share-pz61zIn9.js → share-B1o5mJ56.js} +2 -2
- package/dist/console/assets/{styles-CcceGcu2.js → styles-D_znYrHR.js} +2 -2
- package/dist/console/index.html +2 -2
- package/dist/console/share.html +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +5 -3
- package/dist/harness-table.js +7 -5
- package/dist/key-refusal.js +6 -4
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learned-nodes.d.ts +36 -0
- package/dist/learned-nodes.js +23 -0
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/ollama-provider.d.ts +35 -0
- package/dist/ollama-provider.js +108 -2
- package/dist/openapi.js +59 -7
- package/dist/place.d.ts +7 -6
- package/dist/place.js +13 -10
- package/dist/print.js +1 -1
- package/dist/redact/match.d.ts +17 -4
- package/dist/redact/match.js +57 -15
- package/dist/run-export.js +4 -2
- package/dist/run-usage.js +3 -2
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +100 -20
- package/dist/runner/adapter-run-spec.d.ts +3 -5
- package/dist/runner/adapter-run-spec.js +26 -43
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +13 -10
- package/dist/runner/compare-end.d.ts +1 -1
- package/dist/runner/dispatch.js +2 -2
- package/dist/runner/harness-loops.d.ts +9 -0
- package/dist/runner/harness-loops.js +47 -4
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/live-ticker.js +3 -4
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +19 -4
- package/dist/runner/mcp-run.js +29 -2
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -3
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +1 -1
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/run-child-host.js +1 -1
- package/dist/runner/sdk-loop.js +5 -3
- package/dist/runner/workflow-calls.d.ts +4 -1
- package/dist/runner/workflow-calls.js +35 -18
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.js +97 -83
- package/dist/server.d.ts +7 -0
- package/dist/server.js +97 -34
- package/dist/slack.js +2 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store-reads/learning.d.ts +5 -4
- package/dist/store-reads/learning.js +7 -4
- package/dist/tool-plane.d.ts +23 -1
- package/dist/tool-plane.js +70 -2
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/package.json +12 -12
- package/dist/console/assets/index-DZi-muIj.js +0 -629
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// A free local model on the owner's own machine: what the machine is (platform, arch, memory, GPU) and its Ollama, the
|
|
2
|
+
// model this server recommends for it (recommendLocalModel, a pure function of those facts), and one pull of it at a time
|
|
3
|
+
// through that Ollama, its progress on the read surface (GET /settings/local-model). A pull is only ever of a tag the
|
|
4
|
+
// recommendation can name (LOCAL_MODEL_TAGS), and only where the Ollama here is the owner's own: one owner's own server on
|
|
5
|
+
// their own machine (server.ts whyNotOwnMachine, the rule ollama-provider.ts ollamaHostOf names the default address by),
|
|
6
|
+
// never under the faux model or a model gateway (model.ts asksOllama). Once a pull ends, the kept listing is dropped
|
|
7
|
+
// (ollamaForget), so the model is in the picker at once.
|
|
8
|
+
import { execFile } from "node:child_process";
|
|
9
|
+
import { arch, platform, totalmem } from "node:os";
|
|
10
|
+
import { ApiError } from "./errors.js";
|
|
11
|
+
import { isLoopbackName } from "./host-check.js";
|
|
12
|
+
import { asksOllama, FAUX_ENV } from "./model.js";
|
|
13
|
+
import { ollamaBase, ollamaModels, ollamaPull, ollamaVersion } from "./ollama-provider.js";
|
|
14
|
+
import { logLine } from "./print.js";
|
|
15
|
+
import { registerSecretPage, registerSecretWrite } from "./secret-writes.js";
|
|
16
|
+
import { isObject, unknownFields } from "./validate.js";
|
|
17
|
+
// Owner-only: the machine's facts are the owner's, and a pull spends their disk and bandwidth.
|
|
18
|
+
for (const operation of ["getLocalModel", "pullLocalModel"])
|
|
19
|
+
registerSecretWrite(operation, () => true);
|
|
20
|
+
registerSecretPage(["getLocalModel", "pullLocalModel"], "/#/");
|
|
21
|
+
/** The non-Apple pick, and Apple's where Inkling does not run: one line. A measurement (qwen3:8b against qwen3:30b-a3b,
|
|
22
|
+
* through this server's own runs) sets it. */
|
|
23
|
+
export const QWEN3_DEFAULT = "qwen3:8b";
|
|
24
|
+
/** Apple silicon's pick, where its Ollama runs it (MLX, on Apple silicon alone). */
|
|
25
|
+
export const INKLING = "inkling-2-mini";
|
|
26
|
+
/** The first Ollama that runs INKLING. */
|
|
27
|
+
export const INKLING_OLLAMA = "0.40.17";
|
|
28
|
+
/** Where Ollama is installed from. */
|
|
29
|
+
export const OLLAMA_DOWNLOAD = "https://ollama.com/download";
|
|
30
|
+
const GIB = 1024 ** 3;
|
|
31
|
+
/** The least memory (total RAM; Apple silicon's unified memory) each tag is offered on, in GiB: its weights at Ollama's
|
|
32
|
+
* default quantization, the KV cache of the context this server asks (ollama-provider.ts contextOf), and room for the
|
|
33
|
+
* system. A machine sold as 16 GB reads about 15.5 GiB, so each floor sits under the size it is meant for. */
|
|
34
|
+
export const RAM_FLOOR_GIB = {
|
|
35
|
+
[INKLING]: 15,
|
|
36
|
+
"qwen3:30b-a3b": 30,
|
|
37
|
+
"qwen3:8b": 15,
|
|
38
|
+
"qwen3:4b": 11,
|
|
39
|
+
};
|
|
40
|
+
/** The qwen3 tags, largest first: the pick is QWEN3_DEFAULT, else the next smaller that fits. */
|
|
41
|
+
const QWEN3_LADDER = ["qwen3:30b-a3b", "qwen3:8b", "qwen3:4b"];
|
|
42
|
+
const QWEN3_FITS = QWEN3_LADDER.slice(Math.max(0, QWEN3_LADDER.indexOf(QWEN3_DEFAULT)));
|
|
43
|
+
/** Every tag the recommendation can name, and so the only tags a pull here takes. */
|
|
44
|
+
export const LOCAL_MODEL_TAGS = Object.freeze([INKLING, ...QWEN3_FITS]);
|
|
45
|
+
/** A tag as Ollama lists it: with no `:`, `:latest`. */
|
|
46
|
+
export const fullTag = (tag) => (tag.includes(":") ? tag : `${tag}:latest`);
|
|
47
|
+
const gib = (bytes) => `${(bytes / GIB).toFixed(1)} GiB`;
|
|
48
|
+
const fits = (machine, tag) => machine.ram_bytes >= (RAM_FLOOR_GIB[tag] ?? Infinity) * GIB;
|
|
49
|
+
const needs = (tag) => `${tag} needs ${RAM_FLOOR_GIB[tag]} GiB of memory`;
|
|
50
|
+
/** `version` at or past `floor`, both dotted numbers (a suffix such as `-rc1` ignored); an unreadable version is not. */
|
|
51
|
+
export function versionAtLeast(version, floor) {
|
|
52
|
+
const parts = (text) => /^v?(\d+)\.(\d+)\.(\d+)/.exec(text.trim())?.slice(1).map(Number);
|
|
53
|
+
const [have, want] = [parts(version), parts(floor)];
|
|
54
|
+
if (!have || !want)
|
|
55
|
+
return false;
|
|
56
|
+
for (let i = 0; i < 3; i++)
|
|
57
|
+
if (have[i] !== want[i])
|
|
58
|
+
return have[i] > want[i];
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
/** Whether this machine is Apple silicon. */
|
|
62
|
+
const appleSilicon = (machine) => machine.gpu.kind === "apple";
|
|
63
|
+
/**
|
|
64
|
+
* The model this server recommends for `facts`, and why. No Ollama: none, and where to install it. Apple silicon with an
|
|
65
|
+
* Ollama at INKLING_OLLAMA or later and the memory for it: INKLING. Everyone else: QWEN3_DEFAULT, or the next smaller qwen3
|
|
66
|
+
* that fits in memory, or none, saying what each needs; Apple silicon on an older Ollama is told to update for INKLING. A
|
|
67
|
+
* tag already pulled says so: no pull needed.
|
|
68
|
+
*/
|
|
69
|
+
export function recommendLocalModel(facts) {
|
|
70
|
+
const { machine, ollama } = facts;
|
|
71
|
+
if (!ollama.asked)
|
|
72
|
+
return { tag: null, why: "This server asks no Ollama.", pulled: false };
|
|
73
|
+
if (!ollama.reachable)
|
|
74
|
+
return { tag: null, why: `Ollama isn't running on this machine. Install it from ${OLLAMA_DOWNLOAD}, start it, then come back here.`, pulled: false };
|
|
75
|
+
const has = new Set(facts.pulled.map(fullTag));
|
|
76
|
+
const done = (tag, why) => (has.has(fullTag(tag)) ? { tag, why: `${why} Already pulled: no pull needed.`, pulled: true } : { tag, why, pulled: false });
|
|
77
|
+
const apple = appleSilicon(machine);
|
|
78
|
+
const inklingRuns = apple && versionAtLeast(ollama.version, INKLING_OLLAMA);
|
|
79
|
+
if (inklingRuns && fits(machine, INKLING))
|
|
80
|
+
return done(INKLING, `Apple silicon with Ollama ${ollama.version} runs ${INKLING}; ${needs(INKLING)}, and this Mac has ${gib(machine.ram_bytes)}.`);
|
|
81
|
+
const notes = [
|
|
82
|
+
...(apple && !inklingRuns ? [`Update Ollama to ${INKLING_OLLAMA} for ${INKLING}.`] : []),
|
|
83
|
+
...(inklingRuns ? [`${needs(INKLING)}, and this Mac has ${gib(machine.ram_bytes)}.`] : []),
|
|
84
|
+
];
|
|
85
|
+
const tag = QWEN3_FITS.find((candidate) => fits(machine, candidate));
|
|
86
|
+
if (!tag) {
|
|
87
|
+
const least = QWEN3_FITS[QWEN3_FITS.length - 1];
|
|
88
|
+
return { tag: null, why: [`This machine has ${gib(machine.ram_bytes)} of memory, and the smallest local model offered here, ${needs(least)}. Add a model key instead.`, ...notes].join(" "), pulled: false };
|
|
89
|
+
}
|
|
90
|
+
const smaller = tag === QWEN3_DEFAULT ? "" : ` ${needs(QWEN3_DEFAULT)}, so the smaller ${tag}.`;
|
|
91
|
+
return done(tag, [`${tag} fits this machine's ${gib(machine.ram_bytes)} of memory (it needs ${RAM_FLOOR_GIB[tag]} GiB).${smaller}`, ...notes].join(" "));
|
|
92
|
+
}
|
|
93
|
+
// ---- the machine ------------------------------------------------------------------------------------------------------
|
|
94
|
+
/** How long nvidia-smi is waited for. */
|
|
95
|
+
export const NVIDIA_SMI_TIMEOUT_MS = 2_000;
|
|
96
|
+
/** The first GPU nvidia-smi names (`name, memory.total` in MiB), or unknown where it is not there, fails or is slow. */
|
|
97
|
+
async function nvidiaGpu() {
|
|
98
|
+
const out = await new Promise((resolve) => {
|
|
99
|
+
execFile("nvidia-smi", ["--query-gpu=name,memory.total", "--format=csv,noheader,nounits"], { timeout: NVIDIA_SMI_TIMEOUT_MS, windowsHide: true }, (error, stdout) => resolve(error ? undefined : stdout));
|
|
100
|
+
});
|
|
101
|
+
return nvidiaOf(out);
|
|
102
|
+
}
|
|
103
|
+
/** nvidia-smi's first line, `<name>, <MiB>`, as a GPU; unknown for anything else. */
|
|
104
|
+
export function nvidiaOf(out) {
|
|
105
|
+
const line = out?.split("\n").map((text) => text.trim()).find(Boolean);
|
|
106
|
+
const match = line ? /^(.+?),\s*(\d+)(?:\s*MiB)?$/.exec(line) : null;
|
|
107
|
+
return match ? { kind: "nvidia", name: match[1].trim().slice(0, 200), memory_bytes: Number(match[2]) * 1024 ** 2 } : { kind: "unknown" };
|
|
108
|
+
}
|
|
109
|
+
/** This machine, read once: what a server serves for its life. A test hands its own (ServeOptions.machine). */
|
|
110
|
+
export async function readMachine() {
|
|
111
|
+
const [os, cpu] = [platform(), arch()];
|
|
112
|
+
const gpu = os === "darwin" && cpu === "arm64" ? { kind: "apple", unified: true } : await nvidiaGpu();
|
|
113
|
+
return { platform: os, arch: cpu, ram_bytes: totalmem(), gpu };
|
|
114
|
+
}
|
|
115
|
+
/** One pull at a time, through `pull`; `finished` once it succeeds (the listing dropped and read again), before it reads
|
|
116
|
+
* done. A log line at its start, its end and its failure: the tag, the bytes and the milliseconds, nothing else. */
|
|
117
|
+
export function localPulls({ pull, finished, log, signal }) {
|
|
118
|
+
let current;
|
|
119
|
+
return {
|
|
120
|
+
view: () => (current ? { ...current } : null),
|
|
121
|
+
pulling: () => current?.state === "pulling",
|
|
122
|
+
/** Starts pulling `tag` (checked by the caller), behind the answer. */
|
|
123
|
+
start(tag) {
|
|
124
|
+
const layers = new Map();
|
|
125
|
+
const mine = { tag, state: "pulling", status: "starting", completed_bytes: 0, total_bytes: 0 };
|
|
126
|
+
current = mine;
|
|
127
|
+
const started = performance.now();
|
|
128
|
+
log?.(logLine("local_model_pull_start", { tag }));
|
|
129
|
+
const onLine = (line) => {
|
|
130
|
+
mine.status = line.status.slice(0, 200);
|
|
131
|
+
if (line.digest && line.total !== undefined) {
|
|
132
|
+
layers.set(line.digest, { total: line.total, completed: Math.min(line.completed ?? 0, line.total) });
|
|
133
|
+
mine.total_bytes = [...layers.values()].reduce((sum, layer) => sum + layer.total, 0);
|
|
134
|
+
mine.completed_bytes = [...layers.values()].reduce((sum, layer) => sum + layer.completed, 0);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
void pull(tag, onLine, signal)
|
|
138
|
+
.then(() => finished(tag))
|
|
139
|
+
.then(() => {
|
|
140
|
+
Object.assign(mine, { state: "done", status: "success", completed_bytes: mine.total_bytes });
|
|
141
|
+
log?.(logLine("local_model_pull_end", { tag, bytes: mine.total_bytes, ms: Math.round(performance.now() - started) }));
|
|
142
|
+
})
|
|
143
|
+
.catch((error) => {
|
|
144
|
+
Object.assign(mine, { state: "failed", error: (error instanceof Error ? error.message : String(error)).slice(0, 500) });
|
|
145
|
+
log?.(logLine("local_model_pull_failed", { tag, bytes: mine.completed_bytes, ms: Math.round(performance.now() - started) }));
|
|
146
|
+
});
|
|
147
|
+
return { ...mine };
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// ---- the route --------------------------------------------------------------------------------------------------------
|
|
152
|
+
/** Whether the Ollama `env` names is on another machine: OLLAMA_HOST names an address that is not this machine's own
|
|
153
|
+
* (a loopback name). This server reads only its own memory and GPU, so it recommends and pulls nothing for that one. An
|
|
154
|
+
* address the base rule refuses is no Ollama asked at all, and not said to be elsewhere. */
|
|
155
|
+
export function ollamaElsewhere(env) {
|
|
156
|
+
if (!env.OLLAMA_HOST?.trim())
|
|
157
|
+
return false;
|
|
158
|
+
try {
|
|
159
|
+
return !isLoopbackName(new URL(ollamaBase(env)).hostname);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** The words for an Ollama on another machine (ollamaElsewhere), which never name its address. */
|
|
166
|
+
export const OLLAMA_ELSEWHERE = "The Ollama OLLAMA_HOST names is on another machine, and this server reads only its own memory and GPU, so it recommends and pulls no model for that one. Pull one where that Ollama runs: ollama pull <tag>.";
|
|
167
|
+
/** Why no pull is made through the Ollama `env` names, in words, or undefined where one may: the faux model or a model
|
|
168
|
+
* gateway takes every model here (asksOllama); a server that is not one owner's own on their own machine (`notOwn`,
|
|
169
|
+
* server.ts whyNotOwnMachine's reasons) pulls nothing into an Ollama that is not theirs. */
|
|
170
|
+
export function pullRefusal(env, notOwn) {
|
|
171
|
+
if (env[FAUX_ENV])
|
|
172
|
+
return "This server runs the faux model, so no local model is pulled here.";
|
|
173
|
+
if (!asksOllama(env))
|
|
174
|
+
return "This server sends every model to its model gateway (AGENT_MODEL_BASE_URL), so a local model would not run here.";
|
|
175
|
+
if (notOwn.length)
|
|
176
|
+
return `A local model is pulled from here only on one owner's own server on their own machine, and this server ${notOwn.join("; ")}. Pull it where Ollama runs: ollama pull <tag>.`;
|
|
177
|
+
if (!env.OLLAMA_HOST?.trim())
|
|
178
|
+
return "No Ollama is asked here.";
|
|
179
|
+
if (ollamaElsewhere(env))
|
|
180
|
+
return OLLAMA_ELSEWHERE;
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
/** The read surface: the machine, its Ollama, the recommendation, the pull here, and whether a pull may be made. */
|
|
184
|
+
export async function localModelView({ env, notOwn, machine, pulls }) {
|
|
185
|
+
const refused = pullRefusal(env, notOwn);
|
|
186
|
+
const asked = asksOllama(env);
|
|
187
|
+
const [facts, version, listed] = await Promise.all([machine(), asked ? ollamaVersion(env) : undefined, asked ? ollamaModels(env) : []]);
|
|
188
|
+
const ollama = !asked ? { asked: false, reachable: false, version: null } : version === undefined ? { asked: true, reachable: false, version: null } : { asked: true, reachable: true, version };
|
|
189
|
+
// An Ollama on another machine is not this machine's: no recommendation from this machine's memory and GPU for it.
|
|
190
|
+
const recommended = asked && ollamaElsewhere(env) ? { tag: null, why: OLLAMA_ELSEWHERE, pulled: false }
|
|
191
|
+
: recommendLocalModel({ machine: facts, ollama, pulled: listed.map((model) => model.name) });
|
|
192
|
+
// Not asked, the refusal is the only word on it: never that Ollama isn't running.
|
|
193
|
+
return { machine: facts, ollama, recommended: asked || !refused ? recommended : { ...recommended, why: refused }, pull: pulls.view(), can_pull: refused === undefined, refused: refused ?? null };
|
|
194
|
+
}
|
|
195
|
+
/** POST /settings/local-model/pull: `{ tag }`, one of LOCAL_MODEL_TAGS (422 otherwise), where a pull may be made (403 in
|
|
196
|
+
* words otherwise), none under way (409 local_model_pulling). Answers the read surface with the pull started. */
|
|
197
|
+
export async function pullLocalModel(deps, body) {
|
|
198
|
+
if (!isObject(body) || typeof body.tag !== "string")
|
|
199
|
+
throw new ApiError("input_invalid", "Name the tag to pull: { \"tag\": \"<tag>\" }.", { fields: [{ field: "tag", reason: "missing", message: "required, a string" }] });
|
|
200
|
+
const extra = unknownFields(body, ["tag"]);
|
|
201
|
+
if (extra.length)
|
|
202
|
+
throw new ApiError("input_invalid", extra.map((issue) => issue.message).join(" "), { fields: extra });
|
|
203
|
+
if (!LOCAL_MODEL_TAGS.includes(body.tag))
|
|
204
|
+
throw new ApiError("input_invalid", `Only the tags this server recommends are pulled from here: ${LOCAL_MODEL_TAGS.join(", ")}.`, { fields: [{ field: "tag", reason: "not_an_option", message: `one of ${LOCAL_MODEL_TAGS.join(", ")}` }] });
|
|
205
|
+
const refused = pullRefusal(deps.env, deps.notOwn);
|
|
206
|
+
if (refused)
|
|
207
|
+
throw new ApiError("forbidden", refused);
|
|
208
|
+
if (deps.pulls.pulling())
|
|
209
|
+
throw new ApiError("local_model_pulling", `A pull of ${deps.pulls.view()?.tag} is under way here: one at a time. Its progress is on GET /settings/local-model.`);
|
|
210
|
+
deps.pulls.start(body.tag);
|
|
211
|
+
return localModelView(deps);
|
|
212
|
+
}
|
|
213
|
+
/** The real pull: through the Ollama `env` names (ollama-provider.ts ollamaPull). */
|
|
214
|
+
export const pullThrough = (env, stallMs) => (tag, onLine, signal) => ollamaPull(env(), tag, onLine, { signal, ...(stallMs !== undefined ? { stallMs } : {}) });
|
package/dist/mcp-probe.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ export declare const UNUSABLE: {
|
|
|
20
20
|
* token handed, or which was sealed before the seal marked who handed it. */
|
|
21
21
|
readonly composioOwnersUser: "the Composio user this run is bound to is one the owner connects on this install, and nothing marks the binding as the owner's: hand mcp_auth again on a message, or start a new run";
|
|
22
22
|
};
|
|
23
|
+
/** What a run's timeline says of a server whose credential comes from each run when the run was handed none: its tools
|
|
24
|
+
* were left out of the run's (mcp-run.ts mcpForClaim), so the model is never offered a tool every call of which is
|
|
25
|
+
* refused. */
|
|
26
|
+
export declare const unconnectedWords: (server: string) => string;
|
|
27
|
+
/** The run's timeline note when a message hands the credential of servers whose tools its claim left out
|
|
28
|
+
* (unconnectedWords) while a turn is going: that turn's tools stay as they are, so the message waits for the next. */
|
|
29
|
+
export declare const connectedLaterWords: (servers: readonly string[]) => string;
|
|
23
30
|
export declare const REFRESH_MARGIN_MS: number;
|
|
24
31
|
/** How long an access token given with no expiry is taken to last: it is refreshed within the margin of then. */
|
|
25
32
|
export declare const UNKNOWN_EXPIRY_MS: number;
|
package/dist/mcp-probe.js
CHANGED
|
@@ -37,6 +37,13 @@ export const UNUSABLE = {
|
|
|
37
37
|
* token handed, or which was sealed before the seal marked who handed it. */
|
|
38
38
|
composioOwnersUser: "the Composio user this run is bound to is one the owner connects on this install, and nothing marks the binding as the owner's: hand mcp_auth again on a message, or start a new run",
|
|
39
39
|
};
|
|
40
|
+
/** What a run's timeline says of a server whose credential comes from each run when the run was handed none: its tools
|
|
41
|
+
* were left out of the run's (mcp-run.ts mcpForClaim), so the model is never offered a tool every call of which is
|
|
42
|
+
* refused. */
|
|
43
|
+
export const unconnectedWords = (server) => `The MCP server ${server}'s tools were left out of this run: ${UNUSABLE.perRunMissing}.`;
|
|
44
|
+
/** The run's timeline note when a message hands the credential of servers whose tools its claim left out
|
|
45
|
+
* (unconnectedWords) while a turn is going: that turn's tools stay as they are, so the message waits for the next. */
|
|
46
|
+
export const connectedLaterWords = (servers) => `The MCP server${servers.length > 1 ? "s" : ""} ${servers.join(", ")} ${servers.length > 1 ? "were" : "was"} handed ${servers.length > 1 ? "their credentials" : "its credential"} by a message while this turn was going without ${servers.length > 1 ? "their" : "its"} tools: the message runs as the run's next turn, which has them.`;
|
|
40
47
|
export const REFRESH_MARGIN_MS = 5 * 60_000;
|
|
41
48
|
/** How long an access token given with no expiry is taken to last: it is refreshed within the margin of then. */
|
|
42
49
|
export const UNKNOWN_EXPIRY_MS = 60 * 60_000;
|
|
@@ -88,6 +88,41 @@ export declare function ollamaRelisted(env: NodeJS.ProcessEnv): Promise<readonly
|
|
|
88
88
|
* one none): none where it was never asked. Synchronous, for the host's default model (model.ts hostModel), which a
|
|
89
89
|
* listing primes before it is read. */
|
|
90
90
|
export declare function ollamaKept(env: NodeJS.ProcessEnv): readonly OllamaListed[];
|
|
91
|
+
/** Forgets the listing kept for the Ollama `env` names, and the one under way for it, so the next ollamaModels asks it
|
|
92
|
+
* again at once: after a pull here (local-model.ts), the model is in the picker with no wait for OLLAMA_TTL_MS. A
|
|
93
|
+
* listing under way when it is forgotten still answers its caller, but is never kept: it may be from before the pull. */
|
|
94
|
+
export declare function ollamaForget(env: NodeJS.ProcessEnv): void;
|
|
95
|
+
/** How long the version of the Ollama here is waited for (ollamaVersion): a listing's deadline. */
|
|
96
|
+
export declare const OLLAMA_VERSION_TIMEOUT_MS = 2000;
|
|
97
|
+
/** The version the Ollama `env` names says it is (GET /api/version), or undefined where it names none, is refused, down,
|
|
98
|
+
* hung past `timeoutMs` or answers another shape. Nothing thrown. */
|
|
99
|
+
export declare function ollamaVersion(env: NodeJS.ProcessEnv, { fetch: send, timeoutMs }?: {
|
|
100
|
+
fetch?: typeof fetch;
|
|
101
|
+
timeoutMs?: number;
|
|
102
|
+
}): Promise<string | undefined>;
|
|
103
|
+
/** One line of a pull's progress as Ollama streams it (POST /api/pull): its status, and a layer's digest with its bytes. */
|
|
104
|
+
export type OllamaPullLine = {
|
|
105
|
+
readonly status: string;
|
|
106
|
+
readonly digest?: string;
|
|
107
|
+
readonly total?: number;
|
|
108
|
+
readonly completed?: number;
|
|
109
|
+
};
|
|
110
|
+
/** How long a pull may go with no byte from Ollama before it stops (ollamaPull): a registry that stalls, or an Ollama
|
|
111
|
+
* that wedges, frees the one pull here instead of holding it at `pulling` until the server restarts. */
|
|
112
|
+
export declare const PULL_STALL_MS = 120000;
|
|
113
|
+
/** The longest progress line a pull takes: Ollama's are a few hundred bytes, so a stream that sends no newline ends. */
|
|
114
|
+
export declare const PULL_LINE_MAX: number;
|
|
115
|
+
/**
|
|
116
|
+
* Pulls `tag` through the Ollama `env` names (POST /api/pull, streamed as NDJSON), each line of progress to `onLine` as it
|
|
117
|
+
* comes. Resolves once Ollama says `success`; throws, in Ollama's words, on an `error` line, a refusal, a stream that ends
|
|
118
|
+
* before `success`, or `signal`; in its own, on `stallMs` with no byte from Ollama (the answer's head or a chunk of the
|
|
119
|
+
* stream) or a line past PULL_LINE_MAX. No deadline on the whole: a model is gigabytes, and a pull that moves is let run.
|
|
120
|
+
*/
|
|
121
|
+
export declare function ollamaPull(env: NodeJS.ProcessEnv, tag: string, onLine: (line: OllamaPullLine) => void, { fetch: send, signal, stallMs }?: {
|
|
122
|
+
fetch?: typeof fetch;
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
stallMs?: number;
|
|
125
|
+
}): Promise<void>;
|
|
91
126
|
/** `env`'s Ollama listing as last kept (ollamaKept), in one string: each model's tag, capabilities and trained context.
|
|
92
127
|
* A server compares it to see a model pulled, removed or an Ollama started since it made its offers (server.ts). */
|
|
93
128
|
export declare const ollamaListing: (env: NodeJS.ProcessEnv) => string;
|
package/dist/ollama-provider.js
CHANGED
|
@@ -80,6 +80,9 @@ function splitHostPort(hostport) {
|
|
|
80
80
|
* for it. */
|
|
81
81
|
const kept = new Map();
|
|
82
82
|
const asking = new Map();
|
|
83
|
+
/** Bumped by ollamaForget, per address: a listing asked before a forget answers its caller but is never kept, since it
|
|
84
|
+
* may be from before the pull that made the forget. */
|
|
85
|
+
const forgets = new Map();
|
|
83
86
|
/** The clock a listing is kept by: Date.now, or a test's (ollamaClock). */
|
|
84
87
|
let now = Date.now;
|
|
85
88
|
/** A test's clock for the kept listings, so it ages them without waiting; with none, Date.now again. */
|
|
@@ -181,6 +184,7 @@ export async function listOllama(env, { fetch: send = globalThis.fetch, timeoutM
|
|
|
181
184
|
return [];
|
|
182
185
|
const deadline = AbortSignal.timeout(timeoutMs);
|
|
183
186
|
const ask = askerOf(base, send, deadline);
|
|
187
|
+
const asked = forgets.get(base) ?? 0;
|
|
184
188
|
let models = [];
|
|
185
189
|
let whole = false;
|
|
186
190
|
let down = false;
|
|
@@ -197,7 +201,9 @@ export async function listOllama(env, { fetch: send = globalThis.fetch, timeoutM
|
|
|
197
201
|
}
|
|
198
202
|
const before = kept.get(base)?.models;
|
|
199
203
|
const listing = whole ? { at: now(), models } : { at: -Infinity, models: !down && before?.length ? before : models };
|
|
200
|
-
kept.
|
|
204
|
+
// A forget since this listing was asked: it answers its caller, and is never kept.
|
|
205
|
+
if ((forgets.get(base) ?? 0) === asked)
|
|
206
|
+
kept.set(base, listing);
|
|
201
207
|
return listing.models;
|
|
202
208
|
}
|
|
203
209
|
/** Whether `error` is a refused connection (ECONNREFUSED anywhere in its causes): nothing listens at the address. */
|
|
@@ -239,7 +245,9 @@ export async function ollamaModels(env) {
|
|
|
239
245
|
return known.models;
|
|
240
246
|
let listing = asking.get(base);
|
|
241
247
|
if (!listing) {
|
|
242
|
-
|
|
248
|
+
const mine = listOllama(env).finally(() => { if (asking.get(base) === mine)
|
|
249
|
+
asking.delete(base); });
|
|
250
|
+
listing = mine;
|
|
243
251
|
asking.set(base, listing);
|
|
244
252
|
}
|
|
245
253
|
return known ? known.models : listing;
|
|
@@ -261,6 +269,104 @@ export function ollamaKept(env) {
|
|
|
261
269
|
const base = baseOf(env);
|
|
262
270
|
return base === undefined ? [] : (kept.get(base)?.models ?? []);
|
|
263
271
|
}
|
|
272
|
+
/** Forgets the listing kept for the Ollama `env` names, and the one under way for it, so the next ollamaModels asks it
|
|
273
|
+
* again at once: after a pull here (local-model.ts), the model is in the picker with no wait for OLLAMA_TTL_MS. A
|
|
274
|
+
* listing under way when it is forgotten still answers its caller, but is never kept: it may be from before the pull. */
|
|
275
|
+
export function ollamaForget(env) {
|
|
276
|
+
const base = baseOf(env);
|
|
277
|
+
if (base === undefined)
|
|
278
|
+
return;
|
|
279
|
+
forgets.set(base, (forgets.get(base) ?? 0) + 1);
|
|
280
|
+
kept.delete(base);
|
|
281
|
+
asking.delete(base);
|
|
282
|
+
}
|
|
283
|
+
/** How long the version of the Ollama here is waited for (ollamaVersion): a listing's deadline. */
|
|
284
|
+
export const OLLAMA_VERSION_TIMEOUT_MS = OLLAMA_LIST_TIMEOUT_MS;
|
|
285
|
+
/** The version the Ollama `env` names says it is (GET /api/version), or undefined where it names none, is refused, down,
|
|
286
|
+
* hung past `timeoutMs` or answers another shape. Nothing thrown. */
|
|
287
|
+
export async function ollamaVersion(env, { fetch: send = globalThis.fetch, timeoutMs = OLLAMA_VERSION_TIMEOUT_MS } = {}) {
|
|
288
|
+
const base = baseOf(env);
|
|
289
|
+
if (base === undefined)
|
|
290
|
+
return undefined;
|
|
291
|
+
try {
|
|
292
|
+
const answer = (await askerOf(base, send, AbortSignal.timeout(timeoutMs))("/api/version"));
|
|
293
|
+
return typeof answer?.version === "string" && answer.version.length > 0 && answer.version.length <= 64 ? answer.version : undefined;
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/** How long a pull may go with no byte from Ollama before it stops (ollamaPull): a registry that stalls, or an Ollama
|
|
300
|
+
* that wedges, frees the one pull here instead of holding it at `pulling` until the server restarts. */
|
|
301
|
+
export const PULL_STALL_MS = 120_000;
|
|
302
|
+
/** The longest progress line a pull takes: Ollama's are a few hundred bytes, so a stream that sends no newline ends. */
|
|
303
|
+
export const PULL_LINE_MAX = 64 * 1024;
|
|
304
|
+
/**
|
|
305
|
+
* Pulls `tag` through the Ollama `env` names (POST /api/pull, streamed as NDJSON), each line of progress to `onLine` as it
|
|
306
|
+
* comes. Resolves once Ollama says `success`; throws, in Ollama's words, on an `error` line, a refusal, a stream that ends
|
|
307
|
+
* before `success`, or `signal`; in its own, on `stallMs` with no byte from Ollama (the answer's head or a chunk of the
|
|
308
|
+
* stream) or a line past PULL_LINE_MAX. No deadline on the whole: a model is gigabytes, and a pull that moves is let run.
|
|
309
|
+
*/
|
|
310
|
+
export async function ollamaPull(env, tag, onLine, { fetch: send = globalThis.fetch, signal, stallMs = PULL_STALL_MS } = {}) {
|
|
311
|
+
const base = baseOf(env);
|
|
312
|
+
if (base === undefined)
|
|
313
|
+
throw new Error("no Ollama is asked here");
|
|
314
|
+
const stall = new AbortController();
|
|
315
|
+
let timer;
|
|
316
|
+
const moved = () => {
|
|
317
|
+
clearTimeout(timer);
|
|
318
|
+
timer = setTimeout(() => stall.abort(), stallMs);
|
|
319
|
+
};
|
|
320
|
+
const stopped = signal ? AbortSignal.any([signal, stall.signal]) : stall.signal;
|
|
321
|
+
moved();
|
|
322
|
+
try {
|
|
323
|
+
const response = await send(`${base}/api/pull`, { method: "POST", redirect: "error", signal: stopped, headers: { "content-type": "application/json" }, body: JSON.stringify({ model: tag, stream: true }) });
|
|
324
|
+
if (!response.ok || !response.body) {
|
|
325
|
+
const said = safeJson(await response.text().catch(() => ""));
|
|
326
|
+
throw new Error(typeof said?.error === "string" ? said.error : `/api/pull: ${response.status}`);
|
|
327
|
+
}
|
|
328
|
+
const decoder = new TextDecoder();
|
|
329
|
+
let rest = "";
|
|
330
|
+
let succeeded = false;
|
|
331
|
+
const take = (text) => {
|
|
332
|
+
const line = safeJson(text);
|
|
333
|
+
if (!line || typeof line !== "object")
|
|
334
|
+
return;
|
|
335
|
+
if (typeof line.error === "string")
|
|
336
|
+
throw new Error(line.error);
|
|
337
|
+
if (typeof line.status !== "string")
|
|
338
|
+
return;
|
|
339
|
+
if (line.status === "success")
|
|
340
|
+
succeeded = true;
|
|
341
|
+
onLine({ status: line.status, ...(typeof line.digest === "string" ? { digest: line.digest } : {}), ...(line.total !== undefined ? { total: count(line.total) } : {}), ...(line.completed !== undefined ? { completed: count(line.completed) } : {}) });
|
|
342
|
+
};
|
|
343
|
+
for await (const chunk of response.body) {
|
|
344
|
+
moved();
|
|
345
|
+
rest += decoder.decode(chunk, { stream: true });
|
|
346
|
+
let cut;
|
|
347
|
+
while ((cut = rest.indexOf("\n")) >= 0) {
|
|
348
|
+
const text = rest.slice(0, cut).trim();
|
|
349
|
+
rest = rest.slice(cut + 1);
|
|
350
|
+
if (text)
|
|
351
|
+
take(text);
|
|
352
|
+
}
|
|
353
|
+
if (rest.length > PULL_LINE_MAX)
|
|
354
|
+
throw new Error(`Ollama sent a progress line longer than ${PULL_LINE_MAX} bytes, so the pull stopped. Press Pull again.`);
|
|
355
|
+
}
|
|
356
|
+
if (rest.trim())
|
|
357
|
+
take(rest.trim());
|
|
358
|
+
if (!succeeded)
|
|
359
|
+
throw new Error("the pull ended before Ollama said success");
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
if (stall.signal.aborted && !signal?.aborted)
|
|
363
|
+
throw new Error(`Ollama sent nothing for ${Math.round(stallMs / 1000)} s, so the pull stopped. Press Pull again.`);
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
366
|
+
finally {
|
|
367
|
+
clearTimeout(timer);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
264
370
|
/** `env`'s Ollama listing as last kept (ollamaKept), in one string: each model's tag, capabilities and trained context.
|
|
265
371
|
* A server compares it to see a model pulled, removed or an Ollama started since it made its offers (server.ts). */
|
|
266
372
|
export const ollamaListing = (env) => ollamaKept(env).map((model) => `${model.name}=${model.capabilities.join(",")}@${model.trained ?? ""}`).join(" ");
|
package/dist/openapi.js
CHANGED
|
@@ -33,6 +33,8 @@ import { COMPILE_AFTER_MAX } from "./learning-setting.js";
|
|
|
33
33
|
import { LOOP_COMPILES_MAX } from "./store-reads/loop.js";
|
|
34
34
|
import { GRADE_SOURCES, GRADES_KEPT, LABEL_MAX } from "./learn/promote.js";
|
|
35
35
|
import { MODEL_SOURCES, THINKING_LEVELS } from "./model.js";
|
|
36
|
+
// Also registers its operations as the owner's alone (secret-writes.ts).
|
|
37
|
+
import { INKLING, INKLING_OLLAMA, LOCAL_MODEL_TAGS, QWEN3_DEFAULT } from "./local-model.js";
|
|
36
38
|
import { MAX_MODEL_KEY_CHARS } from "./run-model-key.js";
|
|
37
39
|
import { MIN_SECRET } from "./learn/secrets.js";
|
|
38
40
|
import { HANDED_SECRET } from "./handed-secret.js";
|
|
@@ -367,7 +369,7 @@ const RUN_USAGE_LINE = {
|
|
|
367
369
|
not_metered_calls: { type: "integer", minimum: 1, description: "On `tools`: calls with no price set (an MCP tool its owner set none for), as GET /usage counts them. They ran outside the run's cost and its cap, so they are in neither `quantity` nor `usd`: a line of such calls alone has `quantity` 0 and `usd` 0." },
|
|
368
370
|
resource: { enum: ["vcpu", "memory", "gpu", "disk"], description: "On `compute_time`: the resource the line counts." },
|
|
369
371
|
gpu_type: { type: ["string", "null"], description: "On `compute_time` for `gpu`: the provider's own name for the GPU type. Null on the other resources." },
|
|
370
|
-
unheld_quantity: { type: ["number", "null"], minimum: 0, description: "On `compute_time`: the part of `quantity` no claim of the run held, so no cap held and nothing booked: a computer kept past its claim for a follow-up, one deleted after its run ended, one whose delete failed, one still open. Its cost is in neither `usd` nor `total`. Null when `quantity` is." },
|
|
372
|
+
unheld_quantity: { type: ["number", "null"], minimum: 0, description: "On `compute_time`: the part of `quantity` no claim of the run held, so no cap held and nothing booked: a computer kept past its claim for a follow-up, one deleted after its run ended, one whose delete failed, one still open. Its cost is in neither `usd` nor `total`. 0 for a provider that bills nothing (Docker): its time costs nothing, held or not. Null when `quantity` is." },
|
|
371
373
|
open_computers: { type: "integer", minimum: 0, description: "On `compute_time`: how many of the line's computers no delete has ended yet (still running, or their delete failed), counted up to `measured_to`." },
|
|
372
374
|
measured_to: { type: "string", format: "date-time", description: "On `compute_time` with an open computer: the moment its time is counted to, this read's." },
|
|
373
375
|
},
|
|
@@ -1109,6 +1111,35 @@ const MODEL_GATEWAY_VIEW = closed({
|
|
|
1109
1111
|
secret: { ...SECRET_ITEM("\"model:gateway\": the gateway's key, which PUT /settings/model-gateway takes as api_key and AGENT_MODEL_API_KEY sets with AGENT_MODEL_BASE_URL."), description: "The gateway's key as its SecretMeta: never a value." },
|
|
1110
1112
|
problem: { type: ["string", "null"], description: "Why the gateway in force runs no model, in words: an address the one rule refuses (https only, or http to this machine; no user, query, fragment or dot segment). Null when none." },
|
|
1111
1113
|
});
|
|
1114
|
+
/** GET /settings/local-model's answer (local-model.ts localModelView): this machine, its Ollama, the model recommended for
|
|
1115
|
+
* them and the pull here. */
|
|
1116
|
+
const LOCAL_MODEL_VIEW = closed({
|
|
1117
|
+
machine: closed({
|
|
1118
|
+
platform: { type: "string", description: "The operating system as Node names it: `darwin`, `linux`, `win32`." },
|
|
1119
|
+
arch: { type: "string", description: "The CPU architecture as Node names it: `arm64`, `x64`." },
|
|
1120
|
+
ram_bytes: { type: "integer", minimum: 0, description: "Total memory, in bytes (on Apple silicon, its unified memory)." },
|
|
1121
|
+
gpu: { oneOf: [
|
|
1122
|
+
closed({ kind: { const: "apple" }, unified: { const: true } }, "Apple silicon (darwin on arm64): the GPU shares the unified memory."),
|
|
1123
|
+
closed({ kind: { const: "nvidia" }, name: { type: "string" }, memory_bytes: { type: "integer", minimum: 0 } }, "The first NVIDIA GPU nvidia-smi names, with its memory."),
|
|
1124
|
+
closed({ kind: { const: "unknown" } }, "No GPU read cheaply here."),
|
|
1125
|
+
] },
|
|
1126
|
+
}, "This machine, read once when the server started."),
|
|
1127
|
+
ollama: closed({ asked: { type: "boolean", description: "Whether this server asks an Ollama at all: false under the faux model or a model gateway (AGENT_MODEL_BASE_URL), where `reachable` is false, `version` null, and `recommended.why` is the refusal's words." }, reachable: { type: "boolean", description: "Whether the Ollama here answered GET /api/version." }, version: { type: ["string", "null"], description: "The version it says; null when it did not answer." } }),
|
|
1128
|
+
recommended: closed({
|
|
1129
|
+
tag: { type: ["string", "null"], description: `The Ollama tag recommended here: ${INKLING} on Apple silicon with Ollama ${INKLING_OLLAMA} or later, else ${QWEN3_DEFAULT} or a smaller qwen3 that fits in memory (one of ${LOCAL_MODEL_TAGS.join(", ")}). Null where none fits or no Ollama answers.` },
|
|
1130
|
+
why: { type: "string", description: "Why, in words: the memory each tag needs and this machine has, an Ollama to update or install, or that the tag is already pulled." },
|
|
1131
|
+
pulled: { type: "boolean", description: "Whether the Ollama here has the tag already: no pull needed." },
|
|
1132
|
+
}),
|
|
1133
|
+
pull: { oneOf: [{ type: "null" }, closedWith({
|
|
1134
|
+
tag: { type: "string" },
|
|
1135
|
+
state: { enum: ["pulling", "done", "failed"], description: "`done` once the model is in the server's listing too, so the picker has it." },
|
|
1136
|
+
status: { type: "string", description: "Ollama's last status line (`pulling manifest`, `pulling <digest>`, `success`)." },
|
|
1137
|
+
completed_bytes: { type: "integer", minimum: 0 },
|
|
1138
|
+
total_bytes: { type: "integer", minimum: 0, description: "The bytes of every layer Ollama has named so far." },
|
|
1139
|
+
}, { error: { type: "string", description: "With `failed`: why, in Ollama's words." } })], description: "The last pull made here since the server started, or null." },
|
|
1140
|
+
can_pull: { type: "boolean", description: "Whether POST /settings/local-model/pull may pull here." },
|
|
1141
|
+
refused: { type: ["string", "null"], description: "Why not, in words, with `can_pull` false: the faux model or a model gateway takes every model here, or this server is not one owner's own on their own machine. Null with `can_pull` true." },
|
|
1142
|
+
});
|
|
1112
1143
|
/** POST /settings/model-gateway/test's answer: the model ids the gateway lists, or why it could not be asked. */
|
|
1113
1144
|
const MODEL_GATEWAY_TEST = {
|
|
1114
1145
|
oneOf: [
|
|
@@ -1441,7 +1472,7 @@ const TRIGGER_FIELDS = closed({
|
|
|
1441
1472
|
catchup_window_s: { type: "integer", minimum: 0, maximum: MAX_EVERY_S, description: `How late a missed time may still fire, once: of the times that came while the server was down (or its timer was late), the latest fires if it is this recent, under its own key, and the rest are one \`missed\` firing. 0: a missed time never fires. Default ${CATCHUP_WINDOW_S}.` },
|
|
1442
1473
|
max_active_runs: { type: ["integer", "null"], minimum: 1, maximum: MAX_ACTIVE_RUNS, description: `For a \`start_run\` trigger of a pushed source (a webhook, with or without \`accept\`): each event starts its own run, never skipped behind the last, and this is the most of its runs active at once. A firing past it waits due and is tried again; past 20 due an event is 429 \`rate_limited\`. Null: a trigger with \`accept\` takes every run this server has room for, and one without keeps the overlap skip. A schedule or a \`message_run\` target is 422 with it set.` },
|
|
1443
1474
|
failures_in_a_row: { type: "integer", minimum: 0, description: `Failed firings since the last that started a run; at ${FAILURES_TO_PAUSE} the trigger turns itself off (\`disabled\`). Turned on again, it counts from 0.` },
|
|
1444
|
-
disabled: { oneOf: [closed({ at: DATE_TIME, reason: { const: "auto_paused" } }), closed({ at: DATE_TIME, reason: { const: "source_unreadable" }, detail: { type: "string", description: "Why the source no longer reads." } }), closed({ at: DATE_TIME, reason: { const: "agent_archived" }, detail: { type: "string", description: "The agent it runs as, archived." } }), closed({ at: DATE_TIME, reason: { const: "connection_lost" }, detail: { type: "string", description: "Which connection went (GitHub disconnected here, or the App's installation deleted or suspended on GitHub)." } }), closed({ at: DATE_TIME, reason: { const: "sign_in_refused" }, detail: { type: "string", description: "What to fix: the account in Settings → Email." } }), { type: "null" }], description: `Why it is off, when the server turned it off: \`agent_archived\`, the agent it runs as was archived (turning it on is 409 agent_archived until the agent is unarchived); \`auto_paused\`, ${FAILURES_TO_PAUSE} failed firings in a row; \`connection_lost\`, the connection it needs went (GitHub disconnected here, or the App's installation deleted or suspended on GitHub); \`sign_in_refused\`, an email trigger's mail server refused the sign-in 3 times in a row (fix the account in Settings → Email, then turn it on); \`source_unreadable\`, its cron line or zone no longer reads here (a newer cron library or time zone data refuses it) or its every_s is out of range (a hand edit of its row), found at a start or when it came due, and only this trigger is turned off, or every feed a feed trigger reads has stopped (a 410, or a 404 three checks running, each), which turning it on again reads from the start (edit its urls first). Null once it is on again, which for \`source_unreadable\` takes a new source.` },
|
|
1475
|
+
disabled: { oneOf: [closed({ at: DATE_TIME, reason: { const: "auto_paused" } }), closed({ at: DATE_TIME, reason: { const: "source_unreadable" }, detail: { type: "string", description: "Why the source no longer reads." } }), closed({ at: DATE_TIME, reason: { const: "agent_archived" }, detail: { type: "string", description: "The agent it runs as, archived." } }), closed({ at: DATE_TIME, reason: { const: "connection_lost" }, detail: { type: "string", description: "Which connection went (GitHub disconnected here, or the App's installation deleted or suspended on GitHub)." } }), closed({ at: DATE_TIME, reason: { const: "sign_in_refused" }, detail: { type: "string", description: "What to fix: the account in Settings → Email." } }), { type: "null" }], description: `Why it is off, when the server turned it off: \`agent_archived\`, the agent it runs as was archived (turning it on is 409 agent_archived until the agent is unarchived); \`auto_paused\`, ${FAILURES_TO_PAUSE} failed firings in a row (turned on again in the console, or by PATCH /triggers/{trigger_id} with \`{"enabled": true}\`); \`connection_lost\`, the connection it needs went (GitHub disconnected here, or the App's installation deleted or suspended on GitHub); \`sign_in_refused\`, an email trigger's mail server refused the sign-in 3 times in a row (fix the account in Settings → Email, then turn it on); \`source_unreadable\`, its cron line or zone no longer reads here (a newer cron library or time zone data refuses it) or its every_s is out of range (a hand edit of its row), found at a start or when it came due, and only this trigger is turned off, or every feed a feed trigger reads has stopped (a 410, or a 404 three checks running, each), which turning it on again reads from the start (edit its urls first). Null once it is on again, which for \`source_unreadable\` takes a new source.` },
|
|
1445
1476
|
next_at: { type: ["string", "null"], format: "date-time", description: "When it fires next; null while it is off." },
|
|
1446
1477
|
last_run_id: { type: ["string", "null"], description: "The run its last firing that started one started; while that run is active (working, or waiting on a person), each firing is skipped, unless its firings each start their own run (a webhook with `accept`, or a pushed trigger with `max_active_runs`). Null until one starts." },
|
|
1447
1478
|
created_at: DATE_TIME,
|
|
@@ -3123,6 +3154,27 @@ const EXTENSIONS = {
|
|
|
3123
3154
|
"x-agentrun-serve": "modelgateway/1",
|
|
3124
3155
|
},
|
|
3125
3156
|
},
|
|
3157
|
+
"/settings/local-model": {
|
|
3158
|
+
get: {
|
|
3159
|
+
operationId: "getLocalModel", tags: ["local"], summary: "This machine, its Ollama, the free local model recommended for them, and the pull here",
|
|
3160
|
+
description: `What the console's Free local model card reads: the machine (platform, arch, memory, a GPU where it is cheap to read), whether the Ollama here answers and its version, the model recommended (${INKLING} on Apple silicon with Ollama ${INKLING_OLLAMA} or later; else ${QWEN3_DEFAULT}, or a smaller qwen3 that fits in memory, or none, with why), and the pull here with its progress. The owner's signed-in session alone (ownerSession), never the token, which is 403 forbidden in words.`,
|
|
3161
|
+
"x-agentrun-secret": true,
|
|
3162
|
+
security: [{ ownerSession: [] }],
|
|
3163
|
+
responses: { "200": json(LOCAL_MODEL_VIEW, "This machine and its model."), ...errors(401, 403, 429, 500) },
|
|
3164
|
+
"x-agentrun-serve": "localmodel/1",
|
|
3165
|
+
},
|
|
3166
|
+
},
|
|
3167
|
+
"/settings/local-model/pull": {
|
|
3168
|
+
post: {
|
|
3169
|
+
operationId: "pullLocalModel", tags: ["local"], summary: "Pull a recommended model into the Ollama here",
|
|
3170
|
+
description: `Starts pulling \`tag\` through this server's own Ollama (POST /api/pull) and answers at once; GET /settings/local-model shows its progress, and once it is \`done\` the model is in capabilities' models with no restart. Only a tag the recommendation can name, ${LOCAL_MODEL_TAGS.join(", ")} (422 input_invalid for any other). Only on one owner's own server on their own machine, and never under the faux model or a model gateway: 403 forbidden in words otherwise. One pull at a time: 409 local_model_pulling while one is under way. The owner's signed-in session alone (ownerSession).`,
|
|
3171
|
+
"x-agentrun-secret": true,
|
|
3172
|
+
security: [{ ownerSession: [] }],
|
|
3173
|
+
requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, required: ["tag"], properties: { tag: { enum: [...LOCAL_MODEL_TAGS], description: "The tag to pull: the recommendation's (`recommended.tag`), one of the tags a recommendation names (any other: 422)." } } } } } },
|
|
3174
|
+
responses: { "202": json(LOCAL_MODEL_VIEW, "The pull started: `pull` is under way."), ...errors(401, 403, 409, 415, 422, 429, 500) },
|
|
3175
|
+
"x-agentrun-serve": "localmodel/1",
|
|
3176
|
+
},
|
|
3177
|
+
},
|
|
3126
3178
|
"/auth/session": {
|
|
3127
3179
|
get: {
|
|
3128
3180
|
operationId: "getAuthSession", tags: ["local"], summary: "Whether this browser has accounts, is signed in, and may save a secret",
|
|
@@ -3425,7 +3477,7 @@ const EXTENSIONS = {
|
|
|
3425
3477
|
"/settings/tools": {
|
|
3426
3478
|
get: {
|
|
3427
3479
|
operationId: "getToolSettings", tags: ["capabilities"], summary: "The server's tool settings",
|
|
3428
|
-
description: "Each capability that has a choice, and its provider, and each tool's permission that is set (an MCP server's wildcard mcp:<server>/* among them): web_search auto (Parallel where the server holds its key, which bills it, else Firecrawl's keyless search with Exa's behind it, on every harness), native (the harness's own search, claude-agent's or codex's, or on pi the model provider's hosted one: that alone), firecrawl-keyless (Firecrawl's, Exa's behind it), exa-keyless (that alone) or parallel; web_fetch auto (Parallel's extract where the server holds a Parallel key, which bills it, with the guarded direct fetch behind it, else Firecrawl's keyless fetch, which is sent each URL read, never a private or local one, with the guarded direct fetch behind it), firecrawl-keyless (that, whatever the key), kernel (the guarded direct fetch alone) or parallel; browser auto (Browserbase where the server holds its keys, else Kernel where it holds Kernel's), browserbase, kernel (each that alone) or chrome (a Chrome on the server's host, not set up on any server yet: unavailable). An agent's definition.tool_settings is over these, except a permission set to deny here: a server deny is absolute and refuses the tool on this server whatever the agent sets. capabilities.tools say what each resolves to on each harness, and GET /agents/{agent_id} for that agent. An MCP tool's own key may carry its pin, the arguments its calls must carry.",
|
|
3480
|
+
description: "Each capability that has a choice, and its provider, and each tool's permission that is set (an MCP server's wildcard mcp:<server>/* among them): web_search auto (Parallel where the server holds its key, which bills it, else Firecrawl's keyless search with Exa's behind it, on every harness), native (the harness's own search, claude-agent's or codex's, or on pi the model provider's hosted one: that alone), firecrawl-keyless (Firecrawl's, Exa's behind it), exa-keyless (that alone) or parallel; web_fetch auto (Parallel's extract where the server holds a Parallel key, which bills it, with the guarded direct fetch behind it, else Firecrawl's keyless fetch, which is sent each URL read, never a private or local one, with the guarded direct fetch behind it), firecrawl-keyless (that, whatever the key), kernel (the guarded direct fetch alone) or parallel; browser auto (Browserbase where the server holds its keys, else Kernel where it holds Kernel's), browserbase, kernel (each that alone) or chrome (a Chrome on the server's host, not set up on any server yet: unavailable). An agent's definition.tool_settings is over these, except a permission set to deny here: a server deny is absolute and refuses the tool on this server whatever the agent sets; and web_fetch kernel, or web_search native or off, a ceiling: an agent's firecrawl-keyless, exa-keyless, auto or parallel resolves as the setting does, and under off so does its native. Every other provider set here is a default an agent's pick replaces. A setting applies at a run's next claim; a claim keeps the plane it began with to its end. capabilities.tools say what each resolves to on each harness, and GET /agents/{agent_id} for that agent. An MCP tool's own key may carry its pin, the arguments its calls must carry.",
|
|
3429
3481
|
responses: { "200": json(TOOL_SETTINGS_ANSWER, "Each capability's provider."), ...errors(401, 429, 500) },
|
|
3430
3482
|
"x-agentrun-serve": "providers/1",
|
|
3431
3483
|
},
|
|
@@ -3660,7 +3712,7 @@ const EXTENSIONS = {
|
|
|
3660
3712
|
},
|
|
3661
3713
|
patch: {
|
|
3662
3714
|
operationId: "updateTrigger", tags: ["local"], summary: "Change a trigger, or turn it off and on",
|
|
3663
|
-
description: `Any of its fields. \`enabled: false\` stops its firings; \`enabled: true\` again, or a new source, goes on from now: the time it was off is skipped, never caught up. A firing already due goes on. A new \`target\` is checked as POST /triggers checks one: ${TRIGGER_RUN_KEYS}
|
|
3715
|
+
description: `Any of its fields. \`enabled: false\` stops its firings; \`enabled: true\` again, or a new source, goes on from now: the time it was off is skipped, never caught up. A firing already due goes on. A new \`target\` is checked as POST /triggers checks one: ${TRIGGER_RUN_KEYS} On an API-only server (\`AGENTRUN_API_ONLY=1\`), which has no console, this is how a trigger is turned on again, one auto-paused among them: it takes \`enabled\` alone (any other field is 422 \`not_allowed\`, nothing changed), and turns on a schedule or a feed trigger aimed at an agent (a \`start_run\` target) only with the launch hook set, so its firings go to the backend (else 422 under \`enabled\`: \`not_set_up_here\` without the hook, \`not_an_option\` for any other source, or a \`message_run\` target, whose firings never go to the hook). The triggers' list, a trigger's read and its firings are served there too; making, deleting or firing one and its secret are not.`,
|
|
3664
3716
|
parameters: [TRIGGER_ID],
|
|
3665
3717
|
requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, properties: TRIGGER_WRITE } } } },
|
|
3666
3718
|
responses: { "200": json({ ...TRIGGER_READ, properties: { ...TRIGGER_READ.properties, composio: COMPOSIO_UNDONE } }, "Changed: the trigger as a read answers it, with its secret's metadata, and for a composio trigger turned on or off whose instance Composio did not turn, `composio`: what to do there by hand."), ...errors(400, 401, 404, 409, 415, 422, 429, 500) },
|
|
@@ -4339,7 +4391,7 @@ const FIELD_EXTENSIONS = {
|
|
|
4339
4391
|
{ type: "object", additionalProperties: false, required: ["mode"], properties: { mode: { const: "runner" } } },
|
|
4340
4392
|
{ type: "object", additionalProperties: false, required: ["mode", "box"], properties: { mode: { const: "sandbox" }, box: { enum: [...BOX_IDS] } } },
|
|
4341
4393
|
],
|
|
4342
|
-
description: "Where the revision's runs execute: `runner` (no box and no shell) or `sandbox` (the agent's file and shell tools run in the box; its loop, its log and every key stay on the server). Absent on a create of an agentic revision, the place this server gives a new agent (capabilities.places.default_place): the Docker box where this server has docker, written on the revision so an answer shows it, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools (a list it names, an empty one included, is kept as named, and gets the box only when one of its tools runs only there: `bash` or a background tool); where docker is unavailable, where the definition's tools need no shell, or where it names a tool a box refuses (browser), none, so its runs start on the runner with no container. A revision saved with no place runs where this server's capabilities.places.default_place says at each run (the Docker box where docker is available now, else the runner) when one of its tools needs a shell; a workflow, one whose tools need no shell, and one that names a tool a box refuses, on the runner. A revision keeps the place it names, runner included. An edit that names none keeps the agent's. A box this server does not have saves with a warning, and its runs are 409 agent_not_runnable naming it (capabilities.places.boxes). Only an agentic revision in a sandbox place may name `bash` or a background tool (`bash_background`, `bash_output`, `bash_input`, `bash_signal`, `bash_list`); a workflow revision's place is runner or none (a sandbox place is 422).",
|
|
4394
|
+
description: "Where the revision's runs execute: `runner` (no box and no shell) or `sandbox` (the agent's file and shell tools run in the box; its loop, its log and every key stay on the server). Absent on a create of an agentic revision, the place this server gives a new agent (capabilities.places.default_place): the Docker box where this server has docker in Mode 1, written on the revision so an answer shows it, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools (a list it names, an empty one included, is kept as named, and gets the box only when one of its tools runs only there: `bash` or a background tool); in Mode 2 (Docker's box can't mount Archil's workspaces), where docker is unavailable, where the definition's tools need no shell, or where it names a tool a box refuses (browser), none, so its runs start on the runner with no container. A revision saved with no place runs where this server's capabilities.places.default_place says at each run (the Docker box where docker is available now in Mode 1, else the runner) when one of its tools needs a shell; a workflow, one whose tools need no shell, and one that names a tool a box refuses, on the runner. A revision keeps the place it names, runner included. An edit that names none keeps the agent's. A box this server does not have saves with a warning, and its runs are 409 agent_not_runnable naming it (capabilities.places.boxes). Only an agentic revision in a sandbox place may name `bash` or a background tool (`bash_background`, `bash_output`, `bash_input`, `bash_signal`, `bash_list`); a workflow revision's place is runner or none (a sandbox place is 422).",
|
|
4343
4395
|
"x-agentrun-serve": "place/1",
|
|
4344
4396
|
},
|
|
4345
4397
|
computer: {
|
|
@@ -4358,7 +4410,7 @@ const FIELD_EXTENSIONS = {
|
|
|
4358
4410
|
description: "The computer the revision's runs are given (Settings → Computers): its kind, the provider that serves it, the image it starts from, a sandbox's GPUs, whether the agent keeps it between runs, and, for a desktop or a phone, how the agent drives it, whether it may run programs on it and whether its runs record its screen. `place` is its v2 view where it can say it: `{kind: none}` is `place {mode: runner}`, `{kind: sandbox, provider: X}` is `place {mode: sandbox, box: X}`; a desktop, phone or browser computer leaves the run's folder on the runner, so its place reads runner. Writing either sets both, and both given must agree (422). Absent on a create, the server's default (as `place`); an edit that names neither keeps the agent's.",
|
|
4359
4411
|
"x-agentrun-serve": "computer/1",
|
|
4360
4412
|
},
|
|
4361
|
-
tool_settings: { ...AGENT_TOOL_SETTINGS, description: "The agent's own tool settings (web_search's, web_fetch's and browser's provider, any tool's permission, an MCP server's wildcard mcp:<server>/*, an MCP tool's pin, bash's policy), over the server's (GET /settings/tools), except a deny set on the server, which is absolute: the tool is refused on this server whatever this agent sets; absent, the server's. A pin is not over the server's: both hold. A grant in tools names the capability, never a provider.", "x-agentrun-serve": "providers/1" },
|
|
4413
|
+
tool_settings: { ...AGENT_TOOL_SETTINGS, description: "The agent's own tool settings (web_search's, web_fetch's and browser's provider, any tool's permission, an MCP server's wildcard mcp:<server>/*, an MCP tool's pin, bash's policy), over the server's (GET /settings/tools), except a deny set on the server, which is absolute: the tool is refused on this server whatever this agent sets; and the server's kernel for web_fetch, or native or off for web_search, a ceiling: this agent's pick of firecrawl-keyless, exa-keyless, auto or parallel resolves as the server's setting does, and under off so does its native; every other provider the server sets is a default this agent's pick replaces; absent, the server's. A pin is not over the server's: both hold. A grant in tools names the capability, never a provider.", "x-agentrun-serve": "providers/1" },
|
|
4362
4414
|
approvals: { enum: ["ask", "never"], default: "ask", description: "Whether the agent's runs ask a person or run unattended. `ask`, the default: a tool set to ask parks the run for an approval, as its tool settings say. `never`: the agent runs unattended, and each tool that would ask is allowed instead, decided by the tool gate at each call, so a tool granted later and an MCP tool (`mcp:<server>/<tool>`, which asks by default) are covered on every harness. It never lifts a deny, whether set on this server or in the agent's own tool_settings, nor a pin, nor anything else the gate refuses before it decides between running and asking. A workflow's call node on a tool set to ask runs under `never`. Absent on a request: ask. An edit that leaves it out asks, so no edit makes an agent unattended by saying nothing. Every answer names it.", "x-agentrun-serve": "unattended/1" },
|
|
4363
4415
|
learning: { oneOf: [{ type: "boolean" }, { type: "object", additionalProperties: false, properties: {
|
|
4364
4416
|
compile_after: { type: "integer", minimum: 1, maximum: 200, default: 20, description: "The job compiles into a learned workflow once the agent has this many completed runs of its own." },
|
|
@@ -4588,7 +4640,7 @@ const FIELD_EXTENSIONS = {
|
|
|
4588
4640
|
{ type: "object", additionalProperties: false, required: ["mode", "box"], properties: { mode: { const: "sandbox" }, box: { enum: [...BOX_IDS] } } },
|
|
4589
4641
|
{ type: "null" },
|
|
4590
4642
|
],
|
|
4591
|
-
description: "The place a NEW agentic agent that names none and has a shell is saved with, written on its revision at its create, and where an agentic revision saved with no place and a shell tool runs, resolved at each run.
|
|
4643
|
+
description: "The place a NEW agentic agent that names none and has a shell is saved with, written on its revision at its create, and where an agentic revision saved with no place and a shell tool runs, resolved at each run. In Mode 2, where the runner's shell is Archil's serverless exec, the runner (`{\"mode\": \"runner\"}`), docker or not (Docker's box can't mount Archil's workspaces), and such a create saves with no place. In Mode 1, where the runner has no shell: the Docker box (`{\"mode\": \"sandbox\", \"box\": \"docker\"}`) where this server has docker, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools; where it has no docker, null, meaning no default: a new agent names a box or the runner, `default_reason` gives the words, and a create that names no place and no tools, or a tool that runs only in a box, is refused `422 input_invalid` at field `definition.place`, reason `missing`, in those words, no other box picked for it. A client tells the cases apart by `default_place` being null, never by reading `default_reason`. One whose named tools need no shell is saved with no place and runs on the runner, as do a workflow and a revision that names a tool a box refuses. (It replaces `places.default`, which said `runner`.)",
|
|
4592
4644
|
"x-agentrun-serve": "place/5",
|
|
4593
4645
|
},
|
|
4594
4646
|
default_reason: { type: "string", description: "There exactly when `default_place` is null (Mode 1 with no Docker box): the words a create that names no place and would get the box is refused in, `name a box: this server has no Docker box for a new agent. Set place to {mode: sandbox, box: <one of: …>}, or to {mode: runner} to run without a shell.`, listing the boxes this server has, or `<none is set up>`. Docker's own reason is on its entry in `boxes`.", "x-agentrun-serve": "place/5" },
|