fix: add connectionManager @W-22389160@#278
Open
EstebanRomero84 wants to merge 8 commits into
Open
Conversation
|
|
||
| protected constructor(protected readonly connection: Connection) {} | ||
|
|
||
| public async restoreConnection(): Promise<void> { |
Member
There was a problem hiding this comment.
I like the ConnectionManager a lot more, but will removing this be breaking anywhere in the plugin/VSC?
Contributor
Author
There was a problem hiding this comment.
Good catch, I'l revert this change
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new
ConnectionManagerclass that centralizes and improves the management of JWT and standard Salesforce connections for agent operations. The main goal is to fix JWT token handling issues and prevent token clobbering when agents interact with both SFAP (Salesforce AI Platform) APIs and org-instance operations.Key Changes:
New
ConnectionManagerclass (src/connectionManager.ts):refreshStandardConnection()method for connection refresh operationsUpdated
Agent.init()method (src/agent.ts):ConnectionManager.create()ScriptAgentandProductionAgentConnectionManagerinstead of a raw connectionRefactored
AgentBaseclass (src/agents/agentBase.ts):Connectionto storingConnectionManagerrestoreConnection()method for downstream applicationsConnectionManager.refreshStandardConnection()internallyUpdated Agent implementations (
ProductionAgentandScriptAgent):connectionManager.getJwtConnection()for SFAP API callsconnectionManager.getStandardConnection()for org operations (SOQL queries, tooling API, metadata operations)Simplified
ScriptAgentPublisher(src/agents/scriptAgentPublisher.ts):createStandardConnection()methodConnectionManagerComprehensive test updates:
ConnectionManagerWhy is this important?
This fix addresses a critical issue where JWT tokens could be clobbered (overwritten) by auto-refresh attempts during org operations, causing agent operations to fail. By isolating JWT and standard connections, we:
Breaking Changes
❌ None - All public APIs are maintained for backward compatibility. The
restoreConnection()method continues to work exactly as before for downstream applications.Technical Details
The
ConnectionManagerprovides:getJwtConnection(): Returns JWT-authenticated connection for SFAP API endpointsgetStandardConnection(): Returns standard connection for org-instance operationsrefreshStandardConnection(): Refreshes the standard connection (used internally byrestoreConnection())inspectJwt(): Returns detailed JWT validation information for troubleshootingIssues Addressed
@W-22389160@