Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
263
extensions/microsoft-foundry/provider.ts
Normal file
263
extensions/microsoft-foundry/provider.ts
Normal file
@@ -0,0 +1,263 @@
|
||||
// Microsoft Foundry provider module implements model/runtime integration.
|
||||
import type { ProviderNormalizeResolvedModelContext } from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
resolveClaudeThinkingProfile,
|
||||
supportsClaudeNativeMaxEffort,
|
||||
type ModelProviderConfig,
|
||||
type ProviderPlugin,
|
||||
} from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { OPENAI_RESPONSES_STREAM_HOOKS } from "openclaw/plugin-sdk/provider-stream-family";
|
||||
import { apiKeyAuthMethod, entraIdAuthMethod } from "./auth.js";
|
||||
import { prepareFoundryRuntimeAuth } from "./runtime.js";
|
||||
import {
|
||||
PROVIDER_ID,
|
||||
applyFoundryProfileBinding,
|
||||
applyFoundryProviderConfig,
|
||||
buildFoundryProviderBaseUrl,
|
||||
extractFoundryEndpoint,
|
||||
isFoundryClaudeMythosPreview,
|
||||
isFoundryProviderApi,
|
||||
mergeFoundryCanonicalModelParams,
|
||||
normalizeFoundryEndpoint,
|
||||
resolveFoundryModelCapabilities,
|
||||
resolveFoundryTargetProfileId,
|
||||
} from "./shared.js";
|
||||
|
||||
type FoundryProviderHooks = Pick<ProviderPlugin, "wrapStreamFn">;
|
||||
|
||||
const wrapOpenAIResponsesStreamFn = OPENAI_RESPONSES_STREAM_HOOKS.wrapStreamFn;
|
||||
|
||||
const wrapMicrosoftFoundryStreamFn: NonNullable<FoundryProviderHooks["wrapStreamFn"]> = (ctx) => {
|
||||
if (ctx.model?.api !== "openai-responses") {
|
||||
return ctx.streamFn ?? null;
|
||||
}
|
||||
|
||||
const baseStreamFn = ctx.streamFn;
|
||||
if (!baseStreamFn) {
|
||||
return wrapOpenAIResponsesStreamFn?.(ctx) ?? null;
|
||||
}
|
||||
|
||||
const streamFnWithResponsesReplayIds: NonNullable<typeof ctx.streamFn> = (
|
||||
model,
|
||||
context,
|
||||
options,
|
||||
) =>
|
||||
baseStreamFn(model, context, {
|
||||
...options,
|
||||
// Foundry validates encrypted reasoning replay against the original item id,
|
||||
// even though its Responses endpoint does not support persisted `store`.
|
||||
replayResponsesItemIds: true,
|
||||
} as typeof options & { replayResponsesItemIds: true });
|
||||
|
||||
return (
|
||||
wrapOpenAIResponsesStreamFn?.({
|
||||
...ctx,
|
||||
streamFn: streamFnWithResponsesReplayIds,
|
||||
}) ?? streamFnWithResponsesReplayIds
|
||||
);
|
||||
};
|
||||
|
||||
export function buildMicrosoftFoundryProvider(): ProviderPlugin {
|
||||
return {
|
||||
id: PROVIDER_ID,
|
||||
label: "Microsoft Foundry",
|
||||
docsPath: "/providers/models",
|
||||
envVars: ["AZURE_OPENAI_API_KEY", "AZURE_OPENAI_ENDPOINT"],
|
||||
auth: [entraIdAuthMethod, apiKeyAuthMethod],
|
||||
onModelSelected: async (ctx) => {
|
||||
const providerConfig = ctx.config.models?.providers?.[PROVIDER_ID];
|
||||
if (
|
||||
!providerConfig ||
|
||||
!providerConfig.baseUrl?.trim() ||
|
||||
!Array.isArray(providerConfig.models) ||
|
||||
!ctx.model.startsWith(`${PROVIDER_ID}/`)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const selectedModelId = ctx.model.slice(`${PROVIDER_ID}/`.length);
|
||||
const configuredModels = providerConfig.models ?? [];
|
||||
const existingModel = configuredModels.find(
|
||||
(model: { id: string }) => model.id === selectedModelId,
|
||||
);
|
||||
const existingModelApi = isFoundryProviderApi(existingModel?.api)
|
||||
? existingModel.api
|
||||
: undefined;
|
||||
const providerApiForExistingModel =
|
||||
existingModel && isFoundryProviderApi(providerConfig.api) ? providerConfig.api : undefined;
|
||||
const selectedModelCapabilities = resolveFoundryModelCapabilities(
|
||||
selectedModelId,
|
||||
existingModel?.name,
|
||||
existingModelApi ?? providerApiForExistingModel,
|
||||
existingModel?.input,
|
||||
);
|
||||
const providerEndpoint = normalizeFoundryEndpoint(providerConfig.baseUrl ?? "");
|
||||
const selectedProviderEndpoint =
|
||||
extractFoundryEndpoint(existingModel?.baseUrl) ?? providerEndpoint;
|
||||
const nextModels = configuredModels.map((model) => {
|
||||
if (model.id !== selectedModelId) {
|
||||
return model;
|
||||
}
|
||||
const selectedModelEndpoint = extractFoundryEndpoint(model.baseUrl) ?? providerEndpoint;
|
||||
const selectedModelBaseUrl = buildFoundryProviderBaseUrl(
|
||||
selectedModelEndpoint,
|
||||
selectedModelId,
|
||||
selectedModelCapabilities.modelName,
|
||||
selectedModelCapabilities.api,
|
||||
);
|
||||
const nextModel = Object.assign({}, model, {
|
||||
name: selectedModelCapabilities.modelName,
|
||||
api: selectedModelCapabilities.api,
|
||||
baseUrl: selectedModelBaseUrl,
|
||||
reasoning: selectedModelCapabilities.reasoning || model.reasoning,
|
||||
thinkingLevelMap: selectedModelCapabilities.thinkingLevelMap ?? model.thinkingLevelMap,
|
||||
params: mergeFoundryCanonicalModelParams(
|
||||
model.params,
|
||||
selectedModelCapabilities.modelName,
|
||||
),
|
||||
input: selectedModelCapabilities.input,
|
||||
});
|
||||
if (selectedModelCapabilities.compat) {
|
||||
const explicitSupportsReasoningEffort =
|
||||
typeof model.compat?.supportsReasoningEffort === "boolean"
|
||||
? model.compat.supportsReasoningEffort
|
||||
: undefined;
|
||||
const preserveExplicitReasoningEffort =
|
||||
!selectedModelCapabilities.reasoning &&
|
||||
model.reasoning &&
|
||||
explicitSupportsReasoningEffort !== false;
|
||||
const explicitMaxTokensField =
|
||||
typeof model.compat?.maxTokensField === "string"
|
||||
? model.compat.maxTokensField
|
||||
: preserveExplicitReasoningEffort
|
||||
? "max_completion_tokens"
|
||||
: undefined;
|
||||
nextModel.compat = {
|
||||
...model.compat,
|
||||
...selectedModelCapabilities.compat,
|
||||
...(explicitSupportsReasoningEffort !== undefined
|
||||
? { supportsReasoningEffort: explicitSupportsReasoningEffort }
|
||||
: preserveExplicitReasoningEffort
|
||||
? { supportsReasoningEffort: true }
|
||||
: undefined),
|
||||
...(explicitMaxTokensField ? { maxTokensField: explicitMaxTokensField } : {}),
|
||||
};
|
||||
}
|
||||
return nextModel;
|
||||
});
|
||||
if (!nextModels.some((model) => model.id === selectedModelId)) {
|
||||
nextModels.push({
|
||||
id: selectedModelId,
|
||||
name: selectedModelCapabilities.modelName,
|
||||
api: selectedModelCapabilities.api,
|
||||
baseUrl: buildFoundryProviderBaseUrl(
|
||||
providerEndpoint,
|
||||
selectedModelId,
|
||||
selectedModelCapabilities.modelName,
|
||||
selectedModelCapabilities.api,
|
||||
),
|
||||
reasoning: selectedModelCapabilities.reasoning,
|
||||
...(selectedModelCapabilities.thinkingLevelMap
|
||||
? { thinkingLevelMap: selectedModelCapabilities.thinkingLevelMap }
|
||||
: {}),
|
||||
params: mergeFoundryCanonicalModelParams(undefined, selectedModelCapabilities.modelName),
|
||||
input: selectedModelCapabilities.input,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: selectedModelCapabilities.contextWindow,
|
||||
maxTokens: selectedModelCapabilities.maxTokens,
|
||||
...(selectedModelCapabilities.compat ? { compat: selectedModelCapabilities.compat } : {}),
|
||||
});
|
||||
}
|
||||
const nextProviderConfig: ModelProviderConfig = {
|
||||
...providerConfig,
|
||||
baseUrl: buildFoundryProviderBaseUrl(
|
||||
selectedProviderEndpoint,
|
||||
selectedModelId,
|
||||
selectedModelCapabilities.modelName,
|
||||
selectedModelCapabilities.api,
|
||||
),
|
||||
api: selectedModelCapabilities.api,
|
||||
models: nextModels,
|
||||
};
|
||||
const targetProfileId = resolveFoundryTargetProfileId(ctx.config);
|
||||
if (targetProfileId) {
|
||||
applyFoundryProfileBinding(ctx.config, targetProfileId);
|
||||
}
|
||||
applyFoundryProviderConfig(ctx.config, nextProviderConfig);
|
||||
},
|
||||
resolveThinkingProfile: ({ modelId, params }) => {
|
||||
const modelName =
|
||||
typeof params?.canonicalModelId === "string" ? params.canonicalModelId : undefined;
|
||||
const capabilities = resolveFoundryModelCapabilities(modelId, modelName);
|
||||
if (!capabilities.reasoning || capabilities.api !== "anthropic-messages") {
|
||||
return undefined;
|
||||
}
|
||||
const profile = resolveClaudeThinkingProfile(capabilities.modelName, undefined, {
|
||||
includeNativeMax: supportsClaudeNativeMaxEffort({ id: capabilities.modelName }),
|
||||
});
|
||||
if (!isFoundryClaudeMythosPreview(capabilities.modelName)) {
|
||||
return profile;
|
||||
}
|
||||
const levels = profile.levels.filter((level) => level.id !== "off");
|
||||
return {
|
||||
...profile,
|
||||
defaultLevel: "adaptive",
|
||||
levels: levels.some((level) => level.id === "adaptive")
|
||||
? levels
|
||||
: [...levels, { id: "adaptive" }],
|
||||
};
|
||||
},
|
||||
normalizeResolvedModel: ({ modelId, model }: ProviderNormalizeResolvedModelContext) => {
|
||||
const endpoint = extractFoundryEndpoint(model.baseUrl ?? "");
|
||||
if (!endpoint) {
|
||||
return model;
|
||||
}
|
||||
const capabilities = resolveFoundryModelCapabilities(
|
||||
modelId,
|
||||
model.name,
|
||||
isFoundryProviderApi(model.api) ? model.api : undefined,
|
||||
model.input,
|
||||
);
|
||||
const explicitSupportsReasoningEffort =
|
||||
typeof model.compat?.supportsReasoningEffort === "boolean"
|
||||
? model.compat.supportsReasoningEffort
|
||||
: undefined;
|
||||
const preserveExplicitReasoningEffort = !capabilities.reasoning && model.reasoning;
|
||||
const explicitMaxTokensField =
|
||||
typeof model.compat?.maxTokensField === "string"
|
||||
? model.compat.maxTokensField
|
||||
: preserveExplicitReasoningEffort
|
||||
? "max_completion_tokens"
|
||||
: undefined;
|
||||
const compat = capabilities.compat
|
||||
? {
|
||||
...model.compat,
|
||||
...capabilities.compat,
|
||||
...(explicitSupportsReasoningEffort !== undefined
|
||||
? { supportsReasoningEffort: explicitSupportsReasoningEffort }
|
||||
: preserveExplicitReasoningEffort
|
||||
? { supportsReasoningEffort: true }
|
||||
: undefined),
|
||||
...(explicitMaxTokensField ? { maxTokensField: explicitMaxTokensField } : {}),
|
||||
}
|
||||
: undefined;
|
||||
return {
|
||||
...model,
|
||||
name: capabilities.modelName,
|
||||
api: capabilities.api,
|
||||
reasoning: capabilities.reasoning || model.reasoning,
|
||||
thinkingLevelMap: capabilities.thinkingLevelMap ?? model.thinkingLevelMap,
|
||||
params: mergeFoundryCanonicalModelParams(model.params, capabilities.modelName),
|
||||
input: capabilities.input,
|
||||
baseUrl: buildFoundryProviderBaseUrl(
|
||||
endpoint,
|
||||
modelId,
|
||||
capabilities.modelName,
|
||||
capabilities.api,
|
||||
),
|
||||
...(compat ? { compat } : {}),
|
||||
};
|
||||
},
|
||||
wrapStreamFn: wrapMicrosoftFoundryStreamFn,
|
||||
prepareRuntimeAuth: prepareFoundryRuntimeAuth,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user