@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
package/dist/server.js
CHANGED
|
@@ -31,7 +31,7 @@ import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
|
31
31
|
import { chmod, lstat, mkdir, readFile, realpath, rename, stat, writeFile } from "node:fs/promises";
|
|
32
32
|
import { createServer } from "node:http";
|
|
33
33
|
import proxyaddr from "proxy-addr";
|
|
34
|
-
import {
|
|
34
|
+
import { apiOnlyMcpSave, apiOnlyRefusal, apiOnlyTriggerEdit, apiOnlyTriggerSkipped, apiOnlyTurnsOn, servedApiOnly } from "./api-only.js";
|
|
35
35
|
import { API_ONLY_MCP_ORIGINS_ENV, apiOnlyMcpOriginsFrom, RUN_KEYS_ENV } from "./env-switch.js";
|
|
36
36
|
import { composioOutsideNamespaceServers, holdApiOnlyMcpOrigins, offApiOnlyMcpServers } from "./mcp-api-only-origins.js";
|
|
37
37
|
import { declaredKeys, keysOwed, keysOwedRefusal, runKeysOf, runKeysTriggerSkipped, undeclaredKeys, withCarried } from "./run-keys.js";
|
|
@@ -133,7 +133,8 @@ import { workflowNodesOf } from "./learn/workflow-nodes.js";
|
|
|
133
133
|
import { deleteLearning } from "./learn/delete.js";
|
|
134
134
|
import { forgetLegacyRunLearning, legacyGradesKey, legacyPromotionsKey } from "./learn/legacy/scrub.js";
|
|
135
135
|
import { runModelRef } from "./model.js";
|
|
136
|
-
import {
|
|
136
|
+
import { fullTag, localModelView, localPulls, pullLocalModel, pullThrough, readMachine } from "./local-model.js";
|
|
137
|
+
import { ollamaForget, ollamaHostOf, ollamaHostRefused, ollamaListing, ollamaModels, ollamaReading } from "./ollama-provider.js";
|
|
137
138
|
import { REDACTED } from "./secret-cut.js";
|
|
138
139
|
// The v2 run statuses, as the run view names them (run-view.ts Status), for the list filter's validation. */
|
|
139
140
|
const STATUSES = ["queued", "working", "paused", "input_required", "completed", "failed", "cancelled"];
|
|
@@ -501,6 +502,9 @@ export const ROUTES = [
|
|
|
501
502
|
{ method: "PUT", pattern: /^\/settings\/model-gateway$/, name: "saveModelGateway" },
|
|
502
503
|
{ method: "DELETE", pattern: /^\/settings\/model-gateway$/, name: "deleteModelGateway" },
|
|
503
504
|
{ method: "POST", pattern: /^\/settings\/model-gateway\/test$/, name: "testModelGateway" },
|
|
505
|
+
// A free local model (local-model.ts): this machine and its recommended model, and one pull of it, the owner's alone.
|
|
506
|
+
{ method: "GET", pattern: /^\/settings\/local-model$/, name: "getLocalModel" },
|
|
507
|
+
{ method: "POST", pattern: /^\/settings\/local-model\/pull$/, name: "pullLocalModel" },
|
|
504
508
|
{ method: "GET", pattern: /^\/settings\/mcp-servers$/, name: "listMcpServers" },
|
|
505
509
|
{ method: "GET", pattern: /^\/settings\/mcp-server-names$/, name: "listMcpServerNames" },
|
|
506
510
|
{ method: "POST", pattern: /^\/settings\/mcp-servers\/preview$/, name: "previewMcpServer" },
|
|
@@ -958,7 +962,8 @@ export async function startServe(options) {
|
|
|
958
962
|
}
|
|
959
963
|
// The Ollama this server asks, and its runner beside it: OLLAMA_HOST, else the default address on one owner's own machine
|
|
960
964
|
// alone (ollamaHostOf). Read once, at the start: a refused one is said once, here, in the base rule's words.
|
|
961
|
-
const
|
|
965
|
+
const notOwn = whyNotOwnMachine(options, data, ownUser);
|
|
966
|
+
const ollamaHost = ollamaHostOf(process.env, notOwn.length === 0);
|
|
962
967
|
const tokenRefused = options.token === undefined ? undefined : tokenProblem(options.token);
|
|
963
968
|
if (tokenRefused)
|
|
964
969
|
throw new Error(tokenRefused);
|
|
@@ -1000,7 +1005,7 @@ export async function startServe(options) {
|
|
|
1000
1005
|
// would write the next server's outbox.
|
|
1001
1006
|
const stops = [];
|
|
1002
1007
|
try {
|
|
1003
|
-
return await startHolding(options, data, { maxRuns, minFreeBytes, learning, boxAllow, templates, ollamaHost }, stops);
|
|
1008
|
+
return await startHolding(options, data, { maxRuns, minFreeBytes, learning, boxAllow, templates, ollamaHost, notOwn }, stops);
|
|
1004
1009
|
}
|
|
1005
1010
|
catch (error) {
|
|
1006
1011
|
for (const stop of stops)
|
|
@@ -1030,7 +1035,7 @@ async function whileReplaced(take, held, until, waiting) {
|
|
|
1030
1035
|
}
|
|
1031
1036
|
}
|
|
1032
1037
|
async function startHolding(options, data, checked, stops) {
|
|
1033
|
-
const { maxRuns, minFreeBytes, learning, boxAllow, templates, ollamaHost } = checked;
|
|
1038
|
+
const { maxRuns, minFreeBytes, learning, boxAllow, templates, ollamaHost, notOwn } = checked;
|
|
1034
1039
|
/** What an agent's view says of its learning: how many learned items wait for its owner's OK, for an agent that learns
|
|
1035
1040
|
* on this server (learning on, its current revision `learning: true`); none for another, or when the count cannot be
|
|
1036
1041
|
* read (the view never fails for it). */
|
|
@@ -1363,7 +1368,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1363
1368
|
// probe that fails never lands; when it is the latest, it clears this as it fails, so no probe is out after it.
|
|
1364
1369
|
let probing;
|
|
1365
1370
|
// The latest probe's turn: it ends as that probe lands or fails, or as a later probe starts and overtakes it, whichever
|
|
1366
|
-
// is first, and never fails. A change that waits for the probe out waits for its turn (
|
|
1371
|
+
// is first, and never fails. A change that waits for the probe out waits for its turn (offersNow), so a dropped
|
|
1367
1372
|
// probe holds no one up and its failure is no one else's.
|
|
1368
1373
|
let turn = Promise.resolve();
|
|
1369
1374
|
let endTurn = () => { };
|
|
@@ -1413,16 +1418,17 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1413
1418
|
});
|
|
1414
1419
|
/** Whether the offers held now were made from `inputs` (offersInputs). */
|
|
1415
1420
|
const offersMadeFrom = (inputs) => offersFrom !== undefined && sameInputs(inputs, offersFrom);
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
// serverSecrets live, store-view), and a list builds a listing cut of other keys again (builtOfNow). A failed run's error words
|
|
1419
|
-
// name a refused key by the keys and settings, so those listings are built again.
|
|
1420
|
-
await lister.keysChanged();
|
|
1421
|
-
env = readEnv(base);
|
|
1421
|
+
/** What a revision that names no model needs (needsOf), made again from env as it is now: the latest ask's stands. */
|
|
1422
|
+
const needsNow = async () => {
|
|
1422
1423
|
const mine = ++needsAsked;
|
|
1423
1424
|
const next = await needsOf(env);
|
|
1424
1425
|
if (mine === needsAsked)
|
|
1425
1426
|
needs = next;
|
|
1427
|
+
};
|
|
1428
|
+
/** The offers made again from the inputs read now (offersInputs), with no listing built again and env not read again:
|
|
1429
|
+
* the end of a key's change (keysChanged), and all of a refresh of the login, or of a new Ollama listing, whose offers
|
|
1430
|
+
* are not made from the inputs now, since no key changed there. */
|
|
1431
|
+
const offersNow = async () => {
|
|
1426
1432
|
// A probe still out from other inputs (a turn-on's, after its turn-off) would put back offers made from them as it
|
|
1427
1433
|
// lands: a probe of these overtakes it. Only a change starts one, at most one per change, so nothing loops. While the
|
|
1428
1434
|
// probe out has read these inputs, a change starts none: with the offers held made from them too it recomposes at
|
|
@@ -1447,16 +1453,51 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1447
1453
|
return;
|
|
1448
1454
|
}
|
|
1449
1455
|
};
|
|
1456
|
+
const keysChanged = async () => {
|
|
1457
|
+
// A run's learning, view, list and timeline row are cut of the keys saved now by the run view at read time (it reads
|
|
1458
|
+
// serverSecrets live, store-view), and a list builds a listing cut of other keys again (builtOfNow). A failed run's error words
|
|
1459
|
+
// name a refused key by the keys and settings, so those listings are built again.
|
|
1460
|
+
await lister.keysChanged();
|
|
1461
|
+
env = readEnv(base);
|
|
1462
|
+
await needsNow();
|
|
1463
|
+
await offersNow();
|
|
1464
|
+
};
|
|
1450
1465
|
/** The Ollama here, as capabilities read it: its listing asked again behind the answer once stale (ollamaModels), and
|
|
1451
|
-
*
|
|
1466
|
+
* once a listing differs from the one the offers were made from, what a revision that names no model needs (its
|
|
1467
|
+
* default is the listing's: needsOf) and the offers made again from it. No key changed, so no run is relisted. So a
|
|
1452
1468
|
* model pulled, or Ollama started after this server, shows in a later answer with no restart. */
|
|
1453
1469
|
const ollamaNow = async () => {
|
|
1454
1470
|
if (!asksOllama(env))
|
|
1455
1471
|
return;
|
|
1456
1472
|
void ollamaModels(env);
|
|
1457
|
-
if (offersFrom
|
|
1458
|
-
|
|
1473
|
+
if (!offersFrom || offersMadeFrom(offersInputs(env)))
|
|
1474
|
+
return;
|
|
1475
|
+
await needsNow();
|
|
1476
|
+
await offersNow();
|
|
1459
1477
|
};
|
|
1478
|
+
/** How many times a pull's end reads the Ollama listing for its tag before it fails (ollamaPulled). */
|
|
1479
|
+
const PULL_LISTED_TRIES = 6;
|
|
1480
|
+
/** After a pull of `tag` here ends (local-model.ts): the kept listing dropped and read again at once until it lists
|
|
1481
|
+
* `tag` (a listing whose ask of one model failed lists it not), and the reading made again where it differs, so the
|
|
1482
|
+
* model is in the picker and is the default with no wait for OLLAMA_TTL_MS before the pull says done. Never listed
|
|
1483
|
+
* after PULL_LISTED_TRIES reads, the pull fails in words, so the card never runs a template on another model. */
|
|
1484
|
+
const ollamaPulled = async (tag) => {
|
|
1485
|
+
for (let tries = 1;; tries++) {
|
|
1486
|
+
ollamaForget(env);
|
|
1487
|
+
const listed = await ollamaModels(env);
|
|
1488
|
+
if (listed.some((model) => model.name === fullTag(tag)))
|
|
1489
|
+
break;
|
|
1490
|
+
if (tries >= PULL_LISTED_TRIES)
|
|
1491
|
+
throw new Error(`Ollama finished pulling ${tag} but does not list it yet. Press Pull again.`);
|
|
1492
|
+
await new Promise((resolve) => setTimeout(resolve, 250 * tries));
|
|
1493
|
+
}
|
|
1494
|
+
await ollamaNow();
|
|
1495
|
+
};
|
|
1496
|
+
/** This machine, read once (local-model.ts readMachine), or a test's. */
|
|
1497
|
+
let machineRead;
|
|
1498
|
+
const machineOf = () => (machineRead ??= (options.machine ?? readMachine)());
|
|
1499
|
+
const pulls = localPulls({ pull: pullThrough(() => env, options.pullStallMs), finished: ollamaPulled, ...(log ? { log } : {}), signal: stopping.signal });
|
|
1500
|
+
const localModelDeps = () => ({ env, notOwn, machine: machineOf, pulls });
|
|
1460
1501
|
/** After a harness key is saved or removed (harness-keys.ts): the listings built again, cut of it, and the offers probed
|
|
1461
1502
|
* again, as a recipe is offered once every key it runs on is saved here (harnessKeysSavedHere). No environment changes. */
|
|
1462
1503
|
const harnessKeysChanged = async () => {
|
|
@@ -1561,8 +1602,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1561
1602
|
* that fails is answered to it. A probe with no hand-over (a key's save, a harness key's, a new Ollama listing) can
|
|
1562
1603
|
* drop the hand-over's too, and then fail or still be out: the hand-over is still the latest and did not fail, yet the
|
|
1563
1604
|
* offers held were made before it. So the request also goes on only where the offers held are made from the inputs
|
|
1564
|
-
* now (offersMadeFrom); where not, it makes them as a key's save
|
|
1565
|
-
* these inputs, or probes itself, and a probe of its own that fails is answered to it)
|
|
1605
|
+
* now (offersMadeFrom); where not, it makes them again as a key's save ends (offersNow: it waits for the probe out of
|
|
1606
|
+
* these inputs, or probes itself, and a probe of its own that fails is answered to it), with no run relisted, as no
|
|
1607
|
+
* key changed. It looks at most LOGIN_ROUNDS
|
|
1566
1608
|
* times, then is refused (unavailable, retryable), so turns that keep coming never hold it for ever. */
|
|
1567
1609
|
const loginNow = async () => {
|
|
1568
1610
|
if (loginOff !== undefined)
|
|
@@ -1571,7 +1613,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1571
1613
|
const n = await refreshOnce();
|
|
1572
1614
|
const latest = () => handed.n === n && !handed.failed;
|
|
1573
1615
|
if (latest() && !offersMadeFrom(offersInputs(env)))
|
|
1574
|
-
await
|
|
1616
|
+
await offersNow();
|
|
1575
1617
|
if (latest() && offersMadeFrom(offersInputs(env)))
|
|
1576
1618
|
return;
|
|
1577
1619
|
if (round >= LOGIN_ROUNDS)
|
|
@@ -1791,7 +1833,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1791
1833
|
* list reads it, so a tool of bash's family the run would not have shows unavailable (tool-plane.ts shellUnavailable). */
|
|
1792
1834
|
const shellOfRevision = async (revision) => {
|
|
1793
1835
|
const body = revision.body;
|
|
1794
|
-
return shellOf(settingOfDefinition(body)?.computer ?? computerOfPlace(fallbackPlace(revision.kind, revision.kind === "agentic" ? (body.tools ?? []) : [])));
|
|
1836
|
+
return shellOf(settingOfDefinition(body)?.computer ?? computerOfPlace(await fallbackPlace(revision.kind, revision.kind === "agentic" ? (body.tools ?? []) : [])));
|
|
1795
1837
|
};
|
|
1796
1838
|
/** The run read's costs (A8, store-reads/learning.ts runAllInOverStore): `cost.usd` its own spend, the
|
|
1797
1839
|
* job's (its compile turn is learning's), null while unknown; what learning spent for it
|
|
@@ -3180,7 +3222,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3180
3222
|
if (!revision.mcpPin && tools.some((tool) => mcpToolOf(tool)))
|
|
3181
3223
|
return null;
|
|
3182
3224
|
try {
|
|
3183
|
-
await runnable(revision, resolvePlace(body.place, fallbackPlace(revision.kind, tools)), { capped: body.maxCostUsd !== undefined, price: readDecisionPrice });
|
|
3225
|
+
await runnable(revision, resolvePlace(body.place, await fallbackPlace(revision.kind, tools)), { capped: body.maxCostUsd !== undefined, price: readDecisionPrice });
|
|
3184
3226
|
return null;
|
|
3185
3227
|
}
|
|
3186
3228
|
catch (error) {
|
|
@@ -3311,8 +3353,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3311
3353
|
const asks = blockers.flatMap((b) => (b.asks ? [b.asks] : []));
|
|
3312
3354
|
throw new ApiError("agent_not_runnable", message, { fields, details: { adapters: [...new Set(blockers.flatMap((b) => (b.adapter ? [b.adapter] : [])))], unbound, missing, code: blockers.some((b) => b.codeNodes || b.shell), ...(tier ? { tier } : {}), ...(Object.keys(decisions).length ? { decisions } : {}), ...(denied.length ? { denied } : {}), ...(asks.length ? { asks } : {}), ...named } });
|
|
3313
3355
|
}
|
|
3314
|
-
/** Where a revision of `kind` naming `tools` and no place runs here: the place a new agent would be saved with
|
|
3315
|
-
|
|
3356
|
+
/** Where a revision of `kind` naming `tools` and no place runs here: the place a new agent would be saved with, in the
|
|
3357
|
+
* folder mode of now (Mode 2, where the runner's shell is Archil's exec: the runner, never Docker's box). */
|
|
3358
|
+
const fallbackPlace = async (kind, tools) => defaultPlaceOf(kind, tools, boxOffers, toolOf, (await modeNow()) === 2);
|
|
3316
3359
|
/** What a save of `revision` pins of the MCP tools it grants (an agentic revision's: a workflow's nodes bind none): each
|
|
3317
3360
|
* granted server listed once, now, with its saved credential (McpServersOverStore.pinListing), as `tools` each server's
|
|
3318
3361
|
* listing in the harnesses' shape for the save's checks (blockersOf's `mcp`), and `pin` making the pin from them. A server
|
|
@@ -3421,7 +3464,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3421
3464
|
void install.ensure().catch((error) => log?.(logLine("harness_install_failed", { harness: install.entry.id, message: error.message })));
|
|
3422
3465
|
}
|
|
3423
3466
|
const named = (revision.kind === "agentic" ? { kind: "agentic", ...body } : workflowShape(body));
|
|
3424
|
-
const shape = named.place ? named : { ...named, place: fallbackPlace(named.kind, named.tools ?? []), unnamed: true };
|
|
3467
|
+
const shape = named.place ? named : { ...named, place: await fallbackPlace(named.kind, named.tools ?? []), unnamed: true };
|
|
3425
3468
|
const listing = await mcpListingOf(revision, previous?.mcpPin);
|
|
3426
3469
|
const mcp = listing.tools;
|
|
3427
3470
|
const { monid, warnings: usage = [] } = (await monidPinOf(revision, previous)) ?? {};
|
|
@@ -3502,7 +3545,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3502
3545
|
let warnings = [];
|
|
3503
3546
|
const definition = checkDefinitionBody(body, { harnesses });
|
|
3504
3547
|
const named = Array.isArray(definition.definition.tools) ? definition.definition.tools : [];
|
|
3505
|
-
const place = fallbackPlace("agentic", definition.definition.tools === undefined ? NEW_AGENT_TOOLS : named);
|
|
3548
|
+
const place = await fallbackPlace("agentic", definition.definition.tools === undefined ? NEW_AGENT_TOOLS : named);
|
|
3506
3549
|
const tools = defaultToolsAt(place);
|
|
3507
3550
|
const entry = await agents.create(definition, async (revision) => {
|
|
3508
3551
|
// A template's apply says whether its package named its tools (applyWith): one that named none, and no computer
|
|
@@ -3769,7 +3812,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3769
3812
|
// The model of each tier its subagents run on (packageTiers): the package's where this server runs it.
|
|
3770
3813
|
const tiers = await packageTiers(env, pkg.model, harness ?? DEFAULT_HARNESS, model);
|
|
3771
3814
|
const modelWarnings = [...("warning" in picked && picked.warning ? [picked.warning] : []), ...(tiers.warning ? [tiers.warning] : [])].map((message) => ({ field: "model", reason: "not_an_option", message }));
|
|
3772
|
-
|
|
3815
|
+
// A package that names no tools gets a new agent's where a new agent goes (fallbackPlace): the box's shell tools in
|
|
3816
|
+
// Docker's box; none on the runner, Mode 2's included.
|
|
3817
|
+
const defaultTools = defaultToolsAt(await fallbackPlace("agentic", NEW_AGENT_TOOLS)) ?? [];
|
|
3773
3818
|
// A grant never lifts a deny the owner set on this server: that tool keeps it, and the answer says so.
|
|
3774
3819
|
const server = settings.get();
|
|
3775
3820
|
const denied = grants.filter((tool) => { const set = permissionFrom(tool, server); return set.from === "server" && set.permission === "deny"; });
|
|
@@ -3793,9 +3838,13 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3793
3838
|
if (!skip)
|
|
3794
3839
|
return [];
|
|
3795
3840
|
const keptOn = had.find((row) => row.enabled && row.name === String(trigger.name).trim());
|
|
3796
|
-
//
|
|
3797
|
-
|
|
3798
|
-
|
|
3841
|
+
// Under the run-keys setting the kept one's firings bring no keys. One that starts a run of this revision is refused
|
|
3842
|
+
// for the keys it owes, but the kept trigger's target is not checked here: a message_run trigger whose run is pinned
|
|
3843
|
+
// to an earlier revision that owes no keys still messages it, and that run may spend. So the warning promises no refusal.
|
|
3844
|
+
const kept = options.apiOnly
|
|
3845
|
+
? `is kept as it was, and still fires: PATCH /v2/triggers/${keptOn?.id} with {"enabled": false} turns it off`
|
|
3846
|
+
: `is kept as it was and still fires until you turn it off (PATCH /v2/triggers/${keptOn?.id} with {"enabled": false}): a firing that would start a run of this revision is refused 409 for the keys it owes, but one aimed at a run of an earlier revision that owes none still reaches that run, which may spend`;
|
|
3847
|
+
return [[i, keptOn ? { ...skip, message: `${skip.message} The agent's trigger ${keptOn.id} of that name ${kept}.` } : skip]];
|
|
3799
3848
|
}));
|
|
3800
3849
|
const unmade = (i) => emptyFeeds.has(i) || hostless.has(i);
|
|
3801
3850
|
const refusedTriggers = madeTriggerIssues(made.triggers, options.triggerClock?.now() ?? Date.now(), pkg.inputSchema).filter((issue) => !unmade(Number(/^triggers\.(\d+)\./.exec(issue.field)?.[1])));
|
|
@@ -5649,9 +5698,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5649
5698
|
// the archive, each turned on again by PATCH /triggers/{id} {enabled: true}.
|
|
5650
5699
|
// In the agent's delete turn (agentWrite): an unarchive sent while its purge runs waits for it and is 410, so no
|
|
5651
5700
|
// run of it starts between the purge's live check and its tombstone.
|
|
5652
|
-
// On an API-only server with the launch hook
|
|
5653
|
-
//
|
|
5654
|
-
const turnOn = options.apiOnly && options.launchHook ? (
|
|
5701
|
+
// On an API-only server with the launch hook the unarchive turns its schedule and feed triggers on again (the ones
|
|
5702
|
+
// its apply makes there), so a backend's redeploy needs no PATCH of each.
|
|
5703
|
+
const turnOn = options.apiOnly && options.launchHook ? (trigger) => apiOnlyTurnsOn(trigger.source.kind, trigger.target.kind, true) : undefined;
|
|
5655
5704
|
const triggersOff = await agentWrite(id, () => (found.name === "archiveAgent" ? triggers.agentArchived(id) : triggers.agentUnarchived(id, turnOn)));
|
|
5656
5705
|
// An archived agent's own computer is deleted (an unarchived one gets a new one at its next persistent run).
|
|
5657
5706
|
if (found.name === "archiveAgent")
|
|
@@ -6351,6 +6400,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6351
6400
|
const answer = await modelGatewayRoute({ store, sealKey: seal.key, env: own(withSecrets(base, "own")), changed: gatewayChanged }, found.name, { ...(body !== undefined ? { body } : {}), signal: stopping.signal });
|
|
6352
6401
|
return send(res, 200, answer, { "cache-control": "no-store" });
|
|
6353
6402
|
}
|
|
6403
|
+
// A free local model (local-model.ts): never through `idempotent`, as a pull is one at a time and says so itself.
|
|
6404
|
+
case "getLocalModel":
|
|
6405
|
+
return send(res, 200, await localModelView(localModelDeps()), { "cache-control": "no-store" });
|
|
6406
|
+
case "pullLocalModel":
|
|
6407
|
+
return send(res, 202, await pullLocalModel(localModelDeps(), await bodyOf(req)), { "cache-control": "no-store" });
|
|
6354
6408
|
// Never through `idempotent`: its record keeps the body, and a body may hold a credential.
|
|
6355
6409
|
case "listMcpServers":
|
|
6356
6410
|
return send(res, 200, await mcpServers.list());
|
|
@@ -6561,7 +6615,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6561
6615
|
const records = await promotionsOf(store.learning, id);
|
|
6562
6616
|
const costStop = await costStopOverStore(store, id);
|
|
6563
6617
|
const body = entry.revision?.body;
|
|
6564
|
-
const modelEnv = !body || sdkOf(body) || nativeOf(body) ? env : envAtPlace(env, resolvePlace(body.place, fallbackPlace(entry.revision.kind === "workflow" ? "workflow" : "agentic", body.tools ?? [])));
|
|
6618
|
+
const modelEnv = !body || sdkOf(body) || nativeOf(body) ? env : envAtPlace(env, resolvePlace(body.place, await fallbackPlace(entry.revision.kind === "workflow" ? "workflow" : "agentic", body.tools ?? [])));
|
|
6565
6619
|
return send(res, 200, { ...await agentLearning(store, id, await learningShown(id), counts, impact, (workflow) => servingStateOf(records, workflow, costStop)), learning_model: await learningModelOf(modelEnv, entry.revision) });
|
|
6566
6620
|
}
|
|
6567
6621
|
case "getLearningCost": {
|
|
@@ -6873,9 +6927,18 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6873
6927
|
return send(res, 200, triggerRotated(id, (await triggers.rotate(id)).secret, new Date().toISOString()));
|
|
6874
6928
|
case "getTrigger":
|
|
6875
6929
|
return send(res, 200, withSecretOf(await triggers.get(id)));
|
|
6876
|
-
case "updateTrigger":
|
|
6930
|
+
case "updateTrigger": {
|
|
6931
|
+
const body = await bodyOf(req);
|
|
6932
|
+
// On an API-only server, `enabled` alone, and on only where its apply would make the trigger (api-only.ts).
|
|
6933
|
+
if (options.apiOnly) {
|
|
6934
|
+
const trigger = await triggers.get(id);
|
|
6935
|
+
const refused = apiOnlyTriggerEdit(body, trigger.source.kind, options.launchHook !== undefined, trigger.target.kind);
|
|
6936
|
+
if (refused.length)
|
|
6937
|
+
throw invalid(refused);
|
|
6938
|
+
}
|
|
6877
6939
|
// Its secret's metadata as a read answers it, so a page showing the changed trigger keeps saying it is set.
|
|
6878
|
-
return send(res, 200, withSecretOf(await triggers.update(id,
|
|
6940
|
+
return send(res, 200, withSecretOf(await triggers.update(id, body)));
|
|
6941
|
+
}
|
|
6879
6942
|
case "deleteTrigger": {
|
|
6880
6943
|
// Deleted here whatever its sender says; what could not be removed there is answered (Composio's instance).
|
|
6881
6944
|
const said = await triggers.remove(id);
|
package/dist/slack.js
CHANGED
|
@@ -277,7 +277,8 @@ export function slackMessage(type, data, { agent, base }) {
|
|
|
277
277
|
const lines = [
|
|
278
278
|
`Trigger ${link(triggerUrl, name)} could not start its run${agent ? ` of ${who}` : ""}.`,
|
|
279
279
|
`\`${esc(code || "error")}\`${message ? `: ${esc(message)}` : ""}`,
|
|
280
|
-
|
|
280
|
+
// The console's way, the CLI's and the API's: a server with no console (the API-only profile) takes the last two.
|
|
281
|
+
...(data.auto_paused === true ? [`It failed too many times in a row, so it is off now: turn it on again in the console, with \`agentrun triggers update ${esc(str(data.trigger_id))} --enabled\`, or with \`PATCH /v2/triggers/${esc(str(data.trigger_id))}\` and \`{"enabled": true}\`.`] : []),
|
|
281
282
|
];
|
|
282
283
|
return {
|
|
283
284
|
text: esc(`Trigger ${name} could not start its run${code ? `: ${code}` : ""}`),
|
|
@@ -174,8 +174,10 @@ export async function migrate(client, schema, at, migrations = migrationsIn()) {
|
|
|
174
174
|
throw new SchemaVersionUnknown(placeOf(schema), top, known);
|
|
175
175
|
for (const row of applied) {
|
|
176
176
|
const mine = migrations[Number(row.version) - 1];
|
|
177
|
+
// Both files named, the schema's and this build's, so a migration renamed or renumbered on one side is plain.
|
|
177
178
|
if (mine && mine.sha256 !== row.sha256) {
|
|
178
|
-
|
|
179
|
+
const file = (version, name, sha256) => `${String(version).padStart(4, "0")}_${name}.sql (sha256 ${sha256.slice(0, 12)})`;
|
|
180
|
+
throw new Error(`${placeOf(schema)} applied ${file(row.version, row.name, row.sha256)} where this build has ${file(mine.version, mine.name, mine.sha256)}: an applied migration is never edited, renumbered or renamed, a change is a new file`);
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
for (const migration of migrations.slice(top ?? 0)) {
|
|
@@ -159,10 +159,11 @@ export declare const costStopOverStore: (store: Store, agentId: string) => Promi
|
|
|
159
159
|
* new answer is the agent's, with its digest. Else, for a run its launch offered a learned workflow, its timeline
|
|
160
160
|
* (runner/learning-end.ts runPathOf, the agent calling the tool itself): `workflow` when its job did only that,
|
|
161
161
|
* `handed_back` when the agent went on, with the workflow it called last that ran (its call's record,
|
|
162
|
-
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent
|
|
162
|
+
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent`, one whose learned calls were all refused
|
|
163
|
+
* included. Both read the run's rows less its feedback rounds' (withoutFeedbackRounds): a grade's
|
|
163
164
|
* round never moves the path. `cut` on a hand-back a restart cut (servedOf: the workflow's call ended `interrupted`),
|
|
164
165
|
* never one the workflow made itself. `entries`: the run's (runEntries), when the caller read them already. */
|
|
165
|
-
export declare function runPathOverStore(store: Store, runId: string, started: RunLaunch["learning"], redact
|
|
166
|
+
export declare function runPathOverStore(store: Store, runId: string, started: RunLaunch["learning"], redact: (text: string) => string, entries?: readonly EntryLike[]): Promise<{
|
|
166
167
|
path: RunPath;
|
|
167
168
|
workflow: string | null;
|
|
168
169
|
digest?: string;
|
|
@@ -174,8 +175,8 @@ export declare function runPathOverStore(store: Store, runId: string, started: R
|
|
|
174
175
|
* classified (runPathOverStore, for a run that learns) and kept with its calls (`workflow_calls`) and why its ending
|
|
175
176
|
* claim's first choice did or did not serve (`choice`, firstChoice's reason). `redact`: the run's cut, as its
|
|
176
177
|
* follow-up showed a served answer. */
|
|
177
|
-
export declare function runPathMetricsOverStore(store: Store, runId: string, launch: RunLaunch, { redact, choice }
|
|
178
|
-
readonly redact
|
|
178
|
+
export declare function runPathMetricsOverStore(store: Store, runId: string, launch: RunLaunch, { redact, choice }: {
|
|
179
|
+
readonly redact: (text: string) => string;
|
|
179
180
|
readonly choice?: FirstReason;
|
|
180
181
|
}): Promise<ReturnType<typeof pathMetrics>>;
|
|
181
182
|
/** The path a run's views say it took (GET /runs/{id} and each runs list row: `path`, and `workflow`), read off its record
|
|
@@ -476,7 +476,8 @@ export const costStopOverStore = async (store, agentId) => pastRunsOverStore(sto
|
|
|
476
476
|
* new answer is the agent's, with its digest. Else, for a run its launch offered a learned workflow, its timeline
|
|
477
477
|
* (runner/learning-end.ts runPathOf, the agent calling the tool itself): `workflow` when its job did only that,
|
|
478
478
|
* `handed_back` when the agent went on, with the workflow it called last that ran (its call's record,
|
|
479
|
-
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent
|
|
479
|
+
* runner/workflow-calls.ts workflowCallsOf). Any other run's path is `agent`, one whose learned calls were all refused
|
|
480
|
+
* included. Both read the run's rows less its feedback rounds' (withoutFeedbackRounds): a grade's
|
|
480
481
|
* round never moves the path. `cut` on a hand-back a restart cut (servedOf: the workflow's call ended `interrupted`),
|
|
481
482
|
* never one the workflow made itself. `entries`: the run's (runEntries), when the caller read them already. */
|
|
482
483
|
export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
@@ -485,7 +486,9 @@ export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
|
485
486
|
// the run is classified as the agent's own calls say.
|
|
486
487
|
const calls = workflowCallsOf(entries);
|
|
487
488
|
const served = calls.some((call) => call.caller === "platform" && call.outcome === "refused") ? undefined : servedOf(entries);
|
|
488
|
-
|
|
489
|
+
// A run offered no workflow, or whose every learned call was refused (none ran a node), is the agent's, whatever its
|
|
490
|
+
// timeline shows of the refused calls (runPathOf reads a call and the agent going on after it as a hand-back).
|
|
491
|
+
if (!served && (!started?.workflows?.length || (calls.length > 0 && calls.every((call) => call.outcome === "refused"))))
|
|
489
492
|
return { path: "agent", workflow: null };
|
|
490
493
|
// The path is who wrote the run's final answer, read on the job's own rows: a grade's feedback round asks the agent no
|
|
491
494
|
// turn of the job's, so its words and its rows never change it (withoutFeedbackRounds).
|
|
@@ -496,7 +499,7 @@ export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
|
496
499
|
// The workflow's answer as it produced it (its journal's), and as a follow-up showed it to the agent (cut by the
|
|
497
500
|
// runner's `redact`, adapter-loop.ts servedAnswerText): an agent that says it again leaves the path the workflow's.
|
|
498
501
|
const answer = servedAnswerOf(entries)?.answer ?? "";
|
|
499
|
-
const alone = served.outcome === "answered" && servedAnswerStands(answer, rows, redact
|
|
502
|
+
const alone = served.outcome === "answered" && servedAnswerStands(answer, rows, redact(answer));
|
|
500
503
|
return { path: alone ? "workflow" : "handed_back", workflow: served.workflow, ...(served.digest ? { digest: served.digest } : {}), ...(served.promotion !== undefined ? { promotion: served.promotion } : {}), ...(served.cut ? { cut: true } : {}) };
|
|
501
504
|
}
|
|
502
505
|
const path = runPathOf(rows);
|
|
@@ -514,7 +517,7 @@ export async function runPathOverStore(store, runId, started, redact, entries) {
|
|
|
514
517
|
* classified (runPathOverStore, for a run that learns) and kept with its calls (`workflow_calls`) and why its ending
|
|
515
518
|
* claim's first choice did or did not serve (`choice`, firstChoice's reason). `redact`: the run's cut, as its
|
|
516
519
|
* follow-up showed a served answer. */
|
|
517
|
-
export async function runPathMetricsOverStore(store, runId, launch, { redact, choice }
|
|
520
|
+
export async function runPathMetricsOverStore(store, runId, launch, { redact, choice }) {
|
|
518
521
|
if (!launch.learning && !launch.audit)
|
|
519
522
|
return {};
|
|
520
523
|
const entries = await runEntries(store, runId, BACKGROUND_CONTEXT);
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -145,10 +145,16 @@ export type ResolveInput = {
|
|
|
145
145
|
* none (and for pi, whose hosted search is asked of the model's provider). */
|
|
146
146
|
export declare const ownSearchViaOpenRouter: (env: NodeJS.ProcessEnv, harness: string, model?: string) => boolean;
|
|
147
147
|
export declare const FIRECRAWL_FETCH = "Firecrawl's free keyless fetch, no key, the guarded direct fetch behind it. web_fetch sends each URL to Firecrawl's keyless service (never a private or local one); choose kernel to fetch directly";
|
|
148
|
+
/** A capability a claim held to UNREAD_CEILINGS: it runs nothing, and says why without the store's words. */
|
|
149
|
+
export declare const SETTINGS_NOT_READ: Resolution;
|
|
150
|
+
/** A capability a claim found past a ceiling where today's resolution (planeFor) gives none in its place, as where its
|
|
151
|
+
* tool is not granted in today's tooling: it runs nothing, never the value it was kept with (claimPlane). */
|
|
152
|
+
export declare const CEILING_LEAVES_NONE: Resolution;
|
|
148
153
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
149
154
|
* the two never disagree. A web_search the run's own tool runs, and a web_fetch its own Web serves (any resolution but
|
|
150
155
|
* a deny), say what Jev does with it and what it sends TypeSafe, where the server has a Jev key, or that Jev is off
|
|
151
|
-
* (`jevWhy`, `jevFetchWhy`).
|
|
156
|
+
* (`jevWhy`, `jevFetchWhy`). An agent's pick the server's setting is a ceiling over (CEILINGS) resolves as the server's
|
|
157
|
+
* setting does, and the why says so. */
|
|
152
158
|
export declare function explainCapability(capability: Pickable, input: ResolveInput): {
|
|
153
159
|
resolves: Resolution;
|
|
154
160
|
why: string;
|
|
@@ -256,6 +262,22 @@ export declare function relaunchPlane(kept: Plane | undefined, env: NodeJS.Proce
|
|
|
256
262
|
capped?: boolean;
|
|
257
263
|
first?: boolean;
|
|
258
264
|
}): Plane;
|
|
265
|
+
/** Whether a capability of `kept` goes past a ceiling of the server's `settings` now (claimCeiling). */
|
|
266
|
+
export declare const overCeilings: (kept: Plane, tooling: Tooling, settings: ToolSettingsMap, { unread }?: {
|
|
267
|
+
unread?: boolean;
|
|
268
|
+
}) => boolean;
|
|
269
|
+
/** The Plane a claim hands its run (runner/harness-loops.ts, before anything binds): `kept`, the launch's (resolved at
|
|
270
|
+
* the run's start), under the server's `settings` now. A capability kept past a ceiling the server's setting now sets
|
|
271
|
+
* (claimCeiling) takes today's resolution (planeFor in `env` for `tooling`) on `model`, the run's pinned one (its
|
|
272
|
+
* launch's), so a resume, a follow-up or a reclaim sends nothing the setting keeps from it, and its native search asks
|
|
273
|
+
* the model the run sends. Where the settings could not be read (`unread`), one past the strictest ceiling runs nothing
|
|
274
|
+
* (SETTINGS_NOT_READ), and so does one today's resolution leaves without one (CEILING_LEAVES_NONE). Every other value
|
|
275
|
+
* stays as kept; the same Plane where nothing is past a ceiling. */
|
|
276
|
+
export declare function claimPlane(kept: Plane, env: NodeJS.ProcessEnv, tooling: Tooling, settings: ToolSettingsMap, { capped, model, unread }?: {
|
|
277
|
+
capped?: boolean;
|
|
278
|
+
model?: string;
|
|
279
|
+
unread?: boolean;
|
|
280
|
+
}): Plane;
|
|
259
281
|
/** The Plane the server handed this run's process; empty when it handed none. */
|
|
260
282
|
export declare function planeOf(env: NodeJS.ProcessEnv): Plane;
|
|
261
283
|
/** Whether a run is handed Parallel's key: one of its capabilities resolves to Parallel. */
|
package/dist/tool-plane.js
CHANGED
|
@@ -211,18 +211,56 @@ export const FIRECRAWL_FETCH = "Firecrawl's free keyless fetch, no key, the guar
|
|
|
211
211
|
* only where it is the model provider's hosted search (pi's), never a harness's own search inside its CLI. */
|
|
212
212
|
const searchesOwn = (resolves, facts) => WEB_RUNS.web_search.includes(resolves) && (resolves !== "native" || !facts?.webSearch);
|
|
213
213
|
const ranksOwn = (resolves, input) => searchesOwn(resolves, input.facts);
|
|
214
|
+
/** The server's settings that are a ceiling an agent's pick cannot raise: web_fetch `kernel` keeps every URL on the
|
|
215
|
+
* server; web_search `native` keeps every query with the harness's own search, and `off` sends none. Under one, an
|
|
216
|
+
* agent's pick that would send anywhere but the ceiling's own resolves as the server's setting does: a keyless third
|
|
217
|
+
* party (Firecrawl, Exa), Parallel even when the agent names it, and under `off` a native search even when the agent
|
|
218
|
+
* names it (ceilingOver). An operator who wants Parallel sets it server-wide; that is no ceiling. */
|
|
219
|
+
const CEILINGS = { web_fetch: [DIRECT_FETCH], web_search: ["native", "off"] };
|
|
220
|
+
/** The ceiling a claim holds each capability to where the server's tool settings could not be read: the strictest that
|
|
221
|
+
* leaves the run a tool (claimPlane). */
|
|
222
|
+
const UNREAD_CEILINGS = { web_fetch: DIRECT_FETCH, web_search: "native" };
|
|
223
|
+
/** A capability a claim held to UNREAD_CEILINGS: it runs nothing, and says why without the store's words. */
|
|
224
|
+
export const SETTINGS_NOT_READ = "unavailable: the server's tool settings could not be read";
|
|
225
|
+
/** A capability a claim found past a ceiling where today's resolution (planeFor) gives none in its place, as where its
|
|
226
|
+
* tool is not granted in today's tooling: it runs nothing, never the value it was kept with (claimPlane). */
|
|
227
|
+
export const CEILING_LEAVES_NONE = "unavailable: the server's tool setting keeps it from this run, with nothing it allows in its place";
|
|
228
|
+
const KEYLESS = ["firecrawl-keyless", "exa-keyless"];
|
|
229
|
+
/** Whether `provider`, as picked or as resolved, goes past ceiling `pick`: a keyless third party or Parallel, under any
|
|
230
|
+
* ceiling; a native search, under one that is not native search itself (`off`). */
|
|
231
|
+
const pastCeiling = (pick, provider) => provider !== undefined && (KEYLESS.includes(provider) || provider === "parallel" || (provider === "native" && pick !== "native"));
|
|
232
|
+
/** The ceiling `pick` (the server's setting for `capability`) sets over a run's capability, where it goes past it; else
|
|
233
|
+
* undefined. Past it: the agent's `choice` named past it, whatever it resolves to (Parallel with no key, a native
|
|
234
|
+
* search the harness lacks), or `resolves`, what it resolves to (the agent's auto, or a kept run's from before the
|
|
235
|
+
* setting), past it. One that sends nothing (unavailable, denied, off) from a choice within it, the guarded direct
|
|
236
|
+
* fetch and the ceiling's own native search go past none. */
|
|
237
|
+
const ceilingOver = (capability, pick, choice, resolves) => {
|
|
238
|
+
if (pick === undefined || !CEILINGS[capability]?.includes(pick))
|
|
239
|
+
return undefined;
|
|
240
|
+
return pastCeiling(pick, choice) || pastCeiling(pick, resolves) ? pick : undefined;
|
|
241
|
+
};
|
|
214
242
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
215
243
|
* the two never disagree. A web_search the run's own tool runs, and a web_fetch its own Web serves (any resolution but
|
|
216
244
|
* a deny), say what Jev does with it and what it sends TypeSafe, where the server has a Jev key, or that Jev is off
|
|
217
|
-
* (`jevWhy`, `jevFetchWhy`).
|
|
245
|
+
* (`jevWhy`, `jevFetchWhy`). An agent's pick the server's setting is a ceiling over (CEILINGS) resolves as the server's
|
|
246
|
+
* setting does, and the why says so. */
|
|
218
247
|
export function explainCapability(capability, input) {
|
|
219
|
-
const said =
|
|
248
|
+
const said = ceilinged(capability, input);
|
|
220
249
|
if (capability === "web_search" && input.jevWhy && ranksOwn(said.resolves, input))
|
|
221
250
|
return { ...said, why: `${said.why}; ${input.jevWhy}` };
|
|
222
251
|
if (capability === "web_fetch" && input.jevFetchWhy && WEB_RUNS.web_fetch.includes(said.resolves))
|
|
223
252
|
return { ...said, why: `${said.why}; ${input.jevFetchWhy}` };
|
|
224
253
|
return said;
|
|
225
254
|
}
|
|
255
|
+
function ceilinged(capability, input) {
|
|
256
|
+
const said = explained(capability, input);
|
|
257
|
+
const ceiling = input.override === undefined ? undefined : ceilingOver(capability, input.pick, input.override, said.resolves);
|
|
258
|
+
if (ceiling === undefined)
|
|
259
|
+
return said;
|
|
260
|
+
const { override, ...server } = input;
|
|
261
|
+
const kept = explained(capability, server);
|
|
262
|
+
return { resolves: kept.resolves, why: `the server's setting, ${ceiling}, is a ceiling over this agent's pick of ${override}; ${kept.why}` };
|
|
263
|
+
}
|
|
226
264
|
function explained(capability, input) {
|
|
227
265
|
const chosen = input.override ?? input.pick ?? PROVIDERS[capability][0];
|
|
228
266
|
const picked = input.override !== undefined ? "picked for this agent" : "picked in settings";
|
|
@@ -450,6 +488,36 @@ export function relaunchPlane(kept, env, tooling, settings, { capped = false, fi
|
|
|
450
488
|
return recheckPlane(kept, env, { fresh, permission: (name) => permissionOf(name, settings, tooling?.overrides ?? {}, tooling?.approvals ?? "ask") });
|
|
451
489
|
return tooling ? recheckPlane(keptFromBefore(fresh), env) : {};
|
|
452
490
|
}
|
|
491
|
+
/** The ceiling over capability `name` of `kept` (a launch's Plane) under the server's `settings` now, for a run of
|
|
492
|
+
* `tooling` (its agent's own picks): ceilingOver, or, where the settings could not be read (`unread`), the strictest
|
|
493
|
+
* (UNREAD_CEILINGS). */
|
|
494
|
+
const claimCeiling = (name, kept, tooling, settings, unread) => ceilingOver(name, unread ? UNREAD_CEILINGS[name] : settings[name]?.provider, tooling.overrides?.[name]?.provider, kept[name]);
|
|
495
|
+
/** Whether a capability of `kept` goes past a ceiling of the server's `settings` now (claimCeiling). */
|
|
496
|
+
export const overCeilings = (kept, tooling, settings, { unread = false } = {}) => PICKABLE.some((name) => kept[name] !== undefined && claimCeiling(name, kept, tooling, settings, unread) !== undefined);
|
|
497
|
+
/** The Plane a claim hands its run (runner/harness-loops.ts, before anything binds): `kept`, the launch's (resolved at
|
|
498
|
+
* the run's start), under the server's `settings` now. A capability kept past a ceiling the server's setting now sets
|
|
499
|
+
* (claimCeiling) takes today's resolution (planeFor in `env` for `tooling`) on `model`, the run's pinned one (its
|
|
500
|
+
* launch's), so a resume, a follow-up or a reclaim sends nothing the setting keeps from it, and its native search asks
|
|
501
|
+
* the model the run sends. Where the settings could not be read (`unread`), one past the strictest ceiling runs nothing
|
|
502
|
+
* (SETTINGS_NOT_READ), and so does one today's resolution leaves without one (CEILING_LEAVES_NONE). Every other value
|
|
503
|
+
* stays as kept; the same Plane where nothing is past a ceiling. */
|
|
504
|
+
export function claimPlane(kept, env, tooling, settings, { capped = false, model, unread = false } = {}) {
|
|
505
|
+
const past = PICKABLE.filter((name) => kept[name] !== undefined && claimCeiling(name, kept, tooling, settings, unread) !== undefined);
|
|
506
|
+
if (!past.length)
|
|
507
|
+
return kept;
|
|
508
|
+
const out = { ...kept };
|
|
509
|
+
if (unread) {
|
|
510
|
+
for (const name of past)
|
|
511
|
+
out[name] = SETTINGS_NOT_READ;
|
|
512
|
+
return out;
|
|
513
|
+
}
|
|
514
|
+
const fresh = planeFor(env, model ? { ...tooling, model } : tooling, settings, { capped, run: true });
|
|
515
|
+
for (const name of past)
|
|
516
|
+
out[name] = fresh[name] ?? CEILING_LEAVES_NONE;
|
|
517
|
+
if (out.web_search === "native" && kept.web_search !== "native" && fresh.model)
|
|
518
|
+
out.model = fresh.model;
|
|
519
|
+
return out;
|
|
520
|
+
}
|
|
453
521
|
/** The Plane the server handed this run's process; empty when it handed none. */
|
|
454
522
|
export function planeOf(env) {
|
|
455
523
|
try {
|
package/dist/tools.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { type WebFake } from "./web-fake.js";
|
|
|
14
14
|
import { type SaveSlots } from "./web-save.js";
|
|
15
15
|
import { type Plane, type Resolution, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
|
|
16
16
|
import type { DenyFrom, SettingFrom } from "./tool-gate.js";
|
|
17
|
+
import { type Redact } from "./runner/redact.js";
|
|
17
18
|
import type { LiveHandover, LiveViewerStore } from "./browser-live.js";
|
|
18
19
|
import { type RunnerLive } from "./live-reach.js";
|
|
19
20
|
import type { Claim, Store } from "./store/store.js";
|
|
@@ -110,8 +111,8 @@ export type ToolHost = {
|
|
|
110
111
|
flush: () => Promise<void>;
|
|
111
112
|
};
|
|
112
113
|
/** The run's one redactor (the runner's: every secret value the runner and the claim hold, in every form): what the
|
|
113
|
-
* browser's answers pass through before pi stores them or the model reads them.
|
|
114
|
-
redact
|
|
114
|
+
* browser's answers pass through before pi stores them or the model reads them. */
|
|
115
|
+
redact: (text: string) => string;
|
|
115
116
|
/** The run's own Workspace (on the runner: the run's local folder in Mode 1, its folder on the run's disk in Mode 2),
|
|
116
117
|
* where a tool files what the run's read finds later (monid's whole answer past the model's cut). Absent, the local
|
|
117
118
|
* folder at `where.work`. */
|
|
@@ -243,6 +244,15 @@ export declare const uploadsFrom: (work: Workspace, maxBytes: number, mime: (nam
|
|
|
243
244
|
* run of more than 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), which no model
|
|
244
245
|
* takes as an image. Any other `data`, on a block of any type, is cut like every other string. */
|
|
245
246
|
export declare function cutAnswer<T>(value: T, cut: (text: string) => string): T;
|
|
247
|
+
/** One call's web answer cut by `cut` (timeline/web-calls.ts webCut): each of its JSON's strings cut once, and the whole
|
|
248
|
+
* "[redacted]" when its strings, read joined, hold a held value no cut in place takes (a value split across two of
|
|
249
|
+
* them). The join is read against the values `cut` holds (key-refusal.ts withheldWhole), or through `cut` itself when
|
|
250
|
+
* it does not know them (joinCut). Undefined for an answer that is not a web call's JSON. Make one per call. */
|
|
251
|
+
export declare function webAnswerCut(cut: Redact): (tool: string, text: string) => string | undefined;
|
|
252
|
+
/** `tool` whose answer, and a throw's message, pass `cut` inside its execute: before pi stores the result or the model
|
|
253
|
+
* reads it. A web call's JSON is cut as the agentic specs' answersCut cuts it (webAnswerCut), so it still parses and
|
|
254
|
+
* keeps its links, and a held value split across its strings withholds it whole. */
|
|
255
|
+
export declare function answersCutInside(tool: ToolRegistration, cut: Redact): ToolRegistration;
|
|
246
256
|
/** `provider`, its sessions' profile as this launch was handed it, whatever the policy a conversation was made with (a
|
|
247
257
|
* follow-up's was made under an earlier launch, which may have had no sign-in, or another lease): with a sign-in, every
|
|
248
258
|
* session opens on the profile `default`, saving only as `kept.save` says; without one, none asks for a profile. */
|