@inline-openclaw/inline 0.0.36 → 0.0.37

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.
@@ -11324,7 +11324,8 @@ class UpdateDialogOrderInput$Type extends import_runtime4.MessageType {
11324
11324
  super("UpdateDialogOrderInput", [
11325
11325
  { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
11326
11326
  { no: 2, name: "order", kind: "scalar", opt: true, T: 9 },
11327
- { no: 3, name: "pinned_order", kind: "scalar", opt: true, T: 9 }
11327
+ { no: 3, name: "pinned_order", kind: "scalar", opt: true, T: 9 },
11328
+ { no: 4, name: "pinned", kind: "scalar", opt: true, T: 8 }
11328
11329
  ]);
11329
11330
  }
11330
11331
  create(value) {
@@ -11347,6 +11348,9 @@ class UpdateDialogOrderInput$Type extends import_runtime4.MessageType {
11347
11348
  case 3:
11348
11349
  message.pinnedOrder = reader.string();
11349
11350
  break;
11351
+ case 4:
11352
+ message.pinned = reader.bool();
11353
+ break;
11350
11354
  default:
11351
11355
  let u = options.readUnknownField;
11352
11356
  if (u === "throw")
@@ -11365,6 +11369,8 @@ class UpdateDialogOrderInput$Type extends import_runtime4.MessageType {
11365
11369
  writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.order);
11366
11370
  if (message.pinnedOrder !== undefined)
11367
11371
  writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.pinnedOrder);
11372
+ if (message.pinned !== undefined)
11373
+ writer.tag(4, import_runtime.WireType.Varint).bool(message.pinned);
11368
11374
  let u = options.writeUnknownFields;
11369
11375
  if (u !== false)
11370
11376
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -35789,7 +35795,7 @@ import {
35789
35795
  updateSessionStore
35790
35796
  } from "openclaw/plugin-sdk/config-runtime";
35791
35797
  import { buildModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
35792
- import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/skill-commands-runtime";
35798
+ import { listSkillCommandsForAgents as listSkillCommandsForAgents2 } from "openclaw/plugin-sdk/skill-commands-runtime";
35793
35799
  import { isReasoningReplyPayload } from "openclaw/plugin-sdk/reply-payload";
35794
35800
  import {
35795
35801
  findCodeRegions,
@@ -39063,9 +39069,231 @@ function buildInlineModelBrowseChannelData() {
39063
39069
  return inlineChannelData([[{ text: "Browse providers", callback_data: "mdl_prov" }]]);
39064
39070
  }
39065
39071
 
39072
+ // src/inline/bot-commands-sync.ts
39073
+ import { listNativeCommandSpecsForConfig } from "openclaw/plugin-sdk/native-command-registry";
39074
+ import { getPluginCommandSpecs } from "openclaw/plugin-sdk/plugin-runtime";
39075
+ import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
39076
+ import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/skill-commands-runtime";
39077
+
39078
+ // src/inline/bot-commands-api.ts
39079
+ function normalizeInlineBotBaseUrl(baseUrl) {
39080
+ return baseUrl.replace(/\/+$/, "");
39081
+ }
39082
+ function normalizeInlineBotCommandName(raw) {
39083
+ return raw.trim().replace(/^\/+/, "");
39084
+ }
39085
+ async function callInlineBotApi(params) {
39086
+ const baseUrl = normalizeInlineBotBaseUrl(params.baseUrl);
39087
+ const invoke = async (authMode) => {
39088
+ const url2 = authMode === "header" ? `${baseUrl}/bot/${params.methodName}` : `${baseUrl}/bot${encodeURIComponent(params.token)}/${params.methodName}`;
39089
+ const request = {
39090
+ method: params.method,
39091
+ headers: {
39092
+ ...authMode === "header" ? { authorization: `Bearer ${params.token}` } : {},
39093
+ ...params.body !== undefined ? { "content-type": "application/json" } : {}
39094
+ }
39095
+ };
39096
+ if (params.body !== undefined) {
39097
+ request.body = JSON.stringify(params.body);
39098
+ }
39099
+ let response;
39100
+ try {
39101
+ response = await fetch(url2, request);
39102
+ } catch (error51) {
39103
+ throw new Error(`inline_bot_commands: ${params.method} ${redactInlineBotApiUrl(url2)} fetch failed: ${summarizeInlineBotApiError(error51)}`);
39104
+ }
39105
+ const payload = await response.json().catch(() => null);
39106
+ return { response, payload };
39107
+ };
39108
+ const resolve = (result) => {
39109
+ if (!result.response.ok) {
39110
+ const message = result.payload?.description ?? `HTTP ${result.response.status}`;
39111
+ throw new Error(`inline_bot_commands: ${message}`);
39112
+ }
39113
+ if (!result.payload || result.payload.ok !== true) {
39114
+ const message = result.payload?.description ?? "bot api call failed";
39115
+ throw new Error(`inline_bot_commands: ${message}`);
39116
+ }
39117
+ return result.payload.result ?? {};
39118
+ };
39119
+ const shouldRetryWithPathToken = (result) => {
39120
+ if (result.response.status === 401)
39121
+ return true;
39122
+ if (result.payload?.error_code === 401)
39123
+ return true;
39124
+ const description = result.payload?.description?.toLowerCase() ?? "";
39125
+ return description.includes("unauthorized");
39126
+ };
39127
+ const headerResult = await invoke("header");
39128
+ if (shouldRetryWithPathToken(headerResult)) {
39129
+ const pathResult = await invoke("path");
39130
+ return resolve(pathResult);
39131
+ }
39132
+ return resolve(headerResult);
39133
+ }
39134
+ function summarizeInlineBotApiError(error51) {
39135
+ if (error51 instanceof Error) {
39136
+ return `${error51.name}: ${error51.message}`;
39137
+ }
39138
+ return String(error51);
39139
+ }
39140
+ function redactInlineBotApiUrl(raw) {
39141
+ try {
39142
+ const url2 = new URL(raw);
39143
+ return `${url2.protocol}//${url2.host}${url2.pathname.replace(/\/bot[^/]*\//, "/bot<redacted>/")}`;
39144
+ } catch {
39145
+ return raw.replace(/\/bot[^/]*\//, "/bot<redacted>/");
39146
+ }
39147
+ }
39148
+
39149
+ // src/inline/bot-commands-sync.ts
39150
+ var INLINE_COMMAND_NAME_RE = /^[a-z0-9_]{1,32}$/;
39151
+ var INLINE_COMMAND_LIMIT = 100;
39152
+ var INLINE_COMMAND_DESCRIPTION_LIMIT = 256;
39153
+ var INLINE_NATIVE_COMMAND_PROVIDER = "inline";
39154
+ function normalizeDynamicCommandName(raw) {
39155
+ const trimmed = raw.trim().toLowerCase();
39156
+ const withoutSlash = trimmed.startsWith("/") ? trimmed.slice(1) : trimmed;
39157
+ return withoutSlash.trim();
39158
+ }
39159
+ function appendUniqueCommand(out, seen, command, description, logger) {
39160
+ const normalized = normalizeDynamicCommandName(command);
39161
+ if (!INLINE_COMMAND_NAME_RE.test(normalized) || seen.has(normalized))
39162
+ return;
39163
+ const rawDescription = adaptInlineVisibleCopy(description).trim();
39164
+ const trimmedDescription = rawDescription.length > INLINE_COMMAND_DESCRIPTION_LIMIT ? rawDescription.slice(0, INLINE_COMMAND_DESCRIPTION_LIMIT).trimEnd() : rawDescription;
39165
+ if (!trimmedDescription)
39166
+ return;
39167
+ if (trimmedDescription.length !== rawDescription.length) {
39168
+ logger?.warn?.(`[inline] bot command sync truncated description for /${normalized} to ${INLINE_COMMAND_DESCRIPTION_LIMIT} characters`);
39169
+ }
39170
+ seen.add(normalized);
39171
+ out.push({ command: normalized, description: trimmedDescription });
39172
+ }
39173
+ function shouldSyncInlineNativeCommandsForAccount(params) {
39174
+ const effective = params.account.config.commands?.native ?? params.cfg.commands?.native ?? "auto";
39175
+ return effective !== false;
39176
+ }
39177
+ function shouldSyncInlineNativeSkills(params) {
39178
+ const effective = params.account.config.commands?.nativeSkills ?? params.cfg.commands?.nativeSkills ?? "auto";
39179
+ return effective !== false;
39180
+ }
39181
+ async function buildInlineNativeCommandsForConfig(params) {
39182
+ const route = shouldSyncInlineNativeSkills({ cfg: params.cfg, account: params.account }) ? resolveAgentRoute({
39183
+ cfg: params.cfg,
39184
+ channel: INLINE_NATIVE_COMMAND_PROVIDER,
39185
+ accountId: params.account.accountId
39186
+ }) : null;
39187
+ const skillCommands = route ? listSkillCommandsForAgents({
39188
+ cfg: params.cfg,
39189
+ agentIds: [route.agentId]
39190
+ }) : [];
39191
+ const nativeSpecs = listNativeCommandSpecsForConfig(params.cfg, {
39192
+ skillCommands,
39193
+ provider: INLINE_NATIVE_COMMAND_PROVIDER
39194
+ });
39195
+ const pluginSpecs = getPluginCommandSpecs("inline", { config: params.cfg });
39196
+ const seen = new Set;
39197
+ const resolved = [];
39198
+ for (const spec of nativeSpecs) {
39199
+ appendUniqueCommand(resolved, seen, spec.name, spec.description, params.logger);
39200
+ }
39201
+ for (const spec of pluginSpecs) {
39202
+ appendUniqueCommand(resolved, seen, spec.name, spec.description, params.logger);
39203
+ }
39204
+ return resolved;
39205
+ }
39206
+ async function syncInlineNativeCommands(params) {
39207
+ const accountIds = listInlineAccountIds(params.cfg);
39208
+ if (!accountIds.length) {
39209
+ params.logger?.info?.("[inline] bot command sync disabled");
39210
+ return { attempted: 0, synced: 0, failed: 0 };
39211
+ }
39212
+ let attempted = 0;
39213
+ let synced = 0;
39214
+ let failed = 0;
39215
+ for (const accountId of accountIds) {
39216
+ const account = resolveInlineAccount({ cfg: params.cfg, accountId });
39217
+ const nativeEnabled = shouldSyncInlineNativeCommandsForAccount({ cfg: params.cfg, account });
39218
+ attempted += 1;
39219
+ if (!account.enabled || !account.configured || !account.baseUrl) {
39220
+ continue;
39221
+ }
39222
+ const ownerAccountId = findInlineTokenOwnerAccountId({
39223
+ cfg: params.cfg,
39224
+ accountId: account.accountId
39225
+ });
39226
+ if (ownerAccountId) {
39227
+ failed += 1;
39228
+ params.logger?.warn?.(`[inline] bot command sync skipped for account "${account.accountId}": ${formatDuplicateInlineTokenReason({
39229
+ accountId: account.accountId,
39230
+ ownerAccountId
39231
+ })}`);
39232
+ continue;
39233
+ }
39234
+ let token;
39235
+ try {
39236
+ token = await resolveInlineToken(account);
39237
+ } catch (err) {
39238
+ failed += 1;
39239
+ params.logger?.warn?.(`[inline] bot command sync skipped for account "${account.accountId}": ${String(err)}`);
39240
+ continue;
39241
+ }
39242
+ if (!nativeEnabled) {
39243
+ try {
39244
+ await callInlineBotApi({
39245
+ baseUrl: account.baseUrl,
39246
+ token,
39247
+ methodName: "deleteMyCommands",
39248
+ method: "POST"
39249
+ });
39250
+ synced += 1;
39251
+ params.logger?.info?.(`[inline] bot commands cleared for account "${account.accountId}"`);
39252
+ } catch (err) {
39253
+ failed += 1;
39254
+ params.logger?.warn?.(`[inline] bot command clear failed for account "${account.accountId}": ${String(err)}`);
39255
+ }
39256
+ continue;
39257
+ }
39258
+ const allCommands = await buildInlineNativeCommandsForConfig({
39259
+ cfg: params.cfg,
39260
+ account,
39261
+ ...params.logger ? { logger: params.logger } : {}
39262
+ });
39263
+ const commands = allCommands.slice(0, INLINE_COMMAND_LIMIT);
39264
+ if (allCommands.length > INLINE_COMMAND_LIMIT) {
39265
+ params.logger?.warn?.(`[inline] bot command sync truncating ${allCommands.length} commands to ${INLINE_COMMAND_LIMIT}`);
39266
+ }
39267
+ if (commands.length === 0) {
39268
+ params.logger?.warn?.(`[inline] bot command sync skipped for account "${account.accountId}": no valid commands resolved`);
39269
+ continue;
39270
+ }
39271
+ try {
39272
+ await callInlineBotApi({
39273
+ baseUrl: account.baseUrl,
39274
+ token,
39275
+ methodName: "setMyCommands",
39276
+ method: "POST",
39277
+ body: { commands }
39278
+ });
39279
+ synced += 1;
39280
+ params.logger?.info?.(`[inline] bot commands synced for account "${account.accountId}" (${commands.length} command${commands.length === 1 ? "" : "s"})`);
39281
+ } catch (err) {
39282
+ failed += 1;
39283
+ params.logger?.warn?.(`[inline] bot command sync failed for account "${account.accountId}": ${String(err)}`);
39284
+ }
39285
+ }
39286
+ return {
39287
+ attempted,
39288
+ synced,
39289
+ failed
39290
+ };
39291
+ }
39292
+
39066
39293
  // src/inline/monitor.ts
39067
39294
  var CHANNEL_ID = "inline";
39068
- var INLINE_NATIVE_COMMAND_PROVIDER = CHANNEL_ID;
39295
+ var INLINE_NATIVE_COMMAND_PROVIDER2 = CHANNEL_ID;
39296
+ var INLINE_NATIVE_COMMAND_CALLBACK_PREFIX = "icmd:";
39069
39297
  var INLINE_REQUEST_ERROR_FALLBACK = "OpenClaw could not process that request. Please try again.";
39070
39298
  var INLINE_DEBOUNCE_ERROR_FALLBACK = "OpenClaw could not process those messages. Please try again.";
39071
39299
  function summarizeSdkMeta(meta3) {
@@ -39348,6 +39576,30 @@ function normalizeInlineCommandBody(raw, botUsername) {
39348
39576
  }
39349
39577
  return normalized;
39350
39578
  }
39579
+ function findInlineNativeCommandFromBody(commandBody) {
39580
+ const match = commandBody.trim().match(/^\/([^\s]+)(?:\s+[\s\S]*)?$/);
39581
+ if (!match?.[1])
39582
+ return null;
39583
+ return findCommandByNativeName(match[1], INLINE_NATIVE_COMMAND_PROVIDER2) ?? null;
39584
+ }
39585
+ function buildInlineNativeCommandCallbackData(commandText) {
39586
+ return `${INLINE_NATIVE_COMMAND_CALLBACK_PREFIX}${commandText}`;
39587
+ }
39588
+ function parseInlineNativeCommandCallbackData(raw) {
39589
+ if (!raw)
39590
+ return null;
39591
+ const trimmed = raw.trim();
39592
+ if (!trimmed.startsWith(INLINE_NATIVE_COMMAND_CALLBACK_PREFIX))
39593
+ return null;
39594
+ const commandText = trimmed.slice(INLINE_NATIVE_COMMAND_CALLBACK_PREFIX.length).trim();
39595
+ return commandText.startsWith("/") ? commandText : null;
39596
+ }
39597
+ function isInlineNativeCommandBody(params) {
39598
+ if (!shouldSyncInlineNativeCommandsForAccount({ cfg: params.cfg, account: params.account })) {
39599
+ return false;
39600
+ }
39601
+ return findInlineNativeCommandFromBody(params.commandBody) != null;
39602
+ }
39351
39603
  function escapeInlineRegExp(raw) {
39352
39604
  return raw.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
39353
39605
  }
@@ -39540,7 +39792,7 @@ function resolveInlineNativeCommandMenu(params) {
39540
39792
  const match = normalized.match(/^\/([^\s]+)(?:\s+([\s\S]+))?$/);
39541
39793
  if (!match?.[1])
39542
39794
  return null;
39543
- const command = findCommandByNativeName(match[1], INLINE_NATIVE_COMMAND_PROVIDER);
39795
+ const command = findInlineNativeCommandFromBody(normalized);
39544
39796
  if (!command)
39545
39797
  return null;
39546
39798
  const args = parseCommandArgs(command, match[2]);
@@ -39573,9 +39825,9 @@ function resolveInlineNativeCommandMenu(params) {
39573
39825
  const slice = menu.choices.slice(index, index + 2);
39574
39826
  rows.push(slice.map((choice) => ({
39575
39827
  text: choice.label,
39576
- callback_data: buildCommandTextFromArgs(command, {
39828
+ callback_data: buildInlineNativeCommandCallbackData(buildCommandTextFromArgs(command, {
39577
39829
  values: { [menu.arg.name]: choice.value }
39578
- })
39830
+ }))
39579
39831
  })));
39580
39832
  }
39581
39833
  return { title, buttons: rows };
@@ -39653,6 +39905,9 @@ function normalizeInlineActionCallbackData(raw) {
39653
39905
  const trimmed = raw.trim();
39654
39906
  if (!trimmed)
39655
39907
  return "";
39908
+ const nativeCommandText = parseInlineNativeCommandCallbackData(trimmed);
39909
+ if (nativeCommandText)
39910
+ return nativeCommandText;
39656
39911
  return mapInlineModelPickerCallbackToCommand(trimmed) ?? trimmed;
39657
39912
  }
39658
39913
  function normalizeCompatibleButtonCallbackData(raw) {
@@ -40743,6 +40998,7 @@ ${JSON.stringify(payload)}`;
40743
40998
  const storeAllowList = normalizeAllowlist(storeAllowFrom);
40744
40999
  const effectiveAllowFrom = [...configAllowFrom, ...storeAllowList].filter(Boolean);
40745
41000
  const effectiveGroupAllowFrom = groupSenderAllowlist.expanded.filter(Boolean);
41001
+ const effectiveGroupCommandAllowFrom = groupSenderAllowlist.raw.length > 0 ? effectiveGroupAllowFrom : effectiveAllowFrom;
40746
41002
  const callbackCommandBody = callbackActionEvent ? resolveCallbackCommandBodyFromActionData({
40747
41003
  data: callbackActionEvent.data,
40748
41004
  ...botUsername ? { botUsername } : {}
@@ -40761,14 +41017,17 @@ ${JSON.stringify(payload)}`;
40761
41017
  }
40762
41018
  const shouldEditCallbackTargetInPlace = callbackActionEvent != null;
40763
41019
  const normalizedCommandBody = callbackCommandBody ?? normalizeInlineCommandBody(rawBody, botUsername);
41020
+ const nativeCallbackCommandBody = callbackActionEvent ? parseInlineNativeCommandCallbackData(callbackDataToUtf8(callbackActionEvent.data)) : null;
41021
+ const hasControlCommand = core3.channel.text.hasControlCommand(callbackCommandBody ?? rawBody, cfg, botUsername ? { botUsername } : undefined);
41022
+ const commandSource = hasControlCommand ? (nativeCallbackCommandBody != null || !callbackActionEvent) && isInlineNativeCommandBody({ cfg, account, commandBody: normalizedCommandBody }) ? "native" : "text" : undefined;
40764
41023
  const allowTextCommands = core3.channel.commands.shouldHandleTextCommands({
40765
41024
  cfg,
40766
- surface: CHANNEL_ID
41025
+ surface: CHANNEL_ID,
41026
+ ...commandSource ? { commandSource } : {}
40767
41027
  });
40768
41028
  const useAccessGroups = cfg.commands?.useAccessGroups !== false;
40769
- const allowForCommands = isGroup ? effectiveGroupAllowFrom : effectiveAllowFrom;
41029
+ const allowForCommands = isGroup ? effectiveGroupCommandAllowFrom : effectiveAllowFrom;
40770
41030
  const senderAllowedForCommands = allowlistMatch({ allowFrom: allowForCommands, senderId });
40771
- const hasControlCommand = core3.channel.text.hasControlCommand(callbackCommandBody ?? rawBody, cfg, botUsername ? { botUsername } : undefined);
40772
41031
  const commandGate = resolveControlCommandGate({
40773
41032
  useAccessGroups,
40774
41033
  authorizers: [{ configured: allowForCommands.length > 0, allowed: senderAllowedForCommands }],
@@ -40979,7 +41238,7 @@ ${JSON.stringify(payload)}`;
40979
41238
  if (commandsPageCallback.page === "noop")
40980
41239
  return;
40981
41240
  const agentId = commandsPageCallback.agentId ?? route.agentId;
40982
- const paginated = buildCommandsMessagePaginated(cfg, listSkillCommandsForAgents({
41241
+ const paginated = buildCommandsMessagePaginated(cfg, listSkillCommandsForAgents2({
40983
41242
  cfg,
40984
41243
  agentIds: [agentId]
40985
41244
  }), {
@@ -41304,6 +41563,18 @@ This model will be used for your next message.`, []);
41304
41563
  Provider: CHANNEL_ID,
41305
41564
  Surface: effectiveSurface,
41306
41565
  MessageSid: messageSid,
41566
+ ...commandSource ? { CommandSource: commandSource } : {},
41567
+ CommandTurn: commandSource ? {
41568
+ kind: commandSource === "native" ? "native" : "text-slash",
41569
+ source: commandSource,
41570
+ authorized: commandAuthorized,
41571
+ body: normalizedCommandBody
41572
+ } : {
41573
+ kind: "normal",
41574
+ source: "message",
41575
+ authorized: false,
41576
+ body: normalizedCommandBody
41577
+ },
41307
41578
  ...replyThreadContext ? { MessageThreadId: String(replyThreadContext.childChatId) } : {},
41308
41579
  ...replyThreadContext?.threadLabel ? { ThreadLabel: replyThreadContext.threadLabel } : {},
41309
41580
  ...msg.replyToMsgId != null ? { ReplyToId: String(msg.replyToMsgId) } : {},
@@ -44550,5 +44821,5 @@ export {
44550
44821
  inlineChannelPlugin
44551
44822
  };
44552
44823
 
44553
- //# debugId=7BA9283EE42CF7D464756E2164756E21
44824
+ //# debugId=3F378342A86B5C1E64756E2164756E21
44554
44825
  //# sourceMappingURL=channel-plugin-api.js.map