Skip to content

Commit 35da7d2

Browse files
committed
refactor: remove legacy agent dir resolver
1 parent e8a9c76 commit 35da7d2

70 files changed

Lines changed: 302 additions & 218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Docs: https://docs.openclaw.ai
8080
- Providers/Fireworks: expose Kimi models as thinking-off-only and keep K2.5/K2.6 requests on `thinking: disabled`, so manual model switches do not send Fireworks-rejected `reasoning*` parameters. Refs #74289. Thanks @frankekn.
8181
- WhatsApp responsiveness: stop only verified stale local TUI clients when they degrade the Gateway event loop and delay replies. Thanks @vincentkoc.
8282
- Hooks/session-memory: add collision suffixes to fallback memory filenames so repeated `/new` or `/reset` captures in the same minute do not overwrite the earlier session archive. Thanks @vincentkoc.
83+
- Agents/config: remove the ambiguous legacy `main` agent dir helper from runtime paths; model, auth, gateway, bundled plugin, and test helpers now resolve default/session agent dirs through `agents.list`/agent-scope helpers while plugin SDK keeps a deprecated compatibility export.
8384
- Video generation: wait up to 20 minutes for slow fal/MiniMax queue-backed jobs, stop forwarding unsupported Google Veo generated-audio options, and normalize MiniMax `720P` requests to its supported `768P` resolution with the usual override warning/details instead of failing fallback.
8485
- Video generation: accept provider-specific aspect-ratio and resolution hints at the tool boundary, normalize `720P` to MiniMax's supported `768P`, and stop sending Google `generateAudio` on Gemini video requests so provider fallback can recover from model-specific parameter differences. Thanks @vincentkoc.
8586
- OpenAI/Google Meet: fail realtime voice connection attempts when the socket closes before `session.updated`, avoiding stuck Meet joins waiting on a bridge that never became ready. Thanks @vincentkoc.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
43c6f668cd8301f485c64e6a663dc1b19d38c146ce2572943e2dc961973e0c6f plugin-sdk-api-baseline.json
2-
1d877d94bebb634d90d929fe0581ba4bccf4d12d8342d179ae9bf1053e68c013 plugin-sdk-api-baseline.jsonl
1+
2164ea491c61e643f0a9c68f7b9bd2e41ab338eb93bbdf301da2fae548722581 plugin-sdk-api-baseline.json
2+
c07c3719218a12482e2a76e6b9654da2ddddf75d8d70145cdaef3da2b2eaccef plugin-sdk-api-baseline.jsonl

docs/plugins/sdk-subpaths.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)
117117
| `plugin-sdk/provider-auth-result` | Standard OAuth auth-result builder |
118118
| `plugin-sdk/provider-auth-login` | Shared interactive login helpers for provider plugins |
119119
| `plugin-sdk/provider-env-vars` | Provider auth env-var lookup helpers |
120-
| `plugin-sdk/provider-auth` | `createProviderApiKeyAuthMethod`, `ensureApiKeyFromOptionEnvOrPrompt`, `upsertAuthProfile`, `upsertApiKeyProfile`, `writeOAuthCredentials` |
120+
| `plugin-sdk/provider-auth` | `createProviderApiKeyAuthMethod`, `ensureApiKeyFromOptionEnvOrPrompt`, `upsertAuthProfile`, `upsertApiKeyProfile`, `writeOAuthCredentials`, deprecated `resolveOpenClawAgentDir` compatibility export |
121121
| `plugin-sdk/provider-model-shared` | `ProviderReplayFamily`, `buildProviderReplayFamilyHooks`, `normalizeModelCompat`, shared replay-policy builders, provider-endpoint helpers, and model-id normalization helpers such as `normalizeNativeXaiModelId` |
122122
| `plugin-sdk/provider-catalog-runtime` | Provider catalog augmentation runtime hook and plugin-provider registry seams for contract tests |
123123
| `plugin-sdk/provider-catalog-shared` | `findCatalogTemplate`, `buildSingleProviderApiKeyCatalog`, `buildManifestModelProviderConfig`, `supportsNativeStreamingUsageCompat`, `applyProviderNativeStreamingUsageCompat` |
@@ -253,7 +253,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)
253253
| `plugin-sdk/string-coerce-runtime` | Narrow primitive record/string coercion and normalization helpers without markdown/logging imports |
254254
| `plugin-sdk/host-runtime` | Hostname and SCP host normalization helpers |
255255
| `plugin-sdk/retry-runtime` | Retry config and retry runner helpers |
256-
| `plugin-sdk/agent-runtime` | Agent dir/identity/workspace helpers |
256+
| `plugin-sdk/agent-runtime` | Agent dir/identity/workspace helpers, including `resolveAgentDir`, `resolveDefaultAgentDir`, and deprecated `resolveOpenClawAgentDir` compatibility export |
257257
| `plugin-sdk/directory-runtime` | Config-backed directory query/dedup |
258258
| `plugin-sdk/keyed-async-queue` | `KeyedAsyncQueue` |
259259
</Accordion>

