@solidxai/core 0.1.19-beta.5 → 0.1.20-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/controllers/agent-hub-tag.controller.d.ts +24 -0
  3. package/dist/controllers/agent-hub-tag.controller.d.ts.map +1 -0
  4. package/dist/controllers/agent-hub-tag.controller.js +175 -0
  5. package/dist/controllers/agent-hub-tag.controller.js.map +1 -0
  6. package/dist/controllers/agent-tool-registry.controller.d.ts +18 -0
  7. package/dist/controllers/agent-tool-registry.controller.d.ts.map +1 -1
  8. package/dist/controllers/agent-tool-registry.controller.js +13 -0
  9. package/dist/controllers/agent-tool-registry.controller.js.map +1 -1
  10. package/dist/dtos/create-agent-hub-tag.dto.d.ts +16 -0
  11. package/dist/dtos/create-agent-hub-tag.dto.d.ts.map +1 -0
  12. package/dist/dtos/create-agent-hub-tag.dto.js +98 -0
  13. package/dist/dtos/create-agent-hub-tag.dto.js.map +1 -0
  14. package/dist/dtos/create-agent-registry.dto.d.ts +4 -0
  15. package/dist/dtos/create-agent-registry.dto.d.ts.map +1 -1
  16. package/dist/dtos/create-agent-registry.dto.js +24 -1
  17. package/dist/dtos/create-agent-registry.dto.js.map +1 -1
  18. package/dist/dtos/create-agent-skill-registry.dto.d.ts +4 -1
  19. package/dist/dtos/create-agent-skill-registry.dto.d.ts.map +1 -1
  20. package/dist/dtos/create-agent-skill-registry.dto.js +21 -5
  21. package/dist/dtos/create-agent-skill-registry.dto.js.map +1 -1
  22. package/dist/dtos/create-agent-tool-registry.dto.d.ts +4 -1
  23. package/dist/dtos/create-agent-tool-registry.dto.d.ts.map +1 -1
  24. package/dist/dtos/create-agent-tool-registry.dto.js +24 -8
  25. package/dist/dtos/create-agent-tool-registry.dto.js.map +1 -1
  26. package/dist/dtos/update-agent-hub-tag.dto.d.ts +17 -0
  27. package/dist/dtos/update-agent-hub-tag.dto.d.ts.map +1 -0
  28. package/dist/dtos/update-agent-hub-tag.dto.js +104 -0
  29. package/dist/dtos/update-agent-hub-tag.dto.js.map +1 -0
  30. package/dist/dtos/update-agent-registry.dto.d.ts +4 -0
  31. package/dist/dtos/update-agent-registry.dto.d.ts.map +1 -1
  32. package/dist/dtos/update-agent-registry.dto.js +24 -1
  33. package/dist/dtos/update-agent-registry.dto.js.map +1 -1
  34. package/dist/dtos/update-agent-skill-registry.dto.d.ts +4 -1
  35. package/dist/dtos/update-agent-skill-registry.dto.d.ts.map +1 -1
  36. package/dist/dtos/update-agent-skill-registry.dto.js +20 -4
  37. package/dist/dtos/update-agent-skill-registry.dto.js.map +1 -1
  38. package/dist/dtos/update-agent-tool-registry.dto.d.ts +4 -1
  39. package/dist/dtos/update-agent-tool-registry.dto.d.ts.map +1 -1
  40. package/dist/dtos/update-agent-tool-registry.dto.js +24 -8
  41. package/dist/dtos/update-agent-tool-registry.dto.js.map +1 -1
  42. package/dist/entities/agent-hub-tag.entity.d.ts +11 -0
  43. package/dist/entities/agent-hub-tag.entity.d.ts.map +1 -0
  44. package/dist/entities/agent-hub-tag.entity.js +45 -0
  45. package/dist/entities/agent-hub-tag.entity.js.map +1 -0
  46. package/dist/entities/agent-registry.entity.d.ts +2 -0
  47. package/dist/entities/agent-registry.entity.d.ts.map +1 -1
  48. package/dist/entities/agent-registry.entity.js +7 -1
  49. package/dist/entities/agent-registry.entity.js.map +1 -1
  50. package/dist/entities/agent-skill-registry.entity.d.ts +2 -1
  51. package/dist/entities/agent-skill-registry.entity.d.ts.map +1 -1
  52. package/dist/entities/agent-skill-registry.entity.js +5 -4
  53. package/dist/entities/agent-skill-registry.entity.js.map +1 -1
  54. package/dist/entities/agent-tool-registry.entity.d.ts +2 -1
  55. package/dist/entities/agent-tool-registry.entity.d.ts.map +1 -1
  56. package/dist/entities/agent-tool-registry.entity.js +7 -6
  57. package/dist/entities/agent-tool-registry.entity.js.map +1 -1
  58. package/dist/index.d.ts +6 -0
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +6 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/repository/agent-hub-tag.repository.d.ts +12 -0
  63. package/dist/repository/agent-hub-tag.repository.d.ts.map +1 -0
  64. package/dist/repository/agent-hub-tag.repository.js +39 -0
  65. package/dist/repository/agent-hub-tag.repository.js.map +1 -0
  66. package/dist/seeders/seed-data/solid-core-metadata.json +344 -30
  67. package/dist/services/agent-hub-tag.service.d.ts +12 -0
  68. package/dist/services/agent-hub-tag.service.d.ts.map +1 -0
  69. package/dist/services/agent-hub-tag.service.js +38 -0
  70. package/dist/services/agent-hub-tag.service.js.map +1 -0
  71. package/dist/services/agent-tool-registry.service.d.ts +23 -1
  72. package/dist/services/agent-tool-registry.service.d.ts.map +1 -1
  73. package/dist/services/agent-tool-registry.service.js +168 -4
  74. package/dist/services/agent-tool-registry.service.js.map +1 -1
  75. package/dist/services/agent-tool-registry.service.spec.js +1 -1
  76. package/dist/services/agent-tool-registry.service.spec.js.map +1 -1
  77. package/dist/services/secret.service.d.ts +1 -0
  78. package/dist/services/secret.service.d.ts.map +1 -1
  79. package/dist/services/secret.service.js +10 -0
  80. package/dist/services/secret.service.js.map +1 -1
  81. package/dist/solid-core.module.d.ts.map +1 -1
  82. package/dist/solid-core.module.js +8 -0
  83. package/dist/solid-core.module.js.map +1 -1
  84. package/package.json +1 -1
  85. package/src/controllers/agent-hub-tag.controller.ts +86 -0
  86. package/src/controllers/agent-tool-registry.controller.ts +6 -0
  87. package/src/dtos/create-agent-hub-tag.dto.ts +70 -0
  88. package/src/dtos/create-agent-registry.dto.ts +20 -0
  89. package/src/dtos/create-agent-skill-registry.dto.ts +19 -4
  90. package/src/dtos/create-agent-tool-registry.dto.ts +21 -6
  91. package/src/dtos/update-agent-hub-tag.dto.ts +75 -0
  92. package/src/dtos/update-agent-registry.dto.ts +20 -0
  93. package/src/dtos/update-agent-skill-registry.dto.ts +17 -3
  94. package/src/dtos/update-agent-tool-registry.dto.ts +20 -6
  95. package/src/entities/agent-hub-tag.entity.ts +21 -0
  96. package/src/entities/agent-registry.entity.ts +6 -1
  97. package/src/entities/agent-skill-registry.entity.ts +5 -3
  98. package/src/entities/agent-tool-registry.entity.ts +6 -4
  99. package/src/index.ts +6 -0
  100. package/src/repository/agent-hub-tag.repository.ts +19 -0
  101. package/src/seeders/seed-data/solid-core-metadata.json +344 -30
  102. package/src/services/agent-hub-tag.service.ts +19 -0
  103. package/src/services/agent-tool-registry.service.spec.ts +1 -1
  104. package/src/services/agent-tool-registry.service.ts +161 -1
  105. package/src/services/secret.service.ts +10 -0
  106. package/src/solid-core.module.ts +8 -0
