@kodelyth/googlechat 2026.5.39 → 2026.5.42
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/api.ts +3 -0
- package/channel-config-api.ts +1 -0
- package/channel-plugin-api.ts +1 -0
- package/config-api.ts +2 -0
- package/contract-api.ts +5 -0
- package/dist/actions-YK1wn4ed.js +160 -0
- package/dist/api-BkZX4VNX.js +633 -0
- package/dist/api.js +3 -0
- package/dist/channel-DFZdjXD6.js +584 -0
- package/dist/channel-config-api.js +6 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-en3RNg9S.js +998 -0
- package/dist/contract-api.js +3 -0
- package/dist/doctor-contract-8SF6XoKj.js +151 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/index.js +22 -0
- package/dist/runtime-api-DUH2Cg-0.js +29 -0
- package/dist/runtime-api.js +2 -0
- package/dist/secret-contract-DWX4ikgT.js +99 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/setup-entry.js +15 -0
- package/dist/setup-plugin-api.js +75 -0
- package/dist/setup-surface-B3Fa7XRx.js +321 -0
- package/dist/test-api.js +3 -0
- package/doctor-contract-api.ts +1 -0
- package/index.ts +20 -0
- package/klaw.plugin.json +2 -967
- package/package.json +4 -4
- package/runtime-api.ts +55 -0
- package/secret-contract-api.ts +5 -0
- package/setup-entry.ts +13 -0
- package/setup-plugin-api.ts +3 -0
- package/src/accounts.ts +181 -0
- package/src/actions.test.ts +289 -0
- package/src/actions.ts +227 -0
- package/src/api.ts +316 -0
- package/src/approval-auth.test.ts +24 -0
- package/src/approval-auth.ts +32 -0
- package/src/auth.ts +218 -0
- package/src/channel-config.test.ts +39 -0
- package/src/channel.adapters.ts +340 -0
- package/src/channel.deps.runtime.ts +29 -0
- package/src/channel.runtime.ts +17 -0
- package/src/channel.setup.ts +98 -0
- package/src/channel.test.ts +784 -0
- package/src/channel.ts +277 -0
- package/src/config-schema.test.ts +31 -0
- package/src/config-schema.ts +3 -0
- package/src/doctor-contract.test.ts +75 -0
- package/src/doctor-contract.ts +182 -0
- package/src/doctor.ts +57 -0
- package/src/gateway.ts +63 -0
- package/src/google-auth.runtime.test.ts +543 -0
- package/src/google-auth.runtime.ts +568 -0
- package/src/group-policy.ts +17 -0
- package/src/monitor-access.test.ts +491 -0
- package/src/monitor-access.ts +465 -0
- package/src/monitor-durable.test.ts +39 -0
- package/src/monitor-durable.ts +23 -0
- package/src/monitor-reply-delivery.ts +156 -0
- package/src/monitor-routing.ts +65 -0
- package/src/monitor-types.ts +33 -0
- package/src/monitor-webhook.test.ts +587 -0
- package/src/monitor-webhook.ts +303 -0
- package/src/monitor.reply-delivery.test.ts +144 -0
- package/src/monitor.test.ts +159 -0
- package/src/monitor.ts +527 -0
- package/src/monitor.webhook-routing.test.ts +257 -0
- package/src/runtime.ts +9 -0
- package/src/secret-contract.test.ts +60 -0
- package/src/secret-contract.ts +161 -0
- package/src/setup-core.ts +40 -0
- package/src/setup-surface.ts +243 -0
- package/src/setup.test.ts +619 -0
- package/src/targets.test.ts +453 -0
- package/src/targets.ts +66 -0
- package/src/types.config.ts +3 -0
- package/src/types.ts +73 -0
- package/test-api.ts +2 -0
- package/tsconfig.json +16 -0
- package/api.js +0 -7
- package/channel-config-api.js +0 -7
- package/channel-plugin-api.js +0 -7
- package/contract-api.js +0 -7
- package/doctor-contract-api.js +0 -7
- package/index.js +0 -7
- package/runtime-api.js +0 -7
- package/secret-contract-api.js +0 -7
- package/setup-entry.js +0 -7
- package/setup-plugin-api.js +0 -7
- package/test-api.js +0 -7
package/api.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GoogleChatChannelConfigSchema } from "./src/config-schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { googlechatPlugin } from "./src/channel.js";
|
package/config-api.ts
ADDED
package/contract-api.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { o as resolveGoogleChatAccount, r as listEnabledGoogleChatAccounts } from "./setup-surface-B3Fa7XRx.js";
|
|
2
|
+
import { P as getGoogleChatRuntime } from "./runtime-api-DUH2Cg-0.js";
|
|
3
|
+
import { c as sendGoogleChatMessage, o as listGoogleChatReactions, r as deleteGoogleChatReaction, t as createGoogleChatReaction, u as uploadGoogleChatAttachment } from "./api-BkZX4VNX.js";
|
|
4
|
+
import { n as resolveGoogleChatOutboundSpace } from "./channel-DFZdjXD6.js";
|
|
5
|
+
import { extractToolSend } from "klaw/plugin-sdk/tool-send";
|
|
6
|
+
import { createActionGate, jsonResult, readNumberParam, readReactionParams, readStringParam } from "klaw/plugin-sdk/channel-actions";
|
|
7
|
+
import { loadOutboundMediaFromUrl } from "klaw/plugin-sdk/outbound-media";
|
|
8
|
+
//#region extensions/googlechat/src/actions.ts
|
|
9
|
+
const providerId = "googlechat";
|
|
10
|
+
function listEnabledAccounts(cfg) {
|
|
11
|
+
return listEnabledGoogleChatAccounts(cfg).filter((account) => account.enabled && account.credentialSource !== "none");
|
|
12
|
+
}
|
|
13
|
+
function isReactionsEnabled(accounts) {
|
|
14
|
+
for (const account of accounts) if (createActionGate(account.config.actions)("reactions")) return true;
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
function resolveAppUserNames(account) {
|
|
18
|
+
return new Set(["users/app", account.config.botUser?.trim()].filter(Boolean));
|
|
19
|
+
}
|
|
20
|
+
async function loadGoogleChatActionMedia(params) {
|
|
21
|
+
const runtime = getGoogleChatRuntime();
|
|
22
|
+
return /^https?:\/\//i.test(params.mediaUrl) ? await runtime.channel.media.readRemoteMediaBuffer({
|
|
23
|
+
url: params.mediaUrl,
|
|
24
|
+
maxBytes: params.maxBytes
|
|
25
|
+
}) : await loadOutboundMediaFromUrl(params.mediaUrl, {
|
|
26
|
+
maxBytes: params.maxBytes,
|
|
27
|
+
mediaAccess: params.mediaAccess,
|
|
28
|
+
mediaLocalRoots: params.mediaLocalRoots,
|
|
29
|
+
mediaReadFile: params.mediaReadFile
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const googlechatMessageActions = {
|
|
33
|
+
describeMessageTool: ({ cfg, accountId }) => {
|
|
34
|
+
const accounts = accountId ? [resolveGoogleChatAccount({
|
|
35
|
+
cfg,
|
|
36
|
+
accountId
|
|
37
|
+
})].filter((account) => account.enabled && account.credentialSource !== "none") : listEnabledAccounts(cfg);
|
|
38
|
+
if (accounts.length === 0) return null;
|
|
39
|
+
const actions = /* @__PURE__ */ new Set([]);
|
|
40
|
+
actions.add("send");
|
|
41
|
+
actions.add("upload-file");
|
|
42
|
+
if (isReactionsEnabled(accounts)) {
|
|
43
|
+
actions.add("react");
|
|
44
|
+
actions.add("reactions");
|
|
45
|
+
}
|
|
46
|
+
return { actions: Array.from(actions) };
|
|
47
|
+
},
|
|
48
|
+
extractToolSend: ({ args }) => {
|
|
49
|
+
return extractToolSend(args, "sendMessage");
|
|
50
|
+
},
|
|
51
|
+
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile }) => {
|
|
52
|
+
const account = resolveGoogleChatAccount({
|
|
53
|
+
cfg,
|
|
54
|
+
accountId
|
|
55
|
+
});
|
|
56
|
+
if (account.credentialSource === "none") throw new Error("Google Chat credentials are missing.");
|
|
57
|
+
if (action === "send" || action === "upload-file") {
|
|
58
|
+
const to = readStringParam(params, "to", { required: true });
|
|
59
|
+
const content = readStringParam(params, "message", {
|
|
60
|
+
required: action === "send",
|
|
61
|
+
allowEmpty: true
|
|
62
|
+
}) ?? readStringParam(params, "initialComment", { allowEmpty: true }) ?? "";
|
|
63
|
+
const mediaUrl = readStringParam(params, "media", { trim: false }) ?? readStringParam(params, "filePath", { trim: false }) ?? readStringParam(params, "path", { trim: false });
|
|
64
|
+
const threadId = readStringParam(params, "threadId") ?? readStringParam(params, "replyTo");
|
|
65
|
+
const space = await resolveGoogleChatOutboundSpace({
|
|
66
|
+
account,
|
|
67
|
+
target: to
|
|
68
|
+
});
|
|
69
|
+
if (mediaUrl) {
|
|
70
|
+
const loaded = await loadGoogleChatActionMedia({
|
|
71
|
+
mediaUrl,
|
|
72
|
+
maxBytes: (account.config.mediaMaxMb ?? 20) * 1024 * 1024,
|
|
73
|
+
mediaAccess,
|
|
74
|
+
mediaLocalRoots,
|
|
75
|
+
mediaReadFile
|
|
76
|
+
});
|
|
77
|
+
const uploadFileName = readStringParam(params, "filename") ?? readStringParam(params, "title") ?? loaded.fileName ?? "attachment";
|
|
78
|
+
const upload = await uploadGoogleChatAttachment({
|
|
79
|
+
account,
|
|
80
|
+
space,
|
|
81
|
+
filename: uploadFileName,
|
|
82
|
+
buffer: loaded.buffer,
|
|
83
|
+
contentType: loaded.contentType
|
|
84
|
+
});
|
|
85
|
+
await sendGoogleChatMessage({
|
|
86
|
+
account,
|
|
87
|
+
space,
|
|
88
|
+
text: content,
|
|
89
|
+
thread: threadId ?? void 0,
|
|
90
|
+
attachments: upload.attachmentUploadToken ? [{
|
|
91
|
+
attachmentUploadToken: upload.attachmentUploadToken,
|
|
92
|
+
contentName: uploadFileName
|
|
93
|
+
}] : void 0
|
|
94
|
+
});
|
|
95
|
+
return jsonResult({
|
|
96
|
+
ok: true,
|
|
97
|
+
to: space
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (action === "upload-file") throw new Error("upload-file requires media, filePath, or path");
|
|
101
|
+
await sendGoogleChatMessage({
|
|
102
|
+
account,
|
|
103
|
+
space,
|
|
104
|
+
text: content,
|
|
105
|
+
thread: threadId ?? void 0
|
|
106
|
+
});
|
|
107
|
+
return jsonResult({
|
|
108
|
+
ok: true,
|
|
109
|
+
to: space
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (action === "react") {
|
|
113
|
+
const messageName = readStringParam(params, "messageId", { required: true });
|
|
114
|
+
const { emoji, remove, isEmpty } = readReactionParams(params, { removeErrorMessage: "Emoji is required to remove a Google Chat reaction." });
|
|
115
|
+
if (remove || isEmpty) {
|
|
116
|
+
const reactions = await listGoogleChatReactions({
|
|
117
|
+
account,
|
|
118
|
+
messageName
|
|
119
|
+
});
|
|
120
|
+
const appUsers = resolveAppUserNames(account);
|
|
121
|
+
const toRemove = reactions.filter((reaction) => {
|
|
122
|
+
const userName = reaction.user?.name?.trim();
|
|
123
|
+
if (appUsers.size > 0 && !appUsers.has(userName ?? "")) return false;
|
|
124
|
+
if (emoji) return reaction.emoji?.unicode === emoji;
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
127
|
+
for (const reaction of toRemove) {
|
|
128
|
+
if (!reaction.name) continue;
|
|
129
|
+
await deleteGoogleChatReaction({
|
|
130
|
+
account,
|
|
131
|
+
reactionName: reaction.name
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return jsonResult({
|
|
135
|
+
ok: true,
|
|
136
|
+
removed: toRemove.length
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return jsonResult({
|
|
140
|
+
ok: true,
|
|
141
|
+
reaction: await createGoogleChatReaction({
|
|
142
|
+
account,
|
|
143
|
+
messageName,
|
|
144
|
+
emoji
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (action === "reactions") return jsonResult({
|
|
149
|
+
ok: true,
|
|
150
|
+
reactions: await listGoogleChatReactions({
|
|
151
|
+
account,
|
|
152
|
+
messageName: readStringParam(params, "messageId", { required: true }),
|
|
153
|
+
limit: readNumberParam(params, "limit", { integer: true }) ?? void 0
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
throw new Error(`Action ${action} is not supported for provider ${providerId}.`);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
//#endregion
|
|
160
|
+
export { googlechatMessageActions };
|