modelrig 0.8.1 → 0.10.0
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 +324 -0
- package/README.md +55 -29
- package/data/PROVENANCE.md +14 -0
- package/data/pricing-map.json +26 -0
- package/dist/adapters/attempt-meta-map.d.ts +8 -1
- package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
- package/dist/adapters/attempt-meta-map.js +4 -0
- package/dist/adapters/build-adapters.js +2 -2
- package/dist/adapters/gemini.d.ts +28 -1
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +38 -9
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +53 -4
- package/dist/adapters/openai-compat.d.ts +8 -2
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +8 -1
- package/dist/adapters/openai-stream.d.ts +10 -2
- package/dist/adapters/openai-stream.d.ts.map +1 -1
- package/dist/adapters/openai-stream.js +5 -1
- package/dist/adapters/openai.d.ts +10 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +57 -7
- package/dist/adapters/responses-api.d.ts +61 -0
- package/dist/adapters/responses-api.d.ts.map +1 -0
- package/dist/adapters/responses-api.js +124 -0
- package/dist/artifacts/artifact.d.ts +31 -12
- package/dist/artifacts/artifact.d.ts.map +1 -1
- package/dist/artifacts/artifact.js +218 -188
- package/dist/artifacts/index.d.ts +15 -5
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +19 -5
- package/dist/artifacts/run-context.d.ts +3 -24
- package/dist/artifacts/run-context.d.ts.map +1 -1
- package/dist/artifacts/run-context.js +3 -39
- package/dist/bakeoff/engine.d.ts +29 -0
- package/dist/bakeoff/engine.d.ts.map +1 -1
- package/dist/bakeoff/engine.js +47 -0
- package/dist/bakeoff/eval-cases-rig.d.ts +36 -0
- package/dist/bakeoff/eval-cases-rig.d.ts.map +1 -0
- package/dist/bakeoff/eval-cases-rig.js +27 -0
- package/dist/bakeoff/eval-cases.d.ts +19 -0
- package/dist/bakeoff/eval-cases.d.ts.map +1 -1
- package/dist/bakeoff/eval-cases.js +18 -1
- package/dist/bakeoff/golden-judge.d.ts +47 -0
- package/dist/bakeoff/golden-judge.d.ts.map +1 -0
- package/dist/bakeoff/golden-judge.js +49 -0
- package/dist/bakeoff/groundedness.d.ts +58 -0
- package/dist/bakeoff/groundedness.d.ts.map +1 -0
- package/dist/bakeoff/groundedness.js +165 -0
- package/dist/bakeoff/quality.d.ts +43 -0
- package/dist/bakeoff/quality.d.ts.map +1 -1
- package/dist/bakeoff/quality.js +31 -0
- package/dist/bakeoff/replay.d.ts +11 -0
- package/dist/bakeoff/replay.d.ts.map +1 -1
- package/dist/bakeoff/replay.js +12 -0
- package/dist/bakeoff/report.d.ts +7 -0
- package/dist/bakeoff/report.d.ts.map +1 -1
- package/dist/bakeoff/report.js +26 -0
- package/dist/cli-judge.d.ts +12 -0
- package/dist/cli-judge.d.ts.map +1 -0
- package/dist/cli-judge.js +48 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +22 -42
- package/dist/config.d.ts +85 -29
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +109 -47
- package/dist/detect/detector.d.ts +4 -2
- package/dist/detect/detector.d.ts.map +1 -1
- package/dist/detect/safe-harbor.d.ts +57 -0
- package/dist/detect/safe-harbor.d.ts.map +1 -0
- package/dist/detect/safe-harbor.js +278 -0
- package/dist/doctor-cli.d.ts +7 -0
- package/dist/doctor-cli.d.ts.map +1 -0
- package/dist/doctor-cli.js +67 -0
- package/dist/doctor-preflight.d.ts +52 -0
- package/dist/doctor-preflight.d.ts.map +1 -0
- package/dist/doctor-preflight.js +112 -0
- package/dist/feedback/coverage.d.ts +11 -8
- package/dist/feedback/coverage.d.ts.map +1 -1
- package/dist/feedback/coverage.js +29 -16
- package/dist/feedback/grade.d.ts +58 -0
- package/dist/feedback/grade.d.ts.map +1 -0
- package/dist/feedback/grade.js +67 -0
- package/dist/gateway/http-protocol.d.ts +20 -1
- package/dist/gateway/http-protocol.d.ts.map +1 -1
- package/dist/gateway/http-protocol.js +1 -1
- package/dist/gateway/serve-client.d.ts +99 -0
- package/dist/gateway/serve-client.d.ts.map +1 -0
- package/dist/gateway/serve-client.js +360 -0
- package/dist/index.d.ts +68 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +167 -46
- package/dist/init/observe-cli.js +1 -1
- package/dist/init/observe.d.ts +2 -2
- package/dist/init/observe.d.ts.map +1 -1
- package/dist/init/observe.js +11 -7
- package/dist/mask/arm.d.ts +112 -0
- package/dist/mask/arm.d.ts.map +1 -0
- package/dist/mask/arm.js +179 -0
- package/dist/mask/index.d.ts +2 -0
- package/dist/mask/index.d.ts.map +1 -1
- package/dist/mask/index.js +7 -1
- package/dist/mask/mask-policy-cli.d.ts +12 -4
- package/dist/mask/mask-policy-cli.d.ts.map +1 -1
- package/dist/mask/mask-policy-cli.js +34 -9
- package/dist/prompts/manifest.d.ts +128 -0
- package/dist/prompts/manifest.d.ts.map +1 -0
- package/dist/prompts/manifest.js +214 -0
- package/dist/prompts/prompt-fetch.d.ts +84 -0
- package/dist/prompts/prompt-fetch.d.ts.map +1 -0
- package/dist/prompts/prompt-fetch.js +120 -0
- package/dist/prompts/prompt-resolve.d.ts +76 -0
- package/dist/prompts/prompt-resolve.d.ts.map +1 -0
- package/dist/prompts/prompt-resolve.js +93 -0
- package/dist/prompts/slot-resolver.d.ts +91 -0
- package/dist/prompts/slot-resolver.d.ts.map +1 -0
- package/dist/prompts/slot-resolver.js +135 -0
- package/dist/prompts/tools-register.d.ts +60 -0
- package/dist/prompts/tools-register.d.ts.map +1 -0
- package/dist/prompts/tools-register.js +48 -0
- package/dist/prompts/version-hash.d.ts +29 -0
- package/dist/prompts/version-hash.d.ts.map +1 -0
- package/dist/prompts/version-hash.js +54 -0
- package/dist/prompts-export-cli.d.ts +21 -0
- package/dist/prompts-export-cli.d.ts.map +1 -0
- package/dist/prompts-export-cli.js +130 -0
- package/dist/query/grammar.d.ts +2 -2
- package/dist/query/grammar.d.ts.map +1 -1
- package/dist/query/grammar.js +3 -1
- package/dist/query/saved.d.ts +13 -0
- package/dist/query/saved.d.ts.map +1 -1
- package/dist/query/saved.js +67 -1
- package/dist/receipts/types.d.ts +1 -1
- package/dist/receipts/types.d.ts.map +1 -1
- package/dist/receipts/types.js +1 -0
- package/dist/registry/build.d.ts +43 -1
- package/dist/registry/build.d.ts.map +1 -1
- package/dist/registry/build.js +52 -0
- package/dist/registry/cache-policy.d.ts.map +1 -1
- package/dist/registry/cache-policy.js +22 -0
- package/dist/registry/pricing-shape.d.ts +67 -8
- package/dist/registry/pricing-shape.d.ts.map +1 -1
- package/dist/registry/pricing-shape.js +50 -13
- package/dist/registry/pricing.d.ts +6 -5
- package/dist/registry/pricing.d.ts.map +1 -1
- package/dist/registry/pricing.js +9 -5
- package/dist/registry/rows.d.ts.map +1 -1
- package/dist/registry/rows.js +1 -0
- package/dist/registry/select.d.ts +6 -1
- package/dist/registry/select.d.ts.map +1 -1
- package/dist/registry/select.js +11 -0
- package/dist/routes/call-config.d.ts +199 -0
- package/dist/routes/call-config.d.ts.map +1 -0
- package/dist/routes/call-config.js +343 -0
- package/dist/routes/destination-loader.d.ts +16 -0
- package/dist/routes/destination-loader.d.ts.map +1 -0
- package/dist/routes/destination-loader.js +29 -0
- package/dist/routes/draft.d.ts +7 -0
- package/dist/routes/draft.d.ts.map +1 -1
- package/dist/routes/draft.js +12 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +31 -56
- package/dist/routes/objective-loader.d.ts +12 -0
- package/dist/routes/objective-loader.d.ts.map +1 -1
- package/dist/routes/objective-loader.js +82 -0
- package/dist/routes/output-loader.d.ts +42 -0
- package/dist/routes/output-loader.d.ts.map +1 -0
- package/dist/routes/output-loader.js +112 -0
- package/dist/routes/prompt-loader.d.ts +49 -0
- package/dist/routes/prompt-loader.d.ts.map +1 -0
- package/dist/routes/prompt-loader.js +113 -0
- package/dist/routes/resolved-bundle.d.ts +69 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -1
- package/dist/routes/resolved-bundle.js +76 -0
- package/dist/routes/screen-loader.d.ts +29 -1
- package/dist/routes/screen-loader.d.ts.map +1 -1
- package/dist/routes/screen-loader.js +59 -1
- package/dist/run/accept.d.ts +5 -0
- package/dist/run/accept.d.ts.map +1 -1
- package/dist/run/accept.js +2 -0
- package/dist/run/cost.d.ts +31 -2
- package/dist/run/cost.d.ts.map +1 -1
- package/dist/run/cost.js +57 -2
- package/dist/run/destination.d.ts +39 -0
- package/dist/run/destination.d.ts.map +1 -0
- package/dist/run/destination.js +45 -0
- package/dist/run/dispatch.d.ts +67 -16
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +133 -29
- package/dist/run/grounding.d.ts +28 -2
- package/dist/run/grounding.d.ts.map +1 -1
- package/dist/run/grounding.js +54 -10
- package/dist/run/raw-defaults.d.ts.map +1 -1
- package/dist/run/raw-defaults.js +6 -1
- package/dist/run/raw-finalize.d.ts +50 -0
- package/dist/run/raw-finalize.d.ts.map +1 -0
- package/dist/run/raw-finalize.js +266 -0
- package/dist/run/raw-knobs.d.ts +36 -0
- package/dist/run/raw-knobs.d.ts.map +1 -0
- package/dist/run/raw-knobs.js +99 -0
- package/dist/run/raw-request.d.ts +24 -0
- package/dist/run/raw-request.d.ts.map +1 -0
- package/dist/run/raw-request.js +69 -0
- package/dist/run/raw-schema.d.ts +76 -0
- package/dist/run/raw-schema.d.ts.map +1 -0
- package/dist/run/raw-schema.js +166 -0
- package/dist/run/raw-search-cost.d.ts +48 -0
- package/dist/run/raw-search-cost.d.ts.map +1 -0
- package/dist/run/raw-search-cost.js +78 -0
- package/dist/run/raw-support.d.ts +64 -6
- package/dist/run/raw-support.d.ts.map +1 -1
- package/dist/run/raw-support.js +84 -11
- package/dist/run/raw.d.ts +25 -26
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +30 -351
- package/dist/run/record-attempt.d.ts +12 -0
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +30 -12
- package/dist/run/repair-attempt.d.ts +68 -0
- package/dist/run/repair-attempt.d.ts.map +1 -0
- package/dist/run/repair-attempt.js +180 -0
- package/dist/run/resolve-destination.d.ts +49 -0
- package/dist/run/resolve-destination.d.ts.map +1 -0
- package/dist/run/resolve-destination.js +76 -0
- package/dist/run/routing-docs.d.ts.map +1 -1
- package/dist/run/routing-docs.js +10 -5
- package/dist/run/run.d.ts +30 -1
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +94 -172
- package/dist/run/telemetry-row.d.ts +92 -0
- package/dist/run/telemetry-row.d.ts.map +1 -0
- package/dist/run/telemetry-row.js +81 -0
- package/dist/run/validate.d.ts +12 -1
- package/dist/run/validate.d.ts.map +1 -1
- package/dist/run/validate.js +31 -0
- package/dist/run/web-search-pricing.d.ts +43 -0
- package/dist/run/web-search-pricing.d.ts.map +1 -0
- package/dist/run/web-search-pricing.js +56 -0
- package/dist/savings/odometer.d.ts +4 -0
- package/dist/savings/odometer.d.ts.map +1 -1
- package/dist/savings/odometer.js +20 -1
- package/dist/savings/swap-execute.d.ts +7 -0
- package/dist/savings/swap-execute.d.ts.map +1 -1
- package/dist/savings/swap-execute.js +30 -0
- package/dist/savings/swaps-client.d.ts +10 -0
- package/dist/savings/swaps-client.d.ts.map +1 -1
- package/dist/screen/fixtures/probe-corpora.d.ts +23 -0
- package/dist/screen/fixtures/probe-corpora.d.ts.map +1 -0
- package/dist/screen/fixtures/probe-corpora.js +69 -0
- package/dist/screen/index.d.ts +21 -0
- package/dist/screen/index.d.ts.map +1 -0
- package/dist/screen/index.js +64 -0
- package/dist/screen/model-screen.d.ts +111 -0
- package/dist/screen/model-screen.d.ts.map +1 -0
- package/dist/screen/model-screen.js +178 -0
- package/dist/screen/patterns.d.ts +51 -0
- package/dist/screen/patterns.d.ts.map +1 -0
- package/dist/screen/patterns.js +151 -0
- package/dist/screen/phi-gate.d.ts +52 -0
- package/dist/screen/phi-gate.d.ts.map +1 -0
- package/dist/screen/phi-gate.js +86 -0
- package/dist/screen/policy.d.ts +71 -0
- package/dist/screen/policy.d.ts.map +1 -0
- package/dist/screen/policy.js +334 -0
- package/dist/screen/probe.d.ts +118 -0
- package/dist/screen/probe.d.ts.map +1 -0
- package/dist/screen/probe.js +132 -0
- package/dist/screen/screen-cli.d.ts +16 -0
- package/dist/screen/screen-cli.d.ts.map +1 -0
- package/dist/screen/screen-cli.js +178 -0
- package/dist/screen/screen.d.ts +99 -0
- package/dist/screen/screen.d.ts.map +1 -0
- package/dist/screen/screen.js +0 -0
- package/dist/screen/sidecar.d.ts +69 -0
- package/dist/screen/sidecar.d.ts.map +1 -0
- package/dist/screen/sidecar.js +145 -0
- package/dist/screen/types.d.ts +43 -2
- package/dist/screen/types.d.ts.map +1 -1
- package/dist/settings/api-fetcher.d.ts +14 -3
- package/dist/settings/api-fetcher.d.ts.map +1 -1
- package/dist/settings/api-fetcher.js +61 -10
- package/dist/settings/grading-guide.d.ts +102 -0
- package/dist/settings/grading-guide.d.ts.map +1 -0
- package/dist/settings/grading-guide.js +23 -0
- package/dist/settings/index.d.ts +3 -2
- package/dist/settings/index.d.ts.map +1 -1
- package/dist/settings/index.js +2 -1
- package/dist/settings/task-settings.d.ts +44 -7
- package/dist/settings/task-settings.d.ts.map +1 -1
- package/dist/settings/task-settings.js +53 -12
- package/dist/status.d.ts +32 -20
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +51 -30
- package/dist/telemetry/artifact-store.d.ts +5 -6
- package/dist/telemetry/artifact-store.d.ts.map +1 -1
- package/dist/telemetry/artifact-store.js +21 -24
- package/dist/telemetry/attempt-meta.d.ts +76 -1
- package/dist/telemetry/attempt-meta.d.ts.map +1 -1
- package/dist/telemetry/attempt-meta.js +33 -1
- package/dist/telemetry/exporter-setup.d.ts +2 -0
- package/dist/telemetry/exporter-setup.d.ts.map +1 -1
- package/dist/telemetry/exporter-setup.js +6 -1
- package/dist/telemetry/exporter.d.ts +2 -2
- package/dist/telemetry/exporter.d.ts.map +1 -1
- package/dist/telemetry/exporter.js +22 -41
- package/dist/telemetry/grade-mappers.d.ts +25 -0
- package/dist/telemetry/grade-mappers.d.ts.map +1 -0
- package/dist/telemetry/grade-mappers.js +64 -0
- package/dist/telemetry/grades-sql.d.ts +56 -0
- package/dist/telemetry/grades-sql.d.ts.map +1 -0
- package/dist/telemetry/grades-sql.js +156 -0
- package/dist/telemetry/ingest-protocol.d.ts +55 -48
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/ingest-protocol.js +48 -83
- package/dist/telemetry/org-identity.d.ts +44 -0
- package/dist/telemetry/org-identity.d.ts.map +1 -0
- package/dist/telemetry/org-identity.js +98 -0
- package/dist/telemetry/route-registration.d.ts +48 -0
- package/dist/telemetry/route-registration.d.ts.map +1 -0
- package/dist/telemetry/route-registration.js +77 -0
- package/dist/telemetry/sinks.d.ts +10 -1
- package/dist/telemetry/sinks.d.ts.map +1 -1
- package/dist/telemetry/sinks.js +52 -6
- package/dist/telemetry/store-migrations.d.ts.map +1 -1
- package/dist/telemetry/store-migrations.js +64 -0
- package/dist/telemetry/store.d.ts +9 -6
- package/dist/telemetry/store.d.ts.map +1 -1
- package/dist/telemetry/store.js +8 -50
- package/dist/tenancy/api-key-format.d.ts +45 -1
- package/dist/tenancy/api-key-format.d.ts.map +1 -1
- package/dist/tenancy/api-key-format.js +50 -1
- package/dist/types/provider.d.ts +23 -3
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/provider.js +26 -0
- package/dist/types/route.d.ts +154 -2
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +73 -48
- package/dist/types/telemetry.d.ts.map +1 -1
- package/dist/validate-cli.d.ts.map +1 -1
- package/dist/validate-cli.js +32 -0
- package/dist/verify/verify.d.ts +5 -0
- package/dist/verify/verify.d.ts.map +1 -1
- package/dist/verify/verify.js +2 -0
- package/dist/watch/evaluate.d.ts +84 -1
- package/dist/watch/evaluate.d.ts.map +1 -1
- package/dist/watch/evaluate.js +28 -0
- package/dist/watch/monitor.d.ts +8 -2
- package/dist/watch/monitor.d.ts.map +1 -1
- package/dist/watch/monitor.js +13 -5
- package/dist/watch/regret-monitor-cli.d.ts +16 -0
- package/dist/watch/regret-monitor-cli.d.ts.map +1 -0
- package/dist/watch/regret-monitor-cli.js +137 -0
- package/dist/watch/regret-monitor.d.ts +168 -0
- package/dist/watch/regret-monitor.d.ts.map +1 -0
- package/dist/watch/regret-monitor.js +304 -0
- package/dist/watch/upgrade.d.ts +62 -0
- package/dist/watch/upgrade.d.ts.map +1 -0
- package/dist/watch/upgrade.js +57 -0
- package/docs/agent-skill/SKILL.md +181 -9
- package/docs/how-it-fits.md +3 -2
- package/docs/instrumentation.md +219 -46
- package/docs/llms.txt +158 -35
- package/docs/managed-serving.md +150 -0
- package/docs/mcp-oracle.md +322 -0
- package/docs/migration-playbook.md +5 -4
- package/docs/quickstart.md +263 -89
- package/package.json +18 -4
- package/registry/leaderboard.json +74 -0
- package/registry/registry.json +232 -112
- package/screen.d.ts +16 -0
- package/templates/call-disposition-qa.json +77 -0
- package/templates/catalog-cleansing.json +77 -0
- package/templates/compliance-review.json +76 -0
- package/templates/cs-next-action.json +76 -0
- package/templates/document-extraction.json +78 -0
- package/templates/financial-classification.json +75 -0
- package/templates/lead-qualification.json +76 -0
- package/templates/medical-classification.json +71 -0
- package/templates/ticket-triage.json +76 -0
- package/dist/feedback/feedback.d.ts +0 -35
- package/dist/feedback/feedback.d.ts.map +0 -1
- package/dist/feedback/feedback.js +0 -39
package/dist/cli.js
CHANGED
|
@@ -31,6 +31,7 @@ const failures_teaching_1 = require("./types/failures-teaching");
|
|
|
31
31
|
const config_1 = require("./config");
|
|
32
32
|
const index_1 = require("./index");
|
|
33
33
|
const status_cli_1 = require("./status-cli");
|
|
34
|
+
const doctor_cli_1 = require("./doctor-cli");
|
|
34
35
|
const engine_1 = require("./bakeoff/engine");
|
|
35
36
|
const samples_1 = require("./bakeoff/samples");
|
|
36
37
|
const report_1 = require("./bakeoff/report");
|
|
@@ -59,6 +60,10 @@ const state_store_1 = require("./watch/state-store");
|
|
|
59
60
|
const swaps_client_1 = require("./savings/swaps-client");
|
|
60
61
|
const swap_execute_1 = require("./savings/swap-execute");
|
|
61
62
|
const cli_query_1 = require("./cli-query");
|
|
63
|
+
const prompts_export_cli_1 = require("./prompts-export-cli");
|
|
64
|
+
const cli_judge_1 = require("./cli-judge");
|
|
65
|
+
const regret_monitor_cli_1 = require("./watch/regret-monitor-cli");
|
|
66
|
+
const screen_cli_1 = require("./screen/screen-cli");
|
|
62
67
|
const BARE_FLAGS = new Set([
|
|
63
68
|
"json",
|
|
64
69
|
"no-mirror",
|
|
@@ -492,45 +497,6 @@ async function cmdServe() {
|
|
|
492
497
|
// The server owns the process from here (it holds the listener open).
|
|
493
498
|
return 0;
|
|
494
499
|
}
|
|
495
|
-
/** `modelrig judge <run>` — E5 V.4: explicitly ask the bounded model-judge to
|
|
496
|
-
* score a run. Goes through the API boundary (T12: the CLI never holds a DB
|
|
497
|
-
* client) — POST /v1/runs/:id/judge on the configured server, authed with a
|
|
498
|
-
* rig_sk key. The daily cap + metering are the SERVER's; this just triggers one. */
|
|
499
|
-
async function cmdJudge(flags) {
|
|
500
|
-
const runId = flags.positional[0] ?? "";
|
|
501
|
-
// Config is the only env reader (package-invariants rule). The judge endpoint
|
|
502
|
-
// lives on the same server as the api-mode ingest sink, so the base is that
|
|
503
|
-
// URL's origin and the credential is the api key.
|
|
504
|
-
const exp = (0, config_1.loadConfigFromEnv)().export;
|
|
505
|
-
const api = exp !== undefined && exp.mode === "api" ? exp : undefined;
|
|
506
|
-
const base = api !== undefined ? new URL(api.ingestUrl).origin : "";
|
|
507
|
-
const key = api?.apiKey ?? "";
|
|
508
|
-
if (runId === "" || base === "" || key === "") {
|
|
509
|
-
console.error([
|
|
510
|
-
"usage: modelrig judge <runId>",
|
|
511
|
-
"",
|
|
512
|
-
"Needs api-mode telemetry configured (the judge is on the same server):",
|
|
513
|
-
" MODELRIG_API_KEY a rig_sk_ key with the `oracle-act` scope",
|
|
514
|
-
" MODELRIG_INGEST_URL optional — the server base; defaults to the hosted API",
|
|
515
|
-
"",
|
|
516
|
-
"The judge is EXPLICIT-only and metered; scoring rides the gateway (a route),",
|
|
517
|
-
"so the org's daily cap and spend-stops apply. Nothing schedules it.",
|
|
518
|
-
].join("\n"));
|
|
519
|
-
return 1;
|
|
520
|
-
}
|
|
521
|
-
const res = await fetch(`${base}/v1/runs/${encodeURIComponent(runId)}/judge`, {
|
|
522
|
-
method: "POST",
|
|
523
|
-
headers: { authorization: `Bearer ${key}`, "content-type": "application/json" },
|
|
524
|
-
body: "{}",
|
|
525
|
-
});
|
|
526
|
-
const body = (await res.json().catch(() => ({})));
|
|
527
|
-
if (!res.ok) {
|
|
528
|
-
console.error(`judge ${res.status}: ${typeof body.error === "string" ? body.error : "failed"}`);
|
|
529
|
-
return 1;
|
|
530
|
-
}
|
|
531
|
-
console.log(JSON.stringify(body, null, 2));
|
|
532
|
-
return 0;
|
|
533
|
-
}
|
|
534
500
|
/** The one usage block, printed to stdout on `--help` (exit 0) and to stderr on
|
|
535
501
|
* an unknown command (exit 1). Kept as a const so the two paths can never
|
|
536
502
|
* drift. */
|
|
@@ -538,18 +504,24 @@ const USAGE = [
|
|
|
538
504
|
"usage:",
|
|
539
505
|
" modelrig init [path] [--scope glob,glob] [--out dir] [--dry-run] [--include-tests] [--json]",
|
|
540
506
|
" modelrig observe [path] [--scope glob,glob] [--out dir] [--dry-run] [--json] (T0/T1: see your runs first — no migration)",
|
|
541
|
-
" modelrig validate (structurally check rig.yaml + every route bundle — no provider key needed)",
|
|
507
|
+
" modelrig validate (structurally check rig.yaml + every route bundle + effective screen: policy — no provider key needed)",
|
|
508
|
+
" modelrig screen check <file|-> [--source search|variable|proxy_user|tool_result] (SC-1a: dry-run injection scan — COUNTS only, never values)",
|
|
509
|
+
" modelrig screen pull <classifier:name@version> [--url <weights-url>] (SC-1a: fetch an optional classifier's weights to the local cache — never bundled, A3)",
|
|
510
|
+
" modelrig screen probe [--detectors <ids>] [--corpus <ids>] (SC-3: measured TPR/FP per license-clean synthetic corpus — counts + rates only)",
|
|
542
511
|
" modelrig status (print export/artifact/otlp posture)",
|
|
512
|
+
" modelrig doctor [--expect-org <slug>] (confirm which org MODELRIG_API_KEY resolves to via /v1/whoami — ✓ or a loud 401; exits non-zero on a bad key or, with --expect-org, a different org)",
|
|
543
513
|
" modelrig serve (needs the modelrig-server package)",
|
|
544
514
|
" modelrig bakeoff --route <route> --variants a,b,c --replay-last N [--budget-usd usd] [--objective quality-first|balanced|cost-first] [--keep-outputs[=all]] [--json] [--no-mirror]",
|
|
545
515
|
" modelrig bakeoff --from-proposal <id> [--replay-last N] [--keep-outputs[=all]] [--json]",
|
|
546
|
-
" modelrig bakeoff --mask-policy <route> [--replay-last N] (CS-1:
|
|
516
|
+
" modelrig bakeoff --mask-policy <route> [--replay-last N] [--leak-only] (CS-1: masked-vs-unmasked value-accuracy Δ + leak proof; --leak-only = offline, no dispatch)",
|
|
547
517
|
" modelrig watch run [--events fixtures.json] [--json]",
|
|
518
|
+
" modelrig regret-monitor --route <route> [--dry-run] [--json] (Q1: one regret-band cycle; files a regret_breach bake-off on breach)",
|
|
548
519
|
" modelrig verify-swap --route <route> --captures <fixture.json> [--budget-usd usd] [--out report.md] [--json]",
|
|
549
520
|
" modelrig swap execute <proposalId> --approve [--approved-by name]",
|
|
550
521
|
" modelrig swap revert <swapId>",
|
|
551
522
|
" modelrig judge <runId> (E5: score a run with the bounded model-judge; explicit + metered)",
|
|
552
523
|
' modelrig query "<grammar>" | query --saved <id> (WI-1b: telemetry analytics — metadata only, never content)',
|
|
524
|
+
" modelrig prompts export --route <route> [--out modelrig/routes] [--label prod | --version N] [--segment default] [--json] (PSR-3: export a prompt version back to git, byte-faithful — proves the round-trip)",
|
|
553
525
|
" modelrig samples purge [--bakeoff <id>]",
|
|
554
526
|
].join("\n");
|
|
555
527
|
async function main(argv) {
|
|
@@ -565,8 +537,12 @@ async function main(argv) {
|
|
|
565
537
|
switch (command) {
|
|
566
538
|
case "status":
|
|
567
539
|
return (0, status_cli_1.runStatusCli)();
|
|
540
|
+
case "doctor":
|
|
541
|
+
return (0, doctor_cli_1.runDoctorCli)(flags.named.has("expect-org") ? { expectOrg: flags.named.get("expect-org") ?? "" } : {});
|
|
568
542
|
case "validate":
|
|
569
543
|
return (0, validate_cli_1.runValidateCli)();
|
|
544
|
+
case "screen":
|
|
545
|
+
return (0, screen_cli_1.runScreenCli)(flags);
|
|
570
546
|
case "bakeoff":
|
|
571
547
|
return cmdBakeoff(flags);
|
|
572
548
|
case "watch":
|
|
@@ -582,11 +558,15 @@ async function main(argv) {
|
|
|
582
558
|
case "verify-swap":
|
|
583
559
|
return cmdVerifySwap(flags);
|
|
584
560
|
case "judge":
|
|
585
|
-
return cmdJudge(flags);
|
|
561
|
+
return (0, cli_judge_1.cmdJudge)(flags);
|
|
586
562
|
case "query":
|
|
587
563
|
return (0, cli_query_1.cmdQuery)(flags);
|
|
564
|
+
case "regret-monitor":
|
|
565
|
+
return (0, regret_monitor_cli_1.cmdRegretMonitor)(flags);
|
|
588
566
|
case "serve":
|
|
589
567
|
return cmdServe();
|
|
568
|
+
case "prompts":
|
|
569
|
+
return (0, prompts_export_cli_1.cmdPromptsExport)(flags);
|
|
590
570
|
default:
|
|
591
571
|
console.error(USAGE);
|
|
592
572
|
return 1;
|
package/dist/config.d.ts
CHANGED
|
@@ -35,6 +35,9 @@ export interface RigConfig {
|
|
|
35
35
|
/** A1 aggregator hosts (generic openai-compatible adapter). */
|
|
36
36
|
readonly deepinfra?: string;
|
|
37
37
|
readonly fireworks?: string;
|
|
38
|
+
/** Z.ai / Zhipu (B4a) — env: ZAI_API_KEY (unprefixed vendor key). Reached via
|
|
39
|
+
* the generic openai-compatible adapter (same family as the A1 hosts). */
|
|
40
|
+
readonly zai?: string;
|
|
38
41
|
};
|
|
39
42
|
/** Budget for envelopes first opened by this rig (default: envelope.ts's $25). */
|
|
40
43
|
readonly envelopeBudgetUsd?: number;
|
|
@@ -87,29 +90,70 @@ export interface RigConfig {
|
|
|
87
90
|
*/
|
|
88
91
|
readonly otlp?: OtlpConfig | null;
|
|
89
92
|
/**
|
|
90
|
-
* Artifact / execution-graph namespace (Expansion E2).
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* `
|
|
93
|
+
* Artifact / execution-graph namespace (Expansion E2; P15 CP-3). ON by default
|
|
94
|
+
* when a control plane is configured — a sink exists to ship to, and the ORG's
|
|
95
|
+
* account posture (`artifact_posture`), resolved from the control plane at
|
|
96
|
+
* runtime and enforced authoritatively server-side, is the on/off control (NOT
|
|
97
|
+
* an env var — P15). `enabled: false` (or absent) means the run/artifact SDK
|
|
98
|
+
* surface is inert, the exporter sends protocol v1 byte-identical to before,
|
|
99
|
+
* and zero new rows are written (spec §1.4). A pure local-only rig has no
|
|
100
|
+
* control plane to resolve a posture from, so the namespace is off there unless
|
|
101
|
+
* a dev forces it on (MODELRIG_ARTIFACTS=1, dev-only — see loadConfigFromEnv).
|
|
102
|
+
* Like `otlp`, `loadConfigFromEnv` ALWAYS resolves this so `/status` can answer
|
|
95
103
|
* "enabled|disabled" honestly; optional only so hand-built configs need not
|
|
96
104
|
* spell out the off case.
|
|
97
105
|
*/
|
|
98
106
|
readonly artifacts?: ArtifactsConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Managed serving (Unified Route U3, ruling D-2) — the switch for
|
|
109
|
+
* `destination: modelrig-served`. Set IN CODE at construction, NOT via an env
|
|
110
|
+
* var (Matt, 2026-09-09): `createRig({ ...loadConfigFromEnv(), managedServing: true })`
|
|
111
|
+
* or `loadConfigFromEnv({ managedServing: true })`. `loadConfigFromEnv` defaults
|
|
112
|
+
* it to `false` and reads NO `process.env` key for it; like `otlp`/`artifacts`
|
|
113
|
+
* it is ALWAYS resolved so `/status` can answer "enabled|disabled" honestly.
|
|
114
|
+
* Optional so a hand-built config may omit it — an absent value reads as `false`.
|
|
115
|
+
* When off, a run whose resolved destination is `modelrig-served` FAILS CLOSED
|
|
116
|
+
* pre-dispatch (run/resolve-destination.ts) — never a silent `direct` fallback
|
|
117
|
+
* (fail-closed-but-discoverable). Threaded to the routed run path as
|
|
118
|
+
* RunDeps.managedServingEnabled. Turning it on is a deliberate operator/owner
|
|
119
|
+
* action (P9 money/isolation path); the per-org console toggle is the future GA
|
|
120
|
+
* mechanism (server-resolved). CODE ONLY — no GA, no outward copy; true
|
|
121
|
+
* customer-keyless serving is a hosted-server capability, deferred (spec §4 U3).
|
|
122
|
+
*/
|
|
123
|
+
readonly managedServing?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* The org slug this process expects its `MODELRIG_API_KEY` to resolve to
|
|
126
|
+
* (REL-1, ruling M5). On the first successful flush the api sink asks
|
|
127
|
+
* `GET /v1/whoami` and logs the org it is exporting to; when the resolved slug
|
|
128
|
+
* differs from `expectOrg` it logs `[modelrig] ORG MISMATCH …` loudly on every
|
|
129
|
+
* flush. It NEVER throws and NEVER drops telemetry — the
|
|
130
|
+
* rows still land in the key's org. Set IN CODE, not via an env var (P15):
|
|
131
|
+
* `createRig({ ...loadConfigFromEnv(), expectOrg: "inferwealth" })`. Absent ⇒
|
|
132
|
+
* the org line is still logged, with no comparison.
|
|
133
|
+
*/
|
|
134
|
+
readonly expectOrg?: string;
|
|
99
135
|
}
|
|
100
136
|
/** Scrub mode applied to content BEFORE upload (E2-C chunk B). Default `detect`
|
|
101
|
-
* when content custody is on.
|
|
137
|
+
* when content custody is on. The EFFECTIVE mode is resolved per task/account
|
|
138
|
+
* from the control-plane settings resolver (P15 — scrub is an account setting,
|
|
139
|
+
* not a client env var; the `MODELRIG_ARTIFACTS_SCRUB` gate was deleted, R3
|
|
140
|
+
* follow-up CP-3b). */
|
|
102
141
|
export type ScrubMode = "off" | "detect" | "redact" | "block";
|
|
142
|
+
/** The scrub mode used when NO control-plane resolver answers for a task
|
|
143
|
+
* (local-only / direct rigs, or a run with no task identity). The content-on
|
|
144
|
+
* default — scan and count, upload verbatim. Kept in sync with
|
|
145
|
+
* `settings/task-settings.ts DEFAULT_TASK_SETTINGS.scrub`. */
|
|
146
|
+
export declare const DEFAULT_CONTENT_SCRUB_MODE: ScrubMode;
|
|
103
147
|
/** Per-rig content-custody config (E2-C chunk A/B). Present ONLY when content
|
|
104
148
|
* custody is turned ON and the transport is configured; ABSENT (the default)
|
|
105
149
|
* means metadata + hash only — today's behaviour, unchanged. Consent, off by
|
|
106
|
-
* default (ruling 6).
|
|
150
|
+
* default (ruling 6). Scrub is NOT here — it is a per-task/account setting
|
|
151
|
+
* resolved at runtime from the control plane (P15 CP-3b), not a boot-time env. */
|
|
107
152
|
export interface ArtifactContentConfig {
|
|
108
153
|
/** Full grant endpoint, e.g. https://server/v1/artifacts/uploads. */
|
|
109
154
|
readonly uploadsUrl: string;
|
|
110
155
|
/** `rig_sk_` key with the `artifact-write` scope (header only; never a URL — C2). */
|
|
111
156
|
readonly apiKey: string;
|
|
112
|
-
readonly scrub: ScrubMode;
|
|
113
157
|
/** Client-side ceiling short-circuit; the server enforces the real one. */
|
|
114
158
|
readonly maxBytes: number;
|
|
115
159
|
}
|
|
@@ -120,34 +164,46 @@ export interface ArtifactsConfig {
|
|
|
120
164
|
readonly content?: ArtifactContentConfig;
|
|
121
165
|
}
|
|
122
166
|
/**
|
|
123
|
-
* Resolve the artifact
|
|
167
|
+
* Resolve the artifact-namespace boot shape (E2 / E2-C; P15 CP-3). Env FEATURE
|
|
168
|
+
* GATES are GONE: capture on/off and content on/off are the ORG's account posture
|
|
169
|
+
* (`artifact_posture`), resolved from the control plane at runtime
|
|
170
|
+
* (settings/task-settings.ts) and enforced authoritatively server-side — metadata
|
|
171
|
+
* is dropped at /v1/ingest for posture `off`; content is 403'd at
|
|
172
|
+
* /v1/artifacts/uploads for posture `metadata`. This function decides only the
|
|
173
|
+
* STATIC boot shape:
|
|
174
|
+
* • the metadata namespace is ON whenever a control plane is configured (a sink
|
|
175
|
+
* exists to ship to); OFF for a pure local-only rig UNLESS `devForceOn` (the
|
|
176
|
+
* dev-only MODELRIG_ARTIFACTS=1 escape hatch — NOT a customer control).
|
|
177
|
+
* • content upload is ATTEMPTED whenever the namespace is on and a transport
|
|
178
|
+
* (uploads URL + key) is present; the SERVER's org posture is the real gate,
|
|
179
|
+
* so a `metadata`/`off` org stores nothing and the SDK degrades on the 403. A
|
|
180
|
+
* half-configured transport (no key) stays metadata-only (fail-safe).
|
|
181
|
+
* Remaining env here is NON-gate config (P15-clean): MODELRIG_CONTENT_UPLOAD_URL
|
|
182
|
+
* (endpoint, defaults to the ingest host + uploads path), MODELRIG_CONTENT_API_KEY
|
|
183
|
+
* (credential), MODELRIG_CONTENT_MAX_BYTES (numeric ceiling, default 50MB). Scrub
|
|
184
|
+
* is NOT an env var — it is a per-task/account setting resolved at runtime from
|
|
185
|
+
* the control plane (P15 CP-3b; `MODELRIG_ARTIFACTS_SCRUB` was deleted).
|
|
124
186
|
* Pure — env is read by the caller (the package's sole env-reader rule).
|
|
125
|
-
* MODELRIG_ARTIFACTS unset → namespace ON when a control plane
|
|
126
|
-
* is configured, OFF for local-only
|
|
127
|
-
* (§2: metadata-on by default).
|
|
128
|
-
* MODELRIG_ARTIFACTS=1|true|on → force the namespace ON.
|
|
129
|
-
* MODELRIG_ARTIFACTS=0|false|off → force it OFF (the explicit opt-out).
|
|
130
|
-
* MODELRIG_ARTIFACTS_CONTENT=on|1|true → content custody ON (E2-C).
|
|
131
|
-
* MODELRIG_CONTENT_UPLOAD_URL, MODELRIG_CONTENT_API_KEY → transport.
|
|
132
|
-
* MODELRIG_ARTIFACTS_SCRUB=off|detect|redact|block → scrub mode (default detect).
|
|
133
|
-
* MODELRIG_CONTENT_MAX_BYTES → client ceiling (default 50MB).
|
|
134
|
-
* Content custody stays OFF (content absent) unless it is explicitly on AND the
|
|
135
|
-
* transport is fully configured — a half-configured custody is refused into the
|
|
136
|
-
* safe default (metadata only), never silently half-on. The metadata default
|
|
137
|
-
* flip does NOT flip content: content is its own gate (§2 "content unchanged").
|
|
138
187
|
*/
|
|
139
188
|
export declare function resolveArtifactsConfig(env: {
|
|
140
|
-
readonly artifacts?: string;
|
|
141
|
-
readonly content?: string;
|
|
142
189
|
readonly uploadsUrl?: string;
|
|
143
190
|
readonly apiKey?: string;
|
|
144
|
-
readonly scrub?: string;
|
|
145
191
|
readonly maxBytes?: string;
|
|
146
192
|
},
|
|
147
|
-
/** Is a cloud sink (api or direct) configured?
|
|
148
|
-
* OFF otherwise. Defaults false so
|
|
149
|
-
*
|
|
150
|
-
controlPlaneConfigured?: boolean
|
|
193
|
+
/** Is a cloud sink (api or direct) configured? The namespace defaults ON when
|
|
194
|
+
* so (the org posture governs at runtime), OFF otherwise. Defaults false so
|
|
195
|
+
* hand-built configs/tests keep local-only semantics unless they opt in. */
|
|
196
|
+
controlPlaneConfigured?: boolean,
|
|
197
|
+
/** Dev-only local-rig force-on (MODELRIG_ARTIFACTS=1). Ignored when a control
|
|
198
|
+
* plane is configured; there, posture is the control. NOT a customer opt-out. */
|
|
199
|
+
devForceOn?: boolean): ArtifactsConfig;
|
|
200
|
+
/** Default `MODELRIG_CONTENT_UPLOAD_URL` when it is unset/blank: the ingest host
|
|
201
|
+
* (`MODELRIG_INGEST_URL`, else the SDK default) + the uploads path. The grant
|
|
202
|
+
* endpoint is always on the same server as ingest — deriving it removes a
|
|
203
|
+
* required var AND forecloses the mismatch footgun (uploads pointed at a server
|
|
204
|
+
* whose control plane lacks the artifact's metadata row would 404 forever). An
|
|
205
|
+
* explicit `MODELRIG_CONTENT_UPLOAD_URL` still wins. */
|
|
206
|
+
export declare function defaultContentUploadsUrl(ingestUrlEnv?: string): string;
|
|
151
207
|
/** Resolved OTLP config (E1). Endpoint + sink-auth headers only; the emitter
|
|
152
208
|
* derives batch/interval + watermark from defaults + the source id. */
|
|
153
209
|
export interface OtlpConfig {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;;kFAIkF;AAClF,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAMvD;AAED,MAAM,WAAW,SAAS;IACxB;;;;;4EAKwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;qFAIiF;IACjF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAC5B,qDAAqD;QACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,+DAA+D;QAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"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"}
|
package/dist/config.js
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* __tests__/package-invariants.test.ts).
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.PROVIDER_KEY_ENV = void 0;
|
|
8
|
+
exports.PROVIDER_KEY_ENV = exports.DEFAULT_CONTENT_SCRUB_MODE = void 0;
|
|
9
9
|
exports.pipelineShaFromEnv = pipelineShaFromEnv;
|
|
10
10
|
exports.resolveArtifactsConfig = resolveArtifactsConfig;
|
|
11
|
+
exports.defaultContentUploadsUrl = defaultContentUploadsUrl;
|
|
11
12
|
exports.parseOtlpHeaders = parseOtlpHeaders;
|
|
12
13
|
exports.resolveOtlpConfig = resolveOtlpConfig;
|
|
13
14
|
exports.loadConfigFromEnv = loadConfigFromEnv;
|
|
@@ -26,54 +27,71 @@ function pipelineShaFromEnv() {
|
|
|
26
27
|
}
|
|
27
28
|
return undefined;
|
|
28
29
|
}
|
|
30
|
+
/** The scrub mode used when NO control-plane resolver answers for a task
|
|
31
|
+
* (local-only / direct rigs, or a run with no task identity). The content-on
|
|
32
|
+
* default — scan and count, upload verbatim. Kept in sync with
|
|
33
|
+
* `settings/task-settings.ts DEFAULT_TASK_SETTINGS.scrub`. */
|
|
34
|
+
exports.DEFAULT_CONTENT_SCRUB_MODE = "detect";
|
|
29
35
|
const DEFAULT_SDK_CONTENT_MAX_BYTES = 52428800;
|
|
30
|
-
function resolveScrubMode(raw, contentOn) {
|
|
31
|
-
const v = (raw ?? "").trim().toLowerCase();
|
|
32
|
-
if (v === "off" || v === "detect" || v === "redact" || v === "block")
|
|
33
|
-
return v;
|
|
34
|
-
// Default when content is on is `detect` — scan and count, upload verbatim.
|
|
35
|
-
return contentOn ? "detect" : "off";
|
|
36
|
-
}
|
|
37
36
|
/**
|
|
38
|
-
* Resolve the artifact
|
|
37
|
+
* Resolve the artifact-namespace boot shape (E2 / E2-C; P15 CP-3). Env FEATURE
|
|
38
|
+
* GATES are GONE: capture on/off and content on/off are the ORG's account posture
|
|
39
|
+
* (`artifact_posture`), resolved from the control plane at runtime
|
|
40
|
+
* (settings/task-settings.ts) and enforced authoritatively server-side — metadata
|
|
41
|
+
* is dropped at /v1/ingest for posture `off`; content is 403'd at
|
|
42
|
+
* /v1/artifacts/uploads for posture `metadata`. This function decides only the
|
|
43
|
+
* STATIC boot shape:
|
|
44
|
+
* • the metadata namespace is ON whenever a control plane is configured (a sink
|
|
45
|
+
* exists to ship to); OFF for a pure local-only rig UNLESS `devForceOn` (the
|
|
46
|
+
* dev-only MODELRIG_ARTIFACTS=1 escape hatch — NOT a customer control).
|
|
47
|
+
* • content upload is ATTEMPTED whenever the namespace is on and a transport
|
|
48
|
+
* (uploads URL + key) is present; the SERVER's org posture is the real gate,
|
|
49
|
+
* so a `metadata`/`off` org stores nothing and the SDK degrades on the 403. A
|
|
50
|
+
* half-configured transport (no key) stays metadata-only (fail-safe).
|
|
51
|
+
* Remaining env here is NON-gate config (P15-clean): MODELRIG_CONTENT_UPLOAD_URL
|
|
52
|
+
* (endpoint, defaults to the ingest host + uploads path), MODELRIG_CONTENT_API_KEY
|
|
53
|
+
* (credential), MODELRIG_CONTENT_MAX_BYTES (numeric ceiling, default 50MB). Scrub
|
|
54
|
+
* is NOT an env var — it is a per-task/account setting resolved at runtime from
|
|
55
|
+
* the control plane (P15 CP-3b; `MODELRIG_ARTIFACTS_SCRUB` was deleted).
|
|
39
56
|
* Pure — env is read by the caller (the package's sole env-reader rule).
|
|
40
|
-
* MODELRIG_ARTIFACTS unset → namespace ON when a control plane
|
|
41
|
-
* is configured, OFF for local-only
|
|
42
|
-
* (§2: metadata-on by default).
|
|
43
|
-
* MODELRIG_ARTIFACTS=1|true|on → force the namespace ON.
|
|
44
|
-
* MODELRIG_ARTIFACTS=0|false|off → force it OFF (the explicit opt-out).
|
|
45
|
-
* MODELRIG_ARTIFACTS_CONTENT=on|1|true → content custody ON (E2-C).
|
|
46
|
-
* MODELRIG_CONTENT_UPLOAD_URL, MODELRIG_CONTENT_API_KEY → transport.
|
|
47
|
-
* MODELRIG_ARTIFACTS_SCRUB=off|detect|redact|block → scrub mode (default detect).
|
|
48
|
-
* MODELRIG_CONTENT_MAX_BYTES → client ceiling (default 50MB).
|
|
49
|
-
* Content custody stays OFF (content absent) unless it is explicitly on AND the
|
|
50
|
-
* transport is fully configured — a half-configured custody is refused into the
|
|
51
|
-
* safe default (metadata only), never silently half-on. The metadata default
|
|
52
|
-
* flip does NOT flip content: content is its own gate (§2 "content unchanged").
|
|
53
57
|
*/
|
|
54
58
|
function resolveArtifactsConfig(env,
|
|
55
|
-
/** Is a cloud sink (api or direct) configured?
|
|
56
|
-
* OFF otherwise. Defaults false so
|
|
57
|
-
*
|
|
58
|
-
controlPlaneConfigured = false
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
59
|
+
/** Is a cloud sink (api or direct) configured? The namespace defaults ON when
|
|
60
|
+
* so (the org posture governs at runtime), OFF otherwise. Defaults false so
|
|
61
|
+
* hand-built configs/tests keep local-only semantics unless they opt in. */
|
|
62
|
+
controlPlaneConfigured = false,
|
|
63
|
+
/** Dev-only local-rig force-on (MODELRIG_ARTIFACTS=1). Ignored when a control
|
|
64
|
+
* plane is configured; there, posture is the control. NOT a customer opt-out. */
|
|
65
|
+
devForceOn = false) {
|
|
66
|
+
// Namespace on when there is a control plane to ship to (org posture, resolved
|
|
67
|
+
// at runtime + the server ingest gate, decides what is kept), or when a dev has
|
|
68
|
+
// forced it on for a local-only rig that has no posture to resolve.
|
|
69
|
+
const enabled = controlPlaneConfigured || devForceOn;
|
|
66
70
|
const uploadsUrl = (env.uploadsUrl ?? "").trim();
|
|
67
71
|
const apiKey = (env.apiKey ?? "").trim();
|
|
68
72
|
const maxBytesRaw = env.maxBytes !== undefined && env.maxBytes !== "" ? Number(env.maxBytes) : NaN;
|
|
69
73
|
const maxBytes = Number.isInteger(maxBytesRaw) && maxBytesRaw > 0 ? maxBytesRaw : DEFAULT_SDK_CONTENT_MAX_BYTES;
|
|
70
|
-
// Content is
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
// Content is ATTEMPTED whenever the namespace is enabled and the transport is
|
|
75
|
+
// present; the server's org posture is the consent gate (a `metadata`/`off` org
|
|
76
|
+
// 403s and the SDK degrades to metadata-only). No client env gate — the opt-out
|
|
77
|
+
// is the account posture. Missing transport → metadata-only (fail-safe).
|
|
78
|
+
const content = enabled && uploadsUrl !== "" && apiKey !== ""
|
|
79
|
+
? { uploadsUrl, apiKey, maxBytes }
|
|
74
80
|
: undefined;
|
|
75
81
|
return { enabled, ...(content !== undefined ? { content } : {}) };
|
|
76
82
|
}
|
|
83
|
+
/** The managed content-custody grant endpoint path on the server. */
|
|
84
|
+
const ARTIFACT_UPLOADS_PATH = "/v1/artifacts/uploads";
|
|
85
|
+
/** Default `MODELRIG_CONTENT_UPLOAD_URL` when it is unset/blank: the ingest host
|
|
86
|
+
* (`MODELRIG_INGEST_URL`, else the SDK default) + the uploads path. The grant
|
|
87
|
+
* endpoint is always on the same server as ingest — deriving it removes a
|
|
88
|
+
* required var AND forecloses the mismatch footgun (uploads pointed at a server
|
|
89
|
+
* whose control plane lacks the artifact's metadata row would 404 forever). An
|
|
90
|
+
* explicit `MODELRIG_CONTENT_UPLOAD_URL` still wins. */
|
|
91
|
+
function defaultContentUploadsUrl(ingestUrlEnv) {
|
|
92
|
+
const raw = ingestUrlEnv !== undefined && ingestUrlEnv.trim() !== "" ? ingestUrlEnv.trim() : ingest_protocol_1.DEFAULT_INGEST_URL;
|
|
93
|
+
return `${raw.replace(/\/+$/, "")}${ARTIFACT_UPLOADS_PATH}`;
|
|
94
|
+
}
|
|
77
95
|
/**
|
|
78
96
|
* Parse `MODELRIG_OTLP_HEADERS` ("k=v,k=v") into a header map (E1). Split on the
|
|
79
97
|
* FIRST `=` only, so a base64 Basic-auth value keeping its `=` padding survives.
|
|
@@ -119,6 +137,11 @@ exports.PROVIDER_KEY_ENV = {
|
|
|
119
137
|
grok: "XAI_API_KEY",
|
|
120
138
|
deepinfra: "MODELRIG_DEEPINFRA_API_KEY",
|
|
121
139
|
fireworks: "MODELRIG_FIREWORKS_API_KEY",
|
|
140
|
+
// Z.ai (B4a): UNPREFIXED on purpose — matches the XAI_API_KEY/ANTHROPIC_API_KEY
|
|
141
|
+
// vendor-key convention (only the aggregator hosts deepinfra/fireworks + tavily
|
|
142
|
+
// carry the MODELRIG_ prefix, for host-app env collision-avoidance, which does
|
|
143
|
+
// not apply to a first-party vendor key).
|
|
144
|
+
zai: "ZAI_API_KEY",
|
|
122
145
|
};
|
|
123
146
|
const DEFAULT_ROUTES_DIR = "./modelrig/routes";
|
|
124
147
|
const DEFAULT_TELEMETRY_DB = "./.modelrig/telemetry.db";
|
|
@@ -132,25 +155,62 @@ function loadConfigFromEnv(overrides) {
|
|
|
132
155
|
// OTLP span emission (E1) — off unless an endpoint is set. Additive to
|
|
133
156
|
// `export`; a rig may emit OTLP with no control-plane sink and vice-versa.
|
|
134
157
|
const otlp = resolveOtlpConfig(env.MODELRIG_OTLP_ENDPOINT, env.MODELRIG_OTLP_HEADERS);
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
158
|
+
// Managed serving (Unified Route U3, ruling D-2) is deliberately NOT an env var
|
|
159
|
+
// (Matt, 2026-09-09): `config.managedServing` is set IN CODE at construction —
|
|
160
|
+
// `createRig({ ...loadConfigFromEnv(), managedServing: true })`, or
|
|
161
|
+
// `loadConfigFromEnv({ managedServing: true })` (overrides win below) — and
|
|
162
|
+
// defaults OFF (`false` in `fromEnv`). It is intentionally read from NO
|
|
163
|
+
// `process.env` key. The per-org console/settings toggle is the future GA
|
|
164
|
+
// mechanism (server-resolved, like `artifact_posture`). When off/absent, a
|
|
165
|
+
// resolved `modelrig-served` FAILS CLOSED pre-dispatch (run/resolve-destination.ts)
|
|
166
|
+
// — never a silent `direct` fallback. This is NOT a customer-key override: the
|
|
167
|
+
// fireworks/deepinfra adapters already carry ModelRig-owned keys on the routed
|
|
168
|
+
// lane, so U3 is a config-flag + capability SEAM, not a key switch (true
|
|
169
|
+
// customer-keyless serving now ships as a hosted-server capability behind this
|
|
170
|
+
// same flag — no longer deferred).
|
|
171
|
+
// Artifact / execution-graph namespace (E2; P15 CP-3) — ON by default when a
|
|
172
|
+
// control plane is configured (api key OR the direct supabase pair). The ORG's
|
|
173
|
+
// account posture (`artifact_posture`), resolved from the control plane at
|
|
174
|
+
// runtime and enforced server-side, is the on/off control — NOT an env var
|
|
175
|
+
// (P15). The old `MODELRIG_ARTIFACTS` / `MODELRIG_ARTIFACTS_CONTENT` opt-out
|
|
176
|
+
// gates are DELETED: opt out by setting org posture `off` (capture nothing) or
|
|
177
|
+
// `metadata` (no content) in the console or via the set_org_settings MCP tool.
|
|
178
|
+
//
|
|
179
|
+
// DEV-ONLY escape hatch: a pure LOCAL-ONLY rig has no control plane to resolve
|
|
180
|
+
// a posture from, so the artifact namespace is off there unless a dev forces it
|
|
181
|
+
// on for local inspection — `MODELRIG_ARTIFACTS=1` is honored ONLY when NO
|
|
182
|
+
// control plane is configured. It is NOT a customer control (never advertised
|
|
183
|
+
// in onboarding/get-started/.env.example) and the deleted `=0` opt-out no
|
|
184
|
+
// longer does anything. When a control plane IS configured, MODELRIG_ARTIFACTS
|
|
185
|
+
// is ignored (posture governs) — warn once so a stale `=0` is not read as an
|
|
186
|
+
// opt-out that silently stopped working. Always resolved so /status + the boot
|
|
187
|
+
// banner answer honestly.
|
|
140
188
|
const controlPlaneConfigured = Boolean(apiKey) || Boolean(supabaseUrl && serviceRoleKey);
|
|
189
|
+
const artifactsGate = (env.MODELRIG_ARTIFACTS ?? "").trim().toLowerCase();
|
|
190
|
+
const devForceOn = !controlPlaneConfigured &&
|
|
191
|
+
(artifactsGate === "1" || artifactsGate === "true" || artifactsGate === "on");
|
|
192
|
+
if (controlPlaneConfigured && artifactsGate !== "") {
|
|
193
|
+
console.warn("[modelrig] MODELRIG_ARTIFACTS is ignored — capture on/off is your account posture " +
|
|
194
|
+
"(artifact_posture), not an env var (P15). To stop capture, set org posture 'off' " +
|
|
195
|
+
"(or 'metadata' for no content) in the console or via the set_org_settings MCP tool.");
|
|
196
|
+
}
|
|
141
197
|
const artifacts = resolveArtifactsConfig({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
uploadsUrl: env.MODELRIG_CONTENT_UPLOAD_URL
|
|
198
|
+
// Default the grant endpoint to the ingest host so custody needs only the
|
|
199
|
+
// artifact-write key; an explicit override still wins.
|
|
200
|
+
uploadsUrl: env.MODELRIG_CONTENT_UPLOAD_URL?.trim()
|
|
201
|
+
? env.MODELRIG_CONTENT_UPLOAD_URL
|
|
202
|
+
: defaultContentUploadsUrl(env.MODELRIG_INGEST_URL),
|
|
145
203
|
apiKey: env.MODELRIG_CONTENT_API_KEY ?? env.MODELRIG_API_KEY,
|
|
146
|
-
scrub: env.MODELRIG_ARTIFACTS_SCRUB,
|
|
147
204
|
maxBytes: env.MODELRIG_CONTENT_MAX_BYTES,
|
|
148
|
-
}, controlPlaneConfigured);
|
|
205
|
+
}, controlPlaneConfigured, devForceOn);
|
|
149
206
|
const fromEnv = {
|
|
150
207
|
routesDir: env.MODELRIG_ROUTES_DIR ?? DEFAULT_ROUTES_DIR,
|
|
151
208
|
telemetryDbPath: env.MODELRIG_TELEMETRY_DB ?? DEFAULT_TELEMETRY_DB,
|
|
152
209
|
otlp,
|
|
153
210
|
artifacts,
|
|
211
|
+
// U3 (D-2): default OFF; enabled in code via `createRig`/`loadConfigFromEnv`
|
|
212
|
+
// overrides (spread below), NOT from an env var (Matt, 2026-09-09).
|
|
213
|
+
managedServing: false,
|
|
154
214
|
...(env.MODELRIG_REGISTRY_PATH ? { registryPath: env.MODELRIG_REGISTRY_PATH } : {}),
|
|
155
215
|
keys: {
|
|
156
216
|
...(env.GEMINI_API_KEY ? { gemini: env.GEMINI_API_KEY } : {}),
|
|
@@ -161,6 +221,8 @@ function loadConfigFromEnv(overrides) {
|
|
|
161
221
|
// A1 hosts: ModelRig-scoped names on purpose (same doctrine as Tavily).
|
|
162
222
|
...(env.MODELRIG_DEEPINFRA_API_KEY ? { deepinfra: env.MODELRIG_DEEPINFRA_API_KEY } : {}),
|
|
163
223
|
...(env.MODELRIG_FIREWORKS_API_KEY ? { fireworks: env.MODELRIG_FIREWORKS_API_KEY } : {}),
|
|
224
|
+
// Z.ai (B4a): unprefixed vendor key (see PROVIDER_KEY_ENV).
|
|
225
|
+
...(env.ZAI_API_KEY ? { zai: env.ZAI_API_KEY } : {}),
|
|
164
226
|
},
|
|
165
227
|
...(budget !== undefined && Number.isFinite(budget) ? { envelopeBudgetUsd: budget } : {}),
|
|
166
228
|
...(env.MODELRIG_UNPRICED_RATE_USD_PER_MTOK &&
|
|
@@ -26,8 +26,10 @@ export type ContentSource = "template" | "variable" | "search" | "tool_result" |
|
|
|
26
26
|
export type TrustTier = "trusted" | "semi" | "untrusted";
|
|
27
27
|
/** The family a detector belongs to — used only as a receipt/registry label and
|
|
28
28
|
* to decide the fail-closed matrix (deterministic never fails a run open;
|
|
29
|
-
* classifier/sidecar absence degrades to a notice).
|
|
30
|
-
|
|
29
|
+
* classifier/sidecar/model absence or failure degrades to a notice). The T3
|
|
30
|
+
* `model` screen (SC-3) is a metered inference over the same interface: a signal
|
|
31
|
+
* into the deterministic actions, never a control (spec-sc3 §2). */
|
|
32
|
+
export type DetectorKind = "deterministic" | "classifier" | "sidecar" | "model";
|
|
31
33
|
/** The category of a finding. `pii:*` reuses scrub v1's ScrubDetectorType
|
|
32
34
|
* values; `entity:*` is dictionary/field typing; `injection:*` is the
|
|
33
35
|
* screening lane. Open string union — the value only ever appears as a COUNT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/detect/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;wBAEwB;AACxB,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,UAAU,GACV,QAAQ,GACR,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,SAAS,CAAC;AAEd,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/detect/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;wBAEwB;AACxB,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,UAAU,GACV,QAAQ,GACR,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,SAAS,CAAC;AAEd,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;AAEzD;;;;oEAIoE;AACpE,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhF;;;oCAGoC;AACpC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,EAAE,CAAC;AAExC;+DAC+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B;mEAC+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;oBAEoB;AACpB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B;6EACyE;IACzE,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;CAClE;AAED;;;0DAG0D;AAC1D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC;IACjD;gEAC4D;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SC-2 — deterministic HIPAA Safe Harbor identifier detectors (spec-sc2 §2).
|
|
3
|
+
*
|
|
4
|
+
* These EXTEND scrub v1 (S1: extend, don't twin) as new `Detector`s over the
|
|
5
|
+
* shared interface (src/detect/detector.ts) — `kind: "deterministic"`,
|
|
6
|
+
* `confidence: 1`. They live BESIDE scrub v1's five detectors, NOT inside
|
|
7
|
+
* `scrubContent`: adding one here never widens the custody scrub floor. The
|
|
8
|
+
* composition point is the screen policy `detectors: [...]` opt-in — a route
|
|
9
|
+
* turns a Safe Harbor detector on explicitly (spec-sc2 §2, builder confirmation:
|
|
10
|
+
* "never silently added to the custody scrub floor"). `scrubContent` and the
|
|
11
|
+
* five v1 detectors stay BYTE-IDENTICAL (golden).
|
|
12
|
+
*
|
|
13
|
+
* LEAK INVARIANT (spec-sc2 §1.4): a detector emits SPANS (offsets + type +
|
|
14
|
+
* confidence) — never the matched substring. The matched value is read only to
|
|
15
|
+
* validate (Luhn / VIN checksum / octet range / age bound) and is discarded
|
|
16
|
+
* immediately; nothing here returns, logs, or persists it.
|
|
17
|
+
*
|
|
18
|
+
* SCOPE (honest limits, stated in the coverage table): US-English-shaped,
|
|
19
|
+
* deterministic regex/checksum rules — NOT a model, NOT DLP. Free-text names and
|
|
20
|
+
* street addresses need the customer-run sidecar (src/screen/sidecar.ts); those
|
|
21
|
+
* classes are `sidecar`/`out-of-scope` in the coverage table, never claimed here.
|
|
22
|
+
* Recall on synthetic PHI is MEASURED by the SC-3 probe, not asserted here.
|
|
23
|
+
*/
|
|
24
|
+
import type { Detector } from "./detector";
|
|
25
|
+
/** The finding `type` a Safe Harbor detector emits — a `pii:*` COUNT label
|
|
26
|
+
* (spec-sc2 §5), never a value. Kept parallel to the detector `id` slug. */
|
|
27
|
+
export type SafeHarborType = "pii:date" | "pii:age_over_89" | "pii:fax" | "pii:url" | "pii:ip" | "pii:zip" | "pii:account_id" | "pii:license_id" | "pii:vin" | "pii:device_id";
|
|
28
|
+
/** VIN check-digit rule (position 9): weighted transliteration mod 11, where 10
|
|
29
|
+
* ⇒ 'X'. Separates a real VIN from any 17 alphanumerics — the difference between
|
|
30
|
+
* a false-positive flood and a claimable identifier. */
|
|
31
|
+
export declare function vinValid(vin: string): boolean;
|
|
32
|
+
/** The registry id of the convenience PACK — configuring it in a route's
|
|
33
|
+
* `screen.detectors` opts in to ALL ten deterministic Safe Harbor detectors at
|
|
34
|
+
* once. Individual `pii:<slug>@v1` ids opt in to just that one. */
|
|
35
|
+
export declare const SAFE_HARBOR_PACK_ID = "safe-harbor@v1";
|
|
36
|
+
/** All individual Safe Harbor detector ids, for policy validation. */
|
|
37
|
+
export declare const SAFE_HARBOR_IDS: ReadonlySet<string>;
|
|
38
|
+
/** True when `id` names a Safe Harbor detector (a `pii:<slug>@v1` or the pack).
|
|
39
|
+
* The screen policy validator uses this to accept the id at load time. */
|
|
40
|
+
export declare function isSafeHarborId(id: string): boolean;
|
|
41
|
+
/** Every Safe Harbor detector (one per type), for the pack. */
|
|
42
|
+
export declare function safeHarborDetectors(): Detector[];
|
|
43
|
+
/** The Safe Harbor detector for one id, or `undefined` if `id` is not one.
|
|
44
|
+
* `SAFE_HARBOR_PACK_ID` returns `undefined` here — the pack expands to
|
|
45
|
+
* {@link safeHarborDetectors}; a caller resolves the pack separately. */
|
|
46
|
+
export declare function safeHarborDetectorById(id: string): Detector | undefined;
|
|
47
|
+
/** The detector identities (id + version) for a configured id — the pack
|
|
48
|
+
* expands to all ten; a single id resolves to one. Used to populate the
|
|
49
|
+
* receipt's `detectors[]` at resolve time (counts-only, never a value). */
|
|
50
|
+
export declare function safeHarborIdentities(id: string): readonly {
|
|
51
|
+
id: string;
|
|
52
|
+
version: string;
|
|
53
|
+
}[];
|
|
54
|
+
/** Build the Detector instances a configured id contributes (pack ⇒ all ten,
|
|
55
|
+
* single id ⇒ one, unknown ⇒ none). */
|
|
56
|
+
export declare function safeHarborDetectorsFor(id: string): Detector[];
|
|
57
|
+
//# sourceMappingURL=safe-harbor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-harbor.d.ts","sourceRoot":"","sources":["../../src/detect/safe-harbor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAiC,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1E;4EAC4E;AAC5E,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,iBAAiB,GACjB,SAAS,GACT,SAAS,GACT,QAAQ,GACR,SAAS,GACT,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,GACT,eAAe,CAAC;AAoJpB;;wDAEwD;AACxD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAa7C;AA6CD;;mEAEmE;AACnE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,sEAAsE;AACtE,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAAmC,CAAC;AAEpF;0EAC0E;AAC1E,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAElD;AA8BD,+DAA+D;AAC/D,wBAAgB,mBAAmB,IAAI,QAAQ,EAAE,CAEhD;AAED;;yEAEyE;AACzE,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAGvE;AAED;;2EAE2E;AAC3E,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAG3F;AAED;uCACuC;AACvC,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,EAAE,CAI7D"}
|