@@ -7923,6 +7923,95 @@
7923
7923
  ],
7924
7924
  "moduleUserKey": "solid-core"
7925
7925
  },
7926
+ {
7927
+ "singularName": "agentHubTag",
7928
+ "pluralName": "agentHubTags",
7929
+ "displayName": "Agent Hub Tags",
7930
+ "dataSource": "default",
7931
+ "dataSourceType": "postgres",
7932
+ "tableName": "ss_agent_hub_tag",
7933
+ "userKeyFieldUserKey": "name",
7934
+ "isChild": false,
7935
+ "isSystem": true,
7936
+ "enableSoftDelete": false,
7937
+ "enableAuditTracking": true,
7938
+ "draftPublishWorkflow": false,
7939
+ "internationalisation": false,
7940
+ "legacyTableType": "none",
7941
+ "fields": [
7942
+ {
7943
+ "name": "name",
7944
+ "displayName": "Name",
7945
+ "type": "shortText",
7946
+ "ormType": "varchar",
7947
+ "required": true,
7948
+ "unique": true,
7949
+ "index": true,
7950
+ "private": false,
7951
+ "encrypt": false,
7952
+ "isSystem": true,
7953
+ "isUserKey": true,
7954
+ "enableAuditTracking": true
7955
+ },
7956
+ {
7957
+ "name": "skills",
7958
+ "displayName": "Skills",
7959
+ "type": "relation",
7960
+ "required": false,
7961
+ "unique": false,
7962
+ "index": false,
7963
+ "private": false,
7964
+ "encrypt": false,
7965
+ "relationType": "many-to-many",
7966
+ "relationCoModelSingularName": "agentSkillRegistry",
7967
+ "relationCoModelFieldName": "tags",
7968
+ "relationCreateInverse": false,
7969
+ "relationCascade": "set null",
7970
+ "relationModelModuleName": "solid-core",
7971
+ "isSystem": true,
7972
+ "isRelationManyToManyOwner": false,
7973
+ "enableAuditTracking": true
7974
+ },
7975
+ {
7976
+ "name": "tools",
7977
+ "displayName": "Tools",
7978
+ "type": "relation",
7979
+ "required": false,
7980
+ "unique": false,
7981
+ "index": false,
7982
+ "private": false,
7983
+ "encrypt": false,
7984
+ "relationType": "many-to-many",
7985
+ "relationCoModelSingularName": "agentToolRegistry",
7986
+ "relationCoModelFieldName": "tags",
7987
+ "relationCreateInverse": false,
7988
+ "relationCascade": "set null",
7989
+ "relationModelModuleName": "solid-core",
7990
+ "isSystem": true,
7991
+ "isRelationManyToManyOwner": false,
7992
+ "enableAuditTracking": true
7993
+ },
7994
+ {
7995
+ "name": "agents",
7996
+ "displayName": "Agents",
7997
+ "type": "relation",
7998
+ "required": false,
7999
+ "unique": false,
8000
+ "index": false,
8001
+ "private": false,
8002
+ "encrypt": false,
8003
+ "relationType": "many-to-many",
8004
+ "relationCoModelSingularName": "agentRegistry",
8005
+ "relationCoModelFieldName": "tags",
8006
+ "relationCreateInverse": false,
8007
+ "relationCascade": "set null",
8008
+ "relationModelModuleName": "solid-core",
8009
+ "isSystem": true,
8010
+ "isRelationManyToManyOwner": false,
8011
+ "enableAuditTracking": true
8012
+ }
8013
+ ]
8014
+ },
7926
8015
  {
7927
8016
  "singularName": "agentRegistry",
7928
8017
  "pluralName": "agentRegistries",
@@ -8229,6 +8318,25 @@
8229
8318
  "enableAuditTracking": true,
8230
8319
  "isPrimaryKey": false
8231
8320
  },
