Skip to content
TypeScript

test(server): consolidate agent activity opt-in coverage (#9988)

Julius Marminge94d1fa7ff268
diff --git a/apps/server/src/cli/connect.test.ts b/apps/server/src/cli/connect.test.ts
index f05eeab631f..f3cc88d1b58 100644
--- a/apps/server/src/cli/connect.test.ts
+++ b/apps/server/src/cli/connect.test.ts
@@ -14,7 +14,6 @@ import * as BootService from "../cloud/bootService.ts";
import {
acquireRelayClientForLink,
headlessSessionConfig,
- isPublishAgentActivityEnabledValue,
reportCloudDisconnectResults,
} from "./connect.ts";
import { recoverServiceOnboardingOffer } from "./service.ts";
@@ -190,10 +189,3 @@ it.effect("keeps disconnect causes in structured logs and out of console warning
),
);
});
-
-it("treats only the literal 'true' as publish-enabled", () => {
- assert.equal(isPublishAgentActivityEnabledValue("true"), true);
- assert.equal(isPublishAgentActivityEnabledValue("false"), false);
- assert.equal(isPublishAgentActivityEnabledValue(null), false);
- assert.equal(isPublishAgentActivityEnabledValue("TRUE"), false);
-});
diff --git a/apps/server/src/cli/connect.ts b/apps/server/src/cli/connect.ts
index faa8f69871d..b7c78e5ea68 100644
--- a/apps/server/src/cli/connect.ts
+++ b/apps/server/src/cli/connect.ts
@@ -144,10 +144,6 @@ function stringToBytes(value: string): Uint8Array {
return new TextEncoder().encode(value);
}
-export function isPublishAgentActivityEnabledValue(value: string | null): boolean {
- return isAgentActivityPublishingEnabledValue(value);
-}
-
interface CloudCliStatus {
readonly desired: boolean;
readonly authenticated: boolean;
@@ -573,7 +569,7 @@ const connectStatusCommand = Command.make("status", {
linked: Option.isSome(cloudUserId),
cloudUserId: Option.isSome(cloudUserId) ? bytesToString(cloudUserId.value) : null,
relayUrl: Option.isSome(relayUrl) ? bytesToString(relayUrl.value) : null,
- publishAgentActivity: isPublishAgentActivityEnabledValue(
+ publishAgentActivity: isAgentActivityPublishingEnabledValue(
Option.isSome(publishAgentActivity) ? bytesToString(publishAgentActivity.value) : null,
),
relayClient: executable,
diff --git a/apps/server/src/relay/AgentAwarenessRelay.test.ts b/apps/server/src/relay/AgentAwarenessRelay.test.ts
index 5c79a543fb4..ee23cbffaf0 100644
--- a/apps/server/src/relay/AgentAwarenessRelay.test.ts
+++ b/apps/server/src/relay/AgentAwarenessRelay.test.ts
@@ -39,6 +39,7 @@ import {
type ProjectionSnapshotQueryShape,
} from "../orchestration/Services/ProjectionSnapshotQuery.ts";
import {
+ isAgentActivityPublishingEnabledValue,
RELAY_ENVIRONMENT_CREDENTIAL_SECRET,
RELAY_ISSUER_SECRET,
RELAY_URL_SECRET,
@@ -220,9 +221,10 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
});
it("requires an explicit opt-in before publishing agent activity", () => {
- expect(AgentAwarenessRelay.isAgentActivityPublishingEnabled(null)).toBe(false);
- expect(AgentAwarenessRelay.isAgentActivityPublishingEnabled("false")).toBe(false);
- expect(AgentAwarenessRelay.isAgentActivityPublishingEnabled("true")).toBe(true);
+ expect(isAgentActivityPublishingEnabledValue(null)).toBe(false);
+ expect(isAgentActivityPublishingEnabledValue("false")).toBe(false);
+ expect(isAgentActivityPublishingEnabledValue("TRUE")).toBe(false);
+ expect(isAgentActivityPublishingEnabledValue("true")).toBe(true);
});
it("redacts failed activity details and caps other relay detail", () => {
diff --git a/apps/server/src/relay/AgentAwarenessRelay.ts b/apps/server/src/relay/AgentAwarenessRelay.ts
index 5127ecf7d35..3dd0df642ce 100644
--- a/apps/server/src/relay/AgentAwarenessRelay.ts
+++ b/apps/server/src/relay/AgentAwarenessRelay.ts
@@ -102,10 +102,6 @@ export function agentAwarenessPublishIdentity(state: RelayAgentActivityState | n
return JSON.stringify(meaningfulState);
}
-export function isAgentActivityPublishingEnabled(value: string | null): boolean {
- return isAgentActivityPublishingEnabledValue(value);
-}
-
export function resolveAgentActivityPublishingStartupState(input: {
readonly relayConfigured: boolean;
readonly publishEnabled: boolean;
@@ -322,7 +318,7 @@ export const make = Effect.gen(function* () {
});
const readPublishAgentActivityEnabled = readSecretString(PUBLISH_AGENT_ACTIVITY_SECRET).pipe(
- Effect.map(isAgentActivityPublishingEnabled),
+ Effect.map(isAgentActivityPublishingEnabledValue),
);
const makeRelayClient = (relayConfig: {