@caupulican/pi-adaptative 0.80.54 → 0.80.55
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 +2 -0
- package/dist/core/agent-session.d.ts +10 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +44 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/sdk.d.ts +8 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -1
- 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/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 +12 -12
- package/package.json +4 -4
|
@@ -32,6 +32,7 @@ import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
|
32
32
|
import { disposeExtensionEventSubscriptions } from "./extensions/loader.js";
|
|
33
33
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
34
34
|
import { compactToolResultDetailsForRetention } from "./message-retention.js";
|
|
35
|
+
import { resolveProfileModelSettings } from "./model-resolver.js";
|
|
35
36
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
36
37
|
import { stripResourceProfileBlocks } from "./resource-profile-blocks.js";
|
|
37
38
|
import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
|
|
@@ -109,6 +110,8 @@ export class AgentSession {
|
|
|
109
110
|
_allowedToolNames;
|
|
110
111
|
_excludedToolNames;
|
|
111
112
|
_toolProfileFilter;
|
|
113
|
+
_isExplicitModel;
|
|
114
|
+
_isExplicitThinking;
|
|
112
115
|
_baseToolsOverride;
|
|
113
116
|
_sessionStartEvent;
|
|
114
117
|
_extensionUIContext;
|
|
@@ -145,6 +148,8 @@ export class AgentSession {
|
|
|
145
148
|
this._toolProfileFilter = config.toolProfileFilter
|
|
146
149
|
? { allow: config.toolProfileFilter.allow ?? [], block: config.toolProfileFilter.block ?? [] }
|
|
147
150
|
: undefined;
|
|
151
|
+
this._isExplicitModel = config.isExplicitModel ?? false;
|
|
152
|
+
this._isExplicitThinking = config.isExplicitThinking ?? false;
|
|
148
153
|
this._baseToolsOverride = config.baseToolsOverride;
|
|
149
154
|
this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
|
|
150
155
|
// Always subscribe to agent events for internal handling
|
|
@@ -2123,6 +2128,41 @@ export class AgentSession {
|
|
|
2123
2128
|
const filter = this.settingsManager.getResourceProfileFilter("tools");
|
|
2124
2129
|
return { allow: filter.allow ?? [], block: filter.block ?? [] };
|
|
2125
2130
|
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Re-resolve the active resource profile's model/thinking from current settings and apply it.
|
|
2133
|
+
* Only acts when the profile actually binds model/thinking AND that field was not set by an
|
|
2134
|
+
* explicit launch flag — so live profile edits apply on reload without clobbering an explicit
|
|
2135
|
+
* --model/--thinking. A no-op for profiles that don't bind a model.
|
|
2136
|
+
*/
|
|
2137
|
+
async _reapplyActiveProfileModelSettings() {
|
|
2138
|
+
if (this._isExplicitModel && this._isExplicitThinking)
|
|
2139
|
+
return;
|
|
2140
|
+
const activeProfileNames = this.settingsManager.getActiveResourceProfileNames();
|
|
2141
|
+
if (activeProfileNames.length === 0)
|
|
2142
|
+
return;
|
|
2143
|
+
const profileSettings = resolveProfileModelSettings({
|
|
2144
|
+
activeProfileNames,
|
|
2145
|
+
registry: this.settingsManager.getProfileRegistry(),
|
|
2146
|
+
modelRegistry: this._modelRegistry,
|
|
2147
|
+
cwd: this._cwd,
|
|
2148
|
+
});
|
|
2149
|
+
if (!this._isExplicitModel && profileSettings.model) {
|
|
2150
|
+
const current = this.agent.state.model;
|
|
2151
|
+
const next = profileSettings.model;
|
|
2152
|
+
if (!current || current.provider !== next.provider || current.id !== next.id) {
|
|
2153
|
+
// Mirror the startup/cycle path: set the model directly (no auth gate, no settings
|
|
2154
|
+
// persist) so re-applying the profile model behaves like initial resolution rather
|
|
2155
|
+
// than a runtime model switch. No model_select emit here — reload rebuilds the
|
|
2156
|
+
// extension runtime and emits session_start("reload") right after, and the UI
|
|
2157
|
+
// re-renders from session.model.
|
|
2158
|
+
this.agent.state.model = next;
|
|
2159
|
+
this.sessionManager.appendModelChange(next.provider, next.id);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
if (!this._isExplicitThinking && profileSettings.thinkingLevel) {
|
|
2163
|
+
this.setThinkingLevel(profileSettings.thinkingLevel);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2126
2166
|
_refreshToolRegistry(options) {
|
|
2127
2167
|
const previousRegistryNames = new Set(this._toolRegistry.keys());
|
|
2128
2168
|
const previousActiveToolNames = this.getActiveToolNames();
|
|
@@ -2324,6 +2364,10 @@ export class AgentSession {
|
|
|
2324
2364
|
// active profile's tools allow/block — or switching the active profile — would not
|
|
2325
2365
|
// apply on /reload and allowed tools would stay missing.
|
|
2326
2366
|
this._toolProfileFilter = this._deriveToolProfileFilter();
|
|
2367
|
+
// Re-apply the active profile's model/thinking from the freshly reloaded settings, so a live
|
|
2368
|
+
// profile edit (or switch) takes effect on /reload. Skipped when the launch used an explicit
|
|
2369
|
+
// --model/--thinking flag, which must win over the profile across reloads.
|
|
2370
|
+
await this._reapplyActiveProfileModelSettings();
|
|
2327
2371
|
await this._resourceLoader.reload({ failOnExtensionErrors: true, deferExtensionDispose: true });
|
|
2328
2372
|
resetApiProviders();
|
|
2329
2373
|
this._buildRuntime({
|