@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,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack trace generation from events.
|
|
3
|
+
* Generates human-readable stack traces from event sequences to aid debugging.
|
|
4
|
+
*/
|
|
5
|
+
import { ToolExecutionEventType, TransportEventType, ValidationEventType, LLMProposalEventType, DiagnosticEventType, SessionLifecycleEventType, } from '../../events/event-type.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a human-readable description for an event.
|
|
8
|
+
*/
|
|
9
|
+
function describeEvent(event) {
|
|
10
|
+
const { event_type, payload } = event;
|
|
11
|
+
switch (event_type) {
|
|
12
|
+
case SessionLifecycleEventType.SESSION_STARTED:
|
|
13
|
+
return 'Session started';
|
|
14
|
+
case SessionLifecycleEventType.SESSION_COMPLETED:
|
|
15
|
+
return 'Session completed successfully';
|
|
16
|
+
case SessionLifecycleEventType.SESSION_HALTED:
|
|
17
|
+
return 'Session halted';
|
|
18
|
+
case LLMProposalEventType.LLM_PROPOSED_TOOL_CALL: {
|
|
19
|
+
const p = payload;
|
|
20
|
+
const toolName = p.tool_name || 'unknown';
|
|
21
|
+
return `LLM proposed tool call: ${toolName}`;
|
|
22
|
+
}
|
|
23
|
+
case LLMProposalEventType.LLM_FINAL_RESPONSE_GENERATED:
|
|
24
|
+
return 'LLM generated final response';
|
|
25
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_STARTED: {
|
|
26
|
+
const p = payload;
|
|
27
|
+
const toolName = p.tool_name || 'unknown';
|
|
28
|
+
return `Validating tool call: ${toolName}`;
|
|
29
|
+
}
|
|
30
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_PASSED: {
|
|
31
|
+
const p = payload;
|
|
32
|
+
const toolName = p.tool_name || 'unknown';
|
|
33
|
+
return `Tool call validation passed: ${toolName}`;
|
|
34
|
+
}
|
|
35
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_FAILED: {
|
|
36
|
+
const p = payload;
|
|
37
|
+
const toolName = p.tool_name || 'unknown';
|
|
38
|
+
const errorMsg = p.error?.message || 'Unknown validation error';
|
|
39
|
+
return `Tool call validation failed: ${toolName} - ${errorMsg}`;
|
|
40
|
+
}
|
|
41
|
+
case ToolExecutionEventType.TOOL_EXECUTION_STARTED: {
|
|
42
|
+
const p = payload;
|
|
43
|
+
const toolName = p.tool_name || 'unknown';
|
|
44
|
+
return `Tool execution started: ${toolName}`;
|
|
45
|
+
}
|
|
46
|
+
case ToolExecutionEventType.TOOL_EXECUTION_COMPLETED: {
|
|
47
|
+
const p = payload;
|
|
48
|
+
const toolName = p.tool_name || 'unknown';
|
|
49
|
+
const duration = p.duration_ms ? `${p.duration_ms}ms` : 'unknown';
|
|
50
|
+
return `Tool execution completed: ${toolName} (${duration})`;
|
|
51
|
+
}
|
|
52
|
+
case ToolExecutionEventType.TOOL_EXECUTION_FAILED: {
|
|
53
|
+
const p = payload;
|
|
54
|
+
const toolName = p.tool_name || 'unknown';
|
|
55
|
+
const errorMsg = p.error?.message || 'Unknown error';
|
|
56
|
+
return `Tool execution failed: ${toolName} - ${errorMsg}`;
|
|
57
|
+
}
|
|
58
|
+
case TransportEventType.TRANSPORT_INITIALIZED: {
|
|
59
|
+
const p = payload;
|
|
60
|
+
const transport = p.transport_type || 'unknown';
|
|
61
|
+
const endpoint = p.endpoint || p.command || 'unknown';
|
|
62
|
+
return `Transport initialized: ${transport} (${endpoint})`;
|
|
63
|
+
}
|
|
64
|
+
case TransportEventType.TRANSPORT_MESSAGE_SENT: {
|
|
65
|
+
const p = payload;
|
|
66
|
+
const msgType = p.message_type || 'unknown';
|
|
67
|
+
const size = p.size_bytes ? `${p.size_bytes} bytes` : 'unknown size';
|
|
68
|
+
return `Transport message sent: ${msgType} (${size})`;
|
|
69
|
+
}
|
|
70
|
+
case TransportEventType.TRANSPORT_MESSAGE_RECEIVED: {
|
|
71
|
+
const p = payload;
|
|
72
|
+
const msgType = p.message_type || 'unknown';
|
|
73
|
+
const size = p.size_bytes ? `${p.size_bytes} bytes` : 'unknown size';
|
|
74
|
+
return `Transport message received: ${msgType} (${size})`;
|
|
75
|
+
}
|
|
76
|
+
case TransportEventType.TRANSPORT_ERROR: {
|
|
77
|
+
const p = payload;
|
|
78
|
+
const errorMsg = p.error_message || 'Unknown transport error';
|
|
79
|
+
return `Transport error: ${errorMsg}`;
|
|
80
|
+
}
|
|
81
|
+
case DiagnosticEventType.RUNTIME_ERROR: {
|
|
82
|
+
const p = payload;
|
|
83
|
+
const errorMsg = p.error_message || 'Unknown runtime error';
|
|
84
|
+
return `Runtime error: ${errorMsg}`;
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return `${event_type}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extract context from an event payload.
|
|
92
|
+
*/
|
|
93
|
+
function extractContext(event) {
|
|
94
|
+
const { event_type, payload } = event;
|
|
95
|
+
const context = {};
|
|
96
|
+
switch (event_type) {
|
|
97
|
+
case ToolExecutionEventType.TOOL_EXECUTION_STARTED:
|
|
98
|
+
case ToolExecutionEventType.TOOL_EXECUTION_COMPLETED:
|
|
99
|
+
case ToolExecutionEventType.TOOL_EXECUTION_FAILED: {
|
|
100
|
+
const p = payload;
|
|
101
|
+
if (p.tool_name)
|
|
102
|
+
context.tool_name = p.tool_name;
|
|
103
|
+
if (p.execution_id)
|
|
104
|
+
context.execution_id = p.execution_id;
|
|
105
|
+
if (p.arguments)
|
|
106
|
+
context.arguments = p.arguments;
|
|
107
|
+
if (p.error)
|
|
108
|
+
context.error = p.error;
|
|
109
|
+
if (p.result)
|
|
110
|
+
context.result = p.result;
|
|
111
|
+
if (p.duration_ms !== undefined)
|
|
112
|
+
context.duration_ms = p.duration_ms;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case TransportEventType.TRANSPORT_INITIALIZED:
|
|
116
|
+
case TransportEventType.TRANSPORT_MESSAGE_SENT:
|
|
117
|
+
case TransportEventType.TRANSPORT_MESSAGE_RECEIVED:
|
|
118
|
+
case TransportEventType.TRANSPORT_ERROR: {
|
|
119
|
+
const p = payload;
|
|
120
|
+
Object.assign(context, p);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_FAILED: {
|
|
124
|
+
const p = payload;
|
|
125
|
+
if (p.tool_name)
|
|
126
|
+
context.tool_name = p.tool_name;
|
|
127
|
+
if (p.error)
|
|
128
|
+
context.error = p.error;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return Object.keys(context).length > 0 ? context : undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Determine if an event represents an error.
|
|
136
|
+
*/
|
|
137
|
+
function isErrorEvent(event) {
|
|
138
|
+
return (event.event_type === ToolExecutionEventType.TOOL_EXECUTION_FAILED ||
|
|
139
|
+
event.event_type === TransportEventType.TRANSPORT_ERROR ||
|
|
140
|
+
event.event_type === ValidationEventType.TOOL_CALL_VALIDATION_FAILED ||
|
|
141
|
+
event.event_type === DiagnosticEventType.RUNTIME_ERROR ||
|
|
142
|
+
event.event_type === SessionLifecycleEventType.SESSION_HALTED);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Determine if an event is critical for understanding execution flow.
|
|
146
|
+
*/
|
|
147
|
+
function isCriticalEvent(event) {
|
|
148
|
+
return (isErrorEvent(event) ||
|
|
149
|
+
event.event_type === SessionLifecycleEventType.SESSION_STARTED ||
|
|
150
|
+
event.event_type === SessionLifecycleEventType.SESSION_COMPLETED ||
|
|
151
|
+
event.event_type === SessionLifecycleEventType.SESSION_HALTED ||
|
|
152
|
+
event.event_type === ToolExecutionEventType.TOOL_EXECUTION_STARTED ||
|
|
153
|
+
event.event_type === ToolExecutionEventType.TOOL_EXECUTION_COMPLETED ||
|
|
154
|
+
event.event_type === ToolExecutionEventType.TOOL_EXECUTION_FAILED ||
|
|
155
|
+
event.event_type === ValidationEventType.TOOL_CALL_VALIDATION_FAILED ||
|
|
156
|
+
event.event_type === TransportEventType.TRANSPORT_ERROR ||
|
|
157
|
+
event.event_type === DiagnosticEventType.RUNTIME_ERROR);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Generate a stack trace from events for a given session.
|
|
161
|
+
*
|
|
162
|
+
* @param eventStore - Event store to query
|
|
163
|
+
* @param sessionId - Session ID to generate trace for
|
|
164
|
+
* @param options - Stack trace generation options
|
|
165
|
+
* @returns Stack trace
|
|
166
|
+
*/
|
|
167
|
+
export async function generateStackTrace(eventStore, sessionId, options = {}) {
|
|
168
|
+
const { includeAll = false, maxEntries, eventTypes, executionId, includeContext = true, } = options;
|
|
169
|
+
// Load events for the session
|
|
170
|
+
const events = await Promise.resolve(eventStore.load(sessionId));
|
|
171
|
+
const totalEvents = events.length;
|
|
172
|
+
// Filter events
|
|
173
|
+
let filteredEvents = events;
|
|
174
|
+
// Filter by event types if specified
|
|
175
|
+
if (eventTypes && eventTypes.length > 0) {
|
|
176
|
+
filteredEvents = filteredEvents.filter(e => eventTypes.includes(e.event_type));
|
|
177
|
+
}
|
|
178
|
+
// Filter by execution ID if specified
|
|
179
|
+
if (executionId) {
|
|
180
|
+
filteredEvents = filteredEvents.filter(e => {
|
|
181
|
+
const payload = e.payload;
|
|
182
|
+
return payload.execution_id === executionId;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
// Filter to critical/error events if not including all
|
|
186
|
+
if (!includeAll) {
|
|
187
|
+
filteredEvents = filteredEvents.filter(e => isCriticalEvent(e));
|
|
188
|
+
}
|
|
189
|
+
// Sort by sequence number
|
|
190
|
+
filteredEvents.sort((a, b) => a.sequence - b.sequence);
|
|
191
|
+
// Limit entries if specified
|
|
192
|
+
if (maxEntries && filteredEvents.length > maxEntries) {
|
|
193
|
+
filteredEvents = filteredEvents.slice(-maxEntries);
|
|
194
|
+
}
|
|
195
|
+
// Convert to stack trace entries
|
|
196
|
+
const entries = filteredEvents.map(event => ({
|
|
197
|
+
eventId: event.event_id,
|
|
198
|
+
eventType: event.event_type,
|
|
199
|
+
timestamp: event.timestamp,
|
|
200
|
+
sequence: event.sequence,
|
|
201
|
+
description: describeEvent(event),
|
|
202
|
+
context: includeContext ? extractContext(event) : undefined,
|
|
203
|
+
isError: isErrorEvent(event),
|
|
204
|
+
isCritical: isCriticalEvent(event),
|
|
205
|
+
}));
|
|
206
|
+
// Count errors
|
|
207
|
+
const errorCount = entries.filter(e => e.isError).length;
|
|
208
|
+
const firstError = entries.find(e => e.isError);
|
|
209
|
+
// Generate summary
|
|
210
|
+
let summary = `Session ${sessionId}: ${totalEvents} total events`;
|
|
211
|
+
if (errorCount > 0) {
|
|
212
|
+
summary += `, ${errorCount} error(s)`;
|
|
213
|
+
}
|
|
214
|
+
if (filteredEvents.length < totalEvents) {
|
|
215
|
+
summary += `, ${filteredEvents.length} shown`;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
sessionId,
|
|
219
|
+
entries,
|
|
220
|
+
totalEvents,
|
|
221
|
+
errorCount,
|
|
222
|
+
firstError,
|
|
223
|
+
summary,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Format a stack trace as a human-readable string.
|
|
228
|
+
*
|
|
229
|
+
* @param stackTrace - Stack trace to format
|
|
230
|
+
* @returns Formatted string
|
|
231
|
+
*/
|
|
232
|
+
export function formatStackTrace(stackTrace) {
|
|
233
|
+
const lines = [];
|
|
234
|
+
lines.push(`\n${'='.repeat(80)}`);
|
|
235
|
+
lines.push(`STACK TRACE: ${stackTrace.summary}`);
|
|
236
|
+
lines.push(`${'='.repeat(80)}\n`);
|
|
237
|
+
if (stackTrace.firstError) {
|
|
238
|
+
lines.push(`⚠️ First Error: ${stackTrace.firstError.description}`);
|
|
239
|
+
if (stackTrace.firstError.context?.error) {
|
|
240
|
+
const error = stackTrace.firstError.context.error;
|
|
241
|
+
if (error?.message) {
|
|
242
|
+
lines.push(` Message: ${error.message}`);
|
|
243
|
+
}
|
|
244
|
+
if (error?.code) {
|
|
245
|
+
lines.push(` Code: ${error.code}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
lines.push('');
|
|
249
|
+
}
|
|
250
|
+
lines.push('Event Sequence:');
|
|
251
|
+
lines.push('');
|
|
252
|
+
stackTrace.entries.forEach((entry, index) => {
|
|
253
|
+
const prefix = entry.isError ? '❌' : entry.isCritical ? '🔍' : ' ';
|
|
254
|
+
const seq = String(entry.sequence).padStart(4, '0');
|
|
255
|
+
// Parse timestamp safely
|
|
256
|
+
let time = entry.timestamp;
|
|
257
|
+
try {
|
|
258
|
+
const timestampParts = entry.timestamp.split('T');
|
|
259
|
+
if (timestampParts.length > 1) {
|
|
260
|
+
const timePart = timestampParts[1];
|
|
261
|
+
if (timePart) {
|
|
262
|
+
const timeParts = timePart.split('.');
|
|
263
|
+
time = timeParts[0] || entry.timestamp;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// Fallback to original timestamp if parsing fails
|
|
269
|
+
time = entry.timestamp;
|
|
270
|
+
}
|
|
271
|
+
lines.push(`${prefix} [${seq}] ${time} - ${entry.description}`);
|
|
272
|
+
if (entry.context && Object.keys(entry.context).length > 0) {
|
|
273
|
+
const contextStr = JSON.stringify(entry.context, null, 2)
|
|
274
|
+
.split('\n')
|
|
275
|
+
.map(line => ` ${line}`)
|
|
276
|
+
.join('\n');
|
|
277
|
+
lines.push(contextStr);
|
|
278
|
+
}
|
|
279
|
+
if (index < stackTrace.entries.length - 1) {
|
|
280
|
+
lines.push('');
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
lines.push(`\n${'='.repeat(80)}`);
|
|
284
|
+
return lines.join('\n');
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=stack-trace.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev Mode type definitions.
|
|
3
|
+
*/
|
|
4
|
+
import type { SyrinConfig } from '../../config/types.js';
|
|
5
|
+
import type { LLMProvider } from '../../runtime/llm/provider.js';
|
|
6
|
+
import type { MCPClientManager } from '../../runtime/mcp/client/manager.js';
|
|
7
|
+
import type { EventEmitter } from '../../events/emitter.js';
|
|
8
|
+
import type { LLMMessage } from '../../runtime/llm/types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Dev Mode session configuration.
|
|
11
|
+
*/
|
|
12
|
+
export interface DevSessionConfig {
|
|
13
|
+
/** Syrin configuration */
|
|
14
|
+
config: SyrinConfig;
|
|
15
|
+
/** LLM provider */
|
|
16
|
+
llmProvider: LLMProvider;
|
|
17
|
+
/** MCP client manager */
|
|
18
|
+
mcpClientManager: MCPClientManager;
|
|
19
|
+
/** Event emitter */
|
|
20
|
+
eventEmitter: EventEmitter;
|
|
21
|
+
/** Execution mode (true = execute, false = preview) */
|
|
22
|
+
executionMode: boolean;
|
|
23
|
+
/** Project root directory */
|
|
24
|
+
projectRoot: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tool call information.
|
|
28
|
+
*/
|
|
29
|
+
export interface ToolCallInfo {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
arguments: Record<string, unknown>;
|
|
33
|
+
result?: unknown;
|
|
34
|
+
/** Reference ID for large data stored externally */
|
|
35
|
+
resultReference?: string;
|
|
36
|
+
timestamp: Date;
|
|
37
|
+
duration?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Dev Mode session state.
|
|
41
|
+
*/
|
|
42
|
+
export interface DevSessionState {
|
|
43
|
+
/** Conversation history */
|
|
44
|
+
conversationHistory: LLMMessage[];
|
|
45
|
+
/** Tool calls made during session */
|
|
46
|
+
toolCalls: ToolCallInfo[];
|
|
47
|
+
/** Total tool calls count */
|
|
48
|
+
totalToolCalls: number;
|
|
49
|
+
/** Total LLM calls count */
|
|
50
|
+
totalLLMCalls: number;
|
|
51
|
+
/** Session start time */
|
|
52
|
+
startTime: Date;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude (Anthropic) LLM provider implementation.
|
|
3
|
+
*/
|
|
4
|
+
import type { LLMProvider } from './provider.js';
|
|
5
|
+
import type { LLMRequest, LLMResponse } from './types.js';
|
|
6
|
+
import type { APIKey, ModelName } from '../../types/ids.js';
|
|
7
|
+
/**
|
|
8
|
+
* Claude provider implementation.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ClaudeProvider implements LLMProvider {
|
|
11
|
+
private client;
|
|
12
|
+
private modelName;
|
|
13
|
+
constructor(apiKey: string, modelName: string);
|
|
14
|
+
getName(): string;
|
|
15
|
+
getModelName(): string;
|
|
16
|
+
supportsToolCalls(): boolean;
|
|
17
|
+
chat(request: LLMRequest): Promise<LLMResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Create Claude provider from config.
|
|
20
|
+
* @param apiKeyEnvVar - Environment variable name for API key
|
|
21
|
+
* @param modelNameEnvVar - Environment variable name for model name
|
|
22
|
+
* @param projectRoot - Project root directory
|
|
23
|
+
* @returns Claude provider instance
|
|
24
|
+
*/
|
|
25
|
+
static fromConfig(apiKeyEnvVar: APIKey | string, modelNameEnvVar: ModelName | string, projectRoot?: string): ClaudeProvider;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude (Anthropic) LLM provider implementation.
|
|
3
|
+
*/
|
|
4
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
5
|
+
import { checkEnvVar } from '../../config/env-checker.js';
|
|
6
|
+
import { ConfigurationError } from '../../utils/errors.js';
|
|
7
|
+
/**
|
|
8
|
+
* Claude provider implementation.
|
|
9
|
+
*/
|
|
10
|
+
export class ClaudeProvider {
|
|
11
|
+
client;
|
|
12
|
+
modelName;
|
|
13
|
+
constructor(apiKey, modelName) {
|
|
14
|
+
if (!apiKey) {
|
|
15
|
+
throw new ConfigurationError('Claude API key is required');
|
|
16
|
+
}
|
|
17
|
+
if (!modelName) {
|
|
18
|
+
throw new ConfigurationError('Claude model name is required');
|
|
19
|
+
}
|
|
20
|
+
this.client = new Anthropic({
|
|
21
|
+
apiKey,
|
|
22
|
+
});
|
|
23
|
+
this.modelName = modelName;
|
|
24
|
+
}
|
|
25
|
+
getName() {
|
|
26
|
+
return 'Claude';
|
|
27
|
+
}
|
|
28
|
+
getModelName() {
|
|
29
|
+
return this.modelName;
|
|
30
|
+
}
|
|
31
|
+
supportsToolCalls() {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
async chat(request) {
|
|
35
|
+
try {
|
|
36
|
+
// Convert tools to Claude format
|
|
37
|
+
// Claude requires input_schema to have a 'type' field set to 'object'
|
|
38
|
+
const tools = request.tools?.map(tool => {
|
|
39
|
+
const inputSchema = { ...tool.inputSchema };
|
|
40
|
+
// Ensure the schema has a 'type' field set to 'object'
|
|
41
|
+
const schemaWithType = {
|
|
42
|
+
...inputSchema,
|
|
43
|
+
type: 'object',
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
name: tool.name,
|
|
47
|
+
description: tool.description,
|
|
48
|
+
input_schema: schemaWithType,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
// Convert messages to Claude format
|
|
52
|
+
const messages = request.messages
|
|
53
|
+
.filter(msg => msg.role !== 'system') // System messages handled separately
|
|
54
|
+
.map(msg => ({
|
|
55
|
+
role: msg.role,
|
|
56
|
+
content: msg.content,
|
|
57
|
+
}));
|
|
58
|
+
// Extract system prompt
|
|
59
|
+
const systemPrompt = request.systemPrompt ||
|
|
60
|
+
request.messages.find(msg => msg.role === 'system')?.content ||
|
|
61
|
+
'';
|
|
62
|
+
// Build the request parameters
|
|
63
|
+
const requestParams = {
|
|
64
|
+
model: this.modelName,
|
|
65
|
+
max_tokens: request.maxTokens ?? 4096,
|
|
66
|
+
temperature: request.temperature ?? 0.7,
|
|
67
|
+
messages,
|
|
68
|
+
};
|
|
69
|
+
if (systemPrompt) {
|
|
70
|
+
requestParams.system = systemPrompt;
|
|
71
|
+
}
|
|
72
|
+
if (tools && tools.length > 0) {
|
|
73
|
+
// Cast tools to the expected type - the SDK will validate
|
|
74
|
+
requestParams.tools = tools;
|
|
75
|
+
}
|
|
76
|
+
const response = await this.client.messages.create(requestParams);
|
|
77
|
+
// Type guard: check if it's a Message (not a Stream)
|
|
78
|
+
if (!('content' in response)) {
|
|
79
|
+
throw new Error('Unexpected stream response from Claude API');
|
|
80
|
+
}
|
|
81
|
+
// Now TypeScript knows it's a Message
|
|
82
|
+
const message = response;
|
|
83
|
+
// Extract content from response
|
|
84
|
+
const contentBlocks = message.content.filter(block => block.type === 'text');
|
|
85
|
+
const content = contentBlocks
|
|
86
|
+
.map(block => (block.type === 'text' ? block.text : ''))
|
|
87
|
+
.join('\n');
|
|
88
|
+
// Extract tool use blocks
|
|
89
|
+
const toolCalls = [];
|
|
90
|
+
const toolUseBlocks = message.content.filter(block => block.type === 'tool_use');
|
|
91
|
+
for (const block of toolUseBlocks) {
|
|
92
|
+
if (block.type === 'tool_use' && block.id && block.name) {
|
|
93
|
+
toolCalls.push({
|
|
94
|
+
id: block.id,
|
|
95
|
+
name: block.name,
|
|
96
|
+
arguments: block.input || {},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const finishReason = message.stop_reason === 'tool_use'
|
|
101
|
+
? 'tool_calls'
|
|
102
|
+
: message.stop_reason === 'end_turn'
|
|
103
|
+
? 'stop'
|
|
104
|
+
: message.stop_reason === 'max_tokens'
|
|
105
|
+
? 'length'
|
|
106
|
+
: 'stop';
|
|
107
|
+
return {
|
|
108
|
+
content,
|
|
109
|
+
finishReason,
|
|
110
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
111
|
+
usage: message.usage
|
|
112
|
+
? {
|
|
113
|
+
promptTokens: message.usage.input_tokens,
|
|
114
|
+
completionTokens: message.usage.output_tokens,
|
|
115
|
+
totalTokens: message.usage.input_tokens + message.usage.output_tokens,
|
|
116
|
+
}
|
|
117
|
+
: undefined,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error instanceof Error) {
|
|
122
|
+
throw new Error(`Claude API error: ${error.message}`);
|
|
123
|
+
}
|
|
124
|
+
throw new Error('Unknown error from Claude API');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create Claude provider from config.
|
|
129
|
+
* @param apiKeyEnvVar - Environment variable name for API key
|
|
130
|
+
* @param modelNameEnvVar - Environment variable name for model name
|
|
131
|
+
* @param projectRoot - Project root directory
|
|
132
|
+
* @returns Claude provider instance
|
|
133
|
+
*/
|
|
134
|
+
static fromConfig(apiKeyEnvVar, modelNameEnvVar, projectRoot = process.cwd()) {
|
|
135
|
+
// Check API key
|
|
136
|
+
const apiKeyCheck = checkEnvVar(apiKeyEnvVar, projectRoot);
|
|
137
|
+
if (!apiKeyCheck.isSet || !apiKeyCheck.value) {
|
|
138
|
+
throw new ConfigurationError(apiKeyCheck.errorMessage ||
|
|
139
|
+
`Claude API key (${apiKeyEnvVar}) is not set`);
|
|
140
|
+
}
|
|
141
|
+
// Check model name
|
|
142
|
+
const modelNameCheck = checkEnvVar(modelNameEnvVar, projectRoot);
|
|
143
|
+
if (!modelNameCheck.isSet || !modelNameCheck.value) {
|
|
144
|
+
throw new ConfigurationError(modelNameCheck.errorMessage ||
|
|
145
|
+
`Claude model name (${modelNameEnvVar}) is not set`);
|
|
146
|
+
}
|
|
147
|
+
return new ClaudeProvider(apiKeyCheck.value, modelNameCheck.value);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM provider factory.
|
|
3
|
+
* Creates LLM provider instances from configuration.
|
|
4
|
+
*/
|
|
5
|
+
import type { SyrinConfig } from '../../config/types.js';
|
|
6
|
+
import type { LLMProvider } from './provider.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create an LLM provider from configuration.
|
|
9
|
+
* @param providerName - Name of the provider (e.g., "openai", "claude", "ollama")
|
|
10
|
+
* @param config - Syrin configuration
|
|
11
|
+
* @param projectRoot - Project root directory
|
|
12
|
+
* @returns LLM provider instance
|
|
13
|
+
*/
|
|
14
|
+
export declare function createLLMProvider(providerName: string, config: SyrinConfig, projectRoot?: string): LLMProvider;
|
|
15
|
+
/**
|
|
16
|
+
* Get the default LLM provider from configuration.
|
|
17
|
+
* @param config - Syrin configuration
|
|
18
|
+
* @param projectRoot - Project root directory
|
|
19
|
+
* @returns Default LLM provider instance
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDefaultLLMProvider(config: SyrinConfig, projectRoot?: string): LLMProvider;
|
|
22
|
+
/**
|
|
23
|
+
* Get LLM provider by name or use default.
|
|
24
|
+
* @param providerName - Optional provider name (e.g., "openai", "claude")
|
|
25
|
+
* @param config - Syrin configuration
|
|
26
|
+
* @param projectRoot - Project root directory
|
|
27
|
+
* @returns LLM provider instance
|
|
28
|
+
*/
|
|
29
|
+
export declare function getLLMProvider(providerName: string | undefined, config: SyrinConfig, projectRoot?: string): LLMProvider;
|
|
30
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM provider factory.
|
|
3
|
+
* Creates LLM provider instances from configuration.
|
|
4
|
+
*/
|
|
5
|
+
import { OpenAIProvider } from './openai.js';
|
|
6
|
+
import { ClaudeProvider } from './claude.js';
|
|
7
|
+
import { OllamaProvider } from './ollama.js';
|
|
8
|
+
import { ConfigurationError } from '../../utils/errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create an LLM provider from configuration.
|
|
11
|
+
* @param providerName - Name of the provider (e.g., "openai", "claude", "ollama")
|
|
12
|
+
* @param config - Syrin configuration
|
|
13
|
+
* @param projectRoot - Project root directory
|
|
14
|
+
* @returns LLM provider instance
|
|
15
|
+
*/
|
|
16
|
+
export function createLLMProvider(providerName, config, projectRoot = process.cwd()) {
|
|
17
|
+
const providerConfig = config.llm[providerName];
|
|
18
|
+
if (!providerConfig) {
|
|
19
|
+
throw new ConfigurationError(`LLM provider "${providerName}" not found in configuration`);
|
|
20
|
+
}
|
|
21
|
+
// Handle OpenAI
|
|
22
|
+
if (providerName === 'openai') {
|
|
23
|
+
if (!providerConfig.API_KEY || !providerConfig.MODEL_NAME) {
|
|
24
|
+
throw new ConfigurationError('OpenAI provider requires API_KEY and MODEL_NAME');
|
|
25
|
+
}
|
|
26
|
+
return OpenAIProvider.fromConfig(providerConfig.API_KEY, providerConfig.MODEL_NAME, projectRoot);
|
|
27
|
+
}
|
|
28
|
+
// Handle Claude
|
|
29
|
+
if (providerName === 'claude') {
|
|
30
|
+
if (!providerConfig.API_KEY || !providerConfig.MODEL_NAME) {
|
|
31
|
+
throw new ConfigurationError('Claude provider requires API_KEY and MODEL_NAME');
|
|
32
|
+
}
|
|
33
|
+
return ClaudeProvider.fromConfig(providerConfig.API_KEY, providerConfig.MODEL_NAME, projectRoot);
|
|
34
|
+
}
|
|
35
|
+
// Handle Ollama
|
|
36
|
+
if (providerName === 'ollama') {
|
|
37
|
+
// Ollama provider - MODEL_NAME is required
|
|
38
|
+
if (!providerConfig.MODEL_NAME) {
|
|
39
|
+
throw new ConfigurationError('Ollama provider requires MODEL_NAME to be set in config.yaml');
|
|
40
|
+
}
|
|
41
|
+
return OllamaProvider.fromConfig(providerConfig.MODEL_NAME, projectRoot);
|
|
42
|
+
}
|
|
43
|
+
throw new ConfigurationError(`Unsupported LLM provider: ${providerName}`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the default LLM provider from configuration.
|
|
47
|
+
* @param config - Syrin configuration
|
|
48
|
+
* @param projectRoot - Project root directory
|
|
49
|
+
* @returns Default LLM provider instance
|
|
50
|
+
*/
|
|
51
|
+
export function getDefaultLLMProvider(config, projectRoot = process.cwd()) {
|
|
52
|
+
// Find the provider marked as default
|
|
53
|
+
for (const [providerName, providerConfig] of Object.entries(config.llm)) {
|
|
54
|
+
if (providerConfig.default) {
|
|
55
|
+
return createLLMProvider(providerName, config, projectRoot);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// If no default, use the first provider
|
|
59
|
+
const firstProviderName = Object.keys(config.llm)[0];
|
|
60
|
+
if (!firstProviderName) {
|
|
61
|
+
throw new ConfigurationError('No LLM providers configured');
|
|
62
|
+
}
|
|
63
|
+
return createLLMProvider(firstProviderName, config, projectRoot);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get LLM provider by name or use default.
|
|
67
|
+
* @param providerName - Optional provider name (e.g., "openai", "claude")
|
|
68
|
+
* @param config - Syrin configuration
|
|
69
|
+
* @param projectRoot - Project root directory
|
|
70
|
+
* @returns LLM provider instance
|
|
71
|
+
*/
|
|
72
|
+
export function getLLMProvider(providerName, config, projectRoot = process.cwd()) {
|
|
73
|
+
if (providerName) {
|
|
74
|
+
return createLLMProvider(providerName, config, projectRoot);
|
|
75
|
+
}
|
|
76
|
+
return getDefaultLLMProvider(config, projectRoot);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM provider exports.
|
|
3
|
+
*/
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './provider.js';
|
|
6
|
+
export * from './openai.js';
|
|
7
|
+
export * from './claude.js';
|
|
8
|
+
export * from './ollama.js';
|
|
9
|
+
export * from './factory.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|