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
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
import { t } from "../../i18n/index";
|
|
2
|
-
import { detectTestResults } from "../../tools/bash";
|
|
3
|
-
import { forbiddenWindowsCommand } from "./windows-commands";
|
|
4
|
-
import { extractFileLikeTokens, stripUrls } from "../hallucination/js-identifiers";
|
|
5
|
-
import { toForwardSlash } from "../../tools/path-utils";
|
|
6
|
-
import { platform } from "os";
|
|
7
|
-
import { switchStepToDelete } from "./plan-steps";
|
|
8
|
-
/**
|
|
9
|
-
* Кулдаун (в итерациях) между инжектами stuck-восстановления. Экспортируется,
|
|
10
|
-
* чтобы ExecutionModule сидировал state.lastRecoveryIteration тем же офсетом,
|
|
11
|
-
* с которым плагин сравнивает.
|
|
12
|
-
*/
|
|
13
|
-
export const STUCK_RECOVERY_COOLDOWN = 5;
|
|
14
|
-
const MAX_PLAN_WARNINGS_BEFORE_BLOCK = 3;
|
|
15
|
-
const FORCE_SKIP_THRESHOLD = 10;
|
|
16
|
-
/** Один и тот же stuck-варнинг перелоггируем не чаще каждых N итераций (новый
|
|
17
|
-
* ключ — всегда сразу). Не даёт идентичному варнингу флудить каждую итерацию
|
|
18
|
-
* (было в ses_mt4fn58c: "Tool bash failed N times" после ~30 успешных записей,
|
|
19
|
-
* "No write/exec" на каждом чтении). */
|
|
20
|
-
export const STUCK_WARN_REPEAT_EVERY = 5;
|
|
21
|
-
/** Сколько файл-мутирующих вызовов (write/edit/bash/download) без активного
|
|
22
|
-
* плана триггерит nudge создания плана. Evidence-based (правило #10):
|
|
23
|
-
* агент явно работает с файлами — план оправдан. */
|
|
24
|
-
const PLAN_NUDGE_THRESHOLD = 2;
|
|
25
|
-
/** Тулы, чей успех мог поменять ФС — после них перепроверяем deliverables
|
|
26
|
-
* текущего шага для автопродвижения. Read-only осознанно исключены (см. вызов
|
|
27
|
-
* advance в onAfterTool ниже). */
|
|
28
|
-
const FS_MUTATING_TOOLS = new Set([
|
|
29
|
-
"write_file",
|
|
30
|
-
"edit_file",
|
|
31
|
-
"delete_file",
|
|
32
|
-
"move_file",
|
|
33
|
-
"create_dir",
|
|
34
|
-
"bash",
|
|
35
|
-
"download_file",
|
|
36
|
-
"subagent",
|
|
37
|
-
"mcp_call",
|
|
38
|
-
"pipeline_run",
|
|
39
|
-
"browser",
|
|
40
|
-
]);
|
|
41
|
-
function normalizeBrokenPath(p) {
|
|
42
|
-
return toForwardSlash(p).replace(/^\.\//, "");
|
|
43
|
-
}
|
|
44
|
-
/** Парсит строку ошибки tsc / bun build / node --check в путь файла.
|
|
45
|
-
* Null, если в строке нет привязки к файлу (напр. `error: Could not
|
|
46
|
-
* resolve "..."`). */
|
|
47
|
-
export function parseBrokenFile(line) {
|
|
48
|
-
const trimmed = line.trim();
|
|
49
|
-
// tsc: src/index.tsx(17,15): error TS2322: ...
|
|
50
|
-
const tsc = /^(.+?)\s*\(\d+,\d+\)\s*:\s*error TS\d+/.exec(trimmed);
|
|
51
|
-
if (tsc)
|
|
52
|
-
return normalizeBrokenPath(tsc[1]);
|
|
53
|
-
// bun build / node --check: /abs/file.tsx:1:10: error: ...
|
|
54
|
-
const bn = /^(.+?):\d+:\d+\s*:\s*(?:error|SyntaxError)/.exec(trimmed);
|
|
55
|
-
if (bn)
|
|
56
|
-
return normalizeBrokenPath(bn[1]);
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
/** Вытаскивает пофайловые compile-фейлы из вывода write/edit. Смотрит только
|
|
60
|
-
* строки-маркеры (`[Project typecheck failed]: <line>` /
|
|
61
|
-
* `[Syntax check failed]: <line>`), чтобы тело диффа не давало ложных. */
|
|
62
|
-
export function extractBrokenFiles(output) {
|
|
63
|
-
const out = [];
|
|
64
|
-
for (const line of output.split("\n")) {
|
|
65
|
-
const marker = /\[(?:Project typecheck failed|Syntax check failed)\]:\s*(.+)$/.exec(line);
|
|
66
|
-
if (!marker)
|
|
67
|
-
continue;
|
|
68
|
-
const errLine = marker[1].trim();
|
|
69
|
-
out.push({ file: parseBrokenFile(errLine) ?? "", error: errLine.slice(0, 300) });
|
|
70
|
-
}
|
|
71
|
-
return out;
|
|
72
|
-
}
|
|
73
|
-
/** Сброс пер-шаговых флагов при смене активного шага (или его отсутствии: -1). */
|
|
74
|
-
function resetStepFlags(state, stepId) {
|
|
75
|
-
state.consecutivePlanWarnings = 0;
|
|
76
|
-
state.lastStepId = stepId;
|
|
77
|
-
state.stuckNotified = false;
|
|
78
|
-
state.escalationDirectiveSent = false;
|
|
79
|
-
}
|
|
80
|
-
/** Полный сброс состояния плана (завершён или его нет). */
|
|
81
|
-
function resetPlanState(state) {
|
|
82
|
-
state.consecutivePlanWarnings = 0;
|
|
83
|
-
state.lastStepId = -1;
|
|
84
|
-
state.stuckNotified = false;
|
|
85
|
-
state.mutationsWithoutPlan = 0;
|
|
86
|
-
state.planNudgeSent = false;
|
|
87
|
-
state.escalationDirectiveSent = false;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Гейт для `plan update status=done`: реджектит, пока последний write/edit
|
|
91
|
-
* репортит compile-ошибку. Фейл без привязки к файлу блокирует весь проект;
|
|
92
|
-
* иначе именованные токены файлов шага матчатся против битых (суффикс пути,
|
|
93
|
-
* регистронезависимо). Шаг без файлов обвинить не в чем — его done остаётся
|
|
94
|
-
* vacuous. Возвращает первую ошибку для показа модели, или null чтобы пустить.
|
|
95
|
-
*/
|
|
96
|
-
export function stepTypecheckGate(failures, stepDescription) {
|
|
97
|
-
if (failures.size === 0)
|
|
98
|
-
return null;
|
|
99
|
-
const projectError = failures.get("");
|
|
100
|
-
if (projectError)
|
|
101
|
-
return projectError;
|
|
102
|
-
const stepTokens = extractFileLikeTokens(stripUrls(stepDescription)).map((p) => normalizeBrokenPath(p).toLowerCase());
|
|
103
|
-
if (stepTokens.length === 0)
|
|
104
|
-
return null;
|
|
105
|
-
for (const [file, err] of failures) {
|
|
106
|
-
const f = normalizeBrokenPath(file).toLowerCase();
|
|
107
|
-
if (stepTokens.some((tok) => f.endsWith(tok) || tok.endsWith(f)))
|
|
108
|
-
return err;
|
|
109
|
-
}
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Хуки execution-плагина, вынесенные дословно из ExecutionModule.getPlugin().
|
|
114
|
-
* Всё разделяемое мутабельное состояние (pendingMessages, forbiddenBashFailures,
|
|
115
|
-
* state, tracker) принадлежит модулю и мутируется по ссылке через `deps`.
|
|
116
|
-
*/
|
|
117
|
-
export function createExecutionPlugin(deps) {
|
|
118
|
-
return {
|
|
119
|
-
name: "execution",
|
|
120
|
-
onBeforeThink: (ctx) => {
|
|
121
|
-
// Отложенные <system-summary> флашим первыми: видны следующему вызову
|
|
122
|
-
// модели, но не interleav'ят tool-сообщения.
|
|
123
|
-
if (ctx.contextManager && deps.pendingMessages.length > 0) {
|
|
124
|
-
for (const m of deps.pendingMessages.splice(0)) {
|
|
125
|
-
ctx.contextManager.addMessage(m);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (deps.trackerRef.current?.isComplete()) {
|
|
129
|
-
// Все шаги done/skipped — перестаём считать "no progress" против
|
|
130
|
-
// последнего шага и глушим step-stuck варнинги готового плана, НО
|
|
131
|
-
// историю вызовов храним, чтобы петля чтения-без-записи ловилась
|
|
132
|
-
// (было: план готов + ложноположительный аудит → модель 50+ итераций
|
|
133
|
-
// перечитывала файлы с нулем записей без recovery-хинта).
|
|
134
|
-
deps.stuckDetector.resetStepProgress();
|
|
135
|
-
resetPlanState(deps.state);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
const step = deps.trackerRef.current?.getCurrentStep();
|
|
139
|
-
if (deps.trackerRef.current && step) {
|
|
140
|
-
if (step.id !== deps.state.lastStepId) {
|
|
141
|
-
resetStepFlags(deps.state, step.id);
|
|
142
|
-
}
|
|
143
|
-
deps.stuckDetector.setCurrentStep(step.id, step.description);
|
|
144
|
-
deps.stuckDetector.recordIteration(step.id);
|
|
145
|
-
// A plan is active — any mutation counter no longer applies.
|
|
146
|
-
deps.state.mutationsWithoutPlan = 0;
|
|
147
|
-
deps.state.planNudgeSent = false;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
// До-плана: историю цикла (свежие вызовы, read-only стрик) храним,
|
|
151
|
-
// чтобы петли повторов/read-only ловились и без плана. `reset()`
|
|
152
|
-
// тёр её каждую итерацию, отключая детекцию.
|
|
153
|
-
deps.stuckDetector.resetStepProgress();
|
|
154
|
-
resetStepFlags(deps.state, -1);
|
|
155
|
-
// Evidence-based nudge плана (правило #10 — без голого счётчика
|
|
156
|
-
// итераций, без keyword-классификации задач): только когда агент
|
|
157
|
-
// реально сделал файл-мутирующие вызовы (write/edit/bash/download)
|
|
158
|
-
// без плана, ему нужен план.
|
|
159
|
-
const mutations = deps.state.mutationsWithoutPlan;
|
|
160
|
-
if (mutations >= PLAN_NUDGE_THRESHOLD &&
|
|
161
|
-
!deps.state.planNudgeSent &&
|
|
162
|
-
ctx.contextManager) {
|
|
163
|
-
deps.state.planNudgeSent = true;
|
|
164
|
-
ctx.contextManager.addMessage({
|
|
165
|
-
role: "user",
|
|
166
|
-
content: `<system-summary>${t("exec.plan_nudge", {
|
|
167
|
-
count: String(mutations),
|
|
168
|
-
})}</system-summary>`,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
const stuckReason = deps.stuckDetector.getStuckReason();
|
|
174
|
-
if (stuckReason) {
|
|
175
|
-
// Логируем раз на эпизод варнинга, а не спамим каждую итерацию: новый
|
|
176
|
-
// ключ — сразу; ТОТ ЖЕ ключ — только каждые STUCK_WARN_REPEAT_EVERY
|
|
177
|
-
// итераций. Step-stuck причина хранит свой once-per-episode флаг.
|
|
178
|
-
const isStuck = deps.stuckDetector.isStuck();
|
|
179
|
-
const warnKey = deps.stuckDetector.getWarningKey();
|
|
180
|
-
const iter = typeof ctx.iteration === "number" ? ctx.iteration : 0;
|
|
181
|
-
const logIt = isStuck
|
|
182
|
-
? !deps.state.stuckNotified
|
|
183
|
-
: warnKey !== deps.state.lastStuckWarnKey ||
|
|
184
|
-
iter - deps.state.lastStuckWarnIter >= STUCK_WARN_REPEAT_EVERY;
|
|
185
|
-
if (logIt) {
|
|
186
|
-
ctx.logger?.warn(stuckReason);
|
|
187
|
-
ctx.sessionLog?.plan("stuck-warning", stuckReason, typeof ctx.iteration === "number" ? ctx.iteration : undefined);
|
|
188
|
-
deps.state.lastStuckWarnKey = warnKey;
|
|
189
|
-
deps.state.lastStuckWarnIter = iter;
|
|
190
|
-
if (isStuck)
|
|
191
|
-
deps.state.stuckNotified = true;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
deps.state.lastStuckWarnKey = "";
|
|
196
|
-
}
|
|
197
|
-
if (deps.stuckDetector.isStuck() ||
|
|
198
|
-
deps.stuckDetector.hasRepetitiveToolCalls() ||
|
|
199
|
-
deps.stuckDetector.hasReadOnlyLoop() ||
|
|
200
|
-
deps.stuckDetector.hasBashFlailing() ||
|
|
201
|
-
deps.stuckDetector.hasConsecutiveFailures()) {
|
|
202
|
-
const currentIter = typeof ctx.iteration === "number" ? ctx.iteration : 0;
|
|
203
|
-
if (currentIter - deps.state.lastRecoveryIteration >= STUCK_RECOVERY_COOLDOWN) {
|
|
204
|
-
const recovery = deps.stuckDetector.getRecoveryMessage();
|
|
205
|
-
if (recovery && ctx.contextManager) {
|
|
206
|
-
// Прикладываем контекст tsc-ошибки, чтобы модель знала, ПОЧЕМУ застряла.
|
|
207
|
-
let tscContext = "";
|
|
208
|
-
if (deps.state.typecheckFailures.size > 0) {
|
|
209
|
-
const currentStep = deps.trackerRef.current?.getCurrentStep();
|
|
210
|
-
if (currentStep) {
|
|
211
|
-
const stepFiles = extractFileLikeTokens(stripUrls(currentStep.description));
|
|
212
|
-
for (const [file, error] of deps.state.typecheckFailures) {
|
|
213
|
-
if (!file || stepFiles.some((f) => file.endsWith(f) || f.endsWith(file))) {
|
|
214
|
-
tscContext = `\nLast compile error: ${error}`;
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (!tscContext) {
|
|
219
|
-
const first = deps.state.typecheckFailures.entries().next().value;
|
|
220
|
-
if (first)
|
|
221
|
-
tscContext = `\nLast compile error: ${first[1]}`;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// Префикс стабильной машиночитаемой классификации: модель видит,
|
|
226
|
-
// ПОЧЕМУ застряла, до локализованного recovery-гайданса.
|
|
227
|
-
const diagnostic = deps.stuckDetector.getStuckDiagnostic(currentIter);
|
|
228
|
-
ctx.contextManager.addMessage({
|
|
229
|
-
role: "user",
|
|
230
|
-
content: `<system-summary>${diagnostic ? `${diagnostic}\n` : ""}${recovery}${tscContext}</system-summary>`,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
deps.stuckDetector.recordEscalation();
|
|
234
|
-
deps.state.lastRecoveryIteration = currentIter;
|
|
235
|
-
if (deps.stuckDetector.shouldEscalate()) {
|
|
236
|
-
const escalation = t("exec.escalation", {
|
|
237
|
-
stepId: String(deps.trackerRef.current?.getCurrentStep()?.id ?? "?"),
|
|
238
|
-
description: deps.trackerRef.current?.getCurrentStep()?.description ?? "",
|
|
239
|
-
});
|
|
240
|
-
// Эскалируем МОДЕЛИ, а не только UI-баннеру: после нескольких попыток
|
|
241
|
-
// восстановления даём явные общие опции (сменить подход, поискать
|
|
242
|
-
// ошибку, спросить юзера, re-plan/skip) вместо повтора того же
|
|
243
|
-
// фейлящегося действия. Инжектится раз на эпизод.
|
|
244
|
-
if (!deps.state.escalationDirectiveSent && ctx.contextManager) {
|
|
245
|
-
deps.state.escalationDirectiveSent = true;
|
|
246
|
-
ctx.contextManager.addMessage({
|
|
247
|
-
role: "user",
|
|
248
|
-
content: `<system-summary>${t("exec.escalation_directive")}</system-summary>`,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
ctx.onMeta?.(escalation);
|
|
252
|
-
}
|
|
253
|
-
// Форс-скип после слишком долгого сидения на одном шаге
|
|
254
|
-
if (deps.stuckDetector.getIterationsOnCurrentStep() >= FORCE_SKIP_THRESHOLD &&
|
|
255
|
-
ctx.contextManager) {
|
|
256
|
-
const step = deps.trackerRef.current?.getCurrentStep();
|
|
257
|
-
ctx.contextManager.addMessage({
|
|
258
|
-
role: "user",
|
|
259
|
-
content: `<system-summary>${t("exec.stop_directive", {
|
|
260
|
-
stepId: String(step?.id ?? "?"),
|
|
261
|
-
description: step?.description ?? "",
|
|
262
|
-
iterations: String(deps.stuckDetector.getIterationsOnCurrentStep()),
|
|
263
|
-
})}</system-summary>`,
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
onBeforeTool: (_ctx, call) => {
|
|
270
|
-
const warning = deps.checkPlanAlignment(call);
|
|
271
|
-
if (warning) {
|
|
272
|
-
deps.pendingMessages.push({
|
|
273
|
-
role: "user",
|
|
274
|
-
content: `<system-summary>${warning}</system-summary>`,
|
|
275
|
-
});
|
|
276
|
-
deps.state.consecutivePlanWarnings++;
|
|
277
|
-
if (deps.state.consecutivePlanWarnings >= MAX_PLAN_WARNINGS_BEFORE_BLOCK) {
|
|
278
|
-
deps.pendingMessages.push({
|
|
279
|
-
role: "user",
|
|
280
|
-
content: `<system-summary>${t("exec.plan_blocked", { step: String(deps.trackerRef.current?.getCurrentStep()?.id ?? "?"), max: MAX_PLAN_WARNINGS_BEFORE_BLOCK })}</system-summary>`,
|
|
281
|
-
});
|
|
282
|
-
// Блок с явной причиной, чтобы модель видела, ПОЧЕМУ вызов
|
|
283
|
-
// заблокирован (executor показывает через tool.blocked_reason).
|
|
284
|
-
return t("exec.plan_blocked", {
|
|
285
|
-
step: String(deps.trackerRef.current?.getCurrentStep()?.id ?? "?"),
|
|
286
|
-
max: MAX_PLAN_WARNINGS_BEFORE_BLOCK,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
deps.state.consecutivePlanWarnings = 0;
|
|
292
|
-
}
|
|
293
|
-
return true;
|
|
294
|
-
},
|
|
295
|
-
onToolCall: (ctx) => {
|
|
296
|
-
const toolName = ctx?.toolName;
|
|
297
|
-
const args = ctx?.args;
|
|
298
|
-
if (toolName && args) {
|
|
299
|
-
deps.stuckDetector.recordToolCall(toolName, args);
|
|
300
|
-
// Считаем файл-мутирующие вызовы БЕЗ активного плана — питают
|
|
301
|
-
// evidence-based nudge создания плана в onBeforeThink.
|
|
302
|
-
if (!deps.trackerRef.current &&
|
|
303
|
-
(toolName === "write_file" ||
|
|
304
|
-
toolName === "edit_file" ||
|
|
305
|
-
toolName === "bash" ||
|
|
306
|
-
toolName === "download_file")) {
|
|
307
|
-
deps.state.mutationsWithoutPlan++;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
onAfterTool: (ctx, call, result) => {
|
|
312
|
-
// Запоминаем каждый вызов bash (успех или нет): детекция рассуждает,
|
|
313
|
-
// напр., о повторных прогонах с пустым выводом.
|
|
314
|
-
if (call.name === "bash") {
|
|
315
|
-
deps.stuckDetector.recordBashOutput(String(call.arguments?.command ?? ""), String(result.output ?? ""));
|
|
316
|
-
}
|
|
317
|
-
// Авто-детект delete-намерения из действий модели: при вызове delete_file
|
|
318
|
-
// находим совпадающий шаг плана и ставим kind="delete". Языконезависимо —
|
|
319
|
-
// по СДЕЛАННОМУ моделью, не по сказанному.
|
|
320
|
-
if (call.name === "delete_file" && result.success && deps.trackerRef.current) {
|
|
321
|
-
const deletedPath = String(call.arguments?.path ?? "");
|
|
322
|
-
if (deletedPath) {
|
|
323
|
-
const plan = deps.trackerRef.current.getPlan();
|
|
324
|
-
const tokens = extractFileLikeTokens(stripUrls(deletedPath));
|
|
325
|
-
for (const step of plan.steps) {
|
|
326
|
-
if (step.status !== "pending" && step.status !== "in_progress")
|
|
327
|
-
continue;
|
|
328
|
-
const stepTokens = extractFileLikeTokens(stripUrls(step.description));
|
|
329
|
-
const overlap = tokens.some((t) => stepTokens.some((st) => t.endsWith(st) || st.endsWith(t)));
|
|
330
|
-
if (overlap) {
|
|
331
|
-
switchStepToDelete(plan, step, (p) => deps.store.saveActive(p));
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
// write/edit/bash с успехом, но type/syntax-ошибкой в выводе — НЕ успех:
|
|
338
|
-
// модель чинит реальную ошибку, а не переписывает файл вслепую. Кормим
|
|
339
|
-
// stuck-детектор, чтобы сработал хинт rewrite-петли.
|
|
340
|
-
const toolText = String(result.output ?? "");
|
|
341
|
-
const hasTypeError = /error TS\d+|\[Project typecheck failed\]|\[Syntax check failed\]/.test(toolText);
|
|
342
|
-
if (hasTypeError) {
|
|
343
|
-
deps.stuckDetector.recordToolError(call.name, toolText.slice(0, 300));
|
|
344
|
-
}
|
|
345
|
-
// Трекаем compile-фейлы пофайлово: done-gate плана реджектит "done", пока
|
|
346
|
-
// последняя правка не компилируется (было: агент маркил шаги done, а
|
|
347
|
-
// проектный typecheck фейлился на каждой записи — каскад "починю позже").
|
|
348
|
-
// ЧИСТЫЙ результат чистит карту: дебаунснутый проектный tsc перегнал и
|
|
349
|
-
// прошёл (или tsconfig неприменим) — старые фейлы завершение вечно не
|
|
350
|
-
// блокируют.
|
|
351
|
-
if (call.name === "write_file" || call.name === "edit_file") {
|
|
352
|
-
const broken = extractBrokenFiles(toolText);
|
|
353
|
-
if (broken.length > 0) {
|
|
354
|
-
for (const b of broken)
|
|
355
|
-
deps.state.typecheckFailures.set(b.file, b.error);
|
|
356
|
-
}
|
|
357
|
-
else if (result.success) {
|
|
358
|
-
// Чистим только записи только что писанного/правленного файла (и
|
|
359
|
-
// проектную безадресную запись, которую чистая правка вероятно
|
|
360
|
-
// закрыла). Сплошной `.clear()` стирал несвязанный успешной правкой
|
|
361
|
-
// чужой фейл, обходя done-gate.
|
|
362
|
-
const edited = normalizeBrokenPath(String(call.arguments?.path ?? ""));
|
|
363
|
-
for (const key of [...deps.state.typecheckFailures.keys()]) {
|
|
364
|
-
if (key === "" ||
|
|
365
|
-
!edited ||
|
|
366
|
-
key === edited ||
|
|
367
|
-
key.endsWith(edited) ||
|
|
368
|
-
edited.endsWith(key)) {
|
|
369
|
-
deps.state.typecheckFailures.delete(key);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (!result.success) {
|
|
375
|
-
// Исход bash-попытки кормим во флейлинг-окно ДО пер-командной обработки —
|
|
376
|
-
// ротация разных фейлящихся команд (wc → cat → Get-Content → …) обязана
|
|
377
|
-
// триггерить детектор.
|
|
378
|
-
if (call.name === "bash") {
|
|
379
|
-
deps.stuckDetector.recordBashAttempt(false);
|
|
380
|
-
}
|
|
381
|
-
// Hard stop для запрещённых Windows-команд: после второго фейла той же
|
|
382
|
-
// запрещённой команды (grep/sed/ls/find/…) инжектим STOP, чтобы сессия
|
|
383
|
-
// не жгла bash-вызовы на командах без cmd.exe. Зеркалит собственный
|
|
384
|
-
// win32-gated hard-stop тула bash (src/tools/bash.ts) — на macOS/Linux
|
|
385
|
-
// эти команды есть и фейлятся по легитимным причинам.
|
|
386
|
-
if (call.name === "bash" && platform() === "win32") {
|
|
387
|
-
const cmd = String(call.arguments?.command ?? "");
|
|
388
|
-
const forbidden = forbiddenWindowsCommand(cmd);
|
|
389
|
-
if (forbidden) {
|
|
390
|
-
const n = (deps.forbiddenBashFailures.get(forbidden) || 0) + 1;
|
|
391
|
-
deps.forbiddenBashFailures.set(forbidden, n);
|
|
392
|
-
if (n === 2) {
|
|
393
|
-
deps.pendingMessages.push({
|
|
394
|
-
role: "user",
|
|
395
|
-
content: `<system-summary>${t("exec.forbidden_cmd", { cmd: forbidden })}</system-summary>`,
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
// Type/syntax-ошибка в иначе "успешном" результате уже записана выше.
|
|
401
|
-
// Фейлящийся вызов (result.success === false) иначе посчитал бы ту же
|
|
402
|
-
// ошибку дважды (typecheck-ветка + failure-ветка), раздув счётчик
|
|
403
|
-
// error-сигнатур и триггернув веб-поиск на половине порога.
|
|
404
|
-
if (!hasTypeError) {
|
|
405
|
-
deps.stuckDetector.recordToolError(call.name, result.output);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
// "Успешная" запись/правка может нести type/syntax-ошибку (lint-on-write
|
|
410
|
-
// хук аппендит её, оставляя success:true). Скормленный здесь
|
|
411
|
-
// recordToolSuccess() отменял recordToolError выше на том же вызове —
|
|
412
|
-
// rewrite-loop сигнал не накапливался.
|
|
413
|
-
if (!hasTypeError)
|
|
414
|
-
deps.stuckDetector.recordToolSuccess();
|
|
415
|
-
if (call.name === "bash") {
|
|
416
|
-
deps.stuckDetector.recordBashAttempt(true);
|
|
417
|
-
}
|
|
418
|
-
// Успешно отработавшая команда bash с кодом — предлагаем маркить шаг
|
|
419
|
-
// done, если только вывод не показывает упавшие тесты (их нельзя
|
|
420
|
-
// репортить чистым успехом).
|
|
421
|
-
if (call.name === "bash" && result.success) {
|
|
422
|
-
const cmd = String(call.arguments?.command ?? "");
|
|
423
|
-
const testRun = detectTestResults(String(result.output ?? ""));
|
|
424
|
-
if (testRun && testRun.failed > 0) {
|
|
425
|
-
deps.pendingMessages.push({
|
|
426
|
-
role: "user",
|
|
427
|
-
content: `<system-summary>${t("exec.test_fail_summary", {
|
|
428
|
-
framework: testRun.framework,
|
|
429
|
-
failed: String(testRun.failed),
|
|
430
|
-
passed: String(testRun.passed),
|
|
431
|
-
})}</system-summary>`,
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
else if (testRun && testRun.failed === 0 && testRun.passed > 0) {
|
|
435
|
-
deps.pendingMessages.push({
|
|
436
|
-
role: "user",
|
|
437
|
-
content: `<system-summary>${t("exec.test_pass_summary", {
|
|
438
|
-
framework: testRun.framework,
|
|
439
|
-
passed: String(testRun.passed),
|
|
440
|
-
cmd,
|
|
441
|
-
})}</system-summary>`,
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (result.success && (call.name === "write_file" || call.name === "edit_file")) {
|
|
447
|
-
const filePath = call.arguments?.path;
|
|
448
|
-
if (filePath) {
|
|
449
|
-
deps.stuckDetector.recordFileRewrite(filePath);
|
|
450
|
-
if (deps.stuckDetector.hasExcessiveRewrites()) {
|
|
451
|
-
const file = deps.stuckDetector.getExcessiveRewriteFile();
|
|
452
|
-
const count = deps.stuckDetector.getFileRewriteCount(file);
|
|
453
|
-
if (ctx.onMeta) {
|
|
454
|
-
ctx.onMeta(t("exec.file_rewrite_warning", {
|
|
455
|
-
file: file,
|
|
456
|
-
count: String(count),
|
|
457
|
-
}));
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
// Автопродвижение срабатывает после каждого успешного ФС-МУТИРУЮЩЕГО
|
|
463
|
-
// тула, не только write_file/edit_file. Мелкие модели часто создают файлы
|
|
464
|
-
// через bash (`echo ... > f`, heredoc'и) или delete/move через shell
|
|
465
|
-
// вместо выделенных тулов — план тогда не двигается с шага, хотя
|
|
466
|
-
// deliverables на диске (сертификация 3.5/3.8: файлы на месте, план
|
|
467
|
-
// висит на 1/4 и 4/5). Read-only тулы исключены: успешный read/glob иначе
|
|
468
|
-
// закрыл бы шаг "Update X", чей файл существует с раннего шага, — без
|
|
469
|
-
// единой правки. advancePlanIfStepComplete — no-op, если токены не резолвятся.
|
|
470
|
-
if (result.success && FS_MUTATING_TOOLS.has(call.name)) {
|
|
471
|
-
deps.advancePlanIfStepComplete(ctx.sessionLog);
|
|
472
|
-
}
|
|
473
|
-
// Автопоиск в вебе повторяющейся ошибки (fire-and-forget, результаты
|
|
474
|
-
// падают в pendingMessages на следующем флаше onBeforeThink).
|
|
475
|
-
deps.maybeSearchError(ctx, call);
|
|
476
|
-
},
|
|
477
|
-
};
|
|
478
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Модуль исполнения: реэкспорт планов, трекера, верификатора, stuck-детектора, аудитора.
|
|
2
|
-
export { ExecutionModule } from "./module";
|
|
3
|
-
export { PlanCreator } from "./planner";
|
|
4
|
-
export { PlanTracker } from "./tracker";
|
|
5
|
-
export { StepVerifier } from "./verifier";
|
|
6
|
-
export { StuckDetector } from "./stuck-detector";
|
|
7
|
-
export { Auditor } from "./auditor";
|
|
8
|
-
export { PlanStore } from "./plan-store";
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Принимает обе формы input_from: компактную (`["task-1"]`) и детальную
|
|
3
|
-
* (`[{"subtaskId": "task-1", "field": "json"}]`).
|
|
4
|
-
*/
|
|
5
|
-
export function normalizeInputFrom(input) {
|
|
6
|
-
if (!Array.isArray(input))
|
|
7
|
-
return [];
|
|
8
|
-
const refs = [];
|
|
9
|
-
for (const entry of input) {
|
|
10
|
-
if (typeof entry === "string") {
|
|
11
|
-
refs.push({ subtaskId: entry });
|
|
12
|
-
}
|
|
13
|
-
else if (entry && typeof entry === "object") {
|
|
14
|
-
const obj = entry;
|
|
15
|
-
if (typeof obj.subtaskId === "string") {
|
|
16
|
-
refs.push({
|
|
17
|
-
subtaskId: obj.subtaskId,
|
|
18
|
-
field: typeof obj.field === "string" ? obj.field : undefined,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return refs;
|
|
24
|
-
}
|
|
25
|
-
function truncate(text, cap) {
|
|
26
|
-
const flat = text.replace(/\s+/g, " ").trim();
|
|
27
|
-
if (flat.length <= cap)
|
|
28
|
-
return flat;
|
|
29
|
-
return `${flat.slice(0, cap)}…`;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Рендерит секцию "Input from previous tasks" для промпта зависимой
|
|
33
|
-
* подзадачи. Упавшие зависимости помечаются явно, чтобы читатель не строил
|
|
34
|
-
* логику на отсутствующих данных.
|
|
35
|
-
*/
|
|
36
|
-
export function buildInputSection(subtask, depResults, maxChars) {
|
|
37
|
-
const refs = normalizeInputFrom(subtask.input_from);
|
|
38
|
-
if (refs.length === 0)
|
|
39
|
-
return "";
|
|
40
|
-
// Агрегатный кап: без него 10 зависимостей × maxChars раздувают промпт
|
|
41
|
-
// выше бюджета контекста маленькой модели.
|
|
42
|
-
const totalCap = maxChars * 4;
|
|
43
|
-
const lines = [];
|
|
44
|
-
let used = 0;
|
|
45
|
-
let omitted = 0;
|
|
46
|
-
for (const ref of refs) {
|
|
47
|
-
const dep = depResults.get(ref.subtaskId);
|
|
48
|
-
if (!dep) {
|
|
49
|
-
const line = `- ${ref.subtaskId}: (no result available)`;
|
|
50
|
-
lines.push(line);
|
|
51
|
-
used += line.length;
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const label = ref.field ? `${ref.subtaskId}.${ref.field}` : ref.subtaskId;
|
|
55
|
-
const body = dep.success
|
|
56
|
-
? truncate(dep.result || dep.summary, maxChars)
|
|
57
|
-
: `[FAILED] ${truncate(dep.error || dep.summary || "unknown error", maxChars)}`;
|
|
58
|
-
const line = `- ${label}: ${body}`;
|
|
59
|
-
if (used + line.length > totalCap) {
|
|
60
|
-
omitted++;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
lines.push(line);
|
|
64
|
-
used += line.length;
|
|
65
|
-
}
|
|
66
|
-
if (omitted > 0) {
|
|
67
|
-
lines.push(`- (${omitted} more input(s) omitted: input budget reached)`);
|
|
68
|
-
}
|
|
69
|
-
return `\n\nInput from previous tasks:\n${lines.join("\n")}`;
|
|
70
|
-
}
|