@smthrs/harness 0.0.0-stage → 1.0.0-rc.3
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 +987 -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 +1143 -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,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bound every journaled count in this package is declared with.
|
|
3
|
+
*
|
|
4
|
+
* A count that crossed the safe-integer ceiling would compare and re-encode
|
|
5
|
+
* wrongly on the way back out of a journal, so every ordinal, frame number,
|
|
6
|
+
* byte count and cap is admitted through one validator rather than six copies
|
|
7
|
+
* that happened to agree.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0-rc.0
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Schema } from "effect"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A count in `[0, Number.MAX_SAFE_INTEGER]`.
|
|
17
|
+
*
|
|
18
|
+
* @since 1.0.0-rc.0
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
export const NonNegativeSafeInt = Schema.Int.check(
|
|
22
|
+
Schema.isGreaterThanOrEqualTo(0),
|
|
23
|
+
Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)
|
|
24
|
+
)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model usage a recorded boundary paid for, summed over its readings.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0-rc.1
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type * as Classifier from "@smthrs/model/Classifier"
|
|
9
|
+
import * as Evaluator from "@smthrs/model/Evaluator"
|
|
10
|
+
import type * as EngineLike from "../EngineLike.ts"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One reading's metered usage and the model that read it; absent when the
|
|
14
|
+
* transport reported none.
|
|
15
|
+
*
|
|
16
|
+
* @since 1.0.0-rc.1
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
export type Metered =
|
|
20
|
+
| { readonly inputTokens: number; readonly outputTokens: number; readonly modelId?: string | undefined }
|
|
21
|
+
| undefined
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Sums the readings that were metered, one share per model in the order each
|
|
25
|
+
* model first read. `undefined` when none was: a reading the transport did not
|
|
26
|
+
* meter is not a reading that cost zero.
|
|
27
|
+
*
|
|
28
|
+
* @since 1.0.0-rc.1
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
export const paidUsage = (readings: ReadonlyArray<Metered>): ReadonlyArray<EngineLike.Paid> | undefined => {
|
|
32
|
+
const shares = new Map<string | undefined, { inputTokens: number; outputTokens: number }>()
|
|
33
|
+
for (const reading of readings) {
|
|
34
|
+
if (reading === undefined) continue
|
|
35
|
+
const share = shares.get(reading.modelId)
|
|
36
|
+
shares.set(reading.modelId, {
|
|
37
|
+
inputTokens: (share?.inputTokens ?? 0) + reading.inputTokens,
|
|
38
|
+
outputTokens: (share?.outputTokens ?? 0) + reading.outputTokens
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
if (shares.size === 0) return undefined
|
|
42
|
+
return [...shares].map(([modelId, usage]) => modelId === undefined ? { usage } : { usage, modelId })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* What two readings of one completion paid together. Either may come back
|
|
47
|
+
* unmetered; the completion costs what was metered. Both ask the same judge,
|
|
48
|
+
* so the sum keeps its model id, and drops it only when a fallback answered
|
|
49
|
+
* one.
|
|
50
|
+
*
|
|
51
|
+
* @since 1.0.0-rc.1
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
export const paidTogether = (
|
|
55
|
+
first: Evaluator.Usage | undefined,
|
|
56
|
+
second: Evaluator.Usage | undefined
|
|
57
|
+
): Evaluator.Usage | undefined => {
|
|
58
|
+
if (first === undefined) return second
|
|
59
|
+
if (second === undefined) return first
|
|
60
|
+
const modelId = first.modelId === second.modelId ? first.modelId : undefined
|
|
61
|
+
return {
|
|
62
|
+
inputTokens: first.inputTokens + second.inputTokens,
|
|
63
|
+
outputTokens: first.outputTokens + second.outputTokens,
|
|
64
|
+
...(modelId === undefined ? {} : { modelId })
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A reading that failed, as the typed cause its turn fails with: the
|
|
70
|
+
* transport's code and structured facts, its public message (a transport's
|
|
71
|
+
* own text can name hosts and URLs), and what it paid with what the
|
|
72
|
+
* `earlier` readings of the same completion paid, so the run's budget
|
|
73
|
+
* charges both (#3010).
|
|
74
|
+
*
|
|
75
|
+
* @since 1.0.0-rc.1
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
export const failedReading = (
|
|
79
|
+
error: Classifier.ClassifierError,
|
|
80
|
+
earlier: Evaluator.Usage | undefined
|
|
81
|
+
): Evaluator.EvaluatorError => {
|
|
82
|
+
const usage = paidTogether(earlier, error.usage)
|
|
83
|
+
return new Evaluator.EvaluatorError({
|
|
84
|
+
code: error.code,
|
|
85
|
+
message: Evaluator.publicMessage(error),
|
|
86
|
+
...(error.resetAtEpochMillis === undefined ? {} : { resetAtEpochMillis: error.resetAtEpochMillis }),
|
|
87
|
+
...(error.status === undefined ? {} : { status: error.status }),
|
|
88
|
+
...(usage === undefined ? {} : { usage })
|
|
89
|
+
})
|
|
90
|
+
}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The print channel: how a REPL frame's `console.log` calls become the bytes
|
|
3
|
+
* its successor reads.
|
|
4
|
+
*
|
|
5
|
+
* Two jobs live here, and both were priced off the `rerun-r95repl` lane rather
|
|
6
|
+
* than chosen.
|
|
7
|
+
*
|
|
8
|
+
* Every number here is a count of UTF-8 bytes, which is what the frame bound
|
|
9
|
+
* and the retention ceiling both mean by "bytes": the notices this module writes
|
|
10
|
+
* carry a `…`, three bytes wide and one UTF-16 unit, and counting them in units
|
|
11
|
+
* put a frame one byte over its own ceiling.
|
|
12
|
+
*
|
|
13
|
+
* **Sharing the frame budget.** Statements used to cap independently at 4 KiB
|
|
14
|
+
* each, head-first, under a 16 KiB frame bound that almost nobody reached: 197
|
|
15
|
+
* of the lane's 357 printing frames had a statement cut, 191 of those while the
|
|
16
|
+
* frame bound sat mostly unspent, and 3.06 MB went to per-statement caps against
|
|
17
|
+
* 6 frames that ever reached the frame one. Head-first is the part that cost
|
|
18
|
+
* verdicts — `sympy__sympy-13878` fused one `console.log` of 38,928 bytes whose
|
|
19
|
+
* head was a Python deprecation banner, so what it lost was the tail: the result
|
|
20
|
+
* of a three-minute test suite the same frame had just paid for, and the `git
|
|
21
|
+
* diff` that would have shown it the edit was already in the tree. It re-ran
|
|
22
|
+
* that suite four frames later. So the statements of a frame share one budget,
|
|
23
|
+
* each is elided from the middle, and no ceiling moves: 16 KiB was the most a
|
|
24
|
+
* frame could deliver before and it is the most now.
|
|
25
|
+
*
|
|
26
|
+
* **Compacting a printed structure.** A result printed whole is mostly repeated
|
|
27
|
+
* keys — a grep hit names `file`, `line`, `text` once per match — so an array of
|
|
28
|
+
* matches renders as file groups with numbered hits and context; other records
|
|
29
|
+
* render as a table with the union of keys named once. It is keyed on the shape
|
|
30
|
+
* and nothing else — this module knows no flow. Repeated keys save bytes;
|
|
31
|
+
* sparse records with mostly distinct keys can cost more as a table.
|
|
32
|
+
*
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
* @private
|
|
35
|
+
* @slop
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import { isRecord } from "@smthrs/canonical/Record"
|
|
39
|
+
import * as CanonicalJson from "@smthrs/model/CanonicalJson"
|
|
40
|
+
import type { Schema } from "effect"
|
|
41
|
+
import * as bytes from "./bytes.ts"
|
|
42
|
+
import * as elide from "./elide.ts"
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* How many UTF-8 bytes of one frame's whole print buffer reach the next model turn.
|
|
46
|
+
*
|
|
47
|
+
* This is the only ceiling on the channel. A frame's statements *share* it:
|
|
48
|
+
* each is middle-elided to the share it is apportioned, and a statement short
|
|
49
|
+
* of its share hands the remainder back to the statements that are over theirs.
|
|
50
|
+
*
|
|
51
|
+
* They used to cap independently at 4 KiB each, head-first, and the r95repl
|
|
52
|
+
* lane priced that: 197 of its 357 printing frames had a statement cut, 191 of
|
|
53
|
+
* them while this frame budget sat mostly unspent, and 3.06 MB went to
|
|
54
|
+
* per-statement caps against 6 frames that ever reached this one. The
|
|
55
|
+
* `sympy__sympy-13878` run fused one `console.log` of 38,928 bytes; it was
|
|
56
|
+
* shown the first 4,096 and lost the tail, which held the result of a
|
|
57
|
+
* three-minute test suite the frame had already paid for. It ran that suite
|
|
58
|
+
* again four frames later. Sharing the budget shows that frame 16 KiB from both
|
|
59
|
+
* ends instead of 4 KiB from the head, and moves no ceiling: 16 KiB was the
|
|
60
|
+
* most a frame could ever deliver before, and it is the most now.
|
|
61
|
+
*
|
|
62
|
+
* Every elision is from the middle with the dropped byte count stated, because
|
|
63
|
+
* the head and the tail of a log are where it identifies itself, and the notices
|
|
64
|
+
* are reserved out of this budget before any of it is apportioned — so the
|
|
65
|
+
* assembled buffer is bounded outright and nothing has to shorten it a second
|
|
66
|
+
* time. Sized against the `recall` budget it replaces, and delivered once rather
|
|
67
|
+
* than re-rendered every frame.
|
|
68
|
+
*
|
|
69
|
+
* @category constants
|
|
70
|
+
* @since 0.1.0
|
|
71
|
+
*/
|
|
72
|
+
export const printFrameBytes = 16 * 1024
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The smallest UTF-8-byte share of {@link printFrameBytes} one print statement is given.
|
|
76
|
+
*
|
|
77
|
+
* A share below this is all notice and no value — a middle elision of 80 bytes
|
|
78
|
+
* says less than the sentence explaining it — so a frame that printed more
|
|
79
|
+
* statements than the budget can floor drops whole statements from the middle
|
|
80
|
+
* and states how many, rather than cutting every one of them to nothing. That
|
|
81
|
+
* is the same shape the frame bound already had, applied a statement at a time
|
|
82
|
+
* so nothing is cut mid-line.
|
|
83
|
+
*
|
|
84
|
+
* It bounds how many statements are *kept*, but it is not a division of the
|
|
85
|
+
* budget: how many a frame can carry is priced off the statements it actually
|
|
86
|
+
* printed, so a statement at or under this size is shown whole and costs only
|
|
87
|
+
* itself. Two hundred eight-byte lines cost eighteen hundred bytes and all two
|
|
88
|
+
* hundred survive; sixty statements of four times this size do not, and whole
|
|
89
|
+
* ones go from the middle rather than every one of them being cut to a notice.
|
|
90
|
+
*
|
|
91
|
+
* @category constants
|
|
92
|
+
* @since 0.1.0
|
|
93
|
+
* @slop
|
|
94
|
+
*/
|
|
95
|
+
export const printStatementFloor = 512
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* How many UTF-8 bytes of one frame's print buffer the host keeps while the cell still runs.
|
|
99
|
+
*
|
|
100
|
+
* {@link printFrameBytes} bounds what the model is shown; this bounds what the
|
|
101
|
+
* host holds to show it from, and the two are different numbers because they
|
|
102
|
+
* answer different questions. A cell printing in a loop hands the host one
|
|
103
|
+
* payload per statement, and every payload is copied out of the sandbox's heap
|
|
104
|
+
* and decoded before anything can judge it surplus, so the frame budget alone
|
|
105
|
+
* bounds the answer while leaving the work unbounded. Sixteen times the frame
|
|
106
|
+
* budget is far past any honest use and still a fixed ceiling: past it the
|
|
107
|
+
* payload is not read at all, and the count of what went unread is stated in the
|
|
108
|
+
* buffer rather than dropped in silence.
|
|
109
|
+
*
|
|
110
|
+
* A statement is held at no more than {@link printFrameBytes} — the two ends of
|
|
111
|
+
* it, with the size it had — because a whole frame's budget is the most any one
|
|
112
|
+
* statement could ever be shown. So this ceiling holds at least sixteen
|
|
113
|
+
* statements whatever a cell prints, and a cell that prints many small values
|
|
114
|
+
* reaches it only after hundreds of them.
|
|
115
|
+
*
|
|
116
|
+
* @category constants
|
|
117
|
+
* @since 0.1.0
|
|
118
|
+
*/
|
|
119
|
+
export const printRetainedBytes = 256 * 1024
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The fewest records an array needs before it is rendered as a table.
|
|
123
|
+
*
|
|
124
|
+
* Two rows do not repay a header line, and one row is not a table at all.
|
|
125
|
+
*
|
|
126
|
+
* @since 0.1.0
|
|
127
|
+
* @private
|
|
128
|
+
* @slop
|
|
129
|
+
*/
|
|
130
|
+
export const tableRows = 3
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* What the model is told when a print was cut: the value is still bound.
|
|
134
|
+
*
|
|
135
|
+
* @since 0.1.0
|
|
136
|
+
* @private
|
|
137
|
+
* @slop
|
|
138
|
+
*/
|
|
139
|
+
export const recall = "print a narrower slice of this value; it is still bound in the realm"
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* One `console.log` call, as the host kept it.
|
|
143
|
+
*
|
|
144
|
+
* @since 0.1.0
|
|
145
|
+
* @private
|
|
146
|
+
* @slop
|
|
147
|
+
*/
|
|
148
|
+
export interface Statement {
|
|
149
|
+
/** The head and tail the host kept, in order and possibly the whole thing. */
|
|
150
|
+
readonly text: string
|
|
151
|
+
/** What the statement rendered to before anything was dropped. */
|
|
152
|
+
readonly bytes: number
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const cell = (value: Schema.Json): string =>
|
|
156
|
+
typeof value === "string" && !value.includes("\n") && !value.includes("|")
|
|
157
|
+
? value
|
|
158
|
+
: CanonicalJson.stringify(value)
|
|
159
|
+
|
|
160
|
+
/** A source line, shared by hits and their context. */
|
|
161
|
+
type MatchLine = { readonly line: number; readonly text: string }
|
|
162
|
+
|
|
163
|
+
/** The optional symbol attached to a source hit. */
|
|
164
|
+
type MatchSymbol = {
|
|
165
|
+
readonly kind: string
|
|
166
|
+
readonly name: string
|
|
167
|
+
readonly startLine: number
|
|
168
|
+
readonly endLine: number
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The exact match shape; additional data must survive in the generic table. */
|
|
172
|
+
type Match = MatchLine & {
|
|
173
|
+
readonly file: string
|
|
174
|
+
readonly before?: ReadonlyArray<MatchLine>
|
|
175
|
+
readonly after?: ReadonlyArray<MatchLine>
|
|
176
|
+
readonly symbol?: MatchSymbol
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const isMatchLine = (value: Schema.Json): value is MatchLine =>
|
|
180
|
+
isRecord<Schema.Json>(value) && Object.keys(value).length === 2 &&
|
|
181
|
+
Number.isInteger(value.line) && typeof value.text === "string"
|
|
182
|
+
|
|
183
|
+
const isMatchSymbol = (value: Schema.Json | undefined): value is MatchSymbol =>
|
|
184
|
+
isRecord<Schema.Json>(value) && Object.keys(value).length === 4 &&
|
|
185
|
+
typeof value.kind === "string" && typeof value.name === "string" &&
|
|
186
|
+
Number.isInteger(value.startLine) && Number.isInteger(value.endLine)
|
|
187
|
+
|
|
188
|
+
const isMatch = (value: Schema.Json): value is Match =>
|
|
189
|
+
isRecord<Schema.Json>(value) &&
|
|
190
|
+
typeof value.file === "string" && Number.isInteger(value.line) && typeof value.text === "string" &&
|
|
191
|
+
Object.keys(value).every((key) => ["file", "line", "text", "before", "after", "symbol"].includes(key)) &&
|
|
192
|
+
(!Object.hasOwn(value, "before") || Array.isArray(value.before) && value.before.every(isMatchLine)) &&
|
|
193
|
+
(!Object.hasOwn(value, "after") || Array.isArray(value.after) && value.after.every(isMatchLine)) &&
|
|
194
|
+
(!Object.hasOwn(value, "symbol") || isMatchSymbol(value.symbol))
|
|
195
|
+
|
|
196
|
+
/** Renders nonempty match lists in consecutive file groups, using rg's line markers. */
|
|
197
|
+
const matchList = (value: Schema.Json): string | undefined => {
|
|
198
|
+
if (!Array.isArray(value) || value.length === 0 || !value.every(isMatch)) return undefined
|
|
199
|
+
const lines: Array<string> = []
|
|
200
|
+
let previousFile: string | undefined
|
|
201
|
+
let previousLine = 0
|
|
202
|
+
for (const match of value) {
|
|
203
|
+
const before = match.before ?? []
|
|
204
|
+
const after = match.after ?? []
|
|
205
|
+
if (match.file !== previousFile) lines.push(match.file)
|
|
206
|
+
else if ((before[0]?.line ?? match.line) > previousLine + 1) lines.push("--")
|
|
207
|
+
for (const context of before) lines.push(`${context.line}-${context.text}`)
|
|
208
|
+
const symbol = match.symbol
|
|
209
|
+
const suffix = symbol === undefined ? "" : ` ‹${symbol.kind} ${symbol.name} ${symbol.startLine}-${symbol.endLine}›`
|
|
210
|
+
lines.push(`${match.line}:${match.text}${suffix}`)
|
|
211
|
+
for (const context of after) lines.push(`${context.line}-${context.text}`)
|
|
212
|
+
previousFile = match.file
|
|
213
|
+
previousLine = after.at(-1)?.line ?? match.line
|
|
214
|
+
}
|
|
215
|
+
return lines.join("\n")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Renders an array of records as a table, or nothing.
|
|
220
|
+
*
|
|
221
|
+
* Columns are the union of keys in first-seen order. An absent member is an
|
|
222
|
+
* empty cell; explicit null, empty arrays and empty objects stay `null`, `[]`
|
|
223
|
+
* and `{}`. Cells are the string itself where that is unambiguous — no newline,
|
|
224
|
+
* no column separator — and canonical JSON everywhere else. An empty string
|
|
225
|
+
* still looks absent, and a string spelling a JSON literal still looks like
|
|
226
|
+
* that value: this is a log rather than a wire format, so it is not paid for in
|
|
227
|
+
* quoting every cell.
|
|
228
|
+
*
|
|
229
|
+
* @since 0.1.0
|
|
230
|
+
* @private
|
|
231
|
+
* @slop
|
|
232
|
+
*/
|
|
233
|
+
export const table = (value: Schema.Json): string | undefined => {
|
|
234
|
+
if (!Array.isArray(value) || value.length < tableRows) return undefined
|
|
235
|
+
if (!value.every(isRecord<Schema.Json>)) return undefined
|
|
236
|
+
const columns = [...new Set(value.flatMap((element) => Object.keys(element)))]
|
|
237
|
+
if (columns.length < 2) return undefined
|
|
238
|
+
const rows = value.map((element) =>
|
|
239
|
+
columns.map((column) => Object.hasOwn(element, column) ? cell(element[column]!) : "").join(" | ")
|
|
240
|
+
)
|
|
241
|
+
return `${columns.join(" | ")}\n${rows.join("\n")}`
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Renders one printed JSON value compactly.
|
|
246
|
+
*
|
|
247
|
+
* A match list becomes numbered source lines; other records become a table.
|
|
248
|
+
* An object with exactly one such member becomes that object's other members
|
|
249
|
+
* as JSON, then the member's name, count and rendered list. An exact failed-call
|
|
250
|
+
* envelope becomes its code, message and optional hint. Everything else is
|
|
251
|
+
* canonical JSON as before.
|
|
252
|
+
*
|
|
253
|
+
* Tables save repeated keys but pay for every column boundary, including
|
|
254
|
+
* absent members. The three-row, two-column floor saves bytes for uniform
|
|
255
|
+
* records; it does not guarantee savings for sparse records. Rendering stays
|
|
256
|
+
* shape-based rather than comparing both encodings.
|
|
257
|
+
*
|
|
258
|
+
* @since 0.1.0
|
|
259
|
+
* @private
|
|
260
|
+
* @slop
|
|
261
|
+
*/
|
|
262
|
+
export const render = (value: Schema.Json): string => {
|
|
263
|
+
// A string is itself, which is what `Cell.renderText` promises everywhere
|
|
264
|
+
// else the harness renders a projected value. The prelude sends a primitive
|
|
265
|
+
// string down the `text` side, so this arm answers only for a boxed one.
|
|
266
|
+
if (typeof value === "string") return value
|
|
267
|
+
const flat = matchList(value) ?? table(value)
|
|
268
|
+
if (flat !== undefined) return flat
|
|
269
|
+
if (!isRecord<Schema.Json>(value)) return CanonicalJson.stringify(value)
|
|
270
|
+
const error = value.error
|
|
271
|
+
if (
|
|
272
|
+
Object.keys(value).length === 2 && value.ok === false &&
|
|
273
|
+
isRecord<Schema.Json>(error) &&
|
|
274
|
+
typeof error.code === "string" && typeof error.message === "string" &&
|
|
275
|
+
Object.keys(error).every((key) => key === "code" || key === "message" || key === "hint") &&
|
|
276
|
+
(!Object.hasOwn(error, "hint") || typeof error.hint === "string")
|
|
277
|
+
) {
|
|
278
|
+
return `failed (${error.code}): ${error.message}${Object.hasOwn(error, "hint") ? ` — hint: ${error.hint}` : ""}`
|
|
279
|
+
}
|
|
280
|
+
const tabled = Object.entries(value).flatMap(([key, member]) => {
|
|
281
|
+
const rendered = matchList(member) ?? table(member)
|
|
282
|
+
return rendered === undefined ? [] : [[key, member as ReadonlyArray<unknown>, rendered] as const]
|
|
283
|
+
})
|
|
284
|
+
if (tabled.length !== 1) return CanonicalJson.stringify(value)
|
|
285
|
+
const [key, member, rendered] = tabled[0]!
|
|
286
|
+
const rest = Object.fromEntries(Object.entries(value).filter(([name]) => name !== key))
|
|
287
|
+
return `${
|
|
288
|
+
Object.keys(rest).length === 0 ? "" : `${CanonicalJson.stringify(rest)}\n`
|
|
289
|
+
}${key} (${member.length}):\n${rendered}`
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Apportions one budget across statements of the given sizes.
|
|
294
|
+
*
|
|
295
|
+
* Short statements take what they need and hand the remainder back, so a frame
|
|
296
|
+
* that printed one long value and three short ones spends the budget on the long
|
|
297
|
+
* one. Allocation runs shortest first, which is what makes the hand-back
|
|
298
|
+
* possible, and the result is in the order the sizes were given.
|
|
299
|
+
*
|
|
300
|
+
* @since 0.1.0
|
|
301
|
+
* @private
|
|
302
|
+
* @slop
|
|
303
|
+
*/
|
|
304
|
+
export const shares = (sizes: ReadonlyArray<number>, budget: number): ReadonlyArray<number> => {
|
|
305
|
+
const order = sizes.map((size, index) => ({ size, index })).sort((left, right) =>
|
|
306
|
+
left.size === right.size ? left.index - right.index : left.size - right.size
|
|
307
|
+
)
|
|
308
|
+
const allotted = new Array<number>(sizes.length).fill(0)
|
|
309
|
+
let remaining = budget
|
|
310
|
+
let left = sizes.length
|
|
311
|
+
for (const { index, size } of order) {
|
|
312
|
+
const fair = Math.floor(remaining / left)
|
|
313
|
+
const given = Math.min(size, fair)
|
|
314
|
+
allotted[index] = given
|
|
315
|
+
remaining = remaining - given
|
|
316
|
+
left = left - 1
|
|
317
|
+
}
|
|
318
|
+
return allotted
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** The line a frame writes about the statements it dropped whole. */
|
|
322
|
+
const droppedNotice = (count: number): string =>
|
|
323
|
+
`… ${count} print statements elided from the middle of this frame; the values are still bound in the realm.`
|
|
324
|
+
|
|
325
|
+
/** The line a frame writes about the statements the host never copied out. */
|
|
326
|
+
const unreadNotice = (count: number): string =>
|
|
327
|
+
`… ${count} further print statements were not kept: this frame printed more than the harness holds.`
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* What keeping one statement costs the budget: its floor, its notice, its newline.
|
|
331
|
+
*
|
|
332
|
+
* A statement at or under {@link printStatementFloor} costs only itself
|
|
333
|
+
* and no notice, because {@link buffer} shows it whole and a whole statement has
|
|
334
|
+
* nothing to say about what it lost. One over the floor is promised the floor,
|
|
335
|
+
* and the notice that shortening it prints is charged with it.
|
|
336
|
+
*/
|
|
337
|
+
const price = (statement: Statement): number =>
|
|
338
|
+
Math.min(statement.bytes, printStatementFloor) +
|
|
339
|
+
(statement.bytes > printStatementFloor ? elide.noticeCost(statement.bytes, recall) : 0) + 1
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* How many of *these* statements a budget can keep at the floor, head first.
|
|
343
|
+
*
|
|
344
|
+
* A count of the statements in hand rather than a constant, because what a
|
|
345
|
+
* statement costs is what it is. Taken as `printFrameBytes / printStatementFloor`
|
|
346
|
+
* it was 32 whatever a frame printed, so a frame of two hundred eight-byte lines
|
|
347
|
+
* dropped a hundred and sixty-eight of them while fifteen of its sixteen
|
|
348
|
+
* kilobytes went unspent — the failure the shared budget exists to end,
|
|
349
|
+
* reintroduced one level up. Two hundred lines that cost nine bytes each cost
|
|
350
|
+
* eighteen hundred, and the budget keeps every one of them.
|
|
351
|
+
*
|
|
352
|
+
* The walk takes the head, then the tail, then the head again, which is the
|
|
353
|
+
* order {@link buffer} assembles them in, so a budget that affords an odd number
|
|
354
|
+
* spends the odd one on the earlier statement.
|
|
355
|
+
*
|
|
356
|
+
* @since 0.1.0
|
|
357
|
+
* @private
|
|
358
|
+
* @slop
|
|
359
|
+
*/
|
|
360
|
+
export const capacity = (statements: ReadonlyArray<Statement>, budget: number): number => {
|
|
361
|
+
let left = budget
|
|
362
|
+
let kept = 0
|
|
363
|
+
while (kept < statements.length) {
|
|
364
|
+
const statement = kept % 2 === 0 ? statements[kept / 2]! : statements[statements.length - 1 - (kept - 1) / 2]!
|
|
365
|
+
const cost = price(statement)
|
|
366
|
+
if (cost > left) break
|
|
367
|
+
left = left - cost
|
|
368
|
+
kept = kept + 1
|
|
369
|
+
}
|
|
370
|
+
return kept
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Assembles what a frame printed, bounded by {@link printFrameBytes}.
|
|
375
|
+
*
|
|
376
|
+
* `unread` is the count of statements the host stopped copying out of the realm
|
|
377
|
+
* because the frame had already handed over more than it holds. It is stated
|
|
378
|
+
* rather than dropped, because a buffer that simply stopped reads as a cell that
|
|
379
|
+
* simply stopped printing.
|
|
380
|
+
*
|
|
381
|
+
* The bound holds by construction rather than by a second pass over the result,
|
|
382
|
+
* because a second pass would cut a notice in half and that is the one thing a
|
|
383
|
+
* bound may not do. {@link capacity} charges every kept statement the floor it is
|
|
384
|
+
* promised, the notice it would print and its newline; what survives that walk is
|
|
385
|
+
* therefore affordable, and the apportionment below spends only what the walk
|
|
386
|
+
* left. A statement at or under the floor is shown whole and reserves no notice
|
|
387
|
+
* at all — reserving one apiece is what left a frame of short lines nothing to
|
|
388
|
+
* spend on the lines themselves.
|
|
389
|
+
*
|
|
390
|
+
* @since 0.1.0
|
|
391
|
+
* @private
|
|
392
|
+
* @slop
|
|
393
|
+
*/
|
|
394
|
+
export const buffer = (statements: ReadonlyArray<Statement>, unread: number): string => {
|
|
395
|
+
if (statements.length === 0 && unread === 0) return ""
|
|
396
|
+
// The count-lines come out of the budget before the statements are counted,
|
|
397
|
+
// and the drop line only where there is a drop — so it is priced by asking
|
|
398
|
+
// twice, rather than by charging every frame for a line most never print.
|
|
399
|
+
const overhead = unread === 0 ? 0 : bytes.size(unreadNotice(unread)) + 1
|
|
400
|
+
const roomy = capacity(statements, printFrameBytes - overhead)
|
|
401
|
+
const affordable = roomy === statements.length
|
|
402
|
+
? roomy
|
|
403
|
+
: capacity(statements, printFrameBytes - overhead - bytes.size(droppedNotice(statements.length)) - 1)
|
|
404
|
+
// More statements than the budget can floor: whole statements go from the
|
|
405
|
+
// middle, counted, rather than every one of them being cut to a notice.
|
|
406
|
+
const head = Math.ceil(affordable / 2)
|
|
407
|
+
const kept = statements.length === affordable
|
|
408
|
+
? statements
|
|
409
|
+
: [...statements.slice(0, head), ...statements.slice(statements.length - Math.floor(affordable / 2))]
|
|
410
|
+
const dropped = statements.length - kept.length
|
|
411
|
+
const notices = [
|
|
412
|
+
...(dropped === 0 ? [] : [droppedNotice(dropped)]),
|
|
413
|
+
...(unread === 0 ? [] : [unreadNotice(unread)])
|
|
414
|
+
]
|
|
415
|
+
// What the budget cannot spend on values: the count-lines, the newline between
|
|
416
|
+
// every pair, and one elision notice for each statement the floor does not
|
|
417
|
+
// cover whole.
|
|
418
|
+
const sizes = kept.map((statement) => statement.bytes)
|
|
419
|
+
const reserve = kept.reduce(
|
|
420
|
+
(sum, statement) => sum + (statement.bytes > printStatementFloor ? elide.noticeCost(statement.bytes, recall) : 0),
|
|
421
|
+
0
|
|
422
|
+
) +
|
|
423
|
+
notices.reduce((sum, line) => sum + bytes.size(line), 0) +
|
|
424
|
+
Math.max(0, kept.length + notices.length - 1)
|
|
425
|
+
const allotted = shares(sizes, Math.max(0, printFrameBytes - reserve))
|
|
426
|
+
const lines = kept.map((statement, index) =>
|
|
427
|
+
elide.middleFrom(statement.text, statement.bytes, allotted[index]!, recall)
|
|
428
|
+
)
|
|
429
|
+
return [
|
|
430
|
+
...lines.slice(0, dropped === 0 ? lines.length : head),
|
|
431
|
+
...(dropped === 0 ? [] : [notices[0]!, ...lines.slice(head)]),
|
|
432
|
+
...(unread === 0 ? [] : [notices[notices.length - 1]!])
|
|
433
|
+
].join("\n")
|
|
434
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one rendering of a frame's print buffer into the turn that reads it.
|
|
3
|
+
*
|
|
4
|
+
* The controller journals the RAW buffer as `AgentEvent.CellPrinted` and sends
|
|
5
|
+
* this rendering to the model, so a projection that replays the raw text
|
|
6
|
+
* rebuilds a window the run never had. Both callers go through here for that
|
|
7
|
+
* reason: `CellTurn` when it builds the next turn, and `Transcript` when it
|
|
8
|
+
* rebuilds one from the journal.
|
|
9
|
+
*
|
|
10
|
+
* An empty buffer is a message and not a silence. A cell that printed nothing
|
|
11
|
+
* still opened a turn, and the turn it opened says so — dropping it loses a
|
|
12
|
+
* user message the model actually read, and the model is told the realm still
|
|
13
|
+
* holds everything the cell bound, which is the recovery it needs.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { untrustedData } from "./untrustedData.ts"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Renders one frame's print buffer as the user turn its successor read.
|
|
23
|
+
*
|
|
24
|
+
* @category conversions
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
export const printsObservation = (prints: string): string =>
|
|
29
|
+
prints === ""
|
|
30
|
+
? "Your cell printed nothing, so this turn opens with nothing new to read. Everything it bound is still in the realm; print what you need to look at."
|
|
31
|
+
: untrustedData(`What your cell printed:\n${prints}`, "cell print buffer (may contain repository and tool output)")
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one constructor for a refusal a cell observes as a resolved envelope.
|
|
3
|
+
*
|
|
4
|
+
* A failed call **resolves** with a `failure` `Cell.CallResult`; it does not
|
|
5
|
+
* throw, and `Cell.callFailure` renders it as `{ ok: false, error }`. The shape
|
|
6
|
+
* is fixed — `value` is `null`, because a refusal has no value to hand back,
|
|
7
|
+
* except a timeout's, which records the limit it ran past (see {@link timedOut})
|
|
8
|
+
* — so every boundary that refuses a call builds it here rather than repeating
|
|
9
|
+
* the literal. The cell never sees `value` on a failure. An absent `code` is left absent rather than written as
|
|
10
|
+
* `undefined`: the encoded result is the durable wire contract used in sealed
|
|
11
|
+
* keys, and it means {@link Cell.defaultCallFailureCode}.
|
|
12
|
+
*
|
|
13
|
+
* @since 1.0.0-rc.0
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as Schema from "effect/Schema"
|
|
18
|
+
import { type CallFailureCode, CallResult } from "../Cell.ts"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A refusal the cell observes as a resolved `{ ok: false, error }` envelope.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0-rc.0
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
export const refusal = (code: CallFailureCode | undefined, message: string): CallResult =>
|
|
27
|
+
code === undefined
|
|
28
|
+
? new CallResult({ outcome: "failure", value: null, message })
|
|
29
|
+
: new CallResult({ outcome: "failure", value: null, code, message })
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A timeout refusal: the `timeout` code, with the limit the call ran past
|
|
33
|
+
* recorded as `{ limitMillis }` in `value`, so a host that guards timeouts
|
|
34
|
+
* parks the run on the exact limit whichever clock enforced it.
|
|
35
|
+
*
|
|
36
|
+
* @since 1.0.0-rc.1
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
export const timedOut = (message: string, limitMillis: number): CallResult =>
|
|
40
|
+
new CallResult({ outcome: "failure", value: { limitMillis }, code: "timeout", message })
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The limit a {@link timedOut} refusal recorded, when it recorded one.
|
|
44
|
+
*
|
|
45
|
+
* @since 1.0.0-rc.1
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
export const limitOf = (result: CallResult): number | undefined => {
|
|
49
|
+
const recorded = decodeLimit(result.value)
|
|
50
|
+
return recorded._tag === "Success" ? recorded.success.limitMillis : undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const decodeLimit = Schema.decodeUnknownResult(Schema.Struct({ limitMillis: Schema.Number }))
|