salmon-loop 0.2.3 → 0.2.16
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/dist/cli/argv/headless-detection.js +27 -0
- package/dist/cli/chat-flow.js +11 -0
- package/dist/cli/chat.js +161 -24
- package/dist/cli/commands/chat.js +30 -24
- package/dist/cli/commands/context.js +15 -3
- package/dist/cli/commands/flow-mode.js +63 -0
- package/dist/cli/commands/help-format.js +12 -0
- package/dist/cli/commands/registry.js +6 -7
- package/dist/cli/commands/run/benchmark-artifacts.js +41 -0
- package/dist/cli/commands/run/config-resolution.js +30 -24
- package/dist/cli/commands/run/early-errors.js +23 -0
- package/dist/cli/commands/run/handler.js +131 -44
- package/dist/cli/commands/run/headless-error-writer.js +8 -0
- package/dist/cli/commands/run/loop-params.js +3 -0
- package/dist/cli/commands/run/mode.js +2 -5
- package/dist/cli/commands/run/parse-options.js +18 -2
- package/dist/cli/commands/run/persist-session.js +10 -1
- package/dist/cli/commands/run/preflight.js +10 -0
- package/dist/cli/commands/run/reporter-factory.js +4 -0
- package/dist/cli/commands/run/runtime-llm.js +38 -11
- package/dist/cli/commands/run/runtime-options.js +2 -2
- package/dist/cli/commands/run/validate-options.js +0 -5
- package/dist/cli/commands/run/verbose.js +2 -7
- package/dist/cli/commands/serve.js +117 -90
- package/dist/cli/commands/tool-names.js +78 -78
- package/dist/cli/headless/anthropic-stream-normalized-encoder.js +6 -1
- package/dist/cli/headless/json-protocol.js +37 -0
- package/dist/cli/headless/native-stream-normalized-encoder.js +6 -1
- package/dist/cli/headless/protocol-metadata.js +22 -0
- package/dist/cli/headless/stream-json-protocol.js +34 -1
- package/dist/cli/index.js +6 -4
- package/dist/cli/locales/en.js +32 -6
- package/dist/cli/program-bootstrap.js +14 -4
- package/dist/cli/program-commands.js +9 -1
- package/dist/cli/program-options.js +1 -0
- package/dist/cli/reporters/anthropic-stream.js +7 -1
- package/dist/cli/reporters/json.js +4 -0
- package/dist/cli/reporters/stream-json.js +17 -2
- package/dist/cli/run-cli.js +5 -3
- package/dist/cli/slash/runtime.js +30 -15
- package/dist/cli/ui/components/CommandInput.js +7 -3
- package/dist/cli/ui/components/CommandSuggestionList.js +1 -1
- package/dist/cli/utils/command-option-source.js +13 -0
- package/dist/cli/utils/output-format.js +6 -0
- package/dist/cli/utils/resolve-cli-config.js +98 -0
- package/dist/cli/utils/verbose-level.js +8 -0
- package/dist/cli/utils/verify-resolver.js +8 -4
- package/dist/cli/utils/worktree-prepare-resolver.js +7 -3
- package/dist/core/adapters/fs/file-adapter.js +6 -0
- package/dist/core/adapters/fs/filesystem.js +2 -1
- package/dist/core/adapters/git/git-adapter.js +78 -1
- package/dist/core/benchmark/patch-artifact.js +124 -0
- package/dist/core/benchmark/swe-bench.js +25 -0
- package/dist/core/config/load.js +39 -18
- package/dist/core/config/merge.js +27 -0
- package/dist/core/config/paths.js +24 -5
- package/dist/core/config/resolve-llm.js +12 -0
- package/dist/core/config/resolve.js +7 -5
- package/dist/core/config/resolvers/server.js +0 -6
- package/dist/core/config/validate.js +94 -21
- package/dist/core/context/gatherers/metadata-gatherer.js +1 -0
- package/dist/core/context/gatherers/ripgrep-gatherer.js +84 -2
- package/dist/core/context/keywords.js +18 -4
- package/dist/core/context/service-deps.js +2 -2
- package/dist/core/context/service.js +8 -0
- package/dist/core/context/steps/context-gather.js +38 -0
- package/dist/core/context/summarization/summarizer.js +55 -12
- package/dist/core/context/targeting/target-resolver.js +4 -4
- package/dist/core/extensions/index.js +23 -5
- package/dist/core/extensions/paths.js +31 -0
- package/dist/core/extensions/schemas.js +8 -5
- package/dist/core/facades/cli-chat.js +6 -2
- package/dist/core/facades/cli-command-chat.js +2 -1
- package/dist/core/facades/cli-command-tool-names.js +2 -0
- package/dist/core/facades/cli-context.js +1 -0
- package/dist/core/facades/cli-observability.js +1 -1
- package/dist/core/facades/cli-run-handler.js +4 -2
- package/dist/core/facades/cli-run-persist-session.js +1 -0
- package/dist/core/facades/cli-serve.js +2 -4
- package/dist/core/facades/cli-utils-worktree.js +1 -1
- package/dist/core/failure/diagnostics.js +53 -1
- package/dist/core/grizzco/dsl/llm-strategy.js +4 -1
- package/dist/core/grizzco/engine/outcome/loop-result-mapper.js +67 -9
- package/dist/core/grizzco/engine/pipeline/pipeline.js +6 -2
- package/dist/core/grizzco/engine/transaction/attempt-failure.js +90 -15
- package/dist/core/grizzco/engine/transaction/report-mapper.js +17 -3
- package/dist/core/grizzco/engine/transaction/transaction-runner.js +173 -7
- package/dist/core/grizzco/flows/AutopilotFlow.js +18 -0
- package/dist/core/grizzco/flows/flow-dispatch.js +11 -0
- package/dist/core/grizzco/steps/answer.js +13 -14
- package/dist/core/grizzco/steps/autopilot.js +396 -0
- package/dist/core/grizzco/steps/cache-sharing.js +29 -0
- package/dist/core/grizzco/steps/explore.js +37 -21
- package/dist/core/grizzco/steps/generateReview.js +2 -5
- package/dist/core/grizzco/steps/patch/apply-check.js +10 -0
- package/dist/core/grizzco/steps/patch/diff-normalization.js +70 -0
- package/dist/core/grizzco/steps/patch/diff-salvage.js +46 -0
- package/dist/core/grizzco/steps/patch/prompt-input.js +42 -0
- package/dist/core/grizzco/steps/patch.js +105 -146
- package/dist/core/grizzco/steps/plan.js +101 -25
- package/dist/core/grizzco/steps/preflight.js +5 -3
- package/dist/core/grizzco/steps/request-assembly.js +78 -0
- package/dist/core/grizzco/steps/research.js +39 -36
- package/dist/core/grizzco/steps/tool-runtime.js +47 -0
- package/dist/core/grizzco/steps/verify-shared.js +23 -0
- package/dist/core/grizzco/steps/verify.js +13 -21
- package/dist/core/intent/chat-intent.js +0 -4
- package/dist/core/llm/ai-sdk/chat-executor.js +2 -0
- package/dist/core/llm/ai-sdk/high-level-phase-specs.js +63 -0
- package/dist/core/llm/ai-sdk/message-mapper.js +40 -10
- package/dist/core/llm/ai-sdk/provider-factory.js +14 -0
- package/dist/core/llm/ai-sdk/request-params.js +74 -1
- package/dist/core/llm/ai-sdk/result-mapper.js +16 -0
- package/dist/core/llm/ai-sdk.js +112 -27
- package/dist/core/llm/capabilities.js +12 -0
- package/dist/core/llm/contracts/repair.js +36 -30
- package/dist/core/llm/errors.js +83 -2
- package/dist/core/llm/message-composition.js +7 -22
- package/dist/core/llm/phase-router.js +29 -10
- package/dist/core/llm/redact.js +28 -3
- package/dist/core/llm/registry.js +2 -0
- package/dist/core/llm/request-augmentation.js +55 -0
- package/dist/core/llm/request-envelope.js +334 -0
- package/dist/core/llm/shared-request-assembly.js +35 -0
- package/dist/core/llm/stream-utils.js +13 -4
- package/dist/core/llm/utils.js +18 -29
- package/dist/core/memory/relevant-retrieval.js +144 -0
- package/dist/core/observability/logger.js +11 -2
- package/dist/core/patch/diff.js +1 -0
- package/dist/core/prompts/registry.js +39 -2
- package/dist/core/prompts/runtime.js +50 -12
- package/dist/core/prompts/templates/phases/patch_user.hbs +2 -5
- package/dist/core/prompts/templates/phases/research_user.hbs +11 -0
- package/dist/core/prompts/templates/phases/review_user.hbs +3 -0
- package/dist/core/prompts/templates/system/answer_system.hbs +5 -0
- package/dist/core/prompts/templates/system/autopilot_system.hbs +11 -0
- package/dist/core/prompts/templates/system/explore_system.hbs +14 -23
- package/dist/core/prompts/templates/system/main_system.hbs +4 -16
- package/dist/core/prompts/templates/system/patch_system.hbs +39 -8
- package/dist/core/prompts/templates/system/plan_system.hbs +86 -1
- package/dist/core/prompts/templates/system/research_system.hbs +2 -0
- package/dist/core/protocols/a2a/agent-card.js +3 -2
- package/dist/core/protocols/a2a/sdk/executor.js +8 -6
- package/dist/core/protocols/a2a/sdk/server.js +0 -1
- package/dist/core/protocols/acp/formal-agent.js +221 -55
- package/dist/core/protocols/acp/handlers.js +5 -1
- package/dist/core/protocols/acp/permission-provider.js +21 -1
- package/dist/core/protocols/shared/execution-request.js +24 -0
- package/dist/core/protocols/shared/flow-mode-mapping.js +23 -0
- package/dist/core/public-capabilities/flow-mode-metadata.js +39 -0
- package/dist/core/public-capabilities/projections.js +29 -0
- package/dist/core/public-capabilities/registry.js +26 -0
- package/dist/core/public-capabilities/types.js +2 -0
- package/dist/core/runtime/agent-server-runtime.js +47 -43
- package/dist/core/runtime/execution-profile.js +67 -0
- package/dist/core/session/artifact-state.js +160 -0
- package/dist/core/session/compaction/index.js +183 -0
- package/dist/core/session/compaction/microcompact.js +78 -0
- package/dist/core/session/compaction/tracking.js +48 -0
- package/dist/core/session/compaction/types.js +11 -0
- package/dist/core/session/compression.js +12 -4
- package/dist/core/session/manager.js +247 -10
- package/dist/core/session/pruning-strategy.js +55 -9
- package/dist/core/session/replacement-preview-provider.js +24 -0
- package/dist/core/session/replacement-state.js +131 -0
- package/dist/core/session/resume-repair/pipeline.js +79 -0
- package/dist/core/session/resume-repair/stages/load-raw-archive-state.js +40 -0
- package/dist/core/session/resume-repair/stages/reattach-runtime-state.js +8 -0
- package/dist/core/session/resume-repair/stages/recover-orphaned-branches.js +10 -0
- package/dist/core/session/resume-repair/stages/relink-boundary-and-tail.js +36 -0
- package/dist/core/session/resume-repair/stages/replay-startup-hooks.js +23 -0
- package/dist/core/session/resume-repair/stages/rescue-stale-metadata.js +17 -0
- package/dist/core/session/resume-repair/types.js +2 -0
- package/dist/core/session/summary-sync.js +164 -13
- package/dist/core/session/token-tracker.js +6 -0
- package/dist/core/skills/audit.js +34 -0
- package/dist/core/skills/bridge.js +84 -7
- package/dist/core/skills/discovery.js +94 -0
- package/dist/core/skills/feature-flags.js +52 -0
- package/dist/core/skills/index.js +1 -1
- package/dist/core/skills/loader.js +195 -20
- package/dist/core/skills/parser.js +296 -24
- package/dist/core/skills/permissions.js +117 -0
- package/dist/core/skills/runtime/MicroTaskRunner.js +10 -4
- package/dist/core/skills/runtime/SkillRunner.js +240 -61
- package/dist/core/strata/layers/shadow-driver/shadow-driver.js +37 -7
- package/dist/core/strata/layers/worktree.js +70 -13
- package/dist/core/strata/runtime/synchronizer.js +29 -2
- package/dist/core/streaming/stream-assembler.js +75 -31
- package/dist/core/sub-agent/context-snapshot.js +156 -0
- package/dist/core/sub-agent/core/loop.js +1 -1
- package/dist/core/sub-agent/core/manager.js +119 -20
- package/dist/core/sub-agent/dispatch-policy.js +29 -0
- package/dist/core/sub-agent/prefix-consistency.js +48 -0
- package/dist/core/sub-agent/registry-defaults.js +4 -0
- package/dist/core/sub-agent/tools/task-spawn.js +79 -2
- package/dist/core/sub-agent/types.js +134 -5
- package/dist/core/tools/audit.js +13 -4
- package/dist/core/tools/builtin/ast-grep.js +1 -1
- package/dist/core/tools/builtin/ast.js +1 -1
- package/dist/core/tools/builtin/benchmark.js +360 -0
- package/dist/core/tools/builtin/code-search/backends/rg.js +2 -1
- package/dist/core/tools/builtin/code-search/executor.js +6 -1
- package/dist/core/tools/builtin/code-search/spec.js +26 -2
- package/dist/core/tools/builtin/fs.js +256 -23
- package/dist/core/tools/builtin/git.js +2 -2
- package/dist/core/tools/builtin/index.js +51 -2
- package/dist/core/tools/builtin/interaction.js +8 -1
- package/dist/core/tools/builtin/plan.js +37 -15
- package/dist/core/tools/builtin/shell.js +1 -1
- package/dist/core/tools/loader.js +39 -16
- package/dist/core/tools/mapper.js +17 -3
- package/dist/core/tools/parallel/scheduler.js +35 -4
- package/dist/core/tools/permissions/permission-rules.js +5 -10
- package/dist/core/tools/policy.js +6 -1
- package/dist/core/tools/recoverable-tool-errors.js +10 -0
- package/dist/core/tools/router.js +24 -6
- package/dist/core/tools/session.js +458 -48
- package/dist/core/tools/tool-visibility.js +62 -0
- package/dist/core/tools/types.js +9 -1
- package/dist/core/types/execution.js +4 -0
- package/dist/core/types/flow-mode.js +8 -0
- package/dist/core/utils/path.js +52 -0
- package/dist/core/verification/runner.js +4 -1
- package/dist/interfaces/cli/task-runner.js +4 -3
- package/dist/languages/typescript/index.js +4 -1
- package/dist/locales/en.js +87 -2
- package/dist/utils/eol.js +1 -1
- package/package.json +15 -8
- package/scripts/fix-es-abstract-compat.js +77 -0
- package/dist/core/runtime/fastify-server-bundle.js +0 -26
- package/dist/core/runtime/sidecar-fastify-plugin.js +0 -35
- package/dist/core/runtime/sidecar-paths.js +0 -47
- package/dist/core/runtime/sidecar-route-catalog.js +0 -103
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
import { redactConfigForPrint
|
|
1
|
+
import { redactConfigForPrint } from '../../../core/config/index.js';
|
|
2
2
|
import { getLogger } from '../../../core/facades/cli-observability.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveCliConfig } from '../../utils/resolve-cli-config.js';
|
|
4
4
|
export async function resolveRunConfig(params) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
getLogger().error(msg);
|
|
17
|
-
if (params.outputFormat === 'json') {
|
|
18
|
-
params.writeJsonFailure({ message: msg, errorCode: err.code, repoPath: params.repoPath });
|
|
19
|
-
}
|
|
20
|
-
return { ok: false, exitCode: 1 };
|
|
21
|
-
}
|
|
22
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
23
|
-
getLogger().error(text.config.loadFailed(msg));
|
|
5
|
+
const resolved = await resolveCliConfig({
|
|
6
|
+
repoPath: params.repoPath,
|
|
7
|
+
configPath: params.cliOptions.config,
|
|
8
|
+
enableConfigFile: params.cliOptions.configFile !== false,
|
|
9
|
+
auditScope: params.cliOptions.auditScope,
|
|
10
|
+
verbose: params.cliOptions.verbose,
|
|
11
|
+
outputFormat: params.cliOptions.outputFormat,
|
|
12
|
+
logMode: params.cliOptions.logMode,
|
|
13
|
+
});
|
|
14
|
+
if (!resolved.ok) {
|
|
15
|
+
getLogger().error(resolved.message);
|
|
24
16
|
if (params.outputFormat === 'json') {
|
|
25
|
-
params.writeJsonFailure({
|
|
17
|
+
params.writeJsonFailure({
|
|
18
|
+
message: resolved.message,
|
|
19
|
+
errorCode: resolved.errorCode,
|
|
20
|
+
repoPath: params.repoPath,
|
|
21
|
+
});
|
|
26
22
|
}
|
|
27
23
|
return { ok: false, exitCode: 1 };
|
|
28
24
|
}
|
|
29
25
|
if (params.cliOptions.printConfig) {
|
|
30
|
-
const raw = resolvedConfig.raw || { version: 1 };
|
|
26
|
+
const raw = resolved.resolvedConfig.raw || { version: 1 };
|
|
31
27
|
const redacted = redactConfigForPrint(raw);
|
|
32
28
|
process.stdout.write(JSON.stringify(redacted, null, 2) + '\n');
|
|
33
29
|
return { ok: true, printedConfig: true };
|
|
34
30
|
}
|
|
35
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
ok: true,
|
|
33
|
+
resolvedConfig: {
|
|
34
|
+
repoPath: resolved.repoPath,
|
|
35
|
+
verboseLevel: resolved.verboseLevel,
|
|
36
|
+
outputFormat: resolved.outputFormat,
|
|
37
|
+
headlessOutput: resolved.headlessOutput,
|
|
38
|
+
resolvedConfig: resolved.resolvedConfig,
|
|
39
|
+
auditScope: resolved.auditScope,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
36
42
|
}
|
|
37
43
|
//# sourceMappingURL=config-resolution.js.map
|
|
@@ -57,6 +57,7 @@ export function handleEarlyRunCommandErrors(params) {
|
|
|
57
57
|
instruction: params.instruction,
|
|
58
58
|
message: text.cli.outputProfileRequiresStreamJson,
|
|
59
59
|
exitCode: 1,
|
|
60
|
+
errorCode: 'USAGE_ERROR',
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
return { ok: false, exitCode: 1 };
|
|
@@ -103,6 +104,28 @@ export function handleEarlyRunCommandErrors(params) {
|
|
|
103
104
|
}
|
|
104
105
|
return { ok: false, exitCode: 1 };
|
|
105
106
|
}
|
|
107
|
+
if (params.sweBenchPredictionsPath && !params.sweBenchInstanceId) {
|
|
108
|
+
getLogger().error(text.cli.sweBenchInstanceRequired);
|
|
109
|
+
if (params.headlessOutput) {
|
|
110
|
+
params.headlessErrorWriter.writeUsageError({
|
|
111
|
+
sessionId: params.sessionIdForOutput ?? params.resumeSessionId,
|
|
112
|
+
message: text.cli.sweBenchInstanceRequired,
|
|
113
|
+
instruction: params.instruction,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return { ok: false, exitCode: 1 };
|
|
117
|
+
}
|
|
118
|
+
if (params.sweBenchPredictionsPath && !params.sweBenchModelName) {
|
|
119
|
+
getLogger().error(text.cli.sweBenchModelRequired);
|
|
120
|
+
if (params.headlessOutput) {
|
|
121
|
+
params.headlessErrorWriter.writeUsageError({
|
|
122
|
+
sessionId: params.sessionIdForOutput ?? params.resumeSessionId,
|
|
123
|
+
message: text.cli.sweBenchModelRequired,
|
|
124
|
+
instruction: params.instruction,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return { ok: false, exitCode: 1 };
|
|
128
|
+
}
|
|
106
129
|
return { ok: true };
|
|
107
130
|
}
|
|
108
131
|
//# sourceMappingURL=early-errors.js.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { buildEffectiveConversationContext, createPluginRegistry, createPromptRegistry, getExitCode, getDefaultSessionContextBudgetTokens, getLogger, normalizePermissionMode, resolveExecutionProfile, SilentReporter, setPluginRegistry, setPromptRegistry, } from '../../../core/facades/cli-run-handler.js';
|
|
3
3
|
import { createStdoutWriter } from '../../headless/stdout-writer.js';
|
|
4
4
|
import { text } from '../../locales/index.js';
|
|
5
|
-
import {
|
|
6
|
-
import { resolveAuditScope } from '../../utils/audit-scope.js';
|
|
5
|
+
import { getOptionValueSourceWithGlobalFallback } from '../../utils/command-option-source.js';
|
|
7
6
|
import { createOutcomeReporter } from '../../utils/outcome-reporter.js';
|
|
7
|
+
import { resolveOutputFormat } from '../../utils/output-format.js';
|
|
8
|
+
import { resolveCliCommonOptions } from '../../utils/resolve-cli-config.js';
|
|
8
9
|
import { buildRunAssistantMessage } from './assistant-message.js';
|
|
10
|
+
import { attachRunBenchmarkArtifacts } from './benchmark-artifacts.js';
|
|
9
11
|
import { resolveRunConfig } from './config-resolution.js';
|
|
10
12
|
import { handleEarlyRunCommandErrors } from './early-errors.js';
|
|
11
13
|
import { executeRunLoop } from './execute.js';
|
|
@@ -22,7 +24,7 @@ import { createRuntimeLlmAndWarn } from './runtime-llm.js';
|
|
|
22
24
|
import { resolveRunRuntimeOptions } from './runtime-options.js';
|
|
23
25
|
import { initializeSession } from './session.js';
|
|
24
26
|
import { buildStructuredOutputState } from './structured-output.js';
|
|
25
|
-
import { logRunVerboseSummary
|
|
27
|
+
import { logRunVerboseSummary } from './verbose.js';
|
|
26
28
|
export async function handleRunCommand(options, command) {
|
|
27
29
|
const parsed = parseRunCommandOptions(command);
|
|
28
30
|
const allOptions = parsed.allOptions;
|
|
@@ -36,13 +38,20 @@ export async function handleRunCommand(options, command) {
|
|
|
36
38
|
const explicitInstruction = parsed.explicitInstruction;
|
|
37
39
|
const jsonSchemaSpec = parsed.jsonSchemaSpec;
|
|
38
40
|
const rawOutputFormat = parsed.rawOutputFormat;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const commonOptions = resolveCliCommonOptions({
|
|
42
|
+
repoPath: runPath,
|
|
43
|
+
verbose: allOptions.verbose,
|
|
44
|
+
outputFormat: rawOutputFormat,
|
|
45
|
+
});
|
|
46
|
+
if (!commonOptions.ok) {
|
|
47
|
+
getLogger().error(commonOptions.message, true);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
const outputFormat = commonOptions.options.outputFormat ?? resolveOutputFormat(rawOutputFormat);
|
|
51
|
+
if (!outputFormat) {
|
|
42
52
|
getLogger().error(text.cli.invalidOutputFormat(rawOutputFormat), true);
|
|
43
53
|
process.exit(1);
|
|
44
54
|
}
|
|
45
|
-
const outputFormat = rawOutputFormat;
|
|
46
55
|
const headlessOutput = outputFormat !== 'text';
|
|
47
56
|
const rawOutputProfile = parsed.rawOutputProfile;
|
|
48
57
|
const outputProfileForStreamJson = parsed.outputProfileForStreamJson;
|
|
@@ -50,12 +59,16 @@ export async function handleRunCommand(options, command) {
|
|
|
50
59
|
const headlessIncludeToolOutput = parsed.headlessIncludeToolOutput;
|
|
51
60
|
const headlessIncludeAuthorizationDecisions = parsed.headlessIncludeAuthorizationDecisions;
|
|
52
61
|
const allowOutsideCacheRoot = parsed.allowOutsideCacheRoot;
|
|
62
|
+
const exportPatchPath = parsed.exportPatchPath;
|
|
63
|
+
const sweBenchInstanceId = parsed.sweBenchInstanceId;
|
|
64
|
+
const sweBenchModelName = parsed.sweBenchModelName;
|
|
65
|
+
const sweBenchPredictionsPath = parsed.sweBenchPredictionsPath;
|
|
53
66
|
const stdoutWriter = createStdoutWriter();
|
|
54
67
|
const instruction = parsed.instruction;
|
|
55
68
|
const printMode = Boolean(printInstruction);
|
|
56
69
|
const useGui = !headlessOutput && !printMode && allOptions.gui !== false && process.stdout.isTTY;
|
|
57
70
|
if (headlessOutput) {
|
|
58
|
-
getLogger().setReporter(new
|
|
71
|
+
getLogger().setReporter(new SilentReporter());
|
|
59
72
|
}
|
|
60
73
|
const wantSessionPersistence = !allOptions.printConfig &&
|
|
61
74
|
(headlessOutput ||
|
|
@@ -86,6 +99,9 @@ export async function handleRunCommand(options, command) {
|
|
|
86
99
|
continueSession,
|
|
87
100
|
resumeSessionId,
|
|
88
101
|
jsonSchemaSpec,
|
|
102
|
+
sweBenchInstanceId,
|
|
103
|
+
sweBenchModelName,
|
|
104
|
+
sweBenchPredictionsPath,
|
|
89
105
|
sessionIdForOutput,
|
|
90
106
|
headlessErrorWriter,
|
|
91
107
|
});
|
|
@@ -141,6 +157,7 @@ export async function handleRunCommand(options, command) {
|
|
|
141
157
|
repoPath: runPath,
|
|
142
158
|
validate: Boolean(allOptions.validate),
|
|
143
159
|
useGui,
|
|
160
|
+
headlessOutput,
|
|
144
161
|
preflightPolicy,
|
|
145
162
|
});
|
|
146
163
|
if (allOptions.validate && !instruction)
|
|
@@ -150,6 +167,7 @@ export async function handleRunCommand(options, command) {
|
|
|
150
167
|
exitCode: params.exitCode,
|
|
151
168
|
message: params.message,
|
|
152
169
|
errorCode: params.errorCode,
|
|
170
|
+
auditPath: params.auditPath,
|
|
153
171
|
repoPath: params.repoPath,
|
|
154
172
|
instruction: params.instruction,
|
|
155
173
|
sessionId: sessionIdForOutput ?? randomUUID(),
|
|
@@ -167,12 +185,13 @@ export async function handleRunCommand(options, command) {
|
|
|
167
185
|
}
|
|
168
186
|
if ('printedConfig' in configResult)
|
|
169
187
|
return;
|
|
170
|
-
const resolvedConfig = configResult.resolvedConfig;
|
|
188
|
+
const { resolvedConfig, auditScope } = configResult.resolvedConfig;
|
|
171
189
|
const runtimeOptions = await resolveRunRuntimeOptions({
|
|
172
190
|
repoPath: runPath,
|
|
173
191
|
resolvedConfig,
|
|
174
192
|
cliOptions: allOptions,
|
|
175
193
|
outputFormat,
|
|
194
|
+
headlessOutput,
|
|
176
195
|
writeJsonFailure: ({ message, repoPath }) => writeJsonFailure({ message, repoPath }),
|
|
177
196
|
});
|
|
178
197
|
if (!runtimeOptions.ok) {
|
|
@@ -197,24 +216,54 @@ export async function handleRunCommand(options, command) {
|
|
|
197
216
|
return;
|
|
198
217
|
}
|
|
199
218
|
const instructionText = instruction;
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
219
|
+
const actModeOptionSource = typeof command.getOptionValueSource === 'function'
|
|
220
|
+
? command.getOptionValueSource('actMode')
|
|
221
|
+
: undefined;
|
|
222
|
+
const rawActMode = actModeOptionSource === 'cli' ? allOptions.actMode : undefined;
|
|
223
|
+
const mode = resolveRunMode(rawActMode);
|
|
224
|
+
if (!mode) {
|
|
225
|
+
const invalidMode = String(rawActMode ?? allOptions.actMode);
|
|
226
|
+
getLogger().error(text.cli.invalidActMode(invalidMode));
|
|
227
|
+
if (outputFormat === 'json') {
|
|
228
|
+
writeJsonFailure({
|
|
229
|
+
message: text.cli.invalidActMode(invalidMode),
|
|
230
|
+
errorCode: 'USAGE_ERROR',
|
|
231
|
+
instruction,
|
|
232
|
+
repoPath: runPath,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
else if (outputFormat === 'stream-json') {
|
|
236
|
+
headlessErrorWriter.writeUsageError({
|
|
237
|
+
sessionId: sessionIdForOutput ?? randomUUID(),
|
|
238
|
+
message: text.cli.invalidActMode(invalidMode),
|
|
239
|
+
instruction,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
204
242
|
process.exitCode = 1;
|
|
205
243
|
return;
|
|
206
244
|
}
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
245
|
+
const profile = resolveExecutionProfile(mode);
|
|
246
|
+
const permissionModeOptionSource = getOptionValueSourceWithGlobalFallback(command, 'mode');
|
|
247
|
+
const rawPermissionMode = (permissionModeOptionSource === 'cli' ? allOptions.mode : undefined) ??
|
|
248
|
+
resolvedConfig.permissionMode ??
|
|
249
|
+
profile.defaultPermissionMode ??
|
|
250
|
+
'interactive';
|
|
251
|
+
const permissionMode = normalizePermissionMode(rawPermissionMode);
|
|
252
|
+
if (!permissionMode) {
|
|
253
|
+
const message = `Invalid --mode "${String(rawPermissionMode)}". Expected "interactive" or "yolo".`;
|
|
254
|
+
getLogger().error(message);
|
|
211
255
|
if (outputFormat === 'json') {
|
|
212
|
-
writeJsonFailure({
|
|
256
|
+
writeJsonFailure({
|
|
257
|
+
message,
|
|
258
|
+
errorCode: 'USAGE_ERROR',
|
|
259
|
+
instruction,
|
|
260
|
+
repoPath: runPath,
|
|
261
|
+
});
|
|
213
262
|
}
|
|
214
263
|
else if (outputFormat === 'stream-json') {
|
|
215
264
|
headlessErrorWriter.writeUsageError({
|
|
216
265
|
sessionId: sessionIdForOutput ?? randomUUID(),
|
|
217
|
-
message
|
|
266
|
+
message,
|
|
218
267
|
instruction,
|
|
219
268
|
});
|
|
220
269
|
}
|
|
@@ -227,6 +276,8 @@ export async function handleRunCommand(options, command) {
|
|
|
227
276
|
if (outputFormat === 'json') {
|
|
228
277
|
writeJsonFailure({
|
|
229
278
|
message: text.cli.invalidEnvironmentMode(rawEnvironmentMode),
|
|
279
|
+
errorCode: 'USAGE_ERROR',
|
|
280
|
+
instruction,
|
|
230
281
|
repoPath: runPath,
|
|
231
282
|
});
|
|
232
283
|
}
|
|
@@ -250,10 +301,21 @@ export async function handleRunCommand(options, command) {
|
|
|
250
301
|
return;
|
|
251
302
|
}
|
|
252
303
|
const extensionResolution = extensionsResult.extensionResolution;
|
|
304
|
+
const operationalHeadlessWarnings = [];
|
|
253
305
|
if (!effectiveVerify) {
|
|
254
|
-
|
|
306
|
+
if (!headlessOutput) {
|
|
307
|
+
getLogger().warn(text.verify.noCommandFound);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
operationalHeadlessWarnings.push({
|
|
311
|
+
code: 'VERIFY_COMMAND_MISSING',
|
|
312
|
+
message: text.verify.noCommandFound,
|
|
313
|
+
source: 'verify.runtime',
|
|
314
|
+
severity: 'warning',
|
|
315
|
+
});
|
|
316
|
+
}
|
|
255
317
|
}
|
|
256
|
-
const verboseLevel =
|
|
318
|
+
const verboseLevel = commonOptions.options.verboseLevel;
|
|
257
319
|
logRunVerboseSummary({
|
|
258
320
|
verboseLevel,
|
|
259
321
|
instruction: instructionText,
|
|
@@ -266,19 +328,14 @@ export async function handleRunCommand(options, command) {
|
|
|
266
328
|
dryRun: allOptions.dryRun,
|
|
267
329
|
configPath: resolvedConfig.source.used ? resolvedConfig.source.path || '' : undefined,
|
|
268
330
|
});
|
|
331
|
+
let lastKnownAuditPath;
|
|
332
|
+
let activeReporter;
|
|
333
|
+
let activeReporterStarted = false;
|
|
269
334
|
try {
|
|
270
|
-
const
|
|
271
|
-
cliValue: allOptions.auditScope,
|
|
272
|
-
configValue: resolvedConfig.observability.audit.scope,
|
|
273
|
-
});
|
|
274
|
-
if (!auditScopeResolution.ok) {
|
|
275
|
-
getLogger().error(text.cli.invalidAuditScope(auditScopeResolution.invalid), true);
|
|
276
|
-
process.exit(1);
|
|
277
|
-
}
|
|
278
|
-
const auditScope = auditScopeResolution.value;
|
|
279
|
-
const { llm } = createRuntimeLlmAndWarn({
|
|
335
|
+
const { llm, headlessWarnings } = createRuntimeLlmAndWarn({
|
|
280
336
|
llmConfig: resolvedConfig.llm,
|
|
281
337
|
langfuseEnabled: resolvedConfig.observability.langfuse.enabled,
|
|
338
|
+
headlessOutput,
|
|
282
339
|
});
|
|
283
340
|
let structuredOutputState = { ok: true, candidate: null };
|
|
284
341
|
const reporter = createRunReporter({
|
|
@@ -290,6 +347,7 @@ export async function handleRunCommand(options, command) {
|
|
|
290
347
|
writer: stdoutWriter,
|
|
291
348
|
verbose: Boolean(allOptions.verbose),
|
|
292
349
|
model: resolvedConfig.llm.models?.selectedModelId,
|
|
350
|
+
includeToolInput: headlessIncludeToolInput,
|
|
293
351
|
getStructuredOutput: () => structuredOutputState.ok ? structuredOutputState.candidate : null,
|
|
294
352
|
getPayloadOverrides: () => {
|
|
295
353
|
if (structuredOutputState.ok)
|
|
@@ -306,8 +364,11 @@ export async function handleRunCommand(options, command) {
|
|
|
306
364
|
structuredOutputError: structuredOutputState.errorReason,
|
|
307
365
|
};
|
|
308
366
|
},
|
|
367
|
+
getWarnings: () => [...headlessWarnings, ...operationalHeadlessWarnings],
|
|
309
368
|
});
|
|
369
|
+
activeReporter = reporter;
|
|
310
370
|
reporter.onStart(instructionText);
|
|
371
|
+
activeReporterStarted = true;
|
|
311
372
|
const applyBackOnDirty = allOptions.applyBackOnDirty === 'abort' ? 'abort' : '3way';
|
|
312
373
|
const outcomeReporter = createOutcomeReporter({
|
|
313
374
|
enabled: resolvedConfig.observability.langfuse.outcome,
|
|
@@ -321,11 +382,18 @@ export async function handleRunCommand(options, command) {
|
|
|
321
382
|
process.env.S8P_MODEL;
|
|
322
383
|
const shouldInjectSessionContext = Boolean(continueSession || resumeSessionId);
|
|
323
384
|
const conversationContext = shouldInjectSessionContext && sessionManager
|
|
324
|
-
?
|
|
385
|
+
? buildEffectiveConversationContext({
|
|
386
|
+
llm,
|
|
387
|
+
sessionManager,
|
|
325
388
|
budgetTokens: getDefaultSessionContextBudgetTokens({ modelId: modelIdForBudget }),
|
|
326
|
-
summaryState: sessionManager.getSummaryState(),
|
|
327
389
|
})
|
|
328
390
|
: [];
|
|
391
|
+
const artifactHints = shouldInjectSessionContext
|
|
392
|
+
? sessionManager?.getArtifactState()
|
|
393
|
+
: undefined;
|
|
394
|
+
const replacementState = shouldInjectSessionContext
|
|
395
|
+
? sessionManager?.getReplacementState()
|
|
396
|
+
: undefined;
|
|
329
397
|
const loopParams = buildRunLoopParams({
|
|
330
398
|
instruction: instructionText,
|
|
331
399
|
verify: effectiveVerify,
|
|
@@ -333,17 +401,18 @@ export async function handleRunCommand(options, command) {
|
|
|
333
401
|
llm,
|
|
334
402
|
languagePlugins,
|
|
335
403
|
conversationContext: conversationContext.length > 0 ? conversationContext : undefined,
|
|
404
|
+
artifactHints,
|
|
405
|
+
replacementState,
|
|
336
406
|
mode,
|
|
337
407
|
dryRun: allOptions.dryRun,
|
|
338
408
|
forceReset: allOptions.forceReset,
|
|
339
409
|
file: allOptions.file,
|
|
340
410
|
selection: allOptions.selection,
|
|
341
411
|
verbose: verboseLevel,
|
|
342
|
-
checkpointStrategy:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
: allOptions.checkpointStrategy,
|
|
412
|
+
checkpointStrategy: getOptionValueSourceWithGlobalFallback(command, 'checkpointStrategy') === 'cli'
|
|
413
|
+
? allOptions.checkpointStrategy
|
|
414
|
+
: (profile.defaultCheckpointStrategy ??
|
|
415
|
+
allOptions.checkpointStrategy),
|
|
347
416
|
environmentMode: rawEnvironmentMode,
|
|
348
417
|
applyBackOnDirty,
|
|
349
418
|
worktreePrepare: effectiveWorktreePrepare,
|
|
@@ -361,11 +430,9 @@ export async function handleRunCommand(options, command) {
|
|
|
361
430
|
headlessIncludeToolOutput,
|
|
362
431
|
headlessIncludeAuthorizationDecisions,
|
|
363
432
|
allowOutsideCacheRoot,
|
|
364
|
-
permissionRules:
|
|
365
|
-
?
|
|
366
|
-
:
|
|
367
|
-
? { allow: allowedToolRules, deny: disallowedToolRules }
|
|
368
|
-
: undefined,
|
|
433
|
+
permissionRules: allowedToolRules.length > 0 || disallowedToolRules.length > 0
|
|
434
|
+
? { allow: allowedToolRules, deny: disallowedToolRules }
|
|
435
|
+
: undefined,
|
|
369
436
|
permissionMode,
|
|
370
437
|
});
|
|
371
438
|
const buildAssistantMessage = (result) => buildRunAssistantMessage({ mode, result });
|
|
@@ -385,6 +452,15 @@ export async function handleRunCommand(options, command) {
|
|
|
385
452
|
logMode: resolvedConfig.ui.logMode,
|
|
386
453
|
},
|
|
387
454
|
});
|
|
455
|
+
lastKnownAuditPath = result.auditPath;
|
|
456
|
+
await attachRunBenchmarkArtifacts({
|
|
457
|
+
result,
|
|
458
|
+
repoPath: runPath,
|
|
459
|
+
exportPatchPath,
|
|
460
|
+
sweBenchInstanceId,
|
|
461
|
+
sweBenchModelName,
|
|
462
|
+
sweBenchPredictionsPath,
|
|
463
|
+
});
|
|
388
464
|
structuredOutputState = await buildStructuredOutputState({
|
|
389
465
|
outputFormat,
|
|
390
466
|
jsonSchemaSpec,
|
|
@@ -419,12 +495,23 @@ export async function handleRunCommand(options, command) {
|
|
|
419
495
|
message: text.cli.unexpectedError(msg),
|
|
420
496
|
repoPath: runPath,
|
|
421
497
|
instruction,
|
|
498
|
+
auditPath: lastKnownAuditPath,
|
|
422
499
|
});
|
|
423
500
|
}
|
|
501
|
+
else if (outputFormat === 'stream-json' &&
|
|
502
|
+
rawOutputProfile !== 'anthropic' &&
|
|
503
|
+
rawOutputProfile !== 'openai' &&
|
|
504
|
+
activeReporterStarted &&
|
|
505
|
+
activeReporter) {
|
|
506
|
+
const error = new Error(text.cli.unexpectedError(msg));
|
|
507
|
+
error.auditPath = lastKnownAuditPath;
|
|
508
|
+
activeReporter.onError(error);
|
|
509
|
+
}
|
|
424
510
|
else if (outputFormat === 'stream-json') {
|
|
425
511
|
headlessErrorWriter.writeUnexpectedError({
|
|
426
512
|
sessionId: sessionIdForOutput ?? resumeSessionId ?? randomUUID(),
|
|
427
513
|
message: text.cli.unexpectedError(msg),
|
|
514
|
+
auditPath: lastKnownAuditPath,
|
|
428
515
|
});
|
|
429
516
|
}
|
|
430
517
|
process.exitCode = 1;
|
|
@@ -6,6 +6,7 @@ import { OpenAiStreamEncoder } from '../../headless/openai-stream-encoder.js';
|
|
|
6
6
|
import { encodeStreamEnd, encodeStreamFailure, encodeStreamStart, } from '../../headless/stream-json-protocol.js';
|
|
7
7
|
function writeStreamJsonEarlyFailure(params) {
|
|
8
8
|
const at = new Date();
|
|
9
|
+
let eventSeq = 0;
|
|
9
10
|
params.writer.writeJsonLine(encodeStreamStart({
|
|
10
11
|
uuid: randomUUID(),
|
|
11
12
|
mode: 'run',
|
|
@@ -13,12 +14,15 @@ function writeStreamJsonEarlyFailure(params) {
|
|
|
13
14
|
sessionId: params.sessionId,
|
|
14
15
|
instruction: params.instruction,
|
|
15
16
|
at,
|
|
17
|
+
eventSeq: eventSeq++,
|
|
16
18
|
}));
|
|
17
19
|
params.writer.writeJsonLine(encodeStreamFailure({
|
|
18
20
|
uuid: randomUUID(),
|
|
19
21
|
sessionId: params.sessionId,
|
|
20
22
|
at,
|
|
21
23
|
message: params.message,
|
|
24
|
+
auditPath: params.auditPath,
|
|
25
|
+
eventSeq: eventSeq++,
|
|
22
26
|
}));
|
|
23
27
|
params.writer.writeJsonLine(encodeStreamEnd({
|
|
24
28
|
uuid: randomUUID(),
|
|
@@ -26,6 +30,7 @@ function writeStreamJsonEarlyFailure(params) {
|
|
|
26
30
|
at,
|
|
27
31
|
success: false,
|
|
28
32
|
exitCode: params.exitCode ?? 1,
|
|
33
|
+
eventSeq: eventSeq++,
|
|
29
34
|
}));
|
|
30
35
|
}
|
|
31
36
|
function writeAnthropicEarlyFailure(params) {
|
|
@@ -84,6 +89,7 @@ export function createHeadlessErrorWriter(ctx) {
|
|
|
84
89
|
instruction: params.instruction,
|
|
85
90
|
message: params.message,
|
|
86
91
|
errorCode: params.errorCode,
|
|
92
|
+
auditPath: params.auditPath,
|
|
87
93
|
exitCode: params.exitCode ?? 1,
|
|
88
94
|
}));
|
|
89
95
|
};
|
|
@@ -137,6 +143,7 @@ export function createHeadlessErrorWriter(ctx) {
|
|
|
137
143
|
message: params.message,
|
|
138
144
|
repoPath: ctx.repoPath,
|
|
139
145
|
instruction: params.instruction,
|
|
146
|
+
auditPath: params.auditPath,
|
|
140
147
|
sessionId,
|
|
141
148
|
});
|
|
142
149
|
return;
|
|
@@ -163,6 +170,7 @@ export function createHeadlessErrorWriter(ctx) {
|
|
|
163
170
|
repoPath: ctx.repoPath,
|
|
164
171
|
sessionId,
|
|
165
172
|
message: params.message,
|
|
173
|
+
auditPath: params.auditPath,
|
|
166
174
|
instruction: params.instruction,
|
|
167
175
|
});
|
|
168
176
|
}
|
|
@@ -6,6 +6,8 @@ export function buildRunLoopParams(params) {
|
|
|
6
6
|
repoPath: params.repoPath,
|
|
7
7
|
llm: params.llm,
|
|
8
8
|
conversationContext: params.conversationContext,
|
|
9
|
+
artifactHints: params.artifactHints,
|
|
10
|
+
replacementState: params.replacementState,
|
|
9
11
|
mode: params.mode,
|
|
10
12
|
dryRun: params.dryRun,
|
|
11
13
|
forceReset: params.forceReset,
|
|
@@ -30,6 +32,7 @@ export function buildRunLoopParams(params) {
|
|
|
30
32
|
forceNonInteractive: params.headlessOutput || params.printMode,
|
|
31
33
|
permissionMode: params.permissionMode,
|
|
32
34
|
}),
|
|
35
|
+
permissionMode: params.permissionMode,
|
|
33
36
|
extensions: params.extensions,
|
|
34
37
|
permissionRules: params.permissionRules,
|
|
35
38
|
eventPayload: params.headlessIncludeToolInput ||
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import { parseFlowMode } from '../../../core/types/flow-mode.js';
|
|
1
2
|
export function resolveRunMode(raw) {
|
|
2
|
-
|
|
3
|
-
if (value === 'patch' || value === 'review' || value === 'debug' || value === 'research') {
|
|
4
|
-
return value;
|
|
5
|
-
}
|
|
6
|
-
return undefined;
|
|
3
|
+
return parseFlowMode(raw || 'autopilot');
|
|
7
4
|
}
|
|
8
5
|
//# sourceMappingURL=mode.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveRepoPath } from '../../utils/resolve-cli-config.js';
|
|
2
2
|
function splitToolRules(raw) {
|
|
3
3
|
const parts = [];
|
|
4
4
|
const push = (s) => {
|
|
@@ -20,7 +20,7 @@ function splitToolRules(raw) {
|
|
|
20
20
|
}
|
|
21
21
|
export function parseRunCommandOptions(command) {
|
|
22
22
|
const allOptions = command.optsWithGlobals();
|
|
23
|
-
const repoPath =
|
|
23
|
+
const repoPath = resolveRepoPath({ repo: allOptions.repo, cwd: process.cwd() });
|
|
24
24
|
const continueSession = Boolean(allOptions.continue);
|
|
25
25
|
const resumeSessionId = typeof allOptions.resume === 'string'
|
|
26
26
|
? allOptions.resume
|
|
@@ -41,6 +41,18 @@ export function parseRunCommandOptions(command) {
|
|
|
41
41
|
const headlessIncludeToolOutput = Boolean(allOptions.headlessIncludeToolOutput);
|
|
42
42
|
const headlessIncludeAuthorizationDecisions = Boolean(allOptions.headlessIncludeAuthorizationDecisions);
|
|
43
43
|
const allowOutsideCacheRoot = Boolean(allOptions.allowOutsideCacheRoot);
|
|
44
|
+
const exportPatchPath = typeof allOptions.exportPatch === 'string'
|
|
45
|
+
? allOptions.exportPatch
|
|
46
|
+
: undefined;
|
|
47
|
+
const sweBenchInstanceId = typeof allOptions.sweBenchInstanceId === 'string'
|
|
48
|
+
? allOptions.sweBenchInstanceId
|
|
49
|
+
: undefined;
|
|
50
|
+
const sweBenchModelName = typeof allOptions.sweBenchModelName === 'string'
|
|
51
|
+
? allOptions.sweBenchModelName
|
|
52
|
+
: undefined;
|
|
53
|
+
const sweBenchPredictionsPath = typeof allOptions.sweBenchPredictions === 'string'
|
|
54
|
+
? allOptions.sweBenchPredictions
|
|
55
|
+
: undefined;
|
|
44
56
|
const instruction = explicitInstruction ?? printInstruction;
|
|
45
57
|
const allowedToolRules = splitToolRules(allOptions.allowedTools);
|
|
46
58
|
const disallowedToolRules = splitToolRules(allOptions.disallowedTools);
|
|
@@ -60,6 +72,10 @@ export function parseRunCommandOptions(command) {
|
|
|
60
72
|
headlessIncludeToolOutput,
|
|
61
73
|
headlessIncludeAuthorizationDecisions,
|
|
62
74
|
allowOutsideCacheRoot,
|
|
75
|
+
exportPatchPath,
|
|
76
|
+
sweBenchInstanceId,
|
|
77
|
+
sweBenchModelName,
|
|
78
|
+
sweBenchPredictionsPath,
|
|
63
79
|
allowedToolRules,
|
|
64
80
|
disallowedToolRules,
|
|
65
81
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { refreshSessionSummary, } from '../../../core/facades/cli-run-persist-session.js';
|
|
1
|
+
import { buildSessionArtifactStateFromLoopResult, refreshSessionSummary, } from '../../../core/facades/cli-run-persist-session.js';
|
|
2
2
|
export async function persistRunSession(params) {
|
|
3
3
|
if (!params.sessionManager || typeof params.instruction !== 'string')
|
|
4
4
|
return;
|
|
@@ -20,6 +20,15 @@ export async function persistRunSession(params) {
|
|
|
20
20
|
iterationId,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
params.sessionManager.mergeArtifactState(buildSessionArtifactStateFromLoopResult(params.result));
|
|
24
|
+
for (const preview of params.result.artifactHints?.toolResultPreviewArtifacts ?? []) {
|
|
25
|
+
params.sessionManager.freezeReplacementDecision({
|
|
26
|
+
toolResultId: `${preview.label}::${preview.artifact.handle}`,
|
|
27
|
+
decision: 'replaced',
|
|
28
|
+
preview: preview.label,
|
|
29
|
+
sourceArtifactHandle: preview.artifact.handle,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
23
32
|
await refreshSessionSummary({
|
|
24
33
|
sessionManager: params.sessionManager,
|
|
25
34
|
llm: params.llm,
|
|
@@ -46,10 +46,18 @@ function buildFailureMessage(details) {
|
|
|
46
46
|
}
|
|
47
47
|
async function runValidateCommand(params) {
|
|
48
48
|
const maxBytesPerStream = 500_000;
|
|
49
|
+
const env = params.headlessOutput
|
|
50
|
+
? {
|
|
51
|
+
...process.env,
|
|
52
|
+
NO_COLOR: process.env.NO_COLOR ?? '1',
|
|
53
|
+
FORCE_COLOR: '0',
|
|
54
|
+
}
|
|
55
|
+
: process.env;
|
|
49
56
|
const result = await spawnCommand({
|
|
50
57
|
command: params.cmd,
|
|
51
58
|
args: params.args,
|
|
52
59
|
cwd: params.repoPath,
|
|
60
|
+
env,
|
|
53
61
|
windowsHide: true,
|
|
54
62
|
maxStdoutBytes: maxBytesPerStream,
|
|
55
63
|
maxStderrBytes: maxBytesPerStream,
|
|
@@ -101,6 +109,7 @@ export async function runPreflight(params) {
|
|
|
101
109
|
cmd: lintCommand.command,
|
|
102
110
|
args: lintCommand.args,
|
|
103
111
|
useGui: params.useGui,
|
|
112
|
+
headlessOutput: params.headlessOutput,
|
|
104
113
|
});
|
|
105
114
|
}
|
|
106
115
|
catch (error) {
|
|
@@ -126,6 +135,7 @@ export async function runPreflight(params) {
|
|
|
126
135
|
cmd: testCommand.command,
|
|
127
136
|
args: testCommand.args,
|
|
128
137
|
useGui: params.useGui,
|
|
138
|
+
headlessOutput: params.headlessOutput,
|
|
129
139
|
});
|
|
130
140
|
}
|
|
131
141
|
catch (error) {
|
|
@@ -22,6 +22,7 @@ export function createRunReporter(params) {
|
|
|
22
22
|
repoPath: params.repoPath,
|
|
23
23
|
sessionId: params.sessionIdForOutput,
|
|
24
24
|
writer: params.writer,
|
|
25
|
+
includeToolInput: params.includeToolInput,
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
if (profile === 'openai') {
|
|
@@ -35,6 +36,8 @@ export function createRunReporter(params) {
|
|
|
35
36
|
repoPath: params.repoPath,
|
|
36
37
|
sessionId: params.sessionIdForOutput,
|
|
37
38
|
writer: params.writer,
|
|
39
|
+
getWarnings: params.getWarnings,
|
|
40
|
+
includeToolInput: params.includeToolInput,
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
if (params.outputFormat === 'json') {
|
|
@@ -45,6 +48,7 @@ export function createRunReporter(params) {
|
|
|
45
48
|
writer: params.writer,
|
|
46
49
|
getStructuredOutput: params.getStructuredOutput,
|
|
47
50
|
getPayloadOverrides: params.getPayloadOverrides,
|
|
51
|
+
getWarnings: params.getWarnings,
|
|
48
52
|
});
|
|
49
53
|
}
|
|
50
54
|
return new StandardReporter(params.verbose);
|