@madgagarin/pi-agentrouter 1.0.4 → 1.1.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.
Files changed (2) hide show
  1. package/index.ts +22 -0
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -110,8 +110,30 @@ export default function (pi: ExtensionAPI) {
110
110
 
111
111
  registerAgentRouterProviders(currentApiKey);
112
112
 
113
+ function updatePromptRewriteEnvForModel(model?: any): void {
114
+ if (isAgentRouter(model?.provider, model?.baseUrl)) {
115
+ process.env.PI_CACHE_OPTIMIZER_NO_PROMPT_REWRITE = "1";
116
+ } else {
117
+ delete process.env.PI_CACHE_OPTIMIZER_NO_PROMPT_REWRITE;
118
+ }
119
+ }
120
+
121
+ pi.on("session_start", async (_event, ctx) => {
122
+ updatePromptRewriteEnvForModel(ctx.model);
123
+ lastRequestTime = Date.now();
124
+ });
125
+
126
+ pi.on("model_select", async (event) => {
127
+ updatePromptRewriteEnvForModel(event.model);
128
+ });
129
+
130
+ pi.on("before_agent_start", async (_event, ctx) => {
131
+ updatePromptRewriteEnvForModel(ctx.model);
132
+ });
133
+
113
134
  pi.on("turn_start", async (_event, ctx) => {
114
135
  const model = ctx.model;
136
+ updatePromptRewriteEnvForModel(model);
115
137
  if (!isAgentRouter(model?.provider, (model as any)?.baseUrl)) {
116
138
  return;
117
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madgagarin/pi-agentrouter",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Pi coding agent extension for AgentRouter (GPT-5.6 Sol & Claude Opus 5) with rate-limit pacing and caching.",
5
5
  "publishConfig": {
6
6
  "access": "public"