@solidxai/core-ui 0.1.19-beta.1 → 0.1.20-beta.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.
Files changed (43) hide show
  1. package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.d.ts.map +1 -1
  2. package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.js +3 -10
  3. package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.js.map +1 -1
  4. package/dist/components/core/extension/solid-core/agentRegistry/card/AgentResourceCardWidget.tsx +3 -8
  5. package/dist/components/layout/AdminHeaderActions.d.ts.map +1 -1
  6. package/dist/components/layout/AdminHeaderActions.js +1 -29
  7. package/dist/components/layout/AdminHeaderActions.js.map +1 -1
  8. package/dist/components/layout/AdminHeaderActions.tsx +0 -42
  9. package/dist/components/layout/SolidAiStudioLayout.d.ts +0 -1
  10. package/dist/components/layout/SolidAiStudioLayout.d.ts.map +1 -1
  11. package/dist/components/layout/SolidAiStudioLayout.js +9 -161
  12. package/dist/components/layout/SolidAiStudioLayout.js.map +1 -1
  13. package/dist/components/layout/SolidAiStudioLayout.tsx +7 -136
  14. package/dist/routes/AppEventListener.d.ts.map +1 -1
  15. package/dist/routes/AppEventListener.js +3 -3
  16. package/dist/routes/AppEventListener.js.map +1 -1
  17. package/dist/routes/AppEventListener.tsx +1 -2
  18. package/dist/routes/pages/admin/core/AgentHubTagsField.css +21 -0
  19. package/dist/routes/pages/admin/core/AgentHubTagsField.d.ts +17 -0
  20. package/dist/routes/pages/admin/core/AgentHubTagsField.d.ts.map +1 -0
  21. package/dist/routes/pages/admin/core/AgentHubTagsField.js +171 -0
  22. package/dist/routes/pages/admin/core/AgentHubTagsField.js.map +1 -0
  23. package/dist/routes/pages/admin/core/AgentHubTagsField.tsx +125 -0
  24. package/dist/routes/pages/admin/core/AgentRegistryEditorPage.css +7 -0
  25. package/dist/routes/pages/admin/core/AgentRegistryEditorPage.d.ts.map +1 -1
  26. package/dist/routes/pages/admin/core/AgentRegistryEditorPage.js +65 -52
  27. package/dist/routes/pages/admin/core/AgentRegistryEditorPage.js.map +1 -1
  28. package/dist/routes/pages/admin/core/AgentRegistryEditorPage.tsx +53 -11
  29. package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.d.ts.map +1 -1
  30. package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.js +14 -69
  31. package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.js.map +1 -1
  32. package/dist/routes/pages/admin/core/AgentSkillRegistryEditorPage.tsx +15 -83
  33. package/dist/routes/pages/admin/core/AgentToolActivationDialog.d.ts +11 -0
  34. package/dist/routes/pages/admin/core/AgentToolActivationDialog.d.ts.map +1 -0
  35. package/dist/routes/pages/admin/core/AgentToolActivationDialog.js +166 -0
  36. package/dist/routes/pages/admin/core/AgentToolActivationDialog.js.map +1 -0
  37. package/dist/routes/pages/admin/core/AgentToolActivationDialog.tsx +140 -0
  38. package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.css +26 -0
  39. package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.d.ts.map +1 -1
  40. package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.js +94 -71
  41. package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.js.map +1 -1
  42. package/dist/routes/pages/admin/core/AgentToolRegistryEditorPage.tsx +60 -52
  43. package/package.json +1 -1
@@ -45,23 +45,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
48
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
58
49
  import React from "react";
59
- import { ArrowLeft, Plus, RefreshCw, X } from "lucide-react";
50
+ import { ArrowLeft, RefreshCw } from "lucide-react";
60
51
  import { useDispatch } from "react-redux";
61
52
  import { useNavigate, useParams } from "react-router-dom";
62
53
  import { createSolidEntityApi } from "../../../../redux/api/solidEntityApi";
63
54
  import { showToast } from "../../../../redux/features/toastSlice";
55
+ import { solidPatch } from "../../../../http/solidHttp";
64
56
  import { AgentRegistryAuditPanel } from "./AgentRegistryAuditPanel";
57
+ import { AgentHubTagsField, agentHubTagsFrom, agentHubTagsPayload } from "./AgentHubTagsField";
58
+ import { AgentToolActivationDialog } from "./AgentToolActivationDialog";
65
59
  import { AgentToolSessionsPanel } from "../../../../components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel";
66
60
  import { AgentRegistryCardWidget } from "../../../../components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget";
67
61
  import { SolidButton, SolidCodeEditor, SolidDialog, SolidDialogBody, SolidIconPicker, SolidInput, SolidTabGroup } from "../../../../components/shad-cn-ui";
@@ -79,19 +73,6 @@ function extractEntityRecord(response) {
79
73
  }
80
74
  return candidate && typeof candidate === "object" ? candidate : undefined;
81
75
  }
82
- function parseTags(value) {
83
- if (Array.isArray(value))
84
- return value.map(String).map(function (tag) { return tag.trim(); }).filter(Boolean);
85
- if (typeof value !== "string" || !value.trim())
86
- return [];
87
- try {
88
- var parsed = JSON.parse(value);
89
- return Array.isArray(parsed) ? parsed.map(String).map(function (tag) { return tag.trim(); }).filter(Boolean) : [];
90
- }
91
- catch (_a) {
92
- return value === "{}" ? [] : value.split(",").map(function (tag) { return tag.trim(); }).filter(Boolean);
93
- }
94
- }
95
76
  function sha256Hex(value) {
96
77
  return __awaiter(this, void 0, void 0, function () {
97
78
  var digest;
@@ -134,7 +115,7 @@ export function AgentToolRegistryEditorPage() {
134
115
  var dispatch = useDispatch();
135
116
  var entityApi = React.useMemo(function () { return createSolidEntityApi("agentToolRegistry"); }, []);
136
117
  var useCreateSolidEntityMutation = entityApi.useCreateSolidEntityMutation, useGetSolidEntityByIdQuery = entityApi.useGetSolidEntityByIdQuery, useUpdateSolidEntityMutation = entityApi.useUpdateSolidEntityMutation;
137
- var _c = useGetSolidEntityByIdQuery({ id: id, qs: "populate[0]=agentTools&populate[1]=agentTools.agentRegistry" }, { skip: !id || id === "new" }), response = _c.data, isLoading = _c.isLoading, isFetching = _c.isFetching, refetch = _c.refetch;
118
+ var _c = useGetSolidEntityByIdQuery({ id: id, qs: "populate[0]=agentTools&populate[1]=agentTools.agentRegistry&populate[2]=tags" }, { skip: !id || id === "new" }), response = _c.data, isLoading = _c.isLoading, isFetching = _c.isFetching, refetch = _c.refetch;
138
119
  var _d = useCreateSolidEntityMutation(), createTool = _d[0], isCreating = _d[1].isLoading;
139
120
  var _e = useUpdateSolidEntityMutation(), updateTool = _e[0], isSaving = _e[1].isLoading;
140
121
  var record = extractEntityRecord(response);
@@ -145,50 +126,43 @@ export function AgentToolRegistryEditorPage() {
145
126
  var _k = React.useState("custom"), type = _k[0], setType = _k[1];
146
127
  var _l = React.useState(""), sourceCode = _l[0], setSourceCode = _l[1];
147
128
  var _m = React.useState([]), tags = _m[0], setTags = _m[1];
148
- var _o = React.useState(""), tagDraft = _o[0], setTagDraft = _o[1];
129
+ var _o = React.useState(false), creatingTag = _o[0], setCreatingTag = _o[1];
149
130
  var _p = React.useState({}), fieldErrors = _p[0], setFieldErrors = _p[1];
150
131
  var _q = React.useState(0), auditRefreshVersion = _q[0], setAuditRefreshVersion = _q[1];
151
132
  var _r = React.useState(false), confirmRefresh = _r[0], setConfirmRefresh = _r[1];
133
+ var _s = React.useState(false), activationOpen = _s[0], setActivationOpen = _s[1];
134
+ var _t = React.useState(null), activationTool = _t[0], setActivationTool = _t[1];
135
+ var preparingActivation = React.useRef(false);
152
136
  var baseline = React.useRef("");
153
- var currentForm = function () { return JSON.stringify({ name: name, iconName: iconName, description: description, type: type, sourceCode: sourceCode, tags: tags, tagDraft: tagDraft }); };
137
+ var currentForm = function () { return JSON.stringify({ name: name, iconName: iconName, description: description, type: type, sourceCode: sourceCode, tags: tags }); };
154
138
  React.useEffect(function () {
155
139
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
156
- var nextTags = parseTags(record === null || record === void 0 ? void 0 : record.tags);
140
+ var nextTags = agentHubTagsFrom(record === null || record === void 0 ? void 0 : record.tags);
157
141
  setName((_a = record === null || record === void 0 ? void 0 : record.name) !== null && _a !== void 0 ? _a : "");
158
142
  setIconName((_b = record === null || record === void 0 ? void 0 : record.iconName) !== null && _b !== void 0 ? _b : "");
159
143
  setDescription((_c = record === null || record === void 0 ? void 0 : record.description) !== null && _c !== void 0 ? _c : "");
160
144
  setType((_d = record === null || record === void 0 ? void 0 : record.type) !== null && _d !== void 0 ? _d : "custom");
161
145
  setSourceCode((_e = record === null || record === void 0 ? void 0 : record.sourceCode) !== null && _e !== void 0 ? _e : "");
162
146
  setTags(nextTags);
163
- setTagDraft("");
164
- baseline.current = JSON.stringify({ name: (_f = record === null || record === void 0 ? void 0 : record.name) !== null && _f !== void 0 ? _f : "", iconName: (_g = record === null || record === void 0 ? void 0 : record.iconName) !== null && _g !== void 0 ? _g : "", description: (_h = record === null || record === void 0 ? void 0 : record.description) !== null && _h !== void 0 ? _h : "", type: (_j = record === null || record === void 0 ? void 0 : record.type) !== null && _j !== void 0 ? _j : "custom", sourceCode: (_k = record === null || record === void 0 ? void 0 : record.sourceCode) !== null && _k !== void 0 ? _k : "", tags: nextTags, tagDraft: "" });
147
+ baseline.current = JSON.stringify({ name: (_f = record === null || record === void 0 ? void 0 : record.name) !== null && _f !== void 0 ? _f : "", iconName: (_g = record === null || record === void 0 ? void 0 : record.iconName) !== null && _g !== void 0 ? _g : "", description: (_h = record === null || record === void 0 ? void 0 : record.description) !== null && _h !== void 0 ? _h : "", type: (_j = record === null || record === void 0 ? void 0 : record.type) !== null && _j !== void 0 ? _j : "custom", sourceCode: (_k = record === null || record === void 0 ? void 0 : record.sourceCode) !== null && _k !== void 0 ? _k : "", tags: nextTags });
165
148
  }, [record]);
166
149
  var isReadOnly = (record === null || record === void 0 ? void 0 : record.type) === "solidx";
167
150
  var isDirty = Boolean(record === null || record === void 0 ? void 0 : record.id) && currentForm() !== baseline.current;
168
151
  var requestRefresh = function () { return isDirty ? setConfirmRefresh(true) : void refetch(); };
169
- var addTag = function () {
170
- var next = tagDraft.trim();
171
- if (!next)
172
- return;
173
- if (!tags.some(function (tag) { return tag.toLowerCase() === next.toLowerCase(); }))
174
- setTags(function (current) { return __spreadArray(__spreadArray([], current, true), [next], false); });
175
- setTagDraft("");
176
- setFieldErrors(function (current) { return (__assign(__assign({}, current), { tags: "" })); });
177
- };
178
152
  var save = function (nextStatus) { return __awaiter(_this, void 0, void 0, function () {
179
- var nextErrors, payload, _a, _b, result, createdId, error_1, errorDetail, serverFieldErrors, _i, _c, field, label;
153
+ var nextErrors, payload, _a, _b, result, result, createdId, error_1, errorDetail, serverFieldErrors, _i, _c, field, label;
180
154
  var _d;
181
- var _e, _f, _g;
182
- return __generator(this, function (_h) {
183
- switch (_h.label) {
155
+ var _e, _f, _g, _h;
156
+ return __generator(this, function (_j) {
157
+ switch (_j.label) {
184
158
  case 0:
159
+ if (creatingTag)
160
+ return [2 /*return*/];
185
161
  nextErrors = {};
186
162
  if (!name.trim())
187
163
  nextErrors.name = "Name is required.";
188
164
  if (!description.trim())
189
165
  nextErrors.description = "Description is required.";
190
- if (tags.length === 0)
191
- nextErrors.tags = "At least one tag is required.";
192
166
  if (!type.trim())
193
167
  nextErrors.type = "Tool type is required.";
194
168
  if (!sourceCode.trim())
@@ -199,47 +173,45 @@ export function AgentToolRegistryEditorPage() {
199
173
  dispatch(showToast({ severity: "error", summary: "Missing information", detail: Object.values(nextErrors).join(" ") }));
200
174
  return [2 /*return*/];
201
175
  }
202
- _a = [{ name: name.trim(), iconName: iconName || null, description: description.trim(), type: type, sourceCode: sourceCode, tags: JSON.stringify(tags) }];
203
- if (!(type === "custom")) return [3 /*break*/, 2];
176
+ _a = [__assign({ name: name.trim(), iconName: iconName || null, description: description.trim(), type: type, sourceCode: sourceCode }, agentHubTagsPayload(tags))];
177
+ if (!["custom", "thirdparty"].includes(type)) return [3 /*break*/, 2];
204
178
  _d = {};
205
179
  return [4 /*yield*/, sha256Hex(sourceCode)];
206
180
  case 1:
207
- _b = (_d.checksum = _h.sent(), _d);
181
+ _b = (_d.checksum = _j.sent(), _d);
208
182
  return [3 /*break*/, 3];
209
183
  case 2:
210
184
  _b = {};
211
- _h.label = 3;
185
+ _j.label = 3;
212
186
  case 3:
213
- payload = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_b)])), {
214
- // Status is required by the agentToolRegistry metadata, including partial
215
- // updates. Preserve the current lifecycle state for ordinary saves.
216
- status: nextStatus !== null && nextStatus !== void 0 ? nextStatus : ((record === null || record === void 0 ? void 0 : record.status) === "load_failed" ? "active" : (_e = record === null || record === void 0 ? void 0 : record.status) !== null && _e !== void 0 ? _e : "active") }]), ((nextStatus === "active" || (!nextStatus && (record === null || record === void 0 ? void 0 : record.status) === "load_failed")) ? { lastLoadError: null } : {})]);
217
- _h.label = 4;
187
+ payload = __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_b)])), { status: nextStatus !== null && nextStatus !== void 0 ? nextStatus : (record && (sourceCode !== record.sourceCode || name.trim() !== record.name || type !== record.type)
188
+ ? "inactive" : (_e = record === null || record === void 0 ? void 0 : record.status) !== null && _e !== void 0 ? _e : "inactive") }]);
189
+ _j.label = 4;
218
190
  case 4:
