@hawtio/ai-plugin 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/index.css +11 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +1109 -3012
- package/dist/index.js.map +1 -1
- package/package.json +12 -7
package/dist/index.js
CHANGED
|
@@ -8,9 +8,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
8
8
|
var __esm = (fn, res) => function __init() {
|
|
9
9
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
10
|
};
|
|
11
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
-
};
|
|
14
11
|
var __export = (target, all) => {
|
|
15
12
|
for (var name in all)
|
|
16
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,6 +30,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
30
|
));
|
|
34
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
32
|
|
|
33
|
+
// src/ai-plugin/chat/globals.ts
|
|
34
|
+
var import_react, pluginName, pluginTitle, pluginPath, log;
|
|
35
|
+
var init_globals = __esm({
|
|
36
|
+
"src/ai-plugin/chat/globals.ts"() {
|
|
37
|
+
"use strict";
|
|
38
|
+
import_react = require("@hawtio/react");
|
|
39
|
+
pluginName = "hawtio-ai-chat";
|
|
40
|
+
pluginTitle = "AI Chat";
|
|
41
|
+
pluginPath = "/ai-chat";
|
|
42
|
+
log = import_react.Logger.get(pluginName);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// src/ai-plugin/chat/Chat.css
|
|
47
|
+
var init_Chat = __esm({
|
|
48
|
+
"src/ai-plugin/chat/Chat.css"() {
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
36
52
|
// src/ai-plugin/common/ai-model.ts
|
|
37
53
|
var PROVIDERS, MODELS;
|
|
38
54
|
var init_ai_model = __esm({
|
|
@@ -67,22 +83,282 @@ var init_ai_model = __esm({
|
|
|
67
83
|
}
|
|
68
84
|
});
|
|
69
85
|
|
|
70
|
-
// src/ai-plugin/
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
"src/ai-plugin/
|
|
86
|
+
// src/ai-plugin/common/ai-preferences-service.ts
|
|
87
|
+
var STORAGE_KEY_PREFERENCES, DEFAULT_TOOL_PERMISSIONS, DEFAULT_MAX_AUTO_TOOL_STEPS, DEFAULT_OPTIONS, AiPreferencesService, aiPreferencesService;
|
|
88
|
+
var init_ai_preferences_service = __esm({
|
|
89
|
+
"src/ai-plugin/common/ai-preferences-service.ts"() {
|
|
74
90
|
"use strict";
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
init_ai_model();
|
|
92
|
+
init_ai_service();
|
|
93
|
+
STORAGE_KEY_PREFERENCES = "ai.preferences";
|
|
94
|
+
DEFAULT_TOOL_PERMISSIONS = {
|
|
95
|
+
listMBeans: true,
|
|
96
|
+
getMBeanInfo: true,
|
|
97
|
+
searchMBeans: true,
|
|
98
|
+
readMBeanAttribute: false,
|
|
99
|
+
writeMBeanAttribute: false,
|
|
100
|
+
executeMBeanOperation: false
|
|
101
|
+
};
|
|
102
|
+
DEFAULT_MAX_AUTO_TOOL_STEPS = 10;
|
|
103
|
+
DEFAULT_OPTIONS = {
|
|
104
|
+
model: MODELS[0],
|
|
105
|
+
toolPermissions: DEFAULT_TOOL_PERMISSIONS,
|
|
106
|
+
maxAutoToolSteps: DEFAULT_MAX_AUTO_TOOL_STEPS
|
|
107
|
+
};
|
|
108
|
+
AiPreferencesService = class {
|
|
109
|
+
loadOptions() {
|
|
110
|
+
const item = localStorage.getItem(STORAGE_KEY_PREFERENCES);
|
|
111
|
+
const savedOptions = item ? JSON.parse(item) : {};
|
|
112
|
+
return { ...DEFAULT_OPTIONS, ...savedOptions };
|
|
113
|
+
}
|
|
114
|
+
saveOptions(options) {
|
|
115
|
+
const updated = { ...this.loadOptions(), ...options };
|
|
116
|
+
localStorage.setItem(STORAGE_KEY_PREFERENCES, JSON.stringify(updated));
|
|
117
|
+
if (options.model) {
|
|
118
|
+
aiService.reset(options.model);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
aiPreferencesService = new AiPreferencesService();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/ai-plugin/common/globals.ts
|
|
127
|
+
var import_react2, pluginName2, pluginTitle2, log2;
|
|
128
|
+
var init_globals2 = __esm({
|
|
129
|
+
"src/ai-plugin/common/globals.ts"() {
|
|
130
|
+
"use strict";
|
|
131
|
+
import_react2 = require("@hawtio/react");
|
|
132
|
+
pluginName2 = "hawtio-ai";
|
|
133
|
+
pluginTitle2 = "AI";
|
|
134
|
+
log2 = import_react2.Logger.get(pluginName2);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// src/ai-plugin/common/workspace.ts
|
|
139
|
+
var import_react3, WorkspaceExtension, workspaceExtension;
|
|
140
|
+
var init_workspace = __esm({
|
|
141
|
+
"src/ai-plugin/common/workspace.ts"() {
|
|
142
|
+
"use strict";
|
|
143
|
+
import_react3 = require("@hawtio/react");
|
|
144
|
+
init_globals2();
|
|
145
|
+
WorkspaceExtension = class {
|
|
146
|
+
constructor(workspace5, jolokiaService3) {
|
|
147
|
+
this.workspace = workspace5;
|
|
148
|
+
this.jolokiaService = jolokiaService3;
|
|
149
|
+
}
|
|
150
|
+
workspace;
|
|
151
|
+
jolokiaService;
|
|
152
|
+
async listMBeans() {
|
|
153
|
+
log2.debug("workspace - listMBeans called");
|
|
154
|
+
const tree = await this.workspace.getTree();
|
|
155
|
+
const flat = tree.flatten();
|
|
156
|
+
const result = Object.keys(flat).sort();
|
|
157
|
+
log2.debug("workspace - listMBeans result count:", result.length);
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
async getMBeanInfo(objectName) {
|
|
161
|
+
log2.debug("workspace - getMBeanInfo called:", objectName);
|
|
162
|
+
const tree = await this.workspace.getTree();
|
|
163
|
+
const flat = tree.flatten();
|
|
164
|
+
const mbeanInfo = flat[objectName]?.mbean ?? null;
|
|
165
|
+
if (!mbeanInfo) {
|
|
166
|
+
log2.debug("workspace - getMBeanInfo: not found:", objectName);
|
|
167
|
+
}
|
|
168
|
+
return mbeanInfo;
|
|
169
|
+
}
|
|
170
|
+
async readMBeanAttribute(objectName, attribute) {
|
|
171
|
+
log2.debug("workspace - readMBeanAttribute called:", objectName, attribute);
|
|
172
|
+
return this.jolokiaService.readAttribute(objectName, attribute);
|
|
173
|
+
}
|
|
174
|
+
async writeMBeanAttribute(objectName, attribute, value) {
|
|
175
|
+
log2.debug("workspace - writeMBeanAttribute called:", objectName, attribute, value);
|
|
176
|
+
return this.jolokiaService.writeAttribute(objectName, attribute, value);
|
|
177
|
+
}
|
|
178
|
+
async executeMBeanOperation(objectName, operation, args) {
|
|
179
|
+
log2.debug("workspace - executeMBeanOperation called:", objectName, operation, args);
|
|
180
|
+
return this.jolokiaService.execute(objectName, operation, args);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
workspaceExtension = new WorkspaceExtension(import_react3.workspace, import_react3.jolokiaService);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// src/ai-plugin/common/tools.ts
|
|
188
|
+
function listMBeansTool() {
|
|
189
|
+
return new import_tools.DynamicStructuredTool({
|
|
190
|
+
name: "listMBeans",
|
|
191
|
+
description: `
|
|
192
|
+
List all MBean ObjectNames available in the Hawtio workspace cache.
|
|
193
|
+
Use this to discover what MBeans are present before querying details.
|
|
194
|
+
`,
|
|
195
|
+
schema: import_zod.z.object({}),
|
|
196
|
+
func: async () => {
|
|
197
|
+
log2.debug("tools - listMBeans called");
|
|
198
|
+
const result = await workspaceExtension.listMBeans();
|
|
199
|
+
return JSON.stringify(result);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function getMBeanInfoTool() {
|
|
204
|
+
return new import_tools.DynamicStructuredTool({
|
|
205
|
+
name: "getMBeanInfo",
|
|
206
|
+
description: `
|
|
207
|
+
Return the attribute schema (type, description, read/write flag) and operation definitions
|
|
208
|
+
(arguments, return type, description) for a specific MBean.
|
|
209
|
+
Call this before readMBeanAttribute or executeMBeanOperation to inspect available fields.
|
|
210
|
+
`,
|
|
211
|
+
schema: import_zod.z.object({
|
|
212
|
+
objectName: import_zod.z.string().describe("JMX ObjectName of the target MBean, e.g. 'java.lang:type=Memory'")
|
|
213
|
+
}),
|
|
214
|
+
func: async ({ objectName }) => {
|
|
215
|
+
log2.debug("tools - getMBeanInfo called:", objectName);
|
|
216
|
+
const info = await workspaceExtension.getMBeanInfo(objectName);
|
|
217
|
+
if (!info) {
|
|
218
|
+
return JSON.stringify({ error: `MBean not found: ${objectName}` });
|
|
219
|
+
}
|
|
220
|
+
return JSON.stringify({ objectName, attr: info.attr, op: info.op });
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
function searchMBeansTool() {
|
|
225
|
+
return new import_tools.DynamicStructuredTool({
|
|
226
|
+
name: "searchMBeans",
|
|
227
|
+
description: `
|
|
228
|
+
Search MBeans by JMX domain and property key/value pairs.
|
|
229
|
+
Returns a list of matching ObjectNames.
|
|
230
|
+
Use this to narrow down MBeans by type or name, e.g. domain='java.lang', properties='{"type":"Memory"}'.
|
|
231
|
+
`,
|
|
232
|
+
schema: import_zod.z.object({
|
|
233
|
+
domain: import_zod.z.string().describe("JMX domain to search in, e.g. 'java.lang'"),
|
|
234
|
+
properties: import_zod.z.string().describe(`JSON string of JMX property key/value pairs to match, e.g. '{"type":"Memory"}'`)
|
|
235
|
+
}),
|
|
236
|
+
func: async ({ domain, properties }) => {
|
|
237
|
+
log2.debug("tools - searchMBeans called:", domain, properties);
|
|
238
|
+
let parsed;
|
|
239
|
+
try {
|
|
240
|
+
parsed = JSON.parse(properties);
|
|
241
|
+
} catch {
|
|
242
|
+
return JSON.stringify({ error: `Invalid JSON for properties: ${properties}` });
|
|
243
|
+
}
|
|
244
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
245
|
+
return JSON.stringify({ error: `properties must be a JSON object, got: ${properties}` });
|
|
246
|
+
}
|
|
247
|
+
const nodes = await import_react4.workspace.findMBeans(domain, parsed);
|
|
248
|
+
const result = nodes.map((n) => n.objectName).filter((s) => s !== void 0);
|
|
249
|
+
log2.debug("tools - searchMBeans result count:", result.length);
|
|
250
|
+
return JSON.stringify(result);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function readMBeanAttributeTool() {
|
|
255
|
+
return new import_tools.DynamicStructuredTool({
|
|
256
|
+
name: "readMBeanAttribute",
|
|
257
|
+
description: `
|
|
258
|
+
Read the current value of an MBean attribute via Jolokia.
|
|
259
|
+
This is a read-only operation with no side effects.
|
|
260
|
+
Use getMBeanInfo first to confirm the attribute name and type.
|
|
261
|
+
`,
|
|
262
|
+
schema: import_zod.z.object({
|
|
263
|
+
objectName: import_zod.z.string().describe("ObjectName of the target MBean, e.g. 'java.lang:type=Memory'"),
|
|
264
|
+
attribute: import_zod.z.string().describe("Name of the attribute to read, e.g. 'HeapMemoryUsage'")
|
|
265
|
+
}),
|
|
266
|
+
func: async ({ objectName, attribute }) => {
|
|
267
|
+
log2.debug("tools - readMBeanAttribute called:", objectName, attribute);
|
|
268
|
+
try {
|
|
269
|
+
const value = await workspaceExtension.readMBeanAttribute(objectName, attribute);
|
|
270
|
+
return JSON.stringify({ objectName, attribute, value });
|
|
271
|
+
} catch (e) {
|
|
272
|
+
return JSON.stringify({ error: String(e) });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function writeMBeanAttributeTool() {
|
|
278
|
+
return new import_tools.DynamicStructuredTool({
|
|
279
|
+
name: "writeMBeanAttribute",
|
|
280
|
+
description: `
|
|
281
|
+
Write a value to a writable MBean attribute via Jolokia.
|
|
282
|
+
Verify rw=true with getMBeanInfo before calling this tool.
|
|
283
|
+
`,
|
|
284
|
+
schema: import_zod.z.object({
|
|
285
|
+
objectName: import_zod.z.string().describe("ObjectName of the target MBean, e.g. 'java.lang:type=Memory'"),
|
|
286
|
+
attribute: import_zod.z.string().describe("Name of the attribute to write"),
|
|
287
|
+
value: import_zod.z.string().describe('JSON-encoded value to set, e.g. "42" or "true" or "\\"hello\\""')
|
|
288
|
+
}),
|
|
289
|
+
func: async ({ objectName, attribute, value }) => {
|
|
290
|
+
log2.debug("tools - writeMBeanAttribute called:", objectName, attribute, value);
|
|
291
|
+
let parsed;
|
|
292
|
+
try {
|
|
293
|
+
parsed = JSON.parse(value);
|
|
294
|
+
} catch {
|
|
295
|
+
parsed = value;
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
const result = await workspaceExtension.writeMBeanAttribute(objectName, attribute, parsed);
|
|
299
|
+
return JSON.stringify({ objectName, attribute, result });
|
|
300
|
+
} catch (e) {
|
|
301
|
+
return JSON.stringify({ error: String(e) });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function executeMBeanOperationTool() {
|
|
307
|
+
return new import_tools.DynamicStructuredTool({
|
|
308
|
+
name: "executeMBeanOperation",
|
|
309
|
+
description: `
|
|
310
|
+
Execute an MBean operation via Jolokia.
|
|
311
|
+
Use getMBeanInfo to verify the operation signature before calling.
|
|
312
|
+
For overloaded operations include the signature, e.g. 'gc()'.
|
|
313
|
+
`,
|
|
314
|
+
schema: import_zod.z.object({
|
|
315
|
+
objectName: import_zod.z.string().describe("ObjectName of the target MBean, e.g. 'java.lang:type=Memory'"),
|
|
316
|
+
operation: import_zod.z.string().describe("Operation name to invoke, e.g. 'gc' or 'gc()'"),
|
|
317
|
+
args: import_zod.z.array(import_zod.z.string()).optional().describe('JSON-encoded arguments to pass to the operation, e.g. ["value1", "42"]')
|
|
318
|
+
}),
|
|
319
|
+
func: async ({ objectName, operation, args }) => {
|
|
320
|
+
log2.debug("tools - executeMBeanOperation called:", objectName, operation, args);
|
|
321
|
+
const parsedArgs = args?.map((a) => {
|
|
322
|
+
try {
|
|
323
|
+
return JSON.parse(a);
|
|
324
|
+
} catch {
|
|
325
|
+
return a;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
try {
|
|
329
|
+
const result = await workspaceExtension.executeMBeanOperation(objectName, operation, parsedArgs);
|
|
330
|
+
return JSON.stringify({ objectName, operation, result });
|
|
331
|
+
} catch (e) {
|
|
332
|
+
return JSON.stringify({ error: String(e) });
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function getWorkspaceTools() {
|
|
338
|
+
return [
|
|
339
|
+
listMBeansTool(),
|
|
340
|
+
getMBeanInfoTool(),
|
|
341
|
+
searchMBeansTool(),
|
|
342
|
+
readMBeanAttributeTool(),
|
|
343
|
+
writeMBeanAttributeTool(),
|
|
344
|
+
executeMBeanOperationTool()
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
var import_react4, import_tools, import_zod, WORKSPACE_TOOLS_META;
|
|
348
|
+
var init_tools = __esm({
|
|
349
|
+
"src/ai-plugin/common/tools.ts"() {
|
|
350
|
+
"use strict";
|
|
351
|
+
import_react4 = require("@hawtio/react");
|
|
352
|
+
import_tools = require("@langchain/core/tools");
|
|
353
|
+
import_zod = require("zod");
|
|
354
|
+
init_globals2();
|
|
355
|
+
init_workspace();
|
|
356
|
+
WORKSPACE_TOOLS_META = getWorkspaceTools().map(({ name, description }) => ({ name, description }));
|
|
81
357
|
}
|
|
82
358
|
});
|
|
83
359
|
|
|
84
360
|
// src/ai-plugin/common/ai-service.ts
|
|
85
|
-
var import_anthropic, import_messages, import_google_genai, import_ollama, import_openai, import_patternfly_avatar, import_img_avatar_light, BOT_NAME, TOOLS, TOOLS_BY_NAME, AiService, aiService;
|
|
361
|
+
var import_anthropic, import_messages, import_google_genai, import_ollama, import_openai, import_patternfly_avatar, import_img_avatar_light, import_react5, BOT_NAME, TOOLS, TOOLS_BY_NAME, AiService, aiService;
|
|
86
362
|
var init_ai_service = __esm({
|
|
87
363
|
"src/ai-plugin/common/ai-service.ts"() {
|
|
88
364
|
"use strict";
|
|
@@ -93,10 +369,12 @@ var init_ai_service = __esm({
|
|
|
93
369
|
import_openai = require("@langchain/openai");
|
|
94
370
|
import_patternfly_avatar = __toESM(require("@patternfly/chatbot/patternfly-docs/content/extensions/chatbot/examples/Messages/patternfly_avatar.jpg"));
|
|
95
371
|
import_img_avatar_light = __toESM(require("@patternfly/react-core/dist/styles/assets/images/img_avatar-light.svg"));
|
|
96
|
-
|
|
372
|
+
import_react5 = require("react");
|
|
97
373
|
init_ai_preferences_service();
|
|
374
|
+
init_globals2();
|
|
375
|
+
init_tools();
|
|
98
376
|
BOT_NAME = "Hawtio AI";
|
|
99
|
-
TOOLS =
|
|
377
|
+
TOOLS = getWorkspaceTools();
|
|
100
378
|
TOOLS_BY_NAME = TOOLS.reduce(
|
|
101
379
|
(acc, tool) => {
|
|
102
380
|
acc[tool.name] = tool;
|
|
@@ -109,11 +387,16 @@ var init_ai_service = __esm({
|
|
|
109
387
|
llm;
|
|
110
388
|
llmWithTools;
|
|
111
389
|
memory = {};
|
|
390
|
+
appendToolMessages(messages, toolCalls, content) {
|
|
391
|
+
for (const call of toolCalls) {
|
|
392
|
+
messages.push(new import_messages.ToolMessage({ tool_call_id: call.id ?? call.name, content }));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
112
395
|
reset(model) {
|
|
113
396
|
if (this.model && this.model.id === model.id && this.llm && (!model.tool || this.llmWithTools)) {
|
|
114
397
|
return;
|
|
115
398
|
}
|
|
116
|
-
|
|
399
|
+
log2.info("AI model to use:", model.id);
|
|
117
400
|
this.memory = {};
|
|
118
401
|
const { token } = aiPreferencesService.loadOptions();
|
|
119
402
|
this.model = model;
|
|
@@ -123,7 +406,6 @@ var init_ai_service = __esm({
|
|
|
123
406
|
this.llm = new import_openai.ChatOpenAI({
|
|
124
407
|
model: this.model.id,
|
|
125
408
|
apiKey: token,
|
|
126
|
-
temperature: 0,
|
|
127
409
|
streaming: false
|
|
128
410
|
});
|
|
129
411
|
break;
|
|
@@ -131,7 +413,6 @@ var init_ai_service = __esm({
|
|
|
131
413
|
this.llm = new import_anthropic.ChatAnthropic({
|
|
132
414
|
model: this.model.id,
|
|
133
415
|
apiKey: token,
|
|
134
|
-
temperature: 0,
|
|
135
416
|
streaming: false
|
|
136
417
|
});
|
|
137
418
|
break;
|
|
@@ -151,7 +432,7 @@ var init_ai_service = __esm({
|
|
|
151
432
|
});
|
|
152
433
|
}
|
|
153
434
|
} catch (error) {
|
|
154
|
-
|
|
435
|
+
log2.warn("Error initialising AI model:", error);
|
|
155
436
|
this.llm = void 0;
|
|
156
437
|
}
|
|
157
438
|
this.llmWithTools = void 0;
|
|
@@ -172,7 +453,7 @@ var init_ai_service = __esm({
|
|
|
172
453
|
}
|
|
173
454
|
async invoke(messages) {
|
|
174
455
|
const llm = this.getLlm();
|
|
175
|
-
|
|
456
|
+
log2.debug("Chatting with", this.model?.id, ":", messages);
|
|
176
457
|
try {
|
|
177
458
|
let answer;
|
|
178
459
|
if (!llm) {
|
|
@@ -180,24 +461,28 @@ var init_ai_service = __esm({
|
|
|
180
461
|
}
|
|
181
462
|
answer = await llm.invoke(messages);
|
|
182
463
|
if (answer.tool_calls && answer.tool_calls.length > 0) {
|
|
183
|
-
|
|
464
|
+
log2.debug("\u{1F6E0}\uFE0F calls:", answer.tool_calls);
|
|
184
465
|
}
|
|
185
|
-
|
|
466
|
+
log2.debug("Answer:", answer);
|
|
186
467
|
return answer;
|
|
187
468
|
} catch (error) {
|
|
188
|
-
|
|
469
|
+
log2.error("Error while chatting:", error);
|
|
189
470
|
return String(error);
|
|
190
471
|
}
|
|
191
472
|
}
|
|
192
|
-
newChat(dialogId,
|
|
473
|
+
newChat(dialogId, initialMessage, onMessage) {
|
|
474
|
+
const { message, system } = initialMessage;
|
|
193
475
|
if (system) {
|
|
194
476
|
this.memory[dialogId] = [new import_messages.SystemMessage(system)];
|
|
195
477
|
} else {
|
|
196
478
|
this.memory[dialogId] = [];
|
|
197
479
|
}
|
|
198
|
-
return this.chat(dialogId, message);
|
|
480
|
+
return this.chat(dialogId, message, onMessage);
|
|
481
|
+
}
|
|
482
|
+
hasToolCalls(answer) {
|
|
483
|
+
return typeof answer !== "string" && (answer.tool_calls?.length ?? 0) > 0;
|
|
199
484
|
}
|
|
200
|
-
async chat(dialogId, message) {
|
|
485
|
+
async chat(dialogId, message, onMessage) {
|
|
201
486
|
let messages = this.memory[dialogId];
|
|
202
487
|
if (!messages) {
|
|
203
488
|
messages = [];
|
|
@@ -208,10 +493,26 @@ var init_ai_service = __esm({
|
|
|
208
493
|
if (typeof answer !== "string") {
|
|
209
494
|
messages.push(answer);
|
|
210
495
|
}
|
|
211
|
-
|
|
496
|
+
log2.debug("Current messages:", messages);
|
|
497
|
+
if (this.hasToolCalls(answer)) {
|
|
498
|
+
const { toolPermissions } = aiPreferencesService.loadOptions();
|
|
499
|
+
if (answer.tool_calls.every((call) => toolPermissions?.[call.name] === true)) {
|
|
500
|
+
onMessage?.(answer);
|
|
501
|
+
return this.invokeTools(dialogId, answer.tool_calls, onMessage);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
212
504
|
return answer;
|
|
213
505
|
}
|
|
214
|
-
|
|
506
|
+
/**
|
|
507
|
+
* Executes the given tool calls and invokes the LLM with the results.
|
|
508
|
+
* If the LLM responds with further tool calls that are all auto-approved,
|
|
509
|
+
* this method recurses (up to {@link maxAutoToolSteps} times) to continue
|
|
510
|
+
* the chain without interruption. Tool calls that are not auto-approved are
|
|
511
|
+
* returned as-is so the caller can decide to approve or reject them.
|
|
512
|
+
*
|
|
513
|
+
* @param step - Current recursion depth; used to enforce the step limit.
|
|
514
|
+
*/
|
|
515
|
+
async invokeTools(dialogId, toolCalls, onMessage, step = 0) {
|
|
215
516
|
if (!this.llmWithTools) {
|
|
216
517
|
return "Tool invocation not supported";
|
|
217
518
|
}
|
|
@@ -220,28 +521,60 @@ var init_ai_service = __esm({
|
|
|
220
521
|
messages = [];
|
|
221
522
|
this.memory[dialogId] = messages;
|
|
222
523
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
messages.push(toolAnswer);
|
|
230
|
-
}
|
|
524
|
+
const { toolPermissions, maxAutoToolSteps } = aiPreferencesService.loadOptions();
|
|
525
|
+
if (step >= maxAutoToolSteps) {
|
|
526
|
+
const limitMessage = `Automatic tool-call step limit reached after ${maxAutoToolSteps} steps.`;
|
|
527
|
+
this.appendToolMessages(messages, toolCalls, limitMessage);
|
|
528
|
+
log2.warn(`Auto-tool execution stopped after ${maxAutoToolSteps} steps to prevent runaway execution.`);
|
|
529
|
+
return `Stopped after ${maxAutoToolSteps} automatic tool-call steps. You can increase the limit in Preferences.`;
|
|
231
530
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
531
|
+
try {
|
|
532
|
+
for (const call of toolCalls) {
|
|
533
|
+
log2.debug("\u{1F6E0}\uFE0F Call:", call.name, JSON.stringify(call.args));
|
|
534
|
+
const selectedTool = TOOLS_BY_NAME[call.name];
|
|
535
|
+
const toolAnswer = await selectedTool?.invoke(call);
|
|
536
|
+
if (toolAnswer) {
|
|
537
|
+
log2.debug("\u{1F6E0}\uFE0F " + call.name + ":", toolAnswer);
|
|
538
|
+
messages.push(toolAnswer);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
const answer = await this.llmWithTools.invoke(messages);
|
|
542
|
+
if (answer) {
|
|
543
|
+
messages.push(answer);
|
|
544
|
+
}
|
|
545
|
+
log2.debug("Messages>>", messages);
|
|
546
|
+
if (this.hasToolCalls(answer) && answer.tool_calls.every((call) => toolPermissions?.[call.name] === true)) {
|
|
547
|
+
onMessage?.(answer);
|
|
548
|
+
return this.invokeTools(dialogId, answer.tool_calls, onMessage, step + 1);
|
|
549
|
+
}
|
|
550
|
+
return answer;
|
|
551
|
+
} catch (error) {
|
|
552
|
+
log2.error("Error while invoking tools:", error);
|
|
553
|
+
return String(error);
|
|
235
554
|
}
|
|
236
|
-
|
|
237
|
-
|
|
555
|
+
}
|
|
556
|
+
rejectTools(dialogId, toolCalls) {
|
|
557
|
+
const messages = this.memory[dialogId];
|
|
558
|
+
if (!messages) return;
|
|
559
|
+
this.appendToolMessages(messages, toolCalls, "User rejected");
|
|
560
|
+
log2.debug(
|
|
561
|
+
"rejectTools - added rejection ToolMessages for:",
|
|
562
|
+
toolCalls.map((c) => c.name)
|
|
563
|
+
);
|
|
238
564
|
}
|
|
239
565
|
generateId() {
|
|
240
566
|
return crypto.randomUUID();
|
|
241
567
|
}
|
|
242
568
|
createUserMessage(name, content) {
|
|
243
569
|
const id = this.generateId();
|
|
244
|
-
return {
|
|
570
|
+
return {
|
|
571
|
+
id,
|
|
572
|
+
role: "user",
|
|
573
|
+
content,
|
|
574
|
+
name,
|
|
575
|
+
avatar: import_img_avatar_light.default,
|
|
576
|
+
timestamp: (/* @__PURE__ */ new Date()).toLocaleString()
|
|
577
|
+
};
|
|
245
578
|
}
|
|
246
579
|
createLoadingBotMessage() {
|
|
247
580
|
const id = this.generateId();
|
|
@@ -250,6 +583,7 @@ var init_ai_service = __esm({
|
|
|
250
583
|
role: "bot",
|
|
251
584
|
name: BOT_NAME,
|
|
252
585
|
avatar: import_patternfly_avatar.default,
|
|
586
|
+
avatarProps: { style: { fontSize: "90%" } },
|
|
253
587
|
content: "API response goes here",
|
|
254
588
|
isLoading: true
|
|
255
589
|
};
|
|
@@ -261,9 +595,11 @@ var init_ai_service = __esm({
|
|
|
261
595
|
role: "bot",
|
|
262
596
|
name: BOT_NAME,
|
|
263
597
|
avatar: import_patternfly_avatar.default,
|
|
598
|
+
avatarProps: { style: { fontSize: "90%" } },
|
|
264
599
|
content,
|
|
265
600
|
extraContent,
|
|
266
|
-
isLoading: false
|
|
601
|
+
isLoading: false,
|
|
602
|
+
timestamp: (/* @__PURE__ */ new Date()).toLocaleString()
|
|
267
603
|
};
|
|
268
604
|
}
|
|
269
605
|
extractThink(message) {
|
|
@@ -274,2850 +610,541 @@ var init_ai_service = __esm({
|
|
|
274
610
|
}
|
|
275
611
|
return { content, think };
|
|
276
612
|
}
|
|
277
|
-
toBotMessage(answer,
|
|
613
|
+
toBotMessage(answer, autoApproved, ThinkInfo2, ToolCallsInfo2, ToolCallsApprove2) {
|
|
278
614
|
if (typeof answer === "string") {
|
|
279
|
-
return
|
|
615
|
+
return this.createBotMessage(`Error: ${answer}`);
|
|
280
616
|
}
|
|
281
617
|
if (!answer.tool_calls || answer.tool_calls.length === 0) {
|
|
282
|
-
const { content: content2, think } =
|
|
283
|
-
const
|
|
284
|
-
return
|
|
618
|
+
const { content: content2, think } = this.extractThink(answer);
|
|
619
|
+
const extraContent = think ? { beforeMainContent: (0, import_react5.createElement)(ThinkInfo2, { think }) } : void 0;
|
|
620
|
+
return this.createBotMessage(content2, extraContent);
|
|
285
621
|
}
|
|
286
622
|
const toolCalls = answer.tool_calls;
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
623
|
+
const isMultiple = toolCalls.length > 1;
|
|
624
|
+
const toolNames = toolCalls.map((call) => `**${call.name}**`).filter((name, index, self) => self.indexOf(name) === index).join(", ");
|
|
625
|
+
const beforeMainContent = toolCalls.map((call, index) => (0, import_react5.createElement)(ToolCallsInfo2, { key: index, call, index }));
|
|
626
|
+
if (autoApproved) {
|
|
627
|
+
const content2 = `Auto-approved ${toolCalls.length} tool ${isMultiple ? "calls" : "call"}: ${toolNames}`;
|
|
628
|
+
return this.createBotMessage(content2, { beforeMainContent });
|
|
629
|
+
}
|
|
630
|
+
const content = `${BOT_NAME} wants to use ${isMultiple ? "tools" : "a tool"}: ${toolNames}`;
|
|
631
|
+
const botMessage = this.createBotMessage(content);
|
|
632
|
+
botMessage.extraContent = {
|
|
633
|
+
beforeMainContent,
|
|
634
|
+
afterMainContent: (0, import_react5.createElement)(ToolCallsApprove2, { toolCalls, messageId: botMessage.id })
|
|
291
635
|
};
|
|
292
|
-
return
|
|
636
|
+
return botMessage;
|
|
293
637
|
}
|
|
294
638
|
};
|
|
295
639
|
aiService = new AiService();
|
|
296
640
|
}
|
|
297
641
|
});
|
|
298
642
|
|
|
299
|
-
// src/ai-plugin/
|
|
300
|
-
var
|
|
301
|
-
var
|
|
302
|
-
"src/ai-plugin/
|
|
643
|
+
// src/ai-plugin/chat/model.ts
|
|
644
|
+
var ChatbotDialog;
|
|
645
|
+
var init_model = __esm({
|
|
646
|
+
"src/ai-plugin/chat/model.ts"() {
|
|
303
647
|
"use strict";
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
};
|
|
310
|
-
AiPreferencesService = class {
|
|
311
|
-
loadOptions() {
|
|
312
|
-
const item = localStorage.getItem(STORAGE_KEY_PREFERENCES);
|
|
313
|
-
const savedOptions = item ? JSON.parse(item) : {};
|
|
314
|
-
return { ...DEFAULT_OPTIONS, ...savedOptions };
|
|
648
|
+
ChatbotDialog = class {
|
|
649
|
+
constructor(messages, summary) {
|
|
650
|
+
this.messages = messages;
|
|
651
|
+
this.summary = summary;
|
|
652
|
+
this.id = messages[0]?.id ?? "";
|
|
315
653
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
654
|
+
messages;
|
|
655
|
+
summary;
|
|
656
|
+
id;
|
|
657
|
+
setMessages(messages) {
|
|
658
|
+
if (messages[0]?.id !== this.id) {
|
|
659
|
+
throw new Error("Not the same dialog");
|
|
321
660
|
}
|
|
661
|
+
this.messages = [...messages];
|
|
662
|
+
}
|
|
663
|
+
createConversation() {
|
|
664
|
+
const text = this.summary ?? (this.messages[0]?.content ?? "").substring(0, 20);
|
|
665
|
+
return { id: this.id, text };
|
|
322
666
|
}
|
|
323
667
|
};
|
|
324
|
-
aiPreferencesService = new AiPreferencesService();
|
|
325
668
|
}
|
|
326
669
|
});
|
|
327
670
|
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
var l = b ? /* @__PURE__ */ Symbol.for("react.async_mode") : 60111;
|
|
341
|
-
var m = b ? /* @__PURE__ */ Symbol.for("react.concurrent_mode") : 60111;
|
|
342
|
-
var n = b ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112;
|
|
343
|
-
var p = b ? /* @__PURE__ */ Symbol.for("react.suspense") : 60113;
|
|
344
|
-
var q = b ? /* @__PURE__ */ Symbol.for("react.suspense_list") : 60120;
|
|
345
|
-
var r = b ? /* @__PURE__ */ Symbol.for("react.memo") : 60115;
|
|
346
|
-
var t = b ? /* @__PURE__ */ Symbol.for("react.lazy") : 60116;
|
|
347
|
-
var v = b ? /* @__PURE__ */ Symbol.for("react.block") : 60121;
|
|
348
|
-
var w = b ? /* @__PURE__ */ Symbol.for("react.fundamental") : 60117;
|
|
349
|
-
var x = b ? /* @__PURE__ */ Symbol.for("react.responder") : 60118;
|
|
350
|
-
var y = b ? /* @__PURE__ */ Symbol.for("react.scope") : 60119;
|
|
351
|
-
function z(a) {
|
|
352
|
-
if ("object" === typeof a && null !== a) {
|
|
353
|
-
var u = a.$$typeof;
|
|
354
|
-
switch (u) {
|
|
355
|
-
case c:
|
|
356
|
-
switch (a = a.type, a) {
|
|
357
|
-
case l:
|
|
358
|
-
case m:
|
|
359
|
-
case e:
|
|
360
|
-
case g:
|
|
361
|
-
case f:
|
|
362
|
-
case p:
|
|
363
|
-
return a;
|
|
364
|
-
default:
|
|
365
|
-
switch (a = a && a.$$typeof, a) {
|
|
366
|
-
case k:
|
|
367
|
-
case n:
|
|
368
|
-
case t:
|
|
369
|
-
case r:
|
|
370
|
-
case h:
|
|
371
|
-
return a;
|
|
372
|
-
default:
|
|
373
|
-
return u;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
case d:
|
|
377
|
-
return u;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
671
|
+
// src/ai-plugin/chat/context.ts
|
|
672
|
+
function useChatbot() {
|
|
673
|
+
const [messages, setMessages] = (0, import_react6.useState)([]);
|
|
674
|
+
const [dialogs, setDialogs] = (0, import_react6.useState)([]);
|
|
675
|
+
const [conversations, setConversations] = (0, import_react6.useState)([]);
|
|
676
|
+
const [announcement, setAnnouncement] = (0, import_react6.useState)("");
|
|
677
|
+
const [isChatbotOpen, setIsChatbotOpen] = (0, import_react6.useState)(false);
|
|
678
|
+
const [isSendButtonDisabled, setIsSendButtonDisabled] = (0, import_react6.useState)(false);
|
|
679
|
+
const updateConversations = (messages2, summary) => {
|
|
680
|
+
const dialogId = messages2[0]?.id;
|
|
681
|
+
if (!dialogId) {
|
|
682
|
+
return;
|
|
380
683
|
}
|
|
381
|
-
|
|
382
|
-
|
|
684
|
+
setMessages(messages2);
|
|
685
|
+
let dialog = dialogs.find((d) => d.id === dialogId);
|
|
686
|
+
if (dialog) {
|
|
687
|
+
dialog.setMessages(messages2);
|
|
688
|
+
} else {
|
|
689
|
+
dialog = new ChatbotDialog(messages2, summary);
|
|
690
|
+
dialogs.push(dialog);
|
|
383
691
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
692
|
+
setDialogs([...dialogs]);
|
|
693
|
+
log.debug("Updated dialogs:", dialogs);
|
|
694
|
+
if (!conversations.some((c) => c.id === dialogId)) {
|
|
695
|
+
const conversation = dialog.createConversation();
|
|
696
|
+
conversations.push(conversation);
|
|
697
|
+
setConversations([...conversations]);
|
|
698
|
+
log.debug("Updated conversations:", conversations);
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
return {
|
|
702
|
+
messages,
|
|
703
|
+
setMessages,
|
|
704
|
+
dialogs,
|
|
705
|
+
setDialogs,
|
|
706
|
+
conversations,
|
|
707
|
+
setConversations,
|
|
708
|
+
announcement,
|
|
709
|
+
setAnnouncement,
|
|
710
|
+
isChatbotOpen,
|
|
711
|
+
setIsChatbotOpen,
|
|
712
|
+
isSendButtonDisabled,
|
|
713
|
+
setIsSendButtonDisabled,
|
|
714
|
+
updateConversations
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
var import_react6, ChatbotContext;
|
|
718
|
+
var init_context = __esm({
|
|
719
|
+
"src/ai-plugin/chat/context.ts"() {
|
|
720
|
+
"use strict";
|
|
721
|
+
import_react6 = require("react");
|
|
722
|
+
init_globals();
|
|
723
|
+
init_model();
|
|
724
|
+
ChatbotContext = (0, import_react6.createContext)({
|
|
725
|
+
messages: [],
|
|
726
|
+
setMessages: () => {
|
|
727
|
+
},
|
|
728
|
+
dialogs: [],
|
|
729
|
+
setDialogs: () => {
|
|
730
|
+
},
|
|
731
|
+
conversations: [],
|
|
732
|
+
setConversations: () => {
|
|
733
|
+
},
|
|
734
|
+
announcement: "",
|
|
735
|
+
setAnnouncement: () => {
|
|
736
|
+
},
|
|
737
|
+
isChatbotOpen: false,
|
|
738
|
+
setIsChatbotOpen: () => {
|
|
739
|
+
},
|
|
740
|
+
isSendButtonDisabled: false,
|
|
741
|
+
setIsSendButtonDisabled: () => {
|
|
742
|
+
},
|
|
743
|
+
updateConversations: () => {
|
|
744
|
+
}
|
|
745
|
+
});
|
|
438
746
|
}
|
|
439
747
|
});
|
|
440
748
|
|
|
441
|
-
//
|
|
442
|
-
var
|
|
443
|
-
|
|
749
|
+
// src/ai-plugin/chat/ThinkInfo.tsx
|
|
750
|
+
var import_MarkdownContent, import_react_core, import_jsx_runtime, ThinkInfo;
|
|
751
|
+
var init_ThinkInfo = __esm({
|
|
752
|
+
"src/ai-plugin/chat/ThinkInfo.tsx"() {
|
|
444
753
|
"use strict";
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.fragment") : 60107;
|
|
452
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.strict_mode") : 60108;
|
|
453
|
-
var REACT_PROFILER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.profiler") : 60114;
|
|
454
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.provider") : 60109;
|
|
455
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.context") : 60110;
|
|
456
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.async_mode") : 60111;
|
|
457
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.concurrent_mode") : 60111;
|
|
458
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112;
|
|
459
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.suspense") : 60113;
|
|
460
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.suspense_list") : 60120;
|
|
461
|
-
var REACT_MEMO_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.memo") : 60115;
|
|
462
|
-
var REACT_LAZY_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.lazy") : 60116;
|
|
463
|
-
var REACT_BLOCK_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.block") : 60121;
|
|
464
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.fundamental") : 60117;
|
|
465
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.responder") : 60118;
|
|
466
|
-
var REACT_SCOPE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.scope") : 60119;
|
|
467
|
-
function isValidElementType(type) {
|
|
468
|
-
return typeof type === "string" || typeof type === "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
469
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
470
|
-
}
|
|
471
|
-
function typeOf(object) {
|
|
472
|
-
if (typeof object === "object" && object !== null) {
|
|
473
|
-
var $$typeof = object.$$typeof;
|
|
474
|
-
switch ($$typeof) {
|
|
475
|
-
case REACT_ELEMENT_TYPE:
|
|
476
|
-
var type = object.type;
|
|
477
|
-
switch (type) {
|
|
478
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
479
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
480
|
-
case REACT_FRAGMENT_TYPE:
|
|
481
|
-
case REACT_PROFILER_TYPE:
|
|
482
|
-
case REACT_STRICT_MODE_TYPE:
|
|
483
|
-
case REACT_SUSPENSE_TYPE:
|
|
484
|
-
return type;
|
|
485
|
-
default:
|
|
486
|
-
var $$typeofType = type && type.$$typeof;
|
|
487
|
-
switch ($$typeofType) {
|
|
488
|
-
case REACT_CONTEXT_TYPE:
|
|
489
|
-
case REACT_FORWARD_REF_TYPE:
|
|
490
|
-
case REACT_LAZY_TYPE:
|
|
491
|
-
case REACT_MEMO_TYPE:
|
|
492
|
-
case REACT_PROVIDER_TYPE:
|
|
493
|
-
return $$typeofType;
|
|
494
|
-
default:
|
|
495
|
-
return $$typeof;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
case REACT_PORTAL_TYPE:
|
|
499
|
-
return $$typeof;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return void 0;
|
|
503
|
-
}
|
|
504
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
505
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
506
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
507
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
508
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
509
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
510
|
-
var Fragment2 = REACT_FRAGMENT_TYPE;
|
|
511
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
512
|
-
var Memo = REACT_MEMO_TYPE;
|
|
513
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
514
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
515
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
516
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
517
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
|
518
|
-
function isAsyncMode(object) {
|
|
519
|
-
{
|
|
520
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
521
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true;
|
|
522
|
-
console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
526
|
-
}
|
|
527
|
-
function isConcurrentMode(object) {
|
|
528
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
529
|
-
}
|
|
530
|
-
function isContextConsumer(object) {
|
|
531
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
532
|
-
}
|
|
533
|
-
function isContextProvider(object) {
|
|
534
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
535
|
-
}
|
|
536
|
-
function isElement(object) {
|
|
537
|
-
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
538
|
-
}
|
|
539
|
-
function isForwardRef(object) {
|
|
540
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
541
|
-
}
|
|
542
|
-
function isFragment(object) {
|
|
543
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
544
|
-
}
|
|
545
|
-
function isLazy(object) {
|
|
546
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
547
|
-
}
|
|
548
|
-
function isMemo(object) {
|
|
549
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
550
|
-
}
|
|
551
|
-
function isPortal(object) {
|
|
552
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
553
|
-
}
|
|
554
|
-
function isProfiler(object) {
|
|
555
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
556
|
-
}
|
|
557
|
-
function isStrictMode(object) {
|
|
558
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
559
|
-
}
|
|
560
|
-
function isSuspense(object) {
|
|
561
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
562
|
-
}
|
|
563
|
-
exports2.AsyncMode = AsyncMode;
|
|
564
|
-
exports2.ConcurrentMode = ConcurrentMode;
|
|
565
|
-
exports2.ContextConsumer = ContextConsumer;
|
|
566
|
-
exports2.ContextProvider = ContextProvider;
|
|
567
|
-
exports2.Element = Element;
|
|
568
|
-
exports2.ForwardRef = ForwardRef;
|
|
569
|
-
exports2.Fragment = Fragment2;
|
|
570
|
-
exports2.Lazy = Lazy;
|
|
571
|
-
exports2.Memo = Memo;
|
|
572
|
-
exports2.Portal = Portal;
|
|
573
|
-
exports2.Profiler = Profiler;
|
|
574
|
-
exports2.StrictMode = StrictMode;
|
|
575
|
-
exports2.Suspense = Suspense;
|
|
576
|
-
exports2.isAsyncMode = isAsyncMode;
|
|
577
|
-
exports2.isConcurrentMode = isConcurrentMode;
|
|
578
|
-
exports2.isContextConsumer = isContextConsumer;
|
|
579
|
-
exports2.isContextProvider = isContextProvider;
|
|
580
|
-
exports2.isElement = isElement;
|
|
581
|
-
exports2.isForwardRef = isForwardRef;
|
|
582
|
-
exports2.isFragment = isFragment;
|
|
583
|
-
exports2.isLazy = isLazy;
|
|
584
|
-
exports2.isMemo = isMemo;
|
|
585
|
-
exports2.isPortal = isPortal;
|
|
586
|
-
exports2.isProfiler = isProfiler;
|
|
587
|
-
exports2.isStrictMode = isStrictMode;
|
|
588
|
-
exports2.isSuspense = isSuspense;
|
|
589
|
-
exports2.isValidElementType = isValidElementType;
|
|
590
|
-
exports2.typeOf = typeOf;
|
|
591
|
-
})();
|
|
592
|
-
}
|
|
754
|
+
import_MarkdownContent = __toESM(require("@patternfly/chatbot/dist/dynamic/MarkdownContent"));
|
|
755
|
+
import_react_core = require("@patternfly/react-core");
|
|
756
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
757
|
+
ThinkInfo = ({ think }) => {
|
|
758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_core.Alert, { variant: "info", title: "Thinking", isExpandable: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MarkdownContent.default, { content: think }) });
|
|
759
|
+
};
|
|
593
760
|
}
|
|
594
761
|
});
|
|
595
762
|
|
|
596
|
-
//
|
|
597
|
-
var
|
|
598
|
-
|
|
763
|
+
// src/ai-plugin/chat/ToolCallsInfo.tsx
|
|
764
|
+
var import_react_core2, import_wrench_icon, import_jsx_runtime2, ToolCallsInfo;
|
|
765
|
+
var init_ToolCallsInfo = __esm({
|
|
766
|
+
"src/ai-plugin/chat/ToolCallsInfo.tsx"() {
|
|
599
767
|
"use strict";
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
// node_modules/object-assign/index.js
|
|
609
|
-
var require_object_assign = __commonJS({
|
|
610
|
-
"node_modules/object-assign/index.js"(exports2, module2) {
|
|
611
|
-
"use strict";
|
|
612
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
613
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
614
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
615
|
-
function toObject(val) {
|
|
616
|
-
if (val === null || val === void 0) {
|
|
617
|
-
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
618
|
-
}
|
|
619
|
-
return Object(val);
|
|
620
|
-
}
|
|
621
|
-
function shouldUseNative() {
|
|
622
|
-
try {
|
|
623
|
-
if (!Object.assign) {
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
var test1 = new String("abc");
|
|
627
|
-
test1[5] = "de";
|
|
628
|
-
if (Object.getOwnPropertyNames(test1)[0] === "5") {
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
var test2 = {};
|
|
632
|
-
for (var i = 0; i < 10; i++) {
|
|
633
|
-
test2["_" + String.fromCharCode(i)] = i;
|
|
634
|
-
}
|
|
635
|
-
var order22 = Object.getOwnPropertyNames(test2).map(function(n) {
|
|
636
|
-
return test2[n];
|
|
637
|
-
});
|
|
638
|
-
if (order22.join("") !== "0123456789") {
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
var test3 = {};
|
|
642
|
-
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
643
|
-
test3[letter] = letter;
|
|
644
|
-
});
|
|
645
|
-
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
648
|
-
return true;
|
|
649
|
-
} catch (err) {
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
module2.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
|
654
|
-
var from;
|
|
655
|
-
var to = toObject(target);
|
|
656
|
-
var symbols;
|
|
657
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
658
|
-
from = Object(arguments[s]);
|
|
659
|
-
for (var key in from) {
|
|
660
|
-
if (hasOwnProperty.call(from, key)) {
|
|
661
|
-
to[key] = from[key];
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (getOwnPropertySymbols) {
|
|
665
|
-
symbols = getOwnPropertySymbols(from);
|
|
666
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
667
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
668
|
-
to[symbols[i]] = from[symbols[i]];
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
return to;
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
// node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
679
|
-
var require_ReactPropTypesSecret = __commonJS({
|
|
680
|
-
"node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports2, module2) {
|
|
681
|
-
"use strict";
|
|
682
|
-
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
683
|
-
module2.exports = ReactPropTypesSecret;
|
|
684
|
-
}
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
// node_modules/prop-types/lib/has.js
|
|
688
|
-
var require_has = __commonJS({
|
|
689
|
-
"node_modules/prop-types/lib/has.js"(exports2, module2) {
|
|
690
|
-
"use strict";
|
|
691
|
-
module2.exports = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// node_modules/prop-types/checkPropTypes.js
|
|
696
|
-
var require_checkPropTypes = __commonJS({
|
|
697
|
-
"node_modules/prop-types/checkPropTypes.js"(exports2, module2) {
|
|
698
|
-
"use strict";
|
|
699
|
-
var printWarning = function() {
|
|
700
|
-
};
|
|
701
|
-
if (process.env.NODE_ENV !== "production") {
|
|
702
|
-
ReactPropTypesSecret = require_ReactPropTypesSecret();
|
|
703
|
-
loggedTypeFailures = {};
|
|
704
|
-
has = require_has();
|
|
705
|
-
printWarning = function(text) {
|
|
706
|
-
var message = "Warning: " + text;
|
|
707
|
-
if (typeof console !== "undefined") {
|
|
708
|
-
console.error(message);
|
|
709
|
-
}
|
|
710
|
-
try {
|
|
711
|
-
throw new Error(message);
|
|
712
|
-
} catch (x) {
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
var ReactPropTypesSecret;
|
|
717
|
-
var loggedTypeFailures;
|
|
718
|
-
var has;
|
|
719
|
-
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
720
|
-
if (process.env.NODE_ENV !== "production") {
|
|
721
|
-
for (var typeSpecName in typeSpecs) {
|
|
722
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
723
|
-
var error;
|
|
724
|
-
try {
|
|
725
|
-
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
726
|
-
var err = Error(
|
|
727
|
-
(componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
|
|
728
|
-
);
|
|
729
|
-
err.name = "Invariant Violation";
|
|
730
|
-
throw err;
|
|
731
|
-
}
|
|
732
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
733
|
-
} catch (ex) {
|
|
734
|
-
error = ex;
|
|
735
|
-
}
|
|
736
|
-
if (error && !(error instanceof Error)) {
|
|
737
|
-
printWarning(
|
|
738
|
-
(componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
|
|
739
|
-
);
|
|
740
|
-
}
|
|
741
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
742
|
-
loggedTypeFailures[error.message] = true;
|
|
743
|
-
var stack = getStack ? getStack() : "";
|
|
744
|
-
printWarning(
|
|
745
|
-
"Failed " + location + " type: " + error.message + (stack != null ? stack : "")
|
|
746
|
-
);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
checkPropTypes.resetWarningCache = function() {
|
|
753
|
-
if (process.env.NODE_ENV !== "production") {
|
|
754
|
-
loggedTypeFailures = {};
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
module2.exports = checkPropTypes;
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
// node_modules/prop-types/factoryWithTypeCheckers.js
|
|
762
|
-
var require_factoryWithTypeCheckers = __commonJS({
|
|
763
|
-
"node_modules/prop-types/factoryWithTypeCheckers.js"(exports2, module2) {
|
|
764
|
-
"use strict";
|
|
765
|
-
var ReactIs = require_react_is();
|
|
766
|
-
var assign = require_object_assign();
|
|
767
|
-
var ReactPropTypesSecret = require_ReactPropTypesSecret();
|
|
768
|
-
var has = require_has();
|
|
769
|
-
var checkPropTypes = require_checkPropTypes();
|
|
770
|
-
var printWarning = function() {
|
|
771
|
-
};
|
|
772
|
-
if (process.env.NODE_ENV !== "production") {
|
|
773
|
-
printWarning = function(text) {
|
|
774
|
-
var message = "Warning: " + text;
|
|
775
|
-
if (typeof console !== "undefined") {
|
|
776
|
-
console.error(message);
|
|
777
|
-
}
|
|
778
|
-
try {
|
|
779
|
-
throw new Error(message);
|
|
780
|
-
} catch (x) {
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
function emptyFunctionThatReturnsNull() {
|
|
785
|
-
return null;
|
|
786
|
-
}
|
|
787
|
-
module2.exports = function(isValidElement, throwOnDirectAccess) {
|
|
788
|
-
var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
|
789
|
-
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
790
|
-
function getIteratorFn(maybeIterable) {
|
|
791
|
-
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
792
|
-
if (typeof iteratorFn === "function") {
|
|
793
|
-
return iteratorFn;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
var ANONYMOUS = "<<anonymous>>";
|
|
797
|
-
var ReactPropTypes = {
|
|
798
|
-
array: createPrimitiveTypeChecker("array"),
|
|
799
|
-
bigint: createPrimitiveTypeChecker("bigint"),
|
|
800
|
-
bool: createPrimitiveTypeChecker("boolean"),
|
|
801
|
-
func: createPrimitiveTypeChecker("function"),
|
|
802
|
-
number: createPrimitiveTypeChecker("number"),
|
|
803
|
-
object: createPrimitiveTypeChecker("object"),
|
|
804
|
-
string: createPrimitiveTypeChecker("string"),
|
|
805
|
-
symbol: createPrimitiveTypeChecker("symbol"),
|
|
806
|
-
any: createAnyTypeChecker(),
|
|
807
|
-
arrayOf: createArrayOfTypeChecker,
|
|
808
|
-
element: createElementTypeChecker(),
|
|
809
|
-
elementType: createElementTypeTypeChecker(),
|
|
810
|
-
instanceOf: createInstanceTypeChecker,
|
|
811
|
-
node: createNodeChecker(),
|
|
812
|
-
objectOf: createObjectOfTypeChecker,
|
|
813
|
-
oneOf: createEnumTypeChecker,
|
|
814
|
-
oneOfType: createUnionTypeChecker,
|
|
815
|
-
shape: createShapeTypeChecker,
|
|
816
|
-
exact: createStrictShapeTypeChecker
|
|
817
|
-
};
|
|
818
|
-
function is(x, y) {
|
|
819
|
-
if (x === y) {
|
|
820
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
821
|
-
} else {
|
|
822
|
-
return x !== x && y !== y;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
function PropTypeError(message, data) {
|
|
826
|
-
this.message = message;
|
|
827
|
-
this.data = data && typeof data === "object" ? data : {};
|
|
828
|
-
this.stack = "";
|
|
829
|
-
}
|
|
830
|
-
PropTypeError.prototype = Error.prototype;
|
|
831
|
-
function createChainableTypeChecker(validate) {
|
|
832
|
-
if (process.env.NODE_ENV !== "production") {
|
|
833
|
-
var manualPropTypeCallCache = {};
|
|
834
|
-
var manualPropTypeWarningCount = 0;
|
|
835
|
-
}
|
|
836
|
-
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
837
|
-
componentName = componentName || ANONYMOUS;
|
|
838
|
-
propFullName = propFullName || propName;
|
|
839
|
-
if (secret !== ReactPropTypesSecret) {
|
|
840
|
-
if (throwOnDirectAccess) {
|
|
841
|
-
var err = new Error(
|
|
842
|
-
"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
|
|
843
|
-
);
|
|
844
|
-
err.name = "Invariant Violation";
|
|
845
|
-
throw err;
|
|
846
|
-
} else if (process.env.NODE_ENV !== "production" && typeof console !== "undefined") {
|
|
847
|
-
var cacheKey = componentName + ":" + propName;
|
|
848
|
-
if (!manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors
|
|
849
|
-
manualPropTypeWarningCount < 3) {
|
|
850
|
-
printWarning(
|
|
851
|
-
"You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."
|
|
852
|
-
);
|
|
853
|
-
manualPropTypeCallCache[cacheKey] = true;
|
|
854
|
-
manualPropTypeWarningCount++;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
if (props[propName] == null) {
|
|
859
|
-
if (isRequired) {
|
|
860
|
-
if (props[propName] === null) {
|
|
861
|
-
return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
|
|
862
|
-
}
|
|
863
|
-
return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
|
|
864
|
-
}
|
|
865
|
-
return null;
|
|
866
|
-
} else {
|
|
867
|
-
return validate(props, propName, componentName, location, propFullName);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
var chainedCheckType = checkType.bind(null, false);
|
|
871
|
-
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
872
|
-
return chainedCheckType;
|
|
873
|
-
}
|
|
874
|
-
function createPrimitiveTypeChecker(expectedType) {
|
|
875
|
-
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
876
|
-
var propValue = props[propName];
|
|
877
|
-
var propType = getPropType(propValue);
|
|
878
|
-
if (propType !== expectedType) {
|
|
879
|
-
var preciseType = getPreciseType(propValue);
|
|
880
|
-
return new PropTypeError(
|
|
881
|
-
"Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."),
|
|
882
|
-
{ expectedType }
|
|
883
|
-
);
|
|
884
|
-
}
|
|
885
|
-
return null;
|
|
886
|
-
}
|
|
887
|
-
return createChainableTypeChecker(validate);
|
|
888
|
-
}
|
|
889
|
-
function createAnyTypeChecker() {
|
|
890
|
-
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
891
|
-
}
|
|
892
|
-
function createArrayOfTypeChecker(typeChecker) {
|
|
893
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
894
|
-
if (typeof typeChecker !== "function") {
|
|
895
|
-
return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
|
|
896
|
-
}
|
|
897
|
-
var propValue = props[propName];
|
|
898
|
-
if (!Array.isArray(propValue)) {
|
|
899
|
-
var propType = getPropType(propValue);
|
|
900
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
|
|
901
|
-
}
|
|
902
|
-
for (var i = 0; i < propValue.length; i++) {
|
|
903
|
-
var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
|
|
904
|
-
if (error instanceof Error) {
|
|
905
|
-
return error;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
return null;
|
|
909
|
-
}
|
|
910
|
-
return createChainableTypeChecker(validate);
|
|
911
|
-
}
|
|
912
|
-
function createElementTypeChecker() {
|
|
913
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
914
|
-
var propValue = props[propName];
|
|
915
|
-
if (!isValidElement(propValue)) {
|
|
916
|
-
var propType = getPropType(propValue);
|
|
917
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
|
|
918
|
-
}
|
|
919
|
-
return null;
|
|
920
|
-
}
|
|
921
|
-
return createChainableTypeChecker(validate);
|
|
922
|
-
}
|
|
923
|
-
function createElementTypeTypeChecker() {
|
|
924
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
925
|
-
var propValue = props[propName];
|
|
926
|
-
if (!ReactIs.isValidElementType(propValue)) {
|
|
927
|
-
var propType = getPropType(propValue);
|
|
928
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
|
|
929
|
-
}
|
|
930
|
-
return null;
|
|
931
|
-
}
|
|
932
|
-
return createChainableTypeChecker(validate);
|
|
933
|
-
}
|
|
934
|
-
function createInstanceTypeChecker(expectedClass) {
|
|
935
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
936
|
-
if (!(props[propName] instanceof expectedClass)) {
|
|
937
|
-
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
938
|
-
var actualClassName = getClassName(props[propName]);
|
|
939
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
|
|
940
|
-
}
|
|
941
|
-
return null;
|
|
942
|
-
}
|
|
943
|
-
return createChainableTypeChecker(validate);
|
|
944
|
-
}
|
|
945
|
-
function createEnumTypeChecker(expectedValues) {
|
|
946
|
-
if (!Array.isArray(expectedValues)) {
|
|
947
|
-
if (process.env.NODE_ENV !== "production") {
|
|
948
|
-
if (arguments.length > 1) {
|
|
949
|
-
printWarning(
|
|
950
|
-
"Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."
|
|
951
|
-
);
|
|
952
|
-
} else {
|
|
953
|
-
printWarning("Invalid argument supplied to oneOf, expected an array.");
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
return emptyFunctionThatReturnsNull;
|
|
957
|
-
}
|
|
958
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
959
|
-
var propValue = props[propName];
|
|
960
|
-
for (var i = 0; i < expectedValues.length; i++) {
|
|
961
|
-
if (is(propValue, expectedValues[i])) {
|
|
962
|
-
return null;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
966
|
-
var type = getPreciseType(value);
|
|
967
|
-
if (type === "symbol") {
|
|
968
|
-
return String(value);
|
|
969
|
-
}
|
|
970
|
-
return value;
|
|
971
|
-
});
|
|
972
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
|
|
973
|
-
}
|
|
974
|
-
return createChainableTypeChecker(validate);
|
|
975
|
-
}
|
|
976
|
-
function createObjectOfTypeChecker(typeChecker) {
|
|
977
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
978
|
-
if (typeof typeChecker !== "function") {
|
|
979
|
-
return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
|
|
980
|
-
}
|
|
981
|
-
var propValue = props[propName];
|
|
982
|
-
var propType = getPropType(propValue);
|
|
983
|
-
if (propType !== "object") {
|
|
984
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
|
|
985
|
-
}
|
|
986
|
-
for (var key in propValue) {
|
|
987
|
-
if (has(propValue, key)) {
|
|
988
|
-
var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
|
989
|
-
if (error instanceof Error) {
|
|
990
|
-
return error;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
return null;
|
|
995
|
-
}
|
|
996
|
-
return createChainableTypeChecker(validate);
|
|
997
|
-
}
|
|
998
|
-
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
999
|
-
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
1000
|
-
process.env.NODE_ENV !== "production" ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0;
|
|
1001
|
-
return emptyFunctionThatReturnsNull;
|
|
1002
|
-
}
|
|
1003
|
-
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
1004
|
-
var checker = arrayOfTypeCheckers[i];
|
|
1005
|
-
if (typeof checker !== "function") {
|
|
1006
|
-
printWarning(
|
|
1007
|
-
"Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i + "."
|
|
1008
|
-
);
|
|
1009
|
-
return emptyFunctionThatReturnsNull;
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1013
|
-
var expectedTypes = [];
|
|
1014
|
-
for (var i2 = 0; i2 < arrayOfTypeCheckers.length; i2++) {
|
|
1015
|
-
var checker2 = arrayOfTypeCheckers[i2];
|
|
1016
|
-
var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
1017
|
-
if (checkerResult == null) {
|
|
1018
|
-
return null;
|
|
1019
|
-
}
|
|
1020
|
-
if (checkerResult.data && has(checkerResult.data, "expectedType")) {
|
|
1021
|
-
expectedTypes.push(checkerResult.data.expectedType);
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
|
|
1025
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
|
|
1026
|
-
}
|
|
1027
|
-
return createChainableTypeChecker(validate);
|
|
1028
|
-
}
|
|
1029
|
-
function createNodeChecker() {
|
|
1030
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1031
|
-
if (!isNode(props[propName])) {
|
|
1032
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
|
|
1033
|
-
}
|
|
1034
|
-
return null;
|
|
1035
|
-
}
|
|
1036
|
-
return createChainableTypeChecker(validate);
|
|
1037
|
-
}
|
|
1038
|
-
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
1039
|
-
return new PropTypeError(
|
|
1040
|
-
(componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`."
|
|
1041
|
-
);
|
|
1042
|
-
}
|
|
1043
|
-
function createShapeTypeChecker(shapeTypes) {
|
|
1044
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1045
|
-
var propValue = props[propName];
|
|
1046
|
-
var propType = getPropType(propValue);
|
|
1047
|
-
if (propType !== "object") {
|
|
1048
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
|
|
1049
|
-
}
|
|
1050
|
-
for (var key in shapeTypes) {
|
|
1051
|
-
var checker = shapeTypes[key];
|
|
1052
|
-
if (typeof checker !== "function") {
|
|
1053
|
-
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
1054
|
-
}
|
|
1055
|
-
var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
|
1056
|
-
if (error) {
|
|
1057
|
-
return error;
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
return null;
|
|
1061
|
-
}
|
|
1062
|
-
return createChainableTypeChecker(validate);
|
|
1063
|
-
}
|
|
1064
|
-
function createStrictShapeTypeChecker(shapeTypes) {
|
|
1065
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1066
|
-
var propValue = props[propName];
|
|
1067
|
-
var propType = getPropType(propValue);
|
|
1068
|
-
if (propType !== "object") {
|
|
1069
|
-
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
|
|
1070
|
-
}
|
|
1071
|
-
var allKeys = assign({}, props[propName], shapeTypes);
|
|
1072
|
-
for (var key in allKeys) {
|
|
1073
|
-
var checker = shapeTypes[key];
|
|
1074
|
-
if (has(shapeTypes, key) && typeof checker !== "function") {
|
|
1075
|
-
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
1076
|
-
}
|
|
1077
|
-
if (!checker) {
|
|
1078
|
-
return new PropTypeError(
|
|
1079
|
-
"Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ")
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
|
1083
|
-
if (error) {
|
|
1084
|
-
return error;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
return null;
|
|
1088
|
-
}
|
|
1089
|
-
return createChainableTypeChecker(validate);
|
|
1090
|
-
}
|
|
1091
|
-
function isNode(propValue) {
|
|
1092
|
-
switch (typeof propValue) {
|
|
1093
|
-
case "number":
|
|
1094
|
-
case "string":
|
|
1095
|
-
case "undefined":
|
|
1096
|
-
return true;
|
|
1097
|
-
case "boolean":
|
|
1098
|
-
return !propValue;
|
|
1099
|
-
case "object":
|
|
1100
|
-
if (Array.isArray(propValue)) {
|
|
1101
|
-
return propValue.every(isNode);
|
|
1102
|
-
}
|
|
1103
|
-
if (propValue === null || isValidElement(propValue)) {
|
|
1104
|
-
return true;
|
|
1105
|
-
}
|
|
1106
|
-
var iteratorFn = getIteratorFn(propValue);
|
|
1107
|
-
if (iteratorFn) {
|
|
1108
|
-
var iterator = iteratorFn.call(propValue);
|
|
1109
|
-
var step;
|
|
1110
|
-
if (iteratorFn !== propValue.entries) {
|
|
1111
|
-
while (!(step = iterator.next()).done) {
|
|
1112
|
-
if (!isNode(step.value)) {
|
|
1113
|
-
return false;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
} else {
|
|
1117
|
-
while (!(step = iterator.next()).done) {
|
|
1118
|
-
var entry = step.value;
|
|
1119
|
-
if (entry) {
|
|
1120
|
-
if (!isNode(entry[1])) {
|
|
1121
|
-
return false;
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
} else {
|
|
1127
|
-
return false;
|
|
1128
|
-
}
|
|
1129
|
-
return true;
|
|
1130
|
-
default:
|
|
1131
|
-
return false;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
function isSymbol(propType, propValue) {
|
|
1135
|
-
if (propType === "symbol") {
|
|
1136
|
-
return true;
|
|
1137
|
-
}
|
|
1138
|
-
if (!propValue) {
|
|
1139
|
-
return false;
|
|
1140
|
-
}
|
|
1141
|
-
if (propValue["@@toStringTag"] === "Symbol") {
|
|
1142
|
-
return true;
|
|
1143
|
-
}
|
|
1144
|
-
if (typeof Symbol === "function" && propValue instanceof Symbol) {
|
|
1145
|
-
return true;
|
|
1146
|
-
}
|
|
1147
|
-
return false;
|
|
1148
|
-
}
|
|
1149
|
-
function getPropType(propValue) {
|
|
1150
|
-
var propType = typeof propValue;
|
|
1151
|
-
if (Array.isArray(propValue)) {
|
|
1152
|
-
return "array";
|
|
1153
|
-
}
|
|
1154
|
-
if (propValue instanceof RegExp) {
|
|
1155
|
-
return "object";
|
|
1156
|
-
}
|
|
1157
|
-
if (isSymbol(propType, propValue)) {
|
|
1158
|
-
return "symbol";
|
|
1159
|
-
}
|
|
1160
|
-
return propType;
|
|
1161
|
-
}
|
|
1162
|
-
function getPreciseType(propValue) {
|
|
1163
|
-
if (typeof propValue === "undefined" || propValue === null) {
|
|
1164
|
-
return "" + propValue;
|
|
1165
|
-
}
|
|
1166
|
-
var propType = getPropType(propValue);
|
|
1167
|
-
if (propType === "object") {
|
|
1168
|
-
if (propValue instanceof Date) {
|
|
1169
|
-
return "date";
|
|
1170
|
-
} else if (propValue instanceof RegExp) {
|
|
1171
|
-
return "regexp";
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
return propType;
|
|
1175
|
-
}
|
|
1176
|
-
function getPostfixForTypeWarning(value) {
|
|
1177
|
-
var type = getPreciseType(value);
|
|
1178
|
-
switch (type) {
|
|
1179
|
-
case "array":
|
|
1180
|
-
case "object":
|
|
1181
|
-
return "an " + type;
|
|
1182
|
-
case "boolean":
|
|
1183
|
-
case "date":
|
|
1184
|
-
case "regexp":
|
|
1185
|
-
return "a " + type;
|
|
1186
|
-
default:
|
|
1187
|
-
return type;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
function getClassName(propValue) {
|
|
1191
|
-
if (!propValue.constructor || !propValue.constructor.name) {
|
|
1192
|
-
return ANONYMOUS;
|
|
1193
|
-
}
|
|
1194
|
-
return propValue.constructor.name;
|
|
1195
|
-
}
|
|
1196
|
-
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
1197
|
-
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
1198
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1199
|
-
return ReactPropTypes;
|
|
1200
|
-
};
|
|
1201
|
-
}
|
|
1202
|
-
});
|
|
1203
|
-
|
|
1204
|
-
// node_modules/prop-types/factoryWithThrowingShims.js
|
|
1205
|
-
var require_factoryWithThrowingShims = __commonJS({
|
|
1206
|
-
"node_modules/prop-types/factoryWithThrowingShims.js"(exports2, module2) {
|
|
1207
|
-
"use strict";
|
|
1208
|
-
var ReactPropTypesSecret = require_ReactPropTypesSecret();
|
|
1209
|
-
function emptyFunction() {
|
|
1210
|
-
}
|
|
1211
|
-
function emptyFunctionWithReset() {
|
|
1212
|
-
}
|
|
1213
|
-
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1214
|
-
module2.exports = function() {
|
|
1215
|
-
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1216
|
-
if (secret === ReactPropTypesSecret) {
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
var err = new Error(
|
|
1220
|
-
"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
|
|
1221
|
-
);
|
|
1222
|
-
err.name = "Invariant Violation";
|
|
1223
|
-
throw err;
|
|
1224
|
-
}
|
|
1225
|
-
;
|
|
1226
|
-
shim.isRequired = shim;
|
|
1227
|
-
function getShim() {
|
|
1228
|
-
return shim;
|
|
1229
|
-
}
|
|
1230
|
-
;
|
|
1231
|
-
var ReactPropTypes = {
|
|
1232
|
-
array: shim,
|
|
1233
|
-
bigint: shim,
|
|
1234
|
-
bool: shim,
|
|
1235
|
-
func: shim,
|
|
1236
|
-
number: shim,
|
|
1237
|
-
object: shim,
|
|
1238
|
-
string: shim,
|
|
1239
|
-
symbol: shim,
|
|
1240
|
-
any: shim,
|
|
1241
|
-
arrayOf: getShim,
|
|
1242
|
-
element: shim,
|
|
1243
|
-
elementType: shim,
|
|
1244
|
-
instanceOf: getShim,
|
|
1245
|
-
node: shim,
|
|
1246
|
-
objectOf: getShim,
|
|
1247
|
-
oneOf: getShim,
|
|
1248
|
-
oneOfType: getShim,
|
|
1249
|
-
shape: getShim,
|
|
1250
|
-
exact: getShim,
|
|
1251
|
-
checkPropTypes: emptyFunctionWithReset,
|
|
1252
|
-
resetWarningCache: emptyFunction
|
|
1253
|
-
};
|
|
1254
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1255
|
-
return ReactPropTypes;
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
});
|
|
1259
|
-
|
|
1260
|
-
// node_modules/prop-types/index.js
|
|
1261
|
-
var require_prop_types = __commonJS({
|
|
1262
|
-
"node_modules/prop-types/index.js"(exports2, module2) {
|
|
1263
|
-
"use strict";
|
|
1264
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1265
|
-
ReactIs = require_react_is();
|
|
1266
|
-
throwOnDirectAccess = true;
|
|
1267
|
-
module2.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
1268
|
-
} else {
|
|
1269
|
-
module2.exports = require_factoryWithThrowingShims()();
|
|
1270
|
-
}
|
|
1271
|
-
var ReactIs;
|
|
1272
|
-
var throwOnDirectAccess;
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
|
|
1276
|
-
// node_modules/split.js/dist/split.es.js
|
|
1277
|
-
var global, ssr, document2, addEventListener, removeEventListener, getBoundingClientRect, gutterStartDragging, aGutterSize, bGutterSize, HORIZONTAL, NOOP, calc, isString, elementOrSelector, getOption, getGutterSize, defaultGutterFn, defaultElementStyleFn, defaultGutterStyleFn, Split, split_es_default;
|
|
1278
|
-
var init_split_es = __esm({
|
|
1279
|
-
"node_modules/split.js/dist/split.es.js"() {
|
|
1280
|
-
"use strict";
|
|
1281
|
-
global = typeof window !== "undefined" ? window : null;
|
|
1282
|
-
ssr = global === null;
|
|
1283
|
-
document2 = !ssr ? global.document : void 0;
|
|
1284
|
-
addEventListener = "addEventListener";
|
|
1285
|
-
removeEventListener = "removeEventListener";
|
|
1286
|
-
getBoundingClientRect = "getBoundingClientRect";
|
|
1287
|
-
gutterStartDragging = "_a";
|
|
1288
|
-
aGutterSize = "_b";
|
|
1289
|
-
bGutterSize = "_c";
|
|
1290
|
-
HORIZONTAL = "horizontal";
|
|
1291
|
-
NOOP = function() {
|
|
1292
|
-
return false;
|
|
1293
|
-
};
|
|
1294
|
-
calc = ssr ? "calc" : ["", "-webkit-", "-moz-", "-o-"].filter(function(prefix) {
|
|
1295
|
-
var el = document2.createElement("div");
|
|
1296
|
-
el.style.cssText = "width:" + prefix + "calc(9px)";
|
|
1297
|
-
return !!el.style.length;
|
|
1298
|
-
}).shift() + "calc";
|
|
1299
|
-
isString = function(v) {
|
|
1300
|
-
return typeof v === "string" || v instanceof String;
|
|
1301
|
-
};
|
|
1302
|
-
elementOrSelector = function(el) {
|
|
1303
|
-
if (isString(el)) {
|
|
1304
|
-
var ele = document2.querySelector(el);
|
|
1305
|
-
if (!ele) {
|
|
1306
|
-
throw new Error("Selector " + el + " did not match a DOM element");
|
|
1307
|
-
}
|
|
1308
|
-
return ele;
|
|
1309
|
-
}
|
|
1310
|
-
return el;
|
|
1311
|
-
};
|
|
1312
|
-
getOption = function(options, propName, def) {
|
|
1313
|
-
var value = options[propName];
|
|
1314
|
-
if (value !== void 0) {
|
|
1315
|
-
return value;
|
|
1316
|
-
}
|
|
1317
|
-
return def;
|
|
1318
|
-
};
|
|
1319
|
-
getGutterSize = function(gutterSize, isFirst, isLast, gutterAlign) {
|
|
1320
|
-
if (isFirst) {
|
|
1321
|
-
if (gutterAlign === "end") {
|
|
1322
|
-
return 0;
|
|
1323
|
-
}
|
|
1324
|
-
if (gutterAlign === "center") {
|
|
1325
|
-
return gutterSize / 2;
|
|
1326
|
-
}
|
|
1327
|
-
} else if (isLast) {
|
|
1328
|
-
if (gutterAlign === "start") {
|
|
1329
|
-
return 0;
|
|
1330
|
-
}
|
|
1331
|
-
if (gutterAlign === "center") {
|
|
1332
|
-
return gutterSize / 2;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
return gutterSize;
|
|
1336
|
-
};
|
|
1337
|
-
defaultGutterFn = function(i, gutterDirection) {
|
|
1338
|
-
var gut = document2.createElement("div");
|
|
1339
|
-
gut.className = "gutter gutter-" + gutterDirection;
|
|
1340
|
-
return gut;
|
|
1341
|
-
};
|
|
1342
|
-
defaultElementStyleFn = function(dim, size, gutSize) {
|
|
1343
|
-
var style = {};
|
|
1344
|
-
if (!isString(size)) {
|
|
1345
|
-
style[dim] = calc + "(" + size + "% - " + gutSize + "px)";
|
|
1346
|
-
} else {
|
|
1347
|
-
style[dim] = size;
|
|
1348
|
-
}
|
|
1349
|
-
return style;
|
|
1350
|
-
};
|
|
1351
|
-
defaultGutterStyleFn = function(dim, gutSize) {
|
|
1352
|
-
var obj;
|
|
1353
|
-
return obj = {}, obj[dim] = gutSize + "px", obj;
|
|
1354
|
-
};
|
|
1355
|
-
Split = function(idsOption, options) {
|
|
1356
|
-
if (options === void 0) options = {};
|
|
1357
|
-
if (ssr) {
|
|
1358
|
-
return {};
|
|
1359
|
-
}
|
|
1360
|
-
var ids = idsOption;
|
|
1361
|
-
var dimension;
|
|
1362
|
-
var clientAxis;
|
|
1363
|
-
var position;
|
|
1364
|
-
var positionEnd;
|
|
1365
|
-
var clientSize;
|
|
1366
|
-
var elements;
|
|
1367
|
-
if (Array.from) {
|
|
1368
|
-
ids = Array.from(ids);
|
|
1369
|
-
}
|
|
1370
|
-
var firstElement = elementOrSelector(ids[0]);
|
|
1371
|
-
var parent = firstElement.parentNode;
|
|
1372
|
-
var parentStyle = getComputedStyle ? getComputedStyle(parent) : null;
|
|
1373
|
-
var parentFlexDirection = parentStyle ? parentStyle.flexDirection : null;
|
|
1374
|
-
var sizes = getOption(options, "sizes") || ids.map(function() {
|
|
1375
|
-
return 100 / ids.length;
|
|
1376
|
-
});
|
|
1377
|
-
var minSize = getOption(options, "minSize", 100);
|
|
1378
|
-
var minSizes = Array.isArray(minSize) ? minSize : ids.map(function() {
|
|
1379
|
-
return minSize;
|
|
1380
|
-
});
|
|
1381
|
-
var maxSize = getOption(options, "maxSize", Infinity);
|
|
1382
|
-
var maxSizes = Array.isArray(maxSize) ? maxSize : ids.map(function() {
|
|
1383
|
-
return maxSize;
|
|
1384
|
-
});
|
|
1385
|
-
var expandToMin = getOption(options, "expandToMin", false);
|
|
1386
|
-
var gutterSize = getOption(options, "gutterSize", 10);
|
|
1387
|
-
var gutterAlign = getOption(options, "gutterAlign", "center");
|
|
1388
|
-
var snapOffset = getOption(options, "snapOffset", 30);
|
|
1389
|
-
var snapOffsets = Array.isArray(snapOffset) ? snapOffset : ids.map(function() {
|
|
1390
|
-
return snapOffset;
|
|
1391
|
-
});
|
|
1392
|
-
var dragInterval = getOption(options, "dragInterval", 1);
|
|
1393
|
-
var direction = getOption(options, "direction", HORIZONTAL);
|
|
1394
|
-
var cursor = getOption(
|
|
1395
|
-
options,
|
|
1396
|
-
"cursor",
|
|
1397
|
-
direction === HORIZONTAL ? "col-resize" : "row-resize"
|
|
1398
|
-
);
|
|
1399
|
-
var gutter = getOption(options, "gutter", defaultGutterFn);
|
|
1400
|
-
var elementStyle = getOption(
|
|
1401
|
-
options,
|
|
1402
|
-
"elementStyle",
|
|
1403
|
-
defaultElementStyleFn
|
|
1404
|
-
);
|
|
1405
|
-
var gutterStyle = getOption(options, "gutterStyle", defaultGutterStyleFn);
|
|
1406
|
-
if (direction === HORIZONTAL) {
|
|
1407
|
-
dimension = "width";
|
|
1408
|
-
clientAxis = "clientX";
|
|
1409
|
-
position = "left";
|
|
1410
|
-
positionEnd = "right";
|
|
1411
|
-
clientSize = "clientWidth";
|
|
1412
|
-
} else if (direction === "vertical") {
|
|
1413
|
-
dimension = "height";
|
|
1414
|
-
clientAxis = "clientY";
|
|
1415
|
-
position = "top";
|
|
1416
|
-
positionEnd = "bottom";
|
|
1417
|
-
clientSize = "clientHeight";
|
|
1418
|
-
}
|
|
1419
|
-
function setElementSize(el, size, gutSize, i) {
|
|
1420
|
-
var style = elementStyle(dimension, size, gutSize, i);
|
|
1421
|
-
Object.keys(style).forEach(function(prop) {
|
|
1422
|
-
el.style[prop] = style[prop];
|
|
1423
|
-
});
|
|
1424
|
-
}
|
|
1425
|
-
function setGutterSize(gutterElement, gutSize, i) {
|
|
1426
|
-
var style = gutterStyle(dimension, gutSize, i);
|
|
1427
|
-
Object.keys(style).forEach(function(prop) {
|
|
1428
|
-
gutterElement.style[prop] = style[prop];
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1431
|
-
function getSizes() {
|
|
1432
|
-
return elements.map(function(element) {
|
|
1433
|
-
return element.size;
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
function getMousePosition(e) {
|
|
1437
|
-
if ("touches" in e) {
|
|
1438
|
-
return e.touches[0][clientAxis];
|
|
1439
|
-
}
|
|
1440
|
-
return e[clientAxis];
|
|
1441
|
-
}
|
|
1442
|
-
function adjust(offset) {
|
|
1443
|
-
var a = elements[this.a];
|
|
1444
|
-
var b = elements[this.b];
|
|
1445
|
-
var percentage = a.size + b.size;
|
|
1446
|
-
a.size = offset / this.size * percentage;
|
|
1447
|
-
b.size = percentage - offset / this.size * percentage;
|
|
1448
|
-
setElementSize(a.element, a.size, this[aGutterSize], a.i);
|
|
1449
|
-
setElementSize(b.element, b.size, this[bGutterSize], b.i);
|
|
1450
|
-
}
|
|
1451
|
-
function drag(e) {
|
|
1452
|
-
var offset;
|
|
1453
|
-
var a = elements[this.a];
|
|
1454
|
-
var b = elements[this.b];
|
|
1455
|
-
if (!this.dragging) {
|
|
1456
|
-
return;
|
|
1457
|
-
}
|
|
1458
|
-
offset = getMousePosition(e) - this.start + (this[aGutterSize] - this.dragOffset);
|
|
1459
|
-
if (dragInterval > 1) {
|
|
1460
|
-
offset = Math.round(offset / dragInterval) * dragInterval;
|
|
1461
|
-
}
|
|
1462
|
-
if (offset <= a.minSize + a.snapOffset + this[aGutterSize]) {
|
|
1463
|
-
offset = a.minSize + this[aGutterSize];
|
|
1464
|
-
} else if (offset >= this.size - (b.minSize + b.snapOffset + this[bGutterSize])) {
|
|
1465
|
-
offset = this.size - (b.minSize + this[bGutterSize]);
|
|
1466
|
-
}
|
|
1467
|
-
if (offset >= a.maxSize - a.snapOffset + this[aGutterSize]) {
|
|
1468
|
-
offset = a.maxSize + this[aGutterSize];
|
|
1469
|
-
} else if (offset <= this.size - (b.maxSize - b.snapOffset + this[bGutterSize])) {
|
|
1470
|
-
offset = this.size - (b.maxSize + this[bGutterSize]);
|
|
1471
|
-
}
|
|
1472
|
-
adjust.call(this, offset);
|
|
1473
|
-
getOption(options, "onDrag", NOOP)(getSizes());
|
|
1474
|
-
}
|
|
1475
|
-
function calculateSizes() {
|
|
1476
|
-
var a = elements[this.a].element;
|
|
1477
|
-
var b = elements[this.b].element;
|
|
1478
|
-
var aBounds = a[getBoundingClientRect]();
|
|
1479
|
-
var bBounds = b[getBoundingClientRect]();
|
|
1480
|
-
this.size = aBounds[dimension] + bBounds[dimension] + this[aGutterSize] + this[bGutterSize];
|
|
1481
|
-
this.start = aBounds[position];
|
|
1482
|
-
this.end = aBounds[positionEnd];
|
|
1483
|
-
}
|
|
1484
|
-
function innerSize(element) {
|
|
1485
|
-
if (!getComputedStyle) {
|
|
1486
|
-
return null;
|
|
1487
|
-
}
|
|
1488
|
-
var computedStyle = getComputedStyle(element);
|
|
1489
|
-
if (!computedStyle) {
|
|
1490
|
-
return null;
|
|
1491
|
-
}
|
|
1492
|
-
var size = element[clientSize];
|
|
1493
|
-
if (size === 0) {
|
|
1494
|
-
return null;
|
|
1495
|
-
}
|
|
1496
|
-
if (direction === HORIZONTAL) {
|
|
1497
|
-
size -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
|
|
1498
|
-
} else {
|
|
1499
|
-
size -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
|
|
1500
|
-
}
|
|
1501
|
-
return size;
|
|
1502
|
-
}
|
|
1503
|
-
function trimToMin(sizesToTrim) {
|
|
1504
|
-
var parentSize = innerSize(parent);
|
|
1505
|
-
if (parentSize === null) {
|
|
1506
|
-
return sizesToTrim;
|
|
1507
|
-
}
|
|
1508
|
-
if (minSizes.reduce(function(a, b) {
|
|
1509
|
-
return a + b;
|
|
1510
|
-
}, 0) > parentSize) {
|
|
1511
|
-
return sizesToTrim;
|
|
1512
|
-
}
|
|
1513
|
-
var excessPixels = 0;
|
|
1514
|
-
var toSpare = [];
|
|
1515
|
-
var pixelSizes = sizesToTrim.map(function(size, i) {
|
|
1516
|
-
var pixelSize = parentSize * size / 100;
|
|
1517
|
-
var elementGutterSize = getGutterSize(
|
|
1518
|
-
gutterSize,
|
|
1519
|
-
i === 0,
|
|
1520
|
-
i === sizesToTrim.length - 1,
|
|
1521
|
-
gutterAlign
|
|
1522
|
-
);
|
|
1523
|
-
var elementMinSize = minSizes[i] + elementGutterSize;
|
|
1524
|
-
if (pixelSize < elementMinSize) {
|
|
1525
|
-
excessPixels += elementMinSize - pixelSize;
|
|
1526
|
-
toSpare.push(0);
|
|
1527
|
-
return elementMinSize;
|
|
1528
|
-
}
|
|
1529
|
-
toSpare.push(pixelSize - elementMinSize);
|
|
1530
|
-
return pixelSize;
|
|
1531
|
-
});
|
|
1532
|
-
if (excessPixels === 0) {
|
|
1533
|
-
return sizesToTrim;
|
|
1534
|
-
}
|
|
1535
|
-
return pixelSizes.map(function(pixelSize, i) {
|
|
1536
|
-
var newPixelSize = pixelSize;
|
|
1537
|
-
if (excessPixels > 0 && toSpare[i] - excessPixels > 0) {
|
|
1538
|
-
var takenPixels = Math.min(
|
|
1539
|
-
excessPixels,
|
|
1540
|
-
toSpare[i] - excessPixels
|
|
1541
|
-
);
|
|
1542
|
-
excessPixels -= takenPixels;
|
|
1543
|
-
newPixelSize = pixelSize - takenPixels;
|
|
1544
|
-
}
|
|
1545
|
-
return newPixelSize / parentSize * 100;
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
function stopDragging() {
|
|
1549
|
-
var self = this;
|
|
1550
|
-
var a = elements[self.a].element;
|
|
1551
|
-
var b = elements[self.b].element;
|
|
1552
|
-
if (self.dragging) {
|
|
1553
|
-
getOption(options, "onDragEnd", NOOP)(getSizes());
|
|
1554
|
-
}
|
|
1555
|
-
self.dragging = false;
|
|
1556
|
-
global[removeEventListener]("mouseup", self.stop);
|
|
1557
|
-
global[removeEventListener]("touchend", self.stop);
|
|
1558
|
-
global[removeEventListener]("touchcancel", self.stop);
|
|
1559
|
-
global[removeEventListener]("mousemove", self.move);
|
|
1560
|
-
global[removeEventListener]("touchmove", self.move);
|
|
1561
|
-
self.stop = null;
|
|
1562
|
-
self.move = null;
|
|
1563
|
-
a[removeEventListener]("selectstart", NOOP);
|
|
1564
|
-
a[removeEventListener]("dragstart", NOOP);
|
|
1565
|
-
b[removeEventListener]("selectstart", NOOP);
|
|
1566
|
-
b[removeEventListener]("dragstart", NOOP);
|
|
1567
|
-
a.style.userSelect = "";
|
|
1568
|
-
a.style.webkitUserSelect = "";
|
|
1569
|
-
a.style.MozUserSelect = "";
|
|
1570
|
-
a.style.pointerEvents = "";
|
|
1571
|
-
b.style.userSelect = "";
|
|
1572
|
-
b.style.webkitUserSelect = "";
|
|
1573
|
-
b.style.MozUserSelect = "";
|
|
1574
|
-
b.style.pointerEvents = "";
|
|
1575
|
-
self.gutter.style.cursor = "";
|
|
1576
|
-
self.parent.style.cursor = "";
|
|
1577
|
-
document2.body.style.cursor = "";
|
|
1578
|
-
}
|
|
1579
|
-
function startDragging(e) {
|
|
1580
|
-
if ("button" in e && e.button !== 0) {
|
|
1581
|
-
return;
|
|
1582
|
-
}
|
|
1583
|
-
var self = this;
|
|
1584
|
-
var a = elements[self.a].element;
|
|
1585
|
-
var b = elements[self.b].element;
|
|
1586
|
-
if (!self.dragging) {
|
|
1587
|
-
getOption(options, "onDragStart", NOOP)(getSizes());
|
|
1588
|
-
}
|
|
1589
|
-
e.preventDefault();
|
|
1590
|
-
self.dragging = true;
|
|
1591
|
-
self.move = drag.bind(self);
|
|
1592
|
-
self.stop = stopDragging.bind(self);
|
|
1593
|
-
global[addEventListener]("mouseup", self.stop);
|
|
1594
|
-
global[addEventListener]("touchend", self.stop);
|
|
1595
|
-
global[addEventListener]("touchcancel", self.stop);
|
|
1596
|
-
global[addEventListener]("mousemove", self.move);
|
|
1597
|
-
global[addEventListener]("touchmove", self.move);
|
|
1598
|
-
a[addEventListener]("selectstart", NOOP);
|
|
1599
|
-
a[addEventListener]("dragstart", NOOP);
|
|
1600
|
-
b[addEventListener]("selectstart", NOOP);
|
|
1601
|
-
b[addEventListener]("dragstart", NOOP);
|
|
1602
|
-
a.style.userSelect = "none";
|
|
1603
|
-
a.style.webkitUserSelect = "none";
|
|
1604
|
-
a.style.MozUserSelect = "none";
|
|
1605
|
-
a.style.pointerEvents = "none";
|
|
1606
|
-
b.style.userSelect = "none";
|
|
1607
|
-
b.style.webkitUserSelect = "none";
|
|
1608
|
-
b.style.MozUserSelect = "none";
|
|
1609
|
-
b.style.pointerEvents = "none";
|
|
1610
|
-
self.gutter.style.cursor = cursor;
|
|
1611
|
-
self.parent.style.cursor = cursor;
|
|
1612
|
-
document2.body.style.cursor = cursor;
|
|
1613
|
-
calculateSizes.call(self);
|
|
1614
|
-
self.dragOffset = getMousePosition(e) - self.end;
|
|
1615
|
-
}
|
|
1616
|
-
sizes = trimToMin(sizes);
|
|
1617
|
-
var pairs = [];
|
|
1618
|
-
elements = ids.map(function(id, i) {
|
|
1619
|
-
var element = {
|
|
1620
|
-
element: elementOrSelector(id),
|
|
1621
|
-
size: sizes[i],
|
|
1622
|
-
minSize: minSizes[i],
|
|
1623
|
-
maxSize: maxSizes[i],
|
|
1624
|
-
snapOffset: snapOffsets[i],
|
|
1625
|
-
i
|
|
1626
|
-
};
|
|
1627
|
-
var pair;
|
|
1628
|
-
if (i > 0) {
|
|
1629
|
-
pair = {
|
|
1630
|
-
a: i - 1,
|
|
1631
|
-
b: i,
|
|
1632
|
-
dragging: false,
|
|
1633
|
-
direction,
|
|
1634
|
-
parent
|
|
1635
|
-
};
|
|
1636
|
-
pair[aGutterSize] = getGutterSize(
|
|
1637
|
-
gutterSize,
|
|
1638
|
-
i - 1 === 0,
|
|
1639
|
-
false,
|
|
1640
|
-
gutterAlign
|
|
1641
|
-
);
|
|
1642
|
-
pair[bGutterSize] = getGutterSize(
|
|
1643
|
-
gutterSize,
|
|
1644
|
-
false,
|
|
1645
|
-
i === ids.length - 1,
|
|
1646
|
-
gutterAlign
|
|
1647
|
-
);
|
|
1648
|
-
if (parentFlexDirection === "row-reverse" || parentFlexDirection === "column-reverse") {
|
|
1649
|
-
var temp = pair.a;
|
|
1650
|
-
pair.a = pair.b;
|
|
1651
|
-
pair.b = temp;
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
if (i > 0) {
|
|
1655
|
-
var gutterElement = gutter(i, direction, element.element);
|
|
1656
|
-
setGutterSize(gutterElement, gutterSize, i);
|
|
1657
|
-
pair[gutterStartDragging] = startDragging.bind(pair);
|
|
1658
|
-
gutterElement[addEventListener](
|
|
1659
|
-
"mousedown",
|
|
1660
|
-
pair[gutterStartDragging]
|
|
1661
|
-
);
|
|
1662
|
-
gutterElement[addEventListener](
|
|
1663
|
-
"touchstart",
|
|
1664
|
-
pair[gutterStartDragging]
|
|
1665
|
-
);
|
|
1666
|
-
parent.insertBefore(gutterElement, element.element);
|
|
1667
|
-
pair.gutter = gutterElement;
|
|
1668
|
-
}
|
|
1669
|
-
setElementSize(
|
|
1670
|
-
element.element,
|
|
1671
|
-
element.size,
|
|
1672
|
-
getGutterSize(
|
|
1673
|
-
gutterSize,
|
|
1674
|
-
i === 0,
|
|
1675
|
-
i === ids.length - 1,
|
|
1676
|
-
gutterAlign
|
|
1677
|
-
),
|
|
1678
|
-
i
|
|
1679
|
-
);
|
|
1680
|
-
if (i > 0) {
|
|
1681
|
-
pairs.push(pair);
|
|
1682
|
-
}
|
|
1683
|
-
return element;
|
|
1684
|
-
});
|
|
1685
|
-
function adjustToMin(element) {
|
|
1686
|
-
var isLast = element.i === pairs.length;
|
|
1687
|
-
var pair = isLast ? pairs[element.i - 1] : pairs[element.i];
|
|
1688
|
-
calculateSizes.call(pair);
|
|
1689
|
-
var size = isLast ? pair.size - element.minSize - pair[bGutterSize] : element.minSize + pair[aGutterSize];
|
|
1690
|
-
adjust.call(pair, size);
|
|
1691
|
-
}
|
|
1692
|
-
elements.forEach(function(element) {
|
|
1693
|
-
var computedSize = element.element[getBoundingClientRect]()[dimension];
|
|
1694
|
-
if (computedSize < element.minSize) {
|
|
1695
|
-
if (expandToMin) {
|
|
1696
|
-
adjustToMin(element);
|
|
1697
|
-
} else {
|
|
1698
|
-
element.minSize = computedSize;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
});
|
|
1702
|
-
function setSizes(newSizes) {
|
|
1703
|
-
var trimmed = trimToMin(newSizes);
|
|
1704
|
-
trimmed.forEach(function(newSize, i) {
|
|
1705
|
-
if (i > 0) {
|
|
1706
|
-
var pair = pairs[i - 1];
|
|
1707
|
-
var a = elements[pair.a];
|
|
1708
|
-
var b = elements[pair.b];
|
|
1709
|
-
a.size = trimmed[i - 1];
|
|
1710
|
-
b.size = newSize;
|
|
1711
|
-
setElementSize(a.element, a.size, pair[aGutterSize], a.i);
|
|
1712
|
-
setElementSize(b.element, b.size, pair[bGutterSize], b.i);
|
|
1713
|
-
}
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
function destroy(preserveStyles, preserveGutter) {
|
|
1717
|
-
pairs.forEach(function(pair) {
|
|
1718
|
-
if (preserveGutter !== true) {
|
|
1719
|
-
pair.parent.removeChild(pair.gutter);
|
|
1720
|
-
} else {
|
|
1721
|
-
pair.gutter[removeEventListener](
|
|
1722
|
-
"mousedown",
|
|
1723
|
-
pair[gutterStartDragging]
|
|
1724
|
-
);
|
|
1725
|
-
pair.gutter[removeEventListener](
|
|
1726
|
-
"touchstart",
|
|
1727
|
-
pair[gutterStartDragging]
|
|
1728
|
-
);
|
|
1729
|
-
}
|
|
1730
|
-
if (preserveStyles !== true) {
|
|
1731
|
-
var style = elementStyle(
|
|
1732
|
-
dimension,
|
|
1733
|
-
pair.a.size,
|
|
1734
|
-
pair[aGutterSize]
|
|
1735
|
-
);
|
|
1736
|
-
Object.keys(style).forEach(function(prop) {
|
|
1737
|
-
elements[pair.a].element.style[prop] = "";
|
|
1738
|
-
elements[pair.b].element.style[prop] = "";
|
|
1739
|
-
});
|
|
1740
|
-
}
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1743
|
-
return {
|
|
1744
|
-
setSizes,
|
|
1745
|
-
getSizes,
|
|
1746
|
-
collapse: function collapse(i) {
|
|
1747
|
-
adjustToMin(elements[i]);
|
|
1748
|
-
},
|
|
1749
|
-
destroy,
|
|
1750
|
-
parent,
|
|
1751
|
-
pairs
|
|
1752
|
-
};
|
|
1753
|
-
};
|
|
1754
|
-
split_es_default = Split;
|
|
1755
|
-
}
|
|
1756
|
-
});
|
|
1757
|
-
|
|
1758
|
-
// node_modules/react-split/dist/react-split.es.js
|
|
1759
|
-
function objectWithoutProperties(obj, exclude) {
|
|
1760
|
-
var target = {};
|
|
1761
|
-
for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k];
|
|
1762
|
-
return target;
|
|
1763
|
-
}
|
|
1764
|
-
var import_react5, import_prop_types, SplitWrapper, react_split_es_default;
|
|
1765
|
-
var init_react_split_es = __esm({
|
|
1766
|
-
"node_modules/react-split/dist/react-split.es.js"() {
|
|
1767
|
-
"use strict";
|
|
1768
|
-
import_react5 = __toESM(require("react"));
|
|
1769
|
-
import_prop_types = __toESM(require_prop_types());
|
|
1770
|
-
init_split_es();
|
|
1771
|
-
SplitWrapper = /* @__PURE__ */ (function(superclass) {
|
|
1772
|
-
function SplitWrapper2() {
|
|
1773
|
-
superclass.apply(this, arguments);
|
|
1774
|
-
}
|
|
1775
|
-
if (superclass) SplitWrapper2.__proto__ = superclass;
|
|
1776
|
-
SplitWrapper2.prototype = Object.create(superclass && superclass.prototype);
|
|
1777
|
-
SplitWrapper2.prototype.constructor = SplitWrapper2;
|
|
1778
|
-
SplitWrapper2.prototype.componentDidMount = function componentDidMount() {
|
|
1779
|
-
var ref = this.props;
|
|
1780
|
-
ref.children;
|
|
1781
|
-
var gutter = ref.gutter;
|
|
1782
|
-
var rest = objectWithoutProperties(ref, ["children", "gutter"]);
|
|
1783
|
-
var options = rest;
|
|
1784
|
-
options.gutter = function(index, direction) {
|
|
1785
|
-
var gutterElement;
|
|
1786
|
-
if (gutter) {
|
|
1787
|
-
gutterElement = gutter(index, direction);
|
|
1788
|
-
} else {
|
|
1789
|
-
gutterElement = document.createElement("div");
|
|
1790
|
-
gutterElement.className = "gutter gutter-" + direction;
|
|
1791
|
-
}
|
|
1792
|
-
gutterElement.__isSplitGutter = true;
|
|
1793
|
-
return gutterElement;
|
|
1794
|
-
};
|
|
1795
|
-
this.split = split_es_default(this.parent.children, options);
|
|
1796
|
-
};
|
|
1797
|
-
SplitWrapper2.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
1798
|
-
var this$1 = this;
|
|
1799
|
-
var ref = this.props;
|
|
1800
|
-
ref.children;
|
|
1801
|
-
var minSize = ref.minSize;
|
|
1802
|
-
var sizes = ref.sizes;
|
|
1803
|
-
var collapsed = ref.collapsed;
|
|
1804
|
-
var rest = objectWithoutProperties(ref, ["children", "minSize", "sizes", "collapsed"]);
|
|
1805
|
-
var options = rest;
|
|
1806
|
-
var prevMinSize = prevProps.minSize;
|
|
1807
|
-
var prevSizes = prevProps.sizes;
|
|
1808
|
-
var prevCollapsed = prevProps.collapsed;
|
|
1809
|
-
var otherProps = [
|
|
1810
|
-
"maxSize",
|
|
1811
|
-
"expandToMin",
|
|
1812
|
-
"gutterSize",
|
|
1813
|
-
"gutterAlign",
|
|
1814
|
-
"snapOffset",
|
|
1815
|
-
"dragInterval",
|
|
1816
|
-
"direction",
|
|
1817
|
-
"cursor"
|
|
1818
|
-
];
|
|
1819
|
-
var needsRecreate = otherProps.map(function(prop) {
|
|
1820
|
-
return this$1.props[prop] !== prevProps[prop];
|
|
1821
|
-
}).reduce(function(accum, same) {
|
|
1822
|
-
return accum || same;
|
|
1823
|
-
}, false);
|
|
1824
|
-
if (Array.isArray(minSize) && Array.isArray(prevMinSize)) {
|
|
1825
|
-
var minSizeChanged = false;
|
|
1826
|
-
minSize.forEach(function(minSizeI, i) {
|
|
1827
|
-
minSizeChanged = minSizeChanged || minSizeI !== prevMinSize[i];
|
|
1828
|
-
});
|
|
1829
|
-
needsRecreate = needsRecreate || minSizeChanged;
|
|
1830
|
-
} else if (Array.isArray(minSize) || Array.isArray(prevMinSize)) {
|
|
1831
|
-
needsRecreate = true;
|
|
1832
|
-
} else {
|
|
1833
|
-
needsRecreate = needsRecreate || minSize !== prevMinSize;
|
|
1834
|
-
}
|
|
1835
|
-
if (needsRecreate) {
|
|
1836
|
-
options.minSize = minSize;
|
|
1837
|
-
options.sizes = sizes || this.split.getSizes();
|
|
1838
|
-
this.split.destroy(true, true);
|
|
1839
|
-
options.gutter = function(index, direction, pairB) {
|
|
1840
|
-
return pairB.previousSibling;
|
|
1841
|
-
};
|
|
1842
|
-
this.split = split_es_default(
|
|
1843
|
-
Array.from(this.parent.children).filter(
|
|
1844
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1845
|
-
function(element) {
|
|
1846
|
-
return !element.__isSplitGutter;
|
|
1847
|
-
}
|
|
1848
|
-
),
|
|
1849
|
-
options
|
|
1850
|
-
);
|
|
1851
|
-
} else if (sizes) {
|
|
1852
|
-
var sizeChanged = false;
|
|
1853
|
-
sizes.forEach(function(sizeI, i) {
|
|
1854
|
-
sizeChanged = sizeChanged || sizeI !== prevSizes[i];
|
|
1855
|
-
});
|
|
1856
|
-
if (sizeChanged) {
|
|
1857
|
-
this.split.setSizes(this.props.sizes);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
if (Number.isInteger(collapsed) && (collapsed !== prevCollapsed || needsRecreate)) {
|
|
1861
|
-
this.split.collapse(collapsed);
|
|
1862
|
-
}
|
|
1863
|
-
};
|
|
1864
|
-
SplitWrapper2.prototype.componentWillUnmount = function componentWillUnmount() {
|
|
1865
|
-
this.split.destroy();
|
|
1866
|
-
delete this.split;
|
|
1867
|
-
};
|
|
1868
|
-
SplitWrapper2.prototype.render = function render() {
|
|
1869
|
-
var this$1 = this;
|
|
1870
|
-
var ref = this.props;
|
|
1871
|
-
ref.sizes;
|
|
1872
|
-
ref.minSize;
|
|
1873
|
-
ref.maxSize;
|
|
1874
|
-
ref.expandToMin;
|
|
1875
|
-
ref.gutterSize;
|
|
1876
|
-
ref.gutterAlign;
|
|
1877
|
-
ref.snapOffset;
|
|
1878
|
-
ref.dragInterval;
|
|
1879
|
-
ref.direction;
|
|
1880
|
-
ref.cursor;
|
|
1881
|
-
ref.gutter;
|
|
1882
|
-
ref.elementStyle;
|
|
1883
|
-
ref.gutterStyle;
|
|
1884
|
-
ref.onDrag;
|
|
1885
|
-
ref.onDragStart;
|
|
1886
|
-
ref.onDragEnd;
|
|
1887
|
-
ref.collapsed;
|
|
1888
|
-
var children = ref.children;
|
|
1889
|
-
var rest$1 = objectWithoutProperties(ref, ["sizes", "minSize", "maxSize", "expandToMin", "gutterSize", "gutterAlign", "snapOffset", "dragInterval", "direction", "cursor", "gutter", "elementStyle", "gutterStyle", "onDrag", "onDragStart", "onDragEnd", "collapsed", "children"]);
|
|
1890
|
-
var rest = rest$1;
|
|
1891
|
-
return import_react5.default.createElement(
|
|
1892
|
-
"div",
|
|
1893
|
-
Object.assign(
|
|
1894
|
-
{},
|
|
1895
|
-
{ ref: function(parent) {
|
|
1896
|
-
this$1.parent = parent;
|
|
1897
|
-
} },
|
|
1898
|
-
rest
|
|
1899
|
-
),
|
|
1900
|
-
children
|
|
1901
|
-
);
|
|
1902
|
-
};
|
|
1903
|
-
return SplitWrapper2;
|
|
1904
|
-
})(import_react5.default.Component);
|
|
1905
|
-
SplitWrapper.propTypes = {
|
|
1906
|
-
sizes: import_prop_types.default.arrayOf(import_prop_types.default.number),
|
|
1907
|
-
minSize: import_prop_types.default.oneOfType([
|
|
1908
|
-
import_prop_types.default.number,
|
|
1909
|
-
import_prop_types.default.arrayOf(import_prop_types.default.number)
|
|
1910
|
-
]),
|
|
1911
|
-
maxSize: import_prop_types.default.oneOfType([
|
|
1912
|
-
import_prop_types.default.number,
|
|
1913
|
-
import_prop_types.default.arrayOf(import_prop_types.default.number)
|
|
1914
|
-
]),
|
|
1915
|
-
expandToMin: import_prop_types.default.bool,
|
|
1916
|
-
gutterSize: import_prop_types.default.number,
|
|
1917
|
-
gutterAlign: import_prop_types.default.string,
|
|
1918
|
-
snapOffset: import_prop_types.default.oneOfType([
|
|
1919
|
-
import_prop_types.default.number,
|
|
1920
|
-
import_prop_types.default.arrayOf(import_prop_types.default.number)
|
|
1921
|
-
]),
|
|
1922
|
-
dragInterval: import_prop_types.default.number,
|
|
1923
|
-
direction: import_prop_types.default.string,
|
|
1924
|
-
cursor: import_prop_types.default.string,
|
|
1925
|
-
gutter: import_prop_types.default.func,
|
|
1926
|
-
elementStyle: import_prop_types.default.func,
|
|
1927
|
-
gutterStyle: import_prop_types.default.func,
|
|
1928
|
-
onDrag: import_prop_types.default.func,
|
|
1929
|
-
onDragStart: import_prop_types.default.func,
|
|
1930
|
-
onDragEnd: import_prop_types.default.func,
|
|
1931
|
-
collapsed: import_prop_types.default.number,
|
|
1932
|
-
children: import_prop_types.default.arrayOf(import_prop_types.default.element)
|
|
1933
|
-
};
|
|
1934
|
-
SplitWrapper.defaultProps = {
|
|
1935
|
-
sizes: void 0,
|
|
1936
|
-
minSize: void 0,
|
|
1937
|
-
maxSize: void 0,
|
|
1938
|
-
expandToMin: void 0,
|
|
1939
|
-
gutterSize: void 0,
|
|
1940
|
-
gutterAlign: void 0,
|
|
1941
|
-
snapOffset: void 0,
|
|
1942
|
-
dragInterval: void 0,
|
|
1943
|
-
direction: void 0,
|
|
1944
|
-
cursor: void 0,
|
|
1945
|
-
gutter: void 0,
|
|
1946
|
-
elementStyle: void 0,
|
|
1947
|
-
gutterStyle: void 0,
|
|
1948
|
-
onDrag: void 0,
|
|
1949
|
-
onDragStart: void 0,
|
|
1950
|
-
onDragEnd: void 0,
|
|
1951
|
-
collapsed: void 0,
|
|
1952
|
-
children: void 0
|
|
1953
|
-
};
|
|
1954
|
-
react_split_es_default = SplitWrapper;
|
|
1955
|
-
}
|
|
1956
|
-
});
|
|
1957
|
-
|
|
1958
|
-
// src/ai-plugin/jmx-ai/model.ts
|
|
1959
|
-
var ChatbotDialog;
|
|
1960
|
-
var init_model = __esm({
|
|
1961
|
-
"src/ai-plugin/jmx-ai/model.ts"() {
|
|
1962
|
-
"use strict";
|
|
1963
|
-
ChatbotDialog = class {
|
|
1964
|
-
constructor(messages, summary) {
|
|
1965
|
-
this.messages = messages;
|
|
1966
|
-
this.summary = summary;
|
|
1967
|
-
this.id = messages[0]?.id ?? "";
|
|
1968
|
-
}
|
|
1969
|
-
messages;
|
|
1970
|
-
summary;
|
|
1971
|
-
id;
|
|
1972
|
-
setMessages(messages) {
|
|
1973
|
-
if (messages[0]?.id !== this.id) {
|
|
1974
|
-
throw new Error("Not the same dialog");
|
|
1975
|
-
}
|
|
1976
|
-
this.messages = [...messages];
|
|
1977
|
-
}
|
|
1978
|
-
createConversation() {
|
|
1979
|
-
const text = this.summary ?? (this.messages[0]?.content ?? "").substring(0, 20);
|
|
1980
|
-
return { id: this.id, text };
|
|
1981
|
-
}
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
});
|
|
1985
|
-
|
|
1986
|
-
// src/ai-plugin/jmx-ai/context.ts
|
|
1987
|
-
function useMBeanTree() {
|
|
1988
|
-
const [tree, setTree] = (0, import_react7.useState)(import_react6.MBeanTree.createEmpty(pluginName));
|
|
1989
|
-
const [loaded, setLoaded] = (0, import_react7.useState)(false);
|
|
1990
|
-
const { selectedNode, setSelectedNode } = (0, import_react7.useContext)(import_react6.PluginNodeSelectionContext);
|
|
1991
|
-
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
1992
|
-
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
1993
|
-
const refSelectedNode = (0, import_react7.useRef)();
|
|
1994
|
-
refSelectedNode.current = selectedNode;
|
|
1995
|
-
const populateTree = async () => {
|
|
1996
|
-
const wkspTree = await import_react6.workspace.getTree();
|
|
1997
|
-
setTree(wkspTree);
|
|
1998
|
-
const nodeId = searchParams.get(PARAM_KEY_NODE_ID);
|
|
1999
|
-
if (nodeId && nodeId !== refSelectedNode.current?.id) {
|
|
2000
|
-
log.debug("Restore selected node with nid:", nodeId);
|
|
2001
|
-
const urlNode = wkspTree.find((node) => node.id === nodeId);
|
|
2002
|
-
if (urlNode) {
|
|
2003
|
-
setSelectedNode(urlNode);
|
|
2004
|
-
refSelectedNode.current = urlNode;
|
|
2005
|
-
} else {
|
|
2006
|
-
log.debug("Clear invalid nid:", nodeId);
|
|
2007
|
-
searchParams.delete(PARAM_KEY_NODE_ID);
|
|
2008
|
-
setSearchParams(searchParams);
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
if (!refSelectedNode.current) return;
|
|
2012
|
-
const path = [...refSelectedNode.current.path()];
|
|
2013
|
-
wkspTree.forEach(path, (node) => {
|
|
2014
|
-
node.defaultExpanded = true;
|
|
2015
|
-
});
|
|
2016
|
-
const newSelected = wkspTree.navigate(...path);
|
|
2017
|
-
if (newSelected) {
|
|
2018
|
-
setSelectedNode(newSelected);
|
|
2019
|
-
navigate(pluginPathWithNodeId(newSelected, searchParams));
|
|
2020
|
-
} else {
|
|
2021
|
-
navigate(pluginPath);
|
|
2022
|
-
}
|
|
2023
|
-
};
|
|
2024
|
-
(0, import_react7.useEffect)(() => {
|
|
2025
|
-
const loadTree = async () => {
|
|
2026
|
-
await populateTree();
|
|
2027
|
-
setLoaded(true);
|
|
2028
|
-
};
|
|
2029
|
-
const listener = () => {
|
|
2030
|
-
setLoaded(false);
|
|
2031
|
-
loadTree();
|
|
2032
|
-
};
|
|
2033
|
-
import_react6.eventService.onRefresh(listener);
|
|
2034
|
-
loadTree();
|
|
2035
|
-
return () => import_react6.eventService.removeListener(import_react6.EVENT_REFRESH, listener);
|
|
2036
|
-
}, []);
|
|
2037
|
-
return { tree, loaded, selectedNode, setSelectedNode };
|
|
2038
|
-
}
|
|
2039
|
-
function pluginPathWithNodeId(node, searchParams = new URLSearchParams(window.location.search)) {
|
|
2040
|
-
searchParams.set(PARAM_KEY_NODE_ID, node.id);
|
|
2041
|
-
const query = `?${searchParams.toString()}`;
|
|
2042
|
-
return { pathname: pluginPath, search: query };
|
|
2043
|
-
}
|
|
2044
|
-
function useChatbot() {
|
|
2045
|
-
const [messages, setMessages] = (0, import_react7.useState)([]);
|
|
2046
|
-
const [dialogs, setDialogs] = (0, import_react7.useState)([]);
|
|
2047
|
-
const [conversations, setConversations] = (0, import_react7.useState)([]);
|
|
2048
|
-
const [announcement, setAnnouncement] = (0, import_react7.useState)("");
|
|
2049
|
-
const [isChatbotOpen, setIsChatbotOpen] = (0, import_react7.useState)(false);
|
|
2050
|
-
const [isSendButtonDisabled, setIsSendButtonDisabled] = (0, import_react7.useState)(false);
|
|
2051
|
-
const updateConversations = (messages2, summary) => {
|
|
2052
|
-
const dialogId = messages2[0]?.id;
|
|
2053
|
-
if (!dialogId) {
|
|
2054
|
-
return;
|
|
2055
|
-
}
|
|
2056
|
-
setMessages(messages2);
|
|
2057
|
-
let dialog = dialogs.find((d) => d.id === dialogId);
|
|
2058
|
-
if (dialog) {
|
|
2059
|
-
dialog.setMessages(messages2);
|
|
2060
|
-
} else {
|
|
2061
|
-
dialog = new ChatbotDialog(messages2, summary);
|
|
2062
|
-
dialogs.push(dialog);
|
|
2063
|
-
}
|
|
2064
|
-
setDialogs([...dialogs]);
|
|
2065
|
-
log.debug("Updated dialogs:", dialogs);
|
|
2066
|
-
if (!conversations.some((c) => c.id === dialogId)) {
|
|
2067
|
-
const conversation = dialog.createConversation();
|
|
2068
|
-
conversations.push(conversation);
|
|
2069
|
-
setConversations([...conversations]);
|
|
2070
|
-
log.debug("Updated conversations:", conversations);
|
|
2071
|
-
}
|
|
2072
|
-
};
|
|
2073
|
-
return {
|
|
2074
|
-
messages,
|
|
2075
|
-
setMessages,
|
|
2076
|
-
dialogs,
|
|
2077
|
-
setDialogs,
|
|
2078
|
-
conversations,
|
|
2079
|
-
setConversations,
|
|
2080
|
-
announcement,
|
|
2081
|
-
setAnnouncement,
|
|
2082
|
-
isChatbotOpen,
|
|
2083
|
-
setIsChatbotOpen,
|
|
2084
|
-
isSendButtonDisabled,
|
|
2085
|
-
setIsSendButtonDisabled,
|
|
2086
|
-
updateConversations
|
|
2087
|
-
};
|
|
2088
|
-
}
|
|
2089
|
-
var import_react6, import_react7, import_react_router_dom, MBeanTreeContext, ChatbotContext;
|
|
2090
|
-
var init_context = __esm({
|
|
2091
|
-
"src/ai-plugin/jmx-ai/context.ts"() {
|
|
2092
|
-
"use strict";
|
|
2093
|
-
import_react6 = require("@hawtio/react");
|
|
2094
|
-
import_react7 = require("react");
|
|
2095
|
-
import_react_router_dom = require("react-router-dom");
|
|
2096
|
-
init_globals();
|
|
2097
|
-
init_model();
|
|
2098
|
-
MBeanTreeContext = (0, import_react7.createContext)({
|
|
2099
|
-
tree: import_react6.MBeanTree.createEmpty(pluginName),
|
|
2100
|
-
loaded: false,
|
|
2101
|
-
selectedNode: null,
|
|
2102
|
-
setSelectedNode: () => {
|
|
2103
|
-
}
|
|
2104
|
-
});
|
|
2105
|
-
ChatbotContext = (0, import_react7.createContext)({
|
|
2106
|
-
messages: [],
|
|
2107
|
-
setMessages: () => {
|
|
2108
|
-
},
|
|
2109
|
-
dialogs: [],
|
|
2110
|
-
setDialogs: () => {
|
|
2111
|
-
},
|
|
2112
|
-
conversations: [],
|
|
2113
|
-
setConversations: () => {
|
|
2114
|
-
},
|
|
2115
|
-
announcement: "",
|
|
2116
|
-
setAnnouncement: () => {
|
|
2117
|
-
},
|
|
2118
|
-
isChatbotOpen: false,
|
|
2119
|
-
setIsChatbotOpen: () => {
|
|
2120
|
-
},
|
|
2121
|
-
isSendButtonDisabled: false,
|
|
2122
|
-
setIsSendButtonDisabled: () => {
|
|
2123
|
-
},
|
|
2124
|
-
updateConversations: () => {
|
|
2125
|
-
}
|
|
2126
|
-
});
|
|
2127
|
-
}
|
|
2128
|
-
});
|
|
2129
|
-
|
|
2130
|
-
// src/ai-plugin/jmx-ai/Jmx.css
|
|
2131
|
-
var init_Jmx = __esm({
|
|
2132
|
-
"src/ai-plugin/jmx-ai/Jmx.css"() {
|
|
2133
|
-
}
|
|
2134
|
-
});
|
|
2135
|
-
|
|
2136
|
-
// src/ai-plugin/jmx-ai/DiagnosisChatbot.tsx
|
|
2137
|
-
var import_ui, import_chatbot, import_Chatbot, import_ChatbotContent, import_ChatbotConversationHistoryNav, import_ChatbotFooter, import_ChatbotHeader, import_Message, import_MessageBar, import_MessageBox, import_react_core2, import_wrench_icon, import_react8, import_jsx_runtime2, DiagnosisChatbot, DiagnosisChatbotHeader, DiagnosisChatbotContent, DiagnosisChatbotFooter, ThinkInfo, ToolCallsInfo, ToolCallsApprove;
|
|
2138
|
-
var init_DiagnosisChatbot = __esm({
|
|
2139
|
-
"src/ai-plugin/jmx-ai/DiagnosisChatbot.tsx"() {
|
|
2140
|
-
"use strict";
|
|
2141
|
-
import_ui = require("@hawtio/react/ui");
|
|
2142
|
-
import_chatbot = require("@patternfly/chatbot");
|
|
2143
|
-
import_Chatbot = __toESM(require("@patternfly/chatbot/dist/dynamic/Chatbot"));
|
|
2144
|
-
import_ChatbotContent = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotContent"));
|
|
2145
|
-
import_ChatbotConversationHistoryNav = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav"));
|
|
2146
|
-
import_ChatbotFooter = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotFooter"));
|
|
2147
|
-
import_ChatbotHeader = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotHeader"));
|
|
2148
|
-
import_Message = __toESM(require("@patternfly/chatbot/dist/dynamic/Message"));
|
|
2149
|
-
import_MessageBar = __toESM(require("@patternfly/chatbot/dist/dynamic/MessageBar"));
|
|
2150
|
-
import_MessageBox = __toESM(require("@patternfly/chatbot/dist/dynamic/MessageBox"));
|
|
2151
|
-
import_react_core2 = require("@patternfly/react-core");
|
|
2152
|
-
import_wrench_icon = __toESM(require("@patternfly/react-icons/dist/esm/icons/wrench-icon"));
|
|
2153
|
-
import_react8 = __toESM(require("react"));
|
|
2154
|
-
init_ai_service();
|
|
2155
|
-
init_context();
|
|
2156
|
-
init_globals();
|
|
2157
|
-
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2158
|
-
DiagnosisChatbot = () => {
|
|
2159
|
-
const { setMessages, dialogs, conversations } = (0, import_react8.useContext)(ChatbotContext);
|
|
2160
|
-
const [isDrawerOpen, setIsDrawerOpen] = (0, import_react8.useState)(false);
|
|
2161
|
-
const [filteredConversations, setFilteredConversations] = (0, import_react8.useState)(conversations);
|
|
2162
|
-
const onSelectItemInHistory = (selected) => {
|
|
2163
|
-
log.debug("Selected conversation with ID:", selected);
|
|
2164
|
-
const dialog = dialogs.find((c) => c.id === selected);
|
|
2165
|
-
if (dialog) {
|
|
2166
|
-
setMessages(dialog.messages);
|
|
2167
|
-
setIsDrawerOpen(!isDrawerOpen);
|
|
2168
|
-
}
|
|
2169
|
-
};
|
|
2170
|
-
const handleSearchTextChange = (value) => {
|
|
2171
|
-
if (value.trim() === "") {
|
|
2172
|
-
setFilteredConversations(conversations);
|
|
2173
|
-
return;
|
|
2174
|
-
}
|
|
2175
|
-
const filtered = conversations.filter((c) => c.text.toLowerCase().includes(value.toLowerCase()));
|
|
2176
|
-
log.debug("Filtered conversations:", filtered);
|
|
2177
|
-
setFilteredConversations(filtered);
|
|
2178
|
-
};
|
|
2179
|
-
const displayMode = import_Chatbot.ChatbotDisplayMode.drawer;
|
|
2180
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Chatbot.default, { isCompact: true, displayMode, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2181
|
-
import_ChatbotConversationHistoryNav.default,
|
|
2182
|
-
{
|
|
2183
|
-
isCompact: true,
|
|
2184
|
-
drawerPanelContentProps: { isResizable: true, minSize: "200px" },
|
|
2185
|
-
displayMode,
|
|
2186
|
-
onDrawerToggle: () => {
|
|
2187
|
-
setIsDrawerOpen(!isDrawerOpen);
|
|
2188
|
-
setFilteredConversations(conversations);
|
|
2189
|
-
},
|
|
2190
|
-
isDrawerOpen,
|
|
2191
|
-
setIsDrawerOpen,
|
|
2192
|
-
onSelectActiveItem: (_e, selectedItem) => onSelectItemInHistory(String(selectedItem)),
|
|
2193
|
-
conversations: [...filteredConversations].reverse(),
|
|
2194
|
-
onNewChat: () => {
|
|
2195
|
-
setIsDrawerOpen(!isDrawerOpen);
|
|
2196
|
-
setFilteredConversations(conversations);
|
|
2197
|
-
setMessages([]);
|
|
2198
|
-
},
|
|
2199
|
-
handleTextInputChange: handleSearchTextChange,
|
|
2200
|
-
drawerContent: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2201
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DiagnosisChatbotHeader, { isDrawerOpen, setIsDrawerOpen }),
|
|
2202
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DiagnosisChatbotContent, {}),
|
|
2203
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DiagnosisChatbotFooter, {})
|
|
2204
|
-
] })
|
|
2205
|
-
}
|
|
2206
|
-
) });
|
|
2207
|
-
};
|
|
2208
|
-
DiagnosisChatbotHeader = ({ isDrawerOpen, setIsDrawerOpen }) => {
|
|
2209
|
-
const { setIsChatbotOpen } = (0, import_react8.useContext)(ChatbotContext);
|
|
2210
|
-
const modelName = aiService.getModel()?.name;
|
|
2211
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ChatbotHeader.default, { children: [
|
|
2212
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ChatbotHeader.ChatbotHeaderMain, { children: [
|
|
2213
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ChatbotHeader.ChatbotHeaderMenu, { "aria-expanded": isDrawerOpen, onMenuToggle: () => setIsDrawerOpen(!isDrawerOpen) }),
|
|
2214
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ChatbotHeader.ChatbotHeaderTitle, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_core2.Content, { component: "h2", children: "AI - Diagnosis" }) })
|
|
2215
|
-
] }),
|
|
2216
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ChatbotHeader.ChatbotHeaderActions, { children: [
|
|
2217
|
-
modelName && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_core2.Label, { variant: "outline", children: modelName }),
|
|
2218
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ChatbotHeader.ChatbotHeaderCloseButton, { onClick: () => setIsChatbotOpen(false) })
|
|
2219
|
-
] })
|
|
2220
|
-
] });
|
|
2221
|
-
};
|
|
2222
|
-
DiagnosisChatbotContent = () => {
|
|
2223
|
-
const { messages, announcement } = (0, import_react8.useContext)(ChatbotContext);
|
|
2224
|
-
const scrollToBottomRef = (0, import_react8.useRef)(null);
|
|
2225
|
-
(0, import_react8.useEffect)(() => {
|
|
2226
|
-
if (messages.length > 2) {
|
|
2227
|
-
scrollToBottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
2228
|
-
}
|
|
2229
|
-
}, [messages]);
|
|
2230
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ChatbotContent.default, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_MessageBox.default, { announcement, children: messages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react8.default.Fragment, { children: [
|
|
2231
|
-
index === messages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: scrollToBottomRef }),
|
|
2232
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Message.default, { ...message }, message.id)
|
|
2233
|
-
] }, message.id)) }) });
|
|
768
|
+
import_react_core2 = require("@patternfly/react-core");
|
|
769
|
+
import_wrench_icon = __toESM(require("@patternfly/react-icons/dist/esm/icons/wrench-icon"));
|
|
770
|
+
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
771
|
+
ToolCallsInfo = ({ call, index }) => {
|
|
772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_core2.Alert, { variant: "info", customIcon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_wrench_icon.default, {}), title: call.name, isInline: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
|
|
773
|
+
"Args: ",
|
|
774
|
+
JSON.stringify(call.args)
|
|
775
|
+
] }) }, index);
|
|
2234
776
|
};
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
// src/ai-plugin/chat/ToolCallsApprove.tsx
|
|
781
|
+
var import_ui, import_react_core3, import_react7, import_jsx_runtime3, ToolCallsApprove;
|
|
782
|
+
var init_ToolCallsApprove = __esm({
|
|
783
|
+
"src/ai-plugin/chat/ToolCallsApprove.tsx"() {
|
|
784
|
+
"use strict";
|
|
785
|
+
import_ui = require("@hawtio/react/ui");
|
|
786
|
+
import_react_core3 = require("@patternfly/react-core");
|
|
787
|
+
import_react7 = require("react");
|
|
788
|
+
init_ai_service();
|
|
789
|
+
init_context();
|
|
790
|
+
init_globals();
|
|
791
|
+
init_ThinkInfo();
|
|
792
|
+
init_ToolCallsInfo();
|
|
793
|
+
import_jsx_runtime3 = require("react/jsx-runtime");
|
|
794
|
+
ToolCallsApprove = ({ toolCalls, messageId }) => {
|
|
795
|
+
const { username } = (0, import_react7.useContext)(import_ui.PageContext);
|
|
796
|
+
const { messages, setAnnouncement, setIsSendButtonDisabled, updateConversations } = (0, import_react7.useContext)(ChatbotContext);
|
|
797
|
+
const messagesRef = (0, import_react7.useRef)(messages);
|
|
798
|
+
(0, import_react7.useEffect)(() => {
|
|
2240
799
|
messagesRef.current = messages;
|
|
2241
800
|
}, [messages]);
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
log.debug("Send", messagesRef.current);
|
|
2247
|
-
setIsSendButtonDisabled(true);
|
|
2248
|
-
const newMessages = [];
|
|
2249
|
-
newMessages.push(...messagesRef.current);
|
|
2250
|
-
newMessages.push(aiService.createUserMessage(username, message));
|
|
2251
|
-
newMessages.push(aiService.createLoadingBotMessage());
|
|
2252
|
-
updateConversations(newMessages);
|
|
2253
|
-
setAnnouncement(`Message from User: ${message}. Message from Bot is loading.`);
|
|
2254
|
-
log.debug("handleSend - new messages:", newMessages);
|
|
2255
|
-
const dialogId = newMessages[0].id;
|
|
2256
|
-
const answer = await (newMessages.length === 2 ? aiService.newChat(dialogId, message) : aiService.chat(dialogId, message));
|
|
2257
|
-
const loadedMessages = [];
|
|
2258
|
-
loadedMessages.push(...newMessages);
|
|
2259
|
-
log.debug("handleSend - loaded messages:", loadedMessages);
|
|
2260
|
-
loadedMessages.pop();
|
|
2261
|
-
const botMessage = aiService.toBotMessage(answer, ThinkInfo, ToolCallsInfo, ToolCallsApprove);
|
|
2262
|
-
loadedMessages.push(botMessage);
|
|
2263
|
-
updateConversations(loadedMessages);
|
|
2264
|
-
setAnnouncement(`Message from Bot: ${answer}`);
|
|
2265
|
-
setIsSendButtonDisabled(false);
|
|
801
|
+
const removeApproveButtons = (messages2) => {
|
|
802
|
+
return messages2.map(
|
|
803
|
+
(m) => m.id === messageId ? { ...m, extraContent: { ...m.extraContent, afterMainContent: void 0 } } : m
|
|
804
|
+
);
|
|
2266
805
|
};
|
|
2267
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ChatbotFooter.default, { children: [
|
|
2268
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2269
|
-
import_MessageBar.default,
|
|
2270
|
-
{
|
|
2271
|
-
onSendMessage: (m) => handleSend(String(m)),
|
|
2272
|
-
hasAttachButton: false,
|
|
2273
|
-
isSendButtonDisabled
|
|
2274
|
-
}
|
|
2275
|
-
),
|
|
2276
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ChatbotFooter.ChatbotFootnote, { label: "AI may be inaccurate. Please verify important information." })
|
|
2277
|
-
] });
|
|
2278
|
-
};
|
|
2279
|
-
ThinkInfo = (think) => {
|
|
2280
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_core2.Alert, { variant: "info", title: "Thinking", isExpandable: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_chatbot.MarkdownContent, { content: think }) });
|
|
2281
|
-
};
|
|
2282
|
-
ToolCallsInfo = (call, index) => {
|
|
2283
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_core2.Alert, { variant: "info", customIcon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_wrench_icon.default, {}), title: call.name, isExpandable: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
|
|
2284
|
-
"Args: ",
|
|
2285
|
-
JSON.stringify(call.args),
|
|
2286
|
-
" "
|
|
2287
|
-
] }) }, index);
|
|
2288
|
-
};
|
|
2289
|
-
ToolCallsApprove = (toolCalls) => {
|
|
2290
|
-
const { username } = (0, import_react8.useContext)(import_ui.PageContext);
|
|
2291
|
-
const { messages, setAnnouncement, setIsSendButtonDisabled, updateConversations } = (0, import_react8.useContext)(ChatbotContext);
|
|
2292
|
-
const messagesRef = (0, import_react8.useRef)(messages);
|
|
2293
806
|
const approve = async (toolCalls2) => {
|
|
2294
|
-
log.debug("Approved", messagesRef.current);
|
|
807
|
+
log.debug("ToolCallsApprove - Approved", messagesRef.current);
|
|
2295
808
|
setIsSendButtonDisabled(true);
|
|
2296
|
-
const newMessages = [];
|
|
2297
|
-
newMessages.push(...messagesRef.current);
|
|
809
|
+
const newMessages = removeApproveButtons([...messagesRef.current]);
|
|
2298
810
|
newMessages.push(aiService.createUserMessage(username, "Approved"));
|
|
2299
811
|
newMessages.push(aiService.createLoadingBotMessage());
|
|
2300
812
|
updateConversations(newMessages);
|
|
2301
813
|
setAnnouncement(`User approved tool usage. Message from Bot is loading.`);
|
|
2302
|
-
log.debug("approve - newMessages:", newMessages);
|
|
2303
814
|
const dialogId = newMessages[0].id;
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
815
|
+
const loadedMessages = [...newMessages];
|
|
816
|
+
const answer = await aiService.invokeTools(dialogId, toolCalls2, (intermediateAnswer) => {
|
|
817
|
+
loadedMessages.pop();
|
|
818
|
+
loadedMessages.push(aiService.toBotMessage(intermediateAnswer, true, ThinkInfo, ToolCallsInfo, ToolCallsApprove));
|
|
819
|
+
loadedMessages.push(aiService.createLoadingBotMessage());
|
|
820
|
+
updateConversations([...loadedMessages]);
|
|
821
|
+
});
|
|
2309
822
|
loadedMessages.pop();
|
|
2310
|
-
const botMessage = aiService.toBotMessage(answer, ThinkInfo, ToolCallsInfo, ToolCallsApprove);
|
|
823
|
+
const botMessage = aiService.toBotMessage(answer, false, ThinkInfo, ToolCallsInfo, ToolCallsApprove);
|
|
2311
824
|
loadedMessages.push(botMessage);
|
|
2312
|
-
updateConversations(loadedMessages);
|
|
825
|
+
updateConversations([...loadedMessages]);
|
|
2313
826
|
setAnnouncement(`Message from Bot: ${answer}`);
|
|
2314
|
-
|
|
827
|
+
if (!aiService.hasToolCalls(answer)) {
|
|
828
|
+
setIsSendButtonDisabled(false);
|
|
829
|
+
}
|
|
2315
830
|
};
|
|
2316
831
|
const reject = () => {
|
|
2317
|
-
log.debug("Rejected");
|
|
2318
|
-
|
|
2319
|
-
const
|
|
2320
|
-
|
|
832
|
+
log.debug("ToolCallsApprove - Rejected", messagesRef.current);
|
|
833
|
+
const currentMessages = messagesRef.current;
|
|
834
|
+
const dialogId = currentMessages[0]?.id;
|
|
835
|
+
if (dialogId) {
|
|
836
|
+
aiService.rejectTools(dialogId, toolCalls);
|
|
837
|
+
}
|
|
838
|
+
const newMessages = removeApproveButtons([...currentMessages]);
|
|
2321
839
|
newMessages.push(aiService.createUserMessage(username, "Rejected"));
|
|
2322
840
|
updateConversations(newMessages);
|
|
2323
841
|
setIsSendButtonDisabled(false);
|
|
2324
842
|
};
|
|
2325
|
-
return /* @__PURE__ */ (0,
|
|
2326
|
-
/* @__PURE__ */ (0,
|
|
2327
|
-
/* @__PURE__ */ (0,
|
|
843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_core3.Flex, { columnGap: { default: "columnGapSm" }, children: [
|
|
844
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_core3.Button, { variant: "primary", onClick: () => approve(toolCalls), children: "Approve" }),
|
|
845
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_core3.Button, { variant: "secondary", onClick: reject, children: "Reject" })
|
|
2328
846
|
] });
|
|
2329
847
|
};
|
|
2330
848
|
}
|
|
2331
849
|
});
|
|
2332
850
|
|
|
2333
|
-
// src/ai-plugin/
|
|
2334
|
-
var
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
});
|
|
2338
|
-
|
|
2339
|
-
// node_modules/jolokia.js/dist/jolokia.mjs
|
|
2340
|
-
function prepareRequest(request, agentOptions, params) {
|
|
2341
|
-
const opts = Object.assign({}, agentOptions, { dataType: "json" }, params);
|
|
2342
|
-
assertNotNull(opts.url, "No URL given");
|
|
2343
|
-
const fetchOptions = Object.assign({}, DEFAULT_FETCH_PARAMS);
|
|
2344
|
-
fetchOptions.headers = {};
|
|
2345
|
-
const method = extractMethod(request, opts);
|
|
2346
|
-
let url = ensureTrailingSlash(opts.url);
|
|
2347
|
-
if (opts.headers) {
|
|
2348
|
-
Object.assign(fetchOptions.headers, opts.headers);
|
|
2349
|
-
}
|
|
2350
|
-
if (method === "post") {
|
|
2351
|
-
fetchOptions.method = "POST";
|
|
2352
|
-
Object.assign(fetchOptions.headers, { "Content-Type": "text/json" });
|
|
2353
|
-
} else {
|
|
2354
|
-
fetchOptions.method = "GET";
|
|
2355
|
-
url += constructGetUrlPath(request);
|
|
2356
|
-
}
|
|
2357
|
-
url = addProcessingParameters(url, opts);
|
|
2358
|
-
if (opts.username && opts.password) {
|
|
2359
|
-
if (typeof window.btoa === "function") {
|
|
2360
|
-
fetchOptions.headers["Authorization"] = "Basic " + window.btoa(opts.username + ":" + opts.password);
|
|
2361
|
-
} else {
|
|
2362
|
-
console.warn(`Can't set "Authorization" header - no btoa() function available`);
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
if (opts.timeout != null) {
|
|
2366
|
-
fetchOptions.signal = AbortSignal.timeout(opts.timeout);
|
|
2367
|
-
}
|
|
2368
|
-
let successCb = void 0;
|
|
2369
|
-
let errorCb = void 0;
|
|
2370
|
-
let fetchErrorCb = void 0;
|
|
2371
|
-
if ("success" in opts) {
|
|
2372
|
-
successCb = constructCallbackDispatcher(opts.success);
|
|
2373
|
-
errorCb = constructCallbackDispatcher(opts.error);
|
|
2374
|
-
}
|
|
2375
|
-
if ("error" in opts && !opts.success) {
|
|
2376
|
-
successCb = constructCallbackDispatcher("ignore");
|
|
2377
|
-
errorCb = constructCallbackDispatcher(opts.error);
|
|
2378
|
-
}
|
|
2379
|
-
if (!("fetchError" in opts)) {
|
|
2380
|
-
if (successCb && errorCb) {
|
|
2381
|
-
fetchErrorCb = (_response, reason) => {
|
|
2382
|
-
console.warn(reason);
|
|
2383
|
-
};
|
|
2384
|
-
}
|
|
2385
|
-
} else if (opts.fetchError === "ignore") {
|
|
2386
|
-
fetchErrorCb = (_response, _reason) => {
|
|
2387
|
-
};
|
|
2388
|
-
} else {
|
|
2389
|
-
fetchErrorCb = opts.fetchError;
|
|
2390
|
-
}
|
|
2391
|
-
return { url, fetchOptions, dataType: opts.dataType, resolve: opts.resolve, successCb, errorCb, fetchErrorCb };
|
|
2392
|
-
}
|
|
2393
|
-
async function performRequest(args) {
|
|
2394
|
-
const { url, fetchOptions, dataType, resolve, successCb, errorCb, fetchErrorCb } = args;
|
|
2395
|
-
if (successCb && errorCb) {
|
|
2396
|
-
return fetch(url, fetchOptions).then(async (response) => {
|
|
2397
|
-
if (response.status != 200) {
|
|
2398
|
-
fetchErrorCb?.(response, response.statusText);
|
|
2399
|
-
return void 0;
|
|
2400
|
-
}
|
|
2401
|
-
const ct = response.headers.get("content-type");
|
|
2402
|
-
if (dataType === "text" || !ct || !(ct.startsWith("text/json") || ct.startsWith("application/json"))) {
|
|
2403
|
-
const textResponse = await response.text();
|
|
2404
|
-
void successCb(textResponse);
|
|
2405
|
-
} else {
|
|
2406
|
-
const jsonResponse = await response.json();
|
|
2407
|
-
const responses = Array.isArray(jsonResponse) ? jsonResponse : [jsonResponse];
|
|
2408
|
-
for (let n = 0; n < responses.length; n++) {
|
|
2409
|
-
const resp = responses[n];
|
|
2410
|
-
if (Jolokia.isError(resp)) {
|
|
2411
|
-
errorCb(resp, n);
|
|
2412
|
-
} else {
|
|
2413
|
-
successCb(resp, n);
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
}).catch((reason) => {
|
|
2418
|
-
fetchErrorCb?.(null, reason);
|
|
2419
|
-
return void 0;
|
|
2420
|
-
});
|
|
2421
|
-
} else {
|
|
2422
|
-
if (resolve === "response") {
|
|
2423
|
-
return fetch(url, fetchOptions);
|
|
2424
|
-
} else {
|
|
2425
|
-
const promise = fetch(url, fetchOptions).then(async (response) => {
|
|
2426
|
-
if (response.status != 200) {
|
|
2427
|
-
throw response;
|
|
2428
|
-
}
|
|
2429
|
-
const ct = response.headers.get("content-type");
|
|
2430
|
-
if (dataType === "text" || !ct || !(ct.startsWith("text/json") || ct.startsWith("application/json"))) {
|
|
2431
|
-
return response.text();
|
|
2432
|
-
}
|
|
2433
|
-
return response.json();
|
|
2434
|
-
});
|
|
2435
|
-
if (fetchErrorCb) {
|
|
2436
|
-
return promise.catch((error) => {
|
|
2437
|
-
if (error instanceof Response) {
|
|
2438
|
-
fetchErrorCb(error, null);
|
|
2439
|
-
} else {
|
|
2440
|
-
fetchErrorCb(null, error);
|
|
2441
|
-
}
|
|
2442
|
-
return void 0;
|
|
2443
|
-
});
|
|
2444
|
-
} else {
|
|
2445
|
-
return promise;
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
function constructCallbackDispatcher(cb) {
|
|
2451
|
-
if (!cb || Array.isArray(cb) && cb.length == 0) {
|
|
2452
|
-
return (response, index) => {
|
|
2453
|
-
let r;
|
|
2454
|
-
if (typeof response === "string") {
|
|
2455
|
-
r = response;
|
|
2456
|
-
} else {
|
|
2457
|
-
r = JSON.stringify(response);
|
|
2458
|
-
}
|
|
2459
|
-
if (r && r.length > 256) {
|
|
2460
|
-
r = r.substring(0, 253) + "...";
|
|
2461
|
-
}
|
|
2462
|
-
console.warn("Ignore response", '"' + r + '"', "index=", index);
|
|
2463
|
-
};
|
|
2464
|
-
}
|
|
2465
|
-
if (cb === "ignore") {
|
|
2466
|
-
return () => {
|
|
2467
|
-
};
|
|
2468
|
-
}
|
|
2469
|
-
const cbArray = Array.isArray(cb) ? cb : [cb];
|
|
2470
|
-
return (response, index) => {
|
|
2471
|
-
if (typeof response === "string") {
|
|
2472
|
-
cbArray[0](response);
|
|
2473
|
-
} else {
|
|
2474
|
-
cbArray[index % cbArray.length](response, index);
|
|
2475
|
-
}
|
|
2476
|
-
};
|
|
2477
|
-
}
|
|
2478
|
-
function createJolokiaInvocation(jobs, agentOptions) {
|
|
2479
|
-
const requestArguments = prepareRequest([], agentOptions, { method: "post" });
|
|
2480
|
-
return function() {
|
|
2481
|
-
const successCbs = [];
|
|
2482
|
-
const errorCbs = [];
|
|
2483
|
-
const requests = [];
|
|
2484
|
-
const indexMapping = [];
|
|
2485
|
-
const fetchErrorCbs = [];
|
|
2486
|
-
for (const [jobId, job] of jobs) {
|
|
2487
|
-
const reqsLen = job.requests.length;
|
|
2488
|
-
if (job.success) {
|
|
2489
|
-
const successCb = constructSuccessJobCallback(job, jobId, indexMapping);
|
|
2490
|
-
const errorCb = constructErrorJobCallback(job, jobId, indexMapping);
|
|
2491
|
-
for (let idx = 0; idx < reqsLen; idx++) {
|
|
2492
|
-
requests.push(prepareJobRequest(job, idx));
|
|
2493
|
-
successCbs.push(successCb);
|
|
2494
|
-
errorCbs.push(errorCb);
|
|
2495
|
-
indexMapping.push(idx);
|
|
2496
|
-
}
|
|
2497
|
-
if (job.fetchError) {
|
|
2498
|
-
fetchErrorCbs.push(job.fetchError);
|
|
2499
|
-
}
|
|
2500
|
-
} else if (job.callback) {
|
|
2501
|
-
const callbackConfiguration = constructJobCallbackConfiguration(job, jobId);
|
|
2502
|
-
for (let idx = 0; idx < reqsLen - 1; idx++) {
|
|
2503
|
-
requests.push(prepareJobRequest(job, idx));
|
|
2504
|
-
successCbs.push(callbackConfiguration.cb);
|
|
2505
|
-
errorCbs.push(callbackConfiguration.cb);
|
|
2506
|
-
indexMapping.push(-1);
|
|
2507
|
-
}
|
|
2508
|
-
requests.push(prepareJobRequest(job, reqsLen - 1));
|
|
2509
|
-
successCbs.push(callbackConfiguration.lcb);
|
|
2510
|
-
errorCbs.push(callbackConfiguration.lcb);
|
|
2511
|
-
indexMapping.push(-1);
|
|
2512
|
-
const cb = (response, error) => {
|
|
2513
|
-
job.callback(response ?? error);
|
|
2514
|
-
};
|
|
2515
|
-
fetchErrorCbs.push(cb);
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
if (requests.length > 0) {
|
|
2519
|
-
requestArguments.fetchOptions.body = JSON.stringify(requests);
|
|
2520
|
-
requestArguments.successCb = function(response, index) {
|
|
2521
|
-
successCbs[index](response, index);
|
|
2522
|
-
};
|
|
2523
|
-
requestArguments.errorCb = function(response, index) {
|
|
2524
|
-
errorCbs[index](response, index);
|
|
2525
|
-
};
|
|
2526
|
-
requestArguments.fetchErrorCb = function(response, error) {
|
|
2527
|
-
if (fetchErrorCbs.length > 0) {
|
|
2528
|
-
fetchErrorCbs.forEach((cb) => {
|
|
2529
|
-
cb(response, error);
|
|
2530
|
-
});
|
|
2531
|
-
} else {
|
|
2532
|
-
if (response) {
|
|
2533
|
-
console.error("Problem executing registered jobs: ", response.status, response.statusText);
|
|
2534
|
-
} else {
|
|
2535
|
-
console.error("Problem executing registered jobs: ", error);
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
};
|
|
2539
|
-
performRequest(requestArguments).catch((e) => {
|
|
2540
|
-
console.warn("Problem invoking a poller", e);
|
|
2541
|
-
});
|
|
2542
|
-
}
|
|
2543
|
-
};
|
|
2544
|
-
}
|
|
2545
|
-
function constructSuccessJobCallback(job, jobId, indexMapping) {
|
|
2546
|
-
if (!job.success) {
|
|
2547
|
-
throw "Expected 'success' callback configured for the job with ID=" + jobId;
|
|
2548
|
-
}
|
|
2549
|
-
return function(response, index) {
|
|
2550
|
-
if (job.onlyIfModified) {
|
|
2551
|
-
job.lastModified = response.timestamp;
|
|
2552
|
-
}
|
|
2553
|
-
job.success(response, jobId, indexMapping[index]);
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
function constructErrorJobCallback(job, jobId, indexMapping) {
|
|
2557
|
-
if (!job.error) {
|
|
2558
|
-
throw "Expected 'error' callback configured for the job with ID=" + jobId;
|
|
2559
|
-
}
|
|
2560
|
-
return function(response, index) {
|
|
2561
|
-
if (response.status === 304) {
|
|
2562
|
-
return;
|
|
2563
|
-
} else {
|
|
2564
|
-
job.error(response, jobId, indexMapping[index]);
|
|
2565
|
-
}
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
|
-
function constructJobCallbackConfiguration(job, jobId) {
|
|
2569
|
-
if (!job.callback) {
|
|
2570
|
-
throw "Expected 'callback' configured for the job with ID=" + jobId;
|
|
2571
|
-
}
|
|
2572
|
-
const allResponses = [];
|
|
2573
|
-
let lastModified = 0;
|
|
2574
|
-
return {
|
|
2575
|
-
cb: addResponse,
|
|
2576
|
-
lcb: function(response, index) {
|
|
2577
|
-
addResponse(response);
|
|
2578
|
-
if (allResponses.length > 0) {
|
|
2579
|
-
job.lastModified = lastModified;
|
|
2580
|
-
job.callback(...allResponses);
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
};
|
|
2584
|
-
function addResponse(response, _index) {
|
|
2585
|
-
if (response.status !== 304) {
|
|
2586
|
-
if (lastModified === 0 || response.timestamp && response.timestamp < lastModified) {
|
|
2587
|
-
if (response.timestamp) {
|
|
2588
|
-
lastModified = response.timestamp;
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
allResponses.push(response);
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
function prepareJobRequest(job, requestIndex) {
|
|
2596
|
-
const request = job.requests[requestIndex];
|
|
2597
|
-
const config = job.config || {};
|
|
2598
|
-
const extraConfig = job.onlyIfModified && job.lastModified ? { ifModifiedSince: job.lastModified } : {};
|
|
2599
|
-
request.config = Object.assign({}, config, request.config, extraConfig);
|
|
2600
|
-
return request;
|
|
2601
|
-
}
|
|
2602
|
-
function assertNotNull(value, message) {
|
|
2603
|
-
if (value == null) {
|
|
2604
|
-
throw new Error(message);
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
function extractMethod(request, params) {
|
|
2608
|
-
const methodGiven = params?.method?.toLowerCase();
|
|
2609
|
-
let method;
|
|
2610
|
-
if (!request) {
|
|
2611
|
-
return "get";
|
|
2612
|
-
}
|
|
2613
|
-
if (methodGiven) {
|
|
2614
|
-
if (methodGiven === "get") {
|
|
2615
|
-
if (Array.isArray(request)) {
|
|
2616
|
-
throw new Error("Cannot use GET with bulk requests");
|
|
2617
|
-
}
|
|
2618
|
-
if (request.type?.toLowerCase() === "read" && "attribute" in request && Array.isArray(request.attribute)) {
|
|
2619
|
-
throw new Error("Cannot use GET for read with multiple attributes");
|
|
2620
|
-
}
|
|
2621
|
-
if ("target" in request) {
|
|
2622
|
-
throw new Error("Cannot use GET request with proxy mode");
|
|
2623
|
-
}
|
|
2624
|
-
if ("config" in request) {
|
|
2625
|
-
throw new Error("Cannot use GET with request specific config");
|
|
2626
|
-
}
|
|
2627
|
-
method = "get";
|
|
2628
|
-
} else if (methodGiven !== "post") {
|
|
2629
|
-
throw new Error('Illegal method "' + methodGiven + '"');
|
|
2630
|
-
} else {
|
|
2631
|
-
method = "post";
|
|
2632
|
-
}
|
|
2633
|
-
} else {
|
|
2634
|
-
if (Array.isArray(request) || "config" in request || request.type?.toLowerCase() === "read" && "attribute" in request && Array.isArray(request.attribute) || "target" in request) {
|
|
2635
|
-
method = "post";
|
|
2636
|
-
} else {
|
|
2637
|
-
method = "get";
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
return method;
|
|
2641
|
-
}
|
|
2642
|
-
function ensureTrailingSlash(url) {
|
|
2643
|
-
const v = typeof url === "string" ? url : url.href;
|
|
2644
|
-
let trimEnd = v.length;
|
|
2645
|
-
while (v[trimEnd - 1] === "/") {
|
|
2646
|
-
trimEnd--;
|
|
2647
|
-
}
|
|
2648
|
-
return v.substring(0, trimEnd) + "/";
|
|
2649
|
-
}
|
|
2650
|
-
function addProcessingParameters(url, opts) {
|
|
2651
|
-
let sep = url.indexOf("?") > 0 ? "&" : "?";
|
|
2652
|
-
PROCESSING_PARAMS.forEach(function(key) {
|
|
2653
|
-
const v = opts[key];
|
|
2654
|
-
if (v != null) {
|
|
2655
|
-
url += sep + key + "=" + v;
|
|
2656
|
-
sep = "&";
|
|
2657
|
-
}
|
|
2658
|
-
});
|
|
2659
|
-
return url;
|
|
2660
|
-
}
|
|
2661
|
-
function valueToString(value) {
|
|
2662
|
-
if (value == null) {
|
|
2663
|
-
return "[null]";
|
|
2664
|
-
}
|
|
2665
|
-
if (Array.isArray(value)) {
|
|
2666
|
-
let ret = "";
|
|
2667
|
-
for (let i = 0; i < value.length; i++) {
|
|
2668
|
-
const v = value[i];
|
|
2669
|
-
ret += v == null ? "[null]" : singleValueToString(value[i]);
|
|
2670
|
-
if (i < value.length - 1) {
|
|
2671
|
-
ret += ",";
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
return ret;
|
|
2675
|
-
} else {
|
|
2676
|
-
return singleValueToString(value);
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
function singleValueToString(value) {
|
|
2680
|
-
if (typeof value === "string" && value.length === 0) {
|
|
2681
|
-
return '""';
|
|
2682
|
-
} else {
|
|
2683
|
-
return value.toString();
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
function constructGetUrlPath(request) {
|
|
2687
|
-
let type = request.type;
|
|
2688
|
-
assertNotNull(type, "No request type given for building a GET request");
|
|
2689
|
-
type = type.toLowerCase();
|
|
2690
|
-
const extractor = GET_URL_EXTRACTORS[type];
|
|
2691
|
-
assertNotNull(extractor, "Unknown request type " + type);
|
|
2692
|
-
const result = extractor(request);
|
|
2693
|
-
const parts = result.parts || [];
|
|
2694
|
-
let url = type;
|
|
2695
|
-
parts.forEach(function(v) {
|
|
2696
|
-
url += "/" + Jolokia.escape(v);
|
|
2697
|
-
});
|
|
2698
|
-
if (result.path) {
|
|
2699
|
-
url += (result.path[0] === "/" ? "" : "/") + result.path;
|
|
2700
|
-
}
|
|
2701
|
-
return url;
|
|
2702
|
-
}
|
|
2703
|
-
function extractNotificationMode(client, opts) {
|
|
2704
|
-
const backends = client.backend || {};
|
|
2705
|
-
let mode = opts.mode;
|
|
2706
|
-
if (!mode) {
|
|
2707
|
-
mode = backends["sse"] ? "sse" : backends["pull"] ? "pull" : void 0;
|
|
2708
|
-
if (!mode && backends.length === 1) {
|
|
2709
|
-
return Object.keys(backends)[0];
|
|
2710
|
-
}
|
|
2711
|
-
}
|
|
2712
|
-
if (!mode || !backends[mode]) {
|
|
2713
|
-
throw new Error("Notification mode must be one of [" + Object.keys(backends) + "]" + (mode ? ', and not "' + mode + '"' : ""));
|
|
2714
|
-
}
|
|
2715
|
-
return mode;
|
|
2716
|
-
}
|
|
2717
|
-
var CLIENT_VERSION, DEFAULT_FETCH_PARAMS, PROCESSING_PARAMS, Jolokia, GET_URL_EXTRACTORS;
|
|
2718
|
-
var init_jolokia = __esm({
|
|
2719
|
-
"node_modules/jolokia.js/dist/jolokia.mjs"() {
|
|
851
|
+
// src/ai-plugin/chat/ChatbotPanel.tsx
|
|
852
|
+
var import_ui2, import_Chatbot, import_ChatbotContent, import_ChatbotConversationHistoryNav, import_ChatbotFooter, import_ChatbotHeader, import_ChatbotWelcomePrompt, import_Message, import_MessageBar, import_MessageBox, import_react_core4, import_react8, import_jsx_runtime4, ChatbotPanel, ChatbotPanelHeader, ChatbotPanelContent, ChatbotPanelFooter;
|
|
853
|
+
var init_ChatbotPanel = __esm({
|
|
854
|
+
"src/ai-plugin/chat/ChatbotPanel.tsx"() {
|
|
2720
855
|
"use strict";
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
let timerId = null;
|
|
2751
|
-
if (typeof config === "string") {
|
|
2752
|
-
config = { url: config };
|
|
2753
|
-
}
|
|
2754
|
-
Object.assign(agentOptions, DEFAULT_FETCH_PARAMS, config);
|
|
2755
|
-
this.request = async function(request, params) {
|
|
2756
|
-
const args = prepareRequest(request, agentOptions, params);
|
|
2757
|
-
if (args.fetchOptions.method === "POST") {
|
|
2758
|
-
args.fetchOptions.body = JSON.stringify(request);
|
|
2759
|
-
}
|
|
2760
|
-
return performRequest(args);
|
|
2761
|
-
};
|
|
2762
|
-
this.register = function(jobInfo, ...requests) {
|
|
2763
|
-
if (!requests || requests.length == 0) {
|
|
2764
|
-
throw "At a least one request must be provided";
|
|
2765
|
-
}
|
|
2766
|
-
const job = { requests };
|
|
2767
|
-
if (typeof jobInfo === "function") {
|
|
2768
|
-
job.callback = jobInfo;
|
|
2769
|
-
} else {
|
|
2770
|
-
if ("callback" in jobInfo) {
|
|
2771
|
-
job.callback = jobInfo.callback;
|
|
2772
|
-
} else if ("success" in jobInfo && "error" in jobInfo) {
|
|
2773
|
-
job.success = jobInfo.success;
|
|
2774
|
-
job.error = jobInfo.error;
|
|
2775
|
-
job.fetchError = jobInfo.fetchError;
|
|
2776
|
-
} else {
|
|
2777
|
-
throw "Either 'callback' or ('success' and 'error') callback must be provided when registering a Jolokia job";
|
|
2778
|
-
}
|
|
2779
|
-
job.config = jobInfo.config;
|
|
2780
|
-
job.onlyIfModified = jobInfo.onlyIfModified;
|
|
2781
|
-
}
|
|
2782
|
-
return addJob(job);
|
|
2783
|
-
};
|
|
2784
|
-
this.unregister = function(handle) {
|
|
2785
|
-
jobs.delete(handle);
|
|
2786
|
-
};
|
|
2787
|
-
this.jobs = function() {
|
|
2788
|
-
return [...jobs.keys()];
|
|
2789
|
-
};
|
|
2790
|
-
this.start = function(interval) {
|
|
2791
|
-
interval = interval || agentOptions.fetchInterval || 3e4;
|
|
2792
|
-
if (pollerIsRunning) {
|
|
2793
|
-
if (interval === agentOptions.fetchInterval) {
|
|
2794
|
-
return;
|
|
2795
|
-
}
|
|
2796
|
-
this.stop();
|
|
856
|
+
import_ui2 = require("@hawtio/react/ui");
|
|
857
|
+
import_Chatbot = __toESM(require("@patternfly/chatbot/dist/dynamic/Chatbot"));
|
|
858
|
+
import_ChatbotContent = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotContent"));
|
|
859
|
+
import_ChatbotConversationHistoryNav = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav"));
|
|
860
|
+
import_ChatbotFooter = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotFooter"));
|
|
861
|
+
import_ChatbotHeader = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotHeader"));
|
|
862
|
+
import_ChatbotWelcomePrompt = __toESM(require("@patternfly/chatbot/dist/dynamic/ChatbotWelcomePrompt"));
|
|
863
|
+
import_Message = __toESM(require("@patternfly/chatbot/dist/dynamic/Message"));
|
|
864
|
+
import_MessageBar = __toESM(require("@patternfly/chatbot/dist/dynamic/MessageBar"));
|
|
865
|
+
import_MessageBox = __toESM(require("@patternfly/chatbot/dist/dynamic/MessageBox"));
|
|
866
|
+
import_react_core4 = require("@patternfly/react-core");
|
|
867
|
+
import_react8 = __toESM(require("react"));
|
|
868
|
+
init_ai_service();
|
|
869
|
+
init_context();
|
|
870
|
+
init_globals();
|
|
871
|
+
init_ThinkInfo();
|
|
872
|
+
init_ToolCallsApprove();
|
|
873
|
+
init_ToolCallsInfo();
|
|
874
|
+
import_jsx_runtime4 = require("react/jsx-runtime");
|
|
875
|
+
ChatbotPanel = ({ title, displayMode }) => {
|
|
876
|
+
const { setMessages, dialogs, conversations } = (0, import_react8.useContext)(ChatbotContext);
|
|
877
|
+
const [isDrawerOpen, setIsDrawerOpen] = (0, import_react8.useState)(false);
|
|
878
|
+
const [filteredConversations, setFilteredConversations] = (0, import_react8.useState)(conversations);
|
|
879
|
+
const onSelectItemInHistory = (selected) => {
|
|
880
|
+
log.debug("Selected conversation with ID:", selected);
|
|
881
|
+
const dialog = dialogs.find((c) => c.id === selected);
|
|
882
|
+
if (dialog) {
|
|
883
|
+
setMessages(dialog.messages);
|
|
884
|
+
setIsDrawerOpen(false);
|
|
2797
885
|
}
|
|
2798
|
-
agentOptions.fetchInterval = interval;
|
|
2799
|
-
timerId = setInterval(createJolokiaInvocation(jobs, agentOptions), interval);
|
|
2800
|
-
pollerIsRunning = true;
|
|
2801
886
|
};
|
|
2802
|
-
|
|
2803
|
-
if (
|
|
887
|
+
const handleSearchTextChange = (value) => {
|
|
888
|
+
if (value.trim() === "") {
|
|
889
|
+
setFilteredConversations(conversations);
|
|
2804
890
|
return;
|
|
2805
891
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
};
|
|
2810
|
-
this.isRunning = function() {
|
|
2811
|
-
return pollerIsRunning;
|
|
2812
|
-
};
|
|
2813
|
-
this.addNotificationListener = async function(opts) {
|
|
2814
|
-
await ensureNotificationRegistration(this);
|
|
2815
|
-
const mode = extractNotificationMode(client, opts);
|
|
2816
|
-
notificationHandlerFunc("lazy-init", mode)();
|
|
2817
|
-
return await this.request({
|
|
2818
|
-
type: "notification",
|
|
2819
|
-
command: "add",
|
|
2820
|
-
mode,
|
|
2821
|
-
client: client.id,
|
|
2822
|
-
mbean: opts.mbean,
|
|
2823
|
-
filter: opts.filter,
|
|
2824
|
-
config: opts.config,
|
|
2825
|
-
handback: opts.handback
|
|
2826
|
-
}, { method: "post" }).then((responses) => {
|
|
2827
|
-
const resp = responses;
|
|
2828
|
-
if (Jolokia.isError(resp)) {
|
|
2829
|
-
throw new Error("Cannot not add notification subscription for " + opts.mbean + " (client: " + client.id + "): " + resp.error);
|
|
2830
|
-
}
|
|
2831
|
-
const handle = {
|
|
2832
|
-
id: resp.value,
|
|
2833
|
-
mode
|
|
2834
|
-
};
|
|
2835
|
-
notificationHandlerFunc("add", mode)(this, handle, opts);
|
|
2836
|
-
return handle;
|
|
2837
|
-
});
|
|
2838
|
-
};
|
|
2839
|
-
this.removeNotificationListener = async function(handle) {
|
|
2840
|
-
notificationHandlerFunc("remove", handle.mode)(this, handle);
|
|
2841
|
-
return await this.request({
|
|
2842
|
-
type: "notification",
|
|
2843
|
-
command: "remove",
|
|
2844
|
-
client: client.id,
|
|
2845
|
-
handle: handle.id
|
|
2846
|
-
}, { method: "post" }).then((responses) => {
|
|
2847
|
-
const resp = responses;
|
|
2848
|
-
return !Jolokia.isError(resp);
|
|
2849
|
-
});
|
|
2850
|
-
};
|
|
2851
|
-
this.unregisterNotificationClient = async function() {
|
|
2852
|
-
const backends = client.backend || {};
|
|
2853
|
-
for (const mode in NOTIFICATION_HANDLERS) {
|
|
2854
|
-
if (NOTIFICATION_HANDLERS[mode] && backends[mode]) {
|
|
2855
|
-
notificationHandlerFunc("unregister", mode)();
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
return await this.request({
|
|
2859
|
-
type: "notification",
|
|
2860
|
-
command: "unregister",
|
|
2861
|
-
client: client.id
|
|
2862
|
-
}, { method: "post" }).then((responses) => {
|
|
2863
|
-
const resp = responses;
|
|
2864
|
-
return !Jolokia.isError(resp);
|
|
2865
|
-
});
|
|
892
|
+
const filtered = conversations.filter((c) => c.text.toLowerCase().includes(value.toLowerCase()));
|
|
893
|
+
log.debug("Filtered conversations:", filtered);
|
|
894
|
+
setFilteredConversations(filtered);
|
|
2866
895
|
};
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
return id;
|
|
2877
|
-
}
|
|
2878
|
-
async function ensureNotificationRegistration(jolokia) {
|
|
2879
|
-
if (!client) {
|
|
2880
|
-
return jolokia.request({
|
|
2881
|
-
type: "notification",
|
|
2882
|
-
command: "register"
|
|
2883
|
-
}, { method: "post" }).then((responses) => {
|
|
2884
|
-
const resp = responses;
|
|
2885
|
-
if (Jolokia.isError(resp)) {
|
|
2886
|
-
throw new Error("Can not register client for notifications: " + resp.error + "\nTrace:\n" + resp.stacktrace);
|
|
2887
|
-
} else {
|
|
2888
|
-
client = resp.value;
|
|
2889
|
-
}
|
|
2890
|
-
return true;
|
|
2891
|
-
});
|
|
2892
|
-
} else {
|
|
2893
|
-
return Promise.resolve(true);
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
function notificationHandlerFunc(what, mode) {
|
|
2897
|
-
const notifHandler = NOTIFICATION_HANDLERS[mode];
|
|
2898
|
-
if (!notifHandler) {
|
|
2899
|
-
throw new Error("Unsupported notification mode '" + mode + "'");
|
|
2900
|
-
}
|
|
2901
|
-
return function(jolokia, handle, opts) {
|
|
2902
|
-
return notifHandler[what]?.apply(notifHandler, [jolokia, handle, opts]);
|
|
2903
|
-
};
|
|
2904
|
-
}
|
|
2905
|
-
const NOTIFICATION_HANDLERS = {
|
|
2906
|
-
"pull": {
|
|
2907
|
-
// "pull" handler is based on server-side MBean instance collecting notifications for all registered
|
|
2908
|
-
// clients. In order to get the notifications, we have to call this MBean's "pull" operation, passing
|
|
2909
|
-
// client ID and handle ID
|
|
2910
|
-
// --- operations of pull notification mechanism
|
|
2911
|
-
add: function(_jolokia, handle, opts) {
|
|
2912
|
-
const job = {
|
|
2913
|
-
callback: function(resp) {
|
|
2914
|
-
if (!Jolokia.isResponseFetchError(resp) && !Jolokia.isError(resp)) {
|
|
2915
|
-
const notifs = resp.value;
|
|
2916
|
-
if (notifs && notifs.notifications && notifs.notifications.length > 0) {
|
|
2917
|
-
opts?.callback?.(notifs);
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
},
|
|
2921
|
-
requests: [{
|
|
2922
|
-
type: "exec",
|
|
2923
|
-
mbean: client.backend["pull"].store,
|
|
2924
|
-
operation: "pull",
|
|
2925
|
-
arguments: [client.id, handle.id]
|
|
2926
|
-
}]
|
|
2927
|
-
};
|
|
2928
|
-
this.jobIds[handle.id] = addJob(job);
|
|
896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Chatbot.default, { isCompact: true, displayMode, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
897
|
+
import_ChatbotConversationHistoryNav.default,
|
|
898
|
+
{
|
|
899
|
+
isCompact: true,
|
|
900
|
+
drawerPanelContentProps: { isResizable: true, minSize: "200px" },
|
|
901
|
+
displayMode,
|
|
902
|
+
onDrawerToggle: () => {
|
|
903
|
+
setIsDrawerOpen(!isDrawerOpen);
|
|
904
|
+
setFilteredConversations(conversations);
|
|
2929
905
|
},
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
906
|
+
isDrawerOpen,
|
|
907
|
+
setIsDrawerOpen,
|
|
908
|
+
onSelectActiveItem: (_e, selectedItem) => onSelectItemInHistory(String(selectedItem)),
|
|
909
|
+
conversations: [...filteredConversations].reverse(),
|
|
910
|
+
onNewChat: () => {
|
|
911
|
+
setIsDrawerOpen(false);
|
|
912
|
+
setFilteredConversations(conversations);
|
|
913
|
+
setMessages([]);
|
|
2936
914
|
},
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
915
|
+
handleTextInputChange: handleSearchTextChange,
|
|
916
|
+
drawerContent: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
917
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
918
|
+
ChatbotPanelHeader,
|
|
919
|
+
{
|
|
920
|
+
isDrawerOpen,
|
|
921
|
+
setIsDrawerOpen,
|
|
922
|
+
title,
|
|
923
|
+
hasCloseButton: displayMode === import_Chatbot.ChatbotDisplayMode.drawer
|
|
2941
924
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
jobIds: {}
|
|
2947
|
-
},
|
|
2948
|
-
"sse": {
|
|
2949
|
-
// "sse" handler is based on https://developer.mozilla.org/en-US/docs/Web/API/EventSource
|
|
2950
|
-
// and continuous stream of events sent over single HTTP connection with text/event-stream MIME type
|
|
2951
|
-
// the messages sent are JSON representations of org.jolokia.server.core.service.notification.NotificationResult instances
|
|
2952
|
-
// --- operations of sse notification mechanism
|
|
2953
|
-
"lazy-init": function() {
|
|
2954
|
-
if (!this.eventSource) {
|
|
2955
|
-
this.eventSource = new EventSource(agentOptions.url + "/notification/open/" + client.id + "/sse");
|
|
2956
|
-
const dispatchers = this.dispatchMap;
|
|
2957
|
-
this.eventSource.addEventListener("message", function(event) {
|
|
2958
|
-
const data = JSON.parse(event.data);
|
|
2959
|
-
if (data.handle) {
|
|
2960
|
-
const callback = dispatchers[data.handle];
|
|
2961
|
-
callback?.(data);
|
|
2962
|
-
}
|
|
2963
|
-
});
|
|
2964
|
-
}
|
|
2965
|
-
},
|
|
2966
|
-
add: function(_jolokia, handle, opts) {
|
|
2967
|
-
this.dispatchMap[handle.id] = opts.callback;
|
|
2968
|
-
},
|
|
2969
|
-
remove: function(_jolokia, handle) {
|
|
2970
|
-
delete this.dispatchMap[handle.id];
|
|
2971
|
-
},
|
|
2972
|
-
unregister: function() {
|
|
2973
|
-
this.dispatchMap = {};
|
|
2974
|
-
this.eventSource?.close();
|
|
2975
|
-
this.eventSource = null;
|
|
2976
|
-
},
|
|
2977
|
-
// --- state of sse notification mechanism
|
|
2978
|
-
// Map for dispatching SSE return notifications
|
|
2979
|
-
dispatchMap: {},
|
|
2980
|
-
// SSE event-source
|
|
2981
|
-
eventSource: null
|
|
925
|
+
),
|
|
926
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChatbotPanelContent, {}),
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChatbotPanelFooter, {})
|
|
928
|
+
] })
|
|
2982
929
|
}
|
|
2983
|
-
};
|
|
2984
|
-
};
|
|
2985
|
-
Object.defineProperty(Jolokia.prototype, "CLIENT_VERSION", {
|
|
2986
|
-
value: CLIENT_VERSION,
|
|
2987
|
-
enumerable: true,
|
|
2988
|
-
writable: false
|
|
2989
|
-
});
|
|
2990
|
-
Jolokia.escape = Jolokia.prototype.escape = function(part) {
|
|
2991
|
-
return encodeURIComponent(part.replace(/!/g, "!!").replace(/\//g, "!/"));
|
|
2992
|
-
};
|
|
2993
|
-
Jolokia.escapePost = Jolokia.prototype.escape = function(part) {
|
|
2994
|
-
return part.replace(/!/g, "!!").replace(/\//g, "!/");
|
|
2995
|
-
};
|
|
2996
|
-
Jolokia.isError = Jolokia.prototype.isError = function(resp) {
|
|
2997
|
-
return resp == null || resp.status != 200;
|
|
2998
|
-
};
|
|
2999
|
-
Jolokia.isResponseSuccess = function(resp) {
|
|
3000
|
-
if (!resp || typeof resp !== "object")
|
|
3001
|
-
return false;
|
|
3002
|
-
return "status" in resp && "timestamp" in resp && "value" in resp;
|
|
930
|
+
) });
|
|
3003
931
|
};
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
return
|
|
932
|
+
ChatbotPanelHeader = ({ isDrawerOpen, setIsDrawerOpen, title, hasCloseButton }) => {
|
|
933
|
+
const { setIsChatbotOpen } = (0, import_react8.useContext)(ChatbotContext);
|
|
934
|
+
const modelName = aiService.getModel()?.name;
|
|
935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ChatbotHeader.default, { children: [
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ChatbotHeader.ChatbotHeaderMain, { children: [
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ChatbotHeader.ChatbotHeaderMenu, { "aria-expanded": isDrawerOpen, onMenuToggle: () => setIsDrawerOpen(!isDrawerOpen) }),
|
|
938
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ChatbotHeader.ChatbotHeaderTitle, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_core4.Content, { component: "h2", children: title }) })
|
|
939
|
+
] }),
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ChatbotHeader.ChatbotHeaderActions, { children: [
|
|
941
|
+
modelName && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_core4.Label, { variant: "outline", children: modelName }),
|
|
942
|
+
hasCloseButton && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ChatbotHeader.ChatbotHeaderCloseButton, { onClick: () => setIsChatbotOpen(false) })
|
|
943
|
+
] })
|
|
944
|
+
] });
|
|
3008
945
|
};
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
946
|
+
ChatbotPanelContent = () => {
|
|
947
|
+
const { messages, announcement } = (0, import_react8.useContext)(ChatbotContext);
|
|
948
|
+
const { username } = (0, import_react8.useContext)(import_ui2.PageContext);
|
|
949
|
+
const scrollToBottomRef = (0, import_react8.useRef)(null);
|
|
950
|
+
const welcomeTitle = `Hello, ${username}!`;
|
|
951
|
+
const welcomeDescription = "How can I help you manage or diagnose your Java application?";
|
|
952
|
+
(0, import_react8.useEffect)(() => {
|
|
953
|
+
if (messages.length > 2) {
|
|
954
|
+
scrollToBottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
955
|
+
}
|
|
956
|
+
}, [messages]);
|
|
957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ChatbotContent.default, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_MessageBox.default, { announcement, children: [
|
|
958
|
+
messages.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ChatbotWelcomePrompt.default, { title: welcomeTitle, description: welcomeDescription }),
|
|
959
|
+
messages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react8.default.Fragment, { children: [
|
|
960
|
+
index === messages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: scrollToBottomRef }),
|
|
961
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Message.default, { ...message }, message.id)
|
|
962
|
+
] }, message.id))
|
|
963
|
+
] }) });
|
|
3017
964
|
};
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
if (
|
|
3027
|
-
return
|
|
3028
|
-
} else {
|
|
3029
|
-
return { parts: [request.mbean, request.attribute], path };
|
|
965
|
+
ChatbotPanelFooter = () => {
|
|
966
|
+
const { username } = (0, import_react8.useContext)(import_ui2.PageContext);
|
|
967
|
+
const { messages, setAnnouncement, isSendButtonDisabled, setIsSendButtonDisabled, updateConversations } = (0, import_react8.useContext)(ChatbotContext);
|
|
968
|
+
const messagesRef = (0, import_react8.useRef)(messages);
|
|
969
|
+
(0, import_react8.useEffect)(() => {
|
|
970
|
+
messagesRef.current = messages;
|
|
971
|
+
}, [messages]);
|
|
972
|
+
const handleSend = async (message) => {
|
|
973
|
+
if (!message.trim()) {
|
|
974
|
+
return;
|
|
3030
975
|
}
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
976
|
+
log.debug("Send", messagesRef.current);
|
|
977
|
+
setIsSendButtonDisabled(true);
|
|
978
|
+
const newMessages = [];
|
|
979
|
+
newMessages.push(...messagesRef.current);
|
|
980
|
+
newMessages.push(aiService.createUserMessage(username, message));
|
|
981
|
+
newMessages.push(aiService.createLoadingBotMessage());
|
|
982
|
+
updateConversations(newMessages);
|
|
983
|
+
setAnnouncement(`Message from User: ${message}. Message from Bot is loading.`);
|
|
984
|
+
log.debug("handleSend - new messages:", newMessages);
|
|
985
|
+
const dialogId = newMessages[0].id;
|
|
986
|
+
const loadedMessages = [...newMessages];
|
|
987
|
+
const onMessage = (intermediateAnswer) => {
|
|
988
|
+
loadedMessages.pop();
|
|
989
|
+
loadedMessages.push(aiService.toBotMessage(intermediateAnswer, true, ThinkInfo, ToolCallsInfo, ToolCallsApprove));
|
|
990
|
+
loadedMessages.push(aiService.createLoadingBotMessage());
|
|
991
|
+
updateConversations([...loadedMessages]);
|
|
992
|
+
};
|
|
993
|
+
const answer = await (newMessages.length === 2 ? aiService.newChat(dialogId, { message }, onMessage) : aiService.chat(dialogId, message, onMessage));
|
|
994
|
+
log.debug("handleSend - loaded messages:", loadedMessages);
|
|
995
|
+
loadedMessages.pop();
|
|
996
|
+
const botMessage = aiService.toBotMessage(answer, false, ThinkInfo, ToolCallsInfo, ToolCallsApprove);
|
|
997
|
+
loadedMessages.push(botMessage);
|
|
998
|
+
updateConversations([...loadedMessages]);
|
|
999
|
+
setAnnouncement(`Message from Bot: ${answer}`);
|
|
1000
|
+
if (!aiService.hasToolCalls(answer)) {
|
|
1001
|
+
setIsSendButtonDisabled(false);
|
|
3052
1002
|
}
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
return {};
|
|
3062
|
-
},
|
|
3063
|
-
/**
|
|
3064
|
-
* Function to prepare GET URL for `search` Jolokia request
|
|
3065
|
-
* @param request Jolokia request object
|
|
3066
|
-
* @returns URL configuration object for Jolokia `search` GET request
|
|
3067
|
-
*/
|
|
3068
|
-
"search": function(request) {
|
|
3069
|
-
return { parts: [request.mbean] };
|
|
3070
|
-
},
|
|
3071
|
-
/**
|
|
3072
|
-
* Function to prepare GET URL for `list` Jolokia request
|
|
3073
|
-
* @param request Jolokia request object
|
|
3074
|
-
* @returns URL configuration object for Jolokia `list` GET request
|
|
3075
|
-
*/
|
|
3076
|
-
"list": function(request) {
|
|
3077
|
-
return { path: request.path };
|
|
3078
|
-
},
|
|
3079
|
-
/**
|
|
3080
|
-
* Function to prepare GET URL for `notification` Jolokia request
|
|
3081
|
-
* @param request Jolokia request object
|
|
3082
|
-
* @returns URL configuration object for Jolokia `notification` GET request
|
|
3083
|
-
*/
|
|
3084
|
-
"notification": function(request) {
|
|
3085
|
-
switch (request.command) {
|
|
3086
|
-
case "register":
|
|
3087
|
-
return { parts: ["register"] };
|
|
3088
|
-
case "add": {
|
|
3089
|
-
const ret = ["add", valueToString(request.client), valueToString(request.mode), valueToString(request.mbean)];
|
|
3090
|
-
const extra = [];
|
|
3091
|
-
if (request.handback) {
|
|
3092
|
-
extra.push(valueToString(request.handback));
|
|
3093
|
-
}
|
|
3094
|
-
if (request.config) {
|
|
3095
|
-
extra.push(valueToString(request.config));
|
|
3096
|
-
} else if (extra.length) {
|
|
3097
|
-
extra.push("{}");
|
|
3098
|
-
}
|
|
3099
|
-
if (request.filter) {
|
|
3100
|
-
extra.push(valueToString(request.filter));
|
|
3101
|
-
} else if (extra.length) {
|
|
3102
|
-
extra.push(" ");
|
|
3103
|
-
}
|
|
3104
|
-
return { parts: ret.concat(extra.reverse()) };
|
|
1003
|
+
};
|
|
1004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ChatbotFooter.default, { children: [
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1006
|
+
import_MessageBar.default,
|
|
1007
|
+
{
|
|
1008
|
+
onSendMessage: (m) => handleSend(String(m)),
|
|
1009
|
+
hasAttachButton: false,
|
|
1010
|
+
isSendButtonDisabled
|
|
3105
1011
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
1012
|
+
),
|
|
1013
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ChatbotFooter.ChatbotFootnote, { label: "AI may be inaccurate. Please verify important information." })
|
|
1014
|
+
] });
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
// src/ai-plugin/chat/Chat.tsx
|
|
1020
|
+
var import_Chatbot2, import_react_core5, import_jsx_runtime5, Chat;
|
|
1021
|
+
var init_Chat2 = __esm({
|
|
1022
|
+
"src/ai-plugin/chat/Chat.tsx"() {
|
|
1023
|
+
"use strict";
|
|
1024
|
+
import_Chatbot2 = require("@patternfly/chatbot/dist/dynamic/Chatbot");
|
|
1025
|
+
import_react_core5 = require("@patternfly/react-core");
|
|
1026
|
+
init_Chat();
|
|
1027
|
+
init_ChatbotPanel();
|
|
1028
|
+
init_context();
|
|
1029
|
+
import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1030
|
+
Chat = () => {
|
|
1031
|
+
const chatbotContext = useChatbot();
|
|
1032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChatbotContext.Provider, { value: chatbotContext, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_core5.PageSection, { id: "chat-content", hasBodyWrapper: false, isFilled: true, padding: { default: "noPadding" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChatbotPanel, { title: "AI Chat", displayMode: import_Chatbot2.ChatbotDisplayMode.embedded }) }) });
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
// src/ai-plugin/chat/ui.ts
|
|
1038
|
+
var ui_exports = {};
|
|
1039
|
+
__export(ui_exports, {
|
|
1040
|
+
Chat: () => Chat
|
|
1041
|
+
});
|
|
1042
|
+
var init_ui = __esm({
|
|
1043
|
+
"src/ai-plugin/chat/ui.ts"() {
|
|
1044
|
+
"use strict";
|
|
1045
|
+
init_Chat2();
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
// src/ai-plugin/jmx-ai/globals.ts
|
|
1050
|
+
var import_react12, pluginName3, pluginTitle3, pluginPath2, log3, PARAM_KEY_NODE_ID;
|
|
1051
|
+
var init_globals3 = __esm({
|
|
1052
|
+
"src/ai-plugin/jmx-ai/globals.ts"() {
|
|
1053
|
+
"use strict";
|
|
1054
|
+
import_react12 = require("@hawtio/react");
|
|
1055
|
+
pluginName3 = "hawtio-ai-jmx";
|
|
1056
|
+
pluginTitle3 = "AI JMX";
|
|
1057
|
+
pluginPath2 = "/ai-jmx";
|
|
1058
|
+
log3 = import_react12.Logger.get(pluginName3);
|
|
1059
|
+
PARAM_KEY_NODE_ID = "nid";
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
|
|
1063
|
+
// src/ai-plugin/jmx-ai/context.ts
|
|
1064
|
+
function useMBeanTree() {
|
|
1065
|
+
const [tree, setTree] = (0, import_react14.useState)(import_react13.MBeanTree.createEmpty(pluginName3));
|
|
1066
|
+
const [loaded, setLoaded] = (0, import_react14.useState)(false);
|
|
1067
|
+
const { selectedNode, setSelectedNode } = (0, import_react14.useContext)(import_react13.PluginNodeSelectionContext);
|
|
1068
|
+
const navigate = (0, import_react_router.useNavigate)();
|
|
1069
|
+
const [searchParams, setSearchParams] = (0, import_react_router.useSearchParams)();
|
|
1070
|
+
const refSelectedNode = (0, import_react14.useRef)();
|
|
1071
|
+
refSelectedNode.current = selectedNode;
|
|
1072
|
+
const populateTree = async () => {
|
|
1073
|
+
const wkspTree = await import_react13.workspace.getTree();
|
|
1074
|
+
setTree(wkspTree);
|
|
1075
|
+
const nodeId = searchParams.get(PARAM_KEY_NODE_ID);
|
|
1076
|
+
if (nodeId && nodeId !== refSelectedNode.current?.id) {
|
|
1077
|
+
log3.debug("Restore selected node with nid:", nodeId);
|
|
1078
|
+
const urlNode = wkspTree.find((node) => node.id === nodeId);
|
|
1079
|
+
if (urlNode) {
|
|
1080
|
+
setSelectedNode(urlNode);
|
|
1081
|
+
refSelectedNode.current = urlNode;
|
|
1082
|
+
} else {
|
|
1083
|
+
log3.debug("Clear invalid nid:", nodeId);
|
|
1084
|
+
searchParams.delete(PARAM_KEY_NODE_ID);
|
|
1085
|
+
setSearchParams(searchParams);
|
|
3119
1086
|
}
|
|
1087
|
+
}
|
|
1088
|
+
if (!refSelectedNode.current) return;
|
|
1089
|
+
const path = [...refSelectedNode.current.path()];
|
|
1090
|
+
wkspTree.forEach(path, (node) => {
|
|
1091
|
+
node.defaultExpanded = true;
|
|
1092
|
+
});
|
|
1093
|
+
const newSelected = wkspTree.navigate(...path);
|
|
1094
|
+
if (newSelected) {
|
|
1095
|
+
setSelectedNode(newSelected);
|
|
1096
|
+
navigate(pluginPathWithNodeId(newSelected, searchParams));
|
|
1097
|
+
} else {
|
|
1098
|
+
navigate(pluginPath2);
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
(0, import_react14.useEffect)(() => {
|
|
1102
|
+
const loadTree = async () => {
|
|
1103
|
+
await populateTree();
|
|
1104
|
+
setLoaded(true);
|
|
1105
|
+
};
|
|
1106
|
+
const listener = () => {
|
|
1107
|
+
setLoaded(false);
|
|
1108
|
+
loadTree();
|
|
3120
1109
|
};
|
|
1110
|
+
import_react13.eventService.onRefresh(listener);
|
|
1111
|
+
loadTree();
|
|
1112
|
+
return () => import_react13.eventService.removeListener(import_react13.EVENT_REFRESH, listener);
|
|
1113
|
+
}, []);
|
|
1114
|
+
return { tree, loaded, selectedNode, setSelectedNode };
|
|
1115
|
+
}
|
|
1116
|
+
function pluginPathWithNodeId(node, searchParams = new URLSearchParams(window.location.search)) {
|
|
1117
|
+
searchParams.set(PARAM_KEY_NODE_ID, node.id);
|
|
1118
|
+
const query = `?${searchParams.toString()}`;
|
|
1119
|
+
return { pathname: pluginPath2, search: query };
|
|
1120
|
+
}
|
|
1121
|
+
var import_react13, import_react14, import_react_router, MBeanTreeContext;
|
|
1122
|
+
var init_context2 = __esm({
|
|
1123
|
+
"src/ai-plugin/jmx-ai/context.ts"() {
|
|
1124
|
+
"use strict";
|
|
1125
|
+
import_react13 = require("@hawtio/react");
|
|
1126
|
+
import_react14 = require("react");
|
|
1127
|
+
import_react_router = require("react-router");
|
|
1128
|
+
init_globals3();
|
|
1129
|
+
MBeanTreeContext = (0, import_react14.createContext)({
|
|
1130
|
+
tree: import_react13.MBeanTree.createEmpty(pluginName3),
|
|
1131
|
+
loaded: false,
|
|
1132
|
+
selectedNode: null,
|
|
1133
|
+
setSelectedNode: () => {
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
// src/ai-plugin/jmx-ai/Jmx.css
|
|
1140
|
+
var init_Jmx = __esm({
|
|
1141
|
+
"src/ai-plugin/jmx-ai/Jmx.css"() {
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1145
|
+
// src/ai-plugin/jmx-ai/JmxContent.css
|
|
1146
|
+
var init_JmxContent = __esm({
|
|
1147
|
+
"src/ai-plugin/jmx-ai/JmxContent.css"() {
|
|
3121
1148
|
}
|
|
3122
1149
|
});
|
|
3123
1150
|
|
|
@@ -3190,12 +1217,12 @@ var init_util = __esm({
|
|
|
3190
1217
|
});
|
|
3191
1218
|
|
|
3192
1219
|
// src/ai-plugin/jmx-ai/attributes/attribute-service.ts
|
|
3193
|
-
var
|
|
1220
|
+
var import_react15, AttributeService, attributeService;
|
|
3194
1221
|
var init_attribute_service = __esm({
|
|
3195
1222
|
"src/ai-plugin/jmx-ai/attributes/attribute-service.ts"() {
|
|
3196
1223
|
"use strict";
|
|
3197
|
-
|
|
3198
|
-
|
|
1224
|
+
import_react15 = require("@hawtio/react");
|
|
1225
|
+
init_globals3();
|
|
3199
1226
|
init_util();
|
|
3200
1227
|
AttributeService = class {
|
|
3201
1228
|
handles = [];
|
|
@@ -3206,35 +1233,35 @@ var init_attribute_service = __esm({
|
|
|
3206
1233
|
return request;
|
|
3207
1234
|
}
|
|
3208
1235
|
async read(mbean) {
|
|
3209
|
-
return await
|
|
1236
|
+
return await import_react15.jolokiaService.readAttributes(mbean, this.requestOptions());
|
|
3210
1237
|
}
|
|
3211
1238
|
async readWithCallback(mbean, callback) {
|
|
3212
|
-
const attrs = await
|
|
1239
|
+
const attrs = await import_react15.jolokiaService.readAttributes(mbean, this.requestOptions());
|
|
3213
1240
|
callback(attrs);
|
|
3214
1241
|
}
|
|
3215
1242
|
async register(request, callback) {
|
|
3216
|
-
const handle = await
|
|
3217
|
-
|
|
1243
|
+
const handle = await import_react15.jolokiaService.register(this.setupConfig(request), callback);
|
|
1244
|
+
log3.debug("Register handle:", handle);
|
|
3218
1245
|
this.handles.push(handle);
|
|
3219
1246
|
}
|
|
3220
1247
|
unregisterAll() {
|
|
3221
|
-
|
|
3222
|
-
this.handles.forEach((handle) =>
|
|
1248
|
+
log3.debug("Unregister all handles:", this.handles);
|
|
1249
|
+
this.handles.forEach((handle) => import_react15.jolokiaService.unregister(handle));
|
|
3223
1250
|
this.handles = [];
|
|
3224
1251
|
}
|
|
3225
1252
|
async buildUrl(mbean, attribute) {
|
|
3226
|
-
const jolokiaUrl = await
|
|
1253
|
+
const jolokiaUrl = await import_react15.jolokiaService.getFullJolokiaUrl();
|
|
3227
1254
|
return `${jolokiaUrl}/read/${escapeMBean(mbean)}/${attribute}`;
|
|
3228
1255
|
}
|
|
3229
1256
|
async canInvoke(mbean, attribute, type) {
|
|
3230
1257
|
return true;
|
|
3231
1258
|
}
|
|
3232
1259
|
async update(mbeanName, attribute, value) {
|
|
3233
|
-
await
|
|
3234
|
-
|
|
1260
|
+
await import_react15.jolokiaService.writeAttribute(mbeanName, attribute, value, this.requestOptions());
|
|
1261
|
+
import_react15.eventService.notify({ type: "success", message: `Updated attribute: ${attribute}` });
|
|
3235
1262
|
}
|
|
3236
1263
|
async bulkRequest(requests) {
|
|
3237
|
-
return
|
|
1264
|
+
return import_react15.jolokiaService.bulkRequest(requests.map(this.setupConfig));
|
|
3238
1265
|
}
|
|
3239
1266
|
};
|
|
3240
1267
|
attributeService = new AttributeService();
|
|
@@ -3242,34 +1269,37 @@ var init_attribute_service = __esm({
|
|
|
3242
1269
|
});
|
|
3243
1270
|
|
|
3244
1271
|
// src/ai-plugin/jmx-ai/attributes/Attributes.tsx
|
|
3245
|
-
var
|
|
1272
|
+
var import_react16, import_ui3, import_react_core7, import_react_icons, import_react_table2, import_jolokia, import_react17, import_jsx_runtime7, Attributes, AiJmxToolbar;
|
|
3246
1273
|
var init_Attributes = __esm({
|
|
3247
1274
|
"src/ai-plugin/jmx-ai/attributes/Attributes.tsx"() {
|
|
3248
1275
|
"use strict";
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
1276
|
+
import_react16 = require("@hawtio/react");
|
|
1277
|
+
import_ui3 = require("@hawtio/react/ui");
|
|
1278
|
+
import_react_core7 = require("@patternfly/react-core");
|
|
3252
1279
|
import_react_icons = require("@patternfly/react-icons");
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
init_ai_service();
|
|
1280
|
+
import_react_table2 = require("@patternfly/react-table");
|
|
1281
|
+
import_jolokia = __toESM(require("jolokia.js"));
|
|
1282
|
+
import_react17 = require("react");
|
|
3257
1283
|
init_context();
|
|
3258
|
-
|
|
3259
|
-
|
|
1284
|
+
init_ThinkInfo();
|
|
1285
|
+
init_ToolCallsApprove();
|
|
1286
|
+
init_ToolCallsInfo();
|
|
1287
|
+
init_ai_service();
|
|
1288
|
+
init_context2();
|
|
1289
|
+
init_globals3();
|
|
3260
1290
|
init_jmx_ai_service();
|
|
3261
1291
|
init_util();
|
|
3262
1292
|
init_attribute_service();
|
|
3263
|
-
|
|
1293
|
+
import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3264
1294
|
Attributes = () => {
|
|
3265
|
-
const { selectedNode } = (0,
|
|
3266
|
-
const [attributes, setAttributes] = (0,
|
|
3267
|
-
const [isReading, setIsReading] = (0,
|
|
3268
|
-
const [isModalOpen, setIsModalOpen] = (0,
|
|
3269
|
-
const [sortDirection, setSortDirection] = (0,
|
|
3270
|
-
const [selected, setSelected] = (0,
|
|
3271
|
-
const [reload, setReload] = (0,
|
|
3272
|
-
(0,
|
|
1295
|
+
const { selectedNode } = (0, import_react17.useContext)(MBeanTreeContext);
|
|
1296
|
+
const [attributes, setAttributes] = (0, import_react17.useState)({});
|
|
1297
|
+
const [isReading, setIsReading] = (0, import_react17.useState)(true);
|
|
1298
|
+
const [isModalOpen, setIsModalOpen] = (0, import_react17.useState)(false);
|
|
1299
|
+
const [sortDirection, setSortDirection] = (0, import_react17.useState)("asc");
|
|
1300
|
+
const [selected, setSelected] = (0, import_react17.useState)({ name: "", value: "" });
|
|
1301
|
+
const [reload, setReload] = (0, import_react17.useState)(false);
|
|
1302
|
+
(0, import_react17.useEffect)(() => {
|
|
3273
1303
|
if (!selectedNode || !selectedNode.mbean || !selectedNode.objectName) {
|
|
3274
1304
|
return;
|
|
3275
1305
|
}
|
|
@@ -3282,14 +1312,14 @@ var init_Attributes = __esm({
|
|
|
3282
1312
|
attributeService.register(
|
|
3283
1313
|
{ type: "read", mbean: objectName },
|
|
3284
1314
|
(response) => {
|
|
3285
|
-
if (response && !
|
|
1315
|
+
if (response && !import_jolokia.default.isError(response)) {
|
|
3286
1316
|
setAttributes(response.value);
|
|
3287
1317
|
}
|
|
3288
1318
|
}
|
|
3289
1319
|
);
|
|
3290
1320
|
return () => attributeService.unregisterAll();
|
|
3291
1321
|
}, [selectedNode]);
|
|
3292
|
-
(0,
|
|
1322
|
+
(0, import_react17.useEffect)(() => {
|
|
3293
1323
|
if (!selectedNode || !selectedNode.mbean || !selectedNode.objectName || !reload) {
|
|
3294
1324
|
return;
|
|
3295
1325
|
}
|
|
@@ -3305,14 +1335,14 @@ var init_Attributes = __esm({
|
|
|
3305
1335
|
return null;
|
|
3306
1336
|
}
|
|
3307
1337
|
if (isReading) {
|
|
3308
|
-
return /* @__PURE__ */ (0,
|
|
1338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.HawtioLoadingCard, {});
|
|
3309
1339
|
}
|
|
3310
1340
|
const rows = Object.entries(attributes).map(([name, value]) => ({
|
|
3311
1341
|
name,
|
|
3312
1342
|
value: isObject(value) ? JSON.stringify(value) : String(value)
|
|
3313
1343
|
}));
|
|
3314
1344
|
if (rows.length === 0) {
|
|
3315
|
-
return /* @__PURE__ */ (0,
|
|
1345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.HawtioEmptyCard, { message: "This MBean has no attributes." });
|
|
3316
1346
|
}
|
|
3317
1347
|
const selectAttribute = (attribute) => {
|
|
3318
1348
|
setSelected(attribute);
|
|
@@ -3332,8 +1362,8 @@ var init_Attributes = __esm({
|
|
|
3332
1362
|
},
|
|
3333
1363
|
columnIndex: 0
|
|
3334
1364
|
});
|
|
3335
|
-
const panelContent = /* @__PURE__ */ (0,
|
|
3336
|
-
|
|
1365
|
+
const panelContent = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1366
|
+
import_react16.AttributeModal,
|
|
3337
1367
|
{
|
|
3338
1368
|
isOpen: isModalOpen,
|
|
3339
1369
|
onClose: () => setIsModalOpen(false),
|
|
@@ -3341,34 +1371,34 @@ var init_Attributes = __esm({
|
|
|
3341
1371
|
input: selected
|
|
3342
1372
|
}
|
|
3343
1373
|
);
|
|
3344
|
-
const attributesTable = /* @__PURE__ */ (0,
|
|
3345
|
-
/* @__PURE__ */ (0,
|
|
3346
|
-
/* @__PURE__ */ (0,
|
|
3347
|
-
/* @__PURE__ */ (0,
|
|
3348
|
-
/* @__PURE__ */ (0,
|
|
3349
|
-
/* @__PURE__ */ (0,
|
|
1374
|
+
const attributesTable = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { id: "attribute-table-with-panel", children: [
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AiJmxToolbar, { attributes }),
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_table2.Table, { "aria-label": "Attributes", variant: "compact", children: [
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_table2.Thead, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_table2.Tr, { children: [
|
|
1378
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_table2.Th, { sort: getSortParams(), children: "Attribute" }),
|
|
1379
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_table2.Th, { children: "Value" })
|
|
3350
1380
|
] }) }),
|
|
3351
|
-
/* @__PURE__ */ (0,
|
|
3352
|
-
|
|
1381
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_table2.Tbody, { children: rows.sort((a, b) => objectSorter(a.name, b.name, sortDirection === "desc")).map((att, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1382
|
+
import_react_table2.Tr,
|
|
3353
1383
|
{
|
|
3354
1384
|
isClickable: true,
|
|
3355
1385
|
isRowSelected: selected.name === att.name,
|
|
3356
1386
|
onRowClick: () => selectAttribute(att),
|
|
3357
1387
|
children: [
|
|
3358
|
-
/* @__PURE__ */ (0,
|
|
3359
|
-
/* @__PURE__ */ (0,
|
|
1388
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_table2.Td, { children: att.name }),
|
|
1389
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_table2.Td, { children: att.value })
|
|
3360
1390
|
]
|
|
3361
1391
|
},
|
|
3362
1392
|
att.name + "-" + index
|
|
3363
1393
|
)) })
|
|
3364
1394
|
] })
|
|
3365
1395
|
] });
|
|
3366
|
-
return /* @__PURE__ */ (0,
|
|
1396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.Drawer, { isExpanded: isModalOpen, className: "pf-m-inline-on-2xl", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.DrawerContent, { panelContent, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.DrawerContentBody, { hasPadding: true, children: attributesTable }) }) }) });
|
|
3367
1397
|
};
|
|
3368
1398
|
AiJmxToolbar = ({ attributes }) => {
|
|
3369
|
-
const { selectedNode } = (0,
|
|
3370
|
-
const { username } = (0,
|
|
3371
|
-
const { setAnnouncement, setIsChatbotOpen, updateConversations } = (0,
|
|
1399
|
+
const { selectedNode } = (0, import_react17.useContext)(MBeanTreeContext);
|
|
1400
|
+
const { username } = (0, import_react17.useContext)(import_ui3.PageContext);
|
|
1401
|
+
const { setAnnouncement, setIsChatbotOpen, updateConversations } = (0, import_react17.useContext)(ChatbotContext);
|
|
3372
1402
|
if (!selectedNode || !selectedNode.mbean || !selectedNode.objectName) {
|
|
3373
1403
|
return null;
|
|
3374
1404
|
}
|
|
@@ -3376,7 +1406,7 @@ var init_Attributes = __esm({
|
|
|
3376
1406
|
const diagnose = async () => {
|
|
3377
1407
|
setIsChatbotOpen(true);
|
|
3378
1408
|
const attrsValue = JSON.stringify(attributes);
|
|
3379
|
-
|
|
1409
|
+
log3.debug("Attributes:", attrsValue);
|
|
3380
1410
|
const systemMessage = jmxAiService.systemMessage();
|
|
3381
1411
|
const diagnoseMessage = jmxAiService.diagnoseMessage(objectName, attrsValue);
|
|
3382
1412
|
const newMessages = [];
|
|
@@ -3384,19 +1414,19 @@ var init_Attributes = __esm({
|
|
|
3384
1414
|
newMessages.push(aiService.createLoadingBotMessage());
|
|
3385
1415
|
updateConversations(newMessages, `Diagnose ${objectName}`);
|
|
3386
1416
|
setAnnouncement("Diagnosis in progress...");
|
|
3387
|
-
|
|
1417
|
+
log3.debug("diagnose - new messages:", newMessages);
|
|
3388
1418
|
const dialogId = newMessages[0].id;
|
|
3389
|
-
const answer = await aiService.newChat(dialogId, diagnoseMessage, systemMessage);
|
|
1419
|
+
const answer = await aiService.newChat(dialogId, { message: diagnoseMessage, system: systemMessage });
|
|
3390
1420
|
const loadedMessages = [];
|
|
3391
1421
|
loadedMessages.push(...newMessages);
|
|
3392
|
-
|
|
1422
|
+
log3.debug("diagnose - loaded messages:", loadedMessages);
|
|
3393
1423
|
loadedMessages.pop();
|
|
3394
|
-
const botMessage = aiService.toBotMessage(answer, ThinkInfo, ToolCallsInfo, ToolCallsApprove);
|
|
1424
|
+
const botMessage = aiService.toBotMessage(answer, false, ThinkInfo, ToolCallsInfo, ToolCallsApprove);
|
|
3395
1425
|
loadedMessages.push(botMessage);
|
|
3396
1426
|
updateConversations(loadedMessages);
|
|
3397
1427
|
setAnnouncement("Diagnosis complete.");
|
|
3398
1428
|
};
|
|
3399
|
-
return /* @__PURE__ */ (0,
|
|
1429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.Toolbar, { id: "ai-jmx-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.ToolbarContent, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.ToolbarItem, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_core7.Button, { variant: "primary", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_icons.MonitoringIcon, {}), onClick: diagnose, children: "Diagnose" }) }) }) });
|
|
3400
1430
|
};
|
|
3401
1431
|
}
|
|
3402
1432
|
});
|
|
@@ -3410,30 +1440,32 @@ var init_attributes = __esm({
|
|
|
3410
1440
|
});
|
|
3411
1441
|
|
|
3412
1442
|
// src/ai-plugin/jmx-ai/JmxContent.tsx
|
|
3413
|
-
var
|
|
1443
|
+
var import_react18, import_Chatbot3, import_react_core8, import_popper_core, import_cubes_icon, import_react19, import_react_router2, import_jsx_runtime8, JmxContent;
|
|
3414
1444
|
var init_JmxContent2 = __esm({
|
|
3415
1445
|
"src/ai-plugin/jmx-ai/JmxContent.tsx"() {
|
|
3416
1446
|
"use strict";
|
|
3417
|
-
|
|
3418
|
-
|
|
1447
|
+
import_react18 = require("@hawtio/react");
|
|
1448
|
+
import_Chatbot3 = require("@patternfly/chatbot/dist/dynamic/Chatbot");
|
|
1449
|
+
import_react_core8 = require("@patternfly/react-core");
|
|
3419
1450
|
import_popper_core = require("@patternfly/react-core/dist/esm/helpers/Popper/thirdparty/popper-core");
|
|
3420
1451
|
import_cubes_icon = require("@patternfly/react-icons/dist/esm/icons/cubes-icon");
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
1452
|
+
import_react19 = __toESM(require("react"));
|
|
1453
|
+
import_react_router2 = require("react-router");
|
|
1454
|
+
init_ChatbotPanel();
|
|
1455
|
+
init_context();
|
|
3424
1456
|
init_JmxContent();
|
|
3425
1457
|
init_attributes();
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
1458
|
+
init_context2();
|
|
1459
|
+
init_globals3();
|
|
1460
|
+
import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3429
1461
|
JmxContent = () => {
|
|
3430
|
-
const { selectedNode } = (0,
|
|
3431
|
-
const { pathname, search } = (0,
|
|
1462
|
+
const { selectedNode } = (0, import_react19.useContext)(MBeanTreeContext);
|
|
1463
|
+
const { pathname, search } = (0, import_react_router2.useLocation)();
|
|
3432
1464
|
const chatbotContext = useChatbot();
|
|
3433
1465
|
const { isChatbotOpen, setIsChatbotOpen } = chatbotContext;
|
|
3434
|
-
const drawerRef = (0,
|
|
1466
|
+
const drawerRef = (0, import_react19.useRef)(void 0);
|
|
3435
1467
|
if (!selectedNode) {
|
|
3436
|
-
return /* @__PURE__ */ (0,
|
|
1468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.PageSection, { hasBodyWrapper: false, isFilled: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.EmptyState, { headingLevel: "h1", icon: import_cubes_icon.CubesIcon, titleText: "Select MBean", variant: "full" }) });
|
|
3437
1469
|
}
|
|
3438
1470
|
const mBeanApplicable = (node) => Boolean(node.objectName);
|
|
3439
1471
|
const mBeanCollectionApplicable = (node) => Boolean(node.children?.every((child) => child.objectName));
|
|
@@ -3441,42 +1473,42 @@ var init_JmxContent2 = __esm({
|
|
|
3441
1473
|
const tableSelector = (node) => {
|
|
3442
1474
|
const tablePriorityList = [
|
|
3443
1475
|
{ condition: mBeanApplicable, element: Attributes },
|
|
3444
|
-
{ condition: mBeanCollectionApplicable, element:
|
|
1476
|
+
{ condition: mBeanCollectionApplicable, element: import_react18.AttributeTable }
|
|
3445
1477
|
];
|
|
3446
|
-
return tablePriorityList.find((entry) => entry.condition(node))?.element ??
|
|
1478
|
+
return tablePriorityList.find((entry) => entry.condition(node))?.element ?? import_react18.JmxContentMBeans;
|
|
3447
1479
|
};
|
|
3448
1480
|
const allNavItems = [
|
|
3449
1481
|
{ id: "attributes", title: "Attributes", component: tableSelector(selectedNode), isApplicable: () => true },
|
|
3450
|
-
{ id: "operations", title: "Operations", component:
|
|
3451
|
-
{ id: "chart", title: "Chart", component:
|
|
1482
|
+
{ id: "operations", title: "Operations", component: import_react18.Operations, isApplicable: mBeanApplicable },
|
|
1483
|
+
{ id: "chart", title: "Chart", component: import_react18.Chart, isApplicable: hasAnyApplicableMBean }
|
|
3452
1484
|
];
|
|
3453
1485
|
const navItems = allNavItems.filter((nav) => nav.isApplicable(selectedNode));
|
|
3454
1486
|
const searchWithNid = pluginPathWithNodeId(selectedNode, new URLSearchParams(search)).search;
|
|
3455
|
-
const mbeanNav = /* @__PURE__ */ (0,
|
|
3456
|
-
const mbeanRoutes = navItems.map((nav) => /* @__PURE__ */ (0,
|
|
3457
|
-
const jmxAiToolbar = /* @__PURE__ */ (0,
|
|
3458
|
-
const jmxContent = /* @__PURE__ */ (0,
|
|
3459
|
-
/* @__PURE__ */ (0,
|
|
1487
|
+
const mbeanNav = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.Nav, { "aria-label": "MBean Nav", variant: "horizontal-subnav", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.NavList, { children: navItems.map((nav) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.NavItem, { isActive: pathname === `${pluginPath2}/${nav.id}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router2.NavLink, { to: { pathname: nav.id, search }, children: nav.title }) }, nav.id)) }) });
|
|
1488
|
+
const mbeanRoutes = navItems.map((nav) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router2.Route, { path: nav.id, element: import_react19.default.createElement(nav.component) }, nav.id));
|
|
1489
|
+
const jmxAiToolbar = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.Toolbar, { id: "jmx-ai-toolbar", style: { float: import_popper_core.right }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.ToolbarItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.Button, { variant: "secondary", size: "sm", onClick: () => setIsChatbotOpen(!isChatbotOpen), children: "Chat" }) }) });
|
|
1490
|
+
const jmxContent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_core8.PageGroup, { id: "jmx-content", children: [
|
|
1491
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_core8.PageSection, { id: "jmx-content-header", hasBodyWrapper: false, children: [
|
|
3460
1492
|
jmxAiToolbar,
|
|
3461
|
-
/* @__PURE__ */ (0,
|
|
3462
|
-
/* @__PURE__ */ (0,
|
|
1493
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.Title, { headingLevel: "h1", children: selectedNode.name }),
|
|
1494
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.Content, { component: "small", children: selectedNode.objectName })
|
|
3463
1495
|
] }),
|
|
3464
|
-
/* @__PURE__ */ (0,
|
|
3465
|
-
/* @__PURE__ */ (0,
|
|
3466
|
-
|
|
1496
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.PageSection, { type: "tabs", hasBodyWrapper: false, children: mbeanNav }),
|
|
1497
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1498
|
+
import_react_core8.PageSection,
|
|
3467
1499
|
{
|
|
3468
1500
|
id: "jmx-content-main",
|
|
3469
1501
|
padding: { default: "noPadding" },
|
|
3470
1502
|
hasOverflowScroll: true,
|
|
3471
1503
|
"aria-label": "jmx-content-main",
|
|
3472
1504
|
hasBodyWrapper: false,
|
|
3473
|
-
children: /* @__PURE__ */ (0,
|
|
1505
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_router2.Routes, { children: [
|
|
3474
1506
|
mbeanRoutes,
|
|
3475
|
-
/* @__PURE__ */ (0,
|
|
3476
|
-
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1508
|
+
import_react_router2.Route,
|
|
3477
1509
|
{
|
|
3478
1510
|
path: "/",
|
|
3479
|
-
element: /* @__PURE__ */ (0,
|
|
1511
|
+
element: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router2.Navigate, { to: { pathname: navItems[0]?.id ?? "", search: searchWithNid } })
|
|
3480
1512
|
},
|
|
3481
1513
|
"root"
|
|
3482
1514
|
)
|
|
@@ -3487,8 +1519,8 @@ var init_JmxContent2 = __esm({
|
|
|
3487
1519
|
const onDrawerExpand = () => {
|
|
3488
1520
|
drawerRef.current && drawerRef.current.focus();
|
|
3489
1521
|
};
|
|
3490
|
-
const panelContent = /* @__PURE__ */ (0,
|
|
3491
|
-
return /* @__PURE__ */ (0,
|
|
1522
|
+
const panelContent = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.DrawerPanelContent, { isResizable: true, defaultSize: "500px", minSize: "200px", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.DrawerPanelBody, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChatbotPanel, { title: "AI Diagnosis", displayMode: import_Chatbot3.ChatbotDisplayMode.drawer }) }) });
|
|
1523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChatbotContext.Provider, { value: chatbotContext, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.Drawer, { isExpanded: isChatbotOpen, isInline: true, onExpand: onDrawerExpand, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.DrawerContent, { panelContent, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_core8.DrawerContentBody, { children: jmxContent }) }) }) });
|
|
3492
1524
|
};
|
|
3493
1525
|
}
|
|
3494
1526
|
});
|
|
@@ -3500,23 +1532,23 @@ var init_JmxTreeView = __esm({
|
|
|
3500
1532
|
});
|
|
3501
1533
|
|
|
3502
1534
|
// src/ai-plugin/jmx-ai/JmxTreeView.tsx
|
|
3503
|
-
var
|
|
1535
|
+
var import_react20, import_react_core9, import_react21, import_react_router3, import_jsx_runtime9, JmxTreeView;
|
|
3504
1536
|
var init_JmxTreeView2 = __esm({
|
|
3505
1537
|
"src/ai-plugin/jmx-ai/JmxTreeView.tsx"() {
|
|
3506
1538
|
"use strict";
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
1539
|
+
import_react20 = require("@hawtio/react");
|
|
1540
|
+
import_react_core9 = require("@patternfly/react-core");
|
|
1541
|
+
import_react21 = require("react");
|
|
1542
|
+
import_react_router3 = require("react-router");
|
|
3511
1543
|
init_JmxTreeView();
|
|
3512
|
-
|
|
3513
|
-
|
|
1544
|
+
init_context2();
|
|
1545
|
+
import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3514
1546
|
JmxTreeView = () => {
|
|
3515
|
-
const { tree, selectedNode, setSelectedNode } = (0,
|
|
3516
|
-
const [expanded, setExpanded] = (0,
|
|
3517
|
-
const [filteredTree, setFilteredTree] = (0,
|
|
3518
|
-
const navigate = (0,
|
|
3519
|
-
(0,
|
|
1547
|
+
const { tree, selectedNode, setSelectedNode } = (0, import_react21.useContext)(MBeanTreeContext);
|
|
1548
|
+
const [expanded, setExpanded] = (0, import_react21.useState)(0 /* Default */);
|
|
1549
|
+
const [filteredTree, setFilteredTree] = (0, import_react21.useState)(tree.getTree());
|
|
1550
|
+
const navigate = (0, import_react_router3.useNavigate)();
|
|
1551
|
+
(0, import_react21.useEffect)(() => {
|
|
3520
1552
|
setFilteredTree(tree.getTree());
|
|
3521
1553
|
}, [tree]);
|
|
3522
1554
|
const onSearch = (event) => {
|
|
@@ -3524,7 +1556,7 @@ var init_JmxTreeView2 = __esm({
|
|
|
3524
1556
|
setExpanded(0 /* Default */);
|
|
3525
1557
|
const input = event.target.value;
|
|
3526
1558
|
if (!input) setFilteredTree(tree.getTree());
|
|
3527
|
-
const treeElements =
|
|
1559
|
+
const treeElements = import_react20.MBeanTree.filter(tree.getTree(), (node) => node.name.toLowerCase().includes(input.toLowerCase()));
|
|
3528
1560
|
if (treeElements.length === 0) setFilteredTree(tree.getTree());
|
|
3529
1561
|
else {
|
|
3530
1562
|
setFilteredTree(treeElements);
|
|
@@ -3549,8 +1581,8 @@ var init_JmxTreeView2 = __esm({
|
|
|
3549
1581
|
return {};
|
|
3550
1582
|
}
|
|
3551
1583
|
};
|
|
3552
|
-
return /* @__PURE__ */ (0,
|
|
3553
|
-
|
|
1584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1585
|
+
import_react_core9.TreeView,
|
|
3554
1586
|
{
|
|
3555
1587
|
id: "jmx-tree-view",
|
|
3556
1588
|
data: filteredTree,
|
|
@@ -3559,7 +1591,7 @@ var init_JmxTreeView2 = __esm({
|
|
|
3559
1591
|
activeItems: selectedNode ? [selectedNode] : [],
|
|
3560
1592
|
...expandedProp(),
|
|
3561
1593
|
onSelect,
|
|
3562
|
-
toolbar: /* @__PURE__ */ (0,
|
|
1594
|
+
toolbar: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react20.PluginTreeViewToolbar, { onSearch, onSetExpanded: setAllExpanded })
|
|
3563
1595
|
}
|
|
3564
1596
|
);
|
|
3565
1597
|
};
|
|
@@ -3567,42 +1599,42 @@ var init_JmxTreeView2 = __esm({
|
|
|
3567
1599
|
});
|
|
3568
1600
|
|
|
3569
1601
|
// src/ai-plugin/jmx-ai/Jmx.tsx
|
|
3570
|
-
var
|
|
1602
|
+
var import_react_core10, import_cubes_icon2, import_react_split, import_jsx_runtime10, Jmx;
|
|
3571
1603
|
var init_Jmx2 = __esm({
|
|
3572
1604
|
"src/ai-plugin/jmx-ai/Jmx.tsx"() {
|
|
3573
1605
|
"use strict";
|
|
3574
|
-
|
|
1606
|
+
import_react_core10 = require("@patternfly/react-core");
|
|
3575
1607
|
import_cubes_icon2 = require("@patternfly/react-icons/dist/esm/icons/cubes-icon");
|
|
3576
|
-
|
|
3577
|
-
|
|
1608
|
+
import_react_split = __toESM(require("react-split"));
|
|
1609
|
+
init_context2();
|
|
3578
1610
|
init_Jmx();
|
|
3579
1611
|
init_JmxContent2();
|
|
3580
1612
|
init_JmxTreeView2();
|
|
3581
|
-
|
|
1613
|
+
import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3582
1614
|
Jmx = () => {
|
|
3583
1615
|
const { tree, loaded, selectedNode, setSelectedNode } = useMBeanTree();
|
|
3584
1616
|
if (!loaded) {
|
|
3585
|
-
return /* @__PURE__ */ (0,
|
|
1617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_core10.PageSection, { hasBodyWrapper: false, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_core10.Spinner, { "aria-label": "Loading MBean tree" }) });
|
|
3586
1618
|
}
|
|
3587
1619
|
if (tree.isEmpty()) {
|
|
3588
|
-
return /* @__PURE__ */ (0,
|
|
1620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_core10.PageSection, { hasBodyWrapper: false, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_core10.EmptyState, { headingLevel: "h1", icon: import_cubes_icon2.CubesIcon, titleText: "No MBeans found", variant: "full" }) });
|
|
3589
1621
|
}
|
|
3590
|
-
return /* @__PURE__ */ (0,
|
|
3591
|
-
/* @__PURE__ */ (0,
|
|
3592
|
-
/* @__PURE__ */ (0,
|
|
1622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MBeanTreeContext.Provider, { value: { tree, loaded, selectedNode, setSelectedNode }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_split.default, { className: "jmx-split", sizes: [30, 70], minSize: 200, gutterSize: 5, children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(JmxTreeView, {}) }),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(JmxContent, {}) })
|
|
3593
1625
|
] }) });
|
|
3594
1626
|
};
|
|
3595
1627
|
}
|
|
3596
1628
|
});
|
|
3597
1629
|
|
|
3598
1630
|
// src/ai-plugin/jmx-ai/ui.ts
|
|
3599
|
-
var
|
|
3600
|
-
__export(
|
|
1631
|
+
var ui_exports2 = {};
|
|
1632
|
+
__export(ui_exports2, {
|
|
3601
1633
|
Jmx: () => Jmx,
|
|
3602
1634
|
JmxContent: () => JmxContent,
|
|
3603
1635
|
JmxTreeView: () => JmxTreeView
|
|
3604
1636
|
});
|
|
3605
|
-
var
|
|
1637
|
+
var init_ui2 = __esm({
|
|
3606
1638
|
"src/ai-plugin/jmx-ai/ui.ts"() {
|
|
3607
1639
|
"use strict";
|
|
3608
1640
|
init_Jmx2();
|
|
@@ -3617,28 +1649,58 @@ __export(index_exports, {
|
|
|
3617
1649
|
plugin: () => plugin
|
|
3618
1650
|
});
|
|
3619
1651
|
module.exports = __toCommonJS(index_exports);
|
|
3620
|
-
var
|
|
1652
|
+
var import_react23 = require("@hawtio/react");
|
|
3621
1653
|
var import_main = require("@patternfly/chatbot/dist/css/main.css");
|
|
3622
1654
|
|
|
1655
|
+
// src/ai-plugin/chat/index.ts
|
|
1656
|
+
var import_react9 = require("@hawtio/react");
|
|
1657
|
+
init_globals();
|
|
1658
|
+
var order = 42;
|
|
1659
|
+
var aiChat = () => {
|
|
1660
|
+
log.info("Loading", pluginName);
|
|
1661
|
+
import_react9.hawtio.addDeferredPlugin(pluginName, async () => {
|
|
1662
|
+
return Promise.resolve().then(() => (init_ui(), ui_exports)).then(({ Chat: Chat2 }) => {
|
|
1663
|
+
return {
|
|
1664
|
+
id: pluginName,
|
|
1665
|
+
title: pluginTitle,
|
|
1666
|
+
path: pluginPath,
|
|
1667
|
+
order,
|
|
1668
|
+
component: Chat2,
|
|
1669
|
+
isActive: async () => true
|
|
1670
|
+
};
|
|
1671
|
+
});
|
|
1672
|
+
});
|
|
1673
|
+
};
|
|
1674
|
+
|
|
3623
1675
|
// src/ai-plugin/common/index.ts
|
|
3624
|
-
var
|
|
1676
|
+
var import_react11 = require("@hawtio/react");
|
|
3625
1677
|
|
|
3626
1678
|
// src/ai-plugin/common/AiPreferences.tsx
|
|
3627
|
-
var
|
|
1679
|
+
var import_react_core6 = require("@patternfly/react-core");
|
|
3628
1680
|
var import_eye_icon = __toESM(require("@patternfly/react-icons/dist/esm/icons/eye-icon"));
|
|
3629
1681
|
var import_eye_slash_icon = __toESM(require("@patternfly/react-icons/dist/esm/icons/eye-slash-icon"));
|
|
3630
|
-
var
|
|
1682
|
+
var import_react_table = require("@patternfly/react-table");
|
|
1683
|
+
var import_react10 = require("react");
|
|
3631
1684
|
init_ai_model();
|
|
3632
1685
|
init_ai_preferences_service();
|
|
3633
|
-
|
|
1686
|
+
init_tools();
|
|
1687
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3634
1688
|
var AiPreferences = () => {
|
|
3635
|
-
const [options, setOptions] = (0,
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
1689
|
+
const [options, setOptions] = (0, import_react10.useState)(aiPreferencesService.loadOptions());
|
|
1690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_core6.Form, { id: "ai-prefs-form", isHorizontal: true, children: [
|
|
1691
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModelForm, { options, setOptions }),
|
|
1692
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PermissionForm, { options, setOptions })
|
|
1693
|
+
] }) });
|
|
1694
|
+
};
|
|
1695
|
+
var ModelForm = ({ options, setOptions }) => {
|
|
1696
|
+
const [provider, setProvider] = (0, import_react10.useState)(options.model.provider);
|
|
1697
|
+
const [models, setModels] = (0, import_react10.useState)(MODELS.filter((m) => m.provider === provider));
|
|
1698
|
+
const [passwordHidden, setPasswordHidden] = (0, import_react10.useState)(true);
|
|
3639
1699
|
const updateProvider = (provider2) => {
|
|
3640
1700
|
setProvider(provider2);
|
|
3641
|
-
|
|
1701
|
+
const models2 = MODELS.filter((m) => m.provider === provider2);
|
|
1702
|
+
setModels(models2);
|
|
1703
|
+
updateModel(models2[0].id);
|
|
3642
1704
|
};
|
|
3643
1705
|
const updateModel = (updated) => {
|
|
3644
1706
|
const model = MODELS.find((m) => m.id === updated);
|
|
@@ -3651,126 +1713,161 @@ var AiPreferences = () => {
|
|
|
3651
1713
|
aiPreferencesService.saveOptions({ token: updated });
|
|
3652
1714
|
setOptions({ ...options, token: updated });
|
|
3653
1715
|
};
|
|
3654
|
-
return /* @__PURE__ */ (0,
|
|
3655
|
-
/* @__PURE__ */ (0,
|
|
3656
|
-
|
|
1716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_core6.FormSection, { title: "Model", titleElement: "h2", children: [
|
|
1717
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.FormGroup, { fieldId: "ai-prefs-form-provider", label: "Provider", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1718
|
+
import_react_core6.FormSelect,
|
|
3657
1719
|
{
|
|
3658
1720
|
id: "ai-prefs-form-provider-input",
|
|
3659
1721
|
"aria-label": "Form Select Provider",
|
|
3660
1722
|
value: provider,
|
|
3661
|
-
onChange: (_,
|
|
3662
|
-
children: PROVIDERS.map((p, i) => /* @__PURE__ */ (0,
|
|
1723
|
+
onChange: (_, p) => updateProvider(p),
|
|
1724
|
+
children: PROVIDERS.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.FormSelectOption, { value: p, label: p }, i))
|
|
3663
1725
|
}
|
|
3664
1726
|
) }),
|
|
3665
|
-
/* @__PURE__ */ (0,
|
|
3666
|
-
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.FormGroup, { fieldId: "ai-prefs-form-model", label: "Model", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1728
|
+
import_react_core6.FormSelect,
|
|
3667
1729
|
{
|
|
3668
1730
|
id: "ai-prefs-form-model-input",
|
|
3669
1731
|
"aria-label": "Form Select Model",
|
|
3670
1732
|
value: options.model.id,
|
|
3671
1733
|
onChange: (_, id) => updateModel(id),
|
|
3672
|
-
children: models.map((m) => /* @__PURE__ */ (0,
|
|
1734
|
+
children: models.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.FormSelectOption, { value: m.id, label: m.name }, m.id))
|
|
3673
1735
|
}
|
|
3674
1736
|
) }),
|
|
3675
|
-
/* @__PURE__ */ (0,
|
|
3676
|
-
/* @__PURE__ */ (0,
|
|
3677
|
-
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.FormGroup, { fieldId: "ai-prefs-form-token", label: "API Key / Token (optional)", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_core6.InputGroup, { children: [
|
|
1738
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.InputGroupItem, { isFill: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1739
|
+
import_react_core6.TextInput,
|
|
3678
1740
|
{
|
|
3679
1741
|
id: "ai-prefs-form-token-input",
|
|
3680
1742
|
"aria-label": "Form Select Token",
|
|
3681
1743
|
type: passwordHidden ? "password" : "text",
|
|
3682
1744
|
value: options.token,
|
|
3683
|
-
onChange: (_,
|
|
1745
|
+
onChange: (_, t) => updateToken(t)
|
|
3684
1746
|
}
|
|
3685
1747
|
) }),
|
|
3686
|
-
/* @__PURE__ */ (0,
|
|
3687
|
-
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.InputGroupItem, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1749
|
+
import_react_core6.Button,
|
|
3688
1750
|
{
|
|
3689
1751
|
variant: "control",
|
|
3690
1752
|
onClick: () => setPasswordHidden(!passwordHidden),
|
|
3691
1753
|
"aria-label": passwordHidden ? "Show password" : "Hide password",
|
|
3692
|
-
children: passwordHidden ? /* @__PURE__ */ (0,
|
|
1754
|
+
children: passwordHidden ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eye_icon.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eye_slash_icon.default, {})
|
|
3693
1755
|
}
|
|
3694
1756
|
) })
|
|
3695
1757
|
] }) })
|
|
3696
|
-
] })
|
|
1758
|
+
] });
|
|
1759
|
+
};
|
|
1760
|
+
var PermissionForm = ({ options, setOptions }) => {
|
|
1761
|
+
const maxAutoToolSteps = options.maxAutoToolSteps ?? DEFAULT_MAX_AUTO_TOOL_STEPS;
|
|
1762
|
+
const toolPermissions = options.toolPermissions ?? DEFAULT_TOOL_PERMISSIONS;
|
|
1763
|
+
const updateMaxAutoToolSteps = (updated) => {
|
|
1764
|
+
aiPreferencesService.saveOptions({ maxAutoToolSteps: updated });
|
|
1765
|
+
setOptions({ ...options, maxAutoToolSteps: updated });
|
|
1766
|
+
};
|
|
1767
|
+
const updatePermission = (tool, updated) => {
|
|
1768
|
+
const updatedPermissions = { ...toolPermissions, [tool]: updated };
|
|
1769
|
+
aiPreferencesService.saveOptions({ toolPermissions: updatedPermissions });
|
|
1770
|
+
setOptions({ ...options, toolPermissions: updatedPermissions });
|
|
1771
|
+
};
|
|
1772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_core6.FormSection, { title: "Permission control", titleElement: "h2", children: [
|
|
1773
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.FormGroup, { fieldId: "ai-prefs-form-max-steps", label: "Max auto-approve steps", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1774
|
+
import_react_core6.NumberInput,
|
|
1775
|
+
{
|
|
1776
|
+
id: "ai-prefs-form-max-steps-input",
|
|
1777
|
+
"aria-label": "Form select max auto-approve steps",
|
|
1778
|
+
value: options.maxAutoToolSteps,
|
|
1779
|
+
min: 1,
|
|
1780
|
+
max: 100,
|
|
1781
|
+
onMinus: () => updateMaxAutoToolSteps(Math.max(1, maxAutoToolSteps - 1)),
|
|
1782
|
+
onPlus: () => updateMaxAutoToolSteps(Math.min(100, maxAutoToolSteps + 1)),
|
|
1783
|
+
onChange: (e) => {
|
|
1784
|
+
const value = parseInt(e.target.value);
|
|
1785
|
+
if (!isNaN(value) && value >= 1 && value <= 100) {
|
|
1786
|
+
updateMaxAutoToolSteps(value);
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
) }),
|
|
1791
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_core6.FormGroup, { fieldId: "ai-prefs-form-tool-permissions", style: { display: "flex" }, children: [
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_core6.Content, { component: "small", children: "Enable auto-approve to allow a tool to run without asking for confirmation each time." }),
|
|
1793
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1794
|
+
import_react_table.Table,
|
|
1795
|
+
{
|
|
1796
|
+
"aria-label": "Tool permissions",
|
|
1797
|
+
variant: "compact",
|
|
1798
|
+
borders: false,
|
|
1799
|
+
isStriped: true,
|
|
1800
|
+
isStickyHeader: true,
|
|
1801
|
+
style: { marginTop: "0.5rem" },
|
|
1802
|
+
children: [
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Thead, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_table.Tr, { children: [
|
|
1804
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Th, { modifier: "fitContent", children: "Tool" }),
|
|
1805
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Th, { modifier: "wrap", children: "Description" }),
|
|
1806
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Th, { modifier: "fitContent", children: "Auto-approve" })
|
|
1807
|
+
] }) }),
|
|
1808
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Tbody, { children: WORKSPACE_TOOLS_META.map(({ name, description }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_table.Tr, { children: [
|
|
1809
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Td, { dataLabel: "Tool", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { children: name }) }),
|
|
1810
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Td, { dataLabel: "Description", children: description }),
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_table.Td, { dataLabel: "Auto-approve", textCenter: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1812
|
+
import_react_core6.Switch,
|
|
1813
|
+
{
|
|
1814
|
+
id: `ai-prefs-tool-switch-${name}`,
|
|
1815
|
+
"aria-label": `Auto-approve ${name}`,
|
|
1816
|
+
isChecked: toolPermissions[name] ?? false,
|
|
1817
|
+
onChange: (_, checked) => updatePermission(name, checked)
|
|
1818
|
+
}
|
|
1819
|
+
) })
|
|
1820
|
+
] }, name)) })
|
|
1821
|
+
]
|
|
1822
|
+
}
|
|
1823
|
+
)
|
|
1824
|
+
] })
|
|
1825
|
+
] });
|
|
3697
1826
|
};
|
|
3698
|
-
|
|
3699
|
-
// src/ai-plugin/common/globals.ts
|
|
3700
|
-
var import_react3 = require("@hawtio/react");
|
|
3701
|
-
var pluginName2 = "hawtio-ai";
|
|
3702
|
-
var pluginTitle2 = "AI";
|
|
3703
|
-
var log2 = import_react3.Logger.get(pluginName2);
|
|
3704
1827
|
|
|
3705
1828
|
// src/ai-plugin/common/index.ts
|
|
3706
|
-
|
|
1829
|
+
init_globals2();
|
|
1830
|
+
var order2 = 40;
|
|
3707
1831
|
var aiCommon = () => {
|
|
3708
|
-
|
|
1832
|
+
import_react11.preferencesRegistry.add(pluginName2, pluginTitle2, AiPreferences, order2);
|
|
3709
1833
|
};
|
|
3710
1834
|
|
|
3711
1835
|
// src/ai-plugin/jmx-ai/index.ts
|
|
3712
|
-
var
|
|
3713
|
-
|
|
1836
|
+
var import_react22 = require("@hawtio/react");
|
|
1837
|
+
init_globals3();
|
|
3714
1838
|
|
|
3715
1839
|
// src/ai-plugin/jmx-ai/help.md
|
|
3716
1840
|
var help_default = "# JMX AI - Hawtio AI Plugin\n\nThis view is provided by the Hawtio AI plugin.\n\nIt extends the standard [JMX](./jmx) and adds AI features such as MBean diagnostics to it.\n";
|
|
3717
1841
|
|
|
3718
1842
|
// src/ai-plugin/jmx-ai/index.ts
|
|
3719
|
-
var
|
|
3720
|
-
var
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
return Promise.resolve().then(() => (
|
|
1843
|
+
var order3 = 41;
|
|
1844
|
+
var aiJmx = () => {
|
|
1845
|
+
log3.info("Loading", pluginName3);
|
|
1846
|
+
import_react22.hawtio.addDeferredPlugin(pluginName3, async () => {
|
|
1847
|
+
return Promise.resolve().then(() => (init_ui2(), ui_exports2)).then(({ Jmx: Jmx2 }) => {
|
|
3724
1848
|
return {
|
|
3725
|
-
id:
|
|
3726
|
-
title:
|
|
3727
|
-
path:
|
|
1849
|
+
id: pluginName3,
|
|
1850
|
+
title: pluginTitle3,
|
|
1851
|
+
path: pluginPath2,
|
|
1852
|
+
order: order3,
|
|
3728
1853
|
component: Jmx2,
|
|
3729
1854
|
knownQueryParams: ["nid"],
|
|
3730
|
-
isActive: async () =>
|
|
1855
|
+
isActive: async () => import_react22.workspace.hasMBeans()
|
|
3731
1856
|
};
|
|
3732
1857
|
});
|
|
3733
1858
|
});
|
|
3734
|
-
|
|
1859
|
+
import_react22.helpRegistry.add(pluginName3, pluginTitle3, help_default, order3);
|
|
3735
1860
|
};
|
|
3736
1861
|
|
|
3737
1862
|
// src/ai-plugin/index.ts
|
|
3738
1863
|
var plugin = () => {
|
|
3739
1864
|
aiCommon();
|
|
3740
|
-
|
|
1865
|
+
aiJmx();
|
|
1866
|
+
aiChat();
|
|
3741
1867
|
};
|
|
3742
|
-
|
|
1868
|
+
import_react23.configManager.addProductInfo("Hawtio AI Plugin", "0.3.1");
|
|
3743
1869
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3744
1870
|
0 && (module.exports = {
|
|
3745
1871
|
plugin
|
|
3746
1872
|
});
|
|
3747
|
-
/*! Bundled license information:
|
|
3748
|
-
|
|
3749
|
-
react-is/cjs/react-is.production.min.js:
|
|
3750
|
-
(** @license React v16.13.1
|
|
3751
|
-
* react-is.production.min.js
|
|
3752
|
-
*
|
|
3753
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3754
|
-
*
|
|
3755
|
-
* This source code is licensed under the MIT license found in the
|
|
3756
|
-
* LICENSE file in the root directory of this source tree.
|
|
3757
|
-
*)
|
|
3758
|
-
|
|
3759
|
-
react-is/cjs/react-is.development.js:
|
|
3760
|
-
(** @license React v16.13.1
|
|
3761
|
-
* react-is.development.js
|
|
3762
|
-
*
|
|
3763
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3764
|
-
*
|
|
3765
|
-
* This source code is licensed under the MIT license found in the
|
|
3766
|
-
* LICENSE file in the root directory of this source tree.
|
|
3767
|
-
*)
|
|
3768
|
-
|
|
3769
|
-
object-assign/index.js:
|
|
3770
|
-
(*
|
|
3771
|
-
object-assign
|
|
3772
|
-
(c) Sindre Sorhus
|
|
3773
|
-
@license MIT
|
|
3774
|
-
*)
|
|
3775
|
-
*/
|
|
3776
1873
|
//# sourceMappingURL=index.js.map
|