8321
+ {
8322
+ "name": "tags",
8323
+ "displayName": "Tags",
8324
+ "type": "relation",
8325
+ "required": false,
8326
+ "unique": false,
8327
+ "index": false,
8328
+ "private": false,
8329
+ "encrypt": false,
8330
+ "relationType": "many-to-many",
8331
+ "relationCoModelSingularName": "agentHubTag",
8332
+ "relationCoModelFieldName": "agents",
8333
+ "relationCreateInverse": true,
8334
+ "relationCascade": "set null",
8335
+ "relationModelModuleName": "solid-core",
8336
+ "isSystem": true,
8337
+ "isRelationManyToManyOwner": true,
8338
+ "enableAuditTracking": true
8339
+ },
8232
8340
  {
8233
8341
  "name": "agentTools",
8234
8342
  "displayName": "Agent Tools",
@@ -8496,26 +8604,6 @@
8496
8604
  "columnName": null,
8497
8605
  "enableAuditTracking": true
8498
8606
  },
8499
- {
8500
- "name": "tags",
8501
- "displayName": "Tags",
8502
- "description": null,
8503
- "type": "longText",
8504
- "ormType": "text",
8505
- "isSystem": true,
8506
- "regexPattern": null,
8507
- "regexPatternNotMatchingErrorMsg": null,
8508
- "defaultValue": "[]",
8509
- "required": true,
8510
- "unique": false,
8511
- "index": false,
8512
- "private": false,
8513
- "encrypt": false,
8514
- "encryptionType": null,
8515
- "decryptWhen": null,
8516
- "columnName": null,
8517
- "enableAuditTracking": true
8518
- },
8519
8607
  {
8520
8608
  "name": "type",
8521
8609
  "displayName": "Type",
@@ -8630,6 +8718,25 @@
8630
8718
  "columnName": null,
8631
8719
  "enableAuditTracking": true
8632
8720
  },