219
- _h.trys.push([4, 9, , 10]);
191
+ _j.trys.push([4, 9, , 10]);
220
192
  if (!(record === null || record === void 0 ? void 0 : record.id)) return [3 /*break*/, 6];
221
193
  return [4 /*yield*/, updateTool({ id: record.id, data: payload }).unwrap()];
222
194
  case 5:
223
- _h.sent();
195
+ result = _j.sent();
224
196
  dispatch(showToast({ severity: "success", summary: nextStatus ? "Tool status updated" : "Saved", detail: nextStatus ? "Tool moved to ".concat(nextStatus, ". Restart linked agent processes to apply the change.") : "Tool updated successfully." }));
225
197
  setAuditRefreshVersion(function (version) { return version + 1; });
226
198
  refetch();
227
- return [3 /*break*/, 8];
199
+ return [2 /*return*/, ((_f = extractEntityRecord(result)) !== null && _f !== void 0 ? _f : __assign(__assign({}, record), payload))];
228
200
  case 6: return [4 /*yield*/, createTool(payload).unwrap()];
229
201
  case 7:
230
- result = _h.sent();
231
- createdId = (_g = (_f = result === null || result === void 0 ? void 0 : result.data) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : result === null || result === void 0 ? void 0 : result.id;
202
+ result = _j.sent();
203
+ createdId = (_h = (_g = result === null || result === void 0 ? void 0 : result.data) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : result === null || result === void 0 ? void 0 : result.id;
232
204
  dispatch(showToast({ severity: "success", summary: "Created", detail: "Tool created successfully." }));
233
205
  if (createdId)
234
206
  navigate("/admin/core/solid-core/agent-tool-registry/editor/".concat(createdId), { replace: true });
235
- _h.label = 8;
207
+ _j.label = 8;
236
208
  case 8: return [3 /*break*/, 10];
237
209
  case 9:
238
- error_1 = _h.sent();
210
+ error_1 = _j.sent();
239
211
  errorDetail = getSaveErrorMessage(error_1);
240
212
  serverFieldErrors = {};
241
213
  if (/required|not be empty|cannot be empty|should not be empty/i.test(errorDetail)) {
242
- for (_i = 0, _c = ["name", "description", "tags", "type", "sourceCode"]; _i < _c.length; _i++) {
214
+ for (_i = 0, _c = ["name", "description", "type", "sourceCode"]; _i < _c.length; _i++) {
243
215
  field = _c[_i];
244
216
  if (!new RegExp("\\b".concat(field, "\\b"), "i").test(errorDetail))
245
217
  continue;
@@ -257,6 +229,49 @@ export function AgentToolRegistryEditorPage() {
257
229
  }
258
230
  });
259
231
  }); };
