@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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Manager for handling large data storage and references.
|
|
3
|
+
* Externalizes large tool results to disk to reduce memory usage.
|
|
4
|
+
*/
|
|
5
|
+
export interface DataReference {
|
|
6
|
+
id: string;
|
|
7
|
+
filePath: string;
|
|
8
|
+
size: number;
|
|
9
|
+
toolName: string;
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Data Manager for externalizing large data to reduce memory usage.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DataManager {
|
|
16
|
+
private dataDir;
|
|
17
|
+
private references;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new DataManager instance.
|
|
20
|
+
* @param projectRoot - Project root directory
|
|
21
|
+
*/
|
|
22
|
+
constructor(projectRoot: string);
|
|
23
|
+
/**
|
|
24
|
+
* Check if data should be externalized based on size.
|
|
25
|
+
* @param sizeBytes - Size of data in bytes
|
|
26
|
+
* @returns true if data should be externalized
|
|
27
|
+
*/
|
|
28
|
+
static shouldExternalize(sizeBytes: number): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Store large data to disk and return a reference ID.
|
|
31
|
+
* @param data - Data to store
|
|
32
|
+
* @param toolName - Name of the tool that generated the data
|
|
33
|
+
* @returns Reference ID for the stored data
|
|
34
|
+
*/
|
|
35
|
+
store(data: unknown, toolName: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Load data by reference ID.
|
|
38
|
+
* @param id - Reference ID
|
|
39
|
+
* @returns The stored data
|
|
40
|
+
*/
|
|
41
|
+
load(id: string): unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Get reference metadata without loading the actual data.
|
|
44
|
+
* @param id - Reference ID
|
|
45
|
+
* @returns Reference metadata or undefined if not found
|
|
46
|
+
*/
|
|
47
|
+
getReference(id: string): DataReference | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Format file size for display.
|
|
50
|
+
* @param sizeBytes - Size in bytes
|
|
51
|
+
* @returns Formatted size string
|
|
52
|
+
*/
|
|
53
|
+
static formatSize(sizeBytes: number): string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=data-manager.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Manager for handling large data storage and references.
|
|
3
|
+
* Externalizes large tool results to disk to reduce memory usage.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { saveJSONToFile } from '../../utils/json-file-saver.js';
|
|
8
|
+
/**
|
|
9
|
+
* Data Manager for externalizing large data to reduce memory usage.
|
|
10
|
+
*/
|
|
11
|
+
export class DataManager {
|
|
12
|
+
dataDir;
|
|
13
|
+
references = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Create a new DataManager instance.
|
|
16
|
+
* @param projectRoot - Project root directory
|
|
17
|
+
*/
|
|
18
|
+
constructor(projectRoot) {
|
|
19
|
+
this.dataDir = path.join(projectRoot, '.syrin', 'data');
|
|
20
|
+
if (!fs.existsSync(this.dataDir)) {
|
|
21
|
+
fs.mkdirSync(this.dataDir, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if data should be externalized based on size.
|
|
26
|
+
* @param sizeBytes - Size of data in bytes
|
|
27
|
+
* @returns true if data should be externalized
|
|
28
|
+
*/
|
|
29
|
+
static shouldExternalize(sizeBytes) {
|
|
30
|
+
return sizeBytes > 100 * 1024; // 100KB threshold
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Store large data to disk and return a reference ID.
|
|
34
|
+
* @param data - Data to store
|
|
35
|
+
* @param toolName - Name of the tool that generated the data
|
|
36
|
+
* @returns Reference ID for the stored data
|
|
37
|
+
*/
|
|
38
|
+
store(data, toolName) {
|
|
39
|
+
const id = `data-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
40
|
+
const filePath = saveJSONToFile(data, toolName, this.dataDir);
|
|
41
|
+
const stats = fs.statSync(filePath);
|
|
42
|
+
const ref = {
|
|
43
|
+
id,
|
|
44
|
+
filePath,
|
|
45
|
+
size: stats.size,
|
|
46
|
+
toolName,
|
|
47
|
+
timestamp: new Date(),
|
|
48
|
+
};
|
|
49
|
+
this.references.set(id, ref);
|
|
50
|
+
return id;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Load data by reference ID.
|
|
54
|
+
* @param id - Reference ID
|
|
55
|
+
* @returns The stored data
|
|
56
|
+
*/
|
|
57
|
+
load(id) {
|
|
58
|
+
const ref = this.references.get(id);
|
|
59
|
+
if (!ref) {
|
|
60
|
+
throw new Error(`Data reference not found: ${id}`);
|
|
61
|
+
}
|
|
62
|
+
const content = fs.readFileSync(ref.filePath, 'utf-8');
|
|
63
|
+
return JSON.parse(content);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get reference metadata without loading the actual data.
|
|
67
|
+
* @param id - Reference ID
|
|
68
|
+
* @returns Reference metadata or undefined if not found
|
|
69
|
+
*/
|
|
70
|
+
getReference(id) {
|
|
71
|
+
return this.references.get(id);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Format file size for display.
|
|
75
|
+
* @param sizeBytes - Size in bytes
|
|
76
|
+
* @returns Formatted size string
|
|
77
|
+
*/
|
|
78
|
+
static formatSize(sizeBytes) {
|
|
79
|
+
const sizeKB = sizeBytes / 1024;
|
|
80
|
+
const sizeMB = sizeKB / 1024;
|
|
81
|
+
if (sizeMB >= 1) {
|
|
82
|
+
return `${sizeMB.toFixed(2)}MB`;
|
|
83
|
+
}
|
|
84
|
+
return `${sizeKB.toFixed(2)}KB`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=data-manager.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev Mode Event Mapper.
|
|
3
|
+
* Maps runtime events to UI messages for incremental visibility in dev mode.
|
|
4
|
+
* Uses the generic event subscriber pattern for decoupling.
|
|
5
|
+
*/
|
|
6
|
+
import type { EventEmitter } from '../../events/emitter.js';
|
|
7
|
+
import type { ChatUI } from '../../presentation/dev/chat-ui.js';
|
|
8
|
+
/**
|
|
9
|
+
* Dev Event Mapper.
|
|
10
|
+
* Subscribes to events and updates the ChatUI incrementally.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DevEventMapper {
|
|
13
|
+
private readonly eventEmitter;
|
|
14
|
+
private readonly chatUI;
|
|
15
|
+
private readonly llmProviderName;
|
|
16
|
+
private unsubscribe;
|
|
17
|
+
private readonly executionIdToToolName;
|
|
18
|
+
private readonly executionIdToArguments;
|
|
19
|
+
private readonly waitingMessageIdToRequestDetails;
|
|
20
|
+
private readonly proposedToolArguments;
|
|
21
|
+
private readonly executionOrder;
|
|
22
|
+
private validationPending;
|
|
23
|
+
private validationRules;
|
|
24
|
+
private readonly waitingStartTimes;
|
|
25
|
+
constructor(eventEmitter: EventEmitter, chatUI: ChatUI, llmProviderName?: string);
|
|
26
|
+
/**
|
|
27
|
+
* Start listening to events and updating the UI.
|
|
28
|
+
*/
|
|
29
|
+
start(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Stop listening to events.
|
|
32
|
+
*/
|
|
33
|
+
stop(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Handle an event and update the UI accordingly.
|
|
36
|
+
*/
|
|
37
|
+
private handleEvent;
|
|
38
|
+
/**
|
|
39
|
+
* Handle LLM proposed tool call event.
|
|
40
|
+
*/
|
|
41
|
+
private handleToolProposed;
|
|
42
|
+
/**
|
|
43
|
+
* Handle tool call validation started event.
|
|
44
|
+
* Consolidate with validation passed - just mark as pending.
|
|
45
|
+
*/
|
|
46
|
+
private handleValidationStarted;
|
|
47
|
+
/**
|
|
48
|
+
* Handle tool call validation passed event.
|
|
49
|
+
* Consolidated with validation started - show single message with validation details.
|
|
50
|
+
*/
|
|
51
|
+
private handleValidationPassed;
|
|
52
|
+
/**
|
|
53
|
+
* Handle tool call validation failed event.
|
|
54
|
+
*/
|
|
55
|
+
private handleValidationFailed;
|
|
56
|
+
/**
|
|
57
|
+
* Handle tool execution started event.
|
|
58
|
+
*/
|
|
59
|
+
private handleToolExecutionStarted;
|
|
60
|
+
/**
|
|
61
|
+
* Handle transport message sent event.
|
|
62
|
+
*/
|
|
63
|
+
private handleTransportMessageSent;
|
|
64
|
+
/**
|
|
65
|
+
* Handle transport message received event.
|
|
66
|
+
*/
|
|
67
|
+
private handleTransportMessageReceived;
|
|
68
|
+
/**
|
|
69
|
+
* Handle tool execution completed event.
|
|
70
|
+
*/
|
|
71
|
+
private handleToolExecutionCompleted;
|
|
72
|
+
/**
|
|
73
|
+
* Handle tool execution failed event.
|
|
74
|
+
*/
|
|
75
|
+
private handleToolExecutionFailed;
|
|
76
|
+
/**
|
|
77
|
+
* Clear the most recent waiting timer.
|
|
78
|
+
* Used when a tool execution completes (success) or fails (timeout/error).
|
|
79
|
+
*/
|
|
80
|
+
private clearMostRecentWaitingTimer;
|
|
81
|
+
/**
|
|
82
|
+
* Handle post-tool LLM prompt built event.
|
|
83
|
+
* This happens after tool execution, when LLM is about to generate a response.
|
|
84
|
+
*/
|
|
85
|
+
private handlePostToolLLMPromptBuilt;
|
|
86
|
+
/**
|
|
87
|
+
* Handle LLM final response generated event.
|
|
88
|
+
* This happens when LLM has finished generating the response.
|
|
89
|
+
*/
|
|
90
|
+
private handleLLMFinalResponseGenerated;
|
|
91
|
+
/**
|
|
92
|
+
* Format arguments for display with JSON formatting.
|
|
93
|
+
*/
|
|
94
|
+
private formatArgumentsForDisplay;
|
|
95
|
+
/**
|
|
96
|
+
* Format result preview for display.
|
|
97
|
+
*/
|
|
98
|
+
private formatResultPreview;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=event-mapper.d.ts.map
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev Mode Event Mapper.
|
|
3
|
+
* Maps runtime events to UI messages for incremental visibility in dev mode.
|
|
4
|
+
* Uses the generic event subscriber pattern for decoupling.
|
|
5
|
+
*/
|
|
6
|
+
import { LLMProposalEventType, ValidationEventType, ToolExecutionEventType, TransportEventType, LLMContextEventType, } from '../../events/event-type.js';
|
|
7
|
+
import { DataManager } from './data-manager.js';
|
|
8
|
+
/**
|
|
9
|
+
* Dev Event Mapper.
|
|
10
|
+
* Subscribes to events and updates the ChatUI incrementally.
|
|
11
|
+
*/
|
|
12
|
+
export class DevEventMapper {
|
|
13
|
+
eventEmitter;
|
|
14
|
+
chatUI;
|
|
15
|
+
llmProviderName;
|
|
16
|
+
unsubscribe = null;
|
|
17
|
+
executionIdToToolName = new Map();
|
|
18
|
+
executionIdToArguments = new Map(); // Track arguments for duplicate detection
|
|
19
|
+
waitingMessageIdToRequestDetails = new Map(); // Store request details for each waiting message
|
|
20
|
+
proposedToolArguments = new Map(); // Track proposed tool arguments
|
|
21
|
+
executionOrder = []; // Track execution order for indexing
|
|
22
|
+
validationPending = new Map(); // Track validation state
|
|
23
|
+
validationRules = new Map(); // Store validation rules per tool
|
|
24
|
+
waitingStartTimes = new Map(); // Track start time to calculate elapsed when response arrives
|
|
25
|
+
constructor(eventEmitter, chatUI, llmProviderName = 'LLM') {
|
|
26
|
+
this.eventEmitter = eventEmitter;
|
|
27
|
+
this.chatUI = chatUI;
|
|
28
|
+
this.llmProviderName = llmProviderName;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Start listening to events and updating the UI.
|
|
32
|
+
*/
|
|
33
|
+
start() {
|
|
34
|
+
if (!this.eventEmitter.subscribe) {
|
|
35
|
+
// Event emitter doesn't support subscriptions (shouldn't happen with RuntimeEventEmitter)
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const subscriber = (event) => {
|
|
39
|
+
this.handleEvent(event);
|
|
40
|
+
};
|
|
41
|
+
this.unsubscribe = this.eventEmitter.subscribe(subscriber);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Stop listening to events.
|
|
45
|
+
*/
|
|
46
|
+
stop() {
|
|
47
|
+
if (this.unsubscribe) {
|
|
48
|
+
this.unsubscribe();
|
|
49
|
+
this.unsubscribe = null;
|
|
50
|
+
}
|
|
51
|
+
// Clear all waiting and generation start times (no timers to clear)
|
|
52
|
+
this.waitingStartTimes.clear();
|
|
53
|
+
this.executionIdToToolName.clear();
|
|
54
|
+
this.executionIdToArguments.clear();
|
|
55
|
+
this.proposedToolArguments.clear();
|
|
56
|
+
this.validationPending.clear();
|
|
57
|
+
this.validationRules.clear();
|
|
58
|
+
this.executionOrder.length = 0; // Clear array
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handle an event and update the UI accordingly.
|
|
62
|
+
*/
|
|
63
|
+
handleEvent(event) {
|
|
64
|
+
switch (event.event_type) {
|
|
65
|
+
case LLMProposalEventType.LLM_PROPOSED_TOOL_CALL:
|
|
66
|
+
this.handleToolProposed(event);
|
|
67
|
+
break;
|
|
68
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_STARTED:
|
|
69
|
+
this.handleValidationStarted(event);
|
|
70
|
+
break;
|
|
71
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_PASSED:
|
|
72
|
+
this.handleValidationPassed(event);
|
|
73
|
+
break;
|
|
74
|
+
case ValidationEventType.TOOL_CALL_VALIDATION_FAILED:
|
|
75
|
+
this.handleValidationFailed(event);
|
|
76
|
+
break;
|
|
77
|
+
case ToolExecutionEventType.TOOL_EXECUTION_STARTED:
|
|
78
|
+
this.handleToolExecutionStarted(event);
|
|
79
|
+
break;
|
|
80
|
+
case TransportEventType.TRANSPORT_MESSAGE_SENT:
|
|
81
|
+
this.handleTransportMessageSent(event);
|
|
82
|
+
break;
|
|
83
|
+
case TransportEventType.TRANSPORT_MESSAGE_RECEIVED:
|
|
84
|
+
this.handleTransportMessageReceived(event);
|
|
85
|
+
break;
|
|
86
|
+
case ToolExecutionEventType.TOOL_EXECUTION_COMPLETED:
|
|
87
|
+
this.handleToolExecutionCompleted(event);
|
|
88
|
+
break;
|
|
89
|
+
case ToolExecutionEventType.TOOL_EXECUTION_FAILED:
|
|
90
|
+
this.handleToolExecutionFailed(event);
|
|
91
|
+
break;
|
|
92
|
+
case LLMContextEventType.POST_TOOL_LLM_PROMPT_BUILT:
|
|
93
|
+
this.handlePostToolLLMPromptBuilt(event);
|
|
94
|
+
break;
|
|
95
|
+
case LLMProposalEventType.LLM_FINAL_RESPONSE_GENERATED:
|
|
96
|
+
this.handleLLMFinalResponseGenerated(event);
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
// Ignore other event types for now
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle LLM proposed tool call event.
|
|
105
|
+
*/
|
|
106
|
+
handleToolProposed(event) {
|
|
107
|
+
const payload = event.payload;
|
|
108
|
+
// Store proposed arguments for comparison later
|
|
109
|
+
this.proposedToolArguments.set(payload.tool_name, payload.arguments);
|
|
110
|
+
const argsJson = this.formatArgumentsForDisplay(payload.arguments);
|
|
111
|
+
this.chatUI.addMessage('system', `🔧 **Tool Selected**: \`${payload.tool_name}\`\n**Arguments**:\n\`\`\`json\n${argsJson}\n\`\`\``);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Handle tool call validation started event.
|
|
115
|
+
* Consolidate with validation passed - just mark as pending.
|
|
116
|
+
*/
|
|
117
|
+
handleValidationStarted(event) {
|
|
118
|
+
const payload = event.payload;
|
|
119
|
+
// Store validation pending state - will be updated when passed
|
|
120
|
+
this.validationPending.set(payload.tool_name, true);
|
|
121
|
+
// Store validation rules to display when validation passes
|
|
122
|
+
this.validationRules.set(payload.tool_name, payload.validation_rules);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Handle tool call validation passed event.
|
|
126
|
+
* Consolidated with validation started - show single message with validation details.
|
|
127
|
+
*/
|
|
128
|
+
handleValidationPassed(event) {
|
|
129
|
+
const payload = event.payload;
|
|
130
|
+
const rules = this.validationRules.get(payload.tool_name) || [];
|
|
131
|
+
// Format validation rules for display
|
|
132
|
+
let validationDetails = '';
|
|
133
|
+
if (rules.length > 0) {
|
|
134
|
+
const rulesList = rules.map(rule => ` • ${rule}`).join('\n');
|
|
135
|
+
validationDetails = `\n**Checks passed**:\n${rulesList}`;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Fallback message if no rules available
|
|
139
|
+
validationDetails =
|
|
140
|
+
'\n**Checks passed**: Parameter validation, data type matching';
|
|
141
|
+
}
|
|
142
|
+
this.chatUI.addMessage('system', `✓ Validated: \`${payload.tool_name}\`${validationDetails}`);
|
|
143
|
+
this.validationPending.delete(payload.tool_name);
|
|
144
|
+
this.validationRules.delete(payload.tool_name);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Handle tool call validation failed event.
|
|
148
|
+
*/
|
|
149
|
+
handleValidationFailed(event) {
|
|
150
|
+
const payload = event.payload;
|
|
151
|
+
const errors = payload.validation_errors
|
|
152
|
+
.map(err => ` - ${err.message} (${err.code})`)
|
|
153
|
+
.join('\n');
|
|
154
|
+
this.chatUI.addMessage('system', `❌ Validation failed for **${payload.tool_name}**:\n${errors}`);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Handle tool execution started event.
|
|
158
|
+
*/
|
|
159
|
+
handleToolExecutionStarted(event) {
|
|
160
|
+
const payload = event.payload;
|
|
161
|
+
// Store mapping for later use
|
|
162
|
+
this.executionIdToToolName.set(payload.execution_id, payload.tool_name);
|
|
163
|
+
this.executionIdToArguments.set(payload.execution_id, payload.arguments);
|
|
164
|
+
// Track execution order for indexing
|
|
165
|
+
if (!this.executionOrder.includes(payload.execution_id)) {
|
|
166
|
+
this.executionOrder.push(payload.execution_id);
|
|
167
|
+
}
|
|
168
|
+
// Check if arguments are same as the proposed tool call
|
|
169
|
+
const proposedArgs = this.proposedToolArguments.get(payload.tool_name);
|
|
170
|
+
const argsAreSame = proposedArgs &&
|
|
171
|
+
JSON.stringify(proposedArgs, Object.keys(proposedArgs).sort()) ===
|
|
172
|
+
JSON.stringify(payload.arguments, Object.keys(payload.arguments).sort());
|
|
173
|
+
if (argsAreSame) {
|
|
174
|
+
// Arguments are same - just show executing message
|
|
175
|
+
this.chatUI.addMessage('system', `🚀 **Executing**: \`${payload.tool_name}\``);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// Arguments differ - show parameters
|
|
179
|
+
const argsJson = this.formatArgumentsForDisplay(payload.arguments);
|
|
180
|
+
this.chatUI.addMessage('system', `🚀 **Executing**: \`${payload.tool_name}\`\n**Parameters**:\n\`\`\`json\n${argsJson}\n\`\`\``);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Handle transport message sent event.
|
|
185
|
+
*/
|
|
186
|
+
handleTransportMessageSent(event) {
|
|
187
|
+
const payload = event.payload;
|
|
188
|
+
if (payload.message_type === 'tools/call') {
|
|
189
|
+
const sizeDisplay = DataManager.formatSize(payload.size_bytes);
|
|
190
|
+
const messageId = `waiting-${Date.now()}-${Math.random()}`;
|
|
191
|
+
const startTime = Date.now();
|
|
192
|
+
// Store start time for calculating elapsed time when response arrives
|
|
193
|
+
this.waitingStartTimes.set(messageId, startTime);
|
|
194
|
+
// Format request details
|
|
195
|
+
let requestDetails = `📤 **Request sent** to MCP server (${sizeDisplay})`;
|
|
196
|
+
if (payload.tool_name) {
|
|
197
|
+
requestDetails += `\n\n**Tool:** \`${payload.tool_name}\``;
|
|
198
|
+
requestDetails += `\n**Type:** ${payload.message_type}`;
|
|
199
|
+
if (payload.tool_arguments) {
|
|
200
|
+
const argsStr = JSON.stringify(payload.tool_arguments, null, 2);
|
|
201
|
+
// Truncate very long arguments (over 500 chars) to keep display manageable
|
|
202
|
+
const truncatedArgs = argsStr.length > 500
|
|
203
|
+
? argsStr.substring(0, 500) + '\n... (truncated)'
|
|
204
|
+
: argsStr;
|
|
205
|
+
requestDetails += `\n**Arguments:**\n\`\`\`json\n${truncatedArgs}\n\`\`\``;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Store request details for later use when updating the message
|
|
209
|
+
this.waitingMessageIdToRequestDetails.set(messageId, requestDetails);
|
|
210
|
+
requestDetails += `\n\n⏳ **Waiting** for response...`;
|
|
211
|
+
// Add static waiting message (no live updates to prevent scroll jumping)
|
|
212
|
+
this.chatUI.addMessage('system', requestDetails);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Handle transport message received event.
|
|
217
|
+
*/
|
|
218
|
+
handleTransportMessageReceived(event) {
|
|
219
|
+
const payload = event.payload;
|
|
220
|
+
if (payload.message_type === 'tools/call_response') {
|
|
221
|
+
const sizeDisplay = DataManager.formatSize(payload.size_bytes);
|
|
222
|
+
// Calculate elapsed time and update the waiting message with final response
|
|
223
|
+
if (this.waitingStartTimes.size > 0) {
|
|
224
|
+
// Get the last (most recent) waiting start time
|
|
225
|
+
const startTimeEntries = Array.from(this.waitingStartTimes.entries());
|
|
226
|
+
const lastEntry = startTimeEntries[startTimeEntries.length - 1];
|
|
227
|
+
if (lastEntry) {
|
|
228
|
+
const [messageId, startTime] = lastEntry;
|
|
229
|
+
// Calculate final elapsed time
|
|
230
|
+
const elapsed = (Date.now() - startTime) / 1000;
|
|
231
|
+
const elapsedStr = elapsed < 1 ? `${elapsed.toFixed(1)}s` : `${Math.floor(elapsed)}s`;
|
|
232
|
+
// Get stored request details and append response info
|
|
233
|
+
const requestDetails = this.waitingMessageIdToRequestDetails.get(messageId) ||
|
|
234
|
+
`📤 **Request sent** to MCP server (${sizeDisplay})`;
|
|
235
|
+
const fullMessage = `${requestDetails}\n\n📥 **Response received** from MCP server (${sizeDisplay}) - ${elapsedStr}`;
|
|
236
|
+
// Update the waiting message with final response time (only one state update)
|
|
237
|
+
this.chatUI.updateLastSystemMessage(fullMessage);
|
|
238
|
+
// Clean up stored data
|
|
239
|
+
this.waitingStartTimes.delete(messageId);
|
|
240
|
+
this.waitingMessageIdToRequestDetails.delete(messageId);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// Fallback: if no timer found, just add a new message
|
|
245
|
+
this.chatUI.addMessage('system', `📥 Response received from MCP server (${sizeDisplay})`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Handle tool execution completed event.
|
|
251
|
+
*/
|
|
252
|
+
handleToolExecutionCompleted(event) {
|
|
253
|
+
const payload = event.payload;
|
|
254
|
+
const toolName = this.executionIdToToolName.get(payload.execution_id) || payload.tool_name;
|
|
255
|
+
// Get tool call index (1-based for user convenience)
|
|
256
|
+
const executionIndex = this.executionOrder.indexOf(payload.execution_id);
|
|
257
|
+
const toolIndex = executionIndex >= 0 ? executionIndex + 1 : null;
|
|
258
|
+
// Format result preview (truncate if large)
|
|
259
|
+
const resultPreview = this.formatResultPreview(payload.result, toolIndex);
|
|
260
|
+
const duration = payload.duration_ms;
|
|
261
|
+
const durationStr = duration < 1000 ? `${duration}ms` : `${(duration / 1000).toFixed(1)}s`;
|
|
262
|
+
let resultSection = '';
|
|
263
|
+
if (resultPreview.json) {
|
|
264
|
+
resultSection = `\n**Result**:\n\`\`\`json\n${resultPreview.json}\n\`\`\``;
|
|
265
|
+
if (resultPreview.truncated) {
|
|
266
|
+
resultSection += `\n${resultPreview.truncated}`;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
this.chatUI.addMessage('system', `✅ **Tool Response**: \`${toolName}\` completed (${durationStr})${resultSection}`);
|
|
270
|
+
// Clean up mapping (but keep in executionOrder for indexing)
|
|
271
|
+
this.executionIdToToolName.delete(payload.execution_id);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Handle tool execution failed event.
|
|
275
|
+
*/
|
|
276
|
+
handleToolExecutionFailed(event) {
|
|
277
|
+
const payload = event.payload;
|
|
278
|
+
const toolName = this.executionIdToToolName.get(payload.execution_id) || payload.tool_name;
|
|
279
|
+
const duration = payload.duration_ms;
|
|
280
|
+
// Clear waiting timer if it exists (timeouts/failures don't emit TRANSPORT_MESSAGE_RECEIVED)
|
|
281
|
+
this.clearMostRecentWaitingTimer();
|
|
282
|
+
this.chatUI.addMessage('system', `❌ **${toolName}** failed (${duration}ms)\nError: ${payload.error.message} (${payload.error.code})`);
|
|
283
|
+
// Clean up mapping
|
|
284
|
+
this.executionIdToToolName.delete(payload.execution_id);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Clear the most recent waiting timer.
|
|
288
|
+
* Used when a tool execution completes (success) or fails (timeout/error).
|
|
289
|
+
*/
|
|
290
|
+
clearMostRecentWaitingTimer() {
|
|
291
|
+
if (this.waitingStartTimes.size > 0) {
|
|
292
|
+
// Get the last (most recent) waiting start time
|
|
293
|
+
const startTimeEntries = Array.from(this.waitingStartTimes.entries());
|
|
294
|
+
const lastEntry = startTimeEntries[startTimeEntries.length - 1];
|
|
295
|
+
if (lastEntry) {
|
|
296
|
+
const [messageId] = lastEntry;
|
|
297
|
+
// Clear the start time (no timer to clear since we don't use live updates)
|
|
298
|
+
this.waitingStartTimes.delete(messageId);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Handle post-tool LLM prompt built event.
|
|
304
|
+
* This happens after tool execution, when LLM is about to generate a response.
|
|
305
|
+
*/
|
|
306
|
+
handlePostToolLLMPromptBuilt(_event) {
|
|
307
|
+
// Simply add a static message - no tracking needed
|
|
308
|
+
this.chatUI.addMessage('system', `🤖 **${this.llmProviderName}** generating response...`);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Handle LLM final response generated event.
|
|
312
|
+
* This happens when LLM has finished generating the response.
|
|
313
|
+
*/
|
|
314
|
+
handleLLMFinalResponseGenerated(_event) {
|
|
315
|
+
// No-op: The static message is sufficient, no need to update it
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Format arguments for display with JSON formatting.
|
|
319
|
+
*/
|
|
320
|
+
formatArgumentsForDisplay(args) {
|
|
321
|
+
if (Object.keys(args).length === 0) {
|
|
322
|
+
return '{}';
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
const formatted = JSON.stringify(args, null, 2);
|
|
326
|
+
// Truncate if too long
|
|
327
|
+
if (formatted.length > 300) {
|
|
328
|
+
return formatted.substring(0, 300) + '\n... (truncated)';
|
|
329
|
+
}
|
|
330
|
+
return formatted;
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
try {
|
|
334
|
+
return JSON.stringify(args);
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
return '[Unable to format arguments]';
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Format result preview for display.
|
|
343
|
+
*/
|
|
344
|
+
formatResultPreview(result, toolIndex = null) {
|
|
345
|
+
if (result === null || result === undefined) {
|
|
346
|
+
return { json: 'null' };
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
// Parse string as JSON if needed, then stringify with formatting
|
|
350
|
+
let parsedResult = result;
|
|
351
|
+
if (typeof result === 'string') {
|
|
352
|
+
try {
|
|
353
|
+
parsedResult = JSON.parse(result);
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
// Not JSON, use as-is
|
|
357
|
+
parsedResult = result;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
// Format as JSON with indentation
|
|
361
|
+
const formattedJson = JSON.stringify(parsedResult, null, 2);
|
|
362
|
+
const maxPreviewLength = 500; // Increased from 300 for better preview
|
|
363
|
+
// Truncate if too long
|
|
364
|
+
if (formattedJson.length > maxPreviewLength) {
|
|
365
|
+
// Find a good truncation point (end of a line)
|
|
366
|
+
let truncateAt = maxPreviewLength;
|
|
367
|
+
const lastNewline = formattedJson.lastIndexOf('\n', maxPreviewLength);
|
|
368
|
+
if (lastNewline > maxPreviewLength * 0.7) {
|
|
369
|
+
// If we find a newline in the last 30%, use it for cleaner truncation
|
|
370
|
+
truncateAt = lastNewline;
|
|
371
|
+
}
|
|
372
|
+
const preview = formattedJson.substring(0, truncateAt);
|
|
373
|
+
const saveHint = toolIndex !== null
|
|
374
|
+
? `💡 Result truncated. Use \`/save-json ${toolIndex}\` to save the full data to a file.`
|
|
375
|
+
: '💡 Result truncated. Use `/save-json` to save the full data to a file.';
|
|
376
|
+
return { json: `${preview}\n... (truncated)`, truncated: saveHint };
|
|
377
|
+
}
|
|
378
|
+
return { json: formattedJson };
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
try {
|
|
382
|
+
const fallback = JSON.stringify(result);
|
|
383
|
+
if (fallback.length > 500) {
|
|
384
|
+
const saveHint = toolIndex !== null
|
|
385
|
+
? `💡 Result truncated. Use \`/save-json ${toolIndex}\` to save the full data to a file.`
|
|
386
|
+
: '💡 Result truncated. Use `/save-json` to save the full data to a file.';
|
|
387
|
+
return {
|
|
388
|
+
json: fallback.substring(0, 500) + '\n... (truncated)',
|
|
389
|
+
truncated: saveHint,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
return { json: fallback };
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
return { json: '[Unable to format result]' };
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
//# sourceMappingURL=event-mapper.js.map
|