@inline-openclaw/inline 0.0.19 → 0.0.20
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.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +185 -4
- package/dist/index.js.map +7 -6
- package/dist/inline/accounts.d.ts +20 -0
- package/dist/inline/accounts.d.ts.map +1 -0
- package/dist/inline/actions.d.ts +4 -0
- package/dist/inline/actions.d.ts.map +1 -0
- package/dist/inline/channel.d.ts +4 -0
- package/dist/inline/channel.d.ts.map +1 -0
- package/dist/inline/config-schema.d.ts +453 -0
- package/dist/inline/config-schema.d.ts.map +1 -0
- package/dist/inline/media.d.ts +9 -0
- package/dist/inline/media.d.ts.map +1 -0
- package/dist/inline/members-tool.d.ts +6 -0
- package/dist/inline/members-tool.d.ts.map +1 -0
- package/dist/inline/message-content.d.ts +51 -0
- package/dist/inline/message-content.d.ts.map +1 -0
- package/dist/inline/message-tools.d.ts +10 -0
- package/dist/inline/message-tools.d.ts.map +1 -0
- package/dist/inline/monitor.d.ts +26 -0
- package/dist/inline/monitor.d.ts.map +1 -0
- package/dist/inline/normalize.d.ts +3 -0
- package/dist/inline/normalize.d.ts.map +1 -0
- package/dist/inline/policy.d.ts +19 -0
- package/dist/inline/policy.d.ts.map +1 -0
- package/dist/inline/profile-tool.d.ts +6 -0
- package/dist/inline/profile-tool.d.ts.map +1 -0
- package/dist/inline/space-members.d.ts +22 -0
- package/dist/inline/space-members.d.ts.map +1 -0
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
2
|
+
declare const plugin: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
configSchema: unknown;
|
|
7
|
+
register: (api: OpenClawPluginApi) => void;
|
|
8
|
+
};
|
|
9
|
+
export default plugin;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAQ1E,QAAA,MAAM,MAAM,EAAE;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IAGnB,YAAY,EAAE,OAAO,CAAA;IACrB,QAAQ,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAmB3C,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -32719,9 +32719,12 @@ function looksLikeInlineTargetId(raw, normalizedInput) {
|
|
|
32719
32719
|
import { mkdir } from "node:fs/promises";
|
|
32720
32720
|
import path2 from "node:path";
|
|
32721
32721
|
import {
|
|
32722
|
+
buildPendingHistoryContextFromMap,
|
|
32723
|
+
clearHistoryEntriesIfEnabled,
|
|
32722
32724
|
createReplyPrefixOptions,
|
|
32723
32725
|
createTypingCallbacks,
|
|
32724
32726
|
logInboundDrop,
|
|
32727
|
+
recordPendingHistoryEntryIfEnabled,
|
|
32725
32728
|
resolveChannelMediaMaxBytes as resolveChannelMediaMaxBytes2,
|
|
32726
32729
|
resolveControlCommandGate,
|
|
32727
32730
|
resolveMentionGatingWithBypass
|
|
@@ -33794,6 +33797,7 @@ async function monitorInlineProvider(params) {
|
|
|
33794
33797
|
const chatCache = new Map;
|
|
33795
33798
|
const senderProfilesById = new Map;
|
|
33796
33799
|
const botMessageIdsByChat = new Map;
|
|
33800
|
+
const groupPendingHistories = new Map;
|
|
33797
33801
|
const hydratedParticipantChats = new Set;
|
|
33798
33802
|
const participantFetches = new Map;
|
|
33799
33803
|
const inboundMediaMaxBytes = resolveInlineMediaMaxBytes({ cfg, account });
|
|
@@ -34036,7 +34040,12 @@ async function monitorInlineProvider(params) {
|
|
|
34036
34040
|
}
|
|
34037
34041
|
});
|
|
34038
34042
|
const mentionRegexes = core3.channel.mentions.buildMentionRegexes(cfg, route.agentId);
|
|
34039
|
-
const
|
|
34043
|
+
const nativeMentioned = typeof msg.mentioned === "boolean" ? msg.mentioned : false;
|
|
34044
|
+
const patternMentioned = mentionRegexes.length ? core3.channel.mentions.matchesMentionPatterns(rawBody, mentionRegexes) : false;
|
|
34045
|
+
const wasMentioned = nativeMentioned || patternMentioned;
|
|
34046
|
+
const messageTimestamp = Number(msg.date) * 1000;
|
|
34047
|
+
const groupHistoryKey = isGroup ? route.sessionKey : null;
|
|
34048
|
+
const pendingHistorySender = senderUsername ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
|
|
34040
34049
|
const historyLimit = resolveHistoryLimit({
|
|
34041
34050
|
isGroup,
|
|
34042
34051
|
historyLimit: account.config.historyLimit,
|
|
@@ -34074,6 +34083,17 @@ async function monitorInlineProvider(params) {
|
|
|
34074
34083
|
});
|
|
34075
34084
|
if (isGroup && mentionGate.shouldSkip) {
|
|
34076
34085
|
runtime2.log?.(`inline: drop group chat ${String(chatId)} (no mention)`);
|
|
34086
|
+
recordPendingHistoryEntryIfEnabled({
|
|
34087
|
+
historyMap: groupPendingHistories,
|
|
34088
|
+
historyKey: groupHistoryKey ?? "",
|
|
34089
|
+
limit: historyLimit,
|
|
34090
|
+
entry: groupHistoryKey && rawBody.trim() ? {
|
|
34091
|
+
sender: pendingHistorySender,
|
|
34092
|
+
body: rawBody.trim(),
|
|
34093
|
+
timestamp: messageTimestamp || Date.now(),
|
|
34094
|
+
messageId: String(msg.id)
|
|
34095
|
+
} : null
|
|
34096
|
+
});
|
|
34077
34097
|
continue;
|
|
34078
34098
|
}
|
|
34079
34099
|
const inboundMedia = reactionEvent ? [] : await resolveInlineInboundMedia({
|
|
@@ -34082,7 +34102,7 @@ async function monitorInlineProvider(params) {
|
|
|
34082
34102
|
maxBytes: inboundMediaMaxBytes,
|
|
34083
34103
|
...log ? { log } : {}
|
|
34084
34104
|
});
|
|
34085
|
-
const timestamp =
|
|
34105
|
+
const timestamp = messageTimestamp;
|
|
34086
34106
|
const fromLabel = isGroup ? `chat:${chatInfo.title ?? String(chatId)}` : `user:${senderId}`;
|
|
34087
34107
|
const storePath = core3.channel.session.resolveStorePath(cfg.session?.store, { agentId: route.agentId });
|
|
34088
34108
|
const envelopeOptions = core3.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
@@ -34101,7 +34121,7 @@ ${currentEntityText}` : null
|
|
|
34101
34121
|
].filter(Boolean).join(`
|
|
34102
34122
|
|
|
34103
34123
|
`);
|
|
34104
|
-
|
|
34124
|
+
let body = core3.channel.reply.formatAgentEnvelope({
|
|
34105
34125
|
channel: "Inline",
|
|
34106
34126
|
from: fromLabel,
|
|
34107
34127
|
timestamp,
|
|
@@ -34109,6 +34129,21 @@ ${currentEntityText}` : null
|
|
|
34109
34129
|
envelope: envelopeOptions,
|
|
34110
34130
|
body: combinedBody || rawBody
|
|
34111
34131
|
});
|
|
34132
|
+
if (isGroup && groupHistoryKey) {
|
|
34133
|
+
body = buildPendingHistoryContextFromMap({
|
|
34134
|
+
historyMap: groupPendingHistories,
|
|
34135
|
+
historyKey: groupHistoryKey,
|
|
34136
|
+
limit: historyLimit,
|
|
34137
|
+
currentMessage: body,
|
|
34138
|
+
formatEntry: (entry) => core3.channel.reply.formatAgentEnvelope({
|
|
34139
|
+
channel: "Inline",
|
|
34140
|
+
from: fromLabel,
|
|
34141
|
+
...entry.timestamp != null ? { timestamp: entry.timestamp } : {},
|
|
34142
|
+
envelope: envelopeOptions,
|
|
34143
|
+
body: `${entry.body}${entry.messageId ? ` [id:${entry.messageId} chat:${String(chatId)}]` : ""}`
|
|
34144
|
+
})
|
|
34145
|
+
});
|
|
34146
|
+
}
|
|
34112
34147
|
const commandBody = normalizeInlineCommandBody(rawBody, botUsername);
|
|
34113
34148
|
const ctxPayload = core3.channel.reply.finalizeInboundContext({
|
|
34114
34149
|
Body: body,
|
|
@@ -34349,6 +34384,13 @@ Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
|
|
|
34349
34384
|
},
|
|
34350
34385
|
replyOptions
|
|
34351
34386
|
});
|
|
34387
|
+
if (isGroup && groupHistoryKey) {
|
|
34388
|
+
clearHistoryEntriesIfEnabled({
|
|
34389
|
+
historyMap: groupPendingHistories,
|
|
34390
|
+
historyKey: groupHistoryKey,
|
|
34391
|
+
limit: historyLimit
|
|
34392
|
+
});
|
|
34393
|
+
}
|
|
34352
34394
|
}
|
|
34353
34395
|
} catch (err) {
|
|
34354
34396
|
statusSink?.({ lastError: String(err) });
|
|
@@ -37039,6 +37081,142 @@ function createInlineMembersTool(ctx) {
|
|
|
37039
37081
|
};
|
|
37040
37082
|
}
|
|
37041
37083
|
|
|
37084
|
+
// src/inline/profile-tool.ts
|
|
37085
|
+
import {
|
|
37086
|
+
detectMime as detectMime2,
|
|
37087
|
+
loadWebMedia as loadWebMedia2
|
|
37088
|
+
} from "openclaw/plugin-sdk";
|
|
37089
|
+
var InlineProfileToolParameters = {
|
|
37090
|
+
type: "object",
|
|
37091
|
+
additionalProperties: false,
|
|
37092
|
+
properties: {
|
|
37093
|
+
name: {
|
|
37094
|
+
type: "string",
|
|
37095
|
+
description: "Optional new display name for the authenticated Inline bot."
|
|
37096
|
+
},
|
|
37097
|
+
photoUrl: {
|
|
37098
|
+
type: "string",
|
|
37099
|
+
description: "Optional remote image URL to upload as the bot profile photo."
|
|
37100
|
+
},
|
|
37101
|
+
photoPath: {
|
|
37102
|
+
type: "string",
|
|
37103
|
+
description: "Optional local image path to upload as the bot profile photo."
|
|
37104
|
+
},
|
|
37105
|
+
photoFileUniqueId: {
|
|
37106
|
+
type: "string",
|
|
37107
|
+
description: "Optional existing Inline file unique id to use as the bot profile photo."
|
|
37108
|
+
},
|
|
37109
|
+
accountId: {
|
|
37110
|
+
type: "string",
|
|
37111
|
+
description: "Optional Inline account id override."
|
|
37112
|
+
}
|
|
37113
|
+
}
|
|
37114
|
+
};
|
|
37115
|
+
function jsonResult4(payload) {
|
|
37116
|
+
return {
|
|
37117
|
+
content: [
|
|
37118
|
+
{
|
|
37119
|
+
type: "text",
|
|
37120
|
+
text: JSON.stringify(payload, (_key, value) => typeof value === "bigint" ? value.toString() : value, 2)
|
|
37121
|
+
}
|
|
37122
|
+
],
|
|
37123
|
+
details: payload
|
|
37124
|
+
};
|
|
37125
|
+
}
|
|
37126
|
+
async function withInlineClient5(params) {
|
|
37127
|
+
const account = resolveInlineAccount({ cfg: params.cfg, accountId: params.accountId ?? null });
|
|
37128
|
+
if (!account.configured || !account.baseUrl) {
|
|
37129
|
+
throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
|
|
37130
|
+
}
|
|
37131
|
+
const token = await resolveInlineToken(account);
|
|
37132
|
+
const client = new InlineSdkClient({
|
|
37133
|
+
baseUrl: account.baseUrl,
|
|
37134
|
+
token
|
|
37135
|
+
});
|
|
37136
|
+
await client.connect();
|
|
37137
|
+
try {
|
|
37138
|
+
return await params.fn(client, account.accountId);
|
|
37139
|
+
} finally {
|
|
37140
|
+
await client.close().catch(() => {});
|
|
37141
|
+
}
|
|
37142
|
+
}
|
|
37143
|
+
function readTrimmedString(value) {
|
|
37144
|
+
if (typeof value !== "string")
|
|
37145
|
+
return;
|
|
37146
|
+
const trimmed = value.trim();
|
|
37147
|
+
return trimmed || undefined;
|
|
37148
|
+
}
|
|
37149
|
+
function resolvePhotoSource(args) {
|
|
37150
|
+
return readTrimmedString(args.photoPath) ?? readTrimmedString(args.photoUrl);
|
|
37151
|
+
}
|
|
37152
|
+
async function uploadProfilePhoto(client, rawSource) {
|
|
37153
|
+
const loaded = await loadWebMedia2(rawSource);
|
|
37154
|
+
const contentType = loaded.contentType ?? await detectMime2({
|
|
37155
|
+
buffer: loaded.buffer,
|
|
37156
|
+
...loaded.fileName ? { filePath: loaded.fileName } : {}
|
|
37157
|
+
}) ?? undefined;
|
|
37158
|
+
const fileName = loaded.fileName?.trim() || "profile-photo.png";
|
|
37159
|
+
const uploaded = await client.uploadFile({
|
|
37160
|
+
type: "photo",
|
|
37161
|
+
file: loaded.buffer,
|
|
37162
|
+
fileName,
|
|
37163
|
+
...contentType ? { contentType } : {}
|
|
37164
|
+
});
|
|
37165
|
+
if (!uploaded.fileUniqueId) {
|
|
37166
|
+
throw new Error("inline_update_profile: upload did not return fileUniqueId");
|
|
37167
|
+
}
|
|
37168
|
+
return uploaded.fileUniqueId;
|
|
37169
|
+
}
|
|
37170
|
+
function createInlineProfileTool(ctx) {
|
|
37171
|
+
if (!ctx.config) {
|
|
37172
|
+
return null;
|
|
37173
|
+
}
|
|
37174
|
+
return {
|
|
37175
|
+
name: "inline_update_profile",
|
|
37176
|
+
label: "Inline Update Profile",
|
|
37177
|
+
description: "Update the authenticated Inline bot profile name and/or profile photo.",
|
|
37178
|
+
parameters: InlineProfileToolParameters,
|
|
37179
|
+
execute: async (_toolCallId, rawArgs) => {
|
|
37180
|
+
const args = rawArgs;
|
|
37181
|
+
const name = readTrimmedString(args.name);
|
|
37182
|
+
const existingPhotoFileUniqueId = readTrimmedString(args.photoFileUniqueId);
|
|
37183
|
+
const photoSource = resolvePhotoSource(args);
|
|
37184
|
+
if (!name && !existingPhotoFileUniqueId && !photoSource) {
|
|
37185
|
+
throw new Error("inline_update_profile: provide `name` and/or `photo`");
|
|
37186
|
+
}
|
|
37187
|
+
return await withInlineClient5({
|
|
37188
|
+
cfg: ctx.config,
|
|
37189
|
+
accountId: args.accountId ?? ctx.agentAccountId ?? null,
|
|
37190
|
+
fn: async (client, resolvedAccountId) => {
|
|
37191
|
+
const me = await client.getMe();
|
|
37192
|
+
const photoFileUniqueId = existingPhotoFileUniqueId ?? (photoSource ? await uploadProfilePhoto(client, photoSource) : undefined);
|
|
37193
|
+
const result = await client.invokeRaw(Method.UPDATE_BOT_PROFILE, {
|
|
37194
|
+
oneofKind: "updateBotProfile",
|
|
37195
|
+
updateBotProfile: {
|
|
37196
|
+
botUserId: me.userId,
|
|
37197
|
+
...name ? { name } : {},
|
|
37198
|
+
...photoFileUniqueId ? { photoFileUniqueId } : {}
|
|
37199
|
+
}
|
|
37200
|
+
});
|
|
37201
|
+
if (result.oneofKind !== "updateBotProfile") {
|
|
37202
|
+
throw new Error(`inline_update_profile: expected updateBotProfile result, got ${String(result.oneofKind)}`);
|
|
37203
|
+
}
|
|
37204
|
+
return jsonResult4({
|
|
37205
|
+
ok: true,
|
|
37206
|
+
accountId: resolvedAccountId,
|
|
37207
|
+
botUserId: String(me.userId),
|
|
37208
|
+
updated: {
|
|
37209
|
+
...name ? { name } : {},
|
|
37210
|
+
photo: photoFileUniqueId != null
|
|
37211
|
+
},
|
|
37212
|
+
bot: result.updateBotProfile.bot ?? null
|
|
37213
|
+
});
|
|
37214
|
+
}
|
|
37215
|
+
});
|
|
37216
|
+
}
|
|
37217
|
+
};
|
|
37218
|
+
}
|
|
37219
|
+
|
|
37042
37220
|
// src/index.ts
|
|
37043
37221
|
var plugin = {
|
|
37044
37222
|
id: "inline",
|
|
@@ -37051,6 +37229,9 @@ var plugin = {
|
|
|
37051
37229
|
api2.registerTool((ctx) => createInlineMembersTool(ctx), {
|
|
37052
37230
|
names: ["inline_members"]
|
|
37053
37231
|
});
|
|
37232
|
+
api2.registerTool((ctx) => createInlineProfileTool(ctx), {
|
|
37233
|
+
names: ["inline_update_profile"]
|
|
37234
|
+
});
|
|
37054
37235
|
api2.registerTool((ctx) => createInlineMessageTools(ctx), {
|
|
37055
37236
|
names: ["inline_nudge", "inline_forward"]
|
|
37056
37237
|
});
|
|
@@ -37061,5 +37242,5 @@ export {
|
|
|
37061
37242
|
src_default as default
|
|
37062
37243
|
};
|
|
37063
37244
|
|
|
37064
|
-
//# debugId=
|
|
37245
|
+
//# debugId=442A6C0FCB2305FD64756E2164756E21
|
|
37065
37246
|
//# sourceMappingURL=index.js.map
|