@awebai/claude-channel 1.4.12 → 1.5.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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +5 -0
- package/dist/index.js +74 -0
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
package/dist/index.js
CHANGED
|
@@ -22501,6 +22501,7 @@ var KNOWN_TYPES = /* @__PURE__ */ new Set([
|
|
|
22501
22501
|
"work_available",
|
|
22502
22502
|
"claim_update",
|
|
22503
22503
|
"claim_removed",
|
|
22504
|
+
"app_event",
|
|
22504
22505
|
"error",
|
|
22505
22506
|
"actionable_mail",
|
|
22506
22507
|
"actionable_chat"
|
|
@@ -26738,6 +26739,9 @@ var MAX_DELIVERED_IDS = 5e3;
|
|
|
26738
26739
|
var DELIVERED_IDS_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
26739
26740
|
var MAIL_FETCH_LIMIT = 200;
|
|
26740
26741
|
var CHAT_FETCH_LIMIT = 2e3;
|
|
26742
|
+
var APP_EVENT_SUMMARY_SEPARATOR = " \u2014 ";
|
|
26743
|
+
var MAX_APP_EVENT_VALUE_LENGTH = 160;
|
|
26744
|
+
var MAX_APP_EVENT_PAYLOAD_LENGTH = 500;
|
|
26741
26745
|
async function loadPinStore(path = DEFAULT_PIN_STORE_PATH) {
|
|
26742
26746
|
try {
|
|
26743
26747
|
const content = await readFile4(path, "utf-8");
|
|
@@ -26895,10 +26899,42 @@ async function dispatchAgentEvent(options, dispatched, event) {
|
|
|
26895
26899
|
}
|
|
26896
26900
|
});
|
|
26897
26901
|
break;
|
|
26902
|
+
case "app_event":
|
|
26903
|
+
await dispatchAppEvent(options, dispatched, event);
|
|
26904
|
+
break;
|
|
26898
26905
|
default:
|
|
26899
26906
|
break;
|
|
26900
26907
|
}
|
|
26901
26908
|
}
|
|
26909
|
+
async function dispatchAppEvent(options, dispatched, event) {
|
|
26910
|
+
if (!event.event_id)
|
|
26911
|
+
return;
|
|
26912
|
+
const key = dispatchKey("app", event.app_event_type || "app_event", event.event_id);
|
|
26913
|
+
if (dispatched.has(key) || options.deliveryStore?.has(key))
|
|
26914
|
+
return;
|
|
26915
|
+
const meta3 = {
|
|
26916
|
+
type: event.app_event_type || "app_event",
|
|
26917
|
+
event_id: event.event_id,
|
|
26918
|
+
app_id: event.app_id || "",
|
|
26919
|
+
app_event_type: event.app_event_type || "",
|
|
26920
|
+
resource_ref: event.resource_ref || "",
|
|
26921
|
+
producer_delivery_intent: event.producer_delivery_intent || ""
|
|
26922
|
+
};
|
|
26923
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : void 0;
|
|
26924
|
+
if (payload)
|
|
26925
|
+
meta3.payload = summarizePayload(payload);
|
|
26926
|
+
await options.onAwakening({
|
|
26927
|
+
kind: "app",
|
|
26928
|
+
content: formatAppEventSummary(event, payload),
|
|
26929
|
+
deliveryIntent: event.delivery_intent || "ambient",
|
|
26930
|
+
meta: meta3
|
|
26931
|
+
});
|
|
26932
|
+
dispatched.add(key);
|
|
26933
|
+
if (options.deliveryStore) {
|
|
26934
|
+
options.deliveryStore.mark(key);
|
|
26935
|
+
await options.deliveryStore.save();
|
|
26936
|
+
}
|
|
26937
|
+
}
|
|
26902
26938
|
async function dispatchMailEvent(options, dispatched, event) {
|
|
26903
26939
|
const messages = await fetchInbox(options.client, true, MAIL_FETCH_LIMIT, event.message_id);
|
|
26904
26940
|
let pinsDirty = false;
|
|
@@ -27092,6 +27128,44 @@ function dispatchKey(channel, conversationID, messageID) {
|
|
|
27092
27128
|
const conversation = (conversationID || "").trim();
|
|
27093
27129
|
return `${channel}:${conversation}:${messageID}`;
|
|
27094
27130
|
}
|
|
27131
|
+
function summarizePayload(payload) {
|
|
27132
|
+
const json3 = JSON.stringify(payload);
|
|
27133
|
+
if (!json3)
|
|
27134
|
+
return "";
|
|
27135
|
+
return truncateText(json3, MAX_APP_EVENT_PAYLOAD_LENGTH);
|
|
27136
|
+
}
|
|
27137
|
+
function formatAppEventSummary(event, payload) {
|
|
27138
|
+
const parts = [sanitizeSummaryComponent(event.app_event_type || "app_event") || "app_event"];
|
|
27139
|
+
const resourceRef = sanitizeSummaryComponent(event.resource_ref || "");
|
|
27140
|
+
if (resourceRef)
|
|
27141
|
+
parts.push(resourceRef);
|
|
27142
|
+
const payloadSummary = payload ? summarizePayloadFields(payload) : "";
|
|
27143
|
+
if (payloadSummary)
|
|
27144
|
+
parts.push(payloadSummary);
|
|
27145
|
+
return parts.join(APP_EVENT_SUMMARY_SEPARATOR);
|
|
27146
|
+
}
|
|
27147
|
+
function summarizePayloadFields(payload) {
|
|
27148
|
+
return Object.entries(payload).map(([key, value]) => `${sanitizeSummaryComponent(key)}=${formatPayloadSummaryValue(value)}`).filter((part) => part.trim() !== "").join(", ");
|
|
27149
|
+
}
|
|
27150
|
+
function formatPayloadSummaryValue(value) {
|
|
27151
|
+
if (typeof value === "string")
|
|
27152
|
+
return truncateText(sanitizeSummaryComponent(value), MAX_APP_EVENT_VALUE_LENGTH);
|
|
27153
|
+
if (typeof value === "number" || typeof value === "boolean" || value === null) {
|
|
27154
|
+
return String(value);
|
|
27155
|
+
}
|
|
27156
|
+
const json3 = JSON.stringify(value);
|
|
27157
|
+
return truncateText(sanitizeSummaryComponent(json3 || String(value)), MAX_APP_EVENT_VALUE_LENGTH);
|
|
27158
|
+
}
|
|
27159
|
+
function sanitizeSummaryComponent(value) {
|
|
27160
|
+
return value.replace(/[\u0000-\u001F\u007F]+/g, " ").trim();
|
|
27161
|
+
}
|
|
27162
|
+
function truncateText(value, maxLength) {
|
|
27163
|
+
if (value.length <= maxLength)
|
|
27164
|
+
return value;
|
|
27165
|
+
if (maxLength <= 3)
|
|
27166
|
+
return value.slice(0, maxLength);
|
|
27167
|
+
return `${value.slice(0, maxLength - 3)}...`;
|
|
27168
|
+
}
|
|
27095
27169
|
function senderDisplayAddress(alias, address) {
|
|
27096
27170
|
const qualified = (address || "").trim();
|
|
27097
27171
|
if (qualified)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awebai/claude-channel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"mcpName": "io.github.awebai/channel",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
".mcp.json",
|
|
13
13
|
"skills",
|
|
14
14
|
"README.md",
|
|
15
|
+
"CHANGELOG.md",
|
|
15
16
|
"package.json"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|