232
+ var beginActivation = function () { return __awaiter(_this, void 0, void 0, function () {
233
+ var saved, _a, checksum, _b;
234
+ var _c, _d;
235
+ return __generator(this, function (_e) {
236
+ switch (_e.label) {
237
+ case 0:
238
+ if (isReadOnly)
239
+ return [2 /*return*/];
240
+ if (!record || activationOpen || isSaving || preparingActivation.current)
241
+ return [2 /*return*/];
242
+ preparingActivation.current = true;
243
+ _e.label = 1;
244
+ case 1:
245
+ _e.trys.push([1, 6, 7, 8]);
246
+ if (!(isDirty || record.status === "load_failed")) return [3 /*break*/, 3];
247
+ return [4 /*yield*/, save("inactive")];
248
+ case 2:
249
+ _a = _e.sent();
250
+ return [3 /*break*/, 4];
251
+ case 3:
252
+ _a = record;
253
+ _e.label = 4;
254
+ case 4:
255
+ saved = _a;
256
+ if (!(saved === null || saved === void 0 ? void 0 : saved.id))
257
+ return [2 /*return*/];
258
+ return [4 /*yield*/, sha256Hex((_c = saved.sourceCode) !== null && _c !== void 0 ? _c : sourceCode)];
259
+ case 5:
260
+ checksum = _e.sent();
261
+ setActivationTool({ id: saved.id, checksum: checksum, name: (_d = saved.name) !== null && _d !== void 0 ? _d : name });
262
+ setActivationOpen(true);
263
+ return [3 /*break*/, 8];
264
+ case 6:
265
+ _b = _e.sent();
266
+ dispatch(showToast({ severity: "error", summary: "Activation failed", detail: "Could not prepare the saved tool source for checks." }));
267
+ return [3 /*break*/, 8];
268
+ case 7:
269
+ preparingActivation.current = false;
270
+ return [7 /*endfinally*/];
271
+ case 8: return [2 /*return*/];
272
+ }
273
+ });
274
+ }); };
260
275
  var agents = React.useMemo(function () {
261
276
  var relatedTools = record === null || record === void 0 ? void 0 : record.agentTools;
262
277
  var links = Array.isArray(relatedTools) ? relatedTools : relatedTools ? [relatedTools] : [];
@@ -273,23 +288,31 @@ export function AgentToolRegistryEditorPage() {
273
288
  }, [record === null || record === void 0 ? void 0 : record.agentTools]);
274
289
  var sessionAgents = React.useMemo(function () { return agents.filter(function (agent) { return agent.id !== undefined && agent.id !== null; }); }, [agents]);
275
290
  var tabs = [
276
- { value: "general", label: "General Info", content: _jsxs("fieldset", { className: "agent-tool-editor__general", disabled: isReadOnly, children: [isReadOnly && _jsx("p", { className: "agent-tool-editor__readonly-note", children: "SolidX tools are seeded by the AgentHub runtime and cannot be edited." }), (record === null || record === void 0 ? void 0 : record.status) && _jsxs("section", { className: "agent-tool-editor__runtime-status".concat(record.status === "load_failed" ? " agent-tool-editor__runtime-status--failed" : ""), role: record.status === "load_failed" ? "alert" : "status", children: [_jsxs("div", { className: "agent-tool-editor__runtime-heading", children: [_jsx("strong", { children: "Runtime status" }), _jsx("span", { children: record.status.replace(/[_-]+/g, " ") })] }), record.status === "load_failed" ? _jsxs(_Fragment, { children: [_jsx("p", { children: "The AgentHub runtime could not load this tool. After correcting its source or checksum, restart linked agent processes so the runtime retries loading it." }), record.lastLoadError && _jsx("pre", { children: record.lastLoadError })] }) : _jsx("p", { children: record.lastLoadError || "No tool load error has been reported." })] }), _jsxs("div", { className: "agent-tool-editor__fields", children: [_jsxs("label", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Name ", _jsx("b", { children: "*" })] }), _jsx(SolidInput, { value: name, "aria-invalid": Boolean(fieldErrors.name), "aria-describedby": fieldErrors.name ? "agent-tool-name-error" : undefined, className: fieldErrors.name ? "agent-tool-editor__input--invalid" : undefined, onChange: function (e) { setName(e.target.value); setFieldErrors(function (current) { return (__assign(__assign({}, current), { name: "" })); }); } }), fieldErrors.name && _jsx("small", { id: "agent-tool-name-error", className: "agent-tool-editor__field-error", children: fieldErrors.name })] }), _jsxs("div", { className: "agent-tool-editor__field", children: [_jsx("span", { children: "Icon" }), _jsx(SolidIconPicker, { value: iconName, onChange: setIconName })] }), _jsxs("label", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Description ", _jsx("b", { children: "*" })] }), _jsx(SolidInput, { value: description, "aria-invalid": Boolean(fieldErrors.description), "aria-describedby": fieldErrors.description ? "agent-tool-description-error" : undefined, className: fieldErrors.description ? "agent-tool-editor__input--invalid" : undefined, onChange: function (e) { setDescription(e.target.value); setFieldErrors(function (current) { return (__assign(__assign({}, current), { description: "" })); }); } }), fieldErrors.description && _jsx("small", { id: "agent-tool-description-error", className: "agent-tool-editor__field-error", children: fieldErrors.description })] })] }), _jsxs("label", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Tool type ", _jsx("b", { children: "*" })] }), _jsxs("select", { value: type, "aria-invalid": Boolean(fieldErrors.type), "aria-describedby": fieldErrors.type ? "agent-tool-type-error" : undefined, className: fieldErrors.type ? "agent-tool-editor__input--invalid" : undefined, onChange: function (e) { setType(e.target.value); setFieldErrors(function (current) { return (__assign(__assign({}, current), { type: "" })); }); }, children: [isReadOnly && _jsx("option", { value: "solidx", children: "SolidX" }), _jsx("option", { value: "thirdparty", children: "Third Party" }), _jsx("option", { value: "custom", children: "Custom" })] }), fieldErrors.type && _jsx("small", { id: "agent-tool-type-error", className: "agent-tool-editor__field-error", children: fieldErrors.type })] }), _jsxs("div", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Tags ", _jsx("b", { children: "*" })] }), _jsxs("div", { className: "agent-tool-editor__tag-input".concat(fieldErrors.tags ? " agent-tool-editor__tag-input--invalid" : ""), children: [tags.map(function (tag, index) { return _jsxs("span", { className: "agent-tool-editor__tag", children: [tag, _jsx("button", { type: "button", "aria-label": "Remove ".concat(tag), onClick: function () { return setTags(function (current) { var next = current.filter(function (_, i) { return i !== index; }); if (next.length)
277
- setFieldErrors(function (errors) { return (__assign(__assign({}, errors), { tags: "" })); }); return next; }); }, children: _jsx(X, { size: 13 }) })] }, "".concat(tag, "-").concat(index)); }), _jsx("input", { value: tagDraft, "aria-label": "Add a tag", placeholder: "Type a tag and press Enter", onChange: function (e) { return setTagDraft(e.target.value); }, onKeyDown: function (e) { if (e.key === "Enter") {
278
- e.preventDefault();
279
- addTag();
280
- } } }), _jsxs(SolidButton, { type: "button", variant: "secondary", size: "small", onClick: addTag, children: [_jsx(Plus, { size: 14 }), " Add"] })] }), fieldErrors.tags && _jsx("small", { className: "agent-tool-editor__field-error", children: fieldErrors.tags }), _jsx("small", { children: "Tags are saved as a JSON array." })] }), (record === null || record === void 0 ? void 0 : record.id) && _jsxs("section", { className: "agent-tool-editor__workflow", "aria-labelledby": "agent-tool-lifecycle-title", children: [_jsx("div", { className: "agent-tool-editor__workflow-head", children: _jsxs("div", { children: [_jsx("h2", { id: "agent-tool-lifecycle-title", children: "Tool lifecycle" }), _jsx("p", { children: "Activate or deactivate this tool for linked agents. Load failures are reported by AgentHub." })] }) }), _jsx("div", { className: "agent-tool-editor__workflow-stages", "aria-label": "Current tool stage: ".concat(((_a = record.status) !== null && _a !== void 0 ? _a : "active").replace(/[_-]+/g, " ")), children: [["active", "Active", "Enabled for loading into linked agents."], ["inactive", "Inactive", "Not loaded for linked agents."], ["load_failed", "Load failed", "AgentHub could not load this tool."]].map(function (_a, index) {
291
+ { value: "general", label: "General Info", content: _jsxs("fieldset", { className: "agent-tool-editor__general", disabled: isReadOnly, children: [isReadOnly && _jsx("p", { className: "agent-tool-editor__readonly-note", children: "SolidX tools are seeded by the AgentHub runtime and cannot be edited." }), (record === null || record === void 0 ? void 0 : record.status) && _jsxs("section", { className: "agent-tool-editor__runtime-status".concat(record.status === "load_failed" ? " agent-tool-editor__runtime-status--failed" : ""), role: record.status === "load_failed" ? "alert" : "status", children: [_jsxs("div", { className: "agent-tool-editor__runtime-heading", children: [_jsx("strong", { children: "Runtime status" }), _jsx("span", { children: record.status.replace(/[_-]+/g, " ") })] }), record.status === "load_failed" ? _jsxs(_Fragment, { children: [_jsx("p", { children: "The AgentHub runtime could not load this tool. After correcting its source or checksum, restart linked agent processes so the runtime retries loading it." }), record.lastLoadError && _jsx("pre", { children: record.lastLoadError })] }) : _jsx("p", { children: record.lastLoadError || "No tool load error has been reported." })] }), _jsxs("div", { className: "agent-tool-editor__fields", children: [_jsxs("label", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Name ", _jsx("b", { children: "*" })] }), _jsx(SolidInput, { value: name, "aria-invalid": Boolean(fieldErrors.name), "aria-describedby": fieldErrors.name ? "agent-tool-name-error" : undefined, className: fieldErrors.name ? "agent-tool-editor__input--invalid" : undefined, onChange: function (e) { setName(e.target.value); setFieldErrors(function (current) { return (__assign(__assign({}, current), { name: "" })); }); } }), fieldErrors.name && _jsx("small", { id: "agent-tool-name-error", className: "agent-tool-editor__field-error", children: fieldErrors.name })] }), _jsxs("div", { className: "agent-tool-editor__field", children: [_jsx("span", { children: "Icon" }), _jsx(SolidIconPicker, { value: iconName, onChange: setIconName })] }), _jsxs("label", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Description ", _jsx("b", { children: "*" })] }), _jsx(SolidInput, { value: description, "aria-invalid": Boolean(fieldErrors.description), "aria-describedby": fieldErrors.description ? "agent-tool-description-error" : undefined, className: fieldErrors.description ? "agent-tool-editor__input--invalid" : undefined, onChange: function (e) { setDescription(e.target.value); setFieldErrors(function (current) { return (__assign(__assign({}, current), { description: "" })); }); } }), fieldErrors.description && _jsx("small", { id: "agent-tool-description-error", className: "agent-tool-editor__field-error", children: fieldErrors.description })] })] }), !(record === null || record === void 0 ? void 0 : record.id) && _jsxs("label", { className: "agent-tool-editor__field", children: [_jsx("span", { children: "Tool status" }), _jsx("select", { value: "inactive", disabled: true, "aria-label": "Tool status", children: _jsx("option", { value: "inactive", children: "Inactive" }) }), _jsx("small", { children: "New tools start inactive. Run configuration and initialization checks to activate." })] }), _jsxs("label", { className: "agent-tool-editor__field", children: [_jsxs("span", { children: ["Tool type ", _jsx("b", { children: "*" })] }), _jsxs("select", { value: type, "aria-invalid": Boolean(fieldErrors.type), "aria-describedby": fieldErrors.type ? "agent-tool-type-error" : undefined, className: fieldErrors.type ? "agent-tool-editor__input--invalid" : undefined, onChange: function (e) { setType(e.target.value); setFieldErrors(function (current) { return (__assign(__assign({}, current), { type: "" })); }); }, children: [isReadOnly && _jsx("option", { value: "solidx", children: "SolidX" }), _jsx("option", { value: "thirdparty", children: "Third Party" }), _jsx("option", { value: "custom", children: "Custom" })] }), fieldErrors.type && _jsx("small", { id: "agent-tool-type-error", className: "agent-tool-editor__field-error", children: fieldErrors.type })] }), _jsx(AgentHubTagsField, { value: tags, onChange: setTags, disabled: isReadOnly || isCreating || isSaving, onBusyChange: setCreatingTag }), (record === null || record === void 0 ? void 0 : record.id) && _jsxs("section", { className: "agent-tool-editor__workflow", "aria-labelledby": "agent-tool-lifecycle-title", children: [_jsx("div", { className: "agent-tool-editor__workflow-head", children: _jsxs("div", { children: [_jsx("h2", { id: "agent-tool-lifecycle-title", children: "Tool lifecycle" }), _jsx("p", { children: "Configuration and initialization must pass before this tool can be activated." })] }) }), _jsx("div", { className: "agent-tool-editor__workflow-stages", "aria-label": "Current tool stage: ".concat(((_a = record.status) !== null && _a !== void 0 ? _a : "inactive").replace(/[_-]+/g, " ")), children: [["active", "Active", "Enabled for loading into linked agents."], ["inactive", "Inactive", "Not loaded for linked agents."], ["load_failed", "Load failed", "AgentHub could not load this tool."]].map(function (_a, index) {
281
292
  var _b;
282
293
  var value = _a[0], label = _a[1], description = _a[2];
283
- var currentStatus = (_b = record.status) !== null && _b !== void 0 ? _b : "active";
294
+ var currentStatus = (_b = record.status) !== null && _b !== void 0 ? _b : "inactive";
284
295
  var isCurrent = currentStatus === value;
285
296
  var canRetry = value === "load_failed" && isCurrent;
286
- var disabled = isCreating || isSaving || (!canRetry && (value === "load_failed" || isCurrent));
287
- return _jsxs(React.Fragment, { children: [index > 0 && _jsx("div", { className: "agent-tool-editor__workflow-connector", "aria-hidden": "true" }), _jsxs("button", { type: "button", className: "agent-tool-editor__workflow-stage agent-tool-editor__workflow-stage--".concat(value).concat(isCurrent ? " is-current" : ""), "aria-current": isCurrent ? "step" : undefined, "aria-pressed": isCurrent, disabled: disabled, onClick: function () { return void save(value === "load_failed" ? "active" : value); }, children: [_jsx("span", { className: "agent-tool-editor__workflow-mark", children: index + 1 }), _jsxs("span", { className: "agent-tool-editor__workflow-copy", children: [_jsx("strong", { children: label }), _jsx("small", { children: description }), _jsx("small", { className: "agent-tool-editor__workflow-cta", children: canRetry ? "Click to retry loading" : isCurrent ? "Current stage" : value === "load_failed" ? "Set automatically by AgentHub" : "Click to move to this stage" })] }), isCurrent && _jsx("span", { className: "agent-tool-editor__workflow-current", children: "Current" })] })] }, value);
288
- }) }), record.status === "load_failed" && _jsx("small", { className: "agent-tool-editor__workflow-hint", children: "Fix the source or checksum first. Retrying saves the current tool configuration and clears the reported error; restart linked agent processes to load the updated tool." }), _jsx("small", { className: "agent-tool-editor__workflow-hint", children: "Changing stage saves the current tool configuration. Restart linked agent processes to apply the change." })] })] }) },
297
+ var disabled = isReadOnly || activationOpen || isCreating || isSaving || (!canRetry && (value === "load_failed" || isCurrent));
298
+ return _jsxs(React.Fragment, { children: [index > 0 && _jsx("div", { className: "agent-tool-editor__workflow-connector", "aria-hidden": "true" }), _jsxs("button", { type: "button", className: "agent-tool-editor__workflow-stage agent-tool-editor__workflow-stage--".concat(value).concat(isCurrent ? " is-current" : ""), "aria-current": isCurrent ? "step" : undefined, "aria-pressed": isCurrent, disabled: disabled, onClick: function () { return value === "inactive" ? void save("inactive") : void beginActivation(); }, children: [_jsx("span", { className: "agent-tool-editor__workflow-mark", children: index + 1 }), _jsxs("span", { className: "agent-tool-editor__workflow-copy", children: [_jsx("strong", { children: label }), _jsx("small", { children: description }), _jsx("small", { className: "agent-tool-editor__workflow-cta", children: canRetry ? "Run checks and retry activation" : isCurrent ? "Current stage" : value === "load_failed" ? "Set automatically by AgentHub" : value === "active" ? "Run checks to activate" : "Click to deactivate" })] }), isCurrent && _jsx("span", { className: "agent-tool-editor__workflow-current", children: "Current" })] })] }, value);
299
+ }) }), record.status === "load_failed" && _jsx("small", { className: "agent-tool-editor__workflow-hint", children: "Fix the source or checksum, then run configuration and initialization checks before retrying activation." }), _jsx("small", { className: "agent-tool-editor__workflow-hint", children: "Activation checks use the saved tool configuration. Restart linked agent processes to apply status changes." })] })] }) },
289
300
  { value: "tool", label: "Tool", content: _jsx("div", { className: "agent-tool-editor__tool", children: _jsxs("section", { className: "agent-tool-editor__panel", children: [_jsxs("header", { children: [_jsxs("h2", { children: ["Tool source code ", _jsx("b", { children: "*" })] }), _jsx("p", { children: "Write the tool's Python code here." })] }), _jsx(SolidCodeEditor, { value: sourceCode, onChange: function (value) { setSourceCode(value !== null && value !== void 0 ? value : ""); setFieldErrors(function (current) { return (__assign(__assign({}, current), { sourceCode: "" })); }); }, language: "python", readOnly: isReadOnly, fontSize: 11, height: "max(32rem, calc(100dvh - 18rem))", className: "agent-tool-editor__code".concat(fieldErrors.sourceCode ? " agent-tool-editor__code--invalid" : "") }), fieldErrors.sourceCode && _jsx("small", { className: "agent-tool-editor__field-error agent-tool-editor__code-error", children: fieldErrors.sourceCode })] }) }) },
