@inline-openclaw/inline 0.0.26 → 0.0.27
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
CHANGED
|
@@ -34031,6 +34031,7 @@ import { mkdir } from "node:fs/promises";
|
|
|
34031
34031
|
import path2 from "node:path";
|
|
34032
34032
|
|
|
34033
34033
|
// src/sdk-runtime-compat.ts
|
|
34034
|
+
import { createMessageToolButtonsSchema } from "openclaw/plugin-sdk/channel-actions";
|
|
34034
34035
|
var HISTORY_CONTEXT_MARKER = "[Chat messages since your last reply - for context]";
|
|
34035
34036
|
var CURRENT_MESSAGE_MARKER = "[Current message - respond to this]";
|
|
34036
34037
|
var MAX_HISTORY_KEYS = 1000;
|
|
@@ -34121,24 +34122,13 @@ function recordPendingHistoryEntryIfEnabled(params) {
|
|
|
34121
34122
|
limit: params.limit
|
|
34122
34123
|
});
|
|
34123
34124
|
}
|
|
34125
|
+
var TYPEBOX_OPTIONAL_SYMBOL = Symbol.for("TypeBox.Optional");
|
|
34126
|
+
function markTypeBoxOptional(schema) {
|
|
34127
|
+
schema[TYPEBOX_OPTIONAL_SYMBOL] = "Optional";
|
|
34128
|
+
return schema;
|
|
34129
|
+
}
|
|
34124
34130
|
function createMessageToolButtonsSchemaCompat() {
|
|
34125
|
-
return
|
|
34126
|
-
type: "array",
|
|
34127
|
-
description: "Button rows for channels that support button-style actions.",
|
|
34128
|
-
items: {
|
|
34129
|
-
type: "array",
|
|
34130
|
-
items: {
|
|
34131
|
-
type: "object",
|
|
34132
|
-
additionalProperties: false,
|
|
34133
|
-
required: ["text", "callback_data"],
|
|
34134
|
-
properties: {
|
|
34135
|
-
text: { type: "string" },
|
|
34136
|
-
callback_data: { type: "string" },
|
|
34137
|
-
style: { type: "string", enum: ["danger", "success", "primary"] }
|
|
34138
|
-
}
|
|
34139
|
-
}
|
|
34140
|
-
}
|
|
34141
|
-
};
|
|
34131
|
+
return markTypeBoxOptional(createMessageToolButtonsSchema());
|
|
34142
34132
|
}
|
|
34143
34133
|
function extensionForMimeCompat(mime) {
|
|
34144
34134
|
const normalized = mime?.trim().toLowerCase();
|
|
@@ -36818,6 +36808,12 @@ Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
|
|
|
36818
36808
|
return { stop, done: loop.catch(() => {}) };
|
|
36819
36809
|
}
|
|
36820
36810
|
|
|
36811
|
+
// src/inline/actions.ts
|
|
36812
|
+
import {
|
|
36813
|
+
normalizeInteractiveReply,
|
|
36814
|
+
reduceInteractiveReply
|
|
36815
|
+
} from "openclaw/plugin-sdk/interactive-runtime";
|
|
36816
|
+
|
|
36821
36817
|
// src/inline/space-members.ts
|
|
36822
36818
|
function buildInlineUserDisplayName(user) {
|
|
36823
36819
|
const explicit = [user.firstName?.trim(), user.lastName?.trim()].filter(Boolean).join(" ");
|
|
@@ -36946,9 +36942,78 @@ function normalizeReplyMarkupButtons(raw) {
|
|
|
36946
36942
|
}
|
|
36947
36943
|
return rows;
|
|
36948
36944
|
}
|
|
36945
|
+
function chunkInteractiveButtons(buttons, rows) {
|
|
36946
|
+
for (let i = 0;i < buttons.length; i += INLINE_ACTION_MAX_PER_ROW2) {
|
|
36947
|
+
const row = buttons.slice(i, i + INLINE_ACTION_MAX_PER_ROW2).map((button) => {
|
|
36948
|
+
const text = button.label.trim();
|
|
36949
|
+
const callbackData = button.value.trim();
|
|
36950
|
+
if (!text || !callbackData) {
|
|
36951
|
+
return null;
|
|
36952
|
+
}
|
|
36953
|
+
return { text, callback_data: callbackData };
|
|
36954
|
+
}).filter((button) => button != null);
|
|
36955
|
+
if (row.length === 0)
|
|
36956
|
+
continue;
|
|
36957
|
+
rows.push(row);
|
|
36958
|
+
if (rows.length >= INLINE_ACTION_MAX_ROWS2)
|
|
36959
|
+
return;
|
|
36960
|
+
}
|
|
36961
|
+
}
|
|
36962
|
+
function resolveInlineInteractiveButtonsParam(params) {
|
|
36963
|
+
if (!Object.prototype.hasOwnProperty.call(params, "interactive")) {
|
|
36964
|
+
return;
|
|
36965
|
+
}
|
|
36966
|
+
let rawInteractive = params.interactive;
|
|
36967
|
+
if (typeof rawInteractive === "string") {
|
|
36968
|
+
const trimmed = rawInteractive.trim();
|
|
36969
|
+
if (!trimmed) {
|
|
36970
|
+
return;
|
|
36971
|
+
}
|
|
36972
|
+
try {
|
|
36973
|
+
rawInteractive = JSON.parse(trimmed);
|
|
36974
|
+
} catch {
|
|
36975
|
+
throw new Error("inline action: interactive must be valid JSON");
|
|
36976
|
+
}
|
|
36977
|
+
}
|
|
36978
|
+
const interactive = normalizeInteractiveReply(rawInteractive);
|
|
36979
|
+
if (!interactive) {
|
|
36980
|
+
return;
|
|
36981
|
+
}
|
|
36982
|
+
const rows = reduceInteractiveReply(interactive, [], (state, block) => {
|
|
36983
|
+
if (state.length >= INLINE_ACTION_MAX_ROWS2) {
|
|
36984
|
+
return state;
|
|
36985
|
+
}
|
|
36986
|
+
if (block.type === "buttons") {
|
|
36987
|
+
chunkInteractiveButtons(block.buttons, state);
|
|
36988
|
+
return state;
|
|
36989
|
+
}
|
|
36990
|
+
if (block.type === "select") {
|
|
36991
|
+
chunkInteractiveButtons(block.options.map((option) => ({ label: option.label, value: option.value })), state);
|
|
36992
|
+
}
|
|
36993
|
+
return state;
|
|
36994
|
+
});
|
|
36995
|
+
return rows.length > 0 ? rows : undefined;
|
|
36996
|
+
}
|
|
36997
|
+
function toInlineMessageActions(rows) {
|
|
36998
|
+
return {
|
|
36999
|
+
rows: rows.map((row, rowIndex) => ({
|
|
37000
|
+
actions: row.map((button, buttonIndex) => ({
|
|
37001
|
+
actionId: `btn_${rowIndex + 1}_${buttonIndex + 1}`,
|
|
37002
|
+
text: button.text,
|
|
37003
|
+
action: {
|
|
37004
|
+
oneofKind: "callback",
|
|
37005
|
+
callback: {
|
|
37006
|
+
data: new TextEncoder().encode(button.callback_data)
|
|
37007
|
+
}
|
|
37008
|
+
}
|
|
37009
|
+
}))
|
|
37010
|
+
}))
|
|
37011
|
+
};
|
|
37012
|
+
}
|
|
36949
37013
|
function resolveInlineMessageActionsParam(params) {
|
|
36950
37014
|
if (!Object.prototype.hasOwnProperty.call(params, "buttons")) {
|
|
36951
|
-
|
|
37015
|
+
const interactiveRows = resolveInlineInteractiveButtonsParam(params);
|
|
37016
|
+
return interactiveRows ? toInlineMessageActions(interactiveRows) : undefined;
|
|
36952
37017
|
}
|
|
36953
37018
|
let rawButtons = params.buttons;
|
|
36954
37019
|
if (typeof rawButtons === "string") {
|
|
@@ -36970,20 +37035,7 @@ function resolveInlineMessageActionsParam(params) {
|
|
|
36970
37035
|
throw new Error("inline action: buttons must be an array of button rows");
|
|
36971
37036
|
}
|
|
36972
37037
|
const rows = normalizeReplyMarkupButtons(rawButtons);
|
|
36973
|
-
return
|
|
36974
|
-
rows: rows.map((row, rowIndex) => ({
|
|
36975
|
-
actions: row.map((button, buttonIndex) => ({
|
|
36976
|
-
actionId: `btn_${rowIndex + 1}_${buttonIndex + 1}`,
|
|
36977
|
-
text: button.text,
|
|
36978
|
-
action: {
|
|
36979
|
-
oneofKind: "callback",
|
|
36980
|
-
callback: {
|
|
36981
|
-
data: new TextEncoder().encode(button.callback_data)
|
|
36982
|
-
}
|
|
36983
|
-
}
|
|
36984
|
-
}))
|
|
36985
|
-
}))
|
|
36986
|
-
};
|
|
37038
|
+
return toInlineMessageActions(rows);
|
|
36987
37039
|
}
|
|
36988
37040
|
function normalizeChatId(raw) {
|
|
36989
37041
|
const normalized = normalizeInlineTarget(raw) ?? raw.trim();
|
|
@@ -37513,13 +37565,12 @@ function listAllActions() {
|
|
|
37513
37565
|
return Array.from(out);
|
|
37514
37566
|
}
|
|
37515
37567
|
function listEnabledInlineActions(cfg) {
|
|
37516
|
-
const
|
|
37517
|
-
if (
|
|
37568
|
+
const gates = listInlineAccountIds(cfg).map((accountId) => resolveInlineAccount({ cfg, accountId })).filter((account) => account.enabled && account.configured).map((account) => createActionGate(account.config.actions ?? {}));
|
|
37569
|
+
if (gates.length === 0)
|
|
37518
37570
|
return [];
|
|
37519
|
-
const gate = createActionGate(account.config.actions ?? {});
|
|
37520
37571
|
const actions = new Set;
|
|
37521
37572
|
for (const group of ACTION_GROUPS) {
|
|
37522
|
-
if (!gate(group.key, group.defaultEnabled))
|
|
37573
|
+
if (!gates.some((gate) => gate(group.key, group.defaultEnabled)))
|
|
37523
37574
|
continue;
|
|
37524
37575
|
for (const action of group.actions) {
|
|
37525
37576
|
actions.add(action);
|
|
@@ -40844,5 +40895,5 @@ export {
|
|
|
40844
40895
|
src_default as default
|
|
40845
40896
|
};
|
|
40846
40897
|
|
|
40847
|
-
//# debugId=
|
|
40898
|
+
//# debugId=CE0AB31A68AAA68C64756E2164756E21
|
|
40848
40899
|
//# sourceMappingURL=index.js.map
|