Skip to content

Commit 316fd5b

Browse files
samzongsteipete
andauthored
[Fix] Warm provider auth off main thread (#86281)
* fix(agents): warm provider auth off main thread Signed-off-by: samzong <samzong.lu@gmail.com> * fix(agents): keep provider auth warm read-only * fix(ci): unblock provider auth landing * ci: serialize gateway watch artifact check * fix(ci): stabilize diffs viewer asset generation * fix(agents): avoid stale plugin auth warm results * fix(agents): keep partial auth warm cache --------- Signed-off-by: samzong <samzong.lu@gmail.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
1 parent 5cef288 commit 316fd5b

21 files changed

Lines changed: 954 additions & 71 deletions

config/knip.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const rootEntries = [
1010
"src/entry.ts!",
1111
"src/cli/daemon-cli.ts!",
1212
"src/agents/code-mode.worker.ts!",
13+
"src/agents/model-provider-auth.worker.ts!",
1314
"src/infra/kysely-node-sqlite.ts!",
1415
"src/infra/warning-filter.ts!",
1516
"src/infra/command-explainer/index.ts!",

extensions/diffs/assets/viewer-runtime.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build-diffs-viewer-runtime.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export async function buildDiffsViewerRuntime(targetName) {
3838
target: "es2020",
3939
format: "esm",
4040
minify: true,
41+
define: {
42+
NaN: "Number.NaN",
43+
},
4144
legalComments: "none",
4245
outfile: outputPath,
4346
write: false,

scripts/release-check.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const requiredPathGroups = [
8080
"scripts/postinstall-bundled-plugins.mjs",
8181
"dist/plugin-sdk/compat.js",
8282
"dist/plugin-sdk/root-alias.cjs",
83+
"dist/agents/model-provider-auth.worker.js",
8384
"dist/task-registry-control.runtime.js",
8485
"dist/telegram-ingress-worker.runtime.js",
8586
"dist/build-info.json",

src/agents/auth-profiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export {
5252
clearRuntimeAuthProfileStoreSnapshots,
5353
ensureAuthProfileStore,
5454
ensureAuthProfileStoreWithoutExternalProfiles,
55+
getRuntimeAuthProfileStoreSnapshot,
5556
hasAnyAuthProfileStoreSource,
5657
loadAuthProfileStoreForSecretsRuntime,
5758
loadAuthProfileStoreWithoutExternalProfiles,

src/agents/auth-profiles/store.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
} from "./persisted.js";
3636
import {
3737
clearRuntimeAuthProfileStoreSnapshots as clearRuntimeAuthProfileStoreSnapshotsImpl,
38-
getRuntimeAuthProfileStoreSnapshot,
38+
getRuntimeAuthProfileStoreSnapshot as getRuntimeAuthProfileStoreSnapshotImpl,
3939
hasRuntimeAuthProfileStoreSnapshot,
4040
replaceRuntimeAuthProfileStoreSnapshots as replaceRuntimeAuthProfileStoreSnapshotsImpl,
4141
setRuntimeAuthProfileStoreSnapshot,
@@ -150,8 +150,8 @@ function resolveRuntimeAuthProfileStore(
150150
): AuthProfileStore | null {
151151
const mainKey = resolveAuthStorePath(undefined);
152152
const requestedKey = resolveAuthStorePath(agentDir);
153-
const mainStore = getRuntimeAuthProfileStoreSnapshot(undefined);
154-
const requestedStore = getRuntimeAuthProfileStoreSnapshot(agentDir);
153+
const mainStore = getRuntimeAuthProfileStoreSnapshotImpl(undefined);
154+
const requestedStore = getRuntimeAuthProfileStoreSnapshotImpl(agentDir);
155155

156156
if (!agentDir || requestedKey === mainKey) {
157157
if (!mainStore) {
@@ -899,6 +899,8 @@ export function ensureAuthProfileStore(
899899
externalCli?: ExternalCliAuthDiscovery;
900900
externalCliProviderIds?: Iterable<string>;
901901
externalCliProfileIds?: Iterable<string>;
902+
readOnly?: boolean;
903+
syncExternalCli?: boolean;
902904
},
903905
): AuthProfileStore {
904906
const externalCli = resolveExternalCliOverlayOptions(options);
@@ -921,7 +923,12 @@ export function ensureAuthProfileStore(
921923

922924
export function ensureAuthProfileStoreWithoutExternalProfiles(
923925
agentDir?: string,
924-
options?: { allowKeychainPrompt?: boolean; resolveLegacyOAuthSidecars?: boolean },
926+
options?: {
927+
allowKeychainPrompt?: boolean;
928+
readOnly?: boolean;
929+
resolveLegacyOAuthSidecars?: boolean;
930+
syncExternalCli?: boolean;
931+
},
925932
): AuthProfileStore {
926933
const effectiveOptions: LoadAuthProfileStoreOptions = {
927934
...options,
@@ -1015,6 +1022,12 @@ export function ensureAuthProfileStoreForLocalUpdate(agentDir?: string): AuthPro
10151022

10161023
export { hasAnyAuthProfileStoreSource } from "./source-check.js";
10171024

1025+
export function getRuntimeAuthProfileStoreSnapshot(
1026+
agentDir?: string,
1027+
): AuthProfileStore | undefined {
1028+
return getRuntimeAuthProfileStoreSnapshotImpl(agentDir);
1029+
}
1030+
10181031
export function replaceRuntimeAuthProfileStoreSnapshots(
10191032
entries: Array<{ agentDir?: string; store: AuthProfileStore }>,
10201033
): void {

src/agents/model-auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type ProviderCredentialPrecedence = "profile-first" | "env-first";
6565
export type RuntimeProviderAuthLookup = {
6666
envApiKey: Pick<EnvApiKeyLookupOptions, "aliasMap" | "candidateMap" | "authEvidenceMap">;
6767
syntheticAuthProviderRefs?: readonly string[];
68+
syntheticAuthProviderRefsComplete?: boolean;
6869
};
6970

7071
const log = createSubsystemLogger("model-auth");
@@ -125,6 +126,7 @@ export function createRuntimeProviderAuthLookup(params: {
125126
syntheticAuthProviderRefs: syntheticAuthProviderRefs?.complete
126127
? syntheticAuthProviderRefs.refs
127128
: undefined,
129+
syntheticAuthProviderRefsComplete: syntheticAuthProviderRefs?.complete,
128130
};
129131
}
130132

0 commit comments

Comments
 (0)