@agimon-ai/po-team 0.0.0-alpha.208 → 0.0.0-alpha.209

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/README.md CHANGED
@@ -53,7 +53,7 @@ Treat agent definitions, inherited environments and granted MCP tools as trusted
53
53
 
54
54
  Task submits pending, unblocked assignments. Team resolves the agent and policy, owns execution and cancellation, and returns the terminal result to Task. The Cordis `po/delegation`, `po/background-work` and `po/subagent-policy` connections disconnect and reconnect with their provider; they do not imply shared persistence.
55
55
 
56
- When code mode is loaded, `team.members()` returns native members and `team.runs()` returns tracked runs. These detached snapshots omit capability tokens and delegation prompts. Finished runs drop off ten minutes after acknowledgement; token counts remain available while retained. The direct `subagent` and `intercom` tools remain available.
56
+ When code mode is loaded, `team.members()` returns native members and `team.runs()` returns tracked runs. These detached snapshots omit capability tokens and delegation prompts. Finished runs drop off ten minutes after acknowledgement; token counts remain available while retained. On hosts with live objects, the `team` namespace also carries every `subagent` action (`team.agents`, `team.start`, `team.status`, `team.steer`, `team.stop`) and the team `intercom` actions (`team.send`, `team.ask`, `team.reply`, `team.pending`), so the main agent's direct `subagent` and `intercom` tools are withdrawn. Each member calls the tool's own implementation and stays main-agent-only. Hosts without live objects keep the direct tools.
57
57
 
58
58
  ## Development
59
59
 
@@ -2965,7 +2965,7 @@ var SpawnPlanner = class {
2965
2965
  }, signal);
2966
2966
  } catch (error) {
2967
2967
  intercom?.dispose?.();
2968
- throw error;
2968
+ throw error instanceof Error ? error : new Error(String(error), { cause: error });
2969
2969
  }
