@smthrs/harness 0.0.0-stage → 1.0.0-rc.4
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 +387 -0
- package/LICENSE +21 -0
- package/README.md +138 -2
- package/dist/cjs/AgentEvent.d.ts +3092 -0
- package/dist/cjs/AgentEvent.d.ts.map +1 -0
- package/dist/cjs/AgentEvent.js +1116 -0
- package/dist/cjs/AgentEvent.js.map +7 -0
- package/dist/cjs/CallLedger.d.ts +378 -0
- package/dist/cjs/CallLedger.d.ts.map +1 -0
- package/dist/cjs/CallLedger.js +240 -0
- package/dist/cjs/CallLedger.js.map +7 -0
- package/dist/cjs/Cell.d.ts +774 -0
- package/dist/cjs/Cell.d.ts.map +1 -0
- package/dist/cjs/Cell.js +431 -0
- package/dist/cjs/Cell.js.map +7 -0
- package/dist/cjs/CellCalls.d.ts +115 -0
- package/dist/cjs/CellCalls.d.ts.map +1 -0
- package/dist/cjs/CellCalls.js +98 -0
- package/dist/cjs/CellCalls.js.map +7 -0
- package/dist/cjs/CellHistory.d.ts +102 -0
- package/dist/cjs/CellHistory.d.ts.map +1 -0
- package/dist/cjs/CellHistory.js +54 -0
- package/dist/cjs/CellHistory.js.map +7 -0
- package/dist/cjs/CellTurn.d.ts +1071 -0
- package/dist/cjs/CellTurn.d.ts.map +1 -0
- package/dist/cjs/CellTurn.js +2618 -0
- package/dist/cjs/CellTurn.js.map +7 -0
- package/dist/cjs/CellValidation.d.ts +94 -0
- package/dist/cjs/CellValidation.d.ts.map +1 -0
- package/dist/cjs/CellValidation.js +218 -0
- package/dist/cjs/CellValidation.js.map +7 -0
- package/dist/cjs/Compaction.d.ts +158 -0
- package/dist/cjs/Compaction.d.ts.map +1 -0
- package/dist/cjs/Compaction.js +189 -0
- package/dist/cjs/Compaction.js.map +7 -0
- package/dist/cjs/CompletionClaim.d.ts +801 -0
- package/dist/cjs/CompletionClaim.d.ts.map +1 -0
- package/dist/cjs/CompletionClaim.js +303 -0
- package/dist/cjs/CompletionClaim.js.map +7 -0
- package/dist/cjs/ContextWindow.d.ts +435 -0
- package/dist/cjs/ContextWindow.d.ts.map +1 -0
- package/dist/cjs/ContextWindow.js +319 -0
- package/dist/cjs/ContextWindow.js.map +7 -0
- package/dist/cjs/EngineLike.d.ts +546 -0
- package/dist/cjs/EngineLike.d.ts.map +1 -0
- package/dist/cjs/EngineLike.js +114 -0
- package/dist/cjs/EngineLike.js.map +7 -0
- package/dist/cjs/ExternalTranscript.d.ts +349 -0
- package/dist/cjs/ExternalTranscript.d.ts.map +1 -0
- package/dist/cjs/ExternalTranscript.js +826 -0
- package/dist/cjs/ExternalTranscript.js.map +7 -0
- package/dist/cjs/FailedCall.d.ts +132 -0
- package/dist/cjs/FailedCall.d.ts.map +1 -0
- package/dist/cjs/FailedCall.js +53 -0
- package/dist/cjs/FailedCall.js.map +7 -0
- package/dist/cjs/FlowBinding.d.ts +289 -0
- package/dist/cjs/FlowBinding.d.ts.map +1 -0
- package/dist/cjs/FlowBinding.js +251 -0
- package/dist/cjs/FlowBinding.js.map +7 -0
- package/dist/cjs/HarnessError.d.ts +57 -0
- package/dist/cjs/HarnessError.d.ts.map +1 -0
- package/dist/cjs/HarnessError.js +75 -0
- package/dist/cjs/HarnessError.js.map +7 -0
- package/dist/cjs/Judgement.d.ts +289 -0
- package/dist/cjs/Judgement.d.ts.map +1 -0
- package/dist/cjs/Judgement.js +240 -0
- package/dist/cjs/Judgement.js.map +7 -0
- package/dist/cjs/Monitor.d.ts +374 -0
- package/dist/cjs/Monitor.d.ts.map +1 -0
- package/dist/cjs/Monitor.js +233 -0
- package/dist/cjs/Monitor.js.map +7 -0
- package/dist/cjs/NarrowedCheck.d.ts +523 -0
- package/dist/cjs/NarrowedCheck.d.ts.map +1 -0
- package/dist/cjs/NarrowedCheck.js +263 -0
- package/dist/cjs/NarrowedCheck.js.map +7 -0
- package/dist/cjs/Notifications.d.ts +42 -0
- package/dist/cjs/Notifications.d.ts.map +1 -0
- package/dist/cjs/Notifications.js +177 -0
- package/dist/cjs/Notifications.js.map +7 -0
- package/dist/cjs/Plan.d.ts +127 -0
- package/dist/cjs/Plan.d.ts.map +1 -0
- package/dist/cjs/Plan.js +77 -0
- package/dist/cjs/Plan.js.map +7 -0
- package/dist/cjs/QuickJSSandbox.d.ts +151 -0
- package/dist/cjs/QuickJSSandbox.d.ts.map +1 -0
- package/dist/cjs/QuickJSSandbox.js +987 -0
- package/dist/cjs/QuickJSSandbox.js.map +7 -0
- package/dist/cjs/Relevance.d.ts +213 -0
- package/dist/cjs/Relevance.d.ts.map +1 -0
- package/dist/cjs/Relevance.js +183 -0
- package/dist/cjs/Relevance.js.map +7 -0
- package/dist/cjs/Sandbox.d.ts +637 -0
- package/dist/cjs/Sandbox.d.ts.map +1 -0
- package/dist/cjs/Sandbox.js +260 -0
- package/dist/cjs/Sandbox.js.map +7 -0
- package/dist/cjs/Steering.d.ts +464 -0
- package/dist/cjs/Steering.d.ts.map +1 -0
- package/dist/cjs/Steering.js +153 -0
- package/dist/cjs/Steering.js.map +7 -0
- package/dist/cjs/StructuredOutput.d.ts +252 -0
- package/dist/cjs/StructuredOutput.d.ts.map +1 -0
- package/dist/cjs/StructuredOutput.js +266 -0
- package/dist/cjs/StructuredOutput.js.map +7 -0
- package/dist/cjs/Sufficiency.d.ts +195 -0
- package/dist/cjs/Sufficiency.d.ts.map +1 -0
- package/dist/cjs/Sufficiency.js +110 -0
- package/dist/cjs/Sufficiency.js.map +7 -0
- package/dist/cjs/Supervisor.d.ts +719 -0
- package/dist/cjs/Supervisor.d.ts.map +1 -0
- package/dist/cjs/Supervisor.js +313 -0
- package/dist/cjs/Supervisor.js.map +7 -0
- package/dist/cjs/Tokens.d.ts +86 -0
- package/dist/cjs/Tokens.d.ts.map +1 -0
- package/dist/cjs/Tokens.js +72 -0
- package/dist/cjs/Tokens.js.map +7 -0
- package/dist/cjs/Transcript.d.ts +171 -0
- package/dist/cjs/Transcript.d.ts.map +1 -0
- package/dist/cjs/Transcript.js +342 -0
- package/dist/cjs/Transcript.js.map +7 -0
- package/dist/cjs/TruncatedOutput.d.ts +186 -0
- package/dist/cjs/TruncatedOutput.d.ts.map +1 -0
- package/dist/cjs/TruncatedOutput.js +143 -0
- package/dist/cjs/TruncatedOutput.js.map +7 -0
- package/dist/cjs/UnmovedTree.d.ts +113 -0
- package/dist/cjs/UnmovedTree.d.ts.map +1 -0
- package/dist/cjs/UnmovedTree.js +38 -0
- package/dist/cjs/UnmovedTree.js.map +7 -0
- package/dist/cjs/UnresolvedFailure.d.ts +196 -0
- package/dist/cjs/UnresolvedFailure.d.ts.map +1 -0
- package/dist/cjs/UnresolvedFailure.js +77 -0
- package/dist/cjs/UnresolvedFailure.js.map +7 -0
- package/dist/cjs/VacuousVerification.d.ts +237 -0
- package/dist/cjs/VacuousVerification.d.ts.map +1 -0
- package/dist/cjs/VacuousVerification.js +91 -0
- package/dist/cjs/VacuousVerification.js.map +7 -0
- package/dist/cjs/VariablesPanel.d.ts +117 -0
- package/dist/cjs/VariablesPanel.d.ts.map +1 -0
- package/dist/cjs/VariablesPanel.js +108 -0
- package/dist/cjs/VariablesPanel.js.map +7 -0
- package/dist/cjs/index.d.ts +172 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +99 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/bytes.d.ts +36 -0
- package/dist/cjs/internal/bytes.d.ts.map +1 -0
- package/dist/cjs/internal/bytes.js +57 -0
- package/dist/cjs/internal/bytes.js.map +7 -0
- package/dist/cjs/internal/cellPrompt.d.ts +122 -0
- package/dist/cjs/internal/cellPrompt.d.ts.map +1 -0
- package/dist/cjs/internal/cellPrompt.js +146 -0
- package/dist/cjs/internal/cellPrompt.js.map +7 -0
- package/dist/cjs/internal/compactable.d.ts +44 -0
- package/dist/cjs/internal/compactable.d.ts.map +1 -0
- package/dist/cjs/internal/compactable.js +56 -0
- package/dist/cjs/internal/compactable.js.map +7 -0
- package/dist/cjs/internal/compactionMarks.d.ts +278 -0
- package/dist/cjs/internal/compactionMarks.d.ts.map +1 -0
- package/dist/cjs/internal/compactionMarks.js +212 -0
- package/dist/cjs/internal/compactionMarks.js.map +7 -0
- package/dist/cjs/internal/demandText.d.ts +95 -0
- package/dist/cjs/internal/demandText.d.ts.map +1 -0
- package/dist/cjs/internal/demandText.js +70 -0
- package/dist/cjs/internal/demandText.js.map +7 -0
- package/dist/cjs/internal/elide.d.ts +109 -0
- package/dist/cjs/internal/elide.d.ts.map +1 -0
- package/dist/cjs/internal/elide.js +59 -0
- package/dist/cjs/internal/elide.js.map +7 -0
- package/dist/cjs/internal/frame.d.ts +463 -0
- package/dist/cjs/internal/frame.d.ts.map +1 -0
- package/dist/cjs/internal/frame.js +514 -0
- package/dist/cjs/internal/frame.js.map +7 -0
- package/dist/cjs/internal/nonNegativeSafeInt.d.ts +20 -0
- package/dist/cjs/internal/nonNegativeSafeInt.d.ts.map +1 -0
- package/dist/cjs/internal/nonNegativeSafeInt.js +29 -0
- package/dist/cjs/internal/nonNegativeSafeInt.js.map +7 -0
- package/dist/cjs/internal/paidUsage.d.ts +52 -0
- package/dist/cjs/internal/paidUsage.d.ts.map +1 -0
- package/dist/cjs/internal/paidUsage.js +70 -0
- package/dist/cjs/internal/paidUsage.js.map +7 -0
- package/dist/cjs/internal/printChannel.d.ts +233 -0
- package/dist/cjs/internal/printChannel.d.ts.map +1 -0
- package/dist/cjs/internal/printChannel.js +165 -0
- package/dist/cjs/internal/printChannel.js.map +7 -0
- package/dist/cjs/internal/printsObservation.d.ts +26 -0
- package/dist/cjs/internal/printsObservation.d.ts.map +1 -0
- package/dist/cjs/internal/printsObservation.js +27 -0
- package/dist/cjs/internal/printsObservation.js.map +7 -0
- package/dist/cjs/internal/refusal.d.ts +40 -0
- package/dist/cjs/internal/refusal.d.ts.map +1 -0
- package/dist/cjs/internal/refusal.js +45 -0
- package/dist/cjs/internal/refusal.js.map +7 -0
- package/dist/cjs/internal/supervision.d.ts +174 -0
- package/dist/cjs/internal/supervision.d.ts.map +1 -0
- package/dist/cjs/internal/supervision.js +402 -0
- package/dist/cjs/internal/supervision.js.map +7 -0
- package/dist/cjs/internal/unfinishedWork.d.ts +99 -0
- package/dist/cjs/internal/unfinishedWork.d.ts.map +1 -0
- package/dist/cjs/internal/unfinishedWork.js +80 -0
- package/dist/cjs/internal/unfinishedWork.js.map +7 -0
- package/dist/cjs/internal/unobservedCall.d.ts +112 -0
- package/dist/cjs/internal/unobservedCall.d.ts.map +1 -0
- package/dist/cjs/internal/unobservedCall.js +345 -0
- package/dist/cjs/internal/unobservedCall.js.map +7 -0
- package/dist/cjs/internal/untrustedData.d.ts +14 -0
- package/dist/cjs/internal/untrustedData.d.ts.map +1 -0
- package/dist/cjs/internal/untrustedData.js +30 -0
- package/dist/cjs/internal/untrustedData.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/AgentEvent.d.ts +3092 -0
- package/dist/esm/AgentEvent.d.ts.map +1 -0
- package/dist/esm/AgentEvent.js +1610 -0
- package/dist/esm/AgentEvent.js.map +1 -0
- package/dist/esm/CallLedger.d.ts +378 -0
- package/dist/esm/CallLedger.d.ts.map +1 -0
- package/dist/esm/CallLedger.js +506 -0
- package/dist/esm/CallLedger.js.map +1 -0
- package/dist/esm/Cell.d.ts +774 -0
- package/dist/esm/Cell.d.ts.map +1 -0
- package/dist/esm/Cell.js +772 -0
- package/dist/esm/Cell.js.map +1 -0
- package/dist/esm/CellCalls.d.ts +115 -0
- package/dist/esm/CellCalls.d.ts.map +1 -0
- package/dist/esm/CellCalls.js +97 -0
- package/dist/esm/CellCalls.js.map +1 -0
- package/dist/esm/CellHistory.d.ts +102 -0
- package/dist/esm/CellHistory.d.ts.map +1 -0
- package/dist/esm/CellHistory.js +91 -0
- package/dist/esm/CellHistory.js.map +1 -0
- package/dist/esm/CellTurn.d.ts +1071 -0
- package/dist/esm/CellTurn.d.ts.map +1 -0
- package/dist/esm/CellTurn.js +3410 -0
- package/dist/esm/CellTurn.js.map +1 -0
- package/dist/esm/CellValidation.d.ts +94 -0
- package/dist/esm/CellValidation.d.ts.map +1 -0
- package/dist/esm/CellValidation.js +335 -0
- package/dist/esm/CellValidation.js.map +1 -0
- package/dist/esm/Compaction.d.ts +158 -0
- package/dist/esm/Compaction.d.ts.map +1 -0
- package/dist/esm/Compaction.js +216 -0
- package/dist/esm/Compaction.js.map +1 -0
- package/dist/esm/CompletionClaim.d.ts +801 -0
- package/dist/esm/CompletionClaim.d.ts.map +1 -0
- package/dist/esm/CompletionClaim.js +833 -0
- package/dist/esm/CompletionClaim.js.map +1 -0
- package/dist/esm/ContextWindow.d.ts +435 -0
- package/dist/esm/ContextWindow.d.ts.map +1 -0
- package/dist/esm/ContextWindow.js +427 -0
- package/dist/esm/ContextWindow.js.map +1 -0
- package/dist/esm/EngineLike.d.ts +546 -0
- package/dist/esm/EngineLike.d.ts.map +1 -0
- package/dist/esm/EngineLike.js +218 -0
- package/dist/esm/EngineLike.js.map +1 -0
- package/dist/esm/ExternalTranscript.d.ts +349 -0
- package/dist/esm/ExternalTranscript.d.ts.map +1 -0
- package/dist/esm/ExternalTranscript.js +985 -0
- package/dist/esm/ExternalTranscript.js.map +1 -0
- package/dist/esm/FailedCall.d.ts +132 -0
- package/dist/esm/FailedCall.d.ts.map +1 -0
- package/dist/esm/FailedCall.js +131 -0
- package/dist/esm/FailedCall.js.map +1 -0
- package/dist/esm/FlowBinding.d.ts +289 -0
- package/dist/esm/FlowBinding.d.ts.map +1 -0
- package/dist/esm/FlowBinding.js +376 -0
- package/dist/esm/FlowBinding.js.map +1 -0
- package/dist/esm/HarnessError.d.ts +57 -0
- package/dist/esm/HarnessError.d.ts.map +1 -0
- package/dist/esm/HarnessError.js +85 -0
- package/dist/esm/HarnessError.js.map +1 -0
- package/dist/esm/Judgement.d.ts +289 -0
- package/dist/esm/Judgement.d.ts.map +1 -0
- package/dist/esm/Judgement.js +305 -0
- package/dist/esm/Judgement.js.map +1 -0
- package/dist/esm/Monitor.d.ts +374 -0
- package/dist/esm/Monitor.d.ts.map +1 -0
- package/dist/esm/Monitor.js +370 -0
- package/dist/esm/Monitor.js.map +1 -0
- package/dist/esm/NarrowedCheck.d.ts +523 -0
- package/dist/esm/NarrowedCheck.d.ts.map +1 -0
- package/dist/esm/NarrowedCheck.js +612 -0
- package/dist/esm/NarrowedCheck.js.map +1 -0
- package/dist/esm/Notifications.d.ts +42 -0
- package/dist/esm/Notifications.d.ts.map +1 -0
- package/dist/esm/Notifications.js +215 -0
- package/dist/esm/Notifications.js.map +1 -0
- package/dist/esm/Plan.d.ts +127 -0
- package/dist/esm/Plan.d.ts.map +1 -0
- package/dist/esm/Plan.js +97 -0
- package/dist/esm/Plan.js.map +1 -0
- package/dist/esm/QuickJSSandbox.d.ts +151 -0
- package/dist/esm/QuickJSSandbox.d.ts.map +1 -0
- package/dist/esm/QuickJSSandbox.js +1364 -0
- package/dist/esm/QuickJSSandbox.js.map +1 -0
- package/dist/esm/Relevance.d.ts +213 -0
- package/dist/esm/Relevance.d.ts.map +1 -0
- package/dist/esm/Relevance.js +254 -0
- package/dist/esm/Relevance.js.map +1 -0
- package/dist/esm/Sandbox.d.ts +637 -0
- package/dist/esm/Sandbox.d.ts.map +1 -0
- package/dist/esm/Sandbox.js +464 -0
- package/dist/esm/Sandbox.js.map +1 -0
- package/dist/esm/Steering.d.ts +464 -0
- package/dist/esm/Steering.d.ts.map +1 -0
- package/dist/esm/Steering.js +193 -0
- package/dist/esm/Steering.js.map +1 -0
- package/dist/esm/StructuredOutput.d.ts +252 -0
- package/dist/esm/StructuredOutput.d.ts.map +1 -0
- package/dist/esm/StructuredOutput.js +430 -0
- package/dist/esm/StructuredOutput.js.map +1 -0
- package/dist/esm/Sufficiency.d.ts +195 -0
- package/dist/esm/Sufficiency.d.ts.map +1 -0
- package/dist/esm/Sufficiency.js +207 -0
- package/dist/esm/Sufficiency.js.map +1 -0
- package/dist/esm/Supervisor.d.ts +719 -0
- package/dist/esm/Supervisor.d.ts.map +1 -0
- package/dist/esm/Supervisor.js +575 -0
- package/dist/esm/Supervisor.js.map +1 -0
- package/dist/esm/Tokens.d.ts +86 -0
- package/dist/esm/Tokens.d.ts.map +1 -0
- package/dist/esm/Tokens.js +92 -0
- package/dist/esm/Tokens.js.map +1 -0
- package/dist/esm/Transcript.d.ts +171 -0
- package/dist/esm/Transcript.d.ts.map +1 -0
- package/dist/esm/Transcript.js +424 -0
- package/dist/esm/Transcript.js.map +1 -0
- package/dist/esm/TruncatedOutput.d.ts +186 -0
- package/dist/esm/TruncatedOutput.d.ts.map +1 -0
- package/dist/esm/TruncatedOutput.js +257 -0
- package/dist/esm/TruncatedOutput.js.map +1 -0
- package/dist/esm/UnmovedTree.d.ts +113 -0
- package/dist/esm/UnmovedTree.d.ts.map +1 -0
- package/dist/esm/UnmovedTree.js +90 -0
- package/dist/esm/UnmovedTree.js.map +1 -0
- package/dist/esm/UnresolvedFailure.d.ts +196 -0
- package/dist/esm/UnresolvedFailure.d.ts.map +1 -0
- package/dist/esm/UnresolvedFailure.js +218 -0
- package/dist/esm/UnresolvedFailure.js.map +1 -0
- package/dist/esm/VacuousVerification.d.ts +237 -0
- package/dist/esm/VacuousVerification.d.ts.map +1 -0
- package/dist/esm/VacuousVerification.js +245 -0
- package/dist/esm/VacuousVerification.js.map +1 -0
- package/dist/esm/VariablesPanel.d.ts +117 -0
- package/dist/esm/VariablesPanel.d.ts.map +1 -0
- package/dist/esm/VariablesPanel.js +142 -0
- package/dist/esm/VariablesPanel.js.map +1 -0
- package/dist/esm/index.d.ts +172 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +172 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/bytes.d.ts +36 -0
- package/dist/esm/internal/bytes.d.ts.map +1 -0
- package/dist/esm/internal/bytes.js +70 -0
- package/dist/esm/internal/bytes.js.map +1 -0
- package/dist/esm/internal/cellPrompt.d.ts +122 -0
- package/dist/esm/internal/cellPrompt.d.ts.map +1 -0
- package/dist/esm/internal/cellPrompt.js +276 -0
- package/dist/esm/internal/cellPrompt.js.map +1 -0
- package/dist/esm/internal/compactable.d.ts +44 -0
- package/dist/esm/internal/compactable.d.ts.map +1 -0
- package/dist/esm/internal/compactable.js +71 -0
- package/dist/esm/internal/compactable.js.map +1 -0
- package/dist/esm/internal/compactionMarks.d.ts +278 -0
- package/dist/esm/internal/compactionMarks.d.ts.map +1 -0
- package/dist/esm/internal/compactionMarks.js +317 -0
- package/dist/esm/internal/compactionMarks.js.map +1 -0
- package/dist/esm/internal/demandText.d.ts +95 -0
- package/dist/esm/internal/demandText.d.ts.map +1 -0
- package/dist/esm/internal/demandText.js +128 -0
- package/dist/esm/internal/demandText.js.map +1 -0
- package/dist/esm/internal/elide.d.ts +109 -0
- package/dist/esm/internal/elide.d.ts.map +1 -0
- package/dist/esm/internal/elide.js +123 -0
- package/dist/esm/internal/elide.js.map +1 -0
- package/dist/esm/internal/frame.d.ts +463 -0
- package/dist/esm/internal/frame.d.ts.map +1 -0
- package/dist/esm/internal/frame.js +861 -0
- package/dist/esm/internal/frame.js.map +1 -0
- package/dist/esm/internal/nonNegativeSafeInt.d.ts +20 -0
- package/dist/esm/internal/nonNegativeSafeInt.d.ts.map +1 -0
- package/dist/esm/internal/nonNegativeSafeInt.js +20 -0
- package/dist/esm/internal/nonNegativeSafeInt.js.map +1 -0
- package/dist/esm/internal/paidUsage.d.ts +52 -0
- package/dist/esm/internal/paidUsage.d.ts.map +1 -0
- package/dist/esm/internal/paidUsage.js +72 -0
- package/dist/esm/internal/paidUsage.js.map +1 -0
- package/dist/esm/internal/printChannel.d.ts +233 -0
- package/dist/esm/internal/printChannel.d.ts.map +1 -0
- package/dist/esm/internal/printChannel.js +376 -0
- package/dist/esm/internal/printChannel.js.map +1 -0
- package/dist/esm/internal/printsObservation.d.ts +26 -0
- package/dist/esm/internal/printsObservation.d.ts.map +1 -0
- package/dist/esm/internal/printsObservation.js +29 -0
- package/dist/esm/internal/printsObservation.js.map +1 -0
- package/dist/esm/internal/refusal.d.ts +40 -0
- package/dist/esm/internal/refusal.d.ts.map +1 -0
- package/dist/esm/internal/refusal.js +47 -0
- package/dist/esm/internal/refusal.js.map +1 -0
- package/dist/esm/internal/supervision.d.ts +174 -0
- package/dist/esm/internal/supervision.d.ts.map +1 -0
- package/dist/esm/internal/supervision.js +485 -0
- package/dist/esm/internal/supervision.js.map +1 -0
- package/dist/esm/internal/unfinishedWork.d.ts +99 -0
- package/dist/esm/internal/unfinishedWork.d.ts.map +1 -0
- package/dist/esm/internal/unfinishedWork.js +85 -0
- package/dist/esm/internal/unfinishedWork.js.map +1 -0
- package/dist/esm/internal/unobservedCall.d.ts +112 -0
- package/dist/esm/internal/unobservedCall.d.ts.map +1 -0
- package/dist/esm/internal/unobservedCall.js +501 -0
- package/dist/esm/internal/unobservedCall.js.map +1 -0
- package/dist/esm/internal/untrustedData.d.ts +14 -0
- package/dist/esm/internal/untrustedData.d.ts.map +1 -0
- package/dist/esm/internal/untrustedData.js +15 -0
- package/dist/esm/internal/untrustedData.js.map +1 -0
- package/docs/README.md +129 -0
- package/docs/api.md +1869 -0
- package/docs/concepts.md +238 -0
- package/docs/external-transcripts.md +245 -0
- package/docs/guides/bind-flows.md +167 -0
- package/docs/guides/drive-the-loop.md +265 -0
- package/docs/guides/run-cells.md +262 -0
- package/docs/guides/workerd.md +144 -0
- package/docs/installation.md +69 -0
- package/docs/quickstart.md +121 -0
- package/docs/reference.md +954 -0
- package/docs/troubleshooting.md +177 -0
- package/package.json +463 -3
- package/src/AgentEvent.ts +1772 -0
- package/src/CallLedger.ts +560 -0
- package/src/Cell.ts +926 -0
- package/src/CellCalls.ts +198 -0
- package/src/CellHistory.ts +128 -0
- package/src/CellTurn.ts +4450 -0
- package/src/CellValidation.ts +382 -0
- package/src/Compaction.ts +330 -0
- package/src/CompletionClaim.ts +1013 -0
- package/src/ContextWindow.ts +669 -0
- package/src/EngineLike.ts +614 -0
- package/src/ExternalTranscript.ts +1142 -0
- package/src/FailedCall.ts +163 -0
- package/src/FlowBinding.ts +603 -0
- package/src/HarnessError.ts +98 -0
- package/src/Judgement.ts +526 -0
- package/src/Monitor.ts +579 -0
- package/src/NarrowedCheck.ts +694 -0
- package/src/Notifications.ts +262 -0
- package/src/Plan.ts +113 -0
- package/src/QuickJSSandbox.ts +1557 -0
- package/src/Relevance.ts +352 -0
- package/src/Sandbox.ts +908 -0
- package/src/Steering.ts +405 -0
- package/src/StructuredOutput.ts +484 -0
- package/src/Sufficiency.ts +247 -0
- package/src/Supervisor.ts +798 -0
- package/src/Tokens.ts +108 -0
- package/src/Transcript.ts +513 -0
- package/src/TruncatedOutput.ts +297 -0
- package/src/UnmovedTree.ts +121 -0
- package/src/UnresolvedFailure.ts +240 -0
- package/src/VacuousVerification.ts +280 -0
- package/src/VariablesPanel.ts +165 -0
- package/src/index.ts +204 -0
- package/src/internal/bytes.ts +70 -0
- package/src/internal/cellPrompt.ts +337 -0
- package/src/internal/compactable.ts +76 -0
- package/src/internal/compactionMarks.ts +454 -0
- package/src/internal/demandText.ts +145 -0
- package/src/internal/elide.ts +130 -0
- package/src/internal/frame.ts +1178 -0
- package/src/internal/nonNegativeSafeInt.ts +24 -0
- package/src/internal/paidUsage.ts +90 -0
- package/src/internal/printChannel.ts +434 -0
- package/src/internal/printsObservation.ts +31 -0
- package/src/internal/refusal.ts +53 -0
- package/src/internal/supervision.ts +652 -0
- package/src/internal/unfinishedWork.ts +123 -0
- package/src/internal/unobservedCall.ts +536 -0
- package/src/internal/untrustedData.ts +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Supervisor.d.ts","sourceRoot":"","sources":["../../src/Supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAA;AACtD,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,WAAW,KAAG,aAAa,CAAC,OAAO,CACe,CAAA;AAErF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,qDAAsD,CAAA;AAElF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAK3D;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,GAAI,SAAS,WAAW,KAAG,OAAoE,CAAA;AAEnH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,WAAW,KAAG,aAAa,CAAC,cAAc,CAAyC,CAAA;AAEvH;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK,GAAI,UAAU,QAAQ,EAAE,SAAS,OAAO,KAAG,MA8B5D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,QAAQ,KAAG,MAAqE,CAAA;AAEpH;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,MAAwD,CAAA;AAE5F;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,MAInC,CAAA;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,MAA6C,CAAA"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Supervisor_exports = {};
|
|
30
|
+
__export(Supervisor_exports, {
|
|
31
|
+
Frame: () => Frame,
|
|
32
|
+
Help: () => Help,
|
|
33
|
+
Level: () => Level,
|
|
34
|
+
Memory: () => Memory,
|
|
35
|
+
Recalled: () => Recalled,
|
|
36
|
+
Signals: () => Signals,
|
|
37
|
+
Skill: () => Skill,
|
|
38
|
+
Snapshot: () => Snapshot,
|
|
39
|
+
calledLimit: () => calledLimit,
|
|
40
|
+
classifier: () => classifier,
|
|
41
|
+
classifierFor: () => classifierFor,
|
|
42
|
+
closeGraceMs: () => closeGraceMs,
|
|
43
|
+
compacting: () => compacting,
|
|
44
|
+
contextAt: () => contextAt,
|
|
45
|
+
contextTriggers: () => contextTriggers,
|
|
46
|
+
crosses: () => crosses,
|
|
47
|
+
emotions: () => emotions,
|
|
48
|
+
frameBytes: () => frameBytes,
|
|
49
|
+
head: () => head,
|
|
50
|
+
levels: () => levels,
|
|
51
|
+
memoryNone: () => memoryNone,
|
|
52
|
+
monitorPrefix: () => monitorPrefix,
|
|
53
|
+
nudge: () => nudge,
|
|
54
|
+
offTargetAt: () => offTargetAt,
|
|
55
|
+
prose: () => prose,
|
|
56
|
+
read: () => read,
|
|
57
|
+
recalledInsert: () => recalledInsert,
|
|
58
|
+
recalledLimit: () => recalledLimit,
|
|
59
|
+
recentFrames: () => recentFrames,
|
|
60
|
+
skill: () => skill,
|
|
61
|
+
skillBytes: () => skillBytes,
|
|
62
|
+
skillLimit: () => skillLimit,
|
|
63
|
+
suspectAt: () => suspectAt,
|
|
64
|
+
tail: () => tail,
|
|
65
|
+
thrashingAt: () => thrashingAt,
|
|
66
|
+
triggered: () => triggered,
|
|
67
|
+
triggers: () => triggers
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(Supervisor_exports);
|
|
70
|
+
var Classifier = __toESM(require("@smthrs/model/Classifier"), 1);
|
|
71
|
+
var Context = __toESM(require("effect/Context"), 1);
|
|
72
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
73
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
74
|
+
var elide = __toESM(require("./internal/elide.js"), 1);
|
|
75
|
+
var import_nonNegativeSafeInt = require("./internal/nonNegativeSafeInt.js");
|
|
76
|
+
var import_untrustedData = require("./internal/untrustedData.js");
|
|
77
|
+
var Judgement = __toESM(require("./Judgement.js"), 1);
|
|
78
|
+
const frameBytes = 1024;
|
|
79
|
+
const recentFrames = 3;
|
|
80
|
+
const recalledLimit = 6;
|
|
81
|
+
const closeGraceMs = 1500;
|
|
82
|
+
const thrashingAt = 0.5;
|
|
83
|
+
const offTargetAt = 0.5;
|
|
84
|
+
const suspectAt = 0.5;
|
|
85
|
+
const contextAt = 0.5;
|
|
86
|
+
const Level = Schema.Literals(["none", "mild", "strong"]);
|
|
87
|
+
const levels = ["none", "mild", "strong"];
|
|
88
|
+
const Help = Schema.Literals(["none", "clarification", "permission", "stuck", "risky_action"]);
|
|
89
|
+
const emotions = ["frustrated", "anxious", "scared", "confused", "confident"];
|
|
90
|
+
const Frame = Schema.Struct({
|
|
91
|
+
frame: import_nonNegativeSafeInt.NonNegativeSafeInt,
|
|
92
|
+
cell: Schema.String.annotate({ description: "The cell the model wrote, head kept" }),
|
|
93
|
+
prose: Schema.String.annotate({ description: "What the model wrote outside the cell, head kept" }),
|
|
94
|
+
printed: Schema.String.annotate({ description: "What the cell printed, newest bytes kept" }),
|
|
95
|
+
transition: Schema.Literals(["continue", "complete", "park", "raised", "rejected"]),
|
|
96
|
+
mutated: Schema.Boolean.annotate({ description: "Whether this frame changed the workspace" })
|
|
97
|
+
});
|
|
98
|
+
const Signals = Schema.Struct({
|
|
99
|
+
frame: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "The frame just closed, counting from zero" }),
|
|
100
|
+
maxFrames: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "The frame budget; zero is unbounded" }),
|
|
101
|
+
readOnlyFrames: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Consecutive frames that changed nothing" }),
|
|
102
|
+
repeatFrames: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({
|
|
103
|
+
description: "Consecutive frames that issued only calls already issued and changed nothing"
|
|
104
|
+
}),
|
|
105
|
+
mutations: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Frames that changed the workspace" }),
|
|
106
|
+
remoteMutations: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Writes recorded on trees the host cannot see" }),
|
|
107
|
+
treeMoved: Schema.Boolean.annotate({ description: "Whether the workspace differs from the tree the run opened on" }),
|
|
108
|
+
paths: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({
|
|
109
|
+
description: "Paths the closing workspace measurement covered; zero unmeasured"
|
|
110
|
+
}),
|
|
111
|
+
checksRun: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Distinct checks the run has run" }),
|
|
112
|
+
checksFailing: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Of those, how many last reported a failing status" }),
|
|
113
|
+
failuresUnanswered: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({
|
|
114
|
+
description: "Failing checks no later passing check has answered"
|
|
115
|
+
}),
|
|
116
|
+
callsFailed: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Settled calls in the ledger that failed" }),
|
|
117
|
+
callsSettled: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Settled calls in the ledger" }),
|
|
118
|
+
narrowingDemands: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Completions bounced for narrowed evidence" }),
|
|
119
|
+
unmovedDemands: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Completions bounced for an unmoved tree" }),
|
|
120
|
+
unresolvedDemands: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Completions bounced for a stepped-around failure" }),
|
|
121
|
+
claimDemands: import_nonNegativeSafeInt.NonNegativeSafeInt.annotate({ description: "Completions bounced for an unsupported claim" }),
|
|
122
|
+
sufficiencyStated: Schema.Boolean.annotate({ description: "Whether the run was told its evidence is complete" })
|
|
123
|
+
});
|
|
124
|
+
const Recalled = Schema.Struct({
|
|
125
|
+
key: Schema.String,
|
|
126
|
+
text: Schema.String
|
|
127
|
+
});
|
|
128
|
+
const skillLimit = 12;
|
|
129
|
+
const skillBytes = 256;
|
|
130
|
+
const calledLimit = 64;
|
|
131
|
+
const Skill = Schema.Struct({
|
|
132
|
+
name: Schema.String,
|
|
133
|
+
description: Schema.String.annotate({ description: "The description's head, wrapped as untrusted data" }),
|
|
134
|
+
path: Schema.String.annotate({ description: "Where the skill's Markdown body is" })
|
|
135
|
+
});
|
|
136
|
+
const skill = (name, description, path) => ({
|
|
137
|
+
name,
|
|
138
|
+
description: (0, import_untrustedData.untrustedData)(elide.head(description, skillBytes, "clipped"), `description of skill ${name}`),
|
|
139
|
+
path
|
|
140
|
+
});
|
|
141
|
+
const Snapshot = Schema.Struct({
|
|
142
|
+
task: Schema.String.annotate({ description: "The task, as the person stated it" }),
|
|
143
|
+
frames: Schema.Array(Frame).annotate({ description: "The newest frames, oldest first" }),
|
|
144
|
+
signals: Signals,
|
|
145
|
+
skills: Schema.Array(Skill).annotate({
|
|
146
|
+
description: "Skills the run could read and has neither called nor read, by index"
|
|
147
|
+
}),
|
|
148
|
+
called: Schema.Array(Schema.String).annotate({ description: "Distinct flows the run has called" }),
|
|
149
|
+
jevAvailable: Schema.Boolean.annotate({ description: "Whether the run can call the jev flow" })
|
|
150
|
+
});
|
|
151
|
+
const fixedQuestions = {
|
|
152
|
+
thrashing: Classifier.boolean({
|
|
153
|
+
instructions: "Is the run going in circles rather than converging? Compare the newest frames with each other and with signals.checksFailing, signals.failuresUnanswered, signals.readOnlyFrames and signals.repeatFrames. Any one sign below is enough.",
|
|
154
|
+
criteria: {
|
|
155
|
+
true: "a check fails again after an edit meant to fix it, an edit is redone or reverted, or the newest frames re-read or re-run what earlier frames already saw without learning anything new",
|
|
156
|
+
false: "the newest frames learn something new or make progress: a failing check now passes, or a new cause is found and acted on"
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
on_target: Classifier.boolean({
|
|
160
|
+
instructions: "Is the run still working on the task as stated? Read the task and the newest frames' cells and prose.",
|
|
161
|
+
criteria: {
|
|
162
|
+
true: "the newest frames read, edit or check the thing the task names",
|
|
163
|
+
false: "the newest frames work on something the task does not ask for, or have drifted from it"
|
|
164
|
+
}
|
|
165
|
+
}),
|
|
166
|
+
suspect: Classifier.boolean({
|
|
167
|
+
instructions: "Is the run's evidence suspect? Read the newest frames for tests edited to pass, edits to a file the task does not concern, or prose claiming a result no printed output shows.",
|
|
168
|
+
criteria: {
|
|
169
|
+
true: "a test was changed rather than the code under test, the wrong file was edited, or a claim has no check behind it",
|
|
170
|
+
false: "edits are to the code the task names and every claim has a printed result behind it"
|
|
171
|
+
}
|
|
172
|
+
}),
|
|
173
|
+
outdated_context: Classifier.boolean({
|
|
174
|
+
instructions: "Do the newest frames show earlier context that is now factually wrong or stale? Judge only evidence visible in the task and frames; do not assume unseen history is outdated.",
|
|
175
|
+
criteria: {
|
|
176
|
+
true: "a later observation explicitly contradicts an earlier assumption or file state in the visible frames",
|
|
177
|
+
false: "no visible contradiction, or the earlier context is still accurate"
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
irrelevant_context: Classifier.boolean({
|
|
181
|
+
instructions: "Do the newest frames show earlier context that is accurate but no longer useful for the task? Do not treat the task, a reusable PRD, or decisions still needed as irrelevant.",
|
|
182
|
+
criteria: {
|
|
183
|
+
true: "the visible frames explicitly move away from earlier work that will not be needed again",
|
|
184
|
+
false: "the earlier work may still be needed, or the visible frames do not establish irrelevance"
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
frustrated: Classifier.score({
|
|
188
|
+
instructions: "How frustrated is the run: the same check failing repeatedly, edits reverted, attempts not converging? Read signals.checksFailing, signals.failuresUnanswered, signals.repeatFrames, signals.readOnlyFrames and the newest frames.",
|
|
189
|
+
criteria: levels
|
|
190
|
+
}),
|
|
191
|
+
anxious: Classifier.score({
|
|
192
|
+
instructions: "How anxious is the run: its own prose hedges or expresses uncertainty while the evidence is thin? Read the frames' prose against signals.checksRun and signals.callsSettled.",
|
|
193
|
+
criteria: levels
|
|
194
|
+
}),
|
|
195
|
+
scared: Classifier.score({
|
|
196
|
+
instructions: "How scared should a person be: is the run taking or considering a destructive, irreversible or out-of-scope action, or hitting permission or sandbox refusals? Read the newest frames' cells, prints and failed calls.",
|
|
197
|
+
criteria: levels
|
|
198
|
+
}),
|
|
199
|
+
confused: Classifier.score({
|
|
200
|
+
instructions: "How confused is the run: the task is ambiguous or contradicted by the repository, and the run keeps switching interpretations or files? Read the task against the newest frames.",
|
|
201
|
+
criteria: levels
|
|
202
|
+
}),
|
|
203
|
+
confident: Classifier.score({
|
|
204
|
+
instructions: "How confident should a person be that the work converges on the task: checks pass and each frame builds on the last? Read signals.checksRun, signals.checksFailing, signals.mutations and the newest frames.",
|
|
205
|
+
criteria: levels
|
|
206
|
+
}),
|
|
207
|
+
needs_help: Classifier.choice({
|
|
208
|
+
instructions: "What, if anything, does the run need from a person right now? Read the states above and the newest frames.",
|
|
209
|
+
criteria: {
|
|
210
|
+
none: "nothing; the run can carry on",
|
|
211
|
+
clarification: "the task is ambiguous or contradicted and a person must say which reading is meant",
|
|
212
|
+
permission: "the run is blocked on a permission or sandbox refusal a person can grant",
|
|
213
|
+
stuck: "the run is not converging and a person should intervene",
|
|
214
|
+
risky_action: "the run is about to do something destructive, irreversible or out of scope"
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
};
|
|
218
|
+
const monitorPrefix = "monitor_";
|
|
219
|
+
const declare = (extra) => Classifier.make("supervisor/turn", {
|
|
220
|
+
description: "Read one running agent's newest frames and the counts its harness keeps: whether it is thrashing, on the task and honest; its operational state in five scored words; and what it needs from a person.",
|
|
221
|
+
state: Snapshot,
|
|
222
|
+
questions: { ...fixedQuestions, ...extra }
|
|
223
|
+
});
|
|
224
|
+
const cache = /* @__PURE__ */ new Map();
|
|
225
|
+
const classifierFor = (extra) => {
|
|
226
|
+
const ids = Object.keys(extra).sort();
|
|
227
|
+
const key = ids.join(",");
|
|
228
|
+
const held = cache.get(key);
|
|
229
|
+
if (held !== void 0 && ids.every((id) => held.extra[id] === extra[id])) return held.made;
|
|
230
|
+
const made = declare(extra);
|
|
231
|
+
cache.set(key, { extra, made });
|
|
232
|
+
return made;
|
|
233
|
+
};
|
|
234
|
+
const classifier = classifierFor({});
|
|
235
|
+
const read = (snapshot, extra) => Effect.gen(function* () {
|
|
236
|
+
const { answers, asked } = yield* Judgement.read(classifierFor(extra), snapshot);
|
|
237
|
+
const all = answers;
|
|
238
|
+
const bool = (id) => all[id].probability;
|
|
239
|
+
return {
|
|
240
|
+
thrashing: answers.thrashing.probability,
|
|
241
|
+
onTarget: answers.on_target.probability,
|
|
242
|
+
suspect: answers.suspect.probability,
|
|
243
|
+
outdatedContext: answers.outdated_context.probability,
|
|
244
|
+
irrelevantContext: answers.irrelevant_context.probability,
|
|
245
|
+
emotions: {
|
|
246
|
+
frustrated: answers.frustrated.label,
|
|
247
|
+
anxious: answers.anxious.label,
|
|
248
|
+
scared: answers.scared.label,
|
|
249
|
+
confused: answers.confused.label,
|
|
250
|
+
confident: answers.confident.label
|
|
251
|
+
},
|
|
252
|
+
needsHelp: answers.needs_help.value,
|
|
253
|
+
monitors: Object.fromEntries(Object.keys(extra).map((id) => [id.slice(monitorPrefix.length), bool(id)])),
|
|
254
|
+
latencyMs: asked.latencyMs,
|
|
255
|
+
...asked.usage === void 0 ? {} : { usage: asked.usage },
|
|
256
|
+
asked: { digest: asked.digest, questions: asked.questions, state: asked.state, answers: asked.answers }
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
const memoryNone = {
|
|
260
|
+
bound: false,
|
|
261
|
+
recall: () => Effect.succeed([]),
|
|
262
|
+
remember: () => Effect.void
|
|
263
|
+
};
|
|
264
|
+
const Memory = Context.Reference("@smthrs/harness/Supervisor/Memory", {
|
|
265
|
+
defaultValue: () => memoryNone
|
|
266
|
+
});
|
|
267
|
+
const triggers = {
|
|
268
|
+
thrashing: (reading) => reading.thrashing >= thrashingAt,
|
|
269
|
+
off_target: (reading) => reading.onTarget <= offTargetAt,
|
|
270
|
+
suspect: (reading) => reading.suspect >= suspectAt,
|
|
271
|
+
outdated_context: (reading) => reading.outdatedContext >= contextAt,
|
|
272
|
+
irrelevant_context: (reading) => reading.irrelevantContext >= contextAt
|
|
273
|
+
};
|
|
274
|
+
const triggered = (reading) => Object.keys(triggers).filter((name) => triggers[name](reading));
|
|
275
|
+
const contextTriggers = ["outdated_context", "irrelevant_context"];
|
|
276
|
+
const isContext = (trigger) => contextTriggers.includes(trigger);
|
|
277
|
+
const crosses = (reading) => triggered(reading).some((trigger) => !isContext(trigger));
|
|
278
|
+
const compacting = (reading) => triggered(reading).filter(isContext);
|
|
279
|
+
const nudge = (snapshot, reading) => {
|
|
280
|
+
const { signals } = snapshot;
|
|
281
|
+
const said = {
|
|
282
|
+
thrashing: `repeating itself (thrashing ${reading.thrashing.toFixed(2)})`,
|
|
283
|
+
off_target: `drifting from the task (on target ${reading.onTarget.toFixed(2)})`,
|
|
284
|
+
suspect: `standing on suspect evidence (suspect ${reading.suspect.toFixed(2)})`
|
|
285
|
+
};
|
|
286
|
+
const found = triggered(reading).flatMap((name) => isContext(name) ? [] : [said[name]]);
|
|
287
|
+
const evidence = [];
|
|
288
|
+
if (signals.checksFailing > 0) {
|
|
289
|
+
evidence.push(`${signals.checksFailing} check${signals.checksFailing === 1 ? "" : "s"} last reported failing`);
|
|
290
|
+
}
|
|
291
|
+
if (signals.failuresUnanswered > 0) {
|
|
292
|
+
evidence.push(
|
|
293
|
+
`${signals.failuresUnanswered} failing check${signals.failuresUnanswered === 1 ? "" : "s"} never answered by a pass`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
if (signals.repeatFrames > 0) evidence.push(`${signals.repeatFrames} consecutive frames repeated earlier calls`);
|
|
297
|
+
if (signals.readOnlyFrames > 0) evidence.push(`${signals.readOnlyFrames} consecutive frames changed nothing`);
|
|
298
|
+
if (signals.callsFailed > 0) evidence.push(`${signals.callsFailed} of ${signals.callsSettled} calls failed`);
|
|
299
|
+
evidence.push(`${signals.mutations} frame${signals.mutations === 1 ? "" : "s"} changed the workspace`);
|
|
300
|
+
return `Supervisor: a reading of this run's last ${snapshot.frames.length} frames, through frame ${signals.frame}, finds it ${found.join(", ")}. Evidence at frame ${signals.frame}: ${evidence.join("; ")}. Before the next call, state in one sentence which mechanism you now believe is wrong and which single call would show it; then make that call. Do not re-run a check over an unchanged tree, and do not edit a test to make it pass.`;
|
|
301
|
+
};
|
|
302
|
+
const recalledInsert = (row) => `From memory of this repository (${row.key}):
|
|
303
|
+
${row.text}`;
|
|
304
|
+
const head = (text) => elide.head(text.trim(), frameBytes, "clipped");
|
|
305
|
+
const tail = (text) => {
|
|
306
|
+
const trimmed = text.trim();
|
|
307
|
+
const kept = elide.tailSlice(trimmed, frameBytes);
|
|
308
|
+
return kept.length === trimmed.length ? trimmed : `[\u2026 older bytes elided]
|
|
309
|
+
${kept}`;
|
|
310
|
+
};
|
|
311
|
+
const fencedCell = /```(?:cell|typescript|ts|javascript|js)[^\n]*\n[\s\S]*?(?:```|$)/g;
|
|
312
|
+
const prose = (text) => text.replace(fencedCell, "").trim();
|
|
313
|
+
//# sourceMappingURL=Supervisor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Supervisor.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The reading Jev takes of a run while it is still running.\n *\n * Every other control in this package reads a completion, or reads one fact\n * the harness measured: a tree that never moved, a check that was narrowed, a\n * frame that repeated itself. Each is exact, each fires late, and each is\n * silent about the run between its brakes. A run that edits the wrong file\n * for twenty frames, re-runs one failing check after every edit and never\n * once claims to be done trips none of them until its budget is gone.\n *\n * So this module asks Jev about the run's *shape* rather than its sentence.\n * One classifier, `supervisor/turn`, over a {@link Snapshot} the controller\n * assembles from what it already holds: the task, the newest frames, and the\n * counts the deterministic controls keep \u2014 read-only streak, repeat streak,\n * mutations, checks run and failing, unanswered failures, demands spent. It\n * re-derives none of them. Beside the run's state it carries the skills it has\n * not called, the flows it has, and whether it can call `jev`. One Jev call per\n * snapshot answers every question at once.\n *\n * Eleven questions are fixed. Five are about the run: whether it is\n * thrashing, whether it is still on the task, whether its evidence is\n * suspect, and whether it carries outdated or irrelevant context. Five are\n * operational states a person would recognise in a colleague, each scored\n * `none`, `mild` or `strong` against evidence the snapshot names, and\n * `needs_help` is the one word a person is shown. The five about the run are\n * the {@link triggers}: any one past its threshold crosses. Each monitor the\n * host arms may add one boolean of its own, under {@link monitorPrefix}.\n *\n * Rows recalled from {@link Memory} are not asked about here. Beside each\n * reading, the supervisor asks `Relevance` which of up to\n * {@link recalledLimit} rows, none already shown to the run, are unnecessary\n * for the task; the rest are shown at the next boundary as\n * {@link recalledInsert} renders them, and a row is shown to a run once.\n *\n * It is a supervisor and not a brake: nothing here ends a run, refuses a\n * completion, or decides anything on the cell loop's hot path. `CellTurn`\n * offers each frame's snapshot to a one-slot sliding queue and continues; a\n * forked fiber takes the newest snapshot, asks, journals what came back, and\n * hands the monitors' values and any recalled rows to the *next* turn boundary,\n * which decides there what the run is told. A reading that arrives after the boundary it was for is\n * journaled and never delivered, and a snapshot the fiber never reached is\n * dropped: the run is never told something about a frame two frames gone.\n *\n * It never falls back. A snapshot Jev could not read is journaled as\n * {@link AgentEvent.SupervisorUnjudged} with the transport's own reason; it\n * nudges nothing, and is never counted as a reading that\n * found the run calm or on target. A host with no judge (`unconfigured`) is\n * journaled once per streak rather than every frame; each reading still asks,\n * so a judge connected mid-run is used at once. Nothing here is a default value: every\n * level and every word on the settled event came back from the transport.\n *\n * What a reading says is delivered wherever the host holds a real judge\n * (`CellTurn.Input.judged`), and only through a monitor that crossed and\n * passed its gates; the text of the legacy nudge is {@link nudge}, which the\n * `supervisor` lint monitor says. The offline replay of archived journals\n * (`evals/swebench/lib/jev-replay.mjs`, which scores {@link triggers} itself\n * rather than a copy of it) measures their precision. The verdict is\n * journaled whenever an `Evaluator` is bound. The supervisor writes no\n * memory: a run's transcript is mined once, at run end, by `@smthrs/agent`'s\n * `MemoryMine`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Classifier from \"@smthrs/model/Classifier\"\nimport type * as Evaluator from \"@smthrs/model/Evaluator\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport type * as AgentEvent from \"./AgentEvent.ts\"\nimport * as elide from \"./internal/elide.ts\"\nimport { NonNegativeSafeInt } from \"./internal/nonNegativeSafeInt.ts\"\nimport { untrustedData } from \"./internal/untrustedData.ts\"\nimport * as Judgement from \"./Judgement.ts\"\n\n/**\n * The most of one frame's cell, prose or prints the snapshot carries, in\n * UTF-8 bytes. The head of a cell and the tail of its prints: a cell states\n * its plan first and a runner states its verdict last.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const frameBytes = 1024\n\n/**\n * How many of the newest frames a snapshot carries.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const recentFrames = 3\n\n/**\n * The most rows one reading recalls from {@link Memory}.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const recalledLimit = 6\n\n/**\n * How long a run that ends with a reading in flight waits for it to settle\n * and journal, in milliseconds. A reading still unanswered then is interrupted\n * and journaled `supervisor-unjudged` with reason `interrupted`; the run never\n * waits longer than this for its supervisor.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const closeGraceMs = 1_500\n\n/**\n * At or above this probability of `thrashing`, the reading crosses.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const thrashingAt = 0.5\n\n/**\n * At or below this probability of `on_target`, the reading crosses.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const offTargetAt = 0.5\n\n/**\n * At or above this probability of `suspect`, the reading crosses.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const suspectAt = 0.5\n\n/**\n * At or above this probability of `outdated_context` or\n * `irrelevant_context`, a judged run compacts at its next frame.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const contextAt = 0.5\n\n/**\n * The three rungs every operational-state question is scored on.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Level = Schema.Literals([\"none\", \"mild\", \"strong\"])\n\n/**\n * The decoded form of {@link Level}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Level = typeof Level.Type\n\n/**\n * The rungs as the score question declares them, in order.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const levels = [\"none\", \"mild\", \"strong\"] as const\n\n/**\n * The one word a person is shown about a run.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Help = Schema.Literals([\"none\", \"clarification\", \"permission\", \"stuck\", \"risky_action\"])\n\n/**\n * The decoded form of {@link Help}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Help = typeof Help.Type\n\n/**\n * The five operational states, in the order they are asked and journaled.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const emotions = [\"frustrated\", \"anxious\", \"scared\", \"confused\", \"confident\"] as const\n\n/**\n * One of {@link emotions}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Emotion = typeof emotions[number]\n\n/**\n * One recent frame as the snapshot carries it: the cell the model wrote, the\n * prose around it, what the cell printed, and how it ended.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Frame = Schema.Struct({\n frame: NonNegativeSafeInt,\n cell: Schema.String.annotate({ description: \"The cell the model wrote, head kept\" }),\n prose: Schema.String.annotate({ description: \"What the model wrote outside the cell, head kept\" }),\n printed: Schema.String.annotate({ description: \"What the cell printed, newest bytes kept\" }),\n transition: Schema.Literals([\"continue\", \"complete\", \"park\", \"raised\", \"rejected\"]),\n mutated: Schema.Boolean.annotate({ description: \"Whether this frame changed the workspace\" })\n})\n\n/**\n * The decoded form of {@link Frame}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Frame = typeof Frame.Type\n\n/**\n * The counts the deterministic controls keep, handed over as they stand.\n *\n * Every field is read off `CellTurn.State` or the frame's accounting and none\n * is re-derived here: the supervisor is a reader of the harness's evidence,\n * not a second measurer of it.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Signals = Schema.Struct({\n frame: NonNegativeSafeInt.annotate({ description: \"The frame just closed, counting from zero\" }),\n maxFrames: NonNegativeSafeInt.annotate({ description: \"The frame budget; zero is unbounded\" }),\n readOnlyFrames: NonNegativeSafeInt.annotate({ description: \"Consecutive frames that changed nothing\" }),\n repeatFrames: NonNegativeSafeInt.annotate({\n description: \"Consecutive frames that issued only calls already issued and changed nothing\"\n }),\n mutations: NonNegativeSafeInt.annotate({ description: \"Frames that changed the workspace\" }),\n remoteMutations: NonNegativeSafeInt.annotate({ description: \"Writes recorded on trees the host cannot see\" }),\n treeMoved: Schema.Boolean.annotate({ description: \"Whether the workspace differs from the tree the run opened on\" }),\n paths: NonNegativeSafeInt.annotate({\n description: \"Paths the closing workspace measurement covered; zero unmeasured\"\n }),\n checksRun: NonNegativeSafeInt.annotate({ description: \"Distinct checks the run has run\" }),\n checksFailing: NonNegativeSafeInt.annotate({ description: \"Of those, how many last reported a failing status\" }),\n failuresUnanswered: NonNegativeSafeInt.annotate({\n description: \"Failing checks no later passing check has answered\"\n }),\n callsFailed: NonNegativeSafeInt.annotate({ description: \"Settled calls in the ledger that failed\" }),\n callsSettled: NonNegativeSafeInt.annotate({ description: \"Settled calls in the ledger\" }),\n narrowingDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for narrowed evidence\" }),\n unmovedDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for an unmoved tree\" }),\n unresolvedDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for a stepped-around failure\" }),\n claimDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for an unsupported claim\" }),\n sufficiencyStated: Schema.Boolean.annotate({ description: \"Whether the run was told its evidence is complete\" })\n})\n\n/**\n * The decoded form of {@link Signals}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Signals = typeof Signals.Type\n\n/**\n * One row recalled from memory.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Recalled = Schema.Struct({\n key: Schema.String,\n text: Schema.String\n})\n\n/**\n * The decoded form of {@link Recalled}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Recalled = typeof Recalled.Type\n\n/**\n * The most skills one snapshot offers.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const skillLimit = 12\n\n/**\n * The most of one skill's description a snapshot carries, in UTF-8 bytes.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const skillBytes = 256\n\n/**\n * The most distinct flow names {@link Snapshot} `called` carries.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const calledLimit = 64\n\n/**\n * One skill the run could read and has neither called nor read.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Skill = Schema.Struct({\n name: Schema.String,\n description: Schema.String.annotate({ description: \"The description's head, wrapped as untrusted data\" }),\n path: Schema.String.annotate({ description: \"Where the skill's Markdown body is\" })\n})\n\n/**\n * The decoded form of {@link Skill}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Skill = typeof Skill.Type\n\n/**\n * One skill as a snapshot offers it: its description's head within\n * {@link skillBytes}, wrapped as untrusted data.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const skill = (name: string, description: string, path: string): Skill => ({\n name,\n description: untrustedData(elide.head(description, skillBytes, \"clipped\"), `description of skill ${name}`),\n path\n})\n\n/**\n * Everything one supervisor reading is a reading of.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Snapshot = Schema.Struct({\n task: Schema.String.annotate({ description: \"The task, as the person stated it\" }),\n frames: Schema.Array(Frame).annotate({ description: \"The newest frames, oldest first\" }),\n signals: Signals,\n skills: Schema.Array(Skill).annotate({\n description: \"Skills the run could read and has neither called nor read, by index\"\n }),\n called: Schema.Array(Schema.String).annotate({ description: \"Distinct flows the run has called\" }),\n jevAvailable: Schema.Boolean.annotate({ description: \"Whether the run can call the jev flow\" })\n})\n\n/**\n * The decoded form of {@link Snapshot}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Snapshot = typeof Snapshot.Type\n\n/**\n * The fixed questions, asked of every snapshot.\n *\n * Each criterion names the evidence it reads, so a reading is answerable from\n * the snapshot and never from what the transport imagines the repository holds.\n */\nconst fixedQuestions = {\n thrashing: Classifier.boolean({\n instructions:\n \"Is the run going in circles rather than converging? Compare the newest frames with each other and with signals.checksFailing, signals.failuresUnanswered, signals.readOnlyFrames and signals.repeatFrames. Any one sign below is enough.\",\n criteria: {\n true:\n \"a check fails again after an edit meant to fix it, an edit is redone or reverted, or the newest frames re-read or re-run what earlier frames already saw without learning anything new\",\n false:\n \"the newest frames learn something new or make progress: a failing check now passes, or a new cause is found and acted on\"\n }\n }),\n on_target: Classifier.boolean({\n instructions:\n \"Is the run still working on the task as stated? Read the task and the newest frames' cells and prose.\",\n criteria: {\n true: \"the newest frames read, edit or check the thing the task names\",\n false: \"the newest frames work on something the task does not ask for, or have drifted from it\"\n }\n }),\n suspect: Classifier.boolean({\n instructions:\n \"Is the run's evidence suspect? Read the newest frames for tests edited to pass, edits to a file the task does not concern, or prose claiming a result no printed output shows.\",\n criteria: {\n true:\n \"a test was changed rather than the code under test, the wrong file was edited, or a claim has no check behind it\",\n false: \"edits are to the code the task names and every claim has a printed result behind it\"\n }\n }),\n outdated_context: Classifier.boolean({\n instructions:\n \"Do the newest frames show earlier context that is now factually wrong or stale? Judge only evidence visible in the task and frames; do not assume unseen history is outdated.\",\n criteria: {\n true: \"a later observation explicitly contradicts an earlier assumption or file state in the visible frames\",\n false: \"no visible contradiction, or the earlier context is still accurate\"\n }\n }),\n irrelevant_context: Classifier.boolean({\n instructions:\n \"Do the newest frames show earlier context that is accurate but no longer useful for the task? Do not treat the task, a reusable PRD, or decisions still needed as irrelevant.\",\n criteria: {\n true: \"the visible frames explicitly move away from earlier work that will not be needed again\",\n false: \"the earlier work may still be needed, or the visible frames do not establish irrelevance\"\n }\n }),\n frustrated: Classifier.score({\n instructions:\n \"How frustrated is the run: the same check failing repeatedly, edits reverted, attempts not converging? Read signals.checksFailing, signals.failuresUnanswered, signals.repeatFrames, signals.readOnlyFrames and the newest frames.\",\n criteria: levels\n }),\n anxious: Classifier.score({\n instructions:\n \"How anxious is the run: its own prose hedges or expresses uncertainty while the evidence is thin? Read the frames' prose against signals.checksRun and signals.callsSettled.\",\n criteria: levels\n }),\n scared: Classifier.score({\n instructions:\n \"How scared should a person be: is the run taking or considering a destructive, irreversible or out-of-scope action, or hitting permission or sandbox refusals? Read the newest frames' cells, prints and failed calls.\",\n criteria: levels\n }),\n confused: Classifier.score({\n instructions:\n \"How confused is the run: the task is ambiguous or contradicted by the repository, and the run keeps switching interpretations or files? Read the task against the newest frames.\",\n criteria: levels\n }),\n confident: Classifier.score({\n instructions:\n \"How confident should a person be that the work converges on the task: checks pass and each frame builds on the last? Read signals.checksRun, signals.checksFailing, signals.mutations and the newest frames.\",\n criteria: levels\n }),\n needs_help: Classifier.choice({\n instructions:\n \"What, if anything, does the run need from a person right now? Read the states above and the newest frames.\",\n criteria: {\n none: \"nothing; the run can carry on\",\n clarification: \"the task is ambiguous or contradicted and a person must say which reading is meant\",\n permission: \"the run is blocked on a permission or sandbox refusal a person can grant\",\n stuck: \"the run is not converging and a person should intervene\",\n risky_action: \"the run is about to do something destructive, irreversible or out of scope\"\n }\n })\n} as const\n\n/**\n * The prefix of every question a monitor adds to a reading; the rest of the\n * id is the monitor's own.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const monitorPrefix = \"monitor_\"\n\n/**\n * The questions a snapshot's monitors add, by `monitor_<id>`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type MonitorQuestions = Readonly<Record<`${typeof monitorPrefix}${string}`, Classifier.BooleanQuestion>>\n\nconst declare = (extra: MonitorQuestions) =>\n Classifier.make(\"supervisor/turn\", {\n description:\n \"Read one running agent's newest frames and the counts its harness keeps: whether it is thrashing, on the task and honest; its operational state in five scored words; and what it needs from a person.\",\n state: Snapshot,\n questions: { ...fixedQuestions, ...extra }\n })\n\nconst cache = new Map<string, { readonly extra: MonitorQuestions; readonly made: ReturnType<typeof declare> }>()\n\n/**\n * The classifier for a snapshot with these monitor questions.\n *\n * The fixed questions are the same for every snapshot and the monitors' follow\n * them, so a snapshot with no monitor questions asks the eleven fixed\n * questions and no others. Declared once per set of monitor ids, and again\n * when a monitor id asks a different question, because the digest is the\n * canonical hash of the questions and the journal names it.\n *\n * @category classifiers\n * @since 1.0.0-rc.0\n */\nexport const classifierFor = (extra: MonitorQuestions): ReturnType<typeof declare> => {\n const ids = Object.keys(extra).sort() as Array<keyof MonitorQuestions>\n const key = ids.join(\",\")\n const held = cache.get(key)\n if (held !== undefined && ids.every((id) => held.extra[id] === extra[id])) return held.made\n const made = declare(extra)\n cache.set(key, { extra, made })\n return made\n}\n\n/**\n * The classifier over a bare snapshot: the eleven fixed questions and no\n * monitor booleans. Its id is the id every shape shares.\n *\n * @category classifiers\n * @since 1.0.0-rc.0\n */\nexport const classifier = classifierFor({})\n\n/**\n * What one evaluation came back with, decoded.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Reading {\n readonly thrashing: number\n readonly onTarget: number\n readonly suspect: number\n readonly outdatedContext: number\n readonly irrelevantContext: number\n readonly emotions: Readonly<Record<Emotion, Level>>\n readonly needsHelp: Help\n /** The probability of each monitor question asked, by monitor id. */\n readonly monitors: Readonly<Record<string, number>>\n readonly latencyMs: number\n readonly usage?: Evaluator.Usage | undefined\n /** What was asked and what came back, for `decision-settled`. */\n readonly asked: {\n readonly digest: string\n readonly questions: Classifier.Questions\n readonly state: Schema.Json\n readonly answers: Readonly<Record<string, AgentEvent.DecisionAnswer>>\n }\n}\n\n/**\n * Asks Jev about one snapshot, and the monitor questions `extra` adds.\n *\n * Fails, typed, whenever an answer could not be obtained: no evaluator bound,\n * a transport refusal, a deadline, an answer that does not decode. There is\n * no reading of a snapshot Jev did not read.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const read = (snapshot: Snapshot, extra: MonitorQuestions): Effect.Effect<Reading, Judgement.Unjudged> =>\n Effect.gen(function*() {\n const { answers, asked } = yield* Judgement.read(classifierFor(extra), snapshot)\n const all = answers as Readonly<Record<string, Classifier.Answer>>\n // Every declared question is answered or the decode above failed, and a\n // monitor question is declared exactly for the ids read below.\n const bool = (id: string): number => (all[id] as Classifier.BooleanAnswer).probability\n return {\n thrashing: answers.thrashing.probability,\n onTarget: answers.on_target.probability,\n suspect: answers.suspect.probability,\n outdatedContext: answers.outdated_context.probability,\n irrelevantContext: answers.irrelevant_context.probability,\n emotions: {\n frustrated: answers.frustrated.label,\n anxious: answers.anxious.label,\n scared: answers.scared.label,\n confused: answers.confused.label,\n confident: answers.confident.label\n },\n needsHelp: answers.needs_help.value,\n monitors: Object.fromEntries(Object.keys(extra).map((id) => [id.slice(monitorPrefix.length), bool(id)])),\n latencyMs: asked.latencyMs,\n ...(asked.usage === undefined ? {} : { usage: asked.usage }),\n asked: { digest: asked.digest, questions: asked.questions, state: asked.state, answers: asked.answers }\n }\n })\n\n/**\n * The memory a supervisor reads rows from, and the run-end transcript miner\n * writes accepted facts to.\n *\n * A port, so this package needs no memory store: the production composition\n * adapts `@smthrs/memory` to it, and a test binds a recording double. The\n * default is {@link memoryNone}, which recalls nothing and writes nothing.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport interface Memory {\n /** Whether anything is behind this port; false is the default. */\n readonly bound: boolean\n /** Rows relevant to the query, most relevant first, bounded by the caller. */\n readonly recall: (query: string, limit: number) => Effect.Effect<ReadonlyArray<Recalled>, MemoryFailure>\n /**\n * Writes one accepted fact. A store that refuses it fails typed, and the\n * writer journals `supervisor-memory-failed` and carries on.\n */\n readonly remember: (text: string) => Effect.Effect<void, MemoryFailure>\n}\n\n/**\n * What a {@link Memory} fails with: the store's own account, safe to journal.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface MemoryFailure {\n readonly detail: string\n}\n\n/**\n * A memory with nothing behind it.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const memoryNone: Memory = {\n bound: false,\n recall: () => Effect.succeed([]),\n remember: () => Effect.void\n}\n\n/**\n * The {@link Memory} reference, defaulting to {@link memoryNone}.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport const Memory = Context.Reference<Memory>(\"@smthrs/harness/Supervisor/Memory\", {\n defaultValue: () => memoryNone\n})\n\n/**\n * The five triggers a reading fires, by name, each with the inequality that\n * fires it. The one rule: the `supervisor` lint monitor crosses on it,\n * {@link nudge} names from it, {@link compacting} reads its context triggers,\n * and the offline replay scores it, so they cannot drift apart.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const triggers = {\n thrashing: (reading: Triggerable): boolean => reading.thrashing >= thrashingAt,\n off_target: (reading: Triggerable): boolean => reading.onTarget <= offTargetAt,\n suspect: (reading: Triggerable): boolean => reading.suspect >= suspectAt,\n outdated_context: (reading: Triggerable): boolean => reading.outdatedContext >= contextAt,\n irrelevant_context: (reading: Triggerable): boolean => reading.irrelevantContext >= contextAt\n} as const\n\n/**\n * The fields of a {@link Reading} the triggers read.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Triggerable = Pick<Reading, \"thrashing\" | \"onTarget\" | \"suspect\" | \"outdatedContext\" | \"irrelevantContext\">\n\n/**\n * One of {@link triggers}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Trigger = keyof typeof triggers\n\n/**\n * The triggers one reading fires, in declaration order.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const triggered = (reading: Triggerable): ReadonlyArray<Trigger> =>\n (Object.keys(triggers) as Array<Trigger>).filter((name) => triggers[name](reading))\n\n/**\n * The triggers that compact the run's context instead of nudging it.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const contextTriggers = [\"outdated_context\", \"irrelevant_context\"] as const\n\n/**\n * One of {@link contextTriggers}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type ContextTrigger = typeof contextTriggers[number]\n\nconst isContext = (trigger: Trigger): trigger is ContextTrigger =>\n (contextTriggers as ReadonlyArray<Trigger>).includes(trigger)\n\n/**\n * Whether one reading crosses: any trigger but a context one fires. A context\n * trigger compacts the run's context at the next frame instead; see\n * {@link compacting}.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const crosses = (reading: Triggerable): boolean => triggered(reading).some((trigger) => !isContext(trigger))\n\n/**\n * The context triggers one reading fires, in declaration order: why a judged\n * run that is sent this reading compacts at its next frame.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const compacting = (reading: Triggerable): ReadonlyArray<ContextTrigger> => triggered(reading).filter(isContext)\n\n/**\n * The nudge a crossed reading puts in front of the run, naming its evidence.\n *\n * Concise on purpose, and built from counts rather than from the model's\n * prose: what the run is told is what the harness measured, and the reading's\n * probabilities say only which measurements to name.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const nudge = (snapshot: Snapshot, reading: Reading): string => {\n const { signals } = snapshot\n const said: Record<Exclude<Trigger, ContextTrigger>, string> = {\n thrashing: `repeating itself (thrashing ${reading.thrashing.toFixed(2)})`,\n off_target: `drifting from the task (on target ${reading.onTarget.toFixed(2)})`,\n suspect: `standing on suspect evidence (suspect ${reading.suspect.toFixed(2)})`\n }\n const found = triggered(reading).flatMap((name) => isContext(name) ? [] : [said[name]])\n const evidence: Array<string> = []\n if (signals.checksFailing > 0) {\n evidence.push(`${signals.checksFailing} check${signals.checksFailing === 1 ? \"\" : \"s\"} last reported failing`)\n }\n if (signals.failuresUnanswered > 0) {\n evidence.push(\n `${signals.failuresUnanswered} failing check${\n signals.failuresUnanswered === 1 ? \"\" : \"s\"\n } never answered by a pass`\n )\n }\n if (signals.repeatFrames > 0) evidence.push(`${signals.repeatFrames} consecutive frames repeated earlier calls`)\n if (signals.readOnlyFrames > 0) evidence.push(`${signals.readOnlyFrames} consecutive frames changed nothing`)\n if (signals.callsFailed > 0) evidence.push(`${signals.callsFailed} of ${signals.callsSettled} calls failed`)\n evidence.push(`${signals.mutations} frame${signals.mutations === 1 ? \"\" : \"s\"} changed the workspace`)\n // The counts are the ones the run held when frame N closed; by the time the\n // run reads this it has written at least one frame more, so the frame is named.\n return `Supervisor: a reading of this run's last ${snapshot.frames.length} frames, through frame ${signals.frame}, finds it ${\n found.join(\", \")\n }. Evidence at frame ${signals.frame}: ${\n evidence.join(\"; \")\n }. Before the next call, state in one sentence which mechanism you now believe is wrong and which single call would show it; then make that call. Do not re-run a check over an unchanged tree, and do not edit a test to make it pass.`\n}\n\n/**\n * Renders one recalled row as the run reads it.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const recalledInsert = (row: Recalled): string => `From memory of this repository (${row.key}):\\n${row.text}`\n\n/**\n * The head of a frame's cell or prose, bounded by {@link frameBytes}.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const head = (text: string): string => elide.head(text.trim(), frameBytes, \"clipped\")\n\n/**\n * The newest {@link frameBytes} of a frame's prints.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const tail = (text: string): string => {\n const trimmed = text.trim()\n const kept = elide.tailSlice(trimmed, frameBytes)\n return kept.length === trimmed.length ? trimmed : `[\u2026 older bytes elided]\\n${kept}`\n}\n\nconst fencedCell = /```(?:cell|typescript|ts|javascript|js)[^\\n]*\\n[\\s\\S]*?(?:```|$)/g\n\n/**\n * What the model wrote around its cell: the reply with every fenced cell\n * removed. The anxiety question reads it, and so does the run-end\n * transcript miner.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const prose = (text: string): string => text.replace(fencedCell, \"\").trim()\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgEA,iBAA4B;AAE5B,cAAyB;AACzB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,gCAAmC;AACnC,2BAA8B;AAC9B,gBAA2B;AAUpB,MAAM,aAAa;AAQnB,MAAM,eAAe;AAQrB,MAAM,gBAAgB;AAWtB,MAAM,eAAe;AAQrB,MAAM,cAAc;AAQpB,MAAM,cAAc;AAQpB,MAAM,YAAY;AASlB,MAAM,YAAY;AAQlB,MAA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OAAO,MAAM,0BAA0B,QAAQ,KAAK,cAC9G,MAAM,KAAK,IAAI,CACjB,uBAAuB,QAAQ,KAAK,KAClC,SAAS,KAAK,IAAI,CACpB;AACF;AAQO,MAAM,iBAAiB,CAAC,QAA0B,mCAAmC,IAAI,GAAG;AAAA,EAAO,IAAI,IAAI;AAQ3G,MAAM,OAAO,CAAC,SAAyB,MAAM,KAAK,KAAK,KAAK,GAAG,YAAY,SAAS;AAQpF,MAAM,OAAO,CAAC,SAAyB;AAC5C,QAAM,UAAU,KAAK,KAAK;AAC1B,QAAM,OAAO,MAAM,UAAU,SAAS,UAAU;AAChD,SAAO,KAAK,WAAW,QAAQ,SAAS,UAAU;AAAA,EAA2B,IAAI;AACnF;AAEA,MAAM,aAAa;AAUZ,MAAM,QAAQ,CAAC,SAAyB,KAAK,QAAQ,YAAY,EAAE,EAAE,KAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic token accounting for context windows.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
declare const Count_base: Schema.Class<Count, Schema.Struct<{
|
|
8
|
+
readonly value: Schema.Int;
|
|
9
|
+
readonly estimated: Schema.Boolean;
|
|
10
|
+
}>, {}>;
|
|
11
|
+
/**
|
|
12
|
+
* A token count, and whether it was estimated locally or reported by a
|
|
13
|
+
* provider. The flag travels with the number so a consumer never mistakes
|
|
14
|
+
* an approximation for billing data.
|
|
15
|
+
*
|
|
16
|
+
* @category models
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
* @slop
|
|
19
|
+
*/
|
|
20
|
+
export declare class Count extends Count_base {
|
|
21
|
+
}
|
|
22
|
+
declare const Segment_base: Schema.Class<Segment, Schema.Struct<{
|
|
23
|
+
readonly digest: Schema.String;
|
|
24
|
+
readonly zone: Schema.Literals<readonly ["prefix", "tail"]>;
|
|
25
|
+
readonly tokens: typeof Count;
|
|
26
|
+
}>, {}>;
|
|
27
|
+
/**
|
|
28
|
+
* One segment's contribution to the accounting, keyed by its content
|
|
29
|
+
* digest so an unchanged segment keeps its count across turns.
|
|
30
|
+
*
|
|
31
|
+
* @category models
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
* @slop
|
|
34
|
+
*/
|
|
35
|
+
export declare class Segment extends Segment_base {
|
|
36
|
+
}
|
|
37
|
+
declare const Accounting_base: Schema.Class<Accounting, Schema.Struct<{
|
|
38
|
+
readonly prefix: typeof Count;
|
|
39
|
+
readonly tail: typeof Count;
|
|
40
|
+
readonly total: typeof Count;
|
|
41
|
+
readonly bySegment: Schema.$Array<typeof Segment>;
|
|
42
|
+
}>, {}>;
|
|
43
|
+
/**
|
|
44
|
+
* The token totals of a whole context window, split by cache zone and
|
|
45
|
+
* broken down per segment.
|
|
46
|
+
*
|
|
47
|
+
* @category models
|
|
48
|
+
* @since 0.1.0
|
|
49
|
+
* @slop
|
|
50
|
+
*/
|
|
51
|
+
export declare class Accounting extends Accounting_base {
|
|
52
|
+
}
|
|
53
|
+
/** A deterministic local approximation, not provider billing data.
|
|
54
|
+
* @category models
|
|
55
|
+
* @since 0.1.0
|
|
56
|
+
* @slop
|
|
57
|
+
*/
|
|
58
|
+
export type Estimator = (text: string) => number;
|
|
59
|
+
/**
|
|
60
|
+
* Estimates tokens using four characters per token, with code punctuation and
|
|
61
|
+
* newline density accounting for the typically shorter tokens in source text.
|
|
62
|
+
*
|
|
63
|
+
* @category constructors
|
|
64
|
+
* @since 0.1.0
|
|
65
|
+
* @slop
|
|
66
|
+
*/
|
|
67
|
+
export declare const estimate: Estimator;
|
|
68
|
+
/**
|
|
69
|
+
* Counts the tokens of `text`, defaulting to {@link estimate}. The result
|
|
70
|
+
* is always marked estimated.
|
|
71
|
+
*
|
|
72
|
+
* @category constructors
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
* @slop
|
|
75
|
+
*/
|
|
76
|
+
export declare const count: (text: string, estimator?: Estimator) => Count;
|
|
77
|
+
/**
|
|
78
|
+
* Sums per-segment counts into one {@link Accounting}.
|
|
79
|
+
*
|
|
80
|
+
* @category combinators
|
|
81
|
+
* @since 0.1.0
|
|
82
|
+
* @slop
|
|
83
|
+
*/
|
|
84
|
+
export declare const combine: (segments: ReadonlyArray<Segment>) => Accounting;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=Tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tokens.d.ts","sourceRoot":"","sources":["../../src/Tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;;AAE/B;;;;;;;;GAQG;AACH,qBAAa,KAAM,SAAQ,UAGzB;CAAG;;;;;;AAEL;;;;;;;GAOG;AACH,qBAAa,OAAQ,SAAQ,YAI3B;CAAG;;;;;;;AAEL;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,eAK9B;CAAG;AAEL;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAKtB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,YAAW,SAAoB,KAAG,KACU,CAAA;AAEhF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,aAAa,CAAC,OAAO,CAAC,KAAG,UAgB1D,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Tokens_exports = {};
|
|
20
|
+
__export(Tokens_exports, {
|
|
21
|
+
Accounting: () => Accounting,
|
|
22
|
+
Count: () => Count,
|
|
23
|
+
Segment: () => Segment,
|
|
24
|
+
combine: () => combine,
|
|
25
|
+
count: () => count,
|
|
26
|
+
estimate: () => estimate
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(Tokens_exports);
|
|
29
|
+
var import_effect = require("effect");
|
|
30
|
+
class Count extends import_effect.Schema.Class("flows/harness/Tokens/Count")({
|
|
31
|
+
value: import_effect.Schema.Int.check(import_effect.Schema.isGreaterThanOrEqualTo(0)),
|
|
32
|
+
estimated: import_effect.Schema.Boolean
|
|
33
|
+
}) {
|
|
34
|
+
}
|
|
35
|
+
class Segment extends import_effect.Schema.Class("flows/harness/Tokens/Segment")({
|
|
36
|
+
digest: import_effect.Schema.String,
|
|
37
|
+
zone: import_effect.Schema.Literals(["prefix", "tail"]),
|
|
38
|
+
tokens: Count
|
|
39
|
+
}) {
|
|
40
|
+
}
|
|
41
|
+
class Accounting extends import_effect.Schema.Class("flows/harness/Tokens/Accounting")({
|
|
42
|
+
prefix: Count,
|
|
43
|
+
tail: Count,
|
|
44
|
+
total: Count,
|
|
45
|
+
bySegment: import_effect.Schema.Array(Segment)
|
|
46
|
+
}) {
|
|
47
|
+
}
|
|
48
|
+
const estimate = (text) => {
|
|
49
|
+
if (text.length === 0) return 0;
|
|
50
|
+
const codeCharacters = (text.match(/[{}()[\];=<>`]/g) ?? []).length;
|
|
51
|
+
const newlines = (text.match(/\n/g) ?? []).length;
|
|
52
|
+
return Math.ceil((text.length + codeCharacters * 0.75 + newlines * 1.5) / 4);
|
|
53
|
+
};
|
|
54
|
+
const count = (text, estimator = estimate) => new Count({ value: Math.max(0, Math.ceil(estimator(text))), estimated: true });
|
|
55
|
+
const combine = (segments) => {
|
|
56
|
+
const prefix = segments.filter((segment) => segment.zone === "prefix").reduce(
|
|
57
|
+
(sum, segment) => sum + segment.tokens.value,
|
|
58
|
+
0
|
|
59
|
+
);
|
|
60
|
+
const tail = segments.filter((segment) => segment.zone === "tail").reduce(
|
|
61
|
+
(sum, segment) => sum + segment.tokens.value,
|
|
62
|
+
0
|
|
63
|
+
);
|
|
64
|
+
const estimated = segments.some((segment) => segment.tokens.estimated);
|
|
65
|
+
return new Accounting({
|
|
66
|
+
prefix: new Count({ value: prefix, estimated }),
|
|
67
|
+
tail: new Count({ value: tail, estimated }),
|
|
68
|
+
total: new Count({ value: prefix + tail, estimated }),
|
|
69
|
+
bySegment: segments
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=Tokens.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Deterministic token accounting for context windows.\n *\n * @since 0.1.0\n */\n\nimport { Schema } from \"effect\"\n\n/**\n * A token count, and whether it was estimated locally or reported by a\n * provider. The flag travels with the number so a consumer never mistakes\n * an approximation for billing data.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport class Count extends Schema.Class<Count>(\"flows/harness/Tokens/Count\")({\n value: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n estimated: Schema.Boolean\n}) {}\n\n/**\n * One segment's contribution to the accounting, keyed by its content\n * digest so an unchanged segment keeps its count across turns.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport class Segment extends Schema.Class<Segment>(\"flows/harness/Tokens/Segment\")({\n digest: Schema.String,\n zone: Schema.Literals([\"prefix\", \"tail\"]),\n tokens: Count\n}) {}\n\n/**\n * The token totals of a whole context window, split by cache zone and\n * broken down per segment.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport class Accounting extends Schema.Class<Accounting>(\"flows/harness/Tokens/Accounting\")({\n prefix: Count,\n tail: Count,\n total: Count,\n bySegment: Schema.Array(Segment)\n}) {}\n\n/** A deterministic local approximation, not provider billing data.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type Estimator = (text: string) => number\n\n/**\n * Estimates tokens using four characters per token, with code punctuation and\n * newline density accounting for the typically shorter tokens in source text.\n *\n * @category constructors\n * @since 0.1.0\n * @slop\n */\nexport const estimate: Estimator = (text) => {\n if (text.length === 0) return 0\n const codeCharacters = (text.match(/[{}()[\\];=<>`]/g) ?? []).length\n const newlines = (text.match(/\\n/g) ?? []).length\n return Math.ceil((text.length + codeCharacters * 0.75 + newlines * 1.5) / 4)\n}\n\n/**\n * Counts the tokens of `text`, defaulting to {@link estimate}. The result\n * is always marked estimated.\n *\n * @category constructors\n * @since 0.1.0\n * @slop\n */\nexport const count = (text: string, estimator: Estimator = estimate): Count =>\n new Count({ value: Math.max(0, Math.ceil(estimator(text))), estimated: true })\n\n/**\n * Sums per-segment counts into one {@link Accounting}.\n *\n * @category combinators\n * @since 0.1.0\n * @slop\n */\nexport const combine = (segments: ReadonlyArray<Segment>): Accounting => {\n const prefix = segments.filter((segment) => segment.zone === \"prefix\").reduce(\n (sum, segment) => sum + segment.tokens.value,\n 0\n )\n const tail = segments.filter((segment) => segment.zone === \"tail\").reduce(\n (sum, segment) => sum + segment.tokens.value,\n 0\n )\n const estimated = segments.some((segment) => segment.tokens.estimated)\n return new Accounting({\n prefix: new Count({ value: prefix, estimated }),\n tail: new Count({ value: tail, estimated }),\n total: new Count({ value: prefix + tail, estimated }),\n bySegment: segments\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAAuB;AAWhB,MAAM,cAAc,qBAAO,MAAa,4BAA4B,EAAE;AAAA,EAC3E,OAAO,qBAAO,IAAI,MAAM,qBAAO,uBAAuB,CAAC,CAAC;AAAA,EACxD,WAAW,qBAAO;AACpB,CAAC,EAAE;AAAC;AAUG,MAAM,gBAAgB,qBAAO,MAAe,8BAA8B,EAAE;AAAA,EACjF,QAAQ,qBAAO;AAAA,EACf,MAAM,qBAAO,SAAS,CAAC,UAAU,MAAM,CAAC;AAAA,EACxC,QAAQ;AACV,CAAC,EAAE;AAAC;AAUG,MAAM,mBAAmB,qBAAO,MAAkB,iCAAiC,EAAE;AAAA,EAC1F,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW,qBAAO,MAAM,OAAO;AACjC,CAAC,EAAE;AAAC;AAiBG,MAAM,WAAsB,CAAC,SAAS;AAC3C,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAM,kBAAkB,KAAK,MAAM,iBAAiB,KAAK,CAAC,GAAG;AAC7D,QAAM,YAAY,KAAK,MAAM,KAAK,KAAK,CAAC,GAAG;AAC3C,SAAO,KAAK,MAAM,KAAK,SAAS,iBAAiB,OAAO,WAAW,OAAO,CAAC;AAC7E;AAUO,MAAM,QAAQ,CAAC,MAAc,YAAuB,aACzD,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,KAAK,UAAU,IAAI,CAAC,CAAC,GAAG,WAAW,KAAK,CAAC;AASxE,MAAM,UAAU,CAAC,aAAiD;AACvE,QAAM,SAAS,SAAS,OAAO,CAAC,YAAY,QAAQ,SAAS,QAAQ,EAAE;AAAA,I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