micro-models-agent 2.16.0 → 2.17.1
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/CHANGELOG.md +34 -0
- package/dist/assets/app.js +1 -314
- package/dist/assets/hljs.js +5 -1244
- package/dist/assets/index.html +11 -0
- package/dist/assets/js/api.js +1 -28
- package/dist/assets/js/core/menus.js +1 -0
- package/dist/assets/js/core/store/feed.js +1 -0
- package/dist/assets/js/core/store/index.js +1 -0
- package/dist/assets/js/core/store/session.js +1 -0
- package/dist/assets/js/core/store/settings.js +1 -0
- package/dist/assets/js/core/store/tabs.js +1 -0
- package/dist/assets/js/dialog.js +1 -105
- package/dist/assets/js/dom.js +1 -178
- package/dist/assets/js/feed/core.js +1 -0
- package/dist/assets/js/feed/history.js +1 -0
- package/dist/assets/js/feed/plan.js +1 -0
- package/dist/assets/js/feed/question.js +3 -0
- package/dist/assets/js/feed/sidebar.js +1 -0
- package/dist/assets/js/feed/stream.js +1 -0
- package/dist/assets/js/feed/turn.js +5 -0
- package/dist/assets/js/feed.js +1 -1211
- package/dist/assets/js/format.js +2 -122
- package/dist/assets/js/i18n.js +1 -46
- package/dist/assets/js/rail.js +1 -114
- package/dist/assets/js/session/cmdk.js +1 -0
- package/dist/assets/js/session/composer.js +1 -0
- package/dist/assets/js/session/sessions-menu.js +1 -0
- package/dist/assets/js/session/tabs.js +1 -0
- package/dist/assets/js/settings/controls.js +1 -0
- package/dist/assets/js/settings/editors.js +1 -0
- package/dist/assets/js/settings/form.js +1 -0
- package/dist/assets/js/settings/modal.js +1 -0
- package/dist/assets/js/settings/panels.js +1 -0
- package/dist/assets/js/settings/providers.js +1 -0
- package/dist/assets/js/settings/search.js +1 -0
- package/dist/assets/js/settings/subdialog.js +1 -0
- package/dist/assets/js/settings/write.js +1 -0
- package/dist/assets/js/settings.js +1 -1914
- package/dist/assets/js/sidebar/core.js +1 -0
- package/dist/assets/js/sidebar/lsp.js +2 -0
- package/dist/assets/js/sidebar/map.js +1 -0
- package/dist/assets/js/sidebar/state.js +1 -0
- package/dist/assets/js/sidebar/trace.js +5 -0
- package/dist/assets/js/sidebar.js +1 -705
- package/dist/assets/js/store.js +1 -82
- package/dist/assets/js/subdialog.js +1 -0
- package/dist/assets/md.js +1 -277
- package/dist/assets/setup.js +3 -816
- package/dist/assets/smd.js +29 -1665
- package/dist/assets/styles.css +1 -1592
- package/dist/certification/certifications.json +1 -494
- package/dist/i18n/en.json +1 -1851
- package/dist/i18n/ru.json +1 -1854
- package/dist/main.js +815 -55797
- package/dist/modules/browser/bridge-server.mjs +2 -252
- package/package.json +10 -5
- package/dist/assets/js/settings-controls.js +0 -452
- package/dist/assets/js/tabs.js +0 -867
- package/dist/cli/cache-line.js +0 -31
- package/dist/cli/command-suggest.js +0 -39
- package/dist/cli/commands.js +0 -781
- package/dist/cli/completer.js +0 -268
- package/dist/cli/index.js +0 -3
- package/dist/cli/json-payload.js +0 -32
- package/dist/cli/main.js +0 -346
- package/dist/cli/onboarding-commands.js +0 -126
- package/dist/cli/plugin-commands.js +0 -38
- package/dist/cli/relaunch.js +0 -40
- package/dist/cli/repl-commands-lsp.js +0 -75
- package/dist/cli/repl-commands-skills.js +0 -105
- package/dist/cli/repl-commands.js +0 -1218
- package/dist/cli/repl.js +0 -1238
- package/dist/cli/run-result.js +0 -38
- package/dist/cli/security-commands.js +0 -177
- package/dist/cli/setup-order.js +0 -6
- package/dist/cli/setup-prompt.js +0 -50
- package/dist/cli/setup.js +0 -161
- package/dist/cli/web-command.js +0 -98
- package/dist/config/budget.js +0 -48
- package/dist/config/config.js +0 -345
- package/dist/config/defaults.js +0 -197
- package/dist/config/domains.js +0 -135
- package/dist/config/env.js +0 -46
- package/dist/config/experts.js +0 -17
- package/dist/config/index.js +0 -5
- package/dist/config/paths.js +0 -56
- package/dist/config/redact.js +0 -44
- package/dist/config/registry-extra.js +0 -334
- package/dist/config/registry.js +0 -584
- package/dist/config/security.js +0 -212
- package/dist/config/timeouts.js +0 -74
- package/dist/config/types.js +0 -1
- package/dist/config/utils.js +0 -57
- package/dist/core/agent/artifact-progress.js +0 -59
- package/dist/core/agent/artifact-resolve.js +0 -79
- package/dist/core/agent/audit-gate.js +0 -53
- package/dist/core/agent/compaction.js +0 -89
- package/dist/core/agent/constants.js +0 -90
- package/dist/core/agent/context-log.js +0 -454
- package/dist/core/agent/context-renderer.js +0 -45
- package/dist/core/agent/critic-gate.js +0 -132
- package/dist/core/agent/hallucination-gate.js +0 -197
- package/dist/core/agent/loop-state.js +0 -68
- package/dist/core/agent/prefix-monitor.js +0 -101
- package/dist/core/agent/reasoning-resolver.js +0 -65
- package/dist/core/agent/token-tracker.js +0 -99
- package/dist/core/agent/tool-batch.js +0 -312
- package/dist/core/agent/tool-images.js +0 -18
- package/dist/core/agent/tool-output.js +0 -116
- package/dist/core/agent/tool-pairing.js +0 -60
- package/dist/core/agent-moe.js +0 -248
- package/dist/core/agent.js +0 -1299
- package/dist/core/bootstrap/agent-phase.js +0 -66
- package/dist/core/bootstrap/config-phase.js +0 -86
- package/dist/core/bootstrap/modules-phase.js +0 -269
- package/dist/core/bootstrap/provider-phase.js +0 -183
- package/dist/core/bootstrap/session-phase.js +0 -204
- package/dist/core/bootstrap/state.js +0 -94
- package/dist/core/bootstrap/workspace-phase.js +0 -115
- package/dist/core/bootstrap.js +0 -112
- package/dist/core/crash-handler.js +0 -62
- package/dist/core/environment.js +0 -224
- package/dist/core/host-plan.js +0 -43
- package/dist/core/host.js +0 -23
- package/dist/core/index.js +0 -3
- package/dist/core/prompt-builder.js +0 -95
- package/dist/core/prompt-overflow.js +0 -306
- package/dist/core/session-logger.js +0 -375
- package/dist/core/system-prompt.js +0 -117
- package/dist/core/types.js +0 -1
- package/dist/core/version.js +0 -28
- package/dist/core/web-host.js +0 -34
- package/dist/core/workspace.js +0 -80
- package/dist/i18n/index.js +0 -80
- package/dist/index.js +0 -30
- package/dist/llm/cache-usage.js +0 -76
- package/dist/llm/image-utils.js +0 -138
- package/dist/llm/index.js +0 -4
- package/dist/llm/llm-errors.js +0 -50
- package/dist/llm/model-loader.js +0 -86
- package/dist/llm/models-dev.js +0 -121
- package/dist/llm/openai-compat.js +0 -756
- package/dist/llm/orchestrator.js +0 -294
- package/dist/llm/provider-budget.js +0 -68
- package/dist/llm/provider-context.js +0 -233
- package/dist/llm/provider.js +0 -9
- package/dist/llm/response.js +0 -44
- package/dist/llm/stream-state.js +0 -26
- package/dist/llm/token-counter.js +0 -83
- package/dist/llm/types.js +0 -1
- package/dist/logger/app-logger.js +0 -212
- package/dist/logger/file-log.js +0 -160
- package/dist/logger/index.js +0 -2
- package/dist/migration/backup.js +0 -56
- package/dist/migration/detect.js +0 -61
- package/dist/migration/index.js +0 -3
- package/dist/modules/artifacts/store.js +0 -62
- package/dist/modules/browser/actions.js +0 -79
- package/dist/modules/browser/bridge-client.js +0 -203
- package/dist/modules/browser/bridge-path.js +0 -10
- package/dist/modules/browser/console-buffer.js +0 -37
- package/dist/modules/browser/cookie-store.js +0 -29
- package/dist/modules/browser/driver-types.js +0 -1
- package/dist/modules/browser/driver.js +0 -186
- package/dist/modules/browser/index.js +0 -9
- package/dist/modules/browser/module.js +0 -30
- package/dist/modules/browser/session.js +0 -322
- package/dist/modules/browser/snapshot.js +0 -154
- package/dist/modules/browser/types.js +0 -13
- package/dist/modules/certification/cli.js +0 -264
- package/dist/modules/certification/fact-checker.js +0 -90
- package/dist/modules/certification/loader.js +0 -127
- package/dist/modules/certification/manifest.js +0 -231
- package/dist/modules/certification/runner.js +0 -233
- package/dist/modules/certification/scenarios.js +0 -586
- package/dist/modules/certification/syntax-scenarios.js +0 -50
- package/dist/modules/certification/types.js +0 -1
- package/dist/modules/context/chunk-query.js +0 -122
- package/dist/modules/context/fact-extractor.js +0 -170
- package/dist/modules/context/history.js +0 -15
- package/dist/modules/context/index.js +0 -2
- package/dist/modules/context/manager.js +0 -482
- package/dist/modules/critic/client.js +0 -176
- package/dist/modules/critic/evidence.js +0 -81
- package/dist/modules/critic/provider.js +0 -45
- package/dist/modules/critic/tools.js +0 -78
- package/dist/modules/critic/types.js +0 -1
- package/dist/modules/execution/audit-runners.js +0 -206
- package/dist/modules/execution/auditor.js +0 -222
- package/dist/modules/execution/execution-plugin.js +0 -478
- package/dist/modules/execution/index.js +0 -8
- package/dist/modules/execution/input-from.js +0 -70
- package/dist/modules/execution/module.js +0 -891
- package/dist/modules/execution/moe-executor.js +0 -443
- package/dist/modules/execution/plan-actions.js +0 -642
- package/dist/modules/execution/plan-checks.js +0 -35
- package/dist/modules/execution/plan-coverage.js +0 -71
- package/dist/modules/execution/plan-persister.js +0 -46
- package/dist/modules/execution/plan-steps.js +0 -31
- package/dist/modules/execution/plan-store.js +0 -274
- package/dist/modules/execution/plan-tool.js +0 -249
- package/dist/modules/execution/plan-validator.js +0 -197
- package/dist/modules/execution/planner.js +0 -103
- package/dist/modules/execution/stuck-detector.js +0 -834
- package/dist/modules/execution/tracker.js +0 -92
- package/dist/modules/execution/transient-error.js +0 -30
- package/dist/modules/execution/types.js +0 -1
- package/dist/modules/execution/verifier.js +0 -343
- package/dist/modules/execution/windows-commands.js +0 -52
- package/dist/modules/hallucination/artifact-claim.js +0 -93
- package/dist/modules/hallucination/confidence.js +0 -81
- package/dist/modules/hallucination/consistency.js +0 -37
- package/dist/modules/hallucination/detector.js +0 -57
- package/dist/modules/hallucination/factual.js +0 -205
- package/dist/modules/hallucination/index.js +0 -6
- package/dist/modules/hallucination/js-identifiers.js +0 -261
- package/dist/modules/hallucination/llm-judge.js +0 -116
- package/dist/modules/hallucination/success-claim.js +0 -59
- package/dist/modules/index.js +0 -5
- package/dist/modules/indexer/cache.js +0 -88
- package/dist/modules/indexer/index.js +0 -4
- package/dist/modules/indexer/map-command.js +0 -33
- package/dist/modules/indexer/map-select.js +0 -87
- package/dist/modules/indexer/module.js +0 -293
- package/dist/modules/indexer/project-profile.js +0 -184
- package/dist/modules/indexer/symbols.js +0 -189
- package/dist/modules/indexer/walker.js +0 -285
- package/dist/modules/lsp/check-tool.js +0 -61
- package/dist/modules/lsp/client.js +0 -406
- package/dist/modules/lsp/command.js +0 -53
- package/dist/modules/lsp/config.js +0 -189
- package/dist/modules/lsp/index.js +0 -4
- package/dist/modules/lsp/module.js +0 -295
- package/dist/modules/lsp/probe.js +0 -86
- package/dist/modules/lsp/project-root.js +0 -69
- package/dist/modules/lsp/startup-check.js +0 -154
- package/dist/modules/lsp/types.js +0 -1
- package/dist/modules/mcp/client.js +0 -445
- package/dist/modules/mcp/index.js +0 -4
- package/dist/modules/mcp/module.js +0 -295
- package/dist/modules/mcp/registry.js +0 -20
- package/dist/modules/memory/index.js +0 -2
- package/dist/modules/memory/module.js +0 -101
- package/dist/modules/memory/search.js +0 -45
- package/dist/modules/memory/store.js +0 -107
- package/dist/modules/onboarding/init.js +0 -47
- package/dist/modules/onboarding/meet.js +0 -30
- package/dist/modules/onboarding/mode.js +0 -30
- package/dist/modules/onboarding/prompts.js +0 -43
- package/dist/modules/pipelines/engine.js +0 -70
- package/dist/modules/pipelines/index.js +0 -4
- package/dist/modules/pipelines/parser.js +0 -59
- package/dist/modules/pipelines/template.js +0 -18
- package/dist/modules/plugins/builtin/lint-on-write.js +0 -377
- package/dist/modules/plugins/builtin/notify.js +0 -11
- package/dist/modules/plugins/index.js +0 -2
- package/dist/modules/plugins/loader.js +0 -85
- package/dist/modules/plugins/manager.js +0 -244
- package/dist/modules/plugins/types.js +0 -1
- package/dist/modules/pricing/index.js +0 -70
- package/dist/modules/pricing/prices.js +0 -147
- package/dist/modules/processes/detect.js +0 -34
- package/dist/modules/processes/index.js +0 -4
- package/dist/modules/processes/kill-tree.js +0 -52
- package/dist/modules/processes/registry.js +0 -294
- package/dist/modules/processes/runner.js +0 -23
- package/dist/modules/providers/cache.js +0 -23
- package/dist/modules/providers/capabilities.js +0 -28
- package/dist/modules/providers/create.js +0 -21
- package/dist/modules/providers/factory.js +0 -28
- package/dist/modules/providers/fallback.js +0 -81
- package/dist/modules/providers/health.js +0 -47
- package/dist/modules/providers/index.js +0 -6
- package/dist/modules/providers/manager.js +0 -207
- package/dist/modules/providers/naming.js +0 -15
- package/dist/modules/providers/preflight.js +0 -71
- package/dist/modules/providers/presets.js +0 -232
- package/dist/modules/providers/registry.js +0 -27
- package/dist/modules/providers/types.js +0 -1
- package/dist/modules/reasoning/policy.js +0 -42
- package/dist/modules/reasoning/probe.js +0 -116
- package/dist/modules/registry.js +0 -48
- package/dist/modules/security/audit-log.js +0 -119
- package/dist/modules/security/audit-notifier.js +0 -267
- package/dist/modules/security/command-validator.js +0 -272
- package/dist/modules/security/content-scanner.js +0 -53
- package/dist/modules/security/data-sanitizer.js +0 -82
- package/dist/modules/security/encryption.js +0 -216
- package/dist/modules/security/index.js +0 -15
- package/dist/modules/security/network-validator.js +0 -236
- package/dist/modules/security/path-validator.js +0 -261
- package/dist/modules/security/protected-paths.js +0 -73
- package/dist/modules/security/rate-limiter.js +0 -98
- package/dist/modules/security/security-policies.js +0 -499
- package/dist/modules/security/session-encryption.js +0 -182
- package/dist/modules/security/session-isolation.js +0 -75
- package/dist/modules/session/auto-name.js +0 -63
- package/dist/modules/session/export.js +0 -98
- package/dist/modules/session/index.js +0 -4
- package/dist/modules/session/manager.js +0 -234
- package/dist/modules/session/module.js +0 -33
- package/dist/modules/session/store.js +0 -295
- package/dist/modules/session/types.js +0 -1
- package/dist/modules/setup/answers.js +0 -35
- package/dist/modules/setup/apply.js +0 -79
- package/dist/modules/setup/discovery.js +0 -72
- package/dist/modules/skills/index.js +0 -3
- package/dist/modules/skills/loader.js +0 -86
- package/dist/modules/skills/matcher.js +0 -27
- package/dist/modules/skills/module.js +0 -141
- package/dist/modules/types.js +0 -1
- package/dist/modules/updater/changelog-reader.js +0 -93
- package/dist/modules/updater/checker.js +0 -101
- package/dist/modules/updater/dev-detect.js +0 -18
- package/dist/modules/updater/index.js +0 -4
- package/dist/modules/updater/module.js +0 -129
- package/dist/modules/user-profile/compressor.js +0 -18
- package/dist/modules/user-profile/index.js +0 -2
- package/dist/modules/user-profile/profile.js +0 -77
- package/dist/modules/webui/answer-api.js +0 -29
- package/dist/modules/webui/assets.js +0 -50
- package/dist/modules/webui/body.js +0 -21
- package/dist/modules/webui/commands-settings.js +0 -209
- package/dist/modules/webui/commands-shared.js +0 -60
- package/dist/modules/webui/commands.js +0 -174
- package/dist/modules/webui/config-api.js +0 -134
- package/dist/modules/webui/file-api.js +0 -202
- package/dist/modules/webui/forward.js +0 -159
- package/dist/modules/webui/history-api.js +0 -112
- package/dist/modules/webui/host-state.js +0 -60
- package/dist/modules/webui/i18n-api.js +0 -9
- package/dist/modules/webui/limits.js +0 -6
- package/dist/modules/webui/log-forward.js +0 -20
- package/dist/modules/webui/memory-commands.js +0 -64
- package/dist/modules/webui/model-cache.js +0 -18
- package/dist/modules/webui/module.js +0 -148
- package/dist/modules/webui/persist.js +0 -24
- package/dist/modules/webui/prompt-io.js +0 -97
- package/dist/modules/webui/providers-api.js +0 -337
- package/dist/modules/webui/providers-view.js +0 -56
- package/dist/modules/webui/reasoning-view.js +0 -15
- package/dist/modules/webui/run-agent.js +0 -81
- package/dist/modules/webui/server.js +0 -284
- package/dist/modules/webui/sessions-api.js +0 -178
- package/dist/modules/webui/settings-api.js +0 -561
- package/dist/modules/webui/setup-api.js +0 -201
- package/dist/modules/webui/state.js +0 -74
- package/dist/modules/webui/util.js +0 -261
- package/dist/output/bus.js +0 -37
- package/dist/output/channel.js +0 -285
- package/dist/output/format.js +0 -15
- package/dist/output/index.js +0 -8
- package/dist/output/json-sink.js +0 -24
- package/dist/output/machine.js +0 -9
- package/dist/output/session-sink.js +0 -27
- package/dist/output/types.js +0 -1
- package/dist/tools/approve.js +0 -41
- package/dist/tools/attach-image.js +0 -102
- package/dist/tools/auto-fixer.js +0 -180
- package/dist/tools/auto-tags.js +0 -83
- package/dist/tools/bash.js +0 -649
- package/dist/tools/browser.js +0 -160
- package/dist/tools/chunk-query.js +0 -112
- package/dist/tools/create-dir.js +0 -60
- package/dist/tools/delete-file.js +0 -67
- package/dist/tools/download-file.js +0 -142
- package/dist/tools/edit-file.js +0 -136
- package/dist/tools/enable-tools.js +0 -59
- package/dist/tools/executor.js +0 -304
- package/dist/tools/file-info.js +0 -49
- package/dist/tools/filter-tools.js +0 -17
- package/dist/tools/glob-tool.js +0 -37
- package/dist/tools/grep-tool.js +0 -142
- package/dist/tools/hidden-tools-block.js +0 -37
- package/dist/tools/index.js +0 -88
- package/dist/tools/list-dir.js +0 -53
- package/dist/tools/load-skill.js +0 -51
- package/dist/tools/mcp-call.js +0 -80
- package/dist/tools/meet-done.js +0 -14
- package/dist/tools/move-file.js +0 -94
- package/dist/tools/path-utils.js +0 -108
- package/dist/tools/pipeline-run.js +0 -167
- package/dist/tools/preview.js +0 -2
- package/dist/tools/process-ids.js +0 -31
- package/dist/tools/process-kill.js +0 -33
- package/dist/tools/process-list.js +0 -38
- package/dist/tools/process-log.js +0 -49
- package/dist/tools/process-wait.js +0 -63
- package/dist/tools/prompt-io.js +0 -29
- package/dist/tools/question.js +0 -288
- package/dist/tools/read-file.js +0 -200
- package/dist/tools/recall.js +0 -124
- package/dist/tools/registry.js +0 -48
- package/dist/tools/remember.js +0 -72
- package/dist/tools/scope-check.js +0 -32
- package/dist/tools/scope-request.js +0 -96
- package/dist/tools/search-history.js +0 -88
- package/dist/tools/session-info.js +0 -46
- package/dist/tools/set-thinking.js +0 -75
- package/dist/tools/subagent.js +0 -257
- package/dist/tools/syntax-validator.js +0 -379
- package/dist/tools/types.js +0 -1
- package/dist/tools/user-input.js +0 -134
- package/dist/tools/web-browse.js +0 -93
- package/dist/tools/web-fetch.js +0 -108
- package/dist/tools/web-search.js +0 -107
- package/dist/tools/write-file.js +0 -128
- package/dist/ui/action-log.js +0 -13
- package/dist/ui/box.js +0 -78
- package/dist/ui/colors.js +0 -6
- package/dist/ui/diff.js +0 -189
- package/dist/ui/index.js +0 -7
- package/dist/ui/line-editor.js +0 -1083
- package/dist/ui/line-math.js +0 -98
- package/dist/ui/md-formatter.js +0 -322
- package/dist/ui/output.js +0 -19
- package/dist/ui/plan-view.js +0 -109
- package/dist/ui/renderer.js +0 -589
- package/dist/ui/spinner.js +0 -91
- package/dist/ui/table.js +0 -142
- package/dist/ui/theme.js +0 -143
- package/dist/utils/child-run.js +0 -20
- package/dist/utils/error.js +0 -4
- package/dist/utils/index.js +0 -6
- package/dist/utils/retry.js +0 -17
- package/dist/utils/sleep.js +0 -23
- package/dist/utils/truncate.js +0 -9
package/dist/cli/run-result.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { t } from "../i18n/index";
|
|
2
|
-
import { pc } from "../ui/colors";
|
|
3
|
-
import { formatCost } from "../modules/pricing/prices";
|
|
4
|
-
import { formatCacheLine } from "./cache-line";
|
|
5
|
-
import { getDefaultChannel } from "../output";
|
|
6
|
-
// Печать результата one-shot прогона: стоимость/токены/кеш, код выхода.
|
|
7
|
-
/**
|
|
8
|
-
* Рендерит one-shot AgentResult в терминал (не-JSON режим) и возвращает код выхода.
|
|
9
|
-
*
|
|
10
|
-
* При провале печатается только ошибка. `text` модели (последнее *принятое*
|
|
11
|
-
* сообщение — возможно, протухшее после ошибки аудита/галлюцинаций) уже
|
|
12
|
-
* стримлено живьём во время прогона: допечатка здесь ложно намекнула бы на успех.
|
|
13
|
-
*/
|
|
14
|
-
export function printRunResult(result, flush, channel = getDefaultChannel()) {
|
|
15
|
-
flush();
|
|
16
|
-
if (result.success) {
|
|
17
|
-
if (result.totalCost !== undefined && result.totalCost > 0) {
|
|
18
|
-
channel.writeLine(pc.dim(`${t("repl.cost", { cost: formatCost(result.totalCost) })}`));
|
|
19
|
-
if (result.costBreakdown && result.costBreakdown.length > 1) {
|
|
20
|
-
const parts = result.costBreakdown.map((e) => `${e.provider} ${formatCost(e.cost)}`);
|
|
21
|
-
channel.writeLine(pc.dim(` ${t("repl.cost_breakdown", { breakdown: parts.join(", ") })}`));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else if (result.totalTokens !== undefined && result.totalTokens > 0) {
|
|
25
|
-
channel.writeLine(pc.dim(`${t("repl.tokens", { tokens: result.totalTokens })}`));
|
|
26
|
-
}
|
|
27
|
-
const cacheLine = formatCacheLine(result.cache);
|
|
28
|
-
if (cacheLine) {
|
|
29
|
-
channel.writeLine(pc.dim(` ${cacheLine}`));
|
|
30
|
-
}
|
|
31
|
-
if (!result.text) {
|
|
32
|
-
channel.writeLine(pc.yellow(t("cli.no_output")));
|
|
33
|
-
}
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
channel.writeLine(`${t("error.prefix")}${result.error}`, "stderr");
|
|
37
|
-
return 1;
|
|
38
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "../core/bootstrap";
|
|
2
|
-
import { saveConfig } from "../config/config";
|
|
3
|
-
import { dirname } from "path";
|
|
4
|
-
import { SECURITY_POLICIES, applySecurityPolicy, getSecurityPolicy, } from "../modules/security/security-policies";
|
|
5
|
-
import { globalAuditNotifier } from "../modules/security/audit-notifier";
|
|
6
|
-
import { DEFAULT_SECURITY_CONFIG } from "../config/security";
|
|
7
|
-
import { t } from "../i18n/index";
|
|
8
|
-
import { getDefaultChannel } from "../output";
|
|
9
|
-
import { globalConfigFile } from "../config/paths";
|
|
10
|
-
/**
|
|
11
|
-
* Переключает шифрование файлов сессии на месте: флипает `enabled` (и оба
|
|
12
|
-
* пофайловых флага), СОХРАНЯЯ уже лежащие в конфиге юзер-поля (keyPath и др.).
|
|
13
|
-
* Мутирует переданный объект security.
|
|
14
|
-
*/
|
|
15
|
-
export function toggleSessionEncryption(security, enabled) {
|
|
16
|
-
const enc = (security.sessionEncryption ?? {});
|
|
17
|
-
enc.enabled = enabled;
|
|
18
|
-
enc.encryptHistory = enabled;
|
|
19
|
-
enc.encryptSessionLog = enabled;
|
|
20
|
-
security.sessionEncryption = enc;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Переключает аудит-нотификации на месте: флипает только `enabled`, сохраняя
|
|
24
|
-
* юзерские webhookUrl / filePath / minSeverity / eventTypes.
|
|
25
|
-
*/
|
|
26
|
-
export function toggleAuditNotifier(security, enabled) {
|
|
27
|
-
const notifier = (security.auditNotifier ?? {});
|
|
28
|
-
notifier.enabled = enabled;
|
|
29
|
-
security.auditNotifier = notifier;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Создаёт субкоманду security.
|
|
33
|
-
*/
|
|
34
|
-
export function createSecurityCommand(program) {
|
|
35
|
-
const securityCmd = program.command("security").description(t("cli.security.description"));
|
|
36
|
-
// security status — текущий конфиг безопасности.
|
|
37
|
-
securityCmd
|
|
38
|
-
.command("status")
|
|
39
|
-
.description(t("cli.security.status"))
|
|
40
|
-
.action(async () => {
|
|
41
|
-
const { config } = await bootstrap();
|
|
42
|
-
const security = config.security ?? DEFAULT_SECURITY_CONFIG;
|
|
43
|
-
const bash = security.bash || {};
|
|
44
|
-
const paths = security.paths || {};
|
|
45
|
-
const network = security.network || {};
|
|
46
|
-
const contentScan = security.contentScan || {};
|
|
47
|
-
const rateLimits = security.rateLimits || {};
|
|
48
|
-
const sessionEncryption = security.sessionEncryption || {};
|
|
49
|
-
const auditNotifier = security.auditNotifier || {};
|
|
50
|
-
getDefaultChannel().writeLine(t("cli.security.current_policy"));
|
|
51
|
-
getDefaultChannel().writeLine(` ${t("cli.security.bash_enabled")}: ${bash.blacklist?.length > 0 ? t("cli.yes") : t("cli.no")}`);
|
|
52
|
-
getDefaultChannel().writeLine(` ${t("cli.security.path_validation")}: ${paths.enabled ? t("cli.yes") : t("cli.no")}`);
|
|
53
|
-
getDefaultChannel().writeLine(` ${t("cli.security.network_validation")}: ${network.deniedDomains?.length > 0 || network.allowedDomains?.length > 0 ? t("cli.yes") : t("cli.no")}`);
|
|
54
|
-
getDefaultChannel().writeLine(` ${t("cli.security.content_scanning")}: ${contentScan.enabled ? t("cli.yes") : t("cli.no")}`);
|
|
55
|
-
getDefaultChannel().writeLine(` ${t("cli.security.max_recursion")}: ${security.maxRecursionDepth ?? 3}`);
|
|
56
|
-
getDefaultChannel().writeLine(` ${t("cli.security.max_file_ops")}: ${security.maxFileOperations ?? 100}`);
|
|
57
|
-
getDefaultChannel().writeLine(` ${t("cli.security.rate_limit")}: ${rateLimits.maxRequestsPerMinute ?? 60}/min`);
|
|
58
|
-
getDefaultChannel().writeLine(` ${t("cli.security.session_encryption")}: ${sessionEncryption.enabled ? t("cli.yes") : t("cli.no")}`);
|
|
59
|
-
getDefaultChannel().writeLine(` ${t("cli.security.audit_notifier")}: ${auditNotifier.enabled ? t("cli.yes") : t("cli.no")}`);
|
|
60
|
-
});
|
|
61
|
-
// security policies — список политик.
|
|
62
|
-
securityCmd
|
|
63
|
-
.command("policies")
|
|
64
|
-
.description(t("cli.security.policies"))
|
|
65
|
-
.action(async () => {
|
|
66
|
-
getDefaultChannel().writeLine(t("cli.security.available_policies"));
|
|
67
|
-
getDefaultChannel().writeLine("");
|
|
68
|
-
for (const [preset, policy] of Object.entries(SECURITY_POLICIES)) {
|
|
69
|
-
if (preset === "custom")
|
|
70
|
-
continue;
|
|
71
|
-
const marker = " ";
|
|
72
|
-
getDefaultChannel().writeLine(` ${marker}${preset.padEnd(12)} ${policy.name}`);
|
|
73
|
-
getDefaultChannel().writeLine(` ${policy.description}`);
|
|
74
|
-
getDefaultChannel().writeLine(` ${t("cli.security.recommended_for")}: ${policy.recommendedFor.join(", ")}`);
|
|
75
|
-
getDefaultChannel().writeLine("");
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
// security set-policy — применить политику.
|
|
79
|
-
securityCmd
|
|
80
|
-
.command("set-policy")
|
|
81
|
-
.argument("<preset>", t("cli.security.preset"))
|
|
82
|
-
.description(t("cli.security.set_policy"))
|
|
83
|
-
.action(async (preset) => {
|
|
84
|
-
const configPath = globalConfigFile();
|
|
85
|
-
const { config: appConfig } = await bootstrap();
|
|
86
|
-
const validPresets = ["strict", "balanced", "permissive"];
|
|
87
|
-
if (!validPresets.includes(preset)) {
|
|
88
|
-
getDefaultChannel().writeLine(t("cli.security.invalid_preset", { presets: validPresets.join(", ") }));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const policy = getSecurityPolicy(preset);
|
|
92
|
-
const newSecurityConfig = applySecurityPolicy(preset);
|
|
93
|
-
// Мерж с существующим конфигом.
|
|
94
|
-
appConfig.security = newSecurityConfig;
|
|
95
|
-
saveConfig(appConfig, configPath, dirname(configPath));
|
|
96
|
-
getDefaultChannel().writeLine(t("cli.security.policy_applied", { name: policy.name }));
|
|
97
|
-
getDefaultChannel().writeLine(t("cli.security.policy_description", { description: policy.description }));
|
|
98
|
-
});
|
|
99
|
-
// security enable-encryption — включить шифрование файлов сессии.
|
|
100
|
-
securityCmd
|
|
101
|
-
.command("enable-encryption")
|
|
102
|
-
.description(t("cli.security.enable_encryption"))
|
|
103
|
-
.action(async () => {
|
|
104
|
-
const configPath = globalConfigFile();
|
|
105
|
-
const { config: appConfig } = await bootstrap();
|
|
106
|
-
if (!appConfig.security)
|
|
107
|
-
appConfig.security = structuredClone(DEFAULT_SECURITY_CONFIG);
|
|
108
|
-
const security = appConfig.security;
|
|
109
|
-
toggleSessionEncryption(security, true);
|
|
110
|
-
saveConfig(appConfig, configPath, dirname(configPath));
|
|
111
|
-
getDefaultChannel().writeLine(t("cli.security.encryption_enabled"));
|
|
112
|
-
});
|
|
113
|
-
// security disable-encryption — выключить шифрование файлов сессии.
|
|
114
|
-
securityCmd
|
|
115
|
-
.command("disable-encryption")
|
|
116
|
-
.description(t("cli.security.disable_encryption"))
|
|
117
|
-
.action(async () => {
|
|
118
|
-
const configPath = globalConfigFile();
|
|
119
|
-
const { config: appConfig } = await bootstrap();
|
|
120
|
-
if (!appConfig.security)
|
|
121
|
-
appConfig.security = structuredClone(DEFAULT_SECURITY_CONFIG);
|
|
122
|
-
const security = appConfig.security;
|
|
123
|
-
toggleSessionEncryption(security, false);
|
|
124
|
-
saveConfig(appConfig, configPath, dirname(configPath));
|
|
125
|
-
getDefaultChannel().writeLine(t("cli.security.encryption_disabled"));
|
|
126
|
-
});
|
|
127
|
-
// security enable-audit — включить аудит-нотификации.
|
|
128
|
-
securityCmd
|
|
129
|
-
.command("enable-audit")
|
|
130
|
-
.description(t("cli.security.enable_audit"))
|
|
131
|
-
.action(async () => {
|
|
132
|
-
const configPath = globalConfigFile();
|
|
133
|
-
const { config: appConfig } = await bootstrap();
|
|
134
|
-
if (!appConfig.security)
|
|
135
|
-
appConfig.security = structuredClone(DEFAULT_SECURITY_CONFIG);
|
|
136
|
-
const security = appConfig.security;
|
|
137
|
-
toggleAuditNotifier(security, true);
|
|
138
|
-
saveConfig(appConfig, configPath, dirname(configPath));
|
|
139
|
-
getDefaultChannel().writeLine(t("cli.security.audit_enabled"));
|
|
140
|
-
});
|
|
141
|
-
// security disable-audit — выключить аудит-нотификации.
|
|
142
|
-
securityCmd
|
|
143
|
-
.command("disable-audit")
|
|
144
|
-
.description(t("cli.security.disable_audit"))
|
|
145
|
-
.action(async () => {
|
|
146
|
-
const configPath = globalConfigFile();
|
|
147
|
-
const { config: appConfig } = await bootstrap();
|
|
148
|
-
if (!appConfig.security)
|
|
149
|
-
appConfig.security = structuredClone(DEFAULT_SECURITY_CONFIG);
|
|
150
|
-
const security = appConfig.security;
|
|
151
|
-
toggleAuditNotifier(security, false);
|
|
152
|
-
saveConfig(appConfig, configPath, dirname(configPath));
|
|
153
|
-
getDefaultChannel().writeLine(t("cli.security.audit_disabled"));
|
|
154
|
-
});
|
|
155
|
-
// security audit-stats — статистика аудит-нотификаций.
|
|
156
|
-
securityCmd
|
|
157
|
-
.command("audit-stats")
|
|
158
|
-
.description(t("cli.security.audit_stats"))
|
|
159
|
-
.action(async () => {
|
|
160
|
-
const stats = globalAuditNotifier.getStats();
|
|
161
|
-
getDefaultChannel().writeLine(t("cli.security.audit_stats_title"));
|
|
162
|
-
getDefaultChannel().writeLine(` ${t("cli.security.total_notifications")}: ${stats.total}`);
|
|
163
|
-
getDefaultChannel().writeLine("");
|
|
164
|
-
getDefaultChannel().writeLine(t("cli.security.by_severity"));
|
|
165
|
-
getDefaultChannel().writeLine(` ${t("cli.security.low")}: ${stats.bySeverity.low}`);
|
|
166
|
-
getDefaultChannel().writeLine(` ${t("cli.security.medium")}: ${stats.bySeverity.medium}`);
|
|
167
|
-
getDefaultChannel().writeLine(` ${t("cli.security.high")}: ${stats.bySeverity.high}`);
|
|
168
|
-
getDefaultChannel().writeLine(` ${t("cli.security.critical")}: ${stats.bySeverity.critical}`);
|
|
169
|
-
getDefaultChannel().writeLine("");
|
|
170
|
-
getDefaultChannel().writeLine(t("cli.security.by_type"));
|
|
171
|
-
for (const [type, count] of Object.entries(stats.byType)) {
|
|
172
|
-
if (count > 0) {
|
|
173
|
-
getDefaultChannel().writeLine(` ${type}: ${count}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
package/dist/cli/setup-order.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Шим совместимости: логика записи конфига визарда живёт в
|
|
3
|
-
* `src/modules/setup/apply.ts`, чтобы её делил браузерный визард. Реэкспорт
|
|
4
|
-
* отсюда сохраняет терминальный путь импорта (и его тесты).
|
|
5
|
-
*/
|
|
6
|
-
export { applyAnswersToConfig, SECURITY_BASH_BLOCKLIST } from "../modules/setup/apply";
|
package/dist/cli/setup-prompt.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/** Cooked-режимный промпт визарда: эхо/правка на терминале, мы копим до newline. */
|
|
2
|
-
export class SetupPrompt {
|
|
3
|
-
input;
|
|
4
|
-
output;
|
|
5
|
-
pending = null;
|
|
6
|
-
buffer = "";
|
|
7
|
-
closed = false;
|
|
8
|
-
onData;
|
|
9
|
-
constructor(input = process.stdin, output = process.stdout) {
|
|
10
|
-
this.input = input;
|
|
11
|
-
this.output = output;
|
|
12
|
-
// Cooked-режим: правка строки и эхо — на консоли.
|
|
13
|
-
if (typeof this.input.setRawMode === "function")
|
|
14
|
-
this.input.setRawMode(false);
|
|
15
|
-
this.onData = (buf) => this.consume(buf.toString("utf-8"));
|
|
16
|
-
this.input.on("data", this.onData);
|
|
17
|
-
this.input.resume?.();
|
|
18
|
-
}
|
|
19
|
-
question(query, cb) {
|
|
20
|
-
if (this.closed)
|
|
21
|
-
return;
|
|
22
|
-
this.buffer = "";
|
|
23
|
-
this.pending = cb;
|
|
24
|
-
this.output.write(query);
|
|
25
|
-
}
|
|
26
|
-
close() {
|
|
27
|
-
if (this.closed)
|
|
28
|
-
return;
|
|
29
|
-
this.closed = true;
|
|
30
|
-
this.pending = null;
|
|
31
|
-
this.input.removeListener("data", this.onData);
|
|
32
|
-
this.input.pause?.();
|
|
33
|
-
}
|
|
34
|
-
consume(text) {
|
|
35
|
-
if (!this.pending || this.closed)
|
|
36
|
-
return;
|
|
37
|
-
this.buffer += text;
|
|
38
|
-
const idx = this.buffer.search(/[\r\n]/);
|
|
39
|
-
if (idx === -1)
|
|
40
|
-
return;
|
|
41
|
-
const answer = this.buffer.slice(0, idx);
|
|
42
|
-
this.buffer = "";
|
|
43
|
-
const cb = this.pending;
|
|
44
|
-
this.pending = null;
|
|
45
|
-
// TTY сам эхует Enter переводом строки; дописываем его только пайпам.
|
|
46
|
-
if (!this.output.isTTY)
|
|
47
|
-
this.output.write("\n");
|
|
48
|
-
cb(answer);
|
|
49
|
-
}
|
|
50
|
-
}
|
package/dist/cli/setup.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// Визард первого запуска: язык → провайдер → ключ → модель → контекст → security.
|
|
2
|
-
import { pc } from "../ui/colors";
|
|
3
|
-
import { t, setLocale } from "../i18n/index";
|
|
4
|
-
import { Spinner } from "../ui/spinner";
|
|
5
|
-
import { BUILTIN_PROVIDERS, HOSTED_BASE_URLS } from "../modules/providers/presets";
|
|
6
|
-
import { box } from "../ui/box";
|
|
7
|
-
import { getDefaultChannel } from "../output";
|
|
8
|
-
import { SETUP_DEFAULTS, SETUP_LANGUAGES, } from "../modules/setup/answers";
|
|
9
|
-
import { fetchProviderModels, scanLocalServers, testProviderChat, } from "../modules/setup/discovery";
|
|
10
|
-
import { SetupPrompt } from "./setup-prompt";
|
|
11
|
-
async function withSpinner(message, fn) {
|
|
12
|
-
const spinner = new Spinner({ channel: getDefaultChannel() });
|
|
13
|
-
spinner.start(message);
|
|
14
|
-
try {
|
|
15
|
-
return await fn();
|
|
16
|
-
}
|
|
17
|
-
finally {
|
|
18
|
-
spinner.stop();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/** Рендерит нумерованный список в рамке. */
|
|
22
|
-
function menuList(items) {
|
|
23
|
-
const lines = items.map((it, i) => ` ${pc.cyan(`[${i + 1}]`)} ${it.label}${it.url ? ` ${pc.dim(it.url)}` : ""}`);
|
|
24
|
-
for (const l of box(lines, { width: 72 }))
|
|
25
|
-
getDefaultChannel().writeLine(l);
|
|
26
|
-
}
|
|
27
|
-
/** Спрашивает строку; пустой ответ — defaultValue. */
|
|
28
|
-
function ask(rl, question, defaultValue) {
|
|
29
|
-
return new Promise((resolve) => {
|
|
30
|
-
const prompt = defaultValue ? `${question} [${defaultValue}]: ` : `${question}: `;
|
|
31
|
-
rl.question(prompt, (answer) => {
|
|
32
|
-
resolve(answer.trim() || defaultValue || "");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/** Парсит положительный int-ответ, иначе — дефолт промпта. */
|
|
37
|
-
function askInt(rl, question, defaultValue) {
|
|
38
|
-
return ask(rl, question, String(defaultValue)).then((raw) => {
|
|
39
|
-
const n = parseInt(raw, 10);
|
|
40
|
-
return Number.isFinite(n) && n > 0 ? n : defaultValue;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
const PROVIDER_TYPES = BUILTIN_PROVIDERS.map((spec) => ({
|
|
44
|
-
value: spec.type,
|
|
45
|
-
label: spec.label,
|
|
46
|
-
}));
|
|
47
|
-
/** Прогоняет визард первого запуска (язык → провайдер → … → review). Возвращает ответы. */
|
|
48
|
-
export async function runSetup(externalRl) {
|
|
49
|
-
getDefaultChannel().writeLine(t("setup.title"));
|
|
50
|
-
const rl = externalRl ?? new SetupPrompt();
|
|
51
|
-
const ownRl = !externalRl;
|
|
52
|
-
getDefaultChannel().writeLine(t("setup.language"));
|
|
53
|
-
menuList([...SETUP_LANGUAGES]);
|
|
54
|
-
const languageChoice = await ask(rl, t("setup.select_language_num", { max: SETUP_LANGUAGES.length }), "1");
|
|
55
|
-
const typedLang = languageChoice.trim().toLowerCase();
|
|
56
|
-
const byCode = SETUP_LANGUAGES.find((l) => l.value === typedLang);
|
|
57
|
-
const locale = byCode
|
|
58
|
-
? byCode.value
|
|
59
|
-
: SETUP_LANGUAGES[Math.max(0, Math.min(SETUP_LANGUAGES.length - 1, (parseInt(languageChoice, 10) || 1) - 1))].value;
|
|
60
|
-
setLocale(locale);
|
|
61
|
-
getDefaultChannel().writeLine(t("setup.select_provider"));
|
|
62
|
-
menuList(PROVIDER_TYPES);
|
|
63
|
-
const providerChoice = await ask(rl, t("setup.select_provider_num", { max: PROVIDER_TYPES.length }), "1");
|
|
64
|
-
const providerIdx = Math.max(0, Math.min(PROVIDER_TYPES.length - 1, (parseInt(providerChoice, 10) || 1) - 1));
|
|
65
|
-
const provider = PROVIDER_TYPES[providerIdx].value;
|
|
66
|
-
let apiBase = "";
|
|
67
|
-
if (provider === "openai-compat" || provider === "lmstudio") {
|
|
68
|
-
const found = await withSpinner(t("setup.scanning_spinner"), async () => scanLocalServers());
|
|
69
|
-
if (found.length > 0) {
|
|
70
|
-
getDefaultChannel().writeLine(t("setup.found_servers", { count: found.length }));
|
|
71
|
-
menuList([
|
|
72
|
-
...found.map((f) => ({ label: f.label, url: f.url })),
|
|
73
|
-
{ label: t("setup.custom_url") },
|
|
74
|
-
]);
|
|
75
|
-
const choice = await ask(rl, t("setup.select_server", { max: found.length + 1 }), "1");
|
|
76
|
-
const idx = (parseInt(choice, 10) || 1) - 1;
|
|
77
|
-
if (idx >= found.length) {
|
|
78
|
-
apiBase = await ask(rl, t("setup.api_base"), "http://localhost:1234/v1");
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
apiBase = found[Math.max(0, Math.min(found.length - 1, idx))].url;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
getDefaultChannel().writeLine(t("setup.no_servers"));
|
|
86
|
-
apiBase = await ask(rl, t("setup.api_base"), "http://localhost:1234/v1");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
apiBase = HOSTED_BASE_URLS[provider] ?? "";
|
|
91
|
-
}
|
|
92
|
-
const defaultKey = provider === "openai-compat" || provider === "lmstudio" ? "not-needed" : "";
|
|
93
|
-
const apiKey = await ask(rl, t("setup.api_key"), defaultKey);
|
|
94
|
-
const models = await withSpinner(t("setup.fetching_spinner"), () => fetchProviderModels(apiBase, apiKey));
|
|
95
|
-
let model = "";
|
|
96
|
-
if (models.length > 0) {
|
|
97
|
-
getDefaultChannel().writeLine(t("setup.available_models"));
|
|
98
|
-
menuList(models.slice(0, 10).map((m) => ({ label: m })));
|
|
99
|
-
const choice = await ask(rl, t("setup.select_model", { max: Math.min(models.length, 10) }), "1");
|
|
100
|
-
const idx = Math.max(0, Math.min(models.length - 1, (parseInt(choice, 10) || 1) - 1));
|
|
101
|
-
model = models[idx];
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
model = await ask(rl, t("setup.model_name"), "qwen/qwen3.5-9b");
|
|
105
|
-
}
|
|
106
|
-
const connected = await withSpinner(t("setup.testing_spinner", { model }), () => testProviderChat(apiBase, apiKey, model));
|
|
107
|
-
if (connected) {
|
|
108
|
-
getDefaultChannel().writeLine(pc.green(t("setup.ok")));
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
getDefaultChannel().writeLine(pc.yellow(t("setup.warning")));
|
|
112
|
-
}
|
|
113
|
-
getDefaultChannel().writeLine(t("setup.agent_settings"));
|
|
114
|
-
const contextWindow = await askInt(rl, t("setup.context_window"), SETUP_DEFAULTS.contextWindow);
|
|
115
|
-
const maxIterations = await askInt(rl, t("setup.max_iters"), SETUP_DEFAULTS.maxToolIterations);
|
|
116
|
-
// Security settings
|
|
117
|
-
getDefaultChannel().writeLine(t("setup.security_header"));
|
|
118
|
-
getDefaultChannel().writeLine(pc.dim(t("setup.security_status_on")));
|
|
119
|
-
const configureSecurity = await ask(rl, t("setup.security_configure"), "n");
|
|
120
|
-
let securityBashBlock = false;
|
|
121
|
-
let securityFlagsBlock = false;
|
|
122
|
-
let securityPathsRestrict = false;
|
|
123
|
-
if (configureSecurity.toLowerCase() === "y" || configureSecurity.toLowerCase() === "yes") {
|
|
124
|
-
securityBashBlock = (await ask(rl, t("setup.security_bash_block"), "n")).toLowerCase() === "y";
|
|
125
|
-
securityFlagsBlock =
|
|
126
|
-
(await ask(rl, t("setup.security_flags_block"), "n")).toLowerCase() === "y";
|
|
127
|
-
const pathsAnswer = (await ask(rl, t("setup.security_paths_restrict"), "Y")).toLowerCase();
|
|
128
|
-
securityPathsRestrict = pathsAnswer !== "n" && pathsAnswer !== "no";
|
|
129
|
-
}
|
|
130
|
-
if (ownRl) {
|
|
131
|
-
// Деттачим ридер промпта и ставим stdin на паузу, чтобы raw-режимный
|
|
132
|
-
// LineEditor REPL захватил его чисто (без leftover readline/raw-состояния).
|
|
133
|
-
rl.close();
|
|
134
|
-
}
|
|
135
|
-
const answers = {
|
|
136
|
-
provider,
|
|
137
|
-
apiBase,
|
|
138
|
-
apiKey: apiKey || "not-needed",
|
|
139
|
-
model,
|
|
140
|
-
contextWindow,
|
|
141
|
-
maxToolIterations: maxIterations,
|
|
142
|
-
locale,
|
|
143
|
-
securityBashBlock,
|
|
144
|
-
securityFlagsBlock,
|
|
145
|
-
securityPathsRestrict,
|
|
146
|
-
};
|
|
147
|
-
getDefaultChannel().writeLine(pc.green(pc.bold(t("setup.complete"))));
|
|
148
|
-
const summary = [
|
|
149
|
-
[t("setup.provider_type"), provider],
|
|
150
|
-
[t("setup.model_name"), model],
|
|
151
|
-
[t("setup.api_base"), apiBase],
|
|
152
|
-
[t("setup.api_key"), apiKey || "not-needed"],
|
|
153
|
-
[t("setup.context_window"), String(contextWindow)],
|
|
154
|
-
[t("setup.max_iters"), String(maxIterations)],
|
|
155
|
-
[t("setup.ui_lang"), locale],
|
|
156
|
-
];
|
|
157
|
-
for (const [label, value] of summary) {
|
|
158
|
-
getDefaultChannel().writeLine(` ${pc.yellow(label.trim())}: ${pc.white(value)}`);
|
|
159
|
-
}
|
|
160
|
-
return answers;
|
|
161
|
-
}
|
package/dist/cli/web-command.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Точка входа `mma web`: bootstrap, старт браузерного UI, жизнь процесса до
|
|
3
|
-
* SIGINT/SIGTERM, затем чистое завершение.
|
|
4
|
-
*/
|
|
5
|
-
import { existsSync } from "node:fs";
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
import { bootstrap } from "../core/bootstrap";
|
|
8
|
-
import { agentsMdPaths } from "../core/bootstrap";
|
|
9
|
-
import { getDefaultChannel } from "../output";
|
|
10
|
-
import { t } from "../i18n/index";
|
|
11
|
-
import { pc } from "../ui/colors";
|
|
12
|
-
import { startWebUi } from "../modules/webui/module";
|
|
13
|
-
import { tryOpenBrowser } from "../modules/webui/server";
|
|
14
|
-
import { globalMmaDir } from "../config/paths";
|
|
15
|
-
import { MMA_ENV } from "../config/env";
|
|
16
|
-
/**
|
|
17
|
-
* Парсит и валидирует флаг `--port`. `undefined`/пусто → `undefined` (рандомный
|
|
18
|
-
* порт). Нечисловые и вне диапазона бросают throw, а не молча откатываются на
|
|
19
|
-
* рандом: `--port abc` не должен маскироваться под рабочий bind.
|
|
20
|
-
*/
|
|
21
|
-
export function parsePort(raw) {
|
|
22
|
-
if (raw === undefined || raw.trim() === "")
|
|
23
|
-
return undefined;
|
|
24
|
-
const n = Number(raw);
|
|
25
|
-
if (!Number.isInteger(n) || n < 1 || n > 65535) {
|
|
26
|
-
throw new Error(t("cli.web_invalid_port", { port: raw }));
|
|
27
|
-
}
|
|
28
|
-
return n;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Аргументы bootstrap для `runWeb`. Вынесены, чтобы форвардинг CLI-флагов
|
|
32
|
-
* (особенно `--no-agents-md`) был юнит-тестируем без подъёма настоящего агента:
|
|
33
|
-
* Bun-моки модулей процесс-глобальны, спай на `bootstrap` потёк бы.
|
|
34
|
-
*/
|
|
35
|
-
export function webBootstrapArgs(opts) {
|
|
36
|
-
return [undefined, opts.projectDir, opts.noAgentsMd, true];
|
|
37
|
-
}
|
|
38
|
-
/** Запуск веб-режима: bootstrap → старт UI → ожидание SIGINT/SIGTERM. */
|
|
39
|
-
export async function runWeb(opts) {
|
|
40
|
-
// Транспорт читает их на старте (server/state): у порта нет поля конфига,
|
|
41
|
-
// так что CLI-флаг маппится на env, которую сервер уже уважает.
|
|
42
|
-
if (opts.port !== undefined)
|
|
43
|
-
process.env[MMA_ENV.WEBUI_PORT] = String(opts.port);
|
|
44
|
-
if (opts.host)
|
|
45
|
-
process.env[MMA_ENV.WEBUI_HOST] = opts.host;
|
|
46
|
-
if (opts.token)
|
|
47
|
-
process.env[MMA_ENV.WEBUI_TOKEN] = opts.token;
|
|
48
|
-
if (opts.noOpen)
|
|
49
|
-
process.env[MMA_ENV.WEBUI_OPEN] = "0";
|
|
50
|
-
const mmaDir = globalMmaDir();
|
|
51
|
-
const { hasDomainFiles } = await import("../config/domains");
|
|
52
|
-
const virgin = !existsSync(join(mmaDir, "config.json")) && !hasDomainFiles(mmaDir);
|
|
53
|
-
// exitOnComplete=true: в веб-режиме интерактивный промпт stdin не владеет.
|
|
54
|
-
const { agent, config, sessionManager, execModule, configDir, baseDir, noAgentsMd, indexerModule, memoryStore, skillsModule, pluginManager, toolRegistry, toolCtx, contextProbe, } = await bootstrap(...webBootstrapArgs(opts));
|
|
55
|
-
if (virgin) {
|
|
56
|
-
getDefaultChannel().writeLine(pc.yellow(` ${t("cli.web_setup_required")}`), "stderr");
|
|
57
|
-
}
|
|
58
|
-
const web = await startWebUi({
|
|
59
|
-
agent,
|
|
60
|
-
config,
|
|
61
|
-
sessionManager,
|
|
62
|
-
execModule,
|
|
63
|
-
memory: memoryStore,
|
|
64
|
-
skills: skillsModule,
|
|
65
|
-
plugins: pluginManager,
|
|
66
|
-
toolRegistry,
|
|
67
|
-
toolCtx,
|
|
68
|
-
configDir,
|
|
69
|
-
baseDir,
|
|
70
|
-
agentsMd: {
|
|
71
|
-
disabled: noAgentsMd,
|
|
72
|
-
files: noAgentsMd ? [] : agentsMdPaths(baseDir, configDir).filter((p) => existsSync(p)),
|
|
73
|
-
},
|
|
74
|
-
indexer: indexerModule,
|
|
75
|
-
contextProbe,
|
|
76
|
-
host: opts.host,
|
|
77
|
-
token: opts.token,
|
|
78
|
-
setupRequired: virgin,
|
|
79
|
-
});
|
|
80
|
-
const url = await web.url;
|
|
81
|
-
// Всегда показываем резолвленный workspace: shell-нарезка `-d` пути (пробелы,
|
|
82
|
-
// хвостовой бэкслэш) может молча указать не туда, и эта строка — единственное
|
|
83
|
-
// место, где веб-режим его репортит (зеркало баннера REPL).
|
|
84
|
-
getDefaultChannel().writeLine(t("cli.web_started", { url, dir: baseDir }));
|
|
85
|
-
if (!opts.noOpen)
|
|
86
|
-
tryOpenBrowser(url);
|
|
87
|
-
await new Promise((resolve) => {
|
|
88
|
-
const shutdown = () => {
|
|
89
|
-
process.off("SIGINT", shutdown);
|
|
90
|
-
process.off("SIGTERM", shutdown);
|
|
91
|
-
web.stop();
|
|
92
|
-
agent.shutdown();
|
|
93
|
-
resolve();
|
|
94
|
-
};
|
|
95
|
-
process.on("SIGINT", shutdown);
|
|
96
|
-
process.on("SIGTERM", shutdown);
|
|
97
|
-
});
|
|
98
|
-
}
|
package/dist/config/budget.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { t } from "../i18n/index";
|
|
2
|
-
const MIN_SHARE = 0.05;
|
|
3
|
-
const MAX_SHARE = 0.9;
|
|
4
|
-
/** system + reserve обязаны оставить место под историю. */
|
|
5
|
-
const MAX_COMBINED = 0.95;
|
|
6
|
-
/** Режет окно контекста на части system / reserve / history. */
|
|
7
|
-
export function budgetBreakdown(config) {
|
|
8
|
-
const window = config.contextWindow;
|
|
9
|
-
const budget = config.contextBudget;
|
|
10
|
-
const system = Math.floor(window * budget.systemPrompt);
|
|
11
|
-
const reserve = Math.floor(window * budget.responseReserve);
|
|
12
|
-
const history = window - system - reserve;
|
|
13
|
-
return {
|
|
14
|
-
window,
|
|
15
|
-
system,
|
|
16
|
-
reserve,
|
|
17
|
-
history,
|
|
18
|
-
systemFraction: budget.systemPrompt,
|
|
19
|
-
reserveFraction: budget.responseReserve,
|
|
20
|
-
historyFraction: window > 0 ? history / window : 0,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Проверяет и применяет смену доли. При неуспехе возвращает причину
|
|
25
|
-
* (`"range"` или `"combined"`), при успехе — null. Причину локализует вызывающий.
|
|
26
|
-
*/
|
|
27
|
-
export function setBudgetShare(config, key, value) {
|
|
28
|
-
if (!Number.isFinite(value) || value < MIN_SHARE || value > MAX_SHARE)
|
|
29
|
-
return "range";
|
|
30
|
-
const budget = config.contextBudget;
|
|
31
|
-
const nextSystem = key === "system" ? value : budget.systemPrompt;
|
|
32
|
-
const nextReserve = key === "reserve" ? value : budget.responseReserve;
|
|
33
|
-
if (nextSystem + nextReserve > MAX_COMBINED)
|
|
34
|
-
return "combined";
|
|
35
|
-
budget[key === "system" ? "systemPrompt" : "responseReserve"] = value;
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
/** Локализованные строки разбивки бюджета (общие для `mma context` и `/context`). */
|
|
39
|
-
export function budgetBreakdownLines(config) {
|
|
40
|
-
const bd = budgetBreakdown(config);
|
|
41
|
-
const pct = (f) => Math.round(f * 100);
|
|
42
|
-
return [
|
|
43
|
-
t("cli.context_budget_header", { window: bd.window }),
|
|
44
|
-
t("cli.context_system_line", { tokens: bd.system, percent: pct(bd.systemFraction) }),
|
|
45
|
-
t("cli.context_reserve_line", { tokens: bd.reserve, percent: pct(bd.reserveFraction) }),
|
|
46
|
-
t("cli.context_history_line", { tokens: bd.history, percent: pct(bd.historyFraction) }),
|
|
47
|
-
];
|
|
48
|
-
}
|