@agimon-ai/po-team 0.0.0-alpha.16 → 0.0.0-alpha.18

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.
@@ -208,18 +208,26 @@ function formatRunDuration(elapsedMs) {
208
208
  const minutes = Math.floor(elapsedMs % HOUR_MS / MINUTE_MS);
209
209
  return `${hours}h ${String(minutes).padStart(2, "0")}m`;
210
210
  }
211
- /**
212
- * What to call a run on screen.
213
- *
214
- * Prefers the generated identity, because a fan-out of one agent otherwise
215
- * renders as N rows reading the same word. Falls back to the agent name for a
216
- * run projected before identities existed. Duplicated rather than imported
217
- * from `services/agentIdentity`, which reaches for `node:fs` and so cannot be
218
- * pulled into the browser bundle; that module owns minting, this owns display.
219
- */
211
+ /** What to call a run on screen: the identity's first name, else the agent name. Never a run id. */
220
212
  function agentRunLabel(run) {
221
- const base = run.identity ?? run.agent;
222
- return run.inline ? `${base} (inline)` : base;
213
+ return agentDisplay(run).name;
214
+ }
215
+ function capitalize(word) {
216
+ return word.charAt(0).toUpperCase() + word.slice(1);
217
+ }
218
+ /** `faris-c-6` reads "Faris"; a run without an identity reads as its agent name. */
219
+ function agentDisplay(run) {
220
+ const first = run.identity?.split("-")[0];
221
+ if (!run.identity || !first) return {
222
+ name: run.agent,
223
+ role: "",
224
+ seed: run.agent
225
+ };
226
+ return {
227
+ name: capitalize(first),
228
+ role: run.agent,
229
+ seed: run.identity
230
+ };
223
231
  }
224
232
  //#endregion
