@parcha/agentrun-serve 0.1.0-beta.55 → 0.1.0-beta.57
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 +261 -0
- package/README.md +228 -45
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +18 -5
- package/dist/adapters.js +23 -9
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/answer-json.d.ts +6 -2
- package/dist/answer-json.js +22 -4
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +17 -5
- package/dist/api-only.js +36 -8
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/calendar/tools.js +3 -2
- package/dist/chatgpt-plan.d.ts +28 -3
- package/dist/chatgpt-plan.js +182 -21
- package/dist/claude-login.d.ts +101 -14
- package/dist/claude-login.js +232 -49
- package/dist/claude-sign-in.d.ts +46 -0
- package/dist/claude-sign-in.js +93 -0
- package/dist/cli.js +63 -6
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/console/assets/{backend-D5EmB4N3.js → backend-DVhHzJX2.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-okP-y8PK.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +10 -0
- package/dist/env-switch.js +33 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +58 -20
- package/dist/fal-price.js +341 -82
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/host-check.d.ts +4 -0
- package/dist/host-check.js +4 -0
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +26 -5
- package/dist/key-refusal.js +313 -37
- package/dist/learn/secrets.d.ts +31 -11
- package/dist/learn/secrets.js +152 -191
- package/dist/learning-cost.d.ts +6 -3
- package/dist/learning-cost.js +4 -2
- package/dist/link-check.js +1 -1
- package/dist/llms.txt +2 -2
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +30 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +5 -2
- package/dist/model.js +9 -5
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.d.ts +3 -3
- package/dist/openapi.js +245 -42
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +14 -6
- package/dist/place-offers.js +26 -13
- package/dist/provider.d.ts +9 -0
- package/dist/provider.js +50 -3
- package/dist/redact/match.d.ts +101 -0
- package/dist/redact/match.js +1152 -0
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +2 -0
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +3 -1
- package/dist/run-timeline-served.js +4 -4
- package/dist/run-usage.d.ts +1 -0
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +14 -0
- package/dist/runner/adapter-loop.js +56 -11
- package/dist/runner/adapter-run-spec.d.ts +45 -8
- package/dist/runner/adapter-run-spec.js +154 -29
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.js +11 -6
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +18 -3
- package/dist/runner/claim-secrets.js +35 -6
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +85 -36
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +11 -5
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.js +15 -6
- package/dist/runner/mcp-claim.js +30 -3
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +12 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +4 -3
- package/dist/runner/presence.js +4 -2
- package/dist/runner/run-child-host.d.ts +5 -0
- package/dist/runner/run-child-host.js +71 -30
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +18 -3
- package/dist/runner/runner.js +162 -36
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.js +4 -40
- package/dist/runner/workflow-first.d.ts +11 -4
- package/dist/runner/workflow-first.js +14 -8
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +57 -13
- package/dist/server.js +371 -113
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/dialect.js +3 -0
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/schema.d.ts +6 -0
- package/dist/store/schema.js +11 -1
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +1 -1
- package/dist/store/sqlite/run-patch.js +13 -4
- package/dist/store/sqlite/store.js +76 -16
- package/dist/store/store.d.ts +53 -3
- package/dist/store/store.js +27 -0
- package/dist/store-reads/learning.d.ts +6 -3
- package/dist/store-reads/learning.js +22 -7
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +4 -4
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +22 -11
- package/dist/template-eval.js +124 -41
- package/dist/template-import.d.ts +10 -0
- package/dist/template-import.js +16 -7
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +17 -7
- package/dist/timeline/timeline.js +28 -14
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +26 -9
- package/dist/timeline/web-calls.js +124 -37
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +69 -6
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/validate.js +1 -1
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +6 -4
- package/dist/web-save.js +9 -12
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/computer-deps.d.ts +3 -1
- package/dist/workspace/computer-deps.js +12 -4
- package/dist/workspace/computer-for-claim.d.ts +19 -2
- package/dist/workspace/computer-for-claim.js +101 -13
- package/dist/workspace/computer-janitor.d.ts +15 -7
- package/dist/workspace/computer-janitor.js +33 -8
- package/dist/workspace/computer-kept.d.ts +55 -4
- package/dist/workspace/computer-kept.js +129 -8
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/run-end-computers.d.ts +5 -1
- package/dist/workspace/run-end-computers.js +27 -1
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +65 -0
- package/dist/wrapped.js +77 -0
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +38 -15
- package/dist/console/assets/index-DUYLaqiR.js +0 -746
- package/dist/console/assets/index-DYhU4adm.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
package/dist/harness.js
CHANGED
|
@@ -36,7 +36,8 @@ async function withoutModelKeys(env) {
|
|
|
36
36
|
export function harnessOffers(env) {
|
|
37
37
|
let offers = offered.get(env);
|
|
38
38
|
if (!offers) {
|
|
39
|
-
|
|
39
|
+
// A reading no run waits on (ollamaReading): each Ollama model is the kept listing's, at any age, never an /api/show.
|
|
40
|
+
offers = import("./ollama-provider.js").then(({ ollamaReading }) => ollamaReading(async () => {
|
|
40
41
|
const { hostMemory, neverFits } = await import("./host.js");
|
|
41
42
|
const memory = hostMemory();
|
|
42
43
|
const { harnessInstalled } = await import("./adapters.js");
|
|
@@ -78,6 +79,9 @@ export function harnessOffers(env) {
|
|
|
78
79
|
// so the picker never offers one a save would refuse. None for a harness that does not run here.
|
|
79
80
|
const entry = harnessOf(env, offer.id);
|
|
80
81
|
const models = [];
|
|
82
|
+
// Those of them a run takes now: its provider connected here (its key, or the ChatGPT sign-in where that is how
|
|
83
|
+
// it runs), not one that lacks only a key. The console's Model picker lists these first (GRE: filter by provider).
|
|
84
|
+
const ready = [];
|
|
81
85
|
// Whether any model it offers runs here now, not only lacks a key: its default lacking one leaves it available
|
|
82
86
|
// where another runs (noModelRuns).
|
|
83
87
|
let runsOne = false;
|
|
@@ -94,6 +98,7 @@ export function harnessOffers(env) {
|
|
|
94
98
|
const { factsOf } = await import("./harness-table.js");
|
|
95
99
|
const facts = factsOf(env, offer.id);
|
|
96
100
|
const { OLLAMA_PROVIDER, ollamaToolsModels } = await import("./ollama-provider.js");
|
|
101
|
+
const { serverKeyMissing } = await import("./run-model-key.js");
|
|
97
102
|
const toolsModels = ollamaToolsModels(env);
|
|
98
103
|
for (const id of new Set([...pickerCandidates(env, offer.id), ...free.map((m) => m.id)])) {
|
|
99
104
|
if (!MODEL_REF.test(id))
|
|
@@ -112,9 +117,16 @@ export function harnessOffers(env) {
|
|
|
112
117
|
lacksKey = true;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
120
|
+
// A model whose route goes to the gateway runs only on a gateway key: the server's, or each run's own
|
|
121
|
+
// (model_key). Without the server's, a run that brings none is 422 model_key_required, so it is not ready.
|
|
122
|
+
if (!lacksKey && "model" in chosen && serverKeyMissing(env, { kind: "agentic", model: chosen.model }))
|
|
123
|
+
lacksKey = true;
|
|
115
124
|
models.push(id);
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
if (!lacksKey)
|
|
126
|
+
ready.push(id);
|
|
127
|
+
// A model of the Ollama here that takes no tools stays pickable, and a run on it gets its tools as text, but
|
|
128
|
+
// text tools are unreliable on small models: it is no model a run of this harness has now, as the host's
|
|
129
|
+
// default never is one (model.ts localDefault).
|
|
118
130
|
if (!lacksKey && (!id.startsWith(`${OLLAMA_PROVIDER}/`) || toolsModels.includes(id)))
|
|
119
131
|
runsOne = true;
|
|
120
132
|
}
|
|
@@ -125,9 +137,9 @@ export function harnessOffers(env) {
|
|
|
125
137
|
const wantsKey = offer.available ? resolved !== undefined && "why" in resolved && resolved.needs === "key" : Boolean(offer.keys?.length);
|
|
126
138
|
const sayWhy = !wantsKey ? {} : offer.available ? { reason: resolved.why } : offer.reason ? { reason: withPlanWords(env, offer.id, offer.reason) } : {};
|
|
127
139
|
const needs = wantsKey ? ["key", ...(planWouldRun(env, offer.id) ? ["chatgpt"] : [])] : [];
|
|
128
|
-
return { ...offer, ...sayWhy, default_model: resolved && "model" in resolved ? `${resolved.model.provider}/${resolved.model.modelId}` : null, models, free_models: free.filter((m) => models.includes(m.id)), run_memory_mib: entry.runMib, ...(needs.length ? { needs } : {}), ...(offer.available && needs.length && !runsOne ? { noModelRuns: true } : {}) };
|
|
140
|
+
return { ...offer, ...sayWhy, default_model: resolved && "model" in resolved ? `${resolved.model.provider}/${resolved.model.modelId}` : null, models, ready_models: ready, free_models: free.filter((m) => models.includes(m.id)), run_memory_mib: entry.runMib, ...(needs.length ? { needs } : {}), ...(offer.available && needs.length && !runsOne ? { noModelRuns: true } : {}) };
|
|
129
141
|
}));
|
|
130
|
-
})
|
|
142
|
+
}));
|
|
131
143
|
offered.set(env, offers);
|
|
132
144
|
}
|
|
133
145
|
return offers;
|
package/dist/host-check.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** The name a Host header gives, lowercased and without its port (an IPv6 address keeps its brackets). Undefined for a
|
|
2
2
|
* header that is not `name` or `name:port`: no user part, no path, no empty or non-numeric port. */
|
|
3
3
|
export declare function hostName(header: string | undefined): string | undefined;
|
|
4
|
+
/** Whether a Host name (as hostName gives it) is this machine's own: localhost, an IPv4 loopback address or [::1]. Not a name
|
|
5
|
+
* an operator allowed (--allow-host, AGENTRUN_PUBLIC_URL): those pass the server's Host check, and a route that reads this
|
|
6
|
+
* machine's files asks for more. */
|
|
7
|
+
export declare const isLoopbackName: (name: string | undefined) => boolean;
|
|
4
8
|
/** The port a Host header names (1 to 65535), or undefined for none, or for a header that is not `name` or `name:port`. */
|
|
5
9
|
export declare function hostPort(header: string | undefined): number | undefined;
|
|
6
10
|
/** The names a server listening on loopback `host` answers to: this machine's (localhost, 127.0.0.1, [::1], and `host`
|
package/dist/host-check.js
CHANGED
|
@@ -9,6 +9,10 @@ export function hostName(header) {
|
|
|
9
9
|
const match = /^(\[[0-9a-f:.]+\]|[a-z0-9._-]+)(?::(\d{1,5}))?$/.exec(String(header ?? "").trim().toLowerCase());
|
|
10
10
|
return match && (match[2] === undefined || Number(match[2]) <= 65535) ? match[1] : undefined;
|
|
11
11
|
}
|
|
12
|
+
/** Whether a Host name (as hostName gives it) is this machine's own: localhost, an IPv4 loopback address or [::1]. Not a name
|
|
13
|
+
* an operator allowed (--allow-host, AGENTRUN_PUBLIC_URL): those pass the server's Host check, and a route that reads this
|
|
14
|
+
* machine's files asks for more. */
|
|
15
|
+
export const isLoopbackName = (name) => name === "localhost" || name === "[::1]" || (name !== undefined && /^127(\.\d{1,3}){3}$/.test(name));
|
|
12
16
|
/** The port a Host header names (1 to 65535), or undefined for none, or for a header that is not `name` or `name:port`. */
|
|
13
17
|
export function hostPort(header) {
|
|
14
18
|
const match = /^(?:\[[0-9a-f:.]+\]|[a-z0-9._-]+):(\d{1,5})$/.exec(String(header ?? "").trim().toLowerCase());
|
package/dist/hosted-search.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Models } from "@earendil-works/pi-ai";
|
|
2
|
-
import { type Search, type Searched } from "
|
|
2
|
+
import { type Search, type Searched } from "@parcha/agentrun-web";
|
|
3
3
|
export declare const HOSTED_MAX_USES = 5;
|
|
4
4
|
/** One search's results billed as input: about 25,000 tokens, a working estimate. */
|
|
5
5
|
export declare const SEARCH_INPUT_TOKENS = 25000;
|
package/dist/hosted-search.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { clip, TITLE_CAP } from "
|
|
2
|
-
import { ANSWER_MAX, snippetOf } from "./web-search.js";
|
|
1
|
+
import { ANSWER_MAX, clip, snippetOf, TITLE_CAP } from "@parcha/agentrun-web";
|
|
3
2
|
export const HOSTED_MAX_USES = 5;
|
|
4
3
|
/** One search's results billed as input: about 25,000 tokens, a working estimate. */
|
|
5
4
|
export const SEARCH_INPUT_TOKENS = 25_000;
|
package/dist/import-worker.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "./quiet-sqlite-warning.js";
|
|
2
2
|
import { type ImportCandidate } from "./import.js";
|
|
3
|
+
import type { WrappedRead } from "./wrapped.js";
|
|
3
4
|
/** `secrets`: the server's own, cut out of everything the import writes and never put in an environment; the seal key
|
|
4
5
|
* among them, so the worker opens the saved tool keys the import cuts too (read over the port from the server's store). */
|
|
5
6
|
export type ImportTask = {
|
|
6
|
-
task: "plan" | "import";
|
|
7
|
+
task: "plan" | "import" | "wrapped";
|
|
7
8
|
data: string;
|
|
8
9
|
home: string;
|
|
9
10
|
temp?: string;
|
|
10
11
|
secrets?: Record<string, string>;
|
|
11
12
|
projects?: readonly string[];
|
|
13
|
+
year?: number;
|
|
12
14
|
};
|
|
13
15
|
/** `took`: what this start's import took (stopped too: what it took before it stopped), its agents by id, so the server
|
|
14
16
|
* adds it to what earlier starts took. */
|
|
@@ -25,4 +27,4 @@ export type ImportAnswer = {
|
|
|
25
27
|
stopped?: true;
|
|
26
28
|
} | {
|
|
27
29
|
stopped: true;
|
|
28
|
-
};
|
|
30
|
+
} | WrappedRead;
|
package/dist/import-worker.js
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// every session line happen here, so neither holds up a request the server answers. `plan` counts what an import would
|
|
3
3
|
// take, and names its projects for the owner to choose from; `import` takes it, only the projects chosen when some were
|
|
4
4
|
// (`projects`). The message "stop" ends either between two files or two sessions; what is written stays, and
|
|
5
|
-
// the next import goes on from there.
|
|
5
|
+
// the next import goes on from there. `wrapped` reads a year of the home for GET /v2/wrapped (wrapped.ts), priced at
|
|
6
|
+
// serve's own catalog; it writes nothing, so the server ends it outright when it closes. Its one message back is its answer.
|
|
6
7
|
// Before anything loads node:sqlite, as in the server's own thread: its ExperimentalWarning is not the server's to print.
|
|
7
8
|
import "./quiet-sqlite-warning.js";
|
|
8
9
|
import { parentPort, workerData } from "node:worker_threads";
|
|
9
10
|
import { candidatesOf, ownSecrets, planImport, runImport, sessionsOf } from "./import.js";
|
|
10
11
|
import { importStoreProxy } from "./import-proxy.js";
|
|
12
|
+
import { catalogPrices } from "./model.js";
|
|
11
13
|
import { toolKeysOverStore } from "./tool-keys-store.js";
|
|
12
|
-
const { task, data, home, temp, secrets = {}, projects } = workerData;
|
|
14
|
+
const { task, data, home, temp, secrets = {}, projects, year } = workerData;
|
|
13
15
|
const stop = new AbortController();
|
|
14
16
|
parentPort.on("message", (message) => void (message === "stop" && stop.abort()));
|
|
15
17
|
// The port does not keep the thread alive on its own: the task does (the proxy references it only while it waits for the
|
|
@@ -22,6 +24,11 @@ for (const [name, value] of Object.entries(secrets))
|
|
|
22
24
|
Object.defineProperty(env, name, { value, enumerable: false });
|
|
23
25
|
const options = { home, ...(temp ? { temp } : {}), env, signal: stop.signal };
|
|
24
26
|
const answer = async () => {
|
|
27
|
+
if (task === "wrapped") {
|
|
28
|
+
const failures = [];
|
|
29
|
+
const { wrappedHome } = await import("@parcha/agentrun-import");
|
|
30
|
+
return { wrapped: await wrappedHome(home, year, { failures, catalog: await catalogPrices() }), unread: failures.length };
|
|
31
|
+
}
|
|
25
32
|
if (task === "plan") {
|
|
26
33
|
// A count keeps no transcript: no key scan (a whole history read through secretlint at every start).
|
|
27
34
|
const plan = await planImport({ ...options, keys: false });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EntryLike, TimelineEvent } from "./timeline/index.js";
|
|
2
|
+
/** One request in flight. `name`: the model, by the id its request names (`inkling-2-mini`), or the tool. `started_at`: when it was sent (null for a model request a
|
|
3
|
+
* booking recorded before requests were stamped). `for_tool`: a tool's own model request (a web search's, a learned
|
|
4
|
+
* node's), which runs inside that call. `input_tokens_max`: the input a model request was admitted with, at most. */
|
|
5
|
+
export type InFlight = {
|
|
6
|
+
kind: "model" | "tool";
|
|
7
|
+
name: string;
|
|
8
|
+
started_at: string | null;
|
|
9
|
+
tool_use_id?: string;
|
|
10
|
+
for_tool?: string;
|
|
11
|
+
input_tokens_max?: number;
|
|
12
|
+
};
|
|
13
|
+
/** The model requests a run's sessions sent and have not had answered: each `runner.request` with no `runner.turn` of its
|
|
14
|
+
* turn in its conversation. A paid tool's charge (`paid`, its model `paid:<tool>`) is no model request: its call's row
|
|
15
|
+
* says it. A decision's request (`decision:<model>`) is its model's. */
|
|
16
|
+
export declare function modelsInFlight(entries: readonly EntryLike[]): InFlight[];
|
|
17
|
+
/** The tool calls a run made and has not had back: each `tool_use` row with no `tool_result` row of its id in its
|
|
18
|
+
* conversation. A call's id is its session's own (an ACP agent may number its calls from 1), so two sessions' calls can
|
|
19
|
+
* share one. */
|
|
20
|
+
export declare function toolsInFlight(rows: readonly TimelineEvent[]): InFlight[];
|
|
21
|
+
/** Both, oldest first (one with no start time last), and the key a page's change log reads them by: a request sent or
|
|
22
|
+
* answered is a change of the page, so a reader waiting on the page wakes for it, as for a new row. */
|
|
23
|
+
export declare function inFlightOf(models: readonly InFlight[], tools: readonly InFlight[]): {
|
|
24
|
+
list: InFlight[];
|
|
25
|
+
key: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// What a live run is waiting on now (GRE-4835): every request it has sent and not had back, from the moment it was sent,
|
|
2
|
+
// on every harness. A model request is its booking's record (the kernel's `runner.request`, written and stamped `at`
|
|
3
|
+
// before the request leaves) with no `runner.turn` yet: the booking writes both for pi and for every CLI harness, in each
|
|
4
|
+
// model session's conversation. A tool call (MCP, web, a subagent's, a sandbox command, one held for approval) is its
|
|
5
|
+
// Timeline `tool_use` row with no `tool_result` row yet. A timeline page carries the list beside its rows
|
|
6
|
+
// (run-reads-over-store.ts), so a run page shows "inkling-2-mini · 2:13" while a slow local model reads its prompt, where
|
|
7
|
+
// before nothing showed until the answer came back.
|
|
8
|
+
import { RUNNER_RECORDS } from "@parcha/agentrun-kernel";
|
|
9
|
+
const turnKey = (conversation, turn) => `${conversation ?? 0}:${turn}`;
|
|
10
|
+
/** The model requests a run's sessions sent and have not had answered: each `runner.request` with no `runner.turn` of its
|
|
11
|
+
* turn in its conversation. A paid tool's charge (`paid`, its model `paid:<tool>`) is no model request: its call's row
|
|
12
|
+
* says it. A decision's request (`decision:<model>`) is its model's. */
|
|
13
|
+
export function modelsInFlight(entries) {
|
|
14
|
+
const answered = new Set();
|
|
15
|
+
for (const e of entries) {
|
|
16
|
+
const turn = e.kind === RUNNER_RECORDS.turn ? e.data?.turn : undefined;
|
|
17
|
+
if (typeof turn === "number")
|
|
18
|
+
answered.add(turnKey(e.conversationId, turn));
|
|
19
|
+
}
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const e of entries) {
|
|
22
|
+
if (e.kind !== RUNNER_RECORDS.request)
|
|
23
|
+
continue;
|
|
24
|
+
const d = (e.data ?? {});
|
|
25
|
+
if (typeof d.turn !== "number" || typeof d.model !== "string" || d.paid === true || d.model.startsWith("paid:"))
|
|
26
|
+
continue;
|
|
27
|
+
if (answered.has(turnKey(e.conversationId, d.turn)))
|
|
28
|
+
continue;
|
|
29
|
+
out.push({
|
|
30
|
+
kind: "model", name: d.model.startsWith("decision:") ? d.model.slice("decision:".length) : d.model,
|
|
31
|
+
started_at: typeof d.at === "string" ? d.at : null,
|
|
32
|
+
...(typeof d.host === "string" && d.host ? { for_tool: d.host } : {}),
|
|
33
|
+
...(typeof d.inputTokensMax === "number" && Number.isFinite(d.inputTokensMax) ? { input_tokens_max: d.inputTokensMax } : {}),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
/** The tool calls a run made and has not had back: each `tool_use` row with no `tool_result` row of its id in its
|
|
39
|
+
* conversation. A call's id is its session's own (an ACP agent may number its calls from 1), so two sessions' calls can
|
|
40
|
+
* share one. */
|
|
41
|
+
export function toolsInFlight(rows) {
|
|
42
|
+
const callKey = (r) => `${r.conversation_id ?? 0}:${r.tool_use_id}`;
|
|
43
|
+
const returned = new Set(rows.filter((r) => r.kind === "tool_result" && r.tool_use_id).map(callKey));
|
|
44
|
+
return rows.filter((r) => r.kind === "tool_use" && r.tool_use_id && !returned.has(callKey(r)))
|
|
45
|
+
.map((r) => ({ kind: "tool", name: r.tool_name ?? "tool", started_at: r.timestamp || null, tool_use_id: r.tool_use_id }));
|
|
46
|
+
}
|
|
47
|
+
/** Both, oldest first (one with no start time last), and the key a page's change log reads them by: a request sent or
|
|
48
|
+
* answered is a change of the page, so a reader waiting on the page wakes for it, as for a new row. */
|
|
49
|
+
export function inFlightOf(models, tools) {
|
|
50
|
+
const list = [...models, ...tools].sort((a, b) => (a.started_at ?? "").localeCompare(b.started_at ?? ""));
|
|
51
|
+
return { list, key: list.map((f) => `${f.kind}:${f.tool_use_id ?? f.name}@${f.started_at ?? ""}`).join(",") };
|
|
52
|
+
}
|
package/dist/key-refusal.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function runKeyOf(env: NodeJS.ProcessEnv, harness?: string, ref?:
|
|
|
17
17
|
* form (6 times it, for JSON's \uXXXX; percent is 3, hex 2, base64 4/3) and 16 more. A key whose start the cut can show
|
|
18
18
|
* starts before SHOWN, so it ends inside that head and is found whole; one that starts later is never shown. So a long
|
|
19
19
|
* error costs no more to redact than a short one, whatever it holds. `shown`: a head of another length, for a reader
|
|
20
|
-
* that is shown more
|
|
20
|
+
* that is shown more. */
|
|
21
21
|
export declare function redacted(text: string, secrets: readonly string[], shown?: number): string;
|
|
22
22
|
/** How many texts redactedAnswer has read in this process: a test reads it to see a run's view served from what an
|
|
23
23
|
* earlier view redacted (runs.ts servedOnce). */
|
|
@@ -28,11 +28,32 @@ export declare const answerPasses: {
|
|
|
28
28
|
* in it, and NEVER cut: an answer is shown whole. The same rule as redacted() (redactSecrets over `secrets`), over the
|
|
29
29
|
* whole text, read in pieces of about ANSWER_PIECE characters cut at whitespace. No form of a held value redactSecrets
|
|
30
30
|
* finds as it stands (as written, JSON-escaped, base64, hex) holds whitespace, so a cut there splits none; the one shape
|
|
31
|
-
* read across whitespace, a Bearer scheme and its token, is never cut between the two (endsInScheme)
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* read across whitespace, a Bearer scheme and its token, is never cut between the two (endsInScheme); nor is a private
|
|
32
|
+
* key block, cut whole by its shape from its BEGIN line to its END line (keyWhole). A run with no
|
|
33
|
+
* whitespace past a piece is cut at the end of a JSON string in it (never in a URL's user and password), or, a run of
|
|
34
|
+
* a JSON array's numbers only, after a comma (runCut), so compact JSON reads in pieces too. A run of more than ANSWER_PIECE characters with neither is no
|
|
35
|
+
* person's text and is shown as "[redacted]", unread, from where its run starts. A value or a secret shape split across
|
|
36
|
+
* a cut, or a form only found across pieces, still shows to one pass over the joined pieces (heldIn: valueLeft over
|
|
37
|
+
* them as they came, and secretShapes over them redacted; with the head of each run left unread, where the rest of a
|
|
38
|
+
* value split before it would be, and its tail, where the head of a value split after it would be), and then the whole
|
|
39
|
+
* answer is "[redacted]", as redactSecrets does with a text that still holds a value. So is an answer whose pieces,
|
|
40
|
+
* as shown, read as a held value together (heldIn reads the text it returns too). A value split inside one piece withholds only that piece, by the piece's own redaction. */
|
|
35
41
|
export declare function redactedAnswer(text: string, secrets: readonly string[]): string;
|
|
42
|
+
/** `text`, a call's result as a grader's read shows it (timeline calls, tool_result_text), with no held secret in it:
|
|
43
|
+
* read in pieces as redactedAnswer reads an answer, each piece redacted, then shown as `show` makes it (the timeline's
|
|
44
|
+
* scrubUrls), then one pass over the pieces (heldIn). Every check reads the text as it came, redacted, and not only as
|
|
45
|
+
* shown: shown, a URL's query, fragment and userinfo are cut apart, and a held value in one no longer reads as itself;
|
|
46
|
+
* what it returns is read too, for a held value its pieces show only together. A piece
|
|
47
|
+
* never splits a URL (it is cut at whitespace, after a quote, or in a run of numbers), so a piece shows as the whole
|
|
48
|
+
* text would. Only the head the reader is shown is read: pieces stop once they show more than `shown` characters, and
|
|
49
|
+
* the pass also reads the text where they stopped (peek), so a value or a shape the stop split is seen whole. Every
|
|
50
|
+
* character returned was read; the caller cuts it to `shown`. So no redaction pass reads more than a piece, however long
|
|
51
|
+
* the result or its head. */
|
|
52
|
+
export declare function redactedCall(text: string, secrets: readonly string[], shown: number, show?: (piece: string) => string): string;
|
|
53
|
+
/** Whether redactSecrets withholds `text` whole: it holds a held value or a secret shape no cut in place takes (split by
|
|
54
|
+
* whitespace, encoded, written as JSON's \uXXXX escapes). Read whole, never in pieces: the caller bounds what it reads
|
|
55
|
+
* (a web call's strings, joined: timeline calls.holds). */
|
|
56
|
+
export declare function withheldWhole(text: string, secrets: readonly string[]): boolean;
|
|
36
57
|
/** Whether a number shows a held value. A held value can be all digits (a gateway's key), and a record or a call's
|
|
37
58
|
* arguments can quote it as a number: one whose digits hold a held value, by the same rule as a string's, is held. A
|
|
38
59
|
* number can also EQUAL a held value whose text differs from its own (a leading zero, 1e21, a long key read lossy). A
|