@gotgenes/pi-subagents 10.2.1 → 11.0.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.
@@ -6,8 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { Agent } from "#src/lifecycle/agent";
9
- import type { CompactionInfo } from "#src/lifecycle/agent-manager";
10
- import type { SubscribableSession } from "#src/types";
9
+ import type { CompactionInfo, SubscribableSession } from "#src/types";
11
10
 
12
11
  export interface AgentObserverOptions {
13
12
  onCompact?: (record: Agent, info: CompactionInfo) => void;
@@ -4,14 +4,14 @@ import { defineTool } from "@earendil-works/pi-coding-agent";
4
4
  import { Text } from "@earendil-works/pi-tui";
5
5
  import { Type } from "@sinclair/typebox";
6
6
  import { AgentTypeRegistry } from "#src/config/agent-types";
7
- import type { AgentSpawnConfig, ParentSessionInfo } from "#src/lifecycle/agent-manager";
7
+ import type { AgentSpawnConfig } from "#src/lifecycle/agent-manager";
8
8
  import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
9
9
  import { spawnBackground } from "#src/tools/background-spawner";
10
10
  import { runForeground } from "#src/tools/foreground-runner";
11
11
  import { buildDetails, buildTypeListText, textResult } from "#src/tools/helpers";
12
12
  import { renderAgentResult } from "#src/tools/result-renderer";
13
13
  import { type ModelInfo, resolveSpawnConfig } from "#src/tools/spawn-config";
14
- import type { Agent } from "#src/types";
14
+ import type { Agent, ParentSessionInfo } from "#src/types";
15
15
  import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
16
16
  import { type UICtx } from "#src/ui/agent-widget";
17
17
  import { type AgentDetails, getDisplayName } from "#src/ui/display";
@@ -1,9 +1,9 @@
1
- import type { AgentSpawnConfig, ParentSessionInfo } from "#src/lifecycle/agent-manager";
1
+ import type { AgentSpawnConfig } from "#src/lifecycle/agent-manager";
2
2
  import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
3
3
  import type { AgentActivityAccess } from "#src/tools/agent-tool";
4
4
  import { textResult } from "#src/tools/helpers";
5
5
  import type { ResolvedSpawnConfig } from "#src/tools/spawn-config";
6
- import type { Agent } from "#src/types";
6
+ import type { Agent, ParentSessionInfo } from "#src/types";
7
7
  import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
8
8
  import { subscribeUIObserver } from "#src/ui/ui-observer";
9
9
 
@@ -54,9 +54,11 @@ export function spawnBackground(
54
54
  isBackground: true,
55
55
  isolation: execution.isolation,
56
56
  invocation: execution.agentInvocation,
57
- onSessionCreated: (session) => {
58
- bgState.setSession(session);
59
- subscribeUIObserver(session, bgState);
57
+ observer: {
58
+ onSessionCreated: (_agent, session) => {
59
+ bgState.setSession(session);
60
+ subscribeUIObserver(session, bgState);
61
+ },
60
62
  },
61
63
  });
62
64
  } catch (err) {
@@ -1,5 +1,5 @@
1
1
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
2
- import type { AgentSpawnConfig, ParentSessionInfo } from "#src/lifecycle/agent-manager";
2
+ import type { AgentSpawnConfig } from "#src/lifecycle/agent-manager";
3
3
  import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
4
4
  import type { AgentActivityAccess } from "#src/tools/agent-tool";
5
5
  import {
@@ -9,7 +9,7 @@ import {
9
9
  textResult,
10
10
  } from "#src/tools/helpers";
11
11
  import type { ResolvedSpawnConfig } from "#src/tools/spawn-config";
12
- import type { Agent } from "#src/types";
12
+ import type { Agent, ParentSessionInfo } from "#src/types";
13
13
  import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
14
14
  import {
15
15
  type AgentDetails,
@@ -109,13 +109,15 @@ export async function runForeground(
109
109
  invocation: execution.agentInvocation,
110
110
  signal,
111
111
  parentSession: params.parentSession,
112
- onSessionCreated: (session, record) => {
113
- fgState.setSession(session);
114
- recordRef = record;
115
- unsubUI = subscribeUIObserver(session, fgState, streamUpdate);
116
- fgId = record.id;
117
- agentActivity.set(record.id, fgState);
118
- widget.ensureTimer();
112
+ observer: {
113
+ onSessionCreated: (agent, session) => {
114
+ fgState.setSession(session);
115
+ recordRef = agent;
116
+ unsubUI = subscribeUIObserver(session, fgState, streamUpdate);
117
+ fgId = agent.id;
118
+ agentActivity.set(agent.id, fgState);
119
+ widget.ensureTimer();
120
+ },
119
121
  },
120
122
  },
121
123
  );
package/src/types.ts CHANGED
@@ -105,3 +105,16 @@ export type ShellExec = (
105
105
  args: string[],
106
106
  options?: { cwd?: string; timeout?: number },
107
107
  ) => Promise<{ stdout: string; stderr: string; code: number }>;
108
+
109
+ /** Parent session identity — grouped fields that travel together from the tool boundary. */
110
+ export interface ParentSessionInfo {
111
+ /** Path to the parent session's JSONL file (for deriving the subagent session directory). */
112
+ parentSessionFile?: string;
113
+ /** Session ID of the parent agent (stored in the child session's parentSession header). */
114
+ parentSessionId?: string;
115
+ /** Tool call ID for background notification wiring. When set, spawn attaches NotificationState. */
116
+ toolCallId?: string;
117
+ }
118
+
119
+ /** Compaction event info passed through lifecycle observers. */
120
+ export type CompactionInfo = { reason: "manual" | "threshold" | "overflow"; tokensBefore: number };