@averyyy/pi-coding-agent 1.5.0-piclient.1 → 1.5.0-piclient.3
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/CHANGELOG.md +3 -2
- package/dist/bundle/chunks/{chunk-LXHWY6K4.js → chunk-7FMRLQ6P.js} +10 -12
- package/dist/bundle/chunks/{chunk-ULTM5Q67.js → chunk-NWAB6VML.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-CR5DUKA3.js → virtual-modules-CTTKTI6Z.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +8 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +58 -17
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/pi-server-observer.d.ts +5 -7
- package/dist/core/pi-server-observer.d.ts.map +1 -1
- package/dist/core/pi-server-observer.js +120 -194
- package/dist/core/pi-server-observer.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +28 -33
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +5 -4
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -1
- package/dist/modes/interactive/program-status-reporter.js +13 -6
- package/dist/modes/interactive/program-status-reporter.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-server-observer.js","sourceRoot":"","sources":["../../src/core/pi-server-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,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AAC,OAAO,CAAC,KAAK,CAAC,CAC1B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uCAAuC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;QACzB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent, TextSignatureV1, ThinkingContent, ToolCall } from \"@earendil-works/pi-ai\";\nimport { raceWithAbortSignal } from \"../utils/abort.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"./agent-session.ts\";\nimport { bashExecutionToText } from \"./messages.ts\";\nimport { ChunkRequest } from \"./pi-server-request.ts\";\nimport { type ObserverSubagent, PiServerSubagents, resolvePiServerSubagents } from \"./pi-server-subagents.ts\";\nimport type { SessionEntry } from \"./session-manager.ts\";\n\nconst observers = new WeakMap<AgentSession, PiServerObserver>();\n\nexport async function closePiServerObserver(session: AgentSession): Promise<void> {\n\tawait observers.get(session)?.close();\n}\n\ntype ViewerContent =\n\t| { type: \"text\"; text: string; phase?: TextSignatureV1[\"phase\"] }\n\t| { type: \"thinking\"; thinking: string }\n\t| { type: \"toolCall\"; id: string; name: string; arguments: unknown }\n\t| { type: \"attachment\"; label: string };\n\nexport interface ObserverMessage {\n\tid: string;\n\trole: string;\n\tcontent: string | ViewerContent[];\n\ttimestamp: number;\n\tstopReason?: string;\n\tphase?: string;\n\terrorMessage?: string;\n}\n\ninterface ObserverTool {\n\tid: string;\n\tname: string;\n\targuments: unknown;\n\tresult?: unknown;\n\tstatus: \"running\" | \"completed\" | \"error\";\n}\n\nexport interface ObserverUpdate {\n\tsessionId: string;\n\tconnectionId: string;\n\tsequence: number;\n\tcwd: string;\n\ttitle: string;\n\tsubagents?: ObserverSubagent[];\n\treplace?: ObserverMessage[];\n\tappend?: ObserverMessage[];\n\tstatus: \"running\" | \"idle\";\n\tlive: { message: ObserverMessage | null; tools: ObserverTool[] };\n}\n\nfunction textPhase(signature: string | undefined): TextSignatureV1[\"phase\"] {\n\tif (!signature?.startsWith(\"{\")) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(signature) as Partial<TextSignatureV1>;\n\t\tif (\n\t\t\tparsed.v === 1 &&\n\t\t\ttypeof parsed.id === \"string\" &&\n\t\t\t(parsed.phase === \"commentary\" || parsed.phase === \"final_answer\")\n\t\t)\n\t\t\treturn parsed.phase;\n\t} catch {\n\t\t// Provider signatures outside TextSignatureV1 have no display phase.\n\t}\n\treturn undefined;\n}\n\nfunction projectContent(\n\tcontent: string | (TextContent | ThinkingContent | ImageContent | ToolCall)[],\n): ObserverMessage[\"content\"] {\n\tif (typeof content === \"string\") return content;\n\treturn content.map((part): ViewerContent => {\n\t\tif (part.type === \"text\") return { type: \"text\", text: part.text, phase: textPhase(part.textSignature) };\n\t\tif (part.type === \"thinking\") return { type: \"thinking\", thinking: part.thinking };\n\t\tif (part.type === \"toolCall\")\n\t\t\treturn { type: \"toolCall\", id: part.id, name: part.name, arguments: part.arguments };\n\t\treturn { type: \"attachment\", label: part.mimeType };\n\t});\n}\n\nfunction projectMessage(id: string, message: AgentMessage, timestamp = message.timestamp): ObserverMessage | undefined {\n\tif (message.role === \"system\" || (message.role === \"custom\" && !message.display)) return undefined;\n\tlet content: ObserverMessage[\"content\"];\n\tif (message.role === \"bashExecution\") content = bashExecutionToText(message);\n\telse if (message.role === \"compactionSummary\" || message.role === \"branchSummary\") content = message.summary;\n\telse content = projectContent(message.content);\n\tconst projected: ObserverMessage = { id, role: message.role, content, timestamp };\n\tif (message.role === \"assistant\") {\n\t\tprojected.stopReason = message.stopReason;\n\t\tprojected.errorMessage = message.errorMessage;\n\t\tfor (const part of message.content) {\n\t\t\tconst phase = part.type === \"text\" ? textPhase(part.textSignature) : undefined;\n\t\t\tif (phase) projected.phase = phase;\n\t\t}\n\t}\n\treturn projected;\n}\n\nexport function projectObserverEntries(entries: SessionEntry[]): ObserverMessage[] {\n\tconst messages: ObserverMessage[] = [];\n\tfor (const entry of entries) {\n\t\tlet message: ObserverMessage | undefined;\n\t\tif (entry.type === \"message\") message = projectMessage(entry.id, entry.message, Date.parse(entry.timestamp));\n\t\telse if (entry.type === \"custom_message\" && entry.display) {\n\t\t\tmessage = {\n\t\t\t\tid: entry.id,\n\t\t\t\trole: \"custom\",\n\t\t\t\tcontent: projectContent(entry.content),\n\t\t\t\ttimestamp: Date.parse(entry.timestamp),\n\t\t\t};\n\t\t} else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") {\n\t\t\tmessage = { id: entry.id, role: entry.type, content: entry.summary, timestamp: Date.parse(entry.timestamp) };\n\t\t}\n\t\tif (message) messages.push(message);\n\t}\n\treturn messages;\n}\n\n/** Publishes transcript updates independently of provider requests and durable server trees. */\nexport class PiServerObserver {\n\tprivate readonly session: AgentSession;\n\tprivate readonly unsubscribe: () => void;\n\tprivate controller?: AbortController;\n\tprivate timer?: ReturnType<typeof setTimeout>;\n\tprivate reconnectTimer?: ReturnType<typeof setTimeout>;\n\tprivate disposed = false;\n\tprivate closing = false;\n\tprivate closePromise?: Promise<void>;\n\tprivate connectionReady?: Promise<void>;\n\tprivate deletedSessionId?: string;\n\tprivate connectionId?: string;\n\tprivate connectedSessionId?: string;\n\tprivate sequence = 0;\n\tprivate sending = false;\n\tprivate flushPromise?: Promise<void>;\n\tprivate dirty = true;\n\tprivate historyDirty = true;\n\tprivate replace = true;\n\tprivate sentEntryId?: string;\n\tprivate pendingEntries: SessionEntry[] = [];\n\tprivate firstUserTitle = \"\";\n\tprivate liveMessage: AgentMessage | null = null;\n\tprivate liveMessageId = \"\";\n\tprivate readonly tools = new Map<string, ObserverTool>();\n\tprivate disconnected = false;\n\tprivate observedSessionId?: string;\n\tprivate readonly subagents: PiServerSubagents;\n\tprivate sentSubagentVersion = -1;\n\n\tconstructor(session: AgentSession) {\n\t\tthis.session = session;\n\t\tthis.subagents = new PiServerSubagents(session, () => {\n\t\t\tthis.dirty = true;\n\t\t\tthis.historyDirty = true;\n\t\t\tthis.schedule(0);\n\t\t});\n\t\tthis.syncSession();\n\t\tobservers.set(session, this);\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\ttry {\n\t\t\t\tthis.handleEvent(event);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportError(error);\n\t\t\t}\n\t\t});\n\t\tvoid this.connect();\n\t}\n\n\tprivate handleEvent(event: AgentSessionEvent): void {\n\t\tthis.syncSession();\n\t\tswitch (event.type) {\n\t\t\tcase \"session_disposed\":\n\t\t\t\tthis.dispose();\n\t\t\t\treturn;\n\t\t\tcase \"run_state_changed\":\n\t\t\t\tresolvePiServerSubagents();\n\t\t\t\tif (!event.running) {\n\t\t\t\t\tthis.liveMessage = null;\n\t\t\t\t\tthis.tools.clear();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role !== \"assistant\") return;\n\t\t\t\tthis.tools.clear();\n\t\t\t\tthis.liveMessageId = randomUUID();\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"message_update\":\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"entry_appended\":\n\t\t\tcase \"message_committed\":\n\t\t\t\tif (this.connectionId && !this.historyDirty) {\n\t\t\t\t\tthis.pendingEntries.push(event.entry);\n\t\t\t\t\tif (this.pendingEntries.length > 64) {\n\t\t\t\t\t\tthis.pendingEntries = [];\n\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (event.entry.type === \"message\" && event.entry.message.role === \"assistant\") this.liveMessage = null;\n\t\t\t\tbreak;\n\t\t\tcase \"history_reconciled\":\n\t\t\tcase \"session_tree_changed\":\n\t\t\t\tthis.subagents.restore();\n\t\t\t\tif (this.deletedSessionId && this.deletedSessionId !== this.session.sessionId) {\n\t\t\t\t\tthis.deletedSessionId = undefined;\n\t\t\t\t\tvoid this.connect();\n\t\t\t\t}\n\t\t\t\tif (this.connectedSessionId && this.connectedSessionId !== this.session.sessionId) {\n\t\t\t\t\tthis.connectionId = undefined;\n\t\t\t\t\tthis.controller?.abort();\n\t\t\t\t}\n\t\t\t\tthis.replace = true;\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tbreak;\n\t\t\tcase \"session_info_changed\":\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.tools.set(event.toolCallId, {\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tname: event.toolName,\n\t\t\t\t\targuments: event.args,\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_update\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) tool.result = { content: projectContent(event.partialResult.content) };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool_execution_end\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) {\n\t\t\t\t\ttool.result = { content: projectContent(event.result.content), isError: event.isError };\n\t\t\t\t\ttool.status = event.isError ? \"error\" : \"completed\";\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\t\tthis.dirty = true;\n\t\tthis.schedule(\n\t\t\tevent.type === \"run_state_changed\" || event.type === \"compaction_start\" || event.type === \"compaction_end\"\n\t\t\t\t? 0\n\t\t\t\t: 80,\n\t\t);\n\t}\n\n\tprivate syncSession(): void {\n\t\tif (this.observedSessionId === this.session.sessionId) return;\n\t\tthis.observedSessionId = this.session.sessionId;\n\t\tthis.subagents.syncSession();\n\t\tthis.sentSubagentVersion = -1;\n\t\tthis.sentEntryId = undefined;\n\t\tthis.pendingEntries = [];\n\t\tthis.firstUserTitle = \"\";\n\t\tthis.liveMessage = null;\n\t\tthis.tools.clear();\n\t}\n\n\tprivate schedule(delay: number): void {\n\t\tif (\n\t\t\tthis.disposed ||\n\t\t\tthis.closing ||\n\t\t\tthis.deletedSessionId === this.session.sessionId ||\n\t\t\t!this.dirty ||\n\t\t\t!this.connectionId ||\n\t\t\tthis.sending ||\n\t\t\tthis.timer\n\t\t)\n\t\t\treturn;\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.timer = undefined;\n\t\t\tvoid this.flush();\n\t\t}, delay);\n\t\tthis.timer.unref();\n\t}\n\n\tprivate reportError(error: unknown): void {\n\t\tif (this.disposed || this.disconnected) return;\n\t\tthis.disconnected = true;\n\t\tconsole.error(`pi-server observer disconnected: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n\n\tprivate stopDeletedSession(sessionId: string, controller: AbortController): void {\n\t\tif (sessionId === this.session.sessionId) {\n\t\t\tthis.deletedSessionId = sessionId;\n\t\t\tthis.connectionId = undefined;\n\t\t\tthis.pendingEntries = [];\n\t\t\tthis.liveMessage = null;\n\t\t\tthis.tools.clear();\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t\tclearTimeout(this.reconnectTimer);\n\t\t\tthis.reconnectTimer = undefined;\n\t\t}\n\t\tcontroller.abort();\n\t}\n\n\tprivate request(signal: AbortSignal): ChunkRequest {\n\t\treturn new ChunkRequest({\n\t\t\tserverUrl: process.env.PI_SERVER_URL ?? \"http://127.0.0.1:4217\",\n\t\t\tauthToken: process.env.PI_SERVER_AUTH_TOKEN ?? \"\",\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tprivate async connect(): Promise<void> {\n\t\tif (this.disposed || this.deletedSessionId === this.session.sessionId) return;\n\t\tthis.syncSession();\n\t\tconst controller = new AbortController();\n\t\tthis.controller = controller;\n\t\tconst sessionId = this.session.sessionId;\n\t\tthis.connectedSessionId = sessionId;\n\t\tlet resolveConnection: (() => void) | undefined;\n\t\tthis.connectionReady = new Promise<void>((resolve) => {\n\t\t\tresolveConnection = resolve;\n\t\t});\n\t\tconst timeout = setTimeout(() => controller.abort(new Error(\"connection timed out\")), 10000);\n\t\ttimeout.unref();\n\t\ttry {\n\t\t\tconst response = await this.request(controller.signal).getJson(\n\t\t\t\t`/api/observer/connect?sessionId=${encodeURIComponent(sessionId)}`,\n\t\t\t);\n\t\t\tif (response.status === 410) {\n\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok || !response.headers.get(\"content-type\")?.includes(\"text/event-stream\") || !response.body) {\n\t\t\t\tthrow new Error(`connection failed (HTTP ${response.status})`);\n\t\t\t}\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tlet event = \"\";\n\t\t\ttry {\n\t\t\t\twhile (!this.disposed) {\n\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\tif (done) throw new Error(\"connection closed\");\n\t\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\t\tlet newline = buffer.indexOf(\"\\n\");\n\t\t\t\t\twhile (newline !== -1) {\n\t\t\t\t\t\tconst line = buffer.slice(0, newline).replace(/\\r$/, \"\");\n\t\t\t\t\t\tbuffer = buffer.slice(newline + 1);\n\t\t\t\t\t\tif (line.startsWith(\"event:\")) event = line.slice(6).trim();\n\t\t\t\t\t\tif (event === \"deleted\" && line.startsWith(\"data:\")) {\n\t\t\t\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event === \"connected\" && !this.connectionId && line.startsWith(\"data:\")) {\n\t\t\t\t\t\t\tconst connected = JSON.parse(line.slice(5)) as { connectionId: string };\n\t\t\t\t\t\t\tthis.connectionId = connected.connectionId;\n\t\t\t\t\t\t\tthis.sequence = 0;\n\t\t\t\t\t\t\tthis.sentSubagentVersion = -1;\n\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\tthis.replace = true;\n\t\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t\t\tthis.dirty = true;\n\t\t\t\t\t\t\tthis.schedule(0);\n\t\t\t\t\t\t\tresolveConnection?.();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewline = buffer.indexOf(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait reader.cancel();\n\t\t\t\treader.releaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\terror instanceof TypeError &&\n\t\t\t\terror.message === \"terminated\" &&\n\t\t\t\terror.cause instanceof Error &&\n\t\t\t\t\"code\" in error.cause &&\n\t\t\t\terror.cause.code === \"UND_ERR_SOCKET\"\n\t\t\t)\n\t\t\t\treturn;\n\t\t\tif (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId) this.reportError(error);\n\t\t} finally {\n\t\t\tresolveConnection?.();\n\t\t\tclearTimeout(timeout);\n\t\t\tcontroller.abort();\n\t\t\tif (this.controller === controller) this.connectionId = undefined;\n\t\t\tif (this.controller === controller && !this.disposed && !this.closing && this.deletedSessionId !== sessionId) {\n\t\t\t\tthis.reconnectTimer = setTimeout(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.reconnectTimer = undefined;\n\t\t\t\t\t\tvoid this.connect();\n\t\t\t\t\t},\n\t\t\t\t\tsessionId === this.session.sessionId ? 2000 : 0,\n\t\t\t\t);\n\t\t\t\tthis.reconnectTimer.unref();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate flush(): Promise<void> {\n\t\tif (this.flushPromise) return this.flushPromise;\n\t\tconst promise = this.sendUpdate();\n\t\tthis.flushPromise = promise;\n\t\tvoid promise.finally(() => {\n\t\t\tthis.flushPromise = undefined;\n\t\t});\n\t\treturn promise;\n\t}\n\n\tprivate async sendUpdate(): Promise<void> {\n\t\tthis.subagents.resolve();\n\t\tconst connectionId = this.connectionId;\n\t\tconst sessionId = this.connectedSessionId;\n\t\tconst controller = this.controller;\n\t\tif (\n\t\t\t!connectionId ||\n\t\t\t!sessionId ||\n\t\t\tsessionId !== this.session.sessionId ||\n\t\t\t!controller ||\n\t\t\tthis.disposed ||\n\t\t\tthis.deletedSessionId === sessionId ||\n\t\t\tthis.sending ||\n\t\t\t!this.dirty\n\t\t)\n\t\t\treturn;\n\t\tthis.sending = true;\n\t\tthis.dirty = false;\n\t\ttry {\n\t\t\tconst branch = this.historyDirty ? this.session.sessionManager.getBranch() : undefined;\n\t\t\tconst sentIndex = branch && this.sentEntryId ? branch.findIndex((entry) => entry.id === this.sentEntryId) : -1;\n\t\t\tconst replace = this.replace || (branch !== undefined && this.sentEntryId !== undefined && sentIndex === -1);\n\t\t\tthis.historyDirty = false;\n\t\t\tthis.replace = false;\n\t\t\tconst entries = branch ? (replace ? branch : branch.slice(sentIndex + 1)) : this.pendingEntries;\n\t\t\tthis.pendingEntries = [];\n\t\t\tconst messages = projectObserverEntries(entries);\n\t\t\tif (replace) this.firstUserTitle = \"\";\n\t\t\tif (!this.firstUserTitle) {\n\t\t\t\tconst firstUserContent = messages.find((message) => message.role === \"user\")?.content;\n\t\t\t\tthis.firstUserTitle = (\n\t\t\t\t\ttypeof firstUserContent === \"string\"\n\t\t\t\t\t\t? firstUserContent\n\t\t\t\t\t\t: (firstUserContent\n\t\t\t\t\t\t\t\t?.filter((part) => part.type === \"text\")\n\t\t\t\t\t\t\t\t.map((part) => part.text)\n\t\t\t\t\t\t\t\t.join(\"\") ?? \"\")\n\t\t\t\t).slice(0, 120);\n\t\t\t}\n\t\t\tconst subagentVersion = this.subagents.version;\n\t\t\tconst update: ObserverUpdate = {\n\t\t\t\tsessionId,\n\t\t\t\tconnectionId,\n\t\t\t\tsequence: ++this.sequence,\n\t\t\t\tcwd: this.session.sessionManager.getCwd(),\n\t\t\t\ttitle: this.session.sessionManager.getSessionName() ?? this.firstUserTitle,\n\t\t\t\t...(subagentVersion !== this.sentSubagentVersion ? { subagents: this.subagents.snapshot() } : {}),\n\t\t\t\t...(replace ? { replace: messages } : messages.length ? { append: messages } : {}),\n\t\t\t\tstatus: this.session.isIdle ? \"idle\" : \"running\",\n\t\t\t\tlive: {\n\t\t\t\t\tmessage: this.liveMessage ? (projectMessage(this.liveMessageId, this.liveMessage) ?? null) : null,\n\t\t\t\t\ttools: [...this.tools.values()],\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst response = await this.request(controller.signal).postJson(\"/api/observer\", update);\n\t\t\tif (response.status === 410) {\n\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok) throw new Error(`update failed (HTTP ${response.status})`);\n\t\t\tconst result = (await response.json()) as { accepted: boolean };\n\t\t\tif (!result.accepted) throw new Error(\"update was not accepted\");\n\t\t\tif (sessionId !== this.session.sessionId) return;\n\t\t\tthis.sentSubagentVersion = subagentVersion;\n\t\t\tif (entries.length > 0) this.sentEntryId = entries.at(-1)?.id;\n\t\t\telse if (replace) this.sentEntryId = undefined;\n\t\t\tif (this.disconnected) {\n\t\t\t\tthis.disconnected = false;\n\t\t\t\tconsole.error(\"pi-server observer connected\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId) this.reportError(error);\n\t\t\tcontroller.abort();\n\t\t} finally {\n\t\t\tthis.sending = false;\n\t\t\tthis.schedule(80);\n\t\t}\n\t}\n\n\tclose(): Promise<void> {\n\t\tthis.closePromise ??= this.drainAndClose();\n\t\treturn this.closePromise;\n\t}\n\n\tprivate async drainAndClose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.closing = true;\n\t\tclearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tclearTimeout(this.reconnectTimer);\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(\n\t\t\t\t(async () => {\n\t\t\t\t\tif (this.deletedSessionId === this.session.sessionId) return;\n\t\t\t\t\tif (!this.connectionId && this.controller?.signal.aborted) void this.connect();\n\t\t\t\t\tawait this.connectionReady;\n\t\t\t\t\tawait this.flushPromise;\n\t\t\t\t\tif (!this.connectionId) throw new Error(\"final transcript was not delivered: observer is disconnected\");\n\t\t\t\t\twhile (this.dirty && this.connectionId && !this.disposed) await this.flush();\n\t\t\t\t\tif (this.controller?.signal.aborted && this.deletedSessionId !== this.session.sessionId)\n\t\t\t\t\t\tthrow new Error(\"final transcript was not delivered: observer update failed\");\n\t\t\t\t})(),\n\t\t\t\tAbortSignal.timeout(10000),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(`pi-server observer shutdown failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t} finally {\n\t\t\tthis.dispose();\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.unsubscribe();\n\t\tthis.subagents.dispose();\n\t\tclearTimeout(this.timer);\n\t\tclearTimeout(this.reconnectTimer);\n\t\tthis.controller?.abort();\n\t\tobservers.delete(this.session);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pi-server-observer.js","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AAY,CAAC;gBACxB,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACrC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;wBACxB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;gBAChF,CAAC;YACF,CAAC,CAAC,EAAE,EACJ,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAC1B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uCAAuC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;QACzB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent, TextSignatureV1, ThinkingContent, ToolCall } from \"@earendil-works/pi-ai\";\nimport { raceWithAbortSignal } from \"../utils/abort.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"./agent-session.ts\";\nimport { bashExecutionToText } from \"./messages.ts\";\nimport { ChunkRequest } from \"./pi-server-request.ts\";\nimport { type ObserverSubagent, PiServerSubagents, resolvePiServerSubagents } from \"./pi-server-subagents.ts\";\nimport type { SessionEntry } from \"./session-manager.ts\";\n\nconst observers = new WeakMap<AgentSession, PiServerObserver>();\n\nexport async function closePiServerObserver(session: AgentSession): Promise<void> {\n\tawait observers.get(session)?.close();\n}\n\ntype ViewerContent =\n\t| { type: \"text\"; text: string; phase?: TextSignatureV1[\"phase\"] }\n\t| { type: \"thinking\"; thinking: string }\n\t| { type: \"toolCall\"; id: string; name: string; arguments: unknown }\n\t| { type: \"attachment\"; label: string };\n\nexport interface ObserverMessage {\n\tid: string;\n\trole: string;\n\tcontent: string | ViewerContent[];\n\ttimestamp: number;\n\tstopReason?: string;\n\tphase?: string;\n\terrorMessage?: string;\n}\n\ninterface ObserverTool {\n\tid: string;\n\tname: string;\n\targuments: unknown;\n\tresult?: unknown;\n\tstatus: \"running\" | \"completed\" | \"error\";\n}\n\nexport interface ObserverUpdate {\n\tsessionId: string;\n\tobserverId: string;\n\tsequence: number;\n\tcreate: boolean;\n\tcwd: string;\n\ttitle: string;\n\tsubagents?: ObserverSubagent[];\n\treplace?: ObserverMessage[];\n\tappend?: ObserverMessage[];\n\tstatus: \"running\" | \"idle\";\n\tlive: { message: ObserverMessage | null; tools: ObserverTool[] };\n}\n\nfunction textPhase(signature: string | undefined): TextSignatureV1[\"phase\"] {\n\tif (!signature?.startsWith(\"{\")) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(signature) as Partial<TextSignatureV1>;\n\t\tif (\n\t\t\tparsed.v === 1 &&\n\t\t\ttypeof parsed.id === \"string\" &&\n\t\t\t(parsed.phase === \"commentary\" || parsed.phase === \"final_answer\")\n\t\t)\n\t\t\treturn parsed.phase;\n\t} catch {\n\t\t// Provider signatures outside TextSignatureV1 have no display phase.\n\t}\n\treturn undefined;\n}\n\nfunction projectContent(\n\tcontent: string | (TextContent | ThinkingContent | ImageContent | ToolCall)[],\n): ObserverMessage[\"content\"] {\n\tif (typeof content === \"string\") return content;\n\treturn content.map((part): ViewerContent => {\n\t\tif (part.type === \"text\") return { type: \"text\", text: part.text, phase: textPhase(part.textSignature) };\n\t\tif (part.type === \"thinking\") return { type: \"thinking\", thinking: part.thinking };\n\t\tif (part.type === \"toolCall\")\n\t\t\treturn { type: \"toolCall\", id: part.id, name: part.name, arguments: part.arguments };\n\t\treturn { type: \"attachment\", label: part.mimeType };\n\t});\n}\n\nfunction projectMessage(id: string, message: AgentMessage, timestamp = message.timestamp): ObserverMessage | undefined {\n\tif (message.role === \"system\" || (message.role === \"custom\" && !message.display)) return undefined;\n\tlet content: ObserverMessage[\"content\"];\n\tif (message.role === \"bashExecution\") content = bashExecutionToText(message);\n\telse if (message.role === \"compactionSummary\" || message.role === \"branchSummary\") content = message.summary;\n\telse content = projectContent(message.content);\n\tconst projected: ObserverMessage = { id, role: message.role, content, timestamp };\n\tif (message.role === \"assistant\") {\n\t\tprojected.stopReason = message.stopReason;\n\t\tprojected.errorMessage = message.errorMessage;\n\t\tfor (const part of message.content) {\n\t\t\tconst phase = part.type === \"text\" ? textPhase(part.textSignature) : undefined;\n\t\t\tif (phase) projected.phase = phase;\n\t\t}\n\t}\n\treturn projected;\n}\n\nexport function projectObserverEntries(entries: SessionEntry[]): ObserverMessage[] {\n\tconst messages: ObserverMessage[] = [];\n\tfor (const entry of entries) {\n\t\tlet message: ObserverMessage | undefined;\n\t\tif (entry.type === \"message\") message = projectMessage(entry.id, entry.message, Date.parse(entry.timestamp));\n\t\telse if (entry.type === \"custom_message\" && entry.display) {\n\t\t\tmessage = {\n\t\t\t\tid: entry.id,\n\t\t\t\trole: \"custom\",\n\t\t\t\tcontent: projectContent(entry.content),\n\t\t\t\ttimestamp: Date.parse(entry.timestamp),\n\t\t\t};\n\t\t} else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") {\n\t\t\tmessage = { id: entry.id, role: entry.type, content: entry.summary, timestamp: Date.parse(entry.timestamp) };\n\t\t}\n\t\tif (message) messages.push(message);\n\t}\n\treturn messages;\n}\n\n/** Publishes transcript updates independently of provider requests and durable server trees. */\nexport class PiServerObserver {\n\tprivate readonly session: AgentSession;\n\tprivate readonly unsubscribe: () => void;\n\tprivate controller?: AbortController;\n\tprivate timer?: ReturnType<typeof setTimeout>;\n\tprivate disposed = false;\n\tprivate closing = false;\n\tprivate closePromise?: Promise<void>;\n\tprivate deletedSessionId?: string;\n\tprivate observerId = \"\";\n\tprivate sequence = 0;\n\tprivate published = false;\n\tprivate sending = false;\n\tprivate flushPromise?: Promise<boolean>;\n\tprivate dirty = true;\n\tprivate historyDirty = true;\n\tprivate replace = true;\n\tprivate sentEntryId?: string;\n\tprivate pendingEntries: SessionEntry[] = [];\n\tprivate firstUserTitle = \"\";\n\tprivate liveMessage: AgentMessage | null = null;\n\tprivate liveMessageId = \"\";\n\tprivate readonly tools = new Map<string, ObserverTool>();\n\tprivate deliveryFailed = false;\n\tprivate observedSessionId?: string;\n\tprivate readonly subagents: PiServerSubagents;\n\tprivate sentSubagentVersion = -1;\n\n\tconstructor(session: AgentSession) {\n\t\tthis.session = session;\n\t\tthis.subagents = new PiServerSubagents(session, () => {\n\t\t\tthis.dirty = true;\n\t\t\tthis.historyDirty = true;\n\t\t\tthis.schedule(0);\n\t\t});\n\t\tthis.syncSession();\n\t\tobservers.set(session, this);\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\ttry {\n\t\t\t\tthis.handleEvent(event);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportError(error);\n\t\t\t}\n\t\t});\n\t\tthis.schedule(0);\n\t}\n\n\tprivate handleEvent(event: AgentSessionEvent): void {\n\t\tthis.syncSession();\n\t\tswitch (event.type) {\n\t\t\tcase \"session_disposed\":\n\t\t\t\tthis.dispose();\n\t\t\t\treturn;\n\t\t\tcase \"working_state_changed\":\n\t\t\t\tresolvePiServerSubagents();\n\t\t\t\tif (!event.working) {\n\t\t\t\t\tthis.liveMessage = null;\n\t\t\t\t\tthis.tools.clear();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role !== \"assistant\") return;\n\t\t\t\tthis.tools.clear();\n\t\t\t\tthis.liveMessageId = randomUUID();\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"message_update\":\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"entry_appended\":\n\t\t\tcase \"message_committed\":\n\t\t\t\tif (!this.historyDirty) {\n\t\t\t\t\tthis.pendingEntries.push(event.entry);\n\t\t\t\t\tif (this.pendingEntries.length > 64) {\n\t\t\t\t\t\tthis.pendingEntries = [];\n\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (event.entry.type === \"message\" && event.entry.message.role === \"assistant\") this.liveMessage = null;\n\t\t\t\tbreak;\n\t\t\tcase \"history_reconciled\":\n\t\t\tcase \"session_tree_changed\":\n\t\t\t\tthis.subagents.restore();\n\t\t\t\tthis.replace = true;\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tbreak;\n\t\t\tcase \"session_info_changed\":\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.tools.set(event.toolCallId, {\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tname: event.toolName,\n\t\t\t\t\targuments: event.args,\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_update\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) tool.result = { content: projectContent(event.partialResult.content) };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool_execution_end\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) {\n\t\t\t\t\ttool.result = { content: projectContent(event.result.content), isError: event.isError };\n\t\t\t\t\ttool.status = event.isError ? \"error\" : \"completed\";\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\t\tthis.dirty = true;\n\t\tthis.schedule(\n\t\t\tevent.type === \"working_state_changed\" || event.type === \"compaction_start\" || event.type === \"compaction_end\"\n\t\t\t\t? 0\n\t\t\t\t: 80,\n\t\t);\n\t}\n\n\tprivate syncSession(): void {\n\t\tif (this.observedSessionId === this.session.sessionId) return;\n\t\tthis.controller?.abort();\n\t\tthis.observedSessionId = this.session.sessionId;\n\t\tthis.observerId = randomUUID();\n\t\tthis.sequence = 0;\n\t\tthis.published = false;\n\t\tthis.deletedSessionId = undefined;\n\t\tthis.deliveryFailed = false;\n\t\tthis.dirty = true;\n\t\tthis.historyDirty = true;\n\t\tthis.replace = true;\n\t\tthis.subagents.syncSession();\n\t\tthis.sentSubagentVersion = -1;\n\t\tthis.sentEntryId = undefined;\n\t\tthis.pendingEntries = [];\n\t\tthis.firstUserTitle = \"\";\n\t\tthis.liveMessage = null;\n\t\tthis.tools.clear();\n\t}\n\n\tprivate schedule(delay: number): void {\n\t\tif (\n\t\t\tthis.disposed ||\n\t\t\tthis.closing ||\n\t\t\tthis.deletedSessionId === this.session.sessionId ||\n\t\t\t!this.dirty ||\n\t\t\tthis.sending ||\n\t\t\tthis.timer\n\t\t)\n\t\t\treturn;\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.timer = undefined;\n\t\t\tvoid this.flush();\n\t\t}, delay);\n\t\tthis.timer.unref();\n\t}\n\n\tprivate reportError(error: unknown): void {\n\t\tif (this.disposed || this.deliveryFailed) return;\n\t\tthis.deliveryFailed = true;\n\t\tconsole.error(`pi-server observer update failed: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n\n\tprivate stopDeletedSession(sessionId: string, controller: AbortController): void {\n\t\tif (sessionId === this.session.sessionId) {\n\t\t\tthis.deletedSessionId = sessionId;\n\t\t\tthis.dirty = false;\n\t\t\tthis.pendingEntries = [];\n\t\t\tthis.liveMessage = null;\n\t\t\tthis.tools.clear();\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t\tcontroller.abort();\n\t}\n\n\tprivate request(signal: AbortSignal): ChunkRequest {\n\t\treturn new ChunkRequest({\n\t\t\tserverUrl: process.env.PI_SERVER_URL ?? \"http://127.0.0.1:4217\",\n\t\t\tauthToken: process.env.PI_SERVER_AUTH_TOKEN ?? \"\",\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tprivate flush(): Promise<boolean> {\n\t\tif (this.flushPromise) return this.flushPromise;\n\t\tconst promise = this.sendUpdate();\n\t\tthis.flushPromise = promise;\n\t\tvoid promise.finally(() => {\n\t\t\tthis.flushPromise = undefined;\n\t\t});\n\t\treturn promise;\n\t}\n\n\tprivate async sendUpdate(): Promise<boolean> {\n\t\tthis.subagents.resolve();\n\t\tconst sessionId = this.session.sessionId;\n\t\tif (this.disposed || this.deletedSessionId === sessionId || this.sending || !this.dirty) return true;\n\t\tconst observerId = this.observerId;\n\t\tconst controller = new AbortController();\n\t\tthis.controller = controller;\n\t\tthis.sending = true;\n\t\tlet schedulePending = false;\n\t\ttry {\n\t\t\tfor (let attempt = 0; attempt < 2; attempt++) {\n\t\t\t\tthis.dirty = false;\n\t\t\t\tconst branch = this.historyDirty ? this.session.sessionManager.getBranch() : undefined;\n\t\t\t\tconst sentIndex =\n\t\t\t\t\tbranch && this.sentEntryId ? branch.findIndex((entry) => entry.id === this.sentEntryId) : -1;\n\t\t\t\tconst replace =\n\t\t\t\t\tthis.replace || (branch !== undefined && this.sentEntryId !== undefined && sentIndex === -1);\n\t\t\t\tthis.historyDirty = false;\n\t\t\t\tthis.replace = false;\n\t\t\t\tconst entries = branch ? (replace ? branch : branch.slice(sentIndex + 1)) : this.pendingEntries;\n\t\t\t\tthis.pendingEntries = [];\n\t\t\t\tconst messages = projectObserverEntries(entries);\n\t\t\t\tif (replace) this.firstUserTitle = \"\";\n\t\t\t\tif (!this.firstUserTitle) {\n\t\t\t\t\tconst firstUserContent = messages.find((message) => message.role === \"user\")?.content;\n\t\t\t\t\tthis.firstUserTitle = (\n\t\t\t\t\t\ttypeof firstUserContent === \"string\"\n\t\t\t\t\t\t\t? firstUserContent\n\t\t\t\t\t\t\t: (firstUserContent\n\t\t\t\t\t\t\t\t\t?.filter((part) => part.type === \"text\")\n\t\t\t\t\t\t\t\t\t.map((part) => part.text)\n\t\t\t\t\t\t\t\t\t.join(\"\") ?? \"\")\n\t\t\t\t\t).slice(0, 120);\n\t\t\t\t}\n\t\t\t\tconst subagentVersion = this.subagents.version;\n\t\t\t\tconst update: ObserverUpdate = {\n\t\t\t\t\tsessionId,\n\t\t\t\t\tobserverId,\n\t\t\t\t\tsequence: ++this.sequence,\n\t\t\t\t\tcreate: !this.published,\n\t\t\t\t\tcwd: this.session.sessionManager.getCwd(),\n\t\t\t\t\ttitle: this.session.sessionManager.getSessionName() ?? this.firstUserTitle,\n\t\t\t\t\t...(subagentVersion !== this.sentSubagentVersion ? { subagents: this.subagents.snapshot() } : {}),\n\t\t\t\t\t...(replace ? { replace: messages } : messages.length ? { append: messages } : {}),\n\t\t\t\t\tstatus: this.session.isWorking ? \"running\" : \"idle\",\n\t\t\t\t\tlive: {\n\t\t\t\t\t\tmessage: this.liveMessage ? (projectMessage(this.liveMessageId, this.liveMessage) ?? null) : null,\n\t\t\t\t\t\ttools: [...this.tools.values()],\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst response = await this.request(controller.signal).postJson(\"/api/observer\", update);\n\t\t\t\tif (observerId !== this.observerId) return false;\n\t\t\t\tif (response.status === 410) {\n\t\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (response.status === 409 && attempt === 0) {\n\t\t\t\t\tconst result = (await response.json()) as { snapshotRequired?: boolean };\n\t\t\t\t\tif (observerId !== this.observerId) return false;\n\t\t\t\t\tif (result.snapshotRequired) {\n\t\t\t\t\t\tthis.replace = true;\n\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t\tthis.sentSubagentVersion = -1;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!response.ok) throw new Error(`update failed (HTTP ${response.status})`);\n\t\t\t\tconst result = (await response.json()) as { accepted: boolean };\n\t\t\t\tif (!result.accepted) throw new Error(\"update was not accepted\");\n\t\t\t\tif (observerId !== this.observerId) return false;\n\t\t\t\tthis.published = true;\n\t\t\t\tthis.sentSubagentVersion = subagentVersion;\n\t\t\t\tif (entries.length > 0) this.sentEntryId = entries.at(-1)?.id;\n\t\t\t\telse if (replace) this.sentEntryId = undefined;\n\t\t\t\tif (this.deliveryFailed) {\n\t\t\t\t\tthis.deliveryFailed = false;\n\t\t\t\t\tconsole.error(\"pi-server observer delivery resumed\");\n\t\t\t\t}\n\t\t\t\tschedulePending = true;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} catch (error) {\n\t\t\tschedulePending = this.dirty;\n\t\t\tif (observerId === this.observerId && this.deletedSessionId !== sessionId) {\n\t\t\t\tthis.dirty = true;\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tthis.replace = true;\n\t\t\t\tthis.pendingEntries = [];\n\t\t\t\tthis.sentSubagentVersion = -1;\n\t\t\t\tthis.reportError(error);\n\t\t\t}\n\t\t\tcontroller.abort();\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tthis.sending = false;\n\t\t\tif (this.controller === controller) this.controller = undefined;\n\t\t\tif (schedulePending || observerId !== this.observerId) this.schedule(80);\n\t\t}\n\t}\n\n\tclose(): Promise<void> {\n\t\tthis.closePromise ??= this.drainAndClose();\n\t\treturn this.closePromise;\n\t}\n\n\tprivate async drainAndClose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.closing = true;\n\t\tclearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(\n\t\t\t\t(async () => {\n\t\t\t\t\tif (this.deletedSessionId === this.session.sessionId) return;\n\t\t\t\t\tawait this.flushPromise;\n\t\t\t\t\twhile (this.dirty && !this.disposed) {\n\t\t\t\t\t\tif (!(await this.flush()))\n\t\t\t\t\t\t\tthrow new Error(\"final transcript was not delivered: observer update failed\");\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t\tAbortSignal.timeout(10000),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(`pi-server observer shutdown failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t} finally {\n\t\t\tthis.dispose();\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.unsubscribe();\n\t\tthis.subagents.dispose();\n\t\tclearTimeout(this.timer);\n\t\tthis.controller?.abort();\n\t\tobservers.delete(this.session);\n\t}\n}\n"]}
|
|
@@ -239,7 +239,7 @@ export declare class InteractiveMode {
|
|
|
239
239
|
private showCancellationFailedStatusIndicator;
|
|
240
240
|
private clearStatusIndicator;
|
|
241
241
|
private showWorkingStatusIndicator;
|
|
242
|
-
private
|
|
242
|
+
private restoreWorkingStatusIndicator;
|
|
243
243
|
private setWorkingVisible;
|
|
244
244
|
private refreshStatusIndicator;
|
|
245
245
|
private setWorkingIndicator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAEN,KAAK,YAAY,EAKjB,MAAM,8BAA8B,CAAC;AActC,OAAO,EAYN,KAAK,QAAQ,EASb,MAAM,wBAAwB,CAAC;AAehC,OAAO,EAAE,KAAK,mBAAmB,EAAkC,MAAM,qCAAqC,CAAC;AAC/G,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AA+C1F,OAAO,EAEN,cAAc,EAGd,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,E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AC,yBAAyB;IA4EjC,OAAO,CAAC,yBAAyB;YA6CnB,iBAAiB;YA6EjB,8BAA8B;IAmG5C,OAAO,CAAC,qBAAqB;YA8Bf,qBAAqB;IAmDnC,OAAO,CAAC,cAAc;YAmCR,cAAc;IAwB5B,OAAO,CAAC,gBAAgB;YAaV,aAAa;YAuBb,eAAe;IAmC7B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;YAqDd,4BAA4B;YAgD5B,mBAAmB;YA2FnB,mBAAmB;IAkBjC,OAAO,CAAC,sBAAsB;YA6BhB,mBAAmB;YA4CnB,kBAAkB;YAWlB,gBAAgB;YAehB,iBAAiB;IA+B/B,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,oBAAoB;IAiF5B,OAAO,CAAC,sBAAsB;IAqB9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,oBAAoB;YAqHd,kBAAkB;IAehC,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,oBAAoB;YAMd,iBAAiB;YA6FjB,oBAAoB;IAUlC,IAAI,CAAC,oBAAoB,uBAAiD,GAAG,IAAI,CAoBhF;CACD"}
|
|
@@ -677,9 +677,7 @@ export class InteractiveMode {
|
|
|
677
677
|
nextUi.start();
|
|
678
678
|
this.themeController.rebindTui();
|
|
679
679
|
this.rebindExtensionTerminalInputListeners();
|
|
680
|
-
if (restoreProgress &&
|
|
681
|
-
this.settingsManager.getShowTerminalProgress() &&
|
|
682
|
-
(this.session.isStreaming || this.session.isCompacting)) {
|
|
680
|
+
if (restoreProgress && this.settingsManager.getShowTerminalProgress() && this.session.isWorking) {
|
|
683
681
|
terminal.setProgress(true);
|
|
684
682
|
}
|
|
685
683
|
return true;
|
|
@@ -1954,8 +1952,8 @@ export class InteractiveMode {
|
|
|
1954
1952
|
: undefined;
|
|
1955
1953
|
this.showStatusIndicator(new WorkingStatusIndicator(this.ui, this.workingMessage ?? this.defaultWorkingMessage, this.workingIndicatorOptions, colorFn));
|
|
1956
1954
|
}
|
|
1957
|
-
|
|
1958
|
-
if (!this.session.
|
|
1955
|
+
restoreWorkingStatusIndicator() {
|
|
1956
|
+
if (!this.session.isWorking) {
|
|
1959
1957
|
return;
|
|
1960
1958
|
}
|
|
1961
1959
|
if (this.workingVisible && this.activeStatusIndicator?.kind !== "working") {
|
|
@@ -1976,7 +1974,7 @@ export class InteractiveMode {
|
|
|
1976
1974
|
this.ui.requestRender();
|
|
1977
1975
|
return;
|
|
1978
1976
|
}
|
|
1979
|
-
if (this.session.
|
|
1977
|
+
if (this.session.isWorking && !this.activeStatusIndicator) {
|
|
1980
1978
|
this.showWorkingStatusIndicator();
|
|
1981
1979
|
}
|
|
1982
1980
|
this.ui.requestRender();
|
|
@@ -1986,7 +1984,9 @@ export class InteractiveMode {
|
|
|
1986
1984
|
this.showAbortingStatusIndicator();
|
|
1987
1985
|
return;
|
|
1988
1986
|
}
|
|
1989
|
-
if (this.session.
|
|
1987
|
+
if (this.session.isWorking) {
|
|
1988
|
+
if (this.activeStatusIndicator && this.activeStatusIndicator.kind !== "working")
|
|
1989
|
+
return;
|
|
1990
1990
|
if (this.workingVisible) {
|
|
1991
1991
|
this.showStatusIndicator(new WorkingStatusIndicator(this.ui, this.workingMessage ?? this.defaultWorkingMessage, this.workingIndicatorOptions));
|
|
1992
1992
|
}
|
|
@@ -2946,6 +2946,7 @@ export class InteractiveMode {
|
|
|
2946
2946
|
this.unsubscribe = this.session.subscribe(async (event) => {
|
|
2947
2947
|
await this.handleEvent(event);
|
|
2948
2948
|
});
|
|
2949
|
+
void this.handleEvent({ type: "working_state_changed", working: this.session.isWorking });
|
|
2949
2950
|
}
|
|
2950
2951
|
async handleEvent(event) {
|
|
2951
2952
|
if (!this.isInitialized) {
|
|
@@ -2954,6 +2955,20 @@ export class InteractiveMode {
|
|
|
2954
2955
|
this.footer.invalidate();
|
|
2955
2956
|
this.programStatus.handleEvent(event);
|
|
2956
2957
|
switch (event.type) {
|
|
2958
|
+
case "working_state_changed":
|
|
2959
|
+
if (event.working) {
|
|
2960
|
+
this.refreshStatusIndicator();
|
|
2961
|
+
}
|
|
2962
|
+
else {
|
|
2963
|
+
this.clearStatusIndicator(undefined, true);
|
|
2964
|
+
}
|
|
2965
|
+
if (this.settingsManager.getShowTerminalProgress()) {
|
|
2966
|
+
this.ui.terminal.setProgress(event.working);
|
|
2967
|
+
}
|
|
2968
|
+
this.ui.requestRender();
|
|
2969
|
+
if (!event.working)
|
|
2970
|
+
await this.checkShutdownRequested();
|
|
2971
|
+
break;
|
|
2957
2972
|
case "agent_start":
|
|
2958
2973
|
this.pendingTools.clear();
|
|
2959
2974
|
// Restore main escape handler if retry handler is still active
|
|
@@ -2997,10 +3012,8 @@ export class InteractiveMode {
|
|
|
2997
3012
|
this.ui.requestRender();
|
|
2998
3013
|
break;
|
|
2999
3014
|
case "abort_end":
|
|
3000
|
-
this.
|
|
3001
|
-
|
|
3002
|
-
this.ui.terminal.setProgress(false);
|
|
3003
|
-
}
|
|
3015
|
+
if (this.session.isWorking)
|
|
3016
|
+
this.refreshStatusIndicator();
|
|
3004
3017
|
this.ui.requestRender();
|
|
3005
3018
|
break;
|
|
3006
3019
|
case "queue_update":
|
|
@@ -3193,21 +3206,6 @@ export class InteractiveMode {
|
|
|
3193
3206
|
this.pendingTools.clear();
|
|
3194
3207
|
this.ui.requestRender();
|
|
3195
3208
|
break;
|
|
3196
|
-
case "agent_settled":
|
|
3197
|
-
if (this.session.isAborting) {
|
|
3198
|
-
this.showAbortingStatusIndicator();
|
|
3199
|
-
}
|
|
3200
|
-
else if (this.session.isStreaming) {
|
|
3201
|
-
this.refreshStatusIndicator();
|
|
3202
|
-
}
|
|
3203
|
-
else if (!this.session.isCompacting && !this.session.isRetrying) {
|
|
3204
|
-
if (this.settingsManager.getShowTerminalProgress()) {
|
|
3205
|
-
this.ui.terminal.setProgress(false);
|
|
3206
|
-
}
|
|
3207
|
-
this.clearStatusIndicator("working", true);
|
|
3208
|
-
}
|
|
3209
|
-
await this.checkShutdownRequested();
|
|
3210
|
-
break;
|
|
3211
3209
|
case "compaction_start": {
|
|
3212
3210
|
if (this.settingsManager.getShowTerminalProgress()) {
|
|
3213
3211
|
this.ui.terminal.setProgress(true);
|
|
@@ -3225,9 +3223,6 @@ export class InteractiveMode {
|
|
|
3225
3223
|
break;
|
|
3226
3224
|
}
|
|
3227
3225
|
case "compaction_end": {
|
|
3228
|
-
if (this.settingsManager.getShowTerminalProgress()) {
|
|
3229
|
-
this.ui.terminal.setProgress(false);
|
|
3230
|
-
}
|
|
3231
3226
|
if (this.autoCompactionEscapeHandler) {
|
|
3232
3227
|
this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
|
|
3233
3228
|
this.autoCompactionEscapeHandler = undefined;
|
|
@@ -3272,8 +3267,8 @@ export class InteractiveMode {
|
|
|
3272
3267
|
if (this.session.isAborting) {
|
|
3273
3268
|
this.showAbortingStatusIndicator();
|
|
3274
3269
|
}
|
|
3275
|
-
else if (this.session.
|
|
3276
|
-
this.
|
|
3270
|
+
else if (this.session.isWorking) {
|
|
3271
|
+
this.restoreWorkingStatusIndicator();
|
|
3277
3272
|
}
|
|
3278
3273
|
if (!event.aborted && !this.session.isAborting) {
|
|
3279
3274
|
void this.flushCompactionQueue({ willRetry: event.willRetry });
|
|
@@ -3305,8 +3300,8 @@ export class InteractiveMode {
|
|
|
3305
3300
|
if (this.session.isAborting) {
|
|
3306
3301
|
this.showAbortingStatusIndicator();
|
|
3307
3302
|
}
|
|
3308
|
-
else if (this.session.
|
|
3309
|
-
this.
|
|
3303
|
+
else if (this.session.isWorking) {
|
|
3304
|
+
this.restoreWorkingStatusIndicator();
|
|
3310
3305
|
}
|
|
3311
3306
|
this.ui.requestRender();
|
|
3312
3307
|
break;
|