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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FLOW_MODE_PUBLIC_METADATA } from '../../public-capabilities/flow-mode-metadata.js';
|
|
2
|
+
import { FLOW_MODES, parseFlowMode } from '../../types/flow-mode.js';
|
|
3
|
+
export const SUPPORTED_PROTOCOL_FLOW_MODES = FLOW_MODES;
|
|
4
|
+
export function parseAcpFlowMode(value) {
|
|
5
|
+
const normalized = String(value ?? '')
|
|
6
|
+
.trim()
|
|
7
|
+
.toLowerCase();
|
|
8
|
+
if (normalized === 'interactive' || normalized === 'yolo') {
|
|
9
|
+
return 'autopilot';
|
|
10
|
+
}
|
|
11
|
+
return parseFlowMode(normalized);
|
|
12
|
+
}
|
|
13
|
+
export function parseA2ASkillFlowMode(value) {
|
|
14
|
+
return parseFlowMode(value);
|
|
15
|
+
}
|
|
16
|
+
export function buildA2AFlowSkills() {
|
|
17
|
+
return SUPPORTED_PROTOCOL_FLOW_MODES.map((mode) => ({
|
|
18
|
+
id: mode,
|
|
19
|
+
title: FLOW_MODE_PUBLIC_METADATA[mode].a2aTitle,
|
|
20
|
+
description: FLOW_MODE_PUBLIC_METADATA[mode].description,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=flow-mode-mapping.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const FLOW_MODE_PUBLIC_METADATA = {
|
|
2
|
+
autopilot: {
|
|
3
|
+
publicTitle: 'Autopilot',
|
|
4
|
+
a2aTitle: 'Autopilot',
|
|
5
|
+
acpName: 'Autopilot',
|
|
6
|
+
description: 'Let the agent decide which actions and tools to use.',
|
|
7
|
+
},
|
|
8
|
+
patch: {
|
|
9
|
+
publicTitle: 'Patch code',
|
|
10
|
+
a2aTitle: 'Patch code',
|
|
11
|
+
acpName: 'Patch',
|
|
12
|
+
description: 'Apply code changes with verification.',
|
|
13
|
+
},
|
|
14
|
+
review: {
|
|
15
|
+
publicTitle: 'Review code',
|
|
16
|
+
a2aTitle: 'Review code',
|
|
17
|
+
acpName: 'Review',
|
|
18
|
+
description: 'Inspect code and report findings without mutating files.',
|
|
19
|
+
},
|
|
20
|
+
debug: {
|
|
21
|
+
publicTitle: 'Debug issue',
|
|
22
|
+
a2aTitle: 'Debug issue',
|
|
23
|
+
acpName: 'Debug',
|
|
24
|
+
description: 'Investigate issues and make targeted fixes when needed.',
|
|
25
|
+
},
|
|
26
|
+
research: {
|
|
27
|
+
publicTitle: 'Research request',
|
|
28
|
+
a2aTitle: 'Research request',
|
|
29
|
+
acpName: 'Research',
|
|
30
|
+
description: 'Explore the codebase and summarize relevant findings.',
|
|
31
|
+
},
|
|
32
|
+
answer: {
|
|
33
|
+
publicTitle: 'Answer question',
|
|
34
|
+
a2aTitle: 'Answer question',
|
|
35
|
+
acpName: 'Answer',
|
|
36
|
+
description: 'Answer questions directly without editing files.',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=flow-mode-metadata.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FLOW_MODE_PUBLIC_METADATA } from './flow-mode-metadata.js';
|
|
2
|
+
import { buildPublicCapabilityRegistry } from './registry.js';
|
|
3
|
+
export function selectPublicCapabilitiesForSurface(surface, entries = buildPublicCapabilityRegistry()) {
|
|
4
|
+
return entries.filter((entry) => entry.reachability === 'reachable' && entry.surfaces[surface]);
|
|
5
|
+
}
|
|
6
|
+
function isFlowModeCapability(entry) {
|
|
7
|
+
return entry.kind === 'flow_mode';
|
|
8
|
+
}
|
|
9
|
+
export function toAcpPublicModes(entries = buildPublicCapabilityRegistry()) {
|
|
10
|
+
return selectPublicCapabilitiesForSurface('acp', entries)
|
|
11
|
+
.filter(isFlowModeCapability)
|
|
12
|
+
.map((entry) => ({
|
|
13
|
+
id: entry.target,
|
|
14
|
+
name: FLOW_MODE_PUBLIC_METADATA[entry.target].acpName,
|
|
15
|
+
description: entry.description,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
export function toA2APublicSkills(entries = buildPublicCapabilityRegistry()) {
|
|
19
|
+
return selectPublicCapabilitiesForSurface('a2a', entries).map((entry) => ({
|
|
20
|
+
id: entry.id,
|
|
21
|
+
title: entry.title,
|
|
22
|
+
description: entry.description,
|
|
23
|
+
tags: entry.tags,
|
|
24
|
+
examples: entry.examples,
|
|
25
|
+
inputModes: entry.inputModes,
|
|
26
|
+
outputModes: entry.outputModes,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=projections.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FLOW_MODES } from '../types/flow-mode.js';
|
|
2
|
+
import { FLOW_MODE_PUBLIC_METADATA } from './flow-mode-metadata.js';
|
|
3
|
+
function getFlowModeSurfaces(mode) {
|
|
4
|
+
if (mode === 'autopilot') {
|
|
5
|
+
return {
|
|
6
|
+
a2a: true,
|
|
7
|
+
acp: true,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
a2a: false,
|
|
12
|
+
acp: true,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function buildPublicCapabilityRegistry() {
|
|
16
|
+
return FLOW_MODES.map((mode) => ({
|
|
17
|
+
id: mode,
|
|
18
|
+
kind: 'flow_mode',
|
|
19
|
+
target: mode,
|
|
20
|
+
title: FLOW_MODE_PUBLIC_METADATA[mode].publicTitle,
|
|
21
|
+
description: FLOW_MODE_PUBLIC_METADATA[mode].description,
|
|
22
|
+
surfaces: getFlowModeSurfaces(mode),
|
|
23
|
+
reachability: 'reachable',
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -3,7 +3,6 @@ import { createTaskEventBus } from '../interaction/events/bus.js';
|
|
|
3
3
|
import { createInteractionFacade } from '../interaction/orchestration/facade.js';
|
|
4
4
|
import { createA2AInteractionExecutor } from '../protocols/a2a/sdk/executor.js';
|
|
5
5
|
import { createA2ASdkExpressApp } from '../protocols/a2a/sdk/server.js';
|
|
6
|
-
import { createSidecarFastifyPlugin, } from './sidecar-fastify-plugin.js';
|
|
7
6
|
export function createAgentServerRuntime(deps) {
|
|
8
7
|
const eventBus = deps.a2a.eventBus ?? createTaskEventBus();
|
|
9
8
|
const taskStore = deps.a2a.taskStore ?? new InMemoryTaskStore();
|
|
@@ -20,67 +19,72 @@ export function createAgentServerRuntime(deps) {
|
|
|
20
19
|
taskEventBus: eventBus,
|
|
21
20
|
taskStore,
|
|
22
21
|
});
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
agentCard,
|
|
22
|
+
const a2aServer = (deps.createA2AServerApp ?? createA2ASdkExpressApp)({
|
|
23
|
+
agentCard: deps.a2a.buildAgentCard(),
|
|
26
24
|
agentExecutor: executor,
|
|
27
25
|
taskStore,
|
|
28
26
|
userBuilder: deps.a2a.userBuilder,
|
|
29
27
|
authMiddleware: deps.a2a.authMiddleware,
|
|
30
28
|
});
|
|
31
|
-
const sidecarPlugin = createSidecarFastifyPlugin({
|
|
32
|
-
routes: deps.sidecar.routes,
|
|
33
|
-
scope: deps.listen.sidecar.type === 'tcp' ? 'tcp' : 'uds',
|
|
34
|
-
allowConditional: deps.sidecar.allowConditional,
|
|
35
|
-
authorize: deps.sidecar.authorize,
|
|
36
|
-
baseUrl: deps.sidecar.baseUrl,
|
|
37
|
-
});
|
|
38
|
-
const sidecarServer = deps.createFastify();
|
|
39
29
|
let a2aServerInstance = null;
|
|
40
|
-
let sidecarServerInstance = null;
|
|
41
30
|
let started = false;
|
|
31
|
+
let starting = false;
|
|
42
32
|
async function start() {
|
|
43
|
-
if (started) {
|
|
33
|
+
if (started || starting) {
|
|
44
34
|
throw new Error('Runtime already started');
|
|
45
35
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
36
|
+
starting = true;
|
|
37
|
+
try {
|
|
38
|
+
if (deps.configureA2A) {
|
|
39
|
+
await deps.configureA2A(a2aServer);
|
|
40
|
+
}
|
|
41
|
+
a2aServerInstance = await new Promise((resolve, reject) => {
|
|
42
|
+
const server = a2aServer.listen(deps.listen.a2a.port, deps.listen.a2a.host ?? '0.0.0.0');
|
|
43
|
+
const cleanup = () => {
|
|
44
|
+
server.off('error', onError);
|
|
45
|
+
server.off('listening', onListening);
|
|
46
|
+
};
|
|
47
|
+
const onError = (error) => {
|
|
48
|
+
cleanup();
|
|
49
|
+
reject(error);
|
|
50
|
+
};
|
|
51
|
+
const onListening = () => {
|
|
52
|
+
cleanup();
|
|
58
53
|
resolve(server);
|
|
54
|
+
};
|
|
55
|
+
server.once('error', onError);
|
|
56
|
+
server.once('listening', onListening);
|
|
59
57
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
: { path: deps.listen.sidecar.path };
|
|
64
|
-
sidecarServerInstance = await sidecarServer.listen(sidecarListenOpts);
|
|
65
|
-
started = true;
|
|
66
|
-
}
|
|
67
|
-
async function close() {
|
|
68
|
-
if (a2aServerInstance) {
|
|
69
|
-
await new Promise((resolve) => {
|
|
70
|
-
a2aServerInstance.close(() => resolve());
|
|
71
|
-
});
|
|
58
|
+
started = true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
72
61
|
a2aServerInstance = null;
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
starting = false;
|
|
73
66
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
}
|
|
68
|
+
async function close() {
|
|
69
|
+
if (!a2aServerInstance) {
|
|
70
|
+
started = false;
|
|
71
|
+
return;
|
|
77
72
|
}
|
|
73
|
+
await new Promise((resolve, reject) => {
|
|
74
|
+
a2aServerInstance.close((error) => {
|
|
75
|
+
if (error) {
|
|
76
|
+
reject(error);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
resolve();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
a2aServerInstance = null;
|
|
78
83
|
started = false;
|
|
79
84
|
}
|
|
80
85
|
return {
|
|
81
86
|
eventBus,
|
|
82
|
-
a2aServer
|
|
83
|
-
sidecarServer,
|
|
87
|
+
a2aServer,
|
|
84
88
|
start,
|
|
85
89
|
close,
|
|
86
90
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Phase } from '../types/runtime.js';
|
|
2
|
+
const RECIPE_ENTRY_PHASE = Phase.PLAN;
|
|
3
|
+
const RECIPE_PROFILES = {
|
|
4
|
+
patch: {
|
|
5
|
+
mode: 'patch',
|
|
6
|
+
driver: 'recipe',
|
|
7
|
+
readOnly: false,
|
|
8
|
+
ignoreDirtyPreflight: false,
|
|
9
|
+
failurePolicy: 'rollback',
|
|
10
|
+
verifyPolicy: 'required_before_success_if_mutated',
|
|
11
|
+
entryPhase: RECIPE_ENTRY_PHASE,
|
|
12
|
+
},
|
|
13
|
+
review: {
|
|
14
|
+
mode: 'review',
|
|
15
|
+
driver: 'recipe',
|
|
16
|
+
readOnly: true,
|
|
17
|
+
ignoreDirtyPreflight: true,
|
|
18
|
+
failurePolicy: 'rollback',
|
|
19
|
+
verifyPolicy: 'never',
|
|
20
|
+
entryPhase: RECIPE_ENTRY_PHASE,
|
|
21
|
+
},
|
|
22
|
+
debug: {
|
|
23
|
+
mode: 'debug',
|
|
24
|
+
driver: 'recipe',
|
|
25
|
+
readOnly: false,
|
|
26
|
+
ignoreDirtyPreflight: false,
|
|
27
|
+
failurePolicy: 'rollback',
|
|
28
|
+
verifyPolicy: 'required_before_success_if_mutated',
|
|
29
|
+
entryPhase: RECIPE_ENTRY_PHASE,
|
|
30
|
+
},
|
|
31
|
+
research: {
|
|
32
|
+
mode: 'research',
|
|
33
|
+
driver: 'recipe',
|
|
34
|
+
readOnly: true,
|
|
35
|
+
ignoreDirtyPreflight: true,
|
|
36
|
+
failurePolicy: 'rollback',
|
|
37
|
+
verifyPolicy: 'never',
|
|
38
|
+
entryPhase: RECIPE_ENTRY_PHASE,
|
|
39
|
+
},
|
|
40
|
+
answer: {
|
|
41
|
+
mode: 'answer',
|
|
42
|
+
driver: 'recipe',
|
|
43
|
+
readOnly: true,
|
|
44
|
+
ignoreDirtyPreflight: true,
|
|
45
|
+
failurePolicy: 'rollback',
|
|
46
|
+
verifyPolicy: 'never',
|
|
47
|
+
entryPhase: RECIPE_ENTRY_PHASE,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const AUTOPILOT_PROFILE = {
|
|
51
|
+
mode: 'autopilot',
|
|
52
|
+
driver: 'agent',
|
|
53
|
+
readOnly: false,
|
|
54
|
+
defaultPermissionMode: 'yolo',
|
|
55
|
+
defaultCheckpointStrategy: 'direct',
|
|
56
|
+
ignoreDirtyPreflight: true,
|
|
57
|
+
failurePolicy: 'preserve',
|
|
58
|
+
verifyPolicy: 'required_before_success_if_mutated',
|
|
59
|
+
entryPhase: Phase.AUTOPILOT,
|
|
60
|
+
};
|
|
61
|
+
export function resolveExecutionProfile(mode) {
|
|
62
|
+
if (mode === 'autopilot') {
|
|
63
|
+
return AUTOPILOT_PROFILE;
|
|
64
|
+
}
|
|
65
|
+
return RECIPE_PROFILES[mode];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=execution-profile.js.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { createToolResultIdentity, freezeToolResultReplacementDecision, } from './replacement-state.js';
|
|
2
|
+
const MAX_SUBAGENT_ARTIFACTS = 4;
|
|
3
|
+
const MAX_READ_ARTIFACTS = 6;
|
|
4
|
+
const MAX_PREVIEW_ARTIFACTS = 6;
|
|
5
|
+
function isArtifactHandle(value) {
|
|
6
|
+
if (!value || typeof value !== 'object')
|
|
7
|
+
return false;
|
|
8
|
+
const candidate = value;
|
|
9
|
+
return (typeof candidate.handle === 'string' &&
|
|
10
|
+
typeof candidate.mimeType === 'string' &&
|
|
11
|
+
typeof candidate.sha256 === 'string' &&
|
|
12
|
+
typeof candidate.size === 'number');
|
|
13
|
+
}
|
|
14
|
+
function cloneArtifactHandle(artifact) {
|
|
15
|
+
if (!artifact)
|
|
16
|
+
return undefined;
|
|
17
|
+
return {
|
|
18
|
+
handle: artifact.handle,
|
|
19
|
+
mimeType: artifact.mimeType,
|
|
20
|
+
sha256: artifact.sha256,
|
|
21
|
+
size: artifact.size,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function normalizeArtifactHandles(artifacts, limit) {
|
|
25
|
+
if (!Array.isArray(artifacts) || artifacts.length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
const unique = [];
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
for (const artifact of artifacts) {
|
|
30
|
+
if (!isArtifactHandle(artifact))
|
|
31
|
+
continue;
|
|
32
|
+
if (seen.has(artifact.handle))
|
|
33
|
+
continue;
|
|
34
|
+
seen.add(artifact.handle);
|
|
35
|
+
unique.push(cloneArtifactHandle(artifact));
|
|
36
|
+
}
|
|
37
|
+
if (unique.length === 0)
|
|
38
|
+
return undefined;
|
|
39
|
+
return unique.slice(-limit);
|
|
40
|
+
}
|
|
41
|
+
function normalizeReadArtifacts(artifacts, limit) {
|
|
42
|
+
if (!Array.isArray(artifacts) || artifacts.length === 0)
|
|
43
|
+
return undefined;
|
|
44
|
+
const unique = [];
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
for (const item of artifacts) {
|
|
47
|
+
const path = typeof item?.path === 'string' ? item.path.trim() : '';
|
|
48
|
+
if (!path || !isArtifactHandle(item?.artifact))
|
|
49
|
+
continue;
|
|
50
|
+
const key = `${path}::${item.artifact.handle}`;
|
|
51
|
+
if (seen.has(key))
|
|
52
|
+
continue;
|
|
53
|
+
seen.add(key);
|
|
54
|
+
unique.push({
|
|
55
|
+
path,
|
|
56
|
+
artifact: cloneArtifactHandle(item.artifact),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (unique.length === 0)
|
|
60
|
+
return undefined;
|
|
61
|
+
return unique.slice(-limit);
|
|
62
|
+
}
|
|
63
|
+
function normalizePreviewArtifacts(artifacts, limit) {
|
|
64
|
+
if (!Array.isArray(artifacts) || artifacts.length === 0)
|
|
65
|
+
return undefined;
|
|
66
|
+
const unique = [];
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
for (const item of artifacts) {
|
|
69
|
+
const label = typeof item?.label === 'string' ? item.label.trim() : '';
|
|
70
|
+
if (!label || !isArtifactHandle(item?.artifact))
|
|
71
|
+
continue;
|
|
72
|
+
const key = `${label}::${item.artifact.handle}`;
|
|
73
|
+
if (seen.has(key))
|
|
74
|
+
continue;
|
|
75
|
+
seen.add(key);
|
|
76
|
+
unique.push({
|
|
77
|
+
label,
|
|
78
|
+
artifact: cloneArtifactHandle(item.artifact),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (unique.length === 0)
|
|
82
|
+
return undefined;
|
|
83
|
+
return unique.slice(-limit);
|
|
84
|
+
}
|
|
85
|
+
function hasAnyArtifactState(state) {
|
|
86
|
+
return Boolean(state.verifyArtifact ||
|
|
87
|
+
state.subAgentPatchArtifacts?.length ||
|
|
88
|
+
state.subAgentAuditArtifacts?.length ||
|
|
89
|
+
state.recentReadArtifacts?.length ||
|
|
90
|
+
state.toolResultPreviewArtifacts?.length);
|
|
91
|
+
}
|
|
92
|
+
export function normalizeSessionArtifactState(state) {
|
|
93
|
+
if (!state)
|
|
94
|
+
return undefined;
|
|
95
|
+
const normalized = {
|
|
96
|
+
verifyArtifact: isArtifactHandle(state.verifyArtifact)
|
|
97
|
+
? cloneArtifactHandle(state.verifyArtifact)
|
|
98
|
+
: undefined,
|
|
99
|
+
subAgentPatchArtifacts: normalizeArtifactHandles(state.subAgentPatchArtifacts, MAX_SUBAGENT_ARTIFACTS),
|
|
100
|
+
subAgentAuditArtifacts: normalizeArtifactHandles(state.subAgentAuditArtifacts, MAX_SUBAGENT_ARTIFACTS),
|
|
101
|
+
recentReadArtifacts: normalizeReadArtifacts(state.recentReadArtifacts, MAX_READ_ARTIFACTS),
|
|
102
|
+
toolResultPreviewArtifacts: normalizePreviewArtifacts(state.toolResultPreviewArtifacts, MAX_PREVIEW_ARTIFACTS),
|
|
103
|
+
};
|
|
104
|
+
return hasAnyArtifactState(normalized) ? normalized : undefined;
|
|
105
|
+
}
|
|
106
|
+
export function mergeSessionArtifactState(existing, incoming) {
|
|
107
|
+
const base = normalizeSessionArtifactState(existing);
|
|
108
|
+
const next = normalizeSessionArtifactState(incoming);
|
|
109
|
+
if (!base)
|
|
110
|
+
return next;
|
|
111
|
+
if (!next)
|
|
112
|
+
return base;
|
|
113
|
+
return normalizeSessionArtifactState({
|
|
114
|
+
verifyArtifact: next.verifyArtifact ?? base.verifyArtifact,
|
|
115
|
+
subAgentPatchArtifacts: [
|
|
116
|
+
...(base.subAgentPatchArtifacts ?? []),
|
|
117
|
+
...(next.subAgentPatchArtifacts ?? []),
|
|
118
|
+
],
|
|
119
|
+
subAgentAuditArtifacts: [
|
|
120
|
+
...(base.subAgentAuditArtifacts ?? []),
|
|
121
|
+
...(next.subAgentAuditArtifacts ?? []),
|
|
122
|
+
],
|
|
123
|
+
recentReadArtifacts: [...(base.recentReadArtifacts ?? []), ...(next.recentReadArtifacts ?? [])],
|
|
124
|
+
toolResultPreviewArtifacts: [
|
|
125
|
+
...(base.toolResultPreviewArtifacts ?? []),
|
|
126
|
+
...(next.toolResultPreviewArtifacts ?? []),
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export function buildSessionArtifactStateFromLoopResult(result) {
|
|
131
|
+
const hints = result.artifactHints;
|
|
132
|
+
const withVerifyFallback = hints || result.verifyArtifact
|
|
133
|
+
? {
|
|
134
|
+
...hints,
|
|
135
|
+
verifyArtifact: hints?.verifyArtifact ?? result.verifyArtifact,
|
|
136
|
+
}
|
|
137
|
+
: undefined;
|
|
138
|
+
return normalizeSessionArtifactState(withVerifyFallback);
|
|
139
|
+
}
|
|
140
|
+
export function mergeReplacementStateFromArtifactHints(existing, artifactHints, now = () => Date.now()) {
|
|
141
|
+
let next = existing;
|
|
142
|
+
for (const item of artifactHints?.toolResultPreviewArtifacts ?? []) {
|
|
143
|
+
const toolResultId = createToolResultIdentity({
|
|
144
|
+
canonicalToolCallIdentity: item.label,
|
|
145
|
+
payload: {
|
|
146
|
+
label: item.label,
|
|
147
|
+
handle: item.artifact.handle,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
next = freezeToolResultReplacementDecision(next, {
|
|
151
|
+
toolResultId,
|
|
152
|
+
decision: 'replaced',
|
|
153
|
+
preview: item.label,
|
|
154
|
+
sourceArtifactHandle: item.artifact.handle,
|
|
155
|
+
frozenAt: now(),
|
|
156
|
+
}, { maxEntries: 256 });
|
|
157
|
+
}
|
|
158
|
+
return next;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=artifact-state.js.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { getModelRecommendedBudget } from '../../context/token/adaptive-budget.js';
|
|
2
|
+
import { LlmError } from '../../llm/errors.js';
|
|
3
|
+
import { getLogger } from '../../observability/logger.js';
|
|
4
|
+
import { refreshSessionSummary } from '../summary-sync.js';
|
|
5
|
+
import { TokenTracker } from '../token-tracker.js';
|
|
6
|
+
import { isCircuitBreakerTripped, onCompactionFailure, onCompactionSuccess } from './tracking.js';
|
|
7
|
+
import { DEFAULT_AUTOCOMPACT_CONFIG } from './types.js';
|
|
8
|
+
function isContextOverflowLike(error) {
|
|
9
|
+
if (error instanceof LlmError && error.llmCode === 'LLM_CONTEXT_LENGTH_EXCEEDED') {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
const message = error instanceof Error
|
|
13
|
+
? error.message
|
|
14
|
+
: error && typeof error === 'object' && typeof error.message === 'string'
|
|
15
|
+
? String(error.message)
|
|
16
|
+
: '';
|
|
17
|
+
if (!message)
|
|
18
|
+
return false;
|
|
19
|
+
const lower = message.toLowerCase();
|
|
20
|
+
return (lower.includes('maximum context length') ||
|
|
21
|
+
lower.includes('context length') ||
|
|
22
|
+
lower.includes('too many tokens') ||
|
|
23
|
+
lower.includes('prompt is too long') ||
|
|
24
|
+
lower.includes('input is too long') ||
|
|
25
|
+
lower.includes('reduce the length') ||
|
|
26
|
+
lower.includes('please reduce'));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Autocompact (Level 1)
|
|
30
|
+
*
|
|
31
|
+
* Triggered when token count exceeds threshold.
|
|
32
|
+
* Uses existing summarization infrastructure to reduce context.
|
|
33
|
+
*/
|
|
34
|
+
export async function autocompact(params) {
|
|
35
|
+
const { sessionManager, llm, tracking, contextHash } = params;
|
|
36
|
+
const trigger = params.trigger ?? 'auto';
|
|
37
|
+
const modelId = llm.getModelId?.();
|
|
38
|
+
// Resolve dynamic threshold if not provided in config
|
|
39
|
+
let resolvedThreshold = params.config?.tokenThreshold;
|
|
40
|
+
if (resolvedThreshold === undefined) {
|
|
41
|
+
if (modelId) {
|
|
42
|
+
try {
|
|
43
|
+
resolvedThreshold = getModelRecommendedBudget(modelId);
|
|
44
|
+
}
|
|
45
|
+
catch (_error) {
|
|
46
|
+
// Fallback to default if resolution fails
|
|
47
|
+
resolvedThreshold = DEFAULT_AUTOCOMPACT_CONFIG.tokenThreshold;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
resolvedThreshold = DEFAULT_AUTOCOMPACT_CONFIG.tokenThreshold;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const config = {
|
|
55
|
+
...DEFAULT_AUTOCOMPACT_CONFIG,
|
|
56
|
+
...params.config,
|
|
57
|
+
tokenThreshold: resolvedThreshold,
|
|
58
|
+
};
|
|
59
|
+
// 1. Check circuit breaker
|
|
60
|
+
if (isCircuitBreakerTripped(tracking, config.maxFailures)) {
|
|
61
|
+
getLogger().audit('COMPACTION_SKIP', {
|
|
62
|
+
reason: 'circuit_breaker',
|
|
63
|
+
trigger,
|
|
64
|
+
modelId: modelId ?? 'unknown',
|
|
65
|
+
tokenThreshold: config.tokenThreshold,
|
|
66
|
+
consecutiveFailures: tracking.consecutiveFailures,
|
|
67
|
+
maxFailures: config.maxFailures,
|
|
68
|
+
}, {
|
|
69
|
+
source: 'session',
|
|
70
|
+
severity: 'low',
|
|
71
|
+
scope: 'session',
|
|
72
|
+
phase: 'COMPACTION',
|
|
73
|
+
});
|
|
74
|
+
return { performed: false, tracking };
|
|
75
|
+
}
|
|
76
|
+
// 2. Check threshold (only for auto trigger)
|
|
77
|
+
const messages = sessionManager.getMessages();
|
|
78
|
+
const totalTokens = TokenTracker.estimateMessagesTokens(messages);
|
|
79
|
+
if (trigger === 'auto' && totalTokens < config.tokenThreshold) {
|
|
80
|
+
getLogger().audit('COMPACTION_SKIP', {
|
|
81
|
+
reason: 'below_threshold',
|
|
82
|
+
trigger,
|
|
83
|
+
modelId: modelId ?? 'unknown',
|
|
84
|
+
preTokens: totalTokens,
|
|
85
|
+
tokenThreshold: config.tokenThreshold,
|
|
86
|
+
}, {
|
|
87
|
+
source: 'session',
|
|
88
|
+
severity: 'low',
|
|
89
|
+
scope: 'session',
|
|
90
|
+
phase: 'COMPACTION',
|
|
91
|
+
});
|
|
92
|
+
return { performed: false, tracking };
|
|
93
|
+
}
|
|
94
|
+
// 3. Perform summarization
|
|
95
|
+
try {
|
|
96
|
+
// Reuse existing refreshSessionSummary with 'force' strategy
|
|
97
|
+
// This will trigger the ConversationSummarizer logic
|
|
98
|
+
const summaryResult = await refreshSessionSummary({
|
|
99
|
+
sessionManager,
|
|
100
|
+
llm,
|
|
101
|
+
contextHash,
|
|
102
|
+
strategy: 'force',
|
|
103
|
+
strict: true,
|
|
104
|
+
});
|
|
105
|
+
if (!summaryResult.didSummarize) {
|
|
106
|
+
getLogger().audit('COMPACTION_SKIP', {
|
|
107
|
+
reason: 'no_op',
|
|
108
|
+
trigger,
|
|
109
|
+
modelId: modelId ?? 'unknown',
|
|
110
|
+
preTokens: totalTokens,
|
|
111
|
+
tokenThreshold: config.tokenThreshold,
|
|
112
|
+
}, {
|
|
113
|
+
source: 'session',
|
|
114
|
+
severity: 'low',
|
|
115
|
+
scope: 'session',
|
|
116
|
+
phase: 'COMPACTION',
|
|
117
|
+
});
|
|
118
|
+
return { performed: false, tracking };
|
|
119
|
+
}
|
|
120
|
+
const updatedSummary = sessionManager.getSummaryState();
|
|
121
|
+
getLogger().audit(`COMPACTION_${trigger.toUpperCase()}COMPACT`, {
|
|
122
|
+
trigger,
|
|
123
|
+
modelId: modelId ?? 'unknown',
|
|
124
|
+
preTokens: totalTokens,
|
|
125
|
+
tokenThreshold: config.tokenThreshold,
|
|
126
|
+
summaryTokens: updatedSummary?.summaryTokens,
|
|
127
|
+
hasRecoveryState: Boolean(updatedSummary?.recoveryState),
|
|
128
|
+
circuitBreakerState: { consecutiveFailures: 0 },
|
|
129
|
+
}, {
|
|
130
|
+
source: 'session',
|
|
131
|
+
severity: 'medium',
|
|
132
|
+
scope: 'session',
|
|
133
|
+
phase: 'COMPACTION',
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
performed: true,
|
|
137
|
+
tracking: onCompactionSuccess(tracking),
|
|
138
|
+
preTokens: totalTokens,
|
|
139
|
+
trigger: trigger,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
const newTracking = onCompactionFailure(tracking);
|
|
144
|
+
getLogger().audit('COMPACTION_FAILURE', {
|
|
145
|
+
error: error instanceof Error ? error.message : String(error),
|
|
146
|
+
consecutiveFailures: newTracking.consecutiveFailures,
|
|
147
|
+
trigger,
|
|
148
|
+
}, {
|
|
149
|
+
source: 'session',
|
|
150
|
+
severity: 'medium',
|
|
151
|
+
scope: 'session',
|
|
152
|
+
phase: 'COMPACTION',
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
performed: false,
|
|
156
|
+
tracking: newTracking,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Reactive Compact (Level 2)
|
|
162
|
+
*
|
|
163
|
+
* Emergency compaction when LLM returns prompt-too-long error.
|
|
164
|
+
*/
|
|
165
|
+
export async function reactiveCompact(params) {
|
|
166
|
+
if (!isContextOverflowLike(params.error)) {
|
|
167
|
+
return { performed: false, tracking: params.tracking };
|
|
168
|
+
}
|
|
169
|
+
return autocompact({
|
|
170
|
+
...params,
|
|
171
|
+
trigger: 'reactive',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Main Compaction Pipeline entry point
|
|
176
|
+
*/
|
|
177
|
+
export async function runCompactionPipeline(params) {
|
|
178
|
+
// Level 0 (Microcompact) is already integrated into buildEffectiveConversationContext
|
|
179
|
+
// and refreshSessionSummary.
|
|
180
|
+
// Level 1: Autocompact
|
|
181
|
+
return autocompact(params);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=index.js.map
|