pi-subagent-manager 0.1.1 → 0.3.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.
package/src/tools.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Type } from "typebox";
2
2
  import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
3
+ import { getModelPreferences } from "./models.ts";
3
4
  import type { ThreadManager } from "./manager.ts";
4
5
  import type { AgentType, ThreadView } from "./types.ts";
5
6
 
@@ -39,23 +40,34 @@ export function agentTools(
39
40
  return [
40
41
  make(
41
42
  "agent_types",
42
- "List current agent types and their task descriptions. Reflects configuration reloads; call this before choosing a type.",
43
+ "List current agent types and their task descriptions. Reflects configuration reloads; call this before choosing a type. modelSuggestions are advisory display names, not model pins.",
43
44
  Type.Object({}),
44
45
  () =>
45
46
  result(
46
- getTypes().map(({ name, description, model, thinkingLevel, color }) => ({
47
- name,
48
- description,
49
- model,
50
- thinkingLevel,
51
- color,
52
- })),
47
+ getTypes().map(
48
+ ({ name, description, thinkingLevel, color, modelSuggestions, ...type }) => ({
49
+ name,
50
+ description,
51
+ models: getModelPreferences(type),
52
+ modelSuggestions: modelSuggestions === undefined ? undefined : [...modelSuggestions],
53
+ thinkingLevel,
54
+ color,
55
+ }),
56
+ ),
53
57
  ),
54
58
  ),
55
59
  make(
56
60
  "agent_spawn",
57
- "Spawn a named child. The lexical parent, NOT the caller, supplies a context snapshot. /root is the main thread; independent roots have no inherited context. Foreground waits by default; wait:false runs detached. Existing paths are retained and can be resumed with agent_steer. Use agent_types to discover current types.",
58
- Type.Object({ path, type: text, task: text, wait: Type.Optional(Type.Boolean()) }),
61
+ "Spawn a named child. The lexical parent, NOT the caller, supplies a context snapshot. /root is the main thread; independent roots have no inherited context. Foreground waits by default; wait:false runs detached. For parallel work, spawn every independent sibling with wait:false before calling agent_wait; child agents with delegation tools should do the same. Existing paths are retained and can be resumed with agent_steer. Use agent_types to discover current types.",
62
+ Type.Object({
63
+ path: Type.String({
64
+ description:
65
+ "Task-based kebab-case path, not the agent type (e.g. /root/controller-security-research), or a task name relative to the caller",
66
+ }),
67
+ type: text,
68
+ task: text,
69
+ wait: Type.Optional(Type.Boolean()),
70
+ }),
59
71
  async (params, signal) => result(compact(await threads().spawn(params, signal))),
60
72
  ),
61
73
  make(
@@ -108,7 +120,7 @@ export function agentTools(
108
120
  ),
109
121
  make(
110
122
  "agent_output",
111
- "Read completed thread output in character pages. Paused threads deliberately have no final answer handback. All sessions can be viewed by the user with /agents thread PATH.",
123
+ "Read completed thread output in character pages. Paused threads deliberately have no final answer handback. All sessions can be viewed by the user with /agents tree; select a thread and press Enter to inspect it.",
112
124
  Type.Object({
113
125
  path,
114
126
  offset: Type.Optional(Type.Integer({ minimum: 0 })),
package/src/types.ts CHANGED
@@ -6,8 +6,13 @@ export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
6
6
  export interface AgentType {
7
7
  name: string;
8
8
  description: string;
9
+ models?: string[];
10
+ /** @deprecated Use ordered models instead. */
9
11
  model?: string;
12
+ /** Advisory display names. Not provider/model pins and never used for selection. */
13
+ modelSuggestions?: string[];
10
14
  thinkingLevel?: ThinkingLevel;
15
+ /** Pi semantic token for the type pill background and task path foreground. */
11
16
  color?: string;
12
17
  tools?: { allow?: string[]; block?: string[] };
13
18
  systemPrompt: string;
@@ -29,6 +34,14 @@ export interface ThreadView {
29
34
  createdAt: number;
30
35
  updatedAt: number;
31
36
  sessionFile?: string;
37
+ /** Frozen active time. Renderer adds `Date.now() - startedAt` while a run is active. */
38
+ elapsedMs?: number;
39
+ /** Current run start. Live only; omitted from saved views so reloads do not count offline time. */
40
+ startedAt?: number;
41
+ /** Cumulative input tokens, including cache read/write. Live views include the in-progress message. */
42
+ inputTokens?: number;
43
+ /** Cumulative output tokens. Live views include the in-progress message. */
44
+ outputTokens?: number;
32
45
  }
33
46
  export type DriverEvent =
34
47
  | { kind: "activity" | "error"; text: string }
@@ -37,6 +50,14 @@ export type DriverEvent =
37
50
  text: string;
38
51
  sessionFile?: string;
39
52
  sessionLeafId?: string | null;
53
+ }
54
+ | {
55
+ kind: "usage";
56
+ /** Cumulative own-assistant tokens for this driver instance, excluding inherited history. */
57
+ inputTokens: number;
58
+ outputTokens: number;
59
+ /** Streaming message_update snapshot. Omit for authoritative message_end. */
60
+ partial?: boolean;
40
61
  };
41
62
  export interface AgentDriver {
42
63
  prompt(message: string): Promise<void>;
@@ -58,6 +79,8 @@ export interface DriverOptions {
58
79
  shouldPause(): boolean;
59
80
  parentPath: string | null;
60
81
  sessionFile?: string;
82
+ /** Retained transcript of a nested lexical parent. Absent for /root and independent roots. */
83
+ parentSessionFile?: string;
61
84
  sessionLeafId?: string | null;
62
85
  signal: AbortSignal;
63
86
  }
@@ -75,6 +98,10 @@ export interface SavedThreadView {
75
98
  createdAt: number;
76
99
  sessionFile?: string;
77
100
  sessionLeafId?: string | null;
101
+ /** Frozen cumulative active time. `startedAt` is intentionally not persisted. */
102
+ elapsedMs?: number;
103
+ inputTokens?: number;
104
+ outputTokens?: number;
78
105
  }
79
106
  export interface SavedThread {
80
107
  view: SavedThreadView;
@@ -100,6 +127,7 @@ export interface ThreadService {
100
127
  export type DriverFactory = (options: DriverOptions) => Promise<AgentDriver>;
101
128
  export type ThreadEvent =
102
129
  | { kind: "change"; thread: ThreadView }
130
+ | { kind: "metrics"; thread: ThreadView }
103
131
  | { kind: "update"; thread: ThreadView; message: string; recipient: string }
104
132
  | { kind: "settled"; thread: ThreadView; recipient: string };
105
133
  export interface ManagerOptions {
@@ -108,6 +136,9 @@ export interface ManagerOptions {
108
136
  getType(name: string): AgentType;
109
137
  toolsFor(path: string): ToolDefinition[];
110
138
  onEvent?(event: ThreadEvent): void;
139
+ /** Maximum levels including the main conversation as L1; defaults to 3. */
140
+ maxLevels?: number;
141
+ /** @deprecated Internal legacy path-depth override; prefer maxLevels. */
111
142
  maxDepth?: number;
112
143
  maxThreads?: number;
113
144
  maxConcurrent?: number;