aimeat 1.2.6 → 1.3.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 (128) hide show
  1. package/dist/.env.example +4 -0
  2. package/dist/locales/en.json +74 -2
  3. package/dist/locales/fi.json +74 -2
  4. package/dist/public/css/views/capabilities.css +211 -0
  5. package/dist/public/llms-template.txt +152 -89
  6. package/dist/public/spa.html +1 -0
  7. package/dist/public/views/admin/capabilities-tab.js +114 -0
  8. package/dist/public/views/admin.js +2 -0
  9. package/dist/public/views/aimeat-os.js +194 -34
  10. package/dist/public/views/profile/capabilities-tab.js +252 -0
  11. package/dist/public/views/profile/extensions-tab.js +404 -50
  12. package/dist/public/views/profile/landing-page.js +2 -0
  13. package/dist/public/views/profile.js +2 -0
  14. package/dist/src/config.d.ts +11 -0
  15. package/dist/src/config.d.ts.map +1 -1
  16. package/dist/src/config.js +11 -0
  17. package/dist/src/config.js.map +1 -1
  18. package/dist/src/mcp/apps.d.ts +18 -0
  19. package/dist/src/mcp/apps.d.ts.map +1 -0
  20. package/dist/src/mcp/apps.js +241 -0
  21. package/dist/src/mcp/apps.js.map +1 -0
  22. package/dist/src/mcp/capabilities.d.ts +12 -0
  23. package/dist/src/mcp/capabilities.d.ts.map +1 -0
  24. package/dist/src/mcp/capabilities.js +187 -0
  25. package/dist/src/mcp/capabilities.js.map +1 -0
  26. package/dist/src/mcp/cortex.d.ts +17 -0
  27. package/dist/src/mcp/cortex.d.ts.map +1 -0
  28. package/dist/src/mcp/cortex.js +237 -0
  29. package/dist/src/mcp/cortex.js.map +1 -0
  30. package/dist/src/mcp/extensions.d.ts +4 -3
  31. package/dist/src/mcp/extensions.d.ts.map +1 -1
  32. package/dist/src/mcp/extensions.js +233 -3
  33. package/dist/src/mcp/extensions.js.map +1 -1
  34. package/dist/src/mcp/index.d.ts.map +1 -1
  35. package/dist/src/mcp/index.js +6 -0
  36. package/dist/src/mcp/index.js.map +1 -1
  37. package/dist/src/routes/admin-capabilities.d.ts +11 -0
  38. package/dist/src/routes/admin-capabilities.d.ts.map +1 -0
  39. package/dist/src/routes/admin-capabilities.js +54 -0
  40. package/dist/src/routes/admin-capabilities.js.map +1 -0
  41. package/dist/src/routes/capabilities.d.ts +11 -0
  42. package/dist/src/routes/capabilities.d.ts.map +1 -0
  43. package/dist/src/routes/capabilities.js +289 -0
  44. package/dist/src/routes/capabilities.js.map +1 -0
  45. package/dist/src/routes/cortex.d.ts.map +1 -1
  46. package/dist/src/routes/cortex.js +2 -0
  47. package/dist/src/routes/cortex.js.map +1 -1
  48. package/dist/src/routes/extensions.d.ts.map +1 -1
  49. package/dist/src/routes/extensions.js +9 -0
  50. package/dist/src/routes/extensions.js.map +1 -1
  51. package/dist/src/routes/lib-capabilities.d.ts +9 -0
  52. package/dist/src/routes/lib-capabilities.d.ts.map +1 -0
  53. package/dist/src/routes/lib-capabilities.js +190 -0
  54. package/dist/src/routes/lib-capabilities.js.map +1 -0
  55. package/dist/src/routes/libs.d.ts.map +1 -1
  56. package/dist/src/routes/libs.js +13 -0
  57. package/dist/src/routes/libs.js.map +1 -1
  58. package/dist/src/routes/verification.d.ts +10 -1
  59. package/dist/src/routes/verification.d.ts.map +1 -1
  60. package/dist/src/routes/verification.js +174 -24
  61. package/dist/src/routes/verification.js.map +1 -1
  62. package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
  63. package/dist/src/server-bootstrap/routes-loader.js +35 -2
  64. package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
  65. package/dist/src/services/capability-aggregator.d.ts +8 -0
  66. package/dist/src/services/capability-aggregator.d.ts.map +1 -0
  67. package/dist/src/services/capability-aggregator.js +239 -0
  68. package/dist/src/services/capability-aggregator.js.map +1 -0
  69. package/dist/src/services/capability-invoke.d.ts +20 -0
  70. package/dist/src/services/capability-invoke.d.ts.map +1 -0
  71. package/dist/src/services/capability-invoke.js +95 -0
  72. package/dist/src/services/capability-invoke.js.map +1 -0
  73. package/dist/src/services/config-schema.d.ts.map +1 -1
  74. package/dist/src/services/config-schema.js +4 -0
  75. package/dist/src/services/config-schema.js.map +1 -1
  76. package/dist/src/services/core-jobs.d.ts.map +1 -1
  77. package/dist/src/services/core-jobs.js +16 -0
  78. package/dist/src/services/core-jobs.js.map +1 -1
  79. package/dist/src/services/did-document.d.ts +25 -0
  80. package/dist/src/services/did-document.d.ts.map +1 -0
  81. package/dist/src/services/did-document.js +31 -0
  82. package/dist/src/services/did-document.js.map +1 -0
  83. package/dist/src/services/eudiw.d.ts +11 -1
  84. package/dist/src/services/eudiw.d.ts.map +1 -1
  85. package/dist/src/services/eudiw.js +43 -48
  86. package/dist/src/services/eudiw.js.map +1 -1
  87. package/dist/src/services/extension-runtime.d.ts.map +1 -1
  88. package/dist/src/services/extension-runtime.js +8 -5
  89. package/dist/src/services/extension-runtime.js.map +1 -1
  90. package/dist/src/services/job-seeding.d.ts.map +1 -1
  91. package/dist/src/services/job-seeding.js +4 -0
  92. package/dist/src/services/job-seeding.js.map +1 -1
  93. package/dist/src/services/oidc-client.d.ts +32 -0
  94. package/dist/src/services/oidc-client.d.ts.map +1 -0
  95. package/dist/src/services/oidc-client.js +67 -0
  96. package/dist/src/services/oidc-client.js.map +1 -0
  97. package/dist/src/services/sd-jwt.d.ts +21 -0
  98. package/dist/src/services/sd-jwt.d.ts.map +1 -0
  99. package/dist/src/services/sd-jwt.js +87 -0
  100. package/dist/src/services/sd-jwt.js.map +1 -0
  101. package/dist/src/services/vc-issuer.d.ts +20 -1
  102. package/dist/src/services/vc-issuer.d.ts.map +1 -1
  103. package/dist/src/services/vc-issuer.js +75 -15
  104. package/dist/src/services/vc-issuer.js.map +1 -1
  105. package/dist/src/storage/interface.d.ts +118 -1
  106. package/dist/src/storage/interface.d.ts.map +1 -1
  107. package/dist/src/storage/providers/mongodb/index.d.ts +37 -1
  108. package/dist/src/storage/providers/mongodb/index.d.ts.map +1 -1
  109. package/dist/src/storage/providers/mongodb/index.js +282 -0
  110. package/dist/src/storage/providers/mongodb/index.js.map +1 -1
  111. package/dist/src/storage/providers/sqlite/index.d.ts +37 -1
  112. package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
  113. package/dist/src/storage/providers/sqlite/index.js +241 -0
  114. package/dist/src/storage/providers/sqlite/index.js.map +1 -1
  115. package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
  116. package/dist/src/storage/providers/sqlite/schema.js +77 -0
  117. package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
  118. package/dist/src/storage/repositories/capability.repository.d.ts +35 -0
  119. package/dist/src/storage/repositories/capability.repository.d.ts.map +1 -0
  120. package/dist/src/storage/repositories/capability.repository.js +2 -0
  121. package/dist/src/storage/repositories/capability.repository.js.map +1 -0
  122. package/dist/src/storage/repositories/index.d.ts +1 -0
  123. package/dist/src/storage/repositories/index.d.ts.map +1 -1
  124. package/dist/src/storage/repositories/node.repository.d.ts +5 -1
  125. package/dist/src/storage/repositories/node.repository.d.ts.map +1 -1
  126. package/dist/static/app-catalog.html +156 -29
  127. package/package.json +6 -1
  128. package/prisma/schema.prisma +86 -0
