@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
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-8SF6XoKj.js";
|
|
2
|
+
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-DWX4ikgT.js";
|
|
3
|
+
export { collectRuntimeConfigAssignments, legacyConfigRules, normalizeCompatibilityConfig, secretTargetRegistryEntries };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { asObjectRecord } from "klaw/plugin-sdk/runtime-doctor";
|
|
2
|
+
//#region extensions/googlechat/src/doctor-contract.ts
|
|
3
|
+
function hasLegacyGoogleChatStreamMode(value) {
|
|
4
|
+
return asObjectRecord(value)?.streamMode !== void 0;
|
|
5
|
+
}
|
|
6
|
+
function hasLegacyGoogleChatGroupAllowAlias(value) {
|
|
7
|
+
const groups = asObjectRecord(asObjectRecord(value)?.groups);
|
|
8
|
+
if (!groups) return false;
|
|
9
|
+
return Object.values(groups).some((group) => Object.prototype.hasOwnProperty.call(asObjectRecord(group) ?? {}, "allow"));
|
|
10
|
+
}
|
|
11
|
+
function hasLegacyAccountAliases(value, match) {
|
|
12
|
+
const accounts = asObjectRecord(value);
|
|
13
|
+
if (!accounts) return false;
|
|
14
|
+
return Object.values(accounts).some((account) => match(account));
|
|
15
|
+
}
|
|
16
|
+
function normalizeGoogleChatGroups(params) {
|
|
17
|
+
let changed = false;
|
|
18
|
+
const nextGroups = { ...params.groups };
|
|
19
|
+
for (const [groupId, groupValue] of Object.entries(params.groups)) {
|
|
20
|
+
const group = asObjectRecord(groupValue);
|
|
21
|
+
if (!group || !Object.prototype.hasOwnProperty.call(group, "allow")) continue;
|
|
22
|
+
const nextGroup = { ...group };
|
|
23
|
+
if (nextGroup.enabled === void 0) {
|
|
24
|
+
nextGroup.enabled = group.allow;
|
|
25
|
+
params.changes.push(`Moved ${params.pathPrefix}.${groupId}.allow → ${params.pathPrefix}.${groupId}.enabled.`);
|
|
26
|
+
} else params.changes.push(`Removed ${params.pathPrefix}.${groupId}.allow (${params.pathPrefix}.${groupId}.enabled already set).`);
|
|
27
|
+
delete nextGroup.allow;
|
|
28
|
+
nextGroups[groupId] = nextGroup;
|
|
29
|
+
changed = true;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
groups: nextGroups,
|
|
33
|
+
changed
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function normalizeGoogleChatEntry(params) {
|
|
37
|
+
let updated = params.entry;
|
|
38
|
+
let changed = false;
|
|
39
|
+
if (updated.streamMode !== void 0) {
|
|
40
|
+
updated = { ...updated };
|
|
41
|
+
delete updated.streamMode;
|
|
42
|
+
params.changes.push(`Removed ${params.pathPrefix}.streamMode (legacy key no longer used).`);
|
|
43
|
+
changed = true;
|
|
44
|
+
}
|
|
45
|
+
const groups = asObjectRecord(updated.groups);
|
|
46
|
+
if (groups) {
|
|
47
|
+
const normalized = normalizeGoogleChatGroups({
|
|
48
|
+
groups,
|
|
49
|
+
pathPrefix: `${params.pathPrefix}.groups`,
|
|
50
|
+
changes: params.changes
|
|
51
|
+
});
|
|
52
|
+
if (normalized.changed) {
|
|
53
|
+
updated = {
|
|
54
|
+
...updated,
|
|
55
|
+
groups: normalized.groups
|
|
56
|
+
};
|
|
57
|
+
changed = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
entry: updated,
|
|
62
|
+
changed
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const legacyConfigRules = [
|
|
66
|
+
{
|
|
67
|
+
path: ["channels", "googlechat"],
|
|
68
|
+
message: "channels.googlechat.streamMode is legacy and no longer used; it is removed on load.",
|
|
69
|
+
match: hasLegacyGoogleChatStreamMode
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
path: [
|
|
73
|
+
"channels",
|
|
74
|
+
"googlechat",
|
|
75
|
+
"accounts"
|
|
76
|
+
],
|
|
77
|
+
message: "channels.googlechat.accounts.<id>.streamMode is legacy and no longer used; it is removed on load.",
|
|
78
|
+
match: (value) => hasLegacyAccountAliases(value, hasLegacyGoogleChatStreamMode)
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
path: ["channels", "googlechat"],
|
|
82
|
+
message: "channels.googlechat.groups.<id>.allow is legacy; use channels.googlechat.groups.<id>.enabled instead. Run \"klaw doctor --fix\".",
|
|
83
|
+
match: hasLegacyGoogleChatGroupAllowAlias
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
path: [
|
|
87
|
+
"channels",
|
|
88
|
+
"googlechat",
|
|
89
|
+
"accounts"
|
|
90
|
+
],
|
|
91
|
+
message: "channels.googlechat.accounts.<id>.groups.<id>.allow is legacy; use channels.googlechat.accounts.<id>.groups.<id>.enabled instead. Run \"klaw doctor --fix\".",
|
|
92
|
+
match: (value) => hasLegacyAccountAliases(value, hasLegacyGoogleChatGroupAllowAlias)
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
function normalizeCompatibilityConfig({ cfg }) {
|
|
96
|
+
const rawEntry = asObjectRecord(cfg.channels?.googlechat);
|
|
97
|
+
if (!rawEntry) return {
|
|
98
|
+
config: cfg,
|
|
99
|
+
changes: []
|
|
100
|
+
};
|
|
101
|
+
const changes = [];
|
|
102
|
+
let updated = rawEntry;
|
|
103
|
+
let changed = false;
|
|
104
|
+
const root = normalizeGoogleChatEntry({
|
|
105
|
+
entry: updated,
|
|
106
|
+
pathPrefix: "channels.googlechat",
|
|
107
|
+
changes
|
|
108
|
+
});
|
|
109
|
+
updated = root.entry;
|
|
110
|
+
changed = root.changed;
|
|
111
|
+
const accounts = asObjectRecord(updated.accounts);
|
|
112
|
+
if (accounts) {
|
|
113
|
+
let accountsChanged = false;
|
|
114
|
+
const nextAccounts = { ...accounts };
|
|
115
|
+
for (const [accountId, accountValue] of Object.entries(accounts)) {
|
|
116
|
+
const account = asObjectRecord(accountValue);
|
|
117
|
+
if (!account) continue;
|
|
118
|
+
const normalized = normalizeGoogleChatEntry({
|
|
119
|
+
entry: account,
|
|
120
|
+
pathPrefix: `channels.googlechat.accounts.${accountId}`,
|
|
121
|
+
changes
|
|
122
|
+
});
|
|
123
|
+
if (!normalized.changed) continue;
|
|
124
|
+
nextAccounts[accountId] = normalized.entry;
|
|
125
|
+
accountsChanged = true;
|
|
126
|
+
}
|
|
127
|
+
if (accountsChanged) {
|
|
128
|
+
updated = {
|
|
129
|
+
...updated,
|
|
130
|
+
accounts: nextAccounts
|
|
131
|
+
};
|
|
132
|
+
changed = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!changed) return {
|
|
136
|
+
config: cfg,
|
|
137
|
+
changes: []
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
config: {
|
|
141
|
+
...cfg,
|
|
142
|
+
channels: {
|
|
143
|
+
...cfg.channels,
|
|
144
|
+
googlechat: updated
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
changes
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { normalizeCompatibilityConfig as n, legacyConfigRules as t };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineBundledChannelEntry } from "klaw/plugin-sdk/channel-entry-contract";
|
|
2
|
+
//#region extensions/googlechat/index.ts
|
|
3
|
+
var googlechat_default = defineBundledChannelEntry({
|
|
4
|
+
id: "googlechat",
|
|
5
|
+
name: "Google Chat",
|
|
6
|
+
description: "Klaw Google Chat channel plugin",
|
|
7
|
+
importMetaUrl: import.meta.url,
|
|
8
|
+
plugin: {
|
|
9
|
+
specifier: "./channel-plugin-api.js",
|
|
10
|
+
exportName: "googlechatPlugin"
|
|
11
|
+
},
|
|
12
|
+
secrets: {
|
|
13
|
+
specifier: "./secret-contract-api.js",
|
|
14
|
+
exportName: "channelSecrets"
|
|
15
|
+
},
|
|
16
|
+
runtime: {
|
|
17
|
+
specifier: "./runtime-api.js",
|
|
18
|
+
exportName: "setGoogleChatRuntime"
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
export { googlechat_default as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { extractToolSend as extractToolSend$1 } from "klaw/plugin-sdk/tool-send";
|
|
2
|
+
import { fetchWithSsrFGuard as fetchWithSsrFGuard$1 } from "klaw/plugin-sdk/ssrf-runtime";
|
|
3
|
+
import { DEFAULT_ACCOUNT_ID } from "klaw/plugin-sdk/account-id";
|
|
4
|
+
import { createActionGate as createActionGate$1, jsonResult as jsonResult$1, readNumberParam as readNumberParam$1, readReactionParams as readReactionParams$1, readStringParam as readStringParam$1 } from "klaw/plugin-sdk/channel-actions";
|
|
5
|
+
import { buildChannelConfigSchema } from "klaw/plugin-sdk/channel-config-primitives";
|
|
6
|
+
import { missingTargetError } from "klaw/plugin-sdk/channel-feedback";
|
|
7
|
+
import { createAccountStatusSink as createAccountStatusSink$1, runPassiveAccountLifecycle as runPassiveAccountLifecycle$1 } from "klaw/plugin-sdk/channel-lifecycle";
|
|
8
|
+
import { createChannelPairingController } from "klaw/plugin-sdk/channel-pairing";
|
|
9
|
+
import { createChannelMessageReplyPipeline } from "klaw/plugin-sdk/channel-message";
|
|
10
|
+
import { PAIRING_APPROVED_MESSAGE } from "klaw/plugin-sdk/channel-status";
|
|
11
|
+
import { chunkTextForOutbound } from "klaw/plugin-sdk/text-chunking";
|
|
12
|
+
import { GoogleChatConfigSchema } from "klaw/plugin-sdk/bundled-channel-config-schema";
|
|
13
|
+
import { GROUP_POLICY_BLOCKED_LABEL, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "klaw/plugin-sdk/runtime-group-policy";
|
|
14
|
+
import { isDangerousNameMatchingEnabled } from "klaw/plugin-sdk/dangerous-name-runtime";
|
|
15
|
+
import { readRemoteMediaBuffer, resolveChannelMediaMaxBytes } from "klaw/plugin-sdk/media-runtime";
|
|
16
|
+
import { loadOutboundMediaFromUrl as loadOutboundMediaFromUrl$1 } from "klaw/plugin-sdk/outbound-media";
|
|
17
|
+
import { resolveInboundMentionDecision } from "klaw/plugin-sdk/channel-inbound";
|
|
18
|
+
import { resolveInboundRouteEnvelopeBuilderWithRuntime } from "klaw/plugin-sdk/inbound-envelope";
|
|
19
|
+
import { resolveWebhookPath } from "klaw/plugin-sdk/webhook-ingress";
|
|
20
|
+
import { registerWebhookTargetWithPluginRoute as registerWebhookTargetWithPluginRoute$1, resolveWebhookTargetWithAuthOrReject as resolveWebhookTargetWithAuthOrReject$1, withResolvedWebhookRequestPipeline as withResolvedWebhookRequestPipeline$1 } from "klaw/plugin-sdk/webhook-targets";
|
|
21
|
+
import { createWebhookInFlightLimiter as createWebhookInFlightLimiter$1, readJsonWebhookBodyOrReject as readJsonWebhookBodyOrReject$1 } from "klaw/plugin-sdk/webhook-request-guards";
|
|
22
|
+
import { createPluginRuntimeStore } from "klaw/plugin-sdk/runtime-store";
|
|
23
|
+
//#region extensions/googlechat/src/runtime.ts
|
|
24
|
+
const { setRuntime: setGoogleChatRuntime, getRuntime: getGoogleChatRuntime } = createPluginRuntimeStore({
|
|
25
|
+
pluginId: "googlechat",
|
|
26
|
+
errorMessage: "Google Chat runtime not initialized"
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { resolveWebhookTargetWithAuthOrReject$1 as A, registerWebhookTargetWithPluginRoute$1 as C, resolveInboundMentionDecision as D, resolveDefaultGroupPolicy as E, setGoogleChatRuntime as F, warnMissingProviderGroupPolicyFallbackOnce as M, withResolvedWebhookRequestPipeline$1 as N, resolveInboundRouteEnvelopeBuilderWithRuntime as O, getGoogleChatRuntime as P, readStringParam$1 as S, resolveChannelMediaMaxBytes as T, missingTargetError as _, buildChannelConfigSchema as a, readReactionParams$1 as b, createActionGate$1 as c, createWebhookInFlightLimiter$1 as d, extractToolSend$1 as f, loadOutboundMediaFromUrl$1 as g, jsonResult$1 as h, PAIRING_APPROVED_MESSAGE as i, runPassiveAccountLifecycle$1 as j, resolveWebhookPath as k, createChannelMessageReplyPipeline as l, isDangerousNameMatchingEnabled as m, GROUP_POLICY_BLOCKED_LABEL as n, chunkTextForOutbound as o, fetchWithSsrFGuard$1 as p, GoogleChatConfigSchema as r, createAccountStatusSink$1 as s, DEFAULT_ACCOUNT_ID as t, createChannelPairingController as u, readJsonWebhookBodyOrReject$1 as v, resolveAllowlistProviderRuntimeGroupPolicy as w, readRemoteMediaBuffer as x, readNumberParam$1 as y };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as resolveWebhookTargetWithAuthOrReject, C as registerWebhookTargetWithPluginRoute, D as resolveInboundMentionDecision, E as resolveDefaultGroupPolicy, F as setGoogleChatRuntime, M as warnMissingProviderGroupPolicyFallbackOnce, N as withResolvedWebhookRequestPipeline, O as resolveInboundRouteEnvelopeBuilderWithRuntime, S as readStringParam, T as resolveChannelMediaMaxBytes, _ as missingTargetError, a as buildChannelConfigSchema, b as readReactionParams, c as createActionGate, d as createWebhookInFlightLimiter, f as extractToolSend, g as loadOutboundMediaFromUrl, h as jsonResult, i as PAIRING_APPROVED_MESSAGE, j as runPassiveAccountLifecycle, k as resolveWebhookPath, l as createChannelMessageReplyPipeline, m as isDangerousNameMatchingEnabled, n as GROUP_POLICY_BLOCKED_LABEL, o as chunkTextForOutbound, p as fetchWithSsrFGuard, r as GoogleChatConfigSchema, s as createAccountStatusSink, t as DEFAULT_ACCOUNT_ID, u as createChannelPairingController, v as readJsonWebhookBodyOrReject, w as resolveAllowlistProviderRuntimeGroupPolicy, x as readRemoteMediaBuffer, y as readNumberParam } from "./runtime-api-DUH2Cg-0.js";
|
|
2
|
+
export { DEFAULT_ACCOUNT_ID, GROUP_POLICY_BLOCKED_LABEL, GoogleChatConfigSchema, PAIRING_APPROVED_MESSAGE, buildChannelConfigSchema, chunkTextForOutbound, createAccountStatusSink, createActionGate, createChannelMessageReplyPipeline, createChannelPairingController, createWebhookInFlightLimiter, extractToolSend, fetchWithSsrFGuard, isDangerousNameMatchingEnabled, jsonResult, loadOutboundMediaFromUrl, missingTargetError, readJsonWebhookBodyOrReject, readNumberParam, readReactionParams, readRemoteMediaBuffer, readStringParam, registerWebhookTargetWithPluginRoute, resolveAllowlistProviderRuntimeGroupPolicy, resolveChannelMediaMaxBytes, resolveDefaultGroupPolicy, resolveInboundMentionDecision, resolveInboundRouteEnvelopeBuilderWithRuntime, resolveWebhookPath, resolveWebhookTargetWithAuthOrReject, runPassiveAccountLifecycle, setGoogleChatRuntime, warnMissingProviderGroupPolicyFallbackOnce, withResolvedWebhookRequestPipeline };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { getChannelSurface, hasOwnProperty, pushAssignment, pushInactiveSurfaceWarning, pushWarning, resolveChannelAccountSurface } from "klaw/plugin-sdk/channel-secret-basic-runtime";
|
|
2
|
+
import { coerceSecretRef } from "klaw/plugin-sdk/secret-ref-runtime";
|
|
3
|
+
//#region extensions/googlechat/src/secret-contract.ts
|
|
4
|
+
const secretTargetRegistryEntries = [{
|
|
5
|
+
id: "channels.googlechat.accounts.*.serviceAccount",
|
|
6
|
+
targetType: "channels.googlechat.serviceAccount",
|
|
7
|
+
targetTypeAliases: ["channels.googlechat.accounts.*.serviceAccount"],
|
|
8
|
+
configFile: "klaw.json",
|
|
9
|
+
pathPattern: "channels.googlechat.accounts.*.serviceAccount",
|
|
10
|
+
refPathPattern: "channels.googlechat.accounts.*.serviceAccountRef",
|
|
11
|
+
secretShape: "sibling_ref",
|
|
12
|
+
expectedResolvedValue: "string-or-object",
|
|
13
|
+
includeInPlan: true,
|
|
14
|
+
includeInConfigure: true,
|
|
15
|
+
includeInAudit: true,
|
|
16
|
+
accountIdPathSegmentIndex: 3
|
|
17
|
+
}, {
|
|
18
|
+
id: "channels.googlechat.serviceAccount",
|
|
19
|
+
targetType: "channels.googlechat.serviceAccount",
|
|
20
|
+
configFile: "klaw.json",
|
|
21
|
+
pathPattern: "channels.googlechat.serviceAccount",
|
|
22
|
+
refPathPattern: "channels.googlechat.serviceAccountRef",
|
|
23
|
+
secretShape: "sibling_ref",
|
|
24
|
+
expectedResolvedValue: "string-or-object",
|
|
25
|
+
includeInPlan: true,
|
|
26
|
+
includeInConfigure: true,
|
|
27
|
+
includeInAudit: true
|
|
28
|
+
}];
|
|
29
|
+
function resolveSecretInputRef(params) {
|
|
30
|
+
const explicitRef = coerceSecretRef(params.refValue, params.defaults);
|
|
31
|
+
const inlineRef = explicitRef ? null : coerceSecretRef(params.value, params.defaults);
|
|
32
|
+
return {
|
|
33
|
+
explicitRef,
|
|
34
|
+
inlineRef,
|
|
35
|
+
ref: explicitRef ?? inlineRef
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function collectGoogleChatAccountAssignment(params) {
|
|
39
|
+
const { explicitRef, ref } = resolveSecretInputRef({
|
|
40
|
+
value: params.target.serviceAccount,
|
|
41
|
+
refValue: params.target.serviceAccountRef,
|
|
42
|
+
defaults: params.defaults
|
|
43
|
+
});
|
|
44
|
+
if (!ref) return;
|
|
45
|
+
if (params.active === false) {
|
|
46
|
+
pushInactiveSurfaceWarning({
|
|
47
|
+
context: params.context,
|
|
48
|
+
path: `${params.path}.serviceAccount`,
|
|
49
|
+
details: params.inactiveReason
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (explicitRef && params.target.serviceAccount !== void 0 && !coerceSecretRef(params.target.serviceAccount, params.defaults)) pushWarning(params.context, {
|
|
54
|
+
code: "SECRETS_REF_OVERRIDES_PLAINTEXT",
|
|
55
|
+
path: params.path,
|
|
56
|
+
message: `${params.path}: serviceAccountRef is set; runtime will ignore plaintext serviceAccount.`
|
|
57
|
+
});
|
|
58
|
+
pushAssignment(params.context, {
|
|
59
|
+
ref,
|
|
60
|
+
path: `${params.path}.serviceAccount`,
|
|
61
|
+
expected: "string-or-object",
|
|
62
|
+
apply: (value) => {
|
|
63
|
+
params.target.serviceAccount = value;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function collectRuntimeConfigAssignments(params) {
|
|
68
|
+
const resolved = getChannelSurface(params.config, "googlechat");
|
|
69
|
+
if (!resolved) return;
|
|
70
|
+
const googleChat = resolved.channel;
|
|
71
|
+
const surface = resolveChannelAccountSurface(googleChat);
|
|
72
|
+
const topLevelServiceAccountActive = !surface.channelEnabled ? false : !surface.hasExplicitAccounts ? true : surface.accounts.some(({ account, enabled }) => enabled && !hasOwnProperty(account, "serviceAccount") && !hasOwnProperty(account, "serviceAccountRef"));
|
|
73
|
+
collectGoogleChatAccountAssignment({
|
|
74
|
+
target: googleChat,
|
|
75
|
+
path: "channels.googlechat",
|
|
76
|
+
defaults: params.defaults,
|
|
77
|
+
context: params.context,
|
|
78
|
+
active: topLevelServiceAccountActive,
|
|
79
|
+
inactiveReason: "no enabled account inherits this top-level Google Chat serviceAccount."
|
|
80
|
+
});
|
|
81
|
+
if (!surface.hasExplicitAccounts) return;
|
|
82
|
+
for (const { accountId, account, enabled } of surface.accounts) {
|
|
83
|
+
if (!hasOwnProperty(account, "serviceAccount") && !hasOwnProperty(account, "serviceAccountRef")) continue;
|
|
84
|
+
collectGoogleChatAccountAssignment({
|
|
85
|
+
target: account,
|
|
86
|
+
path: `channels.googlechat.accounts.${accountId}`,
|
|
87
|
+
defaults: params.defaults,
|
|
88
|
+
context: params.context,
|
|
89
|
+
active: enabled,
|
|
90
|
+
inactiveReason: "Google Chat account is disabled."
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const channelSecrets = {
|
|
95
|
+
secretTargetRegistryEntries,
|
|
96
|
+
collectRuntimeConfigAssignments
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { collectRuntimeConfigAssignments as n, secretTargetRegistryEntries as r, channelSecrets as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineBundledChannelSetupEntry } from "klaw/plugin-sdk/channel-entry-contract";
|
|
2
|
+
//#region extensions/googlechat/setup-entry.ts
|
|
3
|
+
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
4
|
+
importMetaUrl: import.meta.url,
|
|
5
|
+
plugin: {
|
|
6
|
+
specifier: "./setup-plugin-api.js",
|
|
7
|
+
exportName: "googlechatSetupPlugin"
|
|
8
|
+
},
|
|
9
|
+
secrets: {
|
|
10
|
+
specifier: "./secret-contract-api.js",
|
|
11
|
+
exportName: "channelSecrets"
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { setup_entry_default as default };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { a as resolveDefaultGoogleChatAccountId, i as listGoogleChatAccountIds, n as googlechatSetupAdapter, o as resolveGoogleChatAccount, s as resolveGoogleChatConfigAccessorAccount, t as googlechatSetupWizard } from "./setup-surface-B3Fa7XRx.js";
|
|
2
|
+
import { describeAccountSnapshot } from "klaw/plugin-sdk/account-helpers";
|
|
3
|
+
import { formatNormalizedAllowFromEntries } from "klaw/plugin-sdk/allow-from";
|
|
4
|
+
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "klaw/plugin-sdk/channel-config-helpers";
|
|
5
|
+
import { normalizeLowercaseStringOrEmpty } from "klaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
//#region extensions/googlechat/src/channel.setup.ts
|
|
7
|
+
const formatGoogleChatAllowFromEntry = (entry) => normalizeLowercaseStringOrEmpty(entry.trim().replace(/^(googlechat|google-chat|gchat):/i, "").replace(/^user:/i, "").replace(/^users\//i, ""));
|
|
8
|
+
const googlechatSetupPlugin = {
|
|
9
|
+
id: "googlechat",
|
|
10
|
+
meta: {
|
|
11
|
+
id: "googlechat",
|
|
12
|
+
label: "Google Chat",
|
|
13
|
+
selectionLabel: "Google Chat (Chat API)",
|
|
14
|
+
docsPath: "/channels/googlechat",
|
|
15
|
+
docsLabel: "googlechat",
|
|
16
|
+
blurb: "Google Workspace Chat app with HTTP webhook.",
|
|
17
|
+
aliases: ["gchat", "google-chat"],
|
|
18
|
+
order: 55,
|
|
19
|
+
detailLabel: "Google Chat",
|
|
20
|
+
systemImage: "message.badge",
|
|
21
|
+
markdownCapable: true
|
|
22
|
+
},
|
|
23
|
+
setup: googlechatSetupAdapter,
|
|
24
|
+
setupWizard: googlechatSetupWizard,
|
|
25
|
+
capabilities: {
|
|
26
|
+
chatTypes: [
|
|
27
|
+
"direct",
|
|
28
|
+
"group",
|
|
29
|
+
"thread"
|
|
30
|
+
],
|
|
31
|
+
reactions: true,
|
|
32
|
+
threads: true,
|
|
33
|
+
media: true,
|
|
34
|
+
nativeCommands: false,
|
|
35
|
+
blockStreaming: true
|
|
36
|
+
},
|
|
37
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
38
|
+
minChars: 1500,
|
|
39
|
+
idleMs: 1e3
|
|
40
|
+
} },
|
|
41
|
+
reload: { configPrefixes: ["channels.googlechat"] },
|
|
42
|
+
config: {
|
|
43
|
+
...createScopedChannelConfigAdapter({
|
|
44
|
+
sectionKey: "googlechat",
|
|
45
|
+
listAccountIds: listGoogleChatAccountIds,
|
|
46
|
+
resolveAccount: adaptScopedAccountAccessor(resolveGoogleChatAccount),
|
|
47
|
+
resolveAccessorAccount: resolveGoogleChatConfigAccessorAccount,
|
|
48
|
+
defaultAccountId: resolveDefaultGoogleChatAccountId,
|
|
49
|
+
clearBaseFields: [
|
|
50
|
+
"serviceAccount",
|
|
51
|
+
"serviceAccountFile",
|
|
52
|
+
"audienceType",
|
|
53
|
+
"audience",
|
|
54
|
+
"webhookPath",
|
|
55
|
+
"webhookUrl",
|
|
56
|
+
"botUser",
|
|
57
|
+
"name"
|
|
58
|
+
],
|
|
59
|
+
resolveAllowFrom: (account) => account.config.dm?.allowFrom,
|
|
60
|
+
formatAllowFrom: (allowFrom) => formatNormalizedAllowFromEntries({
|
|
61
|
+
allowFrom,
|
|
62
|
+
normalizeEntry: formatGoogleChatAllowFromEntry
|
|
63
|
+
}),
|
|
64
|
+
resolveDefaultTo: (account) => account.config.defaultTo
|
|
65
|
+
}),
|
|
66
|
+
isConfigured: (account) => account.credentialSource !== "none",
|
|
67
|
+
describeAccount: (account) => describeAccountSnapshot({
|
|
68
|
+
account,
|
|
69
|
+
configured: account.credentialSource !== "none",
|
|
70
|
+
extra: { credentialSource: account.credentialSource }
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { googlechatSetupPlugin };
|