Files
openclaw/extensions/googlechat/src/setup-core.ts
T
Peter Steinberger 99d662473c fix(channels): fail-fast headless channel setup with plugin-declared env contracts (#122530)
* fix(channels): validate headless channel setup

* docs(channels): document headless provisioning

* fix(channels): repair setup metadata typing

* chore(channels): regenerate official channel catalog for env metadata

* fix(slack): keep mode-conditional env contract plugin-owned

Static --use-env declaration keeps only the unconditional SLACK_BOT_TOKEN;
socket-vs-HTTP conditional requirements (app token, signing secret) stay in
Slack's own setup validation so HTTP mode no longer demands an irrelevant
SLACK_APP_TOKEN.

* chore(sdk): regenerate api baselines and catalog after rebase

* fix(slack): align manifest env declaration with runtime contract

* chore(sdk): regenerate api baselines after rebase

* chore(sdk): regenerate api baselines after rebase

* chore(sdk): regenerate api baselines after rebase
2026-08-12 17:12:15 +00:00

91 lines
2.9 KiB
TypeScript

import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
// Googlechat plugin module implements setup core behavior.
import type { ChannelSetupInput } from "openclaw/plugin-sdk/channel-setup";
import {
createPatchedAccountSetupAdapter,
createSetupInputPresenceValidator,
} from "openclaw/plugin-sdk/setup-runtime";
const channel = "googlechat" as const;
type GoogleChatSetupInput = ChannelSetupInput & {
audienceType?: string;
audience?: string;
webhookPath?: string;
webhookUrl?: string;
};
export const googlechatSetupAdapter = createPatchedAccountSetupAdapter({
channelKey: channel,
validateInput: createSetupInputPresenceValidator({
defaultAccountOnlyEnvError:
"GOOGLE_CHAT_SERVICE_ACCOUNT env vars can only be used for the default account.",
whenNotUseEnv: [
{
someOf: ["token", "tokenFile"],
message: "Google Chat requires --token (service account JSON) or --token-file.",
},
],
}),
buildPatch: (input) => {
const setupInput = input as GoogleChatSetupInput;
const patch = setupInput.useEnv
? {}
: setupInput.tokenFile
? { serviceAccountFile: setupInput.tokenFile }
: setupInput.token
? { serviceAccount: setupInput.token }
: {};
const audienceType = setupInput.audienceType?.trim();
const audience = setupInput.audience?.trim();
const webhookPath = setupInput.webhookPath?.trim();
const webhookUrl = setupInput.webhookUrl?.trim();
return {
...patch,
...(audienceType ? { audienceType } : {}),
...(audience ? { audience } : {}),
...(webhookPath ? { webhookPath } : {}),
...(webhookUrl ? { webhookUrl } : {}),
};
},
});
export const googlechatSetupContract = defineChannelSetupContract({
fields: {
token: {
kind: "string",
sensitive: true,
cli: { flags: "--token <json>", description: "Google Chat service account JSON" },
},
tokenFile: {
kind: "string",
sensitive: true,
cli: { flags: "--token-file <path>", description: "Google Chat service account file" },
},
audienceType: {
kind: "choice",
choices: ["app-url", "project-number"],
cli: { flags: "--audience-type <type>", description: "Google Chat audience type" },
},
audience: {
kind: "string",
cli: { flags: "--audience <value>", description: "Google Chat audience value" },
},
webhookPath: {
kind: "string",
cli: { flags: "--webhook-path <path>", description: "Google Chat webhook path" },
},
webhookUrl: {
kind: "string",
cli: { flags: "--webhook-url <url>", description: "Google Chat webhook URL" },
},
useEnv: {
kind: "boolean",
cli: { flags: "--use-env", description: "Use Google Chat environment credentials" },
envVars: ["GOOGLE_CHAT_SERVICE_ACCOUNT", "GOOGLE_CHAT_SERVICE_ACCOUNT_FILE"],
envVarMode: "any",
},
},
legacyAdapter: googlechatSetupAdapter,
});