225
233
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/launchCommand.ts
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["isRecord","isRecord","WebPluginSlotProps","Badge","Button","Dot","Input","ListRow","SegmentedControl","Sheet","SheetBody","SheetContent","SheetHeader","SheetTitle","Textarea","useCallback","useEffect","useState","useSyncExternalStore","StyleSheet","SubagentCatalogAgent","SubagentRun","launchAgent","steerRun","catalog","closeCatalog","loadCatalog","openCatalog","agentRunLabel","formatRunDuration","agentMeta","filterCatalog","modelChoices","clearPendingLaunch","dismissRun","isTerminalRun","requestLaunch","requestRunStop","subagents","visibleRuns","useSubagents","sessionId","subscribe","listener","sub","store","unsubscribe","select","state","subagentsTab","Parameters","id","label","panel","SubagentsPanel","agentThreadTab","run","runId","props","AgentRunRow","onPress","detail","error","summary","split","find","line","trim","currentTool","tail","at","styles","body","map","openTransientTab","AgentCatalog","filter","setFilter","agent","setAgent","open","undefined","name","models","task","loading","meta","warning","agents","item","description","AgentLaunch","initialTask","onClose","setTask","fork","setFork","defaultContext","model","setModel","busy","setBusy","setError","launch","cause","Error","message","String","value","choice","selected","AgentThreadPanel","renderThread","runs","guidance","setGuidance","notice","setNotice","confirmClear","setConfirmClear","act","action","Promise","screen","title","Math","max","endedAt","lastUpdate","startedAt","stopRequested","includes","transcript","result","create","theme","flex","backgroundColor","colors","bg","uni__dependencies","padding","spacing","gap","color","hi","fontSize","base","fontWeight","dim","sm","red","WebPluginSlotProps","Button","AgentRunRow","agentThreadTab","subagentsTab","useSubagents","openCatalog","activityRuns","AgentsActivitySection","sessionId","openTransientTab","state","runs","map","run","runId","length","fillTeam","activityGroupAgents","channelSubagentCatalog","channelSubagentRuns","fillAgents"],"sources":["../../src/extensions/workspaces/(frontend)/fill/Team.home.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/catalog.native.ts","../../src/types/webSubagents.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/catalogStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/format.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/launchCommand.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/subagentsStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_components/SubagentsPanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/activity-group/agents.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/subagent-catalog.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/subagent-runs.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/AgentsActivitySection.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/Agents.activity.agents.native.tsx","../../generated/native.ts"],"sourcesContent":["import { defineFill } from '@agimon-ai/po-core/native';\n\nexport default defineFill({ data: { version: 1, label: 'Team', source: 'subagent_runs', destination: 'agents' } });\n","import { createApiClient, defineApiRoutes, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\n\nimport type {\n SubagentCatalogAgent,\n SubagentCatalogPayload,\n SubagentSteerResult,\n} from '../../../../../types/webSubagents';\nimport type { LaunchRequest } from './launchCommand';\n\nconst routes = defineApiRoutes({\n catalog: { method: 'GET', path: '/catalog' },\n run: { method: 'POST', path: '/run' },\n steer: { method: 'POST', path: '/steer' },\n stop: { method: 'POST', path: '/stop' },\n});\nconst api = createApiClient(routes, {\n scopes: ['session'],\n basePath: 'team',\n transport: nativeApiTransport,\n sessionAddress: sessionApiAddress,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isStrings(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === 'string');\n}\n\nfunction isAgent(value: unknown): value is SubagentCatalogAgent {\n return (\n isRecord(value) &&\n typeof value.name === 'string' &&\n typeof value.description === 'string' &&\n typeof value.filePath === 'string' &&\n ['project', 'user', 'plugin'].includes(String(value.source)) &&\n (value.packageName === undefined || typeof value.packageName === 'string') &&\n (value.model === undefined || typeof value.model === 'string') &&\n isStrings(value.fallbackModels) &&\n isStrings(value.tools) &&\n isStrings(value.skills) &&\n isStrings(value.extensions) &&\n (value.defaultContext === 'fresh' || value.defaultContext === 'fork')\n );\n}\n\n/** Read the selected session's catalog through the host's authenticated HTTP transport. */\nexport async function fetchCatalog(sessionId: string, signal: AbortSignal): Promise<SubagentCatalogPayload> {\n const response = await api.session(sessionId).catalog({\n signal,\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `Agent catalog could not be loaded (${response.status}).`,\n );\n }\n if (\n !isRecord(body) ||\n typeof body.cwd !== 'string' ||\n !Array.isArray(body.agents) ||\n !body.agents.every(isAgent) ||\n !isStrings(body.models)\n ) {\n throw new Error('The server returned an invalid agent catalog.');\n }\n return { cwd: body.cwd, agents: body.agents, models: body.models };\n}\n\n/** Launch on the selected session host, without submitting a parent prompt. */\nexport async function launchAgent(sessionId: string, request: LaunchRequest): Promise<string> {\n const response = await api.session(sessionId).run({\n body: request,\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `Agent could not be launched (${response.status}).`,\n );\n }\n if (!isRecord(body) || typeof body.runId !== 'string' || body.runId === '')\n throw new Error('The server returned an invalid run ID.');\n return body.runId;\n}\n\nfunction isSteerState(value: unknown): value is SubagentSteerResult['state'] {\n return value === 'delivered' || value === 'failed' || value === 'pending';\n}\n\n/** Steer one run on the selected session host, without submitting a parent prompt. */\nexport async function steerRun(sessionId: string, runId: string, message: string): Promise<SubagentSteerResult> {\n const response = await api.session(sessionId).steer({\n body: { runId, message },\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `Guidance could not be sent (${response.status}).`,\n );\n }\n if (!isRecord(body) || !isSteerState(body.state) || typeof body.message !== 'string')\n throw new Error('The server returned an invalid steer result.');\n return { state: body.state, message: body.message };\n}\n\n/** Ask the selected session host to stop one run; the run's own status reports when it has. */\nexport async function stopRun(sessionId: string, runId: string): Promise<void> {\n const response = await api.session(sessionId).stop({\n body: { runId },\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `The run could not be stopped (${response.status}).`,\n );\n }\n}\n","/**\n * Subagent run view types shared by this package's hub channel and its web\n * plugin. The shapes mirror the per-run status files this package's own\n * runtime writes; the cockpit renders them as 'subagent_runs' channel\n * payloads.\n */\n\n/** Coarse run state the cockpit renders; rawState keeps po-team's exact word. */\nexport type SubagentRunState = 'queued' | 'running' | 'done' | 'failed' | 'stopped';\n\n/**\n * One subagent run of a session, read from po-team's per-run status file.\n */\nexport interface SubagentRun {\n runId: string;\n agent: string;\n /** Optional run details. Missing values mean the runtime did not report them. */\n agentDescription?: string;\n agentFilePath?: string;\n /**\n * Generated addressable identity, for example `alan-reviewer-3`.\n *\n * Additive and optional: a run projected before identities existed, and any\n * run whose claim could not be written, still arrives without one.\n */\n identity?: string;\n /** True when this run came from a one-shot inline agent definition. */\n inline?: boolean;\n state: SubagentRunState;\n rawState: string;\n /** The delegation prompt the main agent gave this run. */\n task: string;\n /** The delegation prompt was intentionally omitted because it is sensitive. */\n promptWithheld?: boolean;\n /** A po-task binding, when the delegation named one; wins over task in the card. */\n taskRef?: string;\n model?: string;\n /** `configured` identifies a model choice not yet confirmed by the runtime. */\n modelSource?: string;\n thinking?: string;\n /** Explicit false disables guidance for runtimes that do not support it. */\n canSteer?: boolean;\n cwd: string;\n /** Epoch milliseconds, as po-team writes them. */\n startedAt: number;\n endedAt?: number;\n lastUpdate: number;\n /** Live one-liner of what the run is doing right now. */\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n cost?: number;\n /** Final report, present once the run finished. */\n summary?: string;\n /** Failure reason, present when the run failed. */\n error?: string;\n /** Recent output lines, oldest first, capped. */\n tail: string[];\n}\n\nexport const SUBAGENT_RUNS_TYPE = 'subagent_runs';\n\n/** How the runtime answered one steer: delivered, refused by the run, or not yet acknowledged. */\nexport interface SubagentSteerResult {\n state: 'delivered' | 'failed' | 'pending';\n message: string;\n}\n/** Where an agent definition came from; the catalog groups by it, nearest first. */\nexport type SubagentCatalogSource = 'project' | 'user' | 'plugin';\n\n/** One launchable agent, as the catalog lists it. */\nexport interface SubagentCatalogAgent {\n name: string;\n source: SubagentCatalogSource;\n /** The package that staged a plugin agent. */\n packageName?: string;\n description: string;\n /** The model the definition pins; absent means the runtime's default. */\n model?: string;\n fallbackModels: string[];\n /** Empty means the definition does not narrow the tool set. */\n tools: string[];\n skills: string[];\n extensions: string[];\n defaultContext: 'fresh' | 'fork';\n filePath: string;\n}\n\n/** The 'subagent_catalog' channel payload: the agents a session's directory can launch. */\nexport interface SubagentCatalogPayload {\n cwd: string;\n agents: SubagentCatalogAgent[];\n /** Model specs the active team package offers, for the launch dialog's picker. */\n models: string[];\n /** Why the list may be incomplete, when discovery failed. */\n warning?: string;\n}\n\nexport const SUBAGENT_CATALOG_TYPE = 'subagent_catalog';\n","import { defineSessionStore } from '@agimon-ai/po-core/native';\n\nimport {\n SUBAGENT_CATALOG_TYPE,\n type SubagentCatalogAgent,\n type SubagentCatalogPayload,\n} from '../../../../../types/webSubagents';\nimport { fetchCatalog } from './catalog.native';\n\n/** One session's catalog: what the hub last reported plus what the drawer is doing with it. */\nexport interface CatalogSession {\n cwd: string;\n agents: SubagentCatalogAgent[];\n models: string[];\n warning: string | undefined;\n loading: boolean;\n requestId: number;\n /** True while the catalog drawer is shown in the subagents tab. */\n open: boolean;\n filter: string;\n /** Task text carried from the surface that opened the catalog. */\n task: string;\n /** The highlighted row, by agent name. */\n selected: string | undefined;\n /** The row whose resources are unfolded. */\n inspected: string | undefined;\n /** The agent the launch dialog is open for, and the context it opened with. */\n launch: { agent: string; fork: boolean } | undefined;\n}\n\nexport const catalog = defineSessionStore<CatalogSession>({\n cwd: '',\n agents: [],\n models: [],\n warning: undefined,\n loading: false,\n requestId: 0,\n open: false,\n filter: '',\n task: '',\n selected: undefined,\n inspected: undefined,\n launch: undefined,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function openCatalog(sessionId: string, task = ''): void {\n catalog.update(sessionId, (current) => ({ ...current, open: true, task }));\n}\n\nexport function closeCatalog(sessionId: string): void {\n catalog.update(sessionId, (current) => ({ ...current, open: false, task: '', launch: undefined }));\n}\n\nexport function setCatalogFilter(sessionId: string, filter: string): void {\n catalog.update(sessionId, (current) => ({ ...current, filter }));\n}\n\nexport function selectAgent(sessionId: string, name: string | undefined): void {\n catalog.update(sessionId, (current) => ({ ...current, selected: name }));\n}\n\nexport function toggleInspect(sessionId: string, name: string): void {\n catalog.update(sessionId, (current) => ({ ...current, inspected: current.inspected === name ? undefined : name }));\n}\n\nexport function openLaunch(sessionId: string, agent: string, fork: boolean): void {\n catalog.update(sessionId, (current) => ({ ...current, selected: agent, launch: { agent, fork } }));\n}\n\nexport function closeLaunch(sessionId: string): void {\n catalog.update(sessionId, (current) => ({ ...current, launch: undefined }));\n}\n\n/** Each drawer opening owns one request and cancels it when the drawer leaves. */\nexport function loadCatalog(sessionId: string): () => void {\n const controller = new AbortController();\n const requestId = catalog.select(catalog.store.state, sessionId).requestId + 1;\n catalog.update(sessionId, (current) => ({ ...current, requestId, loading: true, warning: undefined }));\n const isCurrent = (): boolean =>\n !controller.signal.aborted && catalog.store.state[sessionId]?.requestId === requestId;\n void fetchCatalog(sessionId, controller.signal)\n .then((payload) => {\n if (isCurrent()) subagentCatalogChannel.apply(sessionId, payload);\n })\n .catch((error: unknown) => {\n if (isCurrent())\n catalog.update(sessionId, (current) => ({\n ...current,\n warning: error instanceof Error ? error.message : String(error),\n }));\n })\n .finally(() => {\n if (isCurrent()) catalog.update(sessionId, (current) => ({ ...current, loading: false }));\n });\n return () => {\n if (isCurrent()) catalog.update(sessionId, (current) => ({ ...current, loading: false }));\n controller.abort();\n };\n}\n\n/** The plugin's catalog channel: 'subagent_catalog' payloads into the store; the drawer's own state survives a refresh. */\nexport const subagentCatalogChannel = catalog.channel<SubagentCatalogPayload>({\n channel: SUBAGENT_CATALOG_TYPE,\n parse(input) {\n if (!isRecord(input) || typeof input.cwd !== 'string' || !Array.isArray(input.agents)) return null;\n const models = Array.isArray(input.models) ? input.models.filter((m): m is string => typeof m === 'string') : [];\n return {\n cwd: input.cwd,\n agents: input.agents.filter(isRecord) as unknown as SubagentCatalogAgent[],\n models,\n ...(typeof input.warning === 'string' ? { warning: input.warning } : {}),\n };\n },\n reduce(current, payload) {\n const names = new Set(payload.agents.map((agent) => agent.name));\n return {\n ...current,\n cwd: payload.cwd,\n agents: payload.agents,\n models: payload.models,\n warning: payload.warning,\n selected: current.selected !== undefined && names.has(current.selected) ? current.selected : undefined,\n inspected: current.inspected !== undefined && names.has(current.inspected) ? current.inspected : undefined,\n launch: current.launch !== undefined && names.has(current.launch.agent) ? current.launch : undefined,\n };\n },\n});\n","/**\n * Local copies of the host cockpit's pure formatters\n * (po-web src/web/lib/sessionSummary.ts): this plugin ships zero host\n * imports so the cockpit's bundler can compile it from any install.\n */\nconst MINUTE_MS = 60 * 1000;\nconst HOUR_MS = 60 * MINUTE_MS;\n\nexport function formatRunDuration(elapsedMs: number): string {\n if (elapsedMs < MINUTE_MS) return '<1m';\n if (elapsedMs < HOUR_MS) return `${Math.floor(elapsedMs / MINUTE_MS)}m`;\n const hours = Math.floor(elapsedMs / HOUR_MS);\n const minutes = Math.floor((elapsedMs % HOUR_MS) / MINUTE_MS);\n return `${hours}h ${String(minutes).padStart(2, '0')}m`;\n}\n\nexport function abbreviateCwd(cwd: string): string {\n const match = /^\\/(?:Users|home)\\/[^/]+/u.exec(cwd);\n if (!match) return cwd;\n return `~${cwd.slice(match[0].length)}`;\n}\n\n/**\n * What to call a run on screen.\n *\n * Prefers the generated identity, because a fan-out of one agent otherwise\n * renders as N rows reading the same word. Falls back to the agent name for a\n * run projected before identities existed. Duplicated rather than imported\n * from `services/agentIdentity`, which reaches for `node:fs` and so cannot be\n * pulled into the browser bundle; that module owns minting, this owns display.\n */\nexport function agentRunLabel(run: { agent: string; identity?: string; inline?: boolean }): string {\n const base = run.identity ?? run.agent;\n return run.inline ? `${base} (inline)` : base;\n}\n","import type { SubagentCatalogAgent, SubagentCatalogSource } from '../../../../../types/webSubagents';\n\nconst META_TOOL_LIMIT = 3;\n\nexport interface LaunchRequest {\n agent: string;\n task: string;\n /** A pinned model overrides the agent's default; absent keeps the agent's own. */\n model?: string;\n fork: boolean;\n}\n\n/** Rows whose name, source, package, description or a tool contains the filter, case-insensitively. */\nexport function filterCatalog(agents: readonly SubagentCatalogAgent[], filter: string): SubagentCatalogAgent[] {\n const needle = filter.trim().toLowerCase();\n if (needle === '') return [...agents];\n return agents.filter((agent) =>\n [agent.name, agent.source, agent.packageName ?? '', agent.description, ...agent.tools].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n );\n}\n\nexport interface CatalogSection {\n source: SubagentCatalogSource;\n label: string;\n agents: SubagentCatalogAgent[];\n}\n\nconst SECTION_LABEL: Readonly<Record<SubagentCatalogSource, string>> = {\n project: 'PROJECT',\n user: 'USER',\n plugin: 'PACKAGES',\n};\n\n/** The catalog's sections, nearest source first, keeping the payload's order inside each; empty ones are left out. */\nexport function groupCatalog(agents: readonly SubagentCatalogAgent[]): CatalogSection[] {\n const sections: CatalogSection[] = [];\n for (const source of ['project', 'user', 'plugin'] as const) {\n const members = agents.filter((agent) => agent.source === source);\n if (members.length > 0) sections.push({ source, label: SECTION_LABEL[source], agents: members });\n }\n return sections;\n}\n\n/** What the picker offers: the agent's own model and fallbacks first, then the team's, without repeats. */\nexport function modelChoices(agent: SubagentCatalogAgent, models: readonly string[]): string[] {\n const seen = new Set<string>();\n const choices: string[] = [];\n for (const model of [agent.model ?? '', ...agent.fallbackModels, ...models]) {\n if (model === '' || seen.has(model)) continue;\n seen.add(model);\n choices.push(model);\n }\n return choices;\n}\n\n/** The row's one-liner: what tools it may use, how many skills, and how it starts. */\nexport function agentMeta(agent: SubagentCatalogAgent): string {\n const tools =\n agent.tools.length === 0\n ? 'all tools'\n : `tools ${agent.tools.slice(0, META_TOOL_LIMIT).join(', ')}${\n agent.tools.length > META_TOOL_LIMIT ? ` +${agent.tools.length - META_TOOL_LIMIT}` : ''\n }`;\n const skills =\n agent.skills.length > 0 ? ` · ${agent.skills.length} skill${agent.skills.length === 1 ? '' : 's'}` : '';\n return `${tools}${skills} · ${agent.defaultContext === 'fork' ? 'forks the session' : 'fresh context'}`;\n}\n","import { defineSessionStore } from '@agimon-ai/po-core/native';\n\nimport { SUBAGENT_RUNS_TYPE, type SubagentRun } from '../../../../../types/webSubagents';\nimport { stopRun } from './catalog.native';\nconst TERMINAL_STATES: ReadonlySet<SubagentRun['state']> = new Set(['done', 'failed', 'stopped']);\n\nexport function isTerminalRun(run: SubagentRun): boolean {\n return TERMINAL_STATES.has(run.state);\n}\n\n/** One session's record: the fleet the hub last reported plus what this page did with it. */\nexport interface SubagentsSession {\n /** The fleet the hub last reported; presented order preserved. */\n runs: SubagentRun[];\n /** Finished runs the reader cleared from the grid; they stay on disk and in the hub's feed. */\n dismissed: string[];\n /** Runs a stop was asked for and that have not yet reported a final state. */\n stopRequested: string[];\n /** The run whose detail sheet the subagents tab shows. */\n openRunId: string | undefined;\n /** A launch this page asked for, until a run of that agent it had not seen shows up. */\n pendingLaunch: { agent: string; knownRunIds: string[] } | undefined;\n /** The run a launch produced, for the tab to open once and forget. */\n autoOpenRunId: string | undefined;\n}\n\nexport const subagents = defineSessionStore<SubagentsSession>({\n runs: [],\n dismissed: [],\n stopRequested: [],\n openRunId: undefined,\n pendingLaunch: undefined,\n autoOpenRunId: undefined,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction without(list: readonly string[], runId: string): string[] {\n return list.filter((id) => id !== runId);\n}\n\n/** The full Subagents tab's runs minus the ones the reader dismissed. */\nexport function visibleRuns(session: SubagentsSession): SubagentRun[] {\n return session.dismissed.length === 0\n ? session.runs\n : session.runs.filter((run) => !session.dismissed.includes(run.runId));\n}\n\n/** Only runs that can still be doing work belong in the activity group. */\nexport function activityRuns(session: SubagentsSession): SubagentRun[] {\n return visibleRuns(session).filter((run) => run.state === 'queued' || run.state === 'running');\n}\n\n/**\n * Asks the session host to stop a run over the Team API, never as a parent\n * prompt: the web host does not know Team's slash commands and refuses\n * prompts mid-turn. Marked at once so the control reads \"stopping\"; rolled\n * back and rethrown if the host refuses. Once accepted, the request stands\n * until the run reports a final state.\n */\nexport async function requestRunStop(sessionId: string, runId: string): Promise<void> {\n subagents.update(sessionId, (current) => ({\n ...current,\n stopRequested: [...without(current.stopRequested, runId), runId],\n }));\n try {\n await stopRun(sessionId, runId);\n } catch (error) {\n subagents.update(sessionId, (current) => ({ ...current, stopRequested: without(current.stopRequested, runId) }));\n throw error;\n }\n}\n\n/** Hides a finished run from this page; nothing is deleted. */\nexport function dismissRun(sessionId: string, runId: string): void {\n subagents.update(sessionId, (current) => ({\n ...current,\n dismissed: [...without(current.dismissed, runId), runId],\n openRunId: current.openRunId === runId ? undefined : current.openRunId,\n }));\n}\n\n/** Remember the fleet before the server launch so its first update can open the new run. */\nexport function requestLaunch(sessionId: string, agent: string): void {\n subagents.update(sessionId, (current) => ({\n ...current,\n pendingLaunch: { agent, knownRunIds: current.runs.map((run) => run.runId) },\n }));\n}\n\nexport function clearPendingLaunch(sessionId: string): void {\n subagents.update(sessionId, (current) => ({ ...current, pendingLaunch: undefined }));\n}\n\nexport function clearAutoOpen(sessionId: string): void {\n subagents.update(sessionId, (current) => ({ ...current, autoOpenRunId: undefined }));\n}\n\nexport function openRun(sessionId: string, runId: string | undefined): void {\n subagents.update(sessionId, (current) => ({ ...current, openRunId: runId }));\n}\n\nexport interface SubagentRunsPayload {\n runs: SubagentRun[];\n}\n\n/** The plugin's session data channel: 'subagent_runs' payloads into the store. */\nexport const subagentRunsChannel = subagents.channel<SubagentRunsPayload>({\n channel: SUBAGENT_RUNS_TYPE,\n parse(input) {\n if (!isRecord(input) || !Array.isArray(input.runs)) return null;\n return { runs: input.runs.filter(isRecord) as unknown as SubagentRun[] };\n },\n reduce(current, { runs }) {\n const present = new Map(runs.map((run) => [run.runId, run]));\n // A stop request is spent once the run reports a final state or leaves\n // the feed; a dismissal is forgotten once the run is gone from the feed.\n const stopRequested = current.stopRequested.filter((runId) => {\n const run = present.get(runId);\n return run !== undefined && !isTerminalRun(run);\n });\n const dismissed = current.dismissed.filter((runId) => present.has(runId));\n // The run a launch asked for is the first of that agent the page had not seen.\n const arrived =\n current.pendingLaunch === undefined\n ? undefined\n : runs.find(\n (run) =>\n run.agent === current.pendingLaunch?.agent && !current.pendingLaunch.knownRunIds.includes(run.runId),\n );\n return {\n ...current,\n runs,\n stopRequested,\n dismissed,\n pendingLaunch: arrived === undefined ? current.pendingLaunch : undefined,\n autoOpenRunId: arrived === undefined ? current.autoOpenRunId : arrived.runId,\n };\n },\n});\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport {\n Badge,\n Button,\n Dot,\n Input,\n ListRow,\n SegmentedControl,\n Sheet,\n SheetBody,\n SheetContent,\n SheetHeader,\n SheetTitle,\n Textarea,\n} from '@agimon-ai/po-native-components';\nimport { useCallback, useEffect, useState, useSyncExternalStore } from 'react';\nimport { Text, View, ScrollView } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport type { SubagentCatalogAgent, SubagentRun } from '../../../../../types/webSubagents';\nimport { launchAgent, steerRun } from '../_lib/catalog.native';\nimport { catalog, closeCatalog, loadCatalog, openCatalog } from '../_lib/catalogStore.native';\nimport { agentRunLabel, formatRunDuration } from '../_lib/format';\nimport { agentMeta, filterCatalog, modelChoices } from '../_lib/launchCommand';\nimport {\n clearPendingLaunch,\n dismissRun,\n isTerminalRun,\n requestLaunch,\n requestRunStop,\n subagents,\n visibleRuns,\n} from '../_lib/subagentsStore.native';\n\nexport function useSubagents(sessionId: string | null) {\n const subscribe = useCallback((listener: () => void) => {\n const sub = subagents.store.subscribe(listener);\n return () => sub.unsubscribe();\n }, []);\n return useSyncExternalStore(subscribe, () => subagents.select(subagents.store.state, sessionId));\n}\n\nexport function subagentsTab(): Parameters<WebPluginSlotProps['openTransientTab']>[0] {\n return { id: 'subagents', label: 'agents', panel: SubagentsPanel };\n}\n\nexport function agentThreadTab(run: SubagentRun): Parameters<WebPluginSlotProps['openTransientTab']>[0] {\n const runId = run.runId;\n return {\n id: `subagents-run-${runId}`,\n label: agentRunLabel(run),\n panel: (props) => <AgentThreadPanel {...props} runId={runId} />,\n };\n}\n\nexport function AgentRunRow({ run, onPress }: { run: SubagentRun; onPress: () => void }) {\n const detail =\n run.error ??\n run.summary?.split('\\n').find((line) => line.trim() !== '') ??\n run.currentTool ??\n run.tail.at(-1) ??\n run.state;\n return (\n <ListRow\n leading={\n <Dot\n tone={\n run.state === 'failed'\n ? 'red'\n : run.state === 'running'\n ? 'yellow'\n : run.state === 'done'\n ? 'green'\n : 'muted'\n }\n />\n }\n title={\n <Button variant=\"ghost\" onPress={onPress} testID={`activity-run-${run.runId}`}>\n {agentRunLabel(run)}\n </Button>\n }\n description={detail}\n trailing={<Badge>{run.state}</Badge>}\n />\n );\n}\n\nexport function SubagentsPanel(props: WebPluginSlotProps) {\n const state = useSubagents(props.sessionId);\n return (\n <ScrollView contentContainerStyle={styles.body}>\n <Button\n testID=\"activity-agents-launch\"\n onPress={() => {\n if (props.sessionId !== null) openCatalog(props.sessionId);\n }}\n >\n Launch an agent\n </Button>\n {visibleRuns(state).map((run) => (\n <AgentRunRow key={run.runId} run={run} onPress={() => props.openTransientTab(agentThreadTab(run))} />\n ))}\n <AgentCatalog {...props} />\n </ScrollView>\n );\n}\n\nfunction AgentCatalog({ sessionId }: WebPluginSlotProps) {\n const subscribe = useCallback((listener: () => void) => {\n const sub = catalog.store.subscribe(listener);\n return () => sub.unsubscribe();\n }, []);\n const state = useSyncExternalStore(subscribe, () => catalog.select(catalog.store.state, sessionId));\n const [filter, setFilter] = useState('');\n const [agent, setAgent] = useState<SubagentCatalogAgent>();\n useEffect(() => {\n if (sessionId !== null && state.open) return loadCatalog(sessionId);\n return undefined;\n }, [sessionId, state.open]);\n if (sessionId === null || !state.open) return null;\n return (\n <Sheet\n open\n onOpenChange={(open) => {\n if (!open) {\n closeCatalog(sessionId);\n setAgent(undefined);\n }\n }}\n >\n <SheetContent>\n <SheetHeader>\n <SheetTitle>{agent ? `Launch ${agent.name}` : 'Launch an agent'}</SheetTitle>\n </SheetHeader>\n <SheetBody>\n {agent ? (\n <AgentLaunch\n key={agent.name}\n sessionId={sessionId}\n agent={agent}\n models={state.models}\n initialTask={state.task}\n onClose={() => {\n closeCatalog(sessionId);\n setAgent(undefined);\n }}\n />\n ) : (\n <View style={styles.body}>\n <Input\n accessibilityLabel=\"Filter agents\"\n placeholder=\"Find an agent\"\n value={filter}\n onChangeText={setFilter}\n />\n {state.loading ? <Text style={styles.meta}>Loading agents…</Text> : null}\n {state.warning ? <Text style={styles.error}>{state.warning}</Text> : null}\n {filterCatalog(state.agents, filter).map((item) => (\n <ListRow\n key={item.name}\n title={\n <Button variant=\"ghost\" onPress={() => setAgent(item)}>\n {item.name}\n </Button>\n }\n description={`${item.description}\\n${agentMeta(item)}`}\n />\n ))}\n </View>\n )}\n </SheetBody>\n </SheetContent>\n </Sheet>\n );\n}\n\nfunction AgentLaunch({\n sessionId,\n agent,\n models,\n initialTask,\n onClose,\n}: {\n sessionId: string;\n agent: SubagentCatalogAgent;\n models: string[];\n initialTask: string;\n onClose: () => void;\n}) {\n const [task, setTask] = useState(initialTask);\n const [fork, setFork] = useState(agent.defaultContext === 'fork');\n const [model, setModel] = useState('');\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string>();\n const launch = async () => {\n if (busy) return;\n setBusy(true);\n setError(undefined);\n requestLaunch(sessionId, agent.name);\n try {\n await launchAgent(sessionId, { agent: agent.name, task, fork, ...(model === '' ? {} : { model }) });\n onClose();\n } catch (cause) {\n clearPendingLaunch(sessionId);\n setError(cause instanceof Error ? cause.message : String(cause));\n } finally {\n setBusy(false);\n }\n };\n return (\n <View style={styles.body}>\n <Text style={styles.meta}>{agent.description}</Text>\n <Textarea\n accessibilityLabel=\"Task\"\n value={task}\n onChangeText={setTask}\n placeholder=\"What should the agent do? Empty runs its own prompt\"\n />\n <SegmentedControl\n value={fork ? 'fork' : 'fresh'}\n onValueChange={(value) => setFork(value === 'fork')}\n options={[\n { value: 'fresh', label: 'Fresh' },\n { value: 'fork', label: 'Fork this session' },\n ]}\n />\n <Text style={styles.meta}>Model</Text>\n <Button variant={model === '' ? 'primary' : 'outline'} onPress={() => setModel('')}>\n Agent default{agent.model ? ` · ${agent.model}` : ''}\n </Button>\n {modelChoices(agent, models).map((choice) => (\n <Button\n key={choice}\n variant=\"outline\"\n onPress={() => setModel(choice)}\n accessibilityState={{ selected: model === choice }}\n >\n {choice}\n </Button>\n ))}\n {error ? <Text style={styles.error}>{error}</Text> : null}\n <Button testID=\"launch-agent-submit\" disabled={busy} onPress={() => void launch()}>\n {busy ? 'Launching…' : 'Launch'}\n </Button>\n </View>\n );\n}\n\nexport function AgentThreadPanel({ sessionId, runId, renderThread }: WebPluginSlotProps & { runId: string }) {\n const state = useSubagents(sessionId);\n const run = state.runs.find((item) => item.runId === runId);\n const [guidance, setGuidance] = useState('');\n const [busy, setBusy] = useState(false);\n const [notice, setNotice] = useState<string>();\n const [confirmClear, setConfirmClear] = useState(false);\n const act = async (action: () => Promise<void>) => {\n setBusy(true);\n setNotice(undefined);\n try {\n await action();\n } catch (cause) {\n setNotice(cause instanceof Error ? cause.message : String(cause));\n } finally {\n setBusy(false);\n }\n };\n return (\n <View style={styles.screen}>\n {run ? (\n <View style={styles.body}>\n <Text style={styles.title}>\n {agentRunLabel(run)} · {run.state}\n </Text>\n <Text style={styles.meta}>\n {run.model}\\n{run.task}\\n{formatRunDuration(Math.max(0, (run.endedAt ?? run.lastUpdate) - run.startedAt))}\n </Text>\n {sessionId !== null ? (\n isTerminalRun(run) ? (\n <Button variant=\"outline\" onPress={() => setConfirmClear(true)}>\n Clear run\n </Button>\n ) : (\n <Button\n variant=\"danger-outline\"\n disabled={busy || state.stopRequested.includes(runId)}\n onPress={() => void act(() => requestRunStop(sessionId, runId))}\n >\n {state.stopRequested.includes(runId) ? 'Stopping…' : 'Stop'}\n </Button>\n )\n ) : null}\n </View>\n ) : (\n <Text style={styles.meta}>This run is no longer listed; its transcript stays readable.</Text>\n )}\n <View style={styles.transcript}>{renderThread(runId)}</View>\n {run && sessionId !== null && !isTerminalRun(run) ? (\n <View style={styles.body}>\n <Textarea\n accessibilityLabel=\"Steering guidance\"\n value={guidance}\n onChangeText={setGuidance}\n placeholder=\"Guide this agent…\"\n />\n <Button\n disabled={busy || guidance.trim() === ''}\n onPress={() =>\n void act(async () => {\n const result = await steerRun(sessionId, runId, guidance.trim());\n setNotice(result.message);\n if (result.state !== 'failed') setGuidance('');\n })\n }\n >\n Send guidance\n </Button>\n </View>\n ) : null}\n {notice ? <Text style={styles.meta}>{notice}</Text> : null}\n <Sheet open={confirmClear} onOpenChange={setConfirmClear}>\n <SheetContent>\n <SheetHeader>\n <SheetTitle>Clear this run?</SheetTitle>\n </SheetHeader>\n <SheetBody>\n <Text style={styles.meta}>This hides the finished run. Its transcript stays on disk.</Text>\n <Button\n variant=\"danger-outline\"\n onPress={() => {\n if (sessionId !== null) dismissRun(sessionId, runId);\n setConfirmClear(false);\n }}\n >\n Clear\n </Button>\n </SheetBody>\n </SheetContent>\n </Sheet>\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n screen: { flex: 1, backgroundColor: theme.colors.bg },\n transcript: { flex: 1 },\n body: { padding: theme.spacing(3), gap: theme.spacing(2) },\n title: { color: theme.colors.hi, fontSize: theme.fontSize.base, fontWeight: '600' },\n meta: { color: theme.colors.dim, fontSize: theme.fontSize.sm },\n error: { color: theme.colors.red, fontSize: theme.fontSize.sm },\n}));\n","import { defineActivityGroup } from '@agimon-ai/po-core/native';\nimport { UsersIcon } from '@agimon-ai/po-native-components';\nimport { createElement } from 'react';\n\nimport { subagentsTab } from '../_components/SubagentsPanel.native';\nimport { activityRuns, subagents } from '../_lib/subagentsStore.native';\nexport default defineActivityGroup({\n keys: 'a r',\n icon: () => createElement(UsersIcon),\n statusKey: 'po-team-agents',\n order: 10,\n transientTab: subagentsTab,\n activeSource: {\n subscribe(listener) {\n const subscription = subagents.store.subscribe(listener);\n return () => subscription.unsubscribe();\n },\n isActive(sessionId) {\n return activityRuns(subagents.select(subagents.store.state, sessionId)).length > 0;\n },\n },\n});\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { subagentCatalogChannel } from '../_lib/catalogStore.native';\nexport default defineChannelFile(subagentCatalogChannel);\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { subagentRunsChannel } from '../_lib/subagentsStore.native';\nexport default defineChannelFile(subagentRunsChannel);\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport { Button } from '@agimon-ai/po-native-components';\nimport { View } from 'react-native';\n\nimport { AgentRunRow, agentThreadTab, subagentsTab, useSubagents } from '../../_components/SubagentsPanel.native';\nimport { openCatalog } from '../../_lib/catalogStore.native';\nimport { activityRuns } from '../../_lib/subagentsStore.native';\n\nexport function AgentsActivitySection({ sessionId, openTransientTab }: WebPluginSlotProps) {\n const state = useSubagents(sessionId);\n const runs = activityRuns(state);\n return (\n <View>\n {runs.map((run) => (\n <AgentRunRow key={run.runId} run={run} onPress={() => openTransientTab(agentThreadTab(run))} />\n ))}\n {runs.length === 0 ? (\n <Button\n variant=\"ghost\"\n testID=\"activity-agents-launch\"\n disabled={sessionId === null}\n onPress={() => {\n if (sessionId !== null) {\n openCatalog(sessionId);\n openTransientTab(subagentsTab());\n }\n }}\n >\n Launch an agent\n </Button>\n ) : null}\n </View>\n );\n}\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { AgentsActivitySection } from './_components/AgentsActivitySection.native';\nexport default defineFill({ component: AgentsActivitySection });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport fillTeam from '../src/extensions/workspaces/(frontend)/fill/Team.home.native';\nimport activityGroupAgents from '../src/extensions/workspaces/sessions/(frontend)/activity-group/agents.native';\nimport channelSubagentCatalog from '../src/extensions/workspaces/sessions/(frontend)/channel/subagent-catalog.native';\nimport channelSubagentRuns from '../src/extensions/workspaces/sessions/(frontend)/channel/subagent-runs.native';\nimport fillAgents from '../src/extensions/workspaces/sessions/(frontend)/fill/Agents.activity.agents.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'subagents',\n workspace: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'home', id: 'team' }, fillTeam)]; },\n },\n session: {\n get activityGroups(): WebPluginContributions['activityGroups'] { return [via({ name: 'agents' }, activityGroupAgents)]; },\n get channels(): WebPluginContributions['channels'] { return [via({ channel: 'subagent_catalog' }, channelSubagentCatalog), via({ channel: 'subagent_runs' }, channelSubagentRuns)]; },\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'activity.agents', id: 'agents' }, fillAgents)]; },\n },\n});\n"],"mappings":";;;;;;;;;AAEA,IAAA,2BAAe,WAAW,EAAE,MAAM;CAAE,SAAS;CAAG,OAAO;CAAQ,QAAQ;CAAiB,aAAa;AAAS,EAAE,CAAC;;;ACOjH,MAAM,SAAS,gBAAgB;CAC7B,SAAS;EAAE,QAAQ;EAAO,MAAM;CAAW;CAC3C,KAAK;EAAE,QAAQ;EAAQ,MAAM;CAAO;CACpC,OAAO;EAAE,QAAQ;EAAQ,MAAM;CAAS;CACxC,MAAM;EAAE,QAAQ;EAAQ,MAAM;CAAQ;AACxC,CAAC;AACD,MAAM,MAAM,gBAAgB,QAAQ;CAClC,QAAQ,CAAC,SAAS;CAClB,UAAU;CACV,WAAW;CACX,gBAAgB;AAClB,CAAC;AAED,SAASA,WAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UAAU,OAAmC;CACpD,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,SAAS,OAAO,SAAS,QAAQ;AAC/E;AAEA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A;EAAK,eAAeJ,iBAAiBP,eAAeW,GAAG,CAAC;CAAE,GAA1EA,IAAIC,KAAsE,CAC7F,GACAH,KAAKI,WAAW,IACf,oBAAC,QAAD;EACE,SAAQ;EACR,QAAO;EACP,UAAUP,cAAc;EACxB,eAAe;GACb,IAAIA,cAAc,MAAM;IACtBH,YAAYG,SAAS;IACrBC,iBAAiBN,aAAa,CAAC;GACjC;EACF;EAAE,UAAA;CAGI,CAAA,IACN,IACA,EAAA,CAAA;AAEV;;;AC9BA,IAAA,wCAAe,WAAW,EAAE,WAAW,sBAAsB,CAAC;;;ACM9D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,WAAW,EACT,IAAI,QAAyC;EAAE,OAAO,CAAC,IAAI;GAAE,MAAM;GAAQ,IAAI;EAAO,GAAGa,wBAAQ,CAAC;CAAG,EACvG;CACA,SAAS;EACP,IAAI,iBAA2D;GAAE,OAAO,CAAC,IAAI,EAAE,MAAM,SAAS,GAAGC,qBAAmB,CAAC;EAAG;EACxH,IAAI,WAA+C;GAAE,OAAO,CAAC,IAAI,EAAE,SAAS,mBAAmB,GAAGC,+BAAsB,GAAG,IAAI,EAAE,SAAS,gBAAgB,GAAGC,4BAAmB,CAAC;EAAG;EACpL,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAmB,IAAI;GAAS,GAAGC,qCAAU,CAAC;EAAG;CACtH;AACF,CAAC"}
1
+ {"version":3,"file":"native.mjs","names":["isRecord","isRecord","WebPluginSlotProps","Badge","Button","Dot","Input","ListRow","SegmentedControl","Sheet","SheetBody","SheetContent","SheetHeader","SheetTitle","Textarea","useCallback","useEffect","useState","useSyncExternalStore","StyleSheet","SubagentCatalogAgent","SubagentRun","launchAgent","steerRun","catalog","closeCatalog","loadCatalog","openCatalog","agentRunLabel","formatRunDuration","agentMeta","filterCatalog","modelChoices","clearPendingLaunch","dismissRun","isTerminalRun","requestLaunch","requestRunStop","subagents","visibleRuns","useSubagents","sessionId","subscribe","listener","sub","store","unsubscribe","select","state","subagentsTab","Parameters","id","label","panel","SubagentsPanel","agentThreadTab","run","runId","props","AgentRunRow","onPress","detail","error","summary","split","find","line","trim","currentTool","tail","at","styles","body","map","openTransientTab","AgentCatalog","filter","setFilter","agent","setAgent","open","undefined","name","models","task","loading","meta","warning","agents","item","description","AgentLaunch","initialTask","onClose","setTask","fork","setFork","defaultContext","model","setModel","busy","setBusy","setError","launch","cause","Error","message","String","value","choice","selected","AgentThreadPanel","renderThread","runs","guidance","setGuidance","notice","setNotice","confirmClear","setConfirmClear","act","action","Promise","screen","title","Math","max","endedAt","lastUpdate","startedAt","stopRequested","includes","transcript","result","create","theme","flex","backgroundColor","colors","bg","uni__dependencies","padding","spacing","gap","color","hi","fontSize","base","fontWeight","dim","sm","red","WebPluginSlotProps","Button","AgentRunRow","agentThreadTab","subagentsTab","useSubagents","openCatalog","activityRuns","AgentsActivitySection","sessionId","openTransientTab","state","runs","map","run","runId","length","fillTeam","activityGroupAgents","channelSubagentCatalog","channelSubagentRuns","fillAgents"],"sources":["../../src/extensions/workspaces/(frontend)/fill/Team.home.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/catalog.native.ts","../../src/types/webSubagents.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/catalogStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/format.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/launchCommand.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/subagentsStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_components/SubagentsPanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/activity-group/agents.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/subagent-catalog.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/subagent-runs.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/AgentsActivitySection.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/Agents.activity.agents.native.tsx","../../generated/native.ts"],"sourcesContent":["import { defineFill } from '@agimon-ai/po-core/native';\n\nexport default defineFill({ data: { version: 1, label: 'Team', source: 'subagent_runs', destination: 'agents' } });\n","import { createApiClient, defineApiRoutes, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\n\nimport type {\n SubagentCatalogAgent,\n SubagentCatalogPayload,\n SubagentSteerResult,\n} from '../../../../../types/webSubagents';\nimport type { LaunchRequest } from './launchCommand';\n\nconst routes = defineApiRoutes({\n catalog: { method: 'GET', path: '/catalog' },\n run: { method: 'POST', path: '/run' },\n steer: { method: 'POST', path: '/steer' },\n stop: { method: 'POST', path: '/stop' },\n});\nconst api = createApiClient(routes, {\n scopes: ['session'],\n basePath: 'team',\n transport: nativeApiTransport,\n sessionAddress: sessionApiAddress,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isStrings(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === 'string');\n}\n\nfunction isAgent(value: unknown): value is SubagentCatalogAgent {\n return (\n isRecord(value) &&\n typeof value.name === 'string' &&\n typeof value.description === 'string' &&\n typeof value.filePath === 'string' &&\n ['project', 'user', 'plugin'].includes(String(value.source)) &&\n (value.packageName === undefined || typeof value.packageName === 'string') &&\n (value.model === undefined || typeof value.model === 'string') &&\n isStrings(value.fallbackModels) &&\n isStrings(value.tools) &&\n isStrings(value.skills) &&\n isStrings(value.extensions) &&\n (value.defaultContext === 'fresh' || value.defaultContext === 'fork')\n );\n}\n\n/** Read the selected session's catalog through the host's authenticated HTTP transport. */\nexport async function fetchCatalog(sessionId: string, signal: AbortSignal): Promise<SubagentCatalogPayload> {\n const response = await api.session(sessionId).catalog({\n signal,\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `Agent catalog could not be loaded (${response.status}).`,\n );\n }\n if (\n !isRecord(body) ||\n typeof body.cwd !== 'string' ||\n !Array.isArray(body.agents) ||\n !body.agents.every(isAgent) ||\n !isStrings(body.models)\n ) {\n throw new Error('The server returned an invalid agent catalog.');\n }\n return { cwd: body.cwd, agents: body.agents, models: body.models };\n}\n\n/** Launch on the selected session host, without submitting a parent prompt. */\nexport async function launchAgent(sessionId: string, request: LaunchRequest): Promise<string> {\n const response = await api.session(sessionId).run({\n body: request,\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `Agent could not be launched (${response.status}).`,\n );\n }\n if (!isRecord(body) || typeof body.runId !== 'string' || body.runId === '')\n throw new Error('The server returned an invalid run ID.');\n return body.runId;\n}\n\nfunction isSteerState(value: unknown): value is SubagentSteerResult['state'] {\n return value === 'delivered' || value === 'failed' || value === 'pending';\n}\n\n/** Steer one run on the selected session host, without submitting a parent prompt. */\nexport async function steerRun(sessionId: string, runId: string, message: string): Promise<SubagentSteerResult> {\n const response = await api.session(sessionId).steer({\n body: { runId, message },\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `Guidance could not be sent (${response.status}).`,\n );\n }\n if (!isRecord(body) || !isSteerState(body.state) || typeof body.message !== 'string')\n throw new Error('The server returned an invalid steer result.');\n return { state: body.state, message: body.message };\n}\n\n/** Ask the selected session host to stop one run; the run's own status reports when it has. */\nexport async function stopRun(sessionId: string, runId: string): Promise<void> {\n const response = await api.session(sessionId).stop({\n body: { runId },\n });\n const body: unknown = response.data;\n if (!response.ok) {\n throw new Error(\n isRecord(body) && typeof body.error === 'string'\n ? body.error\n : `The run could not be stopped (${response.status}).`,\n );\n }\n}\n","/**\n * Subagent run view types shared by this package's hub channel and its web\n * plugin. The shapes mirror the per-run status files this package's own\n * runtime writes; the cockpit renders them as 'subagent_runs' channel\n * payloads.\n */\n\n/** Coarse run state the cockpit renders; rawState keeps po-team's exact word. */\nexport type SubagentRunState = 'queued' | 'running' | 'done' | 'failed' | 'stopped';\n\n/**\n * One subagent run of a session, read from po-team's per-run status file.\n */\nexport interface SubagentRun {\n runId: string;\n agent: string;\n /** Optional run details. Missing values mean the runtime did not report them. */\n agentDescription?: string;\n agentFilePath?: string;\n /**\n * Generated addressable identity, for example `alan-reviewer-3`.\n *\n * Additive and optional: a run projected before identities existed, and any\n * run whose claim could not be written, still arrives without one.\n */\n identity?: string;\n /** True when this run came from a one-shot inline agent definition. */\n inline?: boolean;\n state: SubagentRunState;\n rawState: string;\n /** The delegation prompt the main agent gave this run. */\n task: string;\n /** The delegation prompt was intentionally omitted because it is sensitive. */\n promptWithheld?: boolean;\n /** A po-task binding, when the delegation named one; wins over task in the card. */\n taskRef?: string;\n model?: string;\n /** `configured` identifies a model choice not yet confirmed by the runtime. */\n modelSource?: string;\n thinking?: string;\n /** Explicit false disables guidance for runtimes that do not support it. */\n canSteer?: boolean;\n cwd: string;\n /** Epoch milliseconds, as po-team writes them. */\n startedAt: number;\n endedAt?: number;\n lastUpdate: number;\n /** Live one-liner of what the run is doing right now. */\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n cost?: number;\n /** Final report, present once the run finished. */\n summary?: string;\n /** Failure reason, present when the run failed. */\n error?: string;\n /** Recent output lines, oldest first, capped. */\n tail: string[];\n}\n\nexport const SUBAGENT_RUNS_TYPE = 'subagent_runs';\n\n/** How the runtime answered one steer: delivered, refused by the run, or not yet acknowledged. */\nexport interface SubagentSteerResult {\n state: 'delivered' | 'failed' | 'pending';\n message: string;\n}\n/** Where an agent definition came from; the catalog groups by it, nearest first. */\nexport type SubagentCatalogSource = 'project' | 'user' | 'plugin';\n\n/** One launchable agent, as the catalog lists it. */\nexport interface SubagentCatalogAgent {\n name: string;\n source: SubagentCatalogSource;\n /** The package that staged a plugin agent. */\n packageName?: string;\n description: string;\n /** The model the definition pins; absent means the runtime's default. */\n model?: string;\n fallbackModels: string[];\n /** Empty means the definition does not narrow the tool set. */\n tools: string[];\n skills: string[];\n extensions: string[];\n defaultContext: 'fresh' | 'fork';\n filePath: string;\n}\n\n/** The 'subagent_catalog' channel payload: the agents a session's directory can launch. */\nexport interface SubagentCatalogPayload {\n cwd: string;\n agents: SubagentCatalogAgent[];\n /** Model specs the active team package offers, for the launch dialog's picker. */\n models: string[];\n /** Why the list may be incomplete, when discovery failed. */\n warning?: string;\n}\n\nexport const SUBAGENT_CATALOG_TYPE = 'subagent_catalog';\n","import { defineSessionStore } from '@agimon-ai/po-core/native';\n\nimport {\n SUBAGENT_CATALOG_TYPE,\n type SubagentCatalogAgent,\n type SubagentCatalogPayload,\n} from '../../../../../types/webSubagents';\nimport { fetchCatalog } from './catalog.native';\n\n/** One session's catalog: what the hub last reported plus what the drawer is doing with it. */\nexport interface CatalogSession {\n cwd: string;\n agents: SubagentCatalogAgent[];\n models: string[];\n warning: string | undefined;\n loading: boolean;\n requestId: number;\n /** True while the catalog drawer is shown in the subagents tab. */\n open: boolean;\n filter: string;\n /** Task text carried from the surface that opened the catalog. */\n task: string;\n /** The highlighted row, by agent name. */\n selected: string | undefined;\n /** The row whose resources are unfolded. */\n inspected: string | undefined;\n /** The agent the launch dialog is open for, and the context it opened with. */\n launch: { agent: string; fork: boolean } | undefined;\n}\n\nexport const catalog = defineSessionStore<CatalogSession>({\n cwd: '',\n agents: [],\n models: [],\n warning: undefined,\n loading: false,\n requestId: 0,\n open: false,\n filter: '',\n task: '',\n selected: undefined,\n inspected: undefined,\n launch: undefined,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function openCatalog(sessionId: string, task = ''): void {\n catalog.update(sessionId, (current) => ({ ...current, open: true, task }));\n}\n\nexport function closeCatalog(sessionId: string): void {\n catalog.update(sessionId, (current) => ({ ...current, open: false, task: '', launch: undefined }));\n}\n\nexport function setCatalogFilter(sessionId: string, filter: string): void {\n catalog.update(sessionId, (current) => ({ ...current, filter }));\n}\n\nexport function selectAgent(sessionId: string, name: string | undefined): void {\n catalog.update(sessionId, (current) => ({ ...current, selected: name }));\n}\n\nexport function toggleInspect(sessionId: string, name: string): void {\n catalog.update(sessionId, (current) => ({ ...current, inspected: current.inspected === name ? undefined : name }));\n}\n\nexport function openLaunch(sessionId: string, agent: string, fork: boolean): void {\n catalog.update(sessionId, (current) => ({ ...current, selected: agent, launch: { agent, fork } }));\n}\n\nexport function closeLaunch(sessionId: string): void {\n catalog.update(sessionId, (current) => ({ ...current, launch: undefined }));\n}\n\n/** Each drawer opening owns one request and cancels it when the drawer leaves. */\nexport function loadCatalog(sessionId: string): () => void {\n const controller = new AbortController();\n const requestId = catalog.select(catalog.store.state, sessionId).requestId + 1;\n catalog.update(sessionId, (current) => ({ ...current, requestId, loading: true, warning: undefined }));\n const isCurrent = (): boolean =>\n !controller.signal.aborted && catalog.store.state[sessionId]?.requestId === requestId;\n void fetchCatalog(sessionId, controller.signal)\n .then((payload) => {\n if (isCurrent()) subagentCatalogChannel.apply(sessionId, payload);\n })\n .catch((error: unknown) => {\n if (isCurrent())\n catalog.update(sessionId, (current) => ({\n ...current,\n warning: error instanceof Error ? error.message : String(error),\n }));\n })\n .finally(() => {\n if (isCurrent()) catalog.update(sessionId, (current) => ({ ...current, loading: false }));\n });\n return () => {\n if (isCurrent()) catalog.update(sessionId, (current) => ({ ...current, loading: false }));\n controller.abort();\n };\n}\n\n/** The plugin's catalog channel: 'subagent_catalog' payloads into the store; the drawer's own state survives a refresh. */\nexport const subagentCatalogChannel = catalog.channel<SubagentCatalogPayload>({\n channel: SUBAGENT_CATALOG_TYPE,\n parse(input) {\n if (!isRecord(input) || typeof input.cwd !== 'string' || !Array.isArray(input.agents)) return null;\n const models = Array.isArray(input.models) ? input.models.filter((m): m is string => typeof m === 'string') : [];\n return {\n cwd: input.cwd,\n agents: input.agents.filter(isRecord) as unknown as SubagentCatalogAgent[],\n models,\n ...(typeof input.warning === 'string' ? { warning: input.warning } : {}),\n };\n },\n reduce(current, payload) {\n const names = new Set(payload.agents.map((agent) => agent.name));\n return {\n ...current,\n cwd: payload.cwd,\n agents: payload.agents,\n models: payload.models,\n warning: payload.warning,\n selected: current.selected !== undefined && names.has(current.selected) ? current.selected : undefined,\n inspected: current.inspected !== undefined && names.has(current.inspected) ? current.inspected : undefined,\n launch: current.launch !== undefined && names.has(current.launch.agent) ? current.launch : undefined,\n };\n },\n});\n","/**\n * Local copies of the host cockpit's pure formatters\n * (po-web src/web/lib/sessionSummary.ts): this plugin ships zero host\n * imports so the cockpit's bundler can compile it from any install.\n */\nconst MINUTE_MS = 60 * 1000;\nconst HOUR_MS = 60 * MINUTE_MS;\n\nexport function formatRunDuration(elapsedMs: number): string {\n if (elapsedMs < MINUTE_MS) return '<1m';\n if (elapsedMs < HOUR_MS) return `${Math.floor(elapsedMs / MINUTE_MS)}m`;\n const hours = Math.floor(elapsedMs / HOUR_MS);\n const minutes = Math.floor((elapsedMs % HOUR_MS) / MINUTE_MS);\n return `${hours}h ${String(minutes).padStart(2, '0')}m`;\n}\n\nexport function abbreviateCwd(cwd: string): string {\n const match = /^\\/(?:Users|home)\\/[^/]+/u.exec(cwd);\n if (!match) return cwd;\n return `~${cwd.slice(match[0].length)}`;\n}\n\n/** What to call a run on screen: the identity's first name, else the agent name. Never a run id. */\nexport function agentRunLabel(run: { agent: string; identity?: string }): string {\n return agentDisplay(run).name;\n}\n\nexport interface AgentDisplay {\n /** What a person calls it: the identity's first name, else the agent name. */\n name: string;\n /** The agent definition beneath a named run, empty when the name already is it. */\n role: string;\n /** Stable per agent, so its avatar keeps one colour wherever it appears. */\n seed: string;\n}\n\nfunction capitalize(word: string): string {\n return word.charAt(0).toUpperCase() + word.slice(1);\n}\n\n/** `faris-c-6` reads \"Faris\"; a run without an identity reads as its agent name. */\nexport function agentDisplay(run: { agent: string; identity?: string }): AgentDisplay {\n const first = run.identity?.split('-')[0];\n if (!run.identity || !first) return { name: run.agent, role: '', seed: run.agent };\n return { name: capitalize(first), role: run.agent, seed: run.identity };\n}\n","import type { SubagentCatalogAgent, SubagentCatalogSource } from '../../../../../types/webSubagents';\n\nconst META_TOOL_LIMIT = 3;\n\nexport interface LaunchRequest {\n agent: string;\n task: string;\n /** A pinned model overrides the agent's default; absent keeps the agent's own. */\n model?: string;\n fork: boolean;\n}\n\n/** Rows whose name, source, package, description or a tool contains the filter, case-insensitively. */\nexport function filterCatalog(agents: readonly SubagentCatalogAgent[], filter: string): SubagentCatalogAgent[] {\n const needle = filter.trim().toLowerCase();\n if (needle === '') return [...agents];\n return agents.filter((agent) =>\n [agent.name, agent.source, agent.packageName ?? '', agent.description, ...agent.tools].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n );\n}\n\nexport interface CatalogSection {\n source: SubagentCatalogSource;\n label: string;\n agents: SubagentCatalogAgent[];\n}\n\nconst SECTION_LABEL: Readonly<Record<SubagentCatalogSource, string>> = {\n project: 'PROJECT',\n user: 'USER',\n plugin: 'PACKAGES',\n};\n\n/** The catalog's sections, nearest source first, keeping the payload's order inside each; empty ones are left out. */\nexport function groupCatalog(agents: readonly SubagentCatalogAgent[]): CatalogSection[] {\n const sections: CatalogSection[] = [];\n for (const source of ['project', 'user', 'plugin'] as const) {\n const members = agents.filter((agent) => agent.source === source);\n if (members.length > 0) sections.push({ source, label: SECTION_LABEL[source], agents: members });\n }\n return sections;\n}\n\n/** What the picker offers: the agent's own model and fallbacks first, then the team's, without repeats. */\nexport function modelChoices(agent: SubagentCatalogAgent, models: readonly string[]): string[] {\n const seen = new Set<string>();\n const choices: string[] = [];\n for (const model of [agent.model ?? '', ...agent.fallbackModels, ...models]) {\n if (model === '' || seen.has(model)) continue;\n seen.add(model);\n choices.push(model);\n }\n return choices;\n}\n\n/** The row's one-liner: what tools it may use, how many skills, and how it starts. */\nexport function agentMeta(agent: SubagentCatalogAgent): string {\n const tools =\n agent.tools.length === 0\n ? 'all tools'\n : `tools ${agent.tools.slice(0, META_TOOL_LIMIT).join(', ')}${\n agent.tools.length > META_TOOL_LIMIT ? ` +${agent.tools.length - META_TOOL_LIMIT}` : ''\n }`;\n const skills =\n agent.skills.length > 0 ? ` · ${agent.skills.length} skill${agent.skills.length === 1 ? '' : 's'}` : '';\n return `${tools}${skills} · ${agent.defaultContext === 'fork' ? 'forks the session' : 'fresh context'}`;\n}\n","import { defineSessionStore } from '@agimon-ai/po-core/native';\n\nimport { SUBAGENT_RUNS_TYPE, type SubagentRun } from '../../../../../types/webSubagents';\nimport { stopRun } from './catalog.native';\nconst TERMINAL_STATES: ReadonlySet<SubagentRun['state']> = new Set(['done', 'failed', 'stopped']);\n\nexport function isTerminalRun(run: SubagentRun): boolean {\n return TERMINAL_STATES.has(run.state);\n}\n\n/** One session's record: the fleet the hub last reported plus what this page did with it. */\nexport interface SubagentsSession {\n /** The fleet the hub last reported; presented order preserved. */\n runs: SubagentRun[];\n /** Finished runs the reader cleared from the grid; they stay on disk and in the hub's feed. */\n dismissed: string[];\n /** Runs a stop was asked for and that have not yet reported a final state. */\n stopRequested: string[];\n /** The run whose detail sheet the subagents tab shows. */\n openRunId: string | undefined;\n /** A launch this page asked for, until a run of that agent it had not seen shows up. */\n pendingLaunch: { agent: string; knownRunIds: string[] } | undefined;\n /** The run a launch produced, for the tab to open once and forget. */\n autoOpenRunId: string | undefined;\n}\n\nexport const subagents = defineSessionStore<SubagentsSession>({\n runs: [],\n dismissed: [],\n stopRequested: [],\n openRunId: undefined,\n pendingLaunch: undefined,\n autoOpenRunId: undefined,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction without(list: readonly string[], runId: string): string[] {\n return list.filter((id) => id !== runId);\n}\n\n/** The full Subagents tab's runs minus the ones the reader dismissed. */\nexport function visibleRuns(session: SubagentsSession): SubagentRun[] {\n return session.dismissed.length === 0\n ? session.runs\n : session.runs.filter((run) => !session.dismissed.includes(run.runId));\n}\n\n/** Only runs that can still be doing work belong in the activity group. */\nexport function activityRuns(session: SubagentsSession): SubagentRun[] {\n return visibleRuns(session).filter((run) => run.state === 'queued' || run.state === 'running');\n}\n\n/**\n * Asks the session host to stop a run over the Team API, never as a parent\n * prompt: the web host does not know Team's slash commands and refuses\n * prompts mid-turn. Marked at once so the control reads \"stopping\"; rolled\n * back and rethrown if the host refuses. Once accepted, the request stands\n * until the run reports a final state.\n */\nexport async function requestRunStop(sessionId: string, runId: string): Promise<void> {\n subagents.update(sessionId, (current) => ({\n ...current,\n stopRequested: [...without(current.stopRequested, runId), runId],\n }));\n try {\n await stopRun(sessionId, runId);\n } catch (error) {\n subagents.update(sessionId, (current) => ({ ...current, stopRequested: without(current.stopRequested, runId) }));\n throw error;\n }\n}\n\n/** Hides a finished run from this page; nothing is deleted. */\nexport function dismissRun(sessionId: string, runId: string): void {\n subagents.update(sessionId, (current) => ({\n ...current,\n dismissed: [...without(current.dismissed, runId), runId],\n openRunId: current.openRunId === runId ? undefined : current.openRunId,\n }));\n}\n\n/** Remember the fleet before the server launch so its first update can open the new run. */\nexport function requestLaunch(sessionId: string, agent: string): void {\n subagents.update(sessionId, (current) => ({\n ...current,\n pendingLaunch: { agent, knownRunIds: current.runs.map((run) => run.runId) },\n }));\n}\n\nexport function clearPendingLaunch(sessionId: string): void {\n subagents.update(sessionId, (current) => ({ ...current, pendingLaunch: undefined }));\n}\n\nexport function clearAutoOpen(sessionId: string): void {\n subagents.update(sessionId, (current) => ({ ...current, autoOpenRunId: undefined }));\n}\n\nexport function openRun(sessionId: string, runId: string | undefined): void {\n subagents.update(sessionId, (current) => ({ ...current, openRunId: runId }));\n}\n\nexport interface SubagentRunsPayload {\n runs: SubagentRun[];\n}\n\n/** The plugin's session data channel: 'subagent_runs' payloads into the store. */\nexport const subagentRunsChannel = subagents.channel<SubagentRunsPayload>({\n channel: SUBAGENT_RUNS_TYPE,\n parse(input) {\n if (!isRecord(input) || !Array.isArray(input.runs)) return null;\n return { runs: input.runs.filter(isRecord) as unknown as SubagentRun[] };\n },\n reduce(current, { runs }) {\n const present = new Map(runs.map((run) => [run.runId, run]));\n // A stop request is spent once the run reports a final state or leaves\n // the feed; a dismissal is forgotten once the run is gone from the feed.\n const stopRequested = current.stopRequested.filter((runId) => {\n const run = present.get(runId);\n return run !== undefined && !isTerminalRun(run);\n });\n const dismissed = current.dismissed.filter((runId) => present.has(runId));\n // The run a launch asked for is the first of that agent the page had not seen.\n const arrived =\n current.pendingLaunch === undefined\n ? undefined\n : runs.find(\n (run) =>\n run.agent === current.pendingLaunch?.agent && !current.pendingLaunch.knownRunIds.includes(run.runId),\n );\n return {\n ...current,\n runs,\n stopRequested,\n dismissed,\n pendingLaunch: arrived === undefined ? current.pendingLaunch : undefined,\n autoOpenRunId: arrived === undefined ? current.autoOpenRunId : arrived.runId,\n };\n },\n});\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport {\n Badge,\n Button,\n Dot,\n Input,\n ListRow,\n SegmentedControl,\n Sheet,\n SheetBody,\n SheetContent,\n SheetHeader,\n SheetTitle,\n Textarea,\n} from '@agimon-ai/po-native-components';\nimport { useCallback, useEffect, useState, useSyncExternalStore } from 'react';\nimport { Text, View, ScrollView } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport type { SubagentCatalogAgent, SubagentRun } from '../../../../../types/webSubagents';\nimport { launchAgent, steerRun } from '../_lib/catalog.native';\nimport { catalog, closeCatalog, loadCatalog, openCatalog } from '../_lib/catalogStore.native';\nimport { agentRunLabel, formatRunDuration } from '../_lib/format';\nimport { agentMeta, filterCatalog, modelChoices } from '../_lib/launchCommand';\nimport {\n clearPendingLaunch,\n dismissRun,\n isTerminalRun,\n requestLaunch,\n requestRunStop,\n subagents,\n visibleRuns,\n} from '../_lib/subagentsStore.native';\n\nexport function useSubagents(sessionId: string | null) {\n const subscribe = useCallback((listener: () => void) => {\n const sub = subagents.store.subscribe(listener);\n return () => sub.unsubscribe();\n }, []);\n return useSyncExternalStore(subscribe, () => subagents.select(subagents.store.state, sessionId));\n}\n\nexport function subagentsTab(): Parameters<WebPluginSlotProps['openTransientTab']>[0] {\n return { id: 'subagents', label: 'agents', panel: SubagentsPanel };\n}\n\nexport function agentThreadTab(run: SubagentRun): Parameters<WebPluginSlotProps['openTransientTab']>[0] {\n const runId = run.runId;\n return {\n id: `subagents-run-${runId}`,\n label: agentRunLabel(run),\n panel: (props) => <AgentThreadPanel {...props} runId={runId} />,\n };\n}\n\nexport function AgentRunRow({ run, onPress }: { run: SubagentRun; onPress: () => void }) {\n const detail =\n run.error ??\n run.summary?.split('\\n').find((line) => line.trim() !== '') ??\n run.currentTool ??\n run.tail.at(-1) ??\n run.state;\n return (\n <ListRow\n leading={\n <Dot\n tone={\n run.state === 'failed'\n ? 'red'\n : run.state === 'running'\n ? 'yellow'\n : run.state === 'done'\n ? 'green'\n : 'muted'\n }\n />\n }\n title={\n <Button variant=\"ghost\" onPress={onPress} testID={`activity-run-${run.runId}`}>\n {agentRunLabel(run)}\n </Button>\n }\n description={detail}\n trailing={<Badge>{run.state}</Badge>}\n />\n );\n}\n\nexport function SubagentsPanel(props: WebPluginSlotProps) {\n const state = useSubagents(props.sessionId);\n return (\n <ScrollView contentContainerStyle={styles.body}>\n <Button\n testID=\"activity-agents-launch\"\n onPress={() => {\n if (props.sessionId !== null) openCatalog(props.sessionId);\n }}\n >\n Launch an agent\n </Button>\n {visibleRuns(state).map((run) => (\n <AgentRunRow key={run.runId} run={run} onPress={() => props.openTransientTab(agentThreadTab(run))} />\n ))}\n <AgentCatalog {...props} />\n </ScrollView>\n );\n}\n\nfunction AgentCatalog({ sessionId }: WebPluginSlotProps) {\n const subscribe = useCallback((listener: () => void) => {\n const sub = catalog.store.subscribe(listener);\n return () => sub.unsubscribe();\n }, []);\n const state = useSyncExternalStore(subscribe, () => catalog.select(catalog.store.state, sessionId));\n const [filter, setFilter] = useState('');\n const [agent, setAgent] = useState<SubagentCatalogAgent>();\n useEffect(() => {\n if (sessionId !== null && state.open) return loadCatalog(sessionId);\n return undefined;\n }, [sessionId, state.open]);\n if (sessionId === null || !state.open) return null;\n return (\n <Sheet\n open\n onOpenChange={(open) => {\n if (!open) {\n closeCatalog(sessionId);\n setAgent(undefined);\n }\n }}\n >\n <SheetContent>\n <SheetHeader>\n <SheetTitle>{agent ? `Launch ${agent.name}` : 'Launch an agent'}</SheetTitle>\n </SheetHeader>\n <SheetBody>\n {agent ? (\n <AgentLaunch\n key={agent.name}\n sessionId={sessionId}\n agent={agent}\n models={state.models}\n initialTask={state.task}\n onClose={() => {\n closeCatalog(sessionId);\n setAgent(undefined);\n }}\n />\n ) : (\n <View style={styles.body}>\n <Input\n accessibilityLabel=\"Filter agents\"\n placeholder=\"Find an agent\"\n value={filter}\n onChangeText={setFilter}\n />\n {state.loading ? <Text style={styles.meta}>Loading agents…</Text> : null}\n {state.warning ? <Text style={styles.error}>{state.warning}</Text> : null}\n {filterCatalog(state.agents, filter).map((item) => (\n <ListRow\n key={item.name}\n title={\n <Button variant=\"ghost\" onPress={() => setAgent(item)}>\n {item.name}\n </Button>\n }\n description={`${item.description}\\n${agentMeta(item)}`}\n />\n ))}\n </View>\n )}\n </SheetBody>\n </SheetContent>\n </Sheet>\n );\n}\n\nfunction AgentLaunch({\n sessionId,\n agent,\n models,\n initialTask,\n onClose,\n}: {\n sessionId: string;\n agent: SubagentCatalogAgent;\n models: string[];\n initialTask: string;\n onClose: () => void;\n}) {\n const [task, setTask] = useState(initialTask);\n const [fork, setFork] = useState(agent.defaultContext === 'fork');\n const [model, setModel] = useState('');\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string>();\n const launch = async () => {\n if (busy) return;\n setBusy(true);\n setError(undefined);\n requestLaunch(sessionId, agent.name);\n try {\n await launchAgent(sessionId, { agent: agent.name, task, fork, ...(model === '' ? {} : { model }) });\n onClose();\n } catch (cause) {\n clearPendingLaunch(sessionId);\n setError(cause instanceof Error ? cause.message : String(cause));\n } finally {\n setBusy(false);\n }\n };\n return (\n <View style={styles.body}>\n <Text style={styles.meta}>{agent.description}</Text>\n <Textarea\n accessibilityLabel=\"Task\"\n value={task}\n onChangeText={setTask}\n placeholder=\"What should the agent do? Empty runs its own prompt\"\n />\n <SegmentedControl\n value={fork ? 'fork' : 'fresh'}\n onValueChange={(value) => setFork(value === 'fork')}\n options={[\n { value: 'fresh', label: 'Fresh' },\n { value: 'fork', label: 'Fork this session' },\n ]}\n />\n <Text style={styles.meta}>Model</Text>\n <Button variant={model === '' ? 'primary' : 'outline'} onPress={() => setModel('')}>\n Agent default{agent.model ? ` · ${agent.model}` : ''}\n </Button>\n {modelChoices(agent, models).map((choice) => (\n <Button\n key={choice}\n variant=\"outline\"\n onPress={() => setModel(choice)}\n accessibilityState={{ selected: model === choice }}\n >\n {choice}\n </Button>\n ))}\n {error ? <Text style={styles.error}>{error}</Text> : null}\n <Button testID=\"launch-agent-submit\" disabled={busy} onPress={() => void launch()}>\n {busy ? 'Launching…' : 'Launch'}\n </Button>\n </View>\n );\n}\n\nexport function AgentThreadPanel({ sessionId, runId, renderThread }: WebPluginSlotProps & { runId: string }) {\n const state = useSubagents(sessionId);\n const run = state.runs.find((item) => item.runId === runId);\n const [guidance, setGuidance] = useState('');\n const [busy, setBusy] = useState(false);\n const [notice, setNotice] = useState<string>();\n const [confirmClear, setConfirmClear] = useState(false);\n const act = async (action: () => Promise<void>) => {\n setBusy(true);\n setNotice(undefined);\n try {\n await action();\n } catch (cause) {\n setNotice(cause instanceof Error ? cause.message : String(cause));\n } finally {\n setBusy(false);\n }\n };\n return (\n <View style={styles.screen}>\n {run ? (\n <View style={styles.body}>\n <Text style={styles.title}>\n {agentRunLabel(run)} · {run.state}\n </Text>\n <Text style={styles.meta}>\n {run.model}\\n{run.task}\\n{formatRunDuration(Math.max(0, (run.endedAt ?? run.lastUpdate) - run.startedAt))}\n </Text>\n {sessionId !== null ? (\n isTerminalRun(run) ? (\n <Button variant=\"outline\" onPress={() => setConfirmClear(true)}>\n Clear run\n </Button>\n ) : (\n <Button\n variant=\"danger-outline\"\n disabled={busy || state.stopRequested.includes(runId)}\n onPress={() => void act(() => requestRunStop(sessionId, runId))}\n >\n {state.stopRequested.includes(runId) ? 'Stopping…' : 'Stop'}\n </Button>\n )\n ) : null}\n </View>\n ) : (\n <Text style={styles.meta}>This run is no longer listed; its transcript stays readable.</Text>\n )}\n <View style={styles.transcript}>{renderThread(runId)}</View>\n {run && sessionId !== null && !isTerminalRun(run) ? (\n <View style={styles.body}>\n <Textarea\n accessibilityLabel=\"Steering guidance\"\n value={guidance}\n onChangeText={setGuidance}\n placeholder=\"Guide this agent…\"\n />\n <Button\n disabled={busy || guidance.trim() === ''}\n onPress={() =>\n void act(async () => {\n const result = await steerRun(sessionId, runId, guidance.trim());\n setNotice(result.message);\n if (result.state !== 'failed') setGuidance('');\n })\n }\n >\n Send guidance\n </Button>\n </View>\n ) : null}\n {notice ? <Text style={styles.meta}>{notice}</Text> : null}\n <Sheet open={confirmClear} onOpenChange={setConfirmClear}>\n <SheetContent>\n <SheetHeader>\n <SheetTitle>Clear this run?</SheetTitle>\n </SheetHeader>\n <SheetBody>\n <Text style={styles.meta}>This hides the finished run. Its transcript stays on disk.</Text>\n <Button\n variant=\"danger-outline\"\n onPress={() => {\n if (sessionId !== null) dismissRun(sessionId, runId);\n setConfirmClear(false);\n }}\n >\n Clear\n </Button>\n </SheetBody>\n </SheetContent>\n </Sheet>\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n screen: { flex: 1, backgroundColor: theme.colors.bg },\n transcript: { flex: 1 },\n body: { padding: theme.spacing(3), gap: theme.spacing(2) },\n title: { color: theme.colors.hi, fontSize: theme.fontSize.base, fontWeight: '600' },\n meta: { color: theme.colors.dim, fontSize: theme.fontSize.sm },\n error: { color: theme.colors.red, fontSize: theme.fontSize.sm },\n}));\n","import { defineActivityGroup } from '@agimon-ai/po-core/native';\nimport { UsersIcon } from '@agimon-ai/po-native-components';\nimport { createElement } from 'react';\n\nimport { subagentsTab } from '../_components/SubagentsPanel.native';\nimport { activityRuns, subagents } from '../_lib/subagentsStore.native';\nexport default defineActivityGroup({\n keys: 'a r',\n icon: () => createElement(UsersIcon),\n statusKey: 'po-team-agents',\n order: 10,\n transientTab: subagentsTab,\n activeSource: {\n subscribe(listener) {\n const subscription = subagents.store.subscribe(listener);\n return () => subscription.unsubscribe();\n },\n isActive(sessionId) {\n return activityRuns(subagents.select(subagents.store.state, sessionId)).length > 0;\n },\n },\n});\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { subagentCatalogChannel } from '../_lib/catalogStore.native';\nexport default defineChannelFile(subagentCatalogChannel);\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { subagentRunsChannel } from '../_lib/subagentsStore.native';\nexport default defineChannelFile(subagentRunsChannel);\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport { Button } from '@agimon-ai/po-native-components';\nimport { View } from 'react-native';\n\nimport { AgentRunRow, agentThreadTab, subagentsTab, useSubagents } from '../../_components/SubagentsPanel.native';\nimport { openCatalog } from '../../_lib/catalogStore.native';\nimport { activityRuns } from '../../_lib/subagentsStore.native';\n\nexport function AgentsActivitySection({ sessionId, openTransientTab }: WebPluginSlotProps) {\n const state = useSubagents(sessionId);\n const runs = activityRuns(state);\n return (\n <View>\n {runs.map((run) => (\n <AgentRunRow key={run.runId} run={run} onPress={() => openTransientTab(agentThreadTab(run))} />\n ))}\n {runs.length === 0 ? (\n <Button\n variant=\"ghost\"\n testID=\"activity-agents-launch\"\n disabled={sessionId === null}\n onPress={() => {\n if (sessionId !== null) {\n openCatalog(sessionId);\n openTransientTab(subagentsTab());\n }\n }}\n >\n Launch an agent\n </Button>\n ) : null}\n </View>\n );\n}\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { AgentsActivitySection } from './_components/AgentsActivitySection.native';\nexport default defineFill({ component: AgentsActivitySection });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport fillTeam from '../src/extensions/workspaces/(frontend)/fill/Team.home.native';\nimport activityGroupAgents from '../src/extensions/workspaces/sessions/(frontend)/activity-group/agents.native';\nimport channelSubagentCatalog from '../src/extensions/workspaces/sessions/(frontend)/channel/subagent-catalog.native';\nimport channelSubagentRuns from '../src/extensions/workspaces/sessions/(frontend)/channel/subagent-runs.native';\nimport fillAgents from '../src/extensions/workspaces/sessions/(frontend)/fill/Agents.activity.agents.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'subagents',\n workspace: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'home', id: 'team' }, fillTeam)]; },\n },\n session: {\n get activityGroups(): WebPluginContributions['activityGroups'] { return [via({ name: 'agents' }, activityGroupAgents)]; },\n get channels(): WebPluginContributions['channels'] { return [via({ channel: 'subagent_catalog' }, channelSubagentCatalog), via({ channel: 'subagent_runs' }, channelSubagentRuns)]; },\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'activity.agents', id: 'agents' }, fillAgents)]; },\n },\n});\n"],"mappings":";;;;;;;;;AAEA,IAAA,2BAAe,WAAW,EAAE,MAAM;CAAE,SAAS;CAAG,OAAO;CAAQ,QAAQ;CAAiB,aAAa;AAAS,EAAE,CAAC;;;ACOjH,MAAM,SAAS,gBAAgB;CAC7B,SAAS;EAAE,QAAQ;EAAO,MAAM;CAAW;CAC3C,KAAK;EAAE,QAAQ;EAAQ,MAAM;CAAO;CACpC,OAAO;EAAE,QAAQ;EAAQ,MAAM;CAAS;CACxC,MAAM;EAAE,QAAQ;EAAQ,MAAM;CAAQ;AACxC,CAAC;AACD,MAAM,MAAM,gBAAgB,QAAQ;CAClC,QAAQ,CAAC,SAAS;CAClB,UAAU;CACV,WAAW;CACX,gBAAgB;AAClB,CAAC;AAED,SAASA,WA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;EAAG;EACxH,IAAI,WAA+C;GAAE,OAAO,CAAC,IAAI,EAAE,SAAS,mBAAmB,GAAGC,+BAAsB,GAAG,IAAI,EAAE,SAAS,gBAAgB,GAAGC,4BAAmB,CAAC;EAAG;EACpL,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAmB,IAAI;GAAS,GAAGC,qCAAU,CAAC;EAAG;CACtH;AACF,CAAC"}
@@ -19,6 +19,7 @@ let node_fs = require("node:fs");
19
19
  node_fs = require_atomicJson.__toESM(node_fs, 1);
