Files
openclaw-zero-token/plugin-sdk/optional-channel-setup.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

57 lines
1.8 KiB
TypeScript

import type { ChannelSetupWizard } from "../channels/plugins/setup-wizard.js";
import type { ChannelSetupAdapter } from "../channels/plugins/types.adapters.js";
import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
import { formatDocsLink } from "../terminal/links.js";
type OptionalChannelSetupParams = {
channel: string;
label: string;
npmSpec?: string;
docsPath?: string;
};
function buildOptionalChannelSetupMessage(params: OptionalChannelSetupParams): string {
const installTarget = params.npmSpec ?? `the ${params.label} plugin`;
const message = [`${params.label} setup requires ${installTarget} to be installed.`];
if (params.docsPath) {
message.push(`Docs: ${formatDocsLink(params.docsPath, params.docsPath.replace(/^\/+/u, ""))}`);
}
return message.join(" ");
}
export function createOptionalChannelSetupAdapter(
params: OptionalChannelSetupParams,
): ChannelSetupAdapter {
const message = buildOptionalChannelSetupMessage(params);
return {
resolveAccountId: ({ accountId }) => accountId ?? DEFAULT_ACCOUNT_ID,
applyAccountConfig: () => {
throw new Error(message);
},
validateInput: () => message,
};
}
export function createOptionalChannelSetupWizard(
params: OptionalChannelSetupParams,
): ChannelSetupWizard {
const message = buildOptionalChannelSetupMessage(params);
return {
channel: params.channel,
status: {
configuredLabel: `${params.label} plugin installed`,
unconfiguredLabel: `install ${params.label} plugin`,
configuredHint: message,
unconfiguredHint: message,
unconfiguredScore: 0,
resolveConfigured: () => false,
resolveStatusLines: () => [message],
resolveSelectionHint: () => message,
},
credentials: [],
finalize: async () => {
throw new Error(message);
},
};
}