8721
+ {
8722
+ "name": "tags",
8723
+ "displayName": "Tags",
8724
+ "type": "relation",
8725
+ "required": false,
8726
+ "unique": false,
8727
+ "index": false,
8728
+ "private": false,
8729
+ "encrypt": false,
8730
+ "relationType": "many-to-many",
8731
+ "relationCoModelSingularName": "agentHubTag",
8732
+ "relationCoModelFieldName": "tools",
8733
+ "relationCreateInverse": true,
8734
+ "relationCascade": "set null",
8735
+ "relationModelModuleName": "solid-core",
8736
+ "isSystem": true,
8737
+ "isRelationManyToManyOwner": true,
8738
+ "enableAuditTracking": true
8739
+ },
8633
8740
  {
8634
8741
  "name": "agentTools",
8635
8742
  "displayName": "Agent Tools",
@@ -8782,21 +8889,22 @@
8782
8889
  },
8783
8890
  {
8784
8891
  "name": "tags",
8785
- "enableAuditTracking": true,
8786
8892
  "displayName": "Tags",
8787
- "description": null,
8788
- "type": "longText",
8789
- "ormType": "text",
8790
- "isSystem": true,
8791
- "required": true,
8893
+ "type": "relation",
8894
+ "required": false,
8792
8895
  "unique": false,
8793
8896
  "index": false,
8794
8897
  "private": false,
8795
8898
  "encrypt": false,
8796
- "encryptionType": null,
8797
- "decryptWhen": null,
8798
- "columnName": null,
8799
- "defaultValue": "{}"
8899
+ "relationType": "many-to-many",
8900
+ "relationCoModelSingularName": "agentHubTag",
8901
+ "relationCoModelFieldName": "skills",
8902
+ "relationCreateInverse": true,
8903
+ "relationCascade": "set null",
8904
+ "relationModelModuleName": "solid-core",
8905
+ "isSystem": true,
8906
+ "isRelationManyToManyOwner": true,
8907
+ "enableAuditTracking": true
8800
8908
  },
8801
8909
  {
8802
8910
  "name": "agentSkills",
@@ -12369,6 +12477,19 @@
12369
12477
  "moduleUserKey": "solid-core",
12370
12478
  "modelUserKey": "agentSkillRegistry"
12371
12479
  },
12480
+ {
12481
+ "displayName": "Agent Hub Tags List Action",
12482
+ "name": "agentHubTag-list-action",
12483
+ "type": "solid",
12484
+ "domain": "",
12485
+ "context": "",
12486
+ "customComponent": "",
12487
+ "customIsModal": true,
12488
+ "serverEndpoint": "",
12489
+ "viewUserKey": "agentHubTag-list-view",
12490
+ "moduleUserKey": "solid-core",
12491
+ "modelUserKey": "agentHubTag"
12492
+ },
12372
12493
  {
12373
12494
  "displayName": "Agent Tool List Action",
12374
12495
  "name": "agentTool-list-action",
@@ -13123,6 +13244,15 @@
13123
13244
  "parentMenuItemUserKey": "agent-menu-item",
13124
13245
  "iconName": "chat"
13125
13246
  },
13247
+ {
13248
+ "displayName": "Tags",
13249
+ "name": "agentHubTag-menu-item",
13250
+ "sequenceNumber": 8,
13251
+ "actionUserKey": "agentHubTag-list-action",
13252
+ "moduleUserKey": "solid-core",
13253
+ "parentMenuItemUserKey": "agent-menu-item",
13254
+ "iconName": "sell"
13255
+ },
13126
13256
  {
13127
13257
  "displayName": "Human Requests",
13128
13258
  "name": "agentHumanRequest-menu-item",
@@ -24738,6 +24868,190 @@
24738
24868
  ]
24739
24869
  }
24740
24870
  },
