@aparte/plugin-subagents 0.0.0-stage → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +89 -2
- package/dist/aparte-subagent-view.d.ts +150 -0
- package/dist/aparte-subagent-view.d.ts.map +1 -0
- package/dist/connect-65jiVmf_.js +1469 -0
- package/dist/connect-65jiVmf_.js.map +1 -0
- package/dist/connect.d.ts +44 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/custom-elements.json +2057 -0
- package/dist/drawing.d.ts +52 -0
- package/dist/drawing.d.ts.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.d.ts +18 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +10 -0
- package/dist/index.node.js.map +1 -0
- package/dist/lanes.d.ts +44 -0
- package/dist/lanes.d.ts.map +1 -0
- package/dist/line.d.ts +25 -0
- package/dist/line.d.ts.map +1 -0
- package/dist/open.d.ts +34 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/segment.d.ts +20 -0
- package/dist/segment.d.ts.map +1 -0
- package/dist/setup.d.ts +23 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/status.d.ts +24 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/steps.d.ts +22 -0
- package/dist/steps.d.ts.map +1 -0
- package/dist/styles.d.ts +5 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/transcript.d.ts +28 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/words.d.ts +88 -0
- package/dist/words.d.ts.map +1 -0
- package/package.json +92 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-65jiVmf_.js","sources":["../src/types.ts","../src/status.ts","../src/steps.ts","../src/lanes.ts","../src/open.ts","../src/drawing.ts","../src/subagents.css?raw","../src/styles.ts","../src/words.ts","../src/aparte-subagent-view.ts","../src/transcript.ts","../src/line.ts","../src/segment.ts","../src/setup.ts","../src/connect.ts"],"sourcesContent":["/**\n * The shapes the plugin writes and reads: a sub-agent, as it is kept on the segment that\n * stands for it, the plugin's own segment for a sub-agent no call opened, the options, and\n * the two events an app hears.\n */\nimport type { AparteSegment, AparteSegmentBase, AparteToolDetails } from '@aparte/core';\n\n/** Where a sub-agent is: working, waiting for a person, or over — and how. */\nexport type AparteSubagentStatus = 'running' | 'waiting' | 'done' | 'failed' | 'stopped';\n\n/**\n * A sub-agent, as it is saved with the conversation: on the call that opened it (the\n * `subagent` field of that `tool_call` segment), or on a `subagent` segment of its own.\n *\n * `segments` is its conversation — its text, its reasoning, its own tool calls — stamped\n * like a message's, and never part of the reply: the model never reads it back.\n */\nexport interface AparteSubagent {\n /** The sub-agent's id in the run (`agent-start`'s `agentId`). */\n id: string;\n /** Its name, what the line shows. */\n name?: string;\n /** What it was asked to do, shown after the name. */\n description?: string;\n /** As stored. Read it through `subagentStatus`, which knows a saved run is over. */\n status: AparteSubagentStatus;\n /** What it answered, when it is done. */\n result?: string;\n /** Why it failed, when it failed. */\n error?: string;\n /** The sub-agent that opened this one, when one did. */\n parentId?: string;\n /** Its conversation. */\n segments: AparteSegment[];\n}\n\n/** The segment type of a sub-agent that no call opened. */\nexport const SUBAGENT_SEGMENT_TYPE = 'subagent';\n\n/**\n * A sub-agent no call opened (or a second one opened by the same call): a segment of the\n * plugin's own, drawn as the same line a call's sub-agent gets. `isStreaming` is true while\n * it works.\n */\nexport interface AparteSubagentSegment extends AparteSegmentBase {\n type: typeof SUBAGENT_SEGMENT_TYPE;\n subagent: AparteSubagent;\n}\n\ndeclare module '@aparte/core' {\n interface AparteSegmentTypes {\n subagent: AparteSubagentSegment;\n }\n}\n\n/** What `setupSubagents` shows on a sub-agent's line. */\nexport interface SubagentsOptions {\n /** What it is doing now — its latest running tool call — while it works. Default `true`. */\n activity?: boolean;\n /** \"3 tools · 12 s\" after the line: its tool calls and how long it worked. Default `true`. */\n counts?: boolean;\n /**\n * What is behind the line. `false` (the default): the line alone, with no disclosure.\n * A function: what it returns is shown under the line, as a tool display's `details`.\n * `'transcript'`: the sub-agent's conversation under the line (`subagentTranscript`),\n * closed until the reader opens it — or open, with the tool display's `open: true`.\n */\n details?: false | 'transcript' | AparteToolDetails;\n /**\n * What the line can open elsewhere. `'event'`: an Open button at the end of the line\n * dispatches `aparte-subagent-open`, for the app to show the sub-agent's conversation\n * somewhere else (`connectSubagentView` shows it in an `<aparte-subagent-view>` beside the\n * chat). A line with nothing behind it opens on a click anywhere on it too; with `details`,\n * the line keeps opening its detail and only the button opens elsewhere. Left out (the\n * default), the line opens nothing: no button, no pointer.\n */\n open?: false | 'event';\n}\n\n/**\n * A sub-agent started working for a reply, or started again after a pause. Bubbles out of\n * the chat, so an app can list a reply's sub-agents wherever it likes; the detail says which\n * call or which sub-agent opened it, when one did.\n *\n * @event aparte-subagent-start\n */\nexport interface AparteSubagentStartEventDetail {\n /** The chat the reply is in. */\n targetId?: string;\n /** The reply the sub-agent works for. */\n messageId: string;\n agentId: string;\n name?: string;\n description?: string;\n /** The call that opened it, when one did. */\n toolCallId?: string;\n /** The sub-agent that opened it, when one did. */\n parentId?: string;\n}\n\n/**\n * A sub-agent ended, or the run ended without it: `status` says how (`done`, `failed`,\n * `waiting` for a person, `stopped`). Bubbles out of the chat.\n *\n * @event aparte-subagent-end\n */\nexport interface AparteSubagentEndEventDetail {\n /** The chat the reply is in. */\n targetId?: string;\n messageId: string;\n agentId: string;\n status: AparteSubagentStatus;\n}\n\n/**\n * A reader pressed a sub-agent's Open button (`setupSubagents({ open: 'event' })`): show its\n * conversation elsewhere — an `<aparte-subagent-view>` with this `messageId` and `agentId`.\n * Dispatched from the line, bubbles and is composed.\n *\n * @event aparte-subagent-open\n */\nexport interface AparteSubagentOpenEventDetail {\n /** The chat the reply is in, when the line knows it. */\n targetId?: string;\n /** The reply the sub-agent works for: a view's `message-id`. */\n messageId: string;\n /** Which sub-agent: a view's `agent-id`. */\n agentId: string;\n name?: string;\n /** The call that opened it, when its line is that call's row. */\n toolCallId?: string;\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n 'aparte-subagent-start': CustomEvent<AparteSubagentStartEventDetail>;\n 'aparte-subagent-end': CustomEvent<AparteSubagentEndEventDetail>;\n 'aparte-subagent-open': CustomEvent<AparteSubagentOpenEventDetail>;\n }\n}\n","/**\n * What a sub-agent's line says it is doing, read off the segment alone — so a reload and a\n * Stop read right with no bookkeeping of their own.\n */\nimport type { AparteSegment, AparteToolCallSegment } from '@aparte/core';\nimport { SUBAGENT_SEGMENT_TYPE, type AparteSubagent, type AparteSubagentStatus } from './types.js';\n\nconst STATUSES = new Set<AparteSubagentStatus>(['running', 'waiting', 'done', 'failed', 'stopped']);\n\n/**\n * The sub-agent a segment stands for: the one kept on a `tool_call` segment (the call that\n * opened it) or on a `subagent` segment. `undefined` for any other segment.\n */\nexport function subagentOf(segment: AparteSegment): AparteSubagent | undefined {\n const value = (segment as { subagent?: unknown }).subagent;\n if (!value || typeof value !== 'object') return undefined;\n const sub = value as Partial<AparteSubagent>;\n if (typeof sub.id !== 'string') return undefined;\n if (segment.type !== 'tool_call' && segment.type !== SUBAGENT_SEGMENT_TYPE) return undefined;\n return {\n ...sub,\n id: sub.id,\n status: STATUSES.has(sub.status as AparteSubagentStatus) ? sub.status as AparteSubagentStatus : 'stopped',\n segments: Array.isArray(sub.segments) ? sub.segments : [],\n };\n}\n\n/** Whether the segment that stands for a sub-agent has settled: its call is over, or it streams no more. */\nfunction anchorSettled(segment: AparteSegment): boolean {\n if (segment.type === 'tool_call') {\n const status = (segment as AparteToolCallSegment).status;\n return status !== 'pending' && status !== 'awaiting-approval';\n }\n return segment.isStreaming !== true;\n}\n\n/**\n * Where the sub-agent a segment stands for is: its stored status, except that one stored as\n * working (`running`, `waiting`) reads `stopped` once its segment has settled without it — the\n * call that opened it is over, or its own segment streams no more. That is what a reloaded\n * conversation and a Stop look like: nothing will ever end it. A segment that stands for no\n * sub-agent reads `stopped`.\n */\nexport function subagentStatus(segment: AparteSegment): AparteSubagentStatus {\n const sub = subagentOf(segment);\n if (!sub) return 'stopped';\n if ((sub.status === 'running' || sub.status === 'waiting') && anchorSettled(segment)) return 'stopped';\n return sub.status;\n}\n\n/** What a call's own status says of a sub-agent, as its row shows it. */\nexport function statusOfCall(status: AparteToolCallSegment['status'] | undefined): AparteSubagentStatus {\n switch (status ?? 'pending') {\n case 'pending': return 'running';\n case 'awaiting-approval': return 'waiting';\n case 'resolved': return 'done';\n case 'failed': return 'failed';\n default: return 'stopped';\n }\n}\n\n/** The call status that says a sub-agent's status on a row — the reverse of {@link statusOfCall}. */\nexport function callStatusOf(status: AparteSubagentStatus): AparteToolCallSegment['status'] {\n switch (status) {\n case 'running': return 'pending';\n case 'waiting': return 'awaiting-approval';\n case 'done': return 'resolved';\n case 'failed': return 'failed';\n default: return 'aborted';\n }\n}\n","/**\n * The steps a sub-agent has open (\"Reading the parser\"), live: what its line says while none\n * of its calls runs.\n *\n * Kept here, by reply and by agent, and never on a segment: a step lasts only as long as it is\n * open, and the conversation a page saves must not keep one. The lanes write it as the\n * sub-agent's `step-start` / `step-end` arrive and forget it with the sub-agent's end; the line\n * reads it at each draw. Steps nest and overlap: the latest one open is the one said, and when\n * it ends the one before it is said again.\n */\n\nconst open = new Map<string, string[]>();\n\nconst keyOf = (messageId: string, agentId: string): string => `${messageId}\\u0000${agentId}`;\n\n/** A step of the sub-agent `agentId` of the reply `messageId` begins. */\nexport function stepStarted(messageId: string, agentId: string, name: string): void {\n const key = keyOf(messageId, agentId);\n open.set(key, [...(open.get(key) ?? []), name]);\n}\n\n/** The latest open step of that name ends. */\nexport function stepEnded(messageId: string, agentId: string, name: string): void {\n const key = keyOf(messageId, agentId);\n const steps = open.get(key);\n if (!steps) return;\n const at = steps.lastIndexOf(name);\n if (at < 0) return;\n const rest = steps.filter((_, i) => i !== at);\n if (rest.length > 0) open.set(key, rest);\n else open.delete(key);\n}\n\n/** Every step of the sub-agent ends: it ended, or its reply did. */\nexport function stepsEnded(messageId: string, agentId: string): void {\n open.delete(keyOf(messageId, agentId));\n}\n\n/**\n * The step the sub-agent is on, if any. Without the reply's id (a segment that does not carry\n * one), the first sub-agent of that id with a step open.\n */\nexport function currentStep(messageId: string | undefined, agentId: string): string | undefined {\n if (messageId !== undefined) return open.get(keyOf(messageId, agentId))?.at(-1);\n const suffix = `\\u0000${agentId}`;\n for (const [key, steps] of open) if (key.endsWith(suffix)) return steps.at(-1);\n return undefined;\n}\n","/**\n * The lanes: each sub-agent's conversation, kept apart from the reply and saved on the\n * segment that stands for it.\n *\n * Core keeps a sub-agent's events out of the reply and hands every event of the run to the\n * observers of `observeRunEvents`. This observer gives each sub-agent a lane: a segment list\n * (`createSegmentList`) written by a stream adapter of core's own (`createStreamAdapter`), fed\n * the sub-agent's events with their `agentId` taken off, so the lane holds exactly what a\n * reply would — text, reasoning, its tool calls, stamped the same way.\n *\n * A lane lives on its ANCHOR, the segment that stands for the sub-agent: the call that opened\n * it (`tool-<toolCallId>`, in a field `subagent`), or — with no call, or for the second\n * sub-agent of one call — a `subagent` segment of the plugin's own, added to the reply. A\n * sub-agent of a sub-agent follows the same two rules inside its parent's lane. The anchor is\n * written once per animation frame while text streams, and at once for everything a person\n * must see or the conversation must keep: a new segment, a tool's state, the sub-agent's end,\n * the run's end or pause — the conversation is saved on those, so the lane is on the segment\n * before anyone saves it.\n *\n * Memory is per reply, emptied when its run ends (done, stopped, failed), kept across a pause\n * (the run resumes into the same reply), and capped.\n */\nimport {\n createSegmentList,\n createStreamAdapter,\n type AparteMessage,\n type AparteRunEventContext,\n type AparteSegment,\n type AparteSegmentList,\n type AparteStreamRunEmitter,\n type AparteStreamRunEvent,\n type AparteToolCallSegment,\n type StreamAdapterTarget,\n} from '@aparte/core';\nimport { subagentOf } from './status.js';\nimport { stepEnded, stepStarted, stepsEnded } from './steps.js';\nimport {\n SUBAGENT_SEGMENT_TYPE,\n type AparteSubagent,\n type AparteSubagentStatus,\n type AparteSubagentSegment,\n} from './types.js';\n\n/** Replies followed at once by one setup: past this, the oldest is forgotten (a run nobody ended). */\nconst MAX_RUNS = 64;\n/** Sub-agents in one reply: past this, a new one is not drawn. */\nconst MAX_LANES = 512;\n/** Events held for sub-agents not announced yet, per reply. */\nconst MAX_EARLY = 2000;\n\n/** Events written at the next frame: the ones that only grow what is already there. */\nconst COALESCED = new Set<AparteStreamRunEvent['type']>(['text-delta', 'thinking-delta', 'sources', 'text-flush', 'turn-start']);\n\n/** A call's state that a person or the turn is still waiting on. */\nconst isOpen = (status: AparteToolCallSegment['status'] | undefined): boolean =>\n (status ?? 'pending') === 'pending' || status === 'awaiting-approval';\n\n/** A sub-agent's anchor, just written: which chat, which reply, which agent, and the segment as it is now. */\nexport interface LaneWrite {\n readonly target: object;\n readonly targetId?: string;\n readonly messageId: string;\n readonly agentId: string;\n readonly anchor: AparteSegment;\n}\n\n/**\n * The last anchor written for each sub-agent of a run still going, by reply and agent: what a\n * view opened in the middle of a run reads before the next write reaches it — the chat a\n * framework mirrors may not hold the lane yet. Dropped when the run ends: the conversation\n * holds it then.\n */\nconst lastWrites = new Map<string, LaneWrite>();\nconst writeKey = (messageId: string, agentId: string): string => `${messageId}\\u0000${agentId}`;\n\n/** The last anchor written for this sub-agent while its run goes on, if any. */\nexport function lastLaneWrite(messageId: string, agentId: string): LaneWrite | undefined {\n return lastWrites.get(writeKey(messageId, agentId));\n}\n\n/** Who hears every anchor written, from every setup: the standalone views. */\nconst laneWatchers = new Set<(write: LaneWrite) => void>();\n\n/**\n * Hear every sub-agent's anchor as it is written — once a frame while it streams, at once\n * for everything else. What `<aparte-subagent-view>` follows a live sub-agent with.\n */\nexport function watchLaneWrites(fn: (write: LaneWrite) => void): () => void {\n laneWatchers.add(fn);\n return () => { laneWatchers.delete(fn); };\n}\n\n/**\n * Who draws a reply's sub-agents, when two setups hear the same run (one on a chat's config,\n * one on the global): the first to see a sub-agent's event, which is the chat's — observers\n * are called the chat's config first. Per target, per reply.\n */\nconst claims = new WeakMap<object, Map<string, object>>();\n\nfunction claim(target: object, messageId: string, owner: object): boolean {\n let byMessage = claims.get(target);\n if (!byMessage) claims.set(target, (byMessage = new Map()));\n const holder = byMessage.get(messageId);\n if (holder) return holder === owner;\n byMessage.set(messageId, owner);\n return true;\n}\n\nfunction release(target: object, messageId: string, owner: object): void {\n const byMessage = claims.get(target);\n if (byMessage?.get(messageId) === owner) byMessage.delete(messageId);\n}\n\n/** Once per animation frame where there is one (a page), else on a short timer (Node, a worker). */\nfunction nextFrame(fn: () => void): () => void {\n if (typeof requestAnimationFrame === 'function') {\n const handle = requestAnimationFrame(fn);\n return () => cancelAnimationFrame(handle);\n }\n const handle = setTimeout(fn, 16);\n return () => clearTimeout(handle);\n}\n\ninterface Lane {\n readonly id: string;\n name?: string;\n description?: string;\n readonly parentId?: string;\n /** The call that opened it, as its `agent-start` named it: a re-announce on another call is another sub-agent. */\n readonly toolCallId?: string;\n status: AparteSubagentStatus;\n result?: string;\n error?: string;\n /** Its conversation, and the adapter that writes it. */\n readonly list: AparteSegmentList;\n readonly emit: AparteStreamRunEmitter;\n /** Where its anchor lives: the reply, or its parent's lane. */\n readonly host: Lane | null;\n readonly anchorId: string;\n readonly anchorKind: 'call' | 'own';\n /** The anchor exists: its call's row was added. */\n ready: boolean;\n /** Its own anchor streams while it works. */\n streaming: boolean;\n /** Its calls waiting for a person. */\n readonly asking: Set<string>;\n /** The plugin set the spawning call to `awaiting-approval`, and owes it its `pending` back. */\n holding: boolean;\n readonly depth: number;\n}\n\ninterface Run {\n readonly messageId: string;\n readonly target: StreamAdapterTarget;\n readonly targetId?: string;\n readonly lanes: Map<string, Lane>;\n /** The sub-agent each call opened, per host (`''` for the reply, else the parent's id). */\n readonly callAgents: Map<string, string>;\n /** Events for sub-agents not announced yet (a resume after a reload). */\n readonly early: Map<string, AparteStreamRunEvent[]>;\n earlyCount: number;\n /** Lanes whose call has not been started yet, by host and call. */\n readonly awaitingRow: Map<string, Lane[]>;\n /** Lanes whose call's row was just started: ready once the reply has added it. */\n rowsDue: Lane[];\n readonly dirty: Set<Lane>;\n cancelFrame: (() => void) | null;\n closed: boolean;\n unlisten: () => void;\n}\n\n/** Cancel the frame a run's writes wait for, if any. */\nfunction stopFrame(run: Run): void {\n const cancel = run.cancelFrame;\n run.cancelFrame = null;\n cancel?.();\n}\n\nconst hostKey = (host: Lane | null, toolCallId: string): string => `${host?.id ?? ''}\\u0000${toolCallId}`;\n\n/** The plugin segment that stands for a sub-agent no call opened. */\nconst ownSegmentId = (agentId: string): string => `subagent-${agentId}`;\n\n/** That id, or one beside it when the host holds it already: a reused id's first sub-agent keeps its own. */\nfunction freeOwnId(segments: readonly AparteSegment[] | undefined, agentId: string): string {\n const base = ownSegmentId(agentId);\n let id = base;\n for (let n = 2; segments?.some((s) => s.id === id); n += 1) id = `${base}-${n}`;\n return id;\n}\n\n/** The observer of one setup, and what forgets everything it follows. */\nexport function createLanes(): { observe: (event: AparteStreamRunEvent, ctx: AparteRunEventContext) => void; dispose: () => void } {\n const owner = {};\n const runs = new Map<string, Run>();\n /** Replies whose run is over, the latest few: a late event for one opens nothing. */\n const over = new Set<string>();\n\n /** The reply's segments as the target holds them; `undefined` when the target cannot say. */\n const replySegments = (run: Run): readonly AparteSegment[] | undefined => {\n const t = run.target as { getMessage?: (id: string) => AparteMessage | undefined; getMessages?: () => AparteMessage[] };\n try {\n const message = t.getMessage?.(run.messageId) ?? t.getMessages?.()?.find((m) => m.id === run.messageId);\n return message ? (message.segments ?? []) : undefined;\n } catch {\n return undefined;\n }\n };\n\n const hostSegments = (run: Run, host: Lane | null): readonly AparteSegment[] | undefined =>\n (host ? host.list.segments : replySegments(run));\n\n const anchorOf = (run: Run, lane: Lane): AparteSegment | undefined =>\n hostSegments(run, lane.host)?.find((s) => s.id === lane.anchorId);\n\n /** Whether it, or a sub-agent of it, waits for a person. */\n const isWaiting = (run: Run, lane: Lane): boolean => {\n if (lane.status === 'waiting' || lane.asking.size > 0) return true;\n for (const other of run.lanes.values()) {\n if (other.host === lane && (other.status === 'running' || other.status === 'waiting') && isWaiting(run, other)) return true;\n }\n return false;\n };\n\n const snapshot = (run: Run, lane: Lane): AparteSubagent => ({\n id: lane.id,\n ...(lane.name !== undefined ? { name: lane.name } : {}),\n ...(lane.description !== undefined ? { description: lane.description } : {}),\n status: lane.status === 'running' && isWaiting(run, lane) ? 'waiting' : lane.status,\n ...(lane.result !== undefined ? { result: lane.result } : {}),\n ...(lane.error !== undefined ? { error: lane.error } : {}),\n ...(lane.parentId !== undefined ? { parentId: lane.parentId } : {}),\n segments: lane.list.segments as AparteSegment[],\n });\n\n /**\n * Write a segment of the reply or of a lane — never another reply's. Never after the run\n * either, and that is `flush`'s to refuse: it is the one way here, through `writeAnchor`.\n */\n const write = (run: Run, host: Lane | null, segmentId: string, updates: Record<string, unknown>): void => {\n if (host) {\n host.list.updateSegment?.(segmentId, updates as Partial<AparteSegment>);\n return;\n }\n // The target writes \"the reply being streamed\"; a reply it can read must hold the\n // segment, or the write would land on another one.\n const segments = replySegments(run);\n if (segments && !segments.some((s) => s.id === segmentId)) return;\n run.target.updateSegment?.(segmentId, updates as Partial<AparteSegment>);\n };\n\n const writeAnchor = (run: Run, lane: Lane): void => {\n const updates: Record<string, unknown> = { subagent: snapshot(run, lane) };\n if (lane.anchorKind === 'own') {\n updates['isStreaming'] = lane.streaming;\n } else {\n // While it waits for a person, the call that opened it says so: no dots, no fold.\n const call = anchorOf(run, lane) as AparteToolCallSegment | undefined;\n if (call && isOpen(call.status)) {\n const waiting = isWaiting(run, lane);\n if (waiting && call.status !== 'awaiting-approval') {\n updates['status'] = 'awaiting-approval';\n lane.holding = true;\n } else if (!waiting && lane.holding && call.status === 'awaiting-approval') {\n updates['status'] = 'pending';\n lane.holding = false;\n }\n }\n }\n write(run, lane.host, lane.anchorId, updates);\n if (run.closed) return;\n // The anchor as the conversation holds it now; a host that cannot be read gets the\n // plugin's own shape, which reads the same state.\n const anchor = anchorOf(run, lane) ?? {\n id: lane.anchorId, type: SUBAGENT_SEGMENT_TYPE, subagent: updates['subagent'], isStreaming: lane.streaming,\n } as AparteSubagentSegment;\n const note: LaneWrite = {\n target: run.target,\n ...(run.targetId !== undefined ? { targetId: run.targetId } : {}),\n messageId: run.messageId,\n agentId: lane.id,\n anchor,\n };\n lastWrites.set(writeKey(run.messageId, lane.id), note);\n for (const fn of [...laneWatchers]) {\n try {\n fn(note);\n } catch (err) {\n console.error('[aparte] a sub-agent view threw', err);\n }\n }\n };\n\n /** Write every lane that changed, a sub-agent before the parent whose lane holds it. */\n const flush = (run: Run): void => {\n if (run.closed) return;\n stopFrame(run);\n for (let guard = 0; run.dirty.size > 0 && guard < 10_000; guard += 1) {\n let deepest: Lane | undefined;\n for (const lane of run.dirty) if (!deepest || lane.depth > deepest.depth) deepest = lane;\n run.dirty.delete(deepest!);\n if (deepest!.ready) writeAnchor(run, deepest!);\n }\n // Writing a parent's lane scheduled a frame there is nothing left for.\n stopFrame(run);\n };\n\n const schedule = (run: Run): void => {\n if (run.cancelFrame || run.closed) return;\n run.cancelFrame = nextFrame(() => {\n run.cancelFrame = null;\n flush(run);\n });\n };\n\n // Named as core's own helper is, and with its contract: on the chat, bubbling, composed,\n // stamped with the chat's id. The events reference reads where an event goes out from this name.\n const dispatchLifecycleEvent = (run: Run, name: string, detail: Record<string, unknown>): void => {\n if (typeof CustomEvent !== 'function') return;\n const id = run.targetId ?? ((run.target as { id?: unknown }).id || undefined);\n try {\n run.target.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: { targetId: id, ...detail } }));\n } catch { /* a target that cannot dispatch hears nothing */ }\n };\n\n const dispatchEnd = (run: Run, lane: Lane, status: AparteSubagentStatus): void =>\n dispatchLifecycleEvent(run, 'aparte-subagent-end', { messageId: run.messageId, agentId: lane.id, status });\n\n /** The lane's open segments, settled: its text streams no more, and at the run's end its open calls stop. */\n const settleLane = (lane: Lane, calls: boolean): void => {\n for (const segment of lane.list.segments) {\n if (segment.type === 'tool_call') {\n if (calls && isOpen((segment as AparteToolCallSegment).status)) {\n lane.list.updateSegment?.(segment.id, { status: 'aborted' } as Partial<AparteSegment>);\n }\n } else if (segment.isStreaming === true) {\n lane.list.updateSegment?.(segment.id, { isStreaming: false });\n }\n }\n };\n\n /** The run is over: everything written one last time, then forgotten. */\n const close = (run: Run): void => {\n if (run.closed) return;\n for (const lane of run.lanes.values()) {\n const working = lane.status === 'running' || lane.status === 'waiting';\n stepsEnded(run.messageId, lane.id);\n settleLane(lane, true);\n lane.streaming = false;\n run.dirty.add(lane);\n if (working) dispatchEnd(run, lane, 'stopped');\n }\n flush(run);\n forget(run);\n };\n\n /** Drop a run without writing anything. */\n const forget = (run: Run): void => {\n for (const lane of run.lanes.values()) {\n stepsEnded(run.messageId, lane.id);\n lastWrites.delete(writeKey(run.messageId, lane.id));\n }\n run.closed = true;\n stopFrame(run);\n run.unlisten();\n release(run.target, run.messageId, owner);\n if (runs.get(run.messageId) === run) runs.delete(run.messageId);\n over.add(run.messageId);\n if (over.size > MAX_RUNS) over.delete(over.values().next().value!);\n };\n\n const markDirty = (run: Run, lane: Lane, now: boolean): void => {\n run.dirty.add(lane);\n if (now) flush(run);\n else schedule(run);\n };\n\n /** The rows started since the last event are in the reply now: their lanes can be written. */\n const settleDueRows = (run: Run): void => {\n if (run.rowsDue.length === 0) return;\n const due = run.rowsDue;\n run.rowsDue = [];\n for (const lane of due) {\n lane.ready = true;\n run.dirty.add(lane);\n }\n flush(run);\n };\n\n /** A call was started: a sub-agent announced before it can be written now. */\n const callStarted = (run: Run, host: Lane | null, toolCallId: string): void => {\n const key = hostKey(host, toolCallId);\n const held = run.awaitingRow.get(key);\n if (!held) return;\n run.awaitingRow.delete(key);\n if (host) {\n // A lane's call is in its list as soon as its adapter is fed.\n for (const lane of held) { lane.ready = true; run.dirty.add(lane); }\n flush(run);\n return;\n }\n // The reply's row is added AFTER the observers hear `tool-start`: ready on the next\n // event, or once this one has been handled.\n run.rowsDue.push(...held);\n queueMicrotask(() => settleDueRows(run));\n };\n\n const listen = (run: Run): (() => void) => {\n const target = run.target as Partial<Pick<EventTarget, 'addEventListener' | 'removeEventListener'>>;\n if (typeof target.addEventListener !== 'function' || typeof target.removeEventListener !== 'function') return () => {};\n const mine = (e: Event): boolean => (e as CustomEvent<{ messageId?: unknown }>).detail?.messageId === run.messageId;\n const onEnd = (e: Event): void => { if (mine(e)) close(run); };\n // A pause keeps the lanes, and written: the conversation is saved on this event. The\n // reply's own segments were just settled with the message, so a sub-agent still\n // working gets its own segment back open.\n const onPause = (e: Event): void => {\n if (!mine(e)) return;\n for (const lane of run.lanes.values()) run.dirty.add(lane);\n flush(run);\n };\n // Capture, on the target itself: before the chat's own listeners, which save.\n const ends = ['aparte-message-done', 'aparte-message-aborted', 'aparte-message-error'];\n for (const name of ends) target.addEventListener!(name, onEnd, true);\n target.addEventListener!('aparte-message-paused', onPause, true);\n return () => {\n for (const name of ends) target.removeEventListener!(name, onEnd, true);\n target.removeEventListener!('aparte-message-paused', onPause, true);\n };\n };\n\n const openRun = (ctx: AparteRunEventContext): Run | undefined => {\n if (!claim(ctx.target, ctx.messageId, owner)) return undefined;\n if (runs.size >= MAX_RUNS) {\n const oldest = runs.values().next().value;\n if (oldest) forget(oldest);\n }\n const run: Run = {\n messageId: ctx.messageId,\n target: ctx.target,\n ...(ctx.targetId !== undefined ? { targetId: ctx.targetId } : {}),\n lanes: new Map(),\n callAgents: new Map(),\n early: new Map(),\n earlyCount: 0,\n awaitingRow: new Map(),\n rowsDue: [],\n dirty: new Set(),\n cancelFrame: null,\n closed: false,\n unlisten: () => {},\n };\n run.unlisten = listen(run);\n runs.set(ctx.messageId, run);\n return run;\n };\n\n /** What the host already holds for this sub-agent: a lane saved before a reload, resumed now. */\n const savedAnchor = (segments: readonly AparteSegment[] | undefined, agentId: string, toolCallId?: string): AparteSegment | undefined => {\n if (!segments) return undefined;\n return segments.find((s) => s.id === ownSegmentId(agentId) && subagentOf(s)?.id === agentId)\n ?? (toolCallId ? segments.find((s) => s.id === `tool-${toolCallId}` && subagentOf(s)?.id === agentId) : undefined);\n };\n\n /** A lane whose id a new sub-agent now carries: settled as it stands, written, and no longer reached by its id. */\n const retire = (run: Run, lane: Lane): void => {\n run.lanes.delete(lane.id);\n stepsEnded(run.messageId, lane.id);\n if (lane.status === 'running' || lane.status === 'waiting') {\n lane.status = 'stopped';\n settleLane(lane, true);\n lane.streaming = false;\n dispatchEnd(run, lane, 'stopped');\n }\n markDirty(run, lane, true);\n };\n\n const startAgent = (run: Run, e: Extract<AparteStreamRunEvent, { type: 'agent-start' }>, ctx: AparteRunEventContext): void => {\n const known = run.lanes.get(e.agentId);\n /*\n * A resumed sub-agent is re-announced on the call that opened it (AG-UI), or on none:\n * the same lane, working again. On ANOTHER call it is another sub-agent under a reused\n * id — a backend that mints ids per request names a resume's first one like the paused\n * run's — and taking it for the first one resumed wrote its name and its text on the\n * first one's line. The first one is over; the new one gets a line of its own.\n */\n const reused = known !== undefined && e.toolCallId !== undefined && e.toolCallId !== known.toolCallId;\n if (known && reused) retire(run, known);\n if (known && !reused) {\n known.status = 'running';\n delete known.result;\n delete known.error;\n if (e.name !== undefined) known.name = e.name;\n if (e.description !== undefined) known.description = e.description;\n known.streaming = true;\n announce(run, known, e.toolCallId);\n markDirty(run, known, true);\n return;\n }\n if (run.lanes.size >= MAX_LANES) return;\n\n const host = e.parentAgentId ? (run.lanes.get(e.parentAgentId) ?? null) : null;\n const segments = hostSegments(run, host);\n // What the host holds under this id is the retired one's, never this one's to adopt.\n const saved = reused ? undefined : savedAnchor(segments, e.agentId, e.toolCallId);\n const callKey = e.toolCallId ? hostKey(host, e.toolCallId) : '';\n const callId = e.toolCallId ? `tool-${e.toolCallId}` : '';\n const callTaken = callKey !== '' && (run.callAgents.has(callKey)\n || !!segments?.some((s) => s.id === callId && subagentOf(s) && subagentOf(s)!.id !== e.agentId));\n const onCall = saved ? saved.type === 'tool_call' : callKey !== '' && !callTaken;\n if (onCall) run.callAgents.set(callKey, e.agentId);\n\n const previous = saved ? subagentOf(saved) : undefined;\n const list = createSegmentList({ messageId: run.messageId, ...(previous ? { segments: previous.segments } : {}), config: ctx.config });\n const lane: Lane = {\n id: e.agentId,\n ...(e.name !== undefined ? { name: e.name } : previous?.name !== undefined ? { name: previous.name } : {}),\n ...(e.description !== undefined ? { description: e.description } : previous?.description !== undefined ? { description: previous.description } : {}),\n ...(e.parentAgentId !== undefined ? { parentId: e.parentAgentId } : {}),\n ...(e.toolCallId !== undefined ? { toolCallId: e.toolCallId } : {}),\n status: 'running',\n list,\n // Not observed: every observer heard these events from the reply's adapter already.\n emit: createStreamAdapter({ target: list, config: ctx.config, messageId: run.messageId, observe: false }),\n host,\n anchorId: onCall ? callId : saved ? saved.id : freeOwnId(segments, e.agentId),\n anchorKind: onCall ? 'call' : 'own',\n ready: true,\n streaming: true,\n asking: new Set(),\n holding: false,\n depth: host ? host.depth + 1 : 0,\n };\n run.lanes.set(lane.id, lane);\n list.onChange(() => {\n if (!run.closed) {\n run.dirty.add(lane);\n schedule(run);\n }\n });\n\n if (lane.anchorKind === 'call' && !saved && segments && !segments.some((s) => s.id === lane.anchorId)) {\n // Announced before its call was started: written once the call's row is there.\n lane.ready = false;\n const key = callKey;\n run.awaitingRow.set(key, [...(run.awaitingRow.get(key) ?? []), lane]);\n } else if (lane.anchorKind === 'own' && !saved && !run.closed) {\n const segment: AparteSubagentSegment = {\n id: lane.anchorId,\n type: SUBAGENT_SEGMENT_TYPE,\n subagent: snapshot(run, lane),\n isStreaming: true,\n };\n if (host) host.list.addSegment?.(segment);\n else run.target.addSegment?.(segment);\n }\n\n announce(run, lane, e.toolCallId);\n // What arrived for it before it was announced.\n const early = run.early.get(lane.id);\n if (early) {\n run.early.delete(lane.id);\n run.earlyCount -= early.length;\n for (const event of early) feed(run, lane, event);\n }\n markDirty(run, lane, true);\n };\n\n const announce = (run: Run, lane: Lane, toolCallId: string | undefined): void =>\n dispatchLifecycleEvent(run, 'aparte-subagent-start', {\n messageId: run.messageId,\n agentId: lane.id,\n ...(lane.name !== undefined ? { name: lane.name } : {}),\n ...(lane.description !== undefined ? { description: lane.description } : {}),\n ...(toolCallId !== undefined ? { toolCallId } : {}),\n ...(lane.parentId !== undefined ? { parentId: lane.parentId } : {}),\n });\n\n const endAgent = (run: Run, e: Extract<AparteStreamRunEvent, { type: 'agent-end' }>): void => {\n const lane = run.lanes.get(e.agentId);\n if (!lane) return;\n lane.status = e.status;\n if (e.result !== undefined) lane.result = e.result;\n if (e.error !== undefined) lane.error = e.error;\n // Waiting is not over: its text and its calls stay as they are, its segment streams on.\n if (e.status !== 'waiting') {\n stepsEnded(run.messageId, lane.id);\n settleLane(lane, false);\n lane.streaming = false;\n }\n dispatchEnd(run, lane, e.status);\n markDirty(run, lane, true);\n };\n\n /** One of the sub-agent's own events, into its lane — without its `agentId`, as a reply's. */\n const feed = (run: Run, lane: Lane, e: AparteStreamRunEvent): void => {\n const { agentId: _owner, ...event } = e as AparteStreamRunEvent & { agentId?: string };\n if ('toolCallId' in event && typeof event.toolCallId === 'string') {\n if (event.type === 'tool-awaiting-approval') lane.asking.add(event.toolCallId);\n else if (event.type !== 'tool-start') lane.asking.delete(event.toolCallId);\n }\n // Its step is said on its line, live, and kept out of its conversation: the line reads\n // it at the draw this event's write brings about.\n if (event.type === 'step-start') stepStarted(run.messageId, lane.id, event.name);\n else if (event.type === 'step-end') stepEnded(run.messageId, lane.id, event.name);\n const before = lane.list.segments.length;\n lane.emit(event as AparteStreamRunEvent);\n if (event.type === 'tool-start') callStarted(run, lane, event.toolCallId);\n const now = !COALESCED.has(event.type) || lane.list.segments.length !== before;\n markDirty(run, lane, now);\n };\n\n const observe = (event: AparteStreamRunEvent, ctx: AparteRunEventContext): void => {\n const agentId = (event as { agentId?: unknown }).agentId;\n const attributed = typeof agentId === 'string' || event.type === 'agent-start' || event.type === 'agent-end';\n let run = runs.get(ctx.messageId);\n if (run && run.target !== ctx.target) return;\n if (!run) {\n if (!attributed || over.has(ctx.messageId)) return;\n run = openRun(ctx);\n if (!run) return;\n }\n settleDueRows(run);\n\n if (!attributed) {\n switch (event.type) {\n case 'tool-start':\n callStarted(run, null, event.toolCallId);\n break;\n case 'run-suspended':\n for (const lane of run.lanes.values()) run.dirty.add(lane);\n flush(run);\n break;\n case 'run-done':\n case 'run-aborted':\n close(run);\n break;\n default:\n break;\n }\n return;\n }\n if (event.type === 'agent-start') {\n startAgent(run, event, ctx);\n return;\n }\n if (event.type === 'agent-end') {\n endAgent(run, event);\n return;\n }\n // A sub-agent never ends the run, nor its own lane's reply.\n if (event.type === 'run-start' || event.type === 'run-done' || event.type === 'run-aborted' || event.type === 'run-suspended') return;\n const lane = run.lanes.get(agentId as string);\n if (lane) {\n feed(run, lane, event);\n return;\n }\n // Not announced yet (a resume after a reload): held until it is.\n if (run.earlyCount >= MAX_EARLY) return;\n run.early.set(agentId as string, [...(run.early.get(agentId as string) ?? []), event]);\n run.earlyCount += 1;\n };\n\n return {\n observe,\n dispose: () => {\n for (const run of [...runs.values()]) forget(run);\n },\n };\n}\n","/**\n * A sub-agent's line opens its conversation elsewhere: what the line says (the Open button,\n * which one is shown now) and what pressing it dispatches.\n *\n * The line provider gives core an `open` for every sub-agent's line when the setup asks for\n * it; core draws the button and calls back with the row. The plugin then dispatches\n * `aparte-subagent-open` from the row, and the app (or `connectSubagentView`) decides where the\n * conversation goes. Which sub-agent is shown is kept here, by whoever shows it, so a line\n * drawn again — a reload, a row rebuilt — still says it is the one open.\n */\nimport type { AparteToolCallSegment } from '@aparte/core';\nimport type { AparteSubagent, AparteSubagentOpenEventDetail } from './types.js';\n\n/** The sub-agent each view shows now, by the view's wiring. */\nconst shown = new Map<object, string>();\n\nconst keyOf = (messageId: string, agentId: string): string => `${messageId}\\u0000${agentId}`;\n\n/** Whether some view shows this sub-agent now. */\nexport function isShown(messageId: string | undefined, agentId: string): boolean {\n if (!messageId || shown.size === 0) return false;\n const key = keyOf(messageId, agentId);\n for (const value of shown.values()) if (value === key) return true;\n return false;\n}\n\n/** `owner` shows this sub-agent now, or nothing (`null`). */\nexport function setShown(owner: object, at: { messageId: string; agentId: string } | null): void {\n if (at) shown.set(owner, keyOf(at.messageId, at.agentId));\n else shown.delete(owner);\n}\n\n/**\n * The row's Open button: core's, in its own line, or — a row with a detail — in the slot\n * beside its disclosure (never in a summary, never a nested row's).\n */\nexport const openButtonOf = (row: Element): HTMLElement | null =>\n row.querySelector<HTMLElement>(':scope > :is(.aparte-tool-line, .aparte-tool-open-slot) > .aparte-tool-open');\n\n/**\n * Mark a row as the one shown, or not: the two marks core writes from `open.current` when it\n * draws the row, written here on a row already drawn so it does not wait for its next draw.\n */\nexport function markRow(row: Element, on: boolean): void {\n const button = openButtonOf(row);\n if (!button) return;\n row.toggleAttribute('data-current', on);\n if (on) button.setAttribute('aria-current', 'true');\n else button.removeAttribute('aria-current');\n}\n\n/** Every row marked as shown under `root`, unmarked. */\nexport function unmarkAll(root: ParentNode): void {\n for (const row of root.querySelectorAll('.aparte-segment-tool-call[data-current]')) markRow(row, false);\n}\n\n/**\n * The chat the row is in: the `<aparte-chat>` around it, else the chat a standalone\n * `<aparte-subagent-view>` reads (its own sub-agents' lines).\n */\nfunction targetIdOf(row: Element): string | undefined {\n const chat = row.closest('aparte-chat');\n if (chat) return chat.id || undefined;\n const view = row.closest('aparte-subagent-view:not([data-inline])') as (Element & { chat?: { id?: unknown } | null }) | null;\n if (!view) return undefined;\n const id = view.getAttribute('for') || (typeof view.chat?.id === 'string' ? view.chat.id : '');\n return id || undefined;\n}\n\n/** Dispatch `aparte-subagent-open` from the row of `sub`, drawn for `segment`. */\nexport function dispatchOpen(row: HTMLElement, segment: AparteToolCallSegment, sub: AparteSubagent, standIn: boolean): void {\n const messageId = segment.messageId || row.closest('[message-id]')?.getAttribute('message-id') || '';\n if (!messageId) return;\n const targetId = targetIdOf(row);\n const name = sub.name?.trim();\n const toolCallId = standIn ? undefined : segment.toolCall?.id;\n const detail: AparteSubagentOpenEventDetail = {\n ...(targetId ? { targetId } : {}),\n messageId,\n agentId: sub.id,\n ...(name ? { name } : {}),\n ...(toolCallId ? { toolCallId } : {}),\n };\n row.dispatchEvent(new CustomEvent('aparte-subagent-open', { bubbles: true, composed: true, detail }));\n}\n","/**\n * How a sub-agent's conversation is drawn: core's own segment renderers, one row per\n * segment, patched in place.\n *\n * Not `<aparte-chat-bubble>`: a bubble is ONE message of a chat, and it draws the chrome of\n * one — a name and a time over the content, an avatar slot, the app's action bar\n * (`setBubbleActions` reaches every bubble: Retry and Edit on a sub-agent's text would\n * dispatch for a message that does not exist), the `‹1/2›` picker, the app's whole frame\n * (`setBubbleShellRenderer`), `role=\"article\"` named \"Message from Assistant\", and the\n * waiting dots. None of it can be switched off without changing core, and hiding it from a\n * stylesheet would out-specify core's recipes. What a conversation needs from the bubble is\n * its row loop alone — and that is the renderer contract: `render`, then `setup`; `update`\n * on a change (following the element when the renderer replaced its own); `relabel` on a\n * language switch; `cleanup` when the row goes. So this is that loop, and nothing else.\n *\n * A row is found by its segment's id and patched when its segment is a new object (a\n * segment list replaces the object it changes, and only that one), so a token costs the\n * one row it lands in. A row whose renderer is no longer the one in effect is drawn again —\n * for a tool call or an activity, the tool or activity renderer too, as the bubble does.\n */\nimport {\n getSegmentRenderer,\n installDefaultRenderersOnce,\n runWithConfig,\n type AparteActivitySegment,\n type AparteConfig,\n type AparteSegment,\n type AparteSegmentRenderer,\n type AparteToolCallSegment,\n} from '@aparte/core';\n\ninterface Row {\n el: HTMLElement;\n renderer: AparteSegmentRenderer | undefined;\n /** For a tool call or an activity, the tool or activity renderer in effect when it was drawn. */\n inner: object | null;\n segment: AparteSegment;\n}\n\n/**\n * The renderer core's row asks for a tool call (its tool renderer) or an activity (the one for\n * its type): when it changes, the row is drawn again, as the bubble draws its own again.\n */\nfunction innerRendererFor(segment: AparteSegment, config: AparteConfig): object | null {\n if (segment.type === 'activity') return config.getActivityRenderer((segment as AparteActivitySegment).activityType) ?? null;\n if (segment.type !== 'tool_call') return null;\n const name = (segment as AparteToolCallSegment).toolCall?.name;\n return name && !config.isToolHidden(name) ? config.getToolRenderer(name) ?? null : null;\n}\n\n/** The renderer for a type, core's built-ins installed the first time they are missing — as the bubble does. */\nfunction rendererFor(type: string, config: AparteConfig): AparteSegmentRenderer | undefined {\n const renderer = getSegmentRenderer(type, config);\n if (renderer) return renderer as AparteSegmentRenderer;\n installDefaultRenderersOnce(config);\n return getSegmentRenderer(type, config) as AparteSegmentRenderer | undefined;\n}\n\n/** A renderer's output as one element, stamped with its segment's id (the loop finds its rows by it). */\nfunction toElement(out: HTMLElement | string, segment: AparteSegment): HTMLElement | null {\n let el: HTMLElement | null;\n if (typeof out === 'string') {\n const tpl = document.createElement('template');\n tpl.innerHTML = out.trim();\n el = tpl.content.firstElementChild as HTMLElement | null;\n } else {\n el = out;\n }\n if (el && !el.hasAttribute('data-segment-id')) el.setAttribute('data-segment-id', segment.id);\n return el;\n}\n\n/** A segment no renderer claims: its `fallback` text, else nothing for the reader. */\nfunction fallbackOf(segment: AparteSegment): HTMLElement | null {\n const text = (segment as { fallback?: unknown }).fallback;\n if (typeof text !== 'string' || !text.trim()) return null;\n const el = document.createElement('div');\n el.className = 'aparte-segment aparte-segment-fallback';\n el.setAttribute('data-segment-id', segment.id);\n el.textContent = text;\n return el;\n}\n\n/**\n * A text or reasoning segment added while the sub-agent works is arriving, flag or no flag:\n * its `setup` writes it through the streaming renderer (the stream parser's text carries no\n * flag). The bubble tells `setup` the same thing for the same reason.\n */\nfunction drawnAs(segment: AparteSegment, live: boolean): AparteSegment {\n if (!live || (segment.type !== 'text' && segment.type !== 'thinking')) return segment;\n if (segment.isStreaming !== undefined) return segment;\n return { ...segment, isStreaming: true } as AparteSegment;\n}\n\n/** The rows of one conversation, inside `container`. */\nexport class LaneDrawing {\n private readonly rows = new Map<string, Row>();\n\n constructor(readonly container: HTMLElement) {}\n\n /** How many rows are drawn. */\n get size(): number {\n return this.rows.size;\n }\n\n /**\n * Draw `segments`, in order: a new segment gets a row, a changed one is patched, one that\n * left loses its row. `live`: the sub-agent still works, so what it adds is arriving.\n */\n sync(segments: readonly AparteSegment[], config: AparteConfig, live: boolean): void {\n const seen = new Set<string>();\n let previous: Element | null = null;\n for (const segment of segments) {\n if (!segment || typeof segment.id !== 'string' || seen.has(segment.id)) continue;\n seen.add(segment.id);\n const renderer = rendererFor(segment.type, config);\n let row = this.rows.get(segment.id);\n if (row && (row.renderer !== renderer || row.inner !== innerRendererFor(segment, config))) {\n this.release(segment.id, config);\n row.el.remove();\n row = undefined;\n }\n if (!row) row = this.draw(segment, renderer, config, live);\n else if (row.segment !== segment) this.patch(row, segment, config);\n if (!row) continue;\n const expected: ChildNode | null = previous ? previous.nextSibling : this.container.firstChild;\n if (row.el !== expected) this.container.insertBefore(row.el, expected);\n previous = row.el;\n }\n for (const [id, row] of [...this.rows]) {\n if (seen.has(id)) continue;\n this.release(id, config);\n row.el.remove();\n }\n }\n\n /** Every row re-reads what it takes from the config (a language switch). */\n relabel(config: AparteConfig): void {\n for (const row of this.rows.values()) {\n const relabel = row.renderer?.relabel;\n if (!relabel) continue;\n runWithConfig(config, () => relabel.call(row.renderer, row.el, row.segment));\n }\n }\n\n /** Every row goes: each renderer cleans up what it drew. */\n clear(config: AparteConfig): void {\n for (const [id, row] of [...this.rows]) {\n this.release(id, config);\n row.el.remove();\n }\n }\n\n private draw(segment: AparteSegment, renderer: AparteSegmentRenderer | undefined, config: AparteConfig, live: boolean): Row | undefined {\n const el = renderer\n ? toElement(runWithConfig(config, () => renderer.render(segment)), segment)\n : fallbackOf(segment);\n if (!el) return undefined;\n const row: Row = { el, renderer, inner: innerRendererFor(segment, config), segment };\n // Recorded before `setup`: a setup that throws still leaves a row that is cleaned up.\n this.rows.set(segment.id, row);\n if (renderer?.setup) {\n const as = drawnAs(segment, live);\n runWithConfig(config, () => renderer.setup!(el, as));\n }\n return row;\n }\n\n private patch(row: Row, segment: AparteSegment, config: AparteConfig): void {\n const renderer = row.renderer;\n row.segment = segment;\n if (!renderer) {\n const next = fallbackOf(segment);\n if (next) { row.el.replaceWith(next); row.el = next; }\n return;\n }\n if (renderer.update) {\n const before = row.el;\n const next = before.nextSibling;\n runWithConfig(config, () => renderer.update!(before, segment));\n // A renderer may replace its own element (the tool row does when its shape\n // changes), cleaning up the one it replaced: follow the one it left — by its id, or\n // where the old one stood when the id was not carried over. Kept on the old one, the\n // loop put it back beside its replacement: the row was shown twice, stale first.\n if (before.parentNode !== this.container) {\n const now = this.childOf(segment.id) ?? this.inPlaceOf(next, segment.id);\n if (now) row.el = now;\n }\n return;\n }\n // No `update`: drawn again, as the bubble does.\n const next = toElement(runWithConfig(config, () => renderer.render(segment)), segment);\n if (!next) return;\n this.cleanup(row, config);\n row.el.replaceWith(next);\n row.el = next;\n if (renderer.setup) runWithConfig(config, () => renderer.setup!(next, segment));\n }\n\n /** The row for `id` among the container's own children — never a decoy in a row's prose. */\n private childOf(id: string): HTMLElement | null {\n for (const child of this.container.children) {\n if (child.getAttribute('data-segment-id') === id) return child as HTMLElement;\n }\n return null;\n }\n\n /**\n * The element standing where a row stood (before `next`) when it is no row's: what a\n * renderer put in place of its own without the id (`outerHTML`, `replaceWith`), stamped so\n * the loop finds it. A renderer that took its element away left another row there, or\n * nothing: the row keeps its element, and the loop puts it back.\n */\n private inPlaceOf(next: ChildNode | null, id: string): HTMLElement | null {\n const there = next ? next.previousSibling : this.container.lastChild;\n if (there?.nodeType !== Node.ELEMENT_NODE || (there as Element).hasAttribute('data-segment-id')) return null;\n (there as HTMLElement).setAttribute('data-segment-id', id);\n return there as HTMLElement;\n }\n\n private release(id: string, config: AparteConfig): void {\n const row = this.rows.get(id);\n if (!row) return;\n this.rows.delete(id);\n this.cleanup(row, config);\n }\n\n private cleanup(row: Row, config: AparteConfig): void {\n const cleanup = row.renderer?.cleanup;\n if (!cleanup) return;\n try {\n runWithConfig(config, () => cleanup.call(row.renderer, row.el, row.segment));\n } catch (err) {\n console.error('[aparte] a segment renderer\\'s cleanup threw', err);\n }\n }\n}\n","export default \"/*\\n * @aparte/plugin-subagents — a sub-agent's conversation.\\n *\\n * Only what is the plugin's own. The rows inside are core's (text, reasoning, tool rows,\\n * a nested sub-agent's line) and wear core's sheets; under a line, the transcript sits in\\n * core's tool detail, which already draws the rule and the indent a disclosure has. So\\n * this sheet draws the task line, the spacing of the rows, and — for the standalone view\\n * only — the same quiet rule down the leading edge, since nothing of core's is around it.\\n *\\n * Logical properties throughout, so a right-to-left locale puts the rule on its own\\n * leading edge. No colour of its own: core's tokens. Nothing moves, so there is no motion\\n * to reduce.\\n */\\naparte-subagent-view {\\n display: block;\\n min-inline-size: 0;\\n}\\n\\n/* Standalone (a canvas, a pane, a dialog): outside any message, so the conversation's\\n type is set here, as core's segment container sets it in a reply. */\\naparte-subagent-view:not([data-inline]) {\\n font-size: var(--aparte-content-font-size);\\n line-height: var(--aparte-content-line-height);\\n color: var(--aparte-content-color);\\n font-family: var(--aparte-font-family);\\n}\\n\\n/* Nothing to show (an unknown sub-agent, or one not started yet): nothing drawn. */\\naparte-subagent-view[data-empty] {\\n display: none;\\n}\\n\\n/* A closable view (a pane of its own): the sub-agent's name, and Close at the far end. The\\n name takes the focus when the pane opens, so it shows a ring only to the keyboard. */\\n.aparte-subagent-head {\\n display: flex;\\n align-items: center;\\n gap: var(--aparte-space-3);\\n margin-block-end: var(--aparte-space-3);\\n}\\n\\n.aparte-subagent-head[hidden] {\\n display: none;\\n}\\n\\n.aparte-subagent-name {\\n flex: 1 1 auto;\\n min-inline-size: 0;\\n margin: 0;\\n overflow: hidden;\\n font-size: var(--aparte-font-size-md);\\n font-weight: var(--aparte-font-weight-semibold);\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n}\\n\\n.aparte-subagent-name:focus {\\n outline: none;\\n}\\n\\n.aparte-subagent-name:focus-visible {\\n outline: var(--aparte-focus-outline-width) solid var(--aparte-border-focus);\\n}\\n\\n.aparte-subagent-close {\\n flex: none;\\n}\\n\\n.aparte-subagent-task {\\n margin: 0 0 var(--aparte-space-3);\\n color: var(--aparte-text-muted);\\n font-size: var(--aparte-font-size-sm);\\n}\\n\\n.aparte-subagent-transcript {\\n display: flex;\\n flex-direction: column;\\n gap: var(--aparte-space-4);\\n min-inline-size: 0;\\n}\\n\\n.aparte-subagent-transcript:empty {\\n display: none;\\n}\\n\\naparte-subagent-view:not([data-inline]) > .aparte-subagent-transcript {\\n padding-inline-start: var(--aparte-subagent-indent, var(--aparte-space-6));\\n border-inline-start: var(--aparte-border-width) solid var(--aparte-border);\\n}\\n\"","/**\n * The plugin's one stylesheet, put on the page once: by the `subagent` segment renderer's\n * `getStyles()` (core injects it with the other renderers' sheets) or by\n * `<aparte-subagent-view>` as it connects, whichever comes first.\n */\nimport styles from './subagents.css?raw';\n\nconst STYLE_ID = 'aparte-subagent-styles';\n/** A selector only this sheet holds: how a copy already on the page is recognised. */\nconst MARK = '.aparte-subagent-transcript';\n\n/** The `<style>` found holding the sheet, so a view connecting later does not search again. */\nlet holder: Element | null = null;\n\nfunction onPage(): boolean {\n if (holder?.isConnected) return true;\n holder = document.getElementById(STYLE_ID)\n ?? [...document.querySelectorAll('style')].find((sheet) => sheet.textContent?.includes(MARK))\n ?? null;\n return holder !== null;\n}\n\n/** What the segment renderer hands core: the sheet, unless the element already put it on the page. */\nexport function rendererStyles(): string {\n return typeof document !== 'undefined' && document.getElementById(STYLE_ID) ? '' : styles;\n}\n\n/** Put the sheet on the page, unless it is there already. */\nexport function ensureStyles(): void {\n if (typeof document === 'undefined' || onPage()) return;\n const style = document.createElement('style');\n style.id = STYLE_ID;\n style.textContent = styles;\n document.head.appendChild(style);\n holder = style;\n}\n","/**\n * The words a sub-agent's line says, in the chat's language.\n *\n * Core's locale is a closed list of what CORE draws, so this plugin reads its own keys off\n * `getLocale()` and defaults them here: the app's locale first, then this table for the\n * chat's language (the ten `@aparte/locales` ships), then English. The state words (\"Done\",\n * \"Failed\", \"Stopped\") are core's own, read with `t()`: the line says a state in the words\n * the row's badge uses.\n *\n * aparteGlobalConfig.extendLocale({ subagentsTools: 'one:{n} outil|other:{n} outils' });\n *\n * A count is a set of plural forms, each named by its `Intl.PluralRules` category, as core's\n * `turnTools` is: Russian needs `few` and `many`, Japanese, Korean and Chinese one form.\n */\nimport { pluralize, type AparteConfig } from '@aparte/core';\n\ntype Language = 'fr' | 'de' | 'es' | 'it' | 'ja' | 'ko' | 'pt' | 'ru' | 'zh';\ntype Word = { en: string } & Partial<Record<Language, string>>;\n\nexport const WORDS = {\n /** How many tool calls a sub-agent made, on its line: \"3 tools\". */\n subagentsTools: {\n en: 'one:{n} tool|other:{n} tools',\n fr: 'one:{n} outil|other:{n} outils',\n de: 'one:{n} Tool|other:{n} Tools',\n es: 'one:{n} herramienta|other:{n} herramientas',\n it: 'one:{n} strumento|other:{n} strumenti',\n ja: 'other:{n} 個のツール',\n ko: 'other:도구 {n}개',\n pt: 'one:{n} ferramenta|other:{n} ferramentas',\n ru: 'one:{n} инструмент|few:{n} инструмента|many:{n} инструментов|other:{n} инструмента',\n zh: 'other:{n} 个工具',\n },\n /** What a sub-agent's second line says before its first call. */\n subagentsStarting: {\n en: 'Starting…', fr: 'Démarrage…', de: 'Wird gestartet…', es: 'Iniciando…', it: 'Avvio…',\n ja: '開始しています…', ko: '시작하는 중…', pt: 'Iniciando…', ru: 'Запуск…', zh: '正在启动…',\n },\n /** The name of a sub-agent that was given none, when no call names its line either. */\n subagentsUnnamed: {\n en: 'Sub-agent', fr: 'Sous-agent', de: 'Subagent', es: 'Subagente', it: 'Sottoagente',\n ja: 'サブエージェント', ko: '하위 에이전트', pt: 'Subagente', ru: 'Субагент', zh: '子智能体',\n },\n /** The Open button on a sub-agent's line (`setupSubagents({ open: 'event' })`): its name and tooltip. */\n subagentsOpen: {\n en: 'Open {name}', fr: 'Ouvrir {name}', de: '{name} öffnen', es: 'Abrir {name}', it: 'Apri {name}',\n ja: '{name} を開く', ko: '{name} 열기', pt: 'Abrir {name}', ru: 'Открыть: {name}', zh: '打开 {name}',\n },\n /** The Close button of a `<aparte-subagent-view closable>`. */\n subagentsClose: {\n en: 'Close', fr: 'Fermer', de: 'Schließen', es: 'Cerrar', it: 'Chiudi',\n ja: '閉じる', ko: '닫기', pt: 'Fechar', ru: 'Закрыть', zh: '关闭',\n },\n} satisfies Record<string, Word>;\n\nexport type WordKey = keyof typeof WORDS;\n\n/** The language part of the locale's tag: `pt-BR` → `pt`, `zh-CN` → `zh`, none → `en`. */\nfunction languageOf(config: AparteConfig): string {\n const tag = config.getLocale().tag;\n return typeof tag === 'string' && tag ? tag.split('-')[0]!.toLowerCase() : 'en';\n}\n\n/** The word for `key`: the app's locale, else this table in the chat's language, else English. */\nexport function word(config: AparteConfig, key: WordKey): string {\n const fromApp = (config.getLocale() as Record<string, unknown>)[key];\n const table: Word = WORDS[key];\n return (typeof fromApp === 'string' && fromApp) || table[languageOf(config) as Language] || table.en;\n}\n\n/** \"3 tools\", in the chat's language and its plural rules. */\nexport function toolCount(config: AparteConfig, n: number): string {\n const tag = config.getLocale().tag;\n return pluralize(word(config, 'subagentsTools'), n, typeof tag === 'string' && tag ? tag : undefined);\n}\n","/**\n * `<aparte-subagent-view>` — a sub-agent's conversation, wherever the app puts it.\n *\n * The line in the reply says what a sub-agent is doing; this element shows what it said and\n * did — its text, its reasoning, its tool rows, its own sub-agents as lines — drawn by the\n * same renderers as the reply. It is also what `subagentTranscript` puts under the line, so\n * there is one drawing of a conversation, not two.\n *\n * Standalone, it reads the sub-agent from the chat: live, from each write of the plugin's\n * lane (once a frame while it streams); saved, from the segment that stands for it in the\n * reply, searched through the lanes of its parents too. A saved conversation is adopted\n * before it is drawn (`createSegmentList`), so nothing in it reads as still arriving.\n *\n * Light DOM, like core. It writes its own two parts as children and decides nothing about\n * the layout.\n */\nimport {\n createSegmentList,\n deferHydrationOf,\n onRenderersChange,\n resolveConfig,\n runWithConfig,\n subscribeConfigChange,\n type AparteConfig,\n type AparteMessage,\n type AparteSegment,\n} from '@aparte/core';\nimport { LaneDrawing } from './drawing.js';\nimport { lastLaneWrite, watchLaneWrites, type LaneWrite } from './lanes.js';\nimport { subagentOf, subagentStatus } from './status.js';\nimport { ensureStyles } from './styles.js';\nimport { word } from './words.js';\n\n/** Where the view reads the conversation: a chat element, its viewport, or anything with `getMessages()`. */\nexport type SubagentViewSource = (Element | object) & {\n getMessages?: () => AparteMessage[];\n getMessage?: (id: string) => AparteMessage | undefined;\n};\n\n/** What the chat says that may change what a standalone view shows. All bubble out of the chat. */\nconst CONVERSATION_EVENTS = [\n 'aparte-subagent-start', 'aparte-subagent-end', 'aparte-segment-update', 'aparte-message-done',\n 'aparte-message-aborted', 'aparte-message-error', 'aparte-message-paused', 'aparte-path-changed',\n 'aparte-reset-done', 'aparte-conversation-loaded',\n] as const;\n\n/** How deep the search for a sub-agent of a sub-agent goes. */\nconst MAX_DEPTH = 16;\n\n/** A saved conversation, adopted once per list: settled, so nothing in it reads as arriving. */\nconst adopted = new WeakMap<readonly AparteSegment[], readonly AparteSegment[]>();\n\n/**\n * The conversation of the sub-agent `anchor` stands for, as it is drawn: as it is while the\n * sub-agent works, adopted once it is over (a reload, a Stop, its end) — every text settled,\n * every call still open read as stopped.\n */\nexport function laneOf(anchor: AparteSegment): { segments: readonly AparteSegment[]; live: boolean } {\n const sub = subagentOf(anchor);\n if (!sub) return { segments: [], live: false };\n const status = subagentStatus(anchor);\n if (status === 'running' || status === 'waiting') return { segments: sub.segments, live: true };\n let settled = adopted.get(sub.segments);\n if (!settled) {\n settled = createSegmentList({ messageId: anchor.messageId ?? '', segments: sub.segments }).segments;\n adopted.set(sub.segments, settled);\n }\n return { segments: settled, live: false };\n}\n\n/** The segment that stands for `agentId` among `segments`, or in the lanes of the sub-agents there. */\nexport function findSubagent(segments: readonly AparteSegment[], agentId: string, depth = 0): AparteSegment | undefined {\n for (const segment of segments) {\n const sub = subagentOf(segment);\n if (!sub) continue;\n if (sub.id === agentId) return segment;\n if (depth >= MAX_DEPTH) continue;\n const found = findSubagent(laneOf(segment).segments, agentId, depth + 1);\n if (found) return found;\n }\n return undefined;\n}\n\n/** A view drawn under a line: the anchor it was handed, and the config of the row it is in. */\ninterface Fed {\n anchor: AparteSegment;\n config: AparteConfig;\n onRelease?: () => void;\n}\nconst fed = new WeakMap<object, Fed>();\n\n/** Importable where there is no DOM: the class then extends nothing and is never defined. */\nconst ElementBase = (typeof HTMLElement === 'undefined' ? class {} : HTMLElement) as typeof HTMLElement;\n\n/**\n * A sub-agent's conversation — its text, its reasoning, its tool rows, its own sub-agents as\n * lines — where the app places it: a canvas, a pane of `<aparte-split>`, a dialog. It follows\n * the sub-agent live while it works and shows the saved conversation after a reload. Name the\n * chat with `for` (or the `chat` property), the reply with `message-id`, the sub-agent with\n * `agent-id`: `aparte-subagent-start` gives all three as its sub-agents start.\n *\n * It is the same element `subagentTranscript` puts under a sub-agent's line.\n *\n * @element aparte-subagent-view\n *\n * @attr {string} for - The `id` of the chat: `<aparte-chat>`, its viewport, or any element with `getMessages()`. Or set the `chat` property.\n * @attr {string} message-id - The reply the sub-agent worked for (`aparte-subagent-start`'s `messageId`).\n * @attr {string} agent-id - Which sub-agent (`aparte-subagent-start`'s `agentId`).\n * @attr {boolean} data-empty - Written BY the element while there is nothing to show (an unknown sub-agent, or one not started yet): it then draws nothing. Read-only; style or fold your layout against it.\n * @attr {boolean} data-inline - Written BY the element when it is a line's detail rather than a view of its own. Read-only.\n * @attr {boolean} closable - A pane of its own: the sub-agent's name and a Close button above its conversation, and Escape inside it closes too. Both only say so (`aparte-subagent-view-close`): the app, or `connectSubagentView`, folds the pane.\n *\n * @fires {CustomEvent} aparte-subagent-view-close - The Close button, or Escape inside a `closable` view. The view does not hide itself: the app owns the layout. Bubbles.\n *\n * @cssprop [--aparte-subagent-indent=var(--aparte-space-6)] - The space between the rule down the leading edge and the conversation, in a standalone view.\n *\n * @example The chat in one pane, a sub-agent's conversation in the other\n * ```html\n * <aparte-split primary=\"start\" position=\"55\" single>\n * <aparte-chat id=\"chat\">…</aparte-chat>\n * <aparte-subagent-view for=\"chat\"></aparte-subagent-view>\n * </aparte-split>\n * <script type=\"module\">\n * import { setupSubagents } from '@aparte/plugin-subagents';\n *\n * setupSubagents();\n * const view = document.querySelector('aparte-subagent-view');\n * // Show the latest sub-agent to start, as it works.\n * document.getElementById('chat').addEventListener('aparte-subagent-start', (e) => {\n * view.setAttribute('message-id', e.detail.messageId);\n * view.setAttribute('agent-id', e.detail.agentId);\n * });\n * </script>\n * ```\n */\nexport class AparteSubagentView extends ElementBase {\n static get observedAttributes(): string[] { return ['for', 'message-id', 'agent-id', 'closable']; }\n\n private _chat: SubagentViewSource | null = null;\n private _task: HTMLElement | null = null;\n /** A closable view's head: the sub-agent's name and Close. */\n private _head: HTMLElement | null = null;\n private _name: HTMLElement | null = null;\n private _close: HTMLButtonElement | null = null;\n private _drawing: LaneDrawing | null = null;\n /** The config the rows were drawn with, and the segment they were drawn from. */\n private _config: AparteConfig | null = null;\n private _anchor: AparteSegment | null = null;\n private _listening: EventTarget | null = null;\n private _stopConfig: (() => void) | null = null;\n private _stopWatching: (() => void) | null = null;\n private _stopRenderers: (() => void) | null = null;\n private _queued = false;\n private _releaseQueued = false;\n private _warned = '';\n\n private readonly _onConversation = (): void => this._schedule();\n private readonly _onKeydown = (event: KeyboardEvent): void => {\n if (event.key !== 'Escape' || event.defaultPrevented || !this._closable()) return;\n event.preventDefault();\n this._emitClose();\n };\n /** A renderer registered or taken off on the config the rows were drawn with: the rows it changes are drawn again. */\n private readonly _onRenderers = (config: AparteConfig): void => {\n if (config === this._config) this.refresh();\n };\n private readonly _onWrite = (write: LaneWrite): void => {\n if (fed.has(this) || !this.isConnected) return;\n if (write.messageId !== this.getAttribute('message-id') || write.agentId !== this.getAttribute('agent-id')) return;\n if (!this._matches(write)) return;\n this._draw(write.anchor, this._sourceConfig());\n };\n\n // ── What the app sets ──────────────────────────────────────────────────\n\n /** The chat, when it has no `id` for the `for` attribute: an element, or anything with `getMessages()`. */\n get chat(): SubagentViewSource | null { return this._chat; }\n set chat(value: SubagentViewSource | null) {\n this._chat = value;\n if (!this.isConnected) return;\n this._listen();\n this.refresh();\n }\n\n /** Put the focus on the sub-agent's name, in a `closable` view: where a pane that just opened starts. */\n focusTitle(): void {\n if (this._name && !this._head?.hidden) this._name.focus();\n }\n\n /** Read the sub-agent again and draw it: what the element does on every change it hears. */\n refresh(): void {\n const feed = fed.get(this);\n if (!feed && !this.isConnected) return;\n const anchor = feed ? feed.anchor : this._find();\n // A chat that cannot be read keeps what its last write showed.\n this._draw(anchor === null ? this._anchor : anchor, feed ? feed.config : this._sourceConfig());\n }\n\n // ── Lifecycle ──────────────────────────────────────────────────────────\n\n connectedCallback(): void {\n ensureStyles();\n this._build();\n this.addEventListener('keydown', this._onKeydown);\n this._stopRenderers ??= onRenderersChange(this._onRenderers);\n if (!fed.has(this)) {\n this._listen();\n this._stopWatching ??= watchLaneWrites(this._onWrite);\n } else {\n this._stopConfig?.();\n this._stopConfig = subscribeConfigChange(this, () => this._onConfigChange());\n }\n this.refresh();\n }\n\n disconnectedCallback(): void {\n this.removeEventListener('keydown', this._onKeydown);\n this._unlisten();\n this._stopWatching?.();\n this._stopWatching = null;\n this._stopConfig?.();\n this._stopConfig = null;\n this._stopRenderers?.();\n this._stopRenderers = null;\n // Gone for good, or only moved (a row rebuilt around it, a fold taking its row)?\n // Decided once the move is over.\n if (this._releaseQueued) return;\n this._releaseQueued = true;\n queueMicrotask(() => {\n this._releaseQueued = false;\n if (this.isConnected) return;\n this._release();\n });\n }\n\n attributeChangedCallback(_name: string, previous: string | null, value: string | null): void {\n if (previous === value || !this.isConnected || fed.has(this)) return;\n if (_name === 'for') this._listen();\n this.refresh();\n // Shown or taken away, its words in place: a closable view's head.\n if (_name === 'closable' && this._config) this._relabelHead(this._config);\n }\n\n // ── Reading the conversation ───────────────────────────────────────────\n\n private _source(): SubagentViewSource | null {\n if (this._chat) return this._chat;\n const id = this.getAttribute('for');\n return id ? this.ownerDocument.getElementById(id) : null;\n }\n\n private _sourceConfig(): AparteConfig {\n const source = this._source();\n return resolveConfig(typeof Element !== 'undefined' && source instanceof Element ? source : this);\n }\n\n /** A write from this view's chat: the run's target is the chat, inside it, or named by its id. */\n private _matches(write: LaneWrite): boolean {\n const source = this._source();\n if (!source) return false;\n if (source === write.target) return true;\n if (typeof Node !== 'undefined' && source instanceof Node && write.target instanceof Node\n && (source.contains(write.target) || write.target.contains(source))) return true;\n return write.targetId !== undefined && (source as { id?: unknown }).id === write.targetId;\n }\n\n /**\n * The segment that stands for the sub-agent in the chat's reply; `undefined` when there is\n * none, `null` when the chat cannot be read at all.\n */\n private _find(): AparteSegment | undefined | null {\n const messageId = this.getAttribute('message-id');\n const agentId = this.getAttribute('agent-id');\n const source = this._source();\n if (!messageId || !agentId || !source) return undefined;\n type Reader = SubagentViewSource & { querySelector?: (selector: string) => SubagentViewSource | null };\n const own = source as Reader;\n const reader = typeof own.getMessage === 'function' || typeof own.getMessages === 'function'\n ? own\n : own.querySelector?.('aparte-chat-viewport') ?? null;\n if (!reader || (typeof reader.getMessage !== 'function' && typeof reader.getMessages !== 'function')) return null;\n let message: AparteMessage | undefined;\n try {\n message = reader.getMessage?.(messageId) ?? reader.getMessages?.()?.find((m) => m.id === messageId);\n } catch {\n return null;\n }\n // A run still going may have written the lane before the chat a framework mirrors\n // holds it: the last write, then, as the next one would bring it.\n const live = lastLaneWrite(messageId, agentId);\n const anchor = (message ? findSubagent(message.segments ?? [], agentId) : undefined)\n ?? (live && this._matches(live) ? live.anchor : undefined);\n // Said once, for the developer: a finished reply that holds no such sub-agent. A reply\n // still being written may hold it soon, and a missing reply may arrive.\n const key = `${messageId}\\u0000${agentId}`;\n if (message && !anchor && !message.isStreaming && message.status !== 'pending' && message.status !== 'streaming' && this._warned !== key) {\n this._warned = key;\n console.warn(`[aparte] <aparte-subagent-view>: the reply \"${messageId}\" holds no sub-agent \"${agentId}\".`);\n }\n return anchor;\n }\n\n private _listen(): void {\n const source = this._source();\n const target = source && typeof (source as EventTarget).addEventListener === 'function' ? source as EventTarget : null;\n if (target !== this._listening) {\n this._unlisten();\n if (target) for (const name of CONVERSATION_EVENTS) target.addEventListener(name, this._onConversation);\n this._listening = target;\n }\n // The chat's config, not this element's: a language switch on the chat's own config\n // names the chat's config, which this element would not resolve to outside it.\n this._stopConfig?.();\n const holder = typeof Element !== 'undefined' && source instanceof Element ? source : this;\n this._stopConfig = subscribeConfigChange(holder, () => this._onConfigChange());\n }\n\n private _unlisten(): void {\n if (this._listening) for (const name of CONVERSATION_EVENTS) this._listening.removeEventListener(name, this._onConversation);\n this._listening = null;\n }\n\n /** Folds a burst of events (a whole run's end) into one read. */\n private _schedule(): void {\n if (this._queued) return;\n this._queued = true;\n queueMicrotask(() => {\n this._queued = false;\n this.refresh();\n });\n }\n\n private _onConfigChange(): void {\n this.refresh();\n if (this._config) {\n this._drawing?.relabel(this._config);\n this._relabelHead(this._config);\n }\n }\n\n /** A pane of its own, never a line's detail. */\n private _closable(): boolean {\n return this.hasAttribute('closable') && !fed.has(this);\n }\n\n private _emitClose(): void {\n this.dispatchEvent(new CustomEvent('aparte-subagent-view-close', { bubbles: true, composed: true }));\n }\n\n /** The head's words, in the chat's language: the name, and Close. */\n private _relabelHead(config: AparteConfig): void {\n if (!this._head) return;\n const closable = this._closable();\n this._head.hidden = !closable;\n // Nothing in a head that is not shown: the view's text is its conversation's.\n if (!closable) {\n this._name!.textContent = '';\n return;\n }\n const name = (this._anchor ? subagentOf(this._anchor)?.name?.trim() : '') || word(config, 'subagentsUnnamed');\n if (this._name!.textContent !== name) this._name!.textContent = name;\n const close = word(config, 'subagentsClose');\n if (this._close!.getAttribute('aria-label') !== close) {\n this._close!.setAttribute('aria-label', close);\n this._close!.title = close;\n // The chat's icon provider: static SVG the app or core supplied.\n this._close!.innerHTML = config.getIcon('close');\n }\n }\n\n // ── Drawing ────────────────────────────────────────────────────────────\n\n private _build(): void {\n if (this._drawing) {\n // Moved, or put back after a release: its parts go back first.\n if (this._task!.parentNode !== this) this.prepend(this._task!);\n if (this._head!.parentNode !== this) this.prepend(this._head!);\n if (this._drawing.container.parentNode !== this) this.append(this._drawing.container);\n return;\n }\n // The head of a closable view: hidden until the attribute says so.\n const head = this.ownerDocument.createElement('div');\n head.className = 'aparte-subagent-head';\n head.hidden = true;\n const name = this.ownerDocument.createElement('h2');\n name.className = 'aparte-subagent-name';\n name.tabIndex = -1;\n const close = this.ownerDocument.createElement('button');\n close.type = 'button';\n close.className = 'aparte-btn aparte-btn--icon aparte-btn--sm aparte-subagent-close';\n close.addEventListener('click', () => this._emitClose());\n head.append(name, close);\n this._head = head;\n this._name = name;\n this._close = close;\n const task = this.ownerDocument.createElement('p');\n task.className = 'aparte-subagent-task';\n task.hidden = true;\n const list = this.ownerDocument.createElement('div');\n list.className = 'aparte-subagent-transcript';\n this.append(head, task, list);\n this._task = task;\n this._drawing = new LaneDrawing(list);\n }\n\n /** Draw `anchor`'s conversation with `config`. */\n private _draw(anchor: AparteSegment | null | undefined, config: AparteConfig): void {\n this._build();\n const drawing = this._drawing!;\n // Another config draws with other renderers: every row anew.\n if (this._config && this._config !== config) drawing.clear(this._config);\n this._config = config;\n this._anchor = anchor ?? null;\n this.toggleAttribute('data-inline', fed.has(this));\n this.toggleAttribute('data-empty', !anchor);\n const task = (anchor ? subagentOf(anchor)?.description?.trim() : '') ?? '';\n if (this._task!.textContent !== task) this._task!.textContent = task;\n this._task!.hidden = !task;\n this._relabelHead(config);\n const lane = anchor ? laneOf(anchor) : { segments: [], live: false };\n runWithConfig(config, () => drawing.sync(lane.segments, config, lane.live));\n }\n\n /** Out of the page for good: every row's renderer cleans up, and the drawing goes. */\n private _release(): void {\n if (this._config) this._drawing?.clear(this._config);\n const feed = fed.get(this);\n if (feed) {\n fed.delete(this);\n feed.onRelease?.();\n }\n }\n}\n\n/**\n * Draw `anchor` in `view`, as a line's detail: the view then reads nothing of its own and\n * shows what each call hands it. `onRelease` runs when the view leaves the page for good.\n */\nexport function feedView(view: AparteSubagentView, anchor: AparteSegment, config: AparteConfig, onRelease?: () => void): void {\n const release = onRelease ?? fed.get(view)?.onRelease;\n fed.set(view, { anchor, config, ...(release ? { onRelease: release } : {}) });\n (view as unknown as { _draw(anchor: AparteSegment, config: AparteConfig): void })._draw(anchor, config);\n}\n\nif (typeof customElements !== 'undefined' && !customElements.get('aparte-subagent-view')) {\n // Before defining, like core's own elements: in a server-rendered page the tag waits for\n // the wrapper's release instead of drawing into the DOM the framework hydrates.\n deferHydrationOf(AparteSubagentView);\n customElements.define('aparte-subagent-view', AparteSubagentView);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'aparte-subagent-view': AparteSubagentView;\n }\n interface HTMLElementEventMap {\n 'aparte-subagent-view-close': CustomEvent<void>;\n }\n}\n","/**\n * `subagentTranscript` — a sub-agent's conversation under its line.\n *\n * A tool display's `details`: core calls it when the row is drawn and on every update of the\n * call, and leaves in place an element it already holds (so the conversation is never\n * serialised or rewritten per token). It returns the SAME `<aparte-subagent-view>` for one\n * sub-agent of one reply on every call, and hands it the call as it is now: the view patches\n * the rows that changed and nothing else.\n */\nimport { contextConfig, type AparteConfig, type AparteToolDetails } from '@aparte/core';\nimport { AparteSubagentView, feedView } from './aparte-subagent-view.js';\nimport { subagentOf } from './status.js';\n\n/** Views kept for the lines on the page, per config, by reply, segment and sub-agent. */\nconst views = new WeakMap<AparteConfig, Map<string, AparteSubagentView>>();\n/** Past this, the oldest views no row holds are forgotten (rows drawn but never put on the page). */\nconst MAX_VIEWS = 500;\n\n/**\n * A sub-agent's conversation, for a tool display's `details`: its task, then its text, its\n * reasoning and its own tool rows, drawn by the same renderers as the reply, kept up to date\n * while it works. `''` for a call that opened no sub-agent, and for one that has nothing to\n * show yet — no disclosure until there is.\n *\n * `setupSubagents({ details: 'transcript' })` puts it under every sub-agent's line; register\n * it yourself to put it under one tool's only.\n *\n * @example\n * import { aparteGlobalConfig } from '@aparte/core';\n * import { setupSubagents, subagentTranscript } from '@aparte/plugin-subagents';\n *\n * setupSubagents();\n * aparteGlobalConfig.registerToolDisplay('task', { details: subagentTranscript, open: true });\n */\nexport const subagentTranscript: AparteToolDetails = (segment) => {\n if (typeof document === 'undefined') return '';\n const sub = subagentOf(segment);\n if (!sub) return '';\n if (!sub.description?.trim() && sub.segments.length === 0) return '';\n const config = contextConfig();\n let byKey = views.get(config);\n if (!byKey) views.set(config, (byKey = new Map()));\n const key = `${segment.messageId ?? ''}\\u0000${segment.id}\\u0000${sub.id}`;\n let view = byKey.get(key);\n if (!view) {\n view = document.createElement('aparte-subagent-view') as AparteSubagentView;\n const held = view;\n const map = byKey;\n feedView(view, segment, config, () => { if (map.get(key) === held) map.delete(key); });\n map.set(key, view);\n if (map.size > MAX_VIEWS) {\n for (const [k, v] of map) {\n if (map.size <= MAX_VIEWS) break;\n if (!v.isConnected) map.delete(k);\n }\n }\n return view;\n }\n feedView(view, segment, config);\n return view;\n};\n","/**\n * A sub-agent's line: core's tool row, named by what ran it.\n *\n * The plugin gives core a tool-line provider (`setToolLineProvider`): for a call that carries\n * a sub-agent — the call that opened it, or the call the plugin's own segment stands in for —\n * it says the sub-agent's name and its task, and on a second line, from the sub-agent's start to\n * its end, what it is on (\"Starting…\", then its running call, else the step it announced, else\n * its latest call) and once it is over what it did\n * (\"3 tools · 12s\"). The second line is there the whole time, so the row keeps its height: one\n * that grew a line when the sub-agent began acting and lost it at its end moved every row under\n * it twice, and a count that grew beside the task moved the task. Core reads it AFTER the app's\n * `registerToolDisplay`, field by field, so the app's label, summary and details always win. It\n * is asked at every draw, update and relabel and stores nothing: the counts and the words follow\n * the reader's language.\n */\nimport {\n contextConfig,\n formatDuration,\n segmentTiming,\n type AparteConfig,\n type AparteSegment,\n type AparteToolCallSegment,\n type AparteToolLine,\n} from '@aparte/core';\nimport { statusOfCall, subagentOf, subagentStatus } from './status.js';\nimport { dispatchOpen, isShown } from './open.js';\nimport { currentStep } from './steps.js';\nimport { subagentTranscript } from './transcript.js';\nimport { toolCount, word } from './words.js';\nimport type { AparteSubagent, AparteSubagentStatus, SubagentsOptions } from './types.js';\n\n/** The calls the plugin's own segments hand to core's row: named by the agent, not by a tool. */\nconst standIns = new WeakSet<object>();\n\n/** Mark a call built to draw a `subagent` segment with core's row. */\nexport function markStandIn(segment: AparteToolCallSegment): AparteToolCallSegment {\n standIns.add(segment);\n return segment;\n}\n\nconst isOpenCall = (segment: AparteSegment): segment is AparteToolCallSegment =>\n segment.type === 'tool_call'\n && ['pending', 'awaiting-approval'].includes((segment as AparteToolCallSegment).status ?? 'pending');\n\n/** Plain text, trimmed; `''` for anything else or for a function that throws. */\nconst textOf = (read: () => unknown): string => {\n try {\n const value = read();\n return typeof value === 'string' ? value.trim() : '';\n } catch {\n return '';\n }\n};\n\n/**\n * A call of the sub-agent's as its own row names it: the app's label, else the name of the\n * sub-agent it opened, else its identifier; then what it targets, from the app's summary, else\n * that sub-agent's task.\n */\nfunction callLine(call: AparteToolCallSegment, config: AparteConfig): string {\n const name = call.toolCall?.name ?? '';\n const nested = subagentOf(call);\n const label = config.getToolDisplay(name)?.label;\n const shown = (label !== undefined ? textOf(() => (typeof label === 'function' ? label(call) : label)) : '')\n || nested?.name?.trim() || name;\n const summary = config.getToolSummary(name);\n const target = (summary ? textOf(() => summary(call)) : '') || nested?.description?.trim() || '';\n return [shown, target].filter(Boolean).join(' ');\n}\n\n/**\n * What it is doing now: the call running or waiting, as that call's row names it; else the\n * step it announced and is still on (\"Reading the parser\"); else its LATEST call, the last one\n * that finished. Only a call open at that instant used to count,\n * and with fast tools the line never said anything: the call was over before the next draw.\n * The caller asks only while the sub-agent runs or waits, so a finished call reads as the\n * step it is on until the next one starts (it is thinking or writing about that result).\n */\nfunction activityOf(sub: AparteSubagent, config: AparteConfig, step: string | undefined): string {\n let latest: AparteToolCallSegment | undefined;\n for (let i = sub.segments.length - 1; i >= 0; i -= 1) {\n const segment = sub.segments[i]!;\n if (segment.type !== 'tool_call') continue;\n if (isOpenCall(segment)) return callLine(segment, config);\n latest ??= segment as AparteToolCallSegment;\n }\n if (step) return step;\n return latest ? callLine(latest, config) : '';\n}\n\n/**\n * How long it worked: from when its line started to the last moment its conversation moved —\n * data saved with it, so a reload reads the same number.\n */\nfunction durationOf(anchor: AparteSegment, sub: AparteSubagent): number | undefined {\n const start = segmentTiming(anchor)?.startedAt;\n if (start === undefined) return undefined;\n let end: number | undefined;\n for (const segment of sub.segments) {\n const timing = segmentTiming(segment);\n const at = timing?.endedAt ?? timing?.startedAt;\n if (at !== undefined && (end === undefined || at > end)) end = at;\n }\n end ??= segmentTiming(anchor)?.endedAt;\n return end === undefined || end < start ? undefined : end - start;\n}\n\n/** A state in the words core's badge uses. */\nfunction stateWord(config: AparteConfig, status: AparteSubagentStatus): string {\n switch (status) {\n case 'running': return config.t('toolRunning');\n case 'waiting': return config.t('approvalWaiting');\n case 'done': return config.t('toolCompleted');\n case 'failed': return config.t('toolFailed');\n default: return config.t('toolStopped');\n }\n}\n\n/**\n * The provider: the line of every call that carries a sub-agent, `undefined` for any other\n * call (core's own line then).\n */\nexport function createLineProvider(options: SubagentsOptions = {}): (segment: AparteToolCallSegment) => AparteToolLine | undefined {\n return (segment) => {\n const sub = subagentOf(segment);\n if (!sub) return undefined;\n const config = contextConfig();\n const standIn = standIns.has(segment);\n const status = subagentStatus(segment);\n const live = status === 'running' || status === 'waiting';\n const line: AparteToolLine = {};\n\n const name = sub.name?.trim();\n if (name) line.label = name;\n else if (standIn) line.label = word(config, 'subagentsUnnamed');\n const task = sub.description?.trim();\n if (task) line.target = task;\n\n // What it did: \"N tools · duration\", once it is over — while it works the line says what\n // it is on, and a count that grew with each call moved the task beside it.\n const summary = (): string => {\n if (options.counts === false) return '';\n const parts: string[] = [];\n const tools = sub.segments.filter((s) => s.type === 'tool_call').length;\n if (tools > 0) parts.push(toolCount(config, tools));\n const ms = durationOf(segment, sub);\n if (ms !== undefined) {\n const tag = config.getLocale().tag;\n parts.push(formatDuration(ms, typeof tag === 'string' && tag ? tag : undefined));\n }\n return parts.join(' · ');\n };\n\n // The state, only where the row's own badge would say another: the row is the CALL's,\n // and a call can be over while the sub-agent it opened failed or was stopped — or\n // still running after one of its sub-agents is done. A stand-in's row always agrees.\n const note: string[] = [];\n if (!standIn && statusOfCall(segment.status) !== status) note.push(stateWord(config, status));\n\n if (options.activity !== false) {\n // The second line, from its start to its end: what it is on, then what it did (in\n // the state's word when there is no count to give, so the line is never empty).\n line.activity = live\n ? activityOf(sub, config, currentStep(segment.messageId, sub.id)) || word(config, 'subagentsStarting')\n : summary() || stateWord(config, status);\n } else if (!live) {\n // One line: what it did comes after the state, once, at its end.\n const done = summary();\n if (done) note.push(done);\n }\n if (note.length > 0) line.note = note.join(' · ');\n\n const details = options.details;\n line.details = typeof details === 'function' ? details\n : details === 'transcript' ? subagentTranscript\n : false;\n\n // Somewhere else to read it: core draws the button, the plugin says what it opens.\n if (options.open === 'event') {\n const shownName = name || word(config, 'subagentsUnnamed');\n line.open = {\n label: word(config, 'subagentsOpen').replace('{name}', () => shownName),\n current: isShown(segment.messageId, sub.id),\n onOpen: (row) => dispatchOpen(row, segment, sub, standIn),\n };\n }\n return line;\n };\n}\n","/**\n * The line of a sub-agent no call opened: core's own tool row, drawn for a stand-in call.\n *\n * A sub-agent announced without a call (an AG-UI `SUBAGENT_STARTED` with no parent call), or\n * the second one a call opens, has no row of its own in the reply, so the plugin adds a\n * `subagent` segment for it. That segment is drawn by core's `tool_call` renderer, handed a\n * call that stands for the agent: its name is the agent's (so `registerToolDisplay('<agent\n * name>', …)` reaches it — label, icon, `quiet`, `hidden`, `details`), its status says the\n * agent's. The renderer returns the row's own root — no wrapper — and forwards `setup`,\n * `update`, `relabel` and `cleanup` to core's, so the line reads and behaves exactly like a\n * call's sub-agent line.\n */\nimport {\n contextConfig,\n getSegmentRenderer,\n type AparteSegmentRenderer,\n type AparteToolCallSegment,\n} from '@aparte/core';\nimport { callStatusOf, subagentOf, subagentStatus } from './status.js';\nimport { markStandIn } from './line.js';\nimport { rendererStyles } from './styles.js';\nimport { SUBAGENT_SEGMENT_TYPE, type AparteSubagentSegment } from './types.js';\n\n/** The tool name a sub-agent with no name stands in under. */\nexport const UNNAMED_AGENT = 'subagent';\n\n/** The call that stands for a `subagent` segment on core's row: same id, the agent's name, its status. */\nexport function standInCall(segment: AparteSubagentSegment): AparteToolCallSegment {\n const sub = subagentOf(segment);\n const status = subagentStatus(segment);\n const call = {\n id: segment.id,\n type: 'tool_call',\n ...(segment.messageId !== undefined ? { messageId: segment.messageId } : {}),\n ...(segment.index !== undefined ? { index: segment.index } : {}),\n // Its timing is the segment's: the line's duration reads it.\n ...(segment.meta !== undefined ? { meta: segment.meta } : {}),\n ...((segment as { collapsed?: boolean }).collapsed !== undefined ? { collapsed: (segment as { collapsed?: boolean }).collapsed } : {}),\n toolCall: { id: sub?.id ?? segment.id, name: sub?.name?.trim() || UNNAMED_AGENT, input: {} },\n status: callStatusOf(status),\n // A failure reads as a failed call's does.\n ...(status === 'failed' && sub?.error ? { result: sub.error } : {}),\n subagent: segment.subagent,\n } as AparteToolCallSegment;\n return markStandIn(call);\n}\n\n/** Core's renderer for a call, in the chat's config. */\nconst toolRow = () => getSegmentRenderer('tool_call', contextConfig());\n\n/** Draw `out` in place of `element`, as core's row does when its shape changes. */\nfunction replace(element: HTMLElement, out: HTMLElement | string, segment: AparteSubagentSegment): HTMLElement | null {\n const tpl = document.createElement('template');\n tpl.innerHTML = typeof out === 'string' ? out.trim() : '';\n const next = (typeof out === 'string' ? tpl.content.firstElementChild : out) as HTMLElement | null;\n if (!next) return null;\n if (!next.hasAttribute('data-segment-id')) next.setAttribute('data-segment-id', segment.id);\n element.replaceWith(next);\n return next;\n}\n\nexport const subagentRenderer: AparteSegmentRenderer<AparteSubagentSegment> = {\n type: SUBAGENT_SEGMENT_TYPE,\n render: (segment) => toolRow()?.render(standInCall(segment)) ?? '',\n setup: (element, segment) => toolRow()?.setup?.(element, standInCall(segment)),\n update: (element, segment) => {\n const row = toolRow();\n if (!row) return;\n const call = standInCall(segment);\n if (row.update) {\n row.update(element, call);\n return;\n }\n // An app's own `tool_call` renderer with no `update`: drawn again, as the bubble would.\n row.cleanup?.(element, call);\n const next = replace(element, row.render(call), segment);\n if (next) row.setup?.(next, call);\n },\n relabel: (element, segment) => toolRow()?.relabel?.(element, standInCall(segment)),\n cleanup: (element, segment) => toolRow()?.cleanup?.(element, standInCall(segment)),\n // The plugin's sheet (the transcript's, the view's): core puts it on the page with the\n // renderers' own, once, unless a view already did.\n getStyles: rendererStyles,\n};\n","/**\n * `setupSubagents()`: one line per sub-agent, on the config last, like every setup.\n */\nimport {\n aparteGlobalConfig,\n getSegmentRenderer,\n registerSegmentRenderer,\n unregisterSegmentRenderer,\n type AparteConfig,\n} from '@aparte/core';\nimport { createLanes } from './lanes.js';\nimport { createLineProvider } from './line.js';\nimport { subagentRenderer } from './segment.js';\nimport { SUBAGENT_SEGMENT_TYPE, type SubagentsOptions } from './types.js';\n\n/** The setup in effect on each config, so a second call replaces the first. */\nconst installed = new WeakMap<AparteConfig, () => void>();\n\n/**\n * Show each sub-agent of a reply as one line: the line of the call that opened it — its\n * name, its task, what it is doing now, \"3 tools · 12 s\" — and its conversation kept on that\n * call, out of the reply and out of what the model reads. A sub-agent no call opened gets the\n * same line, from a segment of the plugin's own.\n *\n * Installs one run-event observer, one tool-line provider and the `subagent` segment's\n * renderer on `config` (the global config by default). Returns the function that takes them\n * off; calling it again on the same config replaces the first setup.\n *\n * @example\n * import { setupSubagents } from '@aparte/plugin-subagents';\n * setupSubagents(); // the line alone\n * setupSubagents({ counts: false }); // without \"3 tools · 12 s\"\n * setupSubagents({ details: 'transcript' }); // its conversation under the line, closed\n */\nexport function setupSubagents(options: SubagentsOptions = {}, config: AparteConfig = aparteGlobalConfig): () => void {\n installed.get(config)?.();\n const lanes = createLanes();\n const provider = createLineProvider({ ...options });\n const stopObserving = config.observeRunEvents(lanes.observe);\n config.setToolLineProvider(provider);\n registerSegmentRenderer(subagentRenderer, config);\n\n let disposed = false;\n const dispose = (): void => {\n if (disposed) return;\n disposed = true;\n stopObserving();\n lanes.dispose();\n if (config.getToolLineProvider() === provider) config.setToolLineProvider(null);\n if (getSegmentRenderer(SUBAGENT_SEGMENT_TYPE, config) === subagentRenderer) unregisterSegmentRenderer(SUBAGENT_SEGMENT_TYPE, config);\n if (installed.get(config) === dispose) installed.delete(config);\n };\n installed.set(config, dispose);\n return dispose;\n}\n","/**\n * `connectSubagentView()` — the wiring between a chat, a sub-agent's view and the layout.\n *\n * The line only says \"open this\" (`aparte-subagent-open`, with `setupSubagents({ open:\n * 'event' })`), and the view shows whichever sub-agent it is pointed at and decides nothing\n * about where it sits. This is the handful of lines in between, written once: an Open shows\n * that sub-agent in the view, marks its line and opens the pane; Close (or Escape) folds it,\n * clears the mark and gives the focus back. An app with its own layout reads this file and\n * writes its own.\n */\nimport type { AparteSubagentView } from './aparte-subagent-view.js';\nimport { markRow, openButtonOf, setShown, unmarkAll } from './open.js';\nimport type { AparteSubagentOpenEventDetail } from './types.js';\n\n/** The part of `<aparte-split>` this needs: one pane or two, and which one. */\nexport interface SubagentViewSplit extends HTMLElement {\n single: boolean;\n pane: 'start' | 'end';\n}\n\nexport interface ConnectSubagentViewOptions {\n /** The chat whose sub-agents' lines open in the view: the element their `aparte-subagent-open` bubbles through. */\n chat: HTMLElement;\n /** The view. It is made `closable` while connected (its name and a Close button), and given the chat when it reads none. */\n view: AparteSubagentView;\n /**\n * The `<aparte-split>` that holds the chat and the view, when there is one: it is opened on\n * the view's pane and folded back to the chat's. Without it, show and hide the view\n * yourself from `onOpen` and `onClose`.\n */\n split?: SubagentViewSplit;\n /** Which pane of the split the view is in. Default `end`. */\n pane?: 'start' | 'end';\n /** After the view was pointed at a sub-agent: your own layout's turn. */\n onOpen?: (detail: AparteSubagentOpenEventDetail) => void;\n /** After Close or Escape, or another conversation: your own layout's turn. */\n onClose?: () => void;\n}\n\n/**\n * Wire a chat's sub-agent lines to a view. Returns a function that undoes all of it.\n *\n * The lines need `setupSubagents({ open: 'event' })` for their Open button: that is the setup's\n * option, not this function's, since a line drawn before the wiring exists is drawn already.\n * A sub-agent's own sub-agents, drawn as lines inside the view, open in the same view.\n */\nexport function connectSubagentView(options: ConnectSubagentViewOptions): () => void {\n const { chat, view, split } = options;\n const viewPane = options.pane ?? 'end';\n const chatPane = viewPane === 'end' ? 'start' : 'end';\n /** Who shows a sub-agent, for the lines drawn later. */\n const owner = {};\n\n if (!view.chat && !view.getAttribute('for')) view.chat = chat;\n const wasClosable = view.hasAttribute('closable');\n view.setAttribute('closable', '');\n\n /** The line whose button opened the view, to mark and to give the focus back to, and what it said. */\n let opener: HTMLElement | null = null;\n let opened: AparteSubagentOpenEventDetail | null = null;\n let isOpen = false;\n\n const roots = (): ParentNode[] => (chat.contains(view) ? [chat] : [chat, view]);\n const mark = (row: HTMLElement | null): void => {\n for (const root of roots()) unmarkAll(root);\n if (row) markRow(row, true);\n };\n\n const fold = (): void => {\n if (split) {\n split.pane = chatPane;\n split.single = true;\n }\n isOpen = false;\n options.onClose?.();\n };\n\n const onOpen = (event: Event): void => {\n const detail = (event as HTMLElementEventMap['aparte-subagent-open']).detail;\n if (!detail?.messageId || !detail.agentId) return;\n const row = event.target instanceof HTMLElement ? event.target : null;\n opener = row;\n opened = detail;\n setShown(owner, { messageId: detail.messageId, agentId: detail.agentId });\n mark(row);\n view.setAttribute('message-id', detail.messageId);\n view.setAttribute('agent-id', detail.agentId);\n if (split) {\n // Two panes first, from the chat alone: the split moves from what is on screen.\n // Naming the pane first would show the view alone for a frame. Stacked (a phone),\n // the split shows the pane it is told: the view.\n split.single = false;\n split.pane = viewPane;\n }\n isOpen = true;\n options.onOpen?.(detail);\n view.focusTitle();\n };\n\n const close = (giveFocusBack: boolean): void => {\n // Where the focus is before the pane goes: in the view, or nowhere.\n const active = view.ownerDocument.activeElement;\n const adrift = !active || active === view.ownerDocument.body || view.contains(active);\n setShown(owner, null);\n mark(null);\n fold();\n if (giveFocusBack) {\n // Back where the reader was: the button that opened the view, if it is still there;\n // else the composer, so the focus is not left on a pane that is gone.\n const line = opener?.isConnected ? opener : lineOf(opened);\n const button = line ? openButtonOf(line) : null;\n if (button) button.focus();\n else if (adrift) focusComposer(chat);\n }\n opener = null;\n opened = null;\n };\n /**\n * The line of the sub-agent shown, drawn again since it was pressed (a framework redraws a\n * reply when it ends): a call's row by its call id, a sub-agent of the plugin's own by its id.\n */\n const lineOf = (detail: AparteSubagentOpenEventDetail | null): HTMLElement | null => {\n if (!detail) return null;\n const id = detail.toolCallId ?? detail.agentId;\n for (const root of roots()) {\n for (const row of root.querySelectorAll<HTMLElement>('.aparte-segment-tool-call[data-tool-call-id]')) {\n if (row.getAttribute('data-tool-call-id') === id && openButtonOf(row)) return row;\n }\n }\n return null;\n };\n const onClose = (): void => close(true);\n // Another conversation: nothing of the last one shown, and no pane open on nothing.\n const onLoaded = (): void => {\n if (isOpen || opened) close(false);\n view.removeAttribute('message-id');\n view.removeAttribute('agent-id');\n };\n\n chat.addEventListener('aparte-subagent-open', onOpen);\n // A sub-agent's own sub-agents are lines inside the view: they open here too.\n const viewListens = !chat.contains(view);\n if (viewListens) view.addEventListener('aparte-subagent-open', onOpen);\n view.addEventListener('aparte-subagent-view-close', onClose);\n for (const name of ['aparte-conversation-loaded', 'aparte-reset-done'] as const) chat.addEventListener(name, onLoaded);\n\n // Nothing shown yet: the split shows the chat alone.\n if (split && !view.getAttribute('agent-id')) {\n split.pane = chatPane;\n split.single = true;\n }\n\n return () => {\n chat.removeEventListener('aparte-subagent-open', onOpen);\n if (viewListens) view.removeEventListener('aparte-subagent-open', onOpen);\n view.removeEventListener('aparte-subagent-view-close', onClose);\n for (const name of ['aparte-conversation-loaded', 'aparte-reset-done'] as const) chat.removeEventListener(name, onLoaded);\n setShown(owner, null);\n mark(null);\n if (!wasClosable) view.removeAttribute('closable');\n };\n}\n\n/**\n * Put the focus in the chat's composer: core's input when the chat has one, else nothing. Only\n * an element core never upgraded lacks `focusEnd`, and that one has no editor to take the\n * focus either: nothing to fall back on.\n */\nfunction focusComposer(chat: HTMLElement): void {\n chat.querySelector<HTMLElement & { focusEnd?: () => void }>('aparte-composer-input')?.focusEnd?.();\n}\n"],"names":["keyOf","holder","handle","lane","next","release","shown","isOpen"],"mappings":";AAqCO,MAAM,wBAAwB;AC9BrC,MAAM,+BAAe,IAA0B,CAAC,WAAW,WAAW,QAAQ,UAAU,SAAS,CAAC;AAM3F,SAAS,WAAW,SAAoD;AAC3E,QAAM,QAAS,QAAmC;AAClD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,MAAM;AACZ,MAAI,OAAO,IAAI,OAAO,SAAU,QAAO;AACvC,MAAI,QAAQ,SAAS,eAAe,QAAQ,SAAS,sBAAuB,QAAO;AACnF,SAAO;AAAA,IACH,GAAG;AAAA,IACH,IAAI,IAAI;AAAA,IACR,QAAQ,SAAS,IAAI,IAAI,MAA8B,IAAI,IAAI,SAAiC;AAAA,IAChG,UAAU,MAAM,QAAQ,IAAI,QAAQ,IAAI,IAAI,WAAW,CAAA;AAAA,EAAC;AAEhE;AAGA,SAAS,cAAc,SAAiC;AACpD,MAAI,QAAQ,SAAS,aAAa;AAC9B,UAAM,SAAU,QAAkC;AAClD,WAAO,WAAW,aAAa,WAAW;AAAA,EAC9C;AACA,SAAO,QAAQ,gBAAgB;AACnC;AASO,SAAS,eAAe,SAA8C;AACzE,QAAM,MAAM,WAAW,OAAO;AAC9B,MAAI,CAAC,IAAK,QAAO;AACjB,OAAK,IAAI,WAAW,aAAa,IAAI,WAAW,cAAc,cAAc,OAAO,EAAG,QAAO;AAC7F,SAAO,IAAI;AACf;AAGO,SAAS,aAAa,QAA2E;AACpG,UAAQ,UAAU,WAAA;AAAA,IACd,KAAK;AAAW,aAAO;AAAA,IACvB,KAAK;AAAqB,aAAO;AAAA,IACjC,KAAK;AAAY,aAAO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AO;AAC3D,aAAW,QAAQ,CAAC,8BAA8B,mBAAmB,EAAY,MAAK,iBAAiB,MAAM,QAAQ;AAGrH,MAAI,SAAS,CAAC,KAAK,aAAa,UAAU,GAAG;AACzC,UAAM,OAAO;AACb,UAAM,SAAS;AAAA,EACnB;AAEA,SAAO,MAAM;AACT,SAAK,oBAAoB,wBAAwB,MAAM;AACvD,QAAI,YAAa,MAAK,oBAAoB,wBAAwB,MAAM;AACxE,SAAK,oBAAoB,8BAA8B,OAAO;AAC9D,eAAW,QAAQ,CAAC,8BAA8B,mBAAmB,EAAY,MAAK,oBAAoB,MAAM,QAAQ;AACxH,aAAS,OAAO,IAAI;AACpB,SAAK,IAAI;AACT,QAAI,CAAC,YAAa,MAAK,gBAAgB,UAAU;AAAA,EACrD;AACJ;AAOA,SAAS,cAAc,MAAyB;AAC5C,OAAK,cAAuD,uBAAuB,GAAG,WAAA;AAC1F;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `connectSubagentView()` — the wiring between a chat, a sub-agent's view and the layout.
|
|
3
|
+
*
|
|
4
|
+
* The line only says "open this" (`aparte-subagent-open`, with `setupSubagents({ open:
|
|
5
|
+
* 'event' })`), and the view shows whichever sub-agent it is pointed at and decides nothing
|
|
6
|
+
* about where it sits. This is the handful of lines in between, written once: an Open shows
|
|
7
|
+
* that sub-agent in the view, marks its line and opens the pane; Close (or Escape) folds it,
|
|
8
|
+
* clears the mark and gives the focus back. An app with its own layout reads this file and
|
|
9
|
+
* writes its own.
|
|
10
|
+
*/
|
|
11
|
+
import type { AparteSubagentView } from './aparte-subagent-view.js';
|
|
12
|
+
import type { AparteSubagentOpenEventDetail } from './types.js';
|
|
13
|
+
/** The part of `<aparte-split>` this needs: one pane or two, and which one. */
|
|
14
|
+
export interface SubagentViewSplit extends HTMLElement {
|
|
15
|
+
single: boolean;
|
|
16
|
+
pane: 'start' | 'end';
|
|
17
|
+
}
|
|
18
|
+
export interface ConnectSubagentViewOptions {
|
|
19
|
+
/** The chat whose sub-agents' lines open in the view: the element their `aparte-subagent-open` bubbles through. */
|
|
20
|
+
chat: HTMLElement;
|
|
21
|
+
/** The view. It is made `closable` while connected (its name and a Close button), and given the chat when it reads none. */
|
|
22
|
+
view: AparteSubagentView;
|
|
23
|
+
/**
|
|
24
|
+
* The `<aparte-split>` that holds the chat and the view, when there is one: it is opened on
|
|
25
|
+
* the view's pane and folded back to the chat's. Without it, show and hide the view
|
|
26
|
+
* yourself from `onOpen` and `onClose`.
|
|
27
|
+
*/
|
|
28
|
+
split?: SubagentViewSplit;
|
|
29
|
+
/** Which pane of the split the view is in. Default `end`. */
|
|
30
|
+
pane?: 'start' | 'end';
|
|
31
|
+
/** After the view was pointed at a sub-agent: your own layout's turn. */
|
|
32
|
+
onOpen?: (detail: AparteSubagentOpenEventDetail) => void;
|
|
33
|
+
/** After Close or Escape, or another conversation: your own layout's turn. */
|
|
34
|
+
onClose?: () => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Wire a chat's sub-agent lines to a view. Returns a function that undoes all of it.
|
|
38
|
+
*
|
|
39
|
+
* The lines need `setupSubagents({ open: 'event' })` for their Open button: that is the setup's
|
|
40
|
+
* option, not this function's, since a line drawn before the wiring exists is drawn already.
|
|
41
|
+
* A sub-agent's own sub-agents, drawn as lines inside the view, open in the same view.
|
|
42
|
+
*/
|
|
43
|
+
export declare function connectSubagentView(options: ConnectSubagentViewOptions): () => void;
|
|
44
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,+EAA+E;AAC/E,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IAClD,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACvC,mHAAmH;IACnH,IAAI,EAAE,WAAW,CAAC;IAClB,4HAA4H;IAC5H,IAAI,EAAE,kBAAkB,CAAC;IACzB;;;;OAIG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACvB,yEAAyE;IACzE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,6BAA6B,KAAK,IAAI,CAAC;IACzD,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,IAAI,CAmHnF"}
|