Skip to content

refactor: overhaul plugin architecture - #14

Merged
NoOne7135 merged 3 commits into
mainfrom
refactor
Jul 2, 2026
Merged

refactor: overhaul plugin architecture#14
NoOne7135 merged 3 commits into
mainfrom
refactor

Conversation

@NoOne7135

Copy link
Copy Markdown
Contributor

No description provided.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the agent plugin into a layered architecture (domain/application/llm/transport/persistence/tools), introduces a provider port for the LLM runtime, and adds persistent checkpoint support for HITL (human-in-the-loop) resumes.

Changes:

  • Replaces the former AgentTurnService orchestration stack with RunTurnUseCase + an LlmPort (LangGraphLlm) and typed streaming (AgentStreamChunk).
  • Moves cross-cutting utilities into shared/ and domain logic into domain/, updating imports across transports/tools/tests.
  • Adds AdminForth-backed checkpoint persistence (AdminForthCheckpointSaver) and reorganizes HTTP endpoints (including new chat-surface webhook endpoints).

Reviewed changes

Copilot reviewed 45 out of 53 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
types.tsUpdates plugin option types and deprecates unused fields for backwards compatibility.
transport/surfaces/speechTurnService.tsRepoints surface implementation to new shared/domain modules.
transport/surfaces/chatSurfaceService.tsUpdates surface flow to use new domain/shared modules and masks user-facing error messages.
transport/sse/sseWriter.tsUpdates imports and documents SSE wire contract mapping.
transport/http/sessionEndpoints.tsUses persistence session store constant and sets HTTP status codes on auth/not-found cases.
transport/http/coreEndpoints.tsSwitches SSE emitter import and simplifies handler signatures.
transport/http/context.tsRepoints endpoint context types to the new domain types and plugin options.
transport/http/chatSurfaceEndpoints.tsAdds webhook endpoints for external chat surfaces.
tools/skills/registry.tsAdds skill discovery/loading from SKILL.md directories (project + plugins).
tools/navigateUser.tsUpdates agent event imports and uses adminPublicOrigin to build external links for chat surfaces.
tools/index.tsUpdates tool dependency imports after refactor.
tools/getUserLocation.tsAdds a dedicated tool for retrieving the user’s current AdminForth page context.
tools/fetchToolSchema.tsUpdates tool dependency imports after refactor.
tools/fetchSkill.tsUpdates skill registry import path after refactor.
tools/apiTool.tsUpdates tool dependency imports after refactor.
tools/apiBasedTools.tsRemoves verbose OpenAPI/tool invocation logging and updates structure after refactor.
tools/agentToolProvider.tsRepoints to new tools module layout.
tests/units.test.tsUpdates unit test imports; removes AgentModeResolver characterization tests.
tests/turn_flow.test.tsRewrites characterization tests to drive RunTurnUseCase + typed stream chunks and resume logic.
tests/system_prompt.test.tsUpdates imports to new domain system prompt module.
tests/stream_adapter.test.tsAdds coverage for raw LangGraph stream parsing into typed chunks.
tests/sse_emitter.test.tsUpdates imports to new SSE writer location.
tests/session_store.test.tsUpdates imports to new persistence session store location.
shared/sanitizeSpeechText.tsMoves speech-text sanitization to shared module.
shared/errors.tsCentralizes abort detection + error message formatting.
persistence/sessionStore.tsAdds touchSession, saveTurnResponse, and getResumeState APIs and repoints domain imports.
persistence/checkpointStore.tsAdds AdminForth-backed LangGraph checkpointer implementation.
llm/streamAdapter.tsIntroduces raw stream adapter/parser and interrupt normalization.
llm/modelFactory.tsRepoints model factory to new llm agentModels module.
llm/middleware/sequenceDebug.tsUpdates tool-call event import path after refactor.
llm/middleware/apiToolsMiddleware.tsRepoints to new tool/event modules and removes verbose logging.
llm/langGraphLlm.tsImplements LlmPort using LangChain/LangGraph and typed stream adaptation.
llm/agentRuntime.tsRehomes agent runtime and adds pending-interrupts checkpoint read helper.
llm/agentModels.tsCentralizes model creation + adapter contract and metrics logger.
llm/agentContext.tsUpdates runtime context typing and imports after refactor.
index.tsRewires plugin setup to new layered components, checkpointer, and endpoints.
domain/vegaLiteStreamBuffer.tsUpdates imports to new domain agent events module.
domain/turnTypes.tsIntroduces typed stream chunks, provider-agnostic messages, and narrows debug sink contract.
domain/toolCallEvents.tsMoves tool-call debug tracking/events into domain layer.
domain/systemPrompt.tsRepoints skill registry import to new tools location.
domain/languageDetect.tsMoves language detection into domain, using completion adapter structured output.
domain/agentEvents.tsRepoints tool-call event import to new domain module.
application/runTurnUseCase.tsNew single orchestration entrypoint for turn handling, streaming, persistence, and HITL resume.
application/ports.tsDefines the provider port (LlmPort) and adapter contract (AgentModeCompletionAdapter).
agentTurnService.tsRemoved: replaced by application/runTurnUseCase.ts orchestration.
agent/turn/TurnStreamConsumer.tsRemoved: replaced by llm/streamAdapter.ts + use-case consumption.
agent/turn/TurnPromptBuilder.tsRemoved: replaced by RunTurnUseCase.buildMessages() + domain system prompt builder.
agent/turn/TurnPersistenceService.tsRemoved: logic moved into persistence/sessionStore.ts.
agent/turn/TurnLifecycleService.tsRemoved: logic moved into RunTurnUseCase.prepareTurn() + session store helpers.
agent/turn/TurnContextBuilder.tsRemoved: replaced by RunTurnUseCase.buildContext().
agent/simpleAgent.tsRemoved: replaced by llm/agentModels.ts and application-layer adapter contract.
agent/models/AgentModeResolver.tsRemoved: mode resolution now in RunTurnUseCase.resolveMode().
agent/middleware/openAiResponsesContinuation.tsRemoved as part of the architecture overhaul.
Comments suppressed due to low confidence (1)

persistence/sessionStore.ts:110

  • touchSession() updates the field configured as sessionResource.createdAtField. This makes the stored/returned “created at” timestamp inaccurate and also changes /agent/get-sessions ordering semantics (it effectively becomes “last activity”). Consider adding a dedicated updatedAtField/lastActivityField to ISessionResource and using that for touch + sorting, leaving createdAtField immutable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NoOne7135
NoOne7135 merged commit 07346f5 into mainJul 2, 2026
3 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@NoOne7135