oira666_pi-limits-wait 0.6.8 → 0.6.10
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 +3 -3
- package/src/header-dispatch.ts +13 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oira666_pi-limits-wait",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Extension for PI that allows to automatically wait for limits to reset and retry the request",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@earendil-works/pi-ai": "1.4.0",
|
|
52
52
|
"@earendil-works/pi-coding-agent": "1.4.0",
|
|
53
|
-
"tsx": "^4.
|
|
54
|
-
"typescript": "^
|
|
53
|
+
"tsx": "^4.23.15",
|
|
54
|
+
"typescript": "^7.0.2"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/src/header-dispatch.ts
CHANGED
|
@@ -21,7 +21,13 @@ export function installHeaderDispatch(): void {
|
|
|
21
21
|
const runners = new WeakMap<ModelRegistry, ExtensionRunner>();
|
|
22
22
|
const wrapper = function (this: ExtensionRunner) {
|
|
23
23
|
const context = previous.call(this);
|
|
24
|
-
|
|
24
|
+
// modelRegistry is a getter that throws once the runner is stale (after
|
|
25
|
+
// reload / session replacement). Never let that crash pi.
|
|
26
|
+
try {
|
|
27
|
+
runners.set(context.modelRegistry, this);
|
|
28
|
+
} catch {
|
|
29
|
+
// stale runner: skip registration
|
|
30
|
+
}
|
|
25
31
|
return context;
|
|
26
32
|
};
|
|
27
33
|
Object.defineProperty(prototype, SLOT, { configurable: true, value: { runners, wrapper } });
|
|
@@ -29,7 +35,12 @@ export function installHeaderDispatch(): void {
|
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export function fallbackHeaderTransform(): ModelsSimpleStreamOptions["transformHeaders"] {
|
|
32
|
-
|
|
38
|
+
let registry: ModelRegistry | undefined;
|
|
39
|
+
try {
|
|
40
|
+
registry = state.sharedCtx?.modelRegistry;
|
|
41
|
+
} catch {
|
|
42
|
+
return undefined; // stale ctx after reload / session replacement
|
|
43
|
+
}
|
|
33
44
|
const runner = registry && (ExtensionRunner.prototype as RunnerPrototype)[SLOT]?.runners.get(registry);
|
|
34
45
|
return runner ? (headers) => runner.emitBeforeProviderHeaders(headers) : undefined;
|
|
35
46
|
}
|