@@ -2560,6 +2560,50 @@ export class MongoStorage {
2560
2560
  toTrustedIssuerRecord(row) {
2561
2561
  return { id: row.id, name: row.name, url: row.url, publicKey: row.publicKey, type: row.type, trusted: row.trusted, addedBy: row.addedBy, createdAt: row.createdAt instanceof Date ? row.createdAt.toISOString() : row.createdAt };
2562
2562
  }
2563
+ // ── Verification Nonces (Phase 3.3) ──
2564
+ async createVerificationNonce(record) {
2565
+ this.ensureReady();
2566
+ await this.prisma.verificationNonce.create({
2567
+ data: {
2568
+ id: record.id,
2569
+ owner: record.owner,
2570
+ type: record.type,
2571
+ state: record.state,
2572
+ nonce: record.nonce,
2573
+ redirectUri: record.redirectUri ?? '',
2574
+ createdAt: new Date(record.createdAt),
2575
+ expiresAt: new Date(record.expiresAt),
2576
+ },
2577
+ });
2578
+ return record;
2579
+ }
2580
+ async getVerificationNonce(state) {
2581
+ this.ensureReady();
2582
+ const row = await this.prisma.verificationNonce.findUnique({ where: { state } });
2583
+ if (!row)
2584
+ return null;
2585
+ return {
2586
+ id: row.id,
2587
+ owner: row.owner,
2588
+ type: row.type,
2589
+ state: row.state,
2590
+ nonce: row.nonce,
2591
+ redirectUri: row.redirectUri,
2592
+ createdAt: row.createdAt instanceof Date ? row.createdAt.toISOString() : row.createdAt,
2593
+ expiresAt: row.expiresAt instanceof Date ? row.expiresAt.toISOString() : row.expiresAt,
2594
+ };
2595
+ }
2596
+ async deleteVerificationNonce(state) {
2597
+ this.ensureReady();
2598
+ await this.prisma.verificationNonce.deleteMany({ where: { state } });
2599
+ }
2600
+ async cleanExpiredNonces() {
2601
+ this.ensureReady();
2602
+ const result = await this.prisma.verificationNonce.deleteMany({
2603
+ where: { expiresAt: { lt: new Date() } },
2604
+ });
2605
+ return result.count;
2606
+ }
2563
2607
  // ── Genesis Peers (Phase 3.4) ──
2564
2608
  async createGenesisPeer(record) {
2565
2609
  this.ensureReady();
@@ -4872,6 +4916,244 @@ export class MongoStorage {
4872
4916
  updatedAt: row.updatedAt instanceof Date ? row.updatedAt.toISOString() : row.updatedAt,
4873
4917
  };
4874
4918
  }
4919
+ // ── Capability Layer ──────────────────────────────────────────────
4920
+ toCapabilityRecord(row) {
4921
+ return {
4922
+ id: row.id,
4923
+ name: row.name,
4924
+ summary: row.summary ?? '',
4925
+ ownerGhii: row.ownerGhii,
4926
+ visibility: row.visibility ?? 'private',
4927
+ scope: 'local',
4928
+ status: row.status ?? 'draft',
4929
+ rejectionReason: row.rejectionReason ?? null,
4930
+ deprecationMessage: row.deprecationMessage ?? null,
4931
+ replacedBy: row.replacedBy ?? null,
4932
+ source: { type: row.sourceType, ref: row.sourceRef, version: row.sourceVersion ?? '' },
4933
+ authRequired: row.authRequired ?? 'registered',
4934
+ callable: row.callable ?? false,
4935
+ inputSchema: row.inputSchema ?? null,
4936
+ outputSchema: row.outputSchema ?? null,
4937
+ exports: row.exports ?? null,
4938
+ usage: row.usage ?? '',
4939
+ whenToUse: row.whenToUse ?? '',
4940
+ whenNotToUse: row.whenNotToUse ?? '',
4941
+ examples: row.examples ?? [],
4942
+ dependencies: row.dependencies ?? [],
4943
+ schemaHash: row.schemaHash ?? '',
4944
+ webhookUrl: row.webhookUrl ?? null,
4945
+ cost: row.cost ?? null,
4946
+ trustRequired: row.trustRequired ?? null,
4947
+ trust: row.trust ?? { operatorReviewed: false, reviewedAt: null, vouchCount: 0, publisherTrustScore: 0, codeAudited: false, auditNotes: null },
4948
+ redactedFields: row.redactedFields ?? [],
4949
+ operatorOverride: row.operatorOverride ?? null,
4950
+ stats: row.stats ?? { totalInvocations: 0, successCount: 0, errorCount: 0, lastInvokedAt: null, avgResponseMs: 0, lastError: null },
4951
+ tags: row.tags ?? [],
4952
+ createdAt: row.createdAt instanceof Date ? row.createdAt.toISOString() : row.createdAt,
4953
+ updatedAt: row.updatedAt instanceof Date ? row.updatedAt.toISOString() : row.updatedAt,
4954
+ };
4955
+ }
4956
+ async createCapability(record) {
4957
+ this.ensureReady();
4958
+ const row = await this.prisma.capability.create({
4959
+ data: {
4960
+ id: record.id, name: record.name, summary: record.summary,
4961
+ ownerGhii: record.ownerGhii, visibility: record.visibility, scope: record.scope,
4962
+ status: record.status, rejectionReason: record.rejectionReason,
4963
+ deprecationMessage: record.deprecationMessage, replacedBy: record.replacedBy,
4964
+ sourceType: record.source.type, sourceRef: record.source.ref, sourceVersion: record.source.version,
4965
+ authRequired: record.authRequired, callable: record.callable,
4966
+ inputSchema: record.inputSchema ?? undefined, outputSchema: record.outputSchema ?? undefined,
4967
+ exports: record.exports ?? undefined, usage: record.usage,
4968
+ whenToUse: record.whenToUse, whenNotToUse: record.whenNotToUse,
4969
+ examples: record.examples, dependencies: record.dependencies,
4970
+ schemaHash: record.schemaHash, webhookUrl: record.webhookUrl,
4971
+ cost: record.cost ?? undefined, trustRequired: record.trustRequired,
4972
+ trust: record.trust, redactedFields: record.redactedFields,
4973
+ operatorOverride: record.operatorOverride ?? undefined,
4974
+ stats: record.stats, tags: record.tags,
4975
+ },
4976
+ });
4977
+ return this.toCapabilityRecord(row);
4978
+ }
4979
+ async getCapability(id) {
4980
+ this.ensureReady();
4981
+ const row = await this.prisma.capability.findUnique({ where: { id } });
4982
+ return row ? this.toCapabilityRecord(row) : null;
4983
+ }
4984
+ async updateCapability(id, updates) {
4985
+ this.ensureReady();
4986
+ const data = { ...updates };
4987
+ if (updates.source) {
4988
+ data.sourceType = updates.source.type;
4989
+ data.sourceRef = updates.source.ref;
4990
+ data.sourceVersion = updates.source.version;
4991
+ delete data.source;
4992
+ }
4993
+ if (updates.trust) {
4994
+ data.trust = updates.trust;
4995
+ }
4996
+ if (updates.stats) {
4997
+ data.stats = updates.stats;
4998
+ }
4999
+ if (updates.operatorOverride !== undefined) {
5000
+ data.operatorOverride = updates.operatorOverride;
5001
+ }
5002
+ try {
5003
+ const row = await this.prisma.capability.update({ where: { id }, data });
5004
+ return this.toCapabilityRecord(row);
5005
+ }
5006
+ catch {
5007
+ return null;
5008
+ }
5009
+ }
5010
+ async deleteCapability(id) {
5011
+ this.ensureReady();
5012
+ try {
5013
+ await this.prisma.capability.delete({ where: { id } });
5014
+ return true;
5015
+ }
5016
+ catch {
5017
+ return false;
5018
+ }
5019
+ }
5020
+ async listCapabilities(filters) {
5021
+ this.ensureReady();
5022
+ const where = {};
5023
+ if (filters.ownerGhii)
5024
+ where.ownerGhii = filters.ownerGhii;
5025
+ if (filters.visibility)
5026
+ where.visibility = filters.visibility;
5027
+ if (filters.status)
5028
+ where.status = filters.status;
5029
+ if (filters.sourceType)
5030
+ where.sourceType = filters.sourceType;
5031
+ if (filters.authRequired)
5032
+ where.authRequired = filters.authRequired;
5033
+ if (filters.callable !== undefined)
5034
+ where.callable = filters.callable;
5035
+ if (filters.search) {
5036
+ where.OR = [
5037
+ { name: { contains: filters.search, mode: 'insensitive' } },
5038
+ { summary: { contains: filters.search, mode: 'insensitive' } },
5039
+ ];
5040
+ }
5041
+ // tags filter done in JS since tags is a Json field
5042
+ const page = filters.page || 1;
5043
+ const perPage = filters.perPage || 20;
5044
+ const [rows, total] = await Promise.all([
5045
+ this.prisma.capability.findMany({
5046
+ where, orderBy: { updatedAt: 'desc' },
5047
+ skip: (page - 1) * perPage, take: perPage,
5048
+ }),
5049
+ this.prisma.capability.count({ where }),
5050
+ ]);
5051
+ let caps = rows.map((r) => this.toCapabilityRecord(r));
5052
+ if (filters.tags?.length) {
5053
+ caps = caps.filter((c) => filters.tags.some(t => c.tags.includes(t)));
5054
+ }
5055
+ return { capabilities: caps, total };
5056
+ }
5057
+ async listCapabilitiesByOwner(ownerGhii) {
5058
+ this.ensureReady();
5059
+ const rows = await this.prisma.capability.findMany({ where: { ownerGhii }, orderBy: { updatedAt: 'desc' } });
5060
+ return rows.map((r) => this.toCapabilityRecord(r));
5061
+ }
5062
+ async getCapabilityBySourceRef(sourceRef) {
5063
+ this.ensureReady();
5064
+ const row = await this.prisma.capability.findFirst({ where: { sourceRef } });
5065
+ return row ? this.toCapabilityRecord(row) : null;
5066
+ }
5067
+ async listCapabilitiesBySourceType(sourceType) {
5068
+ this.ensureReady();
5069
+ const rows = await this.prisma.capability.findMany({ where: { sourceType } });
5070
+ return rows.map((r) => this.toCapabilityRecord(r));
5071
+ }
5072
+ async incrementCapabilityStats(id, delta) {
5073
+ this.ensureReady();
5074
+ const cap = await this.getCapability(id);
5075
+ if (!cap)
5076
+ return;
5077
+ const s = cap.stats;
5078
+ const newTotal = s.totalInvocations + delta.success + delta.error;
5079
+ const totalMs = (s.avgResponseMs * s.totalInvocations) + delta.totalMs;
5080
+ const updated = {
5081
+ totalInvocations: newTotal,
5082
+ successCount: s.successCount + delta.success,
5083
+ errorCount: s.errorCount + delta.error,
5084
+ lastInvokedAt: new Date().toISOString(),
5085
+ avgResponseMs: newTotal > 0 ? Math.round(totalMs / newTotal) : 0,
5086
+ lastError: delta.lastError ?? s.lastError,
5087
+ };
5088
+ await this.prisma.capability.update({ where: { id }, data: { stats: updated } });
5089
+ }
5090
+ async addCapabilityLog(entry) {
5091
+ this.ensureReady();
5092
+ await this.prisma.capabilityLog.create({
5093
+ data: {
5094
+ capabilityId: entry.capabilityId, callerGhii: entry.callerGhii,
5095
+ input: entry.input, status: entry.status,
5096
+ durationMs: entry.durationMs, error: entry.error,
5097
+ timestamp: new Date(entry.timestamp),
5098
+ },
5099
+ });
5100
+ }
5101
+ async listCapabilityLogs(capabilityId, filters) {
5102
+ this.ensureReady();
5103
+ const where = { capabilityId };
5104
+ if (filters.status)
5105
+ where.status = filters.status;
5106
+ const page = filters.page || 1;
5107
+ const perPage = filters.perPage || 50;
5108
+ const [rows, total] = await Promise.all([
5109
+ this.prisma.capabilityLog.findMany({
5110
+ where, orderBy: { timestamp: 'desc' },
5111
+ skip: (page - 1) * perPage, take: perPage,
5112
+ }),
5113
+ this.prisma.capabilityLog.count({ where }),
5114
+ ]);
5115
+ const logs = rows.map((r) => ({
5116
+ id: r.id,
5117
+ capabilityId: r.capabilityId,
5118
+ callerGhii: r.callerGhii,
5119
+ input: r.input ?? {},
5120
+ status: r.status,
5121
+ durationMs: r.durationMs,
5122
+ error: r.error ?? null,
5123
+ timestamp: r.timestamp instanceof Date ? r.timestamp.toISOString() : r.timestamp,
5124
+ }));
5125
+ return { logs, total };
5126
+ }
5127
+ async deleteCapabilityLogsBefore(before) {
5128
+ this.ensureReady();
5129
+ const result = await this.prisma.capabilityLog.deleteMany({ where: { timestamp: { lt: new Date(before) } } });
5130
+ return result.count;
5131
+ }
5132
+ async setCapabilityOverride(id, override) {
5133
+ this.ensureReady();
5134
+ await this.prisma.capability.update({ where: { id }, data: { operatorOverride: override ?? undefined } });
5135
+ }
5136
+ async setCapabilityTrust(id, trustUpdates) {
5137
+ const cap = await this.getCapability(id);
5138
+ if (!cap)
5139
+ return;
5140
+ const merged = { ...cap.trust, ...trustUpdates };
5141
+ await this.prisma.capability.update({ where: { id }, data: { trust: merged } });
5142
+ }
5143
+ async incrementVouchCount(id) {
5144
+ const cap = await this.getCapability(id);
5145
+ if (!cap)
5146
+ return;
5147
+ const trust = { ...cap.trust, vouchCount: cap.trust.vouchCount + 1 };
5148
+ await this.prisma.capability.update({ where: { id }, data: { trust: trust } });
5149
+ }
5150
+ async decrementVouchCount(id) {
5151
+ const cap = await this.getCapability(id);
5152
+ if (!cap)
5153
+ return;
5154
+ const trust = { ...cap.trust, vouchCount: Math.max(0, cap.trust.vouchCount - 1) };
5155
+ await this.prisma.capability.update({ where: { id }, data: { trust: trust } });
5156
+ }
4875
5157
  }
4876
5158
  /**
4877
5159
  * Wildcard pattern matching: supports '*' (one segment) and '**' (multiple segments)