extensions/codex/src/app-server/auth-bridge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
resolveAuthProfileOrder,
77
resolveProviderIdForAuth,
88
resolveApiKeyForProfile,
9-
resolveOpenClawAgentDir,
9+
resolveDefaultAgentDir,
1010
resolvePersistedAuthProfileOwnerAgentDir,
1111
saveAuthProfileStore,
1212
type AuthProfileCredential,
@@ -82,7 +82,7 @@ export function resolveCodexAppServerAuthProfileIdForAgent(params: {
8282
agentDir?: string;
8383
config?: AuthProfileOrderConfig;
8484
}): string | undefined {
85-
const agentDir = params.agentDir?.trim() || resolveOpenClawAgentDir();
85+
const agentDir = params.agentDir?.trim() || resolveDefaultAgentDir(params.config ?? {});
8686
const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
8787
return resolveCodexAppServerAuthProfileId({
8888
authProfileId: params.authProfileId,

extensions/codex/src/app-server/models.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ vi.mock("./managed-binary.js", () => ({
2727
resolveManagedCodexAppServerStartOptions: mocks.managedBinary.startOptions,
2828
}));
2929

30-
vi.mock("openclaw/plugin-sdk/provider-auth", () => ({
31-
resolveOpenClawAgentDir: mocks.providerAuth.agentDir,
30+
vi.mock("openclaw/plugin-sdk/agent-runtime", () => ({
31+
resolveDefaultAgentDir: mocks.providerAuth.agentDir,
3232
}));
3333

3434
let listCodexAppServerModels: typeof import("./models.js").listCodexAppServerModels;

extensions/codex/src/app-server/run-attempt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import {
1616
isSubagentSessionKey,
1717
normalizeAgentRuntimeTools,
1818
resolveAttemptSpawnWorkspaceDir,
19+
resolveAgentDir,
1920
resolveAgentHarnessBeforePromptBuildResult,
2021
resolveModelAuthMode,
21-
resolveOpenClawAgentDir,
2222
resolveSandboxContext,
2323
resolveSessionAgentIds,
2424
resolveUserPath,
@@ -385,7 +385,7 @@ export async function runCodexAppServerAttempt(
385385
config: params.config,
386386
agentId: params.agentId,
387387
});
388-
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
388+
const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, sessionAgentId);
389389
const startupBinding = await readCodexAppServerBinding(params.sessionFile);
390390
const startupAuthProfileCandidate =
391391
params.runtimePlan?.auth.forwardedAuthProfileId ??
@@ -1477,7 +1477,7 @@ async function buildDynamicTools(input: DynamicToolBuildParams) {
14771477
return [];
14781478
}
14791479
const modelHasVision = params.model.input?.includes("image") ?? false;
1480-
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
1480+
const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, input.sessionAgentId);
14811481
const { createOpenClawCodingTools } = await import("openclaw/plugin-sdk/agent-harness");
14821482
const allTools = createOpenClawCodingTools({
14831483
agentId: input.sessionAgentId,

extensions/codex/src/app-server/session-binding.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
22
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
33
import {
44
ensureAuthProfileStore,
5-
resolveOpenClawAgentDir,
5+
resolveDefaultAgentDir,
66
resolveProviderIdForAuth,
77
type AuthProfileStore,
88
} from "openclaw/plugin-sdk/agent-runtime";
@@ -194,12 +194,16 @@ function resolveCodexAppServerAuthProfileCredential(
194194
if (!authProfileId) {
195195
return undefined;
196196
}
197-
const store = lookup.authProfileStore ?? loadCodexAppServerAuthProfileStore(lookup.agentDir);
197+
const store =
198+
lookup.authProfileStore ?? loadCodexAppServerAuthProfileStore(lookup.agentDir, lookup.config);
198199
return store.profiles[authProfileId];
199200
}
200201

201-
function loadCodexAppServerAuthProfileStore(agentDir: string | undefined): AuthProfileStore {
202-
return ensureAuthProfileStore(agentDir?.trim() || resolveOpenClawAgentDir(), {
202+
function loadCodexAppServerAuthProfileStore(
203+
agentDir: string | undefined,
204+
config?: ProviderAuthAliasConfig,
205+
): AuthProfileStore {
206+
return ensureAuthProfileStore(agentDir?.trim() || resolveDefaultAgentDir(config ?? {}), {
203207
allowKeychainPrompt: false,
204208
});
205209
}

extensions/codex/src/app-server/shared-client.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const mocks = vi.hoisted(() => ({
1111
),
1212
resolveManagedCodexAppServerStartOptions: vi.fn(async (startOptions) => startOptions),
1313
embeddedAgentLog: { debug: vi.fn(), warn: vi.fn() },
14-
resolveOpenClawAgentDir: vi.fn(() => "/tmp/openclaw-agent"),
14+
resolveDefaultAgentDir: vi.fn(() => "/tmp/openclaw-agent"),
1515
}));
1616

1717
vi.mock("./auth-bridge.js", () => ({
@@ -29,8 +29,8 @@ vi.mock("openclaw/plugin-sdk/agent-harness-runtime", () => ({
2929
OPENCLAW_VERSION: "test",
3030
}));
3131

32-
vi.mock("openclaw/plugin-sdk/provider-auth", () => ({
33-
resolveOpenClawAgentDir: mocks.resolveOpenClawAgentDir,
32+
vi.mock("openclaw/plugin-sdk/agent-runtime", () => ({
33+
resolveDefaultAgentDir: mocks.resolveDefaultAgentDir,
3434
}));
3535

3636
let listCodexAppServerModels: typeof import("./models.js").listCodexAppServerModels;
@@ -81,7 +81,7 @@ describe("shared Codex app-server client", () => {
8181
);
8282
mocks.embeddedAgentLog.debug.mockClear();
8383
mocks.embeddedAgentLog.warn.mockClear();
84-
mocks.resolveOpenClawAgentDir.mockClear();
84+
mocks.resolveDefaultAgentDir.mockClear();
8585
});
8686

8787
it("closes the shared app-server when the version gate fails", async () => {

extensions/codex/src/app-server/shared-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resolveOpenClawAgentDir } from "openclaw/plugin-sdk/provider-auth";
1+
import { resolveDefaultAgentDir } from "openclaw/plugin-sdk/agent-runtime";
22
import {
33
applyCodexAppServerAuthProfile,
44
bridgeCodexAppServerStartOptions,
@@ -37,7 +37,7 @@ export async function getSharedCodexAppServerClient(options?: {
3737
config?: Parameters<typeof resolveCodexAppServerAuthProfileIdForAgent>[0]["config"];
3838
}): Promise<CodexAppServerClient> {
3939
const state = getSharedCodexAppServerClientState();
40-
const agentDir = options?.agentDir ?? resolveOpenClawAgentDir();
40+
const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
4141
const authProfileId = resolveCodexAppServerAuthProfileIdForAgent({
4242
authProfileId: options?.authProfileId,
4343
agentDir,
@@ -104,7 +104,7 @@ export async function createIsolatedCodexAppServerClient(options?: {
104104
agentDir?: string;
105105
config?: Parameters<typeof resolveCodexAppServerAuthProfileIdForAgent>[0]["config"];
106106
}): Promise<CodexAppServerClient> {
107-
const agentDir = options?.agentDir ?? resolveOpenClawAgentDir();
107+
const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
108108
const authProfileId = resolveCodexAppServerAuthProfileIdForAgent({
109109
authProfileId: options?.authProfileId,
110110
agentDir,

extensions/codex/src/conversation-binding.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const agentRuntimeMocks = vi.hoisted(() => ({
1212
loadAuthProfileStoreForSecretsRuntime: vi.fn(),
1313
resolveApiKeyForProfile: vi.fn(),
1414
resolveAuthProfileOrder: vi.fn(),
15-
resolveOpenClawAgentDir: vi.fn(() => "/agent"),
15+
resolveDefaultAgentDir: vi.fn(() => "/agent"),
1616
resolvePersistedAuthProfileOwnerAgentDir: vi.fn(),
1717
resolveProviderIdForAuth: vi.fn((provider: string) => provider),
1818
saveAuthProfileStore: vi.fn(),
@@ -40,7 +40,7 @@ describe("codex conversation binding", () => {
4040
agentRuntimeMocks.loadAuthProfileStoreForSecretsRuntime.mockReset();
4141
agentRuntimeMocks.resolveApiKeyForProfile.mockReset();
4242
agentRuntimeMocks.resolveAuthProfileOrder.mockReset();
43-
agentRuntimeMocks.resolveOpenClawAgentDir.mockClear();
43+
agentRuntimeMocks.resolveDefaultAgentDir.mockClear();
4444
agentRuntimeMocks.resolvePersistedAuthProfileOwnerAgentDir.mockReset();
4545
agentRuntimeMocks.resolveProviderIdForAuth.mockClear();
4646
agentRuntimeMocks.saveAuthProfileStore.mockReset();
@@ -53,7 +53,7 @@ describe("codex conversation binding", () => {
5353
profiles: {},
5454
});
5555
agentRuntimeMocks.resolveAuthProfileOrder.mockReturnValue([]);
56-
agentRuntimeMocks.resolveOpenClawAgentDir.mockReturnValue("/agent");
56+
agentRuntimeMocks.resolveDefaultAgentDir.mockReturnValue("/agent");
5757
agentRuntimeMocks.resolveProviderIdForAuth.mockImplementation((provider: string) => provider);
5858
});
5959

0 commit comments

Comments
 (0)