290
301
  { value: "agents", label: "Agents", content: _jsxs("section", { className: "agent-tool-editor__agents", children: [_jsxs("div", { children: [_jsx("h2", { children: "Associated agents" }), _jsx("p", { children: "Agents linked to this tool. Associations are read-only here." })] }), isLoading ? _jsx("p", { children: "Loading associated agents\u2026" }) : agents.length ? _jsx("div", { className: "agent-tool-editor__agent-grid", children: agents.map(function (agent, index) { var _a, _b; return _jsx("div", { className: "agent-tool-editor__agent-card", children: _jsx(SharedAgentRegistryCard, { rowData: agent }) }, String((_b = (_a = agent.id) !== null && _a !== void 0 ? _a : agent.name) !== null && _b !== void 0 ? _b : index)); }) }) : _jsx("div", { className: "agent-tool-editor__empty", children: "No agents are currently associated with this tool." })] }) },
291
302
  { value: "sessions", label: "Sessions", content: _jsx(AgentToolSessionsPanel, { agents: sessionAgents }) },
292
303
  ];
293
- return _jsxs("main", { className: "agent-tool-editor", children: [_jsxs("header", { className: "agent-tool-editor__header", children: [_jsx("div", { children: _jsxs("div", { className: "agent-tool-editor__heading-with-refresh", children: [_jsx("h1", { children: record ? "Edit Tool" : "Create Tool" }), (record === null || record === void 0 ? void 0 : record.id) && _jsx("button", { type: "button", className: "agent-tool-editor__refresh".concat(isFetching ? " is-loading" : ""), "aria-label": "Refresh tool", title: "Refresh tool", disabled: isFetching || isSaving, onClick: requestRefresh, children: _jsx(RefreshCw, { size: 14 }) })] }) }), _jsxs("div", { className: "agent-tool-editor__actions", children: [_jsx(SolidButton, { variant: "secondary", leftIcon: _jsx(ArrowLeft, { size: 16 }), onClick: function () { return navigate(-1); }, children: "Back" }), !isReadOnly && _jsx(SolidButton, { loading: isCreating || isSaving, onClick: function () { return void save(); }, children: "Save Tool" })] })] }), _jsx(SolidDialog, { open: confirmRefresh, onOpenChange: setConfirmRefresh, header: "Discard unsaved changes?", style: { width: "min(28rem, 94vw)" }, footer: _jsxs(_Fragment, { children: [_jsx(SolidButton, { type: "button", variant: "secondary", onClick: function () { return setConfirmRefresh(false); }, children: "Cancel" }), _jsx(SolidButton, { type: "button", disabled: isFetching, onClick: function () { setConfirmRefresh(false); void refetch(); }, children: "Refresh and discard" })] }), children: _jsx(SolidDialogBody, { children: _jsx("p", { children: "You have unsaved changes. Refreshing will discard them and load the latest tool content." }) }) }), isLoading ? _jsx("div", { className: "agent-tool-editor__loading", children: "Loading tool\u2026" }) : (record === null || record === void 0 ? void 0 : record.id) ? (_jsx(AgentRegistryAuditPanel, { modelSingularName: "agentToolRegistry", recordId: record.id, refreshVersion: auditRefreshVersion, modelUserKey: record.name, children: _jsx(SolidTabGroup, { tabs: tabs, value: activeTab, onValueChange: setActiveTab, className: "agent-tool-editor__tabs", listClassName: "agent-tool-editor__tab-list", panelClassName: "agent-tool-editor__tab-panel" }) })) : _jsx(SolidTabGroup, { tabs: tabs, value: activeTab, onValueChange: setActiveTab, className: "agent-tool-editor__tabs", listClassName: "agent-tool-editor__tab-list", panelClassName: "agent-tool-editor__tab-panel" })] });
304
+ return _jsxs("main", { className: "agent-tool-editor", children: [_jsxs("header", { className: "agent-tool-editor__header", children: [_jsx("div", { children: _jsxs("div", { className: "agent-tool-editor__heading-with-refresh", children: [_jsx("h1", { children: record ? "Edit Tool" : "Create Tool" }), (record === null || record === void 0 ? void 0 : record.id) && _jsx("button", { type: "button", className: "agent-tool-editor__refresh".concat(isFetching ? " is-loading" : ""), "aria-label": "Refresh tool", title: "Refresh tool", disabled: isFetching || isSaving, onClick: requestRefresh, children: _jsx(RefreshCw, { size: 14 }) })] }) }), _jsxs("div", { className: "agent-tool-editor__actions", children: [_jsx(SolidButton, { variant: "secondary", leftIcon: _jsx(ArrowLeft, { size: 16 }), onClick: function () { return navigate(-1); }, children: "Back" }), !isReadOnly && _jsx(SolidButton, { disabled: activationOpen || creatingTag, loading: isCreating || isSaving, onClick: function () { return void save(); }, children: "Save Tool" })] })] }), _jsx(SolidDialog, { open: confirmRefresh, onOpenChange: setConfirmRefresh, header: "Discard unsaved changes?", style: { width: "min(28rem, 94vw)" }, footer: _jsxs(_Fragment, { children: [_jsx(SolidButton, { type: "button", variant: "secondary", onClick: function () { return setConfirmRefresh(false); }, children: "Cancel" }), _jsx(SolidButton, { type: "button", disabled: isFetching, onClick: function () { setConfirmRefresh(false); void refetch(); }, children: "Refresh and discard" })] }), children: _jsx(SolidDialogBody, { children: _jsx("p", { children: "You have unsaved changes. Refreshing will discard them and load the latest tool content." }) }) }), activationOpen && activationTool && _jsx(AgentToolActivationDialog, { open: activationOpen, onOpenChange: setActivationOpen, toolId: activationTool.id, checksum: activationTool.checksum, toolName: activationTool.name, onActivated: function () { return __awaiter(_this, void 0, void 0, function () {
305
+ return __generator(this, function (_a) {
306
+ switch (_a.label) {
307
+ case 0: return [4 /*yield*/, solidPatch("/agent-tool-registry/".concat(activationTool.id), { status: "active", checksum: activationTool.checksum })];
308
+ case 1:
309
+ _a.sent();
310
+ setAuditRefreshVersion(function (version) { return version + 1; });
311
+ void refetch();
312
+ dispatch(showToast({ severity: "success", summary: "Tool activated", detail: "Configuration and initialization checks passed." }));
313
+ return [2 /*return*/];
314
+ }
315
+ });
316
+ }); } }), isLoading ? _jsx("div", { className: "agent-tool-editor__loading", children: "Loading tool\u2026" }) : (record === null || record === void 0 ? void 0 : record.id) ? (_jsx(AgentRegistryAuditPanel, { modelSingularName: "agentToolRegistry", recordId: record.id, refreshVersion: auditRefreshVersion, modelUserKey: record.name, children: _jsx(SolidTabGroup, { tabs: tabs, value: activeTab, onValueChange: setActiveTab, className: "agent-tool-editor__tabs", listClassName: "agent-tool-editor__tab-list", panelClassName: "agent-tool-editor__tab-panel" }) })) : _jsx(SolidTabGroup, { tabs: tabs, value: activeTab, onValueChange: setActiveTab, className: "agent-tool-editor__tabs", listClassName: "agent-tool-editor__tab-list", panelClassName: "agent-tool-editor__tab-panel" })] });
294
317
  }
