liminal 0.5.2 → 0.5.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/Agent.ts +25 -7
- package/CHANGELOG.md +10 -0
- package/Fiber.ts +117 -0
- package/Globals.ts +10 -0
- package/Handler.ts +0 -0
- package/L/L.ts +13 -0
- package/L/_infer.ts +35 -0
- package/L/_message.ts +18 -0
- package/L/all.ts +11 -0
- package/L/assistant.ts +34 -0
- package/L/branch.ts +45 -0
- package/L/emit.ts +11 -0
- package/L/fork.ts +18 -0
- package/L/join.ts +9 -0
- package/L/model.ts +11 -0
- package/L/namespace.ts +11 -0
- package/L/rune.ts +19 -0
- package/L/self.ts +13 -0
- package/L/state.ts +20 -0
- package/L/system.ts +13 -0
- package/L/user.ts +13 -0
- package/LEvent.ts +35 -0
- package/Message.ts +11 -90
- package/Model.ts +10 -23
- package/Rune.ts +17 -0
- package/Runic.ts +22 -0
- package/cli/main.ts +1 -24
- package/dist/Agent.d.ts +12 -7
- package/dist/Agent.js +15 -1
- package/dist/Agent.js.map +1 -1
- package/dist/Fiber.d.ts +38 -0
- package/dist/Fiber.js +79 -0
- package/dist/Fiber.js.map +1 -0
- package/dist/Globals.d.ts +7 -0
- package/dist/Globals.js +2 -0
- package/dist/Globals.js.map +1 -0
- package/dist/Handler.js +2 -0
- package/dist/Handler.js.map +1 -0
- package/dist/L/L.d.ts +13 -0
- package/dist/L/L.js +14 -0
- package/dist/L/L.js.map +1 -0
- package/dist/L/_infer.d.ts +4 -0
- package/dist/L/_infer.js +29 -0
- package/dist/L/_infer.js.map +1 -0
- package/dist/L/_message.d.ts +6 -0
- package/dist/L/_message.js +14 -0
- package/dist/L/_message.js.map +1 -0
- package/dist/L/all.d.ts +7 -0
- package/dist/L/all.js +5 -0
- package/dist/L/all.js.map +1 -0
- package/dist/L/assistant.d.ts +7 -0
- package/dist/L/assistant.js +23 -0
- package/dist/L/assistant.js.map +1 -0
- package/dist/L/branch.d.ts +11 -0
- package/dist/L/branch.js +32 -0
- package/dist/L/branch.js.map +1 -0
- package/dist/L/emit.d.ts +5 -0
- package/dist/L/emit.js +7 -0
- package/dist/L/emit.js.map +1 -0
- package/dist/L/fork.d.ts +7 -0
- package/dist/L/fork.js +11 -0
- package/dist/L/fork.js.map +1 -0
- package/dist/L/join.d.ts +5 -0
- package/dist/L/join.js +5 -0
- package/dist/L/join.js.map +1 -0
- package/dist/L/model.d.ts +5 -0
- package/dist/L/model.js +7 -0
- package/dist/L/model.js.map +1 -0
- package/dist/L/namespace.js +12 -0
- package/dist/L/namespace.js.map +1 -0
- package/dist/L/rune.d.ts +6 -0
- package/dist/L/rune.js +11 -0
- package/dist/L/rune.js.map +1 -0
- package/dist/L/self.d.ts +6 -0
- package/dist/L/self.js +7 -0
- package/dist/L/self.js.map +1 -0
- package/dist/L/state.d.ts +7 -0
- package/dist/L/state.js +14 -0
- package/dist/L/state.js.map +1 -0
- package/dist/L/system.d.ts +6 -0
- package/dist/L/system.js +7 -0
- package/dist/L/system.js.map +1 -0
- package/dist/L/user.d.ts +6 -0
- package/dist/L/user.js +7 -0
- package/dist/L/user.js.map +1 -0
- package/dist/LEvent.d.ts +28 -0
- package/dist/LEvent.js +5 -0
- package/dist/LEvent.js.map +1 -0
- package/dist/Message.d.ts +12 -81
- package/dist/Model.d.ts +4 -20
- package/dist/Model.js +6 -0
- package/dist/Model.js.map +1 -1
- package/dist/Rune.d.ts +11 -0
- package/dist/Rune.js +5 -0
- package/dist/Rune.js.map +1 -0
- package/dist/Runic.d.ts +9 -0
- package/dist/Runic.js +18 -0
- package/dist/Runic.js.map +1 -0
- package/dist/cli/main.d.ts +0 -1
- package/dist/cli/main.js +2 -19
- package/dist/cli/main.js.map +1 -1
- package/dist/index.d.ts +9 -39
- package/dist/index.js +9 -39
- package/dist/index.js.map +1 -1
- package/dist/state/Counter.d.ts +6 -0
- package/dist/state/Counter.js +13 -0
- package/dist/state/Counter.js.map +1 -0
- package/dist/state/DefaultStateMap.d.ts +4 -0
- package/dist/state/DefaultStateMap.js +14 -0
- package/dist/state/DefaultStateMap.js.map +1 -0
- package/dist/state/MessageRegistry.d.ts +7 -0
- package/dist/state/MessageRegistry.js +14 -0
- package/dist/state/MessageRegistry.js.map +1 -0
- package/dist/state/ModelConfig.d.ts +49 -0
- package/dist/state/ModelConfig.js +18 -0
- package/dist/state/ModelConfig.js.map +1 -0
- package/dist/state/ModelRegistry.d.ts +15 -0
- package/dist/state/ModelRegistry.js +43 -0
- package/dist/state/ModelRegistry.js.map +1 -0
- package/dist/state/StateMap.d.ts +7 -0
- package/dist/state/StateMap.js +10 -0
- package/dist/state/StateMap.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +9 -39
- package/package.json +6 -9
- package/state/Counter.ts +11 -0
- package/state/DefaultStateMap.ts +14 -0
- package/state/MessageRegistry.ts +17 -0
- package/state/ModelConfig.ts +49 -0
- package/state/ModelRegistry.ts +55 -0
- package/state/StateMap.ts +15 -0
- package/tsconfig.json +5 -1
- package/Action.ts +0 -29
- package/Exec.ts +0 -51
- package/L.ts +0 -24
- package/LiminalAssertionError.ts +0 -3
- package/LiminalConfig.ts +0 -7
- package/PathLike.ts +0 -17
- package/Scope.ts +0 -152
- package/Spec.ts +0 -29
- package/Tool.ts +0 -58
- package/_.ts +0 -11
- package/actions/abort.ts +0 -23
- package/actions/actions_common/updateModels.ts +0 -23
- package/actions/actions_derived/__snapshots__/declareModel.test.ts.snap +0 -89
- package/actions/actions_derived/clear.ts +0 -6
- package/actions/actions_derived/declareModel.test.ts +0 -36
- package/actions/actions_derived/declareModel.ts +0 -9
- package/actions/actions_derived/declareModel.type-test.ts +0 -70
- package/actions/actions_derived/messages.test.ts +0 -88
- package/actions/actions_derived/messages.ts +0 -18
- package/actions/actions_derived/metatype.ts +0 -9
- package/actions/actions_derived/readers_derived.ts +0 -15
- package/actions/appendMessage.ts +0 -54
- package/actions/await.ts +0 -13
- package/actions/branch.ts +0 -106
- package/actions/catch.ts +0 -42
- package/actions/declareArg.ts +0 -14
- package/actions/disableTool.ts +0 -26
- package/actions/embed.ts +0 -29
- package/actions/emit.ts +0 -21
- package/actions/enableTool.ts +0 -75
- package/actions/enableTool.type-test.ts +0 -118
- package/actions/infer.ts +0 -49
- package/actions/messages.ts +0 -62
- package/actions/pushModel.ts +0 -52
- package/actions/scope.ts +0 -13
- package/actions/section.ts +0 -105
- package/actions/throw.ts +0 -18
- package/cli/WriteHandler.ts +0 -35
- package/cli/cli_common.ts +0 -4
- package/cli/runExec.ts +0 -72
- package/dist/Action.d.ts +0 -15
- package/dist/Action.js +0 -13
- package/dist/Action.js.map +0 -1
- package/dist/Exec.d.ts +0 -25
- package/dist/Exec.js +0 -19
- package/dist/Exec.js.map +0 -1
- package/dist/L.d.ts +0 -23
- package/dist/L.js +0 -24
- package/dist/L.js.map +0 -1
- package/dist/LiminalAssertionError.d.ts +0 -3
- package/dist/LiminalAssertionError.js +0 -4
- package/dist/LiminalAssertionError.js.map +0 -1
- package/dist/LiminalConfig.d.ts +0 -6
- package/dist/LiminalConfig.js +0 -2
- package/dist/LiminalConfig.js.map +0 -1
- package/dist/PathLike.d.ts +0 -11
- package/dist/PathLike.js +0 -2
- package/dist/PathLike.js.map +0 -1
- package/dist/Scope.d.ts +0 -42
- package/dist/Scope.js +0 -93
- package/dist/Scope.js.map +0 -1
- package/dist/Spec.d.ts +0 -20
- package/dist/Spec.js +0 -2
- package/dist/Spec.js.map +0 -1
- package/dist/Tool.d.ts +0 -21
- package/dist/Tool.js +0 -32
- package/dist/Tool.js.map +0 -1
- package/dist/_.d.ts +0 -5
- package/dist/_.js +0 -7
- package/dist/_.js.map +0 -1
- package/dist/actions/abort.d.ts +0 -9
- package/dist/actions/abort.js +0 -15
- package/dist/actions/abort.js.map +0 -1
- package/dist/actions/actions_common/updateModels.d.ts +0 -3
- package/dist/actions/actions_common/updateModels.js +0 -17
- package/dist/actions/actions_common/updateModels.js.map +0 -1
- package/dist/actions/actions_derived/clear.d.ts +0 -8
- package/dist/actions/actions_derived/clear.js +0 -5
- package/dist/actions/actions_derived/clear.js.map +0 -1
- package/dist/actions/actions_derived/declareModel.d.ts +0 -5
- package/dist/actions/actions_derived/declareModel.js +0 -7
- package/dist/actions/actions_derived/declareModel.js.map +0 -1
- package/dist/actions/actions_derived/declareModel.test.js +0 -35
- package/dist/actions/actions_derived/declareModel.test.js.map +0 -1
- package/dist/actions/actions_derived/declareModel.type-test.js +0 -66
- package/dist/actions/actions_derived/declareModel.type-test.js.map +0 -1
- package/dist/actions/actions_derived/messages.d.ts +0 -6
- package/dist/actions/actions_derived/messages.js +0 -15
- package/dist/actions/actions_derived/messages.js.map +0 -1
- package/dist/actions/actions_derived/messages.test.d.ts +0 -1
- package/dist/actions/actions_derived/messages.test.js +0 -72
- package/dist/actions/actions_derived/messages.test.js.map +0 -1
- package/dist/actions/actions_derived/metatype.d.ts +0 -9
- package/dist/actions/actions_derived/metatype.js +0 -7
- package/dist/actions/actions_derived/metatype.js.map +0 -1
- package/dist/actions/actions_derived/readers_derived.d.ts +0 -6
- package/dist/actions/actions_derived/readers_derived.js +0 -14
- package/dist/actions/actions_derived/readers_derived.js.map +0 -1
- package/dist/actions/appendMessage.d.ts +0 -14
- package/dist/actions/appendMessage.js +0 -41
- package/dist/actions/appendMessage.js.map +0 -1
- package/dist/actions/await.d.ts +0 -5
- package/dist/actions/await.js +0 -10
- package/dist/actions/await.js.map +0 -1
- package/dist/actions/branch.d.ts +0 -39
- package/dist/actions/branch.js +0 -40
- package/dist/actions/branch.js.map +0 -1
- package/dist/actions/catch.d.ts +0 -10
- package/dist/actions/catch.js +0 -27
- package/dist/actions/catch.js.map +0 -1
- package/dist/actions/declareArg.d.ts +0 -8
- package/dist/actions/declareArg.js +0 -10
- package/dist/actions/declareArg.js.map +0 -1
- package/dist/actions/disableTool.d.ts +0 -10
- package/dist/actions/disableTool.js +0 -17
- package/dist/actions/disableTool.js.map +0 -1
- package/dist/actions/embed.d.ts +0 -9
- package/dist/actions/embed.js +0 -24
- package/dist/actions/embed.js.map +0 -1
- package/dist/actions/emit.d.ts +0 -9
- package/dist/actions/emit.js +0 -14
- package/dist/actions/emit.js.map +0 -1
- package/dist/actions/enableTool.d.ts +0 -20
- package/dist/actions/enableTool.js +0 -26
- package/dist/actions/enableTool.js.map +0 -1
- package/dist/actions/enableTool.type-test.d.ts +0 -1
- package/dist/actions/enableTool.type-test.js +0 -30
- package/dist/actions/enableTool.type-test.js.map +0 -1
- package/dist/actions/infer.d.ts +0 -15
- package/dist/actions/infer.js +0 -29
- package/dist/actions/infer.js.map +0 -1
- package/dist/actions/messages.d.ts +0 -24
- package/dist/actions/messages.js +0 -35
- package/dist/actions/messages.js.map +0 -1
- package/dist/actions/pushModel.d.ts +0 -15
- package/dist/actions/pushModel.js +0 -36
- package/dist/actions/pushModel.js.map +0 -1
- package/dist/actions/scope.d.ts +0 -7
- package/dist/actions/scope.js +0 -10
- package/dist/actions/scope.js.map +0 -1
- package/dist/actions/section.d.ts +0 -23
- package/dist/actions/section.js +0 -64
- package/dist/actions/section.js.map +0 -1
- package/dist/actions/throw.d.ts +0 -9
- package/dist/actions/throw.js +0 -13
- package/dist/actions/throw.js.map +0 -1
- package/dist/cli/WriteHandler.d.ts +0 -9
- package/dist/cli/WriteHandler.js +0 -24
- package/dist/cli/WriteHandler.js.map +0 -1
- package/dist/cli/cli_common.d.ts +0 -4
- package/dist/cli/cli_common.js +0 -2
- package/dist/cli/cli_common.js.map +0 -1
- package/dist/cli/runExec.d.ts +0 -2
- package/dist/cli/runExec.js +0 -74
- package/dist/cli/runExec.js.map +0 -1
- package/dist/events/Aborted.d.ts +0 -4
- package/dist/events/Aborted.js +0 -2
- package/dist/events/Aborted.js.map +0 -1
- package/dist/events/Embedded.d.ts +0 -5
- package/dist/events/Embedded.js +0 -2
- package/dist/events/Embedded.js.map +0 -1
- package/dist/events/EmbeddingRequested.d.ts +0 -4
- package/dist/events/EmbeddingRequested.js +0 -2
- package/dist/events/EmbeddingRequested.js.map +0 -1
- package/dist/events/Emitted.d.ts +0 -4
- package/dist/events/Emitted.js +0 -2
- package/dist/events/Emitted.js.map +0 -1
- package/dist/events/EventBase.d.ts +0 -3
- package/dist/events/EventBase.js +0 -2
- package/dist/events/EventBase.js.map +0 -1
- package/dist/events/EventHandler.d.ts +0 -2
- package/dist/events/EventHandler.js +0 -2
- package/dist/events/EventHandler.js.map +0 -1
- package/dist/events/EventResolved.d.ts +0 -19
- package/dist/events/EventResolved.js +0 -2
- package/dist/events/EventResolved.js.map +0 -1
- package/dist/events/Forked.d.ts +0 -3
- package/dist/events/Forked.js +0 -2
- package/dist/events/Forked.js.map +0 -1
- package/dist/events/InferenceRequested.d.ts +0 -3
- package/dist/events/InferenceRequested.js +0 -2
- package/dist/events/InferenceRequested.js.map +0 -1
- package/dist/events/Inferred.d.ts +0 -5
- package/dist/events/Inferred.js +0 -2
- package/dist/events/Inferred.js.map +0 -1
- package/dist/events/LEvent.d.ts +0 -20
- package/dist/events/LEvent.js +0 -2
- package/dist/events/LEvent.js.map +0 -1
- package/dist/events/MessageAppended.d.ts +0 -5
- package/dist/events/MessageAppended.js +0 -2
- package/dist/events/MessageAppended.js.map +0 -1
- package/dist/events/MessageRemoved.d.ts +0 -5
- package/dist/events/MessageRemoved.js +0 -2
- package/dist/events/MessageRemoved.js.map +0 -1
- package/dist/events/MessagesSet.d.ts +0 -5
- package/dist/events/MessagesSet.js +0 -2
- package/dist/events/MessagesSet.js.map +0 -1
- package/dist/events/ModelPushed.d.ts +0 -7
- package/dist/events/ModelPushed.js +0 -2
- package/dist/events/ModelPushed.js.map +0 -1
- package/dist/events/ModelRemoved.d.ts +0 -7
- package/dist/events/ModelRemoved.js +0 -2
- package/dist/events/ModelRemoved.js.map +0 -1
- package/dist/events/Returned.d.ts +0 -4
- package/dist/events/Returned.js +0 -2
- package/dist/events/Returned.js.map +0 -1
- package/dist/events/SectionCleared.d.ts +0 -5
- package/dist/events/SectionCleared.js +0 -2
- package/dist/events/SectionCleared.js.map +0 -1
- package/dist/events/Sectioned.d.ts +0 -5
- package/dist/events/Sectioned.js +0 -2
- package/dist/events/Sectioned.js.map +0 -1
- package/dist/events/Threw.d.ts +0 -4
- package/dist/events/Threw.js +0 -2
- package/dist/events/Threw.js.map +0 -1
- package/dist/events/ToolCalled.d.ts +0 -6
- package/dist/events/ToolCalled.js +0 -2
- package/dist/events/ToolCalled.js.map +0 -1
- package/dist/events/ToolDisabled.d.ts +0 -5
- package/dist/events/ToolDisabled.js +0 -2
- package/dist/events/ToolDisabled.js.map +0 -1
- package/dist/events/ToolEnabled.d.ts +0 -7
- package/dist/events/ToolEnabled.js +0 -2
- package/dist/events/ToolEnabled.js.map +0 -1
- package/dist/events/isScopeChildEvent.d.ts +0 -6
- package/dist/events/isScopeChildEvent.js +0 -9
- package/dist/events/isScopeChildEvent.js.map +0 -1
- package/dist/events/isScopeDescendantEvent.d.ts +0 -14
- package/dist/events/isScopeDescendantEvent.js +0 -12
- package/dist/events/isScopeDescendantEvent.js.map +0 -1
- package/dist/testing/AgentAssertions.d.ts +0 -9
- package/dist/testing/AgentAssertions.js +0 -6
- package/dist/testing/AgentAssertions.js.map +0 -1
- package/dist/testing/TestEmbeddingModel.d.ts +0 -6
- package/dist/testing/TestEmbeddingModel.js +0 -11
- package/dist/testing/TestEmbeddingModel.js.map +0 -1
- package/dist/testing/TestLanguageModel.d.ts +0 -8
- package/dist/testing/TestLanguageModel.js +0 -22
- package/dist/testing/TestLanguageModel.js.map +0 -1
- package/dist/testing/index.d.ts +0 -4
- package/dist/testing/index.js +0 -5
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/takeFirstAction.d.ts +0 -3
- package/dist/testing/takeFirstAction.js +0 -6
- package/dist/testing/takeFirstAction.js.map +0 -1
- package/dist/types/AssertDiagnostics.d.ts +0 -18
- package/dist/types/AssertDiagnostics.js +0 -152
- package/dist/types/AssertDiagnostics.js.map +0 -1
- package/dist/types/JSONRootType.d.ts +0 -6
- package/dist/types/JSONRootType.js +0 -2
- package/dist/types/JSONRootType.js.map +0 -1
- package/dist/types/JSONType.d.ts +0 -16
- package/dist/types/JSONType.js +0 -2
- package/dist/types/JSONType.js.map +0 -1
- package/dist/types/JSONTypeBase.d.ts +0 -3
- package/dist/types/JSONTypeBase.js +0 -2
- package/dist/types/JSONTypeBase.js.map +0 -1
- package/dist/types/Metatype/MetatypeDescriptor.d.ts +0 -41
- package/dist/types/Metatype/MetatypeDescriptor.js +0 -38
- package/dist/types/Metatype/MetatypeDescriptor.js.map +0 -1
- package/dist/types/Metatype/fromMetatypeDescriptor.d.ts +0 -6
- package/dist/types/Metatype/fromMetatypeDescriptor.js +0 -43
- package/dist/types/Metatype/fromMetatypeDescriptor.js.map +0 -1
- package/dist/types/Type.d.ts +0 -31
- package/dist/types/Type.js +0 -5
- package/dist/types/Type.js.map +0 -1
- package/dist/types/TypeContext.d.ts +0 -7
- package/dist/types/TypeContext.js +0 -17
- package/dist/types/TypeContext.js.map +0 -1
- package/dist/types/TypeLike.d.ts +0 -23
- package/dist/types/TypeLike.js +0 -23
- package/dist/types/TypeLike.js.map +0 -1
- package/dist/types/TypeVisitor.d.ts +0 -14
- package/dist/types/TypeVisitor.js +0 -12
- package/dist/types/TypeVisitor.js.map +0 -1
- package/dist/types/array.d.ts +0 -10
- package/dist/types/array.js +0 -9
- package/dist/types/array.js.map +0 -1
- package/dist/types/boolean.d.ts +0 -6
- package/dist/types/boolean.js +0 -3
- package/dist/types/boolean.js.map +0 -1
- package/dist/types/const.d.ts +0 -8
- package/dist/types/const.js +0 -7
- package/dist/types/const.js.map +0 -1
- package/dist/types/enum.d.ts +0 -8
- package/dist/types/enum.js +0 -7
- package/dist/types/enum.js.map +0 -1
- package/dist/types/factories.d.ts +0 -8
- package/dist/types/factories.js +0 -9
- package/dist/types/factories.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types/integer.d.ts +0 -6
- package/dist/types/integer.js +0 -3
- package/dist/types/integer.js.map +0 -1
- package/dist/types/intrinsics.d.ts +0 -11
- package/dist/types/intrinsics.js +0 -12
- package/dist/types/intrinsics.js.map +0 -1
- package/dist/types/makeType.d.ts +0 -2
- package/dist/types/makeType.js +0 -58
- package/dist/types/makeType.js.map +0 -1
- package/dist/types/match.d.ts +0 -3
- package/dist/types/match.js +0 -11
- package/dist/types/match.js.map +0 -1
- package/dist/types/non_factories.d.ts +0 -21
- package/dist/types/non_factories.js +0 -9
- package/dist/types/non_factories.js.map +0 -1
- package/dist/types/null.d.ts +0 -7
- package/dist/types/null.js +0 -4
- package/dist/types/null.js.map +0 -1
- package/dist/types/number.d.ts +0 -6
- package/dist/types/number.js +0 -3
- package/dist/types/number.js.map +0 -1
- package/dist/types/object.d.ts +0 -16
- package/dist/types/object.js +0 -10
- package/dist/types/object.js.map +0 -1
- package/dist/types/ref.d.ts +0 -7
- package/dist/types/ref.js +0 -5
- package/dist/types/ref.js.map +0 -1
- package/dist/types/string.d.ts +0 -6
- package/dist/types/string.js +0 -3
- package/dist/types/string.js.map +0 -1
- package/dist/types/toJSON.d.ts +0 -5
- package/dist/types/toJSON.js +0 -97
- package/dist/types/toJSON.js.map +0 -1
- package/dist/types/type_common.d.ts +0 -10
- package/dist/types/type_common.js +0 -12
- package/dist/types/type_common.js.map +0 -1
- package/dist/types/types_derived/option.d.ts +0 -5
- package/dist/types/types_derived/option.js +0 -6
- package/dist/types/types_derived/option.js.map +0 -1
- package/dist/types/types_derived/taggedUnion.d.ts +0 -19
- package/dist/types/types_derived/taggedUnion.js +0 -8
- package/dist/types/types_derived/taggedUnion.js.map +0 -1
- package/dist/types/types_derived/wrapper.d.ts +0 -8
- package/dist/types/types_derived/wrapper.js +0 -5
- package/dist/types/types_derived/wrapper.js.map +0 -1
- package/dist/types/union.d.ts +0 -9
- package/dist/types/union.js +0 -9
- package/dist/types/union.js.map +0 -1
- package/dist/util/ArrayOfLength.d.ts +0 -1
- package/dist/util/ArrayOfLength.js +0 -2
- package/dist/util/ArrayOfLength.js.map +0 -1
- package/dist/util/DeferredOr.d.ts +0 -1
- package/dist/util/DeferredOr.js +0 -2
- package/dist/util/DeferredOr.js.map +0 -1
- package/dist/util/EnsureNarrow.d.ts +0 -2
- package/dist/util/EnsureNarrow.js +0 -2
- package/dist/util/EnsureNarrow.js.map +0 -1
- package/dist/util/EnsureRecord.d.ts +0 -2
- package/dist/util/EnsureRecord.js +0 -2
- package/dist/util/EnsureRecord.js.map +0 -1
- package/dist/util/Expand.d.ts +0 -3
- package/dist/util/Expand.js +0 -2
- package/dist/util/Expand.js.map +0 -1
- package/dist/util/Falsy.d.ts +0 -1
- package/dist/util/Falsy.js +0 -2
- package/dist/util/Falsy.js.map +0 -1
- package/dist/util/FromEntries.d.ts +0 -3
- package/dist/util/FromEntries.js +0 -2
- package/dist/util/FromEntries.js.map +0 -1
- package/dist/util/IteratorLike.d.ts +0 -1
- package/dist/util/IteratorLike.js +0 -2
- package/dist/util/IteratorLike.js.map +0 -1
- package/dist/util/JSONEntry.d.ts +0 -2
- package/dist/util/JSONEntry.js +0 -2
- package/dist/util/JSONEntry.js.map +0 -1
- package/dist/util/JSONKey.d.ts +0 -1
- package/dist/util/JSONKey.js +0 -2
- package/dist/util/JSONKey.js.map +0 -1
- package/dist/util/JSONObject.d.ts +0 -5
- package/dist/util/JSONObject.js +0 -2
- package/dist/util/JSONObject.js.map +0 -1
- package/dist/util/JSONSchemaMemo.d.ts +0 -2
- package/dist/util/JSONSchemaMemo.js +0 -13
- package/dist/util/JSONSchemaMemo.js.map +0 -1
- package/dist/util/JSONValue.d.ts +0 -2
- package/dist/util/JSONValue.js +0 -2
- package/dist/util/JSONValue.js.map +0 -1
- package/dist/util/PromiseOr.d.ts +0 -1
- package/dist/util/PromiseOr.js +0 -2
- package/dist/util/PromiseOr.js.map +0 -1
- package/dist/util/Result.d.ts +0 -7
- package/dist/util/Result.js +0 -2
- package/dist/util/Result.js.map +0 -1
- package/dist/util/Taggable.d.ts +0 -9
- package/dist/util/Taggable.js +0 -8
- package/dist/util/Taggable.js.map +0 -1
- package/dist/util/TupleToRecord.d.ts +0 -5
- package/dist/util/TupleToRecord.js +0 -2
- package/dist/util/TupleToRecord.js.map +0 -1
- package/dist/util/assert.d.ts +0 -1
- package/dist/util/assert.js +0 -7
- package/dist/util/assert.js.map +0 -1
- package/dist/util/dedent.d.ts +0 -1
- package/dist/util/dedent.js +0 -5
- package/dist/util/dedent.js.map +0 -1
- package/dist/util/fixTemplateStrings.d.ts +0 -11
- package/dist/util/fixTemplateStrings.js +0 -83
- package/dist/util/fixTemplateStrings.js.map +0 -1
- package/dist/util/fixTemplateStrings.test.d.ts +0 -1
- package/dist/util/fixTemplateStrings.test.js +0 -221
- package/dist/util/fixTemplateStrings.test.js.map +0 -1
- package/dist/util/isAsyncIterator.d.ts +0 -1
- package/dist/util/isAsyncIterator.js +0 -7
- package/dist/util/isAsyncIterator.js.map +0 -1
- package/dist/util/isIterator.d.ts +0 -1
- package/dist/util/isIterator.js +0 -7
- package/dist/util/isIterator.js.map +0 -1
- package/dist/util/isJSONValue.d.ts +0 -2
- package/dist/util/isJSONValue.js +0 -16
- package/dist/util/isJSONValue.js.map +0 -1
- package/dist/util/isPropertyKey.d.ts +0 -1
- package/dist/util/isPropertyKey.js +0 -4
- package/dist/util/isPropertyKey.js.map +0 -1
- package/dist/util/isTemplateStringsArray.d.ts +0 -1
- package/dist/util/isTemplateStringsArray.js +0 -4
- package/dist/util/isTemplateStringsArray.js.map +0 -1
- package/dist/util/jsonEquals.d.ts +0 -2
- package/dist/util/jsonEquals.js +0 -33
- package/dist/util/jsonEquals.js.map +0 -1
- package/dist/util/nullaryMemo.d.ts +0 -1
- package/dist/util/nullaryMemo.js +0 -12
- package/dist/util/nullaryMemo.js.map +0 -1
- package/dist/util/peekLast.d.ts +0 -1
- package/dist/util/peekLast.js +0 -4
- package/dist/util/peekLast.js.map +0 -1
- package/dist/util/unimplemented.d.ts +0 -1
- package/dist/util/unimplemented.js +0 -5
- package/dist/util/unimplemented.js.map +0 -1
- package/dist/util/unreachable.d.ts +0 -1
- package/dist/util/unreachable.js +0 -5
- package/dist/util/unreachable.js.map +0 -1
- package/dist/util/unwrapDeferred.d.ts +0 -2
- package/dist/util/unwrapDeferred.js +0 -4
- package/dist/util/unwrapDeferred.js.map +0 -1
- package/dist/util/util.d.ts +0 -10
- package/dist/util/util.js +0 -11
- package/dist/util/util.js.map +0 -1
- package/events/Aborted.ts +0 -5
- package/events/Embedded.ts +0 -6
- package/events/EmbeddingRequested.ts +0 -5
- package/events/Emitted.ts +0 -5
- package/events/EventBase.ts +0 -3
- package/events/EventHandler.ts +0 -3
- package/events/EventResolved.ts +0 -30
- package/events/Forked.ts +0 -3
- package/events/InferenceRequested.ts +0 -3
- package/events/Inferred.ts +0 -6
- package/events/LEvent.ts +0 -40
- package/events/MessageAppended.ts +0 -6
- package/events/MessageRemoved.ts +0 -6
- package/events/MessagesSet.ts +0 -6
- package/events/ModelPushed.ts +0 -10
- package/events/ModelRemoved.ts +0 -10
- package/events/Returned.ts +0 -5
- package/events/SectionCleared.ts +0 -6
- package/events/Sectioned.ts +0 -6
- package/events/Threw.ts +0 -5
- package/events/ToolCalled.ts +0 -7
- package/events/ToolDisabled.ts +0 -6
- package/events/ToolEnabled.ts +0 -8
- package/events/isScopeChildEvent.ts +0 -15
- package/events/isScopeDescendantEvent.ts +0 -30
- package/testing/AgentAssertions.ts +0 -17
- package/testing/TestEmbeddingModel.ts +0 -19
- package/testing/TestLanguageModel.ts +0 -33
- package/testing/index.ts +0 -4
- package/testing/takeFirstAction.ts +0 -8
- package/types/AssertDiagnostics.ts +0 -183
- package/types/JSONRootType.ts +0 -8
- package/types/JSONType.ts +0 -27
- package/types/JSONTypeBase.ts +0 -3
- package/types/Metatype/MetatypeDescriptor.ts +0 -80
- package/types/Metatype/fromMetatypeDescriptor.ts +0 -52
- package/types/Type.ts +0 -47
- package/types/TypeContext.ts +0 -19
- package/types/TypeLike.ts +0 -60
- package/types/TypeVisitor.ts +0 -49
- package/types/array.ts +0 -20
- package/types/boolean.ts +0 -9
- package/types/const.ts +0 -17
- package/types/enum.ts +0 -14
- package/types/factories.ts +0 -8
- package/types/index.ts +0 -2
- package/types/integer.ts +0 -9
- package/types/intrinsics.ts +0 -11
- package/types/makeType.ts +0 -72
- package/types/match.ts +0 -13
- package/types/non_factories.ts +0 -26
- package/types/null.ts +0 -10
- package/types/number.ts +0 -9
- package/types/object.ts +0 -27
- package/types/ref.ts +0 -12
- package/types/string.ts +0 -9
- package/types/toJSON.ts +0 -111
- package/types/type_common.ts +0 -21
- package/types/types_derived/option.ts +0 -10
- package/types/types_derived/taggedUnion.ts +0 -30
- package/types/types_derived/wrapper.ts +0 -10
- package/types/union.ts +0 -19
- package/util/ArrayOfLength.ts +0 -5
- package/util/DeferredOr.ts +0 -1
- package/util/EnsureNarrow.ts +0 -5
- package/util/EnsureRecord.ts +0 -3
- package/util/Expand.ts +0 -1
- package/util/Falsy.ts +0 -1
- package/util/FromEntries.ts +0 -3
- package/util/IteratorLike.ts +0 -1
- package/util/JSONEntry.ts +0 -3
- package/util/JSONKey.ts +0 -1
- package/util/JSONObject.ts +0 -6
- package/util/JSONSchemaMemo.ts +0 -15
- package/util/JSONValue.ts +0 -3
- package/util/PromiseOr.ts +0 -1
- package/util/Result.ts +0 -7
- package/util/Taggable.ts +0 -18
- package/util/TupleToRecord.ts +0 -5
- package/util/assert.ts +0 -7
- package/util/dedent.ts +0 -5
- package/util/fixTemplateStrings.test.ts +0 -250
- package/util/fixTemplateStrings.ts +0 -99
- package/util/isAsyncIterator.ts +0 -6
- package/util/isIterator.ts +0 -6
- package/util/isJSONValue.ts +0 -20
- package/util/isPropertyKey.ts +0 -3
- package/util/isTemplateStringsArray.ts +0 -3
- package/util/jsonEquals.ts +0 -41
- package/util/nullaryMemo.ts +0 -11
- package/util/peekLast.ts +0 -3
- package/util/unimplemented.ts +0 -5
- package/util/unreachable.ts +0 -5
- package/util/unwrapDeferred.ts +0 -5
- package/util/util.ts +0 -10
- /package/dist/{actions/actions_derived/declareModel.test.d.ts → Handler.d.ts} +0 -0
- /package/dist/{actions/actions_derived/declareModel.type-test.d.ts → L/namespace.d.ts} +0 -0
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { JSONKey } from "../../util/JSONKey.ts"
|
|
2
|
-
import type { JSONConstType } from "../const.ts"
|
|
3
|
-
import { type JSONObjectType, object } from "../object.ts"
|
|
4
|
-
import type { JSONStringType } from "../string.ts"
|
|
5
|
-
import { type Type } from "../Type.ts"
|
|
6
|
-
import { type NormalizeTypeLikeJ, type NormalizeTypeLikeT, type TypeLike } from "../TypeLike.ts"
|
|
7
|
-
import { _union, type JSONUnionType, union } from "../union.ts"
|
|
8
|
-
|
|
9
|
-
export function taggedUnion<const M extends TaggedUnionMembers, K extends Extract<keyof M, string>>(members: M): Type<
|
|
10
|
-
{
|
|
11
|
-
[L in K]: {
|
|
12
|
-
type: L
|
|
13
|
-
value: NormalizeTypeLikeT<M[L]>
|
|
14
|
-
}
|
|
15
|
-
}[K],
|
|
16
|
-
JSONUnionType<
|
|
17
|
-
{
|
|
18
|
-
[L in K]: JSONObjectType<{
|
|
19
|
-
type: JSONConstType<JSONStringType, L>
|
|
20
|
-
value: NormalizeTypeLikeJ<M[L]>
|
|
21
|
-
}>
|
|
22
|
-
}[K]
|
|
23
|
-
>
|
|
24
|
-
> {
|
|
25
|
-
return union(
|
|
26
|
-
...Object.entries(members).map(([type, value]) => object({ type, value })),
|
|
27
|
-
) as never
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type TaggedUnionMembers = Record<JSONKey, TypeLike>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type JSONObjectType, object } from "../object.ts"
|
|
2
|
-
import type { Type } from "../Type.ts"
|
|
3
|
-
import type { NormalizeTypeLikeJ, NormalizeTypeLikeT, TypeLike } from "../TypeLike.ts"
|
|
4
|
-
|
|
5
|
-
export function wrapper<X extends TypeLike>(value: X): Type<
|
|
6
|
-
{ value: NormalizeTypeLikeT<X> },
|
|
7
|
-
JSONObjectType<{ value: NormalizeTypeLikeJ<X> }>
|
|
8
|
-
> {
|
|
9
|
-
return object({ value }) as never
|
|
10
|
-
}
|
package/types/union.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { JSONType } from "./JSONType.ts"
|
|
2
|
-
import type { JSONTypeBase } from "./JSONTypeBase.ts"
|
|
3
|
-
import { makeType } from "./makeType.ts"
|
|
4
|
-
import type { Type } from "./Type.ts"
|
|
5
|
-
import { normalizeTypeLike, type NormalizeTypeLikeJ, type NormalizeTypeLikeT, type TypeLike } from "./TypeLike.ts"
|
|
6
|
-
|
|
7
|
-
export function union<const M extends Array<TypeLike>>(
|
|
8
|
-
...members: M
|
|
9
|
-
): Type<NormalizeTypeLikeT<M[number]>, JSONUnionType<NormalizeTypeLikeJ<M[number]>>> {
|
|
10
|
-
return _union(...members.map(normalizeTypeLike)) as never
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function _union(...members: Array<Type>): Type {
|
|
14
|
-
return makeType(() => _union, members)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface JSONUnionType<M extends JSONType = any> extends JSONTypeBase {
|
|
18
|
-
anyOf: Array<M>
|
|
19
|
-
}
|
package/util/ArrayOfLength.ts
DELETED
package/util/DeferredOr.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type DeferredOr<T> = T | (() => T)
|
package/util/EnsureNarrow.ts
DELETED
package/util/EnsureRecord.ts
DELETED
package/util/Expand.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Expand<T> = T extends T ? { [K in keyof T]: T[K] } : never
|
package/util/Falsy.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Falsy = false | 0 | 0n | "" | null | undefined
|
package/util/FromEntries.ts
DELETED
package/util/IteratorLike.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type IteratorLike<Y = any, O = any> = Iterator<Y, O> | AsyncIterator<Y, O>
|
package/util/JSONEntry.ts
DELETED
package/util/JSONKey.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type JSONKey = number | string
|
package/util/JSONObject.ts
DELETED
package/util/JSONSchemaMemo.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec"
|
|
2
|
-
import { toJSONSchema } from "standard-json-schema"
|
|
3
|
-
import { isType } from "../types/Type.ts"
|
|
4
|
-
|
|
5
|
-
const memo = new WeakMap<StandardSchemaV1, Promise<object>>()
|
|
6
|
-
|
|
7
|
-
export function JSONSchemaMemo(type: StandardSchemaV1): Promise<object> {
|
|
8
|
-
let pending = memo.get(type)
|
|
9
|
-
if (pending) {
|
|
10
|
-
return pending
|
|
11
|
-
}
|
|
12
|
-
pending = isType(type) ? Promise.resolve(type.toJSON()) : toJSONSchema(type)
|
|
13
|
-
memo.set(type, pending)
|
|
14
|
-
return pending
|
|
15
|
-
}
|
package/util/JSONValue.ts
DELETED
package/util/PromiseOr.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type PromiseOr<T> = T | Promise<T>
|
package/util/Result.ts
DELETED
package/util/Taggable.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { applyTemplateWithIndentation } from "./fixTemplateStrings.ts"
|
|
2
|
-
import { isTemplateStringsArray } from "./isTemplateStringsArray.ts"
|
|
3
|
-
|
|
4
|
-
export interface Taggable<A extends Array<any>> {
|
|
5
|
-
(template: TemplateStringsArray, ...substitutions: Array<string>): this
|
|
6
|
-
(...values: A): this
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type TaggableArgs<A extends Array<any>> = A | [
|
|
10
|
-
raw: TemplateStringsArray,
|
|
11
|
-
...substitutions: Array<string>,
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
export function normalizeTaggableArgs<A extends Array<unknown>>(...[e0, ...eRest]: TaggableArgs<A>) {
|
|
15
|
-
return isTemplateStringsArray(e0)
|
|
16
|
-
? [applyTemplateWithIndentation(e0, ...eRest)] as [string]
|
|
17
|
-
: [e0, ...eRest] as A
|
|
18
|
-
}
|
package/util/TupleToRecord.ts
DELETED
package/util/assert.ts
DELETED
package/util/dedent.ts
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { applyTemplateWithIndentation, fixTemplateStrings } from "./fixTemplateStrings"
|
|
3
|
-
|
|
4
|
-
// Helper to create a mock TemplateStringsArray
|
|
5
|
-
function createTemplateArray(strings: string[]): TemplateStringsArray {
|
|
6
|
-
const arr = [...strings] as unknown as TemplateStringsArray
|
|
7
|
-
Object.defineProperty(arr, "raw", { value: strings })
|
|
8
|
-
return arr
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// A template tag function that applies indentation to substitutions
|
|
12
|
-
function templateTag(strings: TemplateStringsArray, ...values: any[]): string {
|
|
13
|
-
return applyTemplateWithIndentation(strings, ...values)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("fixTemplateStrings", () => {
|
|
17
|
-
test("handles basic template strings without indentation", () => {
|
|
18
|
-
const template = createTemplateArray(["hello", "world", "!"])
|
|
19
|
-
const result = fixTemplateStrings(template)
|
|
20
|
-
expect(result.raw).toEqual(["hello", "world", "!"])
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test("removes common indentation from multiline strings", () => {
|
|
24
|
-
const template = createTemplateArray([`
|
|
25
|
-
first line
|
|
26
|
-
second line
|
|
27
|
-
third line`])
|
|
28
|
-
|
|
29
|
-
const result = fixTemplateStrings(template)
|
|
30
|
-
// Leading newline should be removed
|
|
31
|
-
expect(result.raw[0]).toBe("first line\nsecond line\nthird line")
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test("handles escaped characters", () => {
|
|
35
|
-
const template = createTemplateArray(["\\`template\\$\\{with\\}escaped\\nchars"])
|
|
36
|
-
const result = fixTemplateStrings(template)
|
|
37
|
-
// The function only unescapes backticks, dollar signs, and opening braces
|
|
38
|
-
expect(result.raw[0]).toBe("`template${with\\}escaped\\nchars")
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test("preserves intended backticks and dollar signs", () => {
|
|
42
|
-
const template = createTemplateArray(["const code = `const value = ${'test'}`"])
|
|
43
|
-
const result = fixTemplateStrings(template)
|
|
44
|
-
expect(result.raw[0]).toBe("const code = `const value = ${'test'}`")
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test("removes trailing spaces in last segment", () => {
|
|
48
|
-
const template = createTemplateArray([`
|
|
49
|
-
some text
|
|
50
|
-
with trailing spaces
|
|
51
|
-
`])
|
|
52
|
-
|
|
53
|
-
const result = fixTemplateStrings(template)
|
|
54
|
-
// The function only removes trailing spaces after a newline at the end
|
|
55
|
-
// And only if indentation is detected
|
|
56
|
-
// Leading newline should be removed
|
|
57
|
-
expect(result.raw[0]).toBe("some text\nwith trailing spaces \n")
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
test("handles mixed indentation", () => {
|
|
61
|
-
const template = createTemplateArray([`
|
|
62
|
-
spaces here
|
|
63
|
-
more spaces
|
|
64
|
-
less spaces
|
|
65
|
-
most spaces`])
|
|
66
|
-
|
|
67
|
-
const result = fixTemplateStrings(template)
|
|
68
|
-
// The function uses the indentation of the first line as the baseline
|
|
69
|
-
// Leading newline should be removed
|
|
70
|
-
expect(result.raw[0]).toBe("spaces here\n more spaces\n less spaces\n most spaces")
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test("removes escaped newlines", () => {
|
|
74
|
-
const template = createTemplateArray(["first line\\\nsecond line\\\nthird line"])
|
|
75
|
-
const result = fixTemplateStrings(template)
|
|
76
|
-
expect(result.raw[0]).toBe("first linesecond linethird line")
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test("handles multiple segments with indentation", () => {
|
|
80
|
-
const template = createTemplateArray([
|
|
81
|
-
`
|
|
82
|
-
first \${`,
|
|
83
|
-
`}
|
|
84
|
-
second \${`,
|
|
85
|
-
`}
|
|
86
|
-
third
|
|
87
|
-
`,
|
|
88
|
-
])
|
|
89
|
-
|
|
90
|
-
const result = fixTemplateStrings(template)
|
|
91
|
-
// Leading newline should be removed in first segment only
|
|
92
|
-
expect(result.raw).toEqual([
|
|
93
|
-
"first ${",
|
|
94
|
-
"}\nsecond ${",
|
|
95
|
-
"}\nthird",
|
|
96
|
-
])
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
describe("templateTag with indentation", () => {
|
|
101
|
-
test("basic template with substitution", () => {
|
|
102
|
-
const result = templateTag`Hello ${"world"}!`
|
|
103
|
-
expect(result).toBe("Hello world!")
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
test("multiline template with indentation", () => {
|
|
107
|
-
const result = templateTag`
|
|
108
|
-
This is a multiline
|
|
109
|
-
string with proper indentation
|
|
110
|
-
`
|
|
111
|
-
// Leading newline should be removed
|
|
112
|
-
expect(result).toBe("This is a multiline\nstring with proper indentation")
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test("template with multiline substitution without indentation", () => {
|
|
116
|
-
const multilineValue = "line1\nline2\nline3"
|
|
117
|
-
const result = templateTag`Value: ${multilineValue}`
|
|
118
|
-
// The substitution doesn't get indentation because there's no preceding newline
|
|
119
|
-
expect(result).toBe("Value: line1\nline2\nline3")
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
test("template with multiline substitution with indentation", () => {
|
|
123
|
-
const multilineValue = "line1\nline2\nline3"
|
|
124
|
-
const result = templateTag`
|
|
125
|
-
Values:
|
|
126
|
-
${multilineValue}
|
|
127
|
-
End of values
|
|
128
|
-
`
|
|
129
|
-
// The substitution should get the indentation from before the ${}
|
|
130
|
-
// Leading newline should be removed
|
|
131
|
-
expect(result).toBe("Values:\n line1\n line2\n line3\nEnd of values")
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
test("nested indentation with multiline values", () => {
|
|
135
|
-
const codeBlock = "function example() {\n console.log('test');\n}"
|
|
136
|
-
const result = templateTag`
|
|
137
|
-
Here is some code:
|
|
138
|
-
${codeBlock}
|
|
139
|
-
End of code
|
|
140
|
-
`
|
|
141
|
-
// The function should preserve the internal indentation of the code block
|
|
142
|
-
// Leading newline should be removed
|
|
143
|
-
expect(result).toBe("Here is some code:\n function example() {\n console.log('test');\n }\nEnd of code")
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
test("mixed indentation with tabs and spaces", () => {
|
|
147
|
-
const tabIndentedValue = "line1\n\tline2\n\t\tline3"
|
|
148
|
-
const result = templateTag`
|
|
149
|
-
Tab indented:
|
|
150
|
-
${tabIndentedValue}
|
|
151
|
-
End
|
|
152
|
-
`
|
|
153
|
-
// Space indentation should be applied to all lines including those with tabs
|
|
154
|
-
// Leading newline should be removed
|
|
155
|
-
expect(result).toBe("Tab indented:\n line1\n \tline2\n \t\tline3\nEnd")
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
test("numbered list with indented content", () => {
|
|
159
|
-
const listItems = "1\n2\n3"
|
|
160
|
-
const result = templateTag`
|
|
161
|
-
1. Part one:
|
|
162
|
-
${listItems}
|
|
163
|
-
2. Part two
|
|
164
|
-
`
|
|
165
|
-
// This is specifically testing the case mentioned by the user
|
|
166
|
-
// Leading newline should be removed
|
|
167
|
-
expect(result).toBe("1. Part one:\n 1\n 2\n 3\n2. Part two")
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
test("complex nested structures", () => {
|
|
171
|
-
const jsonData = `{
|
|
172
|
-
"name": "example",
|
|
173
|
-
"values": [1, 2, 3]
|
|
174
|
-
}`
|
|
175
|
-
const code = `function test() {
|
|
176
|
-
if (condition) {
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
return false;
|
|
180
|
-
}`
|
|
181
|
-
|
|
182
|
-
const result = templateTag`
|
|
183
|
-
JSON data:
|
|
184
|
-
${jsonData}
|
|
185
|
-
|
|
186
|
-
Code:
|
|
187
|
-
${code}
|
|
188
|
-
|
|
189
|
-
End of examples
|
|
190
|
-
`
|
|
191
|
-
|
|
192
|
-
// The code gets additional indentation due to the spacing before the interpolation
|
|
193
|
-
// Leading newline should be removed
|
|
194
|
-
expect(result).toBe(`JSON data:
|
|
195
|
-
{
|
|
196
|
-
"name": "example",
|
|
197
|
-
"values": [1, 2, 3]
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
Code:
|
|
201
|
-
function test() {
|
|
202
|
-
if (condition) {
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
End of examples`)
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
test("preserves indentation within code blocks", () => {
|
|
212
|
-
const code = `if (true) {
|
|
213
|
-
console.log("indented");
|
|
214
|
-
console.log("double indented");
|
|
215
|
-
}`
|
|
216
|
-
|
|
217
|
-
const result = templateTag`
|
|
218
|
-
Code example:
|
|
219
|
-
${code}
|
|
220
|
-
End
|
|
221
|
-
`
|
|
222
|
-
|
|
223
|
-
// The indentation is applied to each line based on the template's indentation
|
|
224
|
-
// Leading newline should be removed
|
|
225
|
-
expect(result).toBe(`Code example:
|
|
226
|
-
if (true) {
|
|
227
|
-
console.log("indented");
|
|
228
|
-
console.log("double indented");
|
|
229
|
-
}
|
|
230
|
-
End`)
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
test("handles empty lines in substitutions", () => {
|
|
234
|
-
const textWithEmptyLines = "line1\n\nline3"
|
|
235
|
-
|
|
236
|
-
const result = templateTag`
|
|
237
|
-
Text:
|
|
238
|
-
${textWithEmptyLines}
|
|
239
|
-
End
|
|
240
|
-
`
|
|
241
|
-
|
|
242
|
-
// Empty lines also get indentation
|
|
243
|
-
// Leading newline should be removed
|
|
244
|
-
expect(result).toBe(`Text:
|
|
245
|
-
line1
|
|
246
|
-
|
|
247
|
-
line3
|
|
248
|
-
End`)
|
|
249
|
-
})
|
|
250
|
-
})
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const INDENTATION_RE = /^\n([ \t]+)/
|
|
2
|
-
const ESCAPE_SEQ_RE = /\\([`${\\]|\n)/g
|
|
3
|
-
const LAST_INDENTATION_RE = /\n[ \t]+$/
|
|
4
|
-
|
|
5
|
-
export function fixTemplateStrings(template: TemplateStringsArray): { readonly raw: readonly string[] } {
|
|
6
|
-
const firstSegment = template.raw[0]!
|
|
7
|
-
const leadingIndentMatch = INDENTATION_RE.exec(firstSegment)
|
|
8
|
-
const indentation = leadingIndentMatch?.[1]
|
|
9
|
-
|
|
10
|
-
const rawLength = template.raw.length
|
|
11
|
-
const result = new Array(rawLength)
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < rawLength; i++) {
|
|
14
|
-
let str = template.raw[i]!
|
|
15
|
-
// Only perform common indentation replacements if needed
|
|
16
|
-
if (indentation) {
|
|
17
|
-
// Remove leading newline and indentation in the first segment
|
|
18
|
-
if (i === 0) {
|
|
19
|
-
str = str.slice(indentation.length + 1)
|
|
20
|
-
}
|
|
21
|
-
// Use a simple string replacement with a regular expression for better performance
|
|
22
|
-
str = str.replaceAll(`\n${indentation}`, "\n")
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Replace common escape sequences in a single pass
|
|
26
|
-
str = str.replace(ESCAPE_SEQ_RE, (_match, char) => {
|
|
27
|
-
// Keep the escaped newline replacement separate for clarity
|
|
28
|
-
return char === "\n" ? "" : char
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// Handle trailing spaces only for the last segment
|
|
32
|
-
if (indentation && i === rawLength - 1) {
|
|
33
|
-
str = str.replace(LAST_INDENTATION_RE, "")
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
result[i] = str
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return { raw: result }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const LEADING_SPACE_RE = /^([ \t]*)/
|
|
43
|
-
/**
|
|
44
|
-
* Applies template string indentation to substituted values with line breaks
|
|
45
|
-
*
|
|
46
|
-
* @param strings - The template strings array (processed through fixTemplateStrings)
|
|
47
|
-
* @param values - The substitution values
|
|
48
|
-
* @returns - The formatted string with properly indented substitutions
|
|
49
|
-
*/
|
|
50
|
-
export function applyTemplateWithIndentation(strings: TemplateStringsArray, ...values: any[]): string {
|
|
51
|
-
const fixedStrings = fixTemplateStrings(strings)
|
|
52
|
-
const rawArr = fixedStrings.raw
|
|
53
|
-
const valuesLength = values.length
|
|
54
|
-
|
|
55
|
-
const resultParts = new Array(Math.max(1, rawArr.length * 2 - 1))
|
|
56
|
-
let resultIndex = 0
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < rawArr.length; i++) {
|
|
59
|
-
const str = rawArr[i] || ""
|
|
60
|
-
resultParts[resultIndex++] = str
|
|
61
|
-
|
|
62
|
-
// Only process values for non-final segments
|
|
63
|
-
if (i < valuesLength) {
|
|
64
|
-
const value = String(values[i])
|
|
65
|
-
|
|
66
|
-
// If value has line breaks, we should indent it
|
|
67
|
-
if (value.includes("\n")) {
|
|
68
|
-
const lastNewlineIndex = str.lastIndexOf("\n")
|
|
69
|
-
|
|
70
|
-
if (lastNewlineIndex !== -1) {
|
|
71
|
-
// Extract the indentation after the last newline
|
|
72
|
-
const textAfterLastNewline = str.substring(lastNewlineIndex + 1)
|
|
73
|
-
const leadingSpaceMatch = LEADING_SPACE_RE.exec(textAfterLastNewline)
|
|
74
|
-
const indentationToApply = leadingSpaceMatch && leadingSpaceMatch[1] ? leadingSpaceMatch[1] : ""
|
|
75
|
-
|
|
76
|
-
if (indentationToApply) {
|
|
77
|
-
// Split the value into lines once
|
|
78
|
-
const lines = value.split("\n")
|
|
79
|
-
const linesLength = lines.length
|
|
80
|
-
|
|
81
|
-
// First line doesn't need indentation
|
|
82
|
-
resultParts[resultIndex++] = lines[0]
|
|
83
|
-
|
|
84
|
-
// Apply indentation to subsequent lines
|
|
85
|
-
for (let j = 1; j < linesLength; j++) {
|
|
86
|
-
resultParts[resultIndex++] = "\n" + indentationToApply + lines[j]
|
|
87
|
-
}
|
|
88
|
-
continue
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// For simple values or when no indentation is needed
|
|
93
|
-
resultParts[resultIndex++] = value
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Combine all parts at once
|
|
98
|
-
return resultParts.slice(0, resultIndex).join("")
|
|
99
|
-
}
|
package/util/isAsyncIterator.ts
DELETED
package/util/isIterator.ts
DELETED
package/util/isJSONValue.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { JSONValue } from "./JSONValue.ts"
|
|
2
|
-
|
|
3
|
-
export function isJSONValue(value: unknown): value is JSONValue {
|
|
4
|
-
if (value === null) {
|
|
5
|
-
return true
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (Array.isArray(value)) {
|
|
9
|
-
return value.every((item) => isJSONValue(item))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (typeof value === "object") {
|
|
13
|
-
if (value === null) {
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
return Object.values(value).every((v) => isJSONValue(v))
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
20
|
-
}
|
package/util/isPropertyKey.ts
DELETED
package/util/jsonEquals.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { JSONValue } from "./JSONValue"
|
|
2
|
-
|
|
3
|
-
export function jsonEquals(actual: JSONValue, expected: JSONValue): boolean {
|
|
4
|
-
if (actual === expected) {
|
|
5
|
-
return true
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (typeof actual !== typeof expected) {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (actual === null || expected === null) {
|
|
13
|
-
return actual === expected
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (Array.isArray(actual)) {
|
|
17
|
-
if (!Array.isArray(expected)) {
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
if (actual.length !== expected.length) {
|
|
21
|
-
return false
|
|
22
|
-
}
|
|
23
|
-
return actual.every((e, i) => jsonEquals(e, expected[i]!))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (typeof actual === "object") {
|
|
27
|
-
if (typeof expected !== "object" || Array.isArray(expected)) {
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
30
|
-
const keys = Object.keys(actual)
|
|
31
|
-
if (keys.length !== Object.keys(expected).length) {
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
return keys.every((key) =>
|
|
35
|
-
Object.prototype.hasOwnProperty.call(expected, key)
|
|
36
|
-
&& jsonEquals(actual[key]!, expected[key]!)
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return actual === expected
|
|
41
|
-
}
|
package/util/nullaryMemo.ts
DELETED
package/util/peekLast.ts
DELETED
package/util/unimplemented.ts
DELETED
package/util/unreachable.ts
DELETED