@theoremjs/agents 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +1264 -2
- package/esm/_dnt.polyfills.d.ts +66 -0
- package/esm/_dnt.polyfills.js +51 -0
- package/esm/mod.d.ts +65 -0
- package/esm/mod.js +42 -0
- package/esm/package.json +3 -0
- package/esm/src/cli/bin.d.ts +7 -0
- package/esm/src/cli/bin.js +9 -0
- package/esm/src/cli/commands/bench.d.ts +6 -0
- package/esm/src/cli/commands/bench.js +458 -0
- package/esm/src/cli/commands/egress-compile.d.ts +17 -0
- package/esm/src/cli/commands/egress-compile.js +25 -0
- package/esm/src/cli/commands/eval.d.ts +37 -0
- package/esm/src/cli/commands/eval.js +190 -0
- package/esm/src/cli/commands/fuzz-canary.d.ts +15 -0
- package/esm/src/cli/commands/fuzz-canary.js +202 -0
- package/esm/src/cli/commands/fuzz-guardrails.d.ts +2 -0
- package/esm/src/cli/commands/fuzz-guardrails.js +5 -0
- package/esm/src/cli/commands/profile.d.ts +2 -0
- package/esm/src/cli/commands/profile.js +80 -0
- package/esm/src/cli/commands/run.d.ts +13 -0
- package/esm/src/cli/commands/run.js +45 -0
- package/esm/src/cli/commands/test.d.ts +25 -0
- package/esm/src/cli/commands/test.js +143 -0
- package/esm/src/cli/event-log.d.ts +15 -0
- package/esm/src/cli/event-log.js +136 -0
- package/esm/src/cli/index.d.ts +10 -0
- package/esm/src/cli/index.js +267 -0
- package/esm/src/cli/matrix/fixtures.d.ts +10 -0
- package/esm/src/cli/matrix/fixtures.js +72 -0
- package/esm/src/cli/matrix/synthesizer.d.ts +18 -0
- package/esm/src/cli/matrix/synthesizer.js +103 -0
- package/esm/src/evals/attachments.d.ts +4 -0
- package/esm/src/evals/attachments.js +53 -0
- package/esm/src/evals/breakdown.d.ts +28 -0
- package/esm/src/evals/breakdown.js +68 -0
- package/esm/src/evals/graders/answer.d.ts +13 -0
- package/esm/src/evals/graders/answer.js +133 -0
- package/esm/src/evals/graders/code.d.ts +64 -0
- package/esm/src/evals/graders/code.js +205 -0
- package/esm/src/evals/graders/judge.d.ts +20 -0
- package/esm/src/evals/graders/judge.js +365 -0
- package/esm/src/evals/graders/latency.d.ts +5 -0
- package/esm/src/evals/graders/latency.js +81 -0
- package/esm/src/evals/graders/live.d.ts +11 -0
- package/esm/src/evals/graders/live.js +40 -0
- package/esm/src/evals/graders/media.d.ts +18 -0
- package/esm/src/evals/graders/media.js +92 -0
- package/esm/src/evals/graders/shared.d.ts +11 -0
- package/esm/src/evals/graders/shared.js +62 -0
- package/esm/src/evals/graders/transcript.d.ts +17 -0
- package/esm/src/evals/graders/transcript.js +200 -0
- package/esm/src/evals/mod.d.ts +42 -0
- package/esm/src/evals/mod.js +30 -0
- package/esm/src/evals/record.d.ts +35 -0
- package/esm/src/evals/record.js +105 -0
- package/esm/src/evals/rubrics/catalog.d.ts +148 -0
- package/esm/src/evals/rubrics/catalog.js +846 -0
- package/esm/src/evals/rubrics/mod.d.ts +24 -0
- package/esm/src/evals/rubrics/mod.js +55 -0
- package/esm/src/evals/rubrics/mustache.d.ts +23 -0
- package/esm/src/evals/rubrics/mustache.js +154 -0
- package/esm/src/evals/rubrics/types.d.ts +54 -0
- package/esm/src/evals/rubrics/types.js +74 -0
- package/esm/src/evals/run.d.ts +118 -0
- package/esm/src/evals/run.js +452 -0
- package/esm/src/evals/suite.d.ts +19 -0
- package/esm/src/evals/suite.js +92 -0
- package/esm/src/evals/summary.d.ts +32 -0
- package/esm/src/evals/summary.js +30 -0
- package/esm/src/evals/trial.d.ts +27 -0
- package/esm/src/evals/trial.js +158 -0
- package/esm/src/evals/types.d.ts +260 -0
- package/esm/src/evals/types.js +126 -0
- package/esm/src/evals/verdict.d.ts +18 -0
- package/esm/src/evals/verdict.js +45 -0
- package/esm/src/guardrails/canary-gate.d.ts +21 -0
- package/esm/src/guardrails/canary-gate.js +40 -0
- package/esm/src/guardrails/canary.d.ts +112 -0
- package/esm/src/guardrails/canary.js +901 -0
- package/esm/src/guardrails/compile-egress.d.ts +11 -0
- package/esm/src/guardrails/compile-egress.js +11 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +22 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +303 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +5 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +202 -0
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +3 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +118 -0
- package/esm/src/guardrails/corpus/live-attacks.d.ts +13 -0
- package/esm/src/guardrails/corpus/live-attacks.js +224 -0
- package/esm/src/guardrails/corpus/mod.d.ts +7 -0
- package/esm/src/guardrails/corpus/mod.js +4 -0
- package/esm/src/guardrails/corpus/secrets.d.ts +12 -0
- package/esm/src/guardrails/corpus/secrets.js +16 -0
- package/esm/src/guardrails/corpus/strings.d.ts +23 -0
- package/esm/src/guardrails/corpus/strings.js +29 -0
- package/esm/src/guardrails/corpus/types.d.ts +32 -0
- package/esm/src/guardrails/corpus/types.js +1 -0
- package/esm/src/guardrails/egress-automata.d.ts +14 -0
- package/esm/src/guardrails/egress-automata.js +6059 -0
- package/esm/src/guardrails/egress-compiler.d.ts +33 -0
- package/esm/src/guardrails/egress-compiler.js +237 -0
- package/esm/src/guardrails/egress-patterns.d.ts +24 -0
- package/esm/src/guardrails/egress-patterns.js +32 -0
- package/esm/src/guardrails/egress-policy.d.ts +27 -0
- package/esm/src/guardrails/egress-policy.js +76 -0
- package/esm/src/guardrails/egress-rules.d.ts +54 -0
- package/esm/src/guardrails/egress-rules.js +49 -0
- package/esm/src/guardrails/egress-stream.d.ts +105 -0
- package/esm/src/guardrails/egress-stream.js +645 -0
- package/esm/src/guardrails/egress-urls.d.ts +83 -0
- package/esm/src/guardrails/egress-urls.js +917 -0
- package/esm/src/guardrails/egress.d.ts +106 -0
- package/esm/src/guardrails/egress.js +374 -0
- package/esm/src/guardrails/error.d.ts +26 -0
- package/esm/src/guardrails/error.js +91 -0
- package/esm/src/guardrails/event-schemas.d.ts +57 -0
- package/esm/src/guardrails/event-schemas.js +41 -0
- package/esm/src/guardrails/events.d.ts +9 -0
- package/esm/src/guardrails/events.js +42 -0
- package/esm/src/guardrails/hits.d.ts +8 -0
- package/esm/src/guardrails/hits.js +19 -0
- package/esm/src/guardrails/injection-patterns.d.ts +15 -0
- package/esm/src/guardrails/injection-patterns.js +94 -0
- package/esm/src/guardrails/injection.d.ts +14 -0
- package/esm/src/guardrails/injection.js +237 -0
- package/esm/src/guardrails/lexicon.d.ts +30 -0
- package/esm/src/guardrails/lexicon.js +478 -0
- package/esm/src/guardrails/live-outbound-gate.d.ts +54 -0
- package/esm/src/guardrails/live-outbound-gate.js +305 -0
- package/esm/src/guardrails/mod.d.ts +46 -0
- package/esm/src/guardrails/mod.js +29 -0
- package/esm/src/guardrails/network.d.ts +42 -0
- package/esm/src/guardrails/network.js +328 -0
- package/esm/src/guardrails/normalize.d.ts +6 -0
- package/esm/src/guardrails/normalize.js +132 -0
- package/esm/src/guardrails/policy.d.ts +19 -0
- package/esm/src/guardrails/policy.js +50 -0
- package/esm/src/guardrails/progressive-yield.d.ts +69 -0
- package/esm/src/guardrails/progressive-yield.js +237 -0
- package/esm/src/guardrails/prompt-echo.d.ts +38 -0
- package/esm/src/guardrails/prompt-echo.js +225 -0
- package/esm/src/guardrails/quota.d.ts +20 -0
- package/esm/src/guardrails/quota.js +80 -0
- package/esm/src/guardrails/rules.d.ts +56 -0
- package/esm/src/guardrails/rules.js +54 -0
- package/esm/src/guardrails/sanitize.d.ts +23 -0
- package/esm/src/guardrails/sanitize.js +184 -0
- package/esm/src/guardrails/sensitive.d.ts +29 -0
- package/esm/src/guardrails/sensitive.js +113 -0
- package/esm/src/guardrails/serialize.d.ts +14 -0
- package/esm/src/guardrails/serialize.js +37 -0
- package/esm/src/guardrails/testing.d.ts +9 -0
- package/esm/src/guardrails/testing.js +8 -0
- package/esm/src/guardrails/theorem-error.d.ts +18 -0
- package/esm/src/guardrails/theorem-error.js +53 -0
- package/esm/src/guardrails/thought-guard.d.ts +55 -0
- package/esm/src/guardrails/thought-guard.js +464 -0
- package/esm/src/guardrails/tool-directives.d.ts +19 -0
- package/esm/src/guardrails/tool-directives.js +109 -0
- package/esm/src/guardrails/tool-result.d.ts +61 -0
- package/esm/src/guardrails/tool-result.js +248 -0
- package/esm/src/guardrails/types.d.ts +242 -0
- package/esm/src/guardrails/types.js +54 -0
- package/esm/src/host/client-turn.d.ts +9 -0
- package/esm/src/host/client-turn.js +38 -0
- package/esm/src/host/mint-trace.d.ts +28 -0
- package/esm/src/host/mint-trace.js +59 -0
- package/esm/src/host/mod.d.ts +13 -0
- package/esm/src/host/mod.js +11 -0
- package/esm/src/host/readStreamingJsonStringField.d.ts +2 -0
- package/esm/src/host/readStreamingJsonStringField.js +68 -0
- package/esm/src/host/reply.d.ts +7 -0
- package/esm/src/host/reply.js +35 -0
- package/esm/src/interface/blocks.d.ts +8 -0
- package/esm/src/interface/blocks.js +213 -0
- package/esm/src/interface/composer-actions.d.ts +20 -0
- package/esm/src/interface/composer-actions.js +31 -0
- package/esm/src/interface/draft.d.ts +14 -0
- package/esm/src/interface/draft.js +28 -0
- package/esm/src/interface/from-profile.d.ts +12 -0
- package/esm/src/interface/from-profile.js +144 -0
- package/esm/src/interface/history.d.ts +40 -0
- package/esm/src/interface/history.js +269 -0
- package/esm/src/interface/inputs.d.ts +10 -0
- package/esm/src/interface/inputs.js +64 -0
- package/esm/src/interface/mod.d.ts +31 -0
- package/esm/src/interface/mod.js +21 -0
- package/esm/src/interface/models.d.ts +19 -0
- package/esm/src/interface/models.js +45 -0
- package/esm/src/interface/pending.d.ts +48 -0
- package/esm/src/interface/pending.js +146 -0
- package/esm/src/interface/profile-interface.d.ts +4 -0
- package/esm/src/interface/profile-interface.js +223 -0
- package/esm/src/interface/session.d.ts +64 -0
- package/esm/src/interface/session.js +121 -0
- package/esm/src/interface/tool-calls.d.ts +20 -0
- package/esm/src/interface/tool-calls.js +73 -0
- package/esm/src/interface/tool-invoke.d.ts +4 -0
- package/esm/src/interface/tool-invoke.js +20 -0
- package/esm/src/interface/tool-media.d.ts +9 -0
- package/esm/src/interface/tool-media.js +112 -0
- package/esm/src/interface/types.d.ts +213 -0
- package/esm/src/interface/types.js +4 -0
- package/esm/src/kernel/auth/credential-source.d.ts +23 -0
- package/esm/src/kernel/auth/credential-source.js +11 -0
- package/esm/src/kernel/auth/crypto.d.ts +51 -0
- package/esm/src/kernel/auth/crypto.js +161 -0
- package/esm/src/kernel/auth/mod.d.ts +5 -0
- package/esm/src/kernel/auth/mod.js +5 -0
- package/esm/src/kernel/auth/oauth.d.ts +17 -0
- package/esm/src/kernel/auth/oauth.js +438 -0
- package/esm/src/kernel/auth/scope-refusal.d.ts +9 -0
- package/esm/src/kernel/auth/scope-refusal.js +8 -0
- package/esm/src/kernel/auth/typed-secret.d.ts +13 -0
- package/esm/src/kernel/auth/typed-secret.js +23 -0
- package/esm/src/kernel/auth/types.d.ts +139 -0
- package/esm/src/kernel/auth/types.js +1 -0
- package/esm/src/kernel/default-scope.d.ts +34 -0
- package/esm/src/kernel/default-scope.js +72 -0
- package/esm/src/kernel/engine/compaction.d.ts +70 -0
- package/esm/src/kernel/engine/compaction.js +202 -0
- package/esm/src/kernel/engine/decision.d.ts +41 -0
- package/esm/src/kernel/engine/decision.js +412 -0
- package/esm/src/kernel/engine/hash.d.ts +6 -0
- package/esm/src/kernel/engine/hash.js +22 -0
- package/esm/src/kernel/engine/live-inbound.d.ts +9 -0
- package/esm/src/kernel/engine/live-inbound.js +19 -0
- package/esm/src/kernel/engine/live-ingress.d.ts +9 -0
- package/esm/src/kernel/engine/live-ingress.js +37 -0
- package/esm/src/kernel/engine/media-probe/audio.d.ts +7 -0
- package/esm/src/kernel/engine/media-probe/audio.js +342 -0
- package/esm/src/kernel/engine/media-probe/bytes.d.ts +6 -0
- package/esm/src/kernel/engine/media-probe/bytes.js +26 -0
- package/esm/src/kernel/engine/media-probe/image.d.ts +5 -0
- package/esm/src/kernel/engine/media-probe/image.js +171 -0
- package/esm/src/kernel/engine/media-probe/iso-bmff.d.ts +19 -0
- package/esm/src/kernel/engine/media-probe/iso-bmff.js +48 -0
- package/esm/src/kernel/engine/media-probe/matroska.d.ts +35 -0
- package/esm/src/kernel/engine/media-probe/matroska.js +226 -0
- package/esm/src/kernel/engine/media-probe/mp4.d.ts +22 -0
- package/esm/src/kernel/engine/media-probe/mp4.js +279 -0
- package/esm/src/kernel/engine/media-probe/opus.d.ts +4 -0
- package/esm/src/kernel/engine/media-probe/opus.js +23 -0
- package/esm/src/kernel/engine/media-probe/pdf.d.ts +5 -0
- package/esm/src/kernel/engine/media-probe/pdf.js +117 -0
- package/esm/src/kernel/engine/media-probe/video.d.ts +15 -0
- package/esm/src/kernel/engine/media-probe/video.js +49 -0
- package/esm/src/kernel/engine/record.d.ts +3 -0
- package/esm/src/kernel/engine/record.js +11 -0
- package/esm/src/kernel/engine/repair.d.ts +7 -0
- package/esm/src/kernel/engine/repair.js +36 -0
- package/esm/src/kernel/engine/runner/gates.d.ts +5 -0
- package/esm/src/kernel/engine/runner/gates.js +322 -0
- package/esm/src/kernel/engine/runner/mod.d.ts +15 -0
- package/esm/src/kernel/engine/runner/mod.js +574 -0
- package/esm/src/kernel/engine/runner/schema-validation.d.ts +14 -0
- package/esm/src/kernel/engine/runner/schema-validation.js +105 -0
- package/esm/src/kernel/engine/runner/stages.d.ts +28 -0
- package/esm/src/kernel/engine/runner/stages.js +48 -0
- package/esm/src/kernel/engine/runner/state.d.ts +76 -0
- package/esm/src/kernel/engine/runner/state.js +40 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +14 -0
- package/esm/src/kernel/engine/runner/steps.js +360 -0
- package/esm/src/kernel/engine/runner/stream.d.ts +40 -0
- package/esm/src/kernel/engine/runner/stream.js +225 -0
- package/esm/src/kernel/engine/runner/usage.d.ts +45 -0
- package/esm/src/kernel/engine/runner/usage.js +150 -0
- package/esm/src/kernel/engine/session/mod.d.ts +31 -0
- package/esm/src/kernel/engine/session/mod.js +951 -0
- package/esm/src/kernel/engine/session/session-trace.d.ts +115 -0
- package/esm/src/kernel/engine/session/session-trace.js +489 -0
- package/esm/src/kernel/engine/token-estimate.d.ts +77 -0
- package/esm/src/kernel/engine/token-estimate.js +218 -0
- package/esm/src/kernel/engine/tool-trace.d.ts +58 -0
- package/esm/src/kernel/engine/tool-trace.js +131 -0
- package/esm/src/kernel/engine/tree.d.ts +2 -0
- package/esm/src/kernel/engine/tree.js +17 -0
- package/esm/src/kernel/engine/turn-trace.d.ts +118 -0
- package/esm/src/kernel/engine/turn-trace.js +863 -0
- package/esm/src/kernel/engine/usage.d.ts +30 -0
- package/esm/src/kernel/engine/usage.js +134 -0
- package/esm/src/kernel/interaction-parts.d.ts +10 -0
- package/esm/src/kernel/interaction-parts.js +22 -0
- package/esm/src/kernel/mod.d.ts +47 -0
- package/esm/src/kernel/mod.js +30 -0
- package/esm/src/kernel/profile-graph.d.ts +140 -0
- package/esm/src/kernel/profile-graph.js +151 -0
- package/esm/src/kernel/profile-presence.d.ts +9 -0
- package/esm/src/kernel/profile-presence.js +143 -0
- package/esm/src/kernel/profile-scope.d.ts +36 -0
- package/esm/src/kernel/profile-scope.js +262 -0
- package/esm/src/kernel/registry/attachments.d.ts +35 -0
- package/esm/src/kernel/registry/attachments.js +211 -0
- package/esm/src/kernel/registry/catalog.d.ts +19 -0
- package/esm/src/kernel/registry/catalog.js +78 -0
- package/esm/src/kernel/registry/ingress.d.ts +8 -0
- package/esm/src/kernel/registry/ingress.js +134 -0
- package/esm/src/kernel/registry/kernel-registry.d.ts +12 -0
- package/esm/src/kernel/registry/kernel-registry.js +8 -0
- package/esm/src/kernel/registry/profile-outputs.d.ts +3 -0
- package/esm/src/kernel/registry/profile-outputs.js +7 -0
- package/esm/src/kernel/registry/profiles.d.ts +92 -0
- package/esm/src/kernel/registry/profiles.js +698 -0
- package/esm/src/kernel/registry/provider-request.d.ts +6 -0
- package/esm/src/kernel/registry/provider-request.js +42 -0
- package/esm/src/kernel/registry/resolve.d.ts +14 -0
- package/esm/src/kernel/registry/resolve.js +237 -0
- package/esm/src/kernel/registry/schemas.d.ts +9 -0
- package/esm/src/kernel/registry/schemas.js +25 -0
- package/esm/src/kernel/registry/sole-model.d.ts +2 -0
- package/esm/src/kernel/registry/sole-model.js +4 -0
- package/esm/src/kernel/registry/system-prompt.d.ts +8 -0
- package/esm/src/kernel/registry/system-prompt.js +33 -0
- package/esm/src/kernel/registry/system-role.d.ts +3 -0
- package/esm/src/kernel/registry/system-role.js +9 -0
- package/esm/src/kernel/registry/vault.d.ts +13 -0
- package/esm/src/kernel/registry/vault.js +14 -0
- package/esm/src/kernel/schema.d.ts +172 -0
- package/esm/src/kernel/schema.js +653 -0
- package/esm/src/kernel/scope.d.ts +22 -0
- package/esm/src/kernel/scope.js +25 -0
- package/esm/src/kernel/stages.d.ts +141 -0
- package/esm/src/kernel/stages.js +388 -0
- package/esm/src/kernel/stop.d.ts +93 -0
- package/esm/src/kernel/stop.js +125 -0
- package/esm/src/kernel/system-parts.d.ts +26 -0
- package/esm/src/kernel/system-parts.js +98 -0
- package/esm/src/kernel/tools/activity-label.d.ts +16 -0
- package/esm/src/kernel/tools/activity-label.js +209 -0
- package/esm/src/kernel/tools/events.d.ts +51 -0
- package/esm/src/kernel/tools/events.js +149 -0
- package/esm/src/kernel/tools/execute.d.ts +64 -0
- package/esm/src/kernel/tools/execute.js +801 -0
- package/esm/src/kernel/tools/gate-answer.d.ts +50 -0
- package/esm/src/kernel/tools/gate-answer.js +54 -0
- package/esm/src/kernel/tools/harness.d.ts +16 -0
- package/esm/src/kernel/tools/harness.js +42 -0
- package/esm/src/kernel/tools/invoke.d.ts +10 -0
- package/esm/src/kernel/tools/invoke.js +129 -0
- package/esm/src/kernel/tools/mcp-sessions.d.ts +20 -0
- package/esm/src/kernel/tools/mcp-sessions.js +64 -0
- package/esm/src/kernel/tools/mod.d.ts +9 -0
- package/esm/src/kernel/tools/mod.js +6 -0
- package/esm/src/kernel/tools/model-text.d.ts +11 -0
- package/esm/src/kernel/tools/model-text.js +25 -0
- package/esm/src/kernel/tools/permission.d.ts +6 -0
- package/esm/src/kernel/tools/permission.js +38 -0
- package/esm/src/kernel/tools/project.d.ts +8 -0
- package/esm/src/kernel/tools/project.js +25 -0
- package/esm/src/kernel/tools/registry.d.ts +20 -0
- package/esm/src/kernel/tools/registry.js +84 -0
- package/esm/src/kernel/tools/remote.d.ts +110 -0
- package/esm/src/kernel/tools/remote.js +998 -0
- package/esm/src/kernel/tools/resolve.d.ts +28 -0
- package/esm/src/kernel/tools/resolve.js +259 -0
- package/esm/src/kernel/tools/schema.d.ts +10 -0
- package/esm/src/kernel/tools/schema.js +174 -0
- package/esm/src/kernel/tools/signed-in-fetch.d.ts +18 -0
- package/esm/src/kernel/tools/signed-in-fetch.js +45 -0
- package/esm/src/kernel/tools/stage-run.d.ts +93 -0
- package/esm/src/kernel/tools/stage-run.js +140 -0
- package/esm/src/kernel/tools/types.d.ts +287 -0
- package/esm/src/kernel/tools/types.js +1 -0
- package/esm/src/kernel/turn-events.d.ts +599 -0
- package/esm/src/kernel/turn-events.js +425 -0
- package/esm/src/kernel/types.d.ts +884 -0
- package/esm/src/kernel/types.js +1 -0
- package/esm/src/kernel/util/base64.d.ts +2 -0
- package/esm/src/kernel/util/base64.js +13 -0
- package/esm/src/kernel/util/exact-type.d.ts +31 -0
- package/esm/src/kernel/util/exact-type.js +1 -0
- package/esm/src/kernel/util/find-last.d.ts +3 -0
- package/esm/src/kernel/util/find-last.js +9 -0
- package/esm/src/kernel/util/mime.d.ts +2 -0
- package/esm/src/kernel/util/mime.js +4 -0
- package/esm/src/kernel/util/record.d.ts +1 -0
- package/esm/src/kernel/util/record.js +3 -0
- package/esm/src/observability/destinations.d.ts +9 -0
- package/esm/src/observability/destinations.js +38 -0
- package/esm/src/observability/jsonl.d.ts +18 -0
- package/esm/src/observability/jsonl.js +117 -0
- package/esm/src/observability/mod.d.ts +22 -0
- package/esm/src/observability/mod.js +16 -0
- package/esm/src/observability/openinference.d.ts +11 -0
- package/esm/src/observability/openinference.js +205 -0
- package/esm/src/observability/otlp.d.ts +68 -0
- package/esm/src/observability/otlp.js +98 -0
- package/esm/src/observability/phoenix.d.ts +29 -0
- package/esm/src/observability/phoenix.js +71 -0
- package/esm/src/observability/policy.d.ts +14 -0
- package/esm/src/observability/policy.js +69 -0
- package/esm/src/observability/resolve-policy.d.ts +8 -0
- package/esm/src/observability/resolve-policy.js +58 -0
- package/esm/src/observability/spans.d.ts +16 -0
- package/esm/src/observability/spans.js +56 -0
- package/esm/src/observability/trace-catalog.d.ts +111 -0
- package/esm/src/observability/trace-catalog.js +865 -0
- package/esm/src/observability/trace-record.d.ts +23 -0
- package/esm/src/observability/trace-record.js +223 -0
- package/esm/src/observability/trace-schema.d.ts +54 -0
- package/esm/src/observability/trace-schema.js +59 -0
- package/esm/src/observability/trace-sink.d.ts +13 -0
- package/esm/src/observability/trace-sink.js +3 -0
- package/esm/src/observability/trace-span.d.ts +92 -0
- package/esm/src/observability/trace-span.js +199 -0
- package/esm/src/observability/trace.d.ts +11 -0
- package/esm/src/observability/trace.js +35 -0
- package/esm/src/observability/types.d.ts +85 -0
- package/esm/src/observability/types.js +3 -0
- package/esm/src/presets/google/speech-voices.d.ts +8 -0
- package/esm/src/presets/google/speech-voices.js +38 -0
- package/esm/src/presets/google-limits.d.ts +12 -0
- package/esm/src/presets/google-limits.js +18 -0
- package/esm/src/presets/google.d.ts +104 -0
- package/esm/src/presets/google.js +188 -0
- package/esm/src/presets/mod.d.ts +10 -0
- package/esm/src/presets/mod.js +9 -0
- package/esm/src/presets/openrouter.d.ts +13 -0
- package/esm/src/presets/openrouter.js +13 -0
- package/esm/src/presets/typesafe.d.ts +2 -0
- package/esm/src/presets/typesafe.js +2 -0
- package/esm/src/providers/create-provider.d.ts +21 -0
- package/esm/src/providers/create-provider.js +90 -0
- package/esm/src/providers/decision/usage.d.ts +3 -0
- package/esm/src/providers/decision/usage.js +25 -0
- package/esm/src/providers/google/api-error.d.ts +8 -0
- package/esm/src/providers/google/api-error.js +123 -0
- package/esm/src/providers/google/grounding.d.ts +5 -0
- package/esm/src/providers/google/grounding.js +226 -0
- package/esm/src/providers/google/interactions/framing.d.ts +15 -0
- package/esm/src/providers/google/interactions/framing.js +263 -0
- package/esm/src/providers/google/interactions/mod.d.ts +2 -0
- package/esm/src/providers/google/interactions/mod.js +2 -0
- package/esm/src/providers/google/interactions/steps.d.ts +12 -0
- package/esm/src/providers/google/interactions/steps.js +200 -0
- package/esm/src/providers/google/interactions/stream.d.ts +24 -0
- package/esm/src/providers/google/interactions/stream.js +297 -0
- package/esm/src/providers/google/keys.d.ts +20 -0
- package/esm/src/providers/google/keys.js +87 -0
- package/esm/src/providers/google/live/framing.d.ts +51 -0
- package/esm/src/providers/google/live/framing.js +597 -0
- package/esm/src/providers/google/live/mod.d.ts +7 -0
- package/esm/src/providers/google/live/mod.js +7 -0
- package/esm/src/providers/google/live/openapi-schema.d.ts +1 -0
- package/esm/src/providers/google/live/openapi-schema.js +42 -0
- package/esm/src/providers/google/live/session.d.ts +14 -0
- package/esm/src/providers/google/live/session.js +150 -0
- package/esm/src/providers/google/live/stream.d.ts +51 -0
- package/esm/src/providers/google/live/stream.js +263 -0
- package/esm/src/providers/google/thinking.d.ts +3 -0
- package/esm/src/providers/google/thinking.js +8 -0
- package/esm/src/providers/google/urls.d.ts +6 -0
- package/esm/src/providers/google/urls.js +6 -0
- package/esm/src/providers/google/usage.d.ts +7 -0
- package/esm/src/providers/google/usage.js +49 -0
- package/esm/src/providers/local/local.d.ts +12 -0
- package/esm/src/providers/local/local.js +186 -0
- package/esm/src/providers/local/mod.d.ts +8 -0
- package/esm/src/providers/local/mod.js +8 -0
- package/esm/src/providers/mod.d.ts +11 -0
- package/esm/src/providers/mod.js +7 -0
- package/esm/src/providers/openrouter/cache-control.d.ts +5 -0
- package/esm/src/providers/openrouter/cache-control.js +4 -0
- package/esm/src/providers/openrouter/chat.d.ts +64 -0
- package/esm/src/providers/openrouter/chat.js +490 -0
- package/esm/src/providers/openrouter/image.d.ts +24 -0
- package/esm/src/providers/openrouter/image.js +187 -0
- package/esm/src/providers/openrouter/openai/compat.d.ts +19 -0
- package/esm/src/providers/openrouter/openai/compat.js +162 -0
- package/esm/src/providers/openrouter/openai/image-payload.d.ts +9 -0
- package/esm/src/providers/openrouter/openai/image-payload.js +115 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +10 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.js +99 -0
- package/esm/src/providers/openrouter/openai/usage.d.ts +8 -0
- package/esm/src/providers/openrouter/openai/usage.js +56 -0
- package/esm/src/providers/openrouter/resolve-api-key.d.ts +3 -0
- package/esm/src/providers/openrouter/resolve-api-key.js +8 -0
- package/esm/src/providers/openrouter/speech.d.ts +18 -0
- package/esm/src/providers/openrouter/speech.js +109 -0
- package/esm/src/providers/probe.d.ts +5 -0
- package/esm/src/providers/probe.js +15 -0
- package/esm/src/providers/shared/builtin-wire.d.ts +4 -0
- package/esm/src/providers/shared/builtin-wire.js +9 -0
- package/esm/src/providers/shared/pcm.d.ts +14 -0
- package/esm/src/providers/shared/pcm.js +78 -0
- package/esm/src/providers/shared/response-identity.d.ts +11 -0
- package/esm/src/providers/shared/response-identity.js +12 -0
- package/esm/src/providers/shared/sse.d.ts +10 -0
- package/esm/src/providers/shared/sse.js +79 -0
- package/esm/src/providers/shared/structured-output.d.ts +4 -0
- package/esm/src/providers/shared/structured-output.js +11 -0
- package/esm/src/providers/shared/tool-args.d.ts +25 -0
- package/esm/src/providers/shared/tool-args.js +84 -0
- package/esm/src/providers/shared/upstream-tap.d.ts +8 -0
- package/esm/src/providers/shared/upstream-tap.js +85 -0
- package/esm/src/providers/shared/upstream-tape.d.ts +6 -0
- package/esm/src/providers/shared/upstream-tape.js +88 -0
- package/esm/src/providers/shared/vault.d.ts +13 -0
- package/esm/src/providers/shared/vault.js +41 -0
- package/esm/src/providers/types.d.ts +19 -0
- package/esm/src/providers/types.js +1 -0
- package/esm/src/surface/formats.d.ts +28 -0
- package/esm/src/surface/formats.js +139 -0
- package/esm/src/surface/mod.d.ts +14 -0
- package/esm/src/surface/mod.js +10 -0
- package/esm/src/surface/runtime.d.ts +40 -0
- package/esm/src/surface/runtime.js +439 -0
- package/esm/src/surface/tools.d.ts +15 -0
- package/esm/src/surface/tools.js +80 -0
- package/esm/src/surface/types.d.ts +104 -0
- package/esm/src/surface/types.js +4 -0
- package/package.json +108 -4
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { canaryOpeningFrom, createCanaryScanner, promptLeakCarry, RELEASED_LOOKBACK, } from './canary.js';
|
|
2
|
+
import { CANARY_HIT, promptEchoHits, runEnforcer } from './egress.js';
|
|
3
|
+
import { streamPlanOf } from './egress-stream.js';
|
|
4
|
+
import { TheoremError } from './error.js';
|
|
5
|
+
import { promptEchoHoldFrom, promptEchoScanFrom } from './prompt-echo.js';
|
|
6
|
+
import { EGRESS_RULES } from './rules.js';
|
|
7
|
+
/** Default lookback under a host `egress.enforce` the gate cannot read. */
|
|
8
|
+
const DEFAULT_HOLDBACK = 256;
|
|
9
|
+
/**
|
|
10
|
+
* Default lookback on Live under a host policy the gate cannot read, where the
|
|
11
|
+
* held transcript holds back audio too: the shortest that shows the host no
|
|
12
|
+
* character of any egress corpus match however the transcript is chunked
|
|
13
|
+
* (88), with a margin.
|
|
14
|
+
*/
|
|
15
|
+
const LIVE_DEFAULT_HOLDBACK = 96;
|
|
16
|
+
const PEM_BEGIN = '-----BEGIN';
|
|
17
|
+
/**
|
|
18
|
+
* Fixed lookback for a host policy the gate cannot read: `holdback`, or
|
|
19
|
+
* `DEFAULT_HOLDBACK`. The canary, the prompt echo and the bundled policy need
|
|
20
|
+
* none — each holds exactly the tail that could still start a match.
|
|
21
|
+
*/
|
|
22
|
+
function resolveHoldback(options, exact) {
|
|
23
|
+
if (exact) {
|
|
24
|
+
if (options.holdback !== undefined) {
|
|
25
|
+
throw new TheoremError('config', 'holdback applies only to a host egress.enforce; the bundled policy holds exactly');
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
return options.holdback ?? (options.enforce ? DEFAULT_HOLDBACK : 0);
|
|
30
|
+
}
|
|
31
|
+
function holdbackForWindow(window, base) {
|
|
32
|
+
// Incomplete PEM bodies can be large; do not release past BEGIN until END/flush.
|
|
33
|
+
const begin = window.lastIndexOf(PEM_BEGIN);
|
|
34
|
+
if (begin < 0)
|
|
35
|
+
return base;
|
|
36
|
+
const fromBegin = window.slice(begin);
|
|
37
|
+
if (/-----END (?:RSA )?PRIVATE KEY-----/.test(fromBegin))
|
|
38
|
+
return base;
|
|
39
|
+
return Math.max(base, window.length - begin);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The verdict for a match the stream settled: the policy's own, run on the
|
|
43
|
+
* window. The stream only ever settles a match the policy finds, so a policy
|
|
44
|
+
* that does not block here is out of step with it: blocked anyway.
|
|
45
|
+
*/
|
|
46
|
+
async function streamHitVerdict(enforce, hit, window, context) {
|
|
47
|
+
const verdict = await runEnforcer(enforce, { text: window }, context);
|
|
48
|
+
if ((verdict.action === 'block' || verdict.action === 'redact') && verdict.hits.length > 0) {
|
|
49
|
+
return verdict.hits;
|
|
50
|
+
}
|
|
51
|
+
return [{ rule: hit.rule, severity: hit.severity }];
|
|
52
|
+
}
|
|
53
|
+
/** Call `flush` when the stream ends to release the held tail. */
|
|
54
|
+
function createProgressiveYieldGate(options) {
|
|
55
|
+
const { context } = options;
|
|
56
|
+
const stream = options.enforce
|
|
57
|
+
? streamPlanOf(options.enforce)?.(context)
|
|
58
|
+
: undefined;
|
|
59
|
+
const baseHoldback = resolveHoldback(options, stream !== undefined);
|
|
60
|
+
const carry = context.canary ? (options.carry ?? '') : '';
|
|
61
|
+
let accumulated = '';
|
|
62
|
+
let emitted = 0;
|
|
63
|
+
/** The window from `emitted` on. Each piece of the reply is kept apart, so no step rereads the whole. */
|
|
64
|
+
let held = '';
|
|
65
|
+
/** The carry and the released window, as far back as the canary hold rereads. */
|
|
66
|
+
let released = carry.slice(-RELEASED_LOOKBACK);
|
|
67
|
+
/** The carry and window from where the next prompt echo scan may reach back to. */
|
|
68
|
+
let echoed = carry;
|
|
69
|
+
/** Where `echoed` starts in the carry and window. */
|
|
70
|
+
let echoedFrom = 0;
|
|
71
|
+
/**
|
|
72
|
+
* The carry and window from `openingBase` on, for the canary hold. No
|
|
73
|
+
* opening of a leak starts before `openingFrom`: a point further back than
|
|
74
|
+
* `RELEASED_LOOKBACK` that does not open one by now never will. So each
|
|
75
|
+
* step reads from there, not the whole held text.
|
|
76
|
+
*/
|
|
77
|
+
let opening = carry;
|
|
78
|
+
let openingBase = 0;
|
|
79
|
+
let openingFrom = 0;
|
|
80
|
+
/** Reads the carry, then the window as it grows. */
|
|
81
|
+
const scanner = context.canary ? createCanaryScanner(context.canary) : undefined;
|
|
82
|
+
scanner?.push(carry);
|
|
83
|
+
/**
|
|
84
|
+
* The system-prompt leak hits (canary, prompt echo) in the carry and this
|
|
85
|
+
* window. The canary scan reads each character once (`createCanaryScanner`)
|
|
86
|
+
* and the echo check rereads only its own short lookback
|
|
87
|
+
* (`promptEchoScanFrom`), so a long reply costs time in proportion to its
|
|
88
|
+
* length, not its square.
|
|
89
|
+
*/
|
|
90
|
+
function canaryWindowHits(fresh) {
|
|
91
|
+
const scanned = echoed.length;
|
|
92
|
+
echoed += fresh;
|
|
93
|
+
const from = promptEchoScanFrom(echoed, scanned);
|
|
94
|
+
echoed = echoed.slice(from);
|
|
95
|
+
echoedFrom += from;
|
|
96
|
+
return [
|
|
97
|
+
...(scanner?.push(fresh) ? [CANARY_HIT] : []),
|
|
98
|
+
...(context.privateSystem
|
|
99
|
+
? promptEchoHits(echoed, context.privateSystem, context.canary)
|
|
100
|
+
: []),
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The host policy's hits on the window. The bundled policy reads only the
|
|
105
|
+
* new fragment (`egress-stream.ts`) and runs whole only when a match
|
|
106
|
+
* settles; a policy the gate cannot read runs whole at every step. At the
|
|
107
|
+
* end (`fragment` unset) every policy runs whole.
|
|
108
|
+
*/
|
|
109
|
+
async function policyHits(window, fragment) {
|
|
110
|
+
if (!options.enforce) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
if (stream && fragment !== undefined) {
|
|
114
|
+
const hit = stream.push(fragment);
|
|
115
|
+
return hit ? await streamHitVerdict(options.enforce, hit, window, context) : null;
|
|
116
|
+
}
|
|
117
|
+
// Mid-stream the gate can only release or stop: emitted prefixes cannot be
|
|
118
|
+
// rewritten, so `redact` stops here and end-of-attempt egress applies the
|
|
119
|
+
// full verdict. `flag` is advisory and keeps the stream flowing.
|
|
120
|
+
const verdict = await runEnforcer(options.enforce, { text: window }, context);
|
|
121
|
+
if (verdict.action === 'block' || verdict.action === 'redact') {
|
|
122
|
+
return verdict.hits.length > 0
|
|
123
|
+
? verdict.hits
|
|
124
|
+
: [{ rule: EGRESS_RULES.blocked, severity: 'high' }];
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
async function scan(window, fragment) {
|
|
129
|
+
// The system-prompt leak checks always run, under a host policy too: it adds
|
|
130
|
+
// checks, it never replaces these (the guardrail invariant).
|
|
131
|
+
const leaks = context.canary ? canaryWindowHits(fragment ?? '') : [];
|
|
132
|
+
if (leaks.length > 0) {
|
|
133
|
+
return leaks;
|
|
134
|
+
}
|
|
135
|
+
return await policyHits(window, fragment);
|
|
136
|
+
}
|
|
137
|
+
/** Where the leak checks hold from: a canary opening, or words a prompt echo could grow from. */
|
|
138
|
+
function leakHoldFrom() {
|
|
139
|
+
if (!context.canary) {
|
|
140
|
+
return accumulated.length;
|
|
141
|
+
}
|
|
142
|
+
const echo = context.privateSystem
|
|
143
|
+
? echoHoldFrom(context.privateSystem, context.canary)
|
|
144
|
+
: held.length;
|
|
145
|
+
return emitted + Math.min(canaryFrom(context.canary), echo);
|
|
146
|
+
}
|
|
147
|
+
/** `canaryHoldFrom` on the held text, read from where an opening could start. */
|
|
148
|
+
function canaryFrom(canary) {
|
|
149
|
+
const shownTo = carry.length + emitted;
|
|
150
|
+
const from = Math.max(shownTo, openingFrom);
|
|
151
|
+
const lead = Math.max(openingBase, from - RELEASED_LOOKBACK);
|
|
152
|
+
let at = lead + canaryOpeningFrom(opening.slice(lead - openingBase), canary);
|
|
153
|
+
if (at < from && from > shownTo) {
|
|
154
|
+
// An opening the bound rules out: read the held text whole, and from there on.
|
|
155
|
+
opening = released + held;
|
|
156
|
+
openingBase = shownTo - released.length;
|
|
157
|
+
at = openingBase + canaryOpeningFrom(opening, canary);
|
|
158
|
+
}
|
|
159
|
+
openingFrom = Math.min(at, carry.length + accumulated.length - RELEASED_LOOKBACK);
|
|
160
|
+
const base = Math.max(openingBase, Math.max(shownTo, openingFrom) - RELEASED_LOOKBACK);
|
|
161
|
+
opening = opening.slice(base - openingBase);
|
|
162
|
+
openingBase = base;
|
|
163
|
+
return Math.max(0, at - shownTo);
|
|
164
|
+
}
|
|
165
|
+
/** `promptEchoHoldFrom` on the held text, read from its last few words. */
|
|
166
|
+
function echoHoldFrom(privateSystem, canary) {
|
|
167
|
+
// Until this window releases anything, its opening may continue the carry.
|
|
168
|
+
const lead = emitted === 0 ? carry : '';
|
|
169
|
+
const leadFrom = carry.length + emitted - lead.length;
|
|
170
|
+
const [text, from] = echoedFrom >= leadFrom ? [echoed, echoedFrom] : [lead + held, leadFrom];
|
|
171
|
+
return Math.max(0, from + promptEchoHoldFrom(text, privateSystem, canary) - carry.length - emitted);
|
|
172
|
+
}
|
|
173
|
+
/** Where the host policy holds from: exactly for the bundled one, a fixed lookback otherwise. */
|
|
174
|
+
function policyHoldFrom() {
|
|
175
|
+
if (stream) {
|
|
176
|
+
return stream.holdFrom();
|
|
177
|
+
}
|
|
178
|
+
const hold = options.enforce ? holdbackForWindow(accumulated, baseHoldback) : baseHoldback;
|
|
179
|
+
return accumulated.length - hold;
|
|
180
|
+
}
|
|
181
|
+
async function release(fragment) {
|
|
182
|
+
const hits = await scan(accumulated, fragment);
|
|
183
|
+
if (hits) {
|
|
184
|
+
return { blocked: true, hits };
|
|
185
|
+
}
|
|
186
|
+
const end = fragment === undefined ? accumulated.length : Math.min(leakHoldFrom(), policyHoldFrom());
|
|
187
|
+
const emit = take(Math.max(0, end - emitted));
|
|
188
|
+
return { blocked: false, emit };
|
|
189
|
+
}
|
|
190
|
+
/** Release the first `length` characters held. */
|
|
191
|
+
function take(length) {
|
|
192
|
+
const emit = held.slice(0, length);
|
|
193
|
+
held = held.slice(length);
|
|
194
|
+
emitted += emit.length;
|
|
195
|
+
if (context.canary)
|
|
196
|
+
released = (released + emit).slice(-RELEASED_LOOKBACK);
|
|
197
|
+
return emit;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
async process(fragment) {
|
|
201
|
+
if (!fragment) {
|
|
202
|
+
return { blocked: false, emit: '' };
|
|
203
|
+
}
|
|
204
|
+
accumulated += fragment;
|
|
205
|
+
held += fragment;
|
|
206
|
+
if (context.canary)
|
|
207
|
+
opening += fragment;
|
|
208
|
+
return await release(fragment);
|
|
209
|
+
},
|
|
210
|
+
async flush() {
|
|
211
|
+
return await release();
|
|
212
|
+
},
|
|
213
|
+
accumulated: () => accumulated,
|
|
214
|
+
unreleased: () => held,
|
|
215
|
+
drainUnreleased: () => take(held.length),
|
|
216
|
+
carryOut: () => context.canary
|
|
217
|
+
? promptLeakCarry(carry + accumulated, context.canary, context.privateSystem)
|
|
218
|
+
: '',
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Shared constructor for runTurn + Live: gate when canary and/or egress.enforce
|
|
223
|
+
* is active. `context.canary` is set only when the profile enabled canary minting.
|
|
224
|
+
*/
|
|
225
|
+
function createOutboundProgressiveGate(policy, context, carry) {
|
|
226
|
+
const egress = policy.egress;
|
|
227
|
+
if (!egress?.enforce && !context.canary) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return createProgressiveYieldGate({
|
|
231
|
+
context,
|
|
232
|
+
...(egress?.enforce ? { enforce: egress.enforce } : {}),
|
|
233
|
+
...(egress?.holdback === undefined ? {} : { holdback: egress.holdback }),
|
|
234
|
+
...(carry ? { carry } : {}),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
export { createOutboundProgressiveGate, createProgressiveYieldGate, DEFAULT_HOLDBACK, LIVE_DEFAULT_HOLDBACK, };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-prompt echo — the leak the canary cannot see.
|
|
3
|
+
*
|
|
4
|
+
* The canary proves the token leaked; a reply that restates the system prompt
|
|
5
|
+
* while leaving the token out trips nothing. This check reads the reply for a
|
|
6
|
+
* run of `PROMPT_ECHO_WORDS` consecutive words of one private stretch of the
|
|
7
|
+
* system prompt (`BoundSystem.private`); text the host marked shareable is
|
|
8
|
+
* not read, and no run reaches across it. Words are
|
|
9
|
+
* compared case-folded after Unicode compatibility folding, punctuation and
|
|
10
|
+
* markup between them ignored, and bare numbers skipped, so reformatting a
|
|
11
|
+
* dump as a numbered or bulleted list does not hide it. Where the prompt has
|
|
12
|
+
* the canary, any one word or none continues a run: a model told to hide the
|
|
13
|
+
* canary echoes the prompt around a stand-in for it. A streamed reply holds
|
|
14
|
+
* the words an echo could still grow from (`promptEchoHoldFrom`), so none of
|
|
15
|
+
* an echo reaches the host.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/** Consecutive system-prompt words that make a reply an echo of it. */
|
|
20
|
+
declare const PROMPT_ECHO_WORDS = 12;
|
|
21
|
+
/**
|
|
22
|
+
* Where an echo still being written could start: the first word of the
|
|
23
|
+
* longest run of words ending `text` that the system prompt also has, or the
|
|
24
|
+
* word still being written when that is earlier and could become a prompt
|
|
25
|
+
* word. Any echo that completes later starts there or after.
|
|
26
|
+
*/
|
|
27
|
+
declare function promptEchoHoldFrom(text: string, stretches: readonly string[], canary?: string): number;
|
|
28
|
+
/** Offsets `[start, end)` of `text` that repeat a private stretch, ordered by start. */
|
|
29
|
+
declare function promptEchoRanges(text: string, stretches: readonly string[], canary?: string): Array<[number, number]>;
|
|
30
|
+
/** Whether `text` repeats `PROMPT_ECHO_WORDS` consecutive words of a private stretch. */
|
|
31
|
+
declare function scanTextForPromptEcho(text: string, stretches: readonly string[], canary?: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Where a scan of `text` must start when everything before `from` was
|
|
34
|
+
* already scanned clean: at the word an echo run ending past `from` could
|
|
35
|
+
* start in.
|
|
36
|
+
*/
|
|
37
|
+
declare function promptEchoScanFrom(text: string, from: number): number;
|
|
38
|
+
export { PROMPT_ECHO_WORDS, promptEchoHoldFrom, promptEchoRanges, promptEchoScanFrom, scanTextForPromptEcho, };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-prompt echo — the leak the canary cannot see.
|
|
3
|
+
*
|
|
4
|
+
* The canary proves the token leaked; a reply that restates the system prompt
|
|
5
|
+
* while leaving the token out trips nothing. This check reads the reply for a
|
|
6
|
+
* run of `PROMPT_ECHO_WORDS` consecutive words of one private stretch of the
|
|
7
|
+
* system prompt (`BoundSystem.private`); text the host marked shareable is
|
|
8
|
+
* not read, and no run reaches across it. Words are
|
|
9
|
+
* compared case-folded after Unicode compatibility folding, punctuation and
|
|
10
|
+
* markup between them ignored, and bare numbers skipped, so reformatting a
|
|
11
|
+
* dump as a numbered or bulleted list does not hide it. Where the prompt has
|
|
12
|
+
* the canary, any one word or none continues a run: a model told to hide the
|
|
13
|
+
* canary echoes the prompt around a stand-in for it. A streamed reply holds
|
|
14
|
+
* the words an echo could still grow from (`promptEchoHoldFrom`), so none of
|
|
15
|
+
* an echo reaches the host.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/** Consecutive system-prompt words that make a reply an echo of it. */
|
|
20
|
+
const PROMPT_ECHO_WORDS = 12;
|
|
21
|
+
/** Words a scan rereads before new text: an echo run ending in it starts no earlier. */
|
|
22
|
+
const ECHO_LOOKBACK_WORDS = PROMPT_ECHO_WORDS;
|
|
23
|
+
const WORD = /[\p{L}\p{N}]+/gu;
|
|
24
|
+
const WORD_CHAR = /[\p{L}\p{N}]/u;
|
|
25
|
+
const NUMBER = /^\p{N}+$/u;
|
|
26
|
+
const ASCII = /^\p{ASCII}*$/u;
|
|
27
|
+
/** Most letters compatibility folding joins into one (a Hangul syllable from its jamo). */
|
|
28
|
+
const MAX_FOLD = 3;
|
|
29
|
+
/** The words a text is compared by, with the offsets each came from. */
|
|
30
|
+
function echoWords(text) {
|
|
31
|
+
const words = [];
|
|
32
|
+
for (const match of text.matchAll(WORD)) {
|
|
33
|
+
const word = match[0].normalize('NFKC').toLowerCase();
|
|
34
|
+
if (!NUMBER.test(word)) {
|
|
35
|
+
words.push({ word, at: match.index, to: match.index + match[0].length });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return words;
|
|
39
|
+
}
|
|
40
|
+
/** Where the canary stood in the prompt's words: any one word or none matches it. */
|
|
41
|
+
const SLOT = '\u0000';
|
|
42
|
+
/**
|
|
43
|
+
* The private stretches' words as a run can repeat them: as written, with the
|
|
44
|
+
* canary left out, and with the canary as `SLOT`.
|
|
45
|
+
*/
|
|
46
|
+
function promptReadings(stretches, canary) {
|
|
47
|
+
const token = canary ? echoWords(canary).map((entry) => entry.word) : [];
|
|
48
|
+
const readings = { plain: [], slotted: [] };
|
|
49
|
+
for (const stretch of stretches) {
|
|
50
|
+
const words = echoWords(stretch).map((entry) => entry.word);
|
|
51
|
+
readings.plain.push(words);
|
|
52
|
+
if (token.length === 0)
|
|
53
|
+
continue;
|
|
54
|
+
const slotted = [];
|
|
55
|
+
for (let at = 0; at < words.length;) {
|
|
56
|
+
if (token.every((word, k) => words[at + k] === word)) {
|
|
57
|
+
slotted.push(SLOT);
|
|
58
|
+
at += token.length;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
slotted.push(words[at]);
|
|
62
|
+
at++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!slotted.includes(SLOT))
|
|
66
|
+
continue;
|
|
67
|
+
readings.plain.push(slotted.filter((word) => word !== SLOT));
|
|
68
|
+
readings.slotted.push(slotted);
|
|
69
|
+
}
|
|
70
|
+
return readings;
|
|
71
|
+
}
|
|
72
|
+
/** A run with a slot, keyed by where the slot is and the words around it. */
|
|
73
|
+
function slotKey(run, slot) {
|
|
74
|
+
// Bare numbers are never words here, so the slot's index leads unambiguously.
|
|
75
|
+
return [slot, ...run.filter((_, k) => k !== slot)].join(' ');
|
|
76
|
+
}
|
|
77
|
+
/** A run may not start on the canary's place unless `leading`: a stand-in for it is not prompt text. */
|
|
78
|
+
function addRuns(set, readings, lengths, leading) {
|
|
79
|
+
for (const words of readings.plain) {
|
|
80
|
+
for (const length of lengths) {
|
|
81
|
+
for (let from = 0; from + length <= words.length; from++) {
|
|
82
|
+
set.plain.add(words.slice(from, from + length).join(' '));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const slotted of readings.slotted) {
|
|
87
|
+
for (const length of lengths) {
|
|
88
|
+
for (let from = 0; from + length <= slotted.length; from++) {
|
|
89
|
+
const run = slotted.slice(from, from + length);
|
|
90
|
+
const slot = run.indexOf(SLOT);
|
|
91
|
+
if (slot === -1 || (slot === 0 && !leading))
|
|
92
|
+
continue;
|
|
93
|
+
set.slotted.add(slotKey(run, slot));
|
|
94
|
+
set.slots.add(slot);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Where in `run` the canary's place fell when `set` has it: -1 for nowhere, undefined when not a run. */
|
|
100
|
+
function matchRun(set, run) {
|
|
101
|
+
if (set.plain.has(run.join(' ')))
|
|
102
|
+
return -1;
|
|
103
|
+
for (const slot of set.slots) {
|
|
104
|
+
if (slot < run.length && set.slotted.has(slotKey(run, slot)))
|
|
105
|
+
return slot;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
function sameStretches(a, b) {
|
|
110
|
+
return a === b || (a.length === b.length && a.every((stretch, k) => stretch === b[k]));
|
|
111
|
+
}
|
|
112
|
+
let gramsCache;
|
|
113
|
+
/** Every run of `PROMPT_ECHO_WORDS` words in a private stretch. */
|
|
114
|
+
function promptGrams(stretches, canary) {
|
|
115
|
+
if (gramsCache &&
|
|
116
|
+
gramsCache.canary === canary &&
|
|
117
|
+
sameStretches(gramsCache.stretches, stretches)) {
|
|
118
|
+
return gramsCache.grams;
|
|
119
|
+
}
|
|
120
|
+
const grams = { plain: new Set(), slotted: new Set(), slots: new Set() };
|
|
121
|
+
addRuns(grams, promptReadings(stretches, canary), [PROMPT_ECHO_WORDS], true);
|
|
122
|
+
gramsCache = { stretches, canary, grams };
|
|
123
|
+
return grams;
|
|
124
|
+
}
|
|
125
|
+
let shapeCache;
|
|
126
|
+
function promptShape(stretches, canary) {
|
|
127
|
+
if (shapeCache &&
|
|
128
|
+
shapeCache.canary === canary &&
|
|
129
|
+
sameStretches(shapeCache.stretches, stretches)) {
|
|
130
|
+
return shapeCache.shape;
|
|
131
|
+
}
|
|
132
|
+
const readings = promptReadings(stretches, canary);
|
|
133
|
+
const shape = {
|
|
134
|
+
runs: { plain: new Set(), slotted: new Set(), slots: new Set() },
|
|
135
|
+
prefixes: new Set(),
|
|
136
|
+
longest: 0,
|
|
137
|
+
};
|
|
138
|
+
for (const word of readings.plain.flat()) {
|
|
139
|
+
shape.longest = Math.max(shape.longest, word.length);
|
|
140
|
+
for (let end = 1; end <= word.length && ASCII.test(word.charAt(end - 1)); end++) {
|
|
141
|
+
shape.prefixes.add(word.slice(0, end));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
addRuns(shape.runs, readings, Array.from({ length: PROMPT_ECHO_WORDS - 1 }, (_, k) => k + 1), false);
|
|
145
|
+
shapeCache = { stretches, canary, shape };
|
|
146
|
+
return shape;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Whether a word still being written could end as a word of the system
|
|
150
|
+
* prompt. ASCII folds letter by letter, so it must start one; other
|
|
151
|
+
* scripts can fold several letters into one (Hangul jamo, up to three), so
|
|
152
|
+
* only a word too long to fold down to any of them is ruled out.
|
|
153
|
+
*/
|
|
154
|
+
function mayBecomePromptWord(partial, shape) {
|
|
155
|
+
if (ASCII.test(partial)) {
|
|
156
|
+
return shape.prefixes.has(partial.toLowerCase());
|
|
157
|
+
}
|
|
158
|
+
return partial.length <= MAX_FOLD * shape.longest;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Where an echo still being written could start: the first word of the
|
|
162
|
+
* longest run of words ending `text` that the system prompt also has, or the
|
|
163
|
+
* word still being written when that is earlier and could become a prompt
|
|
164
|
+
* word. Any echo that completes later starts there or after.
|
|
165
|
+
*/
|
|
166
|
+
function promptEchoHoldFrom(text, stretches, canary) {
|
|
167
|
+
const tail = promptEchoScanFrom(text, text.length);
|
|
168
|
+
const words = echoWords(text.slice(tail));
|
|
169
|
+
let writing = text.length;
|
|
170
|
+
while (writing > 0 && WORD_CHAR.test(text.charAt(writing - 1)))
|
|
171
|
+
writing--;
|
|
172
|
+
const complete = words.filter((entry) => tail + entry.to < text.length || writing === text.length);
|
|
173
|
+
const shape = promptShape(stretches, canary);
|
|
174
|
+
const hold = mayBecomePromptWord(text.slice(writing), shape) ? writing : text.length;
|
|
175
|
+
for (let from = Math.max(0, complete.length - (PROMPT_ECHO_WORDS - 1)); from < complete.length; from++) {
|
|
176
|
+
const run = complete.slice(from).map((entry) => entry.word);
|
|
177
|
+
if (matchRun(shape.runs, run) !== undefined) {
|
|
178
|
+
return Math.min(hold, tail + complete[from].at);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return hold;
|
|
182
|
+
}
|
|
183
|
+
/** Offsets `[start, end)` of `text` that repeat a private stretch, ordered by start. */
|
|
184
|
+
function promptEchoRanges(text, stretches, canary) {
|
|
185
|
+
const grams = promptGrams(stretches, canary);
|
|
186
|
+
if (!text || grams.plain.size === 0) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
const words = echoWords(text);
|
|
190
|
+
const ranges = [];
|
|
191
|
+
for (let from = 0; from + PROMPT_ECHO_WORDS <= words.length; from++) {
|
|
192
|
+
const run = words.slice(from, from + PROMPT_ECHO_WORDS).map((entry) => entry.word);
|
|
193
|
+
const slot = matchRun(grams, run);
|
|
194
|
+
if (slot === undefined)
|
|
195
|
+
continue;
|
|
196
|
+
// A stand-in for the canary at either end is the model's, not the prompt's.
|
|
197
|
+
const first = slot === 0 ? from + 1 : from;
|
|
198
|
+
const last = slot === PROMPT_ECHO_WORDS - 1 ? from + slot - 1 : from + PROMPT_ECHO_WORDS - 1;
|
|
199
|
+
ranges.push([words[first]?.at ?? 0, words[last]?.to ?? 0]);
|
|
200
|
+
}
|
|
201
|
+
return ranges;
|
|
202
|
+
}
|
|
203
|
+
/** Whether `text` repeats `PROMPT_ECHO_WORDS` consecutive words of a private stretch. */
|
|
204
|
+
function scanTextForPromptEcho(text, stretches, canary) {
|
|
205
|
+
return promptEchoRanges(text, stretches, canary).length > 0;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Where a scan of `text` must start when everything before `from` was
|
|
209
|
+
* already scanned clean: at the word an echo run ending past `from` could
|
|
210
|
+
* start in.
|
|
211
|
+
*/
|
|
212
|
+
function promptEchoScanFrom(text, from) {
|
|
213
|
+
let at = Math.min(from, text.length);
|
|
214
|
+
for (let counted = 0; counted < ECHO_LOOKBACK_WORDS && at > 0;) {
|
|
215
|
+
while (at > 0 && !WORD_CHAR.test(text.charAt(at - 1)))
|
|
216
|
+
at--;
|
|
217
|
+
const end = at;
|
|
218
|
+
while (at > 0 && WORD_CHAR.test(text.charAt(at - 1)))
|
|
219
|
+
at--;
|
|
220
|
+
if (end > at && !NUMBER.test(text.slice(at, end)))
|
|
221
|
+
counted++;
|
|
222
|
+
}
|
|
223
|
+
return at;
|
|
224
|
+
}
|
|
225
|
+
export { PROMPT_ECHO_WORDS, promptEchoHoldFrom, promptEchoRanges, promptEchoScanFrom, scanTextForPromptEcho, };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Profile } from '../kernel/types.js';
|
|
2
|
+
import { TheoremError } from './theorem-error.js';
|
|
3
|
+
type QuotaSlotStatus = 'ok' | 'busy' | 'quota' | 'not_configured';
|
|
4
|
+
/** Returns whether a local request lacks the proxy header needed for quota identity. */
|
|
5
|
+
declare function skipQuota(peer: string, req: Request): boolean;
|
|
6
|
+
/** Resolves the client identity, preferring Cloudflare's header for local peers. */
|
|
7
|
+
declare function clientIp(peer: string, req: Request): string;
|
|
8
|
+
/**
|
|
9
|
+
* Reserves one profile-and-client daily quota slot. The reservation stays busy
|
|
10
|
+
* until `releaseSlot` is called, preventing concurrent turns from overspending.
|
|
11
|
+
*/
|
|
12
|
+
declare function takeSlot(profile: Profile, ip: string, now: number): QuotaSlotStatus;
|
|
13
|
+
/** Releases an active quota reservation without decrementing its daily count. */
|
|
14
|
+
declare function releaseSlot(profile: Profile, ip: string): void;
|
|
15
|
+
/** `undefined` when the profile has no quota configured. */
|
|
16
|
+
declare function quotaExhausted(profile: Profile): TheoremError | undefined;
|
|
17
|
+
/** Clears all process-local quota counters; intended for tests or host resets. */
|
|
18
|
+
declare function resetSlots(): void;
|
|
19
|
+
export type { QuotaSlotStatus };
|
|
20
|
+
export { clientIp, quotaExhausted, releaseSlot, resetSlots, skipQuota, takeSlot };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { resolveGuardrailPolicy } from './policy.js';
|
|
2
|
+
import { TheoremError } from './theorem-error.js';
|
|
3
|
+
const LOOPBACK = new Set(['127.0.0.1', '::1', 'localhost']);
|
|
4
|
+
const slots = new Map();
|
|
5
|
+
function utcDay(now) {
|
|
6
|
+
return new Date(now).toISOString().slice(0, 10);
|
|
7
|
+
}
|
|
8
|
+
function isLoopback(peer) {
|
|
9
|
+
return LOOPBACK.has(peer);
|
|
10
|
+
}
|
|
11
|
+
function cfConnectingIp(req) {
|
|
12
|
+
return req.headers.get('cf-connecting-ip')?.trim() ?? '';
|
|
13
|
+
}
|
|
14
|
+
function slotKey(profileId, ip) {
|
|
15
|
+
return `${profileId}:${ip}`;
|
|
16
|
+
}
|
|
17
|
+
/** Returns whether a local request lacks the proxy header needed for quota identity. */
|
|
18
|
+
function skipQuota(peer, req) {
|
|
19
|
+
return isLoopback(peer) && !cfConnectingIp(req);
|
|
20
|
+
}
|
|
21
|
+
/** Resolves the client identity, preferring Cloudflare's header for local peers. */
|
|
22
|
+
function clientIp(peer, req) {
|
|
23
|
+
if (isLoopback(peer)) {
|
|
24
|
+
const cf = cfConnectingIp(req);
|
|
25
|
+
if (cf) {
|
|
26
|
+
return cf;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (peer) {
|
|
30
|
+
return peer;
|
|
31
|
+
}
|
|
32
|
+
return 'unknown';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reserves one profile-and-client daily quota slot. The reservation stays busy
|
|
36
|
+
* until `releaseSlot` is called, preventing concurrent turns from overspending.
|
|
37
|
+
*/
|
|
38
|
+
function takeSlot(profile, ip, now) {
|
|
39
|
+
const quota = resolveGuardrailPolicy(profile.guardrails).quota;
|
|
40
|
+
if (!quota) {
|
|
41
|
+
return 'not_configured';
|
|
42
|
+
}
|
|
43
|
+
const day = utcDay(now);
|
|
44
|
+
const key = slotKey(profile.id, ip);
|
|
45
|
+
let slot = slots.get(key);
|
|
46
|
+
if (!slot || slot.day !== day) {
|
|
47
|
+
slot = { day, count: 0, busy: false };
|
|
48
|
+
slots.set(key, slot);
|
|
49
|
+
}
|
|
50
|
+
if (slot.busy) {
|
|
51
|
+
return 'busy';
|
|
52
|
+
}
|
|
53
|
+
if (slot.count >= quota.perDay) {
|
|
54
|
+
return 'quota';
|
|
55
|
+
}
|
|
56
|
+
slot.busy = true;
|
|
57
|
+
slot.count += 1;
|
|
58
|
+
return 'ok';
|
|
59
|
+
}
|
|
60
|
+
/** Releases an active quota reservation without decrementing its daily count. */
|
|
61
|
+
function releaseSlot(profile, ip) {
|
|
62
|
+
const slot = slots.get(slotKey(profile.id, ip));
|
|
63
|
+
if (slot) {
|
|
64
|
+
slot.busy = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** `undefined` when the profile has no quota configured. */
|
|
68
|
+
function quotaExhausted(profile) {
|
|
69
|
+
const quota = resolveGuardrailPolicy(profile.guardrails).quota;
|
|
70
|
+
if (!quota) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return new TheoremError('rate_limit', `${profile.id} used its daily quota of ${quota.perDay} turns`, // lexicon-exempt: internal diagnostic; the user reads the copy key
|
|
74
|
+
{ copy: { key: 'quota.exhausted', params: { perDay: quota.perDay } } });
|
|
75
|
+
}
|
|
76
|
+
/** Clears all process-local quota counters; intended for tests or host resets. */
|
|
77
|
+
function resetSlots() {
|
|
78
|
+
slots.clear();
|
|
79
|
+
}
|
|
80
|
+
export { clientIp, quotaExhausted, releaseSlot, resetSlots, skipQuota, takeSlot };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every rule id Theorem's own guardrails report, in one place. The trace
|
|
3
|
+
* catalog describes each one, and its description map is keyed by
|
|
4
|
+
* {@link GuardrailRule}, so a new id fails typecheck until it is described.
|
|
5
|
+
* A host's egress `enforce` hook may report ids of its own; those are not here.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** Injection phrasing or sensitive data stripped from text entering the turn. */
|
|
10
|
+
export declare const SANITIZE_RULES: {
|
|
11
|
+
readonly injection: "sanitize.injection";
|
|
12
|
+
readonly sensitive: "sanitize.sensitive";
|
|
13
|
+
};
|
|
14
|
+
/** What the bundled egress policy finds in the model's outbound text. */
|
|
15
|
+
export declare const EGRESS_RULES: {
|
|
16
|
+
readonly canary: "egress.canary-leak";
|
|
17
|
+
/** The reply repeats the system prompt (`guardrails.promptEcho`). */
|
|
18
|
+
readonly promptEcho: "egress.prompt-echo";
|
|
19
|
+
/**
|
|
20
|
+
* A provider-side built-in tool carried the canary or the system prompt. It
|
|
21
|
+
* ran before Theorem saw it: the data already left, so this is an incident.
|
|
22
|
+
*/
|
|
23
|
+
readonly providerToolLeak: "egress.provider-tool-leak";
|
|
24
|
+
readonly sensitive: "egress.sensitive-echo";
|
|
25
|
+
readonly boundary: "egress.system-boundary";
|
|
26
|
+
readonly injection: "egress.injection-echo";
|
|
27
|
+
/** An image loads a URL the model was not given, from a host not allowed. */
|
|
28
|
+
readonly image: "egress.image-exfil";
|
|
29
|
+
/** A link goes to a URL the model was not given, on a host not allowed. */
|
|
30
|
+
readonly link: "egress.link-exfil";
|
|
31
|
+
/** Payload could not be rendered for inspection — released output is unverified. */
|
|
32
|
+
readonly unscannable: "egress.unscannable";
|
|
33
|
+
readonly enforcerError: "egress.enforcer-error";
|
|
34
|
+
/** The progressive gate stopped the stream on a host verdict that named no rule. */
|
|
35
|
+
readonly blocked: "egress.blocked";
|
|
36
|
+
};
|
|
37
|
+
/** Remote tool content behaving like an instruction to the agent. */
|
|
38
|
+
export declare const DIRECTIVE_RULES: {
|
|
39
|
+
readonly toolName: "tool_result.names-callable-tool";
|
|
40
|
+
readonly imperative: "tool_result.imperative";
|
|
41
|
+
readonly authority: "tool_result.authority-claim";
|
|
42
|
+
};
|
|
43
|
+
/** The tool boundary: results and failures redacted, and calls flagged or blocked. */
|
|
44
|
+
export declare const TOOL_RULES: {
|
|
45
|
+
readonly resultRedacted: "tool_result.redacted";
|
|
46
|
+
readonly failureRedacted: "tool_failure.redacted";
|
|
47
|
+
readonly sensitiveArgument: "tool_call.sensitive-argument";
|
|
48
|
+
readonly taintedTurn: "tool_call.tainted-turn";
|
|
49
|
+
readonly steeredTurn: "tool_call.steered-turn";
|
|
50
|
+
};
|
|
51
|
+
/** A tool's network target refused before any request was made. */
|
|
52
|
+
export declare const NETWORK_RULES: {
|
|
53
|
+
readonly blocked: "network.blocked";
|
|
54
|
+
};
|
|
55
|
+
/** A rule id Theorem's own guardrails report. */
|
|
56
|
+
export type GuardrailRule = (typeof SANITIZE_RULES)[keyof typeof SANITIZE_RULES] | (typeof EGRESS_RULES)[keyof typeof EGRESS_RULES] | (typeof DIRECTIVE_RULES)[keyof typeof DIRECTIVE_RULES] | (typeof TOOL_RULES)[keyof typeof TOOL_RULES] | (typeof NETWORK_RULES)[keyof typeof NETWORK_RULES];
|