nextclaw 0.15.6 → 0.15.7
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/cli/index.js +227 -126
- package/package.json +8 -8
- package/ui-dist/assets/{ChannelsList-DSMuOmMG.js → ChannelsList-DJ7ab8I2.js} +1 -1
- package/ui-dist/assets/{ChatPage-do9TwNxj.js → ChatPage-BLPRATYE.js} +19 -19
- package/ui-dist/assets/{DocBrowser-BjoTblYl.js → DocBrowser-CjN_yaEf.js} +1 -1
- package/ui-dist/assets/{LogoBadge-2yDaYdxw.js → LogoBadge-CkZsATHX.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-DVVk4dlH.js → MarketplacePage-BFhohJco.js} +1 -1
- package/ui-dist/assets/{McpMarketplacePage-B4WUzuLw.js → McpMarketplacePage-c8vjHO0A.js} +1 -1
- package/ui-dist/assets/{ModelConfig-Dr0eI9nN.js → ModelConfig-CSGq2NC4.js} +1 -1
- package/ui-dist/assets/{ProvidersList-C7A-mIbe.js → ProvidersList-DmBQ8OF-.js} +1 -1
- package/ui-dist/assets/{RemoteAccessPage-CI3Am3w1.js → RemoteAccessPage-NVr19yJR.js} +1 -1
- package/ui-dist/assets/{RuntimeConfig-DvSNVSs8.js → RuntimeConfig-CGETL6Yu.js} +1 -1
- package/ui-dist/assets/{SearchConfig-B6TGIZow.js → SearchConfig-DE3LnLxY.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-CpxaKU1j.js → SecretsConfig-D2FPk5Yu.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-B-VHnv4G.js → SessionsConfig-C_9hUwA8.js} +1 -1
- package/ui-dist/assets/{chat-message-BMqngrjp.js → chat-message-QHCI1bOU.js} +1 -1
- package/ui-dist/assets/index-B3MjcTn7.css +1 -0
- package/ui-dist/assets/{index-C6MeoecJ.js → index-BLzicsBO.js} +2 -2
- package/ui-dist/assets/{label-s2ILtQeP.js → label-X47yzn0H.js} +1 -1
- package/ui-dist/assets/{page-layout-BX5Ro4Sj.js → page-layout-x7tLtJ9c.js} +1 -1
- package/ui-dist/assets/{popover-qmNpQSIy.js → popover-DACrbH7x.js} +1 -1
- package/ui-dist/assets/{security-config--F-f-nDl.js → security-config-DxjEyIcP.js} +1 -1
- package/ui-dist/assets/{skeleton-DthPOKSc.js → skeleton-CXzreG6F.js} +1 -1
- package/ui-dist/assets/{status-dot-DWj7aUy8.js → status-dot-C1NZWCI_.js} +1 -1
- package/ui-dist/assets/{switch-62r7L4Lj.js → switch-DOrbztKw.js} +1 -1
- package/ui-dist/assets/{tabs-custom-DEmoGMsc.js → tabs-custom-Cd0VgGG5.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-DzT94nC_.js → useConfirmDialog-KRJdAz3v.js} +1 -1
- package/ui-dist/index.html +2 -2
- package/ui-dist/assets/index-DdXzLuNG.css +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -5547,7 +5547,7 @@ import {
|
|
|
5547
5547
|
ContextBuilder,
|
|
5548
5548
|
InputBudgetPruner,
|
|
5549
5549
|
getWorkspacePath as getWorkspacePath8,
|
|
5550
|
-
parseThinkingLevel,
|
|
5550
|
+
parseThinkingLevel as parseThinkingLevel2,
|
|
5551
5551
|
resolveThinkingLevel
|
|
5552
5552
|
} from "@nextclaw/core";
|
|
5553
5553
|
|
|
@@ -5727,30 +5727,6 @@ function buildLegacyUserContent(parts) {
|
|
|
5727
5727
|
}
|
|
5728
5728
|
return blocks;
|
|
5729
5729
|
}
|
|
5730
|
-
function extractAttachmentsFromNcpMessage(message) {
|
|
5731
|
-
if (!message) {
|
|
5732
|
-
return [];
|
|
5733
|
-
}
|
|
5734
|
-
const attachments = [];
|
|
5735
|
-
for (const part of message.parts) {
|
|
5736
|
-
if (!isRenderableImageFilePart(part)) {
|
|
5737
|
-
continue;
|
|
5738
|
-
}
|
|
5739
|
-
const imageUrl = resolveImageUrl(part);
|
|
5740
|
-
if (!imageUrl) {
|
|
5741
|
-
continue;
|
|
5742
|
-
}
|
|
5743
|
-
attachments.push({
|
|
5744
|
-
name: normalizeString(part.name) ?? void 0,
|
|
5745
|
-
url: imageUrl,
|
|
5746
|
-
mimeType: normalizeString(part.mimeType) ?? guessImageMime(normalizeString(part.url) ?? normalizeString(part.name)) ?? void 0,
|
|
5747
|
-
size: typeof part.sizeBytes === "number" ? part.sizeBytes : void 0,
|
|
5748
|
-
source: "ncp",
|
|
5749
|
-
status: "remote-only"
|
|
5750
|
-
});
|
|
5751
|
-
}
|
|
5752
|
-
return attachments;
|
|
5753
|
-
}
|
|
5754
5730
|
function toLegacyMessages(messages) {
|
|
5755
5731
|
const legacyMessages = [];
|
|
5756
5732
|
for (const rawMessage of messages) {
|
|
@@ -5812,6 +5788,172 @@ function toLegacyMessages(messages) {
|
|
|
5812
5788
|
return legacyMessages;
|
|
5813
5789
|
}
|
|
5814
5790
|
|
|
5791
|
+
// src/cli/commands/ncp/nextclaw-ncp-session-preferences.ts
|
|
5792
|
+
import { parseThinkingLevel } from "@nextclaw/core";
|
|
5793
|
+
function normalizeOptionalString5(value) {
|
|
5794
|
+
if (typeof value !== "string") {
|
|
5795
|
+
return void 0;
|
|
5796
|
+
}
|
|
5797
|
+
const trimmed = value.trim();
|
|
5798
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
5799
|
+
}
|
|
5800
|
+
function readMetadataModel(metadata) {
|
|
5801
|
+
const candidates = [metadata.model, metadata.llm_model, metadata.agent_model, metadata.session_model];
|
|
5802
|
+
for (const candidate of candidates) {
|
|
5803
|
+
const normalized = normalizeOptionalString5(candidate);
|
|
5804
|
+
if (normalized) {
|
|
5805
|
+
return normalized;
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
return null;
|
|
5809
|
+
}
|
|
5810
|
+
function readMetadataThinking(metadata) {
|
|
5811
|
+
const candidates = [
|
|
5812
|
+
metadata.thinking,
|
|
5813
|
+
metadata.thinking_level,
|
|
5814
|
+
metadata.thinkingLevel,
|
|
5815
|
+
metadata.thinking_effort,
|
|
5816
|
+
metadata.thinkingEffort
|
|
5817
|
+
];
|
|
5818
|
+
for (const candidate of candidates) {
|
|
5819
|
+
if (typeof candidate !== "string") {
|
|
5820
|
+
continue;
|
|
5821
|
+
}
|
|
5822
|
+
const normalized = candidate.trim().toLowerCase();
|
|
5823
|
+
if (!normalized) {
|
|
5824
|
+
continue;
|
|
5825
|
+
}
|
|
5826
|
+
if (normalized === "clear" || normalized === "reset" || normalized === "off!") {
|
|
5827
|
+
return "__clear__";
|
|
5828
|
+
}
|
|
5829
|
+
const level = parseThinkingLevel(normalized);
|
|
5830
|
+
if (level) {
|
|
5831
|
+
return level;
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
return null;
|
|
5835
|
+
}
|
|
5836
|
+
function resolveEffectiveModel(params) {
|
|
5837
|
+
const clearModel = params.requestMetadata.clear_model === true || params.requestMetadata.reset_model === true;
|
|
5838
|
+
if (clearModel) {
|
|
5839
|
+
delete params.session.metadata.preferred_model;
|
|
5840
|
+
}
|
|
5841
|
+
const inboundModel = readMetadataModel(params.requestMetadata);
|
|
5842
|
+
if (inboundModel) {
|
|
5843
|
+
params.session.metadata.preferred_model = inboundModel;
|
|
5844
|
+
}
|
|
5845
|
+
return normalizeOptionalString5(params.session.metadata.preferred_model) ?? params.fallbackModel;
|
|
5846
|
+
}
|
|
5847
|
+
function syncSessionThinkingPreference(params) {
|
|
5848
|
+
const clearThinking = params.requestMetadata.clear_thinking === true || params.requestMetadata.reset_thinking === true;
|
|
5849
|
+
if (clearThinking) {
|
|
5850
|
+
delete params.session.metadata.preferred_thinking;
|
|
5851
|
+
}
|
|
5852
|
+
const inboundThinking = readMetadataThinking(params.requestMetadata);
|
|
5853
|
+
if (inboundThinking === "__clear__") {
|
|
5854
|
+
delete params.session.metadata.preferred_thinking;
|
|
5855
|
+
return;
|
|
5856
|
+
}
|
|
5857
|
+
if (inboundThinking) {
|
|
5858
|
+
params.session.metadata.preferred_thinking = inboundThinking;
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5861
|
+
function resolveSessionChannelContext(params) {
|
|
5862
|
+
const channel = normalizeOptionalString5(params.requestMetadata.channel) ?? normalizeOptionalString5(params.session.metadata.last_channel) ?? "ui";
|
|
5863
|
+
const chatId = normalizeOptionalString5(params.requestMetadata.chatId) ?? normalizeOptionalString5(params.requestMetadata.chat_id) ?? normalizeOptionalString5(params.session.metadata.last_to) ?? "web-ui";
|
|
5864
|
+
params.session.metadata.last_channel = channel;
|
|
5865
|
+
params.session.metadata.last_to = chatId;
|
|
5866
|
+
return { channel, chatId };
|
|
5867
|
+
}
|
|
5868
|
+
|
|
5869
|
+
// src/cli/commands/ncp/nextclaw-ncp-current-turn.ts
|
|
5870
|
+
function isTextLikePart2(part) {
|
|
5871
|
+
return part.type === "text" || part.type === "rich-text";
|
|
5872
|
+
}
|
|
5873
|
+
function collectTextPartIndexes(parts) {
|
|
5874
|
+
return parts.map((part, index) => isTextLikePart2(part) ? index : -1).filter((index) => index >= 0);
|
|
5875
|
+
}
|
|
5876
|
+
function replaceTextPartsWithSingleFormattedText(parts, textPartIndexes, formattedText) {
|
|
5877
|
+
const nextParts = structuredClone(parts);
|
|
5878
|
+
const firstTextIndex = textPartIndexes[0];
|
|
5879
|
+
const firstTextPart = nextParts[firstTextIndex];
|
|
5880
|
+
if (firstTextPart && isTextLikePart2(firstTextPart)) {
|
|
5881
|
+
firstTextPart.text = formattedText;
|
|
5882
|
+
}
|
|
5883
|
+
return nextParts.filter((part, index) => {
|
|
5884
|
+
if (!isTextLikePart2(part)) {
|
|
5885
|
+
return true;
|
|
5886
|
+
}
|
|
5887
|
+
return index === firstTextIndex && part.text.length > 0;
|
|
5888
|
+
});
|
|
5889
|
+
}
|
|
5890
|
+
function wrapTextPartsWithFormattedEdges(params) {
|
|
5891
|
+
const nextParts = structuredClone(params.parts);
|
|
5892
|
+
const firstTextIndex = params.textPartIndexes[0];
|
|
5893
|
+
const lastTextIndex = params.textPartIndexes[params.textPartIndexes.length - 1];
|
|
5894
|
+
for (const index of params.textPartIndexes) {
|
|
5895
|
+
const part = nextParts[index];
|
|
5896
|
+
if (!part || !isTextLikePart2(part)) {
|
|
5897
|
+
continue;
|
|
5898
|
+
}
|
|
5899
|
+
if (index === firstTextIndex) {
|
|
5900
|
+
part.text = `${params.prefix}${part.text}`;
|
|
5901
|
+
}
|
|
5902
|
+
if (index === lastTextIndex) {
|
|
5903
|
+
part.text = `${part.text}${params.suffix}`;
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
return nextParts;
|
|
5907
|
+
}
|
|
5908
|
+
function buildFormattedCurrentParts(params) {
|
|
5909
|
+
const parts = params.message?.parts ?? [];
|
|
5910
|
+
if (parts.length === 0) {
|
|
5911
|
+
return params.formattedText.length > 0 ? [{ type: "text", text: params.formattedText }] : [];
|
|
5912
|
+
}
|
|
5913
|
+
const textPartIndexes = collectTextPartIndexes(parts);
|
|
5914
|
+
if (textPartIndexes.length === 0) {
|
|
5915
|
+
return params.formattedText.length > 0 ? [{ type: "text", text: params.formattedText }, ...structuredClone(parts)] : structuredClone(parts);
|
|
5916
|
+
}
|
|
5917
|
+
if (params.formattedText === params.originalText) {
|
|
5918
|
+
return structuredClone(parts);
|
|
5919
|
+
}
|
|
5920
|
+
const originalTextIndex = params.formattedText.indexOf(params.originalText);
|
|
5921
|
+
if (params.originalText.length === 0 || originalTextIndex < 0) {
|
|
5922
|
+
return replaceTextPartsWithSingleFormattedText(parts, textPartIndexes, params.formattedText);
|
|
5923
|
+
}
|
|
5924
|
+
return wrapTextPartsWithFormattedEdges({
|
|
5925
|
+
parts,
|
|
5926
|
+
textPartIndexes,
|
|
5927
|
+
prefix: params.formattedText.slice(0, originalTextIndex),
|
|
5928
|
+
suffix: params.formattedText.slice(originalTextIndex + params.originalText.length)
|
|
5929
|
+
});
|
|
5930
|
+
}
|
|
5931
|
+
function findLatestUserMessage(input) {
|
|
5932
|
+
return input.messages.slice().reverse().find((message) => message.role === "user") ?? input.messages[input.messages.length - 1];
|
|
5933
|
+
}
|
|
5934
|
+
function buildCurrentTurnState(params) {
|
|
5935
|
+
const latestUserMessage = findLatestUserMessage(params.input);
|
|
5936
|
+
const originalText = extractTextFromNcpMessage(latestUserMessage);
|
|
5937
|
+
const formattedText = params.formatPrompt({
|
|
5938
|
+
text: originalText,
|
|
5939
|
+
timestamp: new Date(
|
|
5940
|
+
ensureIsoTimestamp(
|
|
5941
|
+
latestUserMessage?.timestamp,
|
|
5942
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
5943
|
+
)
|
|
5944
|
+
)
|
|
5945
|
+
});
|
|
5946
|
+
const currentParts = buildFormattedCurrentParts({
|
|
5947
|
+
message: latestUserMessage,
|
|
5948
|
+
formattedText,
|
|
5949
|
+
originalText
|
|
5950
|
+
});
|
|
5951
|
+
return {
|
|
5952
|
+
currentUserContent: buildLegacyUserContent(currentParts),
|
|
5953
|
+
effectiveModel: params.currentModel
|
|
5954
|
+
};
|
|
5955
|
+
}
|
|
5956
|
+
|
|
5815
5957
|
// src/cli/commands/ncp/nextclaw-ncp-tool-registry.ts
|
|
5816
5958
|
import {
|
|
5817
5959
|
CronTool,
|
|
@@ -6104,48 +6246,6 @@ function resolveRequestedToolNames(metadata) {
|
|
|
6104
6246
|
)
|
|
6105
6247
|
);
|
|
6106
6248
|
}
|
|
6107
|
-
function normalizeOptionalString5(value) {
|
|
6108
|
-
return normalizeString(value) ?? void 0;
|
|
6109
|
-
}
|
|
6110
|
-
function findLatestUserMessage(input) {
|
|
6111
|
-
return input.messages.slice().reverse().find((message) => message.role === "user") ?? input.messages[input.messages.length - 1];
|
|
6112
|
-
}
|
|
6113
|
-
function readMetadataModel(metadata) {
|
|
6114
|
-
const candidates = [metadata.model, metadata.llm_model, metadata.agent_model, metadata.session_model];
|
|
6115
|
-
for (const candidate of candidates) {
|
|
6116
|
-
const normalized = normalizeString(candidate);
|
|
6117
|
-
if (normalized) {
|
|
6118
|
-
return normalized;
|
|
6119
|
-
}
|
|
6120
|
-
}
|
|
6121
|
-
return null;
|
|
6122
|
-
}
|
|
6123
|
-
function readMetadataThinking(metadata) {
|
|
6124
|
-
const candidates = [
|
|
6125
|
-
metadata.thinking,
|
|
6126
|
-
metadata.thinking_level,
|
|
6127
|
-
metadata.thinkingLevel,
|
|
6128
|
-
metadata.thinking_effort,
|
|
6129
|
-
metadata.thinkingEffort
|
|
6130
|
-
];
|
|
6131
|
-
for (const candidate of candidates) {
|
|
6132
|
-
if (typeof candidate !== "string") {
|
|
6133
|
-
continue;
|
|
6134
|
-
}
|
|
6135
|
-
const normalized = candidate.trim().toLowerCase();
|
|
6136
|
-
if (!normalized) {
|
|
6137
|
-
continue;
|
|
6138
|
-
}
|
|
6139
|
-
if (normalized === "clear" || normalized === "reset" || normalized === "off!") {
|
|
6140
|
-
return "__clear__";
|
|
6141
|
-
}
|
|
6142
|
-
const level = parseThinkingLevel(normalized);
|
|
6143
|
-
if (level) {
|
|
6144
|
-
return level;
|
|
6145
|
-
}
|
|
6146
|
-
}
|
|
6147
|
-
return null;
|
|
6148
|
-
}
|
|
6149
6249
|
function resolvePrimaryAgentProfile(config2) {
|
|
6150
6250
|
const configuredDefaultAgentId = config2.agents.list.find((entry) => entry.default)?.id?.trim() || config2.agents.list[0]?.id?.trim() || "main";
|
|
6151
6251
|
const profile = config2.agents.list.find((entry) => entry.id.trim() === configuredDefaultAgentId);
|
|
@@ -6209,6 +6309,19 @@ function filterTools(toolDefinitions, requestedToolNames) {
|
|
|
6209
6309
|
const filtered = toolDefinitions.filter((tool) => requested.has(tool.function.name));
|
|
6210
6310
|
return filtered.length > 0 ? filtered : void 0;
|
|
6211
6311
|
}
|
|
6312
|
+
function buildRequestedOpenAiTools(toolDefinitions, requestedToolNames) {
|
|
6313
|
+
return filterTools(
|
|
6314
|
+
toolDefinitions.map((tool) => ({
|
|
6315
|
+
type: "function",
|
|
6316
|
+
function: {
|
|
6317
|
+
name: tool.name,
|
|
6318
|
+
description: tool.description,
|
|
6319
|
+
parameters: tool.parameters
|
|
6320
|
+
}
|
|
6321
|
+
})),
|
|
6322
|
+
requestedToolNames
|
|
6323
|
+
);
|
|
6324
|
+
}
|
|
6212
6325
|
var NextclawNcpContextBuilder = class {
|
|
6213
6326
|
constructor(options) {
|
|
6214
6327
|
this.options = options;
|
|
@@ -6219,51 +6332,33 @@ var NextclawNcpContextBuilder = class {
|
|
|
6219
6332
|
const profile = resolvePrimaryAgentProfile(config2);
|
|
6220
6333
|
const requestMetadata = mergeInputMetadata(input);
|
|
6221
6334
|
const session = this.options.sessionManager.getOrCreate(input.sessionId);
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6335
|
+
let effectiveModel = resolveEffectiveModel({
|
|
6336
|
+
session,
|
|
6337
|
+
requestMetadata,
|
|
6338
|
+
fallbackModel: profile.model
|
|
6339
|
+
});
|
|
6340
|
+
syncSessionThinkingPreference({ session, requestMetadata });
|
|
6341
|
+
const { channel, chatId } = resolveSessionChannelContext({
|
|
6342
|
+
session,
|
|
6343
|
+
requestMetadata
|
|
6344
|
+
});
|
|
6345
|
+
const requestedSkillNames = resolveRequestedSkillNames(requestMetadata);
|
|
6346
|
+
const requestedToolNames = resolveRequestedToolNames(requestMetadata);
|
|
6347
|
+
const currentTurn = buildCurrentTurnState({
|
|
6348
|
+
input,
|
|
6349
|
+
currentModel: effectiveModel,
|
|
6350
|
+
formatPrompt: ({ text, timestamp }) => appendTimeHintForPrompt(
|
|
6351
|
+
prependRequestedSkills(text, requestedSkillNames),
|
|
6352
|
+
timestamp
|
|
6353
|
+
)
|
|
6354
|
+
});
|
|
6355
|
+
effectiveModel = currentTurn.effectiveModel;
|
|
6241
6356
|
const runtimeThinking = resolveThinkingLevel({
|
|
6242
6357
|
config: config2,
|
|
6243
6358
|
agentId: profile.agentId,
|
|
6244
6359
|
model: effectiveModel,
|
|
6245
|
-
sessionThinkingLevel:
|
|
6360
|
+
sessionThinkingLevel: parseThinkingLevel2(session.metadata.preferred_thinking) ?? null
|
|
6246
6361
|
});
|
|
6247
|
-
const channel = normalizeOptionalString5(requestMetadata.channel) ?? normalizeOptionalString5(session.metadata.last_channel) ?? "ui";
|
|
6248
|
-
const chatId = normalizeOptionalString5(requestMetadata.chatId) ?? normalizeOptionalString5(requestMetadata.chat_id) ?? normalizeOptionalString5(session.metadata.last_to) ?? "web-ui";
|
|
6249
|
-
session.metadata.last_channel = channel;
|
|
6250
|
-
session.metadata.last_to = chatId;
|
|
6251
|
-
const requestedSkillNames = resolveRequestedSkillNames(requestMetadata);
|
|
6252
|
-
const requestedToolNames = resolveRequestedToolNames(requestMetadata);
|
|
6253
|
-
const latestUserMessage = findLatestUserMessage(input);
|
|
6254
|
-
const currentMessage = appendTimeHintForPrompt(
|
|
6255
|
-
prependRequestedSkills(
|
|
6256
|
-
extractTextFromNcpMessage(latestUserMessage),
|
|
6257
|
-
requestedSkillNames
|
|
6258
|
-
),
|
|
6259
|
-
new Date(
|
|
6260
|
-
ensureIsoTimestamp(
|
|
6261
|
-
latestUserMessage?.timestamp,
|
|
6262
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
6263
|
-
)
|
|
6264
|
-
)
|
|
6265
|
-
);
|
|
6266
|
-
const currentAttachments = extractAttachmentsFromNcpMessage(latestUserMessage);
|
|
6267
6362
|
this.options.toolRegistry.prepareForRun({
|
|
6268
6363
|
sessionId: input.sessionId,
|
|
6269
6364
|
channel,
|
|
@@ -6292,8 +6387,8 @@ var NextclawNcpContextBuilder = class {
|
|
|
6292
6387
|
const sessionMessages = _options?.sessionMessages ?? [];
|
|
6293
6388
|
const messages = contextBuilder.buildMessages({
|
|
6294
6389
|
history: toLegacyMessages([...sessionMessages]),
|
|
6295
|
-
currentMessage,
|
|
6296
|
-
attachments:
|
|
6390
|
+
currentMessage: "",
|
|
6391
|
+
attachments: [],
|
|
6297
6392
|
channel,
|
|
6298
6393
|
chatId,
|
|
6299
6394
|
sessionKey: input.sessionId,
|
|
@@ -6302,21 +6397,17 @@ var NextclawNcpContextBuilder = class {
|
|
|
6302
6397
|
messageToolHints,
|
|
6303
6398
|
availableTools: buildToolCatalogEntries(toolDefinitions)
|
|
6304
6399
|
});
|
|
6400
|
+
messages[messages.length - 1] = {
|
|
6401
|
+
role: "user",
|
|
6402
|
+
content: currentTurn.currentUserContent
|
|
6403
|
+
};
|
|
6305
6404
|
const pruned = this.inputBudgetPruner.prune({
|
|
6306
6405
|
messages,
|
|
6307
6406
|
contextTokens: profile.contextTokens
|
|
6308
6407
|
});
|
|
6309
|
-
const openAiToolDefinitions = toolDefinitions.map((tool) => ({
|
|
6310
|
-
type: "function",
|
|
6311
|
-
function: {
|
|
6312
|
-
name: tool.name,
|
|
6313
|
-
description: tool.description,
|
|
6314
|
-
parameters: tool.parameters
|
|
6315
|
-
}
|
|
6316
|
-
}));
|
|
6317
6408
|
return {
|
|
6318
6409
|
messages: pruned.messages,
|
|
6319
|
-
tools:
|
|
6410
|
+
tools: buildRequestedOpenAiTools(toolDefinitions, requestedToolNames),
|
|
6320
6411
|
model: effectiveModel,
|
|
6321
6412
|
thinkingLevel: runtimeThinking
|
|
6322
6413
|
};
|
|
@@ -6632,7 +6723,7 @@ var NextclawAgentSessionStore = class {
|
|
|
6632
6723
|
};
|
|
6633
6724
|
|
|
6634
6725
|
// src/cli/commands/ncp/provider-manager-ncp-llm-api.ts
|
|
6635
|
-
import { parseThinkingLevel as
|
|
6726
|
+
import { parseThinkingLevel as parseThinkingLevel3 } from "@nextclaw/core";
|
|
6636
6727
|
function normalizeModel(value) {
|
|
6637
6728
|
if (typeof value !== "string") {
|
|
6638
6729
|
return null;
|
|
@@ -6641,7 +6732,7 @@ function normalizeModel(value) {
|
|
|
6641
6732
|
return trimmed.length > 0 ? trimmed : null;
|
|
6642
6733
|
}
|
|
6643
6734
|
function normalizeThinkingLevel(value) {
|
|
6644
|
-
return
|
|
6735
|
+
return parseThinkingLevel3(value);
|
|
6645
6736
|
}
|
|
6646
6737
|
function normalizeFinishReason(value) {
|
|
6647
6738
|
if (typeof value !== "string") {
|
|
@@ -6881,17 +6972,27 @@ async function createMcpRuntimeSupport(getConfig) {
|
|
|
6881
6972
|
getConfig: () => currentMcpConfig,
|
|
6882
6973
|
lifecycleManager: mcpLifecycleManager
|
|
6883
6974
|
});
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6975
|
+
let currentWarmPromise = Promise.resolve();
|
|
6976
|
+
const startBackgroundWarm = () => {
|
|
6977
|
+
currentWarmPromise = mcpRegistryService.prewarmEnabledServers().then((mcpPrewarmResults) => {
|
|
6978
|
+
for (const result of mcpPrewarmResults) {
|
|
6979
|
+
if (!result.ok) {
|
|
6980
|
+
console.warn(`[mcp] Failed to warm ${result.name}: ${result.error}`);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
}).catch((error) => {
|
|
6984
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6985
|
+
console.warn(`[mcp] Failed to prewarm enabled MCP servers: ${message}`);
|
|
6986
|
+
});
|
|
6987
|
+
return currentWarmPromise;
|
|
6988
|
+
};
|
|
6989
|
+
void startBackgroundWarm();
|
|
6890
6990
|
return {
|
|
6891
6991
|
toolRegistryAdapter: new McpNcpToolRegistryAdapter(mcpRegistryService),
|
|
6892
6992
|
applyMcpConfig: async (config2) => {
|
|
6893
6993
|
const previousConfig = currentMcpConfig;
|
|
6894
6994
|
currentMcpConfig = config2;
|
|
6995
|
+
await currentWarmPromise.catch(() => void 0);
|
|
6895
6996
|
const reconcileResult = await mcpRegistryService.reconcileConfig({
|
|
6896
6997
|
prevConfig: previousConfig,
|
|
6897
6998
|
nextConfig: config2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.7",
|
|
4
4
|
"description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"commander": "^12.1.0",
|
|
41
41
|
"yaml": "^2.8.1",
|
|
42
42
|
"@nextclaw/core": "0.11.0",
|
|
43
|
-
"@nextclaw/mcp": "0.1.44",
|
|
44
43
|
"@nextclaw/ncp": "0.3.2",
|
|
45
|
-
"@nextclaw/ncp-mcp": "0.1.
|
|
46
|
-
"@nextclaw/
|
|
44
|
+
"@nextclaw/ncp-mcp": "0.1.44",
|
|
45
|
+
"@nextclaw/mcp": "0.1.45",
|
|
47
46
|
"@nextclaw/ncp-toolkit": "0.4.2",
|
|
48
|
-
"@nextclaw/
|
|
47
|
+
"@nextclaw/remote": "0.1.43",
|
|
49
48
|
"@nextclaw/runtime": "0.2.14",
|
|
50
|
-
"@nextclaw/server": "0.10.
|
|
51
|
-
"@nextclaw/openclaw-compat": "0.3.26"
|
|
49
|
+
"@nextclaw/server": "0.10.49",
|
|
50
|
+
"@nextclaw/openclaw-compat": "0.3.26",
|
|
51
|
+
"@nextclaw/ncp-agent-runtime": "0.2.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^20.17.6",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"tsx": "^4.19.2",
|
|
58
58
|
"typescript": "^5.6.3",
|
|
59
59
|
"vitest": "^2.1.2",
|
|
60
|
-
"@nextclaw/ui": "0.10.
|
|
60
|
+
"@nextclaw/ui": "0.10.3"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"dev": "tsx watch --tsconfig tsconfig.json src/cli/index.ts",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as L,j as u,X as It,K as Pt,aq as Bt,b1 as Tt,b2 as Mt,b3 as Rt,a0 as Lt,g as ut,f as kt,b4 as Me,ae as Re,b5 as Dt,ai as dt,e as q,a3 as Ft,i as Ut,G as qt,H as _t}from"./vendor-CNhxtHCf.js";import{a0 as zt,t as c,c as K,I as Q,S as Ot,e as Ht,f as Kt,g as Jt,h as Vt,a2 as ft,B as je,n as Gt,u as gt,a as ht,b as mt,a3 as Yt,a4 as Qt}from"./index-C6MeoecJ.js";import{S as pt}from"./status-dot-DWj7aUy8.js";import{L as yt}from"./LogoBadge-2yDaYdxw.js";import{h as Se}from"./config-hints-CApS3K_7.js";import{c as Wt,b as Xt,a as Zt,C as $t}from"./config-layout-BHnOoweL.js";import{L as en}from"./label-s2ILtQeP.js";import{S as tn}from"./switch-62r7L4Lj.js";import{T as nn}from"./tabs-custom-DEmoGMsc.js";import{P as rn,a as sn}from"./page-layout-BX5Ro4Sj.js";function bt(e){var n,t;const s=zt();return((n=e.tutorialUrls)==null?void 0:n[s])||((t=e.tutorialUrls)==null?void 0:t.default)||e.tutorialUrl}const an={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",weixin:"weixin.svg",mochat:"mochat.svg",email:"email.svg"};function on(e,s){const a=s.toLowerCase(),n=e[a];return n?`/logos/${n}`:null}function wt(e){return on(an,e)}function ln({value:e,onChange:s,className:a,placeholder:n=""}){const[t,r]=L.useState(""),i=l=>{l.key==="Enter"&&t.trim()?(l.preventDefault(),s([...e,t.trim()]),r("")):l.key==="Backspace"&&!t&&e.length>0&&s(e.slice(0,-1))},o=l=>{s(e.filter((d,h)=>h!==l))};return u.jsxs("div",{className:K("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",a),children:[e.map((l,d)=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[l,u.jsx("button",{type:"button",onClick:()=>o(d),className:"hover:text-red-300 transition-colors",children:u.jsx(It,{className:"h-3 w-3"})})]},d)),u.jsx("input",{type:"text",value:t,onChange:l=>r(l.target.value),onKeyDown:i,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:n||c("enterTag")})]})}function cn(e){return e.includes("token")||e.includes("secret")||e.includes("password")?u.jsx(Pt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("url")||e.includes("host")?u.jsx(Bt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("email")||e.includes("mail")?u.jsx(Tt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("id")||e.includes("from")?u.jsx(Mt,{className:"h-3.5 w-3.5 text-gray-500"}):e==="enabled"||e==="consentGranted"?u.jsx(Rt,{className:"h-3.5 w-3.5 text-gray-500"}):u.jsx(Lt,{className:"h-3.5 w-3.5 text-gray-500"})}function Le({channelName:e,fields:s,formData:a,jsonDrafts:n,setJsonDrafts:t,updateField:r,uiHints:i}){return u.jsx(u.Fragment,{children:s.map(o=>{const l=Se(`channels.${e}.${o.name}`,i),d=(l==null?void 0:l.label)??o.label,h=l==null?void 0:l.placeholder;return u.jsxs("div",{className:"space-y-2.5",children:[u.jsxs(en,{htmlFor:o.name,className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[cn(o.name),d]}),o.type==="boolean"&&u.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-gray-50 p-3",children:[u.jsx("span",{className:"text-sm text-gray-500",children:a[o.name]?c("enabled"):c("disabled")}),u.jsx(tn,{id:o.name,checked:a[o.name]||!1,onCheckedChange:f=>r(o.name,f),className:"data-[state=checked]:bg-emerald-500"})]}),(o.type==="text"||o.type==="email")&&u.jsx(Q,{id:o.name,type:o.type,value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h,className:"rounded-xl"}),o.type==="password"&&u.jsx(Q,{id:o.name,type:"password",value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h??c("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),o.type==="number"&&u.jsx(Q,{id:o.name,type:"number",value:a[o.name]||0,onChange:f=>r(o.name,parseInt(f.target.value,10)||0),placeholder:h,className:"rounded-xl"}),o.type==="tags"&&u.jsx(ln,{value:a[o.name]||[],onChange:f=>r(o.name,f)}),o.type==="select"&&u.jsxs(Ot,{value:a[o.name]||"",onValueChange:f=>r(o.name,f),children:[u.jsx(Ht,{className:"rounded-xl",children:u.jsx(Kt,{})}),u.jsx(Jt,{children:(o.options??[]).map(f=>u.jsx(Vt,{value:f.value,children:f.label},f.value))})]}),o.type==="json"&&u.jsx("textarea",{id:o.name,value:n[o.name]??"{}",onChange:f=>t(x=>({...x,[o.name]:f.target.value})),className:"min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},o.name)})})}const te=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],ne=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],un=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}];function ke(){return{telegram:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"proxy",type:"text",label:c("proxy")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"gatewayUrl",type:"text",label:c("gatewayUrl")},{name:"intents",type:"number",label:c("intents")},{name:"proxy",type:"text",label:c("proxy")},{name:"mediaMaxMb",type:"number",label:c("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:c("streamingMode"),options:un},{name:"draftChunk",type:"json",label:c("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:c("textChunkLimit")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"bridgeUrl",type:"text",label:c("bridgeUrl")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"appSecret",type:"password",label:c("appSecret")},{name:"encryptKey",type:"password",label:c("encryptKey")},{name:"verificationToken",type:"password",label:c("verificationToken")},{name:"domain",type:"text",label:"Domain"},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")},{name:"accounts",type:"json",label:c("accountsJson")}],dingtalk:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"clientId",type:"text",label:c("clientId")},{name:"clientSecret",type:"password",label:c("clientSecret")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"corpId",type:"text",label:c("corpId")},{name:"agentId",type:"text",label:c("agentId")},{name:"secret",type:"password",label:c("secret")},{name:"token",type:"password",label:c("token")},{name:"callbackPort",type:"number",label:c("callbackPort")},{name:"callbackPath",type:"text",label:c("callbackPath")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],weixin:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"defaultAccountId",type:"text",label:c("defaultAccountId")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"pollTimeoutMs",type:"number",label:c("pollTimeoutMs")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"accounts",type:"json",label:c("accountsJson")}],slack:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"mode",type:"text",label:c("mode")},{name:"webhookPath",type:"text",label:c("webhookPath")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"botToken",type:"password",label:c("botToken")},{name:"appToken",type:"password",label:c("appToken")}],email:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"consentGranted",type:"boolean",label:c("consentGranted")},{name:"imapHost",type:"text",label:c("imapHost")},{name:"imapPort",type:"number",label:c("imapPort")},{name:"imapUsername",type:"text",label:c("imapUsername")},{name:"imapPassword",type:"password",label:c("imapPassword")},{name:"fromAddress",type:"email",label:c("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"clawToken",type:"password",label:c("clawToken")},{name:"agentUserId",type:"text",label:c("agentUserId")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"secret",type:"password",label:c("appSecret")},{name:"markdownSupport",type:"boolean",label:c("markdownSupport")},{name:"allowFrom",type:"tags",label:c("allowFrom")}]}}var H={},re,De;function dn(){return De||(De=1,re=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),re}var se={},U={},Fe;function _(){if(Fe)return U;Fe=1;let e;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return U.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},U.getSymbolTotalCodewords=function(n){return s[n]},U.getBCHDigit=function(a){let n=0;for(;a!==0;)n++,a>>>=1;return n},U.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');e=n},U.isKanjiModeEnabled=function(){return typeof e<"u"},U.toSJIS=function(n){return e(n)},U}var ae={},Ue;function Ie(){return Ue||(Ue=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function s(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+a)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,t){if(e.isValid(n))return n;try{return s(n)}catch{return t}}})(ae)),ae}var oe,qe;function fn(){if(qe)return oe;qe=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(s){const a=Math.floor(s/8);return(this.buffer[a]>>>7-s%8&1)===1},put:function(s,a){for(let n=0;n<a;n++)this.putBit((s>>>a-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),s&&(this.buffer[a]|=128>>>this.length%8),this.length++}},oe=e,oe}var ie,_e;function gn(){if(_e)return ie;_e=1;function e(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return e.prototype.set=function(s,a,n,t){const r=s*this.size+a;this.data[r]=n,t&&(this.reservedBit[r]=!0)},e.prototype.get=function(s,a){return this.data[s*this.size+a]},e.prototype.xor=function(s,a,n){this.data[s*this.size+a]^=n},e.prototype.isReserved=function(s,a){return this.reservedBit[s*this.size+a]},ie=e,ie}var le={},ze;function hn(){return ze||(ze=1,(function(e){const s=_().getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const t=Math.floor(n/7)+2,r=s(n),i=r===145?26:Math.ceil((r-13)/(2*t-2))*2,o=[r-7];for(let l=1;l<t-1;l++)o[l]=o[l-1]-i;return o.push(6),o.reverse()},e.getPositions=function(n){const t=[],r=e.getRowColCoords(n),i=r.length;for(let o=0;o<i;o++)for(let l=0;l<i;l++)o===0&&l===0||o===0&&l===i-1||o===i-1&&l===0||t.push([r[o],r[l]]);return t}})(le)),le}var ce={},Oe;function mn(){if(Oe)return ce;Oe=1;const e=_().getSymbolSize,s=7;return ce.getPositions=function(n){const t=e(n);return[[0,0],[t-s,0],[0,t-s]]},ce}var ue={},He;function pn(){return He||(He=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};e.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(t){const r=t.size;let i=0,o=0,l=0,d=null,h=null;for(let f=0;f<r;f++){o=l=0,d=h=null;for(let x=0;x<r;x++){let g=t.get(f,x);g===d?o++:(o>=5&&(i+=s.N1+(o-5)),d=g,o=1),g=t.get(x,f),g===h?l++:(l>=5&&(i+=s.N1+(l-5)),h=g,l=1)}o>=5&&(i+=s.N1+(o-5)),l>=5&&(i+=s.N1+(l-5))}return i},e.getPenaltyN2=function(t){const r=t.size;let i=0;for(let o=0;o<r-1;o++)for(let l=0;l<r-1;l++){const d=t.get(o,l)+t.get(o,l+1)+t.get(o+1,l)+t.get(o+1,l+1);(d===4||d===0)&&i++}return i*s.N2},e.getPenaltyN3=function(t){const r=t.size;let i=0,o=0,l=0;for(let d=0;d<r;d++){o=l=0;for(let h=0;h<r;h++)o=o<<1&2047|t.get(d,h),h>=10&&(o===1488||o===93)&&i++,l=l<<1&2047|t.get(h,d),h>=10&&(l===1488||l===93)&&i++}return i*s.N3},e.getPenaltyN4=function(t){let r=0;const i=t.data.length;for(let l=0;l<i;l++)r+=t.data[l];return Math.abs(Math.ceil(r*100/i/5)-10)*s.N4};function a(n,t,r){switch(n){case e.Patterns.PATTERN000:return(t+r)%2===0;case e.Patterns.PATTERN001:return t%2===0;case e.Patterns.PATTERN010:return r%3===0;case e.Patterns.PATTERN011:return(t+r)%3===0;case e.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2===0;case e.Patterns.PATTERN101:return t*r%2+t*r%3===0;case e.Patterns.PATTERN110:return(t*r%2+t*r%3)%2===0;case e.Patterns.PATTERN111:return(t*r%3+(t+r)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(t,r){const i=r.size;for(let o=0;o<i;o++)for(let l=0;l<i;l++)r.isReserved(l,o)||r.xor(l,o,a(t,l,o))},e.getBestMask=function(t,r){const i=Object.keys(e.Patterns).length;let o=0,l=1/0;for(let d=0;d<i;d++){r(d),e.applyMask(d,t);const h=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(d,t),h<l&&(l=h,o=d)}return o}})(ue)),ue}var Y={},Ke;function xt(){if(Ke)return Y;Ke=1;const e=Ie(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],a=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Y.getBlocksCount=function(t,r){switch(r){case e.L:return s[(t-1)*4+0];case e.M:return s[(t-1)*4+1];case e.Q:return s[(t-1)*4+2];case e.H:return s[(t-1)*4+3];default:return}},Y.getTotalCodewordsCount=function(t,r){switch(r){case e.L:return a[(t-1)*4+0];case e.M:return a[(t-1)*4+1];case e.Q:return a[(t-1)*4+2];case e.H:return a[(t-1)*4+3];default:return}},Y}var de={},V={},Je;function yn(){if(Je)return V;Je=1;const e=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let t=0;t<255;t++)e[t]=n,s[n]=t,n<<=1,n&256&&(n^=285);for(let t=255;t<512;t++)e[t]=e[t-255]})(),V.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},V.exp=function(n){return e[n]},V.mul=function(n,t){return n===0||t===0?0:e[s[n]+s[t]]},V}var Ve;function bn(){return Ve||(Ve=1,(function(e){const s=yn();e.mul=function(n,t){const r=new Uint8Array(n.length+t.length-1);for(let i=0;i<n.length;i++)for(let o=0;o<t.length;o++)r[i+o]^=s.mul(n[i],t[o]);return r},e.mod=function(n,t){let r=new Uint8Array(n);for(;r.length-t.length>=0;){const i=r[0];for(let l=0;l<t.length;l++)r[l]^=s.mul(t[l],i);let o=0;for(;o<r.length&&r[o]===0;)o++;r=r.slice(o)}return r},e.generateECPolynomial=function(n){let t=new Uint8Array([1]);for(let r=0;r<n;r++)t=e.mul(t,new Uint8Array([1,s.exp(r)]));return t}})(de)),de}var fe,Ge;function wn(){if(Ge)return fe;Ge=1;const e=bn();function s(a){this.genPoly=void 0,this.degree=a,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=e.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(n.length+this.degree);t.set(n);const r=e.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r},fe=s,fe}var ge={},he={},me={},Ye;function Ct(){return Ye||(Ye=1,me.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),me}var k={},Qe;function At(){if(Qe)return k;Qe=1;const e="[0-9]+",s="[A-Z $%*+\\-./:]+";let a="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";a=a.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+a+`)(?:.|[\r
|
|
1
|
+
import{r as L,j as u,X as It,K as Pt,aq as Bt,b1 as Tt,b2 as Mt,b3 as Rt,a0 as Lt,g as ut,f as kt,b4 as Me,ae as Re,b5 as Dt,ai as dt,e as q,a3 as Ft,i as Ut,G as qt,H as _t}from"./vendor-CNhxtHCf.js";import{a0 as zt,t as c,c as K,I as Q,S as Ot,e as Ht,f as Kt,g as Jt,h as Vt,a2 as ft,B as je,n as Gt,u as gt,a as ht,b as mt,a3 as Yt,a4 as Qt}from"./index-BLzicsBO.js";import{S as pt}from"./status-dot-C1NZWCI_.js";import{L as yt}from"./LogoBadge-CkZsATHX.js";import{h as Se}from"./config-hints-CApS3K_7.js";import{c as Wt,b as Xt,a as Zt,C as $t}from"./config-layout-BHnOoweL.js";import{L as en}from"./label-X47yzn0H.js";import{S as tn}from"./switch-DOrbztKw.js";import{T as nn}from"./tabs-custom-Cd0VgGG5.js";import{P as rn,a as sn}from"./page-layout-x7tLtJ9c.js";function bt(e){var n,t;const s=zt();return((n=e.tutorialUrls)==null?void 0:n[s])||((t=e.tutorialUrls)==null?void 0:t.default)||e.tutorialUrl}const an={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",weixin:"weixin.svg",mochat:"mochat.svg",email:"email.svg"};function on(e,s){const a=s.toLowerCase(),n=e[a];return n?`/logos/${n}`:null}function wt(e){return on(an,e)}function ln({value:e,onChange:s,className:a,placeholder:n=""}){const[t,r]=L.useState(""),i=l=>{l.key==="Enter"&&t.trim()?(l.preventDefault(),s([...e,t.trim()]),r("")):l.key==="Backspace"&&!t&&e.length>0&&s(e.slice(0,-1))},o=l=>{s(e.filter((d,h)=>h!==l))};return u.jsxs("div",{className:K("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",a),children:[e.map((l,d)=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[l,u.jsx("button",{type:"button",onClick:()=>o(d),className:"hover:text-red-300 transition-colors",children:u.jsx(It,{className:"h-3 w-3"})})]},d)),u.jsx("input",{type:"text",value:t,onChange:l=>r(l.target.value),onKeyDown:i,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:n||c("enterTag")})]})}function cn(e){return e.includes("token")||e.includes("secret")||e.includes("password")?u.jsx(Pt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("url")||e.includes("host")?u.jsx(Bt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("email")||e.includes("mail")?u.jsx(Tt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("id")||e.includes("from")?u.jsx(Mt,{className:"h-3.5 w-3.5 text-gray-500"}):e==="enabled"||e==="consentGranted"?u.jsx(Rt,{className:"h-3.5 w-3.5 text-gray-500"}):u.jsx(Lt,{className:"h-3.5 w-3.5 text-gray-500"})}function Le({channelName:e,fields:s,formData:a,jsonDrafts:n,setJsonDrafts:t,updateField:r,uiHints:i}){return u.jsx(u.Fragment,{children:s.map(o=>{const l=Se(`channels.${e}.${o.name}`,i),d=(l==null?void 0:l.label)??o.label,h=l==null?void 0:l.placeholder;return u.jsxs("div",{className:"space-y-2.5",children:[u.jsxs(en,{htmlFor:o.name,className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[cn(o.name),d]}),o.type==="boolean"&&u.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-gray-50 p-3",children:[u.jsx("span",{className:"text-sm text-gray-500",children:a[o.name]?c("enabled"):c("disabled")}),u.jsx(tn,{id:o.name,checked:a[o.name]||!1,onCheckedChange:f=>r(o.name,f),className:"data-[state=checked]:bg-emerald-500"})]}),(o.type==="text"||o.type==="email")&&u.jsx(Q,{id:o.name,type:o.type,value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h,className:"rounded-xl"}),o.type==="password"&&u.jsx(Q,{id:o.name,type:"password",value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h??c("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),o.type==="number"&&u.jsx(Q,{id:o.name,type:"number",value:a[o.name]||0,onChange:f=>r(o.name,parseInt(f.target.value,10)||0),placeholder:h,className:"rounded-xl"}),o.type==="tags"&&u.jsx(ln,{value:a[o.name]||[],onChange:f=>r(o.name,f)}),o.type==="select"&&u.jsxs(Ot,{value:a[o.name]||"",onValueChange:f=>r(o.name,f),children:[u.jsx(Ht,{className:"rounded-xl",children:u.jsx(Kt,{})}),u.jsx(Jt,{children:(o.options??[]).map(f=>u.jsx(Vt,{value:f.value,children:f.label},f.value))})]}),o.type==="json"&&u.jsx("textarea",{id:o.name,value:n[o.name]??"{}",onChange:f=>t(x=>({...x,[o.name]:f.target.value})),className:"min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},o.name)})})}const te=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],ne=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],un=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}];function ke(){return{telegram:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"proxy",type:"text",label:c("proxy")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"gatewayUrl",type:"text",label:c("gatewayUrl")},{name:"intents",type:"number",label:c("intents")},{name:"proxy",type:"text",label:c("proxy")},{name:"mediaMaxMb",type:"number",label:c("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:c("streamingMode"),options:un},{name:"draftChunk",type:"json",label:c("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:c("textChunkLimit")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"bridgeUrl",type:"text",label:c("bridgeUrl")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"appSecret",type:"password",label:c("appSecret")},{name:"encryptKey",type:"password",label:c("encryptKey")},{name:"verificationToken",type:"password",label:c("verificationToken")},{name:"domain",type:"text",label:"Domain"},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")},{name:"accounts",type:"json",label:c("accountsJson")}],dingtalk:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"clientId",type:"text",label:c("clientId")},{name:"clientSecret",type:"password",label:c("clientSecret")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"corpId",type:"text",label:c("corpId")},{name:"agentId",type:"text",label:c("agentId")},{name:"secret",type:"password",label:c("secret")},{name:"token",type:"password",label:c("token")},{name:"callbackPort",type:"number",label:c("callbackPort")},{name:"callbackPath",type:"text",label:c("callbackPath")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],weixin:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"defaultAccountId",type:"text",label:c("defaultAccountId")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"pollTimeoutMs",type:"number",label:c("pollTimeoutMs")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"accounts",type:"json",label:c("accountsJson")}],slack:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"mode",type:"text",label:c("mode")},{name:"webhookPath",type:"text",label:c("webhookPath")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"botToken",type:"password",label:c("botToken")},{name:"appToken",type:"password",label:c("appToken")}],email:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"consentGranted",type:"boolean",label:c("consentGranted")},{name:"imapHost",type:"text",label:c("imapHost")},{name:"imapPort",type:"number",label:c("imapPort")},{name:"imapUsername",type:"text",label:c("imapUsername")},{name:"imapPassword",type:"password",label:c("imapPassword")},{name:"fromAddress",type:"email",label:c("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"clawToken",type:"password",label:c("clawToken")},{name:"agentUserId",type:"text",label:c("agentUserId")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"secret",type:"password",label:c("appSecret")},{name:"markdownSupport",type:"boolean",label:c("markdownSupport")},{name:"allowFrom",type:"tags",label:c("allowFrom")}]}}var H={},re,De;function dn(){return De||(De=1,re=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),re}var se={},U={},Fe;function _(){if(Fe)return U;Fe=1;let e;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return U.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},U.getSymbolTotalCodewords=function(n){return s[n]},U.getBCHDigit=function(a){let n=0;for(;a!==0;)n++,a>>>=1;return n},U.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');e=n},U.isKanjiModeEnabled=function(){return typeof e<"u"},U.toSJIS=function(n){return e(n)},U}var ae={},Ue;function Ie(){return Ue||(Ue=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function s(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+a)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,t){if(e.isValid(n))return n;try{return s(n)}catch{return t}}})(ae)),ae}var oe,qe;function fn(){if(qe)return oe;qe=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(s){const a=Math.floor(s/8);return(this.buffer[a]>>>7-s%8&1)===1},put:function(s,a){for(let n=0;n<a;n++)this.putBit((s>>>a-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),s&&(this.buffer[a]|=128>>>this.length%8),this.length++}},oe=e,oe}var ie,_e;function gn(){if(_e)return ie;_e=1;function e(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return e.prototype.set=function(s,a,n,t){const r=s*this.size+a;this.data[r]=n,t&&(this.reservedBit[r]=!0)},e.prototype.get=function(s,a){return this.data[s*this.size+a]},e.prototype.xor=function(s,a,n){this.data[s*this.size+a]^=n},e.prototype.isReserved=function(s,a){return this.reservedBit[s*this.size+a]},ie=e,ie}var le={},ze;function hn(){return ze||(ze=1,(function(e){const s=_().getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const t=Math.floor(n/7)+2,r=s(n),i=r===145?26:Math.ceil((r-13)/(2*t-2))*2,o=[r-7];for(let l=1;l<t-1;l++)o[l]=o[l-1]-i;return o.push(6),o.reverse()},e.getPositions=function(n){const t=[],r=e.getRowColCoords(n),i=r.length;for(let o=0;o<i;o++)for(let l=0;l<i;l++)o===0&&l===0||o===0&&l===i-1||o===i-1&&l===0||t.push([r[o],r[l]]);return t}})(le)),le}var ce={},Oe;function mn(){if(Oe)return ce;Oe=1;const e=_().getSymbolSize,s=7;return ce.getPositions=function(n){const t=e(n);return[[0,0],[t-s,0],[0,t-s]]},ce}var ue={},He;function pn(){return He||(He=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};e.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(t){const r=t.size;let i=0,o=0,l=0,d=null,h=null;for(let f=0;f<r;f++){o=l=0,d=h=null;for(let x=0;x<r;x++){let g=t.get(f,x);g===d?o++:(o>=5&&(i+=s.N1+(o-5)),d=g,o=1),g=t.get(x,f),g===h?l++:(l>=5&&(i+=s.N1+(l-5)),h=g,l=1)}o>=5&&(i+=s.N1+(o-5)),l>=5&&(i+=s.N1+(l-5))}return i},e.getPenaltyN2=function(t){const r=t.size;let i=0;for(let o=0;o<r-1;o++)for(let l=0;l<r-1;l++){const d=t.get(o,l)+t.get(o,l+1)+t.get(o+1,l)+t.get(o+1,l+1);(d===4||d===0)&&i++}return i*s.N2},e.getPenaltyN3=function(t){const r=t.size;let i=0,o=0,l=0;for(let d=0;d<r;d++){o=l=0;for(let h=0;h<r;h++)o=o<<1&2047|t.get(d,h),h>=10&&(o===1488||o===93)&&i++,l=l<<1&2047|t.get(h,d),h>=10&&(l===1488||l===93)&&i++}return i*s.N3},e.getPenaltyN4=function(t){let r=0;const i=t.data.length;for(let l=0;l<i;l++)r+=t.data[l];return Math.abs(Math.ceil(r*100/i/5)-10)*s.N4};function a(n,t,r){switch(n){case e.Patterns.PATTERN000:return(t+r)%2===0;case e.Patterns.PATTERN001:return t%2===0;case e.Patterns.PATTERN010:return r%3===0;case e.Patterns.PATTERN011:return(t+r)%3===0;case e.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2===0;case e.Patterns.PATTERN101:return t*r%2+t*r%3===0;case e.Patterns.PATTERN110:return(t*r%2+t*r%3)%2===0;case e.Patterns.PATTERN111:return(t*r%3+(t+r)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(t,r){const i=r.size;for(let o=0;o<i;o++)for(let l=0;l<i;l++)r.isReserved(l,o)||r.xor(l,o,a(t,l,o))},e.getBestMask=function(t,r){const i=Object.keys(e.Patterns).length;let o=0,l=1/0;for(let d=0;d<i;d++){r(d),e.applyMask(d,t);const h=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(d,t),h<l&&(l=h,o=d)}return o}})(ue)),ue}var Y={},Ke;function xt(){if(Ke)return Y;Ke=1;const e=Ie(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],a=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Y.getBlocksCount=function(t,r){switch(r){case e.L:return s[(t-1)*4+0];case e.M:return s[(t-1)*4+1];case e.Q:return s[(t-1)*4+2];case e.H:return s[(t-1)*4+3];default:return}},Y.getTotalCodewordsCount=function(t,r){switch(r){case e.L:return a[(t-1)*4+0];case e.M:return a[(t-1)*4+1];case e.Q:return a[(t-1)*4+2];case e.H:return a[(t-1)*4+3];default:return}},Y}var de={},V={},Je;function yn(){if(Je)return V;Je=1;const e=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let t=0;t<255;t++)e[t]=n,s[n]=t,n<<=1,n&256&&(n^=285);for(let t=255;t<512;t++)e[t]=e[t-255]})(),V.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},V.exp=function(n){return e[n]},V.mul=function(n,t){return n===0||t===0?0:e[s[n]+s[t]]},V}var Ve;function bn(){return Ve||(Ve=1,(function(e){const s=yn();e.mul=function(n,t){const r=new Uint8Array(n.length+t.length-1);for(let i=0;i<n.length;i++)for(let o=0;o<t.length;o++)r[i+o]^=s.mul(n[i],t[o]);return r},e.mod=function(n,t){let r=new Uint8Array(n);for(;r.length-t.length>=0;){const i=r[0];for(let l=0;l<t.length;l++)r[l]^=s.mul(t[l],i);let o=0;for(;o<r.length&&r[o]===0;)o++;r=r.slice(o)}return r},e.generateECPolynomial=function(n){let t=new Uint8Array([1]);for(let r=0;r<n;r++)t=e.mul(t,new Uint8Array([1,s.exp(r)]));return t}})(de)),de}var fe,Ge;function wn(){if(Ge)return fe;Ge=1;const e=bn();function s(a){this.genPoly=void 0,this.degree=a,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=e.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(n.length+this.degree);t.set(n);const r=e.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r},fe=s,fe}var ge={},he={},me={},Ye;function Ct(){return Ye||(Ye=1,me.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),me}var k={},Qe;function At(){if(Qe)return k;Qe=1;const e="[0-9]+",s="[A-Z $%*+\\-./:]+";let a="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";a=a.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+a+`)(?:.|[\r
|
|
2
2
|
]))+`;k.KANJI=new RegExp(a,"g"),k.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),k.BYTE=new RegExp(n,"g"),k.NUMERIC=new RegExp(e,"g"),k.ALPHANUMERIC=new RegExp(s,"g");const t=new RegExp("^"+a+"$"),r=new RegExp("^"+e+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return k.testKanji=function(l){return t.test(l)},k.testNumeric=function(l){return r.test(l)},k.testAlphanumeric=function(l){return i.test(l)},k}var We;function z(){return We||(We=1,(function(e){const s=Ct(),a=At();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(r,i){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!s.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?r.ccBits[0]:i<27?r.ccBits[1]:r.ccBits[2]},e.getBestModeForData=function(r){return a.testNumeric(r)?e.NUMERIC:a.testAlphanumeric(r)?e.ALPHANUMERIC:a.testKanji(r)?e.KANJI:e.BYTE},e.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},e.isValid=function(r){return r&&r.bit&&r.ccBits};function n(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}e.from=function(r,i){if(e.isValid(r))return r;try{return n(r)}catch{return i}}})(he)),he}var Xe;function xn(){return Xe||(Xe=1,(function(e){const s=_(),a=xt(),n=Ie(),t=z(),r=Ct(),i=7973,o=s.getBCHDigit(i);function l(x,g,y){for(let A=1;A<=40;A++)if(g<=e.getCapacity(A,y,x))return A}function d(x,g){return t.getCharCountIndicator(x,g)+4}function h(x,g){let y=0;return x.forEach(function(A){const T=d(A.mode,g);y+=T+A.getBitsLength()}),y}function f(x,g){for(let y=1;y<=40;y++)if(h(x,y)<=e.getCapacity(y,g,t.MIXED))return y}e.from=function(g,y){return r.isValid(g)?parseInt(g,10):y},e.getCapacity=function(g,y,A){if(!r.isValid(g))throw new Error("Invalid QR Code version");typeof A>"u"&&(A=t.BYTE);const T=s.getSymbolTotalCodewords(g),E=a.getTotalCodewordsCount(g,y),B=(T-E)*8;if(A===t.MIXED)return B;const b=B-d(A,g);switch(A){case t.NUMERIC:return Math.floor(b/10*3);case t.ALPHANUMERIC:return Math.floor(b/11*2);case t.KANJI:return Math.floor(b/13);case t.BYTE:default:return Math.floor(b/8)}},e.getBestVersionForData=function(g,y){let A;const T=n.from(y,n.M);if(Array.isArray(g)){if(g.length>1)return f(g,T);if(g.length===0)return 1;A=g[0]}else A=g;return l(A.mode,A.getLength(),T)},e.getEncodedBits=function(g){if(!r.isValid(g)||g<7)throw new Error("Invalid QR Code version");let y=g<<12;for(;s.getBCHDigit(y)-o>=0;)y^=i<<s.getBCHDigit(y)-o;return g<<12|y}})(ge)),ge}var pe={},Ze;function Cn(){if(Ze)return pe;Ze=1;const e=_(),s=1335,a=21522,n=e.getBCHDigit(s);return pe.getEncodedBits=function(r,i){const o=r.bit<<3|i;let l=o<<10;for(;e.getBCHDigit(l)-n>=0;)l^=s<<e.getBCHDigit(l)-n;return(o<<10|l)^a},pe}var ye={},be,$e;function An(){if($e)return be;$e=1;const e=z();function s(a){this.mode=e.NUMERIC,this.data=a.toString()}return s.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){let t,r,i;for(t=0;t+3<=this.data.length;t+=3)r=this.data.substr(t,3),i=parseInt(r,10),n.put(i,10);const o=this.data.length-t;o>0&&(r=this.data.substr(t),i=parseInt(r,10),n.put(i,o*3+1))},be=s,be}var we,et;function vn(){if(et)return we;et=1;const e=z(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function a(n){this.mode=e.ALPHANUMERIC,this.data=n}return a.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(t){let r;for(r=0;r+2<=this.data.length;r+=2){let i=s.indexOf(this.data[r])*45;i+=s.indexOf(this.data[r+1]),t.put(i,11)}this.data.length%2&&t.put(s.indexOf(this.data[r]),6)},we=a,we}var xe,tt;function Nn(){if(tt)return xe;tt=1;const e=z();function s(a){this.mode=e.BYTE,typeof a=="string"?this.data=new TextEncoder().encode(a):this.data=new Uint8Array(a)}return s.getBitsLength=function(n){return n*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(a){for(let n=0,t=this.data.length;n<t;n++)a.put(this.data[n],8)},xe=s,xe}var Ce,nt;function En(){if(nt)return Ce;nt=1;const e=z(),s=_();function a(n){this.mode=e.KANJI,this.data=n}return a.getBitsLength=function(t){return t*13},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(n){let t;for(t=0;t<this.data.length;t++){let r=s.toSJIS(this.data[t]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
3
3
|
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),n.put(r,13)}},Ce=a,Ce}var Ae={exports:{}},rt;function jn(){return rt||(rt=1,(function(e){var s={single_source_shortest_paths:function(a,n,t){var r={},i={};i[n]=0;var o=s.PriorityQueue.make();o.push(n,0);for(var l,d,h,f,x,g,y,A,T;!o.empty();){l=o.pop(),d=l.value,f=l.cost,x=a[d]||{};for(h in x)x.hasOwnProperty(h)&&(g=x[h],y=f+g,A=i[h],T=typeof i[h]>"u",(T||A>y)&&(i[h]=y,o.push(h,y),r[h]=d))}if(typeof t<"u"&&typeof i[t]>"u"){var E=["Could not find a path from ",n," to ",t,"."].join("");throw new Error(E)}return r},extract_shortest_path_from_predecessor_list:function(a,n){for(var t=[],r=n;r;)t.push(r),a[r],r=a[r];return t.reverse(),t},find_path:function(a,n,t){var r=s.single_source_shortest_paths(a,n,t);return s.extract_shortest_path_from_predecessor_list(r,t)},PriorityQueue:{make:function(a){var n=s.PriorityQueue,t={},r;a=a||{};for(r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);return t.queue=[],t.sorter=a.sorter||n.default_sorter,t},default_sorter:function(a,n){return a.cost-n.cost},push:function(a,n){var t={value:a,cost:n};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=s})(Ae)),Ae.exports}var st;function Sn(){return st||(st=1,(function(e){const s=z(),a=An(),n=vn(),t=Nn(),r=En(),i=At(),o=_(),l=jn();function d(E){return unescape(encodeURIComponent(E)).length}function h(E,B,b){const N=[];let M;for(;(M=E.exec(b))!==null;)N.push({data:M[0],index:M.index,mode:B,length:M[0].length});return N}function f(E){const B=h(i.NUMERIC,s.NUMERIC,E),b=h(i.ALPHANUMERIC,s.ALPHANUMERIC,E);let N,M;return o.isKanjiModeEnabled()?(N=h(i.BYTE,s.BYTE,E),M=h(i.KANJI,s.KANJI,E)):(N=h(i.BYTE_KANJI,s.BYTE,E),M=[]),B.concat(b,N,M).sort(function(S,I){return S.index-I.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function x(E,B){switch(B){case s.NUMERIC:return a.getBitsLength(E);case s.ALPHANUMERIC:return n.getBitsLength(E);case s.KANJI:return r.getBitsLength(E);case s.BYTE:return t.getBitsLength(E)}}function g(E){return E.reduce(function(B,b){const N=B.length-1>=0?B[B.length-1]:null;return N&&N.mode===b.mode?(B[B.length-1].data+=b.data,B):(B.push(b),B)},[])}function y(E){const B=[];for(let b=0;b<E.length;b++){const N=E[b];switch(N.mode){case s.NUMERIC:B.push([N,{data:N.data,mode:s.ALPHANUMERIC,length:N.length},{data:N.data,mode:s.BYTE,length:N.length}]);break;case s.ALPHANUMERIC:B.push([N,{data:N.data,mode:s.BYTE,length:N.length}]);break;case s.KANJI:B.push([N,{data:N.data,mode:s.BYTE,length:d(N.data)}]);break;case s.BYTE:B.push([{data:N.data,mode:s.BYTE,length:d(N.data)}])}}return B}function A(E,B){const b={},N={start:{}};let M=["start"];for(let w=0;w<E.length;w++){const S=E[w],I=[];for(let v=0;v<S.length;v++){const P=S[v],j=""+w+v;I.push(j),b[j]={node:P,lastCount:0},N[j]={};for(let m=0;m<M.length;m++){const p=M[m];b[p]&&b[p].node.mode===P.mode?(N[p][j]=x(b[p].lastCount+P.length,P.mode)-x(b[p].lastCount,P.mode),b[p].lastCount+=P.length):(b[p]&&(b[p].lastCount=P.length),N[p][j]=x(P.length,P.mode)+4+s.getCharCountIndicator(P.mode,B))}}M=I}for(let w=0;w<M.length;w++)N[M[w]].end=0;return{map:N,table:b}}function T(E,B){let b;const N=s.getBestModeForData(E);if(b=s.from(B,N),b!==s.BYTE&&b.bit<N.bit)throw new Error('"'+E+'" cannot be encoded with mode '+s.toString(b)+`.
|
|
4
4
|
Suggested mode is: `+s.toString(N));switch(b===s.KANJI&&!o.isKanjiModeEnabled()&&(b=s.BYTE),b){case s.NUMERIC:return new a(E);case s.ALPHANUMERIC:return new n(E);case s.KANJI:return new r(E);case s.BYTE:return new t(E)}}e.fromArray=function(B){return B.reduce(function(b,N){return typeof N=="string"?b.push(T(N,null)):N.data&&b.push(T(N.data,N.mode)),b},[])},e.fromString=function(B,b){const N=f(B,o.isKanjiModeEnabled()),M=y(N),w=A(M,b),S=l.find_path(w.map,"start","end"),I=[];for(let v=1;v<S.length-1;v++)I.push(w.table[S[v]].node);return e.fromArray(g(I))},e.rawSplit=function(B){return e.fromArray(f(B,o.isKanjiModeEnabled()))}})(ye)),ye}var at;function In(){if(at)return se;at=1;const e=_(),s=Ie(),a=fn(),n=gn(),t=hn(),r=mn(),i=pn(),o=xt(),l=wn(),d=xn(),h=Cn(),f=z(),x=Sn();function g(w,S){const I=w.size,v=r.getPositions(S);for(let P=0;P<v.length;P++){const j=v[P][0],m=v[P][1];for(let p=-1;p<=7;p++)if(!(j+p<=-1||I<=j+p))for(let C=-1;C<=7;C++)m+C<=-1||I<=m+C||(p>=0&&p<=6&&(C===0||C===6)||C>=0&&C<=6&&(p===0||p===6)||p>=2&&p<=4&&C>=2&&C<=4?w.set(j+p,m+C,!0,!0):w.set(j+p,m+C,!1,!0))}}function y(w){const S=w.size;for(let I=8;I<S-8;I++){const v=I%2===0;w.set(I,6,v,!0),w.set(6,I,v,!0)}}function A(w,S){const I=t.getPositions(S);for(let v=0;v<I.length;v++){const P=I[v][0],j=I[v][1];for(let m=-2;m<=2;m++)for(let p=-2;p<=2;p++)m===-2||m===2||p===-2||p===2||m===0&&p===0?w.set(P+m,j+p,!0,!0):w.set(P+m,j+p,!1,!0)}}function T(w,S){const I=w.size,v=d.getEncodedBits(S);let P,j,m;for(let p=0;p<18;p++)P=Math.floor(p/3),j=p%3+I-8-3,m=(v>>p&1)===1,w.set(P,j,m,!0),w.set(j,P,m,!0)}function E(w,S,I){const v=w.size,P=h.getEncodedBits(S,I);let j,m;for(j=0;j<15;j++)m=(P>>j&1)===1,j<6?w.set(j,8,m,!0):j<8?w.set(j+1,8,m,!0):w.set(v-15+j,8,m,!0),j<8?w.set(8,v-j-1,m,!0):j<9?w.set(8,15-j-1+1,m,!0):w.set(8,15-j-1,m,!0);w.set(v-8,8,1,!0)}function B(w,S){const I=w.size;let v=-1,P=I-1,j=7,m=0;for(let p=I-1;p>0;p-=2)for(p===6&&p--;;){for(let C=0;C<2;C++)if(!w.isReserved(P,p-C)){let R=!1;m<S.length&&(R=(S[m]>>>j&1)===1),w.set(P,p-C,R),j--,j===-1&&(m++,j=7)}if(P+=v,P<0||I<=P){P-=v,v=-v;break}}}function b(w,S,I){const v=new a;I.forEach(function(C){v.put(C.mode.bit,4),v.put(C.getLength(),f.getCharCountIndicator(C.mode,w)),C.write(v)});const P=e.getSymbolTotalCodewords(w),j=o.getTotalCodewordsCount(w,S),m=(P-j)*8;for(v.getLengthInBits()+4<=m&&v.put(0,4);v.getLengthInBits()%8!==0;)v.putBit(0);const p=(m-v.getLengthInBits())/8;for(let C=0;C<p;C++)v.put(C%2?17:236,8);return N(v,w,S)}function N(w,S,I){const v=e.getSymbolTotalCodewords(S),P=o.getTotalCodewordsCount(S,I),j=v-P,m=o.getBlocksCount(S,I),p=v%m,C=m-p,R=Math.floor(v/m),J=Math.floor(j/m),Et=J+1,Pe=R-J,jt=new l(Pe);let X=0;const G=new Array(m),Be=new Array(m);let Z=0;const St=new Uint8Array(w.buffer);for(let O=0;O<m;O++){const ee=O<C?J:Et;G[O]=St.slice(X,X+ee),Be[O]=jt.encode(G[O]),X+=ee,Z=Math.max(Z,ee)}const $=new Uint8Array(v);let Te=0,D,F;for(D=0;D<Z;D++)for(F=0;F<m;F++)D<G[F].length&&($[Te++]=G[F][D]);for(D=0;D<Pe;D++)for(F=0;F<m;F++)$[Te++]=Be[F][D];return $}function M(w,S,I,v){let P;if(Array.isArray(w))P=x.fromArray(w);else if(typeof w=="string"){let R=S;if(!R){const J=x.rawSplit(w);R=d.getBestVersionForData(J,I)}P=x.fromString(w,R||40)}else throw new Error("Invalid data");const j=d.getBestVersionForData(P,I);if(!j)throw new Error("The amount of data is too big to be stored in a QR Code");if(!S)S=j;else if(S<j)throw new Error(`
|