@solidxai/core 0.1.22-beta.3 → 0.1.22-beta.4
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 +27 -0
- package/dist/constants/error-messages.d.ts +1 -1
- package/dist/constants/error-messages.d.ts.map +1 -1
- package/dist/constants/error-messages.js +1 -1
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/controllers/agent-registry.controller.d.ts +8 -0
- package/dist/controllers/agent-registry.controller.d.ts.map +1 -1
- package/dist/controllers/agent-registry.controller.js +14 -0
- package/dist/controllers/agent-registry.controller.js.map +1 -1
- package/dist/controllers/agent-session.controller.d.ts +8 -1
- package/dist/controllers/agent-session.controller.d.ts.map +1 -1
- package/dist/controllers/agent-session.controller.js +66 -2
- package/dist/controllers/agent-session.controller.js.map +1 -1
- package/dist/controllers/test-data.controller.d.ts +12 -0
- package/dist/controllers/test-data.controller.d.ts.map +1 -0
- package/dist/controllers/test-data.controller.js +66 -0
- package/dist/controllers/test-data.controller.js.map +1 -0
- package/dist/controllers/test-data.controller.spec.d.ts +2 -0
- package/dist/controllers/test-data.controller.spec.d.ts.map +1 -0
- package/dist/controllers/test-data.controller.spec.js +78 -0
- package/dist/controllers/test-data.controller.spec.js.map +1 -0
- package/dist/dtos/create-agent-job.dto.d.ts +1 -0
- package/dist/dtos/create-agent-job.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-job.dto.js +8 -1
- package/dist/dtos/create-agent-job.dto.js.map +1 -1
- package/dist/dtos/create-agent-process.dto.d.ts +5 -0
- package/dist/dtos/create-agent-process.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-process.dto.js +37 -1
- package/dist/dtos/create-agent-process.dto.js.map +1 -1
- package/dist/dtos/create-agent-registry.dto.d.ts +5 -0
- package/dist/dtos/create-agent-registry.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-registry.dto.js +39 -1
- package/dist/dtos/create-agent-registry.dto.js.map +1 -1
- package/dist/dtos/create-agent-session.dto.js +1 -1
- package/dist/dtos/create-agent-session.dto.js.map +1 -1
- package/dist/dtos/test-run-request.dto.d.ts +1 -0
- package/dist/dtos/test-run-request.dto.d.ts.map +1 -1
- package/dist/dtos/test-run-request.dto.js +7 -1
- package/dist/dtos/test-run-request.dto.js.map +1 -1
- package/dist/dtos/update-agent-deployment.dto.d.ts +8 -0
- package/dist/dtos/update-agent-deployment.dto.d.ts.map +1 -0
- package/dist/dtos/update-agent-deployment.dto.js +60 -0
- package/dist/dtos/update-agent-deployment.dto.js.map +1 -0
- package/dist/dtos/update-agent-job.dto.d.ts +1 -0
- package/dist/dtos/update-agent-job.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-job.dto.js +8 -1
- package/dist/dtos/update-agent-job.dto.js.map +1 -1
- package/dist/dtos/update-agent-process.dto.d.ts +5 -0
- package/dist/dtos/update-agent-process.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-process.dto.js +37 -1
- package/dist/dtos/update-agent-process.dto.js.map +1 -1
- package/dist/dtos/update-agent-registry.dto.d.ts +5 -0
- package/dist/dtos/update-agent-registry.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-registry.dto.js +39 -1
- package/dist/dtos/update-agent-registry.dto.js.map +1 -1
- package/dist/dtos/update-agent-session.dto.js +1 -1
- package/dist/dtos/update-agent-session.dto.js.map +1 -1
- package/dist/entities/agent-job.entity.d.ts +1 -0
- package/dist/entities/agent-job.entity.d.ts.map +1 -1
- package/dist/entities/agent-job.entity.js +7 -2
- package/dist/entities/agent-job.entity.js.map +1 -1
- package/dist/entities/agent-process.entity.d.ts +8 -0
- package/dist/entities/agent-process.entity.d.ts.map +1 -1
- package/dist/entities/agent-process.entity.js +38 -1
- package/dist/entities/agent-process.entity.js.map +1 -1
- package/dist/entities/agent-registry.entity.d.ts +5 -0
- package/dist/entities/agent-registry.entity.d.ts.map +1 -1
- package/dist/entities/agent-registry.entity.js +22 -1
- package/dist/entities/agent-registry.entity.js.map +1 -1
- package/dist/entities/agent-session.entity.d.ts.map +1 -1
- package/dist/entities/agent-session.entity.js +3 -1
- package/dist/entities/agent-session.entity.js.map +1 -1
- package/dist/helpers/agent-config-version-name.d.ts +2 -0
- package/dist/helpers/agent-config-version-name.d.ts.map +1 -0
- package/dist/helpers/agent-config-version-name.js +17 -0
- package/dist/helpers/agent-config-version-name.js.map +1 -0
- package/dist/helpers/agent-config-version-name.spec.d.ts +2 -0
- package/dist/helpers/agent-config-version-name.spec.d.ts.map +1 -0
- package/dist/helpers/agent-config-version-name.spec.js +31 -0
- package/dist/helpers/agent-config-version-name.spec.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js +8 -4
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js.map +1 -1
- package/dist/resources/agent-embed/solid-agent-embed.js +243 -4
- package/dist/seeders/module-test-data.service.d.ts +19 -0
- package/dist/seeders/module-test-data.service.d.ts.map +1 -1
- package/dist/seeders/module-test-data.service.js +95 -15
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/seeders/module-test-data.service.spec.d.ts +2 -0
- package/dist/seeders/module-test-data.service.spec.d.ts.map +1 -0
- package/dist/seeders/module-test-data.service.spec.js +158 -0
- package/dist/seeders/module-test-data.service.spec.js.map +1 -0
- package/dist/seeders/seed-data/solid-core-metadata.json +278 -11
- package/dist/services/agent-hub-process-manager.service.d.ts +4 -0
- package/dist/services/agent-hub-process-manager.service.d.ts.map +1 -1
- package/dist/services/agent-hub-process-manager.service.js +19 -3
- package/dist/services/agent-hub-process-manager.service.js.map +1 -1
- package/dist/services/agent-registry.service.d.ts +8 -0
- package/dist/services/agent-registry.service.d.ts.map +1 -1
- package/dist/services/agent-registry.service.js +32 -1
- package/dist/services/agent-registry.service.js.map +1 -1
- package/dist/services/crud.service.d.ts +1 -0
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js +26 -2
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +12 -2
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +7 -1
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +3 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/testing/adapters/ui/browser-provisioner.d.ts +11 -0
- package/dist/testing/adapters/ui/browser-provisioner.d.ts.map +1 -1
- package/dist/testing/adapters/ui/browser-provisioner.js +51 -1
- package/dist/testing/adapters/ui/browser-provisioner.js.map +1 -1
- package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts +2 -0
- package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts.map +1 -0
- package/dist/testing/adapters/ui/browser-provisioner.spec.js +137 -0
- package/dist/testing/adapters/ui/browser-provisioner.spec.js.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +7 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.js +37 -8
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
- package/dist/testing/adapters/ui/run-video.d.ts +40 -0
- package/dist/testing/adapters/ui/run-video.d.ts.map +1 -0
- package/dist/testing/adapters/ui/run-video.js +113 -0
- package/dist/testing/adapters/ui/run-video.js.map +1 -0
- package/dist/testing/adapters/ui/run-video.spec.d.ts +2 -0
- package/dist/testing/adapters/ui/run-video.spec.d.ts.map +1 -0
- package/dist/testing/adapters/ui/run-video.spec.js +62 -0
- package/dist/testing/adapters/ui/run-video.spec.js.map +1 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts +1 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -1
- package/dist/testing/contracts/testing-metadata.types.js.map +1 -1
- package/dist/testing/core/testing-engine.d.ts +1 -1
- package/dist/testing/core/testing-engine.d.ts.map +1 -1
- package/dist/testing/core/testing-engine.js +22 -4
- package/dist/testing/core/testing-engine.js.map +1 -1
- package/dist/testing/reporter/lifecycle-events.types.d.ts +1 -1
- package/dist/testing/reporter/lifecycle-events.types.d.ts.map +1 -1
- package/dist/testing/reporter/lifecycle-events.types.js.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.js +2 -0
- package/dist/testing/reporter/lifecycle-webhook-reporter.js.map +1 -1
- package/dist/testing/runner/read-scenarios-file.d.ts +1 -0
- package/dist/testing/runner/read-scenarios-file.d.ts.map +1 -1
- package/dist/testing/runner/read-scenarios-file.js +20 -0
- package/dist/testing/runner/read-scenarios-file.js.map +1 -1
- package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
- package/dist/testing/runner/run-from-metadata.js +9 -1
- package/dist/testing/runner/run-from-metadata.js.map +1 -1
- package/dist/testing/runner/run-from-metadata.spec.js +12 -1
- package/dist/testing/runner/run-from-metadata.spec.js.map +1 -1
- package/package.json +1 -1
- package/resources/agent-embed/solid-agent-embed.js +243 -4
- package/src/constants/error-messages.ts +2 -1
- package/src/controllers/agent-registry.controller.ts +8 -1
- package/src/controllers/agent-session.controller.ts +37 -2
- package/src/controllers/test-data.controller.spec.ts +94 -0
- package/src/controllers/test-data.controller.ts +58 -0
- package/src/dtos/create-agent-job.dto.ts +6 -0
- package/src/dtos/create-agent-process.dto.ts +32 -1
- package/src/dtos/create-agent-registry.dto.ts +34 -1
- package/src/dtos/create-agent-session.dto.ts +1 -1
- package/src/dtos/test-run-request.dto.ts +6 -0
- package/src/dtos/update-agent-deployment.dto.ts +37 -0
- package/src/dtos/update-agent-job.dto.ts +6 -0
- package/src/dtos/update-agent-process.dto.ts +32 -1
- package/src/dtos/update-agent-registry.dto.ts +34 -1
- package/src/dtos/update-agent-session.dto.ts +1 -1
- package/src/entities/agent-job.entity.ts +5 -1
- package/src/entities/agent-process.entity.ts +28 -0
- package/src/entities/agent-registry.entity.ts +15 -0
- package/src/entities/agent-session.entity.ts +3 -0
- package/src/helpers/agent-config-version-name.spec.ts +35 -0
- package/src/helpers/agent-config-version-name.ts +16 -0
- package/src/index.ts +5 -0
- package/src/jobs/database/test-run-queue-subscriber-database.service.ts +10 -6
- package/src/seeders/module-test-data.service.spec.ts +184 -0
- package/src/seeders/module-test-data.service.ts +136 -20
- package/src/seeders/seed-data/solid-core-metadata.json +278 -11
- package/src/services/agent-hub-process-manager.service.ts +25 -4
- package/src/services/agent-registry.service.ts +35 -2
- package/src/services/crud.service.ts +30 -2
- package/src/services/settings/default-settings-provider.service.ts +11 -1
- package/src/solid-core.module.ts +3 -0
- package/src/testing/adapters/ui/browser-provisioner.spec.ts +131 -0
- package/src/testing/adapters/ui/browser-provisioner.ts +85 -2
- package/src/testing/adapters/ui/playwright-adapter.ts +48 -10
- package/src/testing/adapters/ui/run-video.spec.ts +72 -0
- package/src/testing/adapters/ui/run-video.ts +122 -0
- package/src/testing/contracts/testing-metadata.types.ts +5 -0
- package/src/testing/core/testing-engine.ts +28 -5
- package/src/testing/reporter/lifecycle-events.types.ts +2 -1
- package/src/testing/reporter/lifecycle-webhook-reporter.ts +1 -0
- package/src/testing/runner/read-scenarios-file.ts +24 -0
- package/src/testing/runner/run-from-metadata.spec.ts +15 -1
- package/src/testing/runner/run-from-metadata.ts +13 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* SolidX AgentHub Embed SDK
|
|
1
|
+
/* SolidX AgentHub Embed SDK v7. No dependencies; credentials stay in memory.
|
|
2
2
|
* mode: "popup" (default) owns its launcher and floating window.
|
|
3
3
|
* mode: "inline" fills the supplied container; the host owns its layout.
|
|
4
|
+
* mountWorkspace owns the host layout around an inline chat.
|
|
4
5
|
*/
|
|
5
6
|
(function (global) {
|
|
6
7
|
"use strict";
|
|
7
|
-
if (global.SolidAgentEmbed && global.SolidAgentEmbed.version >=
|
|
8
|
+
if (global.SolidAgentEmbed && global.SolidAgentEmbed.version >= 7) return;
|
|
8
9
|
var channel = "solidx-agent-embed";
|
|
9
10
|
var publicProtocolVersion = 2;
|
|
10
11
|
var maxContextBytes = 32 * 1024;
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
embedUrl.searchParams.set("parentOrigin", location.origin);
|
|
36
37
|
embedUrl.searchParams.set("instanceId", id);
|
|
37
38
|
var inputs = JSON.parse(JSON.stringify(options.inputs || {}));
|
|
39
|
+
var workspaceState = options.workspace || null;
|
|
38
40
|
var destroyed = false, initialized = false, locked = false, open = false, windowMode = "popup", ready = false, tokenFlight = null;
|
|
39
41
|
var pending = new Map();
|
|
40
42
|
var listeners = new Map(), beforeSendListeners = [], contextSnapshots = new Map(), listenerOrder = 0, eventSequence = 0;
|
|
@@ -292,11 +294,15 @@
|
|
|
292
294
|
var missing = (options.requiredCapabilities || []).filter(function (name) { return !frameCapabilities.includes(name); });
|
|
293
295
|
if (missing.length) { emitError(new Error("This hosted chat needs an upgrade. Missing capabilities: " + missing.join(", "))); return; }
|
|
294
296
|
ready = true;
|
|
297
|
+
if (workspaceState) post("workspace_state", { workspace: workspaceState });
|
|
295
298
|
clearTimeout(loadTimer);
|
|
296
299
|
emit("onReady", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId, capabilities: frameCapabilities });
|
|
297
300
|
debug(id, "iframe ready", { protocolVersion: publicProtocolVersion, capabilities: frameCapabilities });
|
|
298
301
|
}
|
|
299
302
|
else if (data.type === "close") hide();
|
|
303
|
+
else if (data.type === "workspace_request" && inline && typeof data.action === "string") {
|
|
304
|
+
emit("onWorkspaceActionRequested", { action: data.action, agentName: data.agentName });
|
|
305
|
+
}
|
|
300
306
|
else if (data.type === "before_send_request") runBeforeSend(data);
|
|
301
307
|
else if (data.type === "public_event" && data.protocolVersion === publicProtocolVersion
|
|
302
308
|
&& typeof data.event === "string" && isPlainObject(data.payload) && payloadSize(data.payload) <= 64 * 1024) {
|
|
@@ -312,7 +318,7 @@
|
|
|
312
318
|
bootstrapAuth = null;
|
|
313
319
|
debug(id, "sending token bootstrap to iframe", { requestId: data.requestId, inputsCount: Object.keys(inputs).length });
|
|
314
320
|
var agentName = hasAgentName ? options.agentName.trim() : (typeof auth.agentName === "string" ? auth.agentName.trim() : undefined);
|
|
315
|
-
post("token", { requestId: data.requestId, auth: auth, inputs: inputs, agentName: agentName });
|
|
321
|
+
post("token", { requestId: data.requestId, auth: auth, inputs: inputs, agentName: agentName, workspace: workspaceState });
|
|
316
322
|
})
|
|
317
323
|
.catch(function (error) { post("token_error", { requestId: data.requestId, error: error.message }); emitError(error); });
|
|
318
324
|
} else if (data.type === "authenticated") { emitRecovered(); emit("onAuthenticationStateChanged", { state: "authenticated" }); }
|
|
@@ -431,6 +437,10 @@
|
|
|
431
437
|
emit("onContextChanged", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId, namespace: namespace, revision: revision, displaySummary: displaySummary });
|
|
432
438
|
return sendCommand("setContext", { namespace: namespace, contribution: contribution });
|
|
433
439
|
},
|
|
440
|
+
setWorkspaceState: function (next) {
|
|
441
|
+
workspaceState = next;
|
|
442
|
+
if (ready) post("workspace_state", { workspace: next });
|
|
443
|
+
},
|
|
434
444
|
sendMessage: function (message) {
|
|
435
445
|
if (!isPlainObject(message) || typeof message.text !== "string") return Promise.reject(new Error("sendMessage requires text."));
|
|
436
446
|
return sendCommand("sendMessage", { text: message.text, source: message.source || "sdk" });
|
|
@@ -476,5 +486,234 @@
|
|
|
476
486
|
}
|
|
477
487
|
};
|
|
478
488
|
}
|
|
479
|
-
|
|
489
|
+
function mountWorkspace(options) {
|
|
490
|
+
var container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
|
|
491
|
+
var content = typeof options.content === "string" ? document.querySelector(options.content) : options.content;
|
|
492
|
+
if (!container || !content || content.parentElement !== container) throw new Error("Provide a workspace container and its content element.");
|
|
493
|
+
var agents = options.agents;
|
|
494
|
+
if (!Array.isArray(agents) || !agents.length || !agents.every(function (agent) {
|
|
495
|
+
return agent && typeof agent.name === "string" && agent.name.trim() && typeof agent.title === "string";
|
|
496
|
+
})) throw new Error("Provide at least one named agent.");
|
|
497
|
+
if (typeof options.tokenEndpoint !== "string" || !options.tokenEndpoint) throw new Error("Provide a token endpoint.");
|
|
498
|
+
var agentNames = agents.map(function (agent) { return agent.name; });
|
|
499
|
+
if (new Set(agentNames).size !== agentNames.length) throw new Error("Agent names must be unique.");
|
|
500
|
+
var defaultAgent = agentNames.includes(options.defaultAgentName) ? options.defaultAgentName : agents[0].name;
|
|
501
|
+
var key = typeof options.persistenceKey === "string" ? options.persistenceKey : "";
|
|
502
|
+
var state = { version: 1, open: false, mode: "docked", agentName: defaultAgent,
|
|
503
|
+
width: 420, floatingWidth: 440, floatingHeight: 720, x: 24, y: 80 };
|
|
504
|
+
try {
|
|
505
|
+
var stored = key && JSON.parse(localStorage.getItem(key) || "null");
|
|
506
|
+
if (stored && stored.version === 1) {
|
|
507
|
+
state.open = stored.open === true;
|
|
508
|
+
state.mode = ["docked", "floating", "fullscreen"].includes(stored.mode) ? stored.mode : "docked";
|
|
509
|
+
state.agentName = agentNames.includes(stored.agentName) ? stored.agentName : defaultAgent;
|
|
510
|
+
["width", "floatingWidth", "floatingHeight", "x", "y"].forEach(function (field) {
|
|
511
|
+
if (Number.isFinite(stored[field])) state[field] = stored[field];
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
} catch (_) { /* Storage is optional. */ }
|
|
515
|
+
|
|
516
|
+
var previousContainerStyle = container.style.cssText;
|
|
517
|
+
var previousContentStyle = content.style.cssText;
|
|
518
|
+
var previousChatSpace = document.documentElement.style.getPropertyValue("--agent-chat-space");
|
|
519
|
+
var host = document.createElement("div");
|
|
520
|
+
var launcherHost = document.createElement("div");
|
|
521
|
+
container.appendChild(host);
|
|
522
|
+
document.body.appendChild(launcherHost);
|
|
523
|
+
var root = host.attachShadow({ mode: "open" });
|
|
524
|
+
var launcherRoot = launcherHost.attachShadow({ mode: "open" });
|
|
525
|
+
var css = document.createElement("style");
|
|
526
|
+
css.textContent = ":host{font:13px system-ui;color:#1e293b}*{box-sizing:border-box}button{font:inherit;cursor:pointer}button:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.panel{position:relative;display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:#fff;border-left:1px solid #d8dee8}.floating{border:1px solid #d8dee8;border-radius:12px;box-shadow:0 20px 60px #0004}.chat{flex:1;min-height:0}.drag{display:none;flex:0 0 22px;width:100%;border:0;border-bottom:1px solid #e2e8f0;background:#f8fafc;cursor:grab;touch-action:none}.floating .drag{display:block}.drag:active{cursor:grabbing}.drag:after{display:block;width:36px;height:4px;margin:auto;border-radius:3px;background:#94a3b8;content:''}.dock-resize{position:absolute;z-index:5;top:0;bottom:0;left:0;width:8px;cursor:col-resize;touch-action:none}.float-resize{position:absolute;z-index:5;right:0;bottom:0;width:28px;height:28px;border:0;background:transparent;cursor:nwse-resize;touch-action:none}.float-resize:after{position:absolute;right:6px;bottom:6px;width:10px;height:10px;border-right:2px solid #64748b;border-bottom:2px solid #64748b;content:''}.error{position:absolute;z-index:4;inset:0;overflow:auto;padding:44px 24px 24px;background:#fff}.floating .error{top:22px}.error-inner{max-width:420px;margin:auto}.error-icon{display:grid;width:36px;height:36px;place-items:center;border-radius:11px;background:#fff1ed;color:#c2412f;font-size:21px;font-weight:700}.eyebrow{margin-top:18px;color:#bd4c3d;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}.error h2{margin:5px 0 8px;font-size:18px;line-height:1.3}.error p{margin:0;color:#64748b;overflow-wrap:anywhere}.recovery{margin-top:30px}.recovery-label{margin-bottom:8px;color:#475569;font-weight:700}.switch{display:flex;align-items:center;gap:10px;width:100%;min-height:40px;padding:0 12px;border:1px solid #d7e1ef;border-radius:10px;background:#fff;color:#23324b;text-align:left;font-weight:600}.switch:hover{background:#f4f7fc}.menu{margin-top:6px;padding:6px;border:1px solid #dce4ef;border-radius:12px;background:#fff;box-shadow:0 14px 40px #0f172a24}.menu-title{padding:7px 9px 9px;color:#64748b;font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase}.option{display:flex;align-items:center;gap:10px;width:100%;min-height:42px;padding:6px 9px;border:0;border-radius:8px;background:transparent;color:#25344d;text-align:left;font-weight:600}.option:hover,.option.selected{background:#eff5ff}.avatar{display:grid;flex:0 0 26px;width:26px;height:26px;place-items:center;border-radius:8px;background:#e8f0ff;color:#2864c6}.option-title{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.close{margin-top:20px;padding:0;border:0;background:none;color:#5277b1;font-weight:600}.close:hover{text-decoration:underline}";
|
|
527
|
+
var panel = document.createElement("div");
|
|
528
|
+
panel.className = "panel";
|
|
529
|
+
panel.setAttribute("role", "region");
|
|
530
|
+
panel.setAttribute("aria-label", "Agent chat");
|
|
531
|
+
var drag = document.createElement("button");
|
|
532
|
+
drag.type = "button"; drag.className = "drag"; drag.setAttribute("aria-label", "Move agent chat");
|
|
533
|
+
drag.title = "Drag or use arrow keys to move chat";
|
|
534
|
+
var chat = document.createElement("div"); chat.className = "chat";
|
|
535
|
+
var dockResize = document.createElement("div"); dockResize.className = "dock-resize";
|
|
536
|
+
dockResize.setAttribute("role", "separator"); dockResize.setAttribute("aria-label", "Resize agent chat");
|
|
537
|
+
var floatResize = document.createElement("button"); floatResize.type = "button";
|
|
538
|
+
floatResize.className = "float-resize"; floatResize.setAttribute("aria-label", "Resize floating agent chat");
|
|
539
|
+
panel.append(drag, chat, dockResize, floatResize); root.append(css, panel);
|
|
540
|
+
var launcherStyle = document.createElement("style");
|
|
541
|
+
launcherStyle.textContent = "button{position:fixed;z-index:2147483000;right:24px;bottom:72px;display:grid;width:56px;height:56px;place-items:center;border:0;border-radius:50%;background:#2563eb;color:#fff;box-shadow:0 10px 30px #2563eb6b;cursor:pointer;font-size:26px}button:focus-visible{outline:2px solid #2563eb;outline-offset:3px}";
|
|
542
|
+
var launcher = document.createElement("button"); launcher.type = "button";
|
|
543
|
+
launcher.setAttribute("aria-label", "Open agent chat"); launcher.textContent = "✧";
|
|
544
|
+
launcherRoot.append(launcherStyle, launcher);
|
|
545
|
+
|
|
546
|
+
var instance = null, disposed = false, error = "", restoreMode = "docked", context = null;
|
|
547
|
+
function clamp(value, min, max) { return Math.min(Math.max(value, min), Math.max(min, max)); }
|
|
548
|
+
function save() { if (key) try { localStorage.setItem(key, JSON.stringify(state)); } catch (_) { /* Storage is optional. */ } }
|
|
549
|
+
function workspaceState() { return { mode: state.mode, agents: agents, selectedAgentName: state.agentName }; }
|
|
550
|
+
function selectedAgent() { return agents.find(function (agent) { return agent.name === state.agentName; }); }
|
|
551
|
+
function showError(message) { error = message; render(); }
|
|
552
|
+
function clearError() { if (error) { error = ""; render(); } }
|
|
553
|
+
function setContext(namespace, snapshot, revision, displaySummary) {
|
|
554
|
+
context = { namespace: namespace, snapshot: snapshot, revision: revision, displaySummary: displaySummary };
|
|
555
|
+
return instance ? instance.setContext(namespace, snapshot, revision, displaySummary) : Promise.resolve();
|
|
556
|
+
}
|
|
557
|
+
function connect() {
|
|
558
|
+
if (disposed || instance) return;
|
|
559
|
+
var agent = selectedAgent();
|
|
560
|
+
instance = mount({ mode: "inline", container: chat, agentName: agent.name, title: agent.title,
|
|
561
|
+
tokenEndpoint: options.tokenEndpoint, getTokenHeaders: options.getTokenHeaders,
|
|
562
|
+
requiredCapabilities: ["inlinePanel", "asyncBeforeSend", "messageContextV1", "publicCommands", "workspaceControlsV1"],
|
|
563
|
+
requiredNamespaces: options.namespace ? [options.namespace] : undefined,
|
|
564
|
+
beforeSendTimeoutMs: 3000, workspace: workspaceState(),
|
|
565
|
+
onClose: function () { if (state.open) close(); },
|
|
566
|
+
onError: function (failure) { showError(failure.message || String(failure)); },
|
|
567
|
+
onRecovered: clearError });
|
|
568
|
+
if (options.namespace && typeof options.beforeSend === "function") instance.on("onBeforeUserMessageSend", options.beforeSend,
|
|
569
|
+
{ namespace: options.namespace, priority: 0, timeoutMs: 3000 });
|
|
570
|
+
instance.on("onAgentNavigationRequested", function (event) { if (typeof options.onNavigationRequested === "function") options.onNavigationRequested(event); });
|
|
571
|
+
instance.on("onWorkspaceActionRequested", function (event) {
|
|
572
|
+
if (event.action === "close") close();
|
|
573
|
+
else if (event.action === "selectAgent") selectAgent(event.agentName);
|
|
574
|
+
else if (["dock", "float", "fullscreen", "restore"].includes(event.action)) changeMode(event.action);
|
|
575
|
+
});
|
|
576
|
+
if (context) instance.setContext(context.namespace, context.snapshot, context.revision, context.displaySummary).catch(function () {});
|
|
577
|
+
if (state.open) instance.open();
|
|
578
|
+
}
|
|
579
|
+
function selectAgent(name) {
|
|
580
|
+
if (!agentNames.includes(name) || name === state.agentName) return;
|
|
581
|
+
if (instance) { instance.destroy(); instance = null; }
|
|
582
|
+
chat.textContent = "";
|
|
583
|
+
state.agentName = name; error = ""; save(); render();
|
|
584
|
+
if (state.open) connect();
|
|
585
|
+
}
|
|
586
|
+
function changeMode(action) {
|
|
587
|
+
if (action === "fullscreen" && state.mode !== "fullscreen") restoreMode = state.mode;
|
|
588
|
+
state.mode = action === "float" ? "floating" : action === "fullscreen" ? "fullscreen"
|
|
589
|
+
: action === "restore" ? restoreMode : "docked";
|
|
590
|
+
save(); render();
|
|
591
|
+
if (instance) instance.setWorkspaceState(workspaceState());
|
|
592
|
+
}
|
|
593
|
+
function open() { state.open = true; save(); render(); connect(); if (instance) instance.open(); }
|
|
594
|
+
function close() { state.open = false; save(); if (instance) instance.close(); render(); }
|
|
595
|
+
function renderError() {
|
|
596
|
+
var previous = panel.querySelector(".error"); if (previous) previous.remove();
|
|
597
|
+
chat.style.visibility = error ? "hidden" : "visible";
|
|
598
|
+
if (!error) return;
|
|
599
|
+
var view = document.createElement("div"); view.className = "error";
|
|
600
|
+
var inner = document.createElement("div"); inner.className = "error-inner";
|
|
601
|
+
var icon = document.createElement("span"); icon.className = "error-icon"; icon.textContent = "!";
|
|
602
|
+
var eyebrow = document.createElement("div"); eyebrow.className = "eyebrow"; eyebrow.textContent = "Agent unavailable";
|
|
603
|
+
var title = document.createElement("h2"); title.textContent = "Couldn’t start " + selectedAgent().title;
|
|
604
|
+
var message = document.createElement("p"); message.setAttribute("role", "alert"); message.textContent = error;
|
|
605
|
+
inner.append(icon, eyebrow, title, message);
|
|
606
|
+
if (agents.length > 1) {
|
|
607
|
+
var recovery = document.createElement("div"); recovery.className = "recovery";
|
|
608
|
+
var label = document.createElement("div"); label.className = "recovery-label"; label.textContent = "Choose another agent";
|
|
609
|
+
var switcher = document.createElement("button"); switcher.type = "button"; switcher.className = "switch";
|
|
610
|
+
switcher.textContent = selectedAgent().title + " ⌄"; switcher.setAttribute("aria-label", "Switch agent");
|
|
611
|
+
switcher.setAttribute("aria-expanded", "false");
|
|
612
|
+
var menu = document.createElement("div"); menu.className = "menu"; menu.style.display = "none";
|
|
613
|
+
menu.setAttribute("role", "menu"); menu.setAttribute("aria-label", "Choose agent");
|
|
614
|
+
var menuTitle = document.createElement("div"); menuTitle.className = "menu-title"; menuTitle.textContent = "Choose an agent";
|
|
615
|
+
menu.appendChild(menuTitle);
|
|
616
|
+
agents.forEach(function (agent) {
|
|
617
|
+
var item = document.createElement("button"); item.type = "button"; item.className = "option";
|
|
618
|
+
if (agent.name === state.agentName) item.classList.add("selected");
|
|
619
|
+
item.setAttribute("role", "menuitemradio"); item.setAttribute("aria-checked", String(agent.name === state.agentName));
|
|
620
|
+
var avatar = document.createElement("span"); avatar.className = "avatar"; avatar.textContent = agent.title.trim().charAt(0).toUpperCase();
|
|
621
|
+
var itemTitle = document.createElement("span"); itemTitle.className = "option-title"; itemTitle.textContent = agent.title;
|
|
622
|
+
item.append(avatar, itemTitle); menu.appendChild(item);
|
|
623
|
+
item.addEventListener("click", function () { selectAgent(agent.name); });
|
|
624
|
+
});
|
|
625
|
+
switcher.addEventListener("click", function () {
|
|
626
|
+
var expanded = menu.style.display === "none";
|
|
627
|
+
menu.style.display = expanded ? "block" : "none"; switcher.setAttribute("aria-expanded", String(expanded));
|
|
628
|
+
});
|
|
629
|
+
recovery.append(label, switcher, menu); inner.appendChild(recovery);
|
|
630
|
+
}
|
|
631
|
+
var closeButton = document.createElement("button"); closeButton.type = "button"; closeButton.className = "close";
|
|
632
|
+
closeButton.textContent = "Close chat"; closeButton.addEventListener("click", close);
|
|
633
|
+
inner.appendChild(closeButton); view.appendChild(inner); panel.appendChild(view);
|
|
634
|
+
}
|
|
635
|
+
function render() {
|
|
636
|
+
if (disposed) return;
|
|
637
|
+
var floating = state.open && state.mode === "floating";
|
|
638
|
+
var fullscreen = state.open && state.mode === "fullscreen";
|
|
639
|
+
var width = clamp(state.width, 280, innerWidth - 320);
|
|
640
|
+
var floatWidth = clamp(state.floatingWidth, 280, innerWidth - 32);
|
|
641
|
+
var floatHeight = clamp(state.floatingHeight, 360, innerHeight - 32);
|
|
642
|
+
var dockWidth = state.open && !floating ? fullscreen ? "100%" : width + "px" : "0px";
|
|
643
|
+
container.style.display = "grid"; container.style.gridTemplateColumns = "minmax(0,1fr) " + dockWidth;
|
|
644
|
+
container.style.width = "100%"; container.style.height = "100dvh"; container.style.overflow = "hidden";
|
|
645
|
+
content.style.minWidth = "0"; content.style.height = "100%"; content.style.overflow = "auto";
|
|
646
|
+
content.style.visibility = fullscreen ? "hidden" : ""; content.style.pointerEvents = fullscreen ? "none" : "";
|
|
647
|
+
document.documentElement.style.setProperty("--agent-chat-space", dockWidth);
|
|
648
|
+
launcher.style.display = state.open ? "none" : "grid";
|
|
649
|
+
host.style.display = state.open ? "block" : "none";
|
|
650
|
+
host.style.width = floating ? floatWidth + "px" : "100%";
|
|
651
|
+
host.style.height = floating ? floatHeight + "px" : "100%";
|
|
652
|
+
host.style.position = floating ? "fixed" : "relative";
|
|
653
|
+
host.style.zIndex = floating ? "2147483000" : "300";
|
|
654
|
+
host.style.left = floating ? clamp(state.x, 0, innerWidth - floatWidth) + "px" : "";
|
|
655
|
+
host.style.top = floating ? clamp(state.y, 0, innerHeight - floatHeight) + "px" : "";
|
|
656
|
+
panel.classList.toggle("floating", floating);
|
|
657
|
+
drag.style.display = floating ? "block" : "none";
|
|
658
|
+
dockResize.style.display = state.open && !floating && !fullscreen ? "block" : "none";
|
|
659
|
+
floatResize.style.display = floating ? "block" : "none";
|
|
660
|
+
renderError();
|
|
661
|
+
}
|
|
662
|
+
function onDrag(event) {
|
|
663
|
+
if (!dragStart) return;
|
|
664
|
+
state.x = clamp(dragStart.x + event.clientX - dragStart.clientX, 0, innerWidth - host.offsetWidth);
|
|
665
|
+
state.y = clamp(dragStart.y + event.clientY - dragStart.clientY, 0, innerHeight - host.offsetHeight);
|
|
666
|
+
render();
|
|
667
|
+
}
|
|
668
|
+
function onResize(event) {
|
|
669
|
+
if (!resizeStart) return;
|
|
670
|
+
if (resizeStart.floating) {
|
|
671
|
+
state.floatingWidth = clamp(resizeStart.width + event.clientX - resizeStart.clientX, 280, innerWidth - state.x - 16);
|
|
672
|
+
state.floatingHeight = clamp(resizeStart.height + event.clientY - resizeStart.clientY, 360, innerHeight - state.y - 16);
|
|
673
|
+
} else state.width = clamp(resizeStart.width + resizeStart.clientX - event.clientX, 280, innerWidth - 320);
|
|
674
|
+
render();
|
|
675
|
+
}
|
|
676
|
+
var dragStart = null, resizeStart = null;
|
|
677
|
+
drag.addEventListener("pointerdown", function (event) {
|
|
678
|
+
dragStart = { clientX: event.clientX, clientY: event.clientY, x: state.x, y: state.y };
|
|
679
|
+
drag.setPointerCapture(event.pointerId);
|
|
680
|
+
});
|
|
681
|
+
drag.addEventListener("pointermove", onDrag);
|
|
682
|
+
drag.addEventListener("pointerup", function () { if (dragStart) save(); dragStart = null; });
|
|
683
|
+
drag.addEventListener("pointercancel", function () { dragStart = null; });
|
|
684
|
+
dockResize.addEventListener("pointerdown", function (event) {
|
|
685
|
+
resizeStart = { clientX: event.clientX, width: state.width, floating: false };
|
|
686
|
+
dockResize.setPointerCapture(event.pointerId);
|
|
687
|
+
});
|
|
688
|
+
floatResize.addEventListener("pointerdown", function (event) {
|
|
689
|
+
resizeStart = { clientX: event.clientX, clientY: event.clientY, width: state.floatingWidth,
|
|
690
|
+
height: state.floatingHeight, floating: true };
|
|
691
|
+
floatResize.setPointerCapture(event.pointerId);
|
|
692
|
+
});
|
|
693
|
+
dockResize.addEventListener("pointermove", onResize); floatResize.addEventListener("pointermove", onResize);
|
|
694
|
+
dockResize.addEventListener("pointerup", function () { if (resizeStart) save(); resizeStart = null; });
|
|
695
|
+
floatResize.addEventListener("pointerup", function () { if (resizeStart) save(); resizeStart = null; });
|
|
696
|
+
dockResize.addEventListener("pointercancel", function () { resizeStart = null; });
|
|
697
|
+
floatResize.addEventListener("pointercancel", function () { resizeStart = null; });
|
|
698
|
+
drag.addEventListener("keydown", function (event) {
|
|
699
|
+
var delta = { ArrowLeft: [-20, 0], ArrowRight: [20, 0], ArrowUp: [0, -20], ArrowDown: [0, 20] }[event.key];
|
|
700
|
+
if (!delta) return; event.preventDefault();
|
|
701
|
+
state.x = clamp(state.x + delta[0], 0, innerWidth - host.offsetWidth);
|
|
702
|
+
state.y = clamp(state.y + delta[1], 0, innerHeight - host.offsetHeight); save(); render();
|
|
703
|
+
});
|
|
704
|
+
launcher.addEventListener("click", open);
|
|
705
|
+
global.addEventListener("resize", render);
|
|
706
|
+
render(); if (state.open) connect();
|
|
707
|
+
return { open: open, close: close, setContext: setContext, destroy: function () {
|
|
708
|
+
if (disposed) return; disposed = true;
|
|
709
|
+
if (instance) instance.destroy();
|
|
710
|
+
global.removeEventListener("resize", render);
|
|
711
|
+
host.remove(); launcherHost.remove();
|
|
712
|
+
container.style.cssText = previousContainerStyle;
|
|
713
|
+
content.style.cssText = previousContentStyle;
|
|
714
|
+
if (previousChatSpace) document.documentElement.style.setProperty("--agent-chat-space", previousChatSpace);
|
|
715
|
+
else document.documentElement.style.removeProperty("--agent-chat-space");
|
|
716
|
+
} };
|
|
717
|
+
}
|
|
718
|
+
global.SolidAgentEmbed = { version: 7, mount: mount, mountWorkspace: mountWorkspace };
|
|
480
719
|
})(window);
|
|
@@ -71,7 +71,8 @@ export const ERROR_MESSAGES = {
|
|
|
71
71
|
// CRUD service errors
|
|
72
72
|
RELATION_TYPE_NOT_SUPPORTED: 'Relation type not supported in CRUD service.',
|
|
73
73
|
NO_SOFT_DELETED_RECORD_FOUND: 'No soft-deleted record found with the given ID.',
|
|
74
|
-
CONFLICTING_RECORD_ON_UNARCHIVE:
|
|
74
|
+
CONFLICTING_RECORD_ON_UNARCHIVE: (conflictDetails = 'the same details') =>
|
|
75
|
+
`A record with ${conflictDetails} already exists. Update or delete the active record before restoring this one.`,
|
|
75
76
|
NO_SOFT_DELETED_RECORDS_FOUND: 'No matching soft-deleted records found.',
|
|
76
77
|
EMPTY_PATH_PARTS: 'Path parts cannot be empty',
|
|
77
78
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Controller, Post, Body, Param, UploadedFiles, UseInterceptors, Put, Get, Query, Delete, Patch } from '@nestjs/common';
|
|
1
|
+
import { Controller, Post, Body, Param, UploadedFiles, UseInterceptors, Put, Get, Query, Delete, Patch, ParseIntPipe } from '@nestjs/common';
|
|
2
2
|
import { AnyFilesInterceptor } from "@nestjs/platform-express";
|
|
3
3
|
import { ApiBearerAuth, ApiQuery, ApiTags } from '@nestjs/swagger';
|
|
4
4
|
import { AgentRegistryService } from '../services/agent-registry.service';
|
|
5
5
|
import { CreateAgentRegistryDto } from '../dtos/create-agent-registry.dto';
|
|
6
6
|
import { UpdateAgentRegistryDto } from '../dtos/update-agent-registry.dto';
|
|
7
7
|
import { ActivateAgentRegistryDto } from '../dtos/activate-agent-registry.dto';
|
|
8
|
+
import { UpdateAgentDeploymentDto } from '../dtos/update-agent-deployment.dto';
|
|
8
9
|
import { ShowSoftDeleted } from '../enums/show-soft-deleted.enum';
|
|
9
10
|
|
|
10
11
|
@ApiTags('Agent Hub')
|
|
@@ -41,6 +42,12 @@ export class AgentRegistryController {
|
|
|
41
42
|
return this.service.update(id, updateDto, files, true);
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
@ApiBearerAuth("jwt")
|
|
46
|
+
@Patch(':id/deployment')
|
|
47
|
+
updateDeployment(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateAgentDeploymentDto) {
|
|
48
|
+
return this.service.updateDeployment(id, dto);
|
|
49
|
+
}
|
|
50
|
+
|
|
44
51
|
@ApiBearerAuth("jwt")
|
|
45
52
|
@Post(':id/activate')
|
|
46
53
|
activate(@Param('id') id: number, @Body() dto: ActivateAgentRegistryDto) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Controller, Post, Body, Param, UploadedFiles, UseInterceptors, Put, Get, Query, Delete, Patch, ParseIntPipe } from '@nestjs/common';
|
|
1
|
+
import { Controller, Post, Body, Param, UploadedFiles, UseInterceptors, Put, Get, Query, Delete, Patch, ParseIntPipe, Headers, UnauthorizedException, Header } from '@nestjs/common';
|
|
2
2
|
import { AnyFilesInterceptor } from "@nestjs/platform-express";
|
|
3
3
|
import { ApiBearerAuth, ApiQuery, ApiTags } from '@nestjs/swagger';
|
|
4
4
|
import { AgentSessionService } from '../services/agent-session.service';
|
|
@@ -7,11 +7,46 @@ import { UpdateAgentSessionDto } from '../dtos/update-agent-session.dto';
|
|
|
7
7
|
import { ShowSoftDeleted } from '../enums/show-soft-deleted.enum';
|
|
8
8
|
import { ActiveUser } from '../decorators/active-user.decorator';
|
|
9
9
|
import { ActiveUserData } from '../interfaces/active-user-data.interface';
|
|
10
|
+
import { AgentHubProcessManagerService } from '../services/agent-hub-process-manager.service';
|
|
10
11
|
|
|
11
12
|
@ApiTags('Agent Hub')
|
|
12
13
|
@Controller('agent-session')
|
|
13
14
|
export class AgentSessionController {
|
|
14
|
-
constructor(private readonly service: AgentSessionService) {}
|
|
15
|
+
constructor(private readonly service: AgentSessionService, private readonly manager: AgentHubProcessManagerService) {}
|
|
16
|
+
|
|
17
|
+
private bearer(authorization?: string) {
|
|
18
|
+
if (!authorization?.startsWith('Bearer ')) throw new UnauthorizedException();
|
|
19
|
+
return authorization;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@ApiBearerAuth('jwt')
|
|
23
|
+
@Get('inbox')
|
|
24
|
+
listInbox(@Headers('authorization') authorization: string, @Query('review') review: string,
|
|
25
|
+
@Query('offset') offset: string) {
|
|
26
|
+
const start = Number(offset);
|
|
27
|
+
return this.manager.listJobSessions(this.bearer(authorization), review === 'true',
|
|
28
|
+
Number.isSafeInteger(start) && start > 0 ? start : 0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ApiBearerAuth('jwt')
|
|
32
|
+
@Get('inbox/:sessionId')
|
|
33
|
+
getInboxRun(@Headers('authorization') authorization: string, @Param('sessionId') sessionId: string) {
|
|
34
|
+
return this.manager.getJobSession(this.bearer(authorization), sessionId);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@ApiBearerAuth('jwt')
|
|
38
|
+
@Header('Cache-Control', 'no-store')
|
|
39
|
+
@Post('inbox/:sessionId/connect')
|
|
40
|
+
connectInboxRun(@Headers('authorization') authorization: string, @Param('sessionId') sessionId: string) {
|
|
41
|
+
return this.manager.connectJobSession(this.bearer(authorization), sessionId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ApiBearerAuth('jwt')
|
|
45
|
+
@Post('inbox/:sessionId/requests/:requestId/answer')
|
|
46
|
+
answerInboxRun(@Headers('authorization') authorization: string, @Param('sessionId') sessionId: string,
|
|
47
|
+
@Param('requestId', ParseIntPipe) requestId: number, @Body() answer: unknown) {
|
|
48
|
+
return this.manager.answerJobSession(this.bearer(authorization), sessionId, requestId, answer);
|
|
49
|
+
}
|
|
15
50
|
|
|
16
51
|
@ApiBearerAuth("jwt")
|
|
17
52
|
@Post()
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { BadRequestException, ConflictException, NotFoundException, UnprocessableEntityException } from '@nestjs/common';
|
|
2
|
+
import { SolidCoreDefaultSettingsProvider } from 'src/services/settings/default-settings-provider.service';
|
|
3
|
+
import { TestDataController } from './test-data.controller';
|
|
4
|
+
|
|
5
|
+
describe('TestDataController', () => {
|
|
6
|
+
const summary = { rolesProcessed: 0, usersProcessed: 0, data: { created: 1, updated: 0, skipped: 0 } };
|
|
7
|
+
let loadTestData: jest.Mock;
|
|
8
|
+
let settings: Record<string, unknown>;
|
|
9
|
+
let controller: TestDataController;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
settings = { testDataEndpointEnabled: true };
|
|
13
|
+
loadTestData = jest.fn(async () => summary);
|
|
14
|
+
const settingService = { getConfigValue: jest.fn((key: string) => settings[key] ?? null) };
|
|
15
|
+
controller = new TestDataController({ loadTestData } as any, settingService as any);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('returns the load summary', async () => {
|
|
19
|
+
const testing = { data: [] };
|
|
20
|
+
await expect(controller.load({ testing })).resolves.toBe(summary);
|
|
21
|
+
expect(loadTestData).toHaveBeenCalledWith(testing);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('responds 404 and loads nothing when the setting is off', async () => {
|
|
25
|
+
settings.testDataEndpointEnabled = false;
|
|
26
|
+
|
|
27
|
+
await expect(controller.load({ testing: {} })).rejects.toBeInstanceOf(NotFoundException);
|
|
28
|
+
expect(loadTestData).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('responds 404 when the setting is not present', async () => {
|
|
32
|
+
delete settings.testDataEndpointEnabled;
|
|
33
|
+
|
|
34
|
+
await expect(controller.load({ testing: {} })).rejects.toBeInstanceOf(NotFoundException);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('responds 400 when the body has no testing object', async () => {
|
|
38
|
+
await expect(controller.load({} as any)).rejects.toBeInstanceOf(BadRequestException);
|
|
39
|
+
await expect(controller.load(undefined as any)).rejects.toBeInstanceOf(BadRequestException);
|
|
40
|
+
expect(loadTestData).not.toHaveBeenCalled();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('responds 409 to a second load while one is running, and accepts a new one afterwards', async () => {
|
|
44
|
+
let finish!: (value: typeof summary) => void;
|
|
45
|
+
loadTestData.mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
|
46
|
+
|
|
47
|
+
const first = controller.load({ testing: { data: [] } });
|
|
48
|
+
await expect(controller.load({ testing: { data: [] } })).rejects.toBeInstanceOf(ConflictException);
|
|
49
|
+
finish(summary);
|
|
50
|
+
await first;
|
|
51
|
+
|
|
52
|
+
await expect(controller.load({ testing: { data: [] } })).resolves.toBe(summary);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('releases the lock when a load fails', async () => {
|
|
56
|
+
loadTestData.mockRejectedValueOnce(new Error('boom'));
|
|
57
|
+
await expect(controller.load({ testing: { data: [] } })).rejects.toBeInstanceOf(UnprocessableEntityException);
|
|
58
|
+
|
|
59
|
+
await expect(controller.load({ testing: { data: [] } })).resolves.toBe(summary);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('responds 422 with the message when the load fails', async () => {
|
|
63
|
+
loadTestData.mockRejectedValueOnce(new Error('Test data relation not found: author.authorCode=A9'));
|
|
64
|
+
|
|
65
|
+
const failure = controller.load({ testing: { data: [] } });
|
|
66
|
+
await expect(failure).rejects.toBeInstanceOf(UnprocessableEntityException);
|
|
67
|
+
await expect(failure).rejects.toThrow('Test data relation not found: author.authorCode=A9');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('testDataEndpointEnabled setting', () => {
|
|
72
|
+
const find = () =>
|
|
73
|
+
new SolidCoreDefaultSettingsProvider().getSettings().find((s: any) => s.key === 'testDataEndpointEnabled') as any;
|
|
74
|
+
const original = process.env.SOLIDX_TEST_DATA_ENDPOINT_ENABLED;
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
if (original === undefined) delete process.env.SOLIDX_TEST_DATA_ENDPOINT_ENABLED;
|
|
77
|
+
else process.env.SOLIDX_TEST_DATA_ENDPOINT_ENABLED = original;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('is on only when SOLIDX_TEST_DATA_ENDPOINT_ENABLED is "true"', () => {
|
|
81
|
+
process.env.SOLIDX_TEST_DATA_ENDPOINT_ENABLED = 'true';
|
|
82
|
+
expect(find().value).toBe(true);
|
|
83
|
+
|
|
84
|
+
process.env.SOLIDX_TEST_DATA_ENDPOINT_ENABLED = 'yes';
|
|
85
|
+
expect(find().value).toBe(false);
|
|
86
|
+
|
|
87
|
+
delete process.env.SOLIDX_TEST_DATA_ENDPOINT_ENABLED;
|
|
88
|
+
expect(find().value).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('is SystemEnv, so the settings screen and settings API never return it', () => {
|
|
92
|
+
expect(find().level).toBe('system-env');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Body,
|
|
4
|
+
ConflictException,
|
|
5
|
+
Controller,
|
|
6
|
+
HttpCode,
|
|
7
|
+
HttpStatus,
|
|
8
|
+
NotFoundException,
|
|
9
|
+
Post,
|
|
10
|
+
UnprocessableEntityException,
|
|
11
|
+
} from '@nestjs/common';
|
|
12
|
+
import { ApiTags } from '@nestjs/swagger';
|
|
13
|
+
|
|
14
|
+
import { ModuleTestDataService, TestDataSpec } from 'src/seeders/module-test-data.service';
|
|
15
|
+
import { SettingService } from 'src/services/setting.service';
|
|
16
|
+
import { SolidCoreSetting } from 'src/services/settings/default-settings-provider.service';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Loads `testing` roles, users and data into this application's database, idempotently.
|
|
20
|
+
* Test Hub calls this before a run so seed data is present for the run. Disabled unless the
|
|
21
|
+
* testDataEndpointEnabled setting is on, which comes from SOLIDX_TEST_DATA_ENDPOINT_ENABLED=true. Uses the default auth guards, so the caller needs
|
|
22
|
+
* a Bearer token or API key whose role has TestDataController.load. One load runs at a time per process: a
|
|
23
|
+
* second request while one is running gets 409, so two loads can never both create the same record.
|
|
24
|
+
*/
|
|
25
|
+
@Controller('test-data')
|
|
26
|
+
@ApiTags('Solid Core')
|
|
27
|
+
export class TestDataController {
|
|
28
|
+
private static loadInProgress = false;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
private readonly moduleTestDataService: ModuleTestDataService,
|
|
32
|
+
private readonly settingService: SettingService,
|
|
33
|
+
) {}
|
|
34
|
+
|
|
35
|
+
@Post('load')
|
|
36
|
+
@HttpCode(HttpStatus.OK)
|
|
37
|
+
async load(@Body() body: { testing?: TestDataSpec }) {
|
|
38
|
+
if (this.settingService.getConfigValue<SolidCoreSetting>('testDataEndpointEnabled') !== true) {
|
|
39
|
+
throw new NotFoundException();
|
|
40
|
+
}
|
|
41
|
+
if (!body || typeof body.testing !== 'object' || body.testing === null) {
|
|
42
|
+
throw new BadRequestException('Request body must contain a "testing" object.');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (TestDataController.loadInProgress) {
|
|
46
|
+
throw new ConflictException('A test data load is already in progress.');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
TestDataController.loadInProgress = true;
|
|
50
|
+
try {
|
|
51
|
+
return await this.moduleTestDataService.loadTestData(body.testing);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
throw new UnprocessableEntityException(error instanceof Error ? error.message : 'Test data load failed.');
|
|
54
|
+
} finally {
|
|
55
|
+
TestDataController.loadInProgress = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -56,6 +56,12 @@ export class CreateAgentJobDto {
|
|
|
56
56
|
@ApiProperty()
|
|
57
57
|
leaseExpiresAt: Date;
|
|
58
58
|
|
|
59
|
+
@IsOptional()
|
|
60
|
+
@Type(() => Date)
|
|
61
|
+
@IsDate()
|
|
62
|
+
@ApiProperty({ required: false, nullable: true, type: Date })
|
|
63
|
+
dispatchedAt?: Date | null;
|
|
64
|
+
|
|
59
65
|
@IsNotEmpty()
|
|
60
66
|
@IsInt()
|
|
61
67
|
@ApiProperty()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiProperty } from '@nestjs/swagger';
|
|
2
2
|
import { IsInt } from 'class-validator';
|
|
3
3
|
import { IsOptional } from 'class-validator';
|
|
4
|
-
import { IsString, IsNotEmpty, IsJSON, IsDate, ValidateNested, IsArray } from 'class-validator';
|
|
4
|
+
import { IsString, IsNotEmpty, IsJSON, IsDate, ValidateNested, IsArray, MaxLength, Min } from 'class-validator';
|
|
5
5
|
import { Type } from 'class-transformer';
|
|
6
6
|
import { UpdateAgentSessionDto } from './update-agent-session.dto';
|
|
7
7
|
|
|
@@ -31,6 +31,37 @@ export class CreateAgentProcessDto {
|
|
|
31
31
|
@ApiProperty()
|
|
32
32
|
pid: number;
|
|
33
33
|
|
|
34
|
+
@IsOptional()
|
|
35
|
+
@IsString()
|
|
36
|
+
@IsNotEmpty()
|
|
37
|
+
@ApiProperty({ required: false, nullable: true, type: String })
|
|
38
|
+
runner?: string | null;
|
|
39
|
+
|
|
40
|
+
@IsOptional()
|
|
41
|
+
@IsString()
|
|
42
|
+
@MaxLength(512)
|
|
43
|
+
@ApiProperty({ required: false, nullable: true, type: String, maxLength: 512 })
|
|
44
|
+
runnerRef?: string | null;
|
|
45
|
+
|
|
46
|
+
@IsOptional()
|
|
47
|
+
@IsString()
|
|
48
|
+
@ApiProperty({ required: false, nullable: true, type: String })
|
|
49
|
+
runtimeVersion?: string | null;
|
|
50
|
+
|
|
51
|
+
@IsOptional()
|
|
52
|
+
@Type(() => Number)
|
|
53
|
+
@IsInt()
|
|
54
|
+
@Min(1)
|
|
55
|
+
@ApiProperty({ required: false, nullable: true, type: Number, minimum: 1 })
|
|
56
|
+
cpu?: number | null;
|
|
57
|
+
|
|
58
|
+
@IsOptional()
|
|
59
|
+
@Type(() => Number)
|
|
60
|
+
@IsInt()
|
|
61
|
+
@Min(1)
|
|
62
|
+
@ApiProperty({ required: false, nullable: true, type: Number, minimum: 1 })
|
|
63
|
+
memory?: number | null;
|
|
64
|
+
|
|
34
65
|
@IsNotEmpty()
|
|
35
66
|
@IsString()
|
|
36
67
|
@ApiProperty()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiProperty } from '@nestjs/swagger';
|
|
2
2
|
import { IsString } from 'class-validator';
|
|
3
|
-
import { IsNotEmpty, IsJSON, IsInt, IsNumber, ValidateNested, IsArray, IsOptional } from 'class-validator';
|
|
3
|
+
import { IsNotEmpty, IsJSON, IsInt, IsNumber, ValidateNested, IsArray, IsOptional, Min, ValidateIf } from 'class-validator';
|
|
4
4
|
import { Type } from 'class-transformer';
|
|
5
5
|
import { UpdateAgentToolDto } from './update-agent-tool.dto';
|
|
6
6
|
import { UpdateAgentSkillDto } from './update-agent-skill.dto';
|
|
@@ -77,6 +77,39 @@ export class CreateAgentRegistryDto {
|
|
|
77
77
|
@ApiProperty({ required: false })
|
|
78
78
|
configVersion?: number;
|
|
79
79
|
|
|
80
|
+
@IsOptional()
|
|
81
|
+
@IsString()
|
|
82
|
+
@IsNotEmpty()
|
|
83
|
+
@ApiProperty({ required: false, nullable: true, type: String })
|
|
84
|
+
runner?: string | null;
|
|
85
|
+
|
|
86
|
+
@ValidateIf((_object, value) => value !== undefined)
|
|
87
|
+
@IsInt()
|
|
88
|
+
@Min(0)
|
|
89
|
+
@ApiProperty({ required: false, minimum: 0 })
|
|
90
|
+
minProcesses?: number;
|
|
91
|
+
|
|
92
|
+
@IsOptional()
|
|
93
|
+
@Type(() => Number)
|
|
94
|
+
@IsInt()
|
|
95
|
+
@Min(1)
|
|
96
|
+
@ApiProperty({ required: false, nullable: true, type: Number, minimum: 1 })
|
|
97
|
+
maxProcesses?: number | null;
|
|
98
|
+
|
|
99
|
+
@IsOptional()
|
|
100
|
+
@Type(() => Number)
|
|
101
|
+
@IsInt()
|
|
102
|
+
@Min(1)
|
|
103
|
+
@ApiProperty({ required: false, nullable: true, type: Number, minimum: 1 })
|
|
104
|
+
processCpu?: number | null;
|
|
105
|
+
|
|
106
|
+
@IsOptional()
|
|
107
|
+
@Type(() => Number)
|
|
108
|
+
@IsInt()
|
|
109
|
+
@Min(1)
|
|
110
|
+
@ApiProperty({ required: false, nullable: true, type: Number, minimum: 1 })
|
|
111
|
+
processMemory?: number | null;
|
|
112
|
+
|
|
80
113
|
@IsOptional()
|
|
81
114
|
@IsInt()
|
|
82
115
|
@ApiProperty({ required: false })
|