@bacnh85/pi-subagent 0.9.1 → 0.9.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.2 (2026-07-16)
4
+
5
+ ### Pi SDK compatibility
6
+
7
+ - Removed use of the deleted `AuthStorage.inMemory()` API so delegated planner and other subagents start on Pi 0.80.10.
8
+
3
9
  ## 0.9.1 (2026-07-16)
4
10
 
5
11
  ### Activity-aware timeouts
@@ -14,17 +14,14 @@
14
14
  */
15
15
 
16
16
  import * as path from "node:path";
17
- import type { Model } from "@earendil-works/pi-ai";
18
17
  import { StringEnum } from "@earendil-works/pi-ai";
19
18
  import {
20
- AuthStorage,
21
19
  CONFIG_DIR_NAME,
22
20
  DynamicBorder,
23
21
  type ExtensionAPI,
24
22
  type ExtensionContext,
25
23
  getAgentDir,
26
24
  getMarkdownTheme,
27
- ModelRegistry,
28
25
  type ThemeColor,
29
26
  } from "@earendil-works/pi-coding-agent";
30
27
  import { Container, Markdown, SelectList, Spacer, Text } from "@earendil-works/pi-tui";
@@ -463,20 +460,9 @@ export default function (pi: ExtensionAPI) {
463
460
  }
464
461
  }
465
462
 
466
- // Shared auth/model setup for SDK sessions
467
- // ponytail: reuse parent modelRegistry instead of a fresh copy — avoids
468
- // internal API casts (storeModelHeaders) and preserves env/headers/OAuth.
469
- const authStorage = AuthStorage.inMemory();
470
463
  const modelRegistry = ctx.modelRegistry;
471
-
472
- // Helper: inject parent's API key into child auth storage
473
- async function injectApiKey(model: Model<any>): Promise<void> {
474
- const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
475
- if (auth.ok) {
476
- if (auth.apiKey) authStorage.setRuntimeApiKey(model.provider, auth.apiKey);
477
- // ponytail: headers/env stay on the parent registry — no copy needed.
478
- }
479
- }
464
+ const modelRuntime = (modelRegistry as any).runtime;
465
+ const authStorage = (modelRegistry as any).authStorage;
480
466
 
481
467
  // Helper: resolve a safe child working directory.