2970
2970
  return {
2971
2971
  agent: agentConfig.name,
@@ -3009,7 +3009,6 @@ var SpawnPlanner = class {
3009
3009
  ...team.excludeTools ?? [],
3010
3010
  "exec",
3011
3011
  "discover",
3012
- "exec_background",
3013
3012
  "exec_cancel",
3014
3013
  "subagent",
3015
3014
  "intercom"
@@ -6097,6 +6096,12 @@ interface TeamRun {
6097
6096
  currentTool?: string;
6098
6097
  toolCount?: number;
6099
6098
  }
6099
+ /** The text the direct tool would show, plus its structured details. */
6100
+ interface TeamToolResult {
6101
+ text: string;
6102
+ details?: unknown;
6103
+ }
6104
+ type AgentScope = 'user' | 'project' | 'both';
6100
6105
  declare const team: {
6101
6106
  /** Native team members in this session, not peer sessions. */
6102
6107
  members(): TeamMember[];
@@ -6108,12 +6113,45 @@ declare const team: {
6108
6113
  }>;
6109
6114
  /** Compatibility forwarder, main-agent coordinators only. Prefer sessions.start. */
6110
6115
  startSession(input: { name: string; brief: string; workspaceId?: string }): Promise<{ sessionId: string; promptError?: string }>;
6116
+ /** Agents you can start, or one agent in full. Main agent only, like every member below. */
6117
+ agents(input?: { name?: string; cwd?: string; scope?: AgentScope }): Promise<TeamToolResult>;
6118
+ /** Start persistent background runs. Each completion arrives later as a message: end the turn rather than polling. */
6119
+ start(input: {
6120
+ requests: { agent: string; task: string; inlineAgent?: { systemPrompt: string; tools?: string[] }; cwd?: string; model?: string }[];
6121
+ concurrency?: number;
6122
+ artifacts?: boolean;
6123
+ scope?: AgentScope;
6124
+ }): Promise<TeamToolResult>;
6125
+ /** The fleet, or one run with an optional transcript tail (up to 500 lines). */
6126
+ status(input?: { id?: string; transcriptLines?: number }): Promise<TeamToolResult>;
6127
+ /** Send a run its next step. A finished or timed-out run resumes on its own conversation. */
6128
+ steer(input: { id: string; message: string }): Promise<TeamToolResult>;
6129
+ stop(input: { id: string; reason?: string }): Promise<TeamToolResult>;
6130
+ /** Push a result, blocker or decision to a team member. Message sessions through network instead. */
6131
+ send(input: { to: string; message: string }): Promise<TeamToolResult>;
6132
+ /** Ask a team member. The reply arrives later as a message. */
6133
+ ask(input: { to: string; message: string }): Promise<TeamToolResult>;
6134
+ reply(input: { requestId: string; message: string }): Promise<TeamToolResult>;
6135
+ /** Questions waiting for your reply. */
6136
+ pending(): Promise<TeamToolResult>;
6111
6137
  };`;
6112
- /** Session-owned state and awaited inline runs. Direct tools retain discovery and management. */
6138
+ /** Each member forwards to one action of the session's `subagent` or `intercom` tool. */
6139
+ const TOOL_MEMBERS = {
6140
+ agents: ["subagent", "agents"],
6141
+ start: ["subagent", "run"],
6142
+ status: ["subagent", "status"],
6143
+ steer: ["subagent", "steer"],
6144
+ stop: ["subagent", "stop"],
6145
+ send: ["intercom", "send"],
6146
+ ask: ["intercom", "ask"],
6147
+ reply: ["intercom", "reply"],
6148
+ pending: ["intercom", "pending"]
6149
+ };
6150
+ /** Session-owned team state, awaited inline runs, and the `subagent` and `intercom` actions for code mode. */
6113
6151
  function createTeamNamespace(options) {
6114
6152
  return {
6115
6153
  name: "team",
6116
- summary: "Read native team members and runs or await an inline agent with team.run(). Session coordination uses sessions.",
6154
+ summary: "Start, inspect, steer and stop subagents, message team members, or await an inline agent with team.run(). Session coordination uses sessions.",
6117
6155
  declarations: DECLARATIONS,
6118
6156
  sync: ["members", "runs"],
6119
6157
  bind(run) {
@@ -6187,6 +6225,23 @@ function createTeamNamespace(options) {
6187
6225
  if (!options.startSession) throw new Error("Starting sessions is unavailable on this host.");
6188
6226
  return JSON.parse(JSON.stringify(await options.startSession(input, signal)));
6189
6227
  };
6228
+ let calls = 0;
6229
+ for (const [member, [tool, action]] of Object.entries(TOOL_MEMBERS)) members[member] = async (input = {}) => {
6230
+ if (run.caller !== "main") throw new Error(`team.${member} is for the main agent only.`);
6231
+ check();
6232
+ if (!options.callTool) throw new Error(`team.${member} is unavailable on this host.`);
6233
+ if (typeof input !== "object" || input === null || Array.isArray(input)) throw new Error(`team.${member} takes one object argument.`);
6234
+ const result = await options.callTool(tool, {
6235
+ ...input,
6236
+ action
6237
+ }, `${run.toolCallId}:team:${++calls}`, signal);
6238
+ const text = result.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
6239
+ if (result.isError) throw new Error(text || `team.${member} failed.`);
6240
+ return JSON.parse(JSON.stringify(result.details === void 0 ? { text } : {
6241
+ text,
6242
+ details: result.details
6243
+ }));
6244
+ };
6190
6245
  return members;
6191
6246
  }
6192
6247
  };
@@ -7238,6 +7293,7 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
7238
7293
  metadataFor: (id) => sessionGroupBridge?.metadataFor(execution.sessionId, id),
7239
7294
  delivery: () => (0, _agimon_ai_po_session.readPoSessionDelivery)(context)
7240
7295
  });
7296
+ const subagent = createHeadlessSubagentTool(runtime, execution, sessionConfig);
7241
7297
  const serverService = (ctx) => {
7242
7298
  ctx.plugin((providerContext) => {
7243
7299
  providerContext.inject([_agimon_ai_po_session.PO_SESSION_GROUP_BRIDGE_SERVICE], (bridgeContext) => {
@@ -7278,6 +7334,7 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
7278
7334
  jobs,
7279
7335
  run: (input, signal) => awaitedInline.run(input, signal),
7280
7336
  startSession: (input, signal) => (0, _agimon_ai_po_session.startCoordinatedSession)(coordinatorSessions, input, signal),
7337
+ callTool: (name, params, operationId, signal) => (name === "subagent" ? subagent : intercom).execute(operationId, params, signal, void 0, execution),
7281
7338
  assertAvailable: () => {
7282
7339
  if (disposing) throw new Error("Team session is disposing.");
7283
7340
  }
@@ -7288,6 +7345,11 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
7288
7345
  registration?.dispose();
7289
7346
  };
7290
7347
  });
7348
+ providerContext.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE, _agimon_ai_po_core_platform.PO_ISOLATE_SERVICE], (scoped) => {
7349
+ if (!(0, _agimon_ai_po_core_codemode.readPoCodemode)(scoped) || (0, _agimon_ai_po_core_platform.readPoIsolate)(scoped)?.liveObjects !== true) return void 0;
7350
+ const restriction = host.registerToolRestriction({ excludedTools: ["subagent", "intercom"] });
7351
+ return () => restriction.dispose();
7352
+ });
7291
7353
  providerContext.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE], (scoped) => {
7292
7354
  const codemode = (0, _agimon_ai_po_core_codemode.readPoCodemode)(scoped);
7293
7355
  if (!codemode) return void 0;
@@ -7354,12 +7416,19 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
7354
7416
  models: catalogModels(discovered, [...models])
7355
7417
  });
7356
7418
  } catch (error) {
7357
- if (!activityAttached) return;
7419
+ const warning = error instanceof Error ? error.message : String(error);
7420
+ if (!activityAttached) {
7421
+ telemetry.recordEvent("po_team.catalog_failed", {
7422
+ outcome: "failed",
7423
+ "error.message": warning
7424
+ });
7425
+ return;
7426
+ }
7358
7427
  directEvents.publish(SUBAGENT_CATALOG_TYPE, execution.sessionId, {
7359
7428
  cwd: execution.cwd,
7360
7429
  agents: [],
7361
7430
  models: [],
7362
- warning: error instanceof Error ? error.message : String(error)
7431
+ warning
7363
7432
  });
7364
7433
  }
7365
7434
  };
@@ -7458,7 +7527,7 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
7458
7527
  serverService,
7459
7528
  (context) => context.provide(PO_TEAM_AGENT_CONFIG_SERVICE, runtime.agentConfig),
7460
7529
  (context) => context.provide(_agimon_ai_po_core_childSession.PO_CHILD_SESSION_LABELS_SERVICE, { labelFor: (runId) => nativeRuns.get(runId)?.identity }),
7461
- mountMcpTools([intercom, createHeadlessSubagentTool(runtime, execution, sessionConfig)])
7530
+ mountMcpTools([intercom, subagent])
7462
7531
  ],
7463
7532
  activities: [activity],
7464
7533
  async onStart() {