aimeat 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.env.example +4 -1
- package/dist/bin/aimeat.js +0 -0
- package/dist/locales/en.json +527 -7
- package/dist/locales/fi.json +526 -6
- package/dist/public/css/views/admin-agent-integration.css +304 -0
- package/dist/public/css/views/agents-detail.css +1573 -146
- package/dist/public/css/views/public-knowledge-viewer.css +479 -0
- package/dist/public/js/i18n.js +9 -3
- package/dist/public/js/services/admin-agent-integration.js +52 -0
- package/dist/public/js/services/agent-integration.js +80 -0
- package/dist/public/js/services/agent-messages.js +3 -1
- package/dist/public/lib/live-updates.js +9 -4
- package/dist/public/llms-template.txt +106 -0
- package/dist/public/spa.html +7 -2
- package/dist/public/views/admin/agent-integration-tab.js +390 -0
- package/dist/public/views/admin.js +2 -0
- package/dist/public/views/profile/agents/agent-card.js +396 -0
- package/dist/public/views/profile/agents/shared-board.js +97 -0
- package/dist/public/views/profile/agents/state-detector.js +62 -0
- package/dist/public/views/profile/agents/tab-activity.js +232 -0
- package/dist/public/views/profile/agents/tab-agent-config.js +199 -0
- package/dist/public/views/profile/agents/tab-data-access.js +304 -0
- package/dist/public/views/profile/agents/tab-directives.js +178 -0
- package/dist/public/views/profile/agents/tab-integration.js +505 -0
- package/dist/public/views/profile/agents/tab-messages.js +278 -0
- package/dist/public/views/profile/agents/tab-services.js +17 -0
- package/dist/public/views/profile/agents/tab-tasks.js +17 -0
- package/dist/public/views/profile/agents-messages-subtab.js +11 -10
- package/dist/public/views/profile/agents-services-subtab.js +17 -11
- package/dist/public/views/profile/agents-tab.js +159 -259
- package/dist/public/views/profile/agents-task-builder.js +403 -0
- package/dist/public/views/profile/agents-tasks-subtab.js +114 -127
- package/dist/public/views/public-knowledge-viewer.js +650 -0
- package/dist/src/auth/middleware.d.ts.map +1 -1
- package/dist/src/auth/middleware.js +17 -0
- package/dist/src/auth/middleware.js.map +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +1 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/middleware/readiness-gate.d.ts +18 -0
- package/dist/src/middleware/readiness-gate.d.ts.map +1 -0
- package/dist/src/middleware/readiness-gate.js +50 -0
- package/dist/src/middleware/readiness-gate.js.map +1 -0
- package/dist/src/models/agent-directives-schemas.d.ts +12 -0
- package/dist/src/models/agent-directives-schemas.d.ts.map +1 -1
- package/dist/src/models/agent-directives-schemas.js +7 -0
- package/dist/src/models/agent-directives-schemas.js.map +1 -1
- package/dist/src/models/agent-onboarding-schemas.d.ts +45 -0
- package/dist/src/models/agent-onboarding-schemas.d.ts.map +1 -0
- package/dist/src/models/agent-onboarding-schemas.js +91 -0
- package/dist/src/models/agent-onboarding-schemas.js.map +1 -0
- package/dist/src/models/webhook-schemas.d.ts +266 -0
- package/dist/src/models/webhook-schemas.d.ts.map +1 -0
- package/dist/src/models/webhook-schemas.js +137 -0
- package/dist/src/models/webhook-schemas.js.map +1 -0
- package/dist/src/routes/admin-agent-integration.d.ts +24 -0
- package/dist/src/routes/admin-agent-integration.d.ts.map +1 -0
- package/dist/src/routes/admin-agent-integration.js +186 -0
- package/dist/src/routes/admin-agent-integration.js.map +1 -0
- package/dist/src/routes/agent-activity.d.ts.map +1 -1
- package/dist/src/routes/agent-activity.js +17 -0
- package/dist/src/routes/agent-activity.js.map +1 -1
- package/dist/src/routes/agent-directives.d.ts +5 -1
- package/dist/src/routes/agent-directives.d.ts.map +1 -1
- package/dist/src/routes/agent-directives.js +74 -20
- package/dist/src/routes/agent-directives.js.map +1 -1
- package/dist/src/routes/agent-integration.d.ts +1 -0
- package/dist/src/routes/agent-integration.d.ts.map +1 -1
- package/dist/src/routes/agent-integration.js +128 -11
- package/dist/src/routes/agent-integration.js.map +1 -1
- package/dist/src/routes/agent-messages.d.ts +5 -1
- package/dist/src/routes/agent-messages.d.ts.map +1 -1
- package/dist/src/routes/agent-messages.js +20 -1
- package/dist/src/routes/agent-messages.js.map +1 -1
- package/dist/src/routes/agent-onboarding.d.ts +23 -0
- package/dist/src/routes/agent-onboarding.d.ts.map +1 -0
- package/dist/src/routes/agent-onboarding.js +374 -0
- package/dist/src/routes/agent-onboarding.js.map +1 -0
- package/dist/src/routes/agent-skill-bundle.d.ts +16 -0
- package/dist/src/routes/agent-skill-bundle.d.ts.map +1 -0
- package/dist/src/routes/agent-skill-bundle.js +133 -0
- package/dist/src/routes/agent-skill-bundle.js.map +1 -0
- package/dist/src/routes/agent-tasks.d.ts +7 -1
- package/dist/src/routes/agent-tasks.d.ts.map +1 -1
- package/dist/src/routes/agent-tasks.js +183 -7
- package/dist/src/routes/agent-tasks.js.map +1 -1
- package/dist/src/routes/agent-telemetry.d.ts +15 -0
- package/dist/src/routes/agent-telemetry.d.ts.map +1 -0
- package/dist/src/routes/agent-telemetry.js +99 -0
- package/dist/src/routes/agent-telemetry.js.map +1 -0
- package/dist/src/routes/agent-webhook.d.ts +18 -0
- package/dist/src/routes/agent-webhook.d.ts.map +1 -0
- package/dist/src/routes/agent-webhook.js +243 -0
- package/dist/src/routes/agent-webhook.js.map +1 -0
- package/dist/src/routes/agents.d.ts.map +1 -1
- package/dist/src/routes/agents.js +203 -4
- package/dist/src/routes/agents.js.map +1 -1
- package/dist/src/routes/auth.d.ts.map +1 -1
- package/dist/src/routes/auth.js +45 -2
- package/dist/src/routes/auth.js.map +1 -1
- package/dist/src/routes/ghii.d.ts.map +1 -1
- package/dist/src/routes/ghii.js +42 -5
- package/dist/src/routes/ghii.js.map +1 -1
- package/dist/src/routes/knowledge.d.ts.map +1 -1
- package/dist/src/routes/knowledge.js +19 -7
- package/dist/src/routes/knowledge.js.map +1 -1
- package/dist/src/routes/memory.js +3 -3
- package/dist/src/routes/memory.js.map +1 -1
- package/dist/src/routes/portal.d.ts.map +1 -1
- package/dist/src/routes/portal.js +1 -0
- package/dist/src/routes/portal.js.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.js +16 -3
- package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
- package/dist/src/services/config-schema.d.ts.map +1 -1
- package/dist/src/services/config-schema.js +2 -1
- package/dist/src/services/config-schema.js.map +1 -1
- package/dist/src/services/core-jobs.d.ts.map +1 -1
- package/dist/src/services/core-jobs.js +3 -2
- package/dist/src/services/core-jobs.js.map +1 -1
- package/dist/src/services/onboarding-validator.d.ts +22 -0
- package/dist/src/services/onboarding-validator.d.ts.map +1 -0
- package/dist/src/services/onboarding-validator.js +202 -0
- package/dist/src/services/onboarding-validator.js.map +1 -0
- package/dist/src/services/platform-detector.d.ts +27 -0
- package/dist/src/services/platform-detector.d.ts.map +1 -0
- package/dist/src/services/platform-detector.js +73 -0
- package/dist/src/services/platform-detector.js.map +1 -0
- package/dist/src/services/prompt-defaults.d.ts.map +1 -1
- package/dist/src/services/prompt-defaults.js +129 -123
- package/dist/src/services/prompt-defaults.js.map +1 -1
- package/dist/src/services/readiness-scorer.d.ts +34 -0
- package/dist/src/services/readiness-scorer.d.ts.map +1 -0
- package/dist/src/services/readiness-scorer.js +87 -0
- package/dist/src/services/readiness-scorer.js.map +1 -0
- package/dist/src/services/skill-bundle/generator.d.ts +17 -0
- package/dist/src/services/skill-bundle/generator.d.ts.map +1 -0
- package/dist/src/services/skill-bundle/generator.js +387 -0
- package/dist/src/services/skill-bundle/generator.js.map +1 -0
- package/dist/src/services/skill-bundle/generic-adapter.d.ts +16 -0
- package/dist/src/services/skill-bundle/generic-adapter.d.ts.map +1 -0
- package/dist/src/services/skill-bundle/generic-adapter.js +96 -0
- package/dist/src/services/skill-bundle/generic-adapter.js.map +1 -0
- package/dist/src/services/skill-bundle/hermes-adapter.d.ts +25 -0
- package/dist/src/services/skill-bundle/hermes-adapter.d.ts.map +1 -0
- package/dist/src/services/skill-bundle/hermes-adapter.js +302 -0
- package/dist/src/services/skill-bundle/hermes-adapter.js.map +1 -0
- package/dist/src/services/skill-bundle/types.d.ts +54 -0
- package/dist/src/services/skill-bundle/types.d.ts.map +1 -0
- package/dist/src/services/skill-bundle/types.js +8 -0
- package/dist/src/services/skill-bundle/types.js.map +1 -0
- package/dist/src/services/task-stall-detector.d.ts +10 -2
- package/dist/src/services/task-stall-detector.d.ts.map +1 -1
- package/dist/src/services/task-stall-detector.js +34 -5
- package/dist/src/services/task-stall-detector.js.map +1 -1
- package/dist/src/services/webhook-dispatcher.d.ts +71 -0
- package/dist/src/services/webhook-dispatcher.d.ts.map +1 -0
- package/dist/src/services/webhook-dispatcher.js +259 -0
- package/dist/src/services/webhook-dispatcher.js.map +1 -0
- package/dist/src/storage/interface.d.ts +80 -2
- package/dist/src/storage/interface.d.ts.map +1 -1
- package/dist/src/storage/providers/mongodb/index.d.ts +20 -1
- package/dist/src/storage/providers/mongodb/index.d.ts.map +1 -1
- package/dist/src/storage/providers/mongodb/index.js +250 -2
- package/dist/src/storage/providers/mongodb/index.js.map +1 -1
- package/dist/src/storage/providers/sqlite/index.d.ts +18 -1
- package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/index.js +168 -4
- package/dist/src/storage/providers/sqlite/index.js.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/agent-directives.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/agent-directives.js +8 -4
- package/dist/src/storage/providers/sqlite/repos/agent-directives.js.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/agent.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/agent.js +25 -4
- package/dist/src/storage/providers/sqlite/repos/agent.js.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.js +71 -1
- package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
- package/dist/src/storage/repositories/agent-onboarding.repository.d.ts +16 -0
- package/dist/src/storage/repositories/agent-onboarding.repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/agent-onboarding.repository.js +8 -0
- package/dist/src/storage/repositories/agent-onboarding.repository.js.map +1 -0
- package/dist/src/storage/repositories/agent-webhook.repository.d.ts +21 -0
- package/dist/src/storage/repositories/agent-webhook.repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/agent-webhook.repository.js +2 -0
- package/dist/src/storage/repositories/agent-webhook.repository.js.map +1 -0
- package/dist/src/storage/repositories/agent.repository.d.ts +1 -0
- package/dist/src/storage/repositories/agent.repository.d.ts.map +1 -1
- package/dist/src/storage/repositories/index.d.ts +2 -0
- package/dist/src/storage/repositories/index.d.ts.map +1 -1
- package/dist/src/utils/env-config.d.ts.map +1 -1
- package/dist/src/utils/env-config.js +7 -1
- package/dist/src/utils/env-config.js.map +1 -1
- package/dist/src/utils/url-validator.d.ts.map +1 -1
- package/dist/src/utils/url-validator.js +3 -0
- package/dist/src/utils/url-validator.js.map +1 -1
- package/package.json +97 -77
- package/prisma/schema.prisma +65 -7
|
@@ -188,6 +188,16 @@ export class MongoStorage {
|
|
|
188
188
|
activityStats: agent.activityStats ?? null,
|
|
189
189
|
modulesLoaded: agent.modulesLoaded ?? null,
|
|
190
190
|
agentLimitations: agent.agentLimitations ?? null,
|
|
191
|
+
webhookUrl: agent.webhookUrl ?? null,
|
|
192
|
+
webhookSecret: agent.webhookSecret ?? null,
|
|
193
|
+
webhookEnabled: agent.webhookEnabled ?? false,
|
|
194
|
+
webhookLastSuccess: agent.webhookLastSuccess ? new Date(agent.webhookLastSuccess) : null,
|
|
195
|
+
webhookLastFailure: agent.webhookLastFailure ? new Date(agent.webhookLastFailure) : null,
|
|
196
|
+
webhookFailCount: agent.webhookFailCount ?? 0,
|
|
197
|
+
platform: agent.platform ?? null,
|
|
198
|
+
platformVersion: agent.platformVersion ?? null,
|
|
199
|
+
platformDetectedBy: agent.platformDetectedBy ?? null,
|
|
200
|
+
tags: agent.tags ?? [],
|
|
191
201
|
createdAt: new Date(agent.createdAt),
|
|
192
202
|
lastSeen: new Date(agent.lastSeen),
|
|
193
203
|
},
|
|
@@ -199,6 +209,11 @@ export class MongoStorage {
|
|
|
199
209
|
const row = await this.prisma.agent.findUnique({ where: { gaii } });
|
|
200
210
|
return row ? this.toAgentRecord(row) : null;
|
|
201
211
|
}
|
|
212
|
+
async getAgentByName(name, nodeId) {
|
|
213
|
+
this.ensureReady();
|
|
214
|
+
const row = await this.prisma.agent.findFirst({ where: { name } });
|
|
215
|
+
return row ? this.toAgentRecord(row) : null;
|
|
216
|
+
}
|
|
202
217
|
async getAgentsByOwner(owner) {
|
|
203
218
|
this.ensureReady();
|
|
204
219
|
const rows = await this.prisma.agent.findMany({ where: { owner } });
|
|
@@ -297,6 +312,19 @@ export class MongoStorage {
|
|
|
297
312
|
catch { /* not found */ }
|
|
298
313
|
// Agent activity
|
|
299
314
|
await this.prisma.agentActivity.deleteMany({ where: { agentGaii: gaii } });
|
|
315
|
+
// Agent messages
|
|
316
|
+
await this.prisma.agentMessage.deleteMany({ where: { agentGaii: gaii } });
|
|
317
|
+
// Telemetry events
|
|
318
|
+
await this.prisma.telemetryEvent.deleteMany({ where: { agentGaii: gaii } });
|
|
319
|
+
// Webhook delivery logs
|
|
320
|
+
await this.prisma.webhookDeliveryLog.deleteMany({ where: { agentGaii: gaii } });
|
|
321
|
+
// Onboarding record
|
|
322
|
+
try {
|
|
323
|
+
await this.prisma.agentOnboarding.delete({ where: { agentGaii: gaii } });
|
|
324
|
+
}
|
|
325
|
+
catch { /* not found */ }
|
|
326
|
+
// Sharing groups
|
|
327
|
+
await this.prisma.sharingGroup.deleteMany({ where: { ownerGaii: gaii } });
|
|
300
328
|
}
|
|
301
329
|
async listAgents() {
|
|
302
330
|
this.ensureReady();
|
|
@@ -1383,7 +1411,7 @@ export class MongoStorage {
|
|
|
1383
1411
|
return { name: row.name, displayName: row.displayName ?? undefined, publicKey: row.publicKey, roles: row.roles, createdAt: row.createdAt.toISOString() };
|
|
1384
1412
|
}
|
|
1385
1413
|
toAgentRecord(row) {
|
|
1386
|
-
return { name: row.name, owner: row.owner, gaii: row.gaii, displayName: row.displayName ?? undefined, description: row.description ?? undefined, capabilities: row.capabilities, publicKey: row.publicKey, trustScore: row.trustScore, morselBalance: row.morselBalance, defaultScopes: row.defaultScopes?.length ? row.defaultScopes : undefined, allowedOrigins: row.allowedOrigins?.length ? row.allowedOrigins : undefined, federate: row.federate ?? false, technicalCapabilities: row.technicalCapabilities ?? undefined, domainCapabilities: row.domainCapabilities ?? undefined, activityStats: row.activityStats ?? undefined, modulesLoaded: row.modulesLoaded ?? undefined, agentLimitations: row.agentLimitations ?? undefined, createdAt: row.createdAt.toISOString(), lastSeen: row.lastSeen.toISOString() };
|
|
1414
|
+
return { name: row.name, owner: row.owner, gaii: row.gaii, displayName: row.displayName ?? undefined, description: row.description ?? undefined, capabilities: row.capabilities, publicKey: row.publicKey, trustScore: row.trustScore, morselBalance: row.morselBalance, defaultScopes: row.defaultScopes?.length ? row.defaultScopes : undefined, allowedOrigins: row.allowedOrigins?.length ? row.allowedOrigins : undefined, federate: row.federate ?? false, technicalCapabilities: row.technicalCapabilities ?? undefined, domainCapabilities: row.domainCapabilities ?? undefined, activityStats: row.activityStats ?? undefined, modulesLoaded: row.modulesLoaded ?? undefined, agentLimitations: row.agentLimitations ?? undefined, webhookUrl: row.webhookUrl ?? undefined, webhookSecret: row.webhookSecret ?? undefined, webhookEnabled: row.webhookEnabled ?? false, webhookLastSuccess: row.webhookLastSuccess ? row.webhookLastSuccess.toISOString() : undefined, webhookLastFailure: row.webhookLastFailure ? row.webhookLastFailure.toISOString() : undefined, webhookFailCount: row.webhookFailCount ?? 0, platform: row.platform ?? undefined, platformVersion: row.platformVersion ?? undefined, platformDetectedBy: row.platformDetectedBy ?? undefined, tags: row.tags?.length ? row.tags : undefined, createdAt: row.createdAt.toISOString(), lastSeen: row.lastSeen.toISOString() };
|
|
1387
1415
|
}
|
|
1388
1416
|
toMemoryRecord(row) {
|
|
1389
1417
|
return { key: row.key, ownerGaii: row.ownerGaii, value: row.value, visibility: row.visibility, groupId: row.groupId ?? undefined, tags: row.tags, ttlHours: row.ttlHours, version: row.version, createdAt: row.createdAt.toISOString(), updatedAt: row.updatedAt.toISOString(), flagCount: row.flagCount ?? undefined, allowedOrigins: row.allowedOrigins?.length ? row.allowedOrigins : undefined };
|
|
@@ -5693,7 +5721,7 @@ export class MongoStorage {
|
|
|
5693
5721
|
}
|
|
5694
5722
|
// ── Agent Directives ──
|
|
5695
5723
|
toDirectivesRecord(row) {
|
|
5696
|
-
|
|
5724
|
+
const record = {
|
|
5697
5725
|
agentGaii: row.agentGaii,
|
|
5698
5726
|
purpose: row.purpose,
|
|
5699
5727
|
rules: row.rules,
|
|
@@ -5701,6 +5729,9 @@ export class MongoStorage {
|
|
|
5701
5729
|
resources: row.resources,
|
|
5702
5730
|
updatedAt: row.updatedAt instanceof Date ? row.updatedAt.toISOString() : row.updatedAt,
|
|
5703
5731
|
};
|
|
5732
|
+
if (row.budgetLimits)
|
|
5733
|
+
record.budgetLimits = row.budgetLimits;
|
|
5734
|
+
return record;
|
|
5704
5735
|
}
|
|
5705
5736
|
toOwnerDefaultsRecord(row) {
|
|
5706
5737
|
const record = {
|
|
@@ -5730,12 +5761,14 @@ export class MongoStorage {
|
|
|
5730
5761
|
rules: record.rules,
|
|
5731
5762
|
memoryAreas: record.memoryAreas,
|
|
5732
5763
|
resources: record.resources,
|
|
5764
|
+
budgetLimits: record.budgetLimits ?? null,
|
|
5733
5765
|
},
|
|
5734
5766
|
update: {
|
|
5735
5767
|
purpose: record.purpose,
|
|
5736
5768
|
rules: record.rules,
|
|
5737
5769
|
memoryAreas: record.memoryAreas,
|
|
5738
5770
|
resources: record.resources,
|
|
5771
|
+
budgetLimits: record.budgetLimits ?? null,
|
|
5739
5772
|
},
|
|
5740
5773
|
});
|
|
5741
5774
|
return this.toDirectivesRecord(row);
|
|
@@ -5950,6 +5983,221 @@ export class MongoStorage {
|
|
|
5950
5983
|
results.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
5951
5984
|
return results;
|
|
5952
5985
|
}
|
|
5986
|
+
// ══════════════════════════════════════════════════════════
|
|
5987
|
+
// ── Agent Onboarding ──
|
|
5988
|
+
// ══════════════════════════════════════════════════════════
|
|
5989
|
+
toOnboardingRecord(row) {
|
|
5990
|
+
return {
|
|
5991
|
+
agentGaii: row.agentGaii,
|
|
5992
|
+
status: row.status,
|
|
5993
|
+
startedAt: row.startedAt instanceof Date ? row.startedAt.toISOString() : row.startedAt,
|
|
5994
|
+
completedAt: row.completedAt instanceof Date ? row.completedAt.toISOString() : row.completedAt ?? undefined,
|
|
5995
|
+
steps: row.steps,
|
|
5996
|
+
readinessScore: row.readinessScore ?? undefined,
|
|
5997
|
+
readinessLevel: row.readinessLevel ?? undefined,
|
|
5998
|
+
detectedPlatform: row.detectedPlatform ?? undefined,
|
|
5999
|
+
installedRuntime: row.installedRuntime ?? undefined,
|
|
6000
|
+
onboardingBaseline: row.onboardingBaseline ?? undefined,
|
|
6001
|
+
operationalHealth: row.operationalHealth ?? undefined,
|
|
6002
|
+
healthComponents: row.healthComponents ?? undefined,
|
|
6003
|
+
healthRecalculatedAt: row.healthRecalculatedAt instanceof Date ? row.healthRecalculatedAt.toISOString() : row.healthRecalculatedAt ?? undefined,
|
|
6004
|
+
readinessOverride: row.readinessOverride ?? undefined,
|
|
6005
|
+
};
|
|
6006
|
+
}
|
|
6007
|
+
async createOnboarding(record) {
|
|
6008
|
+
this.ensureReady();
|
|
6009
|
+
const row = await this.prisma.agentOnboarding.create({
|
|
6010
|
+
data: {
|
|
6011
|
+
agentGaii: record.agentGaii,
|
|
6012
|
+
status: record.status,
|
|
6013
|
+
startedAt: new Date(record.startedAt),
|
|
6014
|
+
completedAt: record.completedAt ? new Date(record.completedAt) : null,
|
|
6015
|
+
steps: record.steps,
|
|
6016
|
+
readinessScore: record.readinessScore ?? null,
|
|
6017
|
+
readinessLevel: record.readinessLevel ?? null,
|
|
6018
|
+
detectedPlatform: record.detectedPlatform ?? null,
|
|
6019
|
+
installedRuntime: record.installedRuntime ?? null,
|
|
6020
|
+
onboardingBaseline: record.onboardingBaseline ?? null,
|
|
6021
|
+
operationalHealth: record.operationalHealth ?? null,
|
|
6022
|
+
healthComponents: record.healthComponents ?? null,
|
|
6023
|
+
healthRecalculatedAt: record.healthRecalculatedAt ? new Date(record.healthRecalculatedAt) : null,
|
|
6024
|
+
readinessOverride: record.readinessOverride ?? null,
|
|
6025
|
+
},
|
|
6026
|
+
});
|
|
6027
|
+
return this.toOnboardingRecord(row);
|
|
6028
|
+
}
|
|
6029
|
+
async getOnboarding(agentGaii) {
|
|
6030
|
+
this.ensureReady();
|
|
6031
|
+
try {
|
|
6032
|
+
const row = await this.prisma.agentOnboarding.findUnique({ where: { agentGaii } });
|
|
6033
|
+
return row ? this.toOnboardingRecord(row) : null;
|
|
6034
|
+
}
|
|
6035
|
+
catch {
|
|
6036
|
+
return null;
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
async updateOnboarding(agentGaii, updates) {
|
|
6040
|
+
this.ensureReady();
|
|
6041
|
+
try {
|
|
6042
|
+
const data = {};
|
|
6043
|
+
if (updates.status !== undefined)
|
|
6044
|
+
data.status = updates.status;
|
|
6045
|
+
if (updates.startedAt !== undefined)
|
|
6046
|
+
data.startedAt = new Date(updates.startedAt);
|
|
6047
|
+
if (updates.completedAt !== undefined)
|
|
6048
|
+
data.completedAt = updates.completedAt ? new Date(updates.completedAt) : null;
|
|
6049
|
+
if (updates.steps !== undefined)
|
|
6050
|
+
data.steps = updates.steps;
|
|
6051
|
+
if (updates.readinessScore !== undefined)
|
|
6052
|
+
data.readinessScore = updates.readinessScore ?? null;
|
|
6053
|
+
if (updates.readinessLevel !== undefined)
|
|
6054
|
+
data.readinessLevel = updates.readinessLevel ?? null;
|
|
6055
|
+
if (updates.detectedPlatform !== undefined)
|
|
6056
|
+
data.detectedPlatform = updates.detectedPlatform ?? null;
|
|
6057
|
+
if (updates.installedRuntime !== undefined)
|
|
6058
|
+
data.installedRuntime = updates.installedRuntime ?? null;
|
|
6059
|
+
if (updates.onboardingBaseline !== undefined)
|
|
6060
|
+
data.onboardingBaseline = updates.onboardingBaseline ?? null;
|
|
6061
|
+
if (updates.operationalHealth !== undefined)
|
|
6062
|
+
data.operationalHealth = updates.operationalHealth ?? null;
|
|
6063
|
+
if (updates.healthComponents !== undefined)
|
|
6064
|
+
data.healthComponents = updates.healthComponents ?? null;
|
|
6065
|
+
if (updates.healthRecalculatedAt !== undefined)
|
|
6066
|
+
data.healthRecalculatedAt = updates.healthRecalculatedAt ? new Date(updates.healthRecalculatedAt) : null;
|
|
6067
|
+
if (updates.readinessOverride !== undefined)
|
|
6068
|
+
data.readinessOverride = updates.readinessOverride ?? null;
|
|
6069
|
+
const row = await this.prisma.agentOnboarding.update({ where: { agentGaii }, data });
|
|
6070
|
+
return this.toOnboardingRecord(row);
|
|
6071
|
+
}
|
|
6072
|
+
catch {
|
|
6073
|
+
return null;
|
|
6074
|
+
}
|
|
6075
|
+
}
|
|
6076
|
+
async deleteOnboarding(agentGaii) {
|
|
6077
|
+
this.ensureReady();
|
|
6078
|
+
try {
|
|
6079
|
+
await this.prisma.agentOnboarding.delete({ where: { agentGaii } });
|
|
6080
|
+
return true;
|
|
6081
|
+
}
|
|
6082
|
+
catch {
|
|
6083
|
+
return false;
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
async listOnboardingByOwner(owner) {
|
|
6087
|
+
this.ensureReady();
|
|
6088
|
+
const rows = await this.prisma.agentOnboarding.findMany({
|
|
6089
|
+
where: { agentGaii: { contains: `#${owner}@` } },
|
|
6090
|
+
orderBy: { startedAt: 'desc' },
|
|
6091
|
+
});
|
|
6092
|
+
return rows.map((r) => this.toOnboardingRecord(r));
|
|
6093
|
+
}
|
|
6094
|
+
async listOnboardingByStatus(status) {
|
|
6095
|
+
this.ensureReady();
|
|
6096
|
+
const rows = await this.prisma.agentOnboarding.findMany({
|
|
6097
|
+
where: { status },
|
|
6098
|
+
orderBy: { startedAt: 'desc' },
|
|
6099
|
+
});
|
|
6100
|
+
return rows.map((r) => this.toOnboardingRecord(r));
|
|
6101
|
+
}
|
|
6102
|
+
// ── Agent Telemetry ──
|
|
6103
|
+
toTelemetryEvent(row) {
|
|
6104
|
+
return {
|
|
6105
|
+
id: row.id,
|
|
6106
|
+
agentGaii: row.agentGaii,
|
|
6107
|
+
type: row.type,
|
|
6108
|
+
data: row.data,
|
|
6109
|
+
sessionId: row.sessionId ?? undefined,
|
|
6110
|
+
taskId: row.taskId ?? undefined,
|
|
6111
|
+
createdAt: row.createdAt.toISOString(),
|
|
6112
|
+
};
|
|
6113
|
+
}
|
|
6114
|
+
async appendTelemetry(event) {
|
|
6115
|
+
this.ensureReady();
|
|
6116
|
+
await this.prisma.telemetryEvent.create({
|
|
6117
|
+
data: {
|
|
6118
|
+
id: event.id,
|
|
6119
|
+
agentGaii: event.agentGaii,
|
|
6120
|
+
type: event.type,
|
|
6121
|
+
data: event.data,
|
|
6122
|
+
sessionId: event.sessionId ?? null,
|
|
6123
|
+
taskId: event.taskId ?? null,
|
|
6124
|
+
createdAt: new Date(event.createdAt),
|
|
6125
|
+
},
|
|
6126
|
+
});
|
|
6127
|
+
}
|
|
6128
|
+
async listTelemetry(agentGaii, opts) {
|
|
6129
|
+
this.ensureReady();
|
|
6130
|
+
const where = { agentGaii };
|
|
6131
|
+
if (opts.type)
|
|
6132
|
+
where.type = opts.type;
|
|
6133
|
+
if (opts.since)
|
|
6134
|
+
where.createdAt = { gt: new Date(opts.since) };
|
|
6135
|
+
const rows = await this.prisma.telemetryEvent.findMany({
|
|
6136
|
+
where,
|
|
6137
|
+
orderBy: { createdAt: 'desc' },
|
|
6138
|
+
take: opts.limit ?? 50,
|
|
6139
|
+
});
|
|
6140
|
+
return rows.map((r) => this.toTelemetryEvent(r));
|
|
6141
|
+
}
|
|
6142
|
+
// ── Webhook Delivery Log ──
|
|
6143
|
+
toDeliveryLog(row) {
|
|
6144
|
+
return {
|
|
6145
|
+
id: row.id,
|
|
6146
|
+
agentGaii: row.agentGaii,
|
|
6147
|
+
event: row.event,
|
|
6148
|
+
payload: row.payload,
|
|
6149
|
+
status: row.status,
|
|
6150
|
+
httpStatus: row.httpStatus ?? undefined,
|
|
6151
|
+
errorMessage: row.errorMessage ?? undefined,
|
|
6152
|
+
attemptCount: row.attemptCount,
|
|
6153
|
+
latencyMs: row.latencyMs,
|
|
6154
|
+
createdAt: row.createdAt.toISOString(),
|
|
6155
|
+
};
|
|
6156
|
+
}
|
|
6157
|
+
async appendDeliveryLog(log) {
|
|
6158
|
+
this.ensureReady();
|
|
6159
|
+
await this.prisma.webhookDeliveryLog.create({
|
|
6160
|
+
data: {
|
|
6161
|
+
id: log.id,
|
|
6162
|
+
agentGaii: log.agentGaii,
|
|
6163
|
+
event: log.event,
|
|
6164
|
+
payload: log.payload,
|
|
6165
|
+
status: log.status,
|
|
6166
|
+
httpStatus: log.httpStatus ?? null,
|
|
6167
|
+
errorMessage: log.errorMessage ?? null,
|
|
6168
|
+
attemptCount: log.attemptCount,
|
|
6169
|
+
latencyMs: log.latencyMs,
|
|
6170
|
+
createdAt: new Date(log.createdAt),
|
|
6171
|
+
},
|
|
6172
|
+
});
|
|
6173
|
+
}
|
|
6174
|
+
async listDeliveryLog(agentGaii, limit) {
|
|
6175
|
+
this.ensureReady();
|
|
6176
|
+
const rows = await this.prisma.webhookDeliveryLog.findMany({
|
|
6177
|
+
where: { agentGaii },
|
|
6178
|
+
orderBy: { createdAt: 'desc' },
|
|
6179
|
+
take: limit ?? 50,
|
|
6180
|
+
});
|
|
6181
|
+
return rows.map((r) => this.toDeliveryLog(r));
|
|
6182
|
+
}
|
|
6183
|
+
async pruneDeliveryLog(agentGaii, keepCount) {
|
|
6184
|
+
this.ensureReady();
|
|
6185
|
+
// Find the cutoff: the keepCount-th newest record's createdAt
|
|
6186
|
+
const cutoffRows = await this.prisma.webhookDeliveryLog.findMany({
|
|
6187
|
+
where: { agentGaii },
|
|
6188
|
+
orderBy: { createdAt: 'desc' },
|
|
6189
|
+
skip: keepCount,
|
|
6190
|
+
take: 1,
|
|
6191
|
+
select: { createdAt: true },
|
|
6192
|
+
});
|
|
6193
|
+
if (cutoffRows.length === 0)
|
|
6194
|
+
return 0;
|
|
6195
|
+
const cutoff = cutoffRows[0].createdAt;
|
|
6196
|
+
const result = await this.prisma.webhookDeliveryLog.deleteMany({
|
|
6197
|
+
where: { agentGaii, createdAt: { lte: cutoff } },
|
|
6198
|
+
});
|
|
6199
|
+
return result.count;
|
|
6200
|
+
}
|
|
5953
6201
|
}
|
|
5954
6202
|
/**
|
|
5955
6203
|
* Wildcard pattern matching: supports '*' (one segment) and '**' (multiple segments)
|