295
318
  //# sourceMappingURL=AgentToolRegistryEditorPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentToolRegistryEditorPage.js","sourceRoot":"","sources":["../../../../../src/routes/pages/admin/core/AgentToolRegistryEditorPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2FAA2F,CAAC;AACnI,OAAO,EAAE,uBAAuB,EAAE,MAAM,6FAA6F,CAAC;AACtI,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAC3J,OAAO,mCAAmC,CAAC;A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AI,EAAC,QAAQ,EAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,cAAQ,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,oCAAmC,IAAG,YACzQ,KAAC,eAAe,cAAC,mHAA+F,GAAkB,GACtH,EACb,SAAS,CAAC,CAAC,CAAC,cAAK,SAAS,EAAC,4BAA4B,mCAAoB,CAAC,CAAC,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EAAC,CAAC,CAAC,CAC1F,KAAC,uBAAuB,IAAC,iBAAiB,EAAC,mBAAmB,EAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,YAChJ,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAC,yBAAyB,EAAC,aAAa,EAAC,6BAA6B,EAAC,cAAc,EAAC,8BAA8B,GAAG,GAClL,CAC3B,CAAC,CAAC,CAAC,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAC,yBAAyB,EAAC,aAAa,EAAC,6BAA6B,EAAC,cAAc,EAAC,8BAA8B,GAAG,IACzM,CAAC;AACV,CAAC","sourcesContent":["import React from \"react\";\nimport { ArrowLeft, Plus, RefreshCw, X } from \"lucide-react\";\nimport { useDispatch } from \"react-redux\";\nimport { useNavigate, useParams } from \"react-router-dom\";\nimport { createSolidEntityApi } from \"../../../../redux/api/solidEntityApi\";\nimport { showToast } from \"../../../../redux/features/toastSlice\";\nimport { AgentRegistryAuditPanel } from \"./AgentRegistryAuditPanel\";\nimport { AgentToolSessionsPanel } from \"../../../../components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel\";\nimport { AgentRegistryCardWidget } from \"../../../../components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget\";\nimport { SolidButton, SolidCodeEditor, SolidDialog, SolidDialogBody, SolidIconPicker, SolidInput, SolidTabGroup } from \"../../../../components/shad-cn-ui\";\nimport \"./AgentToolRegistryEditorPage.css\";\n\nconst SharedAgentRegistryCard = AgentRegistryCardWidget as React.ComponentType<{ rowData: Record<string, any> }>;\n\ntype Agent = { id?: number | string; name?: string; title?: string; [key: string]: any };\ntype AgentToolLink = { agentRegistry?: Agent | number | string | null };\ntype ToolRecord = {\n id: number;\n name?: string;\n iconName?: string | null;\n description?: string;\n tags?: unknown;\n type?: string;\n status?: string | null;\n lastLoadError?: string | null;\n sourceCode?: string;\n agentTools?: AgentToolLink[] | AgentToolLink | null;\n};\n\nfunction extractEntityRecord(response: unknown): Record<string, any> | undefined {\n let candidate: unknown = response;\n for (let depth = 0; depth < 3; depth += 1) {\n if (!candidate || typeof candidate !== \"object\") return undefined;\n const value = candidate as Record<string, unknown>;\n if (\"id\" in value || \"name\" in value) return value;\n candidate = value.data;\n }\n return candidate && typeof candidate === \"object\" ? candidate as Record<string, any> : undefined;\n}\n\nfunction parseTags(value: unknown): string[] {\n if (Array.isArray(value)) return value.map(String).map((tag) => tag.trim()).filter(Boolean);\n if (typeof value !== \"string\" || !value.trim()) return [];\n try {\n const parsed = JSON.parse(value);\n return Array.isArray(parsed) ? parsed.map(String).map((tag) => tag.trim()).filter(Boolean) : [];\n } catch {\n return value === \"{}\" ? [] : value.split(\",\").map((tag) => tag.trim()).filter(Boolean);\n }\n}\n\nasync function sha256Hex(value: string): Promise<string> {\n const digest = await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction formatErrorMessage(value: unknown): string | undefined {\n if (typeof value === \"string\") return value.trim() || undefined;\n if (Array.isArray(value)) {\n const messages = value.map(formatErrorMessage).filter((message): message is string => Boolean(message));\n return messages.length ? messages.join(\"; \") : undefined;\n }\n if (value && typeof value === \"object\") {\n const error = value as Record<string, unknown>;\n return formatErrorMessage(error.message)\n ?? formatErrorMessage(error.constraints)\n ?? formatErrorMessage(error.error);\n }\n return undefined;\n}\n\nfunction getSaveErrorMessage(error: unknown): string {\n if (!error || typeof error !== \"object\") return \"Failed to save tool.\";\n const apiError = error as Record<string, any>;\n return formatErrorMessage(apiError.data?.data?.message)\n ?? formatErrorMessage(apiError.data?.message)\n ?? formatErrorMessage(apiError.data?.error)\n ?? formatErrorMessage(apiError.message)\n ?? \"Failed to save tool.\";\n}\n\nexport function AgentToolRegistryEditorPage() {\n const { id = \"\" } = useParams<{ id: string }>();\n const navigate = useNavigate();\n const dispatch = useDispatch();\n const entityApi = React.useMemo(() => createSolidEntityApi(\"agentToolRegistry\"), []);\n const { useCreateSolidEntityMutation, useGetSolidEntityByIdQuery, useUpdateSolidEntityMutation } = entityApi;\n const { data: response, isLoading, isFetching, refetch } = useGetSolidEntityByIdQuery(\n { id, qs: \"populate[0]=agentTools&populate[1]=agentTools.agentRegistry\" },\n { skip: !id || id === \"new\" },\n );\n const [createTool, { isLoading: isCreating }] = useCreateSolidEntityMutation();\n const [updateTool, { isLoading: isSaving }] = useUpdateSolidEntityMutation();\n const record = extractEntityRecord(response) as ToolRecord | undefined;\n const [activeTab, setActiveTab] = React.useState(\"general\");\n const [name, setName] = React.useState(\"\");\n const [iconName, setIconName] = React.useState(\"\");\n const [description, setDescription] = React.useState(\"\");\n const [type, setType] = React.useState(\"custom\");\n const [sourceCode, setSourceCode] = React.useState(\"\");\n const [tags, setTags] = React.useState<string[]>([]);\n const [tagDraft, setTagDraft] = React.useState(\"\");\n const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({});\n const [auditRefreshVersion, setAuditRefreshVersion] = React.useState(0);\n const [confirmRefresh, setConfirmRefresh] = React.useState(false);\n const baseline = React.useRef(\"\");\n\n const currentForm = () => JSON.stringify({ name, iconName, description, type, sourceCode, tags, tagDraft });\n\n React.useEffect(() => {\n const nextTags = parseTags(record?.tags);\n setName(record?.name ?? \"\");\n setIconName(record?.iconName ?? \"\");\n setDescription(record?.description ?? \"\");\n setType(record?.type ?? \"custom\");\n setSourceCode(record?.sourceCode ?? \"\");\n setTags(nextTags);\n setTagDraft(\"\");\n baseline.current = JSON.stringify({ name: record?.name ?? \"\", iconName: record?.iconName ?? \"\", description: record?.description ?? \"\", type: record?.type ?? \"custom\", sourceCode: record?.sourceCode ?? \"\", tags: nextTags, tagDraft: \"\" });\n }, [record]);\n\n const isReadOnly = record?.type === \"solidx\";\n const isDirty = Boolean(record?.id) && currentForm() !== baseline.current;\n const requestRefresh = () => isDirty ? setConfirmRefresh(true) : void refetch();\n\n const addTag = () => {\n const next = tagDraft.trim();\n if (!next) return;\n if (!tags.some((tag) => tag.toLowerCase() === next.toLowerCase())) setTags((current) => [...current, next]);\n setTagDraft(\"\");\n setFieldErrors((current) => ({ ...current, tags: \"\" }));\n };\n\n const save = async (nextStatus?: \"active\" | \"inactive\") => {\n const nextErrors: Record<string, string> = {};\n if (!name.trim()) nextErrors.name = \"Name is required.\";\n if (!description.trim()) nextErrors.description = \"Description is required.\";\n if (tags.length === 0) nextErrors.tags = \"At least one tag is required.\";\n if (!type.trim()) nextErrors.type = \"Tool type is required.\";\n if (!sourceCode.trim()) nextErrors.sourceCode = \"Tool source code is required.\";\n\n setFieldErrors(nextErrors);\n if (Object.keys(nextErrors).length > 0) {\n setActiveTab(nextErrors.sourceCode ? \"tool\" : \"general\");\n dispatch(showToast({ severity: \"error\", summary: \"Missing information\", detail: Object.values(nextErrors).join(\" \") }));\n return;\n }\n const payload = {\n name: name.trim(), iconName: iconName || null, description: description.trim(), type,\n sourceCode, tags: JSON.stringify(tags),\n ...(type === \"custom\" ? { checksum: await sha256Hex(sourceCode) } : {}),\n // Status is required by the agentToolRegistry metadata, including partial\n // updates. Preserve the current lifecycle state for ordinary saves.\n status: nextStatus ?? (record?.status === \"load_failed\" ? \"active\" : record?.status ?? \"active\"),\n ...((nextStatus === \"active\" || (!nextStatus && record?.status === \"load_failed\")) ? { lastLoadError: null } : {}),\n };\n try {\n if (record?.id) {\n await updateTool({ id: record.id, data: payload }).unwrap();\n dispatch(showToast({ severity: \"success\", summary: nextStatus ? \"Tool status updated\" : \"Saved\", detail: nextStatus ? `Tool moved to ${nextStatus}. Restart linked agent processes to apply the change.` : \"Tool updated successfully.\" }));\n setAuditRefreshVersion((version) => version + 1);\n refetch();\n } else {\n const result: any = await createTool(payload).unwrap();\n const createdId = result?.data?.id ?? result?.id;\n dispatch(showToast({ severity: \"success\", summary: \"Created\", detail: \"Tool created successfully.\" }));\n if (createdId) navigate(`/admin/core/solid-core/agent-tool-registry/editor/${createdId}`, { replace: true });\n }\n } catch (error: any) {\n const errorDetail = getSaveErrorMessage(error);\n const serverFieldErrors: Record<string, string> = {};\n if (/required|not be empty|cannot be empty|should not be empty/i.test(errorDetail)) {\n for (const field of [\"name\", \"description\", \"tags\", \"type\", \"sourceCode\"]) {\n if (!new RegExp(`\\\\b${field}\\\\b`, \"i\").test(errorDetail)) continue;\n const label = field === \"sourceCode\" ? \"Tool source code\" : field[0].toUpperCase() + field.slice(1);\n serverFieldErrors[field] = `${label} is required.`;\n }\n }\n if (Object.keys(serverFieldErrors).length > 0) {\n setFieldErrors(serverFieldErrors);\n setActiveTab(serverFieldErrors.sourceCode ? \"tool\" : \"general\");\n }\n dispatch(showToast({ severity: \"error\", summary: \"Save failed\", detail: errorDetail }));\n }\n };\n\n const agents = React.useMemo(() => {\n const relatedTools = record?.agentTools;\n const links = Array.isArray(relatedTools) ? relatedTools : relatedTools ? [relatedTools] : [];\n const seen = new Set<string>();\n return links.map((link) => link.agentRegistry).filter((agent): agent is Agent => Boolean(agent && typeof agent === \"object\"))\n .filter((agent) => {\n const key = String(agent.id ?? agent.name ?? agent.title ?? \"\");\n if (!key || seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n }, [record?.agentTools]);\n const sessionAgents = React.useMemo(() => agents.filter((agent): agent is Agent & { id: number | string } => agent.id !== undefined && agent.id !== null), [agents]);\n const tabs = [\n { value: \"general\", label: \"General Info\", content: <fieldset className=\"agent-tool-editor__general\" disabled={isReadOnly}>\n {isReadOnly && <p className=\"agent-tool-editor__readonly-note\">SolidX tools are seeded by the AgentHub runtime and cannot be edited.</p>}\n {record?.status && <section className={`agent-tool-editor__runtime-status${record.status === \"load_failed\" ? \" agent-tool-editor__runtime-status--failed\" : \"\"}`} role={record.status === \"load_failed\" ? \"alert\" : \"status\"}>\n <div className=\"agent-tool-editor__runtime-heading\"><strong>Runtime status</strong><span>{record.status.replace(/[_-]+/g, \" \")}</span></div>\n {record.status === \"load_failed\" ? <>\n <p>The AgentHub runtime could not load this tool. After correcting its source or checksum, restart linked agent processes so the runtime retries loading it.</p>\n {record.lastLoadError && <pre>{record.lastLoadError}</pre>}\n </> : <p>{record.lastLoadError || \"No tool load error has been reported.\"}</p>}\n </section>}\n <div className=\"agent-tool-editor__fields\">\n <label className=\"agent-tool-editor__field\"><span>Name <b>*</b></span><SolidInput value={name} aria-invalid={Boolean(fieldErrors.name)} aria-describedby={fieldErrors.name ? \"agent-tool-name-error\" : undefined} className={fieldErrors.name ? \"agent-tool-editor__input--invalid\" : undefined} onChange={(e) => { setName(e.target.value); setFieldErrors((current) => ({ ...current, name: \"\" })); }} />{fieldErrors.name && <small id=\"agent-tool-name-error\" className=\"agent-tool-editor__field-error\">{fieldErrors.name}</small>}</label>\n <div className=\"agent-tool-editor__field\"><span>Icon</span><SolidIconPicker value={iconName} onChange={setIconName} /></div>\n <label className=\"agent-tool-editor__field\"><span>Description <b>*</b></span><SolidInput value={description} aria-invalid={Boolean(fieldErrors.description)} aria-describedby={fieldErrors.description ? \"agent-tool-description-error\" : undefined} className={fieldErrors.description ? \"agent-tool-editor__input--invalid\" : undefined} onChange={(e) => { setDescription(e.target.value); setFieldErrors((current) => ({ ...current, description: \"\" })); }} />{fieldErrors.description && <small id=\"agent-tool-description-error\" className=\"agent-tool-editor__field-error\">{fieldErrors.description}</small>}</label>\n </div>\n <label className=\"agent-tool-editor__field\"><span>Tool type <b>*</b></span><select value={type} aria-invalid={Boolean(fieldErrors.type)} aria-describedby={fieldErrors.type ? \"agent-tool-type-error\" : undefined} className={fieldErrors.type ? \"agent-tool-editor__input--invalid\" : undefined} onChange={(e) => { setType(e.target.value); setFieldErrors((current) => ({ ...current, type: \"\" })); }}>\n {isReadOnly && <option value=\"solidx\">SolidX</option>}<option value=\"thirdparty\">Third Party</option><option value=\"custom\">Custom</option>\n </select>{fieldErrors.type && <small id=\"agent-tool-type-error\" className=\"agent-tool-editor__field-error\">{fieldErrors.type}</small>}</label>\n <div className=\"agent-tool-editor__field\"><span>Tags <b>*</b></span><div className={`agent-tool-editor__tag-input${fieldErrors.tags ? \" agent-tool-editor__tag-input--invalid\" : \"\"}`}>\n {tags.map((tag, index) => <span className=\"agent-tool-editor__tag\" key={`${tag}-${index}`}>{tag}<button type=\"button\" aria-label={`Remove ${tag}`} onClick={() => setTags((current) => { const next = current.filter((_, i) => i !== index); if (next.length) setFieldErrors((errors) => ({ ...errors, tags: \"\" })); return next; })}><X size={13} /></button></span>)}\n <input value={tagDraft} aria-label=\"Add a tag\" placeholder=\"Type a tag and press Enter\" onChange={(e) => setTagDraft(e.target.value)} onKeyDown={(e) => { if (e.key === \"Enter\") { e.preventDefault(); addTag(); } }} />\n <SolidButton type=\"button\" variant=\"secondary\" size=\"small\" onClick={addTag}><Plus size={14} /> Add</SolidButton>\n </div>{fieldErrors.tags && <small className=\"agent-tool-editor__field-error\">{fieldErrors.tags}</small>}<small>Tags are saved as a JSON array.</small></div>\n {record?.id && <section className=\"agent-tool-editor__workflow\" aria-labelledby=\"agent-tool-lifecycle-title\">\n <div className=\"agent-tool-editor__workflow-head\"><div><h2 id=\"agent-tool-lifecycle-title\">Tool lifecycle</h2><p>Activate or deactivate this tool for linked agents. Load failures are reported by AgentHub.</p></div></div>\n <div className=\"agent-tool-editor__workflow-stages\" aria-label={`Current tool stage: ${(record.status ?? \"active\").replace(/[_-]+/g, \" \")}`}>\n {([ [\"active\", \"Active\", \"Enabled for loading into linked agents.\"], [\"inactive\", \"Inactive\", \"Not loaded for linked agents.\"], [\"load_failed\", \"Load failed\", \"AgentHub could not load this tool.\"] ] as const).map(([value, label, description], index) => {\n const currentStatus = record.status ?? \"active\";\n const isCurrent = currentStatus === value;\n const canRetry = value === \"load_failed\" && isCurrent;\n const disabled = isCreating || isSaving || (!canRetry && (value === \"load_failed\" || isCurrent));\n return <React.Fragment key={value}>\n {index > 0 && <div className=\"agent-tool-editor__workflow-connector\" aria-hidden=\"true\" />}\n <button type=\"button\" className={`agent-tool-editor__workflow-stage agent-tool-editor__workflow-stage--${value}${isCurrent ? \" is-current\" : \"\"}`}\n aria-current={isCurrent ? \"step\" : undefined} aria-pressed={isCurrent} disabled={disabled}\n onClick={() => void save(value === \"load_failed\" ? \"active\" : value)}>\n <span className=\"agent-tool-editor__workflow-mark\">{index + 1}</span>\n <span className=\"agent-tool-editor__workflow-copy\"><strong>{label}</strong><small>{description}</small><small className=\"agent-tool-editor__workflow-cta\">{canRetry ? \"Click to retry loading\" : isCurrent ? \"Current stage\" : value === \"load_failed\" ? \"Set automatically by AgentHub\" : \"Click to move to this stage\"}</small></span>\n {isCurrent && <span className=\"agent-tool-editor__workflow-current\">Current</span>}\n </button>\n </React.Fragment>;\n })}\n </div>\n {record.status === \"load_failed\" && <small className=\"agent-tool-editor__workflow-hint\">Fix the source or checksum first. Retrying saves the current tool configuration and clears the reported error; restart linked agent processes to load the updated tool.</small>}\n <small className=\"agent-tool-editor__workflow-hint\">Changing stage saves the current tool configuration. Restart linked agent processes to apply the change.</small>\n </section>}\n </fieldset> },\n { value: \"tool\", label: \"Tool\", content: <div className=\"agent-tool-editor__tool\">\n <section className=\"agent-tool-editor__panel\">\n <header><h2>Tool source code <b>*</b></h2><p>Write the tool's Python code here.</p></header>\n <SolidCodeEditor value={sourceCode} onChange={(value) => { setSourceCode(value ?? \"\"); setFieldErrors((current) => ({ ...current, sourceCode: \"\" })); }} language=\"python\" readOnly={isReadOnly} fontSize={11} height=\"max(32rem, calc(100dvh - 18rem))\" className={`agent-tool-editor__code${fieldErrors.sourceCode ? \" agent-tool-editor__code--invalid\" : \"\"}`} />\n {fieldErrors.sourceCode && <small className=\"agent-tool-editor__field-error agent-tool-editor__code-error\">{fieldErrors.sourceCode}</small>}\n </section>\n </div> },\n { value: \"agents\", label: \"Agents\", content: <section className=\"agent-tool-editor__agents\"><div><h2>Associated agents</h2><p>Agents linked to this tool. Associations are read-only here.</p></div>\n {isLoading ? <p>Loading associated agents…</p> : agents.length ? <div className=\"agent-tool-editor__agent-grid\">{agents.map((agent, index) => <div className=\"agent-tool-editor__agent-card\" key={String(agent.id ?? agent.name ?? index)}><SharedAgentRegistryCard rowData={agent} /></div>)}</div> : <div className=\"agent-tool-editor__empty\">No agents are currently associated with this tool.</div>}\n </section> },\n { value: \"sessions\", label: \"Sessions\", content: <AgentToolSessionsPanel agents={sessionAgents} /> },\n ];\n\n return <main className=\"agent-tool-editor\">\n <header className=\"agent-tool-editor__header\"><div><div className=\"agent-tool-editor__heading-with-refresh\"><h1>{record ? \"Edit Tool\" : \"Create Tool\"}</h1>{record?.id && <button type=\"button\" className={`agent-tool-editor__refresh${isFetching ? \" is-loading\" : \"\"}`} aria-label=\"Refresh tool\" title=\"Refresh tool\" disabled={isFetching || isSaving} onClick={requestRefresh}><RefreshCw size={14} /></button>}</div></div><div className=\"agent-tool-editor__actions\">\n <SolidButton variant=\"secondary\" leftIcon={<ArrowLeft size={16} />} onClick={() => navigate(-1)}>Back</SolidButton>\n {!isReadOnly && <SolidButton loading={isCreating || isSaving} onClick={() => void save()}>Save Tool</SolidButton>}\n </div></header>\n <SolidDialog open={confirmRefresh} onOpenChange={setConfirmRefresh} header=\"Discard unsaved changes?\" style={{ width: \"min(28rem, 94vw)\" }}\n footer={<><SolidButton type=\"button\" variant=\"secondary\" onClick={() => setConfirmRefresh(false)}>Cancel</SolidButton><SolidButton type=\"button\" disabled={isFetching} onClick={() => { setConfirmRefresh(false); void refetch(); }}>Refresh and discard</SolidButton></>}>\n <SolidDialogBody><p>You have unsaved changes. Refreshing will discard them and load the latest tool content.</p></SolidDialogBody>\n </SolidDialog>\n {isLoading ? <div className=\"agent-tool-editor__loading\">Loading tool…</div> : record?.id ? (\n <AgentRegistryAuditPanel modelSingularName=\"agentToolRegistry\" recordId={record.id} refreshVersion={auditRefreshVersion} modelUserKey={record.name}>\n <SolidTabGroup tabs={tabs} value={activeTab} onValueChange={setActiveTab} className=\"agent-tool-editor__tabs\" listClassName=\"agent-tool-editor__tab-list\" panelClassName=\"agent-tool-editor__tab-panel\" />\n </AgentRegistryAuditPanel>\n ) : <SolidTabGroup tabs={tabs} value={activeTab} onValueChange={setActiveTab} className=\"agent-tool-editor__tabs\" listClassName=\"agent-tool-editor__tab-list\" panelClassName=\"agent-tool-editor__tab-panel\" />}\n </main>;\n}\n"]}
