@parcha/agentrun-serve 0.1.0-beta.59 → 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 +135 -0
- package/README.md +230 -120
- package/dist/acp-package.d.ts +4 -0
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/api-only.d.ts +21 -3
- package/dist/api-only.js +41 -6
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +4 -2
- package/dist/chatgpt-plan.js +13 -3
- package/dist/claude-login-token.d.ts +5 -0
- package/dist/claude-login-token.js +8 -0
- package/dist/claude-login.d.ts +49 -3
- package/dist/claude-login.js +140 -10
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +42 -10
- package/dist/console/assets/{backend-BztxEAvb.js → backend-C9ffXUR5.js} +1 -1
- package/dist/console/assets/index-BnZV3lvW.js +639 -0
- package/dist/console/assets/{share-L84tlUDW.js → share-B1o5mJ56.js} +2 -2
- package/dist/console/assets/{styles-CaRKlHke.js → styles-D_znYrHR.js} +31 -31
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +1 -2
- 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 +9 -3
- package/dist/harness-table.js +11 -5
- package/dist/harness.js +6 -2
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +9 -0
- package/dist/import.js +11 -1
- package/dist/key-refusal.d.ts +5 -0
- package/dist/key-refusal.js +30 -18
- package/dist/learn/audit.d.ts +20 -22
- package/dist/learn/audit.js +72 -55
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +4 -4
- package/dist/learn/compile.js +6 -7
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +40 -66
- package/dist/learn/promote.js +69 -207
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +36 -0
- package/dist/learned-nodes.js +23 -0
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +44 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +35 -0
- package/dist/ollama-provider.js +108 -2
- package/dist/openapi.js +147 -35
- package/dist/place-offers.d.ts +3 -0
- package/dist/place-offers.js +3 -0
- package/dist/place.d.ts +35 -12
- package/dist/place.js +67 -29
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +36 -8
- package/dist/redact/match.js +179 -44
- package/dist/run-export.js +4 -2
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +6 -5
- package/dist/run-usage.js +3 -2
- package/dist/runnable.js +25 -8
- 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 +35 -61
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +3 -5
- package/dist/runner/audit.js +28 -51
- package/dist/runner/cli-run-spec.js +19 -22
- package/dist/runner/compare-end.d.ts +1 -3
- package/dist/runner/compare-end.js +6 -2
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/dispatch.js +2 -2
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.d.ts +9 -0
- package/dist/runner/harness-loops.js +49 -7
- package/dist/runner/held.d.ts +4 -11
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +1 -1
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +3 -3
- package/dist/runner/learning-end.d.ts +12 -16
- package/dist/runner/learning-end.js +41 -75
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +3 -4
- package/dist/runner/main.js +1 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +23 -4
- package/dist/runner/mcp-run.js +31 -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 +3 -4
- package/dist/runner/promotion.d.ts +19 -28
- package/dist/runner/promotion.js +50 -69
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/run-child-host.d.ts +1 -9
- package/dist/runner/run-child-host.js +12 -68
- package/dist/runner/runner.d.ts +1 -1
- package/dist/runner/sdk-loop.js +7 -7
- 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/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +20 -7
- package/dist/sdk/runs.js +105 -68
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.js +97 -83
- package/dist/secrets.d.ts +4 -0
- package/dist/secrets.js +44 -10
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +6 -0
- package/dist/server-keys.js +12 -0
- package/dist/server.d.ts +22 -15
- package/dist/server.js +311 -198
- package/dist/slack.js +2 -1
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/schema.d.ts +28 -2
- package/dist/store/schema.js +81 -5
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/store.d.ts +7 -1
- package/dist/store/sqlite/store.js +84 -18
- package/dist/store/store.d.ts +219 -6
- package/dist/store/store.js +13 -0
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +23 -26
- package/dist/store-reads/learning.js +42 -30
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +40 -11
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/tool-plane.d.ts +27 -3
- package/dist/tool-plane.js +79 -4
- 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/dist/web-holds.d.ts +2 -0
- package/dist/web-holds.js +5 -2
- package/dist/web-run.js +2 -1
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-deps.js +5 -3
- package/dist/workspace/computer-providers.d.ts +11 -1
- package/dist/workspace/computer-providers.js +29 -2
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/workspace.d.ts +1 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -13
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/index-LwNL4L9q.js +0 -619
- package/dist/console/assets/styles-DQo8rzY-.css +0 -1
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
package/dist/store-view.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
8
8
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
9
9
|
import { CAPS, isMessageRow } from "./timeline/index.js";
|
|
10
10
|
import { runLink } from "./console-links.js";
|
|
11
|
-
import { redacted, redactedAnswer, redactedOutput, redactedOutputWhole,
|
|
11
|
+
import { redacted, redactedAnswer, redactedOutput, redactedOutputWhole, withoutLoopback } from "./key-refusal.js";
|
|
12
12
|
import { structuredAnswer } from "./answer-json.js";
|
|
13
13
|
import { isObject } from "./validate.js";
|
|
14
14
|
import { currentLearning, holdsForOk, learningView, LEARNING_LABEL, secretsShown, shortOf } from "./learning.js";
|
|
@@ -28,7 +28,7 @@ import { capNowOf, KINDS } from "./runner/journal-kinds.js";
|
|
|
28
28
|
import { laidOf, pathViewOf, roundsOf, runLearningEnd, usedOnly } from "./store-reads/learning.js";
|
|
29
29
|
import { inReflect, reflectRanges } from "./runner/end-of-run.js";
|
|
30
30
|
import { correctionCount } from "./learn/corrections.js";
|
|
31
|
-
import { forgetServedAnswers, isCliRecord, servedSince, runReflect, runTimeline, wholeAnswerFor, wholeAnswers, withoutFeedbackRounds } from "./store-reads/journal.js";
|
|
31
|
+
import { forgetServedAnswers, isCliRecord, rowCutsOnce, servedSince, runReflect, runTimeline, wholeAnswerFor, wholeAnswers, withoutFeedbackRounds } from "./store-reads/journal.js";
|
|
32
32
|
import { costOfRun, readRun, runReadState } from "./store-reads/runs.js";
|
|
33
33
|
import { feedbackOf, keptEndOf } from "./runner/feedback-round.js";
|
|
34
34
|
import { runCutValues, runErrorWordsOf, underCut } from "./run-cut.js";
|
|
@@ -41,6 +41,7 @@ import { approvalsOf } from "./approvals.js";
|
|
|
41
41
|
import { FINAL_STATES, stoppedByPerson } from "./store/store.js";
|
|
42
42
|
import { LISTING_HELD, LISTING_KEYED } from "./store/schema.js";
|
|
43
43
|
import { createHash } from "node:crypto";
|
|
44
|
+
import { factoryChildren, factoryGithub, factoryLastActivity, factoryObservation, factoryObserved, factorySource } from "./factory-activity.js";
|
|
44
45
|
/** A run that has ended reads one of these (the old RunRow state → the v2 status: an escalation is a completion with a
|
|
45
46
|
* review; a stopped run is a cancellation), as runs.ts's STATUS_OF mapped them. A running run reads its status from the
|
|
46
47
|
* journal, and so does an agentic run a person stopped, which reads running (runReadState). */
|
|
@@ -153,7 +154,7 @@ function pausedOf(runRow, entries) {
|
|
|
153
154
|
/** A runner holds the run's claim now: it is not in a final state, a runner is named on its row, and its lease has not run
|
|
154
155
|
* out (claimed_until >= now, the predicate the claimable query's `claimed_until < ?` is the negation of). `now` is the
|
|
155
156
|
* server's clock, so a test on a moved clock reads a fresh claim as live. */
|
|
156
|
-
function liveOf(runRow, now) {
|
|
157
|
+
export function liveOf(runRow, now) {
|
|
157
158
|
return !FINAL_STATES.includes(runRow.state) && runRow.runner !== null && runRow.claimedUntil !== null && runRow.claimedUntil >= now;
|
|
158
159
|
}
|
|
159
160
|
/** Whether the run's turn stands on a person: a tool call asked for their approval with no answer in its journal (the
|
|
@@ -193,7 +194,7 @@ async function storeRunOf(store, runId, deps) {
|
|
|
193
194
|
await healStoredCost(store, runId, run.heal);
|
|
194
195
|
if (!run?.shownEnd || !holdsForOk(run.shownEnd) || !deps.statuses)
|
|
195
196
|
return run && { ...run, learningEnd: run.shownEnd, since };
|
|
196
|
-
// What the learning end held for its owner's OK reads as it stands now
|
|
197
|
+
// What the learning end held for its owner's OK reads as it stands now at its agent's newest save (learning.ts
|
|
197
198
|
// currentLearning); its record stays as the merge wrote it.
|
|
198
199
|
return { ...run, learningEnd: currentLearning(run.shownEnd, await deps.statuses(run.row.agent)), since };
|
|
199
200
|
}
|
|
@@ -268,7 +269,8 @@ async function storeRunIn(store, runId, deps, cut, since) {
|
|
|
268
269
|
// A run that ended reads settled, and its usage row says its cost ("Cost: …"), never what it has cost so far. One
|
|
269
270
|
// looking back is still going: its look-back's rows come yet.
|
|
270
271
|
// A call's arguments, or a web call's output, split across two strings are withheld whole (TimelineOptions.holds).
|
|
271
|
-
|
|
272
|
+
// Each text cut once per held value set (rowCutsOnce): a polled view cuts only what an earlier read had not.
|
|
273
|
+
const timelineOptions = { settled: terminal && !lookingBack, ended: terminal && !lookingBack, ...rowCutsOnce(store, runId, cut, since) };
|
|
272
274
|
// Rendered from the records read above, so its usage row and the cost's `plan` (bookedSpend over the same entries) are
|
|
273
275
|
// of one read.
|
|
274
276
|
const timeline = withAsks(await wholeAnswers(store, runId, context, await runTimeline(store, runId, context, timelineOptions, records), timelineOptions, wholeAnswerFor(values), since));
|
|
@@ -424,7 +426,15 @@ async function storeRunIn(store, runId, deps, cut, since) {
|
|
|
424
426
|
const endSaidCost = endCost && !lookingBack ? endSaid !== undefined : false;
|
|
425
427
|
const endUnread = !lookingBack && bookedCost !== undefined && !endCost && endSaid === null;
|
|
426
428
|
const heal = lookingBack ? undefined : healOf(endCost, runRow);
|
|
427
|
-
|
|
429
|
+
const factory = deps.factory ? {
|
|
430
|
+
lifecycle_version: await store.runs.changesHead(),
|
|
431
|
+
...factorySource(launch, harness),
|
|
432
|
+
...(deps.factory === "kept" ? {} : { observation: await factoryObservation(store, launch, live, liveRow?.updatedAt, deps.now ?? Date.now) }),
|
|
433
|
+
last_activity_at: factoryLastActivity(records),
|
|
434
|
+
github: unshown ? null : factoryGithub(launch, (text) => withoutLoopback(redacted(text, values))),
|
|
435
|
+
children: terminal || FINAL_STATES.includes(runRow.state) || unshown ? [] : await factoryChildren(store, runId, records, (text) => withoutLoopback(redacted(text, values))),
|
|
436
|
+
} : undefined;
|
|
437
|
+
return { ...(factory ? { factory } : {}), ...(cli_learning ? { cli_learning } : {}), ...(sdk ? { sdk } : {}), ...(native ? { native } : {}), row, runRow, launch, rows, version, harness, learningEnd: shownEnd, shownEnd, view, unshown, values, live, updatedAtMs, lastProgressAt, budget, paused, browserAsk, computerAsk, approvalsMode, output, ...(review ? { review } : {}), structured, decisions, model, windDown, ...(endCost ? { endCost, endSaidCost } : {}), ...(endUnread ? { endUnread } : {}), ...(heal ? { heal } : {}), ...(lookingBack ? { lookingBack: true } : {}) };
|
|
428
438
|
}
|
|
429
439
|
/** Run read `read` (a run still going, as the store holds it) as the end `ended` keeps (its state, summary and end time:
|
|
430
440
|
* the end a run looking back keeps), its cost as read. */
|
|
@@ -567,7 +577,7 @@ function healOf(endCost, runRow) {
|
|
|
567
577
|
return { epoch: runRow.epoch, endedAt: runRow.endedAt, costUsd: endCost.usd, costUpperBound };
|
|
568
578
|
}
|
|
569
579
|
/** The start sweep's heal of run `runId` (cost-heal.ts): the same rule as its run read's (bookedCostOf, healOf), from its
|
|
570
|
-
* row, its launch and its journal alone, so a sweep over many runs reads no timeline and no learning
|
|
580
|
+
* row, its launch and its journal alone, so a sweep over many runs reads no timeline and no learning. True when
|
|
571
581
|
* it wrote the booking's figure; a failed read or write throws, for the sweep to count. */
|
|
572
582
|
export async function healedOverStore(store, runId) {
|
|
573
583
|
const heal = await store.snapshot(async (snapshot) => {
|
|
@@ -649,6 +659,11 @@ async function viewOfRun(store, runId, deps, run, read) {
|
|
|
649
659
|
const settled = terminal && ended && !run.lookingBack;
|
|
650
660
|
return {
|
|
651
661
|
...(run.cli_learning && !unshown ? { cli_learning: redactedOutput(run.cli_learning, values) } : {}),
|
|
662
|
+
...(run.factory ? { factory: { ...run.factory, controls: {
|
|
663
|
+
stop: run.factory.control === "managed" && row.kind === "agentic" && status === "working" && state === "working",
|
|
664
|
+
cancel: run.factory.control === "managed" && !terminal && !FINAL_STATES.includes(runRow.state),
|
|
665
|
+
approve: run.factory.control === "managed" && !FINAL_STATES.includes(runRow.state) && pending?.kind === "approval",
|
|
666
|
+
} } } : {}),
|
|
652
667
|
...(run.sdk && !unshown ? { sdk: redactedOutput(run.sdk, values) } : {}),
|
|
653
668
|
...(run.native && !unshown ? { native: redactedOutput(run.native, values) } : {}),
|
|
654
669
|
run_id: row.id,
|
|
@@ -722,6 +737,7 @@ export function summaryOfView(view) {
|
|
|
722
737
|
return {
|
|
723
738
|
run_id, agent_id, agent_version, console_url, revision, kind, sha, status, state, title,
|
|
724
739
|
...(view.cli_learning ? { cli_learning: view.cli_learning } : {}),
|
|
740
|
+
...(view.factory ? { factory: view.factory, ...(view.computer ? { computer: view.computer } : {}) } : {}),
|
|
725
741
|
...(view.sdk ? { sdk: view.sdk } : {}),
|
|
726
742
|
...(view.native ? { native: view.native } : {}),
|
|
727
743
|
...(effort ? { effort } : {}),
|
|
@@ -741,11 +757,12 @@ export function summaryOfView(view) {
|
|
|
741
757
|
* and what outside the run it read (LISTING_HELD, LISTING_KEYED). Undefined for an unknown run. */
|
|
742
758
|
export async function listingOverStore(store, runId, deps) {
|
|
743
759
|
const cut = secretsDigest(deps.serverSecrets());
|
|
744
|
-
|
|
760
|
+
// The same read gives what a scoped list shows beside the item (KeptFactory), so that list reads rows alone too.
|
|
761
|
+
const run = await storeRunOf(store, runId, { ...deps, factory: "kept" });
|
|
745
762
|
if (!run)
|
|
746
763
|
return undefined;
|
|
747
764
|
const read = { withheld: false };
|
|
748
|
-
const summary = summaryOfView(await viewOfRun(store, runId, deps, run, read));
|
|
765
|
+
const { factory: activity, computer: _computer, ...summary } = summaryOfView(await viewOfRun(store, runId, deps, run, read));
|
|
749
766
|
const status = String(summary.status);
|
|
750
767
|
const terminal = TERMINAL.has(status);
|
|
751
768
|
const asks = terminal ? [] : [run.browserAsk?.expires_at, run.computerAsk?.expires_at].map((at) => (typeof at === "string" ? Date.parse(at) : Number.NaN)).filter((at) => Number.isFinite(at));
|
|
@@ -758,8 +775,18 @@ export async function listingOverStore(store, runId, deps) {
|
|
|
758
775
|
live: run.live,
|
|
759
776
|
until: expiries.length ? Math.min(...expiries) : null,
|
|
760
777
|
flags,
|
|
778
|
+
factory: { activity, observed: factoryObserved(run.launch) },
|
|
761
779
|
};
|
|
762
780
|
}
|
|
781
|
+
/** What `listing` keeps for the Agent Factory, cut again of the server's secrets as `listedItem` cuts its item when they
|
|
782
|
+
* moved since its build; undefined for a listing built before one was kept, which a scoped list builds again, once. */
|
|
783
|
+
export function keptFactory(listing, serverSecrets) {
|
|
784
|
+
const kept = listing.factory;
|
|
785
|
+
if (!isObject(kept) || !isObject(kept.activity) || !isObject(kept.observed))
|
|
786
|
+
return undefined;
|
|
787
|
+
const { activity, observed } = kept;
|
|
788
|
+
return listing.cut === secretsDigest(serverSecrets) ? { activity, observed } : { activity: redactedOutput(activity, [...serverSecrets]), observed };
|
|
789
|
+
}
|
|
763
790
|
/** Whether `listing` is cut of the server's secrets as they are now. A list builds any other again before it shows it
|
|
764
791
|
* (server.ts runsPage): the run's view cuts a value whole where it holds a secret (a note's name reads [redacted]), which
|
|
765
792
|
* cutting the built item again could not do. */
|
|
@@ -776,8 +803,10 @@ export function listedItem(listing, origin, archivedAt, serverSecrets) {
|
|
|
776
803
|
const item = { ...listing.item, console_url: runLink(origin, String(listing.item.run_id)), archived_at: archivedAt === null ? null : iso(archivedAt) };
|
|
777
804
|
return listing.cut === secretsDigest(serverSecrets) ? item : redactedOutput(item, [...serverSecrets]);
|
|
778
805
|
}
|
|
779
|
-
/** A set of secrets' digest, the same for the same set in any order: what a listing was cut of.
|
|
780
|
-
|
|
806
|
+
/** A set of secrets' digest, the same for the same set in any order: what a listing was cut of. Of the sorted values'
|
|
807
|
+
* JSON, which escapes a lone surrogate and a NUL as written, so no two sets share it: as UTF-8 every lone surrogate is
|
|
808
|
+
* the one replacement character, and values joined by a NUL read as one value that holds it. */
|
|
809
|
+
const secretsDigest = (values) => createHash("sha256").update(JSON.stringify([...new Set(values)].sort())).digest("hex");
|
|
781
810
|
/** A run's facts as its view states them, and none of its words: its kind, revision, agent, status and times, and whether
|
|
782
811
|
* its output is withheld (`unshown`). What a read that serves its own parts (the graph) needs of the run: read off the
|
|
783
812
|
* run as viewOverStore reads it, with nothing of it served, so nothing is redacted here. Undefined for an unknown run. */
|
package/dist/templates.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { GitHubConnectionView } from "./github-connection.js";
|
|
|
4
4
|
import { type Tier } from "./model.js";
|
|
5
5
|
import { type PinValue } from "./tool-gate.js";
|
|
6
6
|
import { type BashPolicy } from "./bash-read-only.js";
|
|
7
|
+
import { type FileSetting } from "./filed-tool.js";
|
|
7
8
|
import { type Json } from "./validate.js";
|
|
8
9
|
import { type Approvals } from "./approvals.js";
|
|
9
10
|
import { type LearningSetting } from "./learning-setting.js";
|
|
@@ -53,7 +54,10 @@ export declare const MAX_EVAL_FILE_BYTES: number;
|
|
|
53
54
|
* sets a permission: an apply's `grants`, the owner's ticks, grant the tools, and each call follows this server's tool settings
|
|
54
55
|
* (a write asks unless the owner allowed it there, a read follows the server's Allow reads, approvals never lifts an ask). `pin`, by tool: the arguments each of its calls must carry (a value, or
|
|
55
56
|
* `${parameters.<name>}`), which apply writes as the tool's pin in the agent's tool settings, so a send goes only to the
|
|
56
|
-
* destination the owner set.
|
|
57
|
+
* destination the owner set. `file`, by tool: where each of its answers is filed whole in the run's files and the paths of it
|
|
58
|
+
* the tool's result shows (filed-tool.ts), which apply writes as the tool's file setting in the agent's tool settings, so
|
|
59
|
+
* the tool's result is a summary, never the answer (the model's own file tools can still open the folder). Absent when
|
|
60
|
+
* the package files none. */
|
|
57
61
|
export type McpNeed = {
|
|
58
62
|
source: McpSource;
|
|
59
63
|
toolkit: string;
|
|
@@ -62,6 +66,7 @@ export type McpNeed = {
|
|
|
62
66
|
reason?: string;
|
|
63
67
|
allow: string[];
|
|
64
68
|
pin: Record<string, Record<string, PinValue>>;
|
|
69
|
+
file?: Record<string, FileSetting>;
|
|
65
70
|
};
|
|
66
71
|
/** One of a package's model choices (manifest `model.choices`): a model and the harness it runs on, which an owner picks
|
|
67
72
|
* by `id` at install (apply's overrides.choice) in place of the package's tier and preference. `label` names it on the
|
|
@@ -121,7 +126,8 @@ export type Package = {
|
|
|
121
126
|
choices?: ModelChoice[];
|
|
122
127
|
};
|
|
123
128
|
effort?: string;
|
|
124
|
-
/** Absent, the tools the server gives a new agent that names none
|
|
129
|
+
/** Absent, the tools the server gives a new agent that names none; with no `computer` list either, its apply is the
|
|
130
|
+
* create that gets Docker's box, refused where that box is not here and the runner has no shell (server.ts saveable). */
|
|
125
131
|
tools?: string[];
|
|
126
132
|
/** MCP servers by their source and toolkit, and the tools of each the agent is granted. One `required` refuses an apply
|
|
127
133
|
* on a server that has saved none that matches; any other is skipped there, with a warning. */
|
|
@@ -304,6 +310,7 @@ export declare function packageView(p: Package): {
|
|
|
304
310
|
required: boolean;
|
|
305
311
|
reason: string | null;
|
|
306
312
|
tools: {
|
|
313
|
+
file?: FileSetting | undefined;
|
|
307
314
|
pin?: Record<string, PinValue> | undefined;
|
|
308
315
|
name: string;
|
|
309
316
|
tool: string;
|
|
@@ -378,6 +385,7 @@ export declare function packageDetail<Pick>(p: Package, computerHere: (p: Packag
|
|
|
378
385
|
required: boolean;
|
|
379
386
|
reason: string | null;
|
|
380
387
|
tools: {
|
|
388
|
+
file?: FileSetting | undefined;
|
|
381
389
|
pin?: Record<string, PinValue> | undefined;
|
|
382
390
|
name: string;
|
|
383
391
|
tool: string;
|
package/dist/templates.js
CHANGED
|
@@ -23,6 +23,7 @@ import { isPinKeys } from "./tool-gate.js";
|
|
|
23
23
|
import { formatToolName, isMcpName, isMonidName, MCP_SERVER_NAME, MCP_TOOL_NAME, mcpToolName, MONID_NAME_WORDS, parseToolName } from "./tool-names.js";
|
|
24
24
|
import { pinIssues, sortedPin } from "./tool-plane.js";
|
|
25
25
|
import { BASH_POLICIES } from "./bash-read-only.js";
|
|
26
|
+
import { fileIssues } from "./filed-tool.js";
|
|
26
27
|
import { BOUND_TOOLS, toolOf } from "./tools.js";
|
|
27
28
|
import { TRIGGER_ADAPTERS } from "./trigger-adapters.js";
|
|
28
29
|
import { MOVE_FIELD } from "./trigger-composio.js";
|
|
@@ -311,6 +312,25 @@ function pinOf(pin, server, tools, at, bad) {
|
|
|
311
312
|
}
|
|
312
313
|
return out;
|
|
313
314
|
}
|
|
315
|
+
/** An mcp entry's `file` read: by tool, each one of the entry's `tools`, its setting checked by the one rule every file
|
|
316
|
+
* setting is (filed-tool.ts fileIssues). Each problem is told through `bad`; a tool whose setting reads is kept. */
|
|
317
|
+
function fileOf(file, tools, at, bad) {
|
|
318
|
+
const out = {};
|
|
319
|
+
if (!isObject(file))
|
|
320
|
+
return bad(`${at} is {<tool>: {folder, show}}, by the entry's tools: each answer of the tool is filed whole in that folder of the run's files, and the tool's result shows only the values at the show paths and the answer's shape`), out;
|
|
321
|
+
for (const [tool, setting] of Object.entries(file)) {
|
|
322
|
+
if (!tools.includes(tool)) {
|
|
323
|
+
bad(`${at}.${tool}: ${tool} is not one of this entry's tools (${tools.join(", ")}): a file setting files the answers of a tool the package lists`);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const issues = fileIssues(setting, `${at}.${tool}`);
|
|
327
|
+
for (const issue of issues)
|
|
328
|
+
bad(issue.message);
|
|
329
|
+
if (!issues.length)
|
|
330
|
+
out[tool] = { folder: setting.folder, show: [...setting.show] };
|
|
331
|
+
}
|
|
332
|
+
return out;
|
|
333
|
+
}
|
|
314
334
|
/** A pin's scalar filled from the apply's `given` parameters (typedFilled: an integer pins an integer), a list's items
|
|
315
335
|
* as text. `empty`: the parameters its placeholders name that were given no value (absent, or ""), so the pin cannot
|
|
316
336
|
* hold what the owner meant. */
|
|
@@ -645,8 +665,9 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
645
665
|
const names = isObject(need) && Array.isArray(need.tools) ? need.tools : [];
|
|
646
666
|
const allow = isObject(need) && need.allow !== undefined ? need.allow : [];
|
|
647
667
|
const pin = isObject(need) && need.pin !== undefined ? need.pin : {};
|
|
668
|
+
const file = isObject(need) && need.file !== undefined ? need.file : undefined;
|
|
648
669
|
const reason = isObject(need) ? need.reason : undefined;
|
|
649
|
-
const ok = isObject(need) && !unknownFields(need, ["source", "toolkit", "tools", "required", "reason", "allow", "pin"]).length && MCP_SOURCES.includes(need.source) && typeof need.toolkit === "string" && MCP_SERVER_NAME.test(need.toolkit)
|
|
670
|
+
const ok = isObject(need) && !unknownFields(need, ["source", "toolkit", "tools", "required", "reason", "allow", "pin", "file"]).length && MCP_SOURCES.includes(need.source) && typeof need.toolkit === "string" && MCP_SERVER_NAME.test(need.toolkit)
|
|
650
671
|
&& names.length > 0 && names.every((tool) => typeof tool === "string" && MCP_TOOL_NAME.test(tool)) && new Set(names).size === names.length && (need.required === undefined || typeof need.required === "boolean")
|
|
651
672
|
&& (reason === undefined || (typeof reason === "string" && reason.trim() !== "" && reason.length <= MAX_REASON && !/[\r\n]/.test(reason)))
|
|
652
673
|
&& Array.isArray(allow) && allow.every((tool) => names.includes(tool)) && new Set(allow).size === allow.length;
|
|
@@ -655,14 +676,15 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
655
676
|
if (isObject(need) && need.toolkit !== undefined && (typeof need.toolkit !== "string" || !MCP_SERVER_NAME.test(need.toolkit)))
|
|
656
677
|
bad(MANIFEST, `mcp[${i}].toolkit ${JSON.stringify(need.toolkit)} is not a toolkit name: ${MCP_SERVER_NAME.source}, the MCP server name rule, since the package names its tools mcp:<toolkit>/<tool>`);
|
|
657
678
|
else if (!ok)
|
|
658
|
-
bad(MANIFEST, `mcp[${i}] is {source: ${MCP_SOURCES.join(" | ")}, toolkit: the toolkit its tools come from, the name the package calls them by (mcp:<toolkit>/<tool>, ${MCP_SERVER_NAME.source}), tools: its tool names (${MCP_TOOL_NAME.source}), none twice, required?: true or false, reason?: one line of at most ${MAX_REASON} characters on why the agent needs them, allow?: the tools of its tools it asks the owner to allow, pin?: {<tool>: {<argument>: <value>}}}`);
|
|
679
|
+
bad(MANIFEST, `mcp[${i}] is {source: ${MCP_SOURCES.join(" | ")}, toolkit: the toolkit its tools come from, the name the package calls them by (mcp:<toolkit>/<tool>, ${MCP_SERVER_NAME.source}), tools: its tool names (${MCP_TOOL_NAME.source}), none twice, required?: true or false, reason?: one line of at most ${MAX_REASON} characters on why the agent needs them, allow?: the tools of its tools it asks the owner to allow, pin?: {<tool>: {<argument>: <value>}}, file?: {<tool>: {folder, show}}}`);
|
|
659
680
|
else if (need.source === "github" && need.toolkit !== "github")
|
|
660
681
|
bad(MANIFEST, `mcp[${i}]: a github source's toolkit is github (GitHub's MCP server), not ${need.toolkit}`);
|
|
661
682
|
else if (mcp.some((m) => m.toolkit === need.toolkit))
|
|
662
683
|
bad(MANIFEST, `mcp[${i}]: the toolkit ${need.toolkit} is listed twice: its tools are all mcp:${need.toolkit}/<tool>, so they are one entry`);
|
|
663
684
|
else {
|
|
664
685
|
const pinned = pinOf(pin, need.toolkit, names, `mcp[${i}].pin`, (message) => bad(MANIFEST, message));
|
|
665
|
-
|
|
686
|
+
const filed = file === undefined ? undefined : fileOf(file, names, `mcp[${i}].file`, (message) => bad(MANIFEST, message));
|
|
687
|
+
mcp.push({ source: need.source, toolkit: need.toolkit, tools: names, required: need.required === true, ...(typeof reason === "string" ? { reason } : {}), allow: allow, pin: pinned, ...(filed && Object.keys(filed).length ? { file: filed } : {}) });
|
|
666
688
|
}
|
|
667
689
|
}
|
|
668
690
|
// A policy by tool: bash's alone (bash-read-only.ts), on a package that grants bash or names no tools (a new agent's
|
|
@@ -1054,7 +1076,7 @@ export function packageView(p) {
|
|
|
1054
1076
|
category: p.category ?? null, tags: p.tags,
|
|
1055
1077
|
output: p.output ? { schema: p.output.schema, json_schema: p.outputSchema ?? null } : null,
|
|
1056
1078
|
harness: p.harness ?? null, model: modelView(p.model), effort: p.effort ?? null, tools: p.tools ?? null, tool_policy: p.toolPolicy ?? null, computer: p.computer ?? null, needs: p.needs ?? null, checkout: p.checkout ?? null,
|
|
1057
|
-
mcp: p.mcp.map(({ source, toolkit, tools, required, reason, allow, pin }) => ({ source, toolkit, required, reason: reason ?? null, tools: tools.map((name) => ({ name, tool: mcpToolName(toolkit, name), asks: allow.includes(name) ? "allow" : "ask", ...(Object.hasOwn(pin, name) ? { pin: pin[name] } : {}) })) })), parameters: p.parameters, input_schema: p.inputSchema ?? null, secrets: p.secrets,
|
|
1079
|
+
mcp: p.mcp.map(({ source, toolkit, tools, required, reason, allow, pin, file }) => ({ source, toolkit, required, reason: reason ?? null, tools: tools.map((name) => ({ name, tool: mcpToolName(toolkit, name), asks: allow.includes(name) ? "allow" : "ask", ...(Object.hasOwn(pin, name) ? { pin: pin[name] } : {}), ...(file && Object.hasOwn(file, name) ? { file: file[name] } : {}) })) })), parameters: p.parameters, input_schema: p.inputSchema ?? null, secrets: p.secrets,
|
|
1058
1080
|
budget: p.budget ?? null, learning: p.learning ?? false, approvals_default: p.approvals ?? "ask", triggers: p.triggers, skills: Object.keys(p.skills).filter((path) => /^[^/]+\/SKILL\.md$/.test(path)).map((path) => path.slice(0, -"/SKILL.md".length)), evals: p.evals,
|
|
1059
1081
|
};
|
|
1060
1082
|
}
|
|
@@ -1353,6 +1375,11 @@ export function compiled(p, parameters, chosen, _deps) {
|
|
|
1353
1375
|
else
|
|
1354
1376
|
settings[name] = { ...settings[name], pin: sortedPin(pin) };
|
|
1355
1377
|
}
|
|
1378
|
+
// A tool's file setting, written as the package states it, ticked or not (it holds once the tool is granted later), as
|
|
1379
|
+
// a pin is: the tool's result is a summary of each answer, never the answer.
|
|
1380
|
+
for (const { server, file } of chosen.mcp)
|
|
1381
|
+
for (const [tool, setting] of Object.entries(file ?? {}))
|
|
1382
|
+
settings[mcpToolName(server, tool)] = { ...settings[mcpToolName(server, tool)], file: { folder: setting.folder, show: [...setting.show] } };
|
|
1356
1383
|
const definition = {
|
|
1357
1384
|
name: p.displayName ? filled(p.displayName, parameters) : p.name, description: p.description, instructions: filled(p.instructions, parameters),
|
|
1358
1385
|
...(chosen.harness ? { harness: chosen.harness } : {}), ...(chosen.model ? { model: chosen.model } : {}), ...(chosen.modelTiers && Object.keys(chosen.modelTiers).length ? { model_tiers: chosen.modelTiers } : {}), ...(p.effort ? { thinking: p.effort } : {}),
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
|
6
6
|
import { type Permission, type Pin, type ToolEffect } from "./tool-gate.js";
|
|
7
7
|
import { type BashPolicy } from "./bash-read-only.js";
|
|
8
8
|
import { EMAIL_SCOPES } from "./email/names.js";
|
|
9
|
+
import { type FileSetting } from "./filed-tool.js";
|
|
9
10
|
/** An email read tool's scope (email/names.ts). */
|
|
10
11
|
type EmailScope = (typeof EMAIL_SCOPES)[number];
|
|
11
12
|
/**
|
|
@@ -72,7 +73,8 @@ export type ToolSetting = {
|
|
|
72
73
|
pin?: Pin; /** On an MCP server's wildcard (`mcp:<server>/*`) in the server's settings only: the tools its server marks read-only run with no approval (tool-gate.ts readsLift). Kept only when true. */
|
|
73
74
|
allow_reads?: true; /** bash's policy, an agent's own only (bash-read-only.ts). */
|
|
74
75
|
policy?: BashPolicy; /** An email read tool's scope, an agent's own only (email/tools.ts): its email run's thread (the default), or the whole account. */
|
|
75
|
-
scope?: EmailScope; /**
|
|
76
|
+
scope?: EmailScope; /** An MCP tool's file setting, an agent's own only, on the tool's own key (filed-tool.ts): its answers filed whole in the run's files, the model reading a summary. */
|
|
77
|
+
file?: FileSetting; /** Read as a stand-in for a value not offered (checkToolSettings); never shown or written. */
|
|
76
78
|
fallback?: true; /** The stand-in's value as written in the file, which a save that keeps the stand-in writes back (ToolSettings.put). Never shown. */
|
|
77
79
|
raw?: unknown; /** A pin in the file that does not read (readToolSettings): the gate refuses every call of the tool, and a save keeps it (ToolSettings.put) until the owner sets a valid pin or removes the tool's setting. Served as `pin_broken: true`. */
|
|
78
80
|
brokenPin?: true; /** The broken pin as written in the file, which a save that keeps it writes back. Never shown. */
|
|
@@ -143,10 +145,16 @@ export type ResolveInput = {
|
|
|
143
145
|
* none (and for pi, whose hosted search is asked of the model's provider). */
|
|
144
146
|
export declare const ownSearchViaOpenRouter: (env: NodeJS.ProcessEnv, harness: string, model?: string) => boolean;
|
|
145
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;
|
|
146
153
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
147
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
|
|
148
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
|
|
149
|
-
* (`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. */
|
|
150
158
|
export declare function explainCapability(capability: Pickable, input: ResolveInput): {
|
|
151
159
|
resolves: Resolution;
|
|
152
160
|
why: string;
|
|
@@ -254,6 +262,22 @@ export declare function relaunchPlane(kept: Plane | undefined, env: NodeJS.Proce
|
|
|
254
262
|
capped?: boolean;
|
|
255
263
|
first?: boolean;
|
|
256
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;
|
|
257
281
|
/** The Plane the server handed this run's process; empty when it handed none. */
|
|
258
282
|
export declare function planeOf(env: NodeJS.ProcessEnv): Plane;
|
|
259
283
|
/** Whether a run is handed Parallel's key: one of its capabilities resolves to Parallel. */
|
|
@@ -269,7 +293,7 @@ export declare const handsJevWeb: (plane: Plane, env: NodeJS.ProcessEnv, harness
|
|
|
269
293
|
* table, a catalog tool, an MCP server's wildcard) to `{provider?, permission?}`, a provider only for a capability that
|
|
270
294
|
* has a choice and one offered for it, a permission one offered for the tool. */
|
|
271
295
|
export declare function settingsIssues(value: unknown, at?: string, layer?: "server" | "agent"): InputIssue[];
|
|
272
|
-
/** `map` as a revision body keeps it: each tool's provider, permission, pin and
|
|
296
|
+
/** `map` as a revision body keeps it: each tool's provider, permission, pin, policy, scope and file setting as written (never a stand-in's internal
|
|
273
297
|
* marks), tools, fields and a pin's arguments sorted, and a tool with none of them gone. The one form, so two
|
|
274
298
|
* revisions whose settings say the same (a pin's arguments in another order) are the same text, and so one revision
|
|
275
299
|
* where its id is the body's digest (the store keeps the body as given: store/sqlite/store.ts). */
|
package/dist/tool-plane.js
CHANGED
|
@@ -39,6 +39,7 @@ import { canonicalPin, defaultPermission, isPinKeys, MAX_PIN_ARGS, MAX_PIN_CHOIC
|
|
|
39
39
|
import { BASH_POLICIES } from "./bash-read-only.js";
|
|
40
40
|
import { EMAIL_SCOPES, SCOPED_TOOLS, SCOPED_WORDS } from "./email/names.js";
|
|
41
41
|
import { isCatalogName, isMcpName, mcpNameOf, parseToolName } from "./tool-names.js";
|
|
42
|
+
import { fileIssues } from "./filed-tool.js";
|
|
42
43
|
/**
|
|
43
44
|
* The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
|
|
44
45
|
* table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
|
|
@@ -210,18 +211,56 @@ export const FIRECRAWL_FETCH = "Firecrawl's free keyless fetch, no key, the guar
|
|
|
210
211
|
* only where it is the model provider's hosted search (pi's), never a harness's own search inside its CLI. */
|
|
211
212
|
const searchesOwn = (resolves, facts) => WEB_RUNS.web_search.includes(resolves) && (resolves !== "native" || !facts?.webSearch);
|
|
212
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
|
+
};
|
|
213
242
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
214
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
|
|
215
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
|
|
216
|
-
* (`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. */
|
|
217
247
|
export function explainCapability(capability, input) {
|
|
218
|
-
const said =
|
|
248
|
+
const said = ceilinged(capability, input);
|
|
219
249
|
if (capability === "web_search" && input.jevWhy && ranksOwn(said.resolves, input))
|
|
220
250
|
return { ...said, why: `${said.why}; ${input.jevWhy}` };
|
|
221
251
|
if (capability === "web_fetch" && input.jevFetchWhy && WEB_RUNS.web_fetch.includes(said.resolves))
|
|
222
252
|
return { ...said, why: `${said.why}; ${input.jevFetchWhy}` };
|
|
223
253
|
return said;
|
|
224
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
|
+
}
|
|
225
264
|
function explained(capability, input) {
|
|
226
265
|
const chosen = input.override ?? input.pick ?? PROVIDERS[capability][0];
|
|
227
266
|
const picked = input.override !== undefined ? "picked for this agent" : "picked in settings";
|
|
@@ -449,6 +488,36 @@ export function relaunchPlane(kept, env, tooling, settings, { capped = false, fi
|
|
|
449
488
|
return recheckPlane(kept, env, { fresh, permission: (name) => permissionOf(name, settings, tooling?.overrides ?? {}, tooling?.approvals ?? "ask") });
|
|
450
489
|
return tooling ? recheckPlane(keptFromBefore(fresh), env) : {};
|
|
451
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
|
+
}
|
|
452
521
|
/** The Plane the server handed this run's process; empty when it handed none. */
|
|
453
522
|
export function planeOf(env) {
|
|
454
523
|
try {
|
|
@@ -500,6 +569,12 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
500
569
|
return [{ field: field(name, key), reason: "not_allowed", message: `A scope is set on ${SCOPED_WORDS} in an agent's own tool settings (definition.tool_settings.email_read.scope), never ${layer === "agent" ? `on ${name}` : "in the server's"}.` }];
|
|
501
570
|
return EMAIL_SCOPES.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${EMAIL_SCOPES.join(", ")}: thread, an email's run reads its thread alone; mailbox, the whole account` }];
|
|
502
571
|
}
|
|
572
|
+
// An MCP tool's file setting (filed-tool.ts): an agent's own, on the tool's own key only, set as bash's policy is.
|
|
573
|
+
if (key === "file") {
|
|
574
|
+
if (layer !== "agent" || !mcpNameOf(name))
|
|
575
|
+
return [{ field: field(name, key), reason: "not_allowed", message: `A file setting is set on an MCP tool's own key (mcp:<server>/<tool>) in an agent's own tool settings (definition.tool_settings), never ${layer === "agent" ? `on ${name}` : "in the server's"}.` }];
|
|
576
|
+
return fileIssues(given, field(name, key));
|
|
577
|
+
}
|
|
503
578
|
// The server's own mark of a pin in its file that does not read (withDefaults serves it), which a whole-map save
|
|
504
579
|
// sends back: it keeps the broken pin, and nothing else. Never an agent's.
|
|
505
580
|
if (key === "pin_broken") {
|
|
@@ -525,7 +600,7 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
525
600
|
});
|
|
526
601
|
});
|
|
527
602
|
}
|
|
528
|
-
/** `map` as a revision body keeps it: each tool's provider, permission, pin and
|
|
603
|
+
/** `map` as a revision body keeps it: each tool's provider, permission, pin, policy, scope and file setting as written (never a stand-in's internal
|
|
529
604
|
* marks), tools, fields and a pin's arguments sorted, and a tool with none of them gone. The one form, so two
|
|
530
605
|
* revisions whose settings say the same (a pin's arguments in another order) are the same text, and so one revision
|
|
531
606
|
* where its id is the body's digest (the store keeps the body as given: store/sqlite/store.ts). */
|
|
@@ -534,7 +609,7 @@ export function canonicalToolSettings(map) {
|
|
|
534
609
|
return sorted(Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
|
|
535
610
|
if (!setting)
|
|
536
611
|
return [];
|
|
537
|
-
const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads === true ? { allow_reads: true } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.scope ? { scope: setting.scope } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
|
|
612
|
+
const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads === true ? { allow_reads: true } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.scope ? { scope: setting.scope } : {}), ...(setting.file ? { file: { folder: setting.file.folder, show: [...setting.file.show] } } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
|
|
538
613
|
return Object.keys(kept).length ? [[name, kept]] : [];
|
|
539
614
|
})));
|
|
540
615
|
}
|
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. */
|