pi-advisor-flow 0.14.5-dev.3 → 0.14.5-dev.4

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 CHANGED
@@ -14,6 +14,10 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
14
14
 
15
15
  - Updated development dependencies: Pi packages (`pi-ai`, `pi-coding-agent`, and `pi-tui`) to 1.5.2, Oxlint and plugins to 1.93.0, Knip to 6.45.1, TypeBox to 1.4.6, and Ultracite to 8.2.0. Existing peer dependency ranges remain unchanged.
16
16
 
17
+ ### Fixed
18
+
19
+ - Advisor and fallback Advisor requests now forward the active Pi session id, so providers that require a session header (such as OpenCode Go's `x-opencode-session`) no longer fail with HTTP 400 `MissingSessionID`.
20
+
17
21
  ## 0.14.4 - 2026-11-03
18
22
 
19
23
  ### Added
package/dist/index.js CHANGED
@@ -2169,6 +2169,7 @@ var createTextEventStream = (resolved, options, streamModel) => {
2169
2169
  if (!streamModel && resolved.streamSimple) {
2170
2170
  return resolved.streamSimple(resolved.model, context, {
2171
2171
  reasoning: toSimpleReasoning(options.reasoning),
2172
+ sessionId: options.sessionId,
2172
2173
  signal: options.signal
2173
2174
  });
2174
2175
  }
@@ -2177,6 +2178,7 @@ var createTextEventStream = (resolved, options, streamModel) => {
2177
2178
  env: resolved.env,
2178
2179
  headers: resolved.headers,
2179
2180
  reasoning: options.reasoning,
2181
+ sessionId: options.sessionId,
2180
2182
  signal: options.signal
2181
2183
  };
2182
2184
  if (options.reasoning !== undefined) {
@@ -2214,6 +2216,36 @@ var collectTextStream = async (resolved, options, streamModel) => {
2214
2216
  };
2215
2217
  };
2216
2218
 
2219
+ // src/session-context.ts
2220
+ var projectBranch = (source) => {
2221
+ const resetBoundaryIndex = source.findLastIndex((entry) => Object.is(entry.type, "reset_boundary"));
2222
+ const branch = source.slice(resetBoundaryIndex + 1);
2223
+ const compactionIndex = branch.findLastIndex((entry) => entry.type === "compaction");
2224
+ if (compactionIndex === -1) {
2225
+ return branch;
2226
+ }
2227
+ const compaction = branch[compactionIndex];
2228
+ if (compaction.type !== "compaction") {
2229
+ return branch;
2230
+ }
2231
+ const firstKeptIndex = branch.findIndex((entry, index) => index < compactionIndex && entry.id === compaction.firstKeptEntryId);
2232
+ const projected = [compaction];
2233
+ if (firstKeptIndex !== -1) {
2234
+ for (let index = firstKeptIndex;index < compactionIndex; index += 1) {
2235
+ const entry = branch[index];
2236
+ if (entry.type !== "compaction" && !(entry.type === "message" && entry.message.role === "system")) {
2237
+ projected.push(entry);
2238
+ }
2239
+ }
2240
+ }
2241
+ return [...projected, ...branch.slice(compactionIndex + 1)];
2242
+ };
2243
+ var currentSessionId = (ctx) => ctx.sessionManager?.getSessionId?.();
2244
+ var sessionContextEntries = (ctx) => {
2245
+ const sessionManager = ctx.sessionManager;
2246
+ return sessionManager.buildContextEntries ? sessionManager.buildContextEntries() : projectBranch(sessionManager.getBranch());
2247
+ };
2248
+
2217
2249
  // src/tools/consult-context.ts
2218
2250
  import { randomUUID } from "node:crypto";
2219
2251
 
@@ -2596,35 +2628,6 @@ var detectImageFormat = (bytes) => {
2596
2628
  }
2597
2629
  };
2598
2630
 
2599
- // src/session-context.ts
2600
- var projectBranch = (source) => {
2601
- const resetBoundaryIndex = source.findLastIndex((entry) => Object.is(entry.type, "reset_boundary"));
2602
- const branch = source.slice(resetBoundaryIndex + 1);
2603
- const compactionIndex = branch.findLastIndex((entry) => entry.type === "compaction");
2604
- if (compactionIndex === -1) {
2605
- return branch;
2606
- }
2607
- const compaction = branch[compactionIndex];
2608
- if (compaction.type !== "compaction") {
2609
- return branch;
2610
- }
2611
- const firstKeptIndex = branch.findIndex((entry, index) => index < compactionIndex && entry.id === compaction.firstKeptEntryId);
2612
- const projected = [compaction];
2613
- if (firstKeptIndex !== -1) {
2614
- for (let index = firstKeptIndex;index < compactionIndex; index += 1) {
2615
- const entry = branch[index];
2616
- if (entry.type !== "compaction" && !(entry.type === "message" && entry.message.role === "system")) {
2617
- projected.push(entry);
2618
- }
2619
- }
2620
- }
2621
- return [...projected, ...branch.slice(compactionIndex + 1)];
2622
- };
2623
- var sessionContextEntries = (ctx) => {
2624
- const sessionManager = ctx.sessionManager;
2625
- return sessionManager.buildContextEntries ? sessionManager.buildContextEntries() : projectBranch(sessionManager.getBranch());
2626
- };
2627
-
2628
2631
  // src/images.ts
2629
2632
  var ADVISOR_IMAGE_MAX_BYTES = 4 * 1024 * 1024;
2630
2633
  var ADVISOR_IMAGES_TOTAL_MAX_BYTES = 8 * 1024 * 1024;
@@ -3787,7 +3790,7 @@ var setupAbortWatch = (parentSignal, timeoutMs) => {
3787
3790
  wasTimedOut: () => timedOut
3788
3791
  };
3789
3792
  };
