pi-openai-toolkit 0.14.6 → 0.14.7
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/package.json
CHANGED
|
@@ -170,12 +170,9 @@ export class ContextManagementToolController {
|
|
|
170
170
|
parameters: unknown;
|
|
171
171
|
promptGuidelines?: string[];
|
|
172
172
|
}>();
|
|
173
|
-
private readonly ownedNames = new Set<string>();
|
|
174
|
-
private readonly baselineNames = new Set<string>();
|
|
175
173
|
private registered = false;
|
|
176
174
|
private registrationChecked = false;
|
|
177
175
|
private registrationValid = false;
|
|
178
|
-
private baselineCaptured = false;
|
|
179
176
|
|
|
180
177
|
constructor(private readonly pi: ExtensionAPI) {}
|
|
181
178
|
|
|
@@ -233,44 +230,22 @@ export class ContextManagementToolController {
|
|
|
233
230
|
} catch {
|
|
234
231
|
this.registrationValid = false;
|
|
235
232
|
}
|
|
236
|
-
if (!this.registrationValid) this.ownedNames.clear();
|
|
237
233
|
return this.registrationValid;
|
|
238
234
|
}
|
|
239
235
|
|
|
240
|
-
private captureBaseline(): boolean {
|
|
241
|
-
if (this.baselineCaptured) return true;
|
|
242
|
-
try {
|
|
243
|
-
const api = this.pi as ExtensionAPI & { getActiveTools?: () => string[] };
|
|
244
|
-
if (typeof api.getActiveTools !== "function") return false;
|
|
245
|
-
this.baselineNames.clear();
|
|
246
|
-
for (const name of api.getActiveTools()) this.baselineNames.add(name);
|
|
247
|
-
this.baselineCaptured = true;
|
|
248
|
-
return true;
|
|
249
|
-
} catch {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
236
|
sync(active: boolean): boolean {
|
|
255
|
-
if (!this.verifyRegistration()
|
|
237
|
+
if (!this.verifyRegistration()) return false;
|
|
256
238
|
const api = this.pi as ExtensionAPI & { getActiveTools?: () => string[]; setActiveTools?: (names: string[]) => void };
|
|
257
239
|
if (typeof api.getActiveTools !== "function" || typeof api.setActiveTools !== "function") return false;
|
|
258
240
|
try {
|
|
259
241
|
const current = api.getActiveTools();
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (next.length !== current.length) api.setActiveTools(next);
|
|
269
|
-
return true;
|
|
270
|
-
}
|
|
271
|
-
const next = current.filter((name) => !this.ownedNames.has(name));
|
|
242
|
+
// Pi may activate a newly registered tool before the first sync. Once
|
|
243
|
+
// registration is verified, every registered name belongs to this
|
|
244
|
+
// controller: active models get all four, inactive models get none.
|
|
245
|
+
const next = active
|
|
246
|
+
? [...current, ...[...this.registeredNames].filter((name) => !current.includes(name))]
|
|
247
|
+
: current.filter((name) => !this.registeredNames.has(name));
|
|
272
248
|
if (next.length !== current.length) api.setActiveTools(next);
|
|
273
|
-
this.ownedNames.clear();
|
|
274
249
|
return true;
|
|
275
250
|
} catch {
|
|
276
251
|
return false;
|
|
@@ -279,8 +254,6 @@ export class ContextManagementToolController {
|
|
|
279
254
|
|
|
280
255
|
reset(): void {
|
|
281
256
|
this.sync(false);
|
|
282
|
-
this.baselineNames.clear();
|
|
283
|
-
this.baselineCaptured = false;
|
|
284
257
|
}
|
|
285
258
|
get isRegistered(): boolean { return this.registrationValid; }
|
|
286
259
|
}
|