@devries-cameron20 / t3code-1 / commits / 84537c4dd9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(server): read source control host tokens from a secret provider (#27756)

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Yordis Prieto committed Nov 2, 2026 at 14:23 UTC 84537c4dd976a89b6ec094f43ae3ef7bee12cb1a
12 files changed +256 -58
apps/server/src/provider/ProviderInstanceRegistry.ts
+11 -9
@@ -9,6 +9,8 @@ import {
9 type SecretReference,
10 secretReferencesInSettings,
11 type ServerProvider,
12 + type SettingsSecretSlot,
13 + withSettingsSecrets,
14 } from "@t3tools/contracts";
15 import * as Context from "effect/Context";
16 import * as Effect from "effect/Effect";
@@ -45,7 +47,7 @@ export class ProviderInstanceRegistry extends Context.Service<
47
48 interface InstanceSecrets {
49 readonly environment: ResolvedProviderInstanceEnvironment;
48 - readonly config: Readonly<Record<string, string>>;
50 + readonly config: ReadonlyArray<SettingsSecretSlot & { readonly value: string }>;
51 }
52
53 interface LiveEntry {
@@ -110,12 +112,12 @@ const readInstanceSecrets = Effect.fn("ProviderInstanceRegistry.readInstanceSecr
112 }
113 return [{ ...variable, value: secret, sensitive: true }];
114 });
113 - const config: Record<string, string> = {};
114 - for (const { field } of configFields) {
115 + const config = configFields.flatMap(({ field, key }) => {
116 const secret = values[index++];
116 - if (secret === undefined) unreadable.push(field);
117 - else config[field] = secret;
118 - }
117 + if (secret !== undefined) return [{ field, key, value: secret }];
118 + unreadable.push(field);
119 + return [];
120 + });
121 const secrets: InstanceSecrets = { environment, config };
122 return { secrets, unreadable };
123 });
@@ -224,7 +226,7 @@ const buildEntry = Effect.fn("ProviderInstanceRegistry.buildEntry")(function* <R
226 const { secrets, unreadable } = enabled
227 ? yield* readInstanceSecrets(driver, entry)
228 : {
227 - secrets: { environment: withoutSecretReferences(entry.environment ?? []), config: {} },
229 + secrets: { environment: withoutSecretReferences(entry.environment ?? []), config: [] },
230 unreadable: [],
231 };
232 // Starting with a blank credential would fail later with a less useful error, or fall back to
@@ -252,9 +254,9 @@ const buildEntry = Effect.fn("ProviderInstanceRegistry.buildEntry")(function* <R
254 environment: secrets.environment,
255 enabled,
256 config:
255 - Object.keys(secrets.config).length === 0
257 + secrets.config.length === 0
258 ? typedConfig
257 - : { ...typedConfig, ...secrets.config },
259 + : withSettingsSecrets(typedConfig, secrets.config),
260 })
261 .pipe(Effect.provideService(Scope.Scope, childScope), Effect.result);
262 if (createResult._tag === "Failure") {
apps/server/src/secrets/settingsSecretValue.ts
+5 -5
@@ -1,10 +1,10 @@
1 -import { secretReferencesInSettings } from "@t3tools/contracts";
1 +import { secretReferencesInSettings, withSettingsSecrets } from "@t3tools/contracts";
2 import type * as SecretResolver from "@t3tools/secret-provider-core/server/SecretResolver";
3 import * as Effect from "effect/Effect";
4 import type * as Schema from "effect/Schema";
5
6 /**
7 - * Replaces each reference in the fields `schema` declares as `SettingsSecretValue` with the secret
7 + * Replaces each reference in the slots `schema` declares as `SettingsSecretValue` with the secret
8 * it names, read in one batch. An unreadable secret comes back as `""`, so it behaves as unset.
9 */
10 export const resolveSettingsSecrets = Effect.fn("SettingsSecrets.resolve")(function* <
@@ -13,8 +13,8 @@ export const resolveSettingsSecrets = Effect.fn("SettingsSecrets.resolve")(funct
13 const pending = secretReferencesInSettings(schema, settings);
14 if (pending.length === 0) return settings;
15 const values = yield* resolver.read(pending.map(({ reference }) => reference));
16 - const resolved = Object.fromEntries(
17 - pending.map(({ field }, index) => [field, values[index] ?? ""] as const),
16 + return withSettingsSecrets(
17 + settings,
18 + pending.map((slot, index) => ({ ...slot, value: values[index] ?? "" })),
19 );
19 - return { ...settings, ...resolved };
20 });
apps/server/src/serverSettings.test.ts
+21 -7
@@ -1547,20 +1547,34 @@ it.layer(NodeServices.layer)("server settings", (it) => {
1547 provider: SecretProviderId.make("personal"),
1548 reference: "op://Private/Bitbucket/token",
1549 };
1550 + const gitHubReference = {
1551 + provider: SecretProviderId.make("personal"),
1552 + reference: "op://Private/GitHub/token",
1553 + };
1554 yield* serverSettings.updateSettings({
1551 - sourceControlHosts: { bitbucket: { accessToken: "bb-access" } },
1555 + sourceControlHosts: {
1556 + bitbucket: { accessToken: "bb-access" },
1557 + github: { tokens: { "github.com": "ghp_dotcom", "ghe.acme.test": "ghp_ghe" } },
1558 + },
1559 });
1560 assert.isTrue(Option.isSome(yield* stored("bitbucket", "accessToken", null)));
1561 + assert.isTrue(Option.isSome(yield* stored("github", "tokens", "github.com")));
1562 const referenced = yield* serverSettings.updateSettings({
1555 - sourceControlHosts: { bitbucket: { accessToken: reference } },
1563 + sourceControlHosts: {
1564 + bitbucket: { accessToken: reference },
1565 + github: { tokens: { "github.com": gitHubReference, "ghe.acme.test": "ghp_ghe" } },
1566 + },
1567 });
1568 assert.deepEqual(referenced.sourceControlHosts.bitbucket?.accessToken, reference);
1569 assert.isTrue(Option.isNone(yield* stored("bitbucket", "accessToken", null)));
1559 - assert.deepEqual(
1560 - ServerSettingsModule.redactServerSettingsForClient(referenced).sourceControlHosts
1561 - .bitbucket?.accessToken,
1562 - reference,
1563 - );
1570 + assert.isTrue(Option.isNone(yield* stored("github", "tokens", "github.com")));
1571 + assert.isTrue(Option.isSome(yield* stored("github", "tokens", "ghe.acme.test")));
1572 + const redacted =
1573 + ServerSettingsModule.redactServerSettingsForClient(referenced).sourceControlHosts;
1574 + assert.deepEqual(redacted.bitbucket?.accessToken, reference);
1575 + const tokens = redacted.github?.tokens as Record<string, unknown>;
1576 + assert.deepEqual(tokens["github.com"], gitHubReference);
1577 + assert.notEqual(tokens["ghe.acme.test"], "ghp_ghe");
1578 }).pipe(Effect.provide(layerServerSettingsWithSecrets())),
1579 );
1580
apps/server/src/sourceControl/sourceControlHostSecrets.test.ts
+22 -1
@@ -14,7 +14,14 @@ const source = (reference: string) => ({
14 reference,
15 });
16
17 -const secretsByReference = new Map([["bitbucket#token", "bb_from_provider"]]);
17 +const secretsByReference = new Map([
18 + ["bitbucket#token", "bb_from_provider"],
19 + ["github#token", "ghp_from_provider"],
20 +]);
21 +
22 +const perHostHosts = {
23 + github: { tokens: { "github.com": source("github#token"), "ghe.acme.test": "ghp_literal" } },
24 +};
25
26 const hosts = {
27 bitbucket: { email: "me@example.test", accessToken: source("bitbucket#token") },
@@ -69,11 +76,25 @@ it.effect("leaves the resolver unused for a kind that holds no reference", () =>
76 }),
77 );
78
79 +it.effect("replaces a per-host token reference and keeps the literal beside it", () =>
80 + Effect.gen(function* () {
81 + const { reads, resolver } = countingResolver();
82 + const resolved = yield* resolveSourceControlHostSecrets(resolver, perHostHosts, "github");
83 + assert.deepEqual(resolved, {
84 + github: { tokens: { "github.com": "ghp_from_provider", "ghe.acme.test": "ghp_literal" } },
85 + });
86 + assert.deepEqual(reads, ["github#token"]);
87 + }),
88 +);
89 +
90 it("collects the references held in credential fields and skips literal values", () => {
91 assert.deepEqual(collectSourceControlHostSecretReferences(hosts), [
92 source("missing#token"),
93 source("bitbucket#token"),
94 ]);
95 + assert.deepEqual(collectSourceControlHostSecretReferences(perHostHosts), [
96 + source("github#token"),
97 + ]);
98 assert.deepEqual(
99 collectSourceControlHostSecretReferences({
100 bitbucket: { accessToken: "literal" },
apps/server/src/sourceControl/sourceControlHostSecrets.ts
+10 -1
@@ -53,7 +53,16 @@ export function writeSecretFieldValues(
53 ): unknown {
54 if (typeof original === "string") return values[0]?.[1] ?? "";
55 if (isSecretReference(original)) return original;
56 - return Object.fromEntries(values.map(([serverHost, value]) => [serverHost ?? "", value]));
56 + const sources =
57 + original !== null && typeof original === "object" && !Array.isArray(original)
58 + ? Object.entries(original).flatMap(([serverHost, entry]) =>
59 + isSecretReference(entry) ? [[serverHost.trim().toLowerCase(), entry] as const] : [],
60 + )
61 + : [];
62 + return Object.fromEntries([
63 + ...sources,
64 + ...values.map(([serverHost, value]) => [serverHost ?? "", value] as const),
65 + ]);
66 }
67
68 type SourceControlHostsSettings = Readonly<Record<string, Readonly<Record<string, unknown>>>>;
apps/web/src/components/settings/SourceControlAppSignInSettings.tsx
+3 -1
@@ -101,7 +101,9 @@ export function SourceControlAppSignInSettings({
101 readHostCredentialSettings(settings, definition.kind),
102 );
103 const signedIn = (signIns[host] ?? "").length > 0;
104 - const tokenOverrides = (tokens[host] ?? "").length > 0;
104 + const token = tokens[host];
105 + // A token read from a secret provider overrides the sign-in like a saved one.
106 + const tokenOverrides = typeof token === "string" ? token.length > 0 : token !== undefined;
107 const canSignIn = useAtomValue(
108 sourceControlEnvironment.startSignIn.permissionAtom(environmentId),
109 );
apps/web/src/components/settings/SourceControlTokenSettings.tsx
+36 -12
@@ -1,4 +1,9 @@
1 -import type { EnvironmentId } from "@t3tools/contracts";
1 +import {
2 + isSecretReference,
3 + type EnvironmentId,
4 + type SecretReference,
5 + type SettingsSecretValue,
6 +} from "@t3tools/contracts";
7 import { ExternalLinkIcon } from "lucide-react";
8 import { useState } from "react";
9
@@ -12,8 +17,11 @@ import { serverEnvironment } from "../../state/server";
17 import { useAtomCommand } from "../../state/use-atom-command";
18 import { Button, InlineButton } from "../ui/button";
19 import { Input } from "../ui/input";
15 -import { SecretInput } from "./SecretInput";
20 import { Label } from "../ui/label";
21 +import { SecretSourceInput, useSecretSources } from "./SecretSourceInput";
22 +
23 +const hasToken = (token: SettingsSecretValue | undefined) =>
24 + typeof token === "string" ? token.length > 0 : token !== undefined;
25
26 export function SourceControlTokenSettings({
27 environmentId,
@@ -34,15 +42,24 @@ export function SourceControlTokenSettings({
42 });
43 const defaultHost = definition.publicHost ?? "";
44 const [host, setHost] = useState(defaultHost);
37 - const [draft, setDraft] = useState("");
45 + const secretSources = useSecretSources(environmentId);
46 + const [pending, setPending] = useState<{
47 + readonly key: string;
48 + readonly draft: string | SecretReference;
49 + } | null>(null);
50 const [saving, setSaving] = useState(false);
51 const normalizedHost = host.trim().toLowerCase();
40 - const isSaved = (tokens[normalizedHost] ?? "").length > 0;
52 + const savedToken = tokens[normalizedHost];
53 + const isSaved = hasToken(savedToken);
54 const savedHosts = Object.entries(tokens)
42 - .filter(([, value]) => value.length > 0)
55 + .filter(([, value]) => hasToken(value))
56 .map(([saved]) => saved);
57 + const sourceKey = JSON.stringify([normalizedHost, savedToken ?? ""]);
58 + const draft =
59 + pending?.key === sourceKey ? pending.draft : isSecretReference(savedToken) ? savedToken : "";
60 + const submission = typeof draft === "string" ? draft.trim() : draft;
61
45 - const save = async (target: string, token: string) => {
62 + const save = async (target: string, token: SettingsSecretValue) => {
63 setSaving(true);
64 const result = await updateSettings({
65 environmentId,
@@ -55,7 +72,7 @@ export function SourceControlTokenSettings({
72 });
73 setSaving(false);
74 if (result._tag === "Success") {
58 - setDraft("");
75 + setPending(null);
76 onSaved();
77 }
78 };
@@ -65,7 +82,7 @@ export function SourceControlTokenSettings({
82 className="grid gap-3"
83 onSubmit={(event) => {
84 event.preventDefault();
68 - if (normalizedHost && draft.trim()) void save(normalizedHost, draft.trim());
85 + if (normalizedHost && submission !== "") void save(normalizedHost, submission);
86 }}
87 >
88 {/* Locked while saving: a successful save clears the draft, which would drop edits made mid-request. */}
@@ -106,12 +123,15 @@ export function SourceControlTokenSettings({
123 </div>
124 <div className="grid gap-1.5">
125 <Label htmlFor={`${definition.kind}-token-${environmentId}`}>Token</Label>
109 - <SecretInput
126 + <SecretSourceInput
127 id={`${definition.kind}-token-${environmentId}`}
128 size="sm"
112 - configured={isSaved}
129 + aria-label={`${definition.label} token`}
130 + configured={isSaved && !isSecretReference(savedToken)}
131 value={draft}
114 - onChange={(event) => setDraft(event.target.value)}
132 + sources={secretSources}
133 + onChange={(event) => setPending({ key: sourceKey, draft: event.target.value })}
134 + onSecretChange={(secret) => setPending({ key: sourceKey, draft: secret ?? "" })}
135 />
136 </div>
137 </div>
@@ -132,7 +152,11 @@ export function SourceControlTokenSettings({
152 Remove
153 </Button>
154 ) : null}
135 - <Button type="submit" size="xs" disabled={!normalizedHost || !draft.trim() || saving}>
155 + <Button
156 + type="submit"
157 + size="xs"
158 + disabled={!normalizedHost || submission === "" || saving}
159 + >
160 Save
161 </Button>
162 </div>
packages/contracts/src/settingsSecretValue.ts
+56 -14
@@ -26,26 +26,68 @@ export function acceptsSecretReference(schema: Schema.Top): boolean {
26 return Schema.resolveAnnotationsKey(schema)?.settingsSecretReference === true;
27 }
28
29 -/** Fields of a settings struct typed `SettingsSecretValue`; any other schema has none. */
30 -function secretReferenceSettingsFields(schema: Schema.Top): ReadonlyArray<string> {
29 +const declaresSecretReference = (ast: SchemaAST.AST) =>
30 + ast.context?.annotations?.settingsSecretReference === true;
31 +
32 +interface SecretReferenceField {
33 + readonly field: string;
34 + readonly keyed: boolean;
35 +}
36 +
37 +/**
38 + * Fields of a settings struct typed `SettingsSecretValue`, or a record of it such as one value
39 + * per host; any other schema has none.
40 + */
41 +function secretReferenceSettingsFields(schema: Schema.Top): ReadonlyArray<SecretReferenceField> {
42 if (!SchemaAST.isObjects(schema.ast)) return [];
32 - return schema.ast.propertySignatures.flatMap((property) =>
33 - property.type.context?.annotations?.settingsSecretReference === true &&
34 - typeof property.name === "string"
35 - ? [property.name]
36 - : [],
37 - );
43 + return schema.ast.propertySignatures.flatMap<SecretReferenceField>(({ name, type }) => {
44 + if (typeof name !== "string") return [];
45 + if (declaresSecretReference(type)) return [{ field: name, keyed: false }];
46 + return SchemaAST.isObjects(type) &&
47 + type.indexSignatures.some((signature) => declaresSecretReference(signature.type))
48 + ? [{ field: name, keyed: true }]
49 + : [];
50 + });
51 }
52
40 -/** Each declared reference field of `settings` that holds a reference, in field order. */
53 +/** Where a reference sits: a field, or one key of a record field. */
54 +export interface SettingsSecretSlot {
55 + readonly field: string;
56 + readonly key: string | undefined;
57 +}
58 +
59 +interface SettingsSecretReference extends SettingsSecretSlot {
60 + readonly reference: SecretReference;
61 +}
62 +
63 +/** Each declared reference slot of `settings` that holds a reference, in field order. */
64 export function secretReferencesInSettings(
65 schema: Schema.Top,
66 settings: unknown,
44 -): ReadonlyArray<{ readonly field: string; readonly reference: SecretReference }> {
67 +): ReadonlyArray<SettingsSecretReference> {
68 if (settings === null || typeof settings !== "object") return [];
69 const values = settings as Readonly<Record<string, unknown>>;
47 - return secretReferenceSettingsFields(schema).flatMap((field) => {
48 - const value = values[field];
49 - return isSecretReference(value) ? [{ field, reference: value }] : [];
50 - });
70 + return secretReferenceSettingsFields(schema).flatMap<SettingsSecretReference>(
71 + ({ field, keyed }) => {
72 + const value = values[field];
73 + if (!keyed)
74 + return isSecretReference(value) ? [{ field, key: undefined, reference: value }] : [];
75 + if (value === null || typeof value !== "object") return [];
76 + return Object.entries(value).flatMap(([key, entry]) =>
77 + isSecretReference(entry) ? [{ field, key, reference: entry }] : [],
78 + );
79 + },
80 + );
81 +}
82 +
83 +/** `settings` with each slot set to its value, keeping the other keys of a record field. */
84 +export function withSettingsSecrets<Settings extends Readonly<Record<string, unknown>>>(
85 + settings: Settings,
86 + slots: ReadonlyArray<SettingsSecretSlot & { readonly value: string }>,
87 +): Settings {
88 + const next: Record<string, unknown> = { ...settings };
89 + for (const { field, key, value } of slots) {
90 + next[field] = key === undefined ? value : { ...(next[field] as object), [key]: value };
91 + }
92 + return next as Settings;
93 }
packages/source-control-core/src/shared/definition.ts
+2 -1
@@ -3,6 +3,7 @@ import {
3 type PullRequestReviewVerdict,
4 type RepositoryIdentity,
5 secretSetting,
6 + SettingsSecretValue,
7 SourceControlProviderKind,
8 type SourceControlProviderInfo,
9 TrimmedNonEmptyString,
@@ -214,7 +215,7 @@ export const hostCredentialSettingsFields = {
215 Schema.withDecodingDefault(Effect.succeed({})),
216 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
217 ),
217 - tokens: Schema.Record(SourceControlHostName, TrimmedString).pipe(
218 + tokens: Schema.Record(SourceControlHostName, SettingsSecretValue).pipe(
219 Schema.withDecodingDefault(Effect.succeed({})),
220 secretSetting,
221 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
packages/source-control-github/src/server/GitHubCredentials.ts
+5 -3
@@ -16,7 +16,7 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
16
17 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
18 import { readSourceControlHostSettings } from "@t3tools/source-control-core/shared/definition";
19 -import type { ServerSettings } from "@t3tools/contracts";
19 +import { settingsSecretLiteral, type ServerSettings } from "@t3tools/contracts";
20
21 import * as GitHubClient from "../shared/definition.ts";
22
@@ -194,8 +194,10 @@ export const make = Effect.gen(function* () {
194 );
195
196 const savedToken = (host: string) =>
197 - sourceControlHost.settings.get.pipe(
198 - Effect.map((settings) => readSettings(settings).tokens[host]?.trim() || null),
197 + sourceControlHost.settings.getWithSecrets(GitHubClient.definition.kind).pipe(
198 + Effect.map(
199 + (settings) => settingsSecretLiteral(readSettings(settings).tokens[host]).trim() || null,
200 + ),
201 Effect.orElseSucceed(() => null),
202 );
203
packages/source-control-github/src/server/GitHubSourceControlProvider.ts
+4 -3
@@ -1,4 +1,4 @@
1 -import { SourceControlProviderKind } from "@t3tools/contracts";
1 +import { settingsSecretLiteral, SourceControlProviderKind } from "@t3tools/contracts";
2 import * as Data from "effect/Data";
3 import * as DateTime from "effect/DateTime";
4 import * as Effect from "effect/Effect";
@@ -225,7 +225,7 @@ export const makeDiscovery = Effect.gen(function* () {
225 probe: Effect.fn("GitHubSourceControlProvider.discovery")(function* (cwd: string) {
226 const settings = readSourceControlHostSettings(
227 GitHubClient.settings,
228 - yield* sourceControlHost.settings.get.pipe(
228 + yield* sourceControlHost.settings.getWithSecrets(GitHubClient.definition.kind).pipe(
229 Effect.map((current) => current.sourceControlHosts[GitHubClient.definition.kind]),
230 Effect.orElseSucceed(() => undefined),
231 ),
@@ -237,7 +237,8 @@ export const makeDiscovery = Effect.gen(function* () {
237 },
238 spec: { ...discovery, parseAuth: (input) => parseGitHubAuth(input, settings) },
239 });
240 - const savedToken = (settings.tokens["github.com"] ?? "").trim() !== "";
240 + const token = settings.tokens["github.com"];
241 + const savedToken = settingsSecretLiteral(token).trim() !== "";
242 const signedIn =
243 appSignIn.enabled && !savedToken && (settings.signIns["github.com"] ?? "").trim() !== "";
244 const variable = environmentTokenVariable(environment);
packages/source-control-github/src/server/gitHubDiscovery.test.ts
+81 -1
@@ -1,10 +1,14 @@
1 -import { SourceControlProviderKind } from "@t3tools/contracts";
1 +import { ServerSettings, SourceControlProviderKind } from "@t3tools/contracts";
2 import * as HostProcess from "@t3tools/shared/HostProcess";
3 import { assert, it } from "@effect/vitest";
4 import * as Effect from "effect/Effect";
5 import * as Layer from "effect/Layer";
6 +import * as Option from "effect/Option";
7 import * as Redacted from "effect/Redacted";
8 +import * as Schema from "effect/Schema";
9 +import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
10 import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";
11 +import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
12
13 import * as GitHubCredentials from "./GitHubCredentials.ts";
14 import * as GitHubAppSignIn from "./GitHubAppSignIn.ts";
@@ -79,3 +83,79 @@ it.effect("asks for no credential when the identity resolver left the base URL e
83 assert.deepStrictEqual(hosts, []);
84 }),
85 );
86 +
87 +const decodeSettings = Schema.decodeSync(ServerSettings);
88 +const referencedTokenSettings = decodeSettings({
89 + sourceControlHosts: {
90 + github: { tokens: { "github.com": { provider: "vault", reference: "op://v/gh" } } },
91 + },
92 +});
93 +
94 +it.effect.each([
95 + { name: "readable", token: "resolved-token", source: "the token saved in Settings" },
96 + { name: "unreadable", token: "", source: "GH_TOKEN from the server environment" },
97 +])("checks the $name GitHub token reference against the API", (scenario) =>
98 + Effect.gen(function* () {
99 + const paths: Array<string> = [];
100 + const discovery = yield* GitHubSourceControlProvider.makeDiscovery.pipe(
101 + Effect.provide(
102 + Layer.mergeAll(
103 + Layer.mock(GitHubRest.GitHubRest)({
104 + rest: (input) => {
105 + paths.push(input.path);
106 + return Effect.succeed({
107 + status: 200,
108 + headers: {},
109 + body: JSON.stringify({ login: "octocat" }),
110 + truncated: false,
111 + invalidUtf8: false,
112 + });
113 + },
114 + }),
115 + Layer.mock(GitHubAppSignIn.GitHubAppSignIn)({ enabled: false }),
116 + Layer.effect(
117 + SourceControlHost.SourceControlHost,
118 + Effect.gen(function* () {
119 + const host = yield* SourceControlHost.SourceControlHost;
120 + return {
121 + ...host,
122 + settings: {
123 + ...host.settings,
124 + getWithSecrets: () =>
125 + Effect.succeed(
126 + decodeSettings({
127 + sourceControlHosts: {
128 + github: { tokens: { "github.com": scenario.token } },
129 + },
130 + }),
131 + ),
132 + },
133 + };
134 + }),
135 + ).pipe(
136 + Layer.provide(
137 + TestSourceControlHost.layer({
138 + settings: referencedTokenSettings,
139 + process: {
140 + run: () =>
141 + Effect.succeed(
142 + TestSourceControlHost.processOutput("", {
143 + exitCode: ChildProcessSpawner.ExitCode(1),
144 + }),
145 + ),
146 + },
147 + }),
148 + ),
149 + ),
150 + ),
151 + ),
152 + Effect.provideService(HostProcess.Environment, { GH_TOKEN: "environment-token" }),
153 + );
154 + if (discovery.type !== "managed-cli") return assert.fail("expected a managed CLI");
155 + const item = yield* discovery.probe("/repo");
156 + assert.deepStrictEqual(paths, ["user"]);
157 + assert.strictEqual(item.auth.status, "authenticated");
158 + assert.deepStrictEqual(item.auth.account, Option.some("octocat"));
159 + assert.include(Option.getOrThrow(item.auth.detail), scenario.source);
160 + }),
161 +);