mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-04 21:31:40 +00:00
* feat(channels): add channel-owned setup contracts * test(channels): align legacy setup fixtures * chore(channels): regenerate config and SDK baselines after rebase * fix(update): run fresh doctor after current-process core changes * fix(channels): align add pre-scan with execution precedence * style(cli): format channels-cli test additions * fix(channels): restore option-before-positional channel resolution via metadata arity scan * fix(channels): keep help flags out of metadata arity escalation * test(update): mock fresh post-update doctor in current-process suites * style: format review fixes and correct entrypoint mock type * fix(channels): register only modern contract options for dual-publishing plugins * test(update): align downgrade suites with fresh-doctor child invocation * docs(channels): record empty-contract and input-forwarding invariants * fix(line): keep the shipped --token switch as a channel access token alias * fix(signal): stop treating exact cross-family loopback endpoints as bind-aligned * chore(config): regenerate docs config baselines after second rebase * style: format rebased channels add tests * fix(channels): enforce field-key and flag-name agreement in setup contracts * fix(signal): detect container endpoints for bare --http-url setup * fix(signal): ignore unconfigured accounts in transport collision checks * fix(channels): validate negated setup flags in contract and normalizer * fix(signal): preserve existing transport kind when setup detection is unreachable * style(signal): use direct boolean check in collision guard * style(signal): type test config literals * docs(update): record two-read design of fresh-doctor validation gate * fix(channels): satisfy post-rebase architecture gates * docs: refresh channel setup map --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
89 lines
2.8 KiB
TypeScript
89 lines
2.8 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" },
|
|
},
|
|
},
|
|
legacyAdapter: googlechatSetupAdapter,
|
|
});
|