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