20
20
  let node_path = require("node:path");
21
21
  node_path = require_atomicJson.__toESM(node_path, 1);
22
+ let _agimon_ai_po_config = require("@agimon-ai/po-config");
22
23
  let node_os = require("node:os");
23
24
  node_os = require_atomicJson.__toESM(node_os, 1);
24
25
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
@@ -1916,24 +1917,26 @@ function readWorkflowPreferences(payload) {
1916
1917
  if (preferences.subagentThinking && !THINKING_LEVELS.some((level) => level === preferences.subagentThinking)) throw invalid(`subagentThinking must be one of: ${THINKING_LEVELS.join(", ")}.`);
1917
1918
  return preferences;
1918
1919
  }
1919
- function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, availableModels, teamPackageModels, preferences) {
1920
+ function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, availableModels, teamPackageModels, preferences, planning = {}) {
1920
1921
  const parentModelId = isPiRuntime(runtime) && parentModel ? `${parentModel.provider}/${parentModel.id}` : void 0;
1921
1922
  const agentModels = [...agentConfig.modelSource?.scope === "package" ? [] : [agentConfig.model], ...agentConfig.fallbackModels ?? []];
1922
1923
  const candidates = (isPiRuntime(runtime) ? [
1923
1924
  taskInput.model,
1924
1925
  preferences.subagentModel,
1926
+ planning.subagentModel,
1925
1927
  ...agentModels,
1926
1928
  ...teamPackageModels ?? [],
1927
1929
  parentModelId
1928
1930
  ] : [
1929
1931
  taskInput.model,
1930
1932
  preferences.subagentModel,
1933
+ planning.subagentModel,
1931
1934
  ...agentModels,
1932
1935
  ...teamPackageModels ?? []
1933
1936
  ]).filter((candidate) => Boolean(candidate?.trim()));
1934
1937
  const [primaryModel, ...fallbackModels] = candidates;
1935
1938
  const agentThinking = typeof agentConfig.thinking === "string" ? agentConfig.thinking : void 0;
1936
- if (!preferences.subagentModel && !preferences.subagentThinking) return {
1939
+ if (!preferences.subagentModel && !preferences.subagentThinking && !planning.subagentModel && !planning.subagentThinking) return {
1937
1940
  primaryModel,
1938
1941
  fallbackModels,
1939
1942
  model: selectAvailableModel(primaryModel, fallbackModels, availableModels),
@@ -1950,11 +1953,13 @@ function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, av
1950
1953
  }
1951
1954
  const selectedSuffix = model ? splitKnownThinkingSuffix(model).thinkingSuffix.slice(1) : void 0;
1952
1955
  const explicitThinking = selectedCandidate === taskInput.model ? selectedSuffix : void 0;
1953
- const thinking = explicitThinking || preferences.subagentThinking || selectedSuffix || agentThinking;
1954
- const workflowThinking = !explicitThinking && (preferences.subagentThinking || selectedCandidate === preferences.subagentModel && selectedSuffix);
1956
+ const planningThinking = !planning.subagentModel || selectedCandidate === planning.subagentModel ? planning.subagentThinking : void 0;
1957
+ const preferredThinking = (!preferences.subagentModel || selectedCandidate === preferences.subagentModel || selectedCandidate === taskInput.model ? preferences.subagentThinking : void 0) || planningThinking;
1958
+ const thinking = explicitThinking || preferredThinking || selectedSuffix || agentThinking;
1959
+ const workflowThinking = !explicitThinking && (preferredThinking || selectedCandidate === preferences.subagentModel && selectedSuffix);
1955
1960
  const modelInfo = findModelInfo(model, availableModels);
1956
- if (isPiRuntime(runtime) && workflowThinking && modelInfo && !getSupportedThinkingLevels(modelInfo).some((level) => level === thinking)) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `WORKFLOW_RUN_CONFIG thinking '${thinking}' is unsupported by model '${modelInfo.fullId}'.`, false, `Choose a supported thinking level: ${getSupportedThinkingLevels(modelInfo).join(", ")}.`);
1957
- if (model && selectedSuffix && !explicitThinking && preferences.subagentThinking) model = splitKnownThinkingSuffix(model).baseModel;
1961
+ if (isPiRuntime(runtime) && workflowThinking && modelInfo && !getSupportedThinkingLevels(modelInfo).some((level) => level === thinking)) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Subagent thinking '${thinking}' is unsupported by model '${modelInfo.fullId}'.`, false, `Choose a supported thinking level: ${getSupportedThinkingLevels(modelInfo).join(", ")}.`);
1962
+ if (model && selectedSuffix && !explicitThinking && preferredThinking) model = splitKnownThinkingSuffix(model).baseModel;
1958
1963
  return {
1959
1964
  primaryModel,
1960
1965
  fallbackModels,
@@ -2132,12 +2137,12 @@ var SpawnPlanner = class {
2132
2137
  * the module header.
2133
2138
  */
2134
2139
  async spawnOneChild(input) {
2135
- const { runId, operationId, agentConfig, identity, capabilityCeiling, excludeTools, teamPackageModels, workflowPreferences, taskInput, childIndex, fanout, fallbackCwd, parentSessionId, parentForkSource, sessionScope, environment, parentSessionFile, maxLiveRuns, admissionTimeoutMs, handshakeTimeoutMs, artifacts, artifactDir, availableModels, parentModel, runtime, runtimes, skillProjectionCache, sender } = input;
2140
+ const { runId, operationId, agentConfig, identity, capabilityCeiling, excludeTools, teamPackageModels, workflowPreferences, planningPreferences, taskInput, childIndex, fanout, fallbackCwd, parentSessionId, parentForkSource, sessionScope, environment, parentSessionFile, maxLiveRuns, admissionTimeoutMs, handshakeTimeoutMs, artifacts, artifactDir, availableModels, parentModel, runtime, runtimes, skillProjectionCache, sender } = input;
2136
2141
  const cwd = taskInput.cwd ?? fallbackCwd;
2137
2142
  const task = taskInput.task ?? "";
2138
2143
  const effectiveContext = resolveEffectiveContext(taskInput, agentConfig);
2139
2144
  const effectiveRuntime = taskInput.runtime ?? runtime ?? agentConfig.runtime ?? "pi";
2140
- const modelSelection = resolvedModelSelection(taskInput, agentConfig, effectiveRuntime, parentModel, availableModels, teamPackageModels, workflowPreferences);
2145
+ const modelSelection = resolvedModelSelection(taskInput, agentConfig, effectiveRuntime, parentModel, availableModels, teamPackageModels, workflowPreferences, planningPreferences);
2141
2146
  if (modelSelection.primaryModel && availableModels !== void 0 && !modelSelection.model) return {
2142
2147
  agent: agentConfig.name,
2143
2148
  identity: identity.identity,
@@ -2159,7 +2164,11 @@ var SpawnPlanner = class {
2159
2164
  error: error instanceof Error ? error.message : String(error)
2160
2165
  };
2161
2166
  }
2162
- const warnings = [...skillProjection.warnings, ...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools)];
2167
+ const warnings = [
2168
+ ...modelSelection.primaryModel && modelSelection.model && !selectAvailableModel(modelSelection.primaryModel, [], availableModels) ? [`[fallback] ${modelSelection.primaryModel} is unavailable. Using ${modelSelection.model}.`] : [],
2169
+ ...skillProjection.warnings,
2170
+ ...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools)
2171
+ ];
2163
2172
  const warning = warnings.length > 0 ? warnings.join(" ") : void 0;
2164
2173
  const spawnInput = {
2165
2174
  runId,
@@ -2231,6 +2240,7 @@ var SpawnPlanner = class {
2231
2240
  source,
2232
2241
  agent: agentConfig.name,
2233
2242
  task,
2243
+ ...warning ? { meta: { warning } } : {},
2234
2244
  sender: sender ?? MAIN_AGENT_SENDER,
2235
2245
  cwd,
2236
2246
  ...modelSelection.model ? { model: modelSelection.model } : {},
@@ -2294,6 +2304,11 @@ var SpawnPlanner = class {
2294
2304
  async spawn(request, config) {
2295
2305
  const tasks = this.resolveTaskList(request);
2296
2306
  const workflowPreferences = readWorkflowPreferences(request.environment?.WORKFLOW_RUN_CONFIG ?? this.environment.WORKFLOW_RUN_CONFIG);
2307
+ const planningConfig = request.repoRoot && request.parentSelection?.state?.["minor-mode"]?.includes("plan") ? (0, _agimon_ai_po_config.loadPoConfig)(request.repoRoot, request.environment?.HOME ?? this.environment.HOME).modes?.planning?.subagents : void 0;
2308
+ const planningPreferences = {
2309
+ subagentModel: planningConfig?.model,
2310
+ subagentThinking: planningConfig?.thinking
2311
+ };
2297
2312
  const fanout = tasks.length > 1;
2298
2313
  const teamPackageExcludeTools = this.resolveTeamPackageExcludeTools();
2299
2314
  const teamPackageModels = this.resolveTeamPackageModels();
@@ -2341,7 +2356,7 @@ var SpawnPlanner = class {
2341
2356
  const cwd = taskInput.cwd ?? request.cwd;
2342
2357
  this.validateCwd(cwd);
2343
2358
  const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? "pi";
2344
- const modelSelection = resolvedModelSelection(taskInput, agent, runtime, request.parentModel, request.availableModels, teamPackageModels, workflowPreferences);
2359
+ const modelSelection = resolvedModelSelection(taskInput, agent, runtime, request.parentModel, request.availableModels, teamPackageModels, workflowPreferences, planningPreferences);
2345
2360
  if (modelSelection.primaryModel && request.availableModels !== void 0 && !modelSelection.model) throw new PoTeamExpectedError(ERROR_CODE_MODEL_UNAVAILABLE, `No authenticated model is available for '${agent.name}'.`, false, "Authenticate the requested model or choose an available model.");
2346
2361
  if (taskInput.inlineAgent && !isPiRuntime(runtime)) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_OPERATION, `Inline agent '${taskInput.agent}' requires ${PI_RUNTIME_REQUIREMENT} to enforce its read-only tools.`, false, "Remove the runtime override or use a discovered external-runtime agent without inlineAgent.");
2347
2362
  if (capabilityCeiling && !isPiRuntime(runtime)) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_OPERATION, `Runtime '${runtime}' cannot enforce the active capability ceiling.`, false, `Use ${PI_RUNTIME_REQUIREMENT} while plan mode or another capability ceiling is active.`);
@@ -2370,6 +2385,7 @@ var SpawnPlanner = class {
2370
2385
  excludeTools: teamPackageExcludeTools,
2371
2386
  teamPackageModels,
2372
2387
  workflowPreferences,
2388
+ planningPreferences,
2373
2389
  capabilityCeiling,
2374
2390
  taskInput,
2375
2391
  childIndex,
@@ -2596,6 +2612,9 @@ function createDelegationBridge(deps) {
2596
2612
  agentScope: "both",
2597
2613
  sessionScope: session.sessionScope,
2598
2614
  parentSessionId: session.sessionId,
2615
+ parentSelection: session.parentSelection,
2616
+ repoRoot: session.repoRoot,
2617
+ environment: session.environment,
2599
2618
  ...forkRequestFields(forkSource),
2600
2619
  availableModels: await session.availableModels(),
2601
2620
  ...session.parentModel ? { parentModel: session.parentModel } : {}
@@ -2624,6 +2643,11 @@ function createDelegationBridge(deps) {
2624
2643
  requestId: request.requestId,
2625
2644
  runId: outcome.runId
2626
2645
  });
2646
+ if (outcome.warning) try {
2647
+ await session.reportWarning?.(outcome.warning);
2648
+ } catch (error) {
2649
+ process.emitWarning(`Delegation warning could not be delivered: ${error instanceof Error ? error.message : String(error)}`);
2650
+ }
2627
2651
  await monitor(entry, request, ctx, jobs, session.sessionId, session.sessionScope);
2628
2652
  } catch (error) {
2629
2653
  finish(entry, {
@@ -4892,6 +4916,8 @@ function createHeadlessSubagentTool(runtime, initialExecution) {
4892
4916
  sessionScope: require_externalProcessIpc.createSessionScope(execution.sessionId),
4893
4917
  environment: execution.environment,
4894
4918
  parentSessionId: execution.sessionId,
4919
+ parentSelection: execution.selection,
4920
+ repoRoot: execution.repoRoot,
4895
4921
  ...params.concurrency === void 0 ? {} : { concurrency: params.concurrency },
4896
4922
  ...params.artifacts === void 0 ? {} : { artifacts: params.artifacts },
4897
4923
  availableModels: await availableModelInfos(execution),
@@ -4992,7 +5018,7 @@ function subscribeNativeRunProjection(sessionId, listener) {
4992
5018
  if (closed) return;
4993
5019
  closed = true;
4994
5020
  projection.listeners.delete(listener);
4995
- if (projection.listeners.size === 0 && projection.runs.size === 0) sessions.delete(sessionId);
5021
+ if (projection.listeners.size === 0 && projection.runs.size === 0 && sessions.get(sessionId) === projection) sessions.delete(sessionId);
4996
5022
  };
4997
5023
  }
4998
5024
  //#endregion
@@ -6386,9 +6412,17 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ context, host:
6386
6412
  cwd: execution.cwd,
6387
6413
  environment: serverHost.context.environment,
6388
6414
  availableModels: () => availableModelInfos(execution),
6415
+ repoRoot: execution.repoRoot,
6416
+ get parentSelection() {
6417
+ return execution.selection;
6418
+ },
6389
6419
  get parentModel() {
6390
6420
  return execution.model;
6391
6421
  },
6422
+ reportWarning: (body) => execution.client.notify({
6423
+ body,
6424
+ level: "warning"
6425
+ }),
6392
6426
  captureForkSource: () => execution.session.forkSource?.()
6393
6427
  },
6394
6428
  directRunTracker: runtime.asyncJobTracker,
@@ -6521,39 +6555,43 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ context, host:
6521
6555
  async onDispose() {
6522
6556
  disposing = true;
6523
6557
  activityAttached = false;
6524
- stopPeerDiscovery?.();
6525
- sessionPeers.clear();
6526
- execution.client.setStatus(TEAM_COST_STATUS, void 0);
6527
- channel.dispose();
6528
- runtime.completionNotifier.dispose();
6529
- const stopped = stopScopeRuns({
6530
- reason: "headless session ended",
6531
- jobs: jobs.list(),
6532
- stop: (runId, reason) => runtime.management.stop(runId, reason)
6533
- });
6534
- const nativeShutdown = runtime.nativeRuns.close().finally(() => nativeRunProjection.dispose(execution.sessionId));
6535
- const outcomes = await Promise.allSettled([stopped, nativeShutdown]);
6536
- for (const outcome of outcomes) if (outcome.status === "rejected") process.emitWarning(`Could not shut down headless Team runs: ${String(outcome.reason)}`);
6537
- unsubscribeCostTracker();
6538
- unsubscribeCostNative();
6539
- nativeRuns.clear();
6540
- childCosts.clear();
6541
- costText = void 0;
6542
- bridge.abandonAll();
6543
- fablePlan.abandonAll();
6544
- runtime.capabilityPolicies.clear();
6545
- runtime.management.releaseSessionScope(scope);
6546
- runtime.dispose();
6547
- runtime.asyncJobTracker.stop();
6548
- runtime.pollScheduler.stop();
6549
- const stoppedRuns = outcomes[0];
6550
- await telemetry.recordEvent("po_team.session_finished", {
6551
- reason: "headless session ended",
6552
- "team.stopped_count": stoppedRuns?.status === "fulfilled" ? stoppedRuns.value.stopped.length : 0,
6553
- "team.unstoppable_count": stoppedRuns?.status === "fulfilled" ? stoppedRuns.value.unstoppable.length : 0,
6554
- outcome: stoppedRuns?.status === "fulfilled" && !stoppedRuns.value.unstoppable.length ? "stopped" : "degraded"
6555
- });
6556
- await telemetry.shutdown();
6558
+ let stoppedRuns;
6559
+ await (0, _agimon_ai_po_core_extensionFile.runCleanups)([
6560
+ () => stopPeerDiscovery?.(),
6561
+ () => sessionPeers.clear(),
6562
+ () => execution.client.setStatus(TEAM_COST_STATUS, void 0),
6563
+ () => channel.dispose(),
6564
+ () => runtime.completionNotifier.dispose(),
6565
+ async () => {
6566
+ stoppedRuns = await stopScopeRuns({
6567
+ reason: "headless session ended",
6568
+ jobs: jobs.list(),
6569
+ stop: (runId, reason) => runtime.management.stop(runId, reason)
6570
+ });
6571
+ },
6572
+ () => (0, _agimon_ai_po_core_extensionFile.runCleanups)([() => runtime.nativeRuns.close(), () => nativeRunProjection.dispose(execution.sessionId)], "Native Team runs cleanup failed."),
6573
+ unsubscribeCostTracker,
6574
+ unsubscribeCostNative,
6575
+ () => nativeRuns.clear(),
6576
+ () => childCosts.clear(),
6577
+ () => {
6578
+ costText = void 0;
6579
+ },
6580
+ () => bridge.abandonAll(),
6581
+ () => fablePlan.abandonAll(),
6582
+ () => runtime.capabilityPolicies.clear(),
6583
+ () => runtime.management.releaseSessionScope(scope),
6584
+ () => runtime.dispose(),
6585
+ () => runtime.asyncJobTracker.stop(),
6586
+ () => runtime.pollScheduler.stop(),
6587
+ () => telemetry.recordEvent("po_team.session_finished", {
6588
+ reason: "headless session ended",
6589
+ "team.stopped_count": stoppedRuns?.stopped.length ?? 0,
6590
+ "team.unstoppable_count": stoppedRuns?.unstoppable.length ?? 0,
6591
+ outcome: stoppedRuns && !stoppedRuns.unstoppable.length ? "stopped" : "degraded"
6592
+ }),
6593
+ () => telemetry.shutdown()
6594
+ ], "Team cleanup failed.");
6557
6595
  }
6558
6596
  };
6559
6597
  });