open-multi-agent-kit 0.90.0 → 0.90.4
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 +56 -0
- package/README.md +22 -31
- package/dist/cli/args.d.ts +0 -2
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -7
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +3 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +27 -19
- package/dist/config.js.map +1 -1
- package/dist/core/adaptorch-bridge.d.ts +257 -0
- package/dist/core/adaptorch-bridge.d.ts.map +1 -0
- package/dist/core/adaptorch-bridge.js +473 -0
- package/dist/core/adaptorch-bridge.js.map +1 -0
- package/dist/core/agent-session.d.ts +132 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +327 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bang-skill-invocation.d.ts +26 -0
- package/dist/core/bang-skill-invocation.d.ts.map +1 -0
- package/dist/core/bang-skill-invocation.js +208 -0
- package/dist/core/bang-skill-invocation.js.map +1 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +15 -2
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/compactor.d.ts.map +1 -1
- package/dist/core/compactor.js +0 -3
- package/dist/core/compactor.js.map +1 -1
- package/dist/core/context-budget-governor-v2.d.ts +2 -1
- package/dist/core/context-budget-governor-v2.d.ts.map +1 -1
- package/dist/core/context-budget-governor-v2.js +1 -0
- package/dist/core/context-budget-governor-v2.js.map +1 -1
- package/dist/core/context-budget-headroom-types.d.ts +8 -0
- package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-types.js.map +1 -1
- package/dist/core/context-budget-headroom.d.ts +1 -1
- package/dist/core/context-budget-headroom.d.ts.map +1 -1
- package/dist/core/context-budget-headroom.js +17 -4
- package/dist/core/context-budget-headroom.js.map +1 -1
- package/dist/core/context-budget-system-prompt.d.ts +2 -1
- package/dist/core/context-budget-system-prompt.d.ts.map +1 -1
- package/dist/core/context-budget-system-prompt.js +6 -1
- package/dist/core/context-budget-system-prompt.js.map +1 -1
- package/dist/core/context-budget-v2-cache-hash.d.ts +3 -0
- package/dist/core/context-budget-v2-cache-hash.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-hash.js +16 -0
- package/dist/core/context-budget-v2-cache-hash.js.map +1 -0
- package/dist/core/context-budget-v2-cache-keys.d.ts +58 -0
- package/dist/core/context-budget-v2-cache-keys.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-keys.js +128 -0
- package/dist/core/context-budget-v2-cache-keys.js.map +1 -0
- package/dist/core/context-budget-v2-cache-provider.d.ts +23 -0
- package/dist/core/context-budget-v2-cache-provider.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-provider.js +29 -0
- package/dist/core/context-budget-v2-cache-provider.js.map +1 -0
- package/dist/core/context-budget-v2-cache-telemetry.d.ts +36 -0
- package/dist/core/context-budget-v2-cache-telemetry.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-telemetry.js +64 -0
- package/dist/core/context-budget-v2-cache-telemetry.js.map +1 -0
- package/dist/core/context-budget-v2-cache-validation.d.ts +36 -0
- package/dist/core/context-budget-v2-cache-validation.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-validation.js +98 -0
- package/dist/core/context-budget-v2-cache-validation.js.map +1 -0
- package/dist/core/context-budget-v2-cache.d.ts +36 -0
- package/dist/core/context-budget-v2-cache.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache.js +50 -0
- package/dist/core/context-budget-v2-cache.js.map +1 -0
- package/dist/core/context-budget-v2-plan-cache-keys.d.ts +16 -0
- package/dist/core/context-budget-v2-plan-cache-keys.d.ts.map +1 -0
- package/dist/core/context-budget-v2-plan-cache-keys.js +49 -0
- package/dist/core/context-budget-v2-plan-cache-keys.js.map +1 -0
- package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planner.js +55 -2
- package/dist/core/context-budget-v2-planner.js.map +1 -1
- package/dist/core/context-budget-v2-representation-cache.d.ts +27 -0
- package/dist/core/context-budget-v2-representation-cache.d.ts.map +1 -0
- package/dist/core/context-budget-v2-representation-cache.js +173 -0
- package/dist/core/context-budget-v2-representation-cache.js.map +1 -0
- package/dist/core/context-budget-v2-selection.d.ts +2 -0
- package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
- package/dist/core/context-budget-v2-selection.js +12 -2
- package/dist/core/context-budget-v2-selection.js.map +1 -1
- package/dist/core/context-budget-v2-types.d.ts +107 -1
- package/dist/core/context-budget-v2-types.d.ts.map +1 -1
- package/dist/core/context-budget-v2-types.js.map +1 -1
- package/dist/core/domain-loadouts.d.ts.map +1 -1
- package/dist/core/domain-loadouts.js +1 -1
- package/dist/core/domain-loadouts.js.map +1 -1
- package/dist/core/headroom.d.ts.map +1 -1
- package/dist/core/headroom.js +0 -4
- package/dist/core/headroom.js.map +1 -1
- package/dist/core/hook-inventory.d.ts.map +1 -1
- package/dist/core/hook-inventory.js +6 -0
- package/dist/core/hook-inventory.js.map +1 -1
- package/dist/core/mcp-computer-use-presets.d.ts +64 -0
- package/dist/core/mcp-computer-use-presets.d.ts.map +1 -0
- package/dist/core/mcp-computer-use-presets.js +158 -0
- package/dist/core/mcp-computer-use-presets.js.map +1 -0
- package/dist/core/mcp-public-presets.d.ts +578 -0
- package/dist/core/mcp-public-presets.d.ts.map +1 -0
- package/dist/core/mcp-public-presets.js +647 -0
- package/dist/core/mcp-public-presets.js.map +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +1 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/pi-package-intake-candidates.d.ts +14 -1
- package/dist/core/pi-package-intake-candidates.d.ts.map +1 -1
- package/dist/core/pi-package-intake-candidates.js +182 -0
- package/dist/core/pi-package-intake-candidates.js.map +1 -1
- package/dist/core/pi-package-intake.d.ts +8 -1
- package/dist/core/pi-package-intake.d.ts.map +1 -1
- package/dist/core/pi-package-intake.js +14 -4
- package/dist/core/pi-package-intake.js.map +1 -1
- package/dist/core/reasoning-router-bias.d.ts +119 -0
- package/dist/core/reasoning-router-bias.d.ts.map +1 -0
- package/dist/core/reasoning-router-bias.js +287 -0
- package/dist/core/reasoning-router-bias.js.map +1 -0
- package/dist/core/reasoning-router-v2.d.ts +94 -0
- package/dist/core/reasoning-router-v2.d.ts.map +1 -0
- package/dist/core/reasoning-router-v2.js +288 -0
- package/dist/core/reasoning-router-v2.js.map +1 -0
- package/dist/core/reasoning-router-v3.d.ts +15 -0
- package/dist/core/reasoning-router-v3.d.ts.map +1 -0
- package/dist/core/reasoning-router-v3.js +193 -0
- package/dist/core/reasoning-router-v3.js.map +1 -0
- package/dist/core/reasoning-router-v4-weights.d.ts +124 -0
- package/dist/core/reasoning-router-v4-weights.d.ts.map +1 -0
- package/dist/core/reasoning-router-v4-weights.js +112 -0
- package/dist/core/reasoning-router-v4-weights.js.map +1 -0
- package/dist/core/reasoning-router-v4.d.ts +163 -0
- package/dist/core/reasoning-router-v4.d.ts.map +1 -0
- package/dist/core/reasoning-router-v4.js +683 -0
- package/dist/core/reasoning-router-v4.js.map +1 -0
- package/dist/core/reasoning-router-weights.d.ts +155 -0
- package/dist/core/reasoning-router-weights.d.ts.map +1 -0
- package/dist/core/reasoning-router-weights.js +204 -0
- package/dist/core/reasoning-router-weights.js.map +1 -0
- package/dist/core/reasoning-router.d.ts +44 -0
- package/dist/core/reasoning-router.d.ts.map +1 -0
- package/dist/core/reasoning-router.js +138 -0
- package/dist/core/reasoning-router.js.map +1 -0
- package/dist/core/reverse-skill.d.ts +2 -0
- package/dist/core/reverse-skill.d.ts.map +1 -0
- package/dist/core/reverse-skill.js +7 -0
- package/dist/core/reverse-skill.js.map +1 -0
- package/dist/core/router-feedback-collector.d.ts +101 -0
- package/dist/core/router-feedback-collector.d.ts.map +1 -0
- package/dist/core/router-feedback-collector.js +239 -0
- package/dist/core/router-feedback-collector.js.map +1 -0
- package/dist/core/settings-manager.d.ts +31 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +16 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +2 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +58 -5
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations.d.ts +19 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +39 -15
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-box.d.ts +3 -3
- package/dist/modes/interactive/components/control-panel-box.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-box.js +10 -10
- package/dist/modes/interactive/components/control-panel-box.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.js +2 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-layout.d.ts +15 -1
- package/dist/modes/interactive/components/control-panel-layout.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-layout.js +212 -68
- package/dist/modes/interactive/components/control-panel-layout.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-runtime-status.d.ts +15 -0
- package/dist/modes/interactive/components/control-panel-runtime-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-runtime-status.js +105 -5
- package/dist/modes/interactive/components/control-panel-runtime-status.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-sparkles.d.ts +27 -0
- package/dist/modes/interactive/components/control-panel-sparkles.d.ts.map +1 -0
- package/dist/modes/interactive/components/control-panel-sparkles.js +42 -0
- package/dist/modes/interactive/components/control-panel-sparkles.js.map +1 -0
- package/dist/modes/interactive/components/control-panel.d.ts +8 -0
- package/dist/modes/interactive/components/control-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel.js +40 -8
- package/dist/modes/interactive/components/control-panel.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +206 -32
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +2 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/docs/loadout-domains/README.md +8 -6
- package/docs/loadout-domains/ai-agent-ops.md +3 -2
- package/docs/loadout-domains/backend-api.md +3 -2
- package/docs/loadout-domains/data-science.md +3 -2
- package/docs/loadout-domains/devops-infra.md +2 -1
- package/docs/loadout-domains/docs-writing.md +7 -2
- package/docs/loadout-domains/frontend-ui.md +42 -11
- package/docs/loadout-domains/korean-document.md +83 -0
- package/docs/loadout-domains/mobile.md +1 -1
- package/docs/loadout-domains/qa-testing.md +4 -2
- package/docs/loadout-domains/security-audit.md +2 -1
- package/docs/loadout-domains/visual-qa.md +94 -0
- package/docs/skills.md +11 -4
- package/docs/usage.md +39 -4
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +27 -34
- package/package.json +5 -5
- package/dist/agents/jailbreak/index.d.ts +0 -7
- package/dist/agents/jailbreak/index.d.ts.map +0 -1
- package/dist/agents/jailbreak/index.js +0 -7
- package/dist/agents/jailbreak/index.js.map +0 -1
- package/dist/agents/jailbreak/subagent-f.d.ts +0 -44
- package/dist/agents/jailbreak/subagent-f.d.ts.map +0 -1
- package/dist/agents/jailbreak/subagent-f.js +0 -60
- package/dist/agents/jailbreak/subagent-f.js.map +0 -1
- package/dist/cli/jailbreak-args.d.ts +0 -26
- package/dist/cli/jailbreak-args.d.ts.map +0 -1
- package/dist/cli/jailbreak-args.js +0 -86
- package/dist/cli/jailbreak-args.js.map +0 -1
- package/dist/commands/jailbreak.d.ts +0 -49
- package/dist/commands/jailbreak.d.ts.map +0 -1
- package/dist/commands/jailbreak.js +0 -201
- package/dist/commands/jailbreak.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -6
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -6
- package/dist/encoding/index.js.map +0 -1
- package/dist/encoding/l4-encoder.d.ts +0 -96
- package/dist/encoding/l4-encoder.d.ts.map +0 -1
- package/dist/encoding/l4-encoder.js +0 -474
- package/dist/encoding/l4-encoder.js.map +0 -1
- package/dist/fuzzing/index.d.ts +0 -6
- package/dist/fuzzing/index.d.ts.map +0 -1
- package/dist/fuzzing/index.js +0 -6
- package/dist/fuzzing/index.js.map +0 -1
- package/dist/fuzzing/mutation-engine.d.ts +0 -93
- package/dist/fuzzing/mutation-engine.d.ts.map +0 -1
- package/dist/fuzzing/mutation-engine.js +0 -244
- package/dist/fuzzing/mutation-engine.js.map +0 -1
- package/dist/jailbreak-extension.d.ts +0 -48
- package/dist/jailbreak-extension.d.ts.map +0 -1
- package/dist/jailbreak-extension.js +0 -47
- package/dist/jailbreak-extension.js.map +0 -1
- package/dist/modules/index.d.ts +0 -8
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js +0 -7
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/lrl-bypass.d.ts +0 -40
- package/dist/modules/lrl-bypass.d.ts.map +0 -1
- package/dist/modules/lrl-bypass.js +0 -84
- package/dist/modules/lrl-bypass.js.map +0 -1
- package/dist/modules/lrl-deps.d.ts +0 -38
- package/dist/modules/lrl-deps.d.ts.map +0 -1
- package/dist/modules/lrl-deps.js +0 -128
- package/dist/modules/lrl-deps.js.map +0 -1
- package/dist/multiturn/easl-chain.d.ts +0 -113
- package/dist/multiturn/easl-chain.d.ts.map +0 -1
- package/dist/multiturn/easl-chain.js +0 -351
- package/dist/multiturn/easl-chain.js.map +0 -1
- package/dist/multiturn/index.d.ts +0 -6
- package/dist/multiturn/index.d.ts.map +0 -1
- package/dist/multiturn/index.js +0 -6
- package/dist/multiturn/index.js.map +0 -1
- package/dist/routing/fallback-router.d.ts +0 -123
- package/dist/routing/fallback-router.d.ts.map +0 -1
- package/dist/routing/fallback-router.js +0 -355
- package/dist/routing/fallback-router.js.map +0 -1
- package/dist/routing/index.d.ts +0 -6
- package/dist/routing/index.d.ts.map +0 -1
- package/dist/routing/index.js +0 -6
- package/dist/routing/index.js.map +0 -1
- package/dist/types/jailbreak.d.ts +0 -246
- package/dist/types/jailbreak.d.ts.map +0 -1
- package/dist/types/jailbreak.js +0 -8
- package/dist/types/jailbreak.js.map +0 -1
- package/dist/utils/jailbreak/common.d.ts +0 -63
- package/dist/utils/jailbreak/common.d.ts.map +0 -1
- package/dist/utils/jailbreak/common.js +0 -130
- package/dist/utils/jailbreak/common.js.map +0 -1
- package/dist/utils/jailbreak/index.d.ts +0 -7
- package/dist/utils/jailbreak/index.d.ts.map +0 -1
- package/dist/utils/jailbreak/index.js +0 -7
- package/dist/utils/jailbreak/index.js.map +0 -1
|
@@ -20,6 +20,7 @@ import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
|
20
20
|
import { resolvePath } from "../utils/paths.js";
|
|
21
21
|
import { sleep } from "../utils/sleep.js";
|
|
22
22
|
import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
|
|
23
|
+
import { parseBangInvocation } from "./bang-skill-invocation.js";
|
|
23
24
|
import { executeBashWithOperations } from "./bash-executor.js";
|
|
24
25
|
import { classifyShellCommand } from "./command-safety.js";
|
|
25
26
|
import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, estimateProjectedContextTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
|
|
@@ -31,6 +32,12 @@ import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
|
31
32
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
32
33
|
import { assertLoadoutAccess, decideLoadoutAccess } from "./loadout-access-policy.js";
|
|
33
34
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
35
|
+
import { classifyTask, resolveThinkingLevel } from "./reasoning-router.js";
|
|
36
|
+
import { getBiasStepsForCell, getDefaultRouterBiasSnapshotPath, parseRouterBiasSnapshot, } from "./reasoning-router-bias.js";
|
|
37
|
+
import { classifyTaskV2, DEFAULT_WEIGHTS, resolveThinkingLevelV2ForAuto, } from "./reasoning-router-v2.js";
|
|
38
|
+
import { classifyTaskV3, resolveThinkingLevelV3ForAuto } from "./reasoning-router-v3.js";
|
|
39
|
+
import { classifyTaskV4, resolveThinkingLevelV4WithUncertainty } from "./reasoning-router-v4.js";
|
|
40
|
+
import { appendRouterFeedbackRecord, } from "./router-feedback-collector.js";
|
|
34
41
|
import { detectSandboxBackend } from "./sandbox/backend.js";
|
|
35
42
|
import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
|
|
36
43
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
@@ -53,6 +60,17 @@ export function parseSkillBlock(text) {
|
|
|
53
60
|
userMessage: match[4]?.trim() || undefined,
|
|
54
61
|
};
|
|
55
62
|
}
|
|
63
|
+
function mergePromptActiveSkillNames(first, second) {
|
|
64
|
+
const names = [];
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
for (const name of [...first, ...second]) {
|
|
67
|
+
if (!seen.has(name)) {
|
|
68
|
+
seen.add(name);
|
|
69
|
+
names.push(name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return names;
|
|
73
|
+
}
|
|
56
74
|
// ============================================================================
|
|
57
75
|
// Constants
|
|
58
76
|
// ============================================================================
|
|
@@ -86,6 +104,36 @@ export class AgentSession {
|
|
|
86
104
|
sessionManager;
|
|
87
105
|
settingsManager;
|
|
88
106
|
_scopedModels;
|
|
107
|
+
/**
|
|
108
|
+
* Thinking mode (default "manual"). Persists across turns within the session;
|
|
109
|
+
* auto-resolved levels are never written to the user's persisted settings.
|
|
110
|
+
*/
|
|
111
|
+
_thinkingMode = "manual";
|
|
112
|
+
/**
|
|
113
|
+
* Reasoning router version used by auto thinking mode. "v1" (default) keeps
|
|
114
|
+
* the frozen v1 classifyTask/resolveThinkingLevel; "v2" uses the Goal 004
|
|
115
|
+
* weighted router; "v3" uses the Goal 007 calibrated classifier; "v4" uses
|
|
116
|
+
* the Goal 009 confidence-bearing classifier (classifyTaskV4 +
|
|
117
|
+
* resolveThinkingLevelV4WithUncertainty). Default "v1" so behavior is
|
|
118
|
+
* unchanged until explicitly opted in.
|
|
119
|
+
*/
|
|
120
|
+
_thinkingRouterVersion = "v1";
|
|
121
|
+
/**
|
|
122
|
+
* N=8 ring buffer of recent auto-turn task classes (newest first), feeding
|
|
123
|
+
* the v2/v3 classifiers' multi-turn prior feature. Never persisted to settings.
|
|
124
|
+
*/
|
|
125
|
+
_taskClassHistory = [];
|
|
126
|
+
/**
|
|
127
|
+
* Compiled reasoning-router bias snapshot for the opt-in v4 learning path
|
|
128
|
+
* (Goal 010 Lane I). Loaded at most once per session and pinned thereafter:
|
|
129
|
+
* `_reasoningRouterBiasSnapshotLoaded` flips to `true` on the first v4
|
|
130
|
+
* auto-turn that has learning enabled, and `_reasoningRouterBiasSnapshot`
|
|
131
|
+
* then stays fixed for the rest of the session (even across later settings
|
|
132
|
+
* reloads, and even if the on-disk file changes or the load failed/was
|
|
133
|
+
* invalid, in which case it stays `null`). See `_getReasoningRouterBiasSnapshot`.
|
|
134
|
+
*/
|
|
135
|
+
_reasoningRouterBiasSnapshot = null;
|
|
136
|
+
_reasoningRouterBiasSnapshotLoaded = false;
|
|
89
137
|
// Event subscription state
|
|
90
138
|
_unsubscribeAgent;
|
|
91
139
|
_eventListeners = [];
|
|
@@ -540,6 +588,10 @@ export class AgentSession {
|
|
|
540
588
|
get thinkingLevel() {
|
|
541
589
|
return this.agent.state.thinkingLevel;
|
|
542
590
|
}
|
|
591
|
+
/** Current thinking mode ("manual" = user-selected level, "auto" = per-turn router) */
|
|
592
|
+
get thinkingMode() {
|
|
593
|
+
return this._thinkingMode;
|
|
594
|
+
}
|
|
543
595
|
/** Whether agent is currently streaming a response */
|
|
544
596
|
get isStreaming() {
|
|
545
597
|
return this.agent.state.isStreaming;
|
|
@@ -852,12 +904,29 @@ export class AgentSession {
|
|
|
852
904
|
async prompt(text, options) {
|
|
853
905
|
const expandPromptTemplates = options?.expandPromptTemplates ?? true;
|
|
854
906
|
const preflightResult = options?.preflightResult;
|
|
907
|
+
let currentText = text;
|
|
908
|
+
let promptActiveSkillNames = [...(options?.activeSkillNames ?? [])];
|
|
909
|
+
let promptActiveSkillSource = options?.activeSkillSource;
|
|
910
|
+
let isBangSkillInvocation = false;
|
|
911
|
+
if (expandPromptTemplates) {
|
|
912
|
+
const bangInvocation = parseBangInvocation(text, {
|
|
913
|
+
hasSkill: (name) => this._resourceLoader.getSkills().skills.some((skill) => skill.name === name),
|
|
914
|
+
});
|
|
915
|
+
if (bangInvocation.kind === "skill") {
|
|
916
|
+
isBangSkillInvocation = true;
|
|
917
|
+
currentText = bangInvocation.prompt
|
|
918
|
+
? `/skill:${bangInvocation.skillName} ${bangInvocation.prompt}`
|
|
919
|
+
: `/skill:${bangInvocation.skillName}`;
|
|
920
|
+
promptActiveSkillNames = mergePromptActiveSkillNames(promptActiveSkillNames, bangInvocation.activeSkillNames);
|
|
921
|
+
promptActiveSkillSource = bangInvocation.source;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
855
924
|
let messages;
|
|
856
925
|
try {
|
|
857
926
|
// Handle extension commands first (execute immediately, even during streaming)
|
|
858
927
|
// Extension commands manage their own LLM interaction via omk.sendMessage()
|
|
859
|
-
if (expandPromptTemplates &&
|
|
860
|
-
const handled = await this._tryExecuteExtensionCommand(
|
|
928
|
+
if (expandPromptTemplates && !isBangSkillInvocation && currentText.startsWith("/")) {
|
|
929
|
+
const handled = await this._tryExecuteExtensionCommand(currentText);
|
|
861
930
|
if (handled) {
|
|
862
931
|
// Extension command executed, no prompt to send
|
|
863
932
|
preflightResult?.(true);
|
|
@@ -865,7 +934,6 @@ export class AgentSession {
|
|
|
865
934
|
}
|
|
866
935
|
}
|
|
867
936
|
// Emit input event for extension interception (before skill/template expansion)
|
|
868
|
-
let currentText = text;
|
|
869
937
|
let currentImages = options?.images;
|
|
870
938
|
if (this._extensionRunner.hasHandlers("input")) {
|
|
871
939
|
const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive", this.isStreaming ? options?.streamingBehavior : undefined);
|
|
@@ -926,6 +994,9 @@ export class AgentSession {
|
|
|
926
994
|
this._flushPendingBashMessages();
|
|
927
995
|
}
|
|
928
996
|
}
|
|
997
|
+
// Auto thinking mode: resolve this turn's level from the prompt content.
|
|
998
|
+
// Manual mode never enters the router, so /think <level> always wins.
|
|
999
|
+
this._applyAutoThinkingLevelForTurn(expandedText);
|
|
929
1000
|
// Build messages array (custom message if any, then user message)
|
|
930
1001
|
messages = [];
|
|
931
1002
|
// Add user message
|
|
@@ -943,8 +1014,16 @@ export class AgentSession {
|
|
|
943
1014
|
messages.push(msg);
|
|
944
1015
|
}
|
|
945
1016
|
this._pendingNextTurnMessages = [];
|
|
1017
|
+
const turnSystemPromptOptions = promptActiveSkillNames.length > 0
|
|
1018
|
+
? {
|
|
1019
|
+
...this._baseSystemPromptOptions,
|
|
1020
|
+
activeSkillNames: promptActiveSkillNames,
|
|
1021
|
+
...(promptActiveSkillSource ? { activeSkillSource: promptActiveSkillSource } : {}),
|
|
1022
|
+
}
|
|
1023
|
+
: this._baseSystemPromptOptions;
|
|
1024
|
+
const turnSystemPrompt = promptActiveSkillNames.length > 0 ? buildSystemPrompt(turnSystemPromptOptions) : this._baseSystemPrompt;
|
|
946
1025
|
// Emit before_agent_start extension event
|
|
947
|
-
const result = await this._extensionRunner.emitBeforeAgentStart(expandedText, currentImages,
|
|
1026
|
+
const result = await this._extensionRunner.emitBeforeAgentStart(expandedText, currentImages, turnSystemPrompt, turnSystemPromptOptions);
|
|
948
1027
|
// Add all custom messages from extensions
|
|
949
1028
|
if (result?.messages) {
|
|
950
1029
|
for (const msg of result.messages) {
|
|
@@ -964,7 +1043,7 @@ export class AgentSession {
|
|
|
964
1043
|
}
|
|
965
1044
|
else {
|
|
966
1045
|
// Ensure we're using the base prompt (in case previous turn had modifications)
|
|
967
|
-
this.agent.state.systemPrompt =
|
|
1046
|
+
this.agent.state.systemPrompt = turnSystemPrompt;
|
|
968
1047
|
}
|
|
969
1048
|
await this._checkProjectedCompaction(messages);
|
|
970
1049
|
}
|
|
@@ -1344,6 +1423,249 @@ export class AgentSession {
|
|
|
1344
1423
|
});
|
|
1345
1424
|
}
|
|
1346
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Set the thinking mode. "auto" resolves a level per turn via the reasoning
|
|
1428
|
+
* router; "manual" keeps the explicitly selected level. The mode persists for
|
|
1429
|
+
* the session lifetime and is never written to user settings.
|
|
1430
|
+
*/
|
|
1431
|
+
setThinkingMode(mode) {
|
|
1432
|
+
this._thinkingMode = mode;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Reasoning router version selection for auto thinking mode.
|
|
1436
|
+
* Default "v1". Switching to "v2", "v3", or "v4" activates the
|
|
1437
|
+
* corresponding opt-in router; the multi-turn history buffer is only
|
|
1438
|
+
* consulted there.
|
|
1439
|
+
*/
|
|
1440
|
+
get thinkingRouterVersion() {
|
|
1441
|
+
return this._thinkingRouterVersion;
|
|
1442
|
+
}
|
|
1443
|
+
setThinkingRouterVersion(version) {
|
|
1444
|
+
this._thinkingRouterVersion = version;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* In auto thinking mode, resolve and apply this turn's thinking level from the
|
|
1448
|
+
* prompt content. Updates agent state, records the change in the session, and
|
|
1449
|
+
* notifies observers - but never overwrites the user's persisted default
|
|
1450
|
+
* thinking level in settings. Models without reasoning support bypass the
|
|
1451
|
+
* router entirely (level stays "off").
|
|
1452
|
+
*/
|
|
1453
|
+
_applyAutoThinkingLevelForTurn(promptText) {
|
|
1454
|
+
if (this._thinkingMode !== "auto")
|
|
1455
|
+
return;
|
|
1456
|
+
if (!this.supportsThinking())
|
|
1457
|
+
return;
|
|
1458
|
+
if (this._thinkingRouterVersion === "v4") {
|
|
1459
|
+
this._applyAutoThinkingLevelV4(promptText);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
if (this._thinkingRouterVersion === "v3") {
|
|
1463
|
+
this._applyAutoThinkingLevelV3(promptText);
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
if (this._thinkingRouterVersion === "v2") {
|
|
1467
|
+
this._applyAutoThinkingLevelV2(promptText);
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
const taskClass = classifyTask({ prompt: promptText });
|
|
1471
|
+
const resolved = resolveThinkingLevel(taskClass, this.getAvailableThinkingLevels());
|
|
1472
|
+
const previousLevel = this.agent.state.thinkingLevel;
|
|
1473
|
+
if (resolved === previousLevel)
|
|
1474
|
+
return;
|
|
1475
|
+
this.agent.state.thinkingLevel = resolved;
|
|
1476
|
+
this.sessionManager.appendThinkingLevelChange(resolved);
|
|
1477
|
+
this._emit({ type: "thinking_level_changed", level: resolved });
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* v2 auto-mode resolver (Goal 004). Builds the caller-side features the pure
|
|
1481
|
+
* classifier cannot reach on its own (multi-turn ring buffer, context-pressure
|
|
1482
|
+
* bucket), then applies classifyTaskV2 + resolveThinkingLevelV2ForAuto. The
|
|
1483
|
+
* resolved class is pushed to the N=8 history for the NEXT turn's prior.
|
|
1484
|
+
*/
|
|
1485
|
+
_applyAutoThinkingLevelV2(promptText) {
|
|
1486
|
+
const availableLevels = this.getAvailableThinkingLevels();
|
|
1487
|
+
const taskClass = classifyTaskV2({
|
|
1488
|
+
prompt: promptText,
|
|
1489
|
+
history: this._taskClassHistory,
|
|
1490
|
+
pressureBucket: this._computePressureBucket(),
|
|
1491
|
+
}, DEFAULT_WEIGHTS);
|
|
1492
|
+
this._taskClassHistory.unshift(taskClass);
|
|
1493
|
+
if (this._taskClassHistory.length > 8)
|
|
1494
|
+
this._taskClassHistory.length = 8;
|
|
1495
|
+
const resolved = resolveThinkingLevelV2ForAuto(taskClass, availableLevels, undefined);
|
|
1496
|
+
const previousLevel = this.agent.state.thinkingLevel;
|
|
1497
|
+
if (resolved === previousLevel)
|
|
1498
|
+
return;
|
|
1499
|
+
this.agent.state.thinkingLevel = resolved;
|
|
1500
|
+
this.sessionManager.appendThinkingLevelChange(resolved);
|
|
1501
|
+
this._emit({ type: "thinking_level_changed", level: resolved });
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* v3 auto-mode resolver (Goal 007). Reuses the same N=8 recent-class history
|
|
1505
|
+
* and context-pressure bucket as v2, but routes through the v3 classifier and
|
|
1506
|
+
* resolver pair.
|
|
1507
|
+
*/
|
|
1508
|
+
_applyAutoThinkingLevelV3(promptText) {
|
|
1509
|
+
const availableLevels = this.getAvailableThinkingLevels();
|
|
1510
|
+
const taskClass = classifyTaskV3({
|
|
1511
|
+
prompt: promptText,
|
|
1512
|
+
history: this._taskClassHistory,
|
|
1513
|
+
pressureBucket: this._computePressureBucket(),
|
|
1514
|
+
});
|
|
1515
|
+
this._taskClassHistory.unshift(taskClass);
|
|
1516
|
+
if (this._taskClassHistory.length > 8)
|
|
1517
|
+
this._taskClassHistory.length = 8;
|
|
1518
|
+
const resolved = resolveThinkingLevelV3ForAuto(taskClass, availableLevels, undefined);
|
|
1519
|
+
const previousLevel = this.agent.state.thinkingLevel;
|
|
1520
|
+
if (resolved === previousLevel)
|
|
1521
|
+
return;
|
|
1522
|
+
this.agent.state.thinkingLevel = resolved;
|
|
1523
|
+
this.sessionManager.appendThinkingLevelChange(resolved);
|
|
1524
|
+
this._emit({ type: "thinking_level_changed", level: resolved });
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* v4 auto-mode resolver (Goal 009 Wave 3 Lane V1; wired to the opt-in
|
|
1528
|
+
* learning bias by Goal 010 Lane I). Reuses the same N=8 recent-class
|
|
1529
|
+
* history and context-pressure bucket as v2/v3, routed through the
|
|
1530
|
+
* confidence-bearing v4 classifier and its uncertainty-aware resolver. No
|
|
1531
|
+
* `laneType` applies to the main session (always "none"/`undefined`);
|
|
1532
|
+
* `hint` is permanently `null` -- the Adaptorch advisory bridge has no
|
|
1533
|
+
* transport wired into the session (out of this lane's scope; see
|
|
1534
|
+
* adaptorch-bridge.ts). `bias` stays `0` unless BOTH hold: (a) the global,
|
|
1535
|
+
* owner-only `reasoningRouterLearning.enabled` setting is `true` (default
|
|
1536
|
+
* off; a project-scope `.omk/settings.json` value for this key is never
|
|
1537
|
+
* consulted -- see settings-manager.ts), and (b) a compiled
|
|
1538
|
+
* `RouterBiasSnapshot` was found and passed strict validation at the
|
|
1539
|
+
* configured/default path, loaded and cached ("pinned") at most once per
|
|
1540
|
+
* session (see `_getReasoningRouterBiasSnapshot`). When learning is
|
|
1541
|
+
* enabled, exactly one bounded "accepted" feedback record (no raw prompt/
|
|
1542
|
+
* path/diff/session/model/provider/tool/hook content; see
|
|
1543
|
+
* router-feedback-collector.ts's exact ten-key schema) is appended to the
|
|
1544
|
+
* local ledger after every v4 auto-turn resolution, for a future, separate
|
|
1545
|
+
* offline compile step to learn from -- this lane never records an
|
|
1546
|
+
* override/fail/hook-outcome signal, only the neutral "accepted" one. The
|
|
1547
|
+
* resolver's own confidence-band/fallback-reason escalation (see
|
|
1548
|
+
* reasoning-router-v4.ts) still applies on top of the base+lane+bias
|
|
1549
|
+
* target, so a low-confidence or fallback-decided verdict can still only
|
|
1550
|
+
* match or exceed the confident-path level.
|
|
1551
|
+
*/
|
|
1552
|
+
_applyAutoThinkingLevelV4(promptText) {
|
|
1553
|
+
const availableLevels = this.getAvailableThinkingLevels();
|
|
1554
|
+
const verdict = classifyTaskV4({
|
|
1555
|
+
prompt: promptText,
|
|
1556
|
+
history: this._taskClassHistory,
|
|
1557
|
+
pressureBucket: this._computePressureBucket(),
|
|
1558
|
+
});
|
|
1559
|
+
this._taskClassHistory.unshift(verdict.taskClass);
|
|
1560
|
+
if (this._taskClassHistory.length > 8)
|
|
1561
|
+
this._taskClassHistory.length = 8;
|
|
1562
|
+
const learningEnabled = this.settingsManager.getReasoningRouterLearningEnabled();
|
|
1563
|
+
const snapshot = learningEnabled ? this._getReasoningRouterBiasSnapshot() : null;
|
|
1564
|
+
const features = this._deriveRouterFeedbackFeatures(promptText);
|
|
1565
|
+
const bias = snapshot === null
|
|
1566
|
+
? 0
|
|
1567
|
+
: getBiasStepsForCell(snapshot, {
|
|
1568
|
+
predictedClass: verdict.taskClass,
|
|
1569
|
+
laneType: "none",
|
|
1570
|
+
lenBucket: features.lenBucket,
|
|
1571
|
+
hadFence: features.hadFence,
|
|
1572
|
+
hadDiff: features.hadDiff,
|
|
1573
|
+
});
|
|
1574
|
+
const resolved = resolveThinkingLevelV4WithUncertainty(verdict, availableLevels, undefined, bias, null);
|
|
1575
|
+
if (learningEnabled && resolved !== "off") {
|
|
1576
|
+
const record = {
|
|
1577
|
+
routerVersion: "v4",
|
|
1578
|
+
laneType: "none",
|
|
1579
|
+
predictedClass: verdict.taskClass,
|
|
1580
|
+
resolvedLevel: resolved,
|
|
1581
|
+
acceptedLevel: resolved,
|
|
1582
|
+
signal: "s2-accept",
|
|
1583
|
+
outcome: "accepted",
|
|
1584
|
+
lenBucket: features.lenBucket,
|
|
1585
|
+
hadFence: features.hadFence,
|
|
1586
|
+
hadDiff: features.hadDiff,
|
|
1587
|
+
};
|
|
1588
|
+
appendRouterFeedbackRecord(record, {
|
|
1589
|
+
enabled: true,
|
|
1590
|
+
ledgerPath: this.settingsManager.getReasoningRouterLearningFeedbackLedgerPath(),
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
const previousLevel = this.agent.state.thinkingLevel;
|
|
1594
|
+
if (resolved === previousLevel)
|
|
1595
|
+
return;
|
|
1596
|
+
this.agent.state.thinkingLevel = resolved;
|
|
1597
|
+
this.sessionManager.appendThinkingLevelChange(resolved);
|
|
1598
|
+
this._emit({ type: "thinking_level_changed", level: resolved });
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Loads and strictly validates the compiled reasoning-router bias snapshot
|
|
1602
|
+
* for the opt-in v4 learning path (Goal 010 Lane I), at most once per
|
|
1603
|
+
* session ("pinned"): the first call attempts the read and caches whatever
|
|
1604
|
+
* it finds (including a `null` miss/failure); every later call in the same
|
|
1605
|
+
* session reuses that cached result without touching disk again. Returns
|
|
1606
|
+
* `null` when no file exists at the configured/default path, the file
|
|
1607
|
+
* cannot be read, or its contents fail `parseRouterBiasSnapshot`'s schema
|
|
1608
|
+
* validation -- never throws.
|
|
1609
|
+
*/
|
|
1610
|
+
_getReasoningRouterBiasSnapshot() {
|
|
1611
|
+
if (this._reasoningRouterBiasSnapshotLoaded)
|
|
1612
|
+
return this._reasoningRouterBiasSnapshot;
|
|
1613
|
+
this._reasoningRouterBiasSnapshotLoaded = true;
|
|
1614
|
+
const path = this.settingsManager.getReasoningRouterLearningBiasSnapshotPath() ?? getDefaultRouterBiasSnapshotPath();
|
|
1615
|
+
try {
|
|
1616
|
+
if (existsSync(path)) {
|
|
1617
|
+
this._reasoningRouterBiasSnapshot = parseRouterBiasSnapshot(readFileSync(path, "utf-8"));
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
catch {
|
|
1621
|
+
this._reasoningRouterBiasSnapshot = null;
|
|
1622
|
+
}
|
|
1623
|
+
return this._reasoningRouterBiasSnapshot;
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Locally derives the same three bounded, privacy-safe feedback-ledger
|
|
1627
|
+
* features (`lenBucket`, `hadFence`, `hadDiff`) the v4 classifier computes
|
|
1628
|
+
* internally (reasoning-router-v4.ts keeps those helpers file-private, so
|
|
1629
|
+
* they cannot be imported here). Mirrors reasoning-router-v2.ts's
|
|
1630
|
+
* `clampLenBucket` and reasoning-router-v4.ts's `hasCodeFence`/
|
|
1631
|
+
* `hasDiffMarkers` byte-for-byte. Operates on the same trimmed prompt text
|
|
1632
|
+
* the classifier scores; never returns raw prompt content or its exact
|
|
1633
|
+
* length, only the clamped [0,7] bucket and two booleans.
|
|
1634
|
+
*/
|
|
1635
|
+
_deriveRouterFeedbackFeatures(promptText) {
|
|
1636
|
+
const trimmed = promptText.trim();
|
|
1637
|
+
let lenBucket = 0;
|
|
1638
|
+
let remaining = trimmed.length + 1;
|
|
1639
|
+
while (remaining > 1 && lenBucket < 7) {
|
|
1640
|
+
remaining >>= 1;
|
|
1641
|
+
lenBucket++;
|
|
1642
|
+
}
|
|
1643
|
+
const hadFence = trimmed.includes("```");
|
|
1644
|
+
const hadDiff = /^@@[^\n]*@@/m.test(trimmed) ||
|
|
1645
|
+
/^diff --git /m.test(trimmed) ||
|
|
1646
|
+
(/^\+(?!\+)/m.test(trimmed) && /^-(?!-)/m.test(trimmed));
|
|
1647
|
+
return { lenBucket: lenBucket, hadFence, hadDiff };
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Context-pressure band 0..3 from the projected token estimate over the
|
|
1651
|
+
* model context window (reuses estimateProjectedContextTokens). 0..<0.5,
|
|
1652
|
+
* 1..<0.75, 2..<0.9, 3..>=0.9. Inert under DEFAULT_WEIGHTS (no pressure
|
|
1653
|
+
* coefficient); computed for future calibrated weight presets.
|
|
1654
|
+
*/
|
|
1655
|
+
_computePressureBucket() {
|
|
1656
|
+
const contextWindow = this.model?.contextWindow ?? 0;
|
|
1657
|
+
if (contextWindow <= 0)
|
|
1658
|
+
return 0;
|
|
1659
|
+
const estimate = estimateProjectedContextTokens(this.agent.state.messages, []);
|
|
1660
|
+
const pressure = estimate.tokens / contextWindow;
|
|
1661
|
+
if (pressure >= 0.9)
|
|
1662
|
+
return 3;
|
|
1663
|
+
if (pressure >= 0.75)
|
|
1664
|
+
return 2;
|
|
1665
|
+
if (pressure >= 0.5)
|
|
1666
|
+
return 1;
|
|
1667
|
+
return 0;
|
|
1668
|
+
}
|
|
1347
1669
|
/**
|
|
1348
1670
|
* Cycle to next thinking level.
|
|
1349
1671
|
* @returns New level, or undefined if model doesn't support thinking
|