@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,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative supervisor monitors: what one reading can put in front of the
|
|
3
|
+
* run, and when.
|
|
4
|
+
*
|
|
5
|
+
* A monitor turns one {@link Supervisor.Reading} into a probability `p` and a
|
|
6
|
+
* sentence. A {@link Questioned} monitor adds one boolean question to the
|
|
7
|
+
* supervisor's single Jev call; a {@link Derived} monitor scores answers the
|
|
8
|
+
* supervisor already asks and costs nothing. {@link evaluate} runs at reading
|
|
9
|
+
* time and renders every crossed monitor's text against the reading's own
|
|
10
|
+
* snapshot. {@link gate} runs later, at the recorded steering drain, against
|
|
11
|
+
* the durable {@link Ledger}: it applies each monitor's streak, cooldown and
|
|
12
|
+
* limit and delivers at most one message.
|
|
13
|
+
*
|
|
14
|
+
* Both halves are pure. Nothing here asks Jev, journals, or steers.
|
|
15
|
+
*
|
|
16
|
+
* @since 1.0.0-rc.0
|
|
17
|
+
*/
|
|
18
|
+
import * as Digest from "@smthrs/core/Digest";
|
|
19
|
+
import * as Fault from "@smthrs/flow/Fault";
|
|
20
|
+
import * as Classifier from "@smthrs/model/Classifier";
|
|
21
|
+
import * as Effect from "effect/Effect";
|
|
22
|
+
import * as Schema from "effect/Schema";
|
|
23
|
+
import { NonNegativeSafeInt } from "./internal/nonNegativeSafeInt.js";
|
|
24
|
+
import * as Supervisor from "./Supervisor.js";
|
|
25
|
+
/**
|
|
26
|
+
* The budget each kind starts from.
|
|
27
|
+
*
|
|
28
|
+
* @category constants
|
|
29
|
+
* @since 1.0.0-rc.0
|
|
30
|
+
*/
|
|
31
|
+
export const budgets = {
|
|
32
|
+
lint: { at: 0.8, consecutive: 1, cooldownFrames: 6, limit: 2, priority: 30 },
|
|
33
|
+
mood: { at: 0.8, consecutive: 2, cooldownFrames: 6, limit: 2, priority: 20 },
|
|
34
|
+
skill: { at: 0.85, consecutive: 1, cooldownFrames: 6, limit: 1, priority: 10 }
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The ids a monitor may take.
|
|
38
|
+
*
|
|
39
|
+
* @category constants
|
|
40
|
+
* @since 1.0.0-rc.0
|
|
41
|
+
*/
|
|
42
|
+
export const idPattern = /^[a-z][a-z0-9_]{0,47}$/;
|
|
43
|
+
/**
|
|
44
|
+
* The classifier question id of one monitor.
|
|
45
|
+
*
|
|
46
|
+
* @category conversions
|
|
47
|
+
* @since 1.0.0-rc.0
|
|
48
|
+
*/
|
|
49
|
+
export const questionId = (id) => `${Supervisor.monitorPrefix}${id}`;
|
|
50
|
+
/**
|
|
51
|
+
* Declares one monitor, filling any budget field from its kind's
|
|
52
|
+
* {@link budgets}.
|
|
53
|
+
*
|
|
54
|
+
* @category constructors
|
|
55
|
+
* @since 1.0.0-rc.0
|
|
56
|
+
*/
|
|
57
|
+
export const make = (input) => ({ ...budgets[input.kind], ...input });
|
|
58
|
+
/**
|
|
59
|
+
* A monitor declaration that cannot be run.
|
|
60
|
+
*
|
|
61
|
+
* @category errors
|
|
62
|
+
* @since 1.0.0-rc.0
|
|
63
|
+
*/
|
|
64
|
+
export class InvalidMonitor extends Schema.TaggedError()("@smthrs/harness/Monitor/InvalidMonitor", {
|
|
65
|
+
id: Schema.String,
|
|
66
|
+
message: Schema.String
|
|
67
|
+
}) {
|
|
68
|
+
}
|
|
69
|
+
Fault.register("@smthrs/harness/Monitor/InvalidMonitor", "bug");
|
|
70
|
+
const count = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
71
|
+
/** Ids each supervisor reading declares itself: its skill monitors and the use-jev lint. */
|
|
72
|
+
const reserved = /^(?:skill_|use_jev$)/;
|
|
73
|
+
const invalid = (monitor, seen) => {
|
|
74
|
+
if (!idPattern.test(monitor.id))
|
|
75
|
+
return `id must match ${idPattern.source}`;
|
|
76
|
+
if (reserved.test(monitor.id))
|
|
77
|
+
return "id is reserved";
|
|
78
|
+
if (seen.has(monitor.id))
|
|
79
|
+
return "id is declared twice";
|
|
80
|
+
if (!(monitor.at > 0 && monitor.at <= 1))
|
|
81
|
+
return `at ${monitor.at} is outside (0, 1]`;
|
|
82
|
+
for (const field of ["consecutive", "cooldownFrames", "limit"]) {
|
|
83
|
+
if (!count(monitor[field]))
|
|
84
|
+
return `${field} ${monitor[field]} is not a non-negative integer`;
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Admits a set of host monitors, or names the first one that cannot be run.
|
|
90
|
+
* The ids each reading adds (`skill_*`, `use_jev`) are reserved.
|
|
91
|
+
*
|
|
92
|
+
* @category validation
|
|
93
|
+
* @since 1.0.0-rc.0
|
|
94
|
+
*/
|
|
95
|
+
export const validate = (monitors) => Effect.suspend(() => {
|
|
96
|
+
const seen = new Set();
|
|
97
|
+
for (const monitor of monitors) {
|
|
98
|
+
const message = invalid(monitor, seen);
|
|
99
|
+
if (message !== undefined)
|
|
100
|
+
return Effect.fail(new InvalidMonitor({ id: monitor.id, message }));
|
|
101
|
+
seen.add(monitor.id);
|
|
102
|
+
}
|
|
103
|
+
return Effect.succeed(monitors);
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* The supervisor's own nudge as a monitor: it crosses exactly when
|
|
107
|
+
* {@link Supervisor.crosses} does and says {@link Supervisor.nudge}, with no
|
|
108
|
+
* streak, cooldown or limit.
|
|
109
|
+
*
|
|
110
|
+
* @category constructors
|
|
111
|
+
* @since 1.0.0-rc.0
|
|
112
|
+
*/
|
|
113
|
+
export const lint = () => [
|
|
114
|
+
make({
|
|
115
|
+
_tag: "Derived",
|
|
116
|
+
id: "supervisor",
|
|
117
|
+
kind: "lint",
|
|
118
|
+
at: 0.5,
|
|
119
|
+
consecutive: 1,
|
|
120
|
+
cooldownFrames: 0,
|
|
121
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
122
|
+
priority: 30,
|
|
123
|
+
score: (reading) => Supervisor.crosses(reading) ? 1 : 0,
|
|
124
|
+
say: Supervisor.nudge
|
|
125
|
+
})
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* What the `paranoid` monitor says.
|
|
129
|
+
*
|
|
130
|
+
* @category constants
|
|
131
|
+
* @since 1.0.0-rc.0
|
|
132
|
+
*/
|
|
133
|
+
export const paranoidText = "Stance: paranoid. Treat your last result as wrong until a printed check shows it.";
|
|
134
|
+
/**
|
|
135
|
+
* What the `careful` monitor says.
|
|
136
|
+
*
|
|
137
|
+
* @category constants
|
|
138
|
+
* @since 1.0.0-rc.0
|
|
139
|
+
*/
|
|
140
|
+
export const carefulText = "Stance: careful. No destructive or out-of-scope call; ask with ctx.park if unsure.";
|
|
141
|
+
/**
|
|
142
|
+
* What the `step_back` monitor says.
|
|
143
|
+
*
|
|
144
|
+
* @category constants
|
|
145
|
+
* @since 1.0.0-rc.0
|
|
146
|
+
*/
|
|
147
|
+
export const stepBackText = "Stance: step back. Name the wrong assumption before the next edit.";
|
|
148
|
+
/**
|
|
149
|
+
* What the `clarify` monitor says.
|
|
150
|
+
*
|
|
151
|
+
* @category constants
|
|
152
|
+
* @since 1.0.0-rc.0
|
|
153
|
+
*/
|
|
154
|
+
export const clarifyText = "Stance: unsure of the task. Restate it in one line and check it against the files.";
|
|
155
|
+
const mood = (id, text, fires, budget = {}) => make({
|
|
156
|
+
_tag: "Derived",
|
|
157
|
+
id,
|
|
158
|
+
kind: "mood",
|
|
159
|
+
...budget,
|
|
160
|
+
score: (reading, snapshot) => fires(reading, snapshot) ? 1 : 0,
|
|
161
|
+
say: () => text
|
|
162
|
+
});
|
|
163
|
+
/**
|
|
164
|
+
* Stance monitors over the emotions and help the supervisor already reads.
|
|
165
|
+
*
|
|
166
|
+
* `paranoid` scores on a signal the `supervisor` lint does not own: a demand
|
|
167
|
+
* counter increased. A completion the run survived is a bounced one — a
|
|
168
|
+
* standing completion ends the run, so no reading ever follows it — and a
|
|
169
|
+
* bounce is what spends a narrowing, unmoved, unresolved or claim demand, so
|
|
170
|
+
* a frame whose transition is `complete` in the snapshot is the increase.
|
|
171
|
+
* Scoring it on `suspect` instead crossed exactly when the priority-30 lint
|
|
172
|
+
* did, and the mood never won the slot (#2028).
|
|
173
|
+
*
|
|
174
|
+
* @category constructors
|
|
175
|
+
* @since 1.0.0-rc.0
|
|
176
|
+
*/
|
|
177
|
+
export const moods = () => [
|
|
178
|
+
mood("paranoid", paranoidText, (reading, snapshot) => reading.emotions.confident === "strong" &&
|
|
179
|
+
snapshot.frames.some((frame) => frame.transition === "complete")),
|
|
180
|
+
mood("careful", carefulText, (reading) => reading.emotions.scared === "strong" || reading.needsHelp === "risky_action"),
|
|
181
|
+
mood("step_back", stepBackText, (reading) => reading.emotions.frustrated === "strong", { consecutive: 2 }),
|
|
182
|
+
mood("clarify", clarifyText, (reading) => reading.emotions.confused === "strong")
|
|
183
|
+
];
|
|
184
|
+
/**
|
|
185
|
+
* The built-in monitors: {@link lint} then {@link moods}.
|
|
186
|
+
*
|
|
187
|
+
* @category constructors
|
|
188
|
+
* @since 1.0.0-rc.0
|
|
189
|
+
*/
|
|
190
|
+
export const defaults = () => [...lint(), ...moods()];
|
|
191
|
+
const skillQuestions = [];
|
|
192
|
+
/** The question about `skills[index]`, one object per index so the classifier is declared once. */
|
|
193
|
+
const skillQuestion = (index) => skillQuestions[index] ??= Classifier.boolean({
|
|
194
|
+
instructions: `Would reading skills[${index}] now change what the run does next for the task as stated?`,
|
|
195
|
+
criteria: {
|
|
196
|
+
true: `the newest frames do the work skills[${index}] describes without having read it, or violate what it prescribes`,
|
|
197
|
+
false: "unrelated, or the run already follows it"
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
const skillId = (name) => `skill_${name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "")}`.slice(0, 48);
|
|
201
|
+
/**
|
|
202
|
+
* What the skill monitor for `name` says.
|
|
203
|
+
*
|
|
204
|
+
* @category conversions
|
|
205
|
+
* @since 1.0.0-rc.0
|
|
206
|
+
*/
|
|
207
|
+
export const skillText = (name, path) => `Read skill \`${name}\` first: await ctx.call("read", { path: ${JSON.stringify(path)} })`;
|
|
208
|
+
/**
|
|
209
|
+
* One monitor per skill the snapshot offers, asking whether reading it now
|
|
210
|
+
* would change what the run does next. Its id is `skill_` and the name made
|
|
211
|
+
* safe, with a digest of the name after it when two names make the same id.
|
|
212
|
+
* It says only the skill's name and path, never its description.
|
|
213
|
+
*
|
|
214
|
+
* @category constructors
|
|
215
|
+
* @since 1.0.0-rc.0
|
|
216
|
+
*/
|
|
217
|
+
export const skills = (snapshot) => {
|
|
218
|
+
const seen = new Set();
|
|
219
|
+
return snapshot.skills.map((skill, index) => {
|
|
220
|
+
const plain = skillId(skill.name);
|
|
221
|
+
const id = seen.has(plain) ? `${plain.slice(0, 39)}_${Digest.digest(skill.name).slice(0, 8)}` : plain;
|
|
222
|
+
seen.add(id);
|
|
223
|
+
const text = skillText(skill.name, skill.path);
|
|
224
|
+
return make({ _tag: "Questioned", id, kind: "skill", question: skillQuestion(index), say: () => text });
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* What the `use_jev` monitor says.
|
|
229
|
+
*
|
|
230
|
+
* @category constants
|
|
231
|
+
* @since 1.0.0-rc.0
|
|
232
|
+
*/
|
|
233
|
+
export const useJevText = "Judge those items with one jev call, one question per item.";
|
|
234
|
+
const useJevQuestion = Classifier.boolean({
|
|
235
|
+
instructions: "Do the newest frames print lists of items (files, hits, failures, candidates) and then choose among them by hand?",
|
|
236
|
+
criteria: {
|
|
237
|
+
true: "a frame prints several items and a later cell or its prose picks among them without a jev call",
|
|
238
|
+
false: "no list is chosen from by hand, or the choice was a jev call"
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* The lint that nudges a run choosing among printed items by hand toward one
|
|
243
|
+
* `jev` call, asked only while the run can call `jev`.
|
|
244
|
+
*
|
|
245
|
+
* @category constructors
|
|
246
|
+
* @since 1.0.0-rc.0
|
|
247
|
+
*/
|
|
248
|
+
export const useJev = () => make({
|
|
249
|
+
_tag: "Questioned",
|
|
250
|
+
id: "use_jev",
|
|
251
|
+
kind: "lint",
|
|
252
|
+
at: 0.85,
|
|
253
|
+
limit: 2,
|
|
254
|
+
question: useJevQuestion,
|
|
255
|
+
applies: (snapshot) => snapshot.jevAvailable,
|
|
256
|
+
say: () => useJevText
|
|
257
|
+
});
|
|
258
|
+
/**
|
|
259
|
+
* The questions one snapshot adds to the supervisor's call, by
|
|
260
|
+
* {@link questionId}: every {@link Questioned} monitor whose `applies` holds.
|
|
261
|
+
*
|
|
262
|
+
* @category conversions
|
|
263
|
+
* @since 1.0.0-rc.0
|
|
264
|
+
*/
|
|
265
|
+
export const questions = (monitors, snapshot) => Object.fromEntries(monitors.flatMap((monitor) => monitor._tag === "Questioned" && (monitor.applies === undefined || monitor.applies(snapshot))
|
|
266
|
+
? [[questionId(monitor.id), monitor.question]]
|
|
267
|
+
: []));
|
|
268
|
+
/**
|
|
269
|
+
* Scores every monitor against one reading. A {@link Derived} monitor scores
|
|
270
|
+
* itself; a {@link Questioned} monitor reads `values` by monitor id and has no
|
|
271
|
+
* row when it was not asked.
|
|
272
|
+
*
|
|
273
|
+
* @category conversions
|
|
274
|
+
* @since 1.0.0-rc.0
|
|
275
|
+
*/
|
|
276
|
+
export const evaluate = (input) => {
|
|
277
|
+
const rows = [];
|
|
278
|
+
const candidates = [];
|
|
279
|
+
for (const monitor of input.monitors) {
|
|
280
|
+
const p = monitor._tag === "Derived" ? monitor.score(input.reading, input.snapshot) : input.values[monitor.id];
|
|
281
|
+
if (p === undefined)
|
|
282
|
+
continue;
|
|
283
|
+
const crossed = p >= monitor.at;
|
|
284
|
+
rows.push({ id: monitor.id, kind: monitor.kind, p, crossed });
|
|
285
|
+
if (crossed) {
|
|
286
|
+
candidates.push({
|
|
287
|
+
id: monitor.id,
|
|
288
|
+
kind: monitor.kind,
|
|
289
|
+
priority: monitor.priority,
|
|
290
|
+
p,
|
|
291
|
+
text: monitor.say(input.snapshot, input.reading)
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return { rows, candidates };
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* One monitor's durable delivery state.
|
|
299
|
+
*
|
|
300
|
+
* @category schemas
|
|
301
|
+
* @since 1.0.0-rc.0
|
|
302
|
+
*/
|
|
303
|
+
export const Entry = Schema.Struct({
|
|
304
|
+
streak: NonNegativeSafeInt.annotate({ description: "Consecutive readings that crossed" }),
|
|
305
|
+
delivered: NonNegativeSafeInt.annotate({ description: "Deliveries so far" }),
|
|
306
|
+
lastFrame: Schema.Int.annotate({ description: "The frame of the last delivery; -1 never" })
|
|
307
|
+
});
|
|
308
|
+
/**
|
|
309
|
+
* Every monitor's delivery state, by monitor id.
|
|
310
|
+
*
|
|
311
|
+
* @category schemas
|
|
312
|
+
* @since 1.0.0-rc.0
|
|
313
|
+
*/
|
|
314
|
+
export const Ledger = Schema.Record(Schema.String, Entry);
|
|
315
|
+
/**
|
|
316
|
+
* The state of a monitor with no entry.
|
|
317
|
+
*
|
|
318
|
+
* @category constants
|
|
319
|
+
* @since 1.0.0-rc.0
|
|
320
|
+
*/
|
|
321
|
+
export const fresh = { streak: 0, delivered: 0, lastFrame: -1 };
|
|
322
|
+
/**
|
|
323
|
+
* Decides, at the steering drain, which one crossed monitor is delivered.
|
|
324
|
+
*
|
|
325
|
+
* Each row moves its monitor's streak: up on a crossing, to zero otherwise; a
|
|
326
|
+
* monitor with no row keeps it. Each candidate is then withheld for its
|
|
327
|
+
* `streak`, its `cooldown` since the last delivery, or its `limit`, in that
|
|
328
|
+
* order. Of the rest the highest priority, then the lower id, takes the one
|
|
329
|
+
* slot and the others are withheld for `slot`. A candidate no monitor
|
|
330
|
+
* declares is ignored.
|
|
331
|
+
*
|
|
332
|
+
* @category conversions
|
|
333
|
+
* @since 1.0.0-rc.0
|
|
334
|
+
*/
|
|
335
|
+
export const gate = (input) => {
|
|
336
|
+
const ledger = { ...input.ledger };
|
|
337
|
+
for (const row of input.rows) {
|
|
338
|
+
const entry = ledger[row.id] ?? fresh;
|
|
339
|
+
ledger[row.id] = { ...entry, streak: row.crossed ? entry.streak + 1 : 0 };
|
|
340
|
+
}
|
|
341
|
+
const declared = new Map(input.monitors.map((monitor) => [monitor.id, monitor]));
|
|
342
|
+
const suppressed = [];
|
|
343
|
+
const eligible = [];
|
|
344
|
+
for (const candidate of input.candidates) {
|
|
345
|
+
const monitor = declared.get(candidate.id);
|
|
346
|
+
if (monitor === undefined)
|
|
347
|
+
continue;
|
|
348
|
+
const entry = ledger[candidate.id] ?? fresh;
|
|
349
|
+
const reason = entry.streak < monitor.consecutive
|
|
350
|
+
? "streak"
|
|
351
|
+
: entry.lastFrame >= 0 && input.frame - entry.lastFrame < monitor.cooldownFrames
|
|
352
|
+
? "cooldown"
|
|
353
|
+
: entry.delivered >= monitor.limit
|
|
354
|
+
? "limit"
|
|
355
|
+
: undefined;
|
|
356
|
+
if (reason === undefined)
|
|
357
|
+
eligible.push(candidate);
|
|
358
|
+
else
|
|
359
|
+
suppressed.push({ id: candidate.id, reason });
|
|
360
|
+
}
|
|
361
|
+
const [winner, ...losers] = [...eligible].sort((a, b) => b.priority - a.priority || (a.id < b.id ? -1 : 1));
|
|
362
|
+
for (const loser of losers)
|
|
363
|
+
suppressed.push({ id: loser.id, reason: "slot" });
|
|
364
|
+
if (winner === undefined)
|
|
365
|
+
return { suppressed, ledger };
|
|
366
|
+
const entry = ledger[winner.id] ?? fresh;
|
|
367
|
+
ledger[winner.id] = { ...entry, delivered: entry.delivered + 1, lastFrame: input.frame };
|
|
368
|
+
return { message: { id: winner.id, text: winner.text }, suppressed, ledger };
|
|
369
|
+
};
|
|
370
|
+
//# sourceMappingURL=Monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Monitor.js","sourceRoot":"","sources":["../../src/Monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;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AAM,EAAE,CAAC,CAAA;IAC7E,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,CAAA;IACxC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;IACxF,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;AAC9E,CAAC,CAAA","sourcesContent":["/**\n * Declarative supervisor monitors: what one reading can put in front of the\n * run, and when.\n *\n * A monitor turns one {@link Supervisor.Reading} into a probability `p` and a\n * sentence. A {@link Questioned} monitor adds one boolean question to the\n * supervisor's single Jev call; a {@link Derived} monitor scores answers the\n * supervisor already asks and costs nothing. {@link evaluate} runs at reading\n * time and renders every crossed monitor's text against the reading's own\n * snapshot. {@link gate} runs later, at the recorded steering drain, against\n * the durable {@link Ledger}: it applies each monitor's streak, cooldown and\n * limit and delivers at most one message.\n *\n * Both halves are pure. Nothing here asks Jev, journals, or steers.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Digest from \"@smthrs/core/Digest\"\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport * as Classifier from \"@smthrs/model/Classifier\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport type * as AgentEvent from \"./AgentEvent.ts\"\nimport { NonNegativeSafeInt } from \"./internal/nonNegativeSafeInt.ts\"\nimport * as Supervisor from \"./Supervisor.ts\"\n\n/**\n * What a monitor watches for.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Kind = typeof AgentEvent.MonitorKind.Type\n\n/**\n * The fields every monitor declares.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Common {\n /** Matches {@link idPattern}; the question id is {@link questionId}. */\n readonly id: string\n readonly kind: Kind\n /** Crosses when `p >= at`; in `(0, 1]`. */\n readonly at: number\n /** Consecutive crossed readings before delivery. */\n readonly consecutive: number\n /** Frames after a delivery before the next one. */\n readonly cooldownFrames: number\n /** Deliveries per run. */\n readonly limit: number\n /** The higher priority takes the one slot. */\n readonly priority: number\n readonly say: (snapshot: Supervisor.Snapshot, reading: Supervisor.Reading) => string\n}\n\n/**\n * A monitor that adds one boolean question to the supervisor's Jev call.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Questioned extends Common {\n readonly _tag: \"Questioned\"\n readonly question: Classifier.BooleanQuestion\n /** Whether the question is asked of this snapshot; always when absent. */\n readonly applies?: (snapshot: Supervisor.Snapshot) => boolean\n}\n\n/**\n * A monitor scored from answers the supervisor already asks.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Derived extends Common {\n readonly _tag: \"Derived\"\n readonly score: (reading: Supervisor.Reading, snapshot: Supervisor.Snapshot) => number\n}\n\n/**\n * One declared monitor.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Monitor = Questioned | Derived\n\n/**\n * The fields {@link make} fills from {@link budgets}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Budget = Pick<Common, \"at\" | \"consecutive\" | \"cooldownFrames\" | \"limit\" | \"priority\">\n\n/**\n * A monitor as declared, with its budget optional.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Input = (Omit<Questioned, keyof Budget> | Omit<Derived, keyof Budget>) & Partial<Budget>\n\n/**\n * The budget each kind starts from.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const budgets: Readonly<Record<Kind, Budget>> = {\n lint: { at: 0.8, consecutive: 1, cooldownFrames: 6, limit: 2, priority: 30 },\n mood: { at: 0.8, consecutive: 2, cooldownFrames: 6, limit: 2, priority: 20 },\n skill: { at: 0.85, consecutive: 1, cooldownFrames: 6, limit: 1, priority: 10 }\n}\n\n/**\n * The ids a monitor may take.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const idPattern = /^[a-z][a-z0-9_]{0,47}$/\n\n/**\n * The classifier question id of one monitor.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const questionId = (id: string): keyof Supervisor.MonitorQuestions => `${Supervisor.monitorPrefix}${id}`\n\n/**\n * Declares one monitor, filling any budget field from its kind's\n * {@link budgets}.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const make = (input: Input): Monitor => ({ ...budgets[input.kind], ...input })\n\n/**\n * A monitor declaration that cannot be run.\n *\n * @category errors\n * @since 1.0.0-rc.0\n */\nexport class InvalidMonitor extends Schema.TaggedError<InvalidMonitor>()(\"@smthrs/harness/Monitor/InvalidMonitor\", {\n id: Schema.String,\n message: Schema.String\n}) {}\nFault.register(\"@smthrs/harness/Monitor/InvalidMonitor\", \"bug\")\n\ntype Suppression = typeof AgentEvent.Suppression.Type\n\nconst count = (value: number): boolean => Number.isSafeInteger(value) && value >= 0\n\n/** Ids each supervisor reading declares itself: its skill monitors and the use-jev lint. */\nconst reserved = /^(?:skill_|use_jev$)/\n\nconst invalid = (monitor: Monitor, seen: ReadonlySet<string>): string | undefined => {\n if (!idPattern.test(monitor.id)) return `id must match ${idPattern.source}`\n if (reserved.test(monitor.id)) return \"id is reserved\"\n if (seen.has(monitor.id)) return \"id is declared twice\"\n if (!(monitor.at > 0 && monitor.at <= 1)) return `at ${monitor.at} is outside (0, 1]`\n for (const field of [\"consecutive\", \"cooldownFrames\", \"limit\"] as const) {\n if (!count(monitor[field])) return `${field} ${monitor[field]} is not a non-negative integer`\n }\n return undefined\n}\n\n/**\n * Admits a set of host monitors, or names the first one that cannot be run.\n * The ids each reading adds (`skill_*`, `use_jev`) are reserved.\n *\n * @category validation\n * @since 1.0.0-rc.0\n */\nexport const validate = (\n monitors: ReadonlyArray<Monitor>\n): Effect.Effect<ReadonlyArray<Monitor>, InvalidMonitor> =>\n Effect.suspend(() => {\n const seen = new Set<string>()\n for (const monitor of monitors) {\n const message = invalid(monitor, seen)\n if (message !== undefined) return Effect.fail(new InvalidMonitor({ id: monitor.id, message }))\n seen.add(monitor.id)\n }\n return Effect.succeed(monitors)\n })\n\n/**\n * The supervisor's own nudge as a monitor: it crosses exactly when\n * {@link Supervisor.crosses} does and says {@link Supervisor.nudge}, with no\n * streak, cooldown or limit.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const lint = (): ReadonlyArray<Monitor> => [\n make({\n _tag: \"Derived\",\n id: \"supervisor\",\n kind: \"lint\",\n at: 0.5,\n consecutive: 1,\n cooldownFrames: 0,\n limit: Number.MAX_SAFE_INTEGER,\n priority: 30,\n score: (reading) => Supervisor.crosses(reading) ? 1 : 0,\n say: Supervisor.nudge\n })\n]\n\n/**\n * What the `paranoid` monitor says.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const paranoidText = \"Stance: paranoid. Treat your last result as wrong until a printed check shows it.\"\n\n/**\n * What the `careful` monitor says.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const carefulText = \"Stance: careful. No destructive or out-of-scope call; ask with ctx.park if unsure.\"\n\n/**\n * What the `step_back` monitor says.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const stepBackText = \"Stance: step back. Name the wrong assumption before the next edit.\"\n\n/**\n * What the `clarify` monitor says.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const clarifyText = \"Stance: unsure of the task. Restate it in one line and check it against the files.\"\n\nconst mood = (\n id: string,\n text: string,\n fires: (reading: Supervisor.Reading, snapshot: Supervisor.Snapshot) => boolean,\n budget: Partial<Budget> = {}\n): Monitor =>\n make({\n _tag: \"Derived\",\n id,\n kind: \"mood\",\n ...budget,\n score: (reading, snapshot) => fires(reading, snapshot) ? 1 : 0,\n say: () => text\n })\n\n/**\n * Stance monitors over the emotions and help the supervisor already reads.\n *\n * `paranoid` scores on a signal the `supervisor` lint does not own: a demand\n * counter increased. A completion the run survived is a bounced one — a\n * standing completion ends the run, so no reading ever follows it — and a\n * bounce is what spends a narrowing, unmoved, unresolved or claim demand, so\n * a frame whose transition is `complete` in the snapshot is the increase.\n * Scoring it on `suspect` instead crossed exactly when the priority-30 lint\n * did, and the mood never won the slot (#2028).\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const moods = (): ReadonlyArray<Monitor> => [\n mood(\n \"paranoid\",\n paranoidText,\n (reading, snapshot) =>\n reading.emotions.confident === \"strong\" &&\n snapshot.frames.some((frame) => frame.transition === \"complete\")\n ),\n mood(\n \"careful\",\n carefulText,\n (reading) => reading.emotions.scared === \"strong\" || reading.needsHelp === \"risky_action\"\n ),\n mood(\"step_back\", stepBackText, (reading) => reading.emotions.frustrated === \"strong\", { consecutive: 2 }),\n mood(\"clarify\", clarifyText, (reading) => reading.emotions.confused === \"strong\")\n]\n\n/**\n * The built-in monitors: {@link lint} then {@link moods}.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const defaults = (): ReadonlyArray<Monitor> => [...lint(), ...moods()]\n\nconst skillQuestions: Array<Classifier.BooleanQuestion> = []\n\n/** The question about `skills[index]`, one object per index so the classifier is declared once. */\nconst skillQuestion = (index: number): Classifier.BooleanQuestion =>\n skillQuestions[index] ??= Classifier.boolean({\n instructions: `Would reading skills[${index}] now change what the run does next for the task as stated?`,\n criteria: {\n true:\n `the newest frames do the work skills[${index}] describes without having read it, or violate what it prescribes`,\n false: \"unrelated, or the run already follows it\"\n }\n })\n\nconst skillId = (name: string): string =>\n `skill_${name.toLowerCase().replace(/[^a-z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\")}`.slice(0, 48)\n\n/**\n * What the skill monitor for `name` says.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const skillText = (name: string, path: string): string =>\n `Read skill \\`${name}\\` first: await ctx.call(\"read\", { path: ${JSON.stringify(path)} })`\n\n/**\n * One monitor per skill the snapshot offers, asking whether reading it now\n * would change what the run does next. Its id is `skill_` and the name made\n * safe, with a digest of the name after it when two names make the same id.\n * It says only the skill's name and path, never its description.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const skills = (snapshot: Supervisor.Snapshot): ReadonlyArray<Monitor> => {\n const seen = new Set<string>()\n return snapshot.skills.map((skill, index) => {\n const plain = skillId(skill.name)\n const id = seen.has(plain) ? `${plain.slice(0, 39)}_${Digest.digest(skill.name).slice(0, 8)}` : plain\n seen.add(id)\n const text = skillText(skill.name, skill.path)\n return make({ _tag: \"Questioned\", id, kind: \"skill\", question: skillQuestion(index), say: () => text })\n })\n}\n\n/**\n * What the `use_jev` monitor says.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const useJevText = \"Judge those items with one jev call, one question per item.\"\n\nconst useJevQuestion = Classifier.boolean({\n instructions:\n \"Do the newest frames print lists of items (files, hits, failures, candidates) and then choose among them by hand?\",\n criteria: {\n true: \"a frame prints several items and a later cell or its prose picks among them without a jev call\",\n false: \"no list is chosen from by hand, or the choice was a jev call\"\n }\n})\n\n/**\n * The lint that nudges a run choosing among printed items by hand toward one\n * `jev` call, asked only while the run can call `jev`.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const useJev = (): Monitor =>\n make({\n _tag: \"Questioned\",\n id: \"use_jev\",\n kind: \"lint\",\n at: 0.85,\n limit: 2,\n question: useJevQuestion,\n applies: (snapshot) => snapshot.jevAvailable,\n say: () => useJevText\n })\n\n/**\n * The questions one snapshot adds to the supervisor's call, by\n * {@link questionId}: every {@link Questioned} monitor whose `applies` holds.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const questions = (\n monitors: ReadonlyArray<Monitor>,\n snapshot: Supervisor.Snapshot\n): Supervisor.MonitorQuestions =>\n Object.fromEntries(\n monitors.flatMap((monitor) =>\n monitor._tag === \"Questioned\" && (monitor.applies === undefined || monitor.applies(snapshot))\n ? [[questionId(monitor.id), monitor.question] as const]\n : []\n )\n )\n\n/**\n * One monitor's value in one reading.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Row {\n readonly id: string\n readonly kind: Kind\n readonly p: number\n readonly crossed: boolean\n}\n\n/**\n * A crossed monitor's message, rendered against the reading it crossed on.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Candidate {\n readonly id: string\n readonly kind: Kind\n readonly priority: number\n readonly p: number\n readonly text: string\n}\n\n/**\n * What one reading says about every monitor.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Evaluation {\n readonly rows: ReadonlyArray<Row>\n readonly candidates: ReadonlyArray<Candidate>\n}\n\n/**\n * Scores every monitor against one reading. A {@link Derived} monitor scores\n * itself; a {@link Questioned} monitor reads `values` by monitor id and has no\n * row when it was not asked.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const evaluate = (input: {\n readonly monitors: ReadonlyArray<Monitor>\n readonly reading: Supervisor.Reading\n readonly snapshot: Supervisor.Snapshot\n readonly values: Readonly<Record<string, number>>\n}): Evaluation => {\n const rows: Array<Row> = []\n const candidates: Array<Candidate> = []\n for (const monitor of input.monitors) {\n const p = monitor._tag === \"Derived\" ? monitor.score(input.reading, input.snapshot) : input.values[monitor.id]\n if (p === undefined) continue\n const crossed = p >= monitor.at\n rows.push({ id: monitor.id, kind: monitor.kind, p, crossed })\n if (crossed) {\n candidates.push({\n id: monitor.id,\n kind: monitor.kind,\n priority: monitor.priority,\n p,\n text: monitor.say(input.snapshot, input.reading)\n })\n }\n }\n return { rows, candidates }\n}\n\n/**\n * One monitor's durable delivery state.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Entry = Schema.Struct({\n streak: NonNegativeSafeInt.annotate({ description: \"Consecutive readings that crossed\" }),\n delivered: NonNegativeSafeInt.annotate({ description: \"Deliveries so far\" }),\n lastFrame: Schema.Int.annotate({ description: \"The frame of the last delivery; -1 never\" })\n})\n\n/**\n * The decoded form of {@link Entry}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Entry = typeof Entry.Type\n\n/**\n * Every monitor's delivery state, by monitor id.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Ledger = Schema.Record(Schema.String, Entry)\n\n/**\n * The decoded form of {@link Ledger}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Ledger = typeof Ledger.Type\n\n/**\n * The state of a monitor with no entry.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const fresh: Entry = { streak: 0, delivered: 0, lastFrame: -1 }\n\n/**\n * What one drain delivers and withholds.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Gated {\n readonly message?: { readonly id: string; readonly text: string }\n readonly suppressed: ReadonlyArray<{ readonly id: string; readonly reason: Suppression }>\n readonly ledger: Ledger\n}\n\n/**\n * Decides, at the steering drain, which one crossed monitor is delivered.\n *\n * Each row moves its monitor's streak: up on a crossing, to zero otherwise; a\n * monitor with no row keeps it. Each candidate is then withheld for its\n * `streak`, its `cooldown` since the last delivery, or its `limit`, in that\n * order. Of the rest the highest priority, then the lower id, takes the one\n * slot and the others are withheld for `slot`. A candidate no monitor\n * declares is ignored.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const gate = (input: {\n readonly rows: ReadonlyArray<Row>\n readonly candidates: ReadonlyArray<Candidate>\n readonly monitors: ReadonlyArray<Monitor>\n readonly ledger: Ledger\n readonly frame: number\n}): Gated => {\n const ledger: Record<string, Entry> = { ...input.ledger }\n for (const row of input.rows) {\n const entry = ledger[row.id] ?? fresh\n ledger[row.id] = { ...entry, streak: row.crossed ? entry.streak + 1 : 0 }\n }\n const declared = new Map(input.monitors.map((monitor) => [monitor.id, monitor] as const))\n const suppressed: Array<{ id: string; reason: Suppression }> = []\n const eligible: Array<Candidate> = []\n for (const candidate of input.candidates) {\n const monitor = declared.get(candidate.id)\n if (monitor === undefined) continue\n const entry = ledger[candidate.id] ?? fresh\n const reason: Suppression | undefined = entry.streak < monitor.consecutive\n ? \"streak\"\n : entry.lastFrame >= 0 && input.frame - entry.lastFrame < monitor.cooldownFrames\n ? \"cooldown\"\n : entry.delivered >= monitor.limit\n ? \"limit\"\n : undefined\n if (reason === undefined) eligible.push(candidate)\n else suppressed.push({ id: candidate.id, reason })\n }\n const [winner, ...losers] = [...eligible].sort((a, b) => b.priority - a.priority || (a.id < b.id ? -1 : 1))\n for (const loser of losers) suppressed.push({ id: loser.id, reason: \"slot\" })\n if (winner === undefined) return { suppressed, ledger }\n const entry = ledger[winner.id] ?? fresh\n ledger[winner.id] = { ...entry, delivered: entry.delivered + 1, lastFrame: input.frame }\n return { message: { id: winner.id, text: winner.text }, suppressed, ledger }\n}\n"]}
|