@elyracode/coding-agent 0.1.0 → 0.2.0
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 +9 -0
- package/dist/core/agent-session-runtime.d.ts +1 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +35 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +47 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/memory.d.ts +23 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +173 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/settings-manager.d.ts +6 -0
- 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/smart-router.d.ts +43 -0
- package/dist/core/smart-router.d.ts.map +1 -0
- package/dist/core/smart-router.js +206 -0
- package/dist/core/smart-router.js.map +1 -0
- 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 +15 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +8 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +2 -2
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/with-deps/package.json +2 -2
- package/package.json +5 -5
|
@@ -26,8 +26,10 @@ import { exportSessionToHtml } from "./export-html/index.js";
|
|
|
26
26
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
27
27
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
28
28
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
29
|
+
import { loadMemory } from "./memory.js";
|
|
29
30
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
30
31
|
import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
|
|
32
|
+
import { routeNextTurn } from "./smart-router.js";
|
|
31
33
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
32
34
|
import { buildSystemPrompt } from "./system-prompt.js";
|
|
33
35
|
import { createLocalBashOperations } from "./tools/bash.js";
|
|
@@ -130,6 +132,7 @@ export class AgentSession {
|
|
|
130
132
|
// (session persistence, extensions, auto-compaction, retry logic)
|
|
131
133
|
this._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);
|
|
132
134
|
this._installAgentToolHooks();
|
|
135
|
+
this._installSmartRouting();
|
|
133
136
|
this._buildRuntime({
|
|
134
137
|
activeToolNames: this._initialActiveToolNames,
|
|
135
138
|
includeAllExtensionTools: true,
|
|
@@ -663,6 +666,8 @@ export class AgentSession {
|
|
|
663
666
|
const appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join("\n\n") : undefined;
|
|
664
667
|
const loadedSkills = this._resourceLoader.getSkills().skills;
|
|
665
668
|
const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
|
|
669
|
+
// Load codebase memory if enabled
|
|
670
|
+
const memoryContent = this.settingsManager.getCodebaseMemory() ? loadMemory(this._cwd) : undefined;
|
|
666
671
|
this._baseSystemPromptOptions = {
|
|
667
672
|
cwd: this._cwd,
|
|
668
673
|
skills: loadedSkills,
|
|
@@ -672,6 +677,7 @@ export class AgentSession {
|
|
|
672
677
|
selectedTools: validToolNames,
|
|
673
678
|
toolSnippets,
|
|
674
679
|
promptGuidelines,
|
|
680
|
+
memoryContent,
|
|
675
681
|
};
|
|
676
682
|
return buildSystemPrompt(this._baseSystemPromptOptions);
|
|
677
683
|
}
|
|
@@ -1857,6 +1863,47 @@ export class AgentSession {
|
|
|
1857
1863
|
}
|
|
1858
1864
|
this.setActiveToolsByName([...new Set(nextActiveToolNames)]);
|
|
1859
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Install smart model routing via the prepareNextTurn hook.
|
|
1868
|
+
* When enabled, the router analyzes turn complexity and swaps to a
|
|
1869
|
+
* cheaper or more powerful model automatically.
|
|
1870
|
+
*/
|
|
1871
|
+
_installSmartRouting() {
|
|
1872
|
+
const existingHook = this.agent.prepareNextTurn;
|
|
1873
|
+
this.agent.prepareNextTurn = async (signal) => {
|
|
1874
|
+
// Run existing hook first (if any)
|
|
1875
|
+
const existing = existingHook ? await existingHook(signal) : undefined;
|
|
1876
|
+
if (!this.settingsManager.getSmartRouting()) {
|
|
1877
|
+
return existing;
|
|
1878
|
+
}
|
|
1879
|
+
// Build available models list from scoped models or all available
|
|
1880
|
+
let availableModels;
|
|
1881
|
+
if (this._scopedModels.length > 0) {
|
|
1882
|
+
availableModels = this._scopedModels
|
|
1883
|
+
.filter((sm) => this._modelRegistry.hasConfiguredAuth(sm.model))
|
|
1884
|
+
.map((sm) => sm.model);
|
|
1885
|
+
}
|
|
1886
|
+
else {
|
|
1887
|
+
availableModels = await this._modelRegistry.getAvailable();
|
|
1888
|
+
}
|
|
1889
|
+
if (availableModels.length <= 1) {
|
|
1890
|
+
return existing;
|
|
1891
|
+
}
|
|
1892
|
+
const config = {
|
|
1893
|
+
enabled: true,
|
|
1894
|
+
availableModels,
|
|
1895
|
+
preferredModel: this.agent.state.model,
|
|
1896
|
+
};
|
|
1897
|
+
const result = routeNextTurn({ messages: this.agent.state.messages, thinkingLevel: this.agent.state.thinkingLevel }, config);
|
|
1898
|
+
if (!result) {
|
|
1899
|
+
return existing;
|
|
1900
|
+
}
|
|
1901
|
+
return {
|
|
1902
|
+
...existing,
|
|
1903
|
+
model: result.model,
|
|
1904
|
+
};
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1860
1907
|
_buildRuntime(options) {
|
|
1861
1908
|
const autoResizeImages = this.settingsManager.getImageAutoResize();
|
|
1862
1909
|
const shellCommandPrefix = this.settingsManager.getShellCommandPrefix();
|