@solidxai/core 0.1.21 → 0.1.22-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.
- package/CHANGELOG.md +18 -0
- package/dist/decorators/settings-provider.decorator.d.ts +2 -1
- package/dist/decorators/settings-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/settings-provider.decorator.js +3 -2
- package/dist/decorators/settings-provider.decorator.js.map +1 -1
- package/dist/dtos/create-agent-user-memory.dto.d.ts +1 -1
- package/dist/dtos/create-agent-user-memory.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-user-memory.dto.js +2 -2
- package/dist/dtos/create-agent-user-memory.dto.js.map +1 -1
- package/dist/dtos/update-agent-user-memory.dto.d.ts +1 -1
- package/dist/dtos/update-agent-user-memory.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-user-memory.dto.js +2 -2
- package/dist/dtos/update-agent-user-memory.dto.js.map +1 -1
- package/dist/entities/agent-user-memory.entity.d.ts +1 -1
- package/dist/entities/agent-user-memory.entity.d.ts.map +1 -1
- package/dist/entities/agent-user-memory.entity.js +2 -2
- package/dist/entities/agent-user-memory.entity.js.map +1 -1
- package/dist/helpers/setting-key.helper.d.ts +6 -0
- package/dist/helpers/setting-key.helper.d.ts.map +1 -0
- package/dist/helpers/setting-key.helper.js +28 -0
- package/dist/helpers/setting-key.helper.js.map +1 -0
- package/dist/helpers/setting-key.helper.spec.d.ts +2 -0
- package/dist/helpers/setting-key.helper.spec.d.ts.map +1 -0
- package/dist/helpers/setting-key.helper.spec.js +37 -0
- package/dist/helpers/setting-key.helper.spec.js.map +1 -0
- package/dist/resources/agent-embed/solid-agent-embed.js +42 -19
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +13 -1
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +2 -180
- package/dist/services/agent-tool-registry.service.js +5 -5
- package/dist/services/agent-tool-registry.service.js.map +1 -1
- package/dist/services/mail/smtp-email.service.d.ts.map +1 -1
- package/dist/services/mail/smtp-email.service.js +2 -6
- package/dist/services/mail/smtp-email.service.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +4 -2
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/setting.service.d.ts +1 -1
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +25 -8
- package/dist/services/setting.service.js.map +1 -1
- package/dist/services/setting.service.spec.d.ts +2 -0
- package/dist/services/setting.service.spec.d.ts.map +1 -0
- package/dist/services/setting.service.spec.js +110 -0
- package/dist/services/setting.service.spec.js.map +1 -0
- package/dist/services/settings/default-settings-provider.service.d.ts +146 -6
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +81 -4
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/subscribers/agent-tool-registry.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-tool-registry.subscriber.js +16 -11
- package/dist/subscribers/agent-tool-registry.subscriber.js.map +1 -1
- package/package.json +1 -1
- package/plan.md +480 -0
- package/resources/agent-embed/solid-agent-embed.js +42 -19
- package/src/decorators/settings-provider.decorator.ts +6 -3
- package/src/dtos/create-agent-user-memory.dto.ts +1 -1
- package/src/dtos/update-agent-user-memory.dto.ts +1 -1
- package/src/entities/agent-user-memory.entity.ts +2 -2
- package/src/helpers/setting-key.helper.spec.ts +32 -0
- package/src/helpers/setting-key.helper.ts +30 -0
- package/src/seeders/module-metadata-seeder.service.ts +12 -1
- package/src/seeders/seed-data/solid-core-metadata.json +2 -180
- package/src/services/agent-tool-registry.service.ts +5 -5
- package/src/services/mail/smtp-email.service.ts +3 -6
- package/src/services/model-metadata.service.ts +5 -2
- package/src/services/setting.service.spec.ts +117 -0
- package/src/services/setting.service.ts +29 -9
- package/src/services/settings/default-settings-provider.service.ts +81 -4
- package/src/subscribers/agent-tool-registry.subscriber.ts +16 -9
- package/src/services/1.js +0 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* SolidX AgentHub Embed SDK
|
|
1
|
+
/* SolidX AgentHub Embed SDK v5. 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
4
|
*/
|
|
5
5
|
(function (global) {
|
|
6
6
|
"use strict";
|
|
7
|
-
if (global.SolidAgentEmbed && global.SolidAgentEmbed.version >=
|
|
7
|
+
if (global.SolidAgentEmbed && global.SolidAgentEmbed.version >= 5) return;
|
|
8
8
|
var channel = "solidx-agent-embed";
|
|
9
9
|
var publicProtocolVersion = 2;
|
|
10
10
|
var maxContextBytes = 32 * 1024;
|
|
@@ -18,14 +18,19 @@
|
|
|
18
18
|
var inline = mode === "inline";
|
|
19
19
|
var container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
|
|
20
20
|
if (!container || !container.appendChild) throw new Error("Provide an existing container element.");
|
|
21
|
-
|
|
22
|
-
var
|
|
21
|
+
var hasAgentId = options.agentId !== undefined;
|
|
22
|
+
var hasAgentName = options.agentName !== undefined;
|
|
23
|
+
if (hasAgentId === hasAgentName) throw new Error("Provide exactly one of agentId or agentName.");
|
|
24
|
+
if (hasAgentId && (!Number.isSafeInteger(options.agentId) || options.agentId <= 0)) throw new Error("Provide a valid agentId.");
|
|
25
|
+
if (hasAgentName && (typeof options.agentName !== "string" || !options.agentName.trim())) throw new Error("Provide a valid agentName.");
|
|
26
|
+
var resolvedAgentId = hasAgentId ? options.agentId : null;
|
|
27
|
+
var embedUrl = new URL("/embed/agent/" + (resolvedAgentId || ""), hostedUiOrigin);
|
|
23
28
|
var endpoint = new URL(options.tokenEndpoint, location.href);
|
|
24
29
|
if (!/^https?:$/.test(embedUrl.protocol) || !/^https?:$/.test(endpoint.protocol)) throw new Error("Use HTTP or HTTPS URLs.");
|
|
25
30
|
if (embedUrl.username || embedUrl.password || endpoint.username || endpoint.password) throw new Error("Credentials cannot be placed in URLs.");
|
|
26
31
|
if (location.protocol === "https:" && (embedUrl.protocol !== "https:" || endpoint.protocol !== "https:")) throw new Error("Use HTTPS URLs on HTTPS pages.");
|
|
27
32
|
var id = crypto.randomUUID();
|
|
28
|
-
debug(id, "mount", { agentId: options.
|
|
33
|
+
debug(id, "mount", { agentId: resolvedAgentId, agentName: options.agentName, hostedUiOrigin: hostedUiOrigin, iframePath: embedUrl.pathname,
|
|
29
34
|
tokenEndpointOrigin: endpoint.origin, tokenEndpointPath: endpoint.pathname, pageOrigin: location.origin });
|
|
30
35
|
embedUrl.searchParams.set("parentOrigin", location.origin);
|
|
31
36
|
embedUrl.searchParams.set("instanceId", id);
|
|
@@ -33,7 +38,7 @@
|
|
|
33
38
|
var destroyed = false, initialized = false, locked = false, open = false, windowMode = "popup", ready = false, tokenFlight = null;
|
|
34
39
|
var pending = new Map();
|
|
35
40
|
var listeners = new Map(), beforeSendListeners = [], contextSnapshots = new Map(), listenerOrder = 0, eventSequence = 0;
|
|
36
|
-
var controller = null, loadTimer = null;
|
|
41
|
+
var controller = null, loadTimer = null, bootstrapAuth = null;
|
|
37
42
|
var launcherHost = null, button = null;
|
|
38
43
|
if (!inline) {
|
|
39
44
|
launcherHost = document.createElement("span");
|
|
@@ -123,7 +128,7 @@
|
|
|
123
128
|
return Object.keys(value).every(function (key) { return isJsonValue(value[key], depth + 1); });
|
|
124
129
|
}
|
|
125
130
|
function emit(event, payload) {
|
|
126
|
-
var notification = Object.assign({ protocolVersion: publicProtocolVersion, instanceId: id, agentId:
|
|
131
|
+
var notification = Object.assign({ protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId,
|
|
127
132
|
eventId: crypto.randomUUID(), sequence: ++eventSequence, occurredAt: new Date().toISOString() }, payload || {});
|
|
128
133
|
(listeners.get(event) || []).slice().forEach(function (entry) {
|
|
129
134
|
try { entry.listener(notification); } catch (error) { debug(id, "public listener failed", { event: event, message: error && error.message }); }
|
|
@@ -246,18 +251,23 @@
|
|
|
246
251
|
var extraHeaders = typeof options.getTokenHeaders === "function" ? options.getTokenHeaders() : (options.tokenHeaders || {});
|
|
247
252
|
debug(id, "sending token exchange", { hasAuthorizationHeader: !!(extraHeaders && extraHeaders.Authorization) });
|
|
248
253
|
return fetch(endpoint.href, { method: "POST", credentials: "same-origin", cache: "no-store", signal: controller.signal,
|
|
249
|
-
headers: Object.assign({ "Content-Type": "application/json" }, extraHeaders),
|
|
254
|
+
headers: Object.assign({ "Content-Type": "application/json" }, extraHeaders),
|
|
255
|
+
body: JSON.stringify(hasAgentName ? { agentName: options.agentName } : { agentId: options.agentId }) });
|
|
250
256
|
}).then(function (response) {
|
|
251
257
|
debug(id, "token endpoint response", { status: response.status, ok: response.ok, contentType: response.headers.get("content-type") });
|
|
252
258
|
if (!response.ok) throw new Error("Chat authentication failed (HTTP " + response.status + ").");
|
|
253
259
|
return response.json();
|
|
254
260
|
}).then(function (auth) {
|
|
255
|
-
var valid = !!auth && auth.embed === true && auth.agentId
|
|
261
|
+
var valid = !!auth && auth.embed === true && Number.isSafeInteger(auth.agentId) && auth.agentId > 0
|
|
262
|
+
&& (!hasAgentId || auth.agentId === options.agentId) && !!auth.agentToken && !!auth.wsUrl && !!auth.httpUrl && Array.isArray(auth.requiredInputs);
|
|
256
263
|
debug(id, "token response validated", { valid: valid, embed: !!auth && auth.embed === true,
|
|
257
|
-
agentIdMatches: !!auth && auth.agentId === options.agentId, hasAgentToken: !!auth && !!auth.agentToken,
|
|
264
|
+
agentIdMatches: !!auth && (!hasAgentId || auth.agentId === options.agentId), hasAgentToken: !!auth && !!auth.agentToken,
|
|
258
265
|
hasWsUrl: !!auth && !!auth.wsUrl, hasHttpUrl: !!auth && !!auth.httpUrl,
|
|
259
266
|
requiredInputsIsArray: !!auth && Array.isArray(auth.requiredInputs) });
|
|
260
267
|
if (!valid) throw new Error("The token endpoint returned an invalid embed response.");
|
|
268
|
+
if (resolvedAgentId && resolvedAgentId !== auth.agentId) throw new Error("The token endpoint resolved a different agent.");
|
|
269
|
+
resolvedAgentId = auth.agentId;
|
|
270
|
+
embedUrl.pathname = "/embed/agent/" + resolvedAgentId;
|
|
261
271
|
return auth;
|
|
262
272
|
}).catch(function (error) {
|
|
263
273
|
debug(id, "token exchange failed", { name: error && error.name, message: error && error.message });
|
|
@@ -283,7 +293,7 @@
|
|
|
283
293
|
if (missing.length) { emitError(new Error("This hosted chat needs an upgrade. Missing capabilities: " + missing.join(", "))); return; }
|
|
284
294
|
ready = true;
|
|
285
295
|
clearTimeout(loadTimer);
|
|
286
|
-
emit("onReady", { protocolVersion: publicProtocolVersion, instanceId: id, agentId:
|
|
296
|
+
emit("onReady", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId, capabilities: frameCapabilities });
|
|
287
297
|
debug(id, "iframe ready", { protocolVersion: publicProtocolVersion, capabilities: frameCapabilities });
|
|
288
298
|
}
|
|
289
299
|
else if (data.type === "close") hide();
|
|
@@ -298,7 +308,11 @@
|
|
|
298
308
|
if (command) { clearTimeout(command.timer); pending.delete(data.requestId); data.ok ? command.resolve(data.result) : command.reject(new Error(data.error || "Embed command failed.")); }
|
|
299
309
|
}
|
|
300
310
|
else if (data.type === "token_request") {
|
|
301
|
-
|
|
311
|
+
(bootstrapAuth ? Promise.resolve(bootstrapAuth) : fetchToken()).then(function (auth) {
|
|
312
|
+
bootstrapAuth = null;
|
|
313
|
+
debug(id, "sending token bootstrap to iframe", { requestId: data.requestId, inputsCount: Object.keys(inputs).length });
|
|
314
|
+
post("token", { requestId: data.requestId, auth: auth, inputs: inputs });
|
|
315
|
+
})
|
|
302
316
|
.catch(function (error) { post("token_error", { requestId: data.requestId, error: error.message }); emitError(error); });
|
|
303
317
|
} else if (data.type === "authenticated") { emitRecovered(); emit("onAuthenticationStateChanged", { state: "authenticated" }); }
|
|
304
318
|
else if (data.type === "error") { emit("onAuthenticationStateChanged", { state: "failed", code: "embed_error" }); emitError(new Error(data.error)); }
|
|
@@ -310,15 +324,24 @@
|
|
|
310
324
|
}
|
|
311
325
|
function show() {
|
|
312
326
|
if (destroyed) throw new Error("This embed was destroyed.");
|
|
313
|
-
if (open) return;
|
|
327
|
+
if (open && initialized) return;
|
|
328
|
+
var wasOpen = open;
|
|
314
329
|
open = true;
|
|
315
|
-
emit("onPanelVisibilityChanged", { visible: true, reason: "open" });
|
|
330
|
+
if (!wasOpen) emit("onPanelVisibilityChanged", { visible: true, reason: "open" });
|
|
316
331
|
surfaceHost.style.display = "block";
|
|
317
332
|
if (button) button.setAttribute("aria-expanded", "true");
|
|
318
333
|
position();
|
|
319
334
|
if (!initialized) {
|
|
320
|
-
initialized = true;
|
|
321
|
-
|
|
335
|
+
initialized = true;
|
|
336
|
+
var openFrame = function () {
|
|
337
|
+
if (destroyed) return;
|
|
338
|
+
debug(id, "opening hosted iframe", { iframeUrl: embedUrl.href }); frame.src = embedUrl.href; panel.appendChild(frame);
|
|
339
|
+
loadTimer = setTimeout(function () { if (!ready) emitError(new Error("The hosted chat did not load. Check its URL and framing policy.")); }, 20000);
|
|
340
|
+
};
|
|
341
|
+
if (hasAgentName) {
|
|
342
|
+
fetchToken().then(function (auth) { bootstrapAuth = auth; openFrame(); })
|
|
343
|
+
.catch(function (error) { initialized = false; emitError(error); });
|
|
344
|
+
} else openFrame();
|
|
322
345
|
}
|
|
323
346
|
if (!inline) closeButton.focus();
|
|
324
347
|
}
|
|
@@ -404,7 +427,7 @@
|
|
|
404
427
|
}
|
|
405
428
|
catch (error) { return Promise.reject(error); }
|
|
406
429
|
contextSnapshots.set(namespace, JSON.parse(JSON.stringify(contribution)));
|
|
407
|
-
emit("onContextChanged", { protocolVersion: publicProtocolVersion, instanceId: id, agentId:
|
|
430
|
+
emit("onContextChanged", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId, namespace: namespace, revision: revision, displaySummary: displaySummary });
|
|
408
431
|
return sendCommand("setContext", { namespace: namespace, contribution: contribution });
|
|
409
432
|
},
|
|
410
433
|
sendMessage: function (message) {
|
|
@@ -433,7 +456,7 @@
|
|
|
433
456
|
},
|
|
434
457
|
destroy: function () {
|
|
435
458
|
if (destroyed) return;
|
|
436
|
-
emit("onDestroyed", { protocolVersion: publicProtocolVersion, instanceId: id, agentId:
|
|
459
|
+
emit("onDestroyed", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId,
|
|
437
460
|
eventId: crypto.randomUUID(), sequence: ++eventSequence, occurredAt: new Date().toISOString() });
|
|
438
461
|
destroyed = true;
|
|
439
462
|
clearTimeout(loadTimer);
|
|
@@ -452,5 +475,5 @@
|
|
|
452
475
|
}
|
|
453
476
|
};
|
|
454
477
|
}
|
|
455
|
-
global.SolidAgentEmbed = { version:
|
|
478
|
+
global.SolidAgentEmbed = { version: 5, mount: mount };
|
|
456
479
|
})(window);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { SetMetadata } from "@nestjs/common";
|
|
1
|
+
import { applyDecorators, SetMetadata } from "@nestjs/common";
|
|
2
2
|
|
|
3
3
|
export const IS_SETTINGS_PROVIDER = 'IS_SETTINGS_PROVIDER';
|
|
4
|
+
export const SETTINGS_PROVIDER_NAMESPACE = 'SETTINGS_PROVIDER_NAMESPACE';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export const SettingsProvider = (namespace?: string) => applyDecorators(
|
|
7
|
+
SetMetadata(IS_SETTINGS_PROVIDER, true),
|
|
8
|
+
SetMetadata(SETTINGS_PROVIDER_NAMESPACE, namespace),
|
|
9
|
+
);
|
|
7
10
|
|
|
@@ -6,5 +6,5 @@ export class CreateAgentUserMemoryDto {
|
|
|
6
6
|
@IsNotEmpty() @IsInt() @ApiProperty() agentId: number;
|
|
7
7
|
@IsNotEmpty() @IsString() @ApiProperty() memory: string;
|
|
8
8
|
@IsNotEmpty() @IsIn(['explicit', 'implicit']) @ApiProperty({ enum: ['explicit', 'implicit'] }) type: 'explicit' | 'implicit';
|
|
9
|
-
@IsOptional() @IsInt() @ApiProperty({ required: false }) sessionId?: number;
|
|
9
|
+
@IsOptional() @IsInt() @ApiProperty({ required: false, nullable: true }) sessionId?: number | null;
|
|
10
10
|
}
|
|
@@ -7,5 +7,5 @@ export class UpdateAgentUserMemoryDto {
|
|
|
7
7
|
@IsOptional() @IsInt() @ApiProperty({ required: false }) agentId?: number;
|
|
8
8
|
@IsOptional() @IsString() @ApiProperty({ required: false }) memory?: string;
|
|
9
9
|
@IsOptional() @IsIn(['explicit', 'implicit']) @ApiProperty({ enum: ['explicit', 'implicit'], required: false }) type?: 'explicit' | 'implicit';
|
|
10
|
-
@IsOptional() @IsInt() @ApiProperty({ required: false }) sessionId?: number;
|
|
10
|
+
@IsOptional() @IsInt() @ApiProperty({ required: false, nullable: true }) sessionId?: number | null;
|
|
11
11
|
}
|
|
@@ -20,7 +20,7 @@ export class AgentUserMemory extends CommonEntity {
|
|
|
20
20
|
@Column({ type: 'varchar' })
|
|
21
21
|
type: 'explicit' | 'implicit';
|
|
22
22
|
|
|
23
|
-
@ManyToOne(() => AgentSession, { onDelete: 'SET NULL', nullable:
|
|
23
|
+
@ManyToOne(() => AgentSession, { onDelete: 'SET NULL', nullable: true })
|
|
24
24
|
@JoinColumn()
|
|
25
|
-
session: AgentSession;
|
|
25
|
+
session: AgentSession | null;
|
|
26
26
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { SETTINGS_PROVIDER_NAMESPACE, SettingsProvider } from '../decorators/settings-provider.decorator';
|
|
3
|
+
import {
|
|
4
|
+
buildSettingKey,
|
|
5
|
+
validateLocalSettingKey,
|
|
6
|
+
validateSettingNamespace,
|
|
7
|
+
} from './setting-key.helper';
|
|
8
|
+
|
|
9
|
+
describe('setting key helpers', () => {
|
|
10
|
+
it('builds a canonical setting key', () => {
|
|
11
|
+
expect(buildSettingKey('acme-payments', 'clientID')).toBe('acme-payments:clientID');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('rejects invalid namespaces', () => {
|
|
15
|
+
expect(() => validateSettingNamespace('Acme Payments')).toThrow('Invalid settings provider namespace');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('rejects the namespace separator in a local key', () => {
|
|
19
|
+
expect(() => validateLocalSettingKey('acme:clientID')).toThrow('must not contain ":"');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('keeps the provider namespace optional', () => {
|
|
23
|
+
@SettingsProvider()
|
|
24
|
+
class LegacyProvider { }
|
|
25
|
+
|
|
26
|
+
@SettingsProvider('acme-payments')
|
|
27
|
+
class NamespacedProvider { }
|
|
28
|
+
|
|
29
|
+
expect(Reflect.getMetadata(SETTINGS_PROVIDER_NAMESPACE, LegacyProvider)).toBeUndefined();
|
|
30
|
+
expect(Reflect.getMetadata(SETTINGS_PROVIDER_NAMESPACE, NamespacedProvider)).toBe('acme-payments');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const SETTINGS_KEY_SEPARATOR = ':';
|
|
2
|
+
|
|
3
|
+
export const SETTINGS_NAMESPACE_PATTERN = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)*$/;
|
|
4
|
+
|
|
5
|
+
export function validateSettingNamespace(namespace: string): void {
|
|
6
|
+
if (!SETTINGS_NAMESPACE_PATTERN.test(namespace)) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
`Invalid settings provider namespace "${namespace}". ` +
|
|
9
|
+
'Use lowercase letters, digits, hyphens, and optional dot-separated segments.',
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function validateLocalSettingKey(localKey: string): void {
|
|
15
|
+
if (!localKey?.trim()) {
|
|
16
|
+
throw new Error('A namespaced setting must have a non-empty local key.');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (localKey.includes(SETTINGS_KEY_SEPARATOR)) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Local setting key "${localKey}" must not contain "${SETTINGS_KEY_SEPARATOR}".`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function buildSettingKey(namespace: string, localKey: string): string {
|
|
27
|
+
validateSettingNamespace(namespace);
|
|
28
|
+
validateLocalSettingKey(localKey);
|
|
29
|
+
return `${namespace}${SETTINGS_KEY_SEPARATOR}${localKey}`;
|
|
30
|
+
}
|
|
@@ -316,7 +316,10 @@ export class ModuleMetadataSeederService {
|
|
|
316
316
|
console.log(`${this.formatSeedResult(moduleMetadata.name, 'Secrets', secretCounts)}`);
|
|
317
317
|
|
|
318
318
|
currentStep = 'seedAgentHubRegistries';
|
|
319
|
-
|
|
319
|
+
let agentHubCounts = { pruned: 0, upserted: 0 };
|
|
320
|
+
if (process.env.AGENT_HUB_ENABLED === 'true') {
|
|
321
|
+
agentHubCounts = await this.timeOperation('seed-agenthub-registries', () => this.seedAgentHubRegistries(overallMetadata), { moduleName: moduleMetadata.name, component: 'agenthub-registries' });
|
|
322
|
+
}
|
|
320
323
|
console.log(`${this.formatSeedResult(moduleMetadata.name, 'AgentHub Registries', agentHubCounts)}`);
|
|
321
324
|
|
|
322
325
|
currentStep = 'seedActions';
|
|
@@ -944,6 +947,14 @@ export class ModuleMetadataSeederService {
|
|
|
944
947
|
const recordModule = await this.getAgentHubSeedModule(record, defaultModule);
|
|
945
948
|
const existing = await repo.findOne({ where: { name: record.name }, relations: { module: true, tags: true }, withDeleted: true });
|
|
946
949
|
const { tags: tagNames = [], moduleUserKey, ...data } = record;
|
|
950
|
+
const toolSourcePath = path.resolve(process.cwd(), 'src', recordModule.name, 'agent-hub', 'tools', `${record.name}.py`);
|
|
951
|
+
try {
|
|
952
|
+
data.sourceCode = await fs.promises.readFile(toolSourcePath, 'utf8');
|
|
953
|
+
} catch (error: any) {
|
|
954
|
+
if (error?.code !== 'ENOENT' || typeof data.sourceCode !== 'string') {
|
|
955
|
+
throw new Error(`Tool source file not found or unreadable for ${record.name}: ${toolSourcePath}`);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
947
958
|
const tags = await this.getAgentHubSeedTags(tagNames, record.name);
|
|
948
959
|
if (existing) {
|
|
949
960
|
if (typeof data.sourceCode === 'string' && !data.checksum) {
|