liminal 0.4.0 → 0.5.1
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/Action.ts +29 -0
- package/Actor.ts +20 -0
- package/CHANGELOG.md +14 -0
- package/Exec.ts +63 -0
- package/L.ts +27 -0
- package/LiminalAssertionError.ts +3 -0
- package/LiminalConfig.ts +7 -0
- package/Message.ts +94 -0
- package/Model.ts +20 -0
- package/PathLike.ts +19 -0
- package/Scope.ts +133 -0
- package/Spec.ts +29 -0
- package/Tool.ts +58 -0
- package/_.ts +11 -0
- package/actions/abort.ts +23 -0
- package/actions/actions_common/updateModels.ts +23 -0
- package/actions/actions_derived/__snapshots__/declareModel.test.ts.snap +89 -0
- package/actions/actions_derived/clear.ts +6 -0
- package/actions/actions_derived/declareModel.test.ts +33 -0
- package/actions/actions_derived/declareModel.ts +9 -0
- package/actions/actions_derived/declareModel.type-test.ts +70 -0
- package/actions/actions_derived/getMessages.ts +9 -0
- package/actions/actions_derived/messages.test.ts +88 -0
- package/actions/actions_derived/messages.ts +19 -0
- package/actions/actions_derived/metatype.ts +9 -0
- package/actions/appendMessage.ts +30 -0
- package/actions/await.ts +13 -0
- package/actions/branch.ts +108 -0
- package/actions/catch.ts +42 -0
- package/actions/declareArg.ts +14 -0
- package/actions/disableTool.ts +26 -0
- package/actions/embed.ts +28 -0
- package/actions/emit.ts +21 -0
- package/actions/enableTool.ts +75 -0
- package/actions/enableTool.type-test.ts +118 -0
- package/actions/getScope.ts +11 -0
- package/actions/getSignal.ts +10 -0
- package/actions/getTools.ts +11 -0
- package/actions/infer.ts +37 -0
- package/actions/pushModel.ts +32 -0
- package/actions/removeMessage.ts +22 -0
- package/actions/removeModel.ts +31 -0
- package/actions/setMessages.ts +66 -0
- package/actions/throw.ts +18 -0
- package/cli/WriteHandler.ts +35 -0
- package/cli/cli_common.ts +3 -0
- package/cli/main.ts +19 -0
- package/cli/runExec.ts +68 -0
- package/dist/Action.d.ts +15 -0
- package/dist/Action.js +13 -0
- package/dist/Action.js.map +1 -0
- package/dist/Actor.d.ts +14 -0
- package/dist/Actor.js +2 -0
- package/dist/Actor.js.map +1 -0
- package/dist/Exec.d.ts +27 -0
- package/dist/Exec.js +22 -0
- package/dist/Exec.js.map +1 -0
- package/dist/L.d.ts +26 -0
- package/dist/L.js +27 -0
- package/dist/L.js.map +1 -0
- package/dist/LiminalAssertionError.d.ts +3 -0
- package/dist/LiminalAssertionError.js +4 -0
- package/dist/LiminalAssertionError.js.map +1 -0
- package/dist/LiminalConfig.d.ts +6 -0
- package/dist/LiminalConfig.js +2 -0
- package/dist/LiminalConfig.js.map +1 -0
- package/dist/Message.d.ts +82 -0
- package/dist/Message.js +2 -0
- package/dist/Message.js.map +1 -0
- package/dist/Model.d.ts +16 -0
- package/dist/Model.js +2 -0
- package/dist/Model.js.map +1 -0
- package/dist/PathLike.d.ts +14 -0
- package/dist/PathLike.js +2 -0
- package/dist/PathLike.js.map +1 -0
- package/dist/Scope.d.ts +36 -0
- package/dist/Scope.js +90 -0
- package/dist/Scope.js.map +1 -0
- package/dist/Spec.d.ts +20 -0
- package/dist/Spec.js +2 -0
- package/dist/Spec.js.map +1 -0
- package/dist/Tool.d.ts +21 -0
- package/dist/Tool.js +32 -0
- package/dist/Tool.js.map +1 -0
- package/dist/_.d.ts +5 -0
- package/dist/_.js +7 -0
- package/dist/_.js.map +1 -0
- package/dist/actions/abort.d.ts +9 -0
- package/dist/actions/abort.js +15 -0
- package/dist/actions/abort.js.map +1 -0
- package/dist/actions/actions_common/updateModels.d.ts +3 -0
- package/dist/actions/actions_common/updateModels.js +17 -0
- package/dist/actions/actions_common/updateModels.js.map +1 -0
- package/dist/actions/actions_derived/clear.d.ts +8 -0
- package/dist/actions/actions_derived/clear.js +5 -0
- package/dist/actions/actions_derived/clear.js.map +1 -0
- package/dist/actions/actions_derived/declareModel.d.ts +5 -0
- package/dist/actions/actions_derived/declareModel.js +7 -0
- package/dist/actions/actions_derived/declareModel.js.map +1 -0
- package/dist/actions/actions_derived/declareModel.test.d.ts +1 -0
- package/dist/actions/actions_derived/declareModel.test.js +32 -0
- package/dist/actions/actions_derived/declareModel.test.js.map +1 -0
- package/dist/actions/actions_derived/declareModel.type-test.d.ts +1 -0
- package/dist/actions/actions_derived/declareModel.type-test.js +66 -0
- package/dist/actions/actions_derived/declareModel.type-test.js.map +1 -0
- package/dist/actions/actions_derived/getMessages.d.ts +3 -0
- package/dist/actions/actions_derived/getMessages.js +8 -0
- package/dist/actions/actions_derived/getMessages.js.map +1 -0
- package/dist/actions/actions_derived/messages.d.ts +6 -0
- package/dist/actions/actions_derived/messages.js +15 -0
- package/dist/actions/actions_derived/messages.js.map +1 -0
- package/dist/actions/actions_derived/messages.test.d.ts +1 -0
- package/dist/actions/actions_derived/messages.test.js +72 -0
- package/dist/actions/actions_derived/messages.test.js.map +1 -0
- package/dist/actions/actions_derived/metatype.d.ts +9 -0
- package/dist/actions/actions_derived/metatype.js +7 -0
- package/dist/actions/actions_derived/metatype.js.map +1 -0
- package/dist/actions/appendMessage.d.ts +10 -0
- package/dist/actions/appendMessage.js +20 -0
- package/dist/actions/appendMessage.js.map +1 -0
- package/dist/actions/await.d.ts +5 -0
- package/dist/actions/await.js +10 -0
- package/dist/actions/await.js.map +1 -0
- package/dist/actions/branch.d.ts +35 -0
- package/dist/actions/branch.js +40 -0
- package/dist/actions/branch.js.map +1 -0
- package/dist/actions/catch.d.ts +10 -0
- package/dist/actions/catch.js +27 -0
- package/dist/actions/catch.js.map +1 -0
- package/dist/actions/declareArg.d.ts +8 -0
- package/dist/actions/declareArg.js +10 -0
- package/dist/actions/declareArg.js.map +1 -0
- package/dist/actions/disableTool.d.ts +10 -0
- package/dist/actions/disableTool.js +17 -0
- package/dist/actions/disableTool.js.map +1 -0
- package/dist/actions/embed.d.ts +9 -0
- package/dist/actions/embed.js +23 -0
- package/dist/actions/embed.js.map +1 -0
- package/dist/actions/emit.d.ts +9 -0
- package/dist/actions/emit.js +14 -0
- package/dist/actions/emit.js.map +1 -0
- package/dist/actions/enableTool.d.ts +20 -0
- package/dist/actions/enableTool.js +26 -0
- package/dist/actions/enableTool.js.map +1 -0
- package/dist/actions/enableTool.type-test.d.ts +1 -0
- package/dist/actions/enableTool.type-test.js +30 -0
- package/dist/actions/enableTool.type-test.js.map +1 -0
- package/dist/actions/getScope.d.ts +5 -0
- package/dist/actions/getScope.js +8 -0
- package/dist/actions/getScope.js.map +1 -0
- package/dist/actions/getSignal.d.ts +4 -0
- package/dist/actions/getSignal.js +8 -0
- package/dist/actions/getSignal.js.map +1 -0
- package/dist/actions/getTools.d.ts +5 -0
- package/dist/actions/getTools.js +8 -0
- package/dist/actions/getTools.js.map +1 -0
- package/dist/actions/infer.d.ts +13 -0
- package/dist/actions/infer.js +21 -0
- package/dist/actions/infer.js.map +1 -0
- package/dist/actions/pushModel.d.ts +11 -0
- package/dist/actions/pushModel.js +21 -0
- package/dist/actions/pushModel.js.map +1 -0
- package/dist/actions/removeMessage.d.ts +9 -0
- package/dist/actions/removeMessage.js +17 -0
- package/dist/actions/removeMessage.js.map +1 -0
- package/dist/actions/removeModel.d.ts +10 -0
- package/dist/actions/removeModel.js +20 -0
- package/dist/actions/removeModel.js.map +1 -0
- package/dist/actions/setMessages.d.ts +16 -0
- package/dist/actions/setMessages.js +31 -0
- package/dist/actions/setMessages.js.map +1 -0
- package/dist/actions/throw.d.ts +9 -0
- package/dist/actions/throw.js +13 -0
- package/dist/actions/throw.js.map +1 -0
- package/dist/cli/WriteHandler.d.ts +9 -0
- package/dist/cli/WriteHandler.js +24 -0
- package/dist/cli/WriteHandler.js.map +1 -0
- package/dist/cli/cli_common.d.ts +3 -0
- package/dist/cli/cli_common.js +2 -0
- package/dist/cli/cli_common.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +15 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/runExec.d.ts +2 -0
- package/dist/cli/runExec.js +69 -0
- package/dist/cli/runExec.js.map +1 -0
- package/dist/events/Aborted.d.ts +4 -0
- package/dist/events/Aborted.js +2 -0
- package/dist/events/Aborted.js.map +1 -0
- package/dist/events/Embedded.d.ts +5 -0
- package/dist/events/Embedded.js +2 -0
- package/dist/events/Embedded.js.map +1 -0
- package/dist/events/EmbeddingRequested.d.ts +4 -0
- package/dist/events/EmbeddingRequested.js +2 -0
- package/dist/events/EmbeddingRequested.js.map +1 -0
- package/dist/events/Emitted.d.ts +4 -0
- package/dist/events/Emitted.js +2 -0
- package/dist/events/Emitted.js.map +1 -0
- package/dist/events/EventBase.d.ts +3 -0
- package/dist/events/EventBase.js +2 -0
- package/dist/events/EventBase.js.map +1 -0
- package/dist/events/EventHandler.d.ts +2 -0
- package/dist/events/EventHandler.js +2 -0
- package/dist/events/EventHandler.js.map +1 -0
- package/dist/events/EventResolved.d.ts +19 -0
- package/dist/events/EventResolved.js +2 -0
- package/dist/events/EventResolved.js.map +1 -0
- package/dist/events/Forked.d.ts +3 -0
- package/dist/events/Forked.js +2 -0
- package/dist/events/Forked.js.map +1 -0
- package/dist/events/InferenceRequested.d.ts +3 -0
- package/dist/events/InferenceRequested.js +2 -0
- package/dist/events/InferenceRequested.js.map +1 -0
- package/dist/events/Inferred.d.ts +5 -0
- package/dist/events/Inferred.js +2 -0
- package/dist/events/Inferred.js.map +1 -0
- package/dist/events/LEvent.d.ts +18 -0
- package/dist/events/LEvent.js +2 -0
- package/dist/events/LEvent.js.map +1 -0
- package/dist/events/MessageAppended.d.ts +5 -0
- package/dist/events/MessageAppended.js +2 -0
- package/dist/events/MessageAppended.js.map +1 -0
- package/dist/events/MessageRemoved.d.ts +5 -0
- package/dist/events/MessageRemoved.js +2 -0
- package/dist/events/MessageRemoved.js.map +1 -0
- package/dist/events/MessagesSet.d.ts +5 -0
- package/dist/events/MessagesSet.js +2 -0
- package/dist/events/MessagesSet.js.map +1 -0
- package/dist/events/ModelPushed.d.ts +7 -0
- package/dist/events/ModelPushed.js +2 -0
- package/dist/events/ModelPushed.js.map +1 -0
- package/dist/events/ModelRemoved.d.ts +7 -0
- package/dist/events/ModelRemoved.js +2 -0
- package/dist/events/ModelRemoved.js.map +1 -0
- package/dist/events/Returned.d.ts +4 -0
- package/dist/events/Returned.js +2 -0
- package/dist/events/Returned.js.map +1 -0
- package/dist/events/Threw.d.ts +4 -0
- package/dist/events/Threw.js +2 -0
- package/dist/events/Threw.js.map +1 -0
- package/dist/events/ToolCalled.d.ts +6 -0
- package/dist/events/ToolCalled.js +2 -0
- package/dist/events/ToolCalled.js.map +1 -0
- package/dist/events/ToolDisabled.d.ts +5 -0
- package/dist/events/ToolDisabled.js +2 -0
- package/dist/events/ToolDisabled.js.map +1 -0
- package/dist/events/ToolEnabled.d.ts +7 -0
- package/dist/events/ToolEnabled.js +2 -0
- package/dist/events/ToolEnabled.js.map +1 -0
- package/dist/events/isScopeChildEvent.d.ts +6 -0
- package/dist/events/isScopeChildEvent.js +9 -0
- package/dist/events/isScopeChildEvent.js.map +1 -0
- package/dist/events/isScopeDescendantEvent.d.ts +14 -0
- package/dist/events/isScopeDescendantEvent.js +12 -0
- package/dist/events/isScopeDescendantEvent.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/testing/ActorAssertions.d.ts +9 -0
- package/dist/testing/ActorAssertions.js +6 -0
- package/dist/testing/ActorAssertions.js.map +1 -0
- package/dist/testing/TestEmbeddingModel.d.ts +6 -0
- package/dist/testing/TestEmbeddingModel.js +10 -0
- package/dist/testing/TestEmbeddingModel.js.map +1 -0
- package/dist/testing/TestLanguageModel.d.ts +8 -0
- package/dist/testing/TestLanguageModel.js +21 -0
- package/dist/testing/TestLanguageModel.js.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/takeFirstAction.d.ts +3 -0
- package/dist/testing/takeFirstAction.js +6 -0
- package/dist/testing/takeFirstAction.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/AssertDiagnostics.d.ts +18 -0
- package/dist/types/AssertDiagnostics.js +152 -0
- package/dist/types/AssertDiagnostics.js.map +1 -0
- package/dist/types/JSONRootType.d.ts +6 -0
- package/dist/types/JSONRootType.js +2 -0
- package/dist/types/JSONRootType.js.map +1 -0
- package/dist/types/JSONType.d.ts +16 -0
- package/dist/types/JSONType.js +2 -0
- package/dist/types/JSONType.js.map +1 -0
- package/dist/types/JSONTypeBase.d.ts +3 -0
- package/dist/types/JSONTypeBase.js +2 -0
- package/dist/types/JSONTypeBase.js.map +1 -0
- package/dist/types/Metatype/MetatypeDescriptor.d.ts +41 -0
- package/dist/types/Metatype/MetatypeDescriptor.js +38 -0
- package/dist/types/Metatype/MetatypeDescriptor.js.map +1 -0
- package/dist/types/Metatype/fromMetatypeDescriptor.d.ts +6 -0
- package/dist/types/Metatype/fromMetatypeDescriptor.js +43 -0
- package/dist/types/Metatype/fromMetatypeDescriptor.js.map +1 -0
- package/dist/types/Type.d.ts +30 -0
- package/dist/types/Type.js +5 -0
- package/dist/types/Type.js.map +1 -0
- package/dist/types/TypeContext.d.ts +7 -0
- package/dist/types/TypeContext.js +17 -0
- package/dist/types/TypeContext.js.map +1 -0
- package/dist/types/TypeLike.d.ts +23 -0
- package/dist/types/TypeLike.js +23 -0
- package/dist/types/TypeLike.js.map +1 -0
- package/dist/types/TypeVisitor.d.ts +14 -0
- package/dist/types/TypeVisitor.js +12 -0
- package/dist/types/TypeVisitor.js.map +1 -0
- package/dist/types/array.d.ts +10 -0
- package/dist/types/array.js +9 -0
- package/dist/types/array.js.map +1 -0
- package/dist/types/boolean.d.ts +6 -0
- package/dist/types/boolean.js +3 -0
- package/dist/types/boolean.js.map +1 -0
- package/dist/types/const.d.ts +8 -0
- package/dist/types/const.js +7 -0
- package/dist/types/const.js.map +1 -0
- package/dist/types/declareType.d.ts +2 -0
- package/dist/types/declareType.js +57 -0
- package/dist/types/declareType.js.map +1 -0
- package/dist/types/enum.d.ts +8 -0
- package/dist/types/enum.js +7 -0
- package/dist/types/enum.js.map +1 -0
- package/dist/types/factories.d.ts +8 -0
- package/dist/types/factories.js +9 -0
- package/dist/types/factories.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/integer.d.ts +6 -0
- package/dist/types/integer.js +3 -0
- package/dist/types/integer.js.map +1 -0
- package/dist/types/intrinsics.d.ts +11 -0
- package/dist/types/intrinsics.js +12 -0
- package/dist/types/intrinsics.js.map +1 -0
- package/dist/types/match.d.ts +3 -0
- package/dist/types/match.js +11 -0
- package/dist/types/match.js.map +1 -0
- package/dist/types/non_factories.d.ts +21 -0
- package/dist/types/non_factories.js +9 -0
- package/dist/types/non_factories.js.map +1 -0
- package/dist/types/null.d.ts +7 -0
- package/dist/types/null.js +4 -0
- package/dist/types/null.js.map +1 -0
- package/dist/types/number.d.ts +6 -0
- package/dist/types/number.js +3 -0
- package/dist/types/number.js.map +1 -0
- package/dist/types/object.d.ts +16 -0
- package/dist/types/object.js +10 -0
- package/dist/types/object.js.map +1 -0
- package/dist/types/ref.d.ts +7 -0
- package/dist/types/ref.js +5 -0
- package/dist/types/ref.js.map +1 -0
- package/dist/types/string.d.ts +6 -0
- package/dist/types/string.js +3 -0
- package/dist/types/string.js.map +1 -0
- package/dist/types/toJSON.d.ts +5 -0
- package/dist/types/toJSON.js +97 -0
- package/dist/types/toJSON.js.map +1 -0
- package/dist/types/type_common.d.ts +10 -0
- package/dist/types/type_common.js +12 -0
- package/dist/types/type_common.js.map +1 -0
- package/dist/types/types_derived/option.d.ts +5 -0
- package/dist/types/types_derived/option.js +6 -0
- package/dist/types/types_derived/option.js.map +1 -0
- package/dist/types/types_derived/taggedUnion.d.ts +19 -0
- package/dist/types/types_derived/taggedUnion.js +8 -0
- package/dist/types/types_derived/taggedUnion.js.map +1 -0
- package/dist/types/types_derived/wrapper.d.ts +8 -0
- package/dist/types/types_derived/wrapper.js +5 -0
- package/dist/types/types_derived/wrapper.js.map +1 -0
- package/dist/types/union.d.ts +9 -0
- package/dist/types/union.js +9 -0
- package/dist/types/union.js.map +1 -0
- package/dist/util/ArrayOfLength.d.ts +1 -0
- package/dist/util/ArrayOfLength.js +2 -0
- package/dist/util/ArrayOfLength.js.map +1 -0
- package/dist/util/DeferredOr.d.ts +1 -0
- package/dist/util/DeferredOr.js +2 -0
- package/dist/util/DeferredOr.js.map +1 -0
- package/dist/util/EnsureNarrow.d.ts +2 -0
- package/dist/util/EnsureNarrow.js +2 -0
- package/dist/util/EnsureNarrow.js.map +1 -0
- package/dist/util/EnsureRecord.d.ts +2 -0
- package/dist/util/EnsureRecord.js +2 -0
- package/dist/util/EnsureRecord.js.map +1 -0
- package/dist/util/Expand.d.ts +3 -0
- package/dist/util/Expand.js +2 -0
- package/dist/util/Expand.js.map +1 -0
- package/dist/util/Falsy.d.ts +1 -0
- package/dist/util/Falsy.js +2 -0
- package/dist/util/Falsy.js.map +1 -0
- package/dist/util/FromEntries.d.ts +3 -0
- package/dist/util/FromEntries.js +2 -0
- package/dist/util/FromEntries.js.map +1 -0
- package/dist/util/IteratorLike.d.ts +1 -0
- package/dist/util/IteratorLike.js +2 -0
- package/dist/util/IteratorLike.js.map +1 -0
- package/dist/util/JSONEntry.d.ts +2 -0
- package/dist/util/JSONEntry.js +2 -0
- package/dist/util/JSONEntry.js.map +1 -0
- package/dist/util/JSONKey.d.ts +1 -0
- package/dist/util/JSONKey.js +2 -0
- package/dist/util/JSONKey.js.map +1 -0
- package/dist/util/JSONObject.d.ts +5 -0
- package/dist/util/JSONObject.js +2 -0
- package/dist/util/JSONObject.js.map +1 -0
- package/dist/util/JSONSchemaMemo.d.ts +2 -0
- package/dist/util/JSONSchemaMemo.js +13 -0
- package/dist/util/JSONSchemaMemo.js.map +1 -0
- package/dist/util/JSONValue.d.ts +2 -0
- package/dist/util/JSONValue.js +2 -0
- package/dist/util/JSONValue.js.map +1 -0
- package/dist/util/PromiseOr.d.ts +1 -0
- package/dist/util/PromiseOr.js +2 -0
- package/dist/util/PromiseOr.js.map +1 -0
- package/dist/util/Result.d.ts +7 -0
- package/dist/util/Result.js +2 -0
- package/dist/util/Result.js.map +1 -0
- package/dist/util/Taggable.d.ts +9 -0
- package/dist/util/Taggable.js +8 -0
- package/dist/util/Taggable.js.map +1 -0
- package/dist/util/TupleToRecord.d.ts +5 -0
- package/dist/util/TupleToRecord.js +2 -0
- package/dist/util/TupleToRecord.js.map +1 -0
- package/dist/util/assert.d.ts +1 -0
- package/dist/util/assert.js +7 -0
- package/dist/util/assert.js.map +1 -0
- package/dist/util/dedent.d.ts +1 -0
- package/dist/util/dedent.js +5 -0
- package/dist/util/dedent.js.map +1 -0
- package/dist/util/fixTemplateStrings.d.ts +11 -0
- package/dist/util/fixTemplateStrings.js +83 -0
- package/dist/util/fixTemplateStrings.js.map +1 -0
- package/dist/util/fixTemplateStrings.test.d.ts +1 -0
- package/dist/util/fixTemplateStrings.test.js +221 -0
- package/dist/util/fixTemplateStrings.test.js.map +1 -0
- package/dist/util/isAsyncIterator.d.ts +1 -0
- package/dist/util/isAsyncIterator.js +7 -0
- package/dist/util/isAsyncIterator.js.map +1 -0
- package/dist/util/isIterator.d.ts +1 -0
- package/dist/util/isIterator.js +7 -0
- package/dist/util/isIterator.js.map +1 -0
- package/dist/util/isJSONValue.d.ts +2 -0
- package/dist/util/isJSONValue.js +16 -0
- package/dist/util/isJSONValue.js.map +1 -0
- package/dist/util/isPropertyKey.d.ts +1 -0
- package/dist/util/isPropertyKey.js +4 -0
- package/dist/util/isPropertyKey.js.map +1 -0
- package/dist/util/isTemplateStringsArray.d.ts +1 -0
- package/dist/util/isTemplateStringsArray.js +4 -0
- package/dist/util/isTemplateStringsArray.js.map +1 -0
- package/dist/util/jsonEquals.d.ts +2 -0
- package/dist/util/jsonEquals.js +33 -0
- package/dist/util/jsonEquals.js.map +1 -0
- package/dist/util/nullaryMemo.d.ts +1 -0
- package/dist/util/nullaryMemo.js +12 -0
- package/dist/util/nullaryMemo.js.map +1 -0
- package/dist/util/unimplemented.d.ts +1 -0
- package/dist/util/unimplemented.js +5 -0
- package/dist/util/unimplemented.js.map +1 -0
- package/dist/util/unreachable.d.ts +1 -0
- package/dist/util/unreachable.js +5 -0
- package/dist/util/unreachable.js.map +1 -0
- package/dist/util/unwrapDeferred.d.ts +2 -0
- package/dist/util/unwrapDeferred.js +4 -0
- package/dist/util/unwrapDeferred.js.map +1 -0
- package/dist/util/util.d.ts +10 -0
- package/dist/util/util.js +11 -0
- package/dist/util/util.js.map +1 -0
- package/events/Aborted.ts +5 -0
- package/events/Embedded.ts +6 -0
- package/events/EmbeddingRequested.ts +5 -0
- package/events/Emitted.ts +5 -0
- package/events/EventBase.ts +3 -0
- package/events/EventHandler.ts +3 -0
- package/events/EventResolved.ts +30 -0
- package/events/Forked.ts +3 -0
- package/events/InferenceRequested.ts +3 -0
- package/events/Inferred.ts +6 -0
- package/events/LEvent.ts +36 -0
- package/events/MessageAppended.ts +6 -0
- package/events/MessageRemoved.ts +6 -0
- package/events/MessagesSet.ts +6 -0
- package/events/ModelPushed.ts +10 -0
- package/events/ModelRemoved.ts +10 -0
- package/events/Returned.ts +5 -0
- package/events/Threw.ts +5 -0
- package/events/ToolCalled.ts +7 -0
- package/events/ToolDisabled.ts +6 -0
- package/events/ToolEnabled.ts +8 -0
- package/events/isScopeChildEvent.ts +15 -0
- package/events/isScopeDescendantEvent.ts +30 -0
- package/index.ts +41 -0
- package/package.json +28 -19
- package/testing/ActorAssertions.ts +19 -0
- package/testing/TestEmbeddingModel.ts +18 -0
- package/testing/TestLanguageModel.ts +32 -0
- package/testing/index.ts +4 -0
- package/testing/takeFirstAction.ts +8 -0
- package/tsconfig.json +4 -8
- package/types/AssertDiagnostics.ts +183 -0
- package/types/JSONRootType.ts +8 -0
- package/types/JSONType.ts +27 -0
- package/types/JSONTypeBase.ts +3 -0
- package/types/Metatype/MetatypeDescriptor.ts +80 -0
- package/types/Metatype/fromMetatypeDescriptor.ts +52 -0
- package/types/Type.ts +46 -0
- package/types/TypeContext.ts +19 -0
- package/types/TypeLike.ts +60 -0
- package/types/TypeVisitor.ts +49 -0
- package/types/array.ts +20 -0
- package/types/boolean.ts +9 -0
- package/types/const.ts +17 -0
- package/types/declareType.ts +71 -0
- package/types/enum.ts +14 -0
- package/types/factories.ts +8 -0
- package/types/index.ts +2 -0
- package/types/integer.ts +9 -0
- package/types/intrinsics.ts +11 -0
- package/types/match.ts +13 -0
- package/types/non_factories.ts +26 -0
- package/types/null.ts +10 -0
- package/types/number.ts +9 -0
- package/types/object.ts +27 -0
- package/types/ref.ts +12 -0
- package/types/string.ts +9 -0
- package/types/toJSON.ts +111 -0
- package/types/type_common.ts +21 -0
- package/types/types_derived/option.ts +10 -0
- package/types/types_derived/taggedUnion.ts +30 -0
- package/types/types_derived/wrapper.ts +10 -0
- package/types/union.ts +19 -0
- package/util/ArrayOfLength.ts +5 -0
- package/util/DeferredOr.ts +1 -0
- package/util/EnsureNarrow.ts +5 -0
- package/util/EnsureRecord.ts +3 -0
- package/util/Expand.ts +1 -0
- package/util/Falsy.ts +1 -0
- package/util/FromEntries.ts +3 -0
- package/util/IteratorLike.ts +1 -0
- package/util/JSONEntry.ts +3 -0
- package/util/JSONKey.ts +1 -0
- package/util/JSONObject.ts +6 -0
- package/util/JSONSchemaMemo.ts +15 -0
- package/util/JSONValue.ts +3 -0
- package/util/PromiseOr.ts +1 -0
- package/util/Result.ts +7 -0
- package/util/Taggable.ts +18 -0
- package/util/TupleToRecord.ts +5 -0
- package/util/assert.ts +7 -0
- package/util/dedent.ts +5 -0
- package/util/fixTemplateStrings.test.ts +250 -0
- package/util/fixTemplateStrings.ts +99 -0
- package/util/isAsyncIterator.ts +6 -0
- package/util/isIterator.ts +6 -0
- package/util/isJSONValue.ts +20 -0
- package/util/isPropertyKey.ts +3 -0
- package/util/isTemplateStringsArray.ts +3 -0
- package/util/jsonEquals.ts +41 -0
- package/util/nullaryMemo.ts +11 -0
- package/util/unimplemented.ts +5 -0
- package/util/unreachable.ts +5 -0
- package/util/unwrapDeferred.ts +5 -0
- package/util/util.ts +10 -0
- package/LICENSE +0 -15
- package/README.md +0 -94
- package/jest.config.js +0 -4
- package/lib/array/array.d.ts +0 -6
- package/lib/array/array.js +0 -21
- package/lib/array/index.d.ts +0 -11
- package/lib/array/index.js +0 -17
- package/lib/composition/composition.d.ts +0 -6
- package/lib/composition/composition.js +0 -37
- package/lib/composition/index.d.ts +0 -9
- package/lib/composition/index.js +0 -13
- package/lib/composition/types.d.ts +0 -2
- package/lib/composition/types.js +0 -2
- package/lib/dispatch/getType.d.ts +0 -2
- package/lib/dispatch/getType.js +0 -15
- package/lib/dispatch/identity.d.ts +0 -2
- package/lib/dispatch/identity.js +0 -4
- package/lib/dispatch/index.d.ts +0 -22
- package/lib/dispatch/index.js +0 -13
- package/lib/dispatch/types.d.ts +0 -14
- package/lib/dispatch/types.js +0 -16
- package/lib/error/error.d.ts +0 -24
- package/lib/error/error.js +0 -25
- package/lib/error/index.d.ts +0 -2
- package/lib/error/index.js +0 -4
- package/lib/index.d.ts +0 -67
- package/lib/index.js +0 -19
- package/lib/multimethod/index.d.ts +0 -7
- package/lib/multimethod/index.js +0 -9
- package/lib/multimethod/multimethod.d.ts +0 -3
- package/lib/multimethod/multimethod.js +0 -101
- package/src/array/array.ts +0 -29
- package/src/array/index.ts +0 -12
- package/src/composition/composition.ts +0 -45
- package/src/composition/index.ts +0 -10
- package/src/composition/types.ts +0 -6
- package/src/dispatch/getType.ts +0 -17
- package/src/dispatch/identity.ts +0 -3
- package/src/dispatch/index.ts +0 -11
- package/src/dispatch/types.ts +0 -15
- package/src/error/error.ts +0 -26
- package/src/error/index.ts +0 -3
- package/src/index.ts +0 -15
- package/src/multimethod/index.ts +0 -8
- package/src/multimethod/multimethod.test.ts +0 -10
- package/src/multimethod/multimethod.ts +0 -148
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMessages.js","sourceRoot":"","sources":["../../../actions/actions_derived/getMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,SAAS,CAAC,CAAC,WAAW;IAC1B,OAAO,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,KAAK;QACR,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;KAC7B,CAAC,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AssistantContent, UserContent } from "../../Message.ts";
|
|
2
|
+
import { type TaggableArgs } from "../../util/Taggable.ts";
|
|
3
|
+
import { appendMessage } from "../appendMessage.ts";
|
|
4
|
+
export declare function user(...args: TaggableArgs<[content: UserContent]>): Generator<appendMessage<import("../../Message.ts").UserMessage>, Generator<import("../removeMessage.ts").removeMessage, void, any>, any>;
|
|
5
|
+
export declare function system(...args: TaggableArgs<[content: string]>): Generator<appendMessage<import("../../Message.ts").SystemMessage>, Generator<import("../removeMessage.ts").removeMessage, void, any>, any>;
|
|
6
|
+
export declare function assistant(...args: TaggableArgs<[content: AssistantContent]>): Generator<appendMessage<import("../../Message.ts").AssistantMessage>, Generator<import("../removeMessage.ts").removeMessage, void, any>, any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { normalizeTaggableArgs } from "../../util/Taggable.js";
|
|
2
|
+
import { appendMessage } from "../appendMessage.js";
|
|
3
|
+
export function user(...args) {
|
|
4
|
+
const [content] = normalizeTaggableArgs(...args);
|
|
5
|
+
return appendMessage("user", content);
|
|
6
|
+
}
|
|
7
|
+
export function system(...args) {
|
|
8
|
+
const [content] = normalizeTaggableArgs(...args);
|
|
9
|
+
return appendMessage("system", content);
|
|
10
|
+
}
|
|
11
|
+
export function assistant(...args) {
|
|
12
|
+
const [content] = normalizeTaggableArgs(...args);
|
|
13
|
+
return appendMessage("assistant", content);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../actions/actions_derived/messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAqB,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,UAAU,IAAI,CAAC,GAAG,IAA0C;IAChE,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAG,IAAqC;IAC7D,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAG,IAA+C;IAC1E,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// import { describe, expect, test } from "bun:test"
|
|
2
|
+
// import * as L from "../L.ts"
|
|
3
|
+
// import { takeFirstAction } from "../testing/takeFirstAction.ts"
|
|
4
|
+
export {};
|
|
5
|
+
// describe("message templates", () => {
|
|
6
|
+
// test("system messages with indentation", async () => {
|
|
7
|
+
// // Create a system message with indented multiline content
|
|
8
|
+
// const messageGenerator = L.system`
|
|
9
|
+
// Hello, I am an AI assistant.
|
|
10
|
+
// I can help with the following:
|
|
11
|
+
// - Code generation
|
|
12
|
+
// - Answering questions
|
|
13
|
+
// - General assistance
|
|
14
|
+
// `
|
|
15
|
+
// const action = await takeFirstAction(messageGenerator)
|
|
16
|
+
// expect(action?.message.content).toBe(
|
|
17
|
+
// "Hello, I am an AI assistant.\nI can help with the following:\n - Code generation\n - Answering questions\n - General assistance",
|
|
18
|
+
// )
|
|
19
|
+
// })
|
|
20
|
+
// test("user messages with substitution", async () => {
|
|
21
|
+
// const name = "John"
|
|
22
|
+
// const messageGenerator = L.user`Hello, my name is ${name}.`
|
|
23
|
+
// const action = await takeFirstAction(messageGenerator)
|
|
24
|
+
// expect(action?.message.content).toBe("Hello, my name is John.")
|
|
25
|
+
// })
|
|
26
|
+
// test("user messages with multiline substitution and indentation", async () => {
|
|
27
|
+
// const codeBlock = "function example() {\n console.log('Hello');\n}"
|
|
28
|
+
// const messageGenerator = L.user`
|
|
29
|
+
// Here's my code:
|
|
30
|
+
// ${codeBlock}
|
|
31
|
+
// Can you help me understand it?
|
|
32
|
+
// `
|
|
33
|
+
// const action = await takeFirstAction(messageGenerator)
|
|
34
|
+
// // The code block should get indentation applied to lines after the first
|
|
35
|
+
// expect(action?.message.content).toBe(
|
|
36
|
+
// "Here's my code:\n function example() {\n console.log('Hello');\n }\nCan you help me understand it?",
|
|
37
|
+
// )
|
|
38
|
+
// })
|
|
39
|
+
// test("assistant messages with multiline substitution", async () => {
|
|
40
|
+
// const explanation =
|
|
41
|
+
// "1. First, we declare a function\n2. Then we log a message\n3. The function doesn't return anything"
|
|
42
|
+
// const messageGenerator = L.assistant`
|
|
43
|
+
// Let me explain:
|
|
44
|
+
// ${explanation}
|
|
45
|
+
// Does that help?
|
|
46
|
+
// `
|
|
47
|
+
// const action = await takeFirstAction(messageGenerator)
|
|
48
|
+
// // The explanation lines should get indentation
|
|
49
|
+
// expect(action?.message.content).toBe(
|
|
50
|
+
// "Let me explain:\n 1. First, we declare a function\n 2. Then we log a message\n 3. The function doesn't return anything\nDoes that help?",
|
|
51
|
+
// )
|
|
52
|
+
// })
|
|
53
|
+
// test("preserves code indentation", async () => {
|
|
54
|
+
// const code = `if (condition) {
|
|
55
|
+
// // This is indented once
|
|
56
|
+
// if (nestedCondition) {
|
|
57
|
+
// // This is indented twice
|
|
58
|
+
// }
|
|
59
|
+
// }`
|
|
60
|
+
// const messageGenerator = L.user`
|
|
61
|
+
// My code:
|
|
62
|
+
// ${code}
|
|
63
|
+
// `
|
|
64
|
+
// const action = await takeFirstAction(messageGenerator)
|
|
65
|
+
// // The code's internal indentation structure should be preserved
|
|
66
|
+
// // while getting additional indentation from the template
|
|
67
|
+
// expect(action?.message.content).toBe(
|
|
68
|
+
// "My code:\n if (condition) {\n // This is indented once\n if (nestedCondition) {\n // This is indented twice\n }\n }",
|
|
69
|
+
// )
|
|
70
|
+
// })
|
|
71
|
+
// })
|
|
72
|
+
//# sourceMappingURL=messages.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.test.js","sourceRoot":"","sources":["../../../actions/actions_derived/messages.test.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,+BAA+B;AAC/B,kEAAkE;;AAElE,wCAAwC;AACxC,2DAA2D;AAC3D,iEAAiE;AACjE,yCAAyC;AACzC,qCAAqC;AACrC,uCAAuC;AACvC,4BAA4B;AAC5B,gCAAgC;AAChC,+BAA+B;AAC/B,QAAQ;AAER,6DAA6D;AAE7D,4CAA4C;AAC5C,8IAA8I;AAC9I,QAAQ;AACR,OAAO;AAEP,0DAA0D;AAC1D,0BAA0B;AAC1B,kEAAkE;AAElE,6DAA6D;AAE7D,sEAAsE;AACtE,OAAO;AAEP,oFAAoF;AACpF,2EAA2E;AAE3E,uCAAuC;AACvC,wBAAwB;AACxB,uBAAuB;AACvB,uCAAuC;AACvC,QAAQ;AAER,6DAA6D;AAE7D,gFAAgF;AAChF,4CAA4C;AAC5C,mHAAmH;AACnH,QAAQ;AACR,OAAO;AAEP,yEAAyE;AACzE,0BAA0B;AAC1B,6GAA6G;AAE7G,4CAA4C;AAC5C,wBAAwB;AACxB,yBAAyB;AACzB,wBAAwB;AACxB,QAAQ;AAER,6DAA6D;AAE7D,sDAAsD;AACtD,4CAA4C;AAC5C,sJAAsJ;AACtJ,QAAQ;AACR,OAAO;AAEP,qDAAqD;AACrD,qCAAqC;AACrC,6BAA6B;AAC7B,2BAA2B;AAC3B,gCAAgC;AAChC,MAAM;AACN,KAAK;AAEL,uCAAuC;AACvC,iBAAiB;AACjB,kBAAkB;AAClB,QAAQ;AAER,6DAA6D;AAE7D,uEAAuE;AACvE,gEAAgE;AAChE,4CAA4C;AAC5C,+IAA+I;AAC/I,QAAQ;AACR,OAAO;AACP,KAAK"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Falsy } from "../../util/Falsy.ts";
|
|
2
|
+
import type { TaggableArgs } from "../../util/Taggable.ts";
|
|
3
|
+
export declare function metatype(...args: TaggableArgs<[...description: Array<string | Falsy>]>): Generator<import("../../Action.ts").Action<"infer", {
|
|
4
|
+
Event: import("../../index.ts").Inferred | import("../../index.ts").InferenceRequested;
|
|
5
|
+
Child: never;
|
|
6
|
+
Throw: never;
|
|
7
|
+
Entry: never;
|
|
8
|
+
Value: never;
|
|
9
|
+
}>, import("../../index.ts").Type<import("../../index.ts").JSONObject, import("../../index.ts").JSONObjectType<any>>, any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { fromMetatypeRootDescriptor } from "../../types/Metatype/fromMetatypeDescriptor.js";
|
|
2
|
+
import { MetatypeRootDescriptor } from "../../types/Metatype/MetatypeDescriptor.js";
|
|
3
|
+
export function* metatype(...args) {
|
|
4
|
+
const descriptor = yield* MetatypeRootDescriptor(args.map((e) => typeof e === "string").join("\n"));
|
|
5
|
+
return fromMetatypeRootDescriptor(descriptor);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=metatype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metatype.js","sourceRoot":"","sources":["../../../actions/actions_derived/metatype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AAInF,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,IAA2D;IACtF,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACnG,OAAO,0BAA0B,CAAC,UAAU,CAAC,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { MessageAppended } from "../events/MessageAppended.ts";
|
|
3
|
+
import type { Message, MessageContents, MessageRole, Messages } from "../Message.ts";
|
|
4
|
+
import type { Spec } from "../Spec.ts";
|
|
5
|
+
import { removeMessage } from "./removeMessage.ts";
|
|
6
|
+
export interface appendMessage<M extends Message> extends Action<"append_message", Spec.Make<{
|
|
7
|
+
Event: MessageAppended<M>;
|
|
8
|
+
}>> {
|
|
9
|
+
}
|
|
10
|
+
export declare function appendMessage<R extends MessageRole>(role: R, content: MessageContents[R]): Generator<appendMessage<Messages[R]>, Generator<removeMessage, void>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
import { removeMessage } from "./removeMessage.js";
|
|
3
|
+
export function* appendMessage(role, content) {
|
|
4
|
+
return yield Action("append_message", (scope) => {
|
|
5
|
+
const message = {
|
|
6
|
+
role,
|
|
7
|
+
content,
|
|
8
|
+
}; // <-- why isn't this inferred?
|
|
9
|
+
scope.event({
|
|
10
|
+
type: "message_appended",
|
|
11
|
+
message,
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
...scope,
|
|
15
|
+
nextArg: removeMessage(message),
|
|
16
|
+
messages: new Set([...scope.messages, message]),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=appendMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appendMessage.js","sourceRoot":"","sources":["../../actions/appendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMlD,MAAM,SAAS,CAAC,CAAC,aAAa,CAC5B,IAAO,EACP,OAA2B;IAE3B,OAAO,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG;YACd,IAAI;YACJ,OAAO;SACO,CAAA,CAAC,+BAA+B;QAChD,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,kBAAkB;YACxB,OAAO;SACR,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;YAC/B,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;SAChD,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
function* await_(value) {
|
|
3
|
+
return yield Action("await", async (scope) => ({
|
|
4
|
+
...scope,
|
|
5
|
+
nextArg: await value,
|
|
6
|
+
}));
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(await_, "name", { value: "await" });
|
|
9
|
+
export { await_ as await };
|
|
10
|
+
//# sourceMappingURL=await.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await.js","sourceRoot":"","sources":["../../actions/await.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,QAAQ,CAAC,CAAC,MAAM,CAAI,KAAQ;IAC1B,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7C,GAAG,KAAK;QACR,OAAO,EAAE,MAAM,KAAK;KACrB,CAAC,CAAC,CAAA;AACL,CAAC;AACD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;AAEzD,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { ActorLike, ActorLikeArray, ActorLikeRecord, ActorLikesT, ActorLikeT, ActorLikeY } from "../Actor.ts";
|
|
3
|
+
import type { Spec } from "../Spec.ts";
|
|
4
|
+
import type { JSONKey } from "../util/JSONKey.ts";
|
|
5
|
+
export declare function branch<K extends JSONKey, Y extends Action, T>(key: K, actorLike: ActorLike<Y, T>): Generator<Action<"branch", Spec.Make<{
|
|
6
|
+
Child: [Y[""]] extends [never] ? never : [K, Y[""]];
|
|
7
|
+
Entry: Y[""]["Entry"];
|
|
8
|
+
Value: T;
|
|
9
|
+
}>>, T>;
|
|
10
|
+
export declare function branch<K extends JSONKey, const A extends ActorLikeArray>(name: K, actorLikeArray: A): Generator<Action<"branch", Spec.Make<{
|
|
11
|
+
Child: [
|
|
12
|
+
K,
|
|
13
|
+
{
|
|
14
|
+
[L in keyof A]: Spec.Make<{
|
|
15
|
+
Child: [L, ActorLikeY<A[L]>[""]];
|
|
16
|
+
Entry: ActorLikeY<A[L]>[""]["Entry"];
|
|
17
|
+
Value: ActorLikeT<A[L]>;
|
|
18
|
+
}>;
|
|
19
|
+
}[keyof A]
|
|
20
|
+
];
|
|
21
|
+
Entry: ActorLikeY<A[number]>[""]["Entry"];
|
|
22
|
+
}>>, ActorLikesT<A>>;
|
|
23
|
+
export declare function branch<K extends JSONKey, A extends ActorLikeRecord>(name: K, actorLikeRecord: A): Generator<Action<"branch", Spec.Make<{
|
|
24
|
+
Child: [
|
|
25
|
+
K,
|
|
26
|
+
{
|
|
27
|
+
[L in Exclude<keyof A, symbol>]: Spec.Make<{
|
|
28
|
+
Child: [L, ActorLikeY<A[L]>[""]];
|
|
29
|
+
Entry: ActorLikeY<A[L]>[""]["Entry"];
|
|
30
|
+
Value: ActorLikeT<A[L]>;
|
|
31
|
+
}>;
|
|
32
|
+
}[Exclude<keyof A, symbol>]
|
|
33
|
+
];
|
|
34
|
+
Entry: ActorLikeY<A[keyof A]>[""]["Entry"];
|
|
35
|
+
}>>, ActorLikesT<A>>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
import { unwrapDeferred } from "../util/unwrapDeferred.js";
|
|
3
|
+
export function* branch(key, implementation) {
|
|
4
|
+
return yield Action("branch", async (scope) => {
|
|
5
|
+
if (typeof implementation === "function") {
|
|
6
|
+
const branchScope = scope.fork("branch", [key]);
|
|
7
|
+
const actor = unwrapDeferred(implementation);
|
|
8
|
+
const { value } = await branchScope.reduce(actor);
|
|
9
|
+
branchScope.event({
|
|
10
|
+
type: "returned",
|
|
11
|
+
value,
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
...scope,
|
|
15
|
+
nextArg: value,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const armKeys = Array.isArray(implementation)
|
|
19
|
+
? Array.from({ length: implementation.length }, (_0, i) => i)
|
|
20
|
+
: Reflect.ownKeys(implementation);
|
|
21
|
+
const values = await Promise.all(armKeys.map(async (armKey) => {
|
|
22
|
+
const branchArmScope = scope.fork("branch_arm", [key, armKey]);
|
|
23
|
+
const actor = unwrapDeferred(implementation[armKey]);
|
|
24
|
+
const { value } = await branchArmScope.reduce(actor);
|
|
25
|
+
branchArmScope.event({
|
|
26
|
+
type: "returned",
|
|
27
|
+
value,
|
|
28
|
+
});
|
|
29
|
+
return value;
|
|
30
|
+
}));
|
|
31
|
+
const value = Array.isArray(implementation)
|
|
32
|
+
? values
|
|
33
|
+
: Object.fromEntries(armKeys.map((key, i) => [key, values[i]]));
|
|
34
|
+
return {
|
|
35
|
+
...scope,
|
|
36
|
+
nextArg: value,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../actions/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAarC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AA0D1D,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC,GAAY,EAAE,cAAsC;IAC1E,OAAO,MAAM,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC5C,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAC/C,MAAM,KAAK,GAAG,cAAc,CAAC,cAA2B,CAAC,CAAA;YACzD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACjD,WAAW,CAAC,KAAK,CAAC;gBAChB,IAAI,EAAE,UAAU;gBAChB,KAAK;aACN,CAAC,CAAA;YACF,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,KAAK;aACf,CAAA;QACH,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;YAC3C,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7D,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAkB,CAAA;QACpD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAC5D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;YAC9D,MAAM,KAAK,GAAG,cAAc,CAAC,cAAc,CAAC,MAAe,CAAC,CAAU,CAAA;YACtE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACpD,cAAc,CAAC,KAAK,CAAC;gBACnB,IAAI,EAAE,UAAU;gBAChB,KAAK;aACN,CAAC,CAAA;YACF,OAAO,KAAK,CAAA;QACd,CAAC,CAAC,CAAC,CAAA;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;YACzC,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACjE,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,KAAK;SACf,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { ActorLike } from "../Actor.ts";
|
|
3
|
+
import type { Spec } from "../Spec.ts";
|
|
4
|
+
import type { JSONKey } from "../util/JSONKey.ts";
|
|
5
|
+
import type { Result } from "../util/Result.ts";
|
|
6
|
+
export { catch_ as catch };
|
|
7
|
+
declare function catch_<K extends JSONKey, Y extends Action, T>(key: K, actorLike: ActorLike<Y, T>): Generator<Action<"catch", Spec.Make<{
|
|
8
|
+
Child: [K, Y[""]];
|
|
9
|
+
Value: T;
|
|
10
|
+
}>>, Result<T, Y[""]["Throw"]>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
import { unwrapDeferred } from "../util/unwrapDeferred.js";
|
|
3
|
+
export { catch_ as catch };
|
|
4
|
+
function* catch_(key, actorLike) {
|
|
5
|
+
return yield Action("catch", async (scope) => {
|
|
6
|
+
const catchScope = scope.fork("catch", [key]);
|
|
7
|
+
try {
|
|
8
|
+
const { value } = await catchScope.reduce(unwrapDeferred(actorLike));
|
|
9
|
+
catchScope.event({
|
|
10
|
+
type: "returned",
|
|
11
|
+
value,
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
...scope,
|
|
15
|
+
nextArg: { value },
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (thrown) {
|
|
19
|
+
return {
|
|
20
|
+
...scope,
|
|
21
|
+
nextArg: { thrown },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(catch_, "name", { value: "catch" });
|
|
27
|
+
//# sourceMappingURL=catch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catch.js","sourceRoot":"","sources":["../../actions/catch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAKrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAA;AAC1B,QAAQ,CAAC,CAAC,MAAM,CACd,GAAM,EACN,SAA0B;IAW1B,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;QAC7C,IAAI,CAAC;YACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;YACpE,UAAU,CAAC,KAAK,CAAC;gBACf,IAAI,EAAE,UAAU;gBAChB,KAAK;aACN,CAAC,CAAA;YACF,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,EAAE,KAAK,EAAE;aACnB,CAAA;QACH,CAAC;QAAC,OAAO,MAAe,EAAE,CAAC;YACzB,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,EAAE,MAAM,EAAE;aACpB,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AACD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { Spec } from "../Spec.ts";
|
|
3
|
+
import type { JSONKey } from "../util/JSONKey.ts";
|
|
4
|
+
export interface declareArg<K extends JSONKey, T> extends Action<"declare_arg", Spec.Make<{
|
|
5
|
+
Entry: [K, T];
|
|
6
|
+
}>> {
|
|
7
|
+
}
|
|
8
|
+
export declare function declareArg<K extends JSONKey>(key: K): <T>() => Generator<declareArg<K, T>, T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declareArg.js","sourceRoot":"","sources":["../../actions/declareArg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAMrC,MAAM,UAAU,UAAU,CAAoB,GAAM;IAClD,OAAO,QAAQ,CAAC;QACd,OAAO,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7C,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC;SAC3B,CAAC,CAAC,CAAA;IACL,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { ToolDisabled } from "../events/ToolDisabled.ts";
|
|
3
|
+
import type { Spec } from "../Spec.ts";
|
|
4
|
+
import type { Tool } from "../Tool.ts";
|
|
5
|
+
import type { JSONKey } from "../util/JSONKey.ts";
|
|
6
|
+
export interface disableTool<K extends JSONKey> extends Action<"disable_tool", Spec.Make<{
|
|
7
|
+
Event: ToolDisabled<K>;
|
|
8
|
+
}>> {
|
|
9
|
+
}
|
|
10
|
+
export declare function disableTool<K extends JSONKey>(tool: Tool<K>): Generator<disableTool<K>, void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
export function* disableTool(tool) {
|
|
3
|
+
yield Action("disable_tool", (scope) => {
|
|
4
|
+
scope.event({
|
|
5
|
+
type: "tool_disabled",
|
|
6
|
+
tool: tool.toolKey,
|
|
7
|
+
});
|
|
8
|
+
const tools = new Set(scope.tools);
|
|
9
|
+
tools.delete(tool);
|
|
10
|
+
return {
|
|
11
|
+
...scope,
|
|
12
|
+
tools,
|
|
13
|
+
nextArg: undefined,
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=disableTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disableTool.js","sourceRoot":"","sources":["../../actions/disableTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAQrC,MAAM,SAAS,CAAC,CAAC,WAAW,CAAoB,IAAa;IAI3D,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;QACrC,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,IAAI,CAAC,OAAO;SACnB,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAClC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClB,OAAO;YACL,GAAG,KAAK;YACR,KAAK;YACL,OAAO,EAAE,SAAS;SACnB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { Embedded } from "../events/Embedded.ts";
|
|
3
|
+
import type { EmbeddingRequested } from "../events/EmbeddingRequested.ts";
|
|
4
|
+
import type { Spec } from "../Spec.ts";
|
|
5
|
+
export interface embed extends Action<"embed", Spec.Make<{
|
|
6
|
+
Event: EmbeddingRequested | Embedded;
|
|
7
|
+
}>> {
|
|
8
|
+
}
|
|
9
|
+
export declare function embed(value: string): Generator<embed, Array<number>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
import { assert } from "../util/assert.js";
|
|
3
|
+
export function* embed(value) {
|
|
4
|
+
return yield Action("embed", async (scope) => {
|
|
5
|
+
const model = scope.embeddingModels.values().next().value;
|
|
6
|
+
assert(model);
|
|
7
|
+
scope.event({
|
|
8
|
+
type: "embedding_requested",
|
|
9
|
+
value,
|
|
10
|
+
});
|
|
11
|
+
const embedding = await model.embed(value);
|
|
12
|
+
scope.event({
|
|
13
|
+
type: "embedded",
|
|
14
|
+
value,
|
|
15
|
+
embedding,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
...scope,
|
|
19
|
+
nextArg: scope.value,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=embed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.js","sourceRoot":"","sources":["../../actions/embed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI1C,MAAM,SAAS,CAAC,CAAC,KAAK,CAAC,KAAa;IAClC,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;QACzD,MAAM,CAAC,KAAK,CAAC,CAAA;QACb,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,qBAAqB;YAC3B,KAAK;SACN,CAAC,CAAA;QACF,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1C,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,UAAU;YAChB,KAAK;YACL,SAAS;SACV,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,KAAK;SACrB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Action } from "../Action.ts";
|
|
2
|
+
import type { Emitted } from "../events/Emitted.ts";
|
|
3
|
+
import type { Spec } from "../Spec.ts";
|
|
4
|
+
import type { JSONValue } from "../util/JSONValue.ts";
|
|
5
|
+
export interface emit<V extends JSONValue> extends Action<"emit", Spec.Make<{
|
|
6
|
+
Event: Emitted<V>;
|
|
7
|
+
}>> {
|
|
8
|
+
}
|
|
9
|
+
export declare function emit<V extends JSONValue = never>(value?: V): Generator<emit<V>, void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
export function* emit(value = undefined) {
|
|
3
|
+
return yield Action("emit", (scope) => {
|
|
4
|
+
scope.event({
|
|
5
|
+
type: "emitted",
|
|
6
|
+
value,
|
|
7
|
+
});
|
|
8
|
+
return {
|
|
9
|
+
...scope,
|
|
10
|
+
nextArg: undefined,
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=emit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../../actions/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAOrC,MAAM,SAAS,CAAC,CAAC,IAAI,CACnB,QAAW,SAAkB;IAE7B,OAAO,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QACpC,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK;SACN,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,SAAS;SACnB,CAAA;IACH,CAAC,CAAU,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
import { Action } from "../Action.ts";
|
|
3
|
+
import type { Actor } from "../Actor.ts";
|
|
4
|
+
import type { ToolCalled } from "../events/ToolCalled.ts";
|
|
5
|
+
import type { ToolEnabled } from "../events/ToolEnabled.ts";
|
|
6
|
+
import type { Spec } from "../Spec.ts";
|
|
7
|
+
import { type ToolResult } from "../Tool.ts";
|
|
8
|
+
import type { JSONKey } from "../util/JSONKey.ts";
|
|
9
|
+
import type { JSONObject } from "../util/JSONObject.ts";
|
|
10
|
+
import type { PromiseOr } from "../util/PromiseOr.ts";
|
|
11
|
+
import { disableTool } from "./disableTool.ts";
|
|
12
|
+
export declare function enableTool<K extends JSONKey, A>(key: K, description: string, params: StandardSchemaV1<JSONObject, A>, implementation: (params: A) => PromiseOr<ToolResult>): Generator<Action<"enable_tool", Spec.Make<{
|
|
13
|
+
Event: ToolEnabled<K> | ToolCalled<K, A>;
|
|
14
|
+
}>>, Generator<disableTool<K>, void>>;
|
|
15
|
+
export declare function enableTool<K extends JSONKey, A, Y extends Action, T extends ToolResult>(key: K, description: string, params: StandardSchemaV1<JSONObject, A>, implementation: (params: A) => Actor<Y, T>): Generator<Action<"enable_tool", Spec.Make<{
|
|
16
|
+
Event: ToolEnabled<K> | ToolCalled<K, A>;
|
|
17
|
+
Child: [K, Y[""]];
|
|
18
|
+
Entry: Y[""]["Entry"];
|
|
19
|
+
Value: T;
|
|
20
|
+
}>>, Generator<disableTool<K>, void>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Action } from "../Action.js";
|
|
2
|
+
import { Tool } from "../Tool.js";
|
|
3
|
+
import { JSONSchemaMemo } from "../util/JSONSchemaMemo.js";
|
|
4
|
+
import { disableTool } from "./disableTool.js";
|
|
5
|
+
export function* enableTool(key, description, params, implementation) {
|
|
6
|
+
return yield Action("enable_tool", async (scope) => {
|
|
7
|
+
scope.event({
|
|
8
|
+
type: "tool_enabled",
|
|
9
|
+
description,
|
|
10
|
+
schema: await JSONSchemaMemo(params),
|
|
11
|
+
tool: key,
|
|
12
|
+
});
|
|
13
|
+
const tool = Tool({
|
|
14
|
+
toolKey: key,
|
|
15
|
+
description,
|
|
16
|
+
params,
|
|
17
|
+
implementation,
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
...scope,
|
|
21
|
+
tools: new Set([...scope.tools, tool]),
|
|
22
|
+
nextArg: disableTool(tool),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=enableTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableTool.js","sourceRoot":"","sources":["../../actions/enableTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAKrC,OAAO,EAAE,IAAI,EAA4C,MAAM,YAAY,CAAA;AAG3E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAsC9C,MAAM,SAAS,CAAC,CAAC,UAAU,CACzB,GAAY,EACZ,WAAmB,EACnB,MAAyC,EACzC,cAAkC;IAElC,OAAO,MAAM,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACjD,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,cAAc;YACpB,WAAW;YACX,MAAM,EAAE,MAAM,cAAc,CAAC,MAAM,CAAC;YACpC,IAAI,EAAE,GAAG;SACV,CAAC,CAAA;QACF,MAAM,IAAI,GAAG,IAAI,CAAC;YAChB,OAAO,EAAE,GAAG;YACZ,WAAW;YACX,MAAM;YACN,cAAc;SACf,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACtC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC;SAC3B,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as L from "../L.js";
|
|
2
|
+
import { ActorAssertions } from "../testing/ActorAssertions.js";
|
|
3
|
+
import { emit } from "./emit.js";
|
|
4
|
+
import { enableTool } from "./enableTool.js";
|
|
5
|
+
const P = L.object({
|
|
6
|
+
a: L.string,
|
|
7
|
+
b: L.string,
|
|
8
|
+
});
|
|
9
|
+
const arrowTool = L.enableTool("Tool", "", P, (params) => {
|
|
10
|
+
});
|
|
11
|
+
ActorAssertions(arrowTool).assertSpec();
|
|
12
|
+
function* _0() {
|
|
13
|
+
const detach = yield* arrowTool;
|
|
14
|
+
ActorAssertions(detach).assertSpec();
|
|
15
|
+
}
|
|
16
|
+
const genTool = enableTool("tool-key", "", P, function* (params) {
|
|
17
|
+
yield* emit("Test");
|
|
18
|
+
return "";
|
|
19
|
+
});
|
|
20
|
+
ActorAssertions(genTool).assertSpec();
|
|
21
|
+
function* parent() {
|
|
22
|
+
yield* L.enableTool("parent-tool", "", P, () => { });
|
|
23
|
+
yield* L.branch("fork-key", {
|
|
24
|
+
*"arm-key"() {
|
|
25
|
+
yield* arrowTool;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
ActorAssertions(parent).assertSpec();
|
|
30
|
+
//# sourceMappingURL=enableTool.type-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableTool.type-test.js","sourceRoot":"","sources":["../../actions/enableTool.type-test.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACjB,CAAC,EAAE,CAAC,CAAC,MAAM;IACX,CAAC,EAAE,CAAC,CAAC,MAAM;CACZ,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE;AAEzD,CAAC,CAAC,CAAA;AAEF,eAAe,CAAC,SAAS,CAAC,CAAC,UAAU,EAWjC,CAAA;AAEJ,QAAQ,CAAC,CAAC,EAAE;IACV,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,SAAS,CAAA;IAC/B,eAAe,CAAC,MAAM,CAAC,CAAC,UAAU,EAM9B,CAAA;AACN,CAAC;AAED,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAC,MAAM;IAE5D,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnB,OAAO,EAAE,CAAA;AACX,CAAC,CAAC,CAAA;AAEF,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAiB/B,CAAA;AAEJ,QAAQ,CAAC,CAAC,MAAM;IACd,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACnD,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;QAC1B,CAAC,SAAS;YACR,KAAK,CAAC,CAAC,SAAS,CAAA;QAClB,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAID,eAAe,CAAC,MAAM,CAAC,CAAC,UAAU,EAoC/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getScope.js","sourceRoot":"","sources":["../../actions/getScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAKrC,MAAM,SAAS,CAAC,CAAC,QAAQ;IACvB,OAAO,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3C,GAAG,KAAK;QACR,OAAO,EAAE,KAAK;KACf,CAAC,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSignal.js","sourceRoot":"","sources":["../../actions/getSignal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,MAAM,SAAS,CAAC,CAAC,SAAS;IACxB,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7C,GAAG,KAAK;QACR,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM;KACjC,CAAC,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTools.js","sourceRoot":"","sources":["../../actions/getTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAKrC,MAAM,SAAS,CAAC,CAAC,QAAQ;IACvB,OAAO,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3C,GAAG,KAAK;QACR,OAAO,EAAE,KAAK,CAAC,KAAK;KACrB,CAAC,CAAC,CAAA;AACL,CAAC"}
|