@syrin/cli 1.3.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/LICENSE +15 -0
- package/README.md +302 -0
- package/dist/cli/commands/analyse.d.ts +16 -0
- package/dist/cli/commands/analyse.js +61 -0
- package/dist/cli/commands/dev.d.ts +23 -0
- package/dist/cli/commands/dev.js +419 -0
- package/dist/cli/commands/doctor.d.ts +10 -0
- package/dist/cli/commands/doctor.js +195 -0
- package/dist/cli/commands/index.d.ts +12 -0
- package/dist/cli/commands/index.js +12 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.js +90 -0
- package/dist/cli/commands/list.d.ts +15 -0
- package/dist/cli/commands/list.js +50 -0
- package/dist/cli/commands/rollback.d.ts +12 -0
- package/dist/cli/commands/rollback.js +101 -0
- package/dist/cli/commands/test.d.ts +31 -0
- package/dist/cli/commands/test.js +88 -0
- package/dist/cli/commands/update.d.ts +9 -0
- package/dist/cli/commands/update.js +76 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +342 -0
- package/dist/cli/prompts/index.d.ts +5 -0
- package/dist/cli/prompts/index.js +5 -0
- package/dist/cli/prompts/init-prompt.d.ts +17 -0
- package/dist/cli/prompts/init-prompt.js +263 -0
- package/dist/cli/utils/command-error-handler.d.ts +14 -0
- package/dist/cli/utils/command-error-handler.js +35 -0
- package/dist/cli/utils/common-types.d.ts +24 -0
- package/dist/cli/utils/common-types.js +6 -0
- package/dist/cli/utils/connection-handler.d.ts +37 -0
- package/dist/cli/utils/connection-handler.js +90 -0
- package/dist/cli/utils/index.d.ts +11 -0
- package/dist/cli/utils/index.js +11 -0
- package/dist/cli/utils/option-parsers.d.ts +41 -0
- package/dist/cli/utils/option-parsers.js +92 -0
- package/dist/cli/utils/output-utils.d.ts +12 -0
- package/dist/cli/utils/output-utils.js +21 -0
- package/dist/cli/utils/transport-resolver.d.ts +33 -0
- package/dist/cli/utils/transport-resolver.js +82 -0
- package/dist/cli/utils/version-banner.d.ts +10 -0
- package/dist/cli/utils/version-banner.js +26 -0
- package/dist/config/env-checker.d.ts +37 -0
- package/dist/config/env-checker.js +136 -0
- package/dist/config/generator.d.ts +19 -0
- package/dist/config/generator.js +196 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.js +9 -0
- package/dist/config/loader.d.ts +19 -0
- package/dist/config/loader.js +57 -0
- package/dist/config/schema.d.ts +42 -0
- package/dist/config/schema.js +181 -0
- package/dist/config/syrin.template.yaml +127 -0
- package/dist/config/types.d.ts +87 -0
- package/dist/config/types.js +6 -0
- package/dist/constants/app.d.ts +9 -0
- package/dist/constants/app.js +9 -0
- package/dist/constants/commands.d.ts +43 -0
- package/dist/constants/commands.js +43 -0
- package/dist/constants/defaults.d.ts +18 -0
- package/dist/constants/defaults.js +18 -0
- package/dist/constants/env-vars.d.ts +11 -0
- package/dist/constants/env-vars.js +11 -0
- package/dist/constants/icons.d.ts +23 -0
- package/dist/constants/icons.js +23 -0
- package/dist/constants/index.d.ts +17 -0
- package/dist/constants/index.js +17 -0
- package/dist/constants/labels.d.ts +38 -0
- package/dist/constants/labels.js +42 -0
- package/dist/constants/links.d.ts +10 -0
- package/dist/constants/links.js +11 -0
- package/dist/constants/list.d.ts +10 -0
- package/dist/constants/list.js +9 -0
- package/dist/constants/llm.d.ts +26 -0
- package/dist/constants/llm.js +25 -0
- package/dist/constants/messages.d.ts +107 -0
- package/dist/constants/messages.js +138 -0
- package/dist/constants/paths.d.ts +29 -0
- package/dist/constants/paths.js +29 -0
- package/dist/constants/transport.d.ts +9 -0
- package/dist/constants/transport.js +8 -0
- package/dist/events/emitter.d.ts +64 -0
- package/dist/events/emitter.js +142 -0
- package/dist/events/event-type.d.ts +66 -0
- package/dist/events/event-type.js +81 -0
- package/dist/events/payloads/diagnostics.d.ts +24 -0
- package/dist/events/payloads/diagnostics.js +5 -0
- package/dist/events/payloads/index.d.ts +15 -0
- package/dist/events/payloads/index.js +6 -0
- package/dist/events/payloads/llm.d.ts +58 -0
- package/dist/events/payloads/llm.js +6 -0
- package/dist/events/payloads/registry.d.ts +28 -0
- package/dist/events/payloads/registry.js +5 -0
- package/dist/events/payloads/session.d.ts +32 -0
- package/dist/events/payloads/session.js +5 -0
- package/dist/events/payloads/testing.d.ts +17 -0
- package/dist/events/payloads/testing.js +5 -0
- package/dist/events/payloads/tool.d.ts +29 -0
- package/dist/events/payloads/tool.js +5 -0
- package/dist/events/payloads/transport.d.ts +30 -0
- package/dist/events/payloads/transport.js +5 -0
- package/dist/events/payloads/validation.d.ts +37 -0
- package/dist/events/payloads/validation.js +5 -0
- package/dist/events/payloads/workflow.d.ts +45 -0
- package/dist/events/payloads/workflow.js +5 -0
- package/dist/events/store/file-store.d.ts +37 -0
- package/dist/events/store/file-store.js +113 -0
- package/dist/events/store/index.d.ts +7 -0
- package/dist/events/store/index.js +6 -0
- package/dist/events/store/memory-store.d.ts +26 -0
- package/dist/events/store/memory-store.js +39 -0
- package/dist/events/store.d.ts +11 -0
- package/dist/events/store.js +2 -0
- package/dist/events/types.d.ts +14 -0
- package/dist/events/types.js +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +30 -0
- package/dist/presentation/analysis-ui.d.ts +24 -0
- package/dist/presentation/analysis-ui.js +158 -0
- package/dist/presentation/dev/chat-ui-types.d.ts +68 -0
- package/dist/presentation/dev/chat-ui-types.js +5 -0
- package/dist/presentation/dev/chat-ui.d.ts +61 -0
- package/dist/presentation/dev/chat-ui.js +714 -0
- package/dist/presentation/dev/components/assistant-message.d.ts +19 -0
- package/dist/presentation/dev/components/assistant-message.js +36 -0
- package/dist/presentation/dev/components/header.d.ts +16 -0
- package/dist/presentation/dev/components/header.js +22 -0
- package/dist/presentation/dev/components/index.d.ts +13 -0
- package/dist/presentation/dev/components/index.js +13 -0
- package/dist/presentation/dev/components/input-panel.d.ts +22 -0
- package/dist/presentation/dev/components/input-panel.js +43 -0
- package/dist/presentation/dev/components/message-component.d.ts +16 -0
- package/dist/presentation/dev/components/message-component.js +51 -0
- package/dist/presentation/dev/components/messages-list.d.ts +24 -0
- package/dist/presentation/dev/components/messages-list.js +48 -0
- package/dist/presentation/dev/components/system-message.d.ts +16 -0
- package/dist/presentation/dev/components/system-message.js +26 -0
- package/dist/presentation/dev/components/user-message.d.ts +21 -0
- package/dist/presentation/dev/components/user-message.js +35 -0
- package/dist/presentation/dev/components/welcome-banner.d.ts +24 -0
- package/dist/presentation/dev/components/welcome-banner.js +146 -0
- package/dist/presentation/dev/goodbye-messages.d.ts +31 -0
- package/dist/presentation/dev/goodbye-messages.js +100 -0
- package/dist/presentation/dev/index.d.ts +5 -0
- package/dist/presentation/dev/index.js +5 -0
- package/dist/presentation/dev/text-wrapper.d.ts +30 -0
- package/dist/presentation/dev/text-wrapper.js +74 -0
- package/dist/presentation/dev-ui.d.ts +33 -0
- package/dist/presentation/dev-ui.js +246 -0
- package/dist/presentation/doctor-ui.d.ts +40 -0
- package/dist/presentation/doctor-ui.js +157 -0
- package/dist/presentation/init-ui.d.ts +14 -0
- package/dist/presentation/init-ui.js +41 -0
- package/dist/presentation/list-ui.d.ts +44 -0
- package/dist/presentation/list-ui.js +139 -0
- package/dist/presentation/test-ui.d.ts +49 -0
- package/dist/presentation/test-ui.js +358 -0
- package/dist/runtime/analysis/analyser.d.ts +14 -0
- package/dist/runtime/analysis/analyser.js +88 -0
- package/dist/runtime/analysis/dependencies.d.ts +10 -0
- package/dist/runtime/analysis/dependencies.js +140 -0
- package/dist/runtime/analysis/index.d.ts +10 -0
- package/dist/runtime/analysis/index.js +10 -0
- package/dist/runtime/analysis/indexer.d.ts +10 -0
- package/dist/runtime/analysis/indexer.js +62 -0
- package/dist/runtime/analysis/loader.d.ts +15 -0
- package/dist/runtime/analysis/loader.js +47 -0
- package/dist/runtime/analysis/normalizer.d.ts +14 -0
- package/dist/runtime/analysis/normalizer.js +184 -0
- package/dist/runtime/analysis/rules/__test-helpers__.d.ts +18 -0
- package/dist/runtime/analysis/rules/__test-helpers__.js +40 -0
- package/dist/runtime/analysis/rules/base.d.ts +38 -0
- package/dist/runtime/analysis/rules/base.js +23 -0
- package/dist/runtime/analysis/rules/error-codes.d.ts +64 -0
- package/dist/runtime/analysis/rules/error-codes.js +73 -0
- package/dist/runtime/analysis/rules/errors/e000-tool-not-found.d.ts +35 -0
- package/dist/runtime/analysis/rules/errors/e000-tool-not-found.js +32 -0
- package/dist/runtime/analysis/rules/errors/e001-missing-output-schema.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e001-missing-output-schema.js +30 -0
- package/dist/runtime/analysis/rules/errors/e002-underspecified-input.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e002-underspecified-input.js +52 -0
- package/dist/runtime/analysis/rules/errors/e003-type-mismatch.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e003-type-mismatch.js +73 -0
- package/dist/runtime/analysis/rules/errors/e004-free-text-propagation.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e004-free-text-propagation.js +47 -0
- package/dist/runtime/analysis/rules/errors/e005-tool-ambiguity.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e005-tool-ambiguity.js +73 -0
- package/dist/runtime/analysis/rules/errors/e006-param-not-in-description.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e006-param-not-in-description.js +57 -0
- package/dist/runtime/analysis/rules/errors/e007-output-not-guaranteed.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e007-output-not-guaranteed.js +56 -0
- package/dist/runtime/analysis/rules/errors/e008-circular-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e008-circular-dependency.js +84 -0
- package/dist/runtime/analysis/rules/errors/e009-implicit-user-input.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e009-implicit-user-input.js +89 -0
- package/dist/runtime/analysis/rules/errors/e010-non-serializable.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e010-non-serializable.js +46 -0
- package/dist/runtime/analysis/rules/errors/e011-missing-tool-description.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e011-missing-tool-description.js +33 -0
- package/dist/runtime/analysis/rules/errors/e012-side-effect-detected.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e012-side-effect-detected.js +40 -0
- package/dist/runtime/analysis/rules/errors/e013-non-deterministic-output.d.ts +37 -0
- package/dist/runtime/analysis/rules/errors/e013-non-deterministic-output.js +34 -0
- package/dist/runtime/analysis/rules/errors/e013-output-explosion.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e013-output-explosion.js +36 -0
- package/dist/runtime/analysis/rules/errors/e014-hidden-dependency.d.ts +42 -0
- package/dist/runtime/analysis/rules/errors/e014-hidden-dependency.js +46 -0
- package/dist/runtime/analysis/rules/errors/e014-output-explosion.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e014-output-explosion.js +36 -0
- package/dist/runtime/analysis/rules/errors/e015-hidden-dependency.d.ts +42 -0
- package/dist/runtime/analysis/rules/errors/e015-hidden-dependency.js +46 -0
- package/dist/runtime/analysis/rules/errors/e015-unbounded-execution.d.ts +44 -0
- package/dist/runtime/analysis/rules/errors/e015-unbounded-execution.js +66 -0
- package/dist/runtime/analysis/rules/errors/e016-output-validation-failed.d.ts +43 -0
- package/dist/runtime/analysis/rules/errors/e016-output-validation-failed.js +42 -0
- package/dist/runtime/analysis/rules/errors/e016-unbounded-execution.d.ts +44 -0
- package/dist/runtime/analysis/rules/errors/e016-unbounded-execution.js +66 -0
- package/dist/runtime/analysis/rules/errors/e017-input-validation-failed.d.ts +57 -0
- package/dist/runtime/analysis/rules/errors/e017-input-validation-failed.js +80 -0
- package/dist/runtime/analysis/rules/errors/e017-output-validation-failed.d.ts +43 -0
- package/dist/runtime/analysis/rules/errors/e017-output-validation-failed.js +42 -0
- package/dist/runtime/analysis/rules/errors/e018-input-validation-failed.d.ts +57 -0
- package/dist/runtime/analysis/rules/errors/e018-input-validation-failed.js +80 -0
- package/dist/runtime/analysis/rules/errors/e018-tool-execution-failed.d.ts +38 -0
- package/dist/runtime/analysis/rules/errors/e018-tool-execution-failed.js +37 -0
- package/dist/runtime/analysis/rules/errors/e019-tool-execution-failed.d.ts +38 -0
- package/dist/runtime/analysis/rules/errors/e019-tool-execution-failed.js +37 -0
- package/dist/runtime/analysis/rules/errors/e019-unexpected-test-result.d.ts +65 -0
- package/dist/runtime/analysis/rules/errors/e019-unexpected-test-result.js +109 -0
- package/dist/runtime/analysis/rules/errors/e020-unexpected-test-result.d.ts +65 -0
- package/dist/runtime/analysis/rules/errors/e020-unexpected-test-result.js +109 -0
- package/dist/runtime/analysis/rules/errors/e100-missing-output-schema.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e100-missing-output-schema.js +30 -0
- package/dist/runtime/analysis/rules/errors/e101-missing-tool-description.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e101-missing-tool-description.js +33 -0
- package/dist/runtime/analysis/rules/errors/e102-underspecified-input.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e102-underspecified-input.js +52 -0
- package/dist/runtime/analysis/rules/errors/e103-type-mismatch.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e103-type-mismatch.js +72 -0
- package/dist/runtime/analysis/rules/errors/e104-param-not-in-description.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e104-param-not-in-description.js +57 -0
- package/dist/runtime/analysis/rules/errors/e105-free-text-propagation.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e105-free-text-propagation.js +47 -0
- package/dist/runtime/analysis/rules/errors/e106-output-not-guaranteed.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e106-output-not-guaranteed.js +58 -0
- package/dist/runtime/analysis/rules/errors/e107-circular-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e107-circular-dependency.js +84 -0
- package/dist/runtime/analysis/rules/errors/e108-implicit-user-input.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e108-implicit-user-input.js +94 -0
- package/dist/runtime/analysis/rules/errors/e109-non-serializable.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e109-non-serializable.js +44 -0
- package/dist/runtime/analysis/rules/errors/e110-tool-ambiguity.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e110-tool-ambiguity.js +73 -0
- package/dist/runtime/analysis/rules/errors/e200-input-validation-failed.d.ts +57 -0
- package/dist/runtime/analysis/rules/errors/e200-input-validation-failed.js +71 -0
- package/dist/runtime/analysis/rules/errors/e300-output-validation-failed.d.ts +43 -0
- package/dist/runtime/analysis/rules/errors/e300-output-validation-failed.js +44 -0
- package/dist/runtime/analysis/rules/errors/e301-output-explosion.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e301-output-explosion.js +36 -0
- package/dist/runtime/analysis/rules/errors/e400-tool-execution-failed.d.ts +38 -0
- package/dist/runtime/analysis/rules/errors/e400-tool-execution-failed.js +37 -0
- package/dist/runtime/analysis/rules/errors/e403-unbounded-execution.d.ts +44 -0
- package/dist/runtime/analysis/rules/errors/e403-unbounded-execution.js +66 -0
- package/dist/runtime/analysis/rules/errors/e500-side-effect-detected.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e500-side-effect-detected.js +40 -0
- package/dist/runtime/analysis/rules/errors/e501-hidden-dependency.d.ts +47 -0
- package/dist/runtime/analysis/rules/errors/e501-hidden-dependency.js +46 -0
- package/dist/runtime/analysis/rules/errors/e600-unexpected-test-result.d.ts +65 -0
- package/dist/runtime/analysis/rules/errors/e600-unexpected-test-result.js +109 -0
- package/dist/runtime/analysis/rules/index.d.ts +18 -0
- package/dist/runtime/analysis/rules/index.js +94 -0
- package/dist/runtime/analysis/rules/warnings/w001-implicit-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w001-implicit-dependency.js +39 -0
- package/dist/runtime/analysis/rules/warnings/w002-free-text-without-normalization.d.ts +24 -0
- package/dist/runtime/analysis/rules/warnings/w002-free-text-without-normalization.js +40 -0
- package/dist/runtime/analysis/rules/warnings/w003-missing-examples.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w003-missing-examples.js +84 -0
- package/dist/runtime/analysis/rules/warnings/w004-overloaded-responsibility.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w004-overloaded-responsibility.js +96 -0
- package/dist/runtime/analysis/rules/warnings/w005-generic-description.d.ts +53 -0
- package/dist/runtime/analysis/rules/warnings/w005-generic-description.js +108 -0
- package/dist/runtime/analysis/rules/warnings/w006-optional-as-required.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w006-optional-as-required.js +44 -0
- package/dist/runtime/analysis/rules/warnings/w007-broad-output-schema.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w007-broad-output-schema.js +37 -0
- package/dist/runtime/analysis/rules/warnings/w008-multiple-entry-points.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w008-multiple-entry-points.js +97 -0
- package/dist/runtime/analysis/rules/warnings/w009-hidden-side-effects.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w009-hidden-side-effects.js +88 -0
- package/dist/runtime/analysis/rules/warnings/w010-output-not-reusable.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w010-output-not-reusable.js +81 -0
- package/dist/runtime/analysis/rules/warnings/w021-weak-schema.d.ts +40 -0
- package/dist/runtime/analysis/rules/warnings/w021-weak-schema.js +32 -0
- package/dist/runtime/analysis/rules/warnings/w022-high-entropy-output.d.ts +39 -0
- package/dist/runtime/analysis/rules/warnings/w022-high-entropy-output.js +36 -0
- package/dist/runtime/analysis/rules/warnings/w023-unstable-defaults.d.ts +38 -0
- package/dist/runtime/analysis/rules/warnings/w023-unstable-defaults.js +36 -0
- package/dist/runtime/analysis/rules/warnings/w100-implicit-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w100-implicit-dependency.js +89 -0
- package/dist/runtime/analysis/rules/warnings/w101-free-text-without-normalization.d.ts +24 -0
- package/dist/runtime/analysis/rules/warnings/w101-free-text-without-normalization.js +40 -0
- package/dist/runtime/analysis/rules/warnings/w102-missing-examples.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w102-missing-examples.js +76 -0
- package/dist/runtime/analysis/rules/warnings/w103-overloaded-responsibility.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w103-overloaded-responsibility.js +91 -0
- package/dist/runtime/analysis/rules/warnings/w104-generic-description.d.ts +53 -0
- package/dist/runtime/analysis/rules/warnings/w104-generic-description.js +108 -0
- package/dist/runtime/analysis/rules/warnings/w105-optional-as-required.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w105-optional-as-required.js +45 -0
- package/dist/runtime/analysis/rules/warnings/w106-broad-output-schema.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w106-broad-output-schema.js +37 -0
- package/dist/runtime/analysis/rules/warnings/w107-multiple-entry-points.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w107-multiple-entry-points.js +97 -0
- package/dist/runtime/analysis/rules/warnings/w108-hidden-side-effects.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w108-hidden-side-effects.js +94 -0
- package/dist/runtime/analysis/rules/warnings/w109-output-not-reusable.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w109-output-not-reusable.js +63 -0
- package/dist/runtime/analysis/rules/warnings/w110-weak-schema.d.ts +40 -0
- package/dist/runtime/analysis/rules/warnings/w110-weak-schema.js +32 -0
- package/dist/runtime/analysis/rules/warnings/w300-high-entropy-output.d.ts +39 -0
- package/dist/runtime/analysis/rules/warnings/w300-high-entropy-output.js +47 -0
- package/dist/runtime/analysis/rules/warnings/w301-unstable-defaults.d.ts +38 -0
- package/dist/runtime/analysis/rules/warnings/w301-unstable-defaults.js +36 -0
- package/dist/runtime/analysis/strict-mode.d.ts +21 -0
- package/dist/runtime/analysis/strict-mode.js +44 -0
- package/dist/runtime/analysis/types.d.ts +133 -0
- package/dist/runtime/analysis/types.js +6 -0
- package/dist/runtime/analysis/utils.d.ts +19 -0
- package/dist/runtime/analysis/utils.js +21 -0
- package/dist/runtime/dev/data-manager.d.ts +55 -0
- package/dist/runtime/dev/data-manager.js +87 -0
- package/dist/runtime/dev/event-mapper.d.ts +100 -0
- package/dist/runtime/dev/event-mapper.js +400 -0
- package/dist/runtime/dev/formatter.d.ts +94 -0
- package/dist/runtime/dev/formatter.js +236 -0
- package/dist/runtime/dev/index.d.ts +9 -0
- package/dist/runtime/dev/index.js +9 -0
- package/dist/runtime/dev/repl.d.ts +114 -0
- package/dist/runtime/dev/repl.js +310 -0
- package/dist/runtime/dev/session.d.ts +86 -0
- package/dist/runtime/dev/session.js +447 -0
- package/dist/runtime/dev/stack-trace.d.ts +77 -0
- package/dist/runtime/dev/stack-trace.js +286 -0
- package/dist/runtime/dev/types.d.ts +54 -0
- package/dist/runtime/dev/types.js +5 -0
- package/dist/runtime/llm/claude.d.ts +27 -0
- package/dist/runtime/llm/claude.js +150 -0
- package/dist/runtime/llm/factory.d.ts +30 -0
- package/dist/runtime/llm/factory.js +78 -0
- package/dist/runtime/llm/index.d.ts +10 -0
- package/dist/runtime/llm/index.js +10 -0
- package/dist/runtime/llm/ollama.d.ts +45 -0
- package/dist/runtime/llm/ollama.js +449 -0
- package/dist/runtime/llm/openai.d.ts +27 -0
- package/dist/runtime/llm/openai.js +170 -0
- package/dist/runtime/llm/provider.d.ts +32 -0
- package/dist/runtime/llm/provider.js +6 -0
- package/dist/runtime/llm/types.d.ts +55 -0
- package/dist/runtime/llm/types.js +6 -0
- package/dist/runtime/mcp/client/base.d.ts +40 -0
- package/dist/runtime/mcp/client/base.js +157 -0
- package/dist/runtime/mcp/client/manager.d.ts +91 -0
- package/dist/runtime/mcp/client/manager.js +248 -0
- package/dist/runtime/mcp/client/process.d.ts +31 -0
- package/dist/runtime/mcp/client/process.js +82 -0
- package/dist/runtime/mcp/connection.d.ts +63 -0
- package/dist/runtime/mcp/connection.js +449 -0
- package/dist/runtime/mcp/index.d.ts +9 -0
- package/dist/runtime/mcp/index.js +9 -0
- package/dist/runtime/mcp/list.d.ts +50 -0
- package/dist/runtime/mcp/list.js +65 -0
- package/dist/runtime/mcp/stdio-transport.d.ts +23 -0
- package/dist/runtime/mcp/stdio-transport.js +71 -0
- package/dist/runtime/mcp/types.d.ts +85 -0
- package/dist/runtime/mcp/types.js +6 -0
- package/dist/runtime/sandbox/executor.d.ts +102 -0
- package/dist/runtime/sandbox/executor.js +537 -0
- package/dist/runtime/sandbox/index.d.ts +9 -0
- package/dist/runtime/sandbox/index.js +9 -0
- package/dist/runtime/sandbox/io-monitor.d.ts +78 -0
- package/dist/runtime/sandbox/io-monitor.js +98 -0
- package/dist/runtime/sandbox/time-parser.d.ts +19 -0
- package/dist/runtime/sandbox/time-parser.js +67 -0
- package/dist/runtime/sandbox/types.d.ts +58 -0
- package/dist/runtime/sandbox/types.js +23 -0
- package/dist/runtime/test/behavior-observer.d.ts +61 -0
- package/dist/runtime/test/behavior-observer.js +140 -0
- package/dist/runtime/test/contract-loader.d.ts +41 -0
- package/dist/runtime/test/contract-loader.js +158 -0
- package/dist/runtime/test/contract-schema.d.ts +46 -0
- package/dist/runtime/test/contract-schema.js +107 -0
- package/dist/runtime/test/contract-types.d.ts +106 -0
- package/dist/runtime/test/contract-types.js +6 -0
- package/dist/runtime/test/dependency-tracker.d.ts +66 -0
- package/dist/runtime/test/dependency-tracker.js +80 -0
- package/dist/runtime/test/formatters.d.ts +18 -0
- package/dist/runtime/test/formatters.js +172 -0
- package/dist/runtime/test/index.d.ts +12 -0
- package/dist/runtime/test/index.js +13 -0
- package/dist/runtime/test/input-generator.d.ts +33 -0
- package/dist/runtime/test/input-generator.js +498 -0
- package/dist/runtime/test/mcp-root-detector.d.ts +31 -0
- package/dist/runtime/test/mcp-root-detector.js +105 -0
- package/dist/runtime/test/orchestrator.d.ts +131 -0
- package/dist/runtime/test/orchestrator.js +738 -0
- package/dist/runtime/test/output-validator.d.ts +44 -0
- package/dist/runtime/test/output-validator.js +262 -0
- package/dist/runtime/test/retry-tester.d.ts +44 -0
- package/dist/runtime/test/retry-tester.js +103 -0
- package/dist/runtime/test/runner.d.ts +28 -0
- package/dist/runtime/test/runner.js +55 -0
- package/dist/runtime/test/synthetic-input-generator.d.ts +11 -0
- package/dist/runtime/test/synthetic-input-generator.js +154 -0
- package/dist/runtime/test/test-runner.d.ts +28 -0
- package/dist/runtime/test/test-runner.js +55 -0
- package/dist/types/factories.d.ts +16 -0
- package/dist/types/factories.js +43 -0
- package/dist/types/ids.d.ts +16 -0
- package/dist/types/ids.js +2 -0
- package/dist/types/opaque.d.ts +4 -0
- package/dist/types/opaque.js +2 -0
- package/dist/utils/errors.d.ts +92 -0
- package/dist/utils/errors.js +97 -0
- package/dist/utils/gitignore.d.ts +11 -0
- package/dist/utils/gitignore.js +59 -0
- package/dist/utils/json-file-saver.d.ts +17 -0
- package/dist/utils/json-file-saver.js +81 -0
- package/dist/utils/json-formatter.d.ts +63 -0
- package/dist/utils/json-formatter.js +344 -0
- package/dist/utils/logger.d.ts +184 -0
- package/dist/utils/logger.js +330 -0
- package/dist/utils/package-manager.d.ts +30 -0
- package/dist/utils/package-manager.js +157 -0
- package/dist/utils/version-checker.d.ts +47 -0
- package/dist/utils/version-checker.js +167 -0
- package/dist/utils/version-display.d.ts +10 -0
- package/dist/utils/version-display.js +20 -0
- package/package.json +106 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable checker.
|
|
3
|
+
* Validates that required environment variables are set.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import { Messages, Paths } from '../constants/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Parse .env file and return key-value pairs.
|
|
11
|
+
* @param envFilePath - Path to .env file
|
|
12
|
+
* @returns Map of environment variables
|
|
13
|
+
*/
|
|
14
|
+
function parseEnvFile(envFilePath) {
|
|
15
|
+
const envMap = new Map();
|
|
16
|
+
if (!fs.existsSync(envFilePath)) {
|
|
17
|
+
return envMap;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const content = fs.readFileSync(envFilePath, 'utf-8');
|
|
21
|
+
const lines = content.split('\n');
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
// Skip comments and empty lines
|
|
24
|
+
const trimmed = line.trim();
|
|
25
|
+
if (!trimmed || trimmed.startsWith('#')) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// Parse KEY=VALUE format
|
|
29
|
+
const match = trimmed.match(/^([^=:#]+)=(.*)$/);
|
|
30
|
+
if (match) {
|
|
31
|
+
const key = match[1]?.trim();
|
|
32
|
+
const value = match[2]?.trim() || '';
|
|
33
|
+
// Remove quotes if present
|
|
34
|
+
const unquotedValue = value.replace(/^["']|["']$/g, '');
|
|
35
|
+
if (key) {
|
|
36
|
+
envMap.set(key, unquotedValue);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// If we can't parse the file, return empty map
|
|
43
|
+
// The error will be handled elsewhere
|
|
44
|
+
}
|
|
45
|
+
return envMap;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if an environment variable is set.
|
|
49
|
+
* Checks both process.env and .env file, providing detailed error messages.
|
|
50
|
+
* @param varName - Name of the environment variable
|
|
51
|
+
* @param projectRoot - Root directory of the project
|
|
52
|
+
* @returns Check result with detailed error information
|
|
53
|
+
*/
|
|
54
|
+
export function checkEnvVar(varName, projectRoot = process.cwd()) {
|
|
55
|
+
const envFilePath = path.join(projectRoot, Paths.ENV_FILE);
|
|
56
|
+
const envFileExists = fs.existsSync(envFilePath);
|
|
57
|
+
// First check process.env (takes precedence)
|
|
58
|
+
const processEnvValue = process.env[varName];
|
|
59
|
+
if (processEnvValue !== undefined && processEnvValue !== '') {
|
|
60
|
+
return {
|
|
61
|
+
isSet: true,
|
|
62
|
+
value: processEnvValue,
|
|
63
|
+
envFileExists,
|
|
64
|
+
keyExistsInEnvFile: undefined, // Not checked since process.env has it
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// If not in process.env, check .env file
|
|
68
|
+
if (!envFileExists) {
|
|
69
|
+
return {
|
|
70
|
+
isSet: false,
|
|
71
|
+
envFileExists: false,
|
|
72
|
+
keyExistsInEnvFile: false,
|
|
73
|
+
errorMessage: Messages.ENV_FILE_NOT_PRESENT(varName),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Parse .env file
|
|
77
|
+
const envMap = parseEnvFile(envFilePath);
|
|
78
|
+
const keyExistsInEnvFile = envMap.has(varName);
|
|
79
|
+
const envFileValue = envMap.get(varName);
|
|
80
|
+
if (!keyExistsInEnvFile) {
|
|
81
|
+
return {
|
|
82
|
+
isSet: false,
|
|
83
|
+
envFileExists: true,
|
|
84
|
+
keyExistsInEnvFile: false,
|
|
85
|
+
errorMessage: Messages.ENV_KEY_NOT_FOUND(varName),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (envFileValue === '' || envFileValue === undefined) {
|
|
89
|
+
return {
|
|
90
|
+
isSet: false,
|
|
91
|
+
value: envFileValue,
|
|
92
|
+
envFileExists: true,
|
|
93
|
+
keyExistsInEnvFile: true,
|
|
94
|
+
errorMessage: Messages.ENV_KEY_EMPTY(varName),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Key exists and has a value
|
|
98
|
+
return {
|
|
99
|
+
isSet: true,
|
|
100
|
+
value: envFileValue,
|
|
101
|
+
envFileExists: true,
|
|
102
|
+
keyExistsInEnvFile: true,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Check if a command exists and is executable.
|
|
107
|
+
* @param command - Command to check (e.g., "python3", "node")
|
|
108
|
+
* @returns true if command exists
|
|
109
|
+
*/
|
|
110
|
+
export function checkCommandExists(command) {
|
|
111
|
+
try {
|
|
112
|
+
// Try to find the command using 'which' or 'where' depending on platform
|
|
113
|
+
if (process.platform === 'win32') {
|
|
114
|
+
execSync(`where ${command}`, { stdio: 'ignore' });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
execSync(`which ${command}`, { stdio: 'ignore' });
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract command name from a script string.
|
|
127
|
+
* @param script - Script command (e.g., "python3 server.py")
|
|
128
|
+
* @returns Command name (e.g., "python3")
|
|
129
|
+
*/
|
|
130
|
+
export function extractCommandName(script) {
|
|
131
|
+
// Remove quotes and split by space
|
|
132
|
+
const cleaned = script.replace(/['"]/g, '').trim();
|
|
133
|
+
const parts = cleaned.split(/\s+/);
|
|
134
|
+
return parts[0] || '';
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=env-checker.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file generator.
|
|
3
|
+
* Creates well-documented, production-ready syrin.yaml files from template.
|
|
4
|
+
*/
|
|
5
|
+
import type { InitOptions } from '../config/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a production-ready syrin.yaml file with comprehensive documentation.
|
|
8
|
+
* @param options - Initialization options
|
|
9
|
+
* @param projectRoot - Root directory where syrin.yaml will be created
|
|
10
|
+
* @returns Path to the created config file
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateConfigFile(options: InitOptions, projectRoot: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a Syrin project is already initialized in the current directory.
|
|
15
|
+
* @param projectRoot - Root directory of the project
|
|
16
|
+
* @returns true if project is already initialized
|
|
17
|
+
*/
|
|
18
|
+
export declare function isProjectInitialized(projectRoot: string): boolean;
|
|
19
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file generator.
|
|
3
|
+
* Creates well-documented, production-ready syrin.yaml files from template.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { makeSyrinVersion } from '../types/factories.js';
|
|
9
|
+
import { Paths } from '../constants/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get the path to the template file.
|
|
12
|
+
* The template is located in the same directory as this file.
|
|
13
|
+
*/
|
|
14
|
+
function getTemplatePath() {
|
|
15
|
+
// Get the directory of the current file using import.meta.url
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
return path.join(__dirname, 'syrin.template.yaml');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Read the template file.
|
|
22
|
+
*/
|
|
23
|
+
function readTemplate() {
|
|
24
|
+
const templatePath = getTemplatePath();
|
|
25
|
+
if (!fs.existsSync(templatePath)) {
|
|
26
|
+
throw new Error(`Template file not found: ${templatePath}. This is a build error.`);
|
|
27
|
+
}
|
|
28
|
+
return fs.readFileSync(templatePath, 'utf-8');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generate a production-ready syrin.yaml file with comprehensive documentation.
|
|
32
|
+
* @param options - Initialization options
|
|
33
|
+
* @param projectRoot - Root directory where syrin.yaml will be created
|
|
34
|
+
* @returns Path to the created config file
|
|
35
|
+
*/
|
|
36
|
+
export function generateConfigFile(options, projectRoot) {
|
|
37
|
+
const configPath = path.join(projectRoot, Paths.CONFIG_FILE);
|
|
38
|
+
const configContent = buildConfigContent(options);
|
|
39
|
+
fs.writeFileSync(configPath, configContent, 'utf-8');
|
|
40
|
+
return configPath;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build the YAML content for the config file from template.
|
|
44
|
+
*/
|
|
45
|
+
function buildConfigContent(options) {
|
|
46
|
+
const config = {
|
|
47
|
+
version: makeSyrinVersion('1.0.0'),
|
|
48
|
+
project_name: options.projectName,
|
|
49
|
+
agent_name: options.agentName,
|
|
50
|
+
transport: options.transport,
|
|
51
|
+
script: options.script,
|
|
52
|
+
llm: buildLLMConfig(options.llmProviders),
|
|
53
|
+
};
|
|
54
|
+
// Add transport-specific fields
|
|
55
|
+
if (options.transport === 'http' && options.mcpUrl) {
|
|
56
|
+
config.mcp_url = options.mcpUrl;
|
|
57
|
+
}
|
|
58
|
+
// Read template
|
|
59
|
+
let template = readTemplate();
|
|
60
|
+
// Replace simple placeholders
|
|
61
|
+
template = template.replace(/\{\{VERSION\}\}/g, String(config.version));
|
|
62
|
+
template = template.replace(/\{\{PROJECT_NAME\}\}/g, String(config.project_name));
|
|
63
|
+
template = template.replace(/\{\{AGENT_NAME\}\}/g, String(config.agent_name));
|
|
64
|
+
template = template.replace(/\{\{TRANSPORT\}\}/g, config.transport);
|
|
65
|
+
// Handle transport-specific blocks
|
|
66
|
+
if (config.transport === 'http' && config.mcp_url) {
|
|
67
|
+
template = template.replace(/\{\{#IF_HTTP\}\}([\s\S]*?)\{\{\/IF_HTTP\}\}/g, (match, content) => {
|
|
68
|
+
return content.replace(/\{\{MCP_URL\}\}/g, String(config.mcp_url));
|
|
69
|
+
});
|
|
70
|
+
template = template.replace(/\{\{#IF_STDIO\}\}([\s\S]*?)\{\{\/IF_STDIO\}\}/g, '');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
template = template.replace(/\{\{#IF_HTTP\}\}([\s\S]*?)\{\{\/IF_HTTP\}\}/g, '');
|
|
74
|
+
template = template.replace(/\{\{#IF_STDIO\}\}([\s\S]*?)\{\{\/IF_STDIO\}\}/g, (match, content) => content);
|
|
75
|
+
}
|
|
76
|
+
// Handle script blocks
|
|
77
|
+
if (config.script) {
|
|
78
|
+
template = template.replace(/\{\{#IF_SCRIPT\}\}([\s\S]*?)\{\{\/IF_SCRIPT\}\}/g, (match, content) => {
|
|
79
|
+
return content.replace(/\{\{SCRIPT\}\}/g, String(config.script));
|
|
80
|
+
});
|
|
81
|
+
template = template.replace(/\{\{#IF_NO_SCRIPT\}\}([\s\S]*?)\{\{\/IF_NO_SCRIPT\}\}/g, '');
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
template = template.replace(/\{\{#IF_SCRIPT\}\}([\s\S]*?)\{\{\/IF_SCRIPT\}\}/g, '');
|
|
85
|
+
template = template.replace(/\{\{#IF_NO_SCRIPT\}\}([\s\S]*?)\{\{\/IF_NO_SCRIPT\}\}/g, (match, content) => content);
|
|
86
|
+
}
|
|
87
|
+
// Handle LLM providers loop
|
|
88
|
+
const llmEntries = Object.entries(config.llm);
|
|
89
|
+
const hasOpenAI = llmEntries.some(([name]) => name === 'openai');
|
|
90
|
+
const hasClaude = llmEntries.some(([name]) => name === 'claude');
|
|
91
|
+
const hasOllama = llmEntries.some(([name]) => name === 'ollama');
|
|
92
|
+
// Extract the LLM provider template block
|
|
93
|
+
const llmTemplateMatch = template.match(/\{\{#LLM_PROVIDERS\}\}([\s\S]*?)\{\{\/LLM_PROVIDERS\}\}/);
|
|
94
|
+
if (!llmTemplateMatch) {
|
|
95
|
+
throw new Error('LLM_PROVIDERS template block not found');
|
|
96
|
+
}
|
|
97
|
+
const providerTemplate = llmTemplateMatch[1];
|
|
98
|
+
let llmSection = '';
|
|
99
|
+
for (const [providerName, providerConfig] of llmEntries) {
|
|
100
|
+
const isOllama = providerName === 'ollama';
|
|
101
|
+
const isDefault = providerConfig.default === true;
|
|
102
|
+
const providerNameUpper = providerName.toUpperCase();
|
|
103
|
+
// Start with a fresh copy of the template for each provider
|
|
104
|
+
let providerBlock = providerTemplate;
|
|
105
|
+
// Replace provider-specific placeholders
|
|
106
|
+
providerBlock = providerBlock.replace(/\{\{PROVIDER_NAME\}\}/g, providerName);
|
|
107
|
+
providerBlock = providerBlock.replace(/\{\{PROVIDER_NAME_UPPER\}\}/g, providerNameUpper);
|
|
108
|
+
// Handle Ollama vs Cloud provider blocks
|
|
109
|
+
if (isOllama) {
|
|
110
|
+
providerBlock = providerBlock.replace(/\{\{#IF_OLLAMA\}\}([\s\S]*?)\{\{\/IF_OLLAMA\}\}/g, (match, content) => {
|
|
111
|
+
return content.replace(/\{\{MODEL_NAME\}\}/g, String(providerConfig.MODEL_NAME || ''));
|
|
112
|
+
});
|
|
113
|
+
providerBlock = providerBlock.replace(/\{\{#IF_CLOUD_PROVIDER\}\}([\s\S]*?)\{\{\/IF_CLOUD_PROVIDER\}\}/g, '');
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
providerBlock = providerBlock.replace(/\{\{#IF_OLLAMA\}\}([\s\S]*?)\{\{\/IF_OLLAMA\}\}/g, '');
|
|
117
|
+
providerBlock = providerBlock.replace(/\{\{#IF_CLOUD_PROVIDER\}\}([\s\S]*?)\{\{\/IF_CLOUD_PROVIDER\}\}/g, (match, content) => {
|
|
118
|
+
return content
|
|
119
|
+
.replace(/\{\{API_KEY\}\}/g, String(providerConfig.API_KEY || ''))
|
|
120
|
+
.replace(/\{\{MODEL_NAME\}\}/g, String(providerConfig.MODEL_NAME || ''));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Handle default flag
|
|
124
|
+
if (isDefault) {
|
|
125
|
+
providerBlock = providerBlock.replace(/\{\{#IF_DEFAULT\}\}([\s\S]*?)\{\{\/IF_DEFAULT\}\}/g, (match, content) => content);
|
|
126
|
+
providerBlock = providerBlock.replace(/\{\{#IF_NOT_DEFAULT\}\}([\s\S]*?)\{\{\/IF_NOT_DEFAULT\}\}/g, '');
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
providerBlock = providerBlock.replace(/\{\{#IF_DEFAULT\}\}([\s\S]*?)\{\{\/IF_DEFAULT\}\}/g, '');
|
|
130
|
+
providerBlock = providerBlock.replace(/\{\{#IF_NOT_DEFAULT\}\}([\s\S]*?)\{\{\/IF_NOT_DEFAULT\}\}/g, (match, content) => content);
|
|
131
|
+
}
|
|
132
|
+
// Handle alternative provider suggestions (only show once per provider type)
|
|
133
|
+
if (providerName === 'openai' && !hasClaude) {
|
|
134
|
+
providerBlock = providerBlock.replace(/\{\{#IF_OPENAI_AND_NO_CLAUDE\}\}([\s\S]*?)\{\{\/IF_OPENAI_AND_NO_CLAUDE\}\}/g, (match, content) => content);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
providerBlock = providerBlock.replace(/\{\{#IF_OPENAI_AND_NO_CLAUDE\}\}([\s\S]*?)\{\{\/IF_OPENAI_AND_NO_CLAUDE\}\}/g, '');
|
|
138
|
+
}
|
|
139
|
+
if (providerName === 'claude' && !hasOpenAI) {
|
|
140
|
+
providerBlock = providerBlock.replace(/\{\{#IF_CLAUDE_AND_NO_OPENAI\}\}([\s\S]*?)\{\{\/IF_CLAUDE_AND_NO_OPENAI\}\}/g, (match, content) => content);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
providerBlock = providerBlock.replace(/\{\{#IF_CLAUDE_AND_NO_OPENAI\}\}([\s\S]*?)\{\{\/IF_CLAUDE_AND_NO_OPENAI\}\}/g, '');
|
|
144
|
+
}
|
|
145
|
+
// Only show Ollama suggestion if no Ollama provider exists
|
|
146
|
+
// But only add it once (on the last provider)
|
|
147
|
+
const isLastProvider = llmEntries[llmEntries.length - 1][0] === providerName;
|
|
148
|
+
if (isLastProvider && !hasOllama) {
|
|
149
|
+
providerBlock = providerBlock.replace(/\{\{#IF_NO_OLLAMA\}\}([\s\S]*?)\{\{\/IF_NO_OLLAMA\}\}/g, (match, content) => content);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
providerBlock = providerBlock.replace(/\{\{#IF_NO_OLLAMA\}\}([\s\S]*?)\{\{\/IF_NO_OLLAMA\}\}/g, '');
|
|
153
|
+
}
|
|
154
|
+
llmSection += providerBlock;
|
|
155
|
+
}
|
|
156
|
+
// Replace LLM providers section
|
|
157
|
+
template = template.replace(/\{\{#LLM_PROVIDERS\}\}([\s\S]*?)\{\{\/LLM_PROVIDERS\}\}/, llmSection);
|
|
158
|
+
return template;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Build LLM configuration object from init options.
|
|
162
|
+
*/
|
|
163
|
+
function buildLLMConfig(providers) {
|
|
164
|
+
const llmConfig = {};
|
|
165
|
+
if (providers.openai) {
|
|
166
|
+
llmConfig.openai = {
|
|
167
|
+
API_KEY: providers.openai.apiKey,
|
|
168
|
+
MODEL_NAME: providers.openai.modelName,
|
|
169
|
+
default: providers.openai.default ?? false,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (providers.claude) {
|
|
173
|
+
llmConfig.claude = {
|
|
174
|
+
API_KEY: providers.claude.apiKey,
|
|
175
|
+
MODEL_NAME: providers.claude.modelName,
|
|
176
|
+
default: providers.claude.default ?? false,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (providers.ollama) {
|
|
180
|
+
llmConfig.ollama = {
|
|
181
|
+
MODEL_NAME: providers.ollama.modelName,
|
|
182
|
+
default: providers.ollama.default ?? false,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return llmConfig;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Check if a Syrin project is already initialized in the current directory.
|
|
189
|
+
* @param projectRoot - Root directory of the project
|
|
190
|
+
* @returns true if project is already initialized
|
|
191
|
+
*/
|
|
192
|
+
export function isProjectInitialized(projectRoot) {
|
|
193
|
+
const configPath = path.join(projectRoot, Paths.CONFIG_FILE);
|
|
194
|
+
return fs.existsSync(configPath);
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file loader.
|
|
3
|
+
* Loads and parses the syrin.yaml file.
|
|
4
|
+
*/
|
|
5
|
+
import type { SyrinConfig } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Load configuration from syrin.yaml file.
|
|
8
|
+
* @param projectRoot - Root directory of the project (defaults to current working directory)
|
|
9
|
+
* @returns Loaded and validated configuration
|
|
10
|
+
* @throws {ConfigurationError} If config file is missing or invalid
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadConfig(projectRoot?: string): SyrinConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a configuration file exists.
|
|
15
|
+
* @param projectRoot - Root directory of the project
|
|
16
|
+
* @returns true if config file exists
|
|
17
|
+
*/
|
|
18
|
+
export declare function configExists(projectRoot?: string): boolean;
|
|
19
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file loader.
|
|
3
|
+
* Loads and parses the syrin.yaml file.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { load } from 'js-yaml';
|
|
8
|
+
import { validateConfig } from './schema.js';
|
|
9
|
+
import { ConfigurationError } from '../utils/errors.js';
|
|
10
|
+
import { Paths, Messages, ToolCommands } from '../constants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Load configuration from syrin.yaml file.
|
|
13
|
+
* @param projectRoot - Root directory of the project (defaults to current working directory)
|
|
14
|
+
* @returns Loaded and validated configuration
|
|
15
|
+
* @throws {ConfigurationError} If config file is missing or invalid
|
|
16
|
+
*/
|
|
17
|
+
export function loadConfig(projectRoot = process.cwd()) {
|
|
18
|
+
const configPath = path.join(projectRoot, Paths.CONFIG_FILE);
|
|
19
|
+
// Check if config file exists
|
|
20
|
+
if (!fs.existsSync(configPath)) {
|
|
21
|
+
throw new ConfigurationError(Messages.ERROR_CONFIG_NOT_FOUND(ToolCommands.INIT), {
|
|
22
|
+
context: { projectRoot, configPath },
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
// Read and parse YAML file
|
|
27
|
+
const configContent = fs.readFileSync(configPath, 'utf-8');
|
|
28
|
+
const configData = load(configContent);
|
|
29
|
+
if (!configData || typeof configData !== 'object') {
|
|
30
|
+
throw new ConfigurationError(Messages.ERROR_CONFIG_EMPTY_OR_INVALID, {
|
|
31
|
+
context: { configPath },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Validate and transform to opaque types
|
|
35
|
+
const validatedConfig = validateConfig(configData);
|
|
36
|
+
return validatedConfig;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error instanceof ConfigurationError) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
throw new ConfigurationError(`${Messages.ERROR_LOADING_CONFIG}: ${error instanceof Error ? error.message : String(error)}`, {
|
|
43
|
+
cause: error instanceof Error ? error : new Error(String(error)),
|
|
44
|
+
context: { configPath },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if a configuration file exists.
|
|
50
|
+
* @param projectRoot - Root directory of the project
|
|
51
|
+
* @returns true if config file exists
|
|
52
|
+
*/
|
|
53
|
+
export function configExists(projectRoot = process.cwd()) {
|
|
54
|
+
const configPath = path.join(projectRoot, Paths.CONFIG_FILE);
|
|
55
|
+
return fs.existsSync(configPath);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema validation using Zod.
|
|
3
|
+
* Provides runtime validation for the Syrin configuration file.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { SyrinConfig } from '../config/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Main configuration schema.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
11
|
+
version: z.ZodString;
|
|
12
|
+
project_name: z.ZodString;
|
|
13
|
+
agent_name: z.ZodString;
|
|
14
|
+
transport: z.ZodEnum<{
|
|
15
|
+
stdio: "stdio";
|
|
16
|
+
http: "http";
|
|
17
|
+
}>;
|
|
18
|
+
mcp_url: z.ZodOptional<z.ZodString>;
|
|
19
|
+
script: z.ZodOptional<z.ZodString>;
|
|
20
|
+
llm: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
21
|
+
API_KEY: z.ZodOptional<z.ZodString>;
|
|
22
|
+
MODEL_NAME: z.ZodOptional<z.ZodString>;
|
|
23
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
check: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
memory_limit_mb: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
tools_dir: z.ZodOptional<z.ZodString>;
|
|
29
|
+
max_output_size_kb: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
determinism_runs: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
test_retries: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
max_retries: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
retry_delay_ms: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
strict_mode: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
/**
|
|
38
|
+
* Type inference from schema.
|
|
39
|
+
*/
|
|
40
|
+
export type ConfigSchemaType = z.infer<typeof ConfigSchema>;
|
|
41
|
+
export declare function validateConfig(config: unknown): SyrinConfig;
|
|
42
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema validation using Zod.
|
|
3
|
+
* Provides runtime validation for the Syrin configuration file.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ConfigurationError } from '../utils/errors.js';
|
|
7
|
+
import { makeProjectName, makeAgentName, makeMCPURL, makeAPIKey, makeModelName, makeScriptCommand, makeSyrinVersion, } from '../types/factories.js';
|
|
8
|
+
/**
|
|
9
|
+
* Schema for LLM provider configuration.
|
|
10
|
+
*/
|
|
11
|
+
const LLMProviderSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
API_KEY: z.string().optional(),
|
|
14
|
+
MODEL_NAME: z.string().optional(),
|
|
15
|
+
default: z.boolean().optional(),
|
|
16
|
+
})
|
|
17
|
+
.refine(data => {
|
|
18
|
+
// For cloud providers (have API_KEY), both API_KEY and MODEL_NAME are required
|
|
19
|
+
if (data.API_KEY) {
|
|
20
|
+
if (!data.MODEL_NAME) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// For Ollama (no API_KEY), MODEL_NAME is required
|
|
26
|
+
if (!data.API_KEY && !data.MODEL_NAME) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}, {
|
|
31
|
+
message: 'For cloud providers (OpenAI, Claude), API_KEY and MODEL_NAME are required. For Ollama, MODEL_NAME is required.',
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Schema for check configuration (v1.3.0).
|
|
35
|
+
*/
|
|
36
|
+
const CheckConfigSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
timeout_ms: z.number().int().positive().optional(),
|
|
39
|
+
memory_limit_mb: z.number().int().positive().optional(),
|
|
40
|
+
tools_dir: z.string().min(1).optional(),
|
|
41
|
+
max_output_size_kb: z.number().int().positive().optional(),
|
|
42
|
+
determinism_runs: z.number().int().positive().min(2).optional(),
|
|
43
|
+
test_retries: z.boolean().optional(),
|
|
44
|
+
max_retries: z.number().int().min(1).max(10).optional(),
|
|
45
|
+
retry_delay_ms: z.number().int().nonnegative().optional(),
|
|
46
|
+
strict_mode: z.boolean().optional(),
|
|
47
|
+
})
|
|
48
|
+
.optional();
|
|
49
|
+
/**
|
|
50
|
+
* Main configuration schema.
|
|
51
|
+
*/
|
|
52
|
+
export const ConfigSchema = z
|
|
53
|
+
.object({
|
|
54
|
+
version: z.string().min(1, 'Version is required'),
|
|
55
|
+
project_name: z.string().min(1, 'Project name is required'),
|
|
56
|
+
agent_name: z.string().min(1, 'Agent name is required'),
|
|
57
|
+
transport: z.enum(['stdio', 'http']),
|
|
58
|
+
mcp_url: z.string().url().optional(),
|
|
59
|
+
script: z.string().optional(),
|
|
60
|
+
llm: z
|
|
61
|
+
.record(z.string(), LLMProviderSchema)
|
|
62
|
+
.refine(obj => Object.keys(obj).length > 0, {
|
|
63
|
+
message: 'At least one LLM provider is required',
|
|
64
|
+
}),
|
|
65
|
+
check: CheckConfigSchema,
|
|
66
|
+
})
|
|
67
|
+
.refine(data => {
|
|
68
|
+
// If transport is http, mcp_url must be provided
|
|
69
|
+
if (data.transport === 'http' && !data.mcp_url) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}, {
|
|
74
|
+
message: 'mcp_url is required when transport is "http"',
|
|
75
|
+
path: ['mcp_url'],
|
|
76
|
+
})
|
|
77
|
+
.refine(data => {
|
|
78
|
+
// If transport is stdio, script must be provided
|
|
79
|
+
if (data.transport === 'stdio') {
|
|
80
|
+
if (!data.script) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}, {
|
|
86
|
+
message: 'script is required when transport is "stdio"',
|
|
87
|
+
path: ['script'],
|
|
88
|
+
})
|
|
89
|
+
.refine(data => {
|
|
90
|
+
// At least one LLM provider should be set as default
|
|
91
|
+
const providers = Object.values(data.llm);
|
|
92
|
+
const hasDefault = providers.some(provider => {
|
|
93
|
+
return (provider && typeof provider === 'object' && provider.default === true);
|
|
94
|
+
});
|
|
95
|
+
return hasDefault;
|
|
96
|
+
}, {
|
|
97
|
+
message: 'At least one LLM provider must be set as default',
|
|
98
|
+
path: ['llm'],
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Validate a configuration object against the schema.
|
|
102
|
+
* @param config - Configuration object to validate
|
|
103
|
+
* @returns Validated configuration with opaque types
|
|
104
|
+
* @throws {ConfigurationError} If validation fails
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* Format Zod validation errors into user-friendly messages.
|
|
108
|
+
*/
|
|
109
|
+
function formatValidationError(error) {
|
|
110
|
+
const issues = error.issues;
|
|
111
|
+
if (issues.length === 0) {
|
|
112
|
+
return 'Configuration validation failed';
|
|
113
|
+
}
|
|
114
|
+
const messages = [];
|
|
115
|
+
for (const issue of issues) {
|
|
116
|
+
const path = issue.path.length > 0 ? issue.path.join('.') : 'configuration';
|
|
117
|
+
let message = `\n • ${path}: ${issue.message}`;
|
|
118
|
+
// Add helpful hints for common errors
|
|
119
|
+
if (issue.code === 'invalid_type') {
|
|
120
|
+
// Type guard for invalid_type issues
|
|
121
|
+
const invalidTypeIssue = issue;
|
|
122
|
+
if (invalidTypeIssue.received === 'undefined') {
|
|
123
|
+
message += `\n → Fix: Add "${path}" to your config.yaml file`;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
message += `\n → Expected: ${invalidTypeIssue.expected}, but received: ${invalidTypeIssue.received}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (issue.code === 'too_small') {
|
|
130
|
+
// Type guard for too_small issues
|
|
131
|
+
const tooSmallIssue = issue;
|
|
132
|
+
if (tooSmallIssue.type === 'string') {
|
|
133
|
+
message += `\n → Fix: "${path}" cannot be empty`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Check for URL validation errors in the message
|
|
137
|
+
if (issue.message.toLowerCase().includes('url') ||
|
|
138
|
+
issue.message.toLowerCase().includes('invalid url')) {
|
|
139
|
+
message += `\n → Fix: Provide a valid URL for "${path}"`;
|
|
140
|
+
}
|
|
141
|
+
messages.push(message);
|
|
142
|
+
}
|
|
143
|
+
return `Configuration validation failed:${messages.join('')}\n\n💡 Tip: Run \`syrin doctor\` after fixing your config.yaml to verify the setup.`;
|
|
144
|
+
}
|
|
145
|
+
export function validateConfig(config) {
|
|
146
|
+
try {
|
|
147
|
+
const parsed = ConfigSchema.parse(config);
|
|
148
|
+
// Transform to opaque types
|
|
149
|
+
const validated = {
|
|
150
|
+
version: makeSyrinVersion(parsed.version),
|
|
151
|
+
project_name: makeProjectName(parsed.project_name),
|
|
152
|
+
agent_name: makeAgentName(parsed.agent_name),
|
|
153
|
+
transport: parsed.transport,
|
|
154
|
+
mcp_url: parsed.mcp_url ? makeMCPURL(parsed.mcp_url) : undefined,
|
|
155
|
+
script: parsed.script ? makeScriptCommand(parsed.script) : undefined,
|
|
156
|
+
llm: Object.fromEntries(Object.entries(parsed.llm).map(([key, provider]) => [
|
|
157
|
+
key,
|
|
158
|
+
{
|
|
159
|
+
API_KEY: provider.API_KEY
|
|
160
|
+
? makeAPIKey(provider.API_KEY)
|
|
161
|
+
: undefined,
|
|
162
|
+
MODEL_NAME: provider.MODEL_NAME
|
|
163
|
+
? makeModelName(provider.MODEL_NAME)
|
|
164
|
+
: undefined,
|
|
165
|
+
default: provider.default,
|
|
166
|
+
},
|
|
167
|
+
])),
|
|
168
|
+
check: parsed.check,
|
|
169
|
+
};
|
|
170
|
+
return validated;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if (error instanceof z.ZodError) {
|
|
174
|
+
throw new ConfigurationError(formatValidationError(error), {
|
|
175
|
+
context: { errors: error.issues },
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=schema.js.map
|