@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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Relevance.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * What a run is shown of the human-provided items it could be shown.\n *\n * Memory rows, catalog flows and skills, and chunks of instruction files such\n * as `AGENTS.md` are items. {@link judge} asks Jev one question about each:\n * is it unnecessary for the task as stated? An item is withheld only when Jev\n * says so with probability at or above {@link withholdAt}; everything else is\n * kept. An item longer than {@link itemBytes} is sent head-kept and always\n * kept: Jev cannot be confident about text it was not shown. A reading that\n * cannot be judged keeps everything, and the caller\n * journals `decision-unjudged` for it: keeping is the rule, withholding is\n * the exception Jev must be confident of.\n *\n * Nothing here journals or filters a live catalog. {@link settled} is the row\n * a caller writes for a reading, and {@link render} the instruction block a\n * caller builds from what was kept.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Digest from \"@smthrs/core/Digest\"\nimport * as Classifier from \"@smthrs/model/Classifier\"\nimport type * as Evaluator from \"@smthrs/model/Evaluator\"\nimport type * as Descriptor from \"@smthrs/registry/Descriptor\"\nimport * as Duration from \"effect/Duration\"\nimport * as Effect from \"effect/Effect\"\nimport * as Option from \"effect/Option\"\nimport * as Schema from \"effect/Schema\"\nimport * as AgentEvent from \"./AgentEvent.ts\"\nimport * as bytes from \"./internal/bytes.ts\"\nimport * as elide from \"./internal/elide.ts\"\nimport { untrustedData } from \"./internal/untrustedData.ts\"\nimport * as Judgement from \"./Judgement.ts\"\n\n/**\n * What an item is.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const Kind = AgentEvent.RelevanceKind\n\n/**\n * The decoded form of {@link Kind}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Kind = typeof Kind.Type\n\n/**\n * One human-provided item a run could be shown.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Item = Schema.Struct({ kind: Kind, id: Schema.String, text: Schema.String })\n\n/**\n * The decoded form of {@link Item}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Item = typeof Item.Type\n\n/**\n * What every reading is told beside its items.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Context = Schema.Struct({\n task: Schema.String,\n query: Schema.optionalKey(Schema.String),\n recent: Schema.optionalKey(Schema.String)\n})\n\n/**\n * The decoded form of {@link Context}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Context = typeof Context.Type\n\n/**\n * The probability of \"unnecessary\" at or above which an item is withheld.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const withholdAt = 0.9\n\n/**\n * The `Classifier.confident` floor that is {@link withholdAt} for a boolean:\n * its confidence is its distance from even odds, doubled.\n */\nconst confidentAt = (withholdAt - 0.5) * 2\n\n/**\n * The most of one item's text a reading carries, in UTF-8 bytes; the head\n * kept.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const itemBytes = 1024\n\n/** The most of a flow's description an item carries, in UTF-8 bytes. */\nconst descriptionBytes = 512\n\nconst recall = \"the rest is not shown\"\n\n/** `text` within `limit` bytes, its head kept and the cut stated. */\nconst headKept = (text: string, limit: number): string => {\n const whole = bytes.size(text)\n if (whole <= limit) return text\n // The notice names at most `whole` dropped bytes.\n return elide.head(text, limit - bytes.size(`\u2026 [+${whole}b, ${recall}]`), recall)\n}\n\n/**\n * The reading: one question per item, `unnecessary_${index}`.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const reader = Judgement.perItem({\n id: \"relevance/unnecessary\",\n description: \"Decide which provided items an agent run does not need\",\n context: Context,\n item: Item,\n questions: {\n unnecessary: (i) =>\n Classifier.boolean({\n instructions:\n `Is items[${i}] unnecessary for the task as stated? Read context.task, and context.query or context.recent when present.`,\n criteria: {\n true: \"nothing the task, context.query, or a step they plainly imply uses it, needs it, or must follow it\",\n false: \"the task, context.query, or a step they plainly imply may use it, need it, or must follow it\"\n }\n })\n }\n})\n\n/**\n * Jev's verdict on one item. `p` is the probability it is unnecessary.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Verdict {\n readonly item: Item\n /** `Digest.digest` of the item's whole text. */\n readonly digest: string\n readonly p: number\n readonly withheld: boolean\n}\n\n/**\n * One reading: a verdict per item in input order, and the record of asking.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Reading {\n readonly verdicts: ReadonlyArray<Verdict>\n readonly asked: ReadonlyArray<Judgement.Asked>\n /** Wall-clock milliseconds the reading took. */\n readonly latencyMs: number\n /** Token usage summed over every request, absent when none reported any. */\n readonly usage?: Evaluator.Usage | undefined\n}\n\n/**\n * Asks Jev which of `items` the run does not need. Each item's text is sent\n * head-kept to {@link itemBytes}, and an item that was cut is never withheld.\n * No items ask nothing.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const judge = (context: Context, items: ReadonlyArray<Item>): Effect.Effect<Reading, Judgement.Unjudged> =>\n Effect.gen(function*() {\n const sent = items.map((item) => ({ ...item, text: headKept(item.text, itemBytes) }))\n const [elapsed, read] = yield* reader.read(context, sent).pipe(Effect.timed)\n const verdicts = items.map((item, index): Verdict => {\n const answer = read.answers[index]!.unnecessary\n return {\n item,\n digest: Digest.digest(item.text),\n p: answer.probability,\n withheld: bytes.size(item.text) <= itemBytes &&\n Option.getOrElse(Classifier.confident(answer, confidentAt), () => false)\n }\n })\n const usages = read.asked.flatMap((asked) => asked.usage === undefined ? [] : [asked.usage])\n return {\n verdicts,\n asked: read.asked,\n latencyMs: Math.round(Duration.toMillis(elapsed)),\n ...(usages.length === 0 ? {} : {\n usage: {\n inputTokens: usages.reduce((sum, usage) => sum + usage.inputTokens, 0),\n outputTokens: usages.reduce((sum, usage) => sum + usage.outputTokens, 0)\n }\n })\n }\n })\n\n/**\n * The `relevance-settled` row for a reading: ids and digests, never text.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const settled = (\n reading: Reading,\n at: { readonly scope: string; readonly frame: number; readonly source: AgentEvent.RelevanceSettled[\"source\"] }\n): AgentEvent.RelevanceSettled => {\n const row = (verdict: Verdict) => ({\n kind: verdict.item.kind,\n id: verdict.item.id,\n digest: verdict.digest,\n p: verdict.p\n })\n return new AgentEvent.RelevanceSettled({\n eventType: AgentEvent.eventType.relevanceSettled,\n scope: at.scope,\n frame: at.frame,\n source: at.source,\n withholdAt,\n kept: reading.verdicts.filter((verdict) => !verdict.withheld).map(row),\n withheld: reading.verdicts.filter((verdict) => verdict.withheld).map(row),\n latencyMs: reading.latencyMs,\n ...(reading.usage === undefined ? {} : { usage: reading.usage })\n })\n}\n\n/**\n * A catalog entry as an item: a `skill` when its body is markdown, else a\n * `flow`. Its description is untrusted data.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const flowItem = (descriptor: Descriptor.FlowDescriptor): Item => {\n const description = untrustedData(\n headKept(descriptor.description, descriptionBytes),\n `description of ${descriptor.name}`\n )\n const capabilities = descriptor.capabilities.length === 0\n ? \"\"\n : `\\ncapabilities: ${[...descriptor.capabilities].sort().join(\",\")}`\n return {\n kind: descriptor.body._tag === \"Markdown\" ? \"skill\" : \"flow\",\n id: descriptor.name,\n text: `${descriptor.name}\\n${description}${capabilities}`\n }\n}\n\n/**\n * One human-provided instruction file.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Document = Schema.Struct({ path: Schema.String, text: Schema.String })\n\n/**\n * The decoded form of {@link Document}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Document = typeof Document.Type\n\n/**\n * One piece of an instruction file, as {@link chunks} splits it.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Chunk {\n /** `${path}#${n}`, `n` counting from 0 within the file. */\n readonly id: string\n readonly path: string\n readonly text: string\n}\n\nconst heading = /^#{1,6}(?:[ \\t]|$)/\nconst listItem = /^(?:[-*+] |\\d+\\. )/\nconst fence = /^[ \\t]*```/\nconst blank = /^[ \\t]*\\r?$/\nconst indented = /^[ \\t]/\n\nconst split = (document: Document): ReadonlyArray<Chunk> => {\n const pieces: Array<string> = []\n let fenced = false\n // A list item's chunk runs over its indented and wrapped lines, and ends at\n // the first unindented line after a blank one.\n let item = false\n let afterBlank = false\n for (const line of document.text.match(/[^\\n]*\\n|[^\\n]+$/g) ?? []) {\n const bare = line.endsWith(\"\\n\") ? line.slice(0, -1) : line\n const starts = !fenced && pieces.length > 0 && (heading.test(bare) || listItem.test(bare) ||\n (item && afterBlank && !blank.test(bare) && !indented.test(bare)))\n if (!fenced && (heading.test(bare) || listItem.test(bare))) item = listItem.test(bare)\n else if (starts) item = false\n if (starts || pieces.length === 0) pieces.push(line)\n else pieces[pieces.length - 1] += line\n if (fence.test(bare)) fenced = !fenced\n afterBlank = !fenced && blank.test(bare)\n }\n return pieces.map((text, n) => ({ id: `${document.path}#${n}`, path: document.path, text }))\n}\n\n/**\n * Splits instruction files into the chunks a reading judges, in order.\n *\n * A chunk starts at each markdown heading and at each top-level list item,\n * whose indented and wrapped lines are its own. Every other line, blank lines\n * included, joins the chunk before it, and nothing inside a fence is split.\n * A file's chunks concatenate back to the file.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const chunks = (documents: ReadonlyArray<Document>): ReadonlyArray<Chunk> => documents.flatMap(split)\n\n/**\n * The project-instructions block of every chunk not in `withheld`, in order.\n * A file whose every chunk is withheld is left out, and `\"\"` is returned when\n * nothing is left.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const render = (documents: ReadonlyArray<Document>, withheld: ReadonlySet<string>): string => {\n const blocks = documents.flatMap((document) => {\n const all = split(document)\n const kept = all.filter((chunk) => !withheld.has(chunk.id))\n if (all.length > 0 && kept.length === 0) return []\n return [\n `<project_instructions path=\"${document.path}\">\\n${\n kept.map((chunk) => chunk.text).join(\"\")\n }\\n</project_instructions>`\n ]\n })\n return blocks.length === 0 ? \"\" : \"Project-specific instructions and guidelines:\\n\\n\" + blocks.join(\"\\n\\n\")\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The deterministic script sandbox port.
|
|
3
|
+
*
|
|
4
|
+
* A cell is arbitrary agent-authored JavaScript, so it never runs in the host
|
|
5
|
+
* realm. It runs behind this port, which grants exactly one effectful
|
|
6
|
+
* primitive — flow invocation against the capability-narrowed catalog the run
|
|
7
|
+
* was given — and returns a serializable {@link Cell.Outcome}.
|
|
8
|
+
*
|
|
9
|
+
* The port opens a {@link Realm}, and a realm is the whole surface: it is
|
|
10
|
+
* acquired once per run and every cell of that run is evaluated in it, so a
|
|
11
|
+
* name one cell binds is still bound in the next. There is no per-cell
|
|
12
|
+
* evaluation beside it. One binding ships — `QuickJSSandbox`, the QuickJS-WASM
|
|
13
|
+
* binding that isolates a real separate realm in both Node and browsers — and a
|
|
14
|
+
* composition that offers none is refused with {@link realmUnsupported}.
|
|
15
|
+
*
|
|
16
|
+
* Cancellation is fiber interruption and teardown is scope finalization; a
|
|
17
|
+
* sandbox never installs a host abort signal.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
import { Context, Effect, Layer, Schema, type Scope } from "effect";
|
|
22
|
+
import * as Cell from "./Cell.ts";
|
|
23
|
+
import type { HarnessError } from "./HarnessError.ts";
|
|
24
|
+
import type * as VariablesPanel from "./VariablesPanel.ts";
|
|
25
|
+
/**
|
|
26
|
+
* Stable failures raised by a sandbox binding itself, as opposed to failures
|
|
27
|
+
* of the cell it was asked to run.
|
|
28
|
+
*
|
|
29
|
+
* A cell that throws is a {@link Cell.Raised} outcome, not a sandbox error.
|
|
30
|
+
* These codes describe the sandbox being unable to do its job at all.
|
|
31
|
+
*
|
|
32
|
+
* @category models
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
* @slop
|
|
35
|
+
*/
|
|
36
|
+
export declare const SandboxErrorCode: Schema.Literals<readonly ["unavailable", "unsupported", "runtime_failed"]>;
|
|
37
|
+
/**
|
|
38
|
+
* Stable failures raised by a sandbox binding itself.
|
|
39
|
+
*
|
|
40
|
+
* @category models
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
* @slop
|
|
43
|
+
*/
|
|
44
|
+
export type SandboxErrorCode = typeof SandboxErrorCode.Type;
|
|
45
|
+
declare const SandboxError_base: Schema.Class<SandboxError, Schema.TaggedStruct<"flows/harness/SandboxError", {
|
|
46
|
+
readonly code: Schema.Literals<readonly ["unavailable", "unsupported", "runtime_failed"]>;
|
|
47
|
+
readonly message: Schema.String;
|
|
48
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
49
|
+
}>, import("effect/Cause").YieldableError>;
|
|
50
|
+
/**
|
|
51
|
+
* A failure of the sandbox binding.
|
|
52
|
+
*
|
|
53
|
+
* @category errors
|
|
54
|
+
* @since 0.1.0
|
|
55
|
+
* @slop
|
|
56
|
+
*/
|
|
57
|
+
export declare class SandboxError extends SandboxError_base {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One flow invocation requested from inside a running cell.
|
|
61
|
+
*
|
|
62
|
+
* `ordinal` is the zero-based execution order of the call within the cell. It
|
|
63
|
+
* is the replay anchor: re-executing the same source reaches the same ordinal
|
|
64
|
+
* with the same declaration, which is what lets a settled boundary replay
|
|
65
|
+
* instead of re-running.
|
|
66
|
+
*
|
|
67
|
+
* @category models
|
|
68
|
+
* @since 0.1.0
|
|
69
|
+
* @slop
|
|
70
|
+
*/
|
|
71
|
+
export interface Invocation {
|
|
72
|
+
readonly ordinal: number;
|
|
73
|
+
readonly flow: string;
|
|
74
|
+
readonly input: Schema.Json;
|
|
75
|
+
/**
|
|
76
|
+
* Whatever the cell passed as the call's `at` option, undecoded.
|
|
77
|
+
*
|
|
78
|
+
* It arrives as the raw JSON the cell wrote rather than as an id because the
|
|
79
|
+
* boundary, not the realm, decides whether it is a checkpoint: a cell that
|
|
80
|
+
* passes a string, a failure envelope, or last frame's result gets an
|
|
81
|
+
* resolved `invalid_input` failure naming what `at` takes. Throwing from inside
|
|
82
|
+
* the sandbox would lose the calls the cell had already paid for.
|
|
83
|
+
*/
|
|
84
|
+
readonly at?: Schema.Json | undefined;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* One request to pin the workspace, issued from inside a running cell.
|
|
88
|
+
*
|
|
89
|
+
* It carries only its ordinal because that is the whole of its identity: the
|
|
90
|
+
* cell source and the frame are the boundary's, and the ordinal is what makes
|
|
91
|
+
* the pin land where the cell wrote it. See {@link Minter}.
|
|
92
|
+
*
|
|
93
|
+
* @category models
|
|
94
|
+
* @since 0.1.0
|
|
95
|
+
*/
|
|
96
|
+
export interface Mint {
|
|
97
|
+
readonly ordinal: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Pins the workspace on behalf of a running cell.
|
|
101
|
+
*
|
|
102
|
+
* A mint travels the same queue as a flow call and is settled by the same drive
|
|
103
|
+
* loop, in issue order, one at a time. That ordering is the whole contract:
|
|
104
|
+
* `ctx.checkpoint()` promises the tree as it stands *at the line it is written
|
|
105
|
+
* on*, and the only way a cell can move the tree is by issuing a call, so a
|
|
106
|
+
* queue that settles in issue order pins exactly the tree the cell was looking
|
|
107
|
+
* at. A mint that runs on its own schedule — a side channel, a host callback,
|
|
108
|
+
* anything the queue does not order — would pin whichever tree happened to be
|
|
109
|
+
* there when it got round to it.
|
|
110
|
+
*
|
|
111
|
+
* The result is a {@link Cell.CallResult} like any other, so a host with no
|
|
112
|
+
* store, a run past its checkpoint bound, and a store that failed are all
|
|
113
|
+
* resolved `{ ok: false, error }` refusals rather than teardown.
|
|
114
|
+
*
|
|
115
|
+
* @category models
|
|
116
|
+
* @since 0.1.0
|
|
117
|
+
*/
|
|
118
|
+
export type Minter = (mint: Mint) => Effect.Effect<Cell.CallResult, HarnessError>;
|
|
119
|
+
/**
|
|
120
|
+
* The refusal a binding answers `ctx.checkpoint()` with when the caller wired
|
|
121
|
+
* no minter.
|
|
122
|
+
*
|
|
123
|
+
* @category constructors
|
|
124
|
+
* @since 0.1.0
|
|
125
|
+
*/
|
|
126
|
+
export declare const mintUnavailable: Minter;
|
|
127
|
+
/**
|
|
128
|
+
* Resolves one invocation on behalf of a running cell.
|
|
129
|
+
*
|
|
130
|
+
* A {@link Cell.CallResult} of `failure` resolves in the cell as
|
|
131
|
+
* `{ ok: false, error }`, where `error` contains `code`, `message`, and `hint`;
|
|
132
|
+
* it does not throw. Success resolves with the flow's own value, unwrapped.
|
|
133
|
+
* Branch on `.ok === false` and `.error.code` to recover. For a flow whose
|
|
134
|
+
* successful result has a `stdout` field, a cell can retry a timed-out call:
|
|
135
|
+
*
|
|
136
|
+
* ```ts
|
|
137
|
+
* let result = await ctx.call("bash", { command: "find . -name '*.ts'" })
|
|
138
|
+
* if (result.ok === false && result.error.code === "timeout") {
|
|
139
|
+
* result = await ctx.call("bash", { command: "find src -name '*.ts'" })
|
|
140
|
+
* }
|
|
141
|
+
* console.log(result.ok === false ? result.error.code : result.stdout)
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* Anything the cell must not observe, such as a permission park, an abort,
|
|
145
|
+
* or an engine failure, travels in the effect's error channel and tears the
|
|
146
|
+
* cell down.
|
|
147
|
+
*
|
|
148
|
+
* @category models
|
|
149
|
+
* @since 0.1.0
|
|
150
|
+
* @slop
|
|
151
|
+
*/
|
|
152
|
+
export type Handler = (invocation: Invocation) => Effect.Effect<Cell.CallResult, HarnessError>;
|
|
153
|
+
/**
|
|
154
|
+
* Realm memory ceiling and default execution limits for its evaluations.
|
|
155
|
+
*
|
|
156
|
+
* Bindings fill every ceiling they can enforce from {@link defaultLimits} when
|
|
157
|
+
* the caller omits it. A binding that cannot honour an explicitly requested
|
|
158
|
+
* limit fails with `unsupported` rather than silently ignoring it.
|
|
159
|
+
*
|
|
160
|
+
* @category models
|
|
161
|
+
* @since 0.1.0
|
|
162
|
+
* @slop
|
|
163
|
+
*/
|
|
164
|
+
export interface Limits {
|
|
165
|
+
/**
|
|
166
|
+
* Maximum number of flow calls one cell may make; a non-negative safe integer.
|
|
167
|
+
* A checkpoint mint settles on the same channel and counts against this budget.
|
|
168
|
+
*/
|
|
169
|
+
readonly calls?: number | undefined;
|
|
170
|
+
/** Maximum sandbox heap, in bytes; at least {@link minimumMemoryBytes}. */
|
|
171
|
+
readonly memoryBytes?: number | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* Maximum interpreter steps before the cell is stopped.
|
|
174
|
+
*
|
|
175
|
+
* A step is one interrupt check, not one bytecode operation: an interpreter
|
|
176
|
+
* polls its budget periodically, so this bounds work rather than counting
|
|
177
|
+
* individual operations. The limit is a safe integer of at least
|
|
178
|
+
* {@link minimumSteps}.
|
|
179
|
+
*/
|
|
180
|
+
readonly steps?: number | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Maximum cell-compute time in milliseconds; a safe integer of at least
|
|
183
|
+
* {@link minimumTimeMs}.
|
|
184
|
+
*
|
|
185
|
+
* This bounds the cell's own JavaScript execution. Time spent suspended in
|
|
186
|
+
* an outstanding `ctx.call` or `ctx.checkpoint()` does not count: host work
|
|
187
|
+
* belongs to the boundary that runs it, and charging it here rejected every cell that
|
|
188
|
+
* awaited a real test run — 57 of the 62 rejected frames in the first
|
|
189
|
+
* SWE-bench benchmark were legitimate long `bash` calls hitting this clock.
|
|
190
|
+
*/
|
|
191
|
+
readonly timeMs?: number | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* Maximum whole-evaluation time in milliseconds, host calls included; a
|
|
194
|
+
* non-negative safe integer.
|
|
195
|
+
*
|
|
196
|
+
* The backstop for a host call that never settles. Generous on purpose: a
|
|
197
|
+
* cell awaiting a ten-minute test suite is working, not stuck.
|
|
198
|
+
*/
|
|
199
|
+
readonly totalMs?: number | undefined;
|
|
200
|
+
/** Flow names whose pending call time does not spend the frame backstop. */
|
|
201
|
+
readonly pauseTotalMsFor?: ReadonlyArray<string> | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Maximum wall-clock time one flow call may take, in milliseconds; a
|
|
204
|
+
* non-negative safe integer.
|
|
205
|
+
*
|
|
206
|
+
* The per-call budget {@link totalMs} cannot supply. `totalMs` is the frame's
|
|
207
|
+
* last resort, and a call that overruns it takes the whole frame down with a
|
|
208
|
+
* `limit_exceeded` rejection the model never sees as an answer: on the
|
|
209
|
+
* SWE-bench django instance one broad `grep` held its cell for the entire
|
|
210
|
+
* 900,000 ms ceiling, 75% of a 1,204-second run. This ceiling settles that
|
|
211
|
+
* same call as an ordinary resolved failure instead, so the cell observes a
|
|
212
|
+
* timeout it can narrow and retry inside the frame it is already in.
|
|
213
|
+
*/
|
|
214
|
+
readonly callMs?: number | undefined;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Per-frame overrides of a realm's opening limits. Omitted or undefined fields
|
|
218
|
+
* inherit the realm defaults. The memory ceiling remains fixed for the run.
|
|
219
|
+
*
|
|
220
|
+
* @category models
|
|
221
|
+
* @since 0.1.0
|
|
222
|
+
*/
|
|
223
|
+
export type EvaluationLimits = Omit<Limits, "memoryBytes">;
|
|
224
|
+
/**
|
|
225
|
+
* Which limits a binding can actually enforce.
|
|
226
|
+
*
|
|
227
|
+
* @category models
|
|
228
|
+
* @since 0.1.0
|
|
229
|
+
* @slop
|
|
230
|
+
*/
|
|
231
|
+
export interface Capabilities {
|
|
232
|
+
readonly calls: boolean;
|
|
233
|
+
readonly memoryBytes: boolean;
|
|
234
|
+
readonly steps: boolean;
|
|
235
|
+
readonly timeMs: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The execution ceilings a cell runs under when the caller declares none.
|
|
239
|
+
*
|
|
240
|
+
* Agent-authored source must never acquire an unbounded frame merely because a
|
|
241
|
+
* host omitted configuration. These values are deliberately generous for a
|
|
242
|
+
* cell, whose work is choosing flow calls and shaping JSON between them. There
|
|
243
|
+
* is no spelling for "no ceiling": a host that needs more raises the relevant
|
|
244
|
+
* finite value explicitly.
|
|
245
|
+
*
|
|
246
|
+
* @category constants
|
|
247
|
+
* @since 0.1.0
|
|
248
|
+
* @slop
|
|
249
|
+
*/
|
|
250
|
+
export declare const defaultLimits: Readonly<{
|
|
251
|
+
calls: 64;
|
|
252
|
+
memoryBytes: number;
|
|
253
|
+
steps: 1000;
|
|
254
|
+
timeMs: 30000;
|
|
255
|
+
totalMs: 900000;
|
|
256
|
+
callMs: 120000;
|
|
257
|
+
}>;
|
|
258
|
+
/**
|
|
259
|
+
* Smallest interpreter-step budget a binding can enter a realm under.
|
|
260
|
+
*
|
|
261
|
+
* A zero budget interrupts the binding's own scaffolding before any cell source
|
|
262
|
+
* runs, which escapes as a crash rather than a ceiling report, so the sandbox
|
|
263
|
+
* boundary refuses it as `unsupported`.
|
|
264
|
+
*
|
|
265
|
+
* @category constants
|
|
266
|
+
* @since 1.0.0-rc.0
|
|
267
|
+
*/
|
|
268
|
+
export declare const minimumSteps = 1;
|
|
269
|
+
/**
|
|
270
|
+
* Smallest wall-clock budget, in milliseconds, a binding can enter a realm under.
|
|
271
|
+
*
|
|
272
|
+
* A zero budget interrupts the binding's own scaffolding before any cell source
|
|
273
|
+
* runs, which escapes as a crash rather than a ceiling report, so the sandbox
|
|
274
|
+
* boundary refuses it as `unsupported`.
|
|
275
|
+
*
|
|
276
|
+
* @category constants
|
|
277
|
+
* @since 1.0.0-rc.0
|
|
278
|
+
*/
|
|
279
|
+
export declare const minimumTimeMs = 1;
|
|
280
|
+
/**
|
|
281
|
+
* Smallest heap ceiling the QuickJS binding can initialize and tear down
|
|
282
|
+
* safely.
|
|
283
|
+
*
|
|
284
|
+
* QuickJS needs space for its runtime and context before cell source runs.
|
|
285
|
+
* Lower ceilings can leave a partially initialized context that aborts during
|
|
286
|
+
* disposal, so they are refused at the sandbox boundary.
|
|
287
|
+
*
|
|
288
|
+
* @category constants
|
|
289
|
+
* @since 0.1.0
|
|
290
|
+
* @slop
|
|
291
|
+
*/
|
|
292
|
+
export declare const minimumMemoryBytes: number;
|
|
293
|
+
export { printFrameBytes, printRetainedBytes, printStatementFloor } from "./internal/printChannel.ts";
|
|
294
|
+
/**
|
|
295
|
+
* Fills omitted ceilings from {@link defaultLimits} for limits a binding can
|
|
296
|
+
* enforce.
|
|
297
|
+
*
|
|
298
|
+
* Capability gating applies only to defaults. An explicit unsupported limit is
|
|
299
|
+
* passed through so the binding can refuse it instead of silently widening the
|
|
300
|
+
* caller's authority.
|
|
301
|
+
*
|
|
302
|
+
* @category constructors
|
|
303
|
+
* @since 0.1.0
|
|
304
|
+
* @slop
|
|
305
|
+
*/
|
|
306
|
+
export declare const withDefaults: (capabilities: Capabilities, limits: Limits | undefined) => Limits;
|
|
307
|
+
/**
|
|
308
|
+
* Merges and validates one frame's limits without changing the realm defaults.
|
|
309
|
+
* Only per-frame ceilings can be overridden; memory belongs to the realm.
|
|
310
|
+
*
|
|
311
|
+
* @category constructors
|
|
312
|
+
* @since 0.1.0
|
|
313
|
+
*/
|
|
314
|
+
export declare const evaluationLimits: (defaults: Limits, overrides: EvaluationLimits | undefined) => Effect.Effect<EvaluationLimits, SandboxError>;
|
|
315
|
+
/**
|
|
316
|
+
* What a REPL cell asked the controller to do.
|
|
317
|
+
*
|
|
318
|
+
* A cell runs as a global async script in a persistent realm. Top-level
|
|
319
|
+
* `await` is supported; top-level `return` is invalid. The first `ctx.done`
|
|
320
|
+
* or `ctx.park` that records an intent seals the frame. Later `ctx.done` and
|
|
321
|
+
* `ctx.park` calls do nothing. Ordinary JavaScript continues running, but later
|
|
322
|
+
* `ctx.call` and `ctx.checkpoint` calls resolve with a `run_completed` failure
|
|
323
|
+
* envelope without dispatching host work.
|
|
324
|
+
*
|
|
325
|
+
* @category models
|
|
326
|
+
* @since 0.1.0
|
|
327
|
+
*/
|
|
328
|
+
export type Intent = {
|
|
329
|
+
readonly _tag: "Done";
|
|
330
|
+
readonly output: string;
|
|
331
|
+
readonly value?: Schema.Json | undefined;
|
|
332
|
+
} | {
|
|
333
|
+
readonly _tag: "Park";
|
|
334
|
+
readonly reason: "waiting-input" | "waiting-event" | "waiting-quota";
|
|
335
|
+
readonly message: string;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Builds the durable transition one cell settled.
|
|
339
|
+
*
|
|
340
|
+
* A cell states its intent by calling, so this is the only place a
|
|
341
|
+
* {@link Cell.Transition} is constructed. The realm is the run's memory and the
|
|
342
|
+
* print buffer is what the next turn reads, so nothing is filed on the way out:
|
|
343
|
+
* the transition carries only the current intent.
|
|
344
|
+
*
|
|
345
|
+
* @category constructors
|
|
346
|
+
* @since 0.1.0
|
|
347
|
+
*/
|
|
348
|
+
export declare const replTransition: (intent: Intent | undefined, justification: string | undefined) => Cell.Transition;
|
|
349
|
+
/**
|
|
350
|
+
* One cell evaluated inside a realm that outlives it.
|
|
351
|
+
*
|
|
352
|
+
* `frame` names the evaluation for the realm's own stack traces, so a throw
|
|
353
|
+
* reported in frame 7 says which cell threw.
|
|
354
|
+
*
|
|
355
|
+
* @category models
|
|
356
|
+
* @since 0.1.0
|
|
357
|
+
*/
|
|
358
|
+
export interface RealmEvaluation {
|
|
359
|
+
/** Reconstruct a timed-out frame only through its recorded bridge prefix. */
|
|
360
|
+
readonly replay?: {
|
|
361
|
+
readonly boundary: typeof FrameBoundary.Type;
|
|
362
|
+
readonly outcome: Cell.Outcome;
|
|
363
|
+
} | undefined;
|
|
364
|
+
/** Replaces ctx.flows with this frame's frozen catalog; omitted keeps the current catalog. */
|
|
365
|
+
readonly flows?: Readonly<Record<string, Cell.FlowProjection>> | undefined;
|
|
366
|
+
readonly cell: Cell.Source;
|
|
367
|
+
/**
|
|
368
|
+
* The program the controller's boundary parse already compiled from `cell`.
|
|
369
|
+
*
|
|
370
|
+
* A binding evaluates this verbatim when it is present, because the parse it
|
|
371
|
+
* would do is the parse the boundary already did: a controller runs
|
|
372
|
+
* {@link compile} before it commits a frame, so a binding that parses the
|
|
373
|
+
* cell again parses every cell of the run twice. Omitted means the binding
|
|
374
|
+
* compiles the cell itself, which is what a host driving a realm directly
|
|
375
|
+
* does.
|
|
376
|
+
*/
|
|
377
|
+
readonly program?: string | undefined;
|
|
378
|
+
readonly frame: number;
|
|
379
|
+
readonly call: Handler;
|
|
380
|
+
/**
|
|
381
|
+
* Settles a `ctx.checkpoint()` issued by this cell.
|
|
382
|
+
*
|
|
383
|
+
* Optional, and absent means the caller pins no trees — which the cell is
|
|
384
|
+
* told through a resolved failure envelope at the line it asked. It is a
|
|
385
|
+
* separate collaborator from `call` because a checkpoint is not a flow:
|
|
386
|
+
* it is neither in the catalog nor
|
|
387
|
+
* subject to the capability envelope, and the run's own bound on how many
|
|
388
|
+
* trees it may pin is the controller's, not any flow's.
|
|
389
|
+
*/
|
|
390
|
+
readonly mint?: Minter | undefined;
|
|
391
|
+
/**
|
|
392
|
+
* Whether the caller bounds each settlement itself.
|
|
393
|
+
*
|
|
394
|
+
* The loop's own {@link Limits.callMs} ceiling is a clock race it synthesizes
|
|
395
|
+
* a failure from, and that failure is journaled nowhere: the call it
|
|
396
|
+
* interrupted never settled, so nothing downstream holds a result for it. A
|
|
397
|
+
* re-executed cell runs the same call again against a world that has moved
|
|
398
|
+
* on, gets an answer this time, and takes a branch the original attempt never
|
|
399
|
+
* took — with every irreversible effect below the fork bought twice.
|
|
400
|
+
*
|
|
401
|
+
* A caller that journals its settlements applies the same ceiling itself, in
|
|
402
|
+
* front of the boundary that records what the ceiling produced, and sets this
|
|
403
|
+
* so the loop adds none of its own — because two clocks racing one call means
|
|
404
|
+
* the unrecorded one wins: the loop's starts first.
|
|
405
|
+
*/
|
|
406
|
+
readonly bounded?: boolean | undefined;
|
|
407
|
+
/** Validated overrides for this frame only; memory is fixed when the realm opens. */
|
|
408
|
+
readonly limits?: EvaluationLimits | undefined;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* The bridge frontier at a frame limit. Ordinals are zero-based;
|
|
412
|
+
* minus one means no dispatch or settlement occurred. A dispatched call may
|
|
413
|
+
* have been interrupted before its settlement was delivered to JavaScript.
|
|
414
|
+
* `timeout` requires truncating replay; `settled` identifies a limit the
|
|
415
|
+
* interpreter completed itself, such as its step or call budget.
|
|
416
|
+
*
|
|
417
|
+
* @category schemas
|
|
418
|
+
* @since 0.1.0
|
|
419
|
+
*/
|
|
420
|
+
export declare const FrameBoundary: Schema.Struct<{
|
|
421
|
+
readonly terminal: Schema.Literals<readonly ["timeout", "settled"]>;
|
|
422
|
+
readonly dispatched: Schema.Int;
|
|
423
|
+
readonly settled: Schema.Int;
|
|
424
|
+
}>;
|
|
425
|
+
/**
|
|
426
|
+
* Everything one REPL frame produced.
|
|
427
|
+
*
|
|
428
|
+
* @category models
|
|
429
|
+
* @since 0.1.0
|
|
430
|
+
*/
|
|
431
|
+
export interface RealmFrame {
|
|
432
|
+
/** Present when evaluation ended at a frame limit. */
|
|
433
|
+
readonly boundary?: typeof FrameBoundary.Type | undefined;
|
|
434
|
+
readonly outcome: Cell.Outcome;
|
|
435
|
+
/** What the cell printed, already bounded; empty when it printed nothing. */
|
|
436
|
+
readonly prints: string;
|
|
437
|
+
/** Every name the realm holds after the cell ran. */
|
|
438
|
+
readonly bindings: ReadonlyArray<VariablesPanel.Binding>;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* A JavaScript realm that persists across the cells of one run.
|
|
442
|
+
*
|
|
443
|
+
* Teardown is scope closure, so a realm is acquired by the loop that uses it and
|
|
444
|
+
* cancellation is still fiber interruption.
|
|
445
|
+
*
|
|
446
|
+
* @category services
|
|
447
|
+
* @since 0.1.0
|
|
448
|
+
*/
|
|
449
|
+
export interface Realm {
|
|
450
|
+
readonly evaluate: (evaluation: RealmEvaluation) => Effect.Effect<RealmFrame, SandboxError | HarnessError>;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* The initial catalog and limits a realm is opened with.
|
|
454
|
+
*
|
|
455
|
+
* @category models
|
|
456
|
+
* @since 0.1.0
|
|
457
|
+
*/
|
|
458
|
+
export interface RealmOptions {
|
|
459
|
+
readonly flows: Readonly<Record<string, Cell.FlowProjection>>;
|
|
460
|
+
/**
|
|
461
|
+
* The ceilings the realm enforces. `memoryBytes` becomes a **run** budget once
|
|
462
|
+
* a realm outlives a cell, judged at each frame's start against what the
|
|
463
|
+
* realm's own names weigh; a frame that opens over it runs nothing and is told
|
|
464
|
+
* which names to free. Every other ceiling stays per-frame, because they are
|
|
465
|
+
* counters the interrupt handler reads rather than properties of the runtime.
|
|
466
|
+
*/
|
|
467
|
+
readonly limits?: Limits | undefined;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* The deterministic script sandbox.
|
|
471
|
+
*
|
|
472
|
+
* @category services
|
|
473
|
+
* @since 0.1.0
|
|
474
|
+
* @slop
|
|
475
|
+
*/
|
|
476
|
+
export interface Sandbox {
|
|
477
|
+
readonly capabilities: Capabilities;
|
|
478
|
+
/**
|
|
479
|
+
* Opens the realm the run's cells share.
|
|
480
|
+
*
|
|
481
|
+
* Absent on a binding that has no persistent realm to offer, which is what a
|
|
482
|
+
* host composing such a binding is told when the run opens rather than in the
|
|
483
|
+
* middle of a frame. A realm is the only way a cell runs: there is no
|
|
484
|
+
* per-frame evaluation beside it, because a cell that could not see what the
|
|
485
|
+
* cell before it bound was the surface this harness deleted.
|
|
486
|
+
*/
|
|
487
|
+
readonly openRealm?: (options: RealmOptions) => Effect.Effect<Realm, SandboxError, Scope.Scope>;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Context service for the selected sandbox binding.
|
|
491
|
+
*
|
|
492
|
+
* @category services
|
|
493
|
+
* @since 0.1.0
|
|
494
|
+
* @slop
|
|
495
|
+
*/
|
|
496
|
+
export declare const Sandbox: Context.Service<Sandbox, Sandbox>;
|
|
497
|
+
/**
|
|
498
|
+
* Constructs a sandbox from an implementation.
|
|
499
|
+
*
|
|
500
|
+
* @category constructors
|
|
501
|
+
* @since 0.1.0
|
|
502
|
+
* @slop
|
|
503
|
+
*/
|
|
504
|
+
export declare const make: (implementation: Sandbox) => Sandbox;
|
|
505
|
+
/**
|
|
506
|
+
* Provides a sandbox implementation.
|
|
507
|
+
*
|
|
508
|
+
* @category layers
|
|
509
|
+
* @since 0.1.0
|
|
510
|
+
* @slop
|
|
511
|
+
*/
|
|
512
|
+
export declare const layer: (implementation: Sandbox) => Layer.Layer<Sandbox>;
|
|
513
|
+
/**
|
|
514
|
+
* Constructs an unavailable sandbox stub, optionally overriding operations.
|
|
515
|
+
*
|
|
516
|
+
* It offers no realm, which is what a run composed against it is told: see
|
|
517
|
+
* {@link realmUnsupported}.
|
|
518
|
+
*
|
|
519
|
+
* @category constructors
|
|
520
|
+
* @since 0.1.0
|
|
521
|
+
* @slop
|
|
522
|
+
*/
|
|
523
|
+
export declare const makeNoop: (overrides?: Partial<Sandbox>) => Sandbox;
|
|
524
|
+
/**
|
|
525
|
+
* Provides an unavailable sandbox stub.
|
|
526
|
+
*
|
|
527
|
+
* @category layers
|
|
528
|
+
* @since 0.1.0
|
|
529
|
+
* @slop
|
|
530
|
+
*/
|
|
531
|
+
export declare const layerNoop: (overrides?: Partial<Sandbox>) => Layer.Layer<Sandbox>;
|
|
532
|
+
/**
|
|
533
|
+
* Refuses a run on a binding that has no persistent realm.
|
|
534
|
+
*
|
|
535
|
+
* Stated rather than silently downgraded: a realm is the whole surface, so a
|
|
536
|
+
* binding without one cannot run a cell at all and saying so at the open is the
|
|
537
|
+
* only honest answer.
|
|
538
|
+
*
|
|
539
|
+
* @category constructors
|
|
540
|
+
* @since 0.1.0
|
|
541
|
+
*/
|
|
542
|
+
export declare const realmUnsupported: SandboxError;
|
|
543
|
+
/**
|
|
544
|
+
* Settles one overrunning flow call as a resolved failure envelope in the cell.
|
|
545
|
+
*
|
|
546
|
+
* The message is written for the model, because the model is who reads it: it
|
|
547
|
+
* names the flow, the budget it spent, and the one action that recovers the
|
|
548
|
+
* frame. A rejection at the whole-evaluation ceiling teaches the model nothing
|
|
549
|
+
* — the frame is already gone by the time it could act.
|
|
550
|
+
*
|
|
551
|
+
* Exported so a caller that bounds its own settlements
|
|
552
|
+
* ({@link RealmEvaluation.bounded}) synthesizes the same refusal the loop would
|
|
553
|
+
* have: one ceiling means one sentence, whichever clock enforced it.
|
|
554
|
+
*
|
|
555
|
+
* @category constructors
|
|
556
|
+
* @since 0.1.0
|
|
557
|
+
*/
|
|
558
|
+
export declare const callTimedOut: (flow: string, callMs: number) => Cell.CallResult;
|
|
559
|
+
/**
|
|
560
|
+
* Erases type-only syntax from a cell without evaluating or resolving modules.
|
|
561
|
+
*
|
|
562
|
+
* Only Node's strip-safe TypeScript subset is accepted. Constructs that need
|
|
563
|
+
* JavaScript emit are refused instead of being silently transformed into new
|
|
564
|
+
* runtime behaviour.
|
|
565
|
+
*
|
|
566
|
+
* The parse itself belongs to `CellValidation`, which the controller already
|
|
567
|
+
* runs at the boundary before it commits a frame; this is the same answer, for
|
|
568
|
+
* a binding that only needs the program or the reason there is none.
|
|
569
|
+
*
|
|
570
|
+
* @category conversions
|
|
571
|
+
* @since 0.1.0
|
|
572
|
+
* @slop
|
|
573
|
+
*/
|
|
574
|
+
export declare const compile: (cell: Cell.Source) => string | Cell.Rejected;
|
|
575
|
+
/**
|
|
576
|
+
* A queued call awaiting resolution by a binding's driver.
|
|
577
|
+
*
|
|
578
|
+
* @category models
|
|
579
|
+
* @since 0.1.0
|
|
580
|
+
* @slop
|
|
581
|
+
*/
|
|
582
|
+
export interface PendingCall {
|
|
583
|
+
readonly ordinal: number;
|
|
584
|
+
readonly flow: string;
|
|
585
|
+
readonly input: Schema.Json;
|
|
586
|
+
/** Undecoded `at` option; see {@link Invocation.at}. */
|
|
587
|
+
readonly at?: Schema.Json | undefined;
|
|
588
|
+
/**
|
|
589
|
+
* Whether this entry is a flow call or a request to pin the tree.
|
|
590
|
+
*
|
|
591
|
+
* Both ride one queue because both have to be ordered against each other: a
|
|
592
|
+
* mint that overtook an edit, or an edit that overtook a mint, would pin the
|
|
593
|
+
* wrong tree. Absent means `call`, so every binding that queues an ordinary
|
|
594
|
+
* call is unchanged.
|
|
595
|
+
*/
|
|
596
|
+
readonly kind?: "call" | "checkpoint" | undefined;
|
|
597
|
+
readonly settle: (result: Cell.CallResult) => void;
|
|
598
|
+
readonly abort: (message: string) => void;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Drives one externally compiled cell to settlement: settle queued calls one at
|
|
602
|
+
* a time, in the order the cell issued them, until the cell settles.
|
|
603
|
+
*
|
|
604
|
+
* One at a time is deliberate. Data-dependent calls are the normal case, and a
|
|
605
|
+
* deterministic execution ordinal is what makes a mid-cell crash replayable.
|
|
606
|
+
*
|
|
607
|
+
* Bindings differ only in how a cell is compiled and how its promises are
|
|
608
|
+
* settled, so the interleaving lives here once rather than in each of them.
|
|
609
|
+
*
|
|
610
|
+
* @category constructors
|
|
611
|
+
* @since 0.1.0
|
|
612
|
+
* @slop
|
|
613
|
+
*/
|
|
614
|
+
export declare const driveCell: (options: {
|
|
615
|
+
readonly replay?: RealmEvaluation["replay"];
|
|
616
|
+
readonly progress?: ((dispatched: number, settled: number) => void) | undefined;
|
|
617
|
+
readonly pending: Array<PendingCall>;
|
|
618
|
+
/** Called after each resolved call so a binding may flush its job queue. */
|
|
619
|
+
readonly flush: () => void;
|
|
620
|
+
readonly finished: () => Cell.Outcome | undefined;
|
|
621
|
+
readonly abort: (message: string) => void;
|
|
622
|
+
readonly handler: Handler;
|
|
623
|
+
/** Settles a `ctx.checkpoint()`; omitted means the run pins none. */
|
|
624
|
+
readonly mint?: Minter | undefined;
|
|
625
|
+
/** Whether the caller bounds each settlement itself; see {@link RealmEvaluation.bounded}. */
|
|
626
|
+
readonly bounded?: boolean | undefined;
|
|
627
|
+
readonly limits?: Limits | undefined;
|
|
628
|
+
}) => Effect.Effect<Cell.Outcome, SandboxError | HarnessError>;
|
|
629
|
+
/**
|
|
630
|
+
* Projects a thrown value into a stable serializable cell outcome.
|
|
631
|
+
*
|
|
632
|
+
* @category conversions
|
|
633
|
+
* @since 0.1.0
|
|
634
|
+
* @slop
|
|
635
|
+
*/
|
|
636
|
+
export declare const raisedOutcome: (error: unknown) => Cell.Raised;
|
|
637
|
+
//# sourceMappingURL=Sandbox.d.ts.map
|