@juicesharp/rpiv-advisor 2.14.0 → 2.14.2
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/advisor/execute.ts +13 -2
- package/advisor/register.ts +8 -1
- package/package.json +2 -2
package/advisor/execute.ts
CHANGED
|
@@ -35,6 +35,16 @@ import { getRuntimeCompleteSimple, loadCompleteSimple } from "./pi-compat.ts";
|
|
|
35
35
|
import { ADVISOR_SYSTEM_PROMPT } from "./prompt.ts";
|
|
36
36
|
import { getAdvisorEffort, getAdvisorModel } from "./state.ts";
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The session id the advisor sends with every call. Providers derive the prompt
|
|
40
|
+
* cache key, session-affinity headers and OpenCode's required session header
|
|
41
|
+
* from it. It is stable per Pi session so consecutive consultations hit the
|
|
42
|
+
* cache, and distinct from the executor's id so the advisor never shares the
|
|
43
|
+
* executor's cache key or Codex websocket. Provider resources held under it are
|
|
44
|
+
* released on `session_shutdown` (see register.ts).
|
|
45
|
+
*/
|
|
46
|
+
export const advisorSessionId = (ctx: ExtensionContext): string => `advisor-${ctx.sessionManager.getSessionId()}`;
|
|
47
|
+
|
|
38
48
|
interface AdvisorDetails {
|
|
39
49
|
advisorModel?: string;
|
|
40
50
|
effort?: ThinkingLevel;
|
|
@@ -143,9 +153,10 @@ export async function executeAdvisor(
|
|
|
143
153
|
// to this path: explicit overrides would bypass that resolution and
|
|
144
154
|
// reintroduce the endpoint mismatch.
|
|
145
155
|
const completeSimple = runtimeCompleteSimple ?? (await loadCompleteSimple());
|
|
156
|
+
const sessionId = advisorSessionId(ctx);
|
|
146
157
|
const requestOptions = runtimeCompleteSimple
|
|
147
|
-
? { signal, reasoning: effort }
|
|
148
|
-
: { apiKey: auth.apiKey, headers: auth.headers, signal, reasoning: effort };
|
|
158
|
+
? { signal, reasoning: effort, sessionId }
|
|
159
|
+
: { apiKey: auth.apiKey, headers: auth.headers, signal, reasoning: effort, sessionId };
|
|
149
160
|
|
|
150
161
|
// Single dispatch point — both attempts reuse the SAME `messages` and
|
|
151
162
|
// `requestOptions`, so the retry cannot diverge from attempt 1. `tools: []`
|
package/advisor/register.ts
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* to executeAdvisor. The guidance overrides are read from persisted config.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { cleanupSessionResources } from "@earendil-works/pi-ai";
|
|
7
8
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
8
9
|
import { validateGuidanceFields } from "@juicesharp/rpiv-config";
|
|
9
10
|
import { Type } from "typebox";
|
|
10
11
|
import { loadAdvisorConfig } from "./config.ts";
|
|
11
|
-
import { executeAdvisor } from "./execute.ts";
|
|
12
|
+
import { advisorSessionId, executeAdvisor } from "./execute.ts";
|
|
12
13
|
import { ADVISOR_TOOL_NAME, TOOL_LABEL } from "./messages.ts";
|
|
13
14
|
|
|
14
15
|
const AdvisorParams = Type.Object({});
|
|
@@ -48,4 +49,10 @@ export function registerAdvisorTool(pi: ExtensionAPI): void {
|
|
|
48
49
|
return executeAdvisor(ctx, pi, signal, onUpdate);
|
|
49
50
|
},
|
|
50
51
|
});
|
|
52
|
+
// Pi releases provider resources (e.g. pooled Codex websockets) only for the
|
|
53
|
+
// executor's session id; without this, a cached advisor socket keeps a
|
|
54
|
+
// headless `pi -p` process alive until its idle timer fires.
|
|
55
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
56
|
+
cleanupSessionResources(advisorSessionId(ctx));
|
|
57
|
+
});
|
|
51
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-advisor",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.2",
|
|
4
4
|
"description": "Pi extension. A second opinion the model can request from a stronger reviewer model before it acts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@juicesharp/rpiv-config": "^2.14.
|
|
50
|
+
"@juicesharp/rpiv-config": "^2.14.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@earendil-works/pi-ai": "*",
|