@solidxai/core 0.1.21-beta.0 → 0.1.21
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 +74 -0
- package/agenthub-ui-json-seed-audit.md +151 -0
- package/dist/commands/run-tests.command.d.ts +2 -0
- package/dist/commands/run-tests.command.d.ts.map +1 -1
- package/dist/commands/run-tests.command.js +16 -0
- package/dist/commands/run-tests.command.js.map +1 -1
- package/dist/constants/error-messages.js +1 -1
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/controllers/agent-config-version.controller.d.ts +93 -0
- package/dist/controllers/agent-config-version.controller.d.ts.map +1 -0
- package/dist/controllers/agent-config-version.controller.js +211 -0
- package/dist/controllers/agent-config-version.controller.js.map +1 -0
- package/dist/controllers/agent-registry.controller.d.ts +2 -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 +18 -0
- package/dist/controllers/agent-session.controller.d.ts.map +1 -1
- package/dist/controllers/agent-session.controller.js +18 -0
- package/dist/controllers/agent-session.controller.js.map +1 -1
- package/dist/controllers/agent-user-memory.controller.d.ts +16 -0
- package/dist/controllers/agent-user-memory.controller.d.ts.map +1 -0
- package/dist/controllers/agent-user-memory.controller.js +135 -0
- package/dist/controllers/agent-user-memory.controller.js.map +1 -0
- package/dist/dtos/activate-agent-registry.dto.d.ts +5 -0
- package/dist/dtos/activate-agent-registry.dto.d.ts.map +1 -0
- package/dist/dtos/activate-agent-registry.dto.js +34 -0
- package/dist/dtos/activate-agent-registry.dto.js.map +1 -0
- package/dist/dtos/create-agent-config-version.dto.d.ts +8 -0
- package/dist/dtos/create-agent-config-version.dto.d.ts.map +1 -0
- package/dist/dtos/create-agent-config-version.dto.js +50 -0
- package/dist/dtos/create-agent-config-version.dto.js.map +1 -0
- package/dist/dtos/create-agent-user-memory.dto.d.ts +8 -0
- package/dist/dtos/create-agent-user-memory.dto.d.ts.map +1 -0
- package/dist/dtos/create-agent-user-memory.dto.js +52 -0
- package/dist/dtos/create-agent-user-memory.dto.js.map +1 -0
- package/dist/dtos/create-secret.dto.d.ts +2 -0
- package/dist/dtos/create-secret.dto.d.ts.map +1 -1
- package/dist/dtos/create-secret.dto.js +13 -1
- package/dist/dtos/create-secret.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 +6 -1
- package/dist/dtos/test-run-request.dto.js.map +1 -1
- package/dist/dtos/update-agent-config-version.dto.d.ts +9 -0
- package/dist/dtos/update-agent-config-version.dto.d.ts.map +1 -0
- package/dist/dtos/update-agent-config-version.dto.js +58 -0
- package/dist/dtos/update-agent-config-version.dto.js.map +1 -0
- package/dist/dtos/update-agent-user-memory.dto.d.ts +9 -0
- package/dist/dtos/update-agent-user-memory.dto.d.ts.map +1 -0
- package/dist/dtos/update-agent-user-memory.dto.js +58 -0
- package/dist/dtos/update-agent-user-memory.dto.js.map +1 -0
- package/dist/dtos/update-secret.dto.d.ts +2 -0
- package/dist/dtos/update-secret.dto.d.ts.map +1 -1
- package/dist/dtos/update-secret.dto.js +13 -1
- package/dist/dtos/update-secret.dto.js.map +1 -1
- package/dist/entities/agent-config-version.entity.d.ts +9 -0
- package/dist/entities/agent-config-version.entity.d.ts.map +1 -0
- package/dist/entities/agent-config-version.entity.js +44 -0
- package/dist/entities/agent-config-version.entity.js.map +1 -0
- package/dist/entities/agent-hub-tag.entity.js +1 -1
- package/dist/entities/agent-hub-tag.entity.js.map +1 -1
- package/dist/entities/agent-registry.entity.d.ts +2 -0
- package/dist/entities/agent-registry.entity.d.ts.map +1 -1
- package/dist/entities/agent-registry.entity.js +7 -2
- 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.map +1 -1
- package/dist/entities/agent-skill-registry.entity.js +1 -1
- package/dist/entities/agent-skill-registry.entity.js.map +1 -1
- package/dist/entities/agent-tool-registry.entity.js +1 -1
- package/dist/entities/agent-tool-registry.entity.js.map +1 -1
- package/dist/entities/agent-user-memory.entity.d.ts +12 -0
- package/dist/entities/agent-user-memory.entity.d.ts.map +1 -0
- package/dist/entities/agent-user-memory.entity.js +51 -0
- package/dist/entities/agent-user-memory.entity.js.map +1 -0
- package/dist/entities/secret.entity.d.ts +2 -0
- package/dist/entities/secret.entity.d.ts.map +1 -1
- package/dist/entities/secret.entity.js +7 -1
- package/dist/entities/secret.entity.js.map +1 -1
- package/dist/helpers/module-metadata-helper.service.js +1 -1
- package/dist/helpers/module-metadata-helper.service.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -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 +1 -0
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js.map +1 -1
- package/dist/repository/agent-config-version.repository.d.ts +12 -0
- package/dist/repository/agent-config-version.repository.d.ts.map +1 -0
- package/dist/repository/agent-config-version.repository.js +39 -0
- package/dist/repository/agent-config-version.repository.js.map +1 -0
- package/dist/repository/agent-user-memory.repository.d.ts +12 -0
- package/dist/repository/agent-user-memory.repository.d.ts.map +1 -0
- package/dist/repository/agent-user-memory.repository.js +39 -0
- package/dist/repository/agent-user-memory.repository.js.map +1 -0
- package/dist/resources/agent-embed/solid-agent-embed.js +7 -1
- package/dist/seeders/module-metadata-agenthub.spec.js +52 -3
- package/dist/seeders/module-metadata-agenthub.spec.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +87 -45
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +833 -37
- package/dist/services/agent-config-version-record.service.d.ts +81 -0
- package/dist/services/agent-config-version-record.service.d.ts.map +1 -0
- package/dist/services/agent-config-version-record.service.js +308 -0
- package/dist/services/agent-config-version-record.service.js.map +1 -0
- package/dist/services/agent-config-version.service.d.ts +1 -1
- package/dist/services/agent-config-version.service.d.ts.map +1 -1
- package/dist/services/agent-config-version.service.js +14 -15
- package/dist/services/agent-config-version.service.js.map +1 -1
- package/dist/services/agent-registry.service.d.ts +2 -0
- package/dist/services/agent-registry.service.d.ts.map +1 -1
- package/dist/services/agent-registry.service.js +27 -1
- package/dist/services/agent-registry.service.js.map +1 -1
- package/dist/services/agent-session.service.d.ts +21 -1
- package/dist/services/agent-session.service.d.ts.map +1 -1
- package/dist/services/agent-session.service.js +78 -2
- package/dist/services/agent-session.service.js.map +1 -1
- package/dist/services/agent-user-memory.service.d.ts +12 -0
- package/dist/services/agent-user-memory.service.d.ts.map +1 -0
- package/dist/services/agent-user-memory.service.js +38 -0
- package/dist/services/agent-user-memory.service.js.map +1 -0
- package/dist/services/secret.service.js +3 -3
- package/dist/services/secret.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +2 -2
- package/dist/services/settings/default-settings-provider.service.js +1 -1
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/services/view-metadata.service.d.ts.map +1 -1
- package/dist/services/view-metadata.service.js +14 -5
- package/dist/services/view-metadata.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +25 -3
- package/dist/solid-core.module.js.map +1 -1
- package/dist/subscribers/agent-hub-tag.subscriber.d.ts +9 -5
- package/dist/subscribers/agent-hub-tag.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-hub-tag.subscriber.js +100 -88
- package/dist/subscribers/agent-hub-tag.subscriber.js.map +1 -1
- package/dist/subscribers/agent-registry-subscribers.spec.js +158 -6
- package/dist/subscribers/agent-registry-subscribers.spec.js.map +1 -1
- package/dist/subscribers/agent-registry.subscriber.d.ts +16 -6
- package/dist/subscribers/agent-registry.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-registry.subscriber.js +191 -60
- package/dist/subscribers/agent-registry.subscriber.js.map +1 -1
- package/dist/subscribers/agent-role.subscriber.d.ts +19 -0
- package/dist/subscribers/agent-role.subscriber.d.ts.map +1 -0
- package/dist/subscribers/agent-role.subscriber.js +112 -0
- package/dist/subscribers/agent-role.subscriber.js.map +1 -0
- package/dist/subscribers/agent-secret.subscriber.d.ts +19 -0
- package/dist/subscribers/agent-secret.subscriber.d.ts.map +1 -0
- package/dist/subscribers/agent-secret.subscriber.js +112 -0
- package/dist/subscribers/agent-secret.subscriber.js.map +1 -0
- package/dist/subscribers/agent-skill-registry.subscriber.d.ts +12 -4
- package/dist/subscribers/agent-skill-registry.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-skill-registry.subscriber.js +137 -79
- package/dist/subscribers/agent-skill-registry.subscriber.js.map +1 -1
- package/dist/subscribers/agent-skill.subscriber.d.ts +8 -2
- package/dist/subscribers/agent-skill.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-skill.subscriber.js +59 -8
- package/dist/subscribers/agent-skill.subscriber.js.map +1 -1
- package/dist/subscribers/agent-tool-registry.subscriber.d.ts +12 -4
- package/dist/subscribers/agent-tool-registry.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-tool-registry.subscriber.js +138 -80
- package/dist/subscribers/agent-tool-registry.subscriber.js.map +1 -1
- package/dist/subscribers/agent-tool.subscriber.d.ts +8 -2
- package/dist/subscribers/agent-tool.subscriber.d.ts.map +1 -1
- package/dist/subscribers/agent-tool.subscriber.js +59 -8
- package/dist/subscribers/agent-tool.subscriber.js.map +1 -1
- package/dist/subscribers/agenthub-metadata-sync.util.d.ts +0 -9
- package/dist/subscribers/agenthub-metadata-sync.util.d.ts.map +1 -1
- package/dist/subscribers/agenthub-metadata-sync.util.js +21 -14
- package/dist/subscribers/agenthub-metadata-sync.util.js.map +1 -1
- package/dist/subscribers/secret.subscriber.d.ts +26 -0
- package/dist/subscribers/secret.subscriber.d.ts.map +1 -0
- package/dist/subscribers/secret.subscriber.js +236 -0
- package/dist/subscribers/secret.subscriber.js.map +1 -0
- package/dist/testing/contracts/runtime-context.types.d.ts +2 -0
- package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -1
- package/dist/testing/contracts/runtime-context.types.js.map +1 -1
- package/dist/testing/core/call-args.d.ts +18 -0
- package/dist/testing/core/call-args.d.ts.map +1 -0
- package/dist/testing/core/call-args.js +133 -0
- package/dist/testing/core/call-args.js.map +1 -0
- package/dist/testing/core/dates.d.ts +27 -0
- package/dist/testing/core/dates.d.ts.map +1 -0
- package/dist/testing/core/dates.js +151 -0
- package/dist/testing/core/dates.js.map +1 -0
- package/dist/testing/core/dates.spec.d.ts +2 -0
- package/dist/testing/core/dates.spec.d.ts.map +1 -0
- package/dist/testing/core/dates.spec.js +246 -0
- package/dist/testing/core/dates.spec.js.map +1 -0
- package/dist/testing/core/interpolation.d.ts +4 -1
- package/dist/testing/core/interpolation.d.ts.map +1 -1
- package/dist/testing/core/interpolation.js +56 -27
- package/dist/testing/core/interpolation.js.map +1 -1
- package/dist/testing/core/random-data.d.ts +12 -0
- package/dist/testing/core/random-data.d.ts.map +1 -0
- package/dist/testing/core/random-data.js +270 -0
- package/dist/testing/core/random-data.js.map +1 -0
- package/dist/testing/core/random-data.spec.d.ts +2 -0
- package/dist/testing/core/random-data.spec.d.ts.map +1 -0
- package/dist/testing/core/random-data.spec.js +198 -0
- package/dist/testing/core/random-data.spec.js.map +1 -0
- package/dist/testing/core/random-names.d.ts +4 -0
- package/dist/testing/core/random-names.d.ts.map +1 -0
- package/dist/testing/core/random-names.js +50 -0
- package/dist/testing/core/random-names.js.map +1 -0
- package/dist/testing/core/step-registry.d.ts +6 -1
- package/dist/testing/core/step-registry.d.ts.map +1 -1
- package/dist/testing/core/step-registry.js +8 -1
- package/dist/testing/core/step-registry.js.map +1 -1
- package/dist/testing/core/testing-engine.d.ts +1 -0
- package/dist/testing/core/testing-engine.d.ts.map +1 -1
- package/dist/testing/core/testing-engine.js +15 -1
- package/dist/testing/core/testing-engine.js.map +1 -1
- package/dist/testing/core/token-scan.d.ts +8 -0
- package/dist/testing/core/token-scan.d.ts.map +1 -0
- package/dist/testing/core/token-scan.js +70 -0
- package/dist/testing/core/token-scan.js.map +1 -0
- package/dist/testing/runner/run-from-metadata.d.ts +1 -0
- package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
- package/dist/testing/runner/run-from-metadata.js +10 -3
- package/dist/testing/runner/run-from-metadata.js.map +1 -1
- package/dist/testing/runner/run-from-metadata.spec.d.ts +2 -0
- package/dist/testing/runner/run-from-metadata.spec.d.ts.map +1 -0
- package/dist/testing/runner/run-from-metadata.spec.js +62 -0
- package/dist/testing/runner/run-from-metadata.spec.js.map +1 -0
- package/dist/testing/steps/util/index.d.ts.map +1 -1
- package/dist/testing/steps/util/index.js +6 -0
- package/dist/testing/steps/util/index.js.map +1 -1
- package/dist/testing/steps/util/now.step.d.ts +3 -0
- package/dist/testing/steps/util/now.step.d.ts.map +1 -0
- package/dist/testing/steps/util/now.step.js +15 -0
- package/dist/testing/steps/util/now.step.js.map +1 -0
- package/dist/testing/steps/util/random.step.d.ts +3 -0
- package/dist/testing/steps/util/random.step.d.ts.map +1 -0
- package/dist/testing/steps/util/random.step.js +18 -0
- package/dist/testing/steps/util/random.step.js.map +1 -0
- package/dist/testing/steps/util/script.step.d.ts +3 -0
- package/dist/testing/steps/util/script.step.d.ts.map +1 -0
- package/dist/testing/steps/util/script.step.js +221 -0
- package/dist/testing/steps/util/script.step.js.map +1 -0
- package/dist/testing/steps/util/script.step.spec.d.ts +2 -0
- package/dist/testing/steps/util/script.step.spec.d.ts.map +1 -0
- package/dist/testing/steps/util/script.step.spec.js +205 -0
- package/dist/testing/steps/util/script.step.spec.js.map +1 -0
- package/package.json +1 -1
- package/resources/agent-embed/solid-agent-embed.js +7 -1
- package/src/commands/run-tests.command.ts +12 -0
- package/src/constants/error-messages.ts +1 -1
- package/src/controllers/agent-config-version.controller.ts +114 -0
- package/src/controllers/agent-registry.controller.ts +7 -0
- package/src/controllers/agent-session.controller.ts +16 -1
- package/src/controllers/agent-user-memory.controller.ts +32 -0
- package/src/dtos/activate-agent-registry.dto.ts +14 -0
- package/src/dtos/create-agent-config-version.dto.ts +27 -0
- package/src/dtos/create-agent-user-memory.dto.ts +10 -0
- package/src/dtos/create-secret.dto.ts +11 -1
- package/src/dtos/test-run-request.dto.ts +4 -0
- package/src/dtos/update-agent-config-version.dto.ts +34 -0
- package/src/dtos/update-agent-user-memory.dto.ts +11 -0
- package/src/dtos/update-secret.dto.ts +10 -0
- package/src/entities/agent-config-version.entity.ts +20 -0
- package/src/entities/agent-hub-tag.entity.ts +1 -1
- package/src/entities/agent-registry.entity.ts +5 -1
- package/src/entities/agent-session.entity.ts +1 -0
- package/src/entities/agent-skill-registry.entity.ts +1 -1
- package/src/entities/agent-tool-registry.entity.ts +1 -1
- package/src/entities/agent-user-memory.entity.ts +26 -0
- package/src/entities/secret.entity.ts +6 -1
- package/src/helpers/module-metadata-helper.service.ts +1 -1
- package/src/index.ts +13 -0
- package/src/jobs/database/test-run-queue-subscriber-database.service.ts +1 -0
- package/src/repository/agent-config-version.repository.ts +19 -0
- package/src/repository/agent-user-memory.repository.ts +18 -0
- package/src/seeders/module-metadata-agenthub.spec.ts +58 -3
- package/src/seeders/module-metadata-seeder.service.ts +85 -44
- package/src/seeders/seed-data/solid-core-metadata.json +833 -37
- package/src/services/agent-config-version-record.service.ts +317 -0
- package/src/services/agent-config-version.service.ts +24 -10
- package/src/services/agent-registry.service.ts +32 -3
- package/src/services/agent-session.service.ts +75 -2
- package/src/services/agent-user-memory.service.ts +18 -0
- package/src/services/secret.service.ts +4 -4
- package/src/services/settings/default-settings-provider.service.ts +1 -1
- package/src/services/view-metadata.service.ts +17 -5
- package/src/solid-core.module.ts +25 -3
- package/src/subscribers/agent-hub-tag.subscriber.ts +154 -93
- package/src/subscribers/agent-registry-subscribers.spec.ts +163 -6
- package/src/subscribers/agent-registry.subscriber.ts +202 -58
- package/src/subscribers/agent-role.subscriber.ts +105 -0
- package/src/subscribers/agent-secret.subscriber.ts +105 -0
- package/src/subscribers/agent-skill-registry.subscriber.ts +144 -75
- package/src/subscribers/agent-skill.subscriber.ts +68 -9
- package/src/subscribers/agent-tool-registry.subscriber.ts +145 -76
- package/src/subscribers/agent-tool.subscriber.ts +68 -9
- package/src/subscribers/agenthub-metadata-sync.util.ts +19 -13
- package/src/subscribers/secret.subscriber.ts +192 -0
- package/src/testing/README.md +199 -0
- package/src/testing/contracts/runtime-context.types.ts +3 -0
- package/src/testing/core/call-args.ts +154 -0
- package/src/testing/core/dates.spec.ts +311 -0
- package/src/testing/core/dates.ts +198 -0
- package/src/testing/core/interpolation.ts +67 -28
- package/src/testing/core/random-data.spec.ts +253 -0
- package/src/testing/core/random-data.ts +326 -0
- package/src/testing/core/random-names.ts +54 -0
- package/src/testing/core/step-registry.ts +18 -1
- package/src/testing/core/testing-engine.ts +16 -1
- package/src/testing/core/token-scan.ts +72 -0
- package/src/testing/runner/run-from-metadata.spec.ts +82 -0
- package/src/testing/runner/run-from-metadata.ts +15 -3
- package/src/testing/steps/util/index.ts +6 -0
- package/src/testing/steps/util/now.step.ts +19 -0
- package/src/testing/steps/util/random.step.ts +23 -0
- package/src/testing/steps/util/script.step.spec.ts +269 -0
- package/src/testing/steps/util/script.step.ts +242 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AgentRoleSubscriber = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const agent_role_entity_1 = require("../entities/agent-role.entity");
|
|
20
|
+
const agent_registry_subscriber_1 = require("./agent-registry.subscriber");
|
|
21
|
+
let AgentRoleSubscriber = class AgentRoleSubscriber {
|
|
22
|
+
constructor(dataSource, agentRegistrySubscriber) {
|
|
23
|
+
this.agentRegistrySubscriber = agentRegistrySubscriber;
|
|
24
|
+
this.removedAgentIds = new Map();
|
|
25
|
+
dataSource.subscribers.push(this);
|
|
26
|
+
}
|
|
27
|
+
listenTo() {
|
|
28
|
+
return agent_role_entity_1.AgentRole;
|
|
29
|
+
}
|
|
30
|
+
async afterInsert(event) {
|
|
31
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
32
|
+
if (solidCliRunning === "true") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await this.writeAgentRoles(event);
|
|
36
|
+
}
|
|
37
|
+
async afterUpdate(event) {
|
|
38
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
39
|
+
if (solidCliRunning === "true") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await this.writeAgentRoles(event);
|
|
43
|
+
}
|
|
44
|
+
async beforeRemove(event) {
|
|
45
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
46
|
+
if (solidCliRunning === "true") {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);
|
|
50
|
+
}
|
|
51
|
+
async beforeSoftRemove(event) {
|
|
52
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
53
|
+
if (solidCliRunning === "true") {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);
|
|
57
|
+
}
|
|
58
|
+
async afterRemove(event) {
|
|
59
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
60
|
+
if (solidCliRunning === "true") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await this.writeAgentRolesAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);
|
|
64
|
+
}
|
|
65
|
+
async afterSoftRemove(event) {
|
|
66
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
67
|
+
if (solidCliRunning === "true") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await this.writeAgentRolesAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);
|
|
71
|
+
}
|
|
72
|
+
async writeAgentRoles(event) {
|
|
73
|
+
const entity = event.entity;
|
|
74
|
+
let agentId = entity?.agentRegistry?.id;
|
|
75
|
+
if (!agentId && entity?.id) {
|
|
76
|
+
const link = await event.manager.getRepository(agent_role_entity_1.AgentRole).findOne({
|
|
77
|
+
where: { id: entity.id },
|
|
78
|
+
relations: { agentRegistry: true },
|
|
79
|
+
});
|
|
80
|
+
agentId = link?.agentRegistry?.id;
|
|
81
|
+
}
|
|
82
|
+
if (agentId)
|
|
83
|
+
await this.agentRegistrySubscriber.writeAgentRolesToMetadata(agentId, event.manager);
|
|
84
|
+
}
|
|
85
|
+
async rememberAgentId(manager, linkId) {
|
|
86
|
+
if (!linkId)
|
|
87
|
+
return;
|
|
88
|
+
const link = await manager.getRepository(agent_role_entity_1.AgentRole).findOne({
|
|
89
|
+
where: { id: linkId },
|
|
90
|
+
relations: { agentRegistry: true },
|
|
91
|
+
withDeleted: true,
|
|
92
|
+
});
|
|
93
|
+
if (link?.agentRegistry?.id)
|
|
94
|
+
this.removedAgentIds.set(linkId, link.agentRegistry.id);
|
|
95
|
+
}
|
|
96
|
+
async writeAgentRolesAfterRemoval(linkId, manager) {
|
|
97
|
+
if (!linkId)
|
|
98
|
+
return;
|
|
99
|
+
const agentId = this.removedAgentIds.get(linkId);
|
|
100
|
+
this.removedAgentIds.delete(linkId);
|
|
101
|
+
if (agentId)
|
|
102
|
+
await this.agentRegistrySubscriber.writeAgentRolesToMetadata(agentId, manager);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.AgentRoleSubscriber = AgentRoleSubscriber;
|
|
106
|
+
exports.AgentRoleSubscriber = AgentRoleSubscriber = __decorate([
|
|
107
|
+
(0, common_1.Injectable)(),
|
|
108
|
+
__param(0, (0, typeorm_1.InjectDataSource)()),
|
|
109
|
+
__metadata("design:paramtypes", [typeorm_2.DataSource,
|
|
110
|
+
agent_registry_subscriber_1.AgentRegistrySubscriber])
|
|
111
|
+
], AgentRoleSubscriber);
|
|
112
|
+
//# sourceMappingURL=agent-role.subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-role.subscriber.js","sourceRoot":"","sources":["../../src/subscribers/agent-role.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAuI;AACvI,qEAA2D;AAC3D,2EAAsE;AAG/D,IAAM,mBA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AAE,CAAA;qCAAa,oBAAU;QACA,mDAAuB;GAL5D,mBAAmB,CAiG/B","sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { InjectDataSource } from '@nestjs/typeorm';\nimport { DataSource, EntityManager, EntitySubscriberInterface, InsertEvent, RemoveEvent, SoftRemoveEvent, UpdateEvent } from 'typeorm';\nimport { AgentRole } from 'src/entities/agent-role.entity';\nimport { AgentRegistrySubscriber } from './agent-registry.subscriber';\n\n@Injectable()\nexport class AgentRoleSubscriber implements EntitySubscriberInterface<AgentRole> {\n private readonly removedAgentIds = new Map<number, number>();\n\n constructor(\n @InjectDataSource() dataSource: DataSource,\n private readonly agentRegistrySubscriber: AgentRegistrySubscriber,\n ) {\n dataSource.subscribers.push(this);\n }\n\n listenTo() {\n return AgentRole;\n }\n\n async afterInsert(event: InsertEvent<AgentRole>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentRoles(event);\n }\n\n async afterUpdate(event: UpdateEvent<AgentRole>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentRoles(event);\n }\n\n async beforeRemove(event: RemoveEvent<AgentRole>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);\n }\n\n async beforeSoftRemove(event: SoftRemoveEvent<AgentRole>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);\n }\n\n async afterRemove(event: RemoveEvent<AgentRole>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentRolesAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);\n }\n\n async afterSoftRemove(event: SoftRemoveEvent<AgentRole>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentRolesAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);\n }\n\n private async writeAgentRoles(event: InsertEvent<AgentRole> | UpdateEvent<AgentRole>): Promise<void> {\n const entity = event.entity as AgentRole | undefined;\n let agentId = entity?.agentRegistry?.id;\n if (!agentId && entity?.id) {\n const link = await event.manager.getRepository(AgentRole).findOne({\n where: { id: entity.id },\n relations: { agentRegistry: true },\n });\n agentId = link?.agentRegistry?.id;\n }\n if (agentId) await this.agentRegistrySubscriber.writeAgentRolesToMetadata(agentId, event.manager);\n }\n\n private async rememberAgentId(manager: EntityManager, linkId?: number): Promise<void> {\n if (!linkId) return;\n const link = await manager.getRepository(AgentRole).findOne({\n where: { id: linkId },\n relations: { agentRegistry: true },\n withDeleted: true,\n });\n if (link?.agentRegistry?.id) this.removedAgentIds.set(linkId, link.agentRegistry.id);\n }\n\n private async writeAgentRolesAfterRemoval(linkId: number | undefined, manager: EntityManager): Promise<void> {\n if (!linkId) return;\n const agentId = this.removedAgentIds.get(linkId);\n this.removedAgentIds.delete(linkId);\n if (agentId) await this.agentRegistrySubscriber.writeAgentRolesToMetadata(agentId, manager);\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DataSource, EntitySubscriberInterface, InsertEvent, RemoveEvent, SoftRemoveEvent, UpdateEvent } from 'typeorm';
|
|
2
|
+
import { AgentSecret } from '../entities/agent-secret.entity';
|
|
3
|
+
import { AgentRegistrySubscriber } from './agent-registry.subscriber';
|
|
4
|
+
export declare class AgentSecretSubscriber implements EntitySubscriberInterface<AgentSecret> {
|
|
5
|
+
private readonly agentRegistrySubscriber;
|
|
6
|
+
private readonly removedAgentIds;
|
|
7
|
+
constructor(dataSource: DataSource, agentRegistrySubscriber: AgentRegistrySubscriber);
|
|
8
|
+
listenTo(): typeof AgentSecret;
|
|
9
|
+
afterInsert(event: InsertEvent<AgentSecret>): Promise<void>;
|
|
10
|
+
afterUpdate(event: UpdateEvent<AgentSecret>): Promise<void>;
|
|
11
|
+
beforeRemove(event: RemoveEvent<AgentSecret>): Promise<void>;
|
|
12
|
+
beforeSoftRemove(event: SoftRemoveEvent<AgentSecret>): Promise<void>;
|
|
13
|
+
afterRemove(event: RemoveEvent<AgentSecret>): Promise<void>;
|
|
14
|
+
afterSoftRemove(event: SoftRemoveEvent<AgentSecret>): Promise<void>;
|
|
15
|
+
private writeAgentSecrets;
|
|
16
|
+
private rememberAgentId;
|
|
17
|
+
private writeAgentSecretsAfterRemoval;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=agent-secret.subscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-secret.subscriber.d.ts","sourceRoot":"","sources":["../../src/subscribers/agent-secret.subscriber.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAiB,yBAAyB,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvI,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBACa,qBAAsB,YAAW,yBAAyB,CAAC,WAAW,CAAC;IAK5E,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IAJ5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;gBAGrC,UAAU,EAAE,UAAU,EACzB,uBAAuB,EAAE,uBAAuB;IAKrE,QAAQ;IAIF,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3D,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3D,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3D,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAS3D,iBAAiB;YAajB,eAAe;YAUf,6BAA6B;CAM9C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AgentSecretSubscriber = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const agent_secret_entity_1 = require("../entities/agent-secret.entity");
|
|
20
|
+
const agent_registry_subscriber_1 = require("./agent-registry.subscriber");
|
|
21
|
+
let AgentSecretSubscriber = class AgentSecretSubscriber {
|
|
22
|
+
constructor(dataSource, agentRegistrySubscriber) {
|
|
23
|
+
this.agentRegistrySubscriber = agentRegistrySubscriber;
|
|
24
|
+
this.removedAgentIds = new Map();
|
|
25
|
+
dataSource.subscribers.push(this);
|
|
26
|
+
}
|
|
27
|
+
listenTo() {
|
|
28
|
+
return agent_secret_entity_1.AgentSecret;
|
|
29
|
+
}
|
|
30
|
+
async afterInsert(event) {
|
|
31
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
32
|
+
if (solidCliRunning === "true") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await this.writeAgentSecrets(event);
|
|
36
|
+
}
|
|
37
|
+
async afterUpdate(event) {
|
|
38
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
39
|
+
if (solidCliRunning === "true") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await this.writeAgentSecrets(event);
|
|
43
|
+
}
|
|
44
|
+
async beforeRemove(event) {
|
|
45
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
46
|
+
if (solidCliRunning === "true") {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);
|
|
50
|
+
}
|
|
51
|
+
async beforeSoftRemove(event) {
|
|
52
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
53
|
+
if (solidCliRunning === "true") {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);
|
|
57
|
+
}
|
|
58
|
+
async afterRemove(event) {
|
|
59
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
60
|
+
if (solidCliRunning === "true") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await this.writeAgentSecretsAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);
|
|
64
|
+
}
|
|
65
|
+
async afterSoftRemove(event) {
|
|
66
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
67
|
+
if (solidCliRunning === "true") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await this.writeAgentSecretsAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);
|
|
71
|
+
}
|
|
72
|
+
async writeAgentSecrets(event) {
|
|
73
|
+
const entity = event.entity;
|
|
74
|
+
let agentId = entity?.agentRegistry?.id;
|
|
75
|
+
if (!agentId && entity?.id) {
|
|
76
|
+
const link = await event.manager.getRepository(agent_secret_entity_1.AgentSecret).findOne({
|
|
77
|
+
where: { id: entity.id },
|
|
78
|
+
relations: { agentRegistry: true },
|
|
79
|
+
});
|
|
80
|
+
agentId = link?.agentRegistry?.id;
|
|
81
|
+
}
|
|
82
|
+
if (agentId)
|
|
83
|
+
await this.agentRegistrySubscriber.writeAgentSecretsToMetadata(agentId, event.manager);
|
|
84
|
+
}
|
|
85
|
+
async rememberAgentId(manager, linkId) {
|
|
86
|
+
if (!linkId)
|
|
87
|
+
return;
|
|
88
|
+
const link = await manager.getRepository(agent_secret_entity_1.AgentSecret).findOne({
|
|
89
|
+
where: { id: linkId },
|
|
90
|
+
relations: { agentRegistry: true },
|
|
91
|
+
withDeleted: true,
|
|
92
|
+
});
|
|
93
|
+
if (link?.agentRegistry?.id)
|
|
94
|
+
this.removedAgentIds.set(linkId, link.agentRegistry.id);
|
|
95
|
+
}
|
|
96
|
+
async writeAgentSecretsAfterRemoval(linkId, manager) {
|
|
97
|
+
if (!linkId)
|
|
98
|
+
return;
|
|
99
|
+
const agentId = this.removedAgentIds.get(linkId);
|
|
100
|
+
this.removedAgentIds.delete(linkId);
|
|
101
|
+
if (agentId)
|
|
102
|
+
await this.agentRegistrySubscriber.writeAgentSecretsToMetadata(agentId, manager);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.AgentSecretSubscriber = AgentSecretSubscriber;
|
|
106
|
+
exports.AgentSecretSubscriber = AgentSecretSubscriber = __decorate([
|
|
107
|
+
(0, common_1.Injectable)(),
|
|
108
|
+
__param(0, (0, typeorm_1.InjectDataSource)()),
|
|
109
|
+
__metadata("design:paramtypes", [typeorm_2.DataSource,
|
|
110
|
+
agent_registry_subscriber_1.AgentRegistrySubscriber])
|
|
111
|
+
], AgentSecretSubscriber);
|
|
112
|
+
//# sourceMappingURL=agent-secret.subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-secret.subscriber.js","sourceRoot":"","sources":["../../src/subscribers/agent-secret.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAuI;AACvI,yEAA+D;AAC/D,2EAAsE;AAG/D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG9B,YACwB,UAAsB,EACzB,uBAAgD;QAAhD,4BAAuB,GAAvB,uBAAuB,CAAyB;QAJpD,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;QAMzD,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACJ,OAAO,iCAAW,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAA+B;QAC7C,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC;QACjE,IAAI,eAAe,KAAK,MAAM,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QAED,MAAM,IAAI,CAA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aAAa,CAAC,iCAAW,CAAC,CAAC,OAAO,CAAC;YAC1D,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;YAClC,WAAW,EAAE,IAAI;SACpB,CAAC,CAAC;QACH,IAAI,IAAI,EAAE,aAAa,EAAE,EAAE;YAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IAEO,KAAK,CAAC,6BAA6B,CAAC,MAA0B,EAAE,OAAsB;QAC1F,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,OAAO;YAAE,MAAM,IAAI,CAAC,uBAAuB,CAAC,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClG,CAAC;CACJ,CAAA;AAjGY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAKJ,WAAA,IAAA,0BAAgB,GAAE,CAAA;qCAAa,oBAAU;QACA,mDAAuB;GAL5D,qBAAqB,CAiGjC","sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { InjectDataSource } from '@nestjs/typeorm';\nimport { DataSource, EntityManager, EntitySubscriberInterface, InsertEvent, RemoveEvent, SoftRemoveEvent, UpdateEvent } from 'typeorm';\nimport { AgentSecret } from 'src/entities/agent-secret.entity';\nimport { AgentRegistrySubscriber } from './agent-registry.subscriber';\n\n@Injectable()\nexport class AgentSecretSubscriber implements EntitySubscriberInterface<AgentSecret> {\n private readonly removedAgentIds = new Map<number, number>();\n\n constructor(\n @InjectDataSource() dataSource: DataSource,\n private readonly agentRegistrySubscriber: AgentRegistrySubscriber,\n ) {\n dataSource.subscribers.push(this);\n }\n\n listenTo() {\n return AgentSecret;\n }\n\n async afterInsert(event: InsertEvent<AgentSecret>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentSecrets(event);\n }\n\n async afterUpdate(event: UpdateEvent<AgentSecret>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentSecrets(event);\n }\n\n async beforeRemove(event: RemoveEvent<AgentSecret>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);\n }\n\n async beforeSoftRemove(event: SoftRemoveEvent<AgentSecret>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.rememberAgentId(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);\n }\n\n async afterRemove(event: RemoveEvent<AgentSecret>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentSecretsAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);\n }\n\n async afterSoftRemove(event: SoftRemoveEvent<AgentSecret>): Promise<void> {\n const solidCliRunning = process.env.SOLID_CLI_RUNNING || \"false\";\n if (solidCliRunning === \"true\") {\n return;\n }\n\n await this.writeAgentSecretsAfterRemoval(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);\n }\n\n private async writeAgentSecrets(event: InsertEvent<AgentSecret> | UpdateEvent<AgentSecret>): Promise<void> {\n const entity = event.entity as AgentSecret | undefined;\n let agentId = entity?.agentRegistry?.id;\n if (!agentId && entity?.id) {\n const link = await event.manager.getRepository(AgentSecret).findOne({\n where: { id: entity.id },\n relations: { agentRegistry: true },\n });\n agentId = link?.agentRegistry?.id;\n }\n if (agentId) await this.agentRegistrySubscriber.writeAgentSecretsToMetadata(agentId, event.manager);\n }\n\n private async rememberAgentId(manager: EntityManager, linkId?: number): Promise<void> {\n if (!linkId) return;\n const link = await manager.getRepository(AgentSecret).findOne({\n where: { id: linkId },\n relations: { agentRegistry: true },\n withDeleted: true,\n });\n if (link?.agentRegistry?.id) this.removedAgentIds.set(linkId, link.agentRegistry.id);\n }\n\n private async writeAgentSecretsAfterRemoval(linkId: number | undefined, manager: EntityManager): Promise<void> {\n if (!linkId) return;\n const agentId = this.removedAgentIds.get(linkId);\n this.removedAgentIds.delete(linkId);\n if (agentId) await this.agentRegistrySubscriber.writeAgentSecretsToMetadata(agentId, manager);\n }\n}\n"]}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { DataSource, EntitySubscriberInterface, InsertEvent, RemoveEvent, SoftRemoveEvent, UpdateEvent } from 'typeorm';
|
|
2
2
|
import { AgentSkillRegistry } from '../entities/agent-skill-registry.entity';
|
|
3
3
|
import { ModuleMetadataHelperService } from '../helpers/module-metadata-helper.service';
|
|
4
|
+
import { AgentRegistrySubscriber } from './agent-registry.subscriber';
|
|
4
5
|
export declare class AgentSkillRegistrySubscriber implements EntitySubscriberInterface<AgentSkillRegistry> {
|
|
5
6
|
private readonly dataSource;
|
|
6
7
|
private readonly moduleMetadataHelperService;
|
|
8
|
+
private readonly agentRegistrySubscriber;
|
|
7
9
|
private readonly logger;
|
|
8
|
-
private readonly
|
|
9
|
-
|
|
10
|
+
private readonly previousSkills;
|
|
11
|
+
private readonly deletedSkills;
|
|
12
|
+
constructor(dataSource: DataSource, moduleMetadataHelperService: ModuleMetadataHelperService, agentRegistrySubscriber: AgentRegistrySubscriber);
|
|
10
13
|
listenTo(): typeof AgentSkillRegistry;
|
|
11
14
|
afterInsert(event: InsertEvent<AgentSkillRegistry>): Promise<void>;
|
|
15
|
+
beforeUpdate(event: UpdateEvent<AgentSkillRegistry>): Promise<void>;
|
|
12
16
|
afterUpdate(event: UpdateEvent<AgentSkillRegistry>): Promise<void>;
|
|
13
17
|
beforeRemove(event: RemoveEvent<AgentSkillRegistry>): Promise<void>;
|
|
14
|
-
afterRemove(event: RemoveEvent<AgentSkillRegistry>): Promise<void>;
|
|
15
18
|
beforeSoftRemove(event: SoftRemoveEvent<AgentSkillRegistry>): Promise<void>;
|
|
19
|
+
afterRemove(event: RemoveEvent<AgentSkillRegistry>): Promise<void>;
|
|
16
20
|
afterSoftRemove(event: SoftRemoveEvent<AgentSkillRegistry>): Promise<void>;
|
|
17
|
-
private
|
|
21
|
+
private getSkill;
|
|
22
|
+
private rememberDeletedSkill;
|
|
23
|
+
private removeDeletedSkill;
|
|
24
|
+
private writeSkill;
|
|
25
|
+
private removeSkill;
|
|
18
26
|
}
|
|
19
27
|
//# sourceMappingURL=agent-skill-registry.subscriber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-skill-registry.subscriber.d.ts","sourceRoot":"","sources":["../../src/subscribers/agent-skill-registry.subscriber.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"agent-skill-registry.subscriber.d.ts","sourceRoot":"","sources":["../../src/subscribers/agent-skill-registry.subscriber.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAiB,yBAAyB,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvI,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBACa,4BAA6B,YAAW,yBAAyB,CAAC,kBAAkB,CAAC;IAMtE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,2BAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IAP5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiD;IACxE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4D;IAC3F,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgF;gBAGrE,UAAU,EAAE,UAAU,EAC1C,2BAA2B,EAAE,2BAA2B,EACxD,uBAAuB,EAAE,uBAAuB;IAKrE,QAAQ;IAIF,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBnE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBlE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASnE,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3E,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASlE,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YASlE,QAAQ;YASR,oBAAoB;YAoBpB,kBAAkB;YAelB,UAAU;YAkCV,WAAW;CAoB5B"}
|
|
@@ -52,125 +52,156 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
52
52
|
const fs = __importStar(require("fs/promises"));
|
|
53
53
|
const typeorm_2 = require("typeorm");
|
|
54
54
|
const constants_1 = require("../constants");
|
|
55
|
-
const agent_skill_entity_1 = require("../entities/agent-skill.entity");
|
|
56
55
|
const agent_skill_registry_entity_1 = require("../entities/agent-skill-registry.entity");
|
|
57
56
|
const module_metadata_helper_service_1 = require("../helpers/module-metadata-helper.service");
|
|
58
|
-
const
|
|
57
|
+
const agent_skill_entity_1 = require("../entities/agent-skill.entity");
|
|
58
|
+
const agent_registry_subscriber_1 = require("./agent-registry.subscriber");
|
|
59
59
|
let AgentSkillRegistrySubscriber = AgentSkillRegistrySubscriber_1 = class AgentSkillRegistrySubscriber {
|
|
60
|
-
constructor(dataSource, moduleMetadataHelperService) {
|
|
60
|
+
constructor(dataSource, moduleMetadataHelperService, agentRegistrySubscriber) {
|
|
61
61
|
this.dataSource = dataSource;
|
|
62
62
|
this.moduleMetadataHelperService = moduleMetadataHelperService;
|
|
63
|
+
this.agentRegistrySubscriber = agentRegistrySubscriber;
|
|
63
64
|
this.logger = new common_1.Logger(AgentSkillRegistrySubscriber_1.name);
|
|
64
|
-
this.
|
|
65
|
+
this.previousSkills = new Map();
|
|
66
|
+
this.deletedSkills = new Map();
|
|
65
67
|
this.dataSource.subscribers.push(this);
|
|
66
68
|
}
|
|
67
69
|
listenTo() {
|
|
68
70
|
return agent_skill_registry_entity_1.AgentSkillRegistry;
|
|
69
71
|
}
|
|
70
72
|
async afterInsert(event) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
74
|
+
if (solidCliRunning === "true") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const skill = await this.getSkill(event.manager, event.entity?.id);
|
|
78
|
+
if (skill && !skill.deletedAt)
|
|
79
|
+
await this.writeSkill(skill);
|
|
75
80
|
}
|
|
76
|
-
async
|
|
77
|
-
const
|
|
81
|
+
async beforeUpdate(event) {
|
|
82
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
83
|
+
if (solidCliRunning === "true") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const id = event.entity?.id ?? event.databaseEntity?.id;
|
|
78
87
|
if (!id)
|
|
79
88
|
return;
|
|
80
89
|
const skill = await event.manager.getRepository(agent_skill_registry_entity_1.AgentSkillRegistry).findOne({
|
|
81
90
|
where: { id },
|
|
82
91
|
relations: { module: true },
|
|
92
|
+
withDeleted: true,
|
|
83
93
|
});
|
|
94
|
+
if (skill)
|
|
95
|
+
this.previousSkills.set(id, { name: skill.name, moduleName: skill.module?.name });
|
|
96
|
+
}
|
|
97
|
+
async afterUpdate(event) {
|
|
98
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
99
|
+
if (solidCliRunning === "true") {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const id = event.entity?.id ?? event.databaseEntity?.id;
|
|
103
|
+
if (!id)
|
|
104
|
+
return;
|
|
105
|
+
const previous = this.previousSkills.get(id);
|
|
106
|
+
this.previousSkills.delete(id);
|
|
107
|
+
const skill = await this.getSkill(event.manager, id);
|
|
84
108
|
if (!skill)
|
|
85
109
|
return;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
this.removals.set(id, {
|
|
91
|
-
name: skill.name,
|
|
92
|
-
moduleName: skill.module?.name,
|
|
93
|
-
agents: links.map(({ agentRegistry }) => ({
|
|
94
|
-
name: agentRegistry?.name,
|
|
95
|
-
moduleName: agentRegistry?.module?.name,
|
|
96
|
-
})).filter((agent) => Boolean(agent.name)),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async afterRemove(event) {
|
|
100
|
-
const id = (0, agenthub_metadata_sync_util_1.getRemoveEntityId)(event);
|
|
101
|
-
const deletion = id ? this.removals.get(id) : undefined;
|
|
102
|
-
if (id)
|
|
103
|
-
this.removals.delete(id);
|
|
104
|
-
if (!deletion)
|
|
105
|
-
return;
|
|
106
|
-
const modules = new Set();
|
|
107
|
-
const agentsByModule = new Map();
|
|
108
|
-
if (deletion.moduleName)
|
|
109
|
-
modules.add(deletion.moduleName);
|
|
110
|
-
for (const agent of deletion.agents) {
|
|
111
|
-
if (!agent.moduleName)
|
|
112
|
-
continue;
|
|
113
|
-
modules.add(agent.moduleName);
|
|
114
|
-
const agents = agentsByModule.get(agent.moduleName) ?? new Set();
|
|
115
|
-
agents.add(agent.name);
|
|
116
|
-
agentsByModule.set(agent.moduleName, agents);
|
|
110
|
+
if (skill.deletedAt) {
|
|
111
|
+
await this.removeSkill(skill.module?.name, skill.name);
|
|
112
|
+
return;
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
for (const agent of metadata.agenthubAgents) {
|
|
128
|
-
if (!agentsByModule.get(moduleName)?.has(agent.name))
|
|
129
|
-
continue;
|
|
130
|
-
const skills = Array.isArray(agent.agentSkills) ? agent.agentSkills : [];
|
|
131
|
-
const nextSkills = skills.filter((skill) => skill.name !== deletion.name);
|
|
132
|
-
if (nextSkills.length !== skills.length) {
|
|
133
|
-
agent.agentSkills = nextSkills;
|
|
134
|
-
changed = true;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return changed;
|
|
139
|
-
});
|
|
114
|
+
await this.writeSkill(skill);
|
|
115
|
+
if (previous && (previous.name !== skill.name || previous.moduleName !== skill.module?.name)) {
|
|
116
|
+
await this.removeSkill(previous.moduleName, previous.name);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async beforeRemove(event) {
|
|
120
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
121
|
+
if (solidCliRunning === "true") {
|
|
122
|
+
return;
|
|
140
123
|
}
|
|
124
|
+
await this.rememberDeletedSkill(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);
|
|
141
125
|
}
|
|
142
126
|
async beforeSoftRemove(event) {
|
|
143
|
-
|
|
127
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
128
|
+
if (solidCliRunning === "true") {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
await this.rememberDeletedSkill(event.manager, event.entity?.id ?? event.databaseEntity?.id ?? event.entityId);
|
|
144
132
|
}
|
|
145
|
-
async
|
|
146
|
-
|
|
133
|
+
async afterRemove(event) {
|
|
134
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
135
|
+
if (solidCliRunning === "true") {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
await this.removeDeletedSkill(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);
|
|
147
139
|
}
|
|
148
|
-
async
|
|
149
|
-
|
|
140
|
+
async afterSoftRemove(event) {
|
|
141
|
+
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
142
|
+
if (solidCliRunning === "true") {
|
|
150
143
|
return;
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
}
|
|
145
|
+
await this.removeDeletedSkill(event.entity?.id ?? event.databaseEntity?.id ?? event.entityId, event.manager);
|
|
146
|
+
}
|
|
147
|
+
async getSkill(manager, id) {
|
|
148
|
+
if (!id)
|
|
149
|
+
return null;
|
|
150
|
+
return manager.getRepository(agent_skill_registry_entity_1.AgentSkillRegistry).findOne({
|
|
151
|
+
where: { id },
|
|
153
152
|
relations: { module: true, tags: true },
|
|
153
|
+
withDeleted: true,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async rememberDeletedSkill(manager, id) {
|
|
157
|
+
if (!id)
|
|
158
|
+
return;
|
|
159
|
+
const skill = await manager.getRepository(agent_skill_registry_entity_1.AgentSkillRegistry).findOne({
|
|
160
|
+
where: { id },
|
|
161
|
+
relations: { module: true },
|
|
162
|
+
});
|
|
163
|
+
if (!skill)
|
|
164
|
+
return;
|
|
165
|
+
const links = await manager.getRepository(agent_skill_entity_1.AgentSkill).find({
|
|
166
|
+
where: { agentSkillRegistry: { id } },
|
|
167
|
+
relations: { agentRegistry: true },
|
|
168
|
+
});
|
|
169
|
+
this.deletedSkills.set(id, {
|
|
170
|
+
name: skill.name,
|
|
171
|
+
moduleName: skill.module?.name,
|
|
172
|
+
agentIds: links.map((link) => link.agentRegistry.id),
|
|
154
173
|
});
|
|
174
|
+
}
|
|
175
|
+
async removeDeletedSkill(id, manager) {
|
|
176
|
+
if (!id)
|
|
177
|
+
return;
|
|
178
|
+
const skill = this.deletedSkills.get(id);
|
|
179
|
+
this.deletedSkills.delete(id);
|
|
155
180
|
if (!skill)
|
|
156
|
-
|
|
181
|
+
return;
|
|
182
|
+
await this.removeSkill(skill.moduleName, skill.name);
|
|
183
|
+
for (const agentId of skill.agentIds) {
|
|
184
|
+
await this.agentRegistrySubscriber.writeAgentSkillsToMetadata(agentId, manager);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async writeSkill(skill) {
|
|
157
188
|
const moduleName = skill.module?.name;
|
|
158
189
|
if (!moduleName)
|
|
159
190
|
throw new Error(`Module not found for skill ${skill.name}`);
|
|
160
191
|
if (moduleName === constants_1.SOLID_CORE_MODULE_NAME)
|
|
161
192
|
return;
|
|
162
193
|
const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
194
|
+
let metadata;
|
|
163
195
|
try {
|
|
164
|
-
|
|
196
|
+
this.logger.warn(`METADATA READ START pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
197
|
+
metadata = JSON.parse(await fs.readFile(filePath, 'utf8'));
|
|
198
|
+
this.logger.warn(`METADATA READ END pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
165
199
|
}
|
|
166
|
-
catch {
|
|
167
|
-
this.logger.error(`
|
|
200
|
+
catch (error) {
|
|
201
|
+
this.logger.error(`Failed to read module metadata at ${filePath}: ${error?.message ?? error}`);
|
|
168
202
|
return;
|
|
169
203
|
}
|
|
170
|
-
const
|
|
171
|
-
if (!metadata)
|
|
172
|
-
throw new Error(`Module metadata could not be read: ${filePath}`);
|
|
173
|
-
const skills = metadata.agenthubSkills ?? [];
|
|
204
|
+
const skills = Array.isArray(metadata.agenthubSkills) ? metadata.agenthubSkills : [];
|
|
174
205
|
const index = skills.findIndex((item) => item.name === skill.name);
|
|
175
206
|
const entry = {
|
|
176
207
|
name: skill.name,
|
|
@@ -186,7 +217,33 @@ let AgentSkillRegistrySubscriber = AgentSkillRegistrySubscriber_1 = class AgentS
|
|
|
186
217
|
else
|
|
187
218
|
skills[index] = entry;
|
|
188
219
|
metadata.agenthubSkills = skills;
|
|
220
|
+
this.logger.warn(`METADATA WRITE START pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
221
|
+
await fs.writeFile(filePath, JSON.stringify(metadata, null, 2));
|
|
222
|
+
this.logger.warn(`METADATA WRITE END pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
223
|
+
}
|
|
224
|
+
async removeSkill(moduleName, name) {
|
|
225
|
+
if (!moduleName || moduleName === constants_1.SOLID_CORE_MODULE_NAME)
|
|
226
|
+
return;
|
|
227
|
+
const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
228
|
+
let metadata;
|
|
229
|
+
try {
|
|
230
|
+
this.logger.warn(`METADATA READ START pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
231
|
+
metadata = JSON.parse(await fs.readFile(filePath, 'utf8'));
|
|
232
|
+
this.logger.warn(`METADATA READ END pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
this.logger.error(`Failed to read module metadata at ${filePath}: ${error?.message ?? error}`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (!Array.isArray(metadata.agenthubSkills))
|
|
239
|
+
return;
|
|
240
|
+
const skills = metadata.agenthubSkills.filter((skill) => skill.name !== name);
|
|
241
|
+
if (skills.length === metadata.agenthubSkills.length)
|
|
242
|
+
return;
|
|
243
|
+
metadata.agenthubSkills = skills;
|
|
244
|
+
this.logger.warn(`METADATA WRITE START pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
189
245
|
await fs.writeFile(filePath, JSON.stringify(metadata, null, 2));
|
|
246
|
+
this.logger.warn(`METADATA WRITE END pid=${process.pid} at=${Date.now()} path=${filePath}`);
|
|
190
247
|
}
|
|
191
248
|
};
|
|
192
249
|
exports.AgentSkillRegistrySubscriber = AgentSkillRegistrySubscriber;
|
|
@@ -194,6 +251,7 @@ exports.AgentSkillRegistrySubscriber = AgentSkillRegistrySubscriber = AgentSkill
|
|
|
194
251
|
(0, common_1.Injectable)(),
|
|
195
252
|
__param(0, (0, typeorm_1.InjectDataSource)()),
|
|
196
253
|
__metadata("design:paramtypes", [typeorm_2.DataSource,
|
|
197
|
-
module_metadata_helper_service_1.ModuleMetadataHelperService
|
|
254
|
+
module_metadata_helper_service_1.ModuleMetadataHelperService,
|
|
255
|
+
agent_registry_subscriber_1.AgentRegistrySubscriber])
|
|
198
256
|
], AgentSkillRegistrySubscriber);
|
|
199
257
|
//# sourceMappingURL=agent-skill-registry.subscriber.js.map
|