@maudecode/openclaw-cowtail 0.8.0 → 0.9.1
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 +62 -15
- package/dist/setup-entry.js +62 -15
- package/openclaw.plugin.json +43 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13857,6 +13857,17 @@ var openclawIosMarkThreadReadCommandSchema = exports_external.object({
|
|
|
13857
13857
|
requestId: openclawRequestIdSchema,
|
|
13858
13858
|
threadId: nonEmptyStringSchema
|
|
13859
13859
|
});
|
|
13860
|
+
var openclawIosRenameThreadCommandSchema = exports_external.object({
|
|
13861
|
+
type: exports_external.literal("ios_rename_thread"),
|
|
13862
|
+
requestId: openclawRequestIdSchema,
|
|
13863
|
+
threadId: nonEmptyStringSchema,
|
|
13864
|
+
title: nonEmptyStringSchema
|
|
13865
|
+
});
|
|
13866
|
+
var openclawIosDeleteThreadCommandSchema = exports_external.object({
|
|
13867
|
+
type: exports_external.literal("ios_delete_thread"),
|
|
13868
|
+
requestId: openclawRequestIdSchema,
|
|
13869
|
+
threadId: nonEmptyStringSchema
|
|
13870
|
+
});
|
|
13860
13871
|
var openclawSessionBoundCommandSchema = exports_external.object({
|
|
13861
13872
|
type: exports_external.literal("openclaw_session_bound"),
|
|
13862
13873
|
requestId: openclawRequestIdSchema,
|
|
@@ -13876,6 +13887,8 @@ var openclawRealtimeClientMessageSchema = exports_external.discriminatedUnion("t
|
|
|
13876
13887
|
openclawIosReplyCommandSchema,
|
|
13877
13888
|
openclawIosActionCommandSchema,
|
|
13878
13889
|
openclawIosMarkThreadReadCommandSchema,
|
|
13890
|
+
openclawIosRenameThreadCommandSchema,
|
|
13891
|
+
openclawIosDeleteThreadCommandSchema,
|
|
13879
13892
|
openclawSessionBoundCommandSchema,
|
|
13880
13893
|
openclawActionResultCommandSchema
|
|
13881
13894
|
]);
|
|
@@ -14428,21 +14441,22 @@ async function handleCowtailEvent(params) {
|
|
|
14428
14441
|
if (!route) {
|
|
14429
14442
|
return;
|
|
14430
14443
|
}
|
|
14444
|
+
if (!thread.sessionKey) {
|
|
14445
|
+
await client.sendSessionBound({
|
|
14446
|
+
type: "openclaw_session_bound",
|
|
14447
|
+
threadId: thread.id,
|
|
14448
|
+
sessionKey: route.sessionKey
|
|
14449
|
+
});
|
|
14450
|
+
}
|
|
14431
14451
|
await dispatchCowtailTextTurn({
|
|
14432
14452
|
account,
|
|
14453
|
+
client,
|
|
14433
14454
|
runtime,
|
|
14434
14455
|
route,
|
|
14435
14456
|
thread,
|
|
14436
14457
|
message,
|
|
14437
14458
|
...logger ? { logger } : {}
|
|
14438
14459
|
});
|
|
14439
|
-
if (!thread.sessionKey) {
|
|
14440
|
-
await client.sendSessionBound({
|
|
14441
|
-
type: "openclaw_session_bound",
|
|
14442
|
-
threadId: thread.id,
|
|
14443
|
-
sessionKey: route.sessionKey
|
|
14444
|
-
});
|
|
14445
|
-
}
|
|
14446
14460
|
return;
|
|
14447
14461
|
}
|
|
14448
14462
|
case "reply_created": {
|
|
@@ -14458,6 +14472,7 @@ async function handleCowtailEvent(params) {
|
|
|
14458
14472
|
}
|
|
14459
14473
|
await dispatchCowtailTextTurn({
|
|
14460
14474
|
account,
|
|
14475
|
+
client,
|
|
14461
14476
|
runtime,
|
|
14462
14477
|
route: {
|
|
14463
14478
|
agentId: account.agentId,
|
|
@@ -14483,6 +14498,7 @@ async function handleCowtailEvent(params) {
|
|
|
14483
14498
|
try {
|
|
14484
14499
|
const dispatchSucceeded = await dispatchCowtailActionTurn({
|
|
14485
14500
|
account,
|
|
14501
|
+
client,
|
|
14486
14502
|
runtime,
|
|
14487
14503
|
route: {
|
|
14488
14504
|
agentId: account.agentId,
|
|
@@ -14514,7 +14530,7 @@ async function handleCowtailEvent(params) {
|
|
|
14514
14530
|
}
|
|
14515
14531
|
}
|
|
14516
14532
|
async function dispatchCowtailTextTurn(params) {
|
|
14517
|
-
const { account, runtime, logger, route, thread, message } = params;
|
|
14533
|
+
const { account, client, runtime, logger, route, thread, message } = params;
|
|
14518
14534
|
const text = message.text;
|
|
14519
14535
|
const { body, storePath } = buildCowtailInboundBody({
|
|
14520
14536
|
runtime,
|
|
@@ -14540,9 +14556,12 @@ async function dispatchCowtailTextTurn(params) {
|
|
|
14540
14556
|
storePath,
|
|
14541
14557
|
ctxPayload,
|
|
14542
14558
|
core: runtime,
|
|
14543
|
-
deliver: async () => {
|
|
14544
|
-
|
|
14545
|
-
|
|
14559
|
+
deliver: async (payload) => deliverCowtailReply({
|
|
14560
|
+
client,
|
|
14561
|
+
route,
|
|
14562
|
+
thread,
|
|
14563
|
+
payload
|
|
14564
|
+
}),
|
|
14546
14565
|
onRecordError: (error48) => {
|
|
14547
14566
|
logger?.error?.(`Cowtail inbound session record failed: ${errorMessage(error48)}`);
|
|
14548
14567
|
},
|
|
@@ -14552,7 +14571,7 @@ async function dispatchCowtailTextTurn(params) {
|
|
|
14552
14571
|
});
|
|
14553
14572
|
}
|
|
14554
14573
|
async function dispatchCowtailActionTurn(params) {
|
|
14555
|
-
const { account, runtime, logger, route, thread, action, payload, timestamp } = params;
|
|
14574
|
+
const { account, client, runtime, logger, route, thread, action, payload, timestamp } = params;
|
|
14556
14575
|
const text = [
|
|
14557
14576
|
`Cowtail action selected: ${action.label}`,
|
|
14558
14577
|
`kind: ${action.kind}`,
|
|
@@ -14584,9 +14603,12 @@ async function dispatchCowtailActionTurn(params) {
|
|
|
14584
14603
|
storePath,
|
|
14585
14604
|
ctxPayload,
|
|
14586
14605
|
core: runtime,
|
|
14587
|
-
deliver: async () => {
|
|
14588
|
-
|
|
14589
|
-
|
|
14606
|
+
deliver: async (replyPayload) => deliverCowtailReply({
|
|
14607
|
+
client,
|
|
14608
|
+
route,
|
|
14609
|
+
thread,
|
|
14610
|
+
payload: replyPayload
|
|
14611
|
+
}),
|
|
14590
14612
|
onRecordError: (error48) => {
|
|
14591
14613
|
logger?.error?.(`Cowtail inbound session record failed: ${errorMessage(error48)}`);
|
|
14592
14614
|
},
|
|
@@ -14597,6 +14619,31 @@ async function dispatchCowtailActionTurn(params) {
|
|
|
14597
14619
|
});
|
|
14598
14620
|
return !dispatchFailed;
|
|
14599
14621
|
}
|
|
14622
|
+
async function deliverCowtailReply(params) {
|
|
14623
|
+
const text = params.payload.text;
|
|
14624
|
+
if (typeof text !== "string" || !text.trim()) {
|
|
14625
|
+
return;
|
|
14626
|
+
}
|
|
14627
|
+
await params.client.sendOpenClawMessage({
|
|
14628
|
+
type: "openclaw_message",
|
|
14629
|
+
sessionKey: params.thread.sessionKey ?? params.route.sessionKey,
|
|
14630
|
+
title: params.thread.title,
|
|
14631
|
+
text,
|
|
14632
|
+
authorLabel: "OpenClaw",
|
|
14633
|
+
links: resolveCowtailReplyLinks(params.payload),
|
|
14634
|
+
actions: []
|
|
14635
|
+
});
|
|
14636
|
+
}
|
|
14637
|
+
function resolveCowtailReplyLinks(payload) {
|
|
14638
|
+
const urls = [
|
|
14639
|
+
...Array.isArray(payload.mediaUrls) ? payload.mediaUrls : [],
|
|
14640
|
+
...typeof payload.mediaUrl === "string" ? [payload.mediaUrl] : []
|
|
14641
|
+
].filter((url2) => url2.trim().length > 0);
|
|
14642
|
+
return urls.map((url2, index) => ({
|
|
14643
|
+
label: urls.length === 1 ? "Attachment" : `Attachment ${index + 1}`,
|
|
14644
|
+
url: url2
|
|
14645
|
+
}));
|
|
14646
|
+
}
|
|
14600
14647
|
function buildCowtailInboundBody(params) {
|
|
14601
14648
|
const cfg = params.runtime.config.loadConfig();
|
|
14602
14649
|
const storePath = params.runtime.agent.session.resolveStorePath(cfg.session?.store, {
|
package/dist/setup-entry.js
CHANGED
|
@@ -13857,6 +13857,17 @@ var openclawIosMarkThreadReadCommandSchema = exports_external.object({
|
|
|
13857
13857
|
requestId: openclawRequestIdSchema,
|
|
13858
13858
|
threadId: nonEmptyStringSchema
|
|
13859
13859
|
});
|
|
13860
|
+
var openclawIosRenameThreadCommandSchema = exports_external.object({
|
|
13861
|
+
type: exports_external.literal("ios_rename_thread"),
|
|
13862
|
+
requestId: openclawRequestIdSchema,
|
|
13863
|
+
threadId: nonEmptyStringSchema,
|
|
13864
|
+
title: nonEmptyStringSchema
|
|
13865
|
+
});
|
|
13866
|
+
var openclawIosDeleteThreadCommandSchema = exports_external.object({
|
|
13867
|
+
type: exports_external.literal("ios_delete_thread"),
|
|
13868
|
+
requestId: openclawRequestIdSchema,
|
|
13869
|
+
threadId: nonEmptyStringSchema
|
|
13870
|
+
});
|
|
13860
13871
|
var openclawSessionBoundCommandSchema = exports_external.object({
|
|
13861
13872
|
type: exports_external.literal("openclaw_session_bound"),
|
|
13862
13873
|
requestId: openclawRequestIdSchema,
|
|
@@ -13876,6 +13887,8 @@ var openclawRealtimeClientMessageSchema = exports_external.discriminatedUnion("t
|
|
|
13876
13887
|
openclawIosReplyCommandSchema,
|
|
13877
13888
|
openclawIosActionCommandSchema,
|
|
13878
13889
|
openclawIosMarkThreadReadCommandSchema,
|
|
13890
|
+
openclawIosRenameThreadCommandSchema,
|
|
13891
|
+
openclawIosDeleteThreadCommandSchema,
|
|
13879
13892
|
openclawSessionBoundCommandSchema,
|
|
13880
13893
|
openclawActionResultCommandSchema
|
|
13881
13894
|
]);
|
|
@@ -14428,21 +14441,22 @@ async function handleCowtailEvent(params) {
|
|
|
14428
14441
|
if (!route) {
|
|
14429
14442
|
return;
|
|
14430
14443
|
}
|
|
14444
|
+
if (!thread.sessionKey) {
|
|
14445
|
+
await client.sendSessionBound({
|
|
14446
|
+
type: "openclaw_session_bound",
|
|
14447
|
+
threadId: thread.id,
|
|
14448
|
+
sessionKey: route.sessionKey
|
|
14449
|
+
});
|
|
14450
|
+
}
|
|
14431
14451
|
await dispatchCowtailTextTurn({
|
|
14432
14452
|
account,
|
|
14453
|
+
client,
|
|
14433
14454
|
runtime,
|
|
14434
14455
|
route,
|
|
14435
14456
|
thread,
|
|
14436
14457
|
message,
|
|
14437
14458
|
...logger ? { logger } : {}
|
|
14438
14459
|
});
|
|
14439
|
-
if (!thread.sessionKey) {
|
|
14440
|
-
await client.sendSessionBound({
|
|
14441
|
-
type: "openclaw_session_bound",
|
|
14442
|
-
threadId: thread.id,
|
|
14443
|
-
sessionKey: route.sessionKey
|
|
14444
|
-
});
|
|
14445
|
-
}
|
|
14446
14460
|
return;
|
|
14447
14461
|
}
|
|
14448
14462
|
case "reply_created": {
|
|
@@ -14458,6 +14472,7 @@ async function handleCowtailEvent(params) {
|
|
|
14458
14472
|
}
|
|
14459
14473
|
await dispatchCowtailTextTurn({
|
|
14460
14474
|
account,
|
|
14475
|
+
client,
|
|
14461
14476
|
runtime,
|
|
14462
14477
|
route: {
|
|
14463
14478
|
agentId: account.agentId,
|
|
@@ -14483,6 +14498,7 @@ async function handleCowtailEvent(params) {
|
|
|
14483
14498
|
try {
|
|
14484
14499
|
const dispatchSucceeded = await dispatchCowtailActionTurn({
|
|
14485
14500
|
account,
|
|
14501
|
+
client,
|
|
14486
14502
|
runtime,
|
|
14487
14503
|
route: {
|
|
14488
14504
|
agentId: account.agentId,
|
|
@@ -14514,7 +14530,7 @@ async function handleCowtailEvent(params) {
|
|
|
14514
14530
|
}
|
|
14515
14531
|
}
|
|
14516
14532
|
async function dispatchCowtailTextTurn(params) {
|
|
14517
|
-
const { account, runtime, logger, route, thread, message } = params;
|
|
14533
|
+
const { account, client, runtime, logger, route, thread, message } = params;
|
|
14518
14534
|
const text = message.text;
|
|
14519
14535
|
const { body, storePath } = buildCowtailInboundBody({
|
|
14520
14536
|
runtime,
|
|
@@ -14540,9 +14556,12 @@ async function dispatchCowtailTextTurn(params) {
|
|
|
14540
14556
|
storePath,
|
|
14541
14557
|
ctxPayload,
|
|
14542
14558
|
core: runtime,
|
|
14543
|
-
deliver: async () => {
|
|
14544
|
-
|
|
14545
|
-
|
|
14559
|
+
deliver: async (payload) => deliverCowtailReply({
|
|
14560
|
+
client,
|
|
14561
|
+
route,
|
|
14562
|
+
thread,
|
|
14563
|
+
payload
|
|
14564
|
+
}),
|
|
14546
14565
|
onRecordError: (error48) => {
|
|
14547
14566
|
logger?.error?.(`Cowtail inbound session record failed: ${errorMessage(error48)}`);
|
|
14548
14567
|
},
|
|
@@ -14552,7 +14571,7 @@ async function dispatchCowtailTextTurn(params) {
|
|
|
14552
14571
|
});
|
|
14553
14572
|
}
|
|
14554
14573
|
async function dispatchCowtailActionTurn(params) {
|
|
14555
|
-
const { account, runtime, logger, route, thread, action, payload, timestamp } = params;
|
|
14574
|
+
const { account, client, runtime, logger, route, thread, action, payload, timestamp } = params;
|
|
14556
14575
|
const text = [
|
|
14557
14576
|
`Cowtail action selected: ${action.label}`,
|
|
14558
14577
|
`kind: ${action.kind}`,
|
|
@@ -14584,9 +14603,12 @@ async function dispatchCowtailActionTurn(params) {
|
|
|
14584
14603
|
storePath,
|
|
14585
14604
|
ctxPayload,
|
|
14586
14605
|
core: runtime,
|
|
14587
|
-
deliver: async () => {
|
|
14588
|
-
|
|
14589
|
-
|
|
14606
|
+
deliver: async (replyPayload) => deliverCowtailReply({
|
|
14607
|
+
client,
|
|
14608
|
+
route,
|
|
14609
|
+
thread,
|
|
14610
|
+
payload: replyPayload
|
|
14611
|
+
}),
|
|
14590
14612
|
onRecordError: (error48) => {
|
|
14591
14613
|
logger?.error?.(`Cowtail inbound session record failed: ${errorMessage(error48)}`);
|
|
14592
14614
|
},
|
|
@@ -14597,6 +14619,31 @@ async function dispatchCowtailActionTurn(params) {
|
|
|
14597
14619
|
});
|
|
14598
14620
|
return !dispatchFailed;
|
|
14599
14621
|
}
|
|
14622
|
+
async function deliverCowtailReply(params) {
|
|
14623
|
+
const text = params.payload.text;
|
|
14624
|
+
if (typeof text !== "string" || !text.trim()) {
|
|
14625
|
+
return;
|
|
14626
|
+
}
|
|
14627
|
+
await params.client.sendOpenClawMessage({
|
|
14628
|
+
type: "openclaw_message",
|
|
14629
|
+
sessionKey: params.thread.sessionKey ?? params.route.sessionKey,
|
|
14630
|
+
title: params.thread.title,
|
|
14631
|
+
text,
|
|
14632
|
+
authorLabel: "OpenClaw",
|
|
14633
|
+
links: resolveCowtailReplyLinks(params.payload),
|
|
14634
|
+
actions: []
|
|
14635
|
+
});
|
|
14636
|
+
}
|
|
14637
|
+
function resolveCowtailReplyLinks(payload) {
|
|
14638
|
+
const urls = [
|
|
14639
|
+
...Array.isArray(payload.mediaUrls) ? payload.mediaUrls : [],
|
|
14640
|
+
...typeof payload.mediaUrl === "string" ? [payload.mediaUrl] : []
|
|
14641
|
+
].filter((url2) => url2.trim().length > 0);
|
|
14642
|
+
return urls.map((url2, index) => ({
|
|
14643
|
+
label: urls.length === 1 ? "Attachment" : `Attachment ${index + 1}`,
|
|
14644
|
+
url: url2
|
|
14645
|
+
}));
|
|
14646
|
+
}
|
|
14600
14647
|
function buildCowtailInboundBody(params) {
|
|
14601
14648
|
const cfg = params.runtime.config.loadConfig();
|
|
14602
14649
|
const storePath = params.runtime.agent.session.resolveStorePath(cfg.session?.store, {
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,10 +2,53 @@
|
|
|
2
2
|
"id": "cowtail",
|
|
3
3
|
"name": "Cowtail",
|
|
4
4
|
"description": "Cowtail mobile realtime channel for OpenClaw",
|
|
5
|
+
"kind": "channel",
|
|
5
6
|
"channels": ["cowtail"],
|
|
6
7
|
"channelEnvVars": {
|
|
7
8
|
"cowtail": ["OPENCLAW_COWTAIL_BRIDGE_TOKEN"]
|
|
8
9
|
},
|
|
10
|
+
"channelConfigs": {
|
|
11
|
+
"cowtail": {
|
|
12
|
+
"schema": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"additionalProperties": true,
|
|
15
|
+
"properties": {
|
|
16
|
+
"enabled": { "type": "boolean" },
|
|
17
|
+
"url": { "type": "string" },
|
|
18
|
+
"bridgeToken": {
|
|
19
|
+
"oneOf": [
|
|
20
|
+
{ "type": "string" },
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"additionalProperties": false,
|
|
24
|
+
"required": ["source", "provider", "id"],
|
|
25
|
+
"properties": {
|
|
26
|
+
"source": { "enum": ["env", "file", "exec"] },
|
|
27
|
+
"provider": { "type": "string" },
|
|
28
|
+
"id": { "type": "string" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"agentId": { "type": "string" },
|
|
34
|
+
"connectTimeoutMs": { "type": "number" },
|
|
35
|
+
"reconnectMinDelayMs": { "type": "number" },
|
|
36
|
+
"reconnectMaxDelayMs": { "type": "number" }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"uiHints": {
|
|
40
|
+
"url": {
|
|
41
|
+
"label": "Cowtail realtime URL",
|
|
42
|
+
"placeholder": "wss://cowtail.example.invalid/openclaw/realtime"
|
|
43
|
+
},
|
|
44
|
+
"bridgeToken": {
|
|
45
|
+
"label": "Bridge token",
|
|
46
|
+
"placeholder": "${OPENCLAW_COWTAIL_BRIDGE_TOKEN}",
|
|
47
|
+
"sensitive": true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
9
52
|
"uiHints": {
|
|
10
53
|
"url": {
|
|
11
54
|
"label": "Cowtail realtime URL",
|