24871
+ {
24872
+ "name": "agentHubTag-list-view",
24873
+ "displayName": "Agent Hub Tags",
24874
+ "type": "list",
24875
+ "context": "{}",
24876
+ "moduleUserKey": "solid-core",
24877
+ "modelUserKey": "agentHubTag",
24878
+ "layout": {
24879
+ "type": "list",
24880
+ "attrs": {
24881
+ "pagination": true,
24882
+ "pageSizeOptions": [
24883
+ 10,
24884
+ 25,
24885
+ 50
24886
+ ],
24887
+ "enableGlobalSearch": true,
24888
+ "create": true,
24889
+ "edit": true,
24890
+ "delete": true,
24891
+ "allowedViews": [
24892
+ "list"
24893
+ ]
24894
+ },
24895
+ "children": [
24896
+ {
24897
+ "type": "field",
24898
+ "attrs": {
24899
+ "name": "id"
24900
+ }
24901
+ },
24902
+ {
24903
+ "type": "field",
24904
+ "attrs": {
24905
+ "name": "name",
24906
+ "isSearchable": true,
24907
+ "sortable": true
24908
+ }
24909
+ }
24910
+ ]
24911
+ }
24912
+ },
24913
+ {
24914
+ "name": "agentHubTag-form-view",
24915
+ "displayName": "Agent Hub Tag",
24916
+ "type": "form",
24917
+ "context": "{}",
24918
+ "moduleUserKey": "solid-core",
24919
+ "modelUserKey": "agentHubTag",
24920
+ "layout": {
24921
+ "type": "form",
24922
+ "attrs": {
24923
+ "name": "form-1",
24924
+ "label": "Agent Hub Tag",
24925
+ "className": "grid",
24926
+ "showAddFormButton": true,
24927
+ "showEditFormButton": true
24928
+ },
24929
+ "children": [
24930
+ {
24931
+ "type": "sheet",
24932
+ "attrs": {
24933
+ "name": "sheet-1"
24934
+ },
24935
+ "children": [
24936
+ {
24937
+ "type": "notebook",
24938
+ "attrs": {
24939
+ "name": "notebook-1"
24940
+ },
24941
+ "children": [
24942
+ {
24943
+ "type": "page",
24944
+ "attrs": {
24945
+ "name": "details",
24946
+ "label": "Details"
24947
+ },
24948
+ "children": [
24949
+ {
24950
+ "type": "group",
24951
+ "attrs": {
24952
+ "name": "details-fields",
24953
+ "label": "",
24954
+ "className": "col-12 sm:col-12 md:col-6 lg:col-6"
24955
+ },
24956
+ "children": [
24957
+ {
24958
+ "type": "field",
24959
+ "attrs": {
24960
+ "name": "name"
24961
+ }
24962
+ }
24963
+ ]
24964
+ }
24965
+ ]
24966
+ },
24967
+ {
24968
+ "type": "page",
24969
+ "attrs": {
24970
+ "name": "skills",
24971
+ "label": "Skills"
24972
+ },
24973
+ "children": [
24974
+ {
24975
+ "type": "group",
24976
+ "attrs": {
24977
+ "name": "skills-fields",
24978
+ "label": "",
24979
+ "className": "col-12"
24980
+ },
24981
+ "children": [
24982
+ {
24983
+ "type": "field",
24984
+ "attrs": {
24985
+ "name": "skills",
24986
+ "editWidget": "DefaultRelationManyToManyCheckBoxFormEditWidget",
24987
+ "showLabel": false
24988
+ }
24989
+ }
24990
+ ]
24991
+ }
24992
+ ]
24993
+ },
24994
+ {
24995
+ "type": "page",
24996
+ "attrs": {
24997
+ "name": "tools",
24998
+ "label": "Tools"
24999
+ },
25000
+ "children": [
25001
+ {
25002
+ "type": "group",
25003
+ "attrs": {
25004
+ "name": "tools-fields",
25005
+ "label": "",
25006
+ "className": "col-12"
25007
+ },
25008
+ "children": [
25009
+ {
25010
+ "type": "field",
25011
+ "attrs": {
25012
+ "name": "tools",
25013
+ "editWidget": "DefaultRelationManyToManyCheckBoxFormEditWidget",
25014
+ "showLabel": false
25015
+ }
25016
+ }
25017
+ ]
25018
+ }
25019
+ ]
25020
+ },
25021
+ {
25022
+ "type": "page",
25023
+ "attrs": {
25024
+ "name": "agents",
25025
+ "label": "Agents"
25026
+ },
25027
+ "children": [
25028
+ {
25029
+ "type": "group",
25030
+ "attrs": {
25031
+ "name": "agents-fields",
25032
+ "label": "",
25033
+ "className": "col-12"
25034
+ },
25035
+ "children": [
25036
+ {
25037
+ "type": "field",
25038
+ "attrs": {
25039
+ "name": "agents",
25040
+ "editWidget": "DefaultRelationManyToManyCheckBoxFormEditWidget",
25041
+ "showLabel": false
25042
+ }
25043
+ }
25044
+ ]
25045
+ }
25046
+ ]
25047
+ }
25048
+ ]
25049
+ }
25050
+ ]
25051
+ }
25052
+ ]
25053
+ }
25054
+ },
24741
25055
  {
24742
25056
  "name": "agentSkillRegistry-list-view",
24743
25057
  "displayName": "Skills List View",
@@ -0,0 +1,19 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { ModuleRef } from '@nestjs/core';
3
+ import { InjectEntityManager } from '@nestjs/typeorm';
4
+ import { EntityManager } from 'typeorm';
5
+ import { AgentHubTag } from '../entities/agent-hub-tag.entity';
6
+ import { AgentHubTagRepository } from '../repository/agent-hub-tag.repository';
7
+ import { CRUDService } from './crud.service';
8
+
9
+ @Injectable()
10
+ export class AgentHubTagService extends CRUDService<AgentHubTag> {
11
+ constructor(
12
+ @InjectEntityManager('default')
13
+ readonly entityManager: EntityManager,
14
+ readonly repo: AgentHubTagRepository,
15
+ readonly moduleRef: ModuleRef,
16
+ ) {
17
+ super(entityManager, repo, 'agentHubTag', 'agent-hub', moduleRef);
18
+ }
19
+ }
@@ -21,7 +21,7 @@ function fixture() {
21
21
  const repo = { findOne: jest.fn(async () => ({ ...row })) };
22
22
  const transaction = { findOne: jest.fn(async () => ({ ...row })), save: jest.fn(async (_entity, saved) => saved) };
23
23
  const entityManager = { transaction: jest.fn(async (fn) => fn(transaction)) };
24
- const service = new AgentToolRegistryService(entityManager as any, repo as any, {} as any);
24
+ const service = new AgentToolRegistryService(entityManager as any, repo as any, {} as any, {} as any);
25
25
  return { row, repo, transaction, entityManager, service };
26
26
  }
27
27
 
@@ -1,8 +1,13 @@
1
- import { ConflictException, Injectable } from '@nestjs/common';
1
+ import { BadRequestException, ConflictException, Injectable, Logger, NotFoundException, ServiceUnavailableException } from '@nestjs/common';
2
2
  import { InjectEntityManager } from '@nestjs/typeorm';
3
3
  import { ModuleRef } from '@nestjs/core';
4
4
  import { EntityManager } from 'typeorm';
5
5
  import { createHash } from 'node:crypto';
6
+ import { spawn } from 'node:child_process';
7
+ import { existsSync } from 'node:fs';
8
+ import { homedir, tmpdir } from 'node:os';
9
+ import { join } from 'node:path';
10
+ import { SecretService } from './secret.service';
6
11
  import { AgentTool } from '../entities/agent-tool.entity';
7
12
  import { AgentConfigCatalogService } from './agent-config-version.service';
8
13
  import { AgentToolRegistry } from '../entities/agent-tool-registry.entity';
@@ -12,11 +17,14 @@ import { UpdateAgentToolRegistryDto } from '../dtos/update-agent-tool-registry.d
12
17
 
13
18
  @Injectable()
14
19
  export class AgentToolRegistryService extends AgentConfigCatalogService<AgentToolRegistry>{
20
+ private readonly logger = new Logger(AgentToolRegistryService.name);
21
+
15
22
  constructor(
16
23
  @InjectEntityManager("default")
17
24
  readonly entityManager: EntityManager,
18
25
  readonly repo: AgentToolRegistryRepository,
19
26
  readonly moduleRef: ModuleRef,
27
+ readonly secretService: SecretService,
20
28
  ) {
21
29
  super(entityManager, repo, 'agentToolRegistry', moduleRef, AgentTool, 'agentToolRegistry');
22
30
  }
@@ -33,6 +41,158 @@ export class AgentToolRegistryService extends AgentConfigCatalogService<AgentToo
33
41
  };
34
42
  }
