@openclaw/googlechat 2026.9.6 → 2026.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/icon.png +0 -0
- package/dist/.setup/actions-K6_7xusH.mjs +56 -0
- package/dist/.setup/{approval-auth-C6NmZR0i.mjs → approval-auth-DXvh9tfx.mjs} +2 -2
- package/dist/.setup/approval-card-text-BKg_4mXq.mjs +12 -0
- package/dist/.setup/{approval-handler.runtime-DPTrNUbd.mjs → approval-handler.runtime-CT2MVoa-.mjs} +42 -81
- package/dist/.setup/{channel-E2g6ySbf.mjs → channel-DAUmcC2J.mjs} +34 -82
- package/dist/.setup/{channel-base-B3EzcV7X.mjs → channel-base-inLf3HGV.mjs} +15 -36
- package/dist/.setup/{channel.adapters-CSAwKSvQ.mjs → channel.adapters-DIQot11j.mjs} +85 -172
- package/dist/.setup/{channel.runtime-BdzxoqvE.mjs → channel.runtime-C-B60lWL.mjs} +84 -161
- package/dist/.setup/doctor-contract-wLrnvLUn.mjs +294 -0
- package/dist/.setup/runtime-C5OOOlaP.mjs +8 -0
- package/dist/.setup/{secret-contract-DmWM0kwM.mjs → secret-contract-B7H-kkqq.mjs} +4 -11
- package/dist/.setup/{secret-contract-api-DHLd5XO3.mjs → secret-contract-api-GavLI-0W.mjs} +1 -1
- package/dist/.setup/{setup-plugin-api-C0zTOlHy.mjs → setup-plugin-api-CAzvWHwN.mjs} +1 -1
- package/dist/.setup/{setup-plugin-api-DWL3ZytB.mjs → setup-plugin-api-DPYc1usm.mjs} +1 -1
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/runtime-api.js +2 -3
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +2 -2
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/gcp-residency.d.ts +13 -4
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/gcp-residency.js +24 -19
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/gcp-residency.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js +65 -37
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gcp-metadata/package.json +1 -1
- package/node_modules/google-auth-library/package.json +6 -6
- package/package.json +5 -5
- package/dist/.setup/actions-BM-Gd-H7.mjs +0 -72
- package/dist/.setup/approval-card-text-ChngxXdJ.mjs +0 -6
- package/dist/.setup/doctor-contract-BLvSmTXT.mjs +0 -115
- package/dist/.setup/runtime-api-Cc5ZuXih.mjs +0 -24
package/assets/icon.png
CHANGED
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { l as resolveGoogleChatAccount } from "./channel-base-inLf3HGV.mjs";
|
|
2
|
+
import { g as resolveGoogleChatOutboundSpace, x as sendGoogleChatMessage } from "./channel.adapters-DIQot11j.mjs";
|
|
3
|
+
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { jsonResult, readStringArrayParam, readStringParam } from "openclaw/plugin-sdk/channel-actions";
|
|
5
|
+
//#region extensions/googlechat/src/actions.ts
|
|
6
|
+
const OUTBOUND_MEDIA_KEYS = [
|
|
7
|
+
"media",
|
|
8
|
+
"mediaUrl",
|
|
9
|
+
"path",
|
|
10
|
+
"filePath",
|
|
11
|
+
"fileUrl"
|
|
12
|
+
];
|
|
13
|
+
const STRUCTURED_ATTACHMENT_MEDIA_KEYS = [...OUTBOUND_MEDIA_KEYS, "url"];
|
|
14
|
+
function hasGoogleChatOutboundAttachment(params) {
|
|
15
|
+
if (OUTBOUND_MEDIA_KEYS.some((key) => readStringParam(params, key) !== void 0)) return true;
|
|
16
|
+
if (readStringArrayParam(params, "mediaUrls") !== void 0) return true;
|
|
17
|
+
if (!Array.isArray(params.attachments)) return false;
|
|
18
|
+
return params.attachments.some((attachment) => isRecord(attachment) && STRUCTURED_ATTACHMENT_MEDIA_KEYS.some((key) => readStringParam(attachment, key) !== void 0));
|
|
19
|
+
}
|
|
20
|
+
async function handleGoogleChatAction({ action, params, cfg, accountId, assertDirectAdapterHandoff, onPlatformSendDispatch }) {
|
|
21
|
+
if (action === "upload-file" || action === "send" && hasGoogleChatOutboundAttachment(params)) throw new Error("Google Chat outbound attachments require user OAuth and are not supported by this service-account channel.");
|
|
22
|
+
const account = resolveGoogleChatAccount({
|
|
23
|
+
cfg,
|
|
24
|
+
accountId
|
|
25
|
+
});
|
|
26
|
+
if (account.credentialSource === "none" || account.tokenStatus === "configured_unavailable") throw new Error("Google Chat credentials are missing.");
|
|
27
|
+
if (action === "send") {
|
|
28
|
+
const to = readStringParam(params, "to", { required: true });
|
|
29
|
+
const content = readStringParam(params, "message", {
|
|
30
|
+
required: true,
|
|
31
|
+
allowEmpty: true
|
|
32
|
+
});
|
|
33
|
+
const threadId = readStringParam(params, "threadId") ?? readStringParam(params, "replyTo");
|
|
34
|
+
const space = await resolveGoogleChatOutboundSpace({
|
|
35
|
+
account,
|
|
36
|
+
target: to,
|
|
37
|
+
assertDirectAdapterHandoff
|
|
38
|
+
});
|
|
39
|
+
const sent = await sendGoogleChatMessage({
|
|
40
|
+
account,
|
|
41
|
+
space,
|
|
42
|
+
text: content,
|
|
43
|
+
thread: threadId ?? void 0,
|
|
44
|
+
assertDirectAdapterHandoff,
|
|
45
|
+
onPlatformSendDispatch
|
|
46
|
+
});
|
|
47
|
+
return jsonResult({
|
|
48
|
+
ok: true,
|
|
49
|
+
to: space,
|
|
50
|
+
...sent
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Action ${action} is not supported for provider googlechat.`);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { handleGoogleChatAction };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as resolveGoogleChatAccount } from "./channel-base-
|
|
2
|
-
import { m as normalizeGoogleChatTarget, p as isGoogleChatUserTarget } from "./channel.adapters-
|
|
1
|
+
import { l as resolveGoogleChatAccount } from "./channel-base-inLf3HGV.mjs";
|
|
2
|
+
import { m as normalizeGoogleChatTarget, p as isGoogleChatUserTarget } from "./channel.adapters-DIQot11j.mjs";
|
|
3
3
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
5
5
|
//#region extensions/googlechat/src/approval-auth.ts
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
2
|
+
//#region extensions/googlechat/src/approval-card-text.ts
|
|
3
|
+
const MAX_TEXT_PARAGRAPH_CHARS = 1800;
|
|
4
|
+
function escapeGoogleChatApprovalCardText(text) {
|
|
5
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
6
|
+
}
|
|
7
|
+
function buildGoogleChatApprovalTextWidget(text, format = "text") {
|
|
8
|
+
const truncated = text.length <= MAX_TEXT_PARAGRAPH_CHARS ? text : `${truncateUtf16Safe(text, 1797)}...`;
|
|
9
|
+
return { textParagraph: { text: format === "html" ? truncated : escapeGoogleChatApprovalCardText(truncated) } };
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { escapeGoogleChatApprovalCardText as n, buildGoogleChatApprovalTextWidget as t };
|
package/dist/.setup/{approval-handler.runtime-DPTrNUbd.mjs → approval-handler.runtime-CT2MVoa-.mjs}
RENAMED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { l as resolveGoogleChatAccount } from "./channel-base-
|
|
2
|
-
import { A as unregisterGoogleChatManualApprovalFollowupSuppression, E as googleChatApprovalControls, O as registerGoogleChatApprovalCardBinding, S as updateGoogleChatMessage, T as buildGoogleChatApprovalActionParameters, g as resolveGoogleChatOutboundSpace, k as registerGoogleChatManualApprovalFollowupSuppression, w as GOOGLECHAT_APPROVAL_ACTION, x as sendGoogleChatMessage } from "./channel.adapters-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { l as resolveGoogleChatAccount } from "./channel-base-inLf3HGV.mjs";
|
|
2
|
+
import { A as unregisterGoogleChatManualApprovalFollowupSuppression, E as googleChatApprovalControls, O as registerGoogleChatApprovalCardBinding, S as updateGoogleChatMessage, T as buildGoogleChatApprovalActionParameters, g as resolveGoogleChatOutboundSpace, k as registerGoogleChatManualApprovalFollowupSuppression, w as GOOGLECHAT_APPROVAL_ACTION, x as sendGoogleChatMessage } from "./channel.adapters-DIQot11j.mjs";
|
|
3
|
+
import { n as isGoogleChatNativeApprovalClientEnabled, r as shouldHandleGoogleChatNativeApprovalRequest } from "./channel-DAUmcC2J.mjs";
|
|
4
|
+
import { n as escapeGoogleChatApprovalCardText, t as buildGoogleChatApprovalTextWidget } from "./approval-card-text-BKg_4mXq.mjs";
|
|
5
5
|
import { buildChannelApprovalNativeTargetKey } from "openclaw/plugin-sdk/approval-native-runtime";
|
|
6
6
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
-
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
8
7
|
import { formatChannelApprovalResolvedLabel } from "openclaw/plugin-sdk/approval-runtime";
|
|
9
8
|
import { createChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
|
|
10
9
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
11
10
|
//#region extensions/googlechat/src/approval-handler.runtime.ts
|
|
12
11
|
const log = createSubsystemLogger("googlechat/approvals");
|
|
13
12
|
const GOOGLECHAT_APPROVAL_CARD_ID = "openclaw-approval";
|
|
14
|
-
const MAX_TEXT_PARAGRAPH_CHARS = 1800;
|
|
15
13
|
function resolveHandlerAccount(params) {
|
|
16
14
|
const account = params.context?.account ?? resolveGoogleChatAccount({
|
|
17
15
|
cfg: params.cfg,
|
|
@@ -20,68 +18,51 @@ function resolveHandlerAccount(params) {
|
|
|
20
18
|
if (!account.enabled || account.credentialSource === "none" || account.tokenStatus === "configured_unavailable") return null;
|
|
21
19
|
return account;
|
|
22
20
|
}
|
|
23
|
-
function truncateText(text, maxChars = MAX_TEXT_PARAGRAPH_CHARS) {
|
|
24
|
-
return text.length <= maxChars ? text : `${truncateUtf16Safe(text, maxChars - 3)}...`;
|
|
25
|
-
}
|
|
26
21
|
function buildMetadataText(metadata) {
|
|
27
22
|
return metadata.map((item) => `<b>${escapeGoogleChatApprovalCardText(item.label)}:</b> ${escapeGoogleChatApprovalCardText(item.value)}`).join("<br>");
|
|
28
23
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
function buildHtmlTextWidget(text) {
|
|
33
|
-
return { textParagraph: { text: truncateText(text) } };
|
|
34
|
-
}
|
|
35
|
-
function buildExecPendingSections(view) {
|
|
36
|
-
if (view.approvalKind !== "exec") return [];
|
|
37
|
-
return [{
|
|
24
|
+
function buildPendingSections(view) {
|
|
25
|
+
if (view.approvalKind === "exec") return [{
|
|
38
26
|
header: "Command",
|
|
39
|
-
widgets: [
|
|
27
|
+
widgets: [buildGoogleChatApprovalTextWidget(view.commandText)]
|
|
40
28
|
}, ...view.commandPreview && view.commandPreview !== view.commandText ? [{
|
|
41
29
|
header: "Preview",
|
|
42
|
-
widgets: [
|
|
30
|
+
widgets: [buildGoogleChatApprovalTextWidget(view.commandPreview)]
|
|
43
31
|
}] : []];
|
|
44
|
-
|
|
45
|
-
function buildPluginPendingSections(view) {
|
|
46
|
-
if (view.approvalKind !== "plugin") return [];
|
|
47
|
-
return [{
|
|
32
|
+
if (view.approvalKind === "plugin") return [{
|
|
48
33
|
header: "Request",
|
|
49
|
-
widgets: [
|
|
34
|
+
widgets: [buildGoogleChatApprovalTextWidget(`<b>${escapeGoogleChatApprovalCardText(view.title)}</b>${view.description ? `<br>${escapeGoogleChatApprovalCardText(view.description)}` : ""}`, "html")]
|
|
50
35
|
}];
|
|
51
|
-
}
|
|
52
|
-
function buildSystemAgentPendingSections(view) {
|
|
53
|
-
if (view.approvalKind !== "system-agent") return [];
|
|
54
36
|
return [{
|
|
55
37
|
header: "Change",
|
|
56
|
-
widgets: [
|
|
38
|
+
widgets: [buildGoogleChatApprovalTextWidget(view.operationSummary)]
|
|
57
39
|
}];
|
|
58
40
|
}
|
|
59
41
|
function buildMetadataSection(view) {
|
|
60
|
-
|
|
61
|
-
label: "Approval ID",
|
|
62
|
-
value: view.approvalId
|
|
63
|
-
}, ...view.metadata];
|
|
64
|
-
return metadata.length > 0 ? [{
|
|
42
|
+
return {
|
|
65
43
|
header: "Details",
|
|
66
|
-
widgets: [
|
|
67
|
-
|
|
44
|
+
widgets: [buildGoogleChatApprovalTextWidget(buildMetadataText([{
|
|
45
|
+
label: "Approval ID",
|
|
46
|
+
value: view.approvalId
|
|
47
|
+
}, ...view.metadata]), "html")]
|
|
48
|
+
};
|
|
68
49
|
}
|
|
69
50
|
function buildActionSection(params) {
|
|
70
51
|
const { actionFunction, view } = params;
|
|
71
|
-
const actionTokens =
|
|
72
|
-
token: googleChatApprovalControls.createToken(),
|
|
73
|
-
decision: action.decision
|
|
74
|
-
}));
|
|
52
|
+
const actionTokens = [];
|
|
75
53
|
return {
|
|
76
54
|
actionTokens,
|
|
77
|
-
section: { widgets: [{ buttonList: { buttons: view.actions.map((action
|
|
78
|
-
const
|
|
79
|
-
|
|
55
|
+
section: { widgets: [{ buttonList: { buttons: view.actions.map((action) => {
|
|
56
|
+
const token = googleChatApprovalControls.createToken();
|
|
57
|
+
actionTokens.push({
|
|
58
|
+
token,
|
|
59
|
+
decision: action.decision
|
|
60
|
+
});
|
|
80
61
|
return {
|
|
81
62
|
text: action.label,
|
|
82
63
|
onClick: { action: {
|
|
83
64
|
function: actionFunction,
|
|
84
|
-
parameters: buildGoogleChatApprovalActionParameters(
|
|
65
|
+
parameters: buildGoogleChatApprovalActionParameters(token),
|
|
85
66
|
loadIndicator: "SPINNER"
|
|
86
67
|
} }
|
|
87
68
|
};
|
|
@@ -104,10 +85,8 @@ function buildPendingPayload(params) {
|
|
|
104
85
|
subtitle
|
|
105
86
|
},
|
|
106
87
|
sections: [
|
|
107
|
-
...
|
|
108
|
-
|
|
109
|
-
...buildSystemAgentPendingSections(view),
|
|
110
|
-
...buildMetadataSection(view),
|
|
88
|
+
...buildPendingSections(view),
|
|
89
|
+
buildMetadataSection(view),
|
|
111
90
|
actionSection
|
|
112
91
|
]
|
|
113
92
|
}
|
|
@@ -127,29 +106,16 @@ function resolveApprovalActionFunction(params) {
|
|
|
127
106
|
const appPrincipal = normalizeOptionalString(account?.config.appPrincipal);
|
|
128
107
|
return account?.config.audienceType === "app-url" && audience && appPrincipal ? audience : GOOGLECHAT_APPROVAL_ACTION;
|
|
129
108
|
}
|
|
130
|
-
function
|
|
131
|
-
const
|
|
132
|
-
const decisionLabel = formatChannelApprovalResolvedLabel(view);
|
|
133
|
-
return { cardsV2: [{
|
|
134
|
-
cardId: GOOGLECHAT_APPROVAL_CARD_ID,
|
|
135
|
-
card: {
|
|
136
|
-
header: {
|
|
137
|
-
title: `${view.approvalKind === "plugin" ? "Plugin" : view.approvalKind === "system-agent" ? "OpenClaw Change" : "Exec"} Approval: ${decisionLabel}`,
|
|
138
|
-
subtitle: resolvedBy ? `Resolved by ${resolvedBy}` : "Resolved"
|
|
139
|
-
},
|
|
140
|
-
sections: buildMetadataSection(view)
|
|
141
|
-
}
|
|
142
|
-
}] };
|
|
143
|
-
}
|
|
144
|
-
function buildExpiredPayload(view) {
|
|
109
|
+
function buildFinalPayload(view, outcome, subtitle) {
|
|
110
|
+
const kindLabel = view.approvalKind === "plugin" ? "Plugin" : view.approvalKind === "system-agent" ? "OpenClaw Change" : "Exec";
|
|
145
111
|
return { cardsV2: [{
|
|
146
112
|
cardId: GOOGLECHAT_APPROVAL_CARD_ID,
|
|
147
113
|
card: {
|
|
148
114
|
header: {
|
|
149
|
-
title: `${
|
|
150
|
-
subtitle
|
|
115
|
+
title: `${kindLabel} Approval${outcome}`,
|
|
116
|
+
subtitle
|
|
151
117
|
},
|
|
152
|
-
sections: buildMetadataSection(view)
|
|
118
|
+
sections: [buildMetadataSection(view)]
|
|
153
119
|
}
|
|
154
120
|
}] };
|
|
155
121
|
}
|
|
@@ -160,16 +126,8 @@ const googleChatApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapte
|
|
|
160
126
|
"system-agent"
|
|
161
127
|
],
|
|
162
128
|
availability: {
|
|
163
|
-
isConfigured:
|
|
164
|
-
|
|
165
|
-
accountId
|
|
166
|
-
}),
|
|
167
|
-
shouldHandle: ({ cfg, accountId, approvalKind, request }) => shouldHandleGoogleChatNativeApprovalRequest({
|
|
168
|
-
cfg,
|
|
169
|
-
accountId,
|
|
170
|
-
approvalKind,
|
|
171
|
-
request
|
|
172
|
-
})
|
|
129
|
+
isConfigured: isGoogleChatNativeApprovalClientEnabled,
|
|
130
|
+
shouldHandle: shouldHandleGoogleChatNativeApprovalRequest
|
|
173
131
|
},
|
|
174
132
|
presentation: {
|
|
175
133
|
buildPendingPayload: ({ cfg, accountId, context, nowMs, view }) => buildPendingPayload({
|
|
@@ -181,13 +139,16 @@ const googleChatApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapte
|
|
|
181
139
|
nowMs,
|
|
182
140
|
view
|
|
183
141
|
}),
|
|
184
|
-
buildResolvedResult: ({ view }) =>
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
142
|
+
buildResolvedResult: ({ view }) => {
|
|
143
|
+
const resolvedBy = normalizeOptionalString(view.resolvedBy);
|
|
144
|
+
return {
|
|
145
|
+
kind: "update",
|
|
146
|
+
payload: buildFinalPayload(view, `: ${formatChannelApprovalResolvedLabel(view)}`, resolvedBy ? `Resolved by ${resolvedBy}` : "Resolved")
|
|
147
|
+
};
|
|
148
|
+
},
|
|
188
149
|
buildExpiredResult: ({ view }) => ({
|
|
189
150
|
kind: "update",
|
|
190
|
-
payload:
|
|
151
|
+
payload: buildFinalPayload(view, " Expired", "This approval request expired before it was resolved.")
|
|
191
152
|
})
|
|
192
153
|
},
|
|
193
154
|
transport: {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as googlechatPairingTextAdapter, f as isGoogleChatSpaceTarget, h as resolveGoogleChatOutboundSessionRoute, i as googlechatOutboundAdapter, m as normalizeGoogleChatTarget, n as googlechatGroupsAdapter, o as googlechatSecurityAdapter, p as isGoogleChatUserTarget, r as googlechatMessageAdapter, s as googlechatThreadingAdapter, t as googlechatDirectoryAdapter } from "./channel.adapters-CSAwKSvQ.mjs";
|
|
1
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-wLrnvLUn.mjs";
|
|
3
2
|
import { n as buildChannelConfigSchema, t as GoogleChatConfigSchema } from "./config-api-CsD0IFxF.mjs";
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as
|
|
6
|
-
import { n as
|
|
7
|
-
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-
|
|
3
|
+
import { c as resolveDefaultGoogleChatAccountId, l as resolveGoogleChatAccount, n as createGoogleChatPluginBase, o as inspectGoogleChatAccount, s as listGoogleChatAccountIds, t as GOOGLECHAT_CHANNEL_ID } from "./channel-base-inLf3HGV.mjs";
|
|
4
|
+
import { a as googlechatPairingTextAdapter, f as isGoogleChatSpaceTarget, h as resolveGoogleChatOutboundSessionRoute, i as googlechatOutboundAdapter, m as normalizeGoogleChatTarget, n as googlechatGroupsAdapter, o as googlechatSecurityAdapter, p as isGoogleChatUserTarget, r as googlechatMessageAdapter, s as googlechatThreadingAdapter, t as googlechatDirectoryAdapter } from "./channel.adapters-DIQot11j.mjs";
|
|
5
|
+
import { n as googleChatApprovalAuth, r as normalizeGoogleChatApproverId, t as getGoogleChatApprovalApprovers } from "./approval-auth-DXvh9tfx.mjs";
|
|
6
|
+
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-B7H-kkqq.mjs";
|
|
7
|
+
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
8
8
|
import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
9
9
|
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
|
10
10
|
import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
|
11
11
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
12
|
-
import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
|
|
13
12
|
import { createApproverRestrictedNativeApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
|
|
14
13
|
import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY, createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
|
|
15
14
|
import { createChannelApproverDmTargetResolver, createChannelNativeOriginTargetResolver, createNativeApprovalChannelRouteGates, shouldSuppressLocalNativeExecApprovalPrompt } from "openclaw/plugin-sdk/approval-native-runtime";
|
|
@@ -18,20 +17,12 @@ import { createAccountStatusSink, runPassiveAccountLifecycle } from "openclaw/pl
|
|
|
18
17
|
import { buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector } from "openclaw/plugin-sdk/channel-policy";
|
|
19
18
|
import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
|
|
20
19
|
import { channelBlockedPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
20
|
+
import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
|
|
21
21
|
//#region extensions/googlechat/src/approval-native.ts
|
|
22
22
|
const DEFAULT_APPROVAL_FORWARDING_MODE = "session";
|
|
23
|
-
function isGoogleChatAccountConfigured(params) {
|
|
24
|
-
const account = resolveGoogleChatAccount(params);
|
|
25
|
-
return account.enabled && account.credentialSource !== "none" && account.tokenStatus !== "configured_unavailable";
|
|
26
|
-
}
|
|
27
|
-
function hasGoogleChatWebhookApprovalAuthConfig(params) {
|
|
28
|
-
const account = resolveGoogleChatAccount(params).config;
|
|
29
|
-
if (!normalizeOptionalString(account.audience)) return false;
|
|
30
|
-
if (account.audienceType === "project-number") return true;
|
|
31
|
-
return account.audienceType === "app-url";
|
|
32
|
-
}
|
|
33
23
|
function isGoogleChatApprovalTransportEnabled(params) {
|
|
34
|
-
|
|
24
|
+
const account = resolveGoogleChatAccount(params);
|
|
25
|
+
return account.enabled && account.credentialSource !== "none" && account.tokenStatus !== "configured_unavailable" && Boolean(normalizeOptionalString(account.config.audience)) && (account.config.audienceType === "project-number" || account.config.audienceType === "app-url");
|
|
35
26
|
}
|
|
36
27
|
function normalizeGoogleChatForwardTarget(target) {
|
|
37
28
|
if (normalizeLowercaseStringOrEmpty(target.channel) !== "googlechat") return null;
|
|
@@ -105,7 +96,7 @@ const googleChatApprovalCapability = createApproverRestrictedNativeApprovalCapab
|
|
|
105
96
|
channelLabel: "Google Chat",
|
|
106
97
|
describeExecApprovalSetup: ({ accountId }) => {
|
|
107
98
|
const prefix = accountId && accountId !== "default" ? `channels.googlechat.accounts.${accountId}` : "channels.googlechat";
|
|
108
|
-
return `Approve it from the Web UI
|
|
99
|
+
return `Approve it from the Web UI for now. Google Chat supports native approvals for this account when the webhook and service account are configured. Configure \`${prefix}.allowFrom\` or \`${prefix}.defaultTo\` with numeric \`users/{id}\` approvers.`;
|
|
109
100
|
},
|
|
110
101
|
listAccountIds: listGoogleChatAccountIds,
|
|
111
102
|
hasApprovers: ({ cfg, accountId }) => getGoogleChatApprovalApprovers({
|
|
@@ -139,17 +130,9 @@ const googleChatApprovalCapability = createApproverRestrictedNativeApprovalCapab
|
|
|
139
130
|
"plugin",
|
|
140
131
|
"system-agent"
|
|
141
132
|
],
|
|
142
|
-
isConfigured:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}),
|
|
146
|
-
shouldHandle: ({ cfg, accountId, approvalKind, request }) => shouldHandleGoogleChatNativeApprovalRequest({
|
|
147
|
-
cfg,
|
|
148
|
-
accountId,
|
|
149
|
-
approvalKind,
|
|
150
|
-
request
|
|
151
|
-
}),
|
|
152
|
-
load: async () => (await import("./approval-handler.runtime-DPTrNUbd.mjs")).googleChatApprovalNativeRuntime
|
|
133
|
+
isConfigured: isGoogleChatNativeApprovalClientEnabled,
|
|
134
|
+
shouldHandle: shouldHandleGoogleChatNativeApprovalRequest,
|
|
135
|
+
load: async () => (await import("./approval-handler.runtime-CT2MVoa-.mjs")).googleChatApprovalNativeRuntime
|
|
153
136
|
})
|
|
154
137
|
});
|
|
155
138
|
//#endregion
|
|
@@ -173,7 +156,7 @@ const collectGoogleChatMutableAllowlistWarnings = createDangerousNameMatchingMut
|
|
|
173
156
|
});
|
|
174
157
|
//#endregion
|
|
175
158
|
//#region extensions/googlechat/src/gateway.ts
|
|
176
|
-
const loadGoogleChatChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./channel.runtime-
|
|
159
|
+
const loadGoogleChatChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./channel.runtime-C-B60lWL.mjs"), "googleChatChannelRuntime");
|
|
177
160
|
const UNRESOLVED_WEBHOOK_URL_ERROR = "Invalid webhookUrl: expected an absolute URL such as https://chat.example.com/googlechat. No inbound webhook route was registered.";
|
|
178
161
|
async function startGoogleChatGatewayAccount(ctx) {
|
|
179
162
|
const account = ctx.account;
|
|
@@ -183,7 +166,7 @@ async function startGoogleChatGatewayAccount(ctx) {
|
|
|
183
166
|
});
|
|
184
167
|
ctx.log?.info?.(`[${account.accountId}] starting Google Chat webhook`);
|
|
185
168
|
const { resolveGoogleChatWebhookPath, startGoogleChatMonitor } = await loadGoogleChatChannelRuntime$1();
|
|
186
|
-
const webhookPath = resolveGoogleChatWebhookPath(
|
|
169
|
+
const webhookPath = resolveGoogleChatWebhookPath(account.config);
|
|
187
170
|
statusSink({
|
|
188
171
|
running: true,
|
|
189
172
|
lastStartAt: Date.now(),
|
|
@@ -194,15 +177,6 @@ async function startGoogleChatGatewayAccount(ctx) {
|
|
|
194
177
|
audienceType: account.config.audienceType,
|
|
195
178
|
audience: account.config.audience
|
|
196
179
|
});
|
|
197
|
-
let stopped = false;
|
|
198
|
-
const markStopped = () => {
|
|
199
|
-
if (stopped) return;
|
|
200
|
-
stopped = true;
|
|
201
|
-
statusSink({
|
|
202
|
-
running: false,
|
|
203
|
-
lastStopAt: Date.now()
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
180
|
if (isGoogleChatNativeApprovalClientEnabled({
|
|
207
181
|
cfg: ctx.cfg,
|
|
208
182
|
accountId: account.accountId
|
|
@@ -228,14 +202,13 @@ async function startGoogleChatGatewayAccount(ctx) {
|
|
|
228
202
|
}),
|
|
229
203
|
stop: async (unregister) => {
|
|
230
204
|
await unregister?.();
|
|
231
|
-
},
|
|
232
|
-
onStop: async () => {
|
|
233
|
-
markStopped();
|
|
234
205
|
}
|
|
235
206
|
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
207
|
+
} finally {
|
|
208
|
+
statusSink({
|
|
209
|
+
running: false,
|
|
210
|
+
lastStopAt: Date.now()
|
|
211
|
+
});
|
|
239
212
|
}
|
|
240
213
|
}
|
|
241
214
|
//#endregion
|
|
@@ -249,19 +222,15 @@ function describeGoogleChatMessageTool({ cfg, accountId }) {
|
|
|
249
222
|
accountId: listedAccountId
|
|
250
223
|
}))).some((account) => account.enabled && account.credentialSource !== "none" && account.tokenStatus === "available") ? { actions: ["send"] } : null;
|
|
251
224
|
}
|
|
252
|
-
|
|
253
|
-
//#region extensions/googlechat/src/channel.ts
|
|
254
|
-
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-BdzxoqvE.mjs"), "googleChatChannelRuntime");
|
|
255
|
-
const googlechatActions = {
|
|
225
|
+
const googlechatMessageActions = {
|
|
256
226
|
describeMessageTool: describeGoogleChatMessageTool,
|
|
257
227
|
supportsAction: ({ action }) => action === "send",
|
|
258
228
|
extractToolSend: ({ args }) => extractToolSend(args, "sendMessage"),
|
|
259
|
-
handleAction: async (ctx) =>
|
|
260
|
-
const { googlechatMessageActions } = await import("./actions-BM-Gd-H7.mjs");
|
|
261
|
-
if (!googlechatMessageActions.handleAction) throw new Error("Google Chat actions are not available.");
|
|
262
|
-
return await googlechatMessageActions.handleAction(ctx);
|
|
263
|
-
}
|
|
229
|
+
handleAction: async (ctx) => (await import("./actions-K6_7xusH.mjs")).handleGoogleChatAction(ctx)
|
|
264
230
|
};
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region extensions/googlechat/src/channel.ts
|
|
233
|
+
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-C-B60lWL.mjs"), "googleChatChannelRuntime");
|
|
265
234
|
const googlechatPlugin = createChatChannelPlugin({
|
|
266
235
|
base: {
|
|
267
236
|
...createGoogleChatPluginBase({ configSchema: buildChannelConfigSchema(GoogleChatConfigSchema) }),
|
|
@@ -285,7 +254,7 @@ const googlechatPlugin = createChatChannelPlugin({
|
|
|
285
254
|
if (isGoogleChatUserTarget(target)) return "direct";
|
|
286
255
|
return isGoogleChatSpaceTarget(target) ? "group" : void 0;
|
|
287
256
|
},
|
|
288
|
-
resolveOutboundSessionRoute:
|
|
257
|
+
resolveOutboundSessionRoute: resolveGoogleChatOutboundSessionRoute,
|
|
289
258
|
targetResolver: {
|
|
290
259
|
looksLikeId: (raw, normalized) => {
|
|
291
260
|
const value = normalized ?? raw.trim();
|
|
@@ -321,7 +290,7 @@ const googlechatPlugin = createChatChannelPlugin({
|
|
|
321
290
|
};
|
|
322
291
|
});
|
|
323
292
|
} },
|
|
324
|
-
actions:
|
|
293
|
+
actions: googlechatMessageActions,
|
|
325
294
|
doctor: {
|
|
326
295
|
dmAllowFromMode: "topOnly",
|
|
327
296
|
groupModel: "route",
|
|
@@ -334,26 +303,14 @@ const googlechatPlugin = createChatChannelPlugin({
|
|
|
334
303
|
status: createComputedAccountStatusAdapter({
|
|
335
304
|
defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID),
|
|
336
305
|
collectStatusIssues: (accounts) => accounts.flatMap((entry) => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const configured = entry.configured === true;
|
|
340
|
-
if (!enabled || !configured) return [];
|
|
341
|
-
const issues = [];
|
|
342
|
-
if (!entry.audience) issues.push({
|
|
343
|
-
channel: GOOGLECHAT_CHANNEL_ID,
|
|
344
|
-
accountId,
|
|
345
|
-
kind: "config",
|
|
346
|
-
message: "Google Chat audience is missing (set channels.googlechat.audience).",
|
|
347
|
-
fix: "Set channels.googlechat.audienceType and channels.googlechat.audience."
|
|
348
|
-
});
|
|
349
|
-
if (!entry.audienceType) issues.push({
|
|
306
|
+
if (entry.enabled === false || entry.configured !== true) return [];
|
|
307
|
+
return [!entry.audience && "Google Chat audience is missing (set channels.googlechat.audience).", !entry.audienceType && "Google Chat audienceType is missing (app-url or project-number)."].flatMap((message) => message ? [{
|
|
350
308
|
channel: GOOGLECHAT_CHANNEL_ID,
|
|
351
|
-
accountId,
|
|
309
|
+
accountId: entry.accountId ?? DEFAULT_ACCOUNT_ID,
|
|
352
310
|
kind: "config",
|
|
353
|
-
message
|
|
311
|
+
message,
|
|
354
312
|
fix: "Set channels.googlechat.audienceType and channels.googlechat.audience."
|
|
355
|
-
});
|
|
356
|
-
return issues;
|
|
313
|
+
}] : []);
|
|
357
314
|
}),
|
|
358
315
|
buildChannelSummary: ({ snapshot }) => buildPassiveProbedChannelStatusSummary(snapshot, {
|
|
359
316
|
credentialSource: snapshot.credentialSource ?? "none",
|
|
@@ -388,14 +345,9 @@ const googlechatPlugin = createChatChannelPlugin({
|
|
|
388
345
|
...googlechatOutboundAdapter,
|
|
389
346
|
base: {
|
|
390
347
|
...googlechatOutboundAdapter.base,
|
|
391
|
-
shouldSuppressLocalPayloadPrompt:
|
|
392
|
-
cfg,
|
|
393
|
-
accountId,
|
|
394
|
-
payload,
|
|
395
|
-
hint
|
|
396
|
-
})
|
|
348
|
+
shouldSuppressLocalPayloadPrompt: shouldSuppressLocalGoogleChatExecApprovalPrompt
|
|
397
349
|
}
|
|
398
350
|
}
|
|
399
351
|
});
|
|
400
352
|
//#endregion
|
|
401
|
-
export {
|
|
353
|
+
export { isGoogleChatNativeApprovalClientEnabled as n, shouldHandleGoogleChatNativeApprovalRequest as r, googlechatPlugin as t };
|
|
@@ -54,6 +54,19 @@ function parseServiceAccount(value) {
|
|
|
54
54
|
}
|
|
55
55
|
return safeParseWithSchema(JsonRecordSchema, value);
|
|
56
56
|
}
|
|
57
|
+
function resolveCredentialsFile(file, source, configPath) {
|
|
58
|
+
const result = tryReadSecretFileSync(resolveUserPath(file), "Google Chat service account file", {
|
|
59
|
+
maxBytes: MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES,
|
|
60
|
+
rejectHardlinks: false,
|
|
61
|
+
rejectSymlink: false
|
|
62
|
+
}, { configPath });
|
|
63
|
+
return {
|
|
64
|
+
credentialsFile: file,
|
|
65
|
+
source,
|
|
66
|
+
status: result.status,
|
|
67
|
+
...result.status === "configured_unavailable" ? { diagnostic: result.diagnostic } : {}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
57
70
|
function resolveCredentialsFromConfig(params) {
|
|
58
71
|
const { account, accountId } = params;
|
|
59
72
|
const inline = parseServiceAccount(account.serviceAccount);
|
|
@@ -75,24 +88,7 @@ function resolveCredentialsFromConfig(params) {
|
|
|
75
88
|
status: "missing"
|
|
76
89
|
};
|
|
77
90
|
const file = normalizeOptionalString(account.serviceAccountFile);
|
|
78
|
-
if (file) {
|
|
79
|
-
const resolvedFile = resolveUserPath(file);
|
|
80
|
-
const result = tryReadSecretFileSync(resolvedFile, "Google Chat service account file", {
|
|
81
|
-
maxBytes: MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES,
|
|
82
|
-
rejectHardlinks: false,
|
|
83
|
-
rejectSymlink: false
|
|
84
|
-
}, { configPath: `channels.googlechat.accounts.${accountId}.serviceAccountFile` });
|
|
85
|
-
return result.status === "available" ? {
|
|
86
|
-
credentialsFile: file,
|
|
87
|
-
source: "file",
|
|
88
|
-
status: "available"
|
|
89
|
-
} : {
|
|
90
|
-
credentialsFile: file,
|
|
91
|
-
source: "file",
|
|
92
|
-
status: "configured_unavailable",
|
|
93
|
-
diagnostic: result.diagnostic
|
|
94
|
-
};
|
|
95
|
-
}
|
|
91
|
+
if (file) return resolveCredentialsFile(file, "file", `channels.googlechat.accounts.${accountId}.serviceAccountFile`);
|
|
96
92
|
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
97
93
|
const envJson = process.env[ENV_SERVICE_ACCOUNT$1];
|
|
98
94
|
const envInline = parseServiceAccount(envJson);
|
|
@@ -102,24 +98,7 @@ function resolveCredentialsFromConfig(params) {
|
|
|
102
98
|
status: "available"
|
|
103
99
|
};
|
|
104
100
|
const envFile = normalizeOptionalString(process.env[ENV_SERVICE_ACCOUNT_FILE$1]);
|
|
105
|
-
if (envFile) {
|
|
106
|
-
const resolvedEnvFile = resolveUserPath(envFile);
|
|
107
|
-
const result = tryReadSecretFileSync(resolvedEnvFile, "Google Chat service account file", {
|
|
108
|
-
maxBytes: MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES,
|
|
109
|
-
rejectHardlinks: false,
|
|
110
|
-
rejectSymlink: false
|
|
111
|
-
}, { configPath: `env.${ENV_SERVICE_ACCOUNT_FILE$1}` });
|
|
112
|
-
return result.status === "available" ? {
|
|
113
|
-
credentialsFile: envFile,
|
|
114
|
-
source: "env",
|
|
115
|
-
status: "available"
|
|
116
|
-
} : {
|
|
117
|
-
credentialsFile: envFile,
|
|
118
|
-
source: "env",
|
|
119
|
-
status: "configured_unavailable",
|
|
120
|
-
diagnostic: result.diagnostic
|
|
121
|
-
};
|
|
122
|
-
}
|
|
101
|
+
if (envFile) return resolveCredentialsFile(envFile, "env", `env.${ENV_SERVICE_ACCOUNT_FILE$1}`);
|
|
123
102
|
}
|
|
124
103
|
return {
|
|
125
104
|
source: "none",
|