Skip to content

refactor(agent-service): centralize backend DTOs, metadata, endpoint config, and auth#5928

Draft
bobbai00 wants to merge 2 commits into
apache:mainfrom
bobbai00:refactor/agent-service-dto
Draft

refactor(agent-service): centralize backend DTOs, metadata, endpoint config, and auth#5928
bobbai00 wants to merge 2 commits into
apache:mainfrom
bobbai00:refactor/agent-service-dto

Conversation

@bobbai00

@bobbai00 bobbai00 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Centralizes the agent-service type/config layer (no runtime behavior change). Stacked on #5751 (the WS-types PR).

  • types/dto.ts — backend request/response DTOs (workflow persistence, compiling-service responses, WorkflowFatalError).
  • types/metadata.ts — operator-metadata types extracted from api/backend-api.
  • config/endpoints.tsgetServiceEndpoints() centralizing backend base URLs.
  • auth/jwt.ts — relocated from api/auth-api; import paths updated.
  • Replace any with precise types across src/types/*; type ReActStep tool/message fields.
  • Consume the centralized types at the call sites (clients, server, agent utils); expand test coverage (jwt, workflow-system-metadata, compile/workflow clients) and rename *.test.ts*.spec.ts.

types/execution.ts is intentionally untouched here — its redesign is #5927.

Any related issues, documentation, discussions?

Closes #5748
Part of #5747.

How was this PR tested?

bunx tsc --noEmit, bun test (126 pass / 0 fail), and prettier --check all pass in agent-service.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.8 (1M context)

bobbai00 and others added 2 commits June 24, 2026 00:17
Move the inline WS message definitions out of server.ts into a dedicated
types/ws module, modeled as discriminated unions rather than one
all-optional interface:

- client.ts: WsClientRequest = WsClientRequestPrompt | WsClientRequestStopCommand
- server.ts: WsServerMessage union (init/step/state/complete/error/headChange) + OperatorResultSummaryWs
- index.ts: barrel, re-exported from the types barrel

The client->server wire discriminator changes from "message"/"stop" to
"prompt"/"command" (stop becomes commandType: "stop"); server->client `type`
values are unchanged. server.ts parses WsClientRequest and switches on the new
shapes, and the frontend WS sends are updated in lockstep.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qFkyrpTd5PrkNBPcBeo4Q
…config, and auth

Consolidate the agent-service type/config layer. Stacked on the WS PR (apache#5751);
types/execution.ts is left untouched (its redesign is a separate PR).

- types/dto.ts: backend request/response DTOs (workflow persistence, compiling-service responses, WorkflowFatalError).
- types/metadata.ts: operator-metadata types extracted from api/backend-api.
- config/endpoints.ts: getServiceEndpoints() centralizing backend base URLs.
- auth/jwt.ts: relocated from api/auth-api; update import paths.
- Replace `any` with precise types across src/types/*; type ReActStep tool/message fields precisely.
- Consume the centralized types at call sites (clients, server, agent utils).
- Expand test coverage (jwt, workflow-system-metadata, compile/workflow clients); rename *.test.ts -> *.spec.ts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qFkyrpTd5PrkNBPcBeo4Q
@github-actions github-actions Bot added refactor Refactor the code frontend Changes related to the frontend GUI agent-service labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Ma77Ball, @officialasishkumar
    You can notify them by mentioning @Ma77Ball, @officialasishkumar in a comment.

@codecov-commenter

codecov-commenter commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.63636% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.02%. Comparing base (1c580e5) to head (ee9205f).

Files with missing lines Patch % Lines
agent-service/src/server.ts 7.14% 13 Missing ⚠️
agent-service/src/agent/texera-agent.ts 16.66% 5 Missing ⚠️
...d/src/app/workspace/service/agent/agent.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5928      +/-   ##
============================================
+ Coverage     54.60%   55.02%   +0.42%     
  Complexity     2927     2927              
============================================
  Files          1109     1109              
  Lines         42828    42817      -11     
  Branches       4608     4608              
============================================
+ Hits          23385    23561     +176     
+ Misses        18081    17894     -187     
  Partials       1362     1362              
Flag Coverage Δ *Carryforward flag
access-control-service 70.44% <ø> (ø) Carriedforward from 508e72c
agent-service 39.82% <14.28%> (+5.46%) ⬆️
amber 56.73% <ø> (ø) Carriedforward from 508e72c
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from 508e72c
config-service 57.35% <ø> (ø) Carriedforward from 508e72c
file-service 58.59% <ø> (ø) Carriedforward from 508e72c
frontend 48.32% <0.00%> (+<0.01%) ⬆️
pyamber 90.20% <ø> (ø) Carriedforward from 508e72c
python 90.76% <ø> (ø) Carriedforward from 508e72c
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from 508e72c

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-service frontend Changes related to the frontend GUI refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(agent-service): centralize backend DTOs, metadata, endpoint config, and auth

2 participants