micro-models-agent 2.16.1 → 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 +28 -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 -1250
- 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 -291
- package/dist/assets/setup.js +3 -816
- package/dist/assets/smd.js +29 -1665
- package/dist/assets/styles.css +1 -1598
- 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
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// Трекер плана: указатель текущего шага, статусы, прогресс-строка.
|
|
2
|
-
// Двигает указатель мимо уже settled (skipped/done) шагов, не мутируя их —
|
|
3
|
-
// перезапись "skipped" в "in_progress" дедлочит план (модель не возьмётся за
|
|
4
|
-
// шаг, который осознанно пропустила).
|
|
5
|
-
import { PlanCreator, getPlanProgress } from "./planner";
|
|
6
|
-
/** Трекер плана: указатель, статусы шагов, прогресс. */
|
|
7
|
-
export class PlanTracker {
|
|
8
|
-
plan;
|
|
9
|
-
currentStepIndex = 0;
|
|
10
|
-
constructor(plan) {
|
|
11
|
-
this.plan = plan;
|
|
12
|
-
}
|
|
13
|
-
/** План целиком. */
|
|
14
|
-
getPlan() {
|
|
15
|
-
return this.plan;
|
|
16
|
-
}
|
|
17
|
-
/** Индекс текущего шага. */
|
|
18
|
-
getCurrentStepIndex() {
|
|
19
|
-
return this.currentStepIndex;
|
|
20
|
-
}
|
|
21
|
-
/** Текущий шаг (по указателю). */
|
|
22
|
-
getCurrentStep() {
|
|
23
|
-
return this.plan.steps[this.currentStepIndex];
|
|
24
|
-
}
|
|
25
|
-
/** Шаг по id. */
|
|
26
|
-
getStep(id) {
|
|
27
|
-
return this.plan.steps.find((s) => s.id === id);
|
|
28
|
-
}
|
|
29
|
-
/** Ставит статус шагу. */
|
|
30
|
-
updateStepStatus(id, status) {
|
|
31
|
-
const step = this.getStep(id);
|
|
32
|
-
if (step)
|
|
33
|
-
step.status = status;
|
|
34
|
-
}
|
|
35
|
-
/** Добавляет заметку к шагу. */
|
|
36
|
-
addNote(id, note) {
|
|
37
|
-
const step = this.getStep(id);
|
|
38
|
-
if (step)
|
|
39
|
-
step.note = note;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Двигает указатель к следующему незакрытому шагу (мимо done/skipped без
|
|
43
|
-
* мутаций). False, если шагов не осталось.
|
|
44
|
-
*/
|
|
45
|
-
advance() {
|
|
46
|
-
let idx = this.currentStepIndex + 1;
|
|
47
|
-
while (idx < this.plan.steps.length &&
|
|
48
|
-
(this.plan.steps[idx].status === "skipped" || this.plan.steps[idx].status === "done")) {
|
|
49
|
-
idx++;
|
|
50
|
-
}
|
|
51
|
-
if (idx >= this.plan.steps.length)
|
|
52
|
-
return false;
|
|
53
|
-
this.currentStepIndex = idx;
|
|
54
|
-
if (this.plan.steps[idx].status === "pending") {
|
|
55
|
-
this.plan.steps[idx].status = "in_progress";
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Подтягивает указатель мимо done/skipped шагов без смены статусов.
|
|
61
|
-
* Синхронизирует currentStepIndex, когда модель маркит шаги через тул
|
|
62
|
-
* `plan update` (он advance() не зовёт). Без этого getCurrentStep() вечно
|
|
63
|
-
* стоит на первом шаге и stuck-детектор копит ложные "no progress".
|
|
64
|
-
*/
|
|
65
|
-
syncCurrentStep() {
|
|
66
|
-
while (this.currentStepIndex < this.plan.steps.length - 1 &&
|
|
67
|
-
(this.plan.steps[this.currentStepIndex].status === "done" ||
|
|
68
|
-
this.plan.steps[this.currentStepIndex].status === "skipped")) {
|
|
69
|
-
this.currentStepIndex++;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/** True, если все шаги done/skipped. */
|
|
73
|
-
isComplete() {
|
|
74
|
-
return this.plan.steps.every((s) => s.status === "done" || s.status === "skipped");
|
|
75
|
-
}
|
|
76
|
-
/** Строка прогресса: `[id] title settled/total (skipped) bar pct`. */
|
|
77
|
-
getProgressString() {
|
|
78
|
-
const p = getPlanProgress(this.plan);
|
|
79
|
-
const total = p.total;
|
|
80
|
-
const settled = p.settled;
|
|
81
|
-
const pct = total > 0 ? Math.round((settled / total) * 100) : 0;
|
|
82
|
-
const barWidth = 10;
|
|
83
|
-
const filled = Math.round((settled / total) * barWidth);
|
|
84
|
-
const bar = "█".repeat(filled) + "░".repeat(barWidth - filled);
|
|
85
|
-
const skippedPart = p.skipped > 0 ? ` (${p.skipped} skipped)` : "";
|
|
86
|
-
return `[${this.plan.id}] ${this.plan.title} ${settled}/${total}${skippedPart} ${bar} ${pct}%`;
|
|
87
|
-
}
|
|
88
|
-
/** Промпт-блок плана с текущей позиции указателя. */
|
|
89
|
-
toPromptBlock() {
|
|
90
|
-
return PlanCreator.toPromptBlock(this.plan, this.currentStepIndex);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Единая классификация транзиентных (временно сбойных) ошибок.
|
|
3
|
-
*
|
|
4
|
-
* Ранее существовало ДВЕ расходящиеся копии: `TRANSIENT_PATTERNS` в
|
|
5
|
-
* stuck-detector.ts и `TRANSIENT_ERROR_PATTERNS` в moe-executor.ts. Из-за
|
|
6
|
-
* этого одна и та же ошибка по-разному ретраилась в разных подсистемах:
|
|
7
|
-
* moe-executor считал транзиентными 500/504/"network"/"fetch failed",
|
|
8
|
-
* stuck-detector — "killed"/"SIGTERM"/"rate limit" и т.д.
|
|
9
|
-
*
|
|
10
|
-
* Здесь — объединение обеих копий в единый источник истины, чтобы решение
|
|
11
|
-
* "эту ошибку можно ретраить" было одинаковым во всей системе.
|
|
12
|
-
*/
|
|
13
|
-
const TRANSIENT_PATTERNS = [
|
|
14
|
-
/timeout/i,
|
|
15
|
-
/timed out/i,
|
|
16
|
-
/ECONNREFUSED/i,
|
|
17
|
-
/ETIMEDOUT/i,
|
|
18
|
-
/ECONNRESET/i,
|
|
19
|
-
/killed/i,
|
|
20
|
-
/SIGTERM/i,
|
|
21
|
-
/SIGKILL/i,
|
|
22
|
-
/rate limit/i,
|
|
23
|
-
/\b(429|500|502|503|504)\b/,
|
|
24
|
-
/network/i,
|
|
25
|
-
/fetch failed/i,
|
|
26
|
-
];
|
|
27
|
-
/** Истинно, если сообщение похоже на транзиентную (временно сбойную) ошибку. */
|
|
28
|
-
export function isTransientError(message) {
|
|
29
|
-
return TRANSIENT_PATTERNS.some((p) => p.test(message));
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
// Верификатор шагов: файлы, синтаксис, скрипты, typecheck, success_criteria.
|
|
2
|
-
import { existsSync, readFileSync } from "fs";
|
|
3
|
-
import { resolve, extname, dirname, join } from "path";
|
|
4
|
-
import { spawn } from "child_process";
|
|
5
|
-
import { t } from "../../i18n/index";
|
|
6
|
-
import { validateExpertConfig } from "../../config/experts";
|
|
7
|
-
import { findProjectRoot, resolveTscCommand } from "../lsp/project-root";
|
|
8
|
-
import { extractFileLikeTokens, stripUrls } from "../hallucination/js-identifiers";
|
|
9
|
-
import { findExistingFile } from "./auditor";
|
|
10
|
-
import { findTypecheckRoot } from "./audit-runners";
|
|
11
|
-
import { killTree } from "../processes/kill-tree";
|
|
12
|
-
import { settleChildClose } from "../../utils/child-run";
|
|
13
|
-
/** Верификатор шагов и MoE-планов: файлы, синтаксис, скрипты, tsc, критерии. */
|
|
14
|
-
export class StepVerifier {
|
|
15
|
-
baseDir;
|
|
16
|
-
constructor(baseDir) {
|
|
17
|
-
this.baseDir = baseDir;
|
|
18
|
-
}
|
|
19
|
-
/** Проверяет существование файла (с nested-резолвером findExistingFile). */
|
|
20
|
-
async checkFileExists(path) {
|
|
21
|
-
// Nested-aware (тот же резолвер, что в verifyStep): проект в
|
|
22
|
-
// `baseDir/proj/` нельзя репортить пропавшим, если файл ниже.
|
|
23
|
-
const resolved = findExistingFile(this.baseDir, path);
|
|
24
|
-
const exists = !!resolved;
|
|
25
|
-
return {
|
|
26
|
-
passed: exists,
|
|
27
|
-
message: exists ? t("verify.file_exists", { path }) : t("verify.file_not_found", { path }),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/** Запускает `bun run <script>` (60s), возвращает пункт проверки. */
|
|
31
|
-
async runScript(scriptName) {
|
|
32
|
-
try {
|
|
33
|
-
await this.runAsync(`bun run ${scriptName}`, this.baseDir, 60_000);
|
|
34
|
-
return { passed: true, message: t("verify.script_passed", { script: scriptName }) };
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
return {
|
|
38
|
-
passed: false,
|
|
39
|
-
message: t("verify.script_failed", { script: scriptName, message: e.message }),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/** Проектный typecheck (tsc --noEmit); без tsconfig/tsc — пропуск, не фейл. */
|
|
44
|
-
async runTypeCheck(existingFiles = []) {
|
|
45
|
-
// Корень проекта резолвим и по артефактам: проект во вложенном
|
|
46
|
-
// `baseDir/proj/` надо типчекать, а не скипать ("No tsconfig.json found") —
|
|
47
|
-
// старый поиск только от baseDir его не видел.
|
|
48
|
-
const root = findTypecheckRoot(this.baseDir, existingFiles) ?? this.baseDir;
|
|
49
|
-
const tsconfigPath = join(root, "tsconfig.json");
|
|
50
|
-
if (!existsSync(tsconfigPath)) {
|
|
51
|
-
return { passed: true, message: t("verify.typecheck_skipped_no_tsconfig") };
|
|
52
|
-
}
|
|
53
|
-
const tsc = resolveTscCommand(root);
|
|
54
|
-
if (!tsc)
|
|
55
|
-
return { passed: true, message: t("verify.typecheck_skipped_no_tsc") };
|
|
56
|
-
try {
|
|
57
|
-
await this.runAsync(`${tsc} --noEmit`, root, 60_000);
|
|
58
|
-
return { passed: true, message: t("verify.typecheck_passed") };
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
const stderr = e.stderr?.toString() || e.stdout?.toString() || e.message;
|
|
62
|
-
return {
|
|
63
|
-
passed: false,
|
|
64
|
-
message: t("verify.typecheck_failed", { error: stderr.slice(0, 500) }),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Типчекает конкретный файл, резолвя корень проекта от РАСПОЛОЖЕНИЯ ФАЙЛА
|
|
70
|
-
* (не от baseDir агента). Для вложенных раскладок (`baseDir/proj/` со своим
|
|
71
|
-
* tsconfig.json) старая проверка от baseDir молча скипала каждую ошибку типов
|
|
72
|
-
* (было в ses_mst2r0r5: ноль type feedback за всю сессию). Маркеры зеркалят
|
|
73
|
-
* конфиг TypeScript LSP-сервера.
|
|
74
|
-
*/
|
|
75
|
-
async runTypeCheckForFile(filePath) {
|
|
76
|
-
const projectRoot = findProjectRoot(filePath, this.baseDir, ["tsconfig.json", "package.json"]);
|
|
77
|
-
const tsconfigPath = join(projectRoot, "tsconfig.json");
|
|
78
|
-
if (!existsSync(tsconfigPath)) {
|
|
79
|
-
return { passed: true, message: t("verify.typecheck_skipped_no_tsconfig") };
|
|
80
|
-
}
|
|
81
|
-
const tsc = resolveTscCommand(projectRoot);
|
|
82
|
-
if (!tsc)
|
|
83
|
-
return { passed: true, message: t("verify.typecheck_skipped_no_tsc") };
|
|
84
|
-
try {
|
|
85
|
-
await this.runAsync(`${tsc} --noEmit --skipLibCheck`, projectRoot, 60_000);
|
|
86
|
-
return { passed: true, message: t("verify.typecheck_passed") };
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
const stderr = e.stderr?.toString() || e.stdout?.toString() || e.message;
|
|
90
|
-
return {
|
|
91
|
-
passed: false,
|
|
92
|
-
message: t("verify.typecheck_failed", { error: stderr.slice(0, 500) }),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/** Запускает `test`-скрипт проекта; без package.json/скрипта — пропуск. */
|
|
97
|
-
async runTests() {
|
|
98
|
-
const pkgPath = resolve(this.baseDir, "package.json");
|
|
99
|
-
if (!existsSync(pkgPath)) {
|
|
100
|
-
return { passed: true, message: t("verify.tests_skipped_no_package") };
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
const pkg = JSON.parse(require("fs").readFileSync(pkgPath, "utf-8"));
|
|
104
|
-
if (!pkg.scripts?.test) {
|
|
105
|
-
return { passed: true, message: t("verify.tests_skipped_no_script") };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
/* fall through — пробуем запустить */
|
|
110
|
-
}
|
|
111
|
-
return this.runScript("test");
|
|
112
|
-
}
|
|
113
|
-
/** Проверяет существование списка файлов-артефактов (параллельно). */
|
|
114
|
-
async verifyArtifactFiles(files) {
|
|
115
|
-
return Promise.all(files.map((f) => this.checkFileExists(f)));
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Проверяет machine-readable success_criteria подзадачи ДО решения о merge
|
|
119
|
-
* (Plan 5.1). Поддержаны формы:
|
|
120
|
-
* - `file-exists:<path>`
|
|
121
|
-
* - `substring-in-file:<path>:<text>`
|
|
122
|
-
* - `command-exit-0:<command>`
|
|
123
|
-
* Остальное — LLM-only критерий: варнинг (не ошибка), чтобы Router всё равно
|
|
124
|
-
* видел его в контексте.
|
|
125
|
-
*/
|
|
126
|
-
async verifySubtaskCriteria(subtask) {
|
|
127
|
-
const errors = [];
|
|
128
|
-
const warnings = [];
|
|
129
|
-
const details = [];
|
|
130
|
-
for (const criterion of subtask.success_criteria || []) {
|
|
131
|
-
const sep = criterion.indexOf(":");
|
|
132
|
-
if (sep <= 0) {
|
|
133
|
-
warnings.push(`Subtask "${subtask.id}": non-machine criterion "${criterion}" (LLM-only)`);
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
const kind = criterion.slice(0, sep);
|
|
137
|
-
const rest = criterion.slice(sep + 1);
|
|
138
|
-
if (kind === "file-exists") {
|
|
139
|
-
const check = await this.checkFileExists(rest);
|
|
140
|
-
details.push(check);
|
|
141
|
-
if (!check.passed)
|
|
142
|
-
errors.push(`[${subtask.id}] ${check.message}`);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (kind === "substring-in-file") {
|
|
146
|
-
const colon = rest.indexOf(":");
|
|
147
|
-
if (colon <= 0) {
|
|
148
|
-
warnings.push(`Subtask "${subtask.id}": malformed substring-in-file criterion "${criterion}"`);
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const path = rest.slice(0, colon);
|
|
152
|
-
const needle = rest.slice(colon + 1);
|
|
153
|
-
const resolved = resolve(this.baseDir, path);
|
|
154
|
-
if (!existsSync(resolved)) {
|
|
155
|
-
const item = { passed: false, message: t("verify.file_not_found", { path }) };
|
|
156
|
-
details.push(item);
|
|
157
|
-
errors.push(`[${subtask.id}] ${item.message}`);
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const content = readFileSync(resolved, "utf-8");
|
|
161
|
-
const passed = content.includes(needle);
|
|
162
|
-
details.push({ passed, message: `substring "${needle}" in ${path}: ${passed}` });
|
|
163
|
-
if (!passed)
|
|
164
|
-
errors.push(`[${subtask.id}] "${needle}" not found in ${path}`);
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (kind === "command-exit-0") {
|
|
168
|
-
try {
|
|
169
|
-
await this.runAsync(rest, this.baseDir, 30_000);
|
|
170
|
-
details.push({ passed: true, message: `command ok: ${rest}` });
|
|
171
|
-
}
|
|
172
|
-
catch (e) {
|
|
173
|
-
const item = {
|
|
174
|
-
passed: false,
|
|
175
|
-
message: `command failed: ${rest} (${String(e.message).slice(0, 200)})`,
|
|
176
|
-
};
|
|
177
|
-
details.push(item);
|
|
178
|
-
errors.push(`[${subtask.id}] ${item.message}`);
|
|
179
|
-
}
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
warnings.push(`Subtask "${subtask.id}": unknown criterion kind "${kind}" (LLM-only)`);
|
|
183
|
-
}
|
|
184
|
-
return { errors, warnings, details };
|
|
185
|
-
}
|
|
186
|
-
/** Верифицирует MoE-манифест: эксперты, typecheck, файлы и критерии подзадач. */
|
|
187
|
-
async verifyMoEManifest(plan, config, allToolTags) {
|
|
188
|
-
const errors = [];
|
|
189
|
-
const warnings = [];
|
|
190
|
-
const details = [];
|
|
191
|
-
const expertErrors = validateExpertConfig(config, allToolTags);
|
|
192
|
-
for (const err of expertErrors) {
|
|
193
|
-
errors.push(err);
|
|
194
|
-
details.push({ passed: false, message: err });
|
|
195
|
-
}
|
|
196
|
-
const existingArtifacts = plan.subtasks
|
|
197
|
-
.flatMap((s) => s.allowed_files || [])
|
|
198
|
-
.map((f) => findExistingFile(this.baseDir, f))
|
|
199
|
-
.filter((f) => !!f);
|
|
200
|
-
const tscResult = await this.runTypeCheck(existingArtifacts);
|
|
201
|
-
details.push(tscResult);
|
|
202
|
-
if (!tscResult.passed) {
|
|
203
|
-
errors.push(tscResult.message);
|
|
204
|
-
}
|
|
205
|
-
for (const sub of plan.subtasks) {
|
|
206
|
-
const fileChecks = await this.verifyArtifactFiles(sub.allowed_files || []);
|
|
207
|
-
for (const check of fileChecks) {
|
|
208
|
-
details.push(check);
|
|
209
|
-
if (!check.passed) {
|
|
210
|
-
errors.push(check.message);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
// Machine-readable success_criteria (Plan 5.1) — проверяются до merge.
|
|
214
|
-
const criteria = await this.verifySubtaskCriteria(sub);
|
|
215
|
-
errors.push(...criteria.errors);
|
|
216
|
-
warnings.push(...criteria.warnings);
|
|
217
|
-
details.push(...criteria.details);
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
success: errors.length === 0,
|
|
221
|
-
errors,
|
|
222
|
-
warnings,
|
|
223
|
-
details,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
/** Верифицирует шаг: файлы из описания существуют (+синтаксис; delete — наоборот). */
|
|
227
|
-
async verifyStep(stepDescription, kind) {
|
|
228
|
-
const fileMatches = extractFileLikeTokens(stripUrls(stepDescription));
|
|
229
|
-
// Нет именованных файлов — шаг непроверяем по существованию. НЕ пропускаем
|
|
230
|
-
// тривиально (пустой every() = true); сигналим noFiles, чтобы тул вёл
|
|
231
|
-
// модель к настоящей проверке.
|
|
232
|
-
if (fileMatches.length === 0) {
|
|
233
|
-
return { passed: false, syntaxValid: true, failed: [], noFiles: true };
|
|
234
|
-
}
|
|
235
|
-
const results = [];
|
|
236
|
-
let syntaxValid = true;
|
|
237
|
-
for (const filePath of fileMatches) {
|
|
238
|
-
const resolved = findExistingFile(this.baseDir, filePath);
|
|
239
|
-
const exists = !!resolved;
|
|
240
|
-
if (kind === "delete") {
|
|
241
|
-
// Для delete-шагов: отсутствие файла — pass
|
|
242
|
-
results.push({
|
|
243
|
-
passed: !exists,
|
|
244
|
-
message: exists
|
|
245
|
-
? t("verify.file_still_exists", { path: filePath })
|
|
246
|
-
: t("verify.file_not_found", { path: filePath }),
|
|
247
|
-
});
|
|
248
|
-
// Удалённый файл синтаксически не проверяем
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
// Create-шаги: файл обязан существовать + валидный синтаксис
|
|
252
|
-
if (!exists) {
|
|
253
|
-
results.push({ passed: false, message: t("verify.file_not_found", { path: filePath }) });
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
results.push({ passed: true, message: t("verify.file_exists", { path: filePath }) });
|
|
257
|
-
if (!(await this.validateSyntax(resolved))) {
|
|
258
|
-
syntaxValid = false;
|
|
259
|
-
results.push({ passed: false, message: t("verify.syntax_error", { path: filePath }) });
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
passed: results.every((r) => r.passed),
|
|
264
|
-
syntaxValid,
|
|
265
|
-
failed: results.filter((r) => !r.passed),
|
|
266
|
-
noFiles: false,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
async validateSyntax(filePath) {
|
|
270
|
-
const ext = extname(filePath);
|
|
271
|
-
if (ext === ".ts" || ext === ".tsx" || ext === ".cts" || ext === ".mts") {
|
|
272
|
-
// Локальный tsc, а не npx: npx без локального пакета уходит в сеть и
|
|
273
|
-
// висит секундами. Нет tsc — пропускаем проверку (как и раньше «not
|
|
274
|
-
// found → true»), но мгновенно.
|
|
275
|
-
const tsc = resolveTscCommand(dirname(filePath));
|
|
276
|
-
if (!tsc)
|
|
277
|
-
return true;
|
|
278
|
-
try {
|
|
279
|
-
// Путь в кавычках — команды идут через shell и ломаются на пробелах.
|
|
280
|
-
await this.runAsync(`${tsc} --noEmit --skipLibCheck "${filePath}"`, this.baseDir, 20000);
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
catch (err) {
|
|
284
|
-
if (err.status === 127 ||
|
|
285
|
-
err.message.includes("not found") ||
|
|
286
|
-
err.message.includes("ENOENT")) {
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
const stderr = err.stderr?.toString() || "";
|
|
290
|
-
if (stderr.includes("error TS") && !stderr.includes("Cannot find module")) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
if (ext === ".js" || ext === ".jsx" || ext === ".cjs" || ext === ".mjs") {
|
|
297
|
-
try {
|
|
298
|
-
await this.runAsync(`node --check "${filePath}"`, this.baseDir, 5000);
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
catch {
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Запускает команду асинхронно (не блокируя event loop) и резолвится на
|
|
309
|
-
* выходе. На ненулевой exit или таймаут — reject с захваченными stderr/stdout.
|
|
310
|
-
*/
|
|
311
|
-
runAsync(command, cwd, timeoutMs) {
|
|
312
|
-
return new Promise((resolve, reject) => {
|
|
313
|
-
const child = spawn(command, {
|
|
314
|
-
cwd,
|
|
315
|
-
shell: true,
|
|
316
|
-
windowsHide: true,
|
|
317
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
318
|
-
});
|
|
319
|
-
let stdout = "";
|
|
320
|
-
let stderr = "";
|
|
321
|
-
child.stdout?.on("data", (d) => {
|
|
322
|
-
stdout += d.toString();
|
|
323
|
-
});
|
|
324
|
-
child.stderr?.on("data", (d) => {
|
|
325
|
-
stderr += d.toString();
|
|
326
|
-
});
|
|
327
|
-
const timer = setTimeout(() => {
|
|
328
|
-
// Убиваем всё дерево: при shell:true child.kill() останавливает только
|
|
329
|
-
// shell, а реальный внук tsc/node продолжает висеть.
|
|
330
|
-
killTree(child);
|
|
331
|
-
reject(new Error(`Command timed out after ${timeoutMs}ms`));
|
|
332
|
-
}, timeoutMs);
|
|
333
|
-
child.on("error", (err) => {
|
|
334
|
-
clearTimeout(timer);
|
|
335
|
-
reject(err);
|
|
336
|
-
});
|
|
337
|
-
child.on("close", (code) => {
|
|
338
|
-
clearTimeout(timer);
|
|
339
|
-
settleChildClose(code, stdout, stderr, `Command failed with exit code ${code}`, resolve, reject);
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unix-команды, которых нет в Windows cmd.exe (или семантика несовместима).
|
|
3
|
-
* 9B-модель тянется к grep/sed/ls/find через тул bash; каждый фейл возвращает
|
|
4
|
-
* хинт, но модель ретраит.
|
|
5
|
-
*
|
|
6
|
-
* Сессионный модульный компаньон пер-командного hard-stop самого тула bash
|
|
7
|
-
* (`UNIX_TO_WIN_HINTS` / `FAILING_FIRST_WORDS` / `HARD_BLOCK_THRESHOLD` в
|
|
8
|
-
* src/tools/bash.ts). Тот механизм инжектит "STOP using X" В вывод тула,
|
|
9
|
-
* который 9B-модель склонна игнорировать; этот, гейченный на win32 как bash.ts,
|
|
10
|
-
* кладёт <system-summary> перед следующим вызовом модели. Списки команд держим
|
|
11
|
-
* синхронно.
|
|
12
|
-
*
|
|
13
|
-
* Это allow/deny-список команд (как чёрный список команд security-модуля),
|
|
14
|
-
* НЕ классификация задач (правило #10).
|
|
15
|
-
*/
|
|
16
|
-
const FORBIDDEN_COMMANDS = new Set([
|
|
17
|
-
"grep",
|
|
18
|
-
"sed",
|
|
19
|
-
"awk",
|
|
20
|
-
"uniq",
|
|
21
|
-
"xargs",
|
|
22
|
-
"cut",
|
|
23
|
-
"tr",
|
|
24
|
-
"basename",
|
|
25
|
-
"dirname",
|
|
26
|
-
"export",
|
|
27
|
-
"source",
|
|
28
|
-
"sleep",
|
|
29
|
-
"env",
|
|
30
|
-
"ls",
|
|
31
|
-
"find",
|
|
32
|
-
"rm",
|
|
33
|
-
"touch",
|
|
34
|
-
"which",
|
|
35
|
-
"diff",
|
|
36
|
-
"cp",
|
|
37
|
-
"mv",
|
|
38
|
-
]);
|
|
39
|
-
function firstWord(command) {
|
|
40
|
-
const segs = command.trim().split(/[\s;|&]+/);
|
|
41
|
-
return (segs[0] || "").replace(/[^\w-]/g, "").toLowerCase();
|
|
42
|
-
}
|
|
43
|
-
/** Имя запрещённой команды, если `command` с неё начинается (понимает `cd x && …`). */
|
|
44
|
-
export function forbiddenWindowsCommand(command) {
|
|
45
|
-
const m = command.match(/^\s*cd\s+\S+\s*&&\s*(\S+)/);
|
|
46
|
-
if (m)
|
|
47
|
-
return forbiddenWindowsCommand(m[1]);
|
|
48
|
-
const word = firstWord(command);
|
|
49
|
-
if (word && FORBIDDEN_COMMANDS.has(word))
|
|
50
|
-
return word;
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Проверки заявлений об артефактах (ses_mul5pepu_9mdq90): qwen3.5-9b записала fizzbuzz.py,
|
|
3
|
-
* не смогла запустить (python в чёрном списке), затем вставила "ожидаемый" вывод
|
|
4
|
-
* программы с неверными значениями как якобы реальный; также записала schema.drawio
|
|
5
|
-
* с битым `<diagram/>` + висячим `</diagram>` и заявила "валидный XML".
|
|
6
|
-
* Проверка success-claim срабатывает только на сигналы ошибок в выводах тулов,
|
|
7
|
-
* поэтому оба случая прошли молча.
|
|
8
|
-
*
|
|
9
|
-
* Две детерминированные проверки (regex + состояние диска от вызывающего, без LLM):
|
|
10
|
-
* - `checkArtifactClaims`: ответ подаёт файл как созданный/валидный, а на диске
|
|
11
|
-
* его нет или он не парсится.
|
|
12
|
-
* - `checkUnverifiedOutput`: ответ подаёт кодовый блок как реальный вывод
|
|
13
|
-
* программы, но ни один тул в окне доказательств ничего успешно не исполнял.
|
|
14
|
-
*
|
|
15
|
-
* Чистые функции — состояние диска (`ArtifactState[]`) резолвит вызывающий
|
|
16
|
-
* (цикл агента, владелец baseDir), модуль остаётся тестируемым.
|
|
17
|
-
* Точность смещена в сторону recall, как в success-claim.ts: ложное срабатывание
|
|
18
|
-
* стоит одну ограниченную re-check итерацию, пропуск — статус-кво.
|
|
19
|
-
*/
|
|
20
|
-
const WORD = "A-Za-zА-Яа-яЁё0-9_";
|
|
21
|
-
const wb = (body) => new RegExp(`(?<![${WORD}])(?:${body})(?![${WORD}])`, "i");
|
|
22
|
-
/** Язык успеха про файл (любая локаль, на которой говорит агент). */
|
|
23
|
-
const ARTIFACT_SUCCESS_RE = wb("создан[а-яё]*|записан[а-яё]*|сохран[её]н[а-яё]*|готов[а-яё]*|валид[а-яё]*|проверен[а-яё]*|существует|valid(?:ated)?|verified|checked|written|saved|created|exists?|ready");
|
|
24
|
-
/**
|
|
25
|
-
* Каким словом успеха (если есть) ответ описывает упоминание файла.
|
|
26
|
-
* Возвращает найденное слово для точного retry-сообщения.
|
|
27
|
-
*/
|
|
28
|
-
function claimedAs(response, path) {
|
|
29
|
-
const idx = response.toLowerCase().indexOf(path.toLowerCase());
|
|
30
|
-
if (idx === -1)
|
|
31
|
-
return null;
|
|
32
|
-
// Смотрим окно вокруг упоминания — заявление обычно в том же
|
|
33
|
-
// предложении ("Файл schema.drawio создан и валиден").
|
|
34
|
-
const window = response.slice(Math.max(0, idx - 160), idx + path.length + 160);
|
|
35
|
-
const m = window.match(ARTIFACT_SUCCESS_RE);
|
|
36
|
-
return m ? m[0] : null;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Возвращает противоречие, если ответ подаёт резолвленный артефакт как
|
|
40
|
-
* созданный/валидный, а на диске его нет или он не парсится.
|
|
41
|
-
*/
|
|
42
|
-
export function checkArtifactClaims(response, artifacts) {
|
|
43
|
-
if (!response)
|
|
44
|
-
return null;
|
|
45
|
-
for (const a of artifacts) {
|
|
46
|
-
const claim = a.claim ?? claimedAs(response, a.path);
|
|
47
|
-
if (!claim)
|
|
48
|
-
continue;
|
|
49
|
-
if (!a.exists) {
|
|
50
|
-
return {
|
|
51
|
-
tool: "disk",
|
|
52
|
-
path: a.path,
|
|
53
|
-
snippet: `${a.path}: file not found on disk, claimed "${claim}"`,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (a.parseError) {
|
|
57
|
-
return {
|
|
58
|
-
tool: "disk",
|
|
59
|
-
path: a.path,
|
|
60
|
-
snippet: `${a.path}: ${a.parseError}, claimed "${claim}"`,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
/** Фразы, подающие кодовый блок как РЕАЛЬНЫЙ вывод исполнения (не пример). */
|
|
67
|
-
const OUTPUT_AS_RESULT_RE = wb("вывод программы|вывод команды|результат запуска|результат выполнения|program output|command output|execution result|запустил[а-яё]*.*вывод|покажу вывод|actual output");
|
|
68
|
-
/** Хеджирование, понижающее блок до ожидания/примера — честно, пропускаем. */
|
|
69
|
-
const OUTPUT_HEDGE_RE = wb("ожидаем[а-яё]*|expected|пример[а-яё]*|example|для справки|sample|например|предполагаем[а-яё]*|должен быть|should be");
|
|
70
|
-
const FENCE_RE = /```/;
|
|
71
|
-
/** Тулы, чей успех означает "что-то реально исполнилось". */
|
|
72
|
-
const EXEC_TOOLS = new Set(["bash", "process_wait", "pipeline_run"]);
|
|
73
|
-
/**
|
|
74
|
-
* Возвращает противоречие, если ответ показывает вывод как результат запуска,
|
|
75
|
-
* но ни один exec-тул в окне доказательств успешно не отработал.
|
|
76
|
-
*/
|
|
77
|
-
export function checkUnverifiedOutput(response, tools) {
|
|
78
|
-
if (!response || !OUTPUT_AS_RESULT_RE.test(response))
|
|
79
|
-
return null;
|
|
80
|
-
if (OUTPUT_HEDGE_RE.test(response))
|
|
81
|
-
return null;
|
|
82
|
-
if (!FENCE_RE.test(response))
|
|
83
|
-
return null;
|
|
84
|
-
const recent = tools.filter((t) => t.text?.trim()).slice(-10);
|
|
85
|
-
const executed = recent.some((t) => t.ok === true && t.name !== undefined && EXEC_TOOLS.has(t.name));
|
|
86
|
-
if (executed)
|
|
87
|
-
return null;
|
|
88
|
-
const m = response.match(OUTPUT_AS_RESULT_RE);
|
|
89
|
-
return {
|
|
90
|
-
tool: "no-execution",
|
|
91
|
-
snippet: `claimed "${m?.[0] ?? "output"}" with no successful execution tool in evidence`,
|
|
92
|
-
};
|
|
93
|
-
}
|