@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,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionGroupBuilder — Sub-builder for Hierarchical Action Groups
|
|
3
|
+
*
|
|
4
|
+
* Used within {@link GroupedToolBuilder.group} callbacks to register
|
|
5
|
+
* actions under a named group. Supports group-scoped middleware and
|
|
6
|
+
* generates compound keys (e.g., `"users.create"`).
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TContext - Application context type
|
|
9
|
+
* @typeParam TCommon - Common schema shape (inferred from parent builder)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* createTool<AppContext>('platform')
|
|
14
|
+
* .group('users', 'User management', g => g
|
|
15
|
+
* .use(requireAdmin)
|
|
16
|
+
* .query('list', async (ctx) => success(await ctx.db.users.findMany()))
|
|
17
|
+
* .mutation('ban', async (ctx, args) => {
|
|
18
|
+
* await ctx.db.users.ban(args.user_id);
|
|
19
|
+
* return success('User banned');
|
|
20
|
+
* })
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link GroupedToolBuilder.group} for creating groups
|
|
25
|
+
* @see {@link MiddlewareFn} for middleware signature
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { type ZodObject, type ZodRawShape } from 'zod';
|
|
30
|
+
import { type ToolResponse, type InternalAction, type MiddlewareFn, type ActionConfig } from '../types.js';
|
|
31
|
+
import { type MiddlewareDefinition } from '../middleware/ContextDerivation.js';
|
|
32
|
+
/**
|
|
33
|
+
* Callback for configuring actions within a group.
|
|
34
|
+
*
|
|
35
|
+
* Receives an {@link ActionGroupBuilder} to register actions and middleware.
|
|
36
|
+
*
|
|
37
|
+
* @typeParam TContext - Application context type
|
|
38
|
+
* @typeParam TCommon - Common schema shape
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const configure: GroupConfigurator<AppContext, { workspace_id: string }> = (g) => g
|
|
43
|
+
* .query('list', listHandler)
|
|
44
|
+
* .mutation('delete', deleteHandler);
|
|
45
|
+
*
|
|
46
|
+
* builder.group('users', 'User management', configure);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export type GroupConfigurator<TContext, TCommon extends Record<string, unknown>> = (group: ActionGroupBuilder<TContext, TCommon>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Map `ActionConfig` properties to `InternalAction` base fields.
|
|
52
|
+
*
|
|
53
|
+
* Both `GroupedToolBuilder.action()` and `ActionGroupBuilder.action()`
|
|
54
|
+
* perform this same mapping. Extracted here to eliminate duplication
|
|
55
|
+
* and ensure a single source of truth.
|
|
56
|
+
*
|
|
57
|
+
* @param config - The action configuration from the public API
|
|
58
|
+
* @param omitCommonFields - Resolved omitCommon fields (already merged/deduped)
|
|
59
|
+
* @returns Base fields for building an `InternalAction`
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function mapConfigToActionFields<TContext>(config: ActionConfig<TContext>, omitCommonFields: string[] | undefined): Pick<InternalAction<TContext>, 'actionName' | 'description' | 'schema' | 'destructive' | 'idempotent' | 'readOnly' | 'handler' | 'omitCommonFields' | 'returns'>;
|
|
64
|
+
/**
|
|
65
|
+
* Handler function type for semantic verb shortcuts.
|
|
66
|
+
* @typeParam TContext - Application context type
|
|
67
|
+
*/
|
|
68
|
+
type ActionHandler<TContext> = (ctx: TContext, args: Record<string, unknown>) => Promise<ToolResponse>;
|
|
69
|
+
export declare class ActionGroupBuilder<TContext, TCommon extends Record<string, unknown> = Record<string, never>> {
|
|
70
|
+
/** @internal */
|
|
71
|
+
readonly _actions: InternalAction<TContext>[];
|
|
72
|
+
private readonly _groupName;
|
|
73
|
+
private readonly _groupDescription;
|
|
74
|
+
private readonly _groupMiddlewares;
|
|
75
|
+
private _groupOmitCommon;
|
|
76
|
+
constructor(groupName: string, description?: string);
|
|
77
|
+
/**
|
|
78
|
+
* Add middleware scoped to this group only.
|
|
79
|
+
*
|
|
80
|
+
* Unlike {@link GroupedToolBuilder.use}, this middleware runs
|
|
81
|
+
* only for actions within this group — not globally.
|
|
82
|
+
*
|
|
83
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
84
|
+
* raw `MiddlewareFn` functions.
|
|
85
|
+
*
|
|
86
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
87
|
+
* @returns `this` for chaining
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* builder.group('admin', 'Admin operations', (g) => g
|
|
92
|
+
* .use(requireAdmin)
|
|
93
|
+
* .query('list', listHandler)
|
|
94
|
+
* .mutation('reset', resetHandler)
|
|
95
|
+
* );
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @see {@link MiddlewareFn} for the middleware signature
|
|
99
|
+
*/
|
|
100
|
+
use(mw: MiddlewareFn<TContext> | MiddlewareDefinition<TContext, Record<string, unknown>>): this;
|
|
101
|
+
/**
|
|
102
|
+
* Omit common schema fields for all actions in this group.
|
|
103
|
+
*
|
|
104
|
+
* Use when an entire group derives common fields from context
|
|
105
|
+
* (e.g. a "profile" group that resolves `workspace_id` from the JWT).
|
|
106
|
+
*
|
|
107
|
+
* Per-action `omitCommon` merges with group-level omissions.
|
|
108
|
+
*
|
|
109
|
+
* @param fields - Common field names to omit
|
|
110
|
+
* @returns `this` for chaining
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* builder.group('profile', 'User profile', (g) => g
|
|
115
|
+
* .omitCommon('workspace_id')
|
|
116
|
+
* .query('me', meHandler)
|
|
117
|
+
* );
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
omitCommon(...fields: string[]): this;
|
|
121
|
+
/**
|
|
122
|
+
* Register a **read-only** action (readOnly: true).
|
|
123
|
+
*
|
|
124
|
+
* Semantic shortcut — eliminates the need for config objects.
|
|
125
|
+
* The action name is automatically prefixed with the group name
|
|
126
|
+
* (e.g., `"list"` in group `"users"` → `"users.list"`).
|
|
127
|
+
*
|
|
128
|
+
* @param name - Action name (must not contain dots)
|
|
129
|
+
* @param handler - Handler function
|
|
130
|
+
* @returns `this` for chaining
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* builder.group('users', 'User management', (g) => g
|
|
135
|
+
* .query('list', async (ctx) => success(await ctx.db.users.findMany()))
|
|
136
|
+
* .query('get', async (ctx, args) => success(await ctx.db.users.find(args.id)))
|
|
137
|
+
* );
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
query(name: string, handler: ActionHandler<TContext>): this;
|
|
141
|
+
/**
|
|
142
|
+
* Register a **destructive** action (destructive: true).
|
|
143
|
+
*
|
|
144
|
+
* Semantic shortcut — eliminates the need for config objects.
|
|
145
|
+
* Signals to the LLM that this action has irreversible side effects.
|
|
146
|
+
*
|
|
147
|
+
* @param name - Action name (must not contain dots)
|
|
148
|
+
* @param handler - Handler function
|
|
149
|
+
* @returns `this` for chaining
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* builder.group('users', 'User management', (g) => g
|
|
154
|
+
* .mutation('ban', async (ctx, args) => {
|
|
155
|
+
* await ctx.db.users.ban(args.user_id);
|
|
156
|
+
* return success('User banned');
|
|
157
|
+
* })
|
|
158
|
+
* );
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
mutation(name: string, handler: ActionHandler<TContext>): this;
|
|
162
|
+
/**
|
|
163
|
+
* Register an action within this group.
|
|
164
|
+
*
|
|
165
|
+
* **As a 2-arg shortcut** `action(name, handler)`: registers a standard
|
|
166
|
+
* action (neither read-only nor destructive). This completes the
|
|
167
|
+
* semantic verb trio alongside `.query()` and `.mutation()`.
|
|
168
|
+
*
|
|
169
|
+
* **As a config object** `action({ name, schema, ... })`: full control
|
|
170
|
+
* over all action properties (schema, description, omitCommon, etc.).
|
|
171
|
+
*
|
|
172
|
+
* The action key is automatically prefixed with the group name
|
|
173
|
+
* (e.g., action `"create"` in group `"users"` becomes `"users.create"`).
|
|
174
|
+
*
|
|
175
|
+
* @param config - Action configuration OR action name (string)
|
|
176
|
+
* @param handler - Handler function (only when first arg is a string)
|
|
177
|
+
* @returns `this` for chaining
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* builder.group('users', 'User management', (g) => g
|
|
182
|
+
* .query('list', listHandler)
|
|
183
|
+
* .action('invite', inviteHandler)
|
|
184
|
+
* .mutation('ban', banHandler)
|
|
185
|
+
* );
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @see {@link ActionGroupBuilder.query} — read-only actions
|
|
189
|
+
* @see {@link ActionGroupBuilder.mutation} — destructive actions
|
|
190
|
+
* @see {@link ActionConfig} for all configuration options
|
|
191
|
+
*/
|
|
192
|
+
action<TSchema extends ZodObject<ZodRawShape>, TOmit extends keyof TCommon = never>(config: {
|
|
193
|
+
name: string;
|
|
194
|
+
description?: string;
|
|
195
|
+
schema: TSchema;
|
|
196
|
+
destructive?: boolean;
|
|
197
|
+
idempotent?: boolean;
|
|
198
|
+
readOnly?: boolean;
|
|
199
|
+
omitCommon?: TOmit[];
|
|
200
|
+
handler: (ctx: TContext, args: TSchema["_output"] & Omit<TCommon, TOmit>) => Promise<ToolResponse>;
|
|
201
|
+
}): this;
|
|
202
|
+
/** Register a standard action (2-arg shorthand: neither readOnly nor destructive) */
|
|
203
|
+
action(name: string, handler: ActionHandler<TContext>): this;
|
|
204
|
+
/** Register an action within this group (config object) */
|
|
205
|
+
action(config: ActionConfig<TContext>): this;
|
|
206
|
+
}
|
|
207
|
+
export {};
|
|
208
|
+
//# sourceMappingURL=ActionGroupBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionGroupBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,oCAAoC,CAAC;AAElG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,iBAAiB,CAAC,QAAQ,EAAE,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC3E,CAAC,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAI3D;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAC5C,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,EAC9B,gBAAgB,EAAE,MAAM,EAAE,GAAG,SAAS,GACvC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC5B,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,aAAa,GACvD,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CACzE,CAYA;AAID;;;GAGG;AACH,KAAK,aAAa,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,Y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,OAAO,CAAC;QAChB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;KACtG,GAAG,IAAI;IACR,qFAAqF;IACrF,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI;IAC5D,2DAA2D;IAC3D,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI;CAoC/C"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionGroupBuilder — Sub-builder for Hierarchical Action Groups
|
|
3
|
+
*
|
|
4
|
+
* Used within {@link GroupedToolBuilder.group} callbacks to register
|
|
5
|
+
* actions under a named group. Supports group-scoped middleware and
|
|
6
|
+
* generates compound keys (e.g., `"users.create"`).
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TContext - Application context type
|
|
9
|
+
* @typeParam TCommon - Common schema shape (inferred from parent builder)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* createTool<AppContext>('platform')
|
|
14
|
+
* .group('users', 'User management', g => g
|
|
15
|
+
* .use(requireAdmin)
|
|
16
|
+
* .query('list', async (ctx) => success(await ctx.db.users.findMany()))
|
|
17
|
+
* .mutation('ban', async (ctx, args) => {
|
|
18
|
+
* await ctx.db.users.ban(args.user_id);
|
|
19
|
+
* return success('User banned');
|
|
20
|
+
* })
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link GroupedToolBuilder.group} for creating groups
|
|
25
|
+
* @see {@link MiddlewareFn} for middleware signature
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import {} from 'zod';
|
|
30
|
+
import {} from '../types.js';
|
|
31
|
+
import { resolveMiddleware } from '../middleware/ContextDerivation.js';
|
|
32
|
+
// ── Shared Config → InternalAction Mapper ────────────────
|
|
33
|
+
/**
|
|
34
|
+
* Map `ActionConfig` properties to `InternalAction` base fields.
|
|
35
|
+
*
|
|
36
|
+
* Both `GroupedToolBuilder.action()` and `ActionGroupBuilder.action()`
|
|
37
|
+
* perform this same mapping. Extracted here to eliminate duplication
|
|
38
|
+
* and ensure a single source of truth.
|
|
39
|
+
*
|
|
40
|
+
* @param config - The action configuration from the public API
|
|
41
|
+
* @param omitCommonFields - Resolved omitCommon fields (already merged/deduped)
|
|
42
|
+
* @returns Base fields for building an `InternalAction`
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export function mapConfigToActionFields(config, omitCommonFields) {
|
|
47
|
+
return {
|
|
48
|
+
actionName: config.name,
|
|
49
|
+
description: config.description ?? undefined,
|
|
50
|
+
schema: config.schema ?? undefined,
|
|
51
|
+
destructive: config.destructive ?? undefined,
|
|
52
|
+
idempotent: config.idempotent ?? undefined,
|
|
53
|
+
readOnly: config.readOnly ?? undefined,
|
|
54
|
+
handler: config.handler,
|
|
55
|
+
omitCommonFields: (omitCommonFields?.length ?? 0) > 0 ? omitCommonFields : undefined,
|
|
56
|
+
returns: config.returns ?? undefined,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// ── ActionGroupBuilder ───────────────────────────────────
|
|
60
|
+
export class ActionGroupBuilder {
|
|
61
|
+
/** @internal */
|
|
62
|
+
_actions = [];
|
|
63
|
+
_groupName;
|
|
64
|
+
_groupDescription;
|
|
65
|
+
_groupMiddlewares = [];
|
|
66
|
+
_groupOmitCommon = [];
|
|
67
|
+
constructor(groupName, description) {
|
|
68
|
+
this._groupName = groupName;
|
|
69
|
+
this._groupDescription = description || '';
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Add middleware scoped to this group only.
|
|
73
|
+
*
|
|
74
|
+
* Unlike {@link GroupedToolBuilder.use}, this middleware runs
|
|
75
|
+
* only for actions within this group — not globally.
|
|
76
|
+
*
|
|
77
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
78
|
+
* raw `MiddlewareFn` functions.
|
|
79
|
+
*
|
|
80
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
81
|
+
* @returns `this` for chaining
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* builder.group('admin', 'Admin operations', (g) => g
|
|
86
|
+
* .use(requireAdmin)
|
|
87
|
+
* .query('list', listHandler)
|
|
88
|
+
* .mutation('reset', resetHandler)
|
|
89
|
+
* );
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @see {@link MiddlewareFn} for the middleware signature
|
|
93
|
+
*/
|
|
94
|
+
use(mw) {
|
|
95
|
+
this._groupMiddlewares.push(resolveMiddleware(mw));
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Omit common schema fields for all actions in this group.
|
|
100
|
+
*
|
|
101
|
+
* Use when an entire group derives common fields from context
|
|
102
|
+
* (e.g. a "profile" group that resolves `workspace_id` from the JWT).
|
|
103
|
+
*
|
|
104
|
+
* Per-action `omitCommon` merges with group-level omissions.
|
|
105
|
+
*
|
|
106
|
+
* @param fields - Common field names to omit
|
|
107
|
+
* @returns `this` for chaining
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* builder.group('profile', 'User profile', (g) => g
|
|
112
|
+
* .omitCommon('workspace_id')
|
|
113
|
+
* .query('me', meHandler)
|
|
114
|
+
* );
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
omitCommon(...fields) {
|
|
118
|
+
this._groupOmitCommon.push(...fields);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
// ── Semantic Verb Shortcuts ──────────────────────────
|
|
122
|
+
/**
|
|
123
|
+
* Register a **read-only** action (readOnly: true).
|
|
124
|
+
*
|
|
125
|
+
* Semantic shortcut — eliminates the need for config objects.
|
|
126
|
+
* The action name is automatically prefixed with the group name
|
|
127
|
+
* (e.g., `"list"` in group `"users"` → `"users.list"`).
|
|
128
|
+
*
|
|
129
|
+
* @param name - Action name (must not contain dots)
|
|
130
|
+
* @param handler - Handler function
|
|
131
|
+
* @returns `this` for chaining
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* builder.group('users', 'User management', (g) => g
|
|
136
|
+
* .query('list', async (ctx) => success(await ctx.db.users.findMany()))
|
|
137
|
+
* .query('get', async (ctx, args) => success(await ctx.db.users.find(args.id)))
|
|
138
|
+
* );
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
query(name, handler) {
|
|
142
|
+
return this.action({ name, readOnly: true, handler });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Register a **destructive** action (destructive: true).
|
|
146
|
+
*
|
|
147
|
+
* Semantic shortcut — eliminates the need for config objects.
|
|
148
|
+
* Signals to the LLM that this action has irreversible side effects.
|
|
149
|
+
*
|
|
150
|
+
* @param name - Action name (must not contain dots)
|
|
151
|
+
* @param handler - Handler function
|
|
152
|
+
* @returns `this` for chaining
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* builder.group('users', 'User management', (g) => g
|
|
157
|
+
* .mutation('ban', async (ctx, args) => {
|
|
158
|
+
* await ctx.db.users.ban(args.user_id);
|
|
159
|
+
* return success('User banned');
|
|
160
|
+
* })
|
|
161
|
+
* );
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
mutation(name, handler) {
|
|
165
|
+
return this.action({ name, destructive: true, handler });
|
|
166
|
+
}
|
|
167
|
+
action(configOrName, maybeHandler) {
|
|
168
|
+
// 2-arg shorthand: action('invite', inviteHandler)
|
|
169
|
+
if (typeof configOrName === 'string' && typeof maybeHandler !== 'function') {
|
|
170
|
+
throw new Error(`action("${configOrName}") requires a handler function as the second argument.`);
|
|
171
|
+
}
|
|
172
|
+
const config = typeof configOrName === 'string'
|
|
173
|
+
? { name: configOrName, handler: maybeHandler }
|
|
174
|
+
: configOrName;
|
|
175
|
+
if (config.name.includes('.')) {
|
|
176
|
+
throw new Error(`Action name "${config.name}" must not contain dots. ` +
|
|
177
|
+
`The framework uses dots internally for group.action compound keys.`);
|
|
178
|
+
}
|
|
179
|
+
// Merge group-level + per-action omissions (deduped)
|
|
180
|
+
const perAction = config.omitCommon ?? [];
|
|
181
|
+
const mergedOmit = [...new Set([...this._groupOmitCommon, ...perAction])];
|
|
182
|
+
this._actions.push({
|
|
183
|
+
key: `${this._groupName}.${config.name}`,
|
|
184
|
+
groupName: this._groupName,
|
|
185
|
+
groupDescription: this._groupDescription,
|
|
186
|
+
...mapConfigToActionFields(config, mergedOmit),
|
|
187
|
+
middlewares: this._groupMiddlewares.length > 0
|
|
188
|
+
? [...this._groupMiddlewares] : undefined,
|
|
189
|
+
});
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=ActionGroupBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionGroupBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAoC,MAAM,KAAK,CAAC;AACvD,OAAO,EAKN,MAAM,aAAa,CAAC;AACrB,OAAO,EAA6B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAsBlG,4DAA4D;AAE5D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU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,UAAU,IAAI,MAAM,CAAC,IAAI,EAAE;YACxC,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;YACxC,GAAG,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC;YAC9C,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;gBAC1C,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS;SAChD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ErrorCode, ErrorSeverity, ToolResponse } from '../response.js';
|
|
2
|
+
/**
|
|
3
|
+
* ErrorBuilder — Fluent API for Self-Healing Errors
|
|
4
|
+
*
|
|
5
|
+
* Provides a chaining interface to construct structured tool errors
|
|
6
|
+
* with recovery suggestions, available actions, and metadata.
|
|
7
|
+
*
|
|
8
|
+
* Designed to be used via `f.error()` in a tool handler.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* return f.error('NOT_FOUND', `Project "${id}" missing`)
|
|
13
|
+
* .suggest('Check the ID and try again')
|
|
14
|
+
* .actions('projects.list')
|
|
15
|
+
* .critical();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class ErrorBuilder {
|
|
19
|
+
private _message;
|
|
20
|
+
private _code;
|
|
21
|
+
private _suggestion?;
|
|
22
|
+
private _actions;
|
|
23
|
+
private _severity;
|
|
24
|
+
private _details;
|
|
25
|
+
private _retryAfter?;
|
|
26
|
+
/** @internal Cached build result — invalidated by any setter */
|
|
27
|
+
private _cached;
|
|
28
|
+
constructor(code: ErrorCode, message: string);
|
|
29
|
+
/** Add a recovery suggestion for the LLM agent */
|
|
30
|
+
suggest(suggestion: string): this;
|
|
31
|
+
/** List tool names the agent should try instead */
|
|
32
|
+
actions(...names: string[]): this;
|
|
33
|
+
/** Set error severity (default: 'error') */
|
|
34
|
+
severity(level: ErrorSeverity): this;
|
|
35
|
+
/** Set severity to 'critical' (stops agent execution) */
|
|
36
|
+
critical(): this;
|
|
37
|
+
/** Set severity to 'warning' (non-fatal guidance) */
|
|
38
|
+
warning(): this;
|
|
39
|
+
/** Add structured metadata details about the error */
|
|
40
|
+
details(data: Record<string, string | number | boolean>): this;
|
|
41
|
+
/** Suggest a retry delay in seconds for transient errors */
|
|
42
|
+
retryAfter(seconds: number): this;
|
|
43
|
+
/**
|
|
44
|
+
* Build the final {@link ToolResponse}.
|
|
45
|
+
*
|
|
46
|
+
* Note: The execution pipeline also accepts the builder instance
|
|
47
|
+
* directly and calls this method automatically.
|
|
48
|
+
*/
|
|
49
|
+
build(): ToolResponse;
|
|
50
|
+
/** @internal Ensure the response is built and cached */
|
|
51
|
+
private _ensureBuilt;
|
|
52
|
+
/** Implementation of ToolResponse for direct return in handlers */
|
|
53
|
+
get content(): readonly {
|
|
54
|
+
readonly type: "text";
|
|
55
|
+
readonly text: string;
|
|
56
|
+
}[];
|
|
57
|
+
get isError(): boolean | undefined;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ErrorBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/ErrorBuilder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,gEAAgE;IAChE,OAAO,CAAC,OAAO,CAAuC;gBAE1C,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM;IAK5C,kDAAkD;IAClD,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAMjC,mDAAmD;IACnD,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAMjC,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAMpC,yDAAyD;IACzD,QAAQ,IAAI,IAAI;IAEhB,qDAAqD;IACrD,OAAO,IAAI,IAAI;IAEf,sDAAsD;IACtD,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI;IAQ9D,4DAA4D;IAC5D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMjC;;;;;OAKG;IACH,KAAK,IAAI,YAAY;IAmBrB,wDAAwD;IACxD,OAAO,CAAC,YAAY;IAKpB,mEAAmE;IACnE,IAAI,OAAO;;;QAA0C;IACrD,IAAI,OAAO,wBAA0C;CACxD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { toolError } from '../response.js';
|
|
2
|
+
/**
|
|
3
|
+
* ErrorBuilder — Fluent API for Self-Healing Errors
|
|
4
|
+
*
|
|
5
|
+
* Provides a chaining interface to construct structured tool errors
|
|
6
|
+
* with recovery suggestions, available actions, and metadata.
|
|
7
|
+
*
|
|
8
|
+
* Designed to be used via `f.error()` in a tool handler.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* return f.error('NOT_FOUND', `Project "${id}" missing`)
|
|
13
|
+
* .suggest('Check the ID and try again')
|
|
14
|
+
* .actions('projects.list')
|
|
15
|
+
* .critical();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class ErrorBuilder {
|
|
19
|
+
_message;
|
|
20
|
+
_code;
|
|
21
|
+
_suggestion;
|
|
22
|
+
_actions = [];
|
|
23
|
+
_severity = 'error';
|
|
24
|
+
_details = {};
|
|
25
|
+
_retryAfter;
|
|
26
|
+
/** @internal Cached build result — invalidated by any setter */
|
|
27
|
+
_cached = undefined;
|
|
28
|
+
constructor(code, message) {
|
|
29
|
+
this._code = code;
|
|
30
|
+
this._message = message;
|
|
31
|
+
}
|
|
32
|
+
/** Add a recovery suggestion for the LLM agent */
|
|
33
|
+
suggest(suggestion) {
|
|
34
|
+
this._suggestion = suggestion;
|
|
35
|
+
this._cached = undefined;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/** List tool names the agent should try instead */
|
|
39
|
+
actions(...names) {
|
|
40
|
+
this._actions.push(...names);
|
|
41
|
+
this._cached = undefined;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/** Set error severity (default: 'error') */
|
|
45
|
+
severity(level) {
|
|
46
|
+
this._severity = level;
|
|
47
|
+
this._cached = undefined;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/** Set severity to 'critical' (stops agent execution) */
|
|
51
|
+
critical() { return this.severity('critical'); }
|
|
52
|
+
/** Set severity to 'warning' (non-fatal guidance) */
|
|
53
|
+
warning() { return this.severity('warning'); }
|
|
54
|
+
/** Add structured metadata details about the error */
|
|
55
|
+
details(data) {
|
|
56
|
+
for (const [key, value] of Object.entries(data)) {
|
|
57
|
+
this._details[key] = String(value);
|
|
58
|
+
}
|
|
59
|
+
this._cached = undefined;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/** Suggest a retry delay in seconds for transient errors */
|
|
63
|
+
retryAfter(seconds) {
|
|
64
|
+
this._retryAfter = seconds;
|
|
65
|
+
this._cached = undefined;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build the final {@link ToolResponse}.
|
|
70
|
+
*
|
|
71
|
+
* Note: The execution pipeline also accepts the builder instance
|
|
72
|
+
* directly and calls this method automatically.
|
|
73
|
+
*/
|
|
74
|
+
build() {
|
|
75
|
+
const opts = {
|
|
76
|
+
message: this._message,
|
|
77
|
+
severity: this._severity,
|
|
78
|
+
};
|
|
79
|
+
if (this._suggestion)
|
|
80
|
+
opts.suggestion = this._suggestion;
|
|
81
|
+
if (this._actions.length > 0)
|
|
82
|
+
opts.availableActions = this._actions;
|
|
83
|
+
if (Object.keys(this._details).length > 0)
|
|
84
|
+
opts.details = this._details;
|
|
85
|
+
if (this._retryAfter !== undefined)
|
|
86
|
+
opts.retryAfter = this._retryAfter;
|
|
87
|
+
return toolError(this._code, opts);
|
|
88
|
+
}
|
|
89
|
+
/** @internal Ensure the response is built and cached */
|
|
90
|
+
_ensureBuilt() {
|
|
91
|
+
if (!this._cached)
|
|
92
|
+
this._cached = this.build();
|
|
93
|
+
return this._cached;
|
|
94
|
+
}
|
|
95
|
+
/** Implementation of ToolResponse for direct return in handlers */
|
|
96
|
+
get content() { return this._ensureBuilt().content; }
|
|
97
|
+
get isError() { return this._ensureBuilt().isError; }
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=ErrorBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ErrorBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACb,QAAQ,CAAS;IACjB,KAAK,CAAY;IACjB,WAAW,CAAU;IACrB,QAAQ,GAAa,EAAE,CAAC;IACxB,SAAS,GAAkB,OAAO,CAAC;IACnC,QAAQ,GAA2B,EAAE,CAAC;IACtC,WAAW,CAAU;IAC7B,gEAAgE;IACxD,OAAO,GAA6B,SAAS,CAAC;IAEtD,YAAY,IAAe,EAAE,OAAe;QACxC,IAAI,CAAC,KA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,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACD,MAAM,IAAI,GAON;YACA,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ,EAAE,IAAI,CAAC,SAAS;SAC3B,CAAC;QACF,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QACzD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC;QACpE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QACxE,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QACvE,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,wDAAwD;IAChD,YAAY;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,mEAAmE;IACnE,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FluentRouter — Prefix Grouping for Fluent Tools
|
|
3
|
+
*
|
|
4
|
+
* Eliminates repetitive `'users.'` prefixes across dozens of tools.
|
|
5
|
+
* A router shares a common prefix, description, and middleware chain
|
|
6
|
+
* across all child tools.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const f = initVurb<AppContext>();
|
|
11
|
+
*
|
|
12
|
+
* const users = f.router('users')
|
|
13
|
+
* .describe('User management')
|
|
14
|
+
* .use(requireAuth);
|
|
15
|
+
*
|
|
16
|
+
* // Tool name: "users", action: "list"
|
|
17
|
+
* const listUsers = users.query('list')
|
|
18
|
+
* .input({ limit: f.number() })
|
|
19
|
+
* .resolve(async ({ input }) => { ... });
|
|
20
|
+
*
|
|
21
|
+
* // Tool name: "users", action: "delete"
|
|
22
|
+
* const deleteUser = users.mutation('delete')
|
|
23
|
+
* .input({ id: f.string() })
|
|
24
|
+
* .resolve(async ({ input }) => { ... });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { type MiddlewareFn } from '../types.js';
|
|
30
|
+
import { type MiddlewareDefinition } from '../middleware/ContextDerivation.js';
|
|
31
|
+
import { FluentToolBuilder } from './FluentToolBuilder.js';
|
|
32
|
+
/**
|
|
33
|
+
* Fluent router that shares prefix, description, and middleware
|
|
34
|
+
* across child tools created via `.query()`, `.mutation()`, `.action()`.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TContext - Base application context
|
|
37
|
+
*/
|
|
38
|
+
export declare class FluentRouter<TContext> {
|
|
39
|
+
/** @internal */ readonly _prefix: string;
|
|
40
|
+
/** @internal */ _description?: string;
|
|
41
|
+
/** @internal */ _middlewares: MiddlewareFn<TContext>[];
|
|
42
|
+
/** @internal */ _tags: string[];
|
|
43
|
+
constructor(prefix: string);
|
|
44
|
+
/**
|
|
45
|
+
* Set the shared description for all tools in this router.
|
|
46
|
+
*
|
|
47
|
+
* @param text - Human-readable description
|
|
48
|
+
* @returns `this` for chaining
|
|
49
|
+
*/
|
|
50
|
+
describe(text: string): this;
|
|
51
|
+
/**
|
|
52
|
+
* Add middleware shared by all tools in this router.
|
|
53
|
+
*
|
|
54
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
55
|
+
* raw `MiddlewareFn` functions.
|
|
56
|
+
*
|
|
57
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
58
|
+
* @returns Router with narrowed `TContext` type (when using MiddlewareDefinition)
|
|
59
|
+
*/
|
|
60
|
+
use<TDerived extends Record<string, unknown>>(mw: MiddlewareDefinition<TContext, TDerived>): FluentRouter<TContext & TDerived>;
|
|
61
|
+
use(mw: MiddlewareFn<TContext>): this;
|
|
62
|
+
/**
|
|
63
|
+
* Set capability tags shared by all tools in this router.
|
|
64
|
+
*
|
|
65
|
+
* @param tags - Tag strings for filtering
|
|
66
|
+
* @returns `this` for chaining
|
|
67
|
+
*/
|
|
68
|
+
tags(...tags: string[]): this;
|
|
69
|
+
/**
|
|
70
|
+
* Create a read-only query tool under this router's prefix.
|
|
71
|
+
*
|
|
72
|
+
* @param action - Action name (e.g. `'list'` → tool name `'prefix.list'`)
|
|
73
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
74
|
+
*/
|
|
75
|
+
query(action: string): FluentToolBuilder<TContext>;
|
|
76
|
+
/**
|
|
77
|
+
* Create a destructive mutation tool under this router's prefix.
|
|
78
|
+
*
|
|
79
|
+
* @param action - Action name (e.g. `'delete'` → tool name `'prefix.delete'`)
|
|
80
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
81
|
+
*/
|
|
82
|
+
mutation(action: string): FluentToolBuilder<TContext>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a neutral action tool under this router's prefix.
|
|
85
|
+
*
|
|
86
|
+
* @param action - Action name (e.g. `'update'` → tool name `'prefix.update'`)
|
|
87
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
88
|
+
*/
|
|
89
|
+
action(action: string): FluentToolBuilder<TContext>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a FluentToolBuilder with inherited router config.
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
private _createBuilder;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=FluentRouter.d.ts.map
|