@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,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Helpers
|
|
3
|
+
*
|
|
4
|
+
* Universal MCP response builders. No API coupling.
|
|
5
|
+
* These produce the standard MCP ToolResponse format.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { success, error, toonSuccess } from 'vurb';
|
|
10
|
+
*
|
|
11
|
+
* // String response
|
|
12
|
+
* return success('Project created');
|
|
13
|
+
*
|
|
14
|
+
* // Object response (auto JSON.stringify)
|
|
15
|
+
* return success({ id: '123', name: 'My Project' });
|
|
16
|
+
*
|
|
17
|
+
* // Error response
|
|
18
|
+
* return error('Project not found');
|
|
19
|
+
*
|
|
20
|
+
* // TOON-encoded response (~40% fewer tokens)
|
|
21
|
+
* return toonSuccess(users);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link ToolResponse} for the response shape
|
|
25
|
+
* @see {@link toonSuccess} for token-optimized responses
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { encode } from '@toon-format/toon';
|
|
30
|
+
import {} from './serialization/JsonSerializer.js';
|
|
31
|
+
/**
|
|
32
|
+
* Non-enumerable brand symbol stamped on all helper-created ToolResponse objects.
|
|
33
|
+
* Used by FluentToolBuilder to reliably distinguish framework responses from
|
|
34
|
+
* domain data that coincidentally matches the ToolResponse shape (Bug #127).
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export const TOOL_RESPONSE_BRAND = Symbol.for('vurb.ToolResponse');
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// XML Safety
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Escape XML structural characters for element content.
|
|
44
|
+
*
|
|
45
|
+
* Only `&` and `<` are mandatory escapes in XML element content.
|
|
46
|
+
* `>` is preserved for LLM readability (e.g. `>= 1`, `Must be > 0`).
|
|
47
|
+
* Single and double quotes are also preserved since they have no
|
|
48
|
+
* special meaning outside attribute values.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export function escapeXml(str) {
|
|
53
|
+
return str
|
|
54
|
+
.replace(/&/g, '&')
|
|
55
|
+
.replace(/</g, '<');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Escape XML special characters for use inside attribute values.
|
|
59
|
+
*
|
|
60
|
+
* Attribute values are delimited by `"` or `'` and must also
|
|
61
|
+
* escape `<`, `>`, and `&`. All 5 XML special characters are handled.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
export function escapeXmlAttr(str) {
|
|
66
|
+
return str
|
|
67
|
+
.replace(/&/g, '&')
|
|
68
|
+
.replace(/</g, '<')
|
|
69
|
+
.replace(/>/g, '>')
|
|
70
|
+
.replace(/"/g, '"')
|
|
71
|
+
.replace(/'/g, ''');
|
|
72
|
+
}
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Response Builders
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Create a success response from text or a JSON-serializable object.
|
|
78
|
+
*
|
|
79
|
+
* - Strings are returned verbatim (empty strings become `"OK"`)
|
|
80
|
+
* - Objects are serialized with `JSON.stringify(data, null, 2)`
|
|
81
|
+
*
|
|
82
|
+
* @param data - A string message or any JSON-serializable object
|
|
83
|
+
* @returns A {@link ToolResponse} with `isError` unset
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // String response
|
|
88
|
+
* return success('Task completed');
|
|
89
|
+
*
|
|
90
|
+
* // Object response (pretty-printed JSON)
|
|
91
|
+
* const project = await db.projects.create({ name: 'Acme' });
|
|
92
|
+
* return success(project);
|
|
93
|
+
*
|
|
94
|
+
* // Array response
|
|
95
|
+
* const users = await db.users.findMany();
|
|
96
|
+
* return success(users);
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @see {@link error} for error responses
|
|
100
|
+
* @see {@link toonSuccess} for token-optimized array responses
|
|
101
|
+
*/
|
|
102
|
+
export function success(data, compiledStringify) {
|
|
103
|
+
const text = typeof data === 'string'
|
|
104
|
+
? (data || 'OK')
|
|
105
|
+
: (compiledStringify ? compiledStringify(data) : JSON.stringify(data, null, 2));
|
|
106
|
+
const resp = { content: [{ type: "text", text }] };
|
|
107
|
+
Object.defineProperty(resp, TOOL_RESPONSE_BRAND, { value: true });
|
|
108
|
+
return resp;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create an error response.
|
|
112
|
+
*
|
|
113
|
+
* Sets `isError: true` so the MCP client and LLM recognize the failure.
|
|
114
|
+
* The LLM will typically retry or ask the user for clarification.
|
|
115
|
+
*
|
|
116
|
+
* @param message - Human-readable error description
|
|
117
|
+
* @returns A {@link ToolResponse} with `isError: true`
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* // Simple error
|
|
122
|
+
* return error('Project not found');
|
|
123
|
+
*
|
|
124
|
+
* // Contextual error
|
|
125
|
+
* return error(`User "${userId}" does not have access to workspace "${wsId}"`);
|
|
126
|
+
*
|
|
127
|
+
* // In a handler with early return
|
|
128
|
+
* handler: async (ctx, args) => {
|
|
129
|
+
* const project = await ctx.db.projects.findUnique(args.id);
|
|
130
|
+
* if (!project) return error(`Project "${args.id}" not found`);
|
|
131
|
+
* return success(project);
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @see {@link required} for missing field errors
|
|
136
|
+
* @see {@link success} for success responses
|
|
137
|
+
*/
|
|
138
|
+
export function error(message, code) {
|
|
139
|
+
const codeAttr = code !== undefined ? ` code="${escapeXmlAttr(code)}"` : '';
|
|
140
|
+
const resp = {
|
|
141
|
+
content: [{ type: "text", text: `<tool_error${codeAttr}>\n<message>${escapeXml(message)}</message>\n</tool_error>` }],
|
|
142
|
+
isError: true,
|
|
143
|
+
};
|
|
144
|
+
Object.defineProperty(resp, TOOL_RESPONSE_BRAND, { value: true });
|
|
145
|
+
return resp;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create a validation error for a missing required field.
|
|
149
|
+
*
|
|
150
|
+
* Convenience shortcut for `error(\`Error: ${field} required\`)`.
|
|
151
|
+
* Typically used in handlers that accept dynamic or optional schemas.
|
|
152
|
+
*
|
|
153
|
+
* @param field - Name of the missing required field
|
|
154
|
+
* @returns A {@link ToolResponse} with `isError: true`
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* handler: async (ctx, args) => {
|
|
159
|
+
* if (!args.workspace_id) return required('workspace_id');
|
|
160
|
+
* // ...
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @see {@link error} for general error responses
|
|
165
|
+
*/
|
|
166
|
+
export function required(field) {
|
|
167
|
+
const f = escapeXml(field);
|
|
168
|
+
const resp = {
|
|
169
|
+
content: [{
|
|
170
|
+
type: "text",
|
|
171
|
+
text: `<tool_error code="MISSING_REQUIRED_FIELD">\n<message>Required field "${f}" is missing.</message>\n<recovery>Provide the "${f}" parameter and retry.</recovery>\n</tool_error>`,
|
|
172
|
+
}],
|
|
173
|
+
isError: true,
|
|
174
|
+
};
|
|
175
|
+
Object.defineProperty(resp, TOOL_RESPONSE_BRAND, { value: true });
|
|
176
|
+
return resp;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create a success response with TOON-encoded payload.
|
|
180
|
+
*
|
|
181
|
+
* Encodes structured data using TOON (Token-Oriented Object Notation)
|
|
182
|
+
* for ~40-50% token reduction compared to `JSON.stringify()`.
|
|
183
|
+
* Ideal for list/tabular responses (arrays of uniform objects).
|
|
184
|
+
*
|
|
185
|
+
* @param data - Any JSON-serializable value (objects, arrays, primitives)
|
|
186
|
+
* @param options - Optional TOON encode options (default: pipe delimiter)
|
|
187
|
+
* @returns A {@link ToolResponse} with TOON-encoded text
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* // Array response — saves ~40% tokens vs JSON
|
|
192
|
+
* const users = await db.users.findMany();
|
|
193
|
+
* return toonSuccess(users);
|
|
194
|
+
* // Output: "id|name|email\n1|Alice|alice@co.io\n2|Bob|bob@co.io"
|
|
195
|
+
*
|
|
196
|
+
* // With custom delimiter
|
|
197
|
+
* return toonSuccess(data, { delimiter: ',' });
|
|
198
|
+
*
|
|
199
|
+
* // Single object (still valid, but savings are smaller)
|
|
200
|
+
* return toonSuccess({ id: 1, name: 'Alice' });
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @see {@link success} for standard JSON responses
|
|
204
|
+
*/
|
|
205
|
+
export function toonSuccess(data, options) {
|
|
206
|
+
const defaults = { delimiter: '|' };
|
|
207
|
+
const text = encode(data, { ...defaults, ...options });
|
|
208
|
+
const resp = { content: [{ type: "text", text }] };
|
|
209
|
+
Object.defineProperty(resp, TOOL_RESPONSE_BRAND, { value: true });
|
|
210
|
+
return resp;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Create a self-healing error response with recovery instructions.
|
|
214
|
+
*
|
|
215
|
+
* Unlike {@link error}, this provides structured guidance so the LLM
|
|
216
|
+
* agent can self-correct instead of hallucinating or giving up.
|
|
217
|
+
* The response includes an error code, message, suggestion, and
|
|
218
|
+
* available actions — all formatted for optimal LLM comprehension.
|
|
219
|
+
*
|
|
220
|
+
* @param code - Short error code (e.g. `'ProjectNotFound'`, `'Unauthorized'`)
|
|
221
|
+
* @param options - Error details and recovery instructions
|
|
222
|
+
* @returns A {@link ToolResponse} with `isError: true` and recovery guidance
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* handler: async (ctx, args) => {
|
|
227
|
+
* const project = await ctx.db.get(args.project_id);
|
|
228
|
+
*
|
|
229
|
+
* if (!project) {
|
|
230
|
+
* return toolError('ProjectNotFound', {
|
|
231
|
+
* message: `Project '${args.project_id}' does not exist.`,
|
|
232
|
+
* suggestion: 'Call projects.list first to get valid IDs, then retry.',
|
|
233
|
+
* availableActions: ['projects.list'],
|
|
234
|
+
* });
|
|
235
|
+
* }
|
|
236
|
+
*
|
|
237
|
+
* return success(project);
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* // Minimal usage (no suggestion)
|
|
244
|
+
* return toolError('RateLimited', {
|
|
245
|
+
* message: 'Too many requests. Wait 30 seconds.',
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @see {@link error} for simple error responses
|
|
250
|
+
* @see {@link required} for missing field errors
|
|
251
|
+
*/
|
|
252
|
+
export function toolError(code, options) {
|
|
253
|
+
const severity = options.severity ?? 'error';
|
|
254
|
+
const parts = [
|
|
255
|
+
`<tool_error code="${escapeXmlAttr(code)}" severity="${escapeXmlAttr(severity)}">`,
|
|
256
|
+
`<message>${escapeXml(options.message)}</message>`,
|
|
257
|
+
];
|
|
258
|
+
if (options.suggestion) {
|
|
259
|
+
parts.push(`<recovery>${escapeXml(options.suggestion)}</recovery>`);
|
|
260
|
+
}
|
|
261
|
+
if ((options.availableActions?.length ?? 0) > 0) {
|
|
262
|
+
parts.push('<available_actions>');
|
|
263
|
+
for (const action of options.availableActions) {
|
|
264
|
+
parts.push(` <action>${escapeXml(action)}</action>`);
|
|
265
|
+
}
|
|
266
|
+
parts.push('</available_actions>');
|
|
267
|
+
}
|
|
268
|
+
if (options.details != null && Object.keys(options.details).length > 0) {
|
|
269
|
+
parts.push('<details>');
|
|
270
|
+
for (const [key, value] of Object.entries(options.details)) {
|
|
271
|
+
parts.push(` <detail key="${escapeXmlAttr(key)}">${escapeXml(value)}</detail>`);
|
|
272
|
+
}
|
|
273
|
+
parts.push('</details>');
|
|
274
|
+
}
|
|
275
|
+
if (options.retryAfter !== undefined && Number.isFinite(options.retryAfter) && options.retryAfter > 0) {
|
|
276
|
+
parts.push(`<retry_after>${options.retryAfter} seconds</retry_after>`);
|
|
277
|
+
}
|
|
278
|
+
parts.push('</tool_error>');
|
|
279
|
+
// Warnings are non-fatal — do not set isError so the response
|
|
280
|
+
// flows through the success path while still carrying guidance.
|
|
281
|
+
const isError = severity !== 'warning';
|
|
282
|
+
const resp = { content: [{ type: "text", text: parts.join('\n') }], isError };
|
|
283
|
+
Object.defineProperty(resp, TOOL_RESPONSE_BRAND, { value: true });
|
|
284
|
+
return resp;
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,MAAM,EAAsB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAoB,MAAM,mCAAmC,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAElF,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACjC,OAAO,GAAG;SACL,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM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,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;QACpG,KAAK,CAAC,IAAI,CAAC,gBAAgB,OAAO,CAAC,UAAU,wBAAwB,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE5B,8DAA8D;IAC9D,gEAAgE;IAChE,MAAM,OAAO,GAAG,QAAQ,KAAK,SAAS,CAAC;IACvC,MAAM,IAAI,GAAiB,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;IAC5F,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result\<T\> — Railway-Oriented Programming for Vurb
|
|
3
|
+
*
|
|
4
|
+
* A lightweight, zero-overhead discriminated union for expressing
|
|
5
|
+
* success/failure pipelines without exception throwing.
|
|
6
|
+
*
|
|
7
|
+
* Follows the "Result Monad" pattern used in Rust, Haskell, and F#.
|
|
8
|
+
* Each step in a pipeline returns `Result<T>`: either `Success<T>` or `Failure`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { succeed, fail, error, type Result } from 'vurb';
|
|
13
|
+
*
|
|
14
|
+
* function parseId(input: string): Result<number> {
|
|
15
|
+
* const id = parseInt(input, 10);
|
|
16
|
+
* return isNaN(id) ? fail(error('Invalid ID')) : succeed(id);
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Usage in a pipeline:
|
|
20
|
+
* const result = parseId(args.id);
|
|
21
|
+
* if (!result.ok) return result.response; // Early return on failure
|
|
22
|
+
* const userId = result.value; // Narrowed to number
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see {@link succeed} for creating successful results
|
|
26
|
+
* @see {@link fail} for creating failure results
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
import { type ToolResponse } from './response.js';
|
|
31
|
+
/**
|
|
32
|
+
* Successful result containing a typed value.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam T - The success value type
|
|
35
|
+
*/
|
|
36
|
+
export interface Success<T> {
|
|
37
|
+
readonly ok: true;
|
|
38
|
+
readonly value: T;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Failed result containing an error response.
|
|
42
|
+
*
|
|
43
|
+
* The `response` field is a standard {@link ToolResponse} that can
|
|
44
|
+
* be returned directly from a handler.
|
|
45
|
+
*/
|
|
46
|
+
export interface Failure {
|
|
47
|
+
readonly ok: false;
|
|
48
|
+
readonly response: ToolResponse;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Discriminated union: either `Success<T>` or `Failure`.
|
|
52
|
+
*
|
|
53
|
+
* Check `result.ok` to narrow the type:
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const result: Result<User> = findUser(id);
|
|
58
|
+
* if (!result.ok) return result.response; // Failure path
|
|
59
|
+
* const user = result.value; // Success path — typed as User
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export type Result<T> = Success<T> | Failure;
|
|
63
|
+
/**
|
|
64
|
+
* Create a successful result.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam T - The value type
|
|
67
|
+
* @param value - The success value
|
|
68
|
+
* @returns A `Success<T>` with `ok: true`
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* return succeed(42);
|
|
73
|
+
* return succeed({ id: 'user_1', name: 'Alice' });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function succeed<T>(value: T): Success<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Create a failed result from a ToolResponse.
|
|
79
|
+
*
|
|
80
|
+
* @param response - An error {@link ToolResponse} (typically from `error()`)
|
|
81
|
+
* @returns A `Failure` with `ok: false`
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* return fail(error('User not found'));
|
|
86
|
+
* return fail(required('email'));
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @see {@link error} for creating error responses
|
|
90
|
+
* @see {@link required} for missing field errors
|
|
91
|
+
*/
|
|
92
|
+
export declare function fail(response: ToolResponse): Failure;
|
|
93
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD;;;;GAIG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACnC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;AAI7C;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE/C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result\<T\> — Railway-Oriented Programming for Vurb
|
|
3
|
+
*
|
|
4
|
+
* A lightweight, zero-overhead discriminated union for expressing
|
|
5
|
+
* success/failure pipelines without exception throwing.
|
|
6
|
+
*
|
|
7
|
+
* Follows the "Result Monad" pattern used in Rust, Haskell, and F#.
|
|
8
|
+
* Each step in a pipeline returns `Result<T>`: either `Success<T>` or `Failure`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { succeed, fail, error, type Result } from 'vurb';
|
|
13
|
+
*
|
|
14
|
+
* function parseId(input: string): Result<number> {
|
|
15
|
+
* const id = parseInt(input, 10);
|
|
16
|
+
* return isNaN(id) ? fail(error('Invalid ID')) : succeed(id);
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Usage in a pipeline:
|
|
20
|
+
* const result = parseId(args.id);
|
|
21
|
+
* if (!result.ok) return result.response; // Early return on failure
|
|
22
|
+
* const userId = result.value; // Narrowed to number
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see {@link succeed} for creating successful results
|
|
26
|
+
* @see {@link fail} for creating failure results
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
import {} from './response.js';
|
|
31
|
+
// ── Constructors ─────────────────────────────────────────
|
|
32
|
+
/**
|
|
33
|
+
* Create a successful result.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam T - The value type
|
|
36
|
+
* @param value - The success value
|
|
37
|
+
* @returns A `Success<T>` with `ok: true`
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* return succeed(42);
|
|
42
|
+
* return succeed({ id: 'user_1', name: 'Alice' });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function succeed(value) {
|
|
46
|
+
return { ok: true, value };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a failed result from a ToolResponse.
|
|
50
|
+
*
|
|
51
|
+
* @param response - An error {@link ToolResponse} (typically from `error()`)
|
|
52
|
+
* @returns A `Failure` with `ok: false`
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* return fail(error('User not found'));
|
|
57
|
+
* return fail(required('email'));
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @see {@link error} for creating error responses
|
|
61
|
+
* @see {@link required} for missing field errors
|
|
62
|
+
*/
|
|
63
|
+
export function fail(response) {
|
|
64
|
+
return { ok: false, response };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAqB,MAAM,eAAe,CAAC;AAuClD,4DAA4D;AAE5D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,OAAO,CAAI,KAAQ;IAC/B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,IAAI,CAAC,QAAsB;IACvC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnnotationAggregator — Tool Annotation Aggregation Strategy
|
|
3
|
+
*
|
|
4
|
+
* Aggregates per-action hints (readOnly, destructive, idempotent)
|
|
5
|
+
* into a single annotation record, with explicit overrides.
|
|
6
|
+
*
|
|
7
|
+
* Pure-function module: no state, no side effects.
|
|
8
|
+
*/
|
|
9
|
+
import { type InternalAction } from '../types.js';
|
|
10
|
+
export declare function aggregateAnnotations<TContext>(actions: readonly InternalAction<TContext>[], explicitAnnotations: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
11
|
+
//# sourceMappingURL=AnnotationAggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationAggregator.d.ts","sourceRoot":"","sources":["../../../src/core/schema/AnnotationAggregator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAYlD,wBAAgB,oBAAoB,CAAC,QAAQ,EACzC,OAAO,EAAE,SAAS,cAAc,CAAC,QAAQ,CAAC,EAAE,EAC5C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACzD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgCzB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnnotationAggregator — Tool Annotation Aggregation Strategy
|
|
3
|
+
*
|
|
4
|
+
* Aggregates per-action hints (readOnly, destructive, idempotent)
|
|
5
|
+
* into a single annotation record, with explicit overrides.
|
|
6
|
+
*
|
|
7
|
+
* Pure-function module: no state, no side effects.
|
|
8
|
+
*/
|
|
9
|
+
import {} from '../types.js';
|
|
10
|
+
// ── Public API ───────────────────────────────────────────
|
|
11
|
+
export function aggregateAnnotations(actions, explicitAnnotations) {
|
|
12
|
+
const result = {};
|
|
13
|
+
// Copy explicit annotations using explicit loop to guard against
|
|
14
|
+
// __proto__/constructor/prototype keys (prototype pollution defense).
|
|
15
|
+
// Matches the pattern in ContextDerivation, FluentToolBuilder, and ExecutionPipeline.
|
|
16
|
+
if (explicitAnnotations) {
|
|
17
|
+
for (const [key, value] of Object.entries(explicitAnnotations)) {
|
|
18
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype')
|
|
19
|
+
continue;
|
|
20
|
+
result[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Per-action aggregation (only override if not explicitly set)
|
|
24
|
+
if (result.readOnlyHint === undefined) {
|
|
25
|
+
const allReadOnly = actions.length > 0 &&
|
|
26
|
+
actions.every(a => a.readOnly === true);
|
|
27
|
+
result.readOnlyHint = allReadOnly;
|
|
28
|
+
}
|
|
29
|
+
if (result.destructiveHint === undefined) {
|
|
30
|
+
const anyDestructive = actions.some(a => a.destructive === true);
|
|
31
|
+
result.destructiveHint = anyDestructive;
|
|
32
|
+
}
|
|
33
|
+
if (result.idempotentHint === undefined) {
|
|
34
|
+
const allIdempotent = actions.length > 0 &&
|
|
35
|
+
actions.every(a => a.idempotent === true);
|
|
36
|
+
result.idempotentHint = allIdempotent;
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=AnnotationAggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationAggregator.js","sourceRoot":"","sources":["../../../src/core/schema/AnnotationAggregator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAuB,MAAM,aAAa,CAAC;AAUlD,4DAA4D;AAE5D,MAAM,UAAU,oBAAoB,CAChC,OAA4C,EAC5C,mBAAwD;IAExD,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,iEAAiE;IACjE,sEAAsE;IACtE,sFAAsF;IACtF,IAAI,mBAAmB,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC7D,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,GAAG,KAAK,WAAW;gBAAE,SAAS;YACjF,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACrD,CAAC;IACL,CAAC;IAED,+DAA+D;IAC/D,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC;IACtC,CAAC;IAED,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;QACjE,MAAM,CAAC,eAAe,GAAG,cAAc,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,cAAc,GAAG,aAAa,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DescriptionGenerator — LLM-friendly Tool Description Strategy
|
|
3
|
+
*
|
|
4
|
+
* Generates 3-layer descriptions from action metadata:
|
|
5
|
+
* - Layer 1: Tool summary + module/action listing
|
|
6
|
+
* - Layer 2: Workflow section with required params and destructive warnings
|
|
7
|
+
*
|
|
8
|
+
* Pure-function module: no state, no side effects.
|
|
9
|
+
*/
|
|
10
|
+
import { type InternalAction } from '../types.js';
|
|
11
|
+
export declare function generateDescription<TContext>(actions: readonly InternalAction<TContext>[], name: string, description: string | undefined, hasGroup: boolean, discriminator?: string): string;
|
|
12
|
+
//# sourceMappingURL=DescriptionGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptionGenerator.d.ts","sourceRoot":"","sources":["../../../src/core/schema/DescriptionGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,wBAAgB,mBAAmB,CAAC,QAAQ,EACxC,OAAO,EAAE,SAAS,cAAc,CAAC,QAAQ,CAAC,EAAE,EAC5C,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,QAAQ,EAAE,OAAO,EACjB,aAAa,SAAW,GACzB,MAAM,CAgCR"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DescriptionGenerator — LLM-friendly Tool Description Strategy
|
|
3
|
+
*
|
|
4
|
+
* Generates 3-layer descriptions from action metadata:
|
|
5
|
+
* - Layer 1: Tool summary + module/action listing
|
|
6
|
+
* - Layer 2: Workflow section with required params and destructive warnings
|
|
7
|
+
*
|
|
8
|
+
* Pure-function module: no state, no side effects.
|
|
9
|
+
*/
|
|
10
|
+
import {} from '../types.js';
|
|
11
|
+
import { getActionRequiredFields } from './SchemaUtils.js';
|
|
12
|
+
// ── Public API ───────────────────────────────────────────
|
|
13
|
+
export function generateDescription(actions, name, description, hasGroup, discriminator = 'action') {
|
|
14
|
+
const lines = [];
|
|
15
|
+
// Layer 1: Tool description + action/module summary + dispatch instruction
|
|
16
|
+
if (hasGroup) {
|
|
17
|
+
const groups = getGroupSummaries(actions);
|
|
18
|
+
const moduleList = groups
|
|
19
|
+
.map(g => `${g.name} (${g.actions.join(',')})`)
|
|
20
|
+
.join(' | ');
|
|
21
|
+
lines.push(`${description || name}. ` +
|
|
22
|
+
`Select operation via the \`${discriminator}\` parameter. ` +
|
|
23
|
+
`Modules: ${moduleList}`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const actionNames = actions.map(a => a.key);
|
|
27
|
+
lines.push(`${description || name}. ` +
|
|
28
|
+
`Select operation via the \`${discriminator}\` parameter. ` +
|
|
29
|
+
`Actions: ${actionNames.join(', ')}`);
|
|
30
|
+
}
|
|
31
|
+
// Layer 2: Workflow section
|
|
32
|
+
const workflowLines = generateWorkflowLines(actions);
|
|
33
|
+
if (workflowLines.length > 0) {
|
|
34
|
+
lines.push('');
|
|
35
|
+
lines.push('Workflow:');
|
|
36
|
+
lines.push(...workflowLines);
|
|
37
|
+
}
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
}
|
|
40
|
+
// ── Internal helpers ─────────────────────────────────────
|
|
41
|
+
function generateWorkflowLines(actions) {
|
|
42
|
+
const lines = [];
|
|
43
|
+
for (const action of actions) {
|
|
44
|
+
const requiredFields = getActionRequiredFields(action);
|
|
45
|
+
const isDestructive = action.destructive === true;
|
|
46
|
+
if (!action.description && requiredFields.length === 0 && !isDestructive) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
let line = `- '${action.key}': `;
|
|
50
|
+
if (action.description) {
|
|
51
|
+
line += action.description;
|
|
52
|
+
}
|
|
53
|
+
if (requiredFields.length > 0) {
|
|
54
|
+
line += action.description ? '. Requires: ' : 'Requires: ';
|
|
55
|
+
line += requiredFields.join(', ');
|
|
56
|
+
}
|
|
57
|
+
if (isDestructive) {
|
|
58
|
+
line += ' [DESTRUCTIVE]';
|
|
59
|
+
}
|
|
60
|
+
lines.push(line);
|
|
61
|
+
}
|
|
62
|
+
return lines;
|
|
63
|
+
}
|
|
64
|
+
function getGroupSummaries(actions) {
|
|
65
|
+
const groups = new Map();
|
|
66
|
+
for (const action of actions) {
|
|
67
|
+
if (!action.groupName)
|
|
68
|
+
continue;
|
|
69
|
+
let group = groups.get(action.groupName);
|
|
70
|
+
if (!group) {
|
|
71
|
+
group = [];
|
|
72
|
+
groups.set(action.groupName, group);
|
|
73
|
+
}
|
|
74
|
+
group.push(action.actionName);
|
|
75
|
+
}
|
|
76
|
+
return Array.from(groups.entries()).map(([name, groupActions]) => ({
|
|
77
|
+
name,
|
|
78
|
+
actions: groupActions,
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=DescriptionGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptionGenerator.js","sourceRoot":"","sources":["../../../src/core/schema/DescriptionGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAuB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,4DAA4D;AAE5D,MAAM,UAAU,mBAAmB,CAC/B,OAA4C,EAC5C,IAAY,EACZ,WAA+B,EAC/B,QAAiB,EACjB,aAAa,GAAG,QAAQ;IAExB,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,2EAA2E;IAC3E,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,MAAM;aACpB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;aAC9C,IAAI,CAAC,KAAK,CAAC,CAAC;QACjB,KAAK,CAAC,IAAI,CACN,GAAG,WAAW,IAAI,IAAI,IAAI;YAC1B,8BAA8B,aAAa,gBAAgB;YAC3D,YAAY,UAAU,EAAE,CAC3B,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,CACN,GAAG,WAAW,IAAI,IAAI,IAAI;YAC1B,8BAA8B,aAAa,gBAAgB;YAC3D,YAAY,WAAW,CAAC,IAAI,CAAC,IAAI,C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IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,iBAAiB,CACtB,OAA4C;IAE5C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS;YAAE,SAAS;QAChC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,KAAK,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/D,IAAI;QACJ,OAAO,EAAE,YAAY;KACxB,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SchemaGenerator — JSON Schema Input Schema Strategy
|
|
3
|
+
*
|
|
4
|
+
* Generates MCP-compatible inputSchema from Zod definitions:
|
|
5
|
+
* - Discriminator enum from action keys
|
|
6
|
+
* - Common + per-action schema merging (with omitCommon support)
|
|
7
|
+
* - Per-field annotations (required-for / optional-for)
|
|
8
|
+
*
|
|
9
|
+
* Pure-function module: no state, no side effects.
|
|
10
|
+
*/
|
|
11
|
+
import { type ZodObject, type ZodRawShape } from 'zod';
|
|
12
|
+
import { type Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
+
import { type InternalAction } from '../types.js';
|
|
14
|
+
export declare function generateInputSchema<TContext>(actions: readonly InternalAction<TContext>[], discriminator: string, hasGroup: boolean, commonSchema: ZodObject<ZodRawShape> | undefined, selectEnabled?: boolean): McpTool['inputSchema'];
|
|
15
|
+
//# sourceMappingURL=SchemaGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaGenerator.d.ts","sourceRoot":"","sources":["../../../src/core/schema/SchemaGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAEvD,OAAO,EAAE,KAAK,IAAI,IAAI,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAkBlD,wBAAgB,mBAAmB,CAAC,QAAQ,EACxC,OAAO,EAAE,SAAS,cAAc,CAAC,QAAQ,CAAC,EAAE,EAC5C,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,EAChD,aAAa,UAAQ,GACtB,OAAO,CAAC,aAAa,CAAC,CAyBxB"}
|