|
1 | 1 | import { createRequire } from "node:module"; |
| 2 | +import { |
| 3 | + getApiKeyForModel as getApiKeyForModelRaw, |
| 4 | + resolveApiKeyForProvider as resolveApiKeyForProviderRaw, |
| 5 | +} from "../../agents/model-auth.js"; |
2 | 6 | import { resolveStateDir } from "../../config/paths.js"; |
3 | 7 | import { transcribeAudioFile } from "../../media-understanding/transcribe-audio.js"; |
4 | 8 | import { textToSpeechTelephony } from "../../tts/tts.js"; |
@@ -59,6 +63,24 @@ export function createPluginRuntime(_options: CreatePluginRuntimeOptions = {}): |
59 | 63 | events: createRuntimeEvents(), |
60 | 64 | logging: createRuntimeLogging(), |
61 | 65 | state: { resolveStateDir }, |
| 66 | + modelAuth: { |
| 67 | + // Wrap model-auth helpers so plugins cannot steer credential lookups: |
| 68 | + // - agentDir / store: stripped (prevents reading other agents' stores) |
| 69 | + // - profileId / preferredProfile: stripped (prevents cross-provider |
| 70 | + // credential access via profile steering) |
| 71 | + // Plugins only specify provider/model; the core auth pipeline picks |
| 72 | + // the appropriate credential automatically. |
| 73 | + getApiKeyForModel: (params) => |
| 74 | + getApiKeyForModelRaw({ |
| 75 | + model: params.model, |
| 76 | + cfg: params.cfg, |
| 77 | + }), |
| 78 | + resolveApiKeyForProvider: (params) => |
| 79 | + resolveApiKeyForProviderRaw({ |
| 80 | + provider: params.provider, |
| 81 | + cfg: params.cfg, |
| 82 | + }), |
| 83 | + }, |
62 | 84 | } satisfies PluginRuntime; |
63 | 85 |
|
64 | 86 | return runtime; |
|
0 commit comments