1
+ {"version":3,"file":"AgentToolRegistryEditorPage.js","sourceRoot":"","sources":["../../../../../src/routes/pages/admin/core/AgentToolRegistryEditorPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,E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,CAAC,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EAAC,CAAC,CAAC,CAC1F,KAAC,uBAAuB,IAAC,iBAAiB,EAAC,mBAAmB,EAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,YAChJ,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAC,yBAAyB,EAAC,aAAa,EAAC,6BAA6B,EAAC,cAAc,EAAC,8BAA8B,GAAG,GAClL,CAC3B,CAAC,CAAC,CAAC,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAC,yBAAyB,EAAC,aAAa,EAAC,6BAA6B,EAAC,cAAc,EAAC,8BAA8B,GAAG,IACzM,CAAC;AACV,CAAC","sourcesContent":["import React from \"react\";\nimport { ArrowLeft, RefreshCw } from \"lucide-react\";\nimport { useDispatch } from \"react-redux\";\nimport { useNavigate, useParams } from \"react-router-dom\";\nimport { createSolidEntityApi } from \"../../../../redux/api/solidEntityApi\";\nimport { showToast } from \"../../../../redux/features/toastSlice\";\nimport { solidPatch } from \"../../../../http/solidHttp\";\nimport { AgentRegistryAuditPanel } from \"./AgentRegistryAuditPanel\";\nimport { AgentHubTagsField, agentHubTagsFrom, agentHubTagsPayload, type AgentHubTag } from \"./AgentHubTagsField\";\nimport { AgentToolActivationDialog } from \"./AgentToolActivationDialog\";\nimport { AgentToolSessionsPanel } from \"../../../../components/core/extension/solid-core/agentToolRegistry/AgentToolSessionsPanel\";\nimport { AgentRegistryCardWidget } from \"../../../../components/core/extension/solid-core/agentRegistry/card/AgentRegistryCardWidget\";\nimport { SolidButton, SolidCodeEditor, SolidDialog, SolidDialogBody, SolidIconPicker, SolidInput, SolidTabGroup } from \"../../../../components/shad-cn-ui\";\nimport \"./AgentToolRegistryEditorPage.css\";\n\nconst SharedAgentRegistryCard = AgentRegistryCardWidget as React.ComponentType<{ rowData: Record<string, any> }>;\n\ntype Agent = { id?: number | string; name?: string; title?: string; [key: string]: any };\ntype AgentToolLink = { agentRegistry?: Agent | number | string | null };\ntype ToolRecord = {\n id: number;\n name?: string;\n iconName?: string | null;\n description?: string;\n tags?: AgentHubTag[];\n type?: string;\n status?: string | null;\n lastLoadError?: string | null;\n sourceCode?: string;\n checksum?: string;\n agentTools?: AgentToolLink[] | AgentToolLink | null;\n};\n\nfunction extractEntityRecord(response: unknown): Record<string, any> | undefined {\n let candidate: unknown = response;\n for (let depth = 0; depth < 3; depth += 1) {\n if (!candidate || typeof candidate !== \"object\") return undefined;\n const value = candidate as Record<string, unknown>;\n if (\"id\" in value || \"name\" in value) return value;\n candidate = value.data;\n }\n return candidate && typeof candidate === \"object\" ? candidate as Record<string, any> : undefined;\n}\n\nasync function sha256Hex(value: string): Promise<string> {\n const digest = await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction formatErrorMessage(value: unknown): string | undefined {\n if (typeof value === \"string\") return value.trim() || undefined;\n if (Array.isArray(value)) {\n const messages = value.map(formatErrorMessage).filter((message): message is string => Boolean(message));\n return messages.length ? messages.join(\"; \") : undefined;\n }\n if (value && typeof value === \"object\") {\n const error = value as Record<string, unknown>;\n return formatErrorMessage(error.message)\n ?? formatErrorMessage(error.constraints)\n ?? formatErrorMessage(error.error);\n }\n return undefined;\n}\n\nfunction getSaveErrorMessage(error: unknown): string {\n if (!error || typeof error !== \"object\") return \"Failed to save tool.\";\n const apiError = error as Record<string, any>;\n return formatErrorMessage(apiError.data?.data?.message)\n ?? formatErrorMessage(apiError.data?.message)\n ?? formatErrorMessage(apiError.data?.error)\n ?? formatErrorMessage(apiError.message)\n ?? \"Failed to save tool.\";\n}\n\nexport function AgentToolRegistryEditorPage() {\n const { id = \"\" } = useParams<{ id: string }>();\n const navigate = useNavigate();\n const dispatch = useDispatch();\n const entityApi = React.useMemo(() => createSolidEntityApi(\"agentToolRegistry\"), []);\n const { useCreateSolidEntityMutation, useGetSolidEntityByIdQuery, useUpdateSolidEntityMutation } = entityApi;\n const { data: response, isLoading, isFetching, refetch } = useGetSolidEntityByIdQuery(\n { id, qs: \"populate[0]=agentTools&populate[1]=agentTools.agentRegistry&populate[2]=tags\" },\n { skip: !id || id === \"new\" },\n );\n const [createTool, { isLoading: isCreating }] = useCreateSolidEntityMutation();\n const [updateTool, { isLoading: isSaving }] = useUpdateSolidEntityMutation();\n const record = extractEntityRecord(response) as ToolRecord | undefined;\n const [activeTab, setActiveTab] = React.useState(\"general\");\n const [name, setName] = React.useState(\"\");\n const [iconName, setIconName] = React.useState(\"\");\n const [description, setDescription] = React.useState(\"\");\n const [type, setType] = React.useState(\"custom\");\n const [sourceCode, setSourceCode] = React.useState(\"\");\n const [tags, setTags] = React.useState<AgentHubTag[]>([]);\n const [creatingTag, setCreatingTag] = React.useState(false);\n const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({});\n const [auditRefreshVersion, setAuditRefreshVersion] = React.useState(0);\n const [confirmRefresh, setConfirmRefresh] = React.useState(false);\n const [activationOpen, setActivationOpen] = React.useState(false);\n const [activationTool, setActivationTool] = React.useState<{ id: number; checksum: string; name: string } | null>(null);\n const preparingActivation = React.useRef(false);\n const baseline = React.useRef(\"\");\n\n const currentForm = () => JSON.stringify({ name, iconName, description, type, sourceCode, tags });\n\n React.useEffect(() => {\n const nextTags = agentHubTagsFrom(record?.tags);\n setName(record?.name ?? \"\");\n setIconName(record?.iconName ?? \"\");\n setDescription(record?.description ?? \"\");\n setType(record?.type ?? \"custom\");\n setSourceCode(record?.sourceCode ?? \"\");\n setTags(nextTags);\n baseline.current = JSON.stringify({ name: record?.name ?? \"\", iconName: record?.iconName ?? \"\", description: record?.description ?? \"\", type: record?.type ?? \"custom\", sourceCode: record?.sourceCode ?? \"\", tags: nextTags });\n }, [record]);\n\n const isReadOnly = record?.type === \"solidx\";\n const isDirty = Boolean(record?.id) && currentForm() !== baseline.current;\n const requestRefresh = () => isDirty ? setConfirmRefresh(true) : void refetch();\n\n const save = async (nextStatus?: \"inactive\") => {\n if (creatingTag) return;\n const nextErrors: Record<string, string> = {};\n if (!name.trim()) nextErrors.name = \"Name is required.\";\n if (!description.trim()) nextErrors.description = \"Description is required.\";\n if (!type.trim()) nextErrors.type = \"Tool type is required.\";\n if (!sourceCode.trim()) nextErrors.sourceCode = \"Tool source code is required.\";\n\n setFieldErrors(nextErrors);\n if (Object.keys(nextErrors).length > 0) {\n setActiveTab(nextErrors.sourceCode ? \"tool\" : \"general\");\n dispatch(showToast({ severity: \"error\", summary: \"Missing information\", detail: Object.values(nextErrors).join(\" \") }));\n return;\n }\n const payload = {\n name: name.trim(), iconName: iconName || null, description: description.trim(), type,\n sourceCode, ...agentHubTagsPayload(tags),\n ...([\"custom\", \"thirdparty\"].includes(type) ? { checksum: await sha256Hex(sourceCode) } : {}),\n status: nextStatus ?? (record && (sourceCode !== record.sourceCode || name.trim() !== record.name || type !== record.type)\n ? \"inactive\" : record?.status ?? \"inactive\"),\n };\n try {\n if (record?.id) {\n const result = await updateTool({ id: record.id, data: payload }).unwrap();\n dispatch(showToast({ severity: \"success\", summary: nextStatus ? \"Tool status updated\" : \"Saved\", detail: nextStatus ? `Tool moved to ${nextStatus}. Restart linked agent processes to apply the change.` : \"Tool updated successfully.\" }));\n setAuditRefreshVersion((version) => version + 1);\n refetch();\n return (extractEntityRecord(result) ?? { ...record, ...payload }) as ToolRecord;\n } else {\n const result: any = await createTool(payload).unwrap();\n const createdId = result?.data?.id ?? result?.id;\n dispatch(showToast({ severity: \"success\", summary: \"Created\", detail: \"Tool created successfully.\" }));\n if (createdId) navigate(`/admin/core/solid-core/agent-tool-registry/editor/${createdId}`, { replace: true });\n }\n } catch (error: any) {\n const errorDetail = getSaveErrorMessage(error);\n const serverFieldErrors: Record<string, string> = {};\n if (/required|not be empty|cannot be empty|should not be empty/i.test(errorDetail)) {\n for (const field of [\"name\", \"description\", \"type\", \"sourceCode\"]) {\n if (!new RegExp(`\\\\b${field}\\\\b`, \"i\").test(errorDetail)) continue;\n const label = field === \"sourceCode\" ? \"Tool source code\" : field[0].toUpperCase() + field.slice(1);\n serverFieldErrors[field] = `${label} is required.`;\n }\n }\n if (Object.keys(serverFieldErrors).length > 0) {\n setFieldErrors(serverFieldErrors);\n setActiveTab(serverFieldErrors.sourceCode ? \"tool\" : \"general\");\n }\n dispatch(showToast({ severity: \"error\", summary: \"Save failed\", detail: errorDetail }));\n }\n };\n\n const beginActivation = async () => {\n if (isReadOnly) return;\n if (!record || activationOpen || isSaving || preparingActivation.current) return;\n preparingActivation.current = true;\n try {\n const saved = isDirty || record.status === \"load_failed\" ? await save(\"inactive\") : record;\n if (!saved?.id) return;\n const checksum = await sha256Hex(saved.sourceCode ?? sourceCode);\n setActivationTool({ id: saved.id, checksum, name: saved.name ?? name });\n setActivationOpen(true);\n } catch {\n dispatch(showToast({ severity: \"error\", summary: \"Activation failed\", detail: \"Could not prepare the saved tool source for checks.\" }));\n } finally {\n preparingActivation.current = false;\n }\n };\n\n const agents = React.useMemo(() => {\n const relatedTools = record?.agentTools;\n const links = Array.isArray(relatedTools) ? relatedTools : relatedTools ? [relatedTools] : [];\n const seen = new Set<string>();\n return links.map((link) => link.agentRegistry).filter((agent): agent is Agent => Boolean(agent && typeof agent === \"object\"))\n .filter((agent) => {\n const key = String(agent.id ?? agent.name ?? agent.title ?? \"\");\n if (!key || seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n }, [record?.agentTools]);\n const sessionAgents = React.useMemo(() => agents.filter((agent): agent is Agent & { id: number | string } => agent.id !== undefined && agent.id !== null), [agents]);\n const tabs = [\n { value: \"general\", label: \"General Info\", content: <fieldset className=\"agent-tool-editor__general\" disabled={isReadOnly}>\n {isReadOnly && <p className=\"agent-tool-editor__readonly-note\">SolidX tools are seeded by the AgentHub runtime and cannot be edited.</p>}\n {record?.status && <section className={`agent-tool-editor__runtime-status${record.status === \"load_failed\" ? \" agent-tool-editor__runtime-status--failed\" : \"\"}`} role={record.status === \"load_failed\" ? \"alert\" : \"status\"}>\n <div className=\"agent-tool-editor__runtime-heading\"><strong>Runtime status</strong><span>{record.status.replace(/[_-]+/g, \" \")}</span></div>\n {record.status === \"load_failed\" ? <>\n <p>The AgentHub runtime could not load this tool. After correcting its source or checksum, restart linked agent processes so the runtime retries loading it.</p>\n {record.lastLoadError && <pre>{record.lastLoadError}</pre>}\n </> : <p>{record.lastLoadError || \"No tool load error has been reported.\"}</p>}\n </section>}\n <div className=\"agent-tool-editor__fields\">\n <label className=\"agent-tool-editor__field\"><span>Name <b>*</b></span><SolidInput value={name} aria-invalid={Boolean(fieldErrors.name)} aria-describedby={fieldErrors.name ? \"agent-tool-name-error\" : undefined} className={fieldErrors.name ? \"agent-tool-editor__input--invalid\" : undefined} onChange={(e) => { setName(e.target.value); setFieldErrors((current) => ({ ...current, name: \"\" })); }} />{fieldErrors.name && <small id=\"agent-tool-name-error\" className=\"agent-tool-editor__field-error\">{fieldErrors.name}</small>}</label>\n <div className=\"agent-tool-editor__field\"><span>Icon</span><SolidIconPicker value={iconName} onChange={setIconName} /></div>\n <label className=\"agent-tool-editor__field\"><span>Description <b>*</b></span><SolidInput value={description} aria-invalid={Boolean(fieldErrors.description)} aria-describedby={fieldErrors.description ? \"agent-tool-description-error\" : undefined} className={fieldErrors.description ? \"agent-tool-editor__input--invalid\" : undefined} onChange={(e) => { setDescription(e.target.value); setFieldErrors((current) => ({ ...current, description: \"\" })); }} />{fieldErrors.description && <small id=\"agent-tool-description-error\" className=\"agent-tool-editor__field-error\">{fieldErrors.description}</small>}</label>\n </div>\n {!record?.id && <label className=\"agent-tool-editor__field\"><span>Tool status</span><select value=\"inactive\" disabled aria-label=\"Tool status\"><option value=\"inactive\">Inactive</option></select><small>New tools start inactive. Run configuration and initialization checks to activate.</small></label>}\n <label className=\"agent-tool-editor__field\"><span>Tool type <b>*</b></span><select value={type} aria-invalid={Boolean(fieldErrors.type)} aria-describedby={fieldErrors.type ? \"agent-tool-type-error\" : undefined} className={fieldErrors.type ? \"agent-tool-editor__input--invalid\" : undefined} onChange={(e) => { setType(e.target.value); setFieldErrors((current) => ({ ...current, type: \"\" })); }}>\n {isReadOnly && <option value=\"solidx\">SolidX</option>}<option value=\"thirdparty\">Third Party</option><option value=\"custom\">Custom</option>\n </select>{fieldErrors.type && <small id=\"agent-tool-type-error\" className=\"agent-tool-editor__field-error\">{fieldErrors.type}</small>}</label>\n <AgentHubTagsField value={tags} onChange={setTags} disabled={isReadOnly || isCreating || isSaving} onBusyChange={setCreatingTag} />\n {record?.id && <section className=\"agent-tool-editor__workflow\" aria-labelledby=\"agent-tool-lifecycle-title\">\n <div className=\"agent-tool-editor__workflow-head\"><div><h2 id=\"agent-tool-lifecycle-title\">Tool lifecycle</h2><p>Configuration and initialization must pass before this tool can be activated.</p></div></div>\n <div className=\"agent-tool-editor__workflow-stages\" aria-label={`Current tool stage: ${(record.status ?? \"inactive\").replace(/[_-]+/g, \" \")}`}>\n {([ [\"active\", \"Active\", \"Enabled for loading into linked agents.\"], [\"inactive\", \"Inactive\", \"Not loaded for linked agents.\"], [\"load_failed\", \"Load failed\", \"AgentHub could not load this tool.\"] ] as const).map(([value, label, description], index) => {\n const currentStatus = record.status ?? \"inactive\";\n const isCurrent = currentStatus === value;\n const canRetry = value === \"load_failed\" && isCurrent;\n const disabled = isReadOnly || activationOpen || isCreating || isSaving || (!canRetry && (value === \"load_failed\" || isCurrent));\n return <React.Fragment key={value}>\n {index > 0 && <div className=\"agent-tool-editor__workflow-connector\" aria-hidden=\"true\" />}\n <button type=\"button\" className={`agent-tool-editor__workflow-stage agent-tool-editor__workflow-stage--${value}${isCurrent ? \" is-current\" : \"\"}`}\n aria-current={isCurrent ? \"step\" : undefined} aria-pressed={isCurrent} disabled={disabled}\n onClick={() => value === \"inactive\" ? void save(\"inactive\") : void beginActivation()}>\n <span className=\"agent-tool-editor__workflow-mark\">{index + 1}</span>\n <span className=\"agent-tool-editor__workflow-copy\"><strong>{label}</strong><small>{description}</small><small className=\"agent-tool-editor__workflow-cta\">{canRetry ? \"Run checks and retry activation\" : isCurrent ? \"Current stage\" : value === \"load_failed\" ? \"Set automatically by AgentHub\" : value === \"active\" ? \"Run checks to activate\" : \"Click to deactivate\"}</small></span>\n {isCurrent && <span className=\"agent-tool-editor__workflow-current\">Current</span>}\n </button>\n </React.Fragment>;\n })}\n </div>\n {record.status === \"load_failed\" && <small className=\"agent-tool-editor__workflow-hint\">Fix the source or checksum, then run configuration and initialization checks before retrying activation.</small>}\n <small className=\"agent-tool-editor__workflow-hint\">Activation checks use the saved tool configuration. Restart linked agent processes to apply status changes.</small>\n </section>}\n </fieldset> },\n { value: \"tool\", label: \"Tool\", content: <div className=\"agent-tool-editor__tool\">\n <section className=\"agent-tool-editor__panel\">\n <header><h2>Tool source code <b>*</b></h2><p>Write the tool's Python code here.</p></header>\n <SolidCodeEditor value={sourceCode} onChange={(value) => { setSourceCode(value ?? \"\"); setFieldErrors((current) => ({ ...current, sourceCode: \"\" })); }} language=\"python\" readOnly={isReadOnly} fontSize={11} height=\"max(32rem, calc(100dvh - 18rem))\" className={`agent-tool-editor__code${fieldErrors.sourceCode ? \" agent-tool-editor__code--invalid\" : \"\"}`} />\n {fieldErrors.sourceCode && <small className=\"agent-tool-editor__field-error agent-tool-editor__code-error\">{fieldErrors.sourceCode}</small>}\n </section>\n </div> },\n { value: \"agents\", label: \"Agents\", content: <section className=\"agent-tool-editor__agents\"><div><h2>Associated agents</h2><p>Agents linked to this tool. Associations are read-only here.</p></div>\n {isLoading ? <p>Loading associated agents…</p> : agents.length ? <div className=\"agent-tool-editor__agent-grid\">{agents.map((agent, index) => <div className=\"agent-tool-editor__agent-card\" key={String(agent.id ?? agent.name ?? index)}><SharedAgentRegistryCard rowData={agent} /></div>)}</div> : <div className=\"agent-tool-editor__empty\">No agents are currently associated with this tool.</div>}\n </section> },\n { value: \"sessions\", label: \"Sessions\", content: <AgentToolSessionsPanel agents={sessionAgents} /> },\n ];\n\n return <main className=\"agent-tool-editor\">\n <header className=\"agent-tool-editor__header\"><div><div className=\"agent-tool-editor__heading-with-refresh\"><h1>{record ? \"Edit Tool\" : \"Create Tool\"}</h1>{record?.id && <button type=\"button\" className={`agent-tool-editor__refresh${isFetching ? \" is-loading\" : \"\"}`} aria-label=\"Refresh tool\" title=\"Refresh tool\" disabled={isFetching || isSaving} onClick={requestRefresh}><RefreshCw size={14} /></button>}</div></div><div className=\"agent-tool-editor__actions\">\n <SolidButton variant=\"secondary\" leftIcon={<ArrowLeft size={16} />} onClick={() => navigate(-1)}>Back</SolidButton>\n {!isReadOnly && <SolidButton disabled={activationOpen || creatingTag} loading={isCreating || isSaving} onClick={() => void save()}>Save Tool</SolidButton>}\n </div></header>\n <SolidDialog open={confirmRefresh} onOpenChange={setConfirmRefresh} header=\"Discard unsaved changes?\" style={{ width: \"min(28rem, 94vw)\" }}\n footer={<><SolidButton type=\"button\" variant=\"secondary\" onClick={() => setConfirmRefresh(false)}>Cancel</SolidButton><SolidButton type=\"button\" disabled={isFetching} onClick={() => { setConfirmRefresh(false); void refetch(); }}>Refresh and discard</SolidButton></>}>\n <SolidDialogBody><p>You have unsaved changes. Refreshing will discard them and load the latest tool content.</p></SolidDialogBody>\n </SolidDialog>\n {activationOpen && activationTool && <AgentToolActivationDialog open={activationOpen} onOpenChange={setActivationOpen}\n toolId={activationTool.id} checksum={activationTool.checksum} toolName={activationTool.name}\n onActivated={async () => {\n await solidPatch(`/agent-tool-registry/${activationTool.id}`, { status: \"active\", checksum: activationTool.checksum });\n setAuditRefreshVersion((version) => version + 1);\n void refetch();\n dispatch(showToast({ severity: \"success\", summary: \"Tool activated\", detail: \"Configuration and initialization checks passed.\" }));\n }} />}\n {isLoading ? <div className=\"agent-tool-editor__loading\">Loading tool…</div> : record?.id ? (\n <AgentRegistryAuditPanel modelSingularName=\"agentToolRegistry\" recordId={record.id} refreshVersion={auditRefreshVersion} modelUserKey={record.name}>\n <SolidTabGroup tabs={tabs} value={activeTab} onValueChange={setActiveTab} className=\"agent-tool-editor__tabs\" listClassName=\"agent-tool-editor__tab-list\" panelClassName=\"agent-tool-editor__tab-panel\" />\n </AgentRegistryAuditPanel>\n ) : <SolidTabGroup tabs={tabs} value={activeTab} onValueChange={setActiveTab} className=\"agent-tool-editor__tabs\" listClassName=\"agent-tool-editor__tab-list\" panelClassName=\"agent-tool-editor__tab-panel\" />}\n </main>;\n}\n"]}