@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/runner/promotion.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// serves first only when its digest is promoted (learn/promote.ts). Promote once: a digest with no record yet, the learning
|
|
3
3
|
// folder's newest revision, is checked once (startCheck): a replay run of it (RunLaunch.replay, at workflow cost) on the
|
|
4
4
|
// input of each of the agent's last compile_after completed runs of its own (its definition's `learning`,
|
|
5
|
-
// learning-setting.ts), the agent taking the runs meanwhile. A later claim that finds every check run ended
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
5
|
+
// learning-setting.ts), the agent taking the runs meanwhile. A later claim that finds every check run ended judges each
|
|
6
|
+
// field (agree_on's, else the whole answer) against its best known answer, the agent run's grade's expected answer, else
|
|
7
|
+
// the agent's own recorded answer (learn/field-check.ts check), and promotes the digest when, of the inputs it ran on, it
|
|
8
|
+
// answered at least alone_min alone and every field passes; else it is held, its record naming the failing fields and
|
|
9
|
+
// keeping the inputs it disagreed on, which the agent's next run's compile
|
|
9
10
|
// turn reads to write its one recompile (learn/compile.ts); that revision is checked the same way, once, and a hold of
|
|
10
11
|
// it stops (nothing compiles again). A check-promoted digest is never checked again: no grade, no refit, no queue, no
|
|
11
12
|
// second replay. Every reserved input counts: one whose replay run was never created, or never ended, by the check's
|
|
@@ -55,7 +56,8 @@ import { pinAnnotations, recordedCalls, replayCalls, SKIPPED_WRITE, toolClassOf,
|
|
|
55
56
|
import { listed } from "../learning-words.js";
|
|
56
57
|
import { isObject } from "../validate.js";
|
|
57
58
|
import { agentRun, lastOwnRuns, newCompileAttempt, sinceReset } from "../learn/compile.js";
|
|
58
|
-
import {
|
|
59
|
+
import { answerAt, answerValue, checkShares, CHECK_TEXT_MAX, championOf, compareAnswers, comparedGrade, comparedOf, gradesOf, knownAnswerText, promotionOf, promotionsOf, recordPromotion, replayingOf, sameAnswer, skippedToolsOf, valueAtPath } from "../learn/promote.js";
|
|
60
|
+
import { check as checkFields, jointSaid, KNOWN, tallyOf } from "../learn/field-check.js";
|
|
59
61
|
import { refusedIn } from "../purged-workflow.js";
|
|
60
62
|
import { sendCommand } from "./commands.js";
|
|
61
63
|
import { ClaimRefused } from "./loop-contract.js";
|
|
@@ -121,17 +123,18 @@ export function replayLaid(launch, laid) {
|
|
|
121
123
|
return laid.filter((one) => one.name !== workflow || workflowDigest(one) === digest);
|
|
122
124
|
}
|
|
123
125
|
/** The learned workflows a run's learned_workflow tool runs, once its first choice is made: what serves, never a
|
|
124
|
-
* revision its promotion has not promoted. The one its first choice served
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
126
|
+
* revision its promotion has not promoted. The one its first choice served (laidFor: its champion in place of the laid
|
|
127
|
+
* revision) as chosen; any other the records name, its champion (championOf: the laid text when that is the champion,
|
|
128
|
+
* else its text at its record's commit), and none while nothing of it serves (none promoted yet, or the champion
|
|
129
|
+
* held): a revision replaying, held or never decided is never handed to the agent to run in its place. One the records
|
|
130
|
+
* never named is an unchecked draft and is not offered. A replay run's as laid (replayLaid). The records unread: only
|
|
131
|
+
* the one served first, as the gate leaves a run to its agent. The money rule over what this hands the tool, the one
|
|
132
|
+
* its first choice stopped included, is runner/learned-first.ts's (workflow-first.ts toolStopsOf). */
|
|
130
133
|
export async function toolFlowsFor(deps, launch, laid, choice) {
|
|
131
134
|
const chosen = laidFor(laid, choice);
|
|
132
135
|
if (launch.replay || !chosen.length)
|
|
133
136
|
return chosen;
|
|
134
|
-
const name = choice.serve?.name
|
|
137
|
+
const name = choice.serve?.name;
|
|
135
138
|
let records;
|
|
136
139
|
try {
|
|
137
140
|
records = await promotionsOf(deps.store.settings, deps.agentId);
|
|
@@ -443,7 +446,7 @@ export const differentDecisionWords = (k, n, example) => `its answers reached a
|
|
|
443
446
|
* or its owner acts, and `extra` on the record (a connected agent's check: what its reservation carries). Kept only while
|
|
444
447
|
* `still` holds of the digest's record (the one write), and logged. */
|
|
445
448
|
async function holdUnchecked(deps, name, digest, bar, reason, still, { stopped = false, check = {}, extra = {} } = {}) {
|
|
446
|
-
const decided = await recordPromotion(deps.store.settings, deps.agentId, { workflow: name, digest, at: iso((deps.now ?? Date.now)()), decided: "hold", reason, check: { ...bar, n: 0, agreed: 0, alone: 0, of: [], ...check, ...(stopped ? { stopped: true } : {}) }, ...seedOf(deps), ...extra }, still, deps.refused);
|
|
449
|
+
const decided = await recordPromotion(deps.store.settings, deps.agentId, { workflow: name, digest, at: iso((deps.now ?? Date.now)()), decided: "hold", reason, check: { ...bar, n: 0, agreed: 0, alone: 0, agent_agreed: 0, of: [], ...check, ...(stopped ? { stopped: true } : {}) }, ...seedOf(deps), ...extra }, still, deps.refused);
|
|
447
450
|
if (decided.won)
|
|
448
451
|
deps.log(`workflow-first: ${name} at ${digest} ${stopped ? "stopped" : "held"}: ${reason}`);
|
|
449
452
|
return decided;
|
|
@@ -454,6 +457,46 @@ async function holdUnchecked(deps, name, digest, bar, reason, still, { stopped =
|
|
|
454
457
|
* would have nothing to be checked on either, and a stop with nothing checked never counts as a compile's first check
|
|
455
458
|
* (attemptOf). */
|
|
456
459
|
const stopUnchecked = (deps, name, digest, bar, why, still, check = {}, extra = {}) => holdUnchecked(deps, name, digest, bar, `${NOTHING_TO_CHECK}: ${why}. It is not promoted, and it stops: nothing compiles again until a hold or its owner acts`, still, { stopped: true, check, extra });
|
|
460
|
+
/** The field a check judges a whole answer as, with no agree_on. */
|
|
461
|
+
export const WHOLE_ANSWER = "answer";
|
|
462
|
+
/** A check row as learn/field-check.ts judges it, the one comparison a check and an audit make: an input answered alone
|
|
463
|
+
* with one field per agree_on path (the draft's, the agent's and the grade's value there, compared as values: a path
|
|
464
|
+
* that does not resolve on a side is never right), else one field, the whole answer (`answer`), right as compareAnswers
|
|
465
|
+
* says (`compared`, answered with it: equal, or the same decision by the grader's verdict its run kept) against its
|
|
466
|
+
* best known answer: a grade's expected answer written over the agent's (learn/promote.ts knownAnswerText), the grade
|
|
467
|
+
* saying whether the agent's was right; else the agent's answer, known wrong when a grade with no expected answer said
|
|
468
|
+
* so. The field's `grade` is the grade's own expected answer, the part its owner gave, which a disagreement shows the
|
|
469
|
+
* recompile (and a purge blanks). Field names are never taken from a grade: its keys are a person's data, which a
|
|
470
|
+
* run's purge must leave nowhere. Under agree_on a grade that said the answer was wrong, with no expected answer, names
|
|
471
|
+
* no field, so it changes nothing there. */
|
|
472
|
+
function checkInputOf(row, on) {
|
|
473
|
+
const outcome = row.outcome === "skipped_write" ? "skipped" : row.outcome;
|
|
474
|
+
if (outcome !== "answered")
|
|
475
|
+
return { input: { input_id: row.of, outcome } };
|
|
476
|
+
if (on?.length) {
|
|
477
|
+
return { input: { input_id: row.of, outcome, fields: Object.fromEntries(on.map((path) => {
|
|
478
|
+
const grade = row.expected ? valueAtPath(row.expected, path) : undefined;
|
|
479
|
+
return [path, { workflow: answerAt(row.answer, path), agent: answerAt(row.agent, path), ...(grade !== undefined ? { grade } : {}) }];
|
|
480
|
+
})) } };
|
|
481
|
+
}
|
|
482
|
+
// A grade that marked the agent's answer wrong, yet whose expected answer written over it is that answer, contradicts
|
|
483
|
+
// itself: no known answer there, neither right nor wrong (unjudged).
|
|
484
|
+
const contradicts = row.correct === false && row.expected !== undefined && row.agent !== null && sameAnswer(knownAnswerText(row.agent, row.expected), row.agent);
|
|
485
|
+
const graded = contradicts ? { no_known: true } : row.expected ? { grade: row.expected, ...(row.correct !== undefined ? { agent_correct: row.correct } : {}) } : row.correct === false ? { agent_correct: false } : {};
|
|
486
|
+
const compared = compareAnswers(row.answer, row.expected ? knownAnswerText(row.agent, row.expected) : row.agent, row.compared);
|
|
487
|
+
// The answers as sameAnswer reads them, so a draft that says the agent's answer in another dress repeats it.
|
|
488
|
+
return { input: { input_id: row.of, outcome, fields: { [WHOLE_ANSWER]: { workflow: answerValue(row.answer), agent: answerValue(row.agent), agrees: compared.same, ...graded } } }, compared };
|
|
489
|
+
}
|
|
490
|
+
/** One answer judged as the check judges an input it answered alone (checkInputOf, learn/field-check.ts): `answer`
|
|
491
|
+
* against its known answer, a grade's expected answer (`expected`, written over `agent`'s, whose rightness `correct`
|
|
492
|
+
* says) where one exists, else `agent`'s. True: right on every field. False: wrong on one. Null: a field had no known
|
|
493
|
+
* answer and none was wrong (a grade that contradicts itself). The audit's one verdict (runner/audit.ts). */
|
|
494
|
+
export function answerJudged(row, on) {
|
|
495
|
+
const { agreed, fields } = tallyOf([checkInputOf({ of: "", input: "", outcome: "answered", ...row }, on).input]);
|
|
496
|
+
if (agreed)
|
|
497
|
+
return true;
|
|
498
|
+
return Object.values(fields).some((by) => KNOWN.some((known) => (by[known]?.workflow_right ?? 0) < (by[known]?.n ?? 0))) ? false : null;
|
|
499
|
+
}
|
|
457
500
|
/** Decides `ahead`, the check at work for a revision older than the laid (newest) one, as a claim laying it would
|
|
458
501
|
* (relaunch, then settleCheck) once its runs ended: its text read at its record's commit, its verdict standing (promote
|
|
459
502
|
* or hold) though a newer revision waits. Left replaying while a run of it is at work, or when its text cannot be read
|
|
@@ -471,14 +514,19 @@ async function settleAhead(deps, name, ahead) {
|
|
|
471
514
|
* created yet. One row per reserved input, so every one counts: a run not ended by the deadline failed, and so did one
|
|
472
515
|
* never created by then (`unstarted`: the server stopped after reserving it, say), its input read from the agent's run
|
|
473
516
|
* the record names for it. With what its runs cost, the rows' outcomes (one per row, the never created failed), and how
|
|
474
|
-
* many were never created by the deadline.
|
|
475
|
-
*
|
|
517
|
+
* many were never created by the deadline. Each row carries its agent run's newest grade's expected answer (when not
|
|
518
|
+
* empty) and whether it was right (CheckRow.expected, correct). */
|
|
476
519
|
async function checkRows(deps, record) {
|
|
477
520
|
const { store, context } = deps;
|
|
478
521
|
const runs = await Promise.all((record.runs ?? []).map((id) => store.runs.get(id)));
|
|
479
522
|
const late = (deps.now ?? Date.now)() - Date.parse(record.at) > REPLAY_DEADLINE_MS;
|
|
480
523
|
if (!late && runs.some((row) => !row || !FINAL_STATES.includes(row.state)))
|
|
481
524
|
return undefined;
|
|
525
|
+
// The newest grade of each run (gradesOf keeps them oldest first): a re-grade replaces what an earlier one said.
|
|
526
|
+
const grades = new Map((await gradesOf(store.settings, deps.agentId)).map((grade) => [grade.run, grade]));
|
|
527
|
+
// An input whose grader was asked is judged on the grade it was asked against (Compared.graded): a grade given after
|
|
528
|
+
// that is not the pair's, so it counts from the next check, never makes this verdict stale.
|
|
529
|
+
const graded = (of, compared) => (compared?.graded !== undefined ? compared.graded : comparedGrade(grades.get(of))) ?? {};
|
|
482
530
|
const rows = [];
|
|
483
531
|
for (const [i, run] of runs.entries()) {
|
|
484
532
|
const reservedOf = record.inputs?.[i];
|
|
@@ -501,6 +549,7 @@ async function checkRows(deps, record) {
|
|
|
501
549
|
answer: outcome === "answered" ? await answerOf(store, run.id, context) : null,
|
|
502
550
|
...(outcome === "handed_back" ? { escalated: (await handedBackOf(store, run.id, context)) ?? "" } : {}),
|
|
503
551
|
...(stoppedAt ? { skipped: stoppedAt } : {}),
|
|
552
|
+
...graded(replayed, compared),
|
|
504
553
|
});
|
|
505
554
|
}
|
|
506
555
|
// The outcomes are the rows', so they add up to its n: a reserved run never created is a failed input there too.
|
|
@@ -536,46 +585,66 @@ async function settleCheck(deps, workflow, digest, record) {
|
|
|
536
585
|
}
|
|
537
586
|
return decided.record?.decided === "replaying" ? undefined : decided.record;
|
|
538
587
|
}
|
|
539
|
-
/** A check's rows
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
|
|
545
|
-
async function scoreRows(deps, bar, rows, before) {
|
|
588
|
+
/** A check's rows judged field by field (learn/field-check.ts check) on its bar, added to `before` (a connected agent's
|
|
589
|
+
* turns checked so far): each field of agree_on, else the whole answer (checkInputOf), against its best known answer;
|
|
590
|
+
* the inputs it did not agree on (not answered alone, or a field wrong), each naming the fields it had wrong, each text
|
|
591
|
+
* cut of the host's secrets whole, then shortened (learn/secrets.ts excerptShown); and the fast model that compared,
|
|
592
|
+
* when it read any input's answers. */
|
|
593
|
+
async function judgeRows(deps, bar, rows, before) {
|
|
546
594
|
const ran = rows.filter((row) => row.outcome !== "skipped_write");
|
|
547
|
-
|
|
548
|
-
//
|
|
549
|
-
//
|
|
550
|
-
const
|
|
551
|
-
const
|
|
552
|
-
const
|
|
553
|
-
const
|
|
595
|
+
// With no agree_on, the draft's answer is compared whole with its known answer: equal, else the grader's verdict on
|
|
596
|
+
// that pair, which its replay run asked (with no grader, no fast model, they differ). Under agree_on, fields and
|
|
597
|
+
// grades are compared as values (checkInputOf).
|
|
598
|
+
const on = bar.agree_on?.length ? bar.agree_on : undefined;
|
|
599
|
+
const judged = new Map(rows.map((row) => [row, checkInputOf(row, on)]));
|
|
600
|
+
const verdict = checkFields([...judged.values()].map((one) => one.input), bar, before);
|
|
601
|
+
const missed = new Map();
|
|
602
|
+
for (const miss of verdict.misses)
|
|
603
|
+
missed.set(miss.input_id, [...(missed.get(miss.input_id) ?? []), miss.field]);
|
|
604
|
+
const grader = [...judged.values()].find((one) => one.compared?.grader !== undefined)?.compared?.grader;
|
|
554
605
|
const shown = await deps.shown();
|
|
555
606
|
const cut = (text) => excerptShown(text, shown, CHECK_TEXT_MAX);
|
|
556
|
-
|
|
557
|
-
|
|
607
|
+
// The known answers (a grade's) each input's draft missed, for the recompile: never the agent's own (shown);
|
|
608
|
+
// where a grade marked the agent's answer wrong without the right one ("unknown") or contradicts itself
|
|
609
|
+
// ("contradicts"), that it did, no value made up.
|
|
610
|
+
const known = new Map();
|
|
611
|
+
for (const miss of verdict.misses) {
|
|
612
|
+
if (miss.known === "agent")
|
|
613
|
+
continue;
|
|
614
|
+
const value = miss.known !== "grade" ? undefined : cut(typeof miss.expected === "string" ? miss.expected : JSON.stringify(miss.expected) ?? "");
|
|
615
|
+
known.set(miss.input_id, [...(known.get(miss.input_id) ?? []), { field: miss.field, known: miss.known, ...(value !== undefined ? { value } : {}) }]);
|
|
616
|
+
}
|
|
617
|
+
const disagreements = [...(before?.disagreements ?? []), ...ran.filter((row) => row.outcome !== "answered" || missed.has(row.of)).map((row) => {
|
|
618
|
+
const differs = judged.get(row).compared?.differs_on;
|
|
619
|
+
const fields = row.outcome === "answered" ? missed.get(row.of) : undefined;
|
|
620
|
+
const expected = row.outcome === "answered" ? known.get(row.of) : undefined;
|
|
558
621
|
return {
|
|
559
622
|
run: row.of, input: cut(row.input), agent: row.agent === null ? null : cut(row.agent),
|
|
560
623
|
...(row.outcome === "answered" ? { draft: cut(row.answer ?? "") } : row.outcome === "handed_back" ? { escalated: cut(row.escalated ?? "") } : { failed: true }),
|
|
561
624
|
...(differs ? { differs_on: cut(differs) } : {}),
|
|
625
|
+
...(fields ? { fields } : {}),
|
|
626
|
+
...(expected ? { expected } : {}),
|
|
562
627
|
};
|
|
563
628
|
})];
|
|
564
|
-
return {
|
|
629
|
+
return { verdict, disagreements, grader };
|
|
565
630
|
}
|
|
566
631
|
/** Two outcome counts added. */
|
|
567
632
|
const outcomesAdded = (a, b) => b ? { answered: a.answered + b.answered, handed_back: a.handed_back + b.handed_back, failed: a.failed + b.failed, skipped_write: a.skipped_write + b.skipped_write } : a;
|
|
568
|
-
/** Decides a check on its rows, with a connected agent's turns checked before them (`before`),
|
|
569
|
-
* (
|
|
570
|
-
* (`refused`: else held, a purged run's text); else held
|
|
571
|
-
* agent's next run's compile turn reads as data (its one
|
|
572
|
-
* nothing compiles again. No
|
|
573
|
-
* (the one write: of two claims at once, one decides). */
|
|
633
|
+
/** Decides a check on its rows, with a connected agent's turns checked before them (`before`), judged field by field on
|
|
634
|
+
* its bar (judgeRows). Promoted when it serves (learn/field-check.ts: enough answered alone, every field passes) and the
|
|
635
|
+
* purge gate lets its revision through at its commit (`refused`: else held, a purged run's text); else held on its
|
|
636
|
+
* failing fields with the inputs it did not agree on, which the agent's next run's compile turn reads as data (its one
|
|
637
|
+
* recompile); a recompile's check that holds it too stops: nothing compiles again. No refit, queue or second replay.
|
|
638
|
+
* Kept only while `still` holds of the digest's record (the one write: of two claims at once, one decides). */
|
|
574
639
|
export async function decideCheck(deps, name, digest, bar, read, still, extra) {
|
|
575
640
|
const now = deps.now ?? Date.now;
|
|
576
641
|
const { before } = read;
|
|
577
|
-
const {
|
|
578
|
-
const
|
|
642
|
+
const { verdict, disagreements, grader } = await judgeRows(deps, bar, read.rows, before);
|
|
643
|
+
const { tally, fields, failing, joint } = verdict;
|
|
644
|
+
const score = { n: tally.n, agreed: tally.agreed, alone: tally.alone };
|
|
645
|
+
const fieldCount = Object.keys(fields).length;
|
|
646
|
+
const saysJoint = jointSaid(Object.values(fields).map((one) => one.pass), joint.pass);
|
|
647
|
+
const ok = verdict.verdict === "serve";
|
|
579
648
|
const stopped = !ok && bar.attempt === 2;
|
|
580
649
|
const pct = (value) => `${(value * 100).toFixed(1)}%`;
|
|
581
650
|
const shares = checkShares(score);
|
|
@@ -600,14 +669,17 @@ export async function decideCheck(deps, name, digest, bar, read, still, extra) {
|
|
|
600
669
|
// and the words say none ran.
|
|
601
670
|
const said = read.unstarted === score.n
|
|
602
671
|
? `none of its ${plural(score.n, "check run")} started by the check's deadline (its launch was interrupted: the server stopped after reserving it, say): nothing was checked`
|
|
603
|
-
: `checked on ${score.n} of the agent's inputs: answered ${score.alone} alone (${pct(shares.alone)}, the bar ${pct(bar.alone_min)})
|
|
604
|
-
// The
|
|
605
|
-
// once the same
|
|
606
|
-
|
|
672
|
+
: `checked on ${score.n} of the agent's inputs: answered ${score.alone} alone (${pct(shares.alone)}, the bar ${pct(bar.alone_min)})${Object.keys(fields).length ? `; ${Object.values(fields).map((one) => one.reason).join("; ")}` : ""}${saysJoint ? `; right on every field at once: ${joint.agreed} of ${joint.alone} (${pct(shares.agreement)}, the bar ${pct(bar.agree_min)})` : ""}${grader ? `; compared by the fast model (${grader})` : ""}${aside ? ` (${aside})` : ""}`;
|
|
673
|
+
// The whole answer compared with the agent's: with the grader, how many answered alone reached another decision, with
|
|
674
|
+
// one it named; never once the same and no grader: free text two runs never repeat, most likely, so the owner is told
|
|
675
|
+
// what to set.
|
|
676
|
+
const whole = bar.agree_on?.length ? undefined : fields[WHOLE_ANSWER]?.by.agent;
|
|
677
|
+
const differed = whole ? whole.n - whole.workflow_right : 0;
|
|
607
678
|
const example = disagreements.find((one) => one.differs_on !== undefined)?.differs_on;
|
|
608
|
-
const verbatim = ok ||
|
|
609
|
-
const
|
|
610
|
-
const
|
|
679
|
+
const verbatim = ok || !whole ? "" : grader ? (differed > 0 ? `; ${differentDecisionWords(differed, whole.n, example)}` : "") : whole.workflow_right === 0 ? `; ${read.exactMismatchReason ?? NEVER_WORD_FOR_WORD}` : "";
|
|
680
|
+
const heldOn = `held${failing.length ? ` on ${listed(failing)}` : !joint.pass && fieldCount ? " on its fields together" : ""}${verbatim}`;
|
|
681
|
+
const reason = ok ? `${said}: promoted` : stopped ? `${said}: ${heldOn}, and this was the recompile's check, so it stops: nothing compiles again until a hold or its owner acts` : `${said}: ${heldOn}; the agent's next run recompiles it once with the inputs it did not agree on`;
|
|
682
|
+
const check = { ...bar, ...score, agent_agreed: tally.agent_agreed, joint: joint.pass, ...(fieldCount ? { fields } : {}), ...numbers, ...(disagreements.length ? { disagreements } : {}), ...(stopped ? { stopped: true } : {}), ...(grader ? { grader } : {}) };
|
|
611
683
|
const record = { workflow: name, digest, at: iso(now()), decided: ok ? "promote" : "hold", reason, check, ...seedOf(deps), ...extra };
|
|
612
684
|
// A check that outlives its revision's run: the run's purge never stops it (it replays other runs' inputs), and the
|
|
613
685
|
// purge gate refuses the revision at the commit it was checked at (purged-workflow.ts refusedOf). It is held, never
|
|
@@ -737,9 +809,9 @@ export async function sdkCheckTurn(deps, record, row, still, read = {}) {
|
|
|
737
809
|
deps.log(`workflow-first: ${record.workflow} at ${record.digest} checked a native turn; a newer revision has a record since, so it is left as it is`);
|
|
738
810
|
return;
|
|
739
811
|
}
|
|
740
|
-
const {
|
|
812
|
+
const { verdict: { tally }, disagreements } = await judgeRows(deps, bar, [row], before);
|
|
741
813
|
const fresh = (before?.fresh_reads ?? 0) + (read.fresh_reads ?? 0);
|
|
742
|
-
const turns = {
|
|
814
|
+
const turns = { n: tally.n, agreed: tally.agreed, alone: tally.alone, agent_agreed: tally.agent_agreed, fields: tally.fields, of: [row.of, ...(before?.of ?? [])], outcomes: outcomesAdded(outcomes, before?.outcomes), ...(disagreements.length ? { disagreements } : {}), ...(fresh ? { fresh_reads: fresh } : {}) };
|
|
743
815
|
const check = { ...bar, turns };
|
|
744
816
|
const kept = await waitAgain(deps, record, check, `Waiting for the next native turn of the connected agent that it takes: ${sdkTurnsWords(check)}. Nothing was promoted.`, still);
|
|
745
817
|
if (kept.won)
|
|
@@ -1083,8 +1155,11 @@ async function checkView(ask, record, id, name, digest) {
|
|
|
1083
1155
|
const n = check.n ?? 0;
|
|
1084
1156
|
const handedBack = check.outcomes.handed_back;
|
|
1085
1157
|
const wf = n ? Math.round(((check.agreed ?? 0) + handedBack) / n * 1e4) / 1e4 : 0;
|
|
1158
|
+
// The agent's misses are counted where the workflow's are, on the inputs it answered alone (agent_agreed).
|
|
1159
|
+
const alone = check.alone ?? 0;
|
|
1160
|
+
const agent = n ? Math.round((n - (alone - (check.agent_agreed ?? 0))) / n * 1e4) / 1e4 : 0;
|
|
1086
1161
|
const neverStarted = inputs > 0 && check.unstarted === inputs;
|
|
1087
|
-
return { replay: id, workflow: name, digest, status: neverStarted ? "failed" : "done", inputs, outcomes: check.outcomes, score: { n, agree: check.agreed ?? 0, agent_acc:
|
|
1162
|
+
return { replay: id, workflow: name, digest, status: neverStarted ? "failed" : "done", inputs, outcomes: check.outcomes, score: { n, agree: check.agreed ?? 0, agent_acc: agent, wf_acc: wf, delta: n ? Math.round((wf - agent) * 1e4) / 1e4 : 0, handed_back: handedBack }, cost_usd: check.cost_usd ?? null, decided, reason: record.reason };
|
|
1088
1163
|
}
|
|
1089
1164
|
const runs = await Promise.all((record.runs ?? []).map((run) => ask.store.runs.get(run)));
|
|
1090
1165
|
return { replay: id, workflow: name, digest, status: decided ? "done" : "running", inputs, outcomes: outcomesOf(runs, false), score: NO_SCORE, cost_usd: replayCost(runs, false), ...(decided ? { decided, reason: record.reason } : {}) };
|
package/dist/runner/redact.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ export declare const keepText: Redact;
|
|
|
11
11
|
/** Every secret value `env` holds for the runner: the server's held secrets, the MCP credentials and every key-, token-,
|
|
12
12
|
* secret- or password-named value (secrets.ts hostSecrets), and the value `env` itself gives each launcher name (a
|
|
13
13
|
* runner's key comes in its env, which hostSecrets reads only for names off the launcher's list), with any `extra` a
|
|
14
|
-
* caller holds. One shorter than MIN_SECRET, whitespace aside, matches too much text by
|
|
14
|
+
* caller holds, and each OTLP header value. One shorter than MIN_SECRET, whitespace aside, matches too much text by
|
|
15
|
+
* chance and is left out, an OTLP header value's too (secrets.ts keptSecrets); the tracer's own lines cut a short
|
|
16
|
+
* header value as well (secrets.ts otlpHeaderCut). */
|
|
15
17
|
export declare function runnerSecrets(env: NodeJS.ProcessEnv, extra?: readonly string[]): string[];
|
|
16
18
|
/** The redactor over `values`: each one, in every form, replaced with "[redacted]". With none, text is left as it is. */
|
|
17
19
|
export declare function secretRedactor(values: readonly string[]): Redact;
|
package/dist/runner/redact.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// can take in text (key-refusal.ts redactedAnswer: as written, JSON-escaped, base64, hex and percent-encoded).
|
|
6
6
|
import { heldNumber, redactedAnswer } from "../key-refusal.js";
|
|
7
7
|
import { MIN_SECRET } from "../learn/secrets.js";
|
|
8
|
-
import { hostSecrets, SECRET_NAMES } from "../secrets.js";
|
|
8
|
+
import { hostSecrets, keptSecrets, SECRET_NAMES } from "../secrets.js";
|
|
9
9
|
import { planOf } from "../chatgpt-plan.js";
|
|
10
10
|
/** `cut` answering `heldValues()`, the function defined not enumerable: JSON.stringify and util.inspect of the redactor,
|
|
11
11
|
* or of an object holding it, show no value it holds. */
|
|
@@ -17,10 +17,12 @@ export const keepText = withHeldValues((text) => text, () => []);
|
|
|
17
17
|
/** Every secret value `env` holds for the runner: the server's held secrets, the MCP credentials and every key-, token-,
|
|
18
18
|
* secret- or password-named value (secrets.ts hostSecrets), and the value `env` itself gives each launcher name (a
|
|
19
19
|
* runner's key comes in its env, which hostSecrets reads only for names off the launcher's list), with any `extra` a
|
|
20
|
-
* caller holds. One shorter than MIN_SECRET, whitespace aside, matches too much text by
|
|
20
|
+
* caller holds, and each OTLP header value. One shorter than MIN_SECRET, whitespace aside, matches too much text by
|
|
21
|
+
* chance and is left out, an OTLP header value's too (secrets.ts keptSecrets); the tracer's own lines cut a short
|
|
22
|
+
* header value as well (secrets.ts otlpHeaderCut). */
|
|
21
23
|
export function runnerSecrets(env, extra = []) {
|
|
22
24
|
const own = SECRET_NAMES.map((name) => env[name] ?? "");
|
|
23
|
-
return
|
|
25
|
+
return keptSecrets([...hostSecrets(env), ...own, ...extra], env);
|
|
24
26
|
}
|
|
25
27
|
/** The redactor over `values`: each one, in every form, replaced with "[redacted]". With none, text is left as it is. */
|
|
26
28
|
export function secretRedactor(values) {
|
|
@@ -47,7 +47,7 @@ export function createReflectHook(deps) {
|
|
|
47
47
|
// What the step's model turns cost: the run's spend once it closed less the job's, unknown when either is. Kept with
|
|
48
48
|
// every end once a compile turn was asked; 0 for an end that asked none. The step's only model turn is its compile
|
|
49
49
|
// turn, so this is the compile's spend: it joins the revision it drafts, or the bill's unattributed when it kept no
|
|
50
|
-
// draft (
|
|
50
|
+
// draft (learn/ledger.ts record and summarize), never the run's own.
|
|
51
51
|
let asked = begun;
|
|
52
52
|
const spent = async () => {
|
|
53
53
|
if (!asked)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
type Json = Record<string, unknown>;
|
|
2
|
+
/** A request this translation does not take: answered 400 with `message`, in OpenAI's error shape. */
|
|
3
|
+
export declare class ResponsesRefusal extends Error {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A Responses request as one Messages request (see the head of this file). `reasons`: whether the model reasons, so a
|
|
7
|
+
* `reasoning.effort` reaches it as the Messages translation's named level; a model that does not is asked none.
|
|
8
|
+
* Returns the Messages body and what it asks Ollama past it (EdgeAsks). Throws a ResponsesRefusal for what it does not take.
|
|
9
|
+
*/
|
|
10
|
+
export declare function messagesOfResponses(body: Json, reasons: boolean): {
|
|
11
|
+
request: Json;
|
|
12
|
+
asks: EdgeAsks;
|
|
13
|
+
};
|
|
14
|
+
/** What this edge asks an Ollama model past the Messages body: the JSON schema its answer is held to (Ollama's `format`),
|
|
15
|
+
* its temperature and top_p, and no thinking (effort "none"). Handed to the route's Messages fetch on the in-process
|
|
16
|
+
* call's init (`edgeAsks`; model-route.ts messagesFetch reads it on an Ollama model alone), never in the body, so the
|
|
17
|
+
* Messages body a Messages client sends is never rewritten. That client's output schema rides the same field
|
|
18
|
+
* (model-route.ts forMessagesClients); its own temperature, top_p and thinking reach Ollama as before, not at all. */
|
|
19
|
+
export type EdgeAsks = {
|
|
20
|
+
format?: Json;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
top_p?: number;
|
|
23
|
+
think?: false;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A fetch that answers OpenAI Responses requests through `messages` (a Messages fetch: the route's own translation,
|
|
27
|
+
* model-route.ts messagesFetch). `reasons`: whether the model reasons (messagesOfResponses). A request it does not take
|
|
28
|
+
* is answered 400 and never reaches `messages`. `warn`: where a line on what the edge did to an answer goes (the calls
|
|
29
|
+
* parallel_tool_calls false kept from the client, by count and tool name, never their arguments); stderr by default,
|
|
30
|
+
* which the run's own log keeps.
|
|
31
|
+
*/
|
|
32
|
+
export declare function responsesFetch(messages: typeof fetch, { reasons, warn }?: {
|
|
33
|
+
reasons?: boolean;
|
|
34
|
+
warn?: (line: string) => void;
|
|
35
|
+
}): typeof fetch;
|
|
36
|
+
export {};
|