35
43
 
44
+ private lifecycleRunner(): { python: string; runtimeRoot: string; sourceRoot?: string } {
45
+ const binary = process.platform === 'win32' ? 'python.exe' : 'python';
46
+ const configuredSourceRoot = process.env.SOLIDX_AGENTHUB_RUNTIME_PATH;
47
+ const sourceRoot = configuredSourceRoot
48
+ && existsSync(join(configuredSourceRoot, 'src', 'agenthub', 'tools', 'tool_lifecycle_check.py'))
49
+ ? configuredSourceRoot
50
+ : undefined;
51
+ const candidates = [
52
+ { root: join(homedir(), '.solidx', 'agenthub-venv'), sourceRoot },
53
+ ...(process.env.SOLIDX_AGENTHUB_RUNTIME_PATH
54
+ ? [{ root: join(process.env.SOLIDX_AGENTHUB_RUNTIME_PATH, '.venv'), sourceRoot }]
55
+ : []),
56
+ ];
57
+ for (const candidate of candidates) {
58
+ const python = join(candidate.root, process.platform === 'win32' ? 'Scripts' : 'bin', binary);
59
+ if (existsSync(python)) return { python, runtimeRoot: candidate.root, sourceRoot: candidate.sourceRoot };
60
+ }
61
+ throw new ServiceUnavailableException('AgentHub runtime virtual environment was not found.');
62
+ }
63
+
64
+ private lifecycleDatabaseUrl(): string {
65
+ const options = this.entityManager.connection.options as any;
66
+ if (options.type !== 'postgres') {
67
+ throw new ServiceUnavailableException('Tool checks require Core to use PostgreSQL.');
68
+ }
69
+ if (options.url) return options.url;
70
+ const host = String(options.host ?? 'localhost');
71
+ const formattedHost = host.includes(':') && !host.startsWith('[') ? `[${host}]` : host;
72
+ const credentials = options.username
73
+ ? `${encodeURIComponent(String(options.username))}:${encodeURIComponent(String(options.password ?? ''))}@`
74
+ : '';
75
+ const ssl = options.ssl ? '?sslmode=require' : '';
76
+ return `postgresql://${credentials}${formattedHost}:${options.port ?? 5432}/${encodeURIComponent(String(options.database))}${ssl}`;
77
+ }
78
+
79
+ private async runLifecycleScript(request: Record<string, unknown>): Promise<Record<string, any>> {
80
+ const runner = this.lifecycleRunner();
81
+ const requestJson = JSON.stringify(request);
82
+ const childEnv = {
83
+ PATH: process.env.PATH ?? '',
84
+ VIRTUAL_ENV: runner.runtimeRoot,
85
+ HOME: homedir(),
86
+ DATABASE_URL: this.lifecycleDatabaseUrl(),
87
+ ...(process.env.SYSTEMROOT ? { SYSTEMROOT: process.env.SYSTEMROOT } : {}),
88
+ ...(runner.sourceRoot ? { PYTHONPATH: join(runner.sourceRoot, 'src') } : {}),
89
+ };
90
+ return new Promise((resolve, reject) => {
91
+ const child = spawn(runner.python, ['-m', 'agenthub.tools.tool_lifecycle_check'], {
92
+ cwd: runner.sourceRoot ?? tmpdir(),
93
+ env: childEnv,
94
+ stdio: ['pipe', 'pipe', 'pipe'],
95
+ });
96
+ let stdout = '';
97
+ let stderr = '';
98
+ let settled = false;
99
+ const finish = (callback: () => void) => {
100
+ if (settled) return;
101
+ settled = true;
102
+ clearTimeout(timeout);
103
+ callback();
104
+ };
105
+ const timeout = setTimeout(() => {
106
+ child.kill('SIGKILL');
107
+ finish(() => reject(new ServiceUnavailableException('Tool check exceeded the 20 second limit.')));
108
+ }, 20_000);
109
+ child.stdout.setEncoding('utf8');
110
+ child.stderr.setEncoding('utf8');
111
+ child.stdout.on('data', (chunk: string) => {
112
+ stdout += chunk;
113
+ if (stdout.length > 2_000_000) child.kill('SIGKILL');
114
+ });
115
+ child.stderr.on('data', (chunk: string) => {
116
+ if (stderr.length < 2_000_000) stderr += chunk.slice(0, 2_000_000 - stderr.length);
117
+ });
118
+ child.on('error', (error) => finish(() => reject(new ServiceUnavailableException(`Could not start AgentHub tool checker: ${error.message}`))));
119
+ child.on('close', (code) => finish(() => {
120
+ if (stdout.length > 2_000_000) {
121
+ reject(new BadRequestException('Tool check response was too large.'));
122
+ return;
123
+ }
124
+ try {
125
+ const result = JSON.parse(stdout.trim());
126
+ if (!result || typeof result !== 'object' || Array.isArray(result)) throw new Error('Invalid response');
127
+ resolve(result);
128
+ } catch {
129
+ reject(new ServiceUnavailableException(`AgentHub tool checker returned an invalid response${code === 0 ? '' : ` (exit ${code})`}. ${stderr.slice(0, 500)}`));
130
+ }
131
+ }));
132
+ child.stdin.end(requestJson);
133
+ });
134
+ }
135
+
136
+ private async readToolConfig(tool: AgentToolRegistry, checksum: string): Promise<{ success: boolean; message: string; requiredSecrets: string[] }> {
137
+ const result = await this.runLifecycleScript({ tool_id: tool.id, checksum, phase: 'config' });
138
+ const requiredSecrets = result.required_secrets;
139
+ if (result.success !== true || !Array.isArray(requiredSecrets)
140
+ || requiredSecrets.some((key) => typeof key !== 'string' || !key.trim())
141
+ || new Set(requiredSecrets).size !== requiredSecrets.length) {
142
+ return { success: false, message: String(result.message ?? 'The tool returned an invalid configuration.'), requiredSecrets: [] };
143
+ }
144
+ return { success: true, message: String(result.message ?? 'Configuration declaration checked.'), requiredSecrets };
145
+ }
146
+
147
+ async checkTool(id: number, phase: string, checksum: string) {
148
+ if (phase !== 'config' && phase !== 'init') throw new BadRequestException('Phase must be config or init.');
149
+ const tool = await this.repo.findOne({ where: { id } });
150
+ if (!tool) throw new NotFoundException(`Tool ${id} was not found.`);
151
+ if (!['custom', 'thirdparty'].includes(tool.type)) throw new BadRequestException('Only custom and third-party tools can be checked.');
152
+ const currentChecksum = createHash('sha256').update(tool.sourceCode ?? '', 'utf8').digest('hex');
153
+ if (!checksum || checksum !== currentChecksum) throw new ConflictException('Tool source changed. Save the tool again before running checks.');
154
+
155
+ const config = await this.readToolConfig(tool, currentChecksum);
156
+ if (!config.success) {
157
+ return {
158
+ toolId: id, checksum, phase,
159
+ config: { status: 'failed', message: config.message, requiredSecrets: [], missingSecrets: [] },
160
+ init: { status: 'skipped', message: 'Configuration must pass before initialization can run.' },
161
+ };
162
+ }
163
+
164
+ const resolvedSecrets = phase === 'init'
165
+ ? await this.secretService.resolveAvailable(config.requiredSecrets)
166
+ : undefined;
167
+ const available = phase === 'config'
168
+ ? await this.secretService.findAvailableKeys(config.requiredSecrets)
169
+ : Object.keys(resolvedSecrets ?? {});
170
+ const missingSecrets = config.requiredSecrets.filter((key) => !available.includes(key));
171
+ const configStep = {
172
+ status: missingSecrets.length ? 'failed' : 'passed',
173
+ message: missingSecrets.length ? 'Configure all required active secrets before initializing this tool.' : config.message,
174
+ requiredSecrets: config.requiredSecrets,
175
+ missingSecrets,
176
+ };
177
+ if (missingSecrets.length || phase === 'config') {
178
+ return {
179
+ toolId: id, checksum, phase, config: configStep,
180
+ init: { status: 'skipped', message: missingSecrets.length ? 'Required secrets must be configured first.' : 'Run initialization after configuration passes.' },
181
+ };
182
+ }
183
+
184
+ const secretValues = Object.fromEntries(Object.entries(resolvedSecrets ?? {}).map(([key, value]) => [
185
+ key, typeof value === 'string' ? value : JSON.stringify(value),
186
+ ]));
187
+ const init = await this.runLifecycleScript({
188
+ tool_id: id, checksum, phase: 'init', secret_values: secretValues,
189
+ });
190
+ return {
191
+ toolId: id, checksum, phase, config: configStep,
192
+ init: { status: init.success === true ? 'passed' : 'failed', message: String(init.message ?? (init.success ? 'Initialization check passed.' : 'Initialization check failed.')) },
193
+ };
194
+ }
195
+
36
196
  override async create(createDto: CreateAgentToolRegistryDto, files: Express.Multer.File[] = [], solidRequestContext: any = {}): Promise<AgentToolRegistry> {
37
197
  return super.create(this.withChecksum({ ...createDto, status: 'inactive', lastLoadError: null }), files, solidRequestContext);
38
198
  }
@@ -143,6 +143,16 @@ export class SecretService extends CRUDService<Secret> {
143
143
  }, {} as Record<string, any>);
144
144
  }
145
145
 
146
+ async findAvailableKeys(keys: string[]): Promise<string[]> {
147
+ const uniqueKeys = Array.from(new Set((keys ?? []).filter(Boolean)));
148
+ if (uniqueKeys.length === 0) return [];
149
+ const secrets = await this.repo.find({
150
+ where: { key: In(uniqueKeys), status: "active" } as any,
151
+ select: { key: true } as any,
152
+ });
153
+ return secrets.map((secret) => secret.key);
154
+ }
155
+
146
156
  /**
147
157
  * Resolves several secrets in a single query, returning a flat map keyed by the
148
158
  * literal keys requested.