@cfio/cohort-sync 0.17.0 → 0.19.0
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/dist/index.js +84 -1
- package/dist/openclaw.plugin.json +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13423,7 +13423,7 @@ function dumpCtx(ctx) {
|
|
|
13423
13423
|
function dumpEvent(event) {
|
|
13424
13424
|
return dumpCtx(event);
|
|
13425
13425
|
}
|
|
13426
|
-
var PLUGIN_VERSION = true ? "0.
|
|
13426
|
+
var PLUGIN_VERSION = true ? "0.19.0" : "unknown";
|
|
13427
13427
|
function resolveGatewayToken(api) {
|
|
13428
13428
|
const token = api.config?.gateway?.auth?.token;
|
|
13429
13429
|
return typeof token === "string" ? token : null;
|
|
@@ -14281,6 +14281,65 @@ async function invokeSecretsReload(gwClient) {
|
|
|
14281
14281
|
};
|
|
14282
14282
|
}
|
|
14283
14283
|
}
|
|
14284
|
+
var ALLOWED_PAIRING_KINDS = /* @__PURE__ */ new Set([
|
|
14285
|
+
"telegram",
|
|
14286
|
+
"discord",
|
|
14287
|
+
"slack",
|
|
14288
|
+
"whatsapp",
|
|
14289
|
+
"signal",
|
|
14290
|
+
"imessage"
|
|
14291
|
+
]);
|
|
14292
|
+
var PAIRING_CODE_RE = /^[A-Z0-9]{4,16}$/;
|
|
14293
|
+
async function invokePairingApprove(params) {
|
|
14294
|
+
const kind = typeof params.kind === "string" ? params.kind : "";
|
|
14295
|
+
const code2 = typeof params.code === "string" ? params.code : "";
|
|
14296
|
+
if (!ALLOWED_PAIRING_KINDS.has(kind)) {
|
|
14297
|
+
return { ok: false, error: `invalid channel kind: ${kind || "(empty)"}` };
|
|
14298
|
+
}
|
|
14299
|
+
if (!PAIRING_CODE_RE.test(code2)) {
|
|
14300
|
+
return { ok: false, error: "invalid pairing code (expected 4\u201316 uppercase alphanumerics)" };
|
|
14301
|
+
}
|
|
14302
|
+
return {
|
|
14303
|
+
ok: false,
|
|
14304
|
+
error: "pairing-approve via gateway-method is a stub; call openclaw pairing approve via Fly machines exec instead (see convex/cohortChannels.ts:runTelegramPairingApprove)"
|
|
14305
|
+
};
|
|
14306
|
+
}
|
|
14307
|
+
var ALLOWED_SEND_KINDS = /* @__PURE__ */ new Set([
|
|
14308
|
+
"telegram",
|
|
14309
|
+
"discord",
|
|
14310
|
+
"slack",
|
|
14311
|
+
"whatsapp"
|
|
14312
|
+
]);
|
|
14313
|
+
var MAX_BODY_LENGTH = 4e3;
|
|
14314
|
+
var RECIPIENT_RE = /^[A-Za-z0-9@:_.+\-]{1,128}$/;
|
|
14315
|
+
async function invokeSendMessage(params) {
|
|
14316
|
+
const channelKind = typeof params.channelKind === "string" ? params.channelKind : "";
|
|
14317
|
+
const recipient = typeof params.recipient === "string" ? params.recipient : "";
|
|
14318
|
+
const body = typeof params.body === "string" ? params.body : "";
|
|
14319
|
+
const agentId = typeof params.agentId === "string" ? params.agentId : "";
|
|
14320
|
+
if (!ALLOWED_SEND_KINDS.has(channelKind)) {
|
|
14321
|
+
return { ok: false, error: `invalid channel kind: ${channelKind || "(empty)"}` };
|
|
14322
|
+
}
|
|
14323
|
+
if (!RECIPIENT_RE.test(recipient)) {
|
|
14324
|
+
return { ok: false, error: "invalid recipient (must be printable ASCII, \u2264128 chars, no shell metachars)" };
|
|
14325
|
+
}
|
|
14326
|
+
if (body.length === 0) {
|
|
14327
|
+
return { ok: false, error: "body is empty" };
|
|
14328
|
+
}
|
|
14329
|
+
if (body.length > MAX_BODY_LENGTH) {
|
|
14330
|
+
return { ok: false, error: `body too long (${body.length} > ${MAX_BODY_LENGTH})` };
|
|
14331
|
+
}
|
|
14332
|
+
if (agentId.length === 0 || agentId.length > 64) {
|
|
14333
|
+
return { ok: false, error: "agentId must be 1\u201364 chars" };
|
|
14334
|
+
}
|
|
14335
|
+
if (!/^[A-Za-z0-9_\-]+$/.test(agentId)) {
|
|
14336
|
+
return { ok: false, error: "agentId contains invalid characters" };
|
|
14337
|
+
}
|
|
14338
|
+
return {
|
|
14339
|
+
ok: false,
|
|
14340
|
+
error: "send-message via gateway-method is a stub; Convex invokes `openclaw agent --deliver` via Fly machines exec instead (see convex/agentOutbound.ts:_sendOne)"
|
|
14341
|
+
};
|
|
14342
|
+
}
|
|
14284
14343
|
function registerGatewayMethods(api, getGatewayClient) {
|
|
14285
14344
|
api.registerGatewayMethod(
|
|
14286
14345
|
"cohort-sync/secrets-reload",
|
|
@@ -14293,6 +14352,30 @@ function registerGatewayMethods(api, getGatewayClient) {
|
|
|
14293
14352
|
// superset).
|
|
14294
14353
|
{ scope: "operator.write" }
|
|
14295
14354
|
);
|
|
14355
|
+
api.registerGatewayMethod(
|
|
14356
|
+
"cohort-sync/pairing-approve",
|
|
14357
|
+
async ({ respond, params }) => {
|
|
14358
|
+
const result = await invokePairingApprove(
|
|
14359
|
+
params ?? {}
|
|
14360
|
+
);
|
|
14361
|
+
respond(true, result);
|
|
14362
|
+
},
|
|
14363
|
+
// Same scope rationale as secrets-reload — pairing approve is a channel
|
|
14364
|
+
// write operation.
|
|
14365
|
+
{ scope: "operator.write" }
|
|
14366
|
+
);
|
|
14367
|
+
api.registerGatewayMethod(
|
|
14368
|
+
"cohort-sync/send-message",
|
|
14369
|
+
async ({ respond, params }) => {
|
|
14370
|
+
const result = await invokeSendMessage(
|
|
14371
|
+
params ?? {}
|
|
14372
|
+
);
|
|
14373
|
+
respond(true, result);
|
|
14374
|
+
},
|
|
14375
|
+
// operator.write — outbound messaging is a mutating operator action,
|
|
14376
|
+
// same tier as channel attach/detach.
|
|
14377
|
+
{ scope: "operator.write" }
|
|
14378
|
+
);
|
|
14296
14379
|
}
|
|
14297
14380
|
|
|
14298
14381
|
// src/pocket-guide.ts
|
package/dist/package.json
CHANGED
package/package.json
CHANGED