@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,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SandboxGuard — Fail-Fast Syntax Checker for LLM-Provided Code
|
|
3
|
+
*
|
|
4
|
+
* Provides quick feedback BEFORE sending code to the isolated-vm engine.
|
|
5
|
+
* This is NOT a security boundary — security comes from the empty V8
|
|
6
|
+
* Context (no `process`, `require`, `fs`, or `globalThis` injected).
|
|
7
|
+
*
|
|
8
|
+
* Purpose:
|
|
9
|
+
* - Validate that the code is syntactically valid JavaScript
|
|
10
|
+
* - Check that it looks like a function expression / arrow function
|
|
11
|
+
* - Provide fast, descriptive error messages to the LLM
|
|
12
|
+
*
|
|
13
|
+
* Properties:
|
|
14
|
+
* - Zero runtime dependencies (pure string analysis)
|
|
15
|
+
* - Fail-fast: rejects obviously broken code before V8 boot
|
|
16
|
+
* - NOT a security gate (LLMs can obfuscate; the Isolate is the real wall)
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export interface GuardResult {
|
|
22
|
+
/** Whether the code passed the fail-fast check */
|
|
23
|
+
readonly ok: boolean;
|
|
24
|
+
/** Human-readable reason for rejection (present when `ok` is false) */
|
|
25
|
+
readonly violation?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validate LLM-provided code before sending it to the sandbox.
|
|
29
|
+
*
|
|
30
|
+
* Performs two checks:
|
|
31
|
+
* 1. **Shape check**: The code must look like a function expression
|
|
32
|
+
* 2. **Suspicious pattern check**: Fail-fast for obviously unsandboxable patterns
|
|
33
|
+
*
|
|
34
|
+
* @param code - The JavaScript code string from the LLM
|
|
35
|
+
* @returns A `GuardResult` indicating whether the code passed
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const result = validateSandboxCode('(data) => data.filter(d => d.x > 5)');
|
|
40
|
+
* // { ok: true }
|
|
41
|
+
*
|
|
42
|
+
* const bad = validateSandboxCode('require("fs").readFileSync("/etc/passwd")');
|
|
43
|
+
* // { ok: false, violation: 'Code must be a function expression...' }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateSandboxCode(code: string): GuardResult;
|
|
47
|
+
//# sourceMappingURL=SandboxGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SandboxGuard.d.ts","sourceRoot":"","sources":["../../src/sandbox/SandboxGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,WAAW,WAAW;IACxB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC/B;AAqCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CA2C7D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SandboxGuard — Fail-Fast Syntax Checker for LLM-Provided Code
|
|
3
|
+
*
|
|
4
|
+
* Provides quick feedback BEFORE sending code to the isolated-vm engine.
|
|
5
|
+
* This is NOT a security boundary — security comes from the empty V8
|
|
6
|
+
* Context (no `process`, `require`, `fs`, or `globalThis` injected).
|
|
7
|
+
*
|
|
8
|
+
* Purpose:
|
|
9
|
+
* - Validate that the code is syntactically valid JavaScript
|
|
10
|
+
* - Check that it looks like a function expression / arrow function
|
|
11
|
+
* - Provide fast, descriptive error messages to the LLM
|
|
12
|
+
*
|
|
13
|
+
* Properties:
|
|
14
|
+
* - Zero runtime dependencies (pure string analysis)
|
|
15
|
+
* - Fail-fast: rejects obviously broken code before V8 boot
|
|
16
|
+
* - NOT a security gate (LLMs can obfuscate; the Isolate is the real wall)
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
// ── Constants ────────────────────────────────────────────
|
|
22
|
+
/**
|
|
23
|
+
* Patterns that indicate the code is NOT a pure function.
|
|
24
|
+
* These are fail-fast hints, not security barriers.
|
|
25
|
+
* The V8 Isolate with an empty Context is the real security wall.
|
|
26
|
+
*/
|
|
27
|
+
const SUSPICIOUS_PATTERNS = [
|
|
28
|
+
{ pattern: /\bimport\s*\(/, reason: 'Dynamic import() is not available in the sandbox.' },
|
|
29
|
+
{ pattern: /\bimport\s+/, reason: 'ES module imports are not available in the sandbox.' },
|
|
30
|
+
{ pattern: /\brequire\s*\(/, reason: 'require() is not available in the sandbox.' },
|
|
31
|
+
// Bug #139: fail-fast for eval()/Function() — no security risk (empty Context),
|
|
32
|
+
// but provides immediate, actionable feedback to the LLM.
|
|
33
|
+
{ pattern: /\beval\s*\(/, reason: 'eval() has no effect in the sandbox — use direct expressions instead.' },
|
|
34
|
+
{ pattern: /\bnew\s+Function\s*\(/, reason: 'new Function() has no effect in the sandbox — use direct expressions instead.' },
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* The code must start with one of these patterns to be recognized
|
|
38
|
+
* as a function expression or arrow function.
|
|
39
|
+
*/
|
|
40
|
+
const FUNCTION_PATTERNS = [
|
|
41
|
+
/^\s*\(.*\)\s*=>/s, // (x) => ...
|
|
42
|
+
/^\s*[a-zA-Z_$]\w*\s*=>/, // x => ...
|
|
43
|
+
/^\s*function\s*\(/, // function(x) { ... }
|
|
44
|
+
/^\s*function\s+\w+\s*\(/, // function name(x) { ... }
|
|
45
|
+
// Async patterns kept for shape recognition — SUSPICIOUS_PATTERNS
|
|
46
|
+
// will reject them before they reach execution (Bug #16)
|
|
47
|
+
/^\s*async\s+\(.*\)\s*=>/s, // async (x) => ...
|
|
48
|
+
/^\s*async\s+function\s*\(/, // async function(x) { ... }
|
|
49
|
+
/^\s*async\s+[a-zA-Z_$]\w*\s*=>/, // async x => ...
|
|
50
|
+
];
|
|
51
|
+
// ── Guard Implementation ─────────────────────────────────
|
|
52
|
+
/**
|
|
53
|
+
* Validate LLM-provided code before sending it to the sandbox.
|
|
54
|
+
*
|
|
55
|
+
* Performs two checks:
|
|
56
|
+
* 1. **Shape check**: The code must look like a function expression
|
|
57
|
+
* 2. **Suspicious pattern check**: Fail-fast for obviously unsandboxable patterns
|
|
58
|
+
*
|
|
59
|
+
* @param code - The JavaScript code string from the LLM
|
|
60
|
+
* @returns A `GuardResult` indicating whether the code passed
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const result = validateSandboxCode('(data) => data.filter(d => d.x > 5)');
|
|
65
|
+
* // { ok: true }
|
|
66
|
+
*
|
|
67
|
+
* const bad = validateSandboxCode('require("fs").readFileSync("/etc/passwd")');
|
|
68
|
+
* // { ok: false, violation: 'Code must be a function expression...' }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function validateSandboxCode(code) {
|
|
72
|
+
if (!code || typeof code !== 'string') {
|
|
73
|
+
return { ok: false, violation: 'Code must be a non-empty string.' };
|
|
74
|
+
}
|
|
75
|
+
const trimmed = code.trim();
|
|
76
|
+
if (trimmed.length === 0) {
|
|
77
|
+
return { ok: false, violation: 'Code must be a non-empty string.' };
|
|
78
|
+
}
|
|
79
|
+
// Shape check: must look like a function
|
|
80
|
+
const looksLikeFunction = FUNCTION_PATTERNS.some(p => p.test(trimmed));
|
|
81
|
+
if (!looksLikeFunction) {
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
violation: 'Code must be a function expression or arrow function. ' +
|
|
85
|
+
'Example: (data) => data.filter(d => d.value > 10)',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Suspicious pattern check (fail-fast hints, not security)
|
|
89
|
+
for (const { pattern, reason } of SUSPICIOUS_PATTERNS) {
|
|
90
|
+
if (pattern.test(trimmed)) {
|
|
91
|
+
return { ok: false, violation: reason };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Bug #136: detect `async` anywhere in the code (not just at the start).
|
|
95
|
+
// Strip string literals first to avoid false positives on e.g. "async".
|
|
96
|
+
if (containsAsyncKeyword(trimmed)) {
|
|
97
|
+
return {
|
|
98
|
+
ok: false,
|
|
99
|
+
violation: 'Async functions are not supported in the sandbox. ' +
|
|
100
|
+
'The sandbox uses synchronous JSON.stringify(fn(input)) — ' +
|
|
101
|
+
'an async function would serialize to \'{}\'. ' +
|
|
102
|
+
'Use a synchronous function instead.',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return { ok: true };
|
|
106
|
+
}
|
|
107
|
+
// ── Helpers ──────────────────────────────────────────────
|
|
108
|
+
/**
|
|
109
|
+
* Strip string literals (single, double, template) to avoid
|
|
110
|
+
* false positives when scanning for keywords like `async`.
|
|
111
|
+
* Replaces each string literal with empty quotes of the same kind.
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
function stripStringLiterals(code) {
|
|
115
|
+
// Match single-quoted, double-quoted, and back-tick strings
|
|
116
|
+
// (respects escape sequences: \' \" \` don't close the string)
|
|
117
|
+
return code.replace(/(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`)/gs, '""');
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if `async` appears as a keyword anywhere in the code,
|
|
121
|
+
* ignoring occurrences inside string literals (Bug #136).
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
function containsAsyncKeyword(code) {
|
|
125
|
+
return /\basync\b/.test(stripStringLiterals(code));
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=Sand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andbox — Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* Zero-Trust Computation Delegation via isolated-vm.
|
|
5
|
+
* Allows LLMs to send JavaScript functions to be executed
|
|
6
|
+
* in a sealed V8 isolate on the client's machine.
|
|
7
|
+
*
|
|
8
|
+
* The `isolated-vm` package is an optional peerDependency.
|
|
9
|
+
* The framework works fully without it — sandbox is a power add-on.
|
|
10
|
+
*/
|
|
11
|
+
export { SandboxEngine, resetIvmCache } from './SandboxEngine.js';
|
|
12
|
+
export type { SandboxConfig, SandboxResult, SandboxErrorCode } from './SandboxEngine.js';
|
|
13
|
+
export { validateSandboxCode } from './SandboxGuard.js';
|
|
14
|
+
export type { GuardResult } from './SandboxGuard.js';
|
|
15
|
+
/**
|
|
16
|
+
* System instruction auto-injected into the tool description
|
|
17
|
+
* when `.sandboxed()` is used. Teaches the LLM how to send
|
|
18
|
+
* JavaScript functions for server-side computation delegation.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare const SANDBOX_SYSTEM_INSTRUCTION: string;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,QAKiC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox — Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* Zero-Trust Computation Delegation via isolated-vm.
|
|
5
|
+
* Allows LLMs to send JavaScript functions to be executed
|
|
6
|
+
* in a sealed V8 isolate on the client's machine.
|
|
7
|
+
*
|
|
8
|
+
* The `isolated-vm` package is an optional peerDependency.
|
|
9
|
+
* The framework works fully without it — sandbox is a power add-on.
|
|
10
|
+
*/
|
|
11
|
+
export { SandboxEngine, resetIvmCache } from './SandboxEngine.js';
|
|
12
|
+
export { validateSandboxCode } from './SandboxGuard.js';
|
|
13
|
+
// ── HATEOAS Auto-Prompting Instruction ───────────────────
|
|
14
|
+
/**
|
|
15
|
+
* System instruction auto-injected into the tool description
|
|
16
|
+
* when `.sandboxed()` is used. Teaches the LLM how to send
|
|
17
|
+
* JavaScript functions for server-side computation delegation.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export const SANDBOX_SYSTEM_INSTRUCTION = '\n\n[SYSTEM: This tool supports Zero-Trust Compute. ' +
|
|
22
|
+
'You MUST pass a valid, pure, synchronous JavaScript arrow function as a string ' +
|
|
23
|
+
'to filter/map the data on the server before receiving it. ' +
|
|
24
|
+
'E.g.: (data) => data.filter(d => d.value > 10). ' +
|
|
25
|
+
'Do not use markdown formatting, async/await, or external imports.]';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,4DAA4D;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACnC,sDAAsD;IACtD,iFAAiF;IACjF,4DAA4D;IAC5D,kDAAkD;IAClD,oEAAoE,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** Duck-typed MCP server that supports notifications */
|
|
2
|
+
interface McpServerLike {
|
|
3
|
+
notification(notification: {
|
|
4
|
+
method: string;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
sendNotification?(notification: {
|
|
7
|
+
method: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/** Duck-typed ToolRegistry */
|
|
11
|
+
interface ToolRegistryLike {
|
|
12
|
+
register(builder: unknown): void;
|
|
13
|
+
getBuilders?(): unknown[];
|
|
14
|
+
/** Optional: clear all builders before re-registering (for hot-reload) */
|
|
15
|
+
clear?(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for the development server.
|
|
19
|
+
*/
|
|
20
|
+
export interface DevServerConfig {
|
|
21
|
+
/**
|
|
22
|
+
* Directory to watch for file changes.
|
|
23
|
+
* Relative paths are resolved from the current working directory.
|
|
24
|
+
*/
|
|
25
|
+
readonly dir: string;
|
|
26
|
+
/**
|
|
27
|
+
* File extension filter for watched files.
|
|
28
|
+
* @default ['.ts', '.js', '.mjs', '.mts']
|
|
29
|
+
*/
|
|
30
|
+
readonly extensions?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Debounce interval in milliseconds.
|
|
33
|
+
* Prevents rapid-fire reloads when editors save multiple files.
|
|
34
|
+
* @default 300
|
|
35
|
+
*/
|
|
36
|
+
readonly debounce?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Setup callback invoked on every reload.
|
|
39
|
+
*
|
|
40
|
+
* Receives a fresh ToolRegistry. The callback should:
|
|
41
|
+
* 1. Import/define all tools
|
|
42
|
+
* 2. Register them on the registry
|
|
43
|
+
*
|
|
44
|
+
* This is called on initial startup and on every file change.
|
|
45
|
+
*/
|
|
46
|
+
readonly setup: (registry: ToolRegistryLike) => void | Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Optional callback when a reload occurs.
|
|
49
|
+
* Useful for logging or triggering downstream updates.
|
|
50
|
+
*/
|
|
51
|
+
readonly onReload?: (changedFile: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Optional MCP server reference for sending tool list change notifications.
|
|
54
|
+
* When provided, the dev server sends `notifications/tools/list_changed`
|
|
55
|
+
* on every reload, so the LLM client picks up changes automatically.
|
|
56
|
+
*/
|
|
57
|
+
readonly server?: McpServerLike;
|
|
58
|
+
/**
|
|
59
|
+
* Optional real ToolRegistry reference for hot-reload.
|
|
60
|
+
*
|
|
61
|
+
* When provided, builders collected during `setup()` are automatically
|
|
62
|
+
* transferred to this registry after each reload, making hot-reload
|
|
63
|
+
* effective. Without this, the user must close over their own registry
|
|
64
|
+
* in the setup callback (fragile and undocumented pattern).
|
|
65
|
+
*
|
|
66
|
+
* If the registry implements `clear()`, old builders are removed
|
|
67
|
+
* before re-registration to avoid duplicates.
|
|
68
|
+
*/
|
|
69
|
+
readonly registry?: ToolRegistryLike;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Interface for a running dev server instance.
|
|
73
|
+
*/
|
|
74
|
+
export interface DevServer {
|
|
75
|
+
/** Start watching and perform initial load */
|
|
76
|
+
start(): Promise<void>;
|
|
77
|
+
/** Stop the watcher and clean up */
|
|
78
|
+
stop(): void;
|
|
79
|
+
/** Force a manual reload (useful from CLI) */
|
|
80
|
+
reload(reason?: string): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a cache-busting import URL for ESM modules.
|
|
84
|
+
* Appends a timestamp query to force the module to be re-evaluated.
|
|
85
|
+
*
|
|
86
|
+
* Use this inside a DevServer `setup` callback to re-import ESM modules:
|
|
87
|
+
* ```ts
|
|
88
|
+
* const mod = await import(cacheBustUrl('./src/tools.ts'));
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function cacheBustUrl(filePath: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Create an HMR-enabled MCP development server.
|
|
94
|
+
*
|
|
95
|
+
* Watches a directory for file changes and automatically reloads
|
|
96
|
+
* tools, then notifies the connected MCP client via the native
|
|
97
|
+
* `notifications/tools/list_changed` notification.
|
|
98
|
+
*
|
|
99
|
+
* @param config - Dev server configuration
|
|
100
|
+
* @returns A {@link DevServer} instance with start/stop/reload controls
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* import { createDevServer, autoDiscover, ToolRegistry } from 'vurb';
|
|
105
|
+
*
|
|
106
|
+
* const devServer = createDevServer({
|
|
107
|
+
* dir: './src/tools',
|
|
108
|
+
* setup: async (registry) => {
|
|
109
|
+
* await autoDiscover(registry, './src/tools');
|
|
110
|
+
* },
|
|
111
|
+
* onReload: (file) => console.log(`[HMR] Reloaded: ${file}`),
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* await devServer.start();
|
|
115
|
+
* // File changes → auto-reload → LLM client gets notification
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function createDevServer(config: DevServerConfig): DevServer;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=DevServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../../src/server/DevServer.ts"],"names":[],"mappings":"AAkDA,wDAAwD;AACxD,UAAU,aAAa;IACnB,YAAY,CAAC,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,gBAAgB,CAAC,CAAC,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE;AAED,8BAA8B;AAC9B,UAAU,gBAAgB;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjC,WAAW,CAAC,IAAI,OAAO,EAAE,CAAC;IAC1B,0EAA0E;IAC1E,KAAK,CAAC,IAAI,IAAI,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAElD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,8CAA8C;IAC9C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,oCAAoC;IACpC,IAAI,IAAI,IAAI,CAAC;IACb,8CAA8C;IAC9C,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAgED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrD;AAID;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CA6HlE"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevServer — HMR-enabled MCP Development Server
|
|
3
|
+
*
|
|
4
|
+
* The "killer feature" for MCP DX: `vurb dev` starts a
|
|
5
|
+
* development server that watches for file changes and performs
|
|
6
|
+
* automatic Hot Module Replacement without requiring the LLM client
|
|
7
|
+
* (Claude Desktop, Cursor, etc.) to be restarted.
|
|
8
|
+
*
|
|
9
|
+
* ## How It Works
|
|
10
|
+
*
|
|
11
|
+
* 1. The dev server starts an MCP stdio server with your tools
|
|
12
|
+
* 2. When a `.ts`/`.js` file changes, the module cache is invalidated
|
|
13
|
+
* 3. Tools are re-registered from the updated modules
|
|
14
|
+
* 4. The MCP `notifications/tools/list_changed` notification is sent
|
|
15
|
+
* 5. The LLM client picks up the new tool definitions transparently
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
18
|
+
*
|
|
19
|
+
* ```bash
|
|
20
|
+
* # Auto-detects src/server.ts
|
|
21
|
+
* vurb dev
|
|
22
|
+
*
|
|
23
|
+
* # Explicit entrypoint + custom watch dir
|
|
24
|
+
* vurb dev --server ./src/server.ts --dir ./src/tools
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Using the programmatic API
|
|
30
|
+
* import { createDevServer } from 'vurb/dev';
|
|
31
|
+
*
|
|
32
|
+
* const devServer = createDevServer({
|
|
33
|
+
* dir: './src/tools',
|
|
34
|
+
* setup: async (registry) => {
|
|
35
|
+
* // Your setup logic — called on every reload
|
|
36
|
+
* await autoDiscover(registry, './src/tools');
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* await devServer.start();
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/
|
|
45
|
+
import { watch } from 'node:fs';
|
|
46
|
+
import { resolve, join, relative } from 'node:path';
|
|
47
|
+
import { pathToFileURL } from 'node:url';
|
|
48
|
+
// ── Module Cache Invalidation ────────────────────────────
|
|
49
|
+
/**
|
|
50
|
+
* Invalidate Node.js ESM module cache for a given file.
|
|
51
|
+
*
|
|
52
|
+
* ESM modules are cached by URL. We use an import timestamp trick
|
|
53
|
+
* to force re-evaluation on next import.
|
|
54
|
+
*
|
|
55
|
+
* For CJS, we clear `require.cache` if available.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
function invalidateModule(filePath) {
|
|
60
|
+
const absolutePath = resolve(filePath);
|
|
61
|
+
// CJS cache invalidation (when running in CJS mode)
|
|
62
|
+
if (typeof require !== 'undefined' && require.cache) {
|
|
63
|
+
invalidateCjsTree(absolutePath);
|
|
64
|
+
}
|
|
65
|
+
// ESM modules can't be uncached directly — use a cache-busting
|
|
66
|
+
// query parameter so the next dynamic import() re-evaluates the module.
|
|
67
|
+
lastCacheBustUrl = cacheBustUrl(absolutePath);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The last cache-busted URL produced by `invalidateModule()`.
|
|
71
|
+
* The setup callback can use this to re-import an ESM module that was invalidated.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
let lastCacheBustUrl;
|
|
75
|
+
/**
|
|
76
|
+
* Recursively invalidate a CJS module and all modules that depend on it.
|
|
77
|
+
*
|
|
78
|
+
* Walks `require.cache` to find modules whose `children` include the
|
|
79
|
+
* changed module (i.e., importers / dependents), and removes them so
|
|
80
|
+
* the next `require()` re-evaluates the entire dependency chain.
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
function invalidateCjsTree(entryPath) {
|
|
85
|
+
const visited = new Set();
|
|
86
|
+
const queue = [entryPath];
|
|
87
|
+
while (queue.length > 0) {
|
|
88
|
+
const current = queue.pop();
|
|
89
|
+
if (visited.has(current))
|
|
90
|
+
continue;
|
|
91
|
+
visited.add(current);
|
|
92
|
+
delete require.cache[current];
|
|
93
|
+
// Find all cached modules that imported `current`
|
|
94
|
+
for (const [key, mod] of Object.entries(require.cache)) {
|
|
95
|
+
if (!mod)
|
|
96
|
+
continue;
|
|
97
|
+
const children = mod.children ?? [];
|
|
98
|
+
if (children.some(c => c.id === current)) {
|
|
99
|
+
queue.push(key);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a cache-busting import URL for ESM modules.
|
|
106
|
+
* Appends a timestamp query to force the module to be re-evaluated.
|
|
107
|
+
*
|
|
108
|
+
* Use this inside a DevServer `setup` callback to re-import ESM modules:
|
|
109
|
+
* ```ts
|
|
110
|
+
* const mod = await import(cacheBustUrl('./src/tools.ts'));
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export function cacheBustUrl(filePath) {
|
|
114
|
+
const url = pathToFileURL(resolve(filePath));
|
|
115
|
+
url.searchParams.set('t', String(Date.now()));
|
|
116
|
+
return url.href;
|
|
117
|
+
}
|
|
118
|
+
// ── Dev Server Factory ───────────────────────────────────
|
|
119
|
+
/**
|
|
120
|
+
* Create an HMR-enabled MCP development server.
|
|
121
|
+
*
|
|
122
|
+
* Watches a directory for file changes and automatically reloads
|
|
123
|
+
* tools, then notifies the connected MCP client via the native
|
|
124
|
+
* `notifications/tools/list_changed` notification.
|
|
125
|
+
*
|
|
126
|
+
* @param config - Dev server configuration
|
|
127
|
+
* @returns A {@link DevServer} instance with start/stop/reload controls
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* import { createDevServer, autoDiscover, ToolRegistry } from 'vurb';
|
|
132
|
+
*
|
|
133
|
+
* const devServer = createDevServer({
|
|
134
|
+
* dir: './src/tools',
|
|
135
|
+
* setup: async (registry) => {
|
|
136
|
+
* await autoDiscover(registry, './src/tools');
|
|
137
|
+
* },
|
|
138
|
+
* onReload: (file) => console.log(`[HMR] Reloaded: ${file}`),
|
|
139
|
+
* });
|
|
140
|
+
*
|
|
141
|
+
* await devServer.start();
|
|
142
|
+
* // File changes → auto-reload → LLM client gets notification
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export function createDevServer(config) {
|
|
146
|
+
const { dir, extensions = ['.ts', '.js', '.mjs', '.mts'], debounce = 300, setup, onReload, server, } = config;
|
|
147
|
+
const absoluteDir = resolve(dir);
|
|
148
|
+
let watcher;
|
|
149
|
+
let debounceTimer;
|
|
150
|
+
let reloadCount = 0;
|
|
151
|
+
/**
|
|
152
|
+
* Perform a full reload: clear caches, re-run setup, notify MCP client.
|
|
153
|
+
*/
|
|
154
|
+
async function performReload(changedFile) {
|
|
155
|
+
reloadCount++;
|
|
156
|
+
// Invalidate CJS cache for all watched files
|
|
157
|
+
invalidateModule(changedFile);
|
|
158
|
+
// Re-run the user's setup callback
|
|
159
|
+
// Provide a duck-typed registry that satisfies the interface.
|
|
160
|
+
// The user's setup may use this or close over their own registry.
|
|
161
|
+
const builders = [];
|
|
162
|
+
const reloadRegistry = {
|
|
163
|
+
register(builder) { builders.push(builder); },
|
|
164
|
+
getBuilders() { return builders; },
|
|
165
|
+
};
|
|
166
|
+
try {
|
|
167
|
+
await setup(reloadRegistry);
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
171
|
+
// eslint-disable-next-line no-console
|
|
172
|
+
console.error(`[vurb dev] Reload failed: ${message}`);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// Transfer collected builders to the real registry (Bug #42 fix)
|
|
176
|
+
if (builders.length > 0 && config.registry) {
|
|
177
|
+
if (typeof config.registry.clear === 'function') {
|
|
178
|
+
config.registry.clear();
|
|
179
|
+
}
|
|
180
|
+
for (const b of builders) {
|
|
181
|
+
config.registry.register(b);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Notify MCP client about tool list changes
|
|
185
|
+
if (server) {
|
|
186
|
+
const notification = { method: 'notifications/tools/list_changed' };
|
|
187
|
+
try {
|
|
188
|
+
if (typeof server.sendNotification === 'function') {
|
|
189
|
+
await server.sendNotification(notification);
|
|
190
|
+
}
|
|
191
|
+
else if (typeof server.notification === 'function') {
|
|
192
|
+
await server.notification(notification);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// Connection might not be established yet — ignore
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// User callback
|
|
200
|
+
onReload?.(changedFile);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
async start() {
|
|
204
|
+
// Perform initial load
|
|
205
|
+
await performReload('(initial)');
|
|
206
|
+
// Start watching
|
|
207
|
+
const watchOptions = { recursive: true };
|
|
208
|
+
// Bug #128: warn on Linux with Node.js < 20 where recursive watch is unsupported
|
|
209
|
+
if (process.platform === 'linux' && parseInt(process.versions.node, 10) < 20) {
|
|
210
|
+
// eslint-disable-next-line no-console
|
|
211
|
+
console.warn('[vurb dev] Warning: recursive fs.watch() is not fully supported on Linux with Node.js < 20. ' +
|
|
212
|
+
'File changes in subdirectories may not be detected. Consider upgrading to Node.js 20+.');
|
|
213
|
+
}
|
|
214
|
+
watcher = watch(absoluteDir, watchOptions, (_eventType, filename) => {
|
|
215
|
+
if (!filename)
|
|
216
|
+
return;
|
|
217
|
+
// Filter by extension
|
|
218
|
+
const ext = '.' + filename.split('.').pop();
|
|
219
|
+
if (!extensions.includes(ext))
|
|
220
|
+
return;
|
|
221
|
+
// Skip test/spec files
|
|
222
|
+
if (/\.(test|spec|d)\./.test(filename))
|
|
223
|
+
return;
|
|
224
|
+
// Debounce rapid changes
|
|
225
|
+
if (debounceTimer)
|
|
226
|
+
clearTimeout(debounceTimer);
|
|
227
|
+
debounceTimer = setTimeout(() => {
|
|
228
|
+
const fullPath = join(absoluteDir, filename);
|
|
229
|
+
void performReload(relative(process.cwd(), fullPath));
|
|
230
|
+
}, debounce);
|
|
231
|
+
});
|
|
232
|
+
watcher.on('error', (err) => {
|
|
233
|
+
// eslint-disable-next-line no-console
|
|
234
|
+
console.error(`[vurb dev] Watcher error: ${err instanceof Error ? err.message : String(err)}`);
|
|
235
|
+
});
|
|
236
|
+
// eslint-disable-next-line no-console
|
|
237
|
+
console.log(`[vurb dev] Watching ${relative(process.cwd(), absoluteDir)} for changes...`);
|
|
238
|
+
},
|
|
239
|
+
stop() {
|
|
240
|
+
if (debounceTimer)
|
|
241
|
+
clearTimeout(debounceTimer);
|
|
242
|
+
watcher?.close();
|
|
243
|
+
watcher = undefined;
|
|
244
|
+
// eslint-disable-next-line no-console
|
|
245
|
+
console.log(`[vurb dev] Stopped. ${reloadCount} reload(s) performed.`);
|
|
246
|
+
},
|
|
247
|
+
async reload(reason) {
|
|
248
|
+
await performReload(reason ?? '(manual)');
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=DevServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevServer.js","sourceRoot":"","sources":["../../src/server/DevServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA4FzC,4DAA4D;AAE5D;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,QAAgB;IACtC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEvC,oDAAoD;IACpD,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClD,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAED,+DAA+D;IAC/D,wEAAwE;IACxE,gBAAgB,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,IAAI,gBAAoC,CAAC;AAEzC;;;;;;;;GAQG;AACH,SAAS,iBAAiB,CAAC,SAAiB;IACxC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC;IAE1B,OAAO,K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