@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,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResponseBuilder — Fluent Multi-Block Response Composer
|
|
3
|
+
*
|
|
4
|
+
* Standalone builder for composing rich, multi-content-block MCP
|
|
5
|
+
* responses. Each semantic layer (data, UI blocks, system rules,
|
|
6
|
+
* LLM hints) becomes a separate content block in the response array,
|
|
7
|
+
* following MCP's multimodal content design.
|
|
8
|
+
*
|
|
9
|
+
* Inspired by Next.js's `NextResponse` — the builder is a standalone
|
|
10
|
+
* function, keeping `ctx` pure and the response testable.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { response, ui } from 'vurb';
|
|
15
|
+
*
|
|
16
|
+
* // Simple data response (equivalent to success())
|
|
17
|
+
* return response({ id: '123', amount: 4500 }).build();
|
|
18
|
+
*
|
|
19
|
+
* // Rich multi-block response
|
|
20
|
+
* return response(data)
|
|
21
|
+
* .uiBlock(ui.echarts(chartConfig))
|
|
22
|
+
* .llmHint('Divide amounts by 100 before displaying.')
|
|
23
|
+
* .systemRules(['Use $ for currency', 'Emojis: ✅ Paid'])
|
|
24
|
+
* .build();
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link response} for the factory function
|
|
28
|
+
* @see {@link Presenter} for automatic response composition
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import {} from '../core/response.js';
|
|
33
|
+
import {} from './ui.js';
|
|
34
|
+
import { MVA_META_SYMBOL } from '../testing/MvaMetaSymbol.js';
|
|
35
|
+
import {} from '../core/serialization/JsonSerializer.js';
|
|
36
|
+
// ── Brand ────────────────────────────────────────────────
|
|
37
|
+
const RESPONSE_BUILDER_BRAND = 'VurbResponseBuilder';
|
|
38
|
+
/**
|
|
39
|
+
* Check if a value is a {@link ResponseBuilder} instance.
|
|
40
|
+
*
|
|
41
|
+
* Used by the execution pipeline to auto-call `.build()` when
|
|
42
|
+
* a handler returns a builder without explicitly calling `.build()`.
|
|
43
|
+
*
|
|
44
|
+
* @param value - Any value returned by a handler
|
|
45
|
+
* @returns `true` if the value is a ResponseBuilder
|
|
46
|
+
*/
|
|
47
|
+
export function isResponseBuilder(value) {
|
|
48
|
+
return (typeof value === 'object' &&
|
|
49
|
+
value !== null &&
|
|
50
|
+
'__brand' in value &&
|
|
51
|
+
value.__brand === RESPONSE_BUILDER_BRAND);
|
|
52
|
+
}
|
|
53
|
+
// ── ResponseBuilder ──────────────────────────────────────
|
|
54
|
+
/**
|
|
55
|
+
* Fluent builder for multi-content-block MCP responses.
|
|
56
|
+
*
|
|
57
|
+
* Each method appends a semantic layer. The final `.build()` compiles
|
|
58
|
+
* all layers into an array of `{ type: "text", text: "..." }` blocks,
|
|
59
|
+
* one per layer, following MCP's multimodal content specification.
|
|
60
|
+
*
|
|
61
|
+
* Content block order:
|
|
62
|
+
* 1. Data (JSON-serialized raw data)
|
|
63
|
+
* 2. UI Blocks (fenced code blocks from Presenter/manual)
|
|
64
|
+
* 3. Raw Blocks (merged from embedded child Presenters)
|
|
65
|
+
* 4. LLM Hints (inline directives)
|
|
66
|
+
* 5. System Rules (domain-level `[DOMAIN RULES]` block)
|
|
67
|
+
* 6. Action Suggestions (HATEOAS-style `[SYSTEM HINT]` block)
|
|
68
|
+
*
|
|
69
|
+
* @see {@link response} for the factory function
|
|
70
|
+
*/
|
|
71
|
+
export class ResponseBuilder {
|
|
72
|
+
/** @internal Brand for instanceof-free detection in the pipeline */
|
|
73
|
+
__brand = RESPONSE_BUILDER_BRAND;
|
|
74
|
+
_data;
|
|
75
|
+
_uiBlocks = [];
|
|
76
|
+
_hints = [];
|
|
77
|
+
_rules = [];
|
|
78
|
+
_suggestions = [];
|
|
79
|
+
_rawBlocks = [];
|
|
80
|
+
/** @internal Use {@link response} factory instead */
|
|
81
|
+
constructor(data, compiledStringify) {
|
|
82
|
+
this._data = typeof data === 'string'
|
|
83
|
+
? (data.length > 0 ? data : 'OK')
|
|
84
|
+
: (compiledStringify ? compiledStringify(data) : JSON.stringify(data, null, 2));
|
|
85
|
+
}
|
|
86
|
+
uiBlock(blockOrType, content) {
|
|
87
|
+
if (typeof blockOrType === 'object') {
|
|
88
|
+
this._uiBlocks.push(blockOrType);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this._uiBlocks.push({ type: blockOrType, content: content });
|
|
92
|
+
}
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Append pre-built UI blocks (from a Presenter's SSR layer).
|
|
97
|
+
*
|
|
98
|
+
* @param blocks - Array of {@link UiBlock} objects
|
|
99
|
+
* @returns `this` for chaining
|
|
100
|
+
*
|
|
101
|
+
* @internal Used by the Presenter engine
|
|
102
|
+
*/
|
|
103
|
+
uiBlocks(blocks) {
|
|
104
|
+
this._uiBlocks.push(...blocks);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Append an inline LLM hint to the response.
|
|
109
|
+
*
|
|
110
|
+
* Hints are action-specific directives that guide the LLM's
|
|
111
|
+
* behavior for this particular response. Unlike system rules,
|
|
112
|
+
* hints are typically added manually in handlers for dynamic context.
|
|
113
|
+
*
|
|
114
|
+
* @param hint - Directive text for the LLM
|
|
115
|
+
* @returns `this` for chaining
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* response(invoice)
|
|
120
|
+
* .llmHint('This client has an overdue balance. Mention it.')
|
|
121
|
+
* .build();
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
llmHint(hint) {
|
|
125
|
+
this._hints.push(hint);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Append domain-level system rules to the response.
|
|
130
|
+
*
|
|
131
|
+
* Rules are JIT context directives that travel with the data,
|
|
132
|
+
* eliminating the need for bloated system prompts. They are
|
|
133
|
+
* rendered as a `[DOMAIN RULES]` block in the response.
|
|
134
|
+
*
|
|
135
|
+
* @param rules - Array of rule strings
|
|
136
|
+
* @returns `this` for chaining
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* response(data)
|
|
141
|
+
* .systemRules([
|
|
142
|
+
* 'CRITICAL: amounts are in CENTS — divide by 100.',
|
|
143
|
+
* 'Use emojis: ✅ Paid, ⚠️ Pending.',
|
|
144
|
+
* ])
|
|
145
|
+
* .build();
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
systemRules(rules) {
|
|
149
|
+
this._rules.push(...rules);
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Append HATEOAS-style action suggestions to the response.
|
|
154
|
+
*
|
|
155
|
+
* Generates a `[SYSTEM HINT]` block with recommended next tools,
|
|
156
|
+
* guiding the AI through the business state machine.
|
|
157
|
+
*
|
|
158
|
+
* @param suggestions - Array of action suggestions
|
|
159
|
+
* @returns `this` for chaining
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* builder.systemHint([
|
|
164
|
+
* { tool: 'billing.pay', reason: 'Offer immediate payment' },
|
|
165
|
+
* ]);
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
systemHint(suggestions) {
|
|
169
|
+
this._suggestions.push(...suggestions);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Append a raw text block to the response.
|
|
174
|
+
*
|
|
175
|
+
* Used internally by Presenter composition (`.embed()`) to merge
|
|
176
|
+
* child Presenter blocks into the parent response.
|
|
177
|
+
*
|
|
178
|
+
* @param text - Raw text content
|
|
179
|
+
* @returns `this` for chaining
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
rawBlock(text) {
|
|
183
|
+
this._rawBlocks.push(text);
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
// ── Introspection (for cross-module composition) ─────
|
|
187
|
+
/**
|
|
188
|
+
* Get the serialized data payload.
|
|
189
|
+
*
|
|
190
|
+
* Returns the JSON-stringified (or raw string) data
|
|
191
|
+
* that was passed to the constructor.
|
|
192
|
+
*
|
|
193
|
+
* @returns The data string
|
|
194
|
+
*
|
|
195
|
+
* @remarks Used by {@link PromptMessage.fromView} to decompose
|
|
196
|
+
* a Presenter view into prompt messages without calling `.build()`.
|
|
197
|
+
*/
|
|
198
|
+
getData() {
|
|
199
|
+
return this._data;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get the accumulated domain rules.
|
|
203
|
+
*
|
|
204
|
+
* @returns Read-only array of rule strings
|
|
205
|
+
*/
|
|
206
|
+
getRules() {
|
|
207
|
+
return this._rules;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get the accumulated UI blocks.
|
|
211
|
+
*
|
|
212
|
+
* @returns Read-only array of UI blocks
|
|
213
|
+
*/
|
|
214
|
+
getUiBlocks() {
|
|
215
|
+
return this._uiBlocks;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get the accumulated LLM hints.
|
|
219
|
+
*
|
|
220
|
+
* @returns Read-only array of hint strings
|
|
221
|
+
*/
|
|
222
|
+
getHints() {
|
|
223
|
+
return this._hints;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get the accumulated action suggestions.
|
|
227
|
+
*
|
|
228
|
+
* @returns Read-only array of action suggestions
|
|
229
|
+
*/
|
|
230
|
+
getSuggestions() {
|
|
231
|
+
return this._suggestions;
|
|
232
|
+
}
|
|
233
|
+
// ── Compilation ──────────────────────────────────────
|
|
234
|
+
/**
|
|
235
|
+
* Compile all layers into a multi-block MCP `ToolResponse`.
|
|
236
|
+
*
|
|
237
|
+
* Block order:
|
|
238
|
+
* 1. **Data** — JSON-serialized raw data
|
|
239
|
+
* 2. **UI Blocks** — one content entry per UI block,
|
|
240
|
+
* each with a `[SYSTEM]` pass-through instruction
|
|
241
|
+
* 3. **Hints** — inline LLM directives
|
|
242
|
+
* 4. **Rules** — domain-level `[DOMAIN RULES]` block
|
|
243
|
+
*
|
|
244
|
+
* @returns A valid MCP {@link ToolResponse}
|
|
245
|
+
*/
|
|
246
|
+
build() {
|
|
247
|
+
const content = [];
|
|
248
|
+
// Block 1: Data
|
|
249
|
+
content.push({ type: 'text', text: this._data });
|
|
250
|
+
// Block 2: UI Blocks — XML semantic boundary for pass-through rendering
|
|
251
|
+
for (const block of this._uiBlocks) {
|
|
252
|
+
content.push({
|
|
253
|
+
type: 'text',
|
|
254
|
+
text: `<ui_passthrough type="${block.type}">\n${block.content}\n</ui_passthrough>`,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
// Block 3: Raw blocks (from embedded child Presenters)
|
|
258
|
+
for (const raw of this._rawBlocks) {
|
|
259
|
+
content.push({ type: 'text', text: raw });
|
|
260
|
+
}
|
|
261
|
+
// Block 4: LLM Directives — XML semantic boundary
|
|
262
|
+
if (this._hints.length > 0) {
|
|
263
|
+
const hintsText = '<llm_directives>\n' +
|
|
264
|
+
this._hints.map(h => `- ${h}`).join('\n') +
|
|
265
|
+
'\n</llm_directives>';
|
|
266
|
+
content.push({ type: 'text', text: hintsText });
|
|
267
|
+
}
|
|
268
|
+
// Block 5: Domain Rules — XML semantic boundary
|
|
269
|
+
if (this._rules.length > 0) {
|
|
270
|
+
const rulesText = '<domain_rules>\n' +
|
|
271
|
+
this._rules.map(r => `- ${r}`).join('\n') +
|
|
272
|
+
'\n</domain_rules>';
|
|
273
|
+
content.push({ type: 'text', text: rulesText });
|
|
274
|
+
}
|
|
275
|
+
// Block 6: Action Suggestions (HATEOAS) — XML semantic boundary
|
|
276
|
+
if (this._suggestions.length > 0) {
|
|
277
|
+
const suggestionsText = '<action_suggestions>\n' +
|
|
278
|
+
this._suggestions.map(s => `- ${s.tool}: ${s.reason}`).join('\n') +
|
|
279
|
+
'\n</action_suggestions>';
|
|
280
|
+
content.push({ type: 'text', text: suggestionsText });
|
|
281
|
+
}
|
|
282
|
+
const response = { content };
|
|
283
|
+
// ── MVA Meta Backdoor (Testing) ──────────────────
|
|
284
|
+
// Attach structured MVA layers via Symbol — invisible to
|
|
285
|
+
// JSON.stringify (MCP transport), readable by VurbTester.
|
|
286
|
+
let parsedData;
|
|
287
|
+
try {
|
|
288
|
+
parsedData = JSON.parse(this._data);
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
parsedData = this._data;
|
|
292
|
+
}
|
|
293
|
+
response[MVA_META_SYMBOL] = {
|
|
294
|
+
data: parsedData,
|
|
295
|
+
systemRules: this._rules,
|
|
296
|
+
uiBlocks: this._uiBlocks,
|
|
297
|
+
};
|
|
298
|
+
return response;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// ── Factory ──────────────────────────────────────────────
|
|
302
|
+
/**
|
|
303
|
+
* Create a new response builder for composing multi-block MCP responses.
|
|
304
|
+
*
|
|
305
|
+
* This is the **recommended standalone function** for building rich
|
|
306
|
+
* responses with UI blocks, LLM hints, and system rules. It keeps
|
|
307
|
+
* the handler's `ctx` pure — no framework methods injected.
|
|
308
|
+
*
|
|
309
|
+
* For simple responses, continue using {@link success} and {@link error}.
|
|
310
|
+
* Use `response()` when you need JIT context, UI blocks, or domain rules.
|
|
311
|
+
*
|
|
312
|
+
* @param data - A string message or any JSON-serializable object
|
|
313
|
+
* @returns A new {@link ResponseBuilder} for chaining
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* import { response, ui } from 'vurb';
|
|
318
|
+
*
|
|
319
|
+
* // Simple (equivalent to success())
|
|
320
|
+
* return response('Task created').build();
|
|
321
|
+
*
|
|
322
|
+
* // Rich multi-block response
|
|
323
|
+
* return response(sprintData)
|
|
324
|
+
* .uiBlock(ui.echarts(burndownConfig))
|
|
325
|
+
* .llmHint('Summarize the sprint progress analytically.')
|
|
326
|
+
* .systemRules(['Use tables for task lists.'])
|
|
327
|
+
* .build();
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @see {@link ResponseBuilder} for all available methods
|
|
331
|
+
* @see {@link Presenter} for automatic response composition
|
|
332
|
+
*/
|
|
333
|
+
export function response(data) {
|
|
334
|
+
return new ResponseBuilder(data);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Build a complete response in one call.
|
|
338
|
+
*
|
|
339
|
+
* Shorthand for `response(data).build()` — the fastest path
|
|
340
|
+
* to a valid multi-block response.
|
|
341
|
+
*
|
|
342
|
+
* @param data - A string message or JSON-serializable object
|
|
343
|
+
* @returns A ready-to-return {@link ToolResponse}
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* return response.ok('Task created');
|
|
348
|
+
* return response.ok({ id: '123', name: 'Acme' });
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
response.ok = function ok(data) {
|
|
352
|
+
return new ResponseBuilder(data).build();
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Build a response with domain rules in one call.
|
|
356
|
+
*
|
|
357
|
+
* Shorthand for `response(data).systemRules(rules).build()`.
|
|
358
|
+
*
|
|
359
|
+
* @param data - A string message or JSON-serializable object
|
|
360
|
+
* @param rules - Array of domain rule strings
|
|
361
|
+
* @returns A ready-to-return {@link ToolResponse}
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```typescript
|
|
365
|
+
* return response.withRules(invoiceData, [
|
|
366
|
+
* 'CRITICAL: amounts are in CENTS — divide by 100.',
|
|
367
|
+
* 'Use emojis: ✅ Paid, ⚠️ Pending.',
|
|
368
|
+
* ]);
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
response.withRules = function withRules(data, rules) {
|
|
372
|
+
return new ResponseBuilder(data).systemRules(rules).build();
|
|
373
|
+
};
|
|
374
|
+
//# sourceMappingURL=ResponseBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseBuilder.js","sourceRoot":"","sources":["../../src/presenter/ResponseBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAqB,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAoB,MAAM,yCAAyC,CAAC;AAQ3E,4DAA4D;AAE5D,MAAM,sBAAsB,GAAG,qBAA8B,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QACjB,KAA8B,CAAC,OAAO,KAAK,sBAAsB,CACrE,CAAC;AACN,CAAC;AAED,4DAA4D;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,eAAe;IACxB,oEAAoE;IAC3D,OAAO,GAAG,sBAAsB,CAAC;IAEzB,KAAK,CAAS;IACd,SAAS,GAAc,EAAE,CAAC;IAC1B,MAAM,GAAa,EAAE,CAAC;IACtB,MAAM,GAAa,EAAE,CAAC;IACtB,YAAY,GAAuB,EAAE,CAAC;IACtC,UAAU,GAAa,EAAE,CAAC;IAE3C,qDAAqD;IACrD,YAAY,IAAqB,EAAE,iBAA+B;QAC9D,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,KAAK,QAAQ;YACjC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,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CAAC;QAAC,MAAM,CAAC;YAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC;QAAC,CAAC;QAC9E,QAA+C,CAAC,eAAe,CAAC,GAAG;YAChE,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE,IAAI,CAAC,MAAM;YACxB,QAAQ,EAAE,IAAI,CAAC,SAAS;SAC3B,CAAC;QAEF,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAED,4DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAqB;IAC1C,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,QAAQ,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,IAAqB;IAC3C,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,QAAQ,CAAC,SAAS,GAAG,SAAS,SAAS,CACnC,IAAqB,EACrB,KAAwB;IAExB,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;AAChE,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SelectUtils — Zod Reflection & Shallow Field Filter
|
|
3
|
+
*
|
|
4
|
+
* Utilities for the `_select` context window optimization feature.
|
|
5
|
+
*
|
|
6
|
+
* - `extractZodKeys()`: Recursively unwraps Zod wrappers (Optional,
|
|
7
|
+
* Nullable, Default, Effects, Array) to reach the inner ZodObject
|
|
8
|
+
* and extract its top-level keys. Fails gracefully (returns [])
|
|
9
|
+
* for schemas without a discoverable shape.
|
|
10
|
+
*
|
|
11
|
+
* - `pickFields()`: Shallow (top-level only) field filter. Keeps
|
|
12
|
+
* only the keys requested by the AI's `_select` parameter.
|
|
13
|
+
* Nested objects are returned whole — no recursive GraphQL-style
|
|
14
|
+
* traversal. This resolves 95% of real-world overfetching.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
import { type ZodType } from 'zod';
|
|
20
|
+
/**
|
|
21
|
+
* Recursively unwrap a Zod schema to extract the top-level object keys.
|
|
22
|
+
*
|
|
23
|
+
* Peels through layers of modifiers (Optional → Nullable → Default →
|
|
24
|
+
* Effects → Array) until it finds a ZodObject, then returns
|
|
25
|
+
* `Object.keys(shape)`.
|
|
26
|
+
*
|
|
27
|
+
* Returns `[]` for schemas that don't resolve to an object shape
|
|
28
|
+
* (e.g. `z.string()`, `z.any()`, `z.record()`), which gracefully
|
|
29
|
+
* disables `_select` injection for that Presenter.
|
|
30
|
+
*
|
|
31
|
+
* @param schema - Any Zod schema (ZodType)
|
|
32
|
+
* @returns Array of top-level key names, or `[]` if not extractable
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* extractZodKeys(z.object({ id: z.string(), name: z.string() }))
|
|
37
|
+
* // → ['id', 'name']
|
|
38
|
+
*
|
|
39
|
+
* extractZodKeys(z.object({ id: z.string() }).optional().array())
|
|
40
|
+
* // → ['id']
|
|
41
|
+
*
|
|
42
|
+
* extractZodKeys(z.string())
|
|
43
|
+
* // → []
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractZodKeys(schema: ZodType): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Shallow (top-level only) field picker.
|
|
49
|
+
*
|
|
50
|
+
* Keeps only the keys present in `selectSet`. Nested objects are
|
|
51
|
+
* returned whole — no recursive path traversal. This is by design:
|
|
52
|
+
* the `_select` enum only lists root-level keys, matching 95% of
|
|
53
|
+
* real-world overfetching scenarios with O(1) complexity.
|
|
54
|
+
*
|
|
55
|
+
* @param data - The validated object to filter
|
|
56
|
+
* @param selectSet - Set of top-level keys to keep
|
|
57
|
+
* @returns A new object with only the selected keys
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* pickFields({ id: '1', status: 'paid', amount: 100 }, new Set(['status']))
|
|
62
|
+
* // → { status: 'paid' }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function pickFields(data: Record<string, unknown>, selectSet: Set<string>): Record<string, unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Apply `_select` filtering to validated data.
|
|
68
|
+
*
|
|
69
|
+
* Handles both single objects and arrays. When `isArray` is true,
|
|
70
|
+
* each item in the array is filtered independently.
|
|
71
|
+
*
|
|
72
|
+
* @param data - Validated data (single object or array)
|
|
73
|
+
* @param selectFields - Array of top-level keys to keep
|
|
74
|
+
* @param isArray - Whether `data` is an array
|
|
75
|
+
* @returns The filtered data (same shape as input, fewer fields)
|
|
76
|
+
*/
|
|
77
|
+
export declare function applySelectFilter<T>(data: T | T[], selectFields: string[], isArray: boolean): T | T[];
|
|
78
|
+
//# sourceMappingURL=SelectUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectUtils.d.ts","sourceRoot":"","sources":["../../src/presenter/SelectUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAInC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAqDxD;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAC/B,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EACb,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,OAAO,GACjB,CAAC,GAAG,CAAC,EAAE,CAUT"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SelectUtils — Zod Reflection & Shallow Field Filter
|
|
3
|
+
*
|
|
4
|
+
* Utilities for the `_select` context window optimization feature.
|
|
5
|
+
*
|
|
6
|
+
* - `extractZodKeys()`: Recursively unwraps Zod wrappers (Optional,
|
|
7
|
+
* Nullable, Default, Effects, Array) to reach the inner ZodObject
|
|
8
|
+
* and extract its top-level keys. Fails gracefully (returns [])
|
|
9
|
+
* for schemas without a discoverable shape.
|
|
10
|
+
*
|
|
11
|
+
* - `pickFields()`: Shallow (top-level only) field filter. Keeps
|
|
12
|
+
* only the keys requested by the AI's `_select` parameter.
|
|
13
|
+
* Nested objects are returned whole — no recursive GraphQL-style
|
|
14
|
+
* traversal. This resolves 95% of real-world overfetching.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
import {} from 'zod';
|
|
20
|
+
// ── Zod Key Extraction ───────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* Recursively unwrap a Zod schema to extract the top-level object keys.
|
|
23
|
+
*
|
|
24
|
+
* Peels through layers of modifiers (Optional → Nullable → Default →
|
|
25
|
+
* Effects → Array) until it finds a ZodObject, then returns
|
|
26
|
+
* `Object.keys(shape)`.
|
|
27
|
+
*
|
|
28
|
+
* Returns `[]` for schemas that don't resolve to an object shape
|
|
29
|
+
* (e.g. `z.string()`, `z.any()`, `z.record()`), which gracefully
|
|
30
|
+
* disables `_select` injection for that Presenter.
|
|
31
|
+
*
|
|
32
|
+
* @param schema - Any Zod schema (ZodType)
|
|
33
|
+
* @returns Array of top-level key names, or `[]` if not extractable
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* extractZodKeys(z.object({ id: z.string(), name: z.string() }))
|
|
38
|
+
* // → ['id', 'name']
|
|
39
|
+
*
|
|
40
|
+
* extractZodKeys(z.object({ id: z.string() }).optional().array())
|
|
41
|
+
* // → ['id']
|
|
42
|
+
*
|
|
43
|
+
* extractZodKeys(z.string())
|
|
44
|
+
* // → []
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function extractZodKeys(schema) {
|
|
48
|
+
let current = schema;
|
|
49
|
+
// Safety: iterate up to 20 layers to prevent infinite loops
|
|
50
|
+
// on pathological or circular Zod constructions.
|
|
51
|
+
for (let depth = 0; depth < 20; depth++) {
|
|
52
|
+
if (!current || typeof current !== 'object')
|
|
53
|
+
return [];
|
|
54
|
+
const def = current._def;
|
|
55
|
+
if (!def)
|
|
56
|
+
return [];
|
|
57
|
+
const typeName = def['typeName'];
|
|
58
|
+
switch (typeName) {
|
|
59
|
+
// ── Modifier Wrappers ─────────────────────────
|
|
60
|
+
case 'ZodOptional':
|
|
61
|
+
case 'ZodNullable':
|
|
62
|
+
case 'ZodDefault':
|
|
63
|
+
case 'ZodReadonly':
|
|
64
|
+
case 'ZodBranded':
|
|
65
|
+
case 'ZodCatch':
|
|
66
|
+
case 'ZodLazy':
|
|
67
|
+
current = def['innerType'];
|
|
68
|
+
continue;
|
|
69
|
+
// ── Effects (Refine, Transform, Preprocess) ───
|
|
70
|
+
case 'ZodEffects':
|
|
71
|
+
current = def['schema'];
|
|
72
|
+
continue;
|
|
73
|
+
// ── Array → extract element type ──────────────
|
|
74
|
+
case 'ZodArray':
|
|
75
|
+
current = def['type'];
|
|
76
|
+
continue;
|
|
77
|
+
// ── Pipeline → follow through ─────────────────
|
|
78
|
+
case 'ZodPipeline':
|
|
79
|
+
current = def['out'];
|
|
80
|
+
continue;
|
|
81
|
+
// ── Object → extract keys ─────────────────────
|
|
82
|
+
case 'ZodObject': {
|
|
83
|
+
const shape = current.shape;
|
|
84
|
+
return shape ? Object.keys(shape) : [];
|
|
85
|
+
}
|
|
86
|
+
// ── Terminal: cannot extract keys ─────────────
|
|
87
|
+
default:
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
// ── Field Filtering ──────────────────────────────────────
|
|
94
|
+
/**
|
|
95
|
+
* Shallow (top-level only) field picker.
|
|
96
|
+
*
|
|
97
|
+
* Keeps only the keys present in `selectSet`. Nested objects are
|
|
98
|
+
* returned whole — no recursive path traversal. This is by design:
|
|
99
|
+
* the `_select` enum only lists root-level keys, matching 95% of
|
|
100
|
+
* real-world overfetching scenarios with O(1) complexity.
|
|
101
|
+
*
|
|
102
|
+
* @param data - The validated object to filter
|
|
103
|
+
* @param selectSet - Set of top-level keys to keep
|
|
104
|
+
* @returns A new object with only the selected keys
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* pickFields({ id: '1', status: 'paid', amount: 100 }, new Set(['status']))
|
|
109
|
+
* // → { status: 'paid' }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export function pickFields(data, selectSet) {
|
|
113
|
+
const result = {};
|
|
114
|
+
for (const key of selectSet) {
|
|
115
|
+
// Defense-in-depth: only copy OWN properties, blocking
|
|
116
|
+
// prototype chain access (__proto__, constructor, etc.)
|
|
117
|
+
if (Object.hasOwn(data, key)) {
|
|
118
|
+
result[key] = data[key];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Apply `_select` filtering to validated data.
|
|
125
|
+
*
|
|
126
|
+
* Handles both single objects and arrays. When `isArray` is true,
|
|
127
|
+
* each item in the array is filtered independently.
|
|
128
|
+
*
|
|
129
|
+
* @param data - Validated data (single object or array)
|
|
130
|
+
* @param selectFields - Array of top-level keys to keep
|
|
131
|
+
* @param isArray - Whether `data` is an array
|
|
132
|
+
* @returns The filtered data (same shape as input, fewer fields)
|
|
133
|
+
*/
|
|
134
|
+
export function applySelectFilter(data, selectFields, isArray) {
|
|
135
|
+
const selectSet = new Set(selectFields);
|
|
136
|
+
if (isArray) {
|
|
137
|
+
return data.map(item => pickFields(item, selectSet));
|
|
138
|
+
}
|
|
139
|
+
return pickFields(data, selectSet);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=SelectUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectUtils.js","sourceRoot":"","sources":["../../src/presenter/SelectUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAgB,MAAM,KAAK,CAAC;AAEnC,4DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC1C,IAAI,OAAO,GAAY,MAAM,CAAC;IAE9B,4DAA4D;IAC5D,iDAAiD;IACjD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAEvD,MAAM,GAAG,GAAI,OAA8C,CAAC,IAAI,CAAC;QACjE,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QAEpB,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAuB,CAAC;QAEvD,QAAQ,QAAQ,EAAE,CAAC;YACf,iDAAiD;YACjD,KAAK,aAAa,CAAC;YACnB,KAAK,aAAa,CAAC;YACnB,KAAK,YAAY,CAAC;YAClB,KAAK,aAAa,CAAC;YACnB,KAAK,YAAY,CAAC;YAClB,KAAK,UAAU,CAAC;YAChB,KAAK,SAAS;gBACV,OAAO,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;gBAC3B,SAAS;YAEb,iDAAiD;YACjD,KAAK,YAAY;gB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A+B,EAAE,SAAS,CAAM,CAC9D,CAAC;IACN,CAAC;IAED,OAAO,UAAU,CAAC,IAA+B,EAAE,SAAS,CAAM,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZodDescriptionExtractor — Automatic Prompt Extraction from Zod .describe()
|
|
3
|
+
*
|
|
4
|
+
* Walks a Zod schema's AST and collects `.describe()` annotations from
|
|
5
|
+
* every field. These descriptions are injected as system rules via
|
|
6
|
+
* Context Tree-Shaking, eliminating the need for manual `systemRules`
|
|
7
|
+
* when the Zod schema already carries domain-specific constraints.
|
|
8
|
+
*
|
|
9
|
+
* This ensures documentation never drifts from the actual data shape:
|
|
10
|
+
* the single source of truth is the Zod `.describe()` annotation.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const schema = z.object({
|
|
15
|
+
* amount_cents: z.number().describe('CRITICAL: in CENTS. Divide by 100.'),
|
|
16
|
+
* status: z.enum(['paid', 'pending']).describe('Always display with emoji'),
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* extractZodDescriptions(schema);
|
|
20
|
+
* // → ['amount_cents: CRITICAL: in CENTS. Divide by 100.',
|
|
21
|
+
* // 'status: Always display with emoji']
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
import { type ZodType } from 'zod';
|
|
27
|
+
/**
|
|
28
|
+
* Extract `.describe()` annotations from a Zod schema's fields.
|
|
29
|
+
*
|
|
30
|
+
* Walks the top-level `z.object()` shape and retrieves the description
|
|
31
|
+
* string from each field (after unwrapping wrappers like `z.optional()`,
|
|
32
|
+
* `z.nullable()`, `z.default()`, etc.).
|
|
33
|
+
*
|
|
34
|
+
* Returns an array of human-readable `"fieldName: description"` strings,
|
|
35
|
+
* ready to be injected as system rules.
|
|
36
|
+
*
|
|
37
|
+
* @param schema - A Zod schema (typically z.object, but safely handles non-objects)
|
|
38
|
+
* @returns Array of `"fieldName: description"` strings (empty if no descriptions found)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const schema = z.object({
|
|
43
|
+
* amount_cents: z.number().describe('CRITICAL: value is in CENTS. Divide by 100.'),
|
|
44
|
+
* currency: z.string(), // No .describe() → skipped
|
|
45
|
+
* status: z.enum(['paid', 'pending']).describe('Show with emoji'),
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* extractZodDescriptions(schema);
|
|
49
|
+
* // → ['amount_cents: CRITICAL: value is in CENTS. Divide by 100.',
|
|
50
|
+
* // 'status: Show with emoji']
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractZodDescriptions(schema: ZodType): string[];
|
|
54
|
+
//# sourceMappingURL=ZodDescriptionExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodDescriptionExtractor.d.ts","sourceRoot":"","sources":["../../src/presenter/ZodDescriptionExtractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAqEnC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAehE"}
|