Skip to content

Commit 9394721

Browse files
Merge pull request #260 from salesforcecli/er/publishAgent
W-19857466: preserve accessToken before calling ai-agent APIs
2 parents e264d40 + 66c9f87 commit 9394721

File tree

2 files changed

+676
-670
lines changed

2 files changed

+676
-670
lines changed

src/commands/agent/publish/authoring-bundle.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
103103
const targetOrg = flags['target-org'];
104104
const conn = targetOrg.getConnection(flags['api-version']);
105105

106+
// Preserve the original accessToken by storing its value
107+
const originalAccessToken = conn.accessToken;
108+
106109
// First compile the .agent file to get the Agent JSON
107110
const compileResponse = await Agent.compileAgentScript(
108111
conn,
@@ -133,6 +136,9 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
133136
}
134137
return Promise.resolve();
135138
});
139+
140+
// Restore the original accessToken after compilation
141+
conn.accessToken = originalAccessToken;
136142
const result = await Agent.publishAgentJson(conn, this.project!, compileResponse.compiledArtifact);
137143
mso.stop();
138144

0 commit comments

Comments
 (0)