482
468
  function resolveChildCwd(childCwd: string | undefined): string {
@@ -566,8 +552,6 @@ export default function (pi: ExtensionAPI) {
566
552
  let effectiveTimeoutMs: number | undefined;
567
553
  let safeCwd: string;
568
554
  try {
569
- // Inject parent's API key so --api-key and other runtime overrides work
570
- await injectApiKey(resolved.model);
571
555
  tools = resolveChildTools(agent.tools, agent.sandbox, isReadOnly);
572
556
  effectiveTimeoutMs = resolveChildTimeout(timeoutMs, params.timeout);
573
557
  safeCwd = resolveChildCwd(cwd);
@@ -599,6 +583,7 @@ export default function (pi: ExtensionAPI) {
599
583
  task,
600
584
  tools,
601
585
  model: resolved.model,
586
+ modelRuntime,
602
587
  authStorage,
603
588
  modelRegistry,
604
589
  signal: parentSignal,
@@ -17,10 +17,8 @@
17
17
  import type { Message, Model } from "@earendil-works/pi-ai";
18
18
  import type { AgentMessage } from "@earendil-works/pi-agent-core";
19
19
  import {
20
- AuthStorage,
21
20
  createAgentSession,
22
21
  createExtensionRuntime,
23
- ModelRegistry,
24
22
  type ResourceLoader,
25
23
  SessionManager,
26
24
  SettingsManager,
@@ -87,8 +85,11 @@ export async function runSubAgent(options: {
87
85
  task: string;
88
86
  tools: string[];
89
87
  model: Model<any>;
90
- authStorage: AuthStorage;
91
- modelRegistry: ModelRegistry;
88
+ /** Pi 0.80.10's canonical credential/model runtime. */
89
+ modelRuntime?: unknown;
90
+ /** Legacy Pi SDK session options retained for 0.80.6 tests and hosts. */
91
+ authStorage?: unknown;
92
+ modelRegistry?: unknown;
92
93
  signal?: AbortSignal;
93
94
  agentName?: string;
94
95
  thinkingLevel?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
@@ -98,7 +99,7 @@ export async function runSubAgent(options: {
98
99
  hardTimeoutMs?: number;
99
100
  }): Promise<SubAgentResult> {
100
101
  const {
101
- cwd, systemPrompt, task, tools, model, authStorage, modelRegistry, signal,
102
+ cwd, systemPrompt, task, tools, model, modelRuntime, authStorage, modelRegistry, signal,
102
103
  agentName = "subagent", thinkingLevel = "off", onMessage, onProgress,
103
104
  timeoutMs = DEFAULT_INACTIVITY_TIMEOUT_MS, hardTimeoutMs = HARD_TIMEOUT_MS,
104
105
  } = options;
@@ -142,7 +143,12 @@ export async function runSubAgent(options: {
142
143
  result.status = classifyStopReason(result.stopReason, !timedOut, timedOut);
143
144
  return result;
144
145
  }
145
- const { session } = await createAgentSession({ cwd, model, thinkingLevel, authStorage, modelRegistry, resourceLoader, tools, sessionManager: SessionManager.inMemory(cwd), settingsManager });
146
+ const { session } = await createAgentSession({
147
+ cwd, model, thinkingLevel, resourceLoader, tools, sessionManager: SessionManager.inMemory(cwd), settingsManager,
148
+ ...(modelRuntime ? { modelRuntime } : {}),
149
+ // Pi 0.80.10 owns credentials in ModelRuntime; older SDKs still accept these.
150
+ ...(authStorage ? { authStorage, modelRegistry } : {}),
151
+ } as any);
146
152
  let unsubscribe: (() => void) | undefined;
147
153
  let removeAbort: (() => void) | undefined;
148
154
  try {
@@ -1,4 +1,4 @@
1
- import { AuthStorage, type ExtensionContext } from "@earendil-works/pi-coding-agent";
1
+ import { type ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { type AgentConfig, getModelCandidates } from "./agents.ts";
3
3
  import { runSubAgent, type SubAgentProgress, type SubAgentResult } from "./runner.ts";
4
4
  import { resolveModel } from "./model.ts";
@@ -44,13 +44,9 @@ export async function runNamedAgent(options: {
44
44
  const { model, attempted } = await resolveModel(getModelCandidates(options.agent), options.ctx.model, options.ctx.modelRegistry);
45
45
  if (!model) throw new Error(`No model resolved for agent "${options.agent.name}" (tried: ${attempted.join(", ") || "none"})`);
46
46
 
47
- const authStorage = AuthStorage.inMemory();
48
47
  const modelRegistry = options.ctx.modelRegistry;
49
- const auth = await options.ctx.modelRegistry.getApiKeyAndHeaders(model);
50
- if (auth.ok) {
51
- if (auth.apiKey) authStorage.setRuntimeApiKey(model.provider, auth.apiKey);
52
- // ponytail: env and headers stay on the parent modelRegistry — reuse it directly.
53
- }
48
+ const modelRuntime = (modelRegistry as any).runtime;
49
+ const authStorage = (modelRegistry as any).authStorage;
54
50
 
55
51
  // Security: validate and normalise timeout.
56
52
  const effectiveTimeoutMs = normalizeTimeout({ requested: options.timeout }).timeoutMs;
@@ -83,6 +79,7 @@ export async function runNamedAgent(options: {
83
79
  task: options.task,
84
80
  tools: toolValidation.tools,
85
81
  model,
82
+ modelRuntime,
86
83
  authStorage,
87
84
  modelRegistry,
88
85
  signal: options.signal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacnh85/pi-subagent",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "In-process subagents for Pi with isolated SDK sessions, parallel and chained delegation, and inspectable threads.",
5
5
  "type": "module",
6
6
  "license": "MIT",