Skip to content

Commit 947a335

Browse files
committed
merge: update PR branch with main
2 parents 6086b14 + 1763792 commit 947a335

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/lib/onboard/messaging-prep.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ export function prepareCreateSandboxMessaging(
102102
retainWhileDisabled: staticProviderType !== null,
103103
};
104104
})
105-
.filter(({ envKey }) => !enabledEnvKeys || enabledEnvKeys.has(envKey));
105+
.filter(
106+
({ envKey, retainWhileDisabled }) =>
107+
!enabledEnvKeys ||
108+
enabledEnvKeys.has(envKey) ||
109+
(retainWhileDisabled && disabledEnvKeys.has(envKey)),
110+
);
106111
const messagingTokenDefs: MessagingTokenDef[] = messagingCredentialDefs
107112
.filter(({ envKey }) => !disabledEnvKeys.has(envKey))
108113
.map(({ retainWhileDisabled: _retainWhileDisabled, ...definition }) => definition);
@@ -196,8 +201,11 @@ export function prepareCreateSandboxMessaging(
196201
retainWhileDisabled,
197202
} of messagingCredentialDefs) {
198203
const channel = input.getMessagingChannelForEnvKey(envKey);
199-
if (!channel || !input.enabledChannels.includes(channel)) continue;
204+
if (!channel) continue;
200205
const channelDisabled = disabledChannelNames.has(channel);
206+
if (!input.enabledChannels.includes(channel) && !(channelDisabled && retainWhileDisabled)) {
207+
continue;
208+
}
201209
if (channelDisabled && !retainWhileDisabled) continue;
202210
// Disabled definitions are intentionally absent from messagingTokenDefs,
203211
// so even a still-readable source token cannot recreate their provider.

test/hermes-discord-credential-binding.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function prepareDiscord(
2525
sandboxName: SANDBOX_NAME,
2626
agentName: "hermes",
2727
channels: discord,
28-
enabledChannels: ["discord"],
28+
enabledChannels: disabled ? [] : ["discord"],
2929
disabledChannels: disabled ? ["discord"] : [],
3030
webSearchConfig: null,
3131
env: token ? { DISCORD_BOT_TOKEN: token } : {},
@@ -66,9 +66,12 @@ describe("Hermes Discord credential endpoint binding", () => {
6666
expect(profileYaml.endpoints).toEqual([]);
6767
});
6868

69-
it("does not reuse an untyped provider for the endpoint-bound credential", () => {
69+
it.each([
70+
{ state: "active", disabled: false },
71+
{ state: "stopped", disabled: true },
72+
])("does not reuse an untyped provider for a $state channel", ({ disabled }) => {
7073
const providerMatches = vi.fn(() => false);
71-
const result = prepareDiscord(null, providerMatches);
74+
const result = prepareDiscord(null, providerMatches, disabled);
7275

7376
expect(result.reusableMessagingProviders).toEqual([]);
7477
expect(result.reusableMessagingChannels).toEqual([]);

0 commit comments

Comments
 (0)