@vurb/core 3.2.0
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/README.md +677 -0
- package/dist/cli/args.d.ts +26 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +117 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands/create.d.ts +11 -0
- package/dist/cli/commands/create.d.ts.map +1 -0
- package/dist/cli/commands/create.js +121 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +3 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +268 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +9 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +58 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/lock.d.ts +5 -0
- package/dist/cli/commands/lock.d.ts.map +1 -0
- package/dist/cli/commands/lock.js +94 -0
- package/dist/cli/commands/lock.js.map +1 -0
- package/dist/cli/commands/remote.d.ts +3 -0
- package/dist/cli/commands/remote.d.ts.map +1 -0
- package/dist/cli/commands/remote.js +37 -0
- package/dist/cli/commands/remote.js.map +1 -0
- package/dist/cli/constants.d.ts +18 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/constants.js +95 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/progress.d.ts +34 -0
- package/dist/cli/progress.d.ts.map +1 -0
- package/dist/cli/progress.js +102 -0
- package/dist/cli/progress.js.map +1 -0
- package/dist/cli/rc.d.ts +11 -0
- package/dist/cli/rc.d.ts.map +1 -0
- package/dist/cli/rc.js +75 -0
- package/dist/cli/rc.js.map +1 -0
- package/dist/cli/registry.d.ts +25 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +86 -0
- package/dist/cli/registry.js.map +1 -0
- package/dist/cli/scaffold.d.ts +10 -0
- package/dist/cli/scaffold.d.ts.map +1 -0
- package/dist/cli/scaffold.js +105 -0
- package/dist/cli/scaffold.js.map +1 -0
- package/dist/cli/templates/config.d.ts +14 -0
- package/dist/cli/templates/config.d.ts.map +1 -0
- package/dist/cli/templates/config.js +133 -0
- package/dist/cli/templates/config.js.map +1 -0
- package/dist/cli/templates/constants.d.ts +9 -0
- package/dist/cli/templates/constants.d.ts.map +1 -0
- package/dist/cli/templates/constants.js +9 -0
- package/dist/cli/templates/constants.js.map +1 -0
- package/dist/cli/templates/core.d.ts +14 -0
- package/dist/cli/templates/core.d.ts.map +1 -0
- package/dist/cli/templates/core.js +186 -0
- package/dist/cli/templates/core.js.map +1 -0
- package/dist/cli/templates/cursor.d.ts +8 -0
- package/dist/cli/templates/cursor.d.ts.map +1 -0
- package/dist/cli/templates/cursor.js +13 -0
- package/dist/cli/templates/cursor.js.map +1 -0
- package/dist/cli/templates/index.d.ts +17 -0
- package/dist/cli/templates/index.d.ts.map +1 -0
- package/dist/cli/templates/index.js +27 -0
- package/dist/cli/templates/index.js.map +1 -0
- package/dist/cli/templates/middleware.d.ts +7 -0
- package/dist/cli/templates/middleware.d.ts.map +1 -0
- package/dist/cli/templates/middleware.js +34 -0
- package/dist/cli/templates/middleware.js.map +1 -0
- package/dist/cli/templates/presenter.d.ts +7 -0
- package/dist/cli/templates/presenter.d.ts.map +1 -0
- package/dist/cli/templates/presenter.js +46 -0
- package/dist/cli/templates/presenter.js.map +1 -0
- package/dist/cli/templates/prompt.d.ts +7 -0
- package/dist/cli/templates/prompt.d.ts.map +1 -0
- package/dist/cli/templates/prompt.js +42 -0
- package/dist/cli/templates/prompt.js.map +1 -0
- package/dist/cli/templates/readme.d.ts +8 -0
- package/dist/cli/templates/readme.d.ts.map +1 -0
- package/dist/cli/templates/readme.js +173 -0
- package/dist/cli/templates/readme.js.map +1 -0
- package/dist/cli/templates/testing.d.ts +11 -0
- package/dist/cli/templates/testing.d.ts.map +1 -0
- package/dist/cli/templates/testing.js +101 -0
- package/dist/cli/templates/testing.js.map +1 -0
- package/dist/cli/templates/tools.d.ts +13 -0
- package/dist/cli/templates/tools.d.ts.map +1 -0
- package/dist/cli/templates/tools.js +63 -0
- package/dist/cli/templates/tools.js.map +1 -0
- package/dist/cli/templates/vectors/database.d.ts +9 -0
- package/dist/cli/templates/vectors/database.d.ts.map +1 -0
- package/dist/cli/templates/vectors/database.js +82 -0
- package/dist/cli/templates/vectors/database.js.map +1 -0
- package/dist/cli/templates/vectors/index.d.ts +9 -0
- package/dist/cli/templates/vectors/index.d.ts.map +1 -0
- package/dist/cli/templates/vectors/index.js +9 -0
- package/dist/cli/templates/vectors/index.js.map +1 -0
- package/dist/cli/templates/vectors/oauth.d.ts +10 -0
- package/dist/cli/templates/vectors/oauth.d.ts.map +1 -0
- package/dist/cli/templates/vectors/oauth.js +76 -0
- package/dist/cli/templates/vectors/oauth.js.map +1 -0
- package/dist/cli/templates/vectors/openapi.d.ts +10 -0
- package/dist/cli/templates/vectors/openapi.d.ts.map +1 -0
- package/dist/cli/templates/vectors/openapi.js +106 -0
- package/dist/cli/templates/vectors/openapi.js.map +1 -0
- package/dist/cli/templates/vectors/workflow.d.ts +7 -0
- package/dist/cli/templates/vectors/workflow.d.ts.map +1 -0
- package/dist/cli/templates/vectors/workflow.js +49 -0
- package/dist/cli/templates/vectors/workflow.js.map +1 -0
- package/dist/cli/types.d.ts +36 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +10 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/utils.d.ts +27 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +73 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/cli/vurb.d.ts +15 -0
- package/dist/cli/vurb.d.ts.map +1 -0
- package/dist/cli/vurb.js +87 -0
- package/dist/cli/vurb.js.map +1 -0
- package/dist/client/InferRouter.d.ts +92 -0
- package/dist/client/InferRouter.d.ts.map +1 -0
- package/dist/client/InferRouter.js +31 -0
- package/dist/client/InferRouter.js.map +1 -0
- package/dist/client/VurbClient.d.ts +282 -0
- package/dist/client/VurbClient.d.ts.map +1 -0
- package/dist/client/VurbClient.js +287 -0
- package/dist/client/VurbClient.js.map +1 -0
- package/dist/client/createTypedRegistry.d.ts +25 -0
- package/dist/client/createTypedRegistry.d.ts.map +1 -0
- package/dist/client/createTypedRegistry.js +74 -0
- package/dist/client/createTypedRegistry.js.map +1 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -0
- package/dist/converters/ConverterBase.d.ts +68 -0
- package/dist/converters/ConverterBase.d.ts.map +1 -0
- package/dist/converters/ConverterBase.js +62 -0
- package/dist/converters/ConverterBase.js.map +1 -0
- package/dist/converters/GroupConverter.d.ts +33 -0
- package/dist/converters/GroupConverter.d.ts.map +1 -0
- package/dist/converters/GroupConverter.js +26 -0
- package/dist/converters/GroupConverter.js.map +1 -0
- package/dist/converters/PromptConverter.d.ts +33 -0
- package/dist/converters/PromptConverter.d.ts.map +1 -0
- package/dist/converters/PromptConverter.js +26 -0
- package/dist/converters/PromptConverter.js.map +1 -0
- package/dist/converters/ResourceConverter.d.ts +35 -0
- package/dist/converters/ResourceConverter.d.ts.map +1 -0
- package/dist/converters/ResourceConverter.js +28 -0
- package/dist/converters/ResourceConverter.js.map +1 -0
- package/dist/converters/ToolAnnotationsConverter.d.ts +33 -0
- package/dist/converters/ToolAnnotationsConverter.d.ts.map +1 -0
- package/dist/converters/ToolAnnotationsConverter.js +26 -0
- package/dist/converters/ToolAnnotationsConverter.js.map +1 -0
- package/dist/converters/ToolConverter.d.ts +35 -0
- package/dist/converters/ToolConverter.d.ts.map +1 -0
- package/dist/converters/ToolConverter.js +28 -0
- package/dist/converters/ToolConverter.js.map +1 -0
- package/dist/converters/index.d.ts +7 -0
- package/dist/converters/index.d.ts.map +1 -0
- package/dist/converters/index.js +7 -0
- package/dist/converters/index.js.map +1 -0
- package/dist/core/StandardSchema.d.ts +178 -0
- package/dist/core/StandardSchema.d.ts.map +1 -0
- package/dist/core/StandardSchema.js +174 -0
- package/dist/core/StandardSchema.js.map +1 -0
- package/dist/core/builder/ActionGroupBuilder.d.ts +208 -0
- package/dist/core/builder/ActionGroupBuilder.d.ts.map +1 -0
- package/dist/core/builder/ActionGroupBuilder.js +193 -0
- package/dist/core/builder/ActionGroupBuilder.js.map +1 -0
- package/dist/core/builder/ErrorBuilder.d.ts +59 -0
- package/dist/core/builder/ErrorBuilder.d.ts.map +1 -0
- package/dist/core/builder/ErrorBuilder.js +99 -0
- package/dist/core/builder/ErrorBuilder.js.map +1 -0
- package/dist/core/builder/FluentRouter.d.ts +96 -0
- package/dist/core/builder/FluentRouter.d.ts.map +1 -0
- package/dist/core/builder/FluentRouter.js +116 -0
- package/dist/core/builder/FluentRouter.js.map +1 -0
- package/dist/core/builder/FluentSchemaHelpers.d.ts +237 -0
- package/dist/core/builder/FluentSchemaHelpers.d.ts.map +1 -0
- package/dist/core/builder/FluentSchemaHelpers.js +227 -0
- package/dist/core/builder/FluentSchemaHelpers.js.map +1 -0
- package/dist/core/builder/FluentToolBuilder.d.ts +419 -0
- package/dist/core/builder/FluentToolBuilder.d.ts.map +1 -0
- package/dist/core/builder/FluentToolBuilder.js +643 -0
- package/dist/core/builder/FluentToolBuilder.js.map +1 -0
- package/dist/core/builder/GroupedToolBuilder.d.ts +832 -0
- package/dist/core/builder/GroupedToolBuilder.d.ts.map +1 -0
- package/dist/core/builder/GroupedToolBuilder.js +1306 -0
- package/dist/core/builder/GroupedToolBuilder.js.map +1 -0
- package/dist/core/builder/ParamDescriptors.d.ts +142 -0
- package/dist/core/builder/ParamDescriptors.d.ts.map +1 -0
- package/dist/core/builder/ParamDescriptors.js +164 -0
- package/dist/core/builder/ParamDescriptors.js.map +1 -0
- package/dist/core/builder/ToolDefinitionCompiler.d.ts +37 -0
- package/dist/core/builder/ToolDefinitionCompiler.d.ts.map +1 -0
- package/dist/core/builder/ToolDefinitionCompiler.js +72 -0
- package/dist/core/builder/ToolDefinitionCompiler.js.map +1 -0
- package/dist/core/builder/defineTool.d.ts +180 -0
- package/dist/core/builder/defineTool.d.ts.map +1 -0
- package/dist/core/builder/defineTool.js +164 -0
- package/dist/core/builder/defineTool.js.map +1 -0
- package/dist/core/builder/index.d.ts +13 -0
- package/dist/core/builder/index.d.ts.map +1 -0
- package/dist/core/builder/index.js +13 -0
- package/dist/core/builder/index.js.map +1 -0
- package/dist/core/createGroup.d.ts +140 -0
- package/dist/core/createGroup.d.ts.map +1 -0
- package/dist/core/createGroup.js +144 -0
- package/dist/core/createGroup.js.map +1 -0
- package/dist/core/execution/ConcurrencyGuard.d.ts +103 -0
- package/dist/core/execution/ConcurrencyGuard.d.ts.map +1 -0
- package/dist/core/execution/ConcurrencyGuard.js +147 -0
- package/dist/core/execution/ConcurrencyGuard.js.map +1 -0
- package/dist/core/execution/EgressGuard.d.ts +72 -0
- package/dist/core/execution/EgressGuard.d.ts.map +1 -0
- package/dist/core/execution/EgressGuard.js +163 -0
- package/dist/core/execution/EgressGuard.js.map +1 -0
- package/dist/core/execution/ExecutionPipeline.d.ts +67 -0
- package/dist/core/execution/ExecutionPipeline.d.ts.map +1 -0
- package/dist/core/execution/ExecutionPipeline.js +176 -0
- package/dist/core/execution/ExecutionPipeline.js.map +1 -0
- package/dist/core/execution/MiddlewareCompiler.d.ts +35 -0
- package/dist/core/execution/MiddlewareCompiler.d.ts.map +1 -0
- package/dist/core/execution/MiddlewareCompiler.js +111 -0
- package/dist/core/execution/MiddlewareCompiler.js.map +1 -0
- package/dist/core/execution/MutationSerializer.d.ts +78 -0
- package/dist/core/execution/MutationSerializer.d.ts.map +1 -0
- package/dist/core/execution/MutationSerializer.js +106 -0
- package/dist/core/execution/MutationSerializer.js.map +1 -0
- package/dist/core/execution/PipelineHooks.d.ts +46 -0
- package/dist/core/execution/PipelineHooks.d.ts.map +1 -0
- package/dist/core/execution/PipelineHooks.js +66 -0
- package/dist/core/execution/PipelineHooks.js.map +1 -0
- package/dist/core/execution/ProgressHelper.d.ts +67 -0
- package/dist/core/execution/ProgressHelper.d.ts.map +1 -0
- package/dist/core/execution/ProgressHelper.js +59 -0
- package/dist/core/execution/ProgressHelper.js.map +1 -0
- package/dist/core/execution/ValidationErrorFormatter.d.ts +34 -0
- package/dist/core/execution/ValidationErrorFormatter.d.ts.map +1 -0
- package/dist/core/execution/ValidationErrorFormatter.js +193 -0
- package/dist/core/execution/ValidationErrorFormatter.js.map +1 -0
- package/dist/core/execution/index.d.ts +9 -0
- package/dist/core/execution/index.d.ts.map +1 -0
- package/dist/core/execution/index.js +9 -0
- package/dist/core/execution/index.js.map +1 -0
- package/dist/core/index.d.ts +34 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +29 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/initVurb.d.ts +295 -0
- package/dist/core/initVurb.d.ts.map +1 -0
- package/dist/core/initVurb.js +171 -0
- package/dist/core/initVurb.js.map +1 -0
- package/dist/core/middleware/ContextDerivation.d.ts +124 -0
- package/dist/core/middleware/ContextDerivation.d.ts.map +1 -0
- package/dist/core/middleware/ContextDerivation.js +117 -0
- package/dist/core/middleware/ContextDerivation.js.map +1 -0
- package/dist/core/middleware/index.d.ts +4 -0
- package/dist/core/middleware/index.d.ts.map +1 -0
- package/dist/core/middleware/index.js +3 -0
- package/dist/core/middleware/index.js.map +1 -0
- package/dist/core/registry/ToolFilterEngine.d.ts +27 -0
- package/dist/core/registry/ToolFilterEngine.d.ts.map +1 -0
- package/dist/core/registry/ToolFilterEngine.js +45 -0
- package/dist/core/registry/ToolFilterEngine.js.map +1 -0
- package/dist/core/registry/ToolRegistry.d.ts +259 -0
- package/dist/core/registry/ToolRegistry.d.ts.map +1 -0
- package/dist/core/registry/ToolRegistry.js +343 -0
- package/dist/core/registry/ToolRegistry.js.map +1 -0
- package/dist/core/registry/index.d.ts +4 -0
- package/dist/core/registry/index.d.ts.map +1 -0
- package/dist/core/registry/index.js +3 -0
- package/dist/core/registry/index.js.map +1 -0
- package/dist/core/response.d.ts +289 -0
- package/dist/core/response.d.ts.map +1 -0
- package/dist/core/response.js +286 -0
- package/dist/core/response.js.map +1 -0
- package/dist/core/result.d.ts +93 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/result.js +66 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/schema/AnnotationAggregator.d.ts +11 -0
- package/dist/core/schema/AnnotationAggregator.d.ts.map +1 -0
- package/dist/core/schema/AnnotationAggregator.js +40 -0
- package/dist/core/schema/AnnotationAggregator.js.map +1 -0
- package/dist/core/schema/DescriptionGenerator.d.ts +12 -0
- package/dist/core/schema/DescriptionGenerator.d.ts.map +1 -0
- package/dist/core/schema/DescriptionGenerator.js +81 -0
- package/dist/core/schema/DescriptionGenerator.js.map +1 -0
- package/dist/core/schema/SchemaGenerator.d.ts +15 -0
- package/dist/core/schema/SchemaGenerator.d.ts.map +1 -0
- package/dist/core/schema/SchemaGenerator.js +192 -0
- package/dist/core/schema/SchemaGenerator.js.map +1 -0
- package/dist/core/schema/SchemaUtils.d.ts +26 -0
- package/dist/core/schema/SchemaUtils.d.ts.map +1 -0
- package/dist/core/schema/SchemaUtils.js +85 -0
- package/dist/core/schema/SchemaUtils.js.map +1 -0
- package/dist/core/schema/ToonDescriptionGenerator.d.ts +3 -0
- package/dist/core/schema/ToonDescriptionGenerator.d.ts.map +1 -0
- package/dist/core/schema/ToonDescriptionGenerator.js +65 -0
- package/dist/core/schema/ToonDescriptionGenerator.js.map +1 -0
- package/dist/core/schema/index.d.ts +7 -0
- package/dist/core/schema/index.d.ts.map +1 -0
- package/dist/core/schema/index.js +7 -0
- package/dist/core/schema/index.js.map +1 -0
- package/dist/core/serialization/JsonSerializer.d.ts +71 -0
- package/dist/core/serialization/JsonSerializer.d.ts.map +1 -0
- package/dist/core/serialization/JsonSerializer.js +192 -0
- package/dist/core/serialization/JsonSerializer.js.map +1 -0
- package/dist/core/serialization/index.d.ts +7 -0
- package/dist/core/serialization/index.d.ts.map +1 -0
- package/dist/core/serialization/index.js +7 -0
- package/dist/core/serialization/index.js.map +1 -0
- package/dist/core/types.d.ts +303 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +17 -0
- package/dist/core/types.js.map +1 -0
- package/dist/domain/Annotations.d.ts +42 -0
- package/dist/domain/Annotations.d.ts.map +1 -0
- package/dist/domain/Annotations.js +16 -0
- package/dist/domain/Annotations.js.map +1 -0
- package/dist/domain/BaseModel.d.ts +50 -0
- package/dist/domain/BaseModel.d.ts.map +1 -0
- package/dist/domain/BaseModel.js +41 -0
- package/dist/domain/BaseModel.js.map +1 -0
- package/dist/domain/Group.d.ts +99 -0
- package/dist/domain/Group.d.ts.map +1 -0
- package/dist/domain/Group.js +172 -0
- package/dist/domain/Group.js.map +1 -0
- package/dist/domain/GroupItem.d.ts +46 -0
- package/dist/domain/GroupItem.d.ts.map +1 -0
- package/dist/domain/GroupItem.js +58 -0
- package/dist/domain/GroupItem.js.map +1 -0
- package/dist/domain/Icon.d.ts +41 -0
- package/dist/domain/Icon.d.ts.map +1 -0
- package/dist/domain/Icon.js +15 -0
- package/dist/domain/Icon.js.map +1 -0
- package/dist/domain/Prompt.d.ts +49 -0
- package/dist/domain/Prompt.d.ts.map +1 -0
- package/dist/domain/Prompt.js +59 -0
- package/dist/domain/Prompt.js.map +1 -0
- package/dist/domain/PromptArgument.d.ts +23 -0
- package/dist/domain/PromptArgument.d.ts.map +1 -0
- package/dist/domain/PromptArgument.js +27 -0
- package/dist/domain/PromptArgument.js.map +1 -0
- package/dist/domain/Resource.d.ts +37 -0
- package/dist/domain/Resource.d.ts.map +1 -0
- package/dist/domain/Resource.js +39 -0
- package/dist/domain/Resource.js.map +1 -0
- package/dist/domain/Role.d.ts +23 -0
- package/dist/domain/Role.d.ts.map +1 -0
- package/dist/domain/Role.js +24 -0
- package/dist/domain/Role.js.map +1 -0
- package/dist/domain/Tool.d.ts +39 -0
- package/dist/domain/Tool.d.ts.map +1 -0
- package/dist/domain/Tool.js +41 -0
- package/dist/domain/Tool.js.map +1 -0
- package/dist/domain/ToolAnnotations.d.ts +48 -0
- package/dist/domain/ToolAnnotations.d.ts.map +1 -0
- package/dist/domain/ToolAnnotations.js +15 -0
- package/dist/domain/ToolAnnotations.js.map +1 -0
- package/dist/domain/index.d.ts +16 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +13 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/utils.d.ts +6 -0
- package/dist/domain/utils.d.ts.map +1 -0
- package/dist/domain/utils.js +12 -0
- package/dist/domain/utils.js.map +1 -0
- package/dist/edge-stub.d.ts +73 -0
- package/dist/edge-stub.d.ts.map +1 -0
- package/dist/edge-stub.js +83 -0
- package/dist/edge-stub.js.map +1 -0
- package/dist/exposition/ExpositionCompiler.d.ts +66 -0
- package/dist/exposition/ExpositionCompiler.d.ts.map +1 -0
- package/dist/exposition/ExpositionCompiler.js +279 -0
- package/dist/exposition/ExpositionCompiler.js.map +1 -0
- package/dist/exposition/index.d.ts +4 -0
- package/dist/exposition/index.d.ts.map +1 -0
- package/dist/exposition/index.js +2 -0
- package/dist/exposition/index.js.map +1 -0
- package/dist/exposition/types.d.ts +58 -0
- package/dist/exposition/types.d.ts.map +1 -0
- package/dist/exposition/types.js +11 -0
- package/dist/exposition/types.js.map +1 -0
- package/dist/fsm/StateMachineGate.d.ts +294 -0
- package/dist/fsm/StateMachineGate.d.ts.map +1 -0
- package/dist/fsm/StateMachineGate.js +400 -0
- package/dist/fsm/StateMachineGate.js.map +1 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +112 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection/BehaviorDigest.d.ts +112 -0
- package/dist/introspection/BehaviorDigest.d.ts.map +1 -0
- package/dist/introspection/BehaviorDigest.js +149 -0
- package/dist/introspection/BehaviorDigest.js.map +1 -0
- package/dist/introspection/CapabilityLockfile.d.ts +261 -0
- package/dist/introspection/CapabilityLockfile.d.ts.map +1 -0
- package/dist/introspection/CapabilityLockfile.js +395 -0
- package/dist/introspection/CapabilityLockfile.js.map +1 -0
- package/dist/introspection/ContractAwareSelfHealing.d.ts +90 -0
- package/dist/introspection/ContractAwareSelfHealing.d.ts.map +1 -0
- package/dist/introspection/ContractAwareSelfHealing.js +132 -0
- package/dist/introspection/ContractAwareSelfHealing.js.map +1 -0
- package/dist/introspection/ContractDiff.d.ts +91 -0
- package/dist/introspection/ContractDiff.d.ts.map +1 -0
- package/dist/introspection/ContractDiff.js +466 -0
- package/dist/introspection/ContractDiff.js.map +1 -0
- package/dist/introspection/CryptoAttestation.d.ts +143 -0
- package/dist/introspection/CryptoAttestation.d.ts.map +1 -0
- package/dist/introspection/CryptoAttestation.js +192 -0
- package/dist/introspection/CryptoAttestation.js.map +1 -0
- package/dist/introspection/EntitlementScanner.d.ts +177 -0
- package/dist/introspection/EntitlementScanner.d.ts.map +1 -0
- package/dist/introspection/EntitlementScanner.js +459 -0
- package/dist/introspection/EntitlementScanner.js.map +1 -0
- package/dist/introspection/GovernanceObserver.d.ts +88 -0
- package/dist/introspection/GovernanceObserver.d.ts.map +1 -0
- package/dist/introspection/GovernanceObserver.js +136 -0
- package/dist/introspection/GovernanceObserver.js.map +1 -0
- package/dist/introspection/IntrospectionResource.d.ts +20 -0
- package/dist/introspection/IntrospectionResource.d.ts.map +1 -0
- package/dist/introspection/IntrospectionResource.js +112 -0
- package/dist/introspection/IntrospectionResource.js.map +1 -0
- package/dist/introspection/ManifestCompiler.d.ts +33 -0
- package/dist/introspection/ManifestCompiler.d.ts.map +1 -0
- package/dist/introspection/ManifestCompiler.js +88 -0
- package/dist/introspection/ManifestCompiler.js.map +1 -0
- package/dist/introspection/SemanticProbe.d.ts +207 -0
- package/dist/introspection/SemanticProbe.d.ts.map +1 -0
- package/dist/introspection/SemanticProbe.js +274 -0
- package/dist/introspection/SemanticProbe.js.map +1 -0
- package/dist/introspection/TokenEconomics.d.ts +210 -0
- package/dist/introspection/TokenEconomics.d.ts.map +1 -0
- package/dist/introspection/TokenEconomics.js +292 -0
- package/dist/introspection/TokenEconomics.js.map +1 -0
- package/dist/introspection/ToolContract.d.ts +161 -0
- package/dist/introspection/ToolContract.d.ts.map +1 -0
- package/dist/introspection/ToolContract.js +218 -0
- package/dist/introspection/ToolContract.js.map +1 -0
- package/dist/introspection/canonicalize.d.ts +35 -0
- package/dist/introspection/canonicalize.d.ts.map +1 -0
- package/dist/introspection/canonicalize.js +72 -0
- package/dist/introspection/canonicalize.js.map +1 -0
- package/dist/introspection/index.d.ts +26 -0
- package/dist/introspection/index.d.ts.map +1 -0
- package/dist/introspection/index.js +24 -0
- package/dist/introspection/index.js.map +1 -0
- package/dist/introspection/types.d.ts +120 -0
- package/dist/introspection/types.d.ts.map +1 -0
- package/dist/introspection/types.js +13 -0
- package/dist/introspection/types.js.map +1 -0
- package/dist/observability/DebugObserver.d.ts +185 -0
- package/dist/observability/DebugObserver.d.ts.map +1 -0
- package/dist/observability/DebugObserver.js +102 -0
- package/dist/observability/DebugObserver.js.map +1 -0
- package/dist/observability/TelemetryBus.d.ts +88 -0
- package/dist/observability/TelemetryBus.d.ts.map +1 -0
- package/dist/observability/TelemetryBus.js +463 -0
- package/dist/observability/TelemetryBus.js.map +1 -0
- package/dist/observability/TelemetryEvent.d.ts +177 -0
- package/dist/observability/TelemetryEvent.d.ts.map +1 -0
- package/dist/observability/TelemetryEvent.js +2 -0
- package/dist/observability/TelemetryEvent.js.map +1 -0
- package/dist/observability/Tracing.d.ts +155 -0
- package/dist/observability/Tracing.d.ts.map +1 -0
- package/dist/observability/Tracing.js +67 -0
- package/dist/observability/Tracing.js.map +1 -0
- package/dist/observability/index.d.ts +13 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +12 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/presenter/PostProcessor.d.ts +52 -0
- package/dist/presenter/PostProcessor.d.ts.map +1 -0
- package/dist/presenter/PostProcessor.js +148 -0
- package/dist/presenter/PostProcessor.js.map +1 -0
- package/dist/presenter/Presenter.d.ts +575 -0
- package/dist/presenter/Presenter.d.ts.map +1 -0
- package/dist/presenter/Presenter.js +768 -0
- package/dist/presenter/Presenter.js.map +1 -0
- package/dist/presenter/PresenterValidationError.d.ts +42 -0
- package/dist/presenter/PresenterValidationError.d.ts.map +1 -0
- package/dist/presenter/PresenterValidationError.js +55 -0
- package/dist/presenter/PresenterValidationError.js.map +1 -0
- package/dist/presenter/RedactEngine.d.ts +110 -0
- package/dist/presenter/RedactEngine.d.ts.map +1 -0
- package/dist/presenter/RedactEngine.js +128 -0
- package/dist/presenter/RedactEngine.js.map +1 -0
- package/dist/presenter/ResponseBuilder.d.ts +262 -0
- package/dist/presenter/ResponseBuilder.d.ts.map +1 -0
- package/dist/presenter/ResponseBuilder.js +374 -0
- package/dist/presenter/ResponseBuilder.js.map +1 -0
- package/dist/presenter/SelectUtils.d.ts +78 -0
- package/dist/presenter/SelectUtils.d.ts.map +1 -0
- package/dist/presenter/SelectUtils.js +141 -0
- package/dist/presenter/SelectUtils.js.map +1 -0
- package/dist/presenter/ZodDescriptionExtractor.d.ts +54 -0
- package/dist/presenter/ZodDescriptionExtractor.d.ts.map +1 -0
- package/dist/presenter/ZodDescriptionExtractor.js +131 -0
- package/dist/presenter/ZodDescriptionExtractor.js.map +1 -0
- package/dist/presenter/definePresenter.d.ts +193 -0
- package/dist/presenter/definePresenter.d.ts.map +1 -0
- package/dist/presenter/definePresenter.js +99 -0
- package/dist/presenter/definePresenter.js.map +1 -0
- package/dist/presenter/index.d.ts +21 -0
- package/dist/presenter/index.d.ts.map +1 -0
- package/dist/presenter/index.js +28 -0
- package/dist/presenter/index.js.map +1 -0
- package/dist/presenter/suggest.d.ts +39 -0
- package/dist/presenter/suggest.d.ts.map +1 -0
- package/dist/presenter/suggest.js +41 -0
- package/dist/presenter/suggest.js.map +1 -0
- package/dist/presenter/typeHelpers.d.ts +147 -0
- package/dist/presenter/typeHelpers.d.ts.map +1 -0
- package/dist/presenter/typeHelpers.js +152 -0
- package/dist/presenter/typeHelpers.js.map +1 -0
- package/dist/presenter/ui.d.ts +205 -0
- package/dist/presenter/ui.d.ts.map +1 -0
- package/dist/presenter/ui.js +222 -0
- package/dist/presenter/ui.js.map +1 -0
- package/dist/prompt/CursorCodec.d.ts +43 -0
- package/dist/prompt/CursorCodec.d.ts.map +1 -0
- package/dist/prompt/CursorCodec.js +171 -0
- package/dist/prompt/CursorCodec.js.map +1 -0
- package/dist/prompt/FluentPromptBuilder.d.ts +155 -0
- package/dist/prompt/FluentPromptBuilder.d.ts.map +1 -0
- package/dist/prompt/FluentPromptBuilder.js +195 -0
- package/dist/prompt/FluentPromptBuilder.js.map +1 -0
- package/dist/prompt/HydrationSandbox.d.ts +55 -0
- package/dist/prompt/HydrationSandbox.d.ts.map +1 -0
- package/dist/prompt/HydrationSandbox.js +122 -0
- package/dist/prompt/HydrationSandbox.js.map +1 -0
- package/dist/prompt/PromptExecutionPipeline.d.ts +61 -0
- package/dist/prompt/PromptExecutionPipeline.d.ts.map +1 -0
- package/dist/prompt/PromptExecutionPipeline.js +177 -0
- package/dist/prompt/PromptExecutionPipeline.js.map +1 -0
- package/dist/prompt/PromptMessage.d.ts +133 -0
- package/dist/prompt/PromptMessage.d.ts.map +1 -0
- package/dist/prompt/PromptMessage.js +182 -0
- package/dist/prompt/PromptMessage.js.map +1 -0
- package/dist/prompt/PromptRegistry.d.ts +236 -0
- package/dist/prompt/PromptRegistry.d.ts.map +1 -0
- package/dist/prompt/PromptRegistry.js +399 -0
- package/dist/prompt/PromptRegistry.js.map +1 -0
- package/dist/prompt/definePrompt.d.ts +111 -0
- package/dist/prompt/definePrompt.d.ts.map +1 -0
- package/dist/prompt/definePrompt.js +130 -0
- package/dist/prompt/definePrompt.js.map +1 -0
- package/dist/prompt/index.d.ts +12 -0
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/index.js +13 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/types.d.ts +425 -0
- package/dist/prompt/types.d.ts.map +1 -0
- package/dist/prompt/types.js +19 -0
- package/dist/prompt/types.js.map +1 -0
- package/dist/sandbox/SandboxEngine.d.ts +225 -0
- package/dist/sandbox/SandboxEngine.d.ts.map +1 -0
- package/dist/sandbox/SandboxEngine.js +437 -0
- package/dist/sandbox/SandboxEngine.js.map +1 -0
- package/dist/sandbox/SandboxGuard.d.ts +47 -0
- package/dist/sandbox/SandboxGuard.d.ts.map +1 -0
- package/dist/sandbox/SandboxGuard.js +127 -0
- package/dist/sandbox/SandboxGuard.js.map +1 -0
- package/dist/sandbox/index.d.ts +23 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +26 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/server/DevServer.d.ts +120 -0
- package/dist/server/DevServer.d.ts.map +1 -0
- package/dist/server/DevServer.js +252 -0
- package/dist/server/DevServer.js.map +1 -0
- package/dist/server/ServerAttachment.d.ts +354 -0
- package/dist/server/ServerAttachment.d.ts.map +1 -0
- package/dist/server/ServerAttachment.js +709 -0
- package/dist/server/ServerAttachment.js.map +1 -0
- package/dist/server/ServerResolver.d.ts +24 -0
- package/dist/server/ServerResolver.d.ts.map +1 -0
- package/dist/server/ServerResolver.js +50 -0
- package/dist/server/ServerResolver.js.map +1 -0
- package/dist/server/autoDiscover.d.ts +75 -0
- package/dist/server/autoDiscover.d.ts.map +1 -0
- package/dist/server/autoDiscover.js +164 -0
- package/dist/server/autoDiscover.js.map +1 -0
- package/dist/server/index.d.ts +12 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +11 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/startServer.d.ts +81 -0
- package/dist/server/startServer.d.ts.map +1 -0
- package/dist/server/startServer.js +143 -0
- package/dist/server/startServer.js.map +1 -0
- package/dist/state-sync/CausalEngine.d.ts +28 -0
- package/dist/state-sync/CausalEngine.d.ts.map +1 -0
- package/dist/state-sync/CausalEngine.js +17 -0
- package/dist/state-sync/CausalEngine.js.map +1 -0
- package/dist/state-sync/DescriptionDecorator.d.ts +31 -0
- package/dist/state-sync/DescriptionDecorator.d.ts.map +1 -0
- package/dist/state-sync/DescriptionDecorator.js +38 -0
- package/dist/state-sync/DescriptionDecorator.js.map +1 -0
- package/dist/state-sync/GlobMatcher.d.ts +29 -0
- package/dist/state-sync/GlobMatcher.d.ts.map +1 -0
- package/dist/state-sync/GlobMatcher.js +79 -0
- package/dist/state-sync/GlobMatcher.js.map +1 -0
- package/dist/state-sync/PolicyEngine.d.ts +75 -0
- package/dist/state-sync/PolicyEngine.d.ts.map +1 -0
- package/dist/state-sync/PolicyEngine.js +107 -0
- package/dist/state-sync/PolicyEngine.js.map +1 -0
- package/dist/state-sync/PolicyValidator.d.ts +67 -0
- package/dist/state-sync/PolicyValidator.d.ts.map +1 -0
- package/dist/state-sync/PolicyValidator.js +122 -0
- package/dist/state-sync/PolicyValidator.js.map +1 -0
- package/dist/state-sync/ResponseDecorator.d.ts +33 -0
- package/dist/state-sync/ResponseDecorator.d.ts.map +1 -0
- package/dist/state-sync/ResponseDecorator.js +20 -0
- package/dist/state-sync/ResponseDecorator.js.map +1 -0
- package/dist/state-sync/StateSyncBuilder.d.ts +77 -0
- package/dist/state-sync/StateSyncBuilder.d.ts.map +1 -0
- package/dist/state-sync/StateSyncBuilder.js +129 -0
- package/dist/state-sync/StateSyncBuilder.js.map +1 -0
- package/dist/state-sync/StateSyncLayer.d.ts +107 -0
- package/dist/state-sync/StateSyncLayer.d.ts.map +1 -0
- package/dist/state-sync/StateSyncLayer.js +158 -0
- package/dist/state-sync/StateSyncLayer.js.map +1 -0
- package/dist/state-sync/index.d.ts +27 -0
- package/dist/state-sync/index.d.ts.map +1 -0
- package/dist/state-sync/index.js +27 -0
- package/dist/state-sync/index.js.map +1 -0
- package/dist/state-sync/types.d.ts +174 -0
- package/dist/state-sync/types.d.ts.map +1 -0
- package/dist/state-sync/types.js +17 -0
- package/dist/state-sync/types.js.map +1 -0
- package/dist/testing/MvaMetaSymbol.d.ts +45 -0
- package/dist/testing/MvaMetaSymbol.d.ts.map +1 -0
- package/dist/testing/MvaMetaSymbol.js +34 -0
- package/dist/testing/MvaMetaSymbol.js.map +1 -0
- package/package.json +153 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* initVurb() — tRPC-Style Context Initialization
|
|
3
|
+
*
|
|
4
|
+
* Eliminates the need to pass `<AppContext>` as a generic parameter
|
|
5
|
+
* everywhere. Define your context type once, and every `f.query()`,
|
|
6
|
+
* `f.mutation()`, `f.action()` call automatically inherits it.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // src/vurb.ts — defined once in the project
|
|
11
|
+
* import { initVurb } from 'vurb';
|
|
12
|
+
*
|
|
13
|
+
* interface AppContext {
|
|
14
|
+
* db: PrismaClient;
|
|
15
|
+
* user: { id: string; role: string };
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* export const f = initVurb<AppContext>();
|
|
19
|
+
*
|
|
20
|
+
* // src/tools/billing.ts — clean fluent API
|
|
21
|
+
* import { f } from '../vurb';
|
|
22
|
+
*
|
|
23
|
+
* export const getInvoice = f.query('billing.get_invoice')
|
|
24
|
+
* .describe('Get an invoice by ID')
|
|
25
|
+
* .withString('id', 'The invoice ID')
|
|
26
|
+
* .handle(async (input, ctx) => {
|
|
27
|
+
* return await ctx.db.invoices.findUnique(input.id);
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
import { type ZodType } from 'zod';
|
|
34
|
+
import { GroupedToolBuilder } from './builder/GroupedToolBuilder.js';
|
|
35
|
+
import { ToolRegistry } from './registry/ToolRegistry.js';
|
|
36
|
+
import { type Presenter } from '../presenter/Presenter.js';
|
|
37
|
+
import { type PresenterConfig } from '../presenter/definePresenter.js';
|
|
38
|
+
import { type MiddlewareDefinition } from './middleware/index.js';
|
|
39
|
+
import { type ToolConfig } from './builder/defineTool.js';
|
|
40
|
+
import { FluentPromptBuilder } from '../prompt/FluentPromptBuilder.js';
|
|
41
|
+
import { type PromptBuilder, type PromptConfig } from '../prompt/types.js';
|
|
42
|
+
import { FluentToolBuilder } from './builder/FluentToolBuilder.js';
|
|
43
|
+
import { FluentRouter } from './builder/FluentRouter.js';
|
|
44
|
+
import { ErrorBuilder } from './builder/ErrorBuilder.js';
|
|
45
|
+
import { StateSyncBuilder } from '../state-sync/StateSyncBuilder.js';
|
|
46
|
+
import { type ErrorCode } from './response.js';
|
|
47
|
+
import { SandboxEngine, type SandboxConfig } from '../sandbox/SandboxEngine.js';
|
|
48
|
+
import { type JsonSerializer } from './serialization/JsonSerializer.js';
|
|
49
|
+
import { StateMachineGate, type FsmConfig } from '../fsm/StateMachineGate.js';
|
|
50
|
+
/**
|
|
51
|
+
* The initialized Vurb instance.
|
|
52
|
+
*
|
|
53
|
+
* Provides context-typed factory methods for tools, presenters,
|
|
54
|
+
* prompts, middleware, and registry. Every method automatically
|
|
55
|
+
* inherits the `TContext` defined in `initVurb<TContext>()`.
|
|
56
|
+
*
|
|
57
|
+
* @typeParam TContext - The application context type
|
|
58
|
+
*/
|
|
59
|
+
export interface VurbInstance<TContext> {
|
|
60
|
+
/**
|
|
61
|
+
* Create a **read-only** query tool (readOnly: true by default).
|
|
62
|
+
*
|
|
63
|
+
* @param name - Tool name in `domain.action` format
|
|
64
|
+
* @returns A type-chaining {@link FluentToolBuilder}
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const listUsers = f.query('users.list')
|
|
69
|
+
* .describe('List users from the database')
|
|
70
|
+
* .withNumber('limit', 'Max results to return')
|
|
71
|
+
* .withOptionalEnum('status', ['active', 'inactive'], 'Filter by status')
|
|
72
|
+
* .handle(async (input, ctx) => {
|
|
73
|
+
* return ctx.db.user.findMany({ take: input.limit });
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
query(name: string): FluentToolBuilder<TContext>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a **destructive** mutation tool (destructive: true by default).
|
|
80
|
+
*
|
|
81
|
+
* @param name - Tool name in `domain.action` format
|
|
82
|
+
* @returns A type-chaining {@link FluentToolBuilder}
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const deleteUser = f.mutation('users.delete')
|
|
87
|
+
* .describe('Delete a user permanently')
|
|
88
|
+
* .withString('id', 'User ID to delete')
|
|
89
|
+
* .handle(async (input, ctx) => {
|
|
90
|
+
* await ctx.db.user.delete({ where: { id: input.id } });
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
mutation(name: string): FluentToolBuilder<TContext>;
|
|
95
|
+
/**
|
|
96
|
+
* Create a **neutral** action tool (no defaults applied).
|
|
97
|
+
*
|
|
98
|
+
* @param name - Tool name in `domain.action` format
|
|
99
|
+
* @returns A type-chaining {@link FluentToolBuilder}
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const updateUser = f.action('users.update')
|
|
104
|
+
* .describe('Update user profile')
|
|
105
|
+
* .idempotent()
|
|
106
|
+
* .withString('id', 'User ID')
|
|
107
|
+
* .withOptionalString('name', 'New display name')
|
|
108
|
+
* .handle(async (input, ctx) => {
|
|
109
|
+
* return ctx.db.user.update({ where: { id: input.id }, data: input });
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
action(name: string): FluentToolBuilder<TContext>;
|
|
114
|
+
/**
|
|
115
|
+
* Define a Presenter with the standard object-config API.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const InvoicePresenter = f.presenter({
|
|
120
|
+
* name: 'Invoice',
|
|
121
|
+
* schema: invoiceSchema,
|
|
122
|
+
* rules: ['CRITICAL: amount_cents is in CENTS.'],
|
|
123
|
+
* ui: (inv) => [ui.echarts({ ... })],
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
presenter<TSchema extends ZodType<any, any, any>>(config: Omit<PresenterConfig<TSchema['_output']>, 'schema'> & {
|
|
128
|
+
schema: TSchema;
|
|
129
|
+
}): Presenter<TSchema['_output']>;
|
|
130
|
+
/**
|
|
131
|
+
* Define a prompt — fluent builder.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const greet = f.prompt('greet')
|
|
136
|
+
* .describe('Greet a user')
|
|
137
|
+
* .withString('name', 'User name')
|
|
138
|
+
* .handler(async (ctx, { name }) => ({
|
|
139
|
+
* messages: [PromptMessage.user(`Hello ${name}!`)],
|
|
140
|
+
* }));
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
prompt(name: string): FluentPromptBuilder<TContext>;
|
|
144
|
+
prompt(name: string, config: Omit<PromptConfig<TContext>, 'handler'> & {
|
|
145
|
+
handler: PromptConfig<TContext>['handler'];
|
|
146
|
+
}): PromptBuilder<TContext>;
|
|
147
|
+
/**
|
|
148
|
+
* Define a context-derivation middleware.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const withUser = f.middleware(async (ctx) => ({
|
|
153
|
+
* user: await ctx.db.users.findUnique(ctx.userId),
|
|
154
|
+
* }));
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
middleware<TDerived extends Record<string, unknown>>(derive: (ctx: TContext) => TDerived | Promise<TDerived>): MiddlewareDefinition<TContext, TDerived>;
|
|
158
|
+
/**
|
|
159
|
+
* Create a pre-typed ToolRegistry ready for registration.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const registry = f.registry();
|
|
164
|
+
* registry.register(listUsers);
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
registry(): ToolRegistry<TContext>;
|
|
168
|
+
/**
|
|
169
|
+
* Create a router that shares prefix, middleware, and tags.
|
|
170
|
+
*
|
|
171
|
+
* @param prefix - Common prefix for all tools (e.g. `'users'`)
|
|
172
|
+
* @returns A {@link FluentRouter} for creating child tools
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const users = f.router('users')
|
|
177
|
+
* .describe('User management')
|
|
178
|
+
* .use(requireAuth);
|
|
179
|
+
*
|
|
180
|
+
* const listUsers = users.query('list')
|
|
181
|
+
* .withNumber('limit', 'Max results')
|
|
182
|
+
* .handle(async (input) => { ... });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
router(prefix: string): FluentRouter<TContext>;
|
|
186
|
+
/**
|
|
187
|
+
* Create a fluent, self-healing error builder.
|
|
188
|
+
*
|
|
189
|
+
* @param code - Canonical error code
|
|
190
|
+
* @param message - Human-readable error message
|
|
191
|
+
* @returns A chaining {@link ErrorBuilder}
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* return f.error('NOT_FOUND', `Project "${id}" not found`)
|
|
196
|
+
* .suggest('Check the list for valid IDs')
|
|
197
|
+
* .actions('projects.list');
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
error(code: ErrorCode, message: string): ErrorBuilder;
|
|
201
|
+
/**
|
|
202
|
+
* Create a fluent builder for centralized State Sync policies.
|
|
203
|
+
*/
|
|
204
|
+
stateSync(): StateSyncBuilder;
|
|
205
|
+
/**
|
|
206
|
+
* Create a tool using the low-level `defineTool()` config.
|
|
207
|
+
* For internal use and advanced scenarios only.
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
defineTool(name: string, config: ToolConfig<TContext>): GroupedToolBuilder<TContext>;
|
|
211
|
+
/**
|
|
212
|
+
* Create a standalone SandboxEngine for advanced use cases.
|
|
213
|
+
*
|
|
214
|
+
* Use when you need direct control over the sandbox lifecycle,
|
|
215
|
+
* or when calling it from custom middleware/handlers.
|
|
216
|
+
*
|
|
217
|
+
* @param config - Optional sandbox configuration
|
|
218
|
+
* @returns A new SandboxEngine instance
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const sandbox = f.sandbox({ timeout: 3000, memoryLimit: 64 });
|
|
223
|
+
* const result = await sandbox.execute(
|
|
224
|
+
* '(data) => data.filter(d => d.risk > 90)',
|
|
225
|
+
* records,
|
|
226
|
+
* );
|
|
227
|
+
* sandbox.dispose();
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
sandbox(config?: SandboxConfig): SandboxEngine;
|
|
231
|
+
/**
|
|
232
|
+
* AOT JSON serializer.
|
|
233
|
+
*
|
|
234
|
+
* Compile Zod schemas into hyper-fast stringify functions at boot time.
|
|
235
|
+
* Used internally by Presenters; exposed here for advanced use cases.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const stringify = f.serializer.compile(myZodSchema);
|
|
240
|
+
* if (stringify) {
|
|
241
|
+
* return success(data, stringify); // 2-5x faster
|
|
242
|
+
* }
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
readonly serializer: JsonSerializer;
|
|
246
|
+
/**
|
|
247
|
+
* Create a Finite State Machine gate for temporal anti-hallucination.
|
|
248
|
+
*
|
|
249
|
+
* Tools bound to FSM states (via `.bindState()`) are dynamically
|
|
250
|
+
* filtered from `tools/list` based on the current workflow state.
|
|
251
|
+
*
|
|
252
|
+
* @param config - FSM definition (states, transitions, initial state)
|
|
253
|
+
* @returns A new StateMachineGate instance
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const gate = f.fsm({
|
|
258
|
+
* id: 'checkout',
|
|
259
|
+
* initial: 'empty',
|
|
260
|
+
* states: {
|
|
261
|
+
* empty: { on: { ADD_ITEM: 'has_items' } },
|
|
262
|
+
* has_items: { on: { CHECKOUT: 'payment' } },
|
|
263
|
+
* payment: { on: { PAY: 'confirmed' } },
|
|
264
|
+
* confirmed: { type: 'final' },
|
|
265
|
+
* },
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
fsm(config: FsmConfig): StateMachineGate;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Initialize a Vurb instance with a fixed context type.
|
|
273
|
+
*
|
|
274
|
+
* Call once per project. All factory methods on the returned instance
|
|
275
|
+
* automatically inherit the context type — zero generic repetition.
|
|
276
|
+
*
|
|
277
|
+
* @typeParam TContext - The application-level context type
|
|
278
|
+
* @returns A {@link VurbInstance} with context-typed factories
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Single definition, typically in src/vurb.ts
|
|
283
|
+
* export const f = initVurb<AppContext>();
|
|
284
|
+
*
|
|
285
|
+
* // Build tools with the Fluent API
|
|
286
|
+
* const listUsers = f.query('users.list')
|
|
287
|
+
* .describe('List all users')
|
|
288
|
+
* .withOptionalNumber('limit', 'Max results (default: 50)')
|
|
289
|
+
* .handle(async (input, ctx) => {
|
|
290
|
+
* return ctx.db.users.findMany({ take: input.limit ?? 50 });
|
|
291
|
+
* });
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
export declare function initVurb<TContext = void>(): VurbInstance<TContext>;
|
|
295
|
+
//# sourceMappingURL=initVurb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initVurb.d.ts","sourceRoot":"","sources":["../../src/core/initVurb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,KAAK,OAAO,EAAoC,MAAM,KAA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SAAS,IAAI,gBAAgB,CAAC;IAI9B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAIrF;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC;IAI/C;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IAIpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,gBAAgB,CAAC;CAC5C;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,GAAG,IAAI,KAAK,YAAY,CAAC,QAAQ,CAAC,CA4FlE"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* initVurb() — tRPC-Style Context Initialization
|
|
3
|
+
*
|
|
4
|
+
* Eliminates the need to pass `<AppContext>` as a generic parameter
|
|
5
|
+
* everywhere. Define your context type once, and every `f.query()`,
|
|
6
|
+
* `f.mutation()`, `f.action()` call automatically inherits it.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // src/vurb.ts — defined once in the project
|
|
11
|
+
* import { initVurb } from 'vurb';
|
|
12
|
+
*
|
|
13
|
+
* interface AppContext {
|
|
14
|
+
* db: PrismaClient;
|
|
15
|
+
* user: { id: string; role: string };
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* export const f = initVurb<AppContext>();
|
|
19
|
+
*
|
|
20
|
+
* // src/tools/billing.ts — clean fluent API
|
|
21
|
+
* import { f } from '../vurb';
|
|
22
|
+
*
|
|
23
|
+
* export const getInvoice = f.query('billing.get_invoice')
|
|
24
|
+
* .describe('Get an invoice by ID')
|
|
25
|
+
* .withString('id', 'The invoice ID')
|
|
26
|
+
* .handle(async (input, ctx) => {
|
|
27
|
+
* return await ctx.db.invoices.findUnique(input.id);
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
import {} from 'zod';
|
|
34
|
+
import { GroupedToolBuilder } from './builder/GroupedToolBuilder.js';
|
|
35
|
+
import {} from './response.js';
|
|
36
|
+
import {} from './types.js';
|
|
37
|
+
import { ToolRegistry } from './registry/ToolRegistry.js';
|
|
38
|
+
import {} from '../presenter/Presenter.js';
|
|
39
|
+
import { definePresenter } from '../presenter/definePresenter.js';
|
|
40
|
+
import { defineMiddleware } from './middleware/index.js';
|
|
41
|
+
import { defineTool } from './builder/defineTool.js';
|
|
42
|
+
import { definePrompt } from '../prompt/definePrompt.js';
|
|
43
|
+
import { FluentPromptBuilder } from '../prompt/FluentPromptBuilder.js';
|
|
44
|
+
import {} from '../prompt/types.js';
|
|
45
|
+
import { FluentToolBuilder, QUERY_DEFAULTS, MUTATION_DEFAULTS, ACTION_DEFAULTS, } from './builder/FluentToolBuilder.js';
|
|
46
|
+
import { FluentRouter } from './builder/FluentRouter.js';
|
|
47
|
+
import { ErrorBuilder } from './builder/ErrorBuilder.js';
|
|
48
|
+
import { StateSyncBuilder } from '../state-sync/StateSyncBuilder.js';
|
|
49
|
+
import {} from './response.js';
|
|
50
|
+
import { SandboxEngine } from '../sandbox/SandboxEngine.js';
|
|
51
|
+
import { defaultSerializer } from './serialization/JsonSerializer.js';
|
|
52
|
+
import { StateMachineGate } from '../fsm/StateMachineGate.js';
|
|
53
|
+
// ── Factory ──────────────────────────────────────────────
|
|
54
|
+
/**
|
|
55
|
+
* Initialize a Vurb instance with a fixed context type.
|
|
56
|
+
*
|
|
57
|
+
* Call once per project. All factory methods on the returned instance
|
|
58
|
+
* automatically inherit the context type — zero generic repetition.
|
|
59
|
+
*
|
|
60
|
+
* @typeParam TContext - The application-level context type
|
|
61
|
+
* @returns A {@link VurbInstance} with context-typed factories
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Single definition, typically in src/vurb.ts
|
|
66
|
+
* export const f = initVurb<AppContext>();
|
|
67
|
+
*
|
|
68
|
+
* // Build tools with the Fluent API
|
|
69
|
+
* const listUsers = f.query('users.list')
|
|
70
|
+
* .describe('List all users')
|
|
71
|
+
* .withOptionalNumber('limit', 'Max results (default: 50)')
|
|
72
|
+
* .handle(async (input, ctx) => {
|
|
73
|
+
* return ctx.db.users.findMany({ take: input.limit ?? 50 });
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export function initVurb() {
|
|
78
|
+
return {
|
|
79
|
+
// ── Semantic Verbs ────────────────────────────────
|
|
80
|
+
query(name) {
|
|
81
|
+
return new FluentToolBuilder(name, QUERY_DEFAULTS);
|
|
82
|
+
},
|
|
83
|
+
mutation(name) {
|
|
84
|
+
return new FluentToolBuilder(name, MUTATION_DEFAULTS);
|
|
85
|
+
},
|
|
86
|
+
action(name) {
|
|
87
|
+
return new FluentToolBuilder(name, ACTION_DEFAULTS);
|
|
88
|
+
},
|
|
89
|
+
// ── MVA Presenter ────────────────────────────────
|
|
90
|
+
presenter(config) {
|
|
91
|
+
return definePresenter(config);
|
|
92
|
+
},
|
|
93
|
+
// ── Prompts ──────────────────────────────────────
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
prompt(name, config) {
|
|
96
|
+
if (!config) {
|
|
97
|
+
return new FluentPromptBuilder(name);
|
|
98
|
+
}
|
|
99
|
+
return definePrompt(name, config);
|
|
100
|
+
},
|
|
101
|
+
// ── Middleware ───────────────────────────────────
|
|
102
|
+
middleware(derive) {
|
|
103
|
+
return defineMiddleware(derive);
|
|
104
|
+
},
|
|
105
|
+
// ── Registry ─────────────────────────────────────
|
|
106
|
+
registry() {
|
|
107
|
+
return new ToolRegistry();
|
|
108
|
+
},
|
|
109
|
+
// ── Router ───────────────────────────────────────
|
|
110
|
+
router(prefix) {
|
|
111
|
+
return new FluentRouter(prefix);
|
|
112
|
+
},
|
|
113
|
+
// ── Error Builder ────────────────────────────────
|
|
114
|
+
error(code, message) {
|
|
115
|
+
return new ErrorBuilder(code, message);
|
|
116
|
+
},
|
|
117
|
+
// ── State Sync ───────────────────────────────────
|
|
118
|
+
stateSync() {
|
|
119
|
+
return new StateSyncBuilder();
|
|
120
|
+
},
|
|
121
|
+
// ── Internal / Advanced ──────────────────────────
|
|
122
|
+
defineTool(name, config) {
|
|
123
|
+
return defineTool(name, config);
|
|
124
|
+
},
|
|
125
|
+
// ── Sandbox ──────────────────────────────────────
|
|
126
|
+
sandbox(config) {
|
|
127
|
+
const engine = new SandboxEngine(config);
|
|
128
|
+
// Bug #141: warn when engines are garbage-collected without dispose().
|
|
129
|
+
// V8 Isolates hold native memory invisible to the Node GC.
|
|
130
|
+
_trackSandboxDispose(engine);
|
|
131
|
+
return engine;
|
|
132
|
+
},
|
|
133
|
+
// ── Serialization ────────────────────────────────
|
|
134
|
+
serializer: defaultSerializer,
|
|
135
|
+
// ── FSM State Gate ─────────────────────────────
|
|
136
|
+
fsm(config) {
|
|
137
|
+
return new StateMachineGate(config);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// ── Bug #141: FinalizationRegistry leak-detection for SandboxEngine ──
|
|
142
|
+
/**
|
|
143
|
+
* Track SandboxEngine instances and emit a console.warn when one is
|
|
144
|
+
* garbage-collected without being disposed first. V8 Isolates hold
|
|
145
|
+
* native C++ memory invisible to the Node.js GC — a forgotten
|
|
146
|
+
* `.dispose()` silently leaks until process exit.
|
|
147
|
+
*
|
|
148
|
+
* Uses `FinalizationRegistry` (ES2021). No-op if the API is unavailable.
|
|
149
|
+
* The warning is best-effort — GC timing is non-deterministic.
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
const _sandboxFinalizer = typeof FinalizationRegistry !== 'undefined'
|
|
153
|
+
? new FinalizationRegistry((label) => {
|
|
154
|
+
console.warn(`[vurb] SandboxEngine was garbage-collected without dispose(). ` +
|
|
155
|
+
`This leaks native V8 Isolate memory. Call engine.dispose() when done. (${label})`);
|
|
156
|
+
})
|
|
157
|
+
: undefined;
|
|
158
|
+
/** @internal */
|
|
159
|
+
function _trackSandboxDispose(engine) {
|
|
160
|
+
if (!_sandboxFinalizer)
|
|
161
|
+
return;
|
|
162
|
+
const label = `created at ${new Date().toISOString()}`;
|
|
163
|
+
_sandboxFinalizer.register(engine, label, engine);
|
|
164
|
+
// When dispose() is called, unregister so no false warning fires
|
|
165
|
+
const originalDispose = engine.dispose.bind(engine);
|
|
166
|
+
engine.dispose = () => {
|
|
167
|
+
_sandboxFinalizer.unregister(engine);
|
|
168
|
+
originalDispose();
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=initVurb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initVurb.js","sourceRoot":"","sources":["../../src/core/initVurb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAkD,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAqB,MAAM,eAAe,CAAC;AAClD,OAAO,EAAqB,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAwB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAA6B,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAA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gBAAgB;AAChB,SAAS,oBAAoB,CAAC,MAAqB;IAC/C,IAAI,CAAC,iBAAiB;QAAE,OAAO;IAC/B,MAAM,KAAK,GAAG,cAAc,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IACvD,iBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,iEAAiE;IACjE,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;QAClB,iBAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,eAAe,EAAE,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* defineMiddleware() — Context Derivation (tRPC-style)
|
|
3
|
+
*
|
|
4
|
+
* Middlewares that return data have that data merged into the context
|
|
5
|
+
* for downstream handlers. TypeScript infers the derived context type
|
|
6
|
+
* automatically, so removing a middleware causes a compile error
|
|
7
|
+
* if the handler accesses properties that middleware provided.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const requireAuth = defineMiddleware(async (ctx: BaseCtx) => {
|
|
12
|
+
* const user = await db.getUser(ctx.token);
|
|
13
|
+
* if (!user) throw new Error('Unauthorized');
|
|
14
|
+
* return { user }; // ← TS infers: { user: User }
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const billing = defineTool('billing', {
|
|
18
|
+
* middleware: [requireAuth],
|
|
19
|
+
* actions: {
|
|
20
|
+
* refund: {
|
|
21
|
+
* handler: async (ctx, args) => {
|
|
22
|
+
* // ctx.user EXISTS and is typed! ✅
|
|
23
|
+
* return success(`Refunded by ${ctx.user.id}`);
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* },
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import { type MiddlewareFn } from '../types.js';
|
|
33
|
+
/**
|
|
34
|
+
* A middleware definition that derives additional context.
|
|
35
|
+
*
|
|
36
|
+
* The `derive` function receives the current context and returns
|
|
37
|
+
* an object whose properties are merged into the context for
|
|
38
|
+
* downstream middleware and the final handler.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam TContextIn - The input context type
|
|
41
|
+
* @typeParam TDerived - The derived properties to merge
|
|
42
|
+
*/
|
|
43
|
+
export interface MiddlewareDefinition<TContextIn, TDerived extends Record<string, unknown>> {
|
|
44
|
+
/** Brand for type discrimination */
|
|
45
|
+
readonly __brand: 'MiddlewareDefinition';
|
|
46
|
+
/** The derive function */
|
|
47
|
+
readonly derive: (ctx: TContextIn) => Promise<TDerived> | TDerived;
|
|
48
|
+
/**
|
|
49
|
+
* Convert to a standard MiddlewareFn for use in existing pipelines.
|
|
50
|
+
* The derived properties are merged into `ctx` before calling `next()`.
|
|
51
|
+
*/
|
|
52
|
+
readonly toMiddlewareFn: () => MiddlewareFn<TContextIn>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Utility type: merge a base context with derived properties.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* type Base = { token: string };
|
|
60
|
+
* type Derived = { user: User };
|
|
61
|
+
* type Result = MergeContext<Base, Derived>;
|
|
62
|
+
* // Result = { token: string; user: User }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export type MergeContext<TBase, TDerived> = TBase & TDerived;
|
|
66
|
+
/**
|
|
67
|
+
* Utility type: infer the output context from a MiddlewareDefinition.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const auth = defineMiddleware(async (ctx: Base) => ({ user }));
|
|
72
|
+
* type Ctx = InferContextOut<Base, typeof auth>;
|
|
73
|
+
* // Ctx = Base & { user: User }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export type InferContextOut<TContextIn, TMw extends MiddlewareDefinition<TContextIn, Record<string, unknown>>> = TMw extends MiddlewareDefinition<TContextIn, infer TDerived> ? TContextIn & TDerived : never;
|
|
77
|
+
/**
|
|
78
|
+
* Define a context-deriving middleware.
|
|
79
|
+
*
|
|
80
|
+
* The returned object can be used in two ways:
|
|
81
|
+
* 1. As a type-level constraint (the generics carry the derived context)
|
|
82
|
+
* 2. As a runtime middleware via `.toMiddlewareFn()` (for the existing pipeline)
|
|
83
|
+
*
|
|
84
|
+
* @typeParam TContextIn - The input context type
|
|
85
|
+
* @typeParam TDerived - Auto-inferred derived properties
|
|
86
|
+
* @param derive - Function that inspects context and returns derived data
|
|
87
|
+
* @returns A {@link MiddlewareDefinition} with the derived type encoded
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* // Auth middleware that derives `user`
|
|
92
|
+
* const requireAuth = defineMiddleware(async (ctx: { token: string }) => {
|
|
93
|
+
* const user = await db.getUser(ctx.token);
|
|
94
|
+
* if (!user) throw new Error('Unauthorized');
|
|
95
|
+
* return { user };
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Rate limit middleware that derives `rateLimitInfo`
|
|
99
|
+
* const rateLimit = defineMiddleware(async (ctx: { ip: string }) => {
|
|
100
|
+
* const info = await checkRateLimit(ctx.ip);
|
|
101
|
+
* if (info.exceeded) throw new Error('Rate limited');
|
|
102
|
+
* return { rateLimitInfo: info };
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @see {@link MiddlewareFn} for the standard middleware type
|
|
107
|
+
*/
|
|
108
|
+
export declare function defineMiddleware<TContextIn, TDerived extends Record<string, unknown>>(derive: (ctx: TContextIn) => Promise<TDerived> | TDerived): MiddlewareDefinition<TContextIn, TDerived>;
|
|
109
|
+
/**
|
|
110
|
+
* Type guard: check if a value is a MiddlewareDefinition.
|
|
111
|
+
*
|
|
112
|
+
* Used internally to auto-convert MiddlewareDefinitions to MiddlewareFns
|
|
113
|
+
* when passed to `defineTool({ middleware: [...] })`.
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
export declare function isMiddlewareDefinition<TContext>(value: unknown): value is MiddlewareDefinition<TContext, Record<string, unknown>>;
|
|
118
|
+
/**
|
|
119
|
+
* Convert a middleware arg (either MiddlewareFn or MiddlewareDefinition) to MiddlewareFn.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
export declare function resolveMiddleware<TContext>(mw: MiddlewareFn<TContext> | MiddlewareDefinition<TContext, Record<string, unknown>>): MiddlewareFn<TContext>;
|
|
124
|
+
//# sourceMappingURL=ContextDerivation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextDerivation.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/ContextDerivation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAMhD;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB,CAAC,UAAU,EAAE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACtF,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACnE;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,EAAE,QAAQ,IAAI,KAAK,GAAG,QAAQ,CAAC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