3790
- var streamScoutResponse = async (dependencies, resolved, executorModel, executorEffort, manifest, parentSignal, timeoutMs, publish) => {
3793
+ var streamScoutResponse = async (dependencies, resolved, executorModel, executorEffort, sessionId, manifest, parentSignal, timeoutMs, publish) => {
3791
3794
  const { abortPromise, controller, teardown, wasTimedOut } = setupAbortWatch(parentSignal, timeoutMs);
3792
3795
  try {
3793
3796
  const collection = dependencies.collect(resolved, {
@@ -3798,6 +3801,7 @@ var streamScoutResponse = async (dependencies, resolved, executorModel, executor
3798
3801
  }
3799
3802
  },
3800
3803
  reasoning: executorEffort,
3804
+ sessionId,
3801
3805
  signal: controller.signal,
3802
3806
  systemPrompt: SCOUT_SYSTEM
3803
3807
  });
@@ -3855,7 +3859,7 @@ var runAdvisorScout = async (ctx, manifest, parentSignal, onEvent, timeoutMs = a
3855
3859
  return cancelled();
3856
3860
  }
3857
3861
  publish({ model: executorModel, type: "call" });
3858
- const streamed = await streamScoutResponse(dependencies, resolved, executorModel, executorEffort, manifest, parentSignal, timeoutMs, publish);
3862
+ const streamed = await streamScoutResponse(dependencies, resolved, executorModel, executorEffort, currentSessionId(ctx), manifest, parentSignal, timeoutMs, publish);
3859
3863
  if (!streamed.ok) {
3860
3864
  if (parentSignal?.aborted) {
3861
3865
  return cancelled();
@@ -4337,6 +4341,7 @@ var runAdvisorAttempt = async (options, prepared, resolved, modelRef) => {
4337
4341
  messages: structuredClone(prepared.messages),
4338
4342
  onChunk: options.onChunk,
4339
4343
  reasoning: advisorEffortRef,
4344
+ sessionId: currentSessionId(options.ctx),
4340
4345
  signal: options.signal,
4341
4346
  systemPrompt: prepared.systemPrompt
4342
4347
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-advisor-flow",
3
- "version": "0.14.5-dev.3",
3
+ "version": "0.14.5-dev.4",
4
4
  "description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
5
5
  "keywords": [
6
6
  "advisor",
@@ -75,6 +75,7 @@ export interface CollectTextStreamOptions {
75
75
  messages: Message[];
76
76
  onChunk?: (thinking: string, text: string) => void;
77
77
  reasoning?: string;
78
+ sessionId?: string;
78
79
  signal?: AbortSignal;
79
80
  systemPrompt: string;
80
81
  }
@@ -250,6 +251,7 @@ const createTextEventStream = (
250
251
  if (!streamModel && resolved.streamSimple) {
251
252
  return resolved.streamSimple(resolved.model, context, {
252
253
  reasoning: toSimpleReasoning(options.reasoning),
254
+ sessionId: options.sessionId,
253
255
  signal: options.signal,
254
256
  });
255
257
  }
@@ -259,6 +261,7 @@ const createTextEventStream = (
259
261
  env: resolved.env,
260
262
  headers: resolved.headers,
261
263
  reasoning: options.reasoning,
264
+ sessionId: options.sessionId,
262
265
  signal: options.signal,
263
266
  };
264
267
 
package/src/scout.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  SCOUT_SYNTHESIS_MAX_BYTES,
20
20
  } from "./scout-types.ts";
21
21
  import type { ScoutManifest } from "./scout-types.ts";
22
+ import { currentSessionId } from "./session-context.ts";
22
23
  import { snapshotAdvisorUsage } from "./usage.ts";
23
24
  import type { AdvisorUsageSnapshot } from "./usage.ts";
24
25
 
@@ -281,6 +282,7 @@ const streamScoutResponse = async (
281
282
  resolved: ResolvedConfiguredModel,
282
283
  executorModel: string,
283
284
  executorEffort: string | undefined,
285
+ sessionId: string | undefined,
284
286
  manifest: ScoutManifest,
285
287
  parentSignal: AbortSignal | undefined,
286
288
  timeoutMs: number,
@@ -300,6 +302,7 @@ const streamScoutResponse = async (
300
302
  }
301
303
  },
302
304
  reasoning: executorEffort,
305
+ sessionId,
303
306
  signal: controller.signal,
304
307
  systemPrompt: SCOUT_SYSTEM,
305
308
  });
@@ -395,6 +398,7 @@ export const runAdvisorScout = async (
395
398
  resolved,
396
399
  executorModel,
397
400
  executorEffort,
401
+ currentSessionId(ctx),
398
402
  manifest,
399
403
  parentSignal,
400
404
  timeoutMs,
@@ -51,6 +51,10 @@ const projectBranch = (source: SessionEntry[]): SessionEntry[] => {
51
51
  return [...projected, ...branch.slice(compactionIndex + 1)];
52
52
  };
53
53
 
54
+ export const currentSessionId = (ctx: {
55
+ sessionManager?: { getSessionId?: () => string };
56
+ }): string | undefined => ctx.sessionManager?.getSessionId?.();
57
+
54
58
  export const sessionContextEntries = (
55
59
  ctx: ExtensionContext
56
60
  ): SessionEntry[] => {
@@ -17,6 +17,7 @@ import type { GitContextLevel } from "../git.ts";
17
17
  import { collectTextStream, resolveConfiguredModel } from "../model-stream.ts";
18
18
  import { redactSecrets } from "../redaction.ts";
19
19
  import type { ScoutLifecycleEvent } from "../scout.ts";
20
+ import { currentSessionId } from "../session-context.ts";
20
21
  import type { ConsultationTrigger, GateTrigger } from "../session-state.ts";
21
22
  import { assembleConsultationContext } from "./consult-context.ts";
22
23
  import type { ConsultationContext } from "./consult-context.ts";
@@ -282,6 +283,7 @@ const runAdvisorAttempt = async (
282
283
  messages: structuredClone(prepared.messages),
283
284
  onChunk: options.onChunk,
284
285
  reasoning: advisorEffortRef,
286
+ sessionId: currentSessionId(options.ctx),
285
287
  signal: options.signal,
286
288
  systemPrompt: prepared.systemPrompt,
287
289
  });