@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.59
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 +376 -0
- package/README.md +393 -118
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +7 -5
- package/dist/box-paths.js +12 -8
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +121 -0
- package/dist/claude-login-token.js +797 -0
- package/dist/claude-login.d.ts +119 -34
- package/dist/claude-login.js +551 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +325 -328
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +40 -19
- package/dist/computer-attach.js +326 -62
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +12 -11
- package/dist/computers.js +11 -8
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +139 -5
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +13 -5
- package/dist/env-switch.js +24 -6
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +12 -4
- package/dist/fal-price.js +110 -26
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.js +9 -6
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +8 -0
- package/dist/harness-table.js +17 -6
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +173 -0
- package/dist/learn/ledger.js +225 -0
- package/dist/learn/promote.d.ts +82 -39
- package/dist/learn/promote.js +61 -66
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +40 -21
- package/dist/learning-cost.js +30 -21
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +9 -0
- package/dist/live-reach.js +9 -0
- package/dist/mcp-api-only-origins.d.ts +23 -3
- package/dist/mcp-api-only-origins.js +57 -17
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +234 -61
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +59 -34
- package/dist/place-offers.js +100 -58
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +5 -4
- package/dist/provider.js +26 -13
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.js +3 -1
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +97 -63
- package/dist/runner/adapter-run-spec.d.ts +34 -14
- package/dist/runner/adapter-run-spec.js +120 -75
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +29 -13
- package/dist/runner/claim-secrets.d.ts +27 -18
- package/dist/runner/claim-secrets.js +61 -47
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +93 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +19 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +24 -18
- package/dist/runner/mcp-claim.js +24 -7
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +10 -8
- package/dist/runner/presence.d.ts +11 -4
- package/dist/runner/presence.js +11 -6
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +38 -12
- package/dist/runner/run-child-host.js +231 -83
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +5 -3
- package/dist/runner/runner.js +14 -10
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +138 -37
- package/dist/runner/workflow-first.js +230 -99
- package/dist/runner/workflow-spec.js +2 -2
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +33 -10
- package/dist/server.js +454 -136
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +44 -4
- package/dist/store/schema.js +111 -11
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +19 -2
- package/dist/store/sqlite/run-patch.js +67 -2
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +177 -32
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +74 -25
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +102 -136
- package/dist/store-reads/learning.js +251 -302
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +91 -9
- package/dist/template-eval.js +448 -105
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +14 -14
- package/dist/timeline/web-calls.js +18 -30
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +50 -11
- package/dist/tool-plane.js +94 -30
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +27 -55
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +38 -11
- package/dist/workspace/attached-computers.js +81 -16
- package/dist/workspace/computer-deps.d.ts +29 -7
- package/dist/workspace/computer-deps.js +36 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +166 -57
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +152 -0
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +6 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +25 -9
- package/dist/console/assets/backend-DVhHzJX2.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-okP-y8PK.js +0 -747
package/dist/fal-price.js
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import { mediaSeconds, voiceSeconds } from "./media-duration.js";
|
|
17
17
|
import { SAVE_MAX_BYTES, SERVER_SLOTS } from "./web-save.js";
|
|
18
|
-
|
|
19
|
-
const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
|
|
18
|
+
import { micro } from "./micro.js";
|
|
20
19
|
/** The host of fal's hosted MCP server (its key endpoint /mcp and its sign-in endpoint /mcp-relay). */
|
|
21
20
|
export const FAL_MCP_HOST = "mcp.fal.ai";
|
|
22
21
|
/** A pin's `meter` for a fal server. */
|
|
@@ -144,8 +143,9 @@ function settingOf(input, field, named, fallback) {
|
|
|
144
143
|
return { value, words: `${field} ${JSON.stringify(value)}${given === undefined ? ", its default" : ""}` };
|
|
145
144
|
}
|
|
146
145
|
/** A rate set by one setting: `rates` by value. */
|
|
147
|
-
const byOne = (field, base, rates, fallback) => ({
|
|
146
|
+
const byOne = (unit, field, base, rates, fallback) => ({
|
|
148
147
|
base,
|
|
148
|
+
unit,
|
|
149
149
|
rate: (input) => {
|
|
150
150
|
const setting = settingOf(input, field, [...rates.keys()], fallback);
|
|
151
151
|
return "why" in setting ? setting : { rate: rates.get(setting.value), words: setting.words };
|
|
@@ -157,6 +157,7 @@ const audio = (off, on) => ({ off, on });
|
|
|
157
157
|
* audio (on by default). */
|
|
158
158
|
const veo = (base, rates) => ({
|
|
159
159
|
base,
|
|
160
|
+
unit: "seconds",
|
|
160
161
|
rate: (input) => {
|
|
161
162
|
const sound = settingOf(input, "generate_audio", [true, false], true);
|
|
162
163
|
if ("why" in sound)
|
|
@@ -176,6 +177,7 @@ const VEO31_LITE = veo(0.05, { "720p": audio(0.03, 0.05), "1080p": audio(0.05, 0
|
|
|
176
177
|
* no rate for voice control. */
|
|
177
178
|
const kling = (base, page, floor = 0) => ({
|
|
178
179
|
base,
|
|
180
|
+
unit: "seconds",
|
|
179
181
|
rate: (input) => {
|
|
180
182
|
const sound = settingOf(input, "generate_audio", [true, false], true);
|
|
181
183
|
if ("why" in sound)
|
|
@@ -195,17 +197,17 @@ const kling = (base, page, floor = 0) => ({
|
|
|
195
197
|
return { rate: held(sound.value ? page.on : page.off), words: sound.words };
|
|
196
198
|
},
|
|
197
199
|
});
|
|
198
|
-
const IDEOGRAM_V3 = byOne("rendering_speed", 0.03, new Map([["TURBO", 0.03], ["BALANCED", 0.06], ["QUALITY", 0.09]]), "BALANCED");
|
|
200
|
+
const IDEOGRAM_V3 = byOne("images", "rendering_speed", 0.03, new Map([["TURBO", 0.03], ["BALANCED", 0.06], ["QUALITY", 0.09]]), "BALANCED");
|
|
199
201
|
/** A web search's charge, per unit: $0.015 when enable_web_search is true (its default is false). */
|
|
200
202
|
const webSearch = (input) => {
|
|
201
203
|
const search = settingOf(input, "enable_web_search", [true, false], false);
|
|
202
204
|
return "why" in search ? search : search.value ? { usd: 0.015, words: "a web search" } : undefined;
|
|
203
205
|
};
|
|
204
|
-
const NANO_BANANA_PRO = { ...byOne("resolution", 0.15, new Map([["1K", 0.15], ["2K", 0.15], ["4K", 0.3]]), "1K"), perUnitUsd: webSearch };
|
|
206
|
+
const NANO_BANANA_PRO = { ...byOne("images", "resolution", 0.15, new Map([["1K", 0.15], ["2K", 0.15], ["4K", 0.3]]), "1K"), perUnitUsd: webSearch };
|
|
205
207
|
/** Nano Banana 2: by its resolution, plus a web search's charge and high thinking's ($0.002, thinking_level "high"; none
|
|
206
208
|
* for "minimal" or none, its default), each per unit. */
|
|
207
209
|
const NANO_BANANA_2 = {
|
|
208
|
-
...byOne("resolution", 0.08, new Map([["0.5K", 0.06], ["1K", 0.08], ["2K", 0.12], ["4K", 0.16]]), "1K"),
|
|
210
|
+
...byOne("images", "resolution", 0.08, new Map([["0.5K", 0.06], ["1K", 0.08], ["2K", 0.12], ["4K", 0.16]]), "1K"),
|
|
209
211
|
perUnitUsd: (input) => {
|
|
210
212
|
const search = webSearch(input);
|
|
211
213
|
if (search && "why" in search)
|
|
@@ -214,15 +216,15 @@ const NANO_BANANA_2 = {
|
|
|
214
216
|
if ("why" in thinking)
|
|
215
217
|
return thinking;
|
|
216
218
|
const added = [...(search ? [search] : []), ...(thinking.value === "high" ? [{ usd: 0.002, words: "high thinking" }] : [])];
|
|
217
|
-
return added.length ? { usd:
|
|
219
|
+
return added.length ? { usd: micro(added.reduce((sum, one) => sum + one.usd, 0)), words: added.map((one) => one.words).join(" and ") } : undefined;
|
|
218
220
|
},
|
|
219
221
|
};
|
|
220
222
|
const KLING_PRO = kling(0.14, { off: 0.112, on: 0.168, voice: 0.196 }, 0.14);
|
|
221
223
|
const KLING_STANDARD = kling(0.14, { off: 0.084, on: 0.126, voice: 0.154 }, 0.14);
|
|
222
|
-
const FABRIC = byOne("resolution", 0.08, new Map([["480p", 0.08], ["720p", 0.15]]));
|
|
224
|
+
const FABRIC = byOne("seconds", "resolution", 0.08, new Map([["480p", 0.08], ["720p", 0.15]]));
|
|
223
225
|
const RATE_TIERS = new Map([
|
|
224
226
|
...["", "/edit", "/remix", "/reframe", "/replace-background", "/generate-transparent"].map((variant) => [`fal-ai/ideogram/v3${variant}`, IDEOGRAM_V3]),
|
|
225
|
-
...["", "/edit", "/remix"].map((variant) => [`fal-ai/ideogram/character${variant}`, byOne("rendering_speed", 0.05, new Map([["TURBO", 0.1], ["BALANCED", 0.15], ["QUALITY", 0.2]]), "BALANCED")]),
|
|
227
|
+
...["", "/edit", "/remix"].map((variant) => [`fal-ai/ideogram/character${variant}`, byOne("images", "rendering_speed", 0.05, new Map([["TURBO", 0.1], ["BALANCED", 0.15], ["QUALITY", 0.2]]), "BALANCED")]),
|
|
226
228
|
...["", "/image-to-video", "/first-last-frame-to-video", "/reference-to-video"].map((variant) => [`fal-ai/veo3.1${variant}`, VEO31]),
|
|
227
229
|
["fal-ai/veo3.1/extend-video", veo(0.4, { "720p": audio(0.2, 0.4) })],
|
|
228
230
|
...["/fast", "/fast/image-to-video", "/fast/first-last-frame-to-video", "/fast/reference-to-video"].map((variant) => [`fal-ai/veo3.1${variant}`, VEO31_FAST]),
|
|
@@ -235,7 +237,7 @@ const RATE_TIERS = new Map([
|
|
|
235
237
|
["fal-ai/kling-video/v3/standard/image-to-video", KLING_STANDARD],
|
|
236
238
|
["fal-ai/kling-video/v3/standard/text-to-video", KLING_STANDARD],
|
|
237
239
|
["fal-ai/kling-video/v3/4k/image-to-video", kling(0.42, { off: 0.42, on: 0.42 })],
|
|
238
|
-
["fal-ai/sync-lipsync/v2", byOne("model", 3, new Map([["lipsync-2", 3], ["lipsync-2-pro", 5]]), "lipsync-2")],
|
|
240
|
+
["fal-ai/sync-lipsync/v2", byOne("minutes", "model", 3, new Map([["lipsync-2", 3], ["lipsync-2-pro", 5]]), "lipsync-2")],
|
|
239
241
|
["fal-ai/nano-banana-pro", NANO_BANANA_PRO],
|
|
240
242
|
["fal-ai/nano-banana-pro/edit", NANO_BANANA_PRO],
|
|
241
243
|
["fal-ai/gemini-3-pro-image-preview", NANO_BANANA_PRO],
|
|
@@ -243,7 +245,7 @@ const RATE_TIERS = new Map([
|
|
|
243
245
|
...["fal-ai/nano-banana-2", "fal-ai/nano-banana-2/edit", "fal-ai/gemini-3.1-flash-image-preview", "fal-ai/gemini-3.1-flash-image-preview/edit"].map((endpoint) => [endpoint, NANO_BANANA_2]),
|
|
244
246
|
["veed/fabric-1.0", FABRIC],
|
|
245
247
|
["veed/fabric-1.0/text", FABRIC],
|
|
246
|
-
["veed/fabric-1.0/fast", byOne("resolution", 0.1, new Map([["480p", 0.1], ["720p", 0.2]]))],
|
|
248
|
+
["veed/fabric-1.0/fast", byOne("seconds", "resolution", 0.1, new Map([["480p", 0.1], ["720p", 0.2]]))],
|
|
247
249
|
]);
|
|
248
250
|
/** The families fal bills by their settings: an endpoint is in one when it is the family's id or under it. Ideogram v4's
|
|
249
251
|
* pages (read 2026-11-23 13:13Z) bill by rendering_speed and megapixels, and get_pricing (13:20:43Z) states most of
|
|
@@ -274,7 +276,7 @@ export function decidedRates() {
|
|
|
274
276
|
}
|
|
275
277
|
/** The rate a job of `endpoint` is billed at, against get_pricing's (in `unit`): `ratio`, its tier's rate over the rate
|
|
276
278
|
* get_pricing states (RATE_TIERS), `perUnitUsd` a charge added to each unit's price, and `words` the settings they came from (none at
|
|
277
|
-
* get_pricing's own rate); or `unknown`, why it can't be known. 1 and nothing for an endpoint with one rate; unknown for
|
|
279
|
+
* get_pricing's own rate); or `unknown`, why it can't be known (get_pricing stating it in another unit than its tiers' among them). 1 and nothing for an endpoint with one rate; unknown for
|
|
278
280
|
* an endpoint in a family fal bills by its settings whose rate is not decided here (TIERED_FAMILIES). */
|
|
279
281
|
export function rateOf(endpoint, unit, input) {
|
|
280
282
|
const tiers = RATE_TIERS.get(endpoint);
|
|
@@ -285,6 +287,9 @@ export function rateOf(endpoint, unit, input) {
|
|
|
285
287
|
return { unknown: `fal bills ${family} by its settings and ${endpoint} has no rate decided here` };
|
|
286
288
|
return { ratio: 1, perUnitUsd: 0, words: [] };
|
|
287
289
|
}
|
|
290
|
+
// The ratios and the model page's rates hold only in the unit they were decided in: per second, minute or image.
|
|
291
|
+
if (unit !== tiers.unit)
|
|
292
|
+
return { unknown: `get_pricing states ${endpoint} per ${oneOf(unit)}, and its rates were decided per ${oneOf(tiers.unit)}` };
|
|
288
293
|
if (!isObject(input))
|
|
289
294
|
return { ratio: 1, perUnitUsd: 0, words: [] };
|
|
290
295
|
const bills = `fal bills ${endpoint} per ${oneOf(unit)} at a rate`;
|
|
@@ -411,7 +416,7 @@ function bodyOf(result) {
|
|
|
411
416
|
return undefined;
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
|
-
const shown = (n) => String(
|
|
419
|
+
const shown = (n) => String(micro(n));
|
|
415
420
|
/** A MediaReader over the public-host guard web_fetch and web_save download through (`guard`: their fetch options),
|
|
416
421
|
* within web_save's size cap and download slots. */
|
|
417
422
|
export const publicMedia = (guard, slots = SERVER_SLOTS) => async (url, signal, read = {}) => {
|
|
@@ -456,7 +461,7 @@ function chargeOfJob(quote, item) {
|
|
|
456
461
|
const after = item.status === "completed" ? unitsAfter(quote.unit, item.result) : undefined;
|
|
457
462
|
if (after === undefined)
|
|
458
463
|
return quote.holdUsd;
|
|
459
|
-
return
|
|
464
|
+
return micro(quote.unitPrice * (quote.step ? roundedUp(after, quote.unit, quote.step) : after));
|
|
460
465
|
}
|
|
461
466
|
/** `units` of `unit` (seconds or minutes) rounded up to a whole `step` of seconds, in `unit`. Rounded to the
|
|
462
467
|
* microsecond first, so a length a float sum or a conversion leaves a hair over a whole step (125 frames of 0.024 s)
|
|
@@ -473,7 +478,7 @@ const hex16 = (text) => createHash("sha256").update(text).digest("hex").slice(0,
|
|
|
473
478
|
/** What a run adds to each key: `.` and 16 hex. */
|
|
474
479
|
const KEY_TAIL = 17;
|
|
475
480
|
/** The longest submission_key an agent can send fal in a run: fal's KEY_MAX less the run's KEY_TAIL. */
|
|
476
|
-
|
|
481
|
+
const KEY_ROOM = KEY_MAX - KEY_TAIL;
|
|
477
482
|
/** The submission keys of a call of fal's `tool`: its own, and for submit_jobs each request's. */
|
|
478
483
|
const keysOf = (tool, args) => [args.submission_key, ...(tool === "submit_jobs" && Array.isArray(args.requests) ? args.requests.map((one) => (isObject(one) ? one.submission_key : undefined)) : [])];
|
|
479
484
|
/** The submission keys of one run on fal's hosted server (McpMeter.keys). fal's journal is per account, so the same key
|
|
@@ -505,16 +510,51 @@ export function falKeys(run) {
|
|
|
505
510
|
back: (text) => (text.includes(mark) ? text.replace(suffix, "") : text),
|
|
506
511
|
};
|
|
507
512
|
}
|
|
513
|
+
/** Where a fal job's result is filed in the run's files: evidence/fal/<request_id>.json. */
|
|
514
|
+
export const FAL_RESULTS_DIR = "evidence/fal";
|
|
515
|
+
/** fal's request ids: UUIDs. Only one names a file: anything else (a path, a dot name, a name past a filename's
|
|
516
|
+
* limit, a plain name fal never gives) is never filed. */
|
|
517
|
+
export const FAL_REQUEST_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
518
|
+
/** fal's tools whose answers carry completed jobs: run_model's one, submit_jobs' and wait_for_jobs' each. */
|
|
519
|
+
const WITH_RESULTS = new Set(["run_model", "submit_jobs", "wait_for_jobs"]);
|
|
520
|
+
/** The completed jobs of fal's answer to `tool`, each by its request_id with its `result` as fal answered it: the answer
|
|
521
|
+
* itself (run_model), and each entry of a list in it (submit_jobs', wait_for_jobs' `jobs`). A job is completed when
|
|
522
|
+
* fal says so (`status` "completed") and it carries a `result`. One whose request_id is not a UUID is left out, and a
|
|
523
|
+
* request_id twice in one answer is filed from its first entry. */
|
|
524
|
+
export const falResults = {
|
|
525
|
+
dir: FAL_RESULTS_DIR,
|
|
526
|
+
of(tool, reply) {
|
|
527
|
+
if (!WITH_RESULTS.has(tool))
|
|
528
|
+
return [];
|
|
529
|
+
const body = bodyOf(reply);
|
|
530
|
+
if (!isObject(body))
|
|
531
|
+
return [];
|
|
532
|
+
const entries = [body, ...Object.values(body).flatMap((value) => (Array.isArray(value) ? value : []))];
|
|
533
|
+
const seen = new Set();
|
|
534
|
+
return entries.flatMap((entry) => {
|
|
535
|
+
if (!isObject(entry) || entry.status !== "completed" || !Object.hasOwn(entry, "result"))
|
|
536
|
+
return [];
|
|
537
|
+
const id = entry.request_id;
|
|
538
|
+
if (typeof id !== "string" || !FAL_REQUEST_ID.test(id) || seen.has(id))
|
|
539
|
+
return [];
|
|
540
|
+
seen.add(id);
|
|
541
|
+
return [{ name: id, value: entry.result }];
|
|
542
|
+
});
|
|
543
|
+
},
|
|
544
|
+
};
|
|
508
545
|
/** A fal server's meter: fal's unit prices read through the gateway's `ask`, kept per endpoint for PRICE_TTL_MS.
|
|
509
546
|
* `media` reads an input media file (none: such a job is unpriceable); `now`, the clock. */
|
|
510
547
|
export function falMeter({ media, now = Date.now } = {}) {
|
|
511
548
|
const prices = new Map();
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
const answer = await ask("get_pricing", { endpoint_id: endpoint });
|
|
549
|
+
/** The reads under way, by endpoint: calls sent together share one get_pricing call rather than each sending its own.
|
|
550
|
+
* `signal` is the signal of the call that sent it. */
|
|
551
|
+
const reading = new Map();
|
|
552
|
+
const readPrice = async (endpoint, ask) => {
|
|
517
553
|
const unread = (why) => ({ why: `fal's price for ${endpoint} could not be read (its get_pricing ${why})` });
|
|
554
|
+
// get_pricing reads a price and runs no job: an error or no answer is asked once more, never kept as the price.
|
|
555
|
+
let answer = await ask("get_pricing", { endpoint_id: endpoint });
|
|
556
|
+
if (!answer || answer.isError === true)
|
|
557
|
+
answer = await ask("get_pricing", { endpoint_id: endpoint });
|
|
518
558
|
if (!answer)
|
|
519
559
|
return unread("did not answer");
|
|
520
560
|
if (answer.isError === true)
|
|
@@ -522,10 +562,44 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
522
562
|
const price = priceIn(bodyOf(answer), endpoint);
|
|
523
563
|
if (!price)
|
|
524
564
|
return unread("lists no USD price for it");
|
|
565
|
+
// fal bills its jobs: a rate of $0 is no price, so the job is unpriceable (refused under a cap, booked as unknown).
|
|
566
|
+
if (price.unitPrice === 0)
|
|
567
|
+
return unread(`states $0 per ${oneOf(price.unit)} for it, which is no price`);
|
|
525
568
|
const read = { ...price, at: now() };
|
|
526
569
|
prices.set(endpoint, read);
|
|
527
570
|
return read;
|
|
528
571
|
};
|
|
572
|
+
const unitPrice = async (endpoint, ask, signal) => {
|
|
573
|
+
for (;;) {
|
|
574
|
+
const kept = prices.get(endpoint);
|
|
575
|
+
if (kept && now() - kept.at < PRICE_TTL_MS)
|
|
576
|
+
return kept;
|
|
577
|
+
const shared = reading.get(endpoint);
|
|
578
|
+
if (!shared)
|
|
579
|
+
break;
|
|
580
|
+
try {
|
|
581
|
+
const read = await shared.read;
|
|
582
|
+
// A read whose call stopped (its deadline, its run's abort) got no answer from fal, which says nothing of the
|
|
583
|
+
// price: a call still live reads again, with its own ask. A read that failed while its call was live stands.
|
|
584
|
+
if (!("why" in read) || !shared.signal.aborted || signal.aborted)
|
|
585
|
+
return read;
|
|
586
|
+
}
|
|
587
|
+
catch {
|
|
588
|
+
// The call that sent it threw: this one reads with its own ask.
|
|
589
|
+
}
|
|
590
|
+
if (reading.get(endpoint) === shared)
|
|
591
|
+
reading.delete(endpoint);
|
|
592
|
+
}
|
|
593
|
+
const mine = { read: readPrice(endpoint, ask), signal };
|
|
594
|
+
reading.set(endpoint, mine);
|
|
595
|
+
try {
|
|
596
|
+
return await mine.read;
|
|
597
|
+
}
|
|
598
|
+
finally {
|
|
599
|
+
if (reading.get(endpoint) === mine)
|
|
600
|
+
reading.delete(endpoint);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
529
603
|
/** The longest of the media at `urls`, in seconds by `measure`, or the URL whose length could not be read. */
|
|
530
604
|
const longest = async (urls, signal, read, measure = mediaSeconds) => {
|
|
531
605
|
const lengths = await Promise.all([...new Set(urls)].map(async (url) => {
|
|
@@ -541,7 +615,7 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
541
615
|
const quoteJob = async (job, ask, signal) => {
|
|
542
616
|
if (!job.endpoint)
|
|
543
617
|
return { job, why: "this job names no endpoint_id to price" };
|
|
544
|
-
const price = await unitPrice(job.endpoint, ask);
|
|
618
|
+
const price = await unitPrice(job.endpoint, ask, signal);
|
|
545
619
|
if ("why" in price)
|
|
546
620
|
return { job, why: price.why };
|
|
547
621
|
// The rate its settings are billed at, before any media is read for a job that can't be priced.
|
|
@@ -567,12 +641,22 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
567
641
|
const step = price.unit === "seconds" || price.unit === "minutes" ? BILLING_STEP.get(job.endpoint) : undefined;
|
|
568
642
|
if (step)
|
|
569
643
|
units = { units: roundedUp(units.units, price.unit, step), from: `${units.from}, in whole ${step === 60 ? "minutes" : "seconds"}` };
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
644
|
+
// The ratios were decided against get_pricing's rate as it stood (page.base). When fal states another, the scaled
|
|
645
|
+
// rate can fall under what its model page bills this tier, and the hold and the booking (the same unitPrice) with it:
|
|
646
|
+
// the job is held at the higher of the two.
|
|
647
|
+
const scaled = price.unitPrice * rate.ratio;
|
|
648
|
+
const base = RATE_TIERS.get(job.endpoint)?.base;
|
|
649
|
+
// The tier's rate on the model page: the ratio was decided as that rate over base (rateOf).
|
|
650
|
+
const page = base === undefined ? undefined : micro(base * rate.ratio);
|
|
651
|
+
const moved = base !== undefined && page !== undefined && price.unitPrice !== base && page > scaled;
|
|
652
|
+
const rated = (moved ? page : scaled) + rate.perUnitUsd;
|
|
653
|
+
const drift = moved ? [`(get_pricing states $${price.unitPrice}, not the $${base} its rates were decided at: held at the model page's $${page} per ${oneOf(price.unit)})`] : [];
|
|
654
|
+
const words = [`fal's price for ${job.endpoint}: $${price.unitPrice} per ${oneOf(price.unit)}`, ...rate.words, ...drift, `× ${shown(units.units)} (${units.from})`].join(" ");
|
|
655
|
+
return { job, holdUsd: micro(rated * units.units), unitPrice: rated, unit: price.unit, at: price.at, words, ...(step ? { step } : {}) };
|
|
573
656
|
};
|
|
574
657
|
return {
|
|
575
658
|
bills: falBills,
|
|
659
|
+
results: falResults,
|
|
576
660
|
async quote(tool, args, ask, signal) {
|
|
577
661
|
const quotes = [];
|
|
578
662
|
// One at a time: each endpoint's price is read once, the next job's from what the last one kept.
|
|
@@ -581,7 +665,7 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
581
665
|
const priced = quotes.filter((quote) => "holdUsd" in quote);
|
|
582
666
|
const unpriced = quotes.find((quote) => "why" in quote);
|
|
583
667
|
const basis = priced.length ? `${priced.map((quote) => quote.words).join("; ")}, from get_pricing at ${new Date(Math.min(...priced.map((quote) => quote.at))).toISOString()}` : "fal's price for it could not be worked out";
|
|
584
|
-
const holdUsd =
|
|
668
|
+
const holdUsd = micro(priced.reduce((sum, quote) => sum + quote.holdUsd, 0));
|
|
585
669
|
return {
|
|
586
670
|
holdUsd,
|
|
587
671
|
basis: unpriced && priced.length ? `${basis}; not counting what could not be priced` : basis,
|
|
@@ -606,7 +690,7 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
606
690
|
return null;
|
|
607
691
|
total += charge;
|
|
608
692
|
}
|
|
609
|
-
return
|
|
693
|
+
return micro(total);
|
|
610
694
|
},
|
|
611
695
|
};
|
|
612
696
|
},
|
package/dist/faux-computers.js
CHANGED
|
@@ -143,7 +143,7 @@ export function fauxComputers() {
|
|
|
143
143
|
async function fauxDial(dial, run) {
|
|
144
144
|
// The computer package's words for a dial provider with no dial (hosted/provider.ts #dialed).
|
|
145
145
|
if (dial === undefined)
|
|
146
|
-
throw new Error("Faux dial machines dial in to this server, and this runner runs in a process of its own
|
|
146
|
+
throw new Error("Faux dial machines dial in to this server, and this runner runs in a process of its own and relays no machine's socket: give the runner AGENTRUN_PUBLIC_URL (this server's public address), or start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)");
|
|
147
147
|
if (!dial.url)
|
|
148
148
|
throw new Error("Faux dial machines dial in to this server, which has no public address: set AGENTRUN_PUBLIC_URL");
|
|
149
149
|
const name = `faux-dial-${randomBytes(6).toString("hex")}`;
|
package/dist/filed-answer.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export declare function laidOut(text: string): string | undefined;
|
|
|
24
24
|
/** The model's text for `text`, longer than `clip` characters: the filed text's first lines, whole, within `clip`, then
|
|
25
25
|
* a note naming the file (`<folder>/<stem>.txt`, or `.json` for JSON) and the read offset that goes on. A file that
|
|
26
26
|
* cannot be written still answers its start, saying why in the Workspace's words (never an error's message, which
|
|
27
|
-
* names paths). `clip` is at least FILED_LINE_MAX, so the start holds at least one line. */
|
|
28
|
-
export declare function filedAnswer(work: Workspace | (() => Workspace), folder: string, stem: string, text: string, clip: number): Promise<string>;
|
|
27
|
+
* names paths), a Workspace that cannot be opened (`work` a thunk that rejects) too. `clip` is at least FILED_LINE_MAX, so the start holds at least one line. */
|
|
28
|
+
export declare function filedAnswer(work: Workspace | (() => Workspace | Promise<Workspace>), folder: string, stem: string, text: string, clip: number): Promise<string>;
|
|
29
29
|
/** For a unified diff (`diff --git a/... b/...` lines), where each file not wholly shown starts in the filed text and
|
|
30
30
|
* how many lines it runs, so a reader takes the files it needs by range (and passes a generated one by) rather than
|
|
31
31
|
* paging through all of it: "; files past the cut, from the line each starts at (its lines): a.ts 908 (120), ...". */
|
package/dist/filed-answer.js
CHANGED
|
@@ -100,7 +100,7 @@ export function laidOut(text) {
|
|
|
100
100
|
/** The model's text for `text`, longer than `clip` characters: the filed text's first lines, whole, within `clip`, then
|
|
101
101
|
* a note naming the file (`<folder>/<stem>.txt`, or `.json` for JSON) and the read offset that goes on. A file that
|
|
102
102
|
* cannot be written still answers its start, saying why in the Workspace's words (never an error's message, which
|
|
103
|
-
* names paths). `clip` is at least FILED_LINE_MAX, so the start holds at least one line. */
|
|
103
|
+
* names paths), a Workspace that cannot be opened (`work` a thunk that rejects) too. `clip` is at least FILED_LINE_MAX, so the start holds at least one line. */
|
|
104
104
|
export async function filedAnswer(work, folder, stem, text, clip) {
|
|
105
105
|
const filed = fileable(text);
|
|
106
106
|
const lines = filed.text.split("\n");
|
|
@@ -120,7 +120,7 @@ export async function filedAnswer(work, folder, stem, text, clip) {
|
|
|
120
120
|
const cut = `\n[cut at line ${shown} of ${total} (${head.length} of ${filed.text.length} characters${how.length ? `; ${how.join("; ")}` : ""}); `;
|
|
121
121
|
const path = `${folder}/${stem}.${filed.json ? "json" : "txt"}`;
|
|
122
122
|
try {
|
|
123
|
-
await (typeof work === "function" ? work() : work).write(path, filed.text);
|
|
123
|
+
await (await (typeof work === "function" ? work() : work)).write(path, filed.text);
|
|
124
124
|
}
|
|
125
125
|
catch (error) {
|
|
126
126
|
return `${head}${cut}the whole answer could not be saved (${workspaceErrorWords(error) ?? error?.code ?? "write failed"})]`;
|
package/dist/graph-served.d.ts
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
export declare const LABEL_SHOWN = 200;
|
|
3
3
|
export declare const ERROR_SHOWN = 2000;
|
|
4
4
|
export type PartKind = "nodes" | "decision" | "effect";
|
|
5
|
-
/** `value`, a part of a graph view of `kind`, as the graph serves it with `values` held:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
/** `value`, a part of a graph view of `kind`, as the graph serves it with `values` held: read whole first, so a held
|
|
6
|
+
* value split across two of its fields withholds the part as "[redacted]", then each string and number by
|
|
7
|
+
* redactedOutput (redactedOutputWhole); then a map item's label cut at LABEL_SHOWN and an error at ERROR_SHOWN. A text
|
|
8
|
+
* stored cut (a decision's state past 64 KB, an error marked cut, or one of exactly ERROR_CUT_BEFORE characters from
|
|
9
|
+
* before) has its last 6 times the longest held value plus 16 characters held back, where a value the stored cut split
|
|
10
|
+
* would sit. */
|
|
9
11
|
export declare function servedPart(kind: PartKind, value: unknown, values: readonly string[]): unknown;
|
|
10
12
|
/** How many walks servedGraphView made, by what it walked: a part (servedPart over the nodes, a decision or a call) or a
|
|
11
13
|
* field of the rest (redactedOutput over one top-level field). Counted for the tests, which read that a read again walks
|
|
@@ -18,7 +20,10 @@ export declare const graphWalks: {
|
|
|
18
20
|
* over the same values), the parts by the file path's rule on top:
|
|
19
21
|
* - its nodes, each decision and each call through servedPart (a map item's label and an error cut short after);
|
|
20
22
|
* - every other top-level field (its run, its workflow, its structure `graph`, which echoes the workflow's nodes and their
|
|
21
|
-
* words, its totals, and any field added later) through
|
|
23
|
+
* words, its totals, and any field added later) through redactedOutputWhole, each by itself, its keys included: a
|
|
24
|
+
* field whose JSON holds a held value split across two of its strings is "[redacted]", but for `graph` and `run`,
|
|
25
|
+
* each served in its own shape (IN_SHAPE), so every reader that draws the run still reads a graph's nodes and edges
|
|
26
|
+
* and the run's status;
|
|
22
27
|
* - `read_at`, which moves with every read: the server's clock as toISOString writes it, served as it is, never kept;
|
|
23
28
|
* anything else under the name is cut each read.
|
|
24
29
|
* Each part and each field, its name and its value, scalar or not, is cut once per content and held set and kept in
|
package/dist/graph-served.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
// What GET /runs/{id}/graph serves of each part of a run's graph (servedGraphView, below): redacted by a run's answer's rule
|
|
2
|
-
// (key-refusal.ts
|
|
3
|
-
// makes the view whole, so a key saved after it was made, or kept for a busy store's read, is still found.
|
|
2
|
+
// (key-refusal.ts redactedOutputWhole, over the values the server holds and handed the run), and only then cut.
|
|
3
|
+
// graph-view.ts makes the view whole, so a key saved after it was made, or kept for a busy store's read, is still found.
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
-
import { redactedOutput } from "./key-refusal.js";
|
|
5
|
+
import { redactedOutput, redactedOutputWhole } from "./key-refusal.js";
|
|
6
6
|
/** The most of a map item's label and of an error (a call's, a decision's) the graph shows. */
|
|
7
7
|
export const LABEL_SHOWN = 200;
|
|
8
8
|
export const ERROR_SHOWN = 2000;
|
|
9
9
|
/** Where an error was cut when it was stored, before errors were stored whole: one this long may have been cut there. */
|
|
10
10
|
const ERROR_CUT_BEFORE = 2000;
|
|
11
11
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
-
/** `value`, a part of a graph view of `kind`, as the graph serves it with `values` held:
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
/** `value`, a part of a graph view of `kind`, as the graph serves it with `values` held: read whole first, so a held
|
|
13
|
+
* value split across two of its fields withholds the part as "[redacted]", then each string and number by
|
|
14
|
+
* redactedOutput (redactedOutputWhole); then a map item's label cut at LABEL_SHOWN and an error at ERROR_SHOWN. A text
|
|
15
|
+
* stored cut (a decision's state past 64 KB, an error marked cut, or one of exactly ERROR_CUT_BEFORE characters from
|
|
16
|
+
* before) has its last 6 times the longest held value plus 16 characters held back, where a value the stored cut split
|
|
17
|
+
* would sit. */
|
|
16
18
|
export function servedPart(kind, value, values) {
|
|
17
|
-
const shown =
|
|
19
|
+
const shown = redactedOutputWhole(value, values);
|
|
18
20
|
if (!isRecord(shown))
|
|
19
21
|
return shown;
|
|
20
22
|
const hold = 6 * values.reduce((most, held) => Math.max(most, held.length), 0) + 16;
|
|
@@ -38,13 +40,35 @@ export function servedPart(kind, value, values) {
|
|
|
38
40
|
* nothing, with no clock. */
|
|
39
41
|
export const graphWalks = { part: 0, rest: 0 };
|
|
40
42
|
const isRecordOrArray = (value) => typeof value === "object" && value !== null;
|
|
43
|
+
/** The graph's structure (`graph`) when its JSON holds a held value split across two of its strings (a question's
|
|
44
|
+
* instructions ending with the value's head and its first option starting with the rest): the shape the contract gives
|
|
45
|
+
* the field, no nodes and no edges, and `withheld`, so a reader draws nothing and can say why. */
|
|
46
|
+
const WITHHELD_GRAPH = { nodes: [], edges: [], withheld: true };
|
|
47
|
+
/** The run's facts (`run`) when their JSON holds a held value split across two of them (its agent and its revision): the
|
|
48
|
+
* facts the server makes itself, which carry no one's words (its id, status, pause and times), each still cut as any
|
|
49
|
+
* string is, the agent and the revision "[redacted]", and `withheld`. */
|
|
50
|
+
const withheldRun = (run, values) => ({
|
|
51
|
+
...Object.fromEntries(["id", "status", "paused", "startedAt", "endedAt"].filter((key) => key in run).map((key) => [key, redactedOutput(run[key], values)])),
|
|
52
|
+
agent: "[redacted]",
|
|
53
|
+
revision: "[redacted]",
|
|
54
|
+
withheld: true,
|
|
55
|
+
});
|
|
56
|
+
/** The top-level fields served in their own shape when withheld whole, by name: what a reader of the graph reads at once
|
|
57
|
+
* (the console draws the graph's nodes and reads the run's status). Any other field withheld whole is "[redacted]". */
|
|
58
|
+
const IN_SHAPE = {
|
|
59
|
+
graph: () => ({ ...WITHHELD_GRAPH }),
|
|
60
|
+
run: withheldRun,
|
|
61
|
+
};
|
|
41
62
|
/** A time as Date's toISOString writes it, and nothing else: digits, its fixed separators and Z. */
|
|
42
63
|
const ISO_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
43
64
|
/** A graph view as GET /runs/{id}/graph serves it with `values` held, every field of it cut by the one rule (redactedOutput
|
|
44
65
|
* over the same values), the parts by the file path's rule on top:
|
|
45
66
|
* - its nodes, each decision and each call through servedPart (a map item's label and an error cut short after);
|
|
46
67
|
* - every other top-level field (its run, its workflow, its structure `graph`, which echoes the workflow's nodes and their
|
|
47
|
-
* words, its totals, and any field added later) through
|
|
68
|
+
* words, its totals, and any field added later) through redactedOutputWhole, each by itself, its keys included: a
|
|
69
|
+
* field whose JSON holds a held value split across two of its strings is "[redacted]", but for `graph` and `run`,
|
|
70
|
+
* each served in its own shape (IN_SHAPE), so every reader that draws the run still reads a graph's nodes and edges
|
|
71
|
+
* and the run's status;
|
|
48
72
|
* - `read_at`, which moves with every read: the server's clock as toISOString writes it, served as it is, never kept;
|
|
49
73
|
* anything else under the name is cut each read.
|
|
50
74
|
* Each part and each field, its name and its value, scalar or not, is cut once per content and held set and kept in
|
|
@@ -69,7 +93,13 @@ export function servedGraphView(view, values, cache) {
|
|
|
69
93
|
// A field's name and its value, scalar or not, each cut once per content and held set: a poll walks none again.
|
|
70
94
|
// (graphWalks.rest counts the walks of a field that holds more than one value, as before.)
|
|
71
95
|
const cutName = kept(`name:${keys}:${digest(name)}`, () => redactedOutput(name, values));
|
|
72
|
-
fields[cutName] = kept(`field:${keys}:${digest(name)}:${digest(value)}`, () =>
|
|
96
|
+
fields[cutName] = kept(`field:${keys}:${digest(name)}:${digest(value)}`, () => {
|
|
97
|
+
if (isRecordOrArray(value))
|
|
98
|
+
graphWalks.rest++;
|
|
99
|
+
const cut = redactedOutputWhole(value, values);
|
|
100
|
+
const shape = Object.hasOwn(IN_SHAPE, name) ? IN_SHAPE[name] : undefined;
|
|
101
|
+
return shape && isRecord(value) && cut === "[redacted]" ? shape(value, values) : cut;
|
|
102
|
+
});
|
|
73
103
|
}
|
|
74
104
|
return {
|
|
75
105
|
// The read's own time, the server's clock as toISOString writes it, holds nothing of the run: served as it is. Any other
|
package/dist/handed-values.js
CHANGED
|
@@ -12,6 +12,7 @@ import { ServerSecrets } from "./server-secrets.js";
|
|
|
12
12
|
import { sealedAt, unsealColumn } from "./store/seal.js";
|
|
13
13
|
import { handedMark, handedPointers } from "./run-view.js";
|
|
14
14
|
import { readLaunchBody } from "./run-launch.js";
|
|
15
|
+
import { SIGN_IN_VENDORS } from "./sign-ins-store.js";
|
|
15
16
|
import { StoreLaunchMissing } from "./store/store.js";
|
|
16
17
|
import { keptVendor } from "./tool-plane.js";
|
|
17
18
|
/** The run's launch body read back, or undefined when it has none (an old run, or one not started with one). */
|
|
@@ -148,8 +149,6 @@ export function cutHanded(value, values) {
|
|
|
148
149
|
};
|
|
149
150
|
return walk(value);
|
|
150
151
|
}
|
|
151
|
-
/** The browser vendors that keep a sign-in (sign-ins-store.ts vendorOf). */
|
|
152
|
-
const SIGN_IN_VENDORS = ["browserbase", "kernel"];
|
|
153
152
|
/** Why what an agent learned is withheld (403): a pointer of its sign-in can't be read here, so the cut would be shorter
|
|
154
153
|
* than what a note may hold. */
|
|
155
154
|
export const WITHHELD_LEARNING = "This server can't read the agent's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so what it learned is not shown.";
|
package/dist/harness-check.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export interface HarnessCheckOptions {
|
|
|
12
12
|
/** The most the check may spend, USD. */
|
|
13
13
|
capUsd?: number;
|
|
14
14
|
platform?: string;
|
|
15
|
-
/** For tests: the
|
|
15
|
+
/** For tests: the network the model proxy forwards to, under the check's recorder. A model the route translates goes
|
|
16
|
+
* through the route's own fetch instead, as on a server. */
|
|
16
17
|
fetch?: typeof fetch;
|
|
17
18
|
/** Each step as it happens, a line of words. */
|
|
18
19
|
say?: (line: string) => void;
|
package/dist/harness-check.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
// provider sees only the turns' Messages requests; anything it reaches for beyond loopback goes to the check's own
|
|
9
9
|
// proxy, which refuses and lists it).
|
|
10
10
|
// Stage 3, live: the agent is killed (SIGKILL) after a turn and the next turn resumes it (its own session/load, or a
|
|
11
|
-
// fresh session told the conversation), a denied call never runs, one of our tools runs over MCP
|
|
12
|
-
//
|
|
11
|
+
// fresh session told the conversation), a denied call never runs, one of our tools runs over MCP without the agent
|
|
12
|
+
// asking permission for it (unless its recipe declares the title tie), and another runner with its own directory
|
|
13
|
+
// picks the session up from the records.
|
|
13
14
|
// It prints the three facts a harness row carries: resume (load | restart), tool_gate (permission | config: whether the
|
|
14
15
|
// agent asks before a tool call) and billing (proxy | plan).
|
|
15
16
|
// The check spends: four short turns on the run's model, under a cap (default $0.25).
|
|
@@ -179,25 +180,44 @@ async function checkRun(options, held) {
|
|
|
179
180
|
return refuse("HARNESS_CHECK_USAGE", `${recipe.label} is billed through the proxy: name the run's model with --model provider/model-id (openrouter/anthropic/claude-haiku-4.5, anthropic/claude-haiku-4-5)`);
|
|
180
181
|
needs = { model: ref, models: await providerModels(env) };
|
|
181
182
|
}
|
|
182
|
-
// The session: the check's tools, its gate, its egress proxy,
|
|
183
|
+
// The session: the check's tools, its gate, its egress proxy, its recorder.
|
|
183
184
|
const nonce = randomBytes(6).toString("hex");
|
|
184
185
|
const echoed = [];
|
|
185
186
|
const deniedRan = [];
|
|
186
187
|
const tools = [
|
|
187
|
-
|
|
188
|
+
// A path beside the text: Goose 1.59.2 titles a call whose arguments hold one with a summary of it (` · proof.txt`), so
|
|
189
|
+
// each release's title form for such a call runs here, and the adapter ties nothing to it.
|
|
190
|
+
{ name: "check_echo", description: "Echo the text back, prefixed with ECHO.", inputSchema: { type: "object", properties: { text: { type: "string" }, path: { type: "string", description: "A file name to echo beside it." } }, required: ["text"] }, replay: "never", call: async (args) => (echoed.push(args), { text: `ECHO:${args?.text ?? ""}` }) },
|
|
188
191
|
{ name: "check_denied", description: "A tool this run refuses: calling it shows the refusal.", inputSchema: { type: "object", properties: { text: { type: "string" } }, required: ["text"] }, replay: "never", call: async (args) => (deniedRan.push(args), { text: "this call should never have run" }) },
|
|
189
192
|
];
|
|
190
193
|
// The gate allows check_echo alone. Everything else is denied, the agent's own calls (`acp_<kind>`) included, as a
|
|
191
|
-
// server's gate answers them: a call of ours
|
|
194
|
+
// server's gate answers them: a permission request for a call of ours, on a recipe with no title tie or one whose title
|
|
195
|
+
// the adapter can't tie, is one of those: refused, so mcp_tool fails (on calls 0, or on ourAsks where the agent runs it
|
|
196
|
+
// anyway), and the row counts it in ourAsks either way.
|
|
192
197
|
const gateAsked = [];
|
|
198
|
+
// The ids of check_echo's MCP calls, as the gate got them: the agent's announced toolCallId where the adapter matched
|
|
199
|
+
// the call to one. A permission request under one of these ids was for our tool.
|
|
200
|
+
const echoIds = new Set();
|
|
201
|
+
// The agent's toolCallIds (the gate call's args carry each) of the permission requests (`acp_<kind>`) whose input's
|
|
202
|
+
// `text` is the nonce, as check_echo's text argument is: requests for our tool by its arguments, as the adapter
|
|
203
|
+
// matches a call to its MCP call (CallIds), never by a title. The nonce is new for each check. Its `text` field and not
|
|
204
|
+
// anywhere in the input: an agent may write the nonce into proof.txt with an editor of its own (Goose's
|
|
205
|
+
// developer__text_editor, `file_text`), and Goose asks with kind "other" for every call, so the kind can't tell the
|
|
206
|
+
// two apart. This catches a request the gate refused and the agent never ran, which no check_echo id ever names.
|
|
207
|
+
const nonceToolCallIds = new Set();
|
|
193
208
|
const gate = async (call) => {
|
|
194
209
|
const answer = call.tool === "check_echo" ? "allow" : "deny";
|
|
210
|
+
if (call.tool === "check_echo")
|
|
211
|
+
echoIds.add(call.callId);
|
|
212
|
+
else if (call.tool.startsWith("acp_") && call.args?.input?.text === nonce && typeof call.args?.toolCallId === "string")
|
|
213
|
+
nonceToolCallIds.add(call.args.toolCallId);
|
|
195
214
|
gateAsked.push({ tool: call.tool, answer });
|
|
196
215
|
return answer === "allow" ? "allow" : { deny: "harness-check refuses this call on purpose" };
|
|
197
216
|
};
|
|
198
217
|
const forwarded = [];
|
|
199
|
-
|
|
200
|
-
|
|
218
|
+
// The recorder wraps the hop the proxy forwards with: the route's own fetch for a model it translates (an Ollama
|
|
219
|
+
// model), else the network (options.fetch in tests). So a check on such a model runs the route a server's run takes.
|
|
220
|
+
const record = (next) => async (input, init) => {
|
|
201
221
|
const url = new URL(typeof input === "string" ? input : input instanceof URL ? input.href : input.url);
|
|
202
222
|
const text = bodyText(init?.body);
|
|
203
223
|
let toolNames = [];
|
|
@@ -209,7 +229,7 @@ async function checkRun(options, held) {
|
|
|
209
229
|
// Not JSON: no tools.
|
|
210
230
|
}
|
|
211
231
|
forwarded.push({ method: init?.method ?? "GET", path: url.pathname, tools: toolNames, text });
|
|
212
|
-
return
|
|
232
|
+
return (next ?? options.fetch ?? fetch)(input, init);
|
|
213
233
|
};
|
|
214
234
|
const logs = [];
|
|
215
235
|
const log = (message, fields) => void logs.push({ message, ...(fields ?? {}) });
|
|
@@ -239,8 +259,8 @@ async function checkRun(options, held) {
|
|
|
239
259
|
starts += 1;
|
|
240
260
|
};
|
|
241
261
|
// The recipe's entry as a server builds it (harness-recipe-entry.ts), on this check's route, log, variables (its egress
|
|
242
|
-
// proxy) and
|
|
243
|
-
const entry = recipeEntryOf({ recipe, binary, release, route: () => route, beforeStart, vars: () => childVars,
|
|
262
|
+
// proxy) and recorder.
|
|
263
|
+
const entry = recipeEntryOf({ recipe, binary, release, route: () => route, beforeStart, vars: () => childVars, record, log });
|
|
244
264
|
const planNeeds = { model: { provider: recipe.id, modelId: planModel ?? "default" }, models: { getModel: () => undefined } };
|
|
245
265
|
const adapterFor = async () => entry.adapter(hostEnv, needs ?? planNeeds);
|
|
246
266
|
// The first runner's adapter is made before any turn, so a model this server can't run is refused before the agent
|
|
@@ -304,12 +324,25 @@ async function checkRun(options, held) {
|
|
|
304
324
|
// Turn 1: one of our tools over MCP.
|
|
305
325
|
say(`${recipe.label}: turn 1, a call of our check_echo tool over MCP`);
|
|
306
326
|
const first = await sessionOn(join(work, "runner-a"));
|
|
307
|
-
const t1 = await first.turn(`Use the check_echo tool once, with the text argument set to ${nonce}. Then reply with exactly what it returned and nothing else.`);
|
|
327
|
+
const t1 = await first.turn(`Use the check_echo tool once, with the text argument set to ${nonce} and the path argument set to proof.txt. Then reply with exactly what it returned and nothing else.`);
|
|
328
|
+
// The permissions the agent asked for in turn 1 (permissionAsks), and of those the ones for our tool (ourAsks), each
|
|
329
|
+
// counted once: a request whose toolCallId is the id a check_echo MCP call reached the gate under, or one whose gate
|
|
330
|
+
// question's input carried check_echo's nonce as its text (nonceToolCallIds, by the toolCallId its args carry).
|
|
331
|
+
// Matched by id and arguments, never by title. The adapter answers a request for our tool only where
|
|
332
|
+
// the recipe declares the title tie (quirks.permissionTie, Cursor's); any other agent must ask nothing for our tools
|
|
333
|
+
// (an allowFile, Goose's), since the server's gate asks at the MCP call. Any other request is the agent's own call:
|
|
334
|
+
// the gate denied it and lists it (gate.permissionsAsked), and it fails no stage.
|
|
335
|
+
const turnAsks = asked();
|
|
336
|
+
const permissionAsks = turnAsks.length;
|
|
337
|
+
const ourIds = new Set([...echoIds, ...nonceToolCallIds]);
|
|
338
|
+
const ourAsks = turnAsks.filter((l) => typeof l.toolCallId === "string" && ourIds.has(l.toolCallId)).length;
|
|
339
|
+
const tied = recipe.quirks.permissionTie === "title";
|
|
340
|
+
const askedProblem = ourAsks > 0 && !tied ? `the agent asked permission for our tool ${ourAsks} time(s) (a request under the id of a check_echo call, or with check_echo's arguments): its recipe needs an allowFile in the form the agent reads, so it runs our tools unasked, or the title tie (quirks.permissionTie) when the agent asks for every MCP call whatever its config says` : undefined;
|
|
308
341
|
const firstOpen = opened()[0];
|
|
309
342
|
// The environment while the agent runs.
|
|
310
343
|
const environ = firstOpen?.pid ? environOf(firstOpen.pid) : undefined;
|
|
311
344
|
const echoReached = messages().some((r) => r.text.includes(`ECHO:${nonce}`));
|
|
312
|
-
stage3.mcp_tool = { ok: t1.status === "completed" && echoed.length >= 1 && (recipe.model.billing !== "proxy" || echoReached), turn: t1.status, ...(t1.error ? { error: t1.error } : {}), calls: echoed.length, resultReachedModel: recipe.model.billing === "proxy" ? echoReached : null };
|
|
345
|
+
stage3.mcp_tool = { ok: t1.status === "completed" && echoed.length >= 1 && (recipe.model.billing !== "proxy" || echoReached) && !askedProblem, turn: t1.status, ...(t1.error ? { error: t1.error } : {}), calls: echoed.length, resultReachedModel: recipe.model.billing === "proxy" ? echoReached : null, permissionAsks, ourAsks, ...(askedProblem ? { problem: askedProblem } : {}) };
|
|
313
346
|
// Stage 2: the tools the agent offered its model on its first request. The proxy refuses a request that offers a tool
|
|
314
347
|
// its policy does not allow, so one that reached the provider at all passed that rule: the stage is whether one did.
|
|
315
348
|
// Its refusals are listed beside it, never counted: a port watcher's GET / is refused too.
|