@mebular/mcp 0.3.5 → 0.3.8
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/bin/mebular.mjs +120 -0
- package/package.json +4 -4
- package/src/adapter-health.mjs +213 -0
- package/src/adapter-provision.mjs +405 -0
- package/src/adapter-state.mjs +154 -0
- package/src/adapters/dsh.mjs +830 -0
- package/src/adapters/hermes.mjs +966 -0
- package/src/adapters/index.mjs +91 -0
- package/src/adapters/opencode.mjs +757 -0
- package/src/clients.mjs +184 -13
- package/src/first-run.mjs +343 -0
- package/src/memory-capability.mjs +15 -0
- package/src/memory-runtime-config.mjs +2 -0
- package/src/memory-runtime-effective.mjs +91 -0
- package/src/memory-runtime-supervisor.mjs +247 -2
- package/src/provision.mjs +11 -1
- package/src/serve.mjs +798 -11
- package/src/server.mjs +36 -0
- package/src/tools.mjs +8 -0
- package/src/version.mjs +1 -1
package/bin/mebular.mjs
CHANGED
|
@@ -363,6 +363,121 @@ async function runPrintConfig(flags) {
|
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
+
async function runAdapter(action, flags) {
|
|
367
|
+
const asJson = flags.json === true;
|
|
368
|
+
const out = (value) => console.log(JSON.stringify(value, null, 2));
|
|
369
|
+
const adapterErrorMessages = {
|
|
370
|
+
ADAPTER_UNSUPPORTED: '该宿主仅支持 MCP,不提供自动适配器',
|
|
371
|
+
ADAPTER_UNAVAILABLE: '该宿主的适配器尚未提供',
|
|
372
|
+
ADAPTER_PACKAGE_NOT_FOUND: '未找到适配器包',
|
|
373
|
+
ADAPTER_VERSION_MISMATCH: '适配器包版本与 App 不一致',
|
|
374
|
+
HOST_NOT_DETECTED: '未检测到宿主配置',
|
|
375
|
+
CONFIG_UNPARSEABLE: '宿主配置不是合法 JSON(未改写)',
|
|
376
|
+
CONFIG_STRUCTURE_UNKNOWN: '宿主配置结构未知(未改写)',
|
|
377
|
+
CONFIG_UNREADABLE: '宿主配置不可读(未改写)',
|
|
378
|
+
FORBIDDEN_PATH: '拒绝写入宿主私有配置',
|
|
379
|
+
NOT_CONNECTED: '宿主未连接,跳过适配器写入',
|
|
380
|
+
VERIFY_FAILED: '适配器验证失败',
|
|
381
|
+
VERIFY_CONFIG_MISSING: '适配器配置不存在',
|
|
382
|
+
VERIFY_CONFIG_UNPARSEABLE: '适配器配置无法解析',
|
|
383
|
+
VERIFY_STRUCTURE_UNKNOWN: '适配器配置结构未知',
|
|
384
|
+
VERIFY_ENTRY_MISSING: '适配器条目缺失',
|
|
385
|
+
VERIFY_ENTRY_DUPLICATE: '适配器条目重复(旧版本未清理)',
|
|
386
|
+
VERIFY_OPTIONS_MISMATCH: '适配器选项不完整',
|
|
387
|
+
VERIFY_PACKAGE_MISSING: '适配器包缺失',
|
|
388
|
+
ACTIVATION_FAILED: '适配器激活失败',
|
|
389
|
+
WRITE_FAILED: '写入失败',
|
|
390
|
+
ROLLBACK_FAILED: '回滚失败',
|
|
391
|
+
};
|
|
392
|
+
const fail = (code) => {
|
|
393
|
+
const message = adapterErrorMessages[code] ?? '适配器命令失败';
|
|
394
|
+
if (asJson) out({ ok: false, code, message });
|
|
395
|
+
else console.error(`✗ ${message}(${code})`);
|
|
396
|
+
process.exit(2);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
try {
|
|
400
|
+
if (action === 'status') {
|
|
401
|
+
const { adapterStatus } = await import('../src/adapter-provision.mjs');
|
|
402
|
+
const view = adapterStatus({ home: homeDir() });
|
|
403
|
+
// Read-only CLI projection: always expose adapter/installedAt/lastIngestedAt
|
|
404
|
+
// (null when absent) without changing the on-disk state shape.
|
|
405
|
+
const projectedHosts = Object.fromEntries(Object.entries(view.hosts ?? {}).map(([hostId, record]) => [
|
|
406
|
+
hostId,
|
|
407
|
+
{
|
|
408
|
+
...record,
|
|
409
|
+
adapter: record.adapter ?? 'absent',
|
|
410
|
+
installedAt: record.installedAt ?? null,
|
|
411
|
+
lastIngestedAt: record.lastIngestedAt ?? null,
|
|
412
|
+
},
|
|
413
|
+
]));
|
|
414
|
+
const projected = { ...view, hosts: projectedHosts };
|
|
415
|
+
if (asJson) {
|
|
416
|
+
out(projected);
|
|
417
|
+
} else {
|
|
418
|
+
const entries = Object.entries(projected.hosts);
|
|
419
|
+
if (entries.length === 0) console.log('(尚无适配器状态;连接 AI 助手后会写入 adapters.json)');
|
|
420
|
+
for (const [hostId, record] of entries) {
|
|
421
|
+
console.log(`${hostId}\t${record.adapter ?? 'absent'}${record.version ? `\tv${record.version}` : ''}${record.activation ? `\t${record.activation}` : ''}${record.lastError ? `\t${record.lastError}` : ''}`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (action === 'ensure') {
|
|
428
|
+
const hostId = typeof flags.host === 'string' && flags.host.length > 0 ? flags.host : 'opencode';
|
|
429
|
+
const { ensureAdapter } = await import('../src/adapter-provision.mjs');
|
|
430
|
+
const { assistantUserHome } = await import('../src/clients.mjs');
|
|
431
|
+
const result = await ensureAdapter(hostId, {
|
|
432
|
+
home: homeDir(),
|
|
433
|
+
userHome: assistantUserHome(),
|
|
434
|
+
cwd: process.cwd(),
|
|
435
|
+
...(typeof flags.config === 'string' ? { configPath: flags.config } : {}),
|
|
436
|
+
...(typeof flags.package === 'string' ? { adapterPackagePath: flags.package } : {}),
|
|
437
|
+
...(typeof flags['expected-version'] === 'string' ? { expectedVersion: flags['expected-version'] } : {}),
|
|
438
|
+
...(typeof flags['resources-path'] === 'string' ? { resourcesPath: flags['resources-path'] } : {}),
|
|
439
|
+
...(flags['dry-run'] === true ? { dryRun: true } : {}),
|
|
440
|
+
...(flags.force === true ? { force: true } : {}),
|
|
441
|
+
});
|
|
442
|
+
if (!result.ok) return fail(result.code ?? 'ADAPTER_COMMAND_FAILED');
|
|
443
|
+
if (asJson) out(result);
|
|
444
|
+
else console.log(`✓ ${hostId}\t${result.status}${result.activation ? `\t${result.activation}` : ''}${result.changed ? '\t已更新' : '\t无改动'}`);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (action === 'repair') {
|
|
449
|
+
const { listAssistantsAsync, assistantUserHome } = await import('../src/clients.mjs');
|
|
450
|
+
const { ensureAdaptersForConnected } = await import('../src/adapter-provision.mjs');
|
|
451
|
+
const userHome = assistantUserHome();
|
|
452
|
+
const list = await listAssistantsAsync({ home: homeDir(), userHome, cwd: process.cwd(), refresh: true, ttlMs: 0 });
|
|
453
|
+
const connectedHostIds = list.assistants.filter((assistant) => assistant.connected === true).map((assistant) => assistant.id);
|
|
454
|
+
const result = await ensureAdaptersForConnected({
|
|
455
|
+
home: homeDir(),
|
|
456
|
+
userHome,
|
|
457
|
+
cwd: process.cwd(),
|
|
458
|
+
connectedHostIds,
|
|
459
|
+
...(typeof flags['resources-path'] === 'string' ? { resourcesPath: flags['resources-path'] } : {}),
|
|
460
|
+
});
|
|
461
|
+
if (asJson) out(result);
|
|
462
|
+
else {
|
|
463
|
+
console.log(`适配器修复:${result.summary.active} 活跃 · ${result.summary.installed} 已安装 · ${result.summary.unsupported} 不支持 · ${result.summary.degraded} 降级`);
|
|
464
|
+
for (const host of result.hosts) {
|
|
465
|
+
console.log(` ${host.hostId}\t${host.ok ? host.status : host.code}`);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (!result.ok) process.exitCode = 2;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
fail('ADAPTER_COMMAND_FAILED');
|
|
473
|
+
} catch (error) {
|
|
474
|
+
const code = typeof error?.code === 'string' && /^[A-Z][A-Z0-9_]{0,63}$/.test(error.code)
|
|
475
|
+
? error.code
|
|
476
|
+
: 'ADAPTER_COMMAND_FAILED';
|
|
477
|
+
fail(code);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
366
481
|
async function runConsole(flags) {
|
|
367
482
|
const { homeDir: home, loadConfigFile } = await import('../src/config.mjs');
|
|
368
483
|
const dir = home();
|
|
@@ -2280,6 +2395,10 @@ async function main() {
|
|
|
2280
2395
|
await runConsole(flags);
|
|
2281
2396
|
return;
|
|
2282
2397
|
}
|
|
2398
|
+
case 'adapter': {
|
|
2399
|
+
await runAdapter(argv[1], flags);
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2283
2402
|
case 'cloud': {
|
|
2284
2403
|
await runCloud(argv[1], argv.slice(2), flags);
|
|
2285
2404
|
return;
|
|
@@ -2312,6 +2431,7 @@ async function main() {
|
|
|
2312
2431
|
' serve [--host --port --auth --tls-key --tls-cert --tokens-file] Streamable HTTP server',
|
|
2313
2432
|
' service install|uninstall|restart|status|logs [--no-autostart --label L] 常驻服务管理(mebular-serve)',
|
|
2314
2433
|
' console [--host --port] 打印控制台 URL(需 serve 正在运行)',
|
|
2434
|
+
' adapter status|ensure|repair [--host H] [--json] [--dry-run] [--config P] [--package P] 宿主适配器状态/准备/修复',
|
|
2315
2435
|
' cloud list|use|rename [id] [name] [--force] 忆云管理(use 停旧/起新/失败回滚)',
|
|
2316
2436
|
' runtime resolve|ensure|status|supervise [--start auto|child|service] [--port N] [--json] 共享 runtime(supervise 持有 child)',
|
|
2317
2437
|
' runtime install|reinstall [--version V] [--json] 安装/重装共享 runtime(固定 @mebular/core 版本)',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mebular/mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Mebular MCP server (stdio + Streamable HTTP): exposes Mebular memory and task capabilities to any MCP client. | Mebular MCP server(stdio + Streamable HTTP):把 Mebular 的记忆与任务能力暴露给任意 MCP client。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mebular/core": "^0.3.
|
|
33
|
-
"@mebular/memory-runtime": "^0.3.
|
|
32
|
+
"@mebular/core": "^0.3.8",
|
|
33
|
+
"@mebular/memory-runtime": "^0.3.8",
|
|
34
34
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
35
35
|
"zod": "^4.6.7",
|
|
36
|
-
"@mebular/fleet": "^0.3.
|
|
36
|
+
"@mebular/fleet": "^0.3.8"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Adapter health from the existing Memory Runtime sidecar (W1/W7).
|
|
2
|
+
//
|
|
3
|
+
// The sidecar already knows whether an adapter is really working:
|
|
4
|
+
// * `/status.counts.ingested` — has any ingest landed?
|
|
5
|
+
// * `/traces?limit=…` — did this host produce recall/context evidence?
|
|
6
|
+
//
|
|
7
|
+
// Discovery lives at `<home>/memory-runtime.json`; the host token is read from
|
|
8
|
+
// its `tokenFile` (JSON `{ token }`, or a bare token for older runtimes) and is
|
|
9
|
+
// never logged or persisted. `probeAdapterHealth` is strictly read-only and
|
|
10
|
+
// fails open: a missing/unreachable/unauthorized sidecar is `deferred`, never a
|
|
11
|
+
// false `degraded`.
|
|
12
|
+
|
|
13
|
+
import { readFileSync } from 'node:fs';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { homeDir } from './home.mjs';
|
|
16
|
+
|
|
17
|
+
export const HEALTH_AGENT_IDS = Object.freeze({
|
|
18
|
+
opencode: 'opencode',
|
|
19
|
+
// OpenChamber shares the OpenCode plugin (`agentId=opencode`).
|
|
20
|
+
openchamber: 'opencode',
|
|
21
|
+
dsh: 'dsh',
|
|
22
|
+
hermes: 'hermes',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const HEALTH_STATES = Object.freeze(['healthy', 'degraded', 'deferred']);
|
|
26
|
+
|
|
27
|
+
const DEFAULT_TIMEOUT_MS = 1500;
|
|
28
|
+
const DEFAULT_TRACE_LIMIT = 50;
|
|
29
|
+
const MAX_TRACE_LIMIT = 100;
|
|
30
|
+
const API_PREFIX = '/memory-runtime/v1';
|
|
31
|
+
|
|
32
|
+
/** Stable host → sidecar `agentId` (OpenChamber reuses the OpenCode plugin). */
|
|
33
|
+
export function agentIdForHost(hostId) {
|
|
34
|
+
if (typeof hostId !== 'string' || hostId.length === 0) return null;
|
|
35
|
+
return HEALTH_AGENT_IDS[hostId] ?? hostId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function positiveInt(value, fallback, max = Number.MAX_SAFE_INTEGER) {
|
|
39
|
+
const number = typeof value === 'number' ? value : Number(value);
|
|
40
|
+
if (!Number.isFinite(number) || number <= 0) return fallback;
|
|
41
|
+
return Math.min(Math.trunc(number), max);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function timestamp(value) {
|
|
45
|
+
const number = typeof value === 'number' ? value : Number(value);
|
|
46
|
+
return Number.isFinite(number) && number >= 0 ? Math.trunc(number) : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readJson(file) {
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(readFileSync(file, 'utf-8'));
|
|
52
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Read the sidecar discovery record; null when absent/unreadable. */
|
|
59
|
+
export function readRuntimeDiscovery(home = homeDir()) {
|
|
60
|
+
const discovery = readJson(join(home, 'memory-runtime.json'));
|
|
61
|
+
if (!discovery) return null;
|
|
62
|
+
return discovery;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Runtime base URL with the `/memory-runtime/v1` API prefix, or null. */
|
|
66
|
+
export function runtimeBaseUrl(discovery) {
|
|
67
|
+
if (!discovery || typeof discovery !== 'object') return null;
|
|
68
|
+
if (typeof discovery.url === 'string' && discovery.url.length > 0) {
|
|
69
|
+
return discovery.url.replace(/\/+$/, '');
|
|
70
|
+
}
|
|
71
|
+
const host = typeof discovery.host === 'string' && discovery.host.length > 0 ? discovery.host : null;
|
|
72
|
+
const port = positiveInt(discovery.port, 0, 65535);
|
|
73
|
+
if (!host || port === 0) return null;
|
|
74
|
+
return `http://${host}:${port}${API_PREFIX}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Host token from `tokenFile`; supports JSON `{ token }` and bare tokens. */
|
|
78
|
+
export function readHostToken(discovery) {
|
|
79
|
+
if (!discovery || typeof discovery.tokenFile !== 'string' || discovery.tokenFile.length === 0) return '';
|
|
80
|
+
let raw;
|
|
81
|
+
try {
|
|
82
|
+
raw = readFileSync(discovery.tokenFile, 'utf-8').trim();
|
|
83
|
+
} catch {
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
if (raw.length === 0) return '';
|
|
87
|
+
try {
|
|
88
|
+
const parsed = JSON.parse(raw);
|
|
89
|
+
if (parsed && typeof parsed.token === 'string') return parsed.token.trim();
|
|
90
|
+
} catch {
|
|
91
|
+
// Older/raw token file.
|
|
92
|
+
}
|
|
93
|
+
return raw;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function getJson(fetchImpl, url, token, timeoutMs) {
|
|
97
|
+
const headers = { accept: 'application/json' };
|
|
98
|
+
if (token.length > 0) headers.authorization = `Bearer ${token}`;
|
|
99
|
+
const init = { method: 'GET', headers };
|
|
100
|
+
if (typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function') {
|
|
101
|
+
init.signal = AbortSignal.timeout(timeoutMs);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const response = await fetchImpl(url, init);
|
|
105
|
+
if (!response || response.ok === false) return { ok: false };
|
|
106
|
+
let body = null;
|
|
107
|
+
try {
|
|
108
|
+
body = typeof response.json === 'function' ? await response.json() : null;
|
|
109
|
+
} catch {
|
|
110
|
+
body = null;
|
|
111
|
+
}
|
|
112
|
+
if (body && typeof body === 'object' && body.ok === false) return { ok: false };
|
|
113
|
+
const data = body && typeof body === 'object' && body.data !== undefined
|
|
114
|
+
? body.data
|
|
115
|
+
: body;
|
|
116
|
+
return { ok: true, data };
|
|
117
|
+
} catch {
|
|
118
|
+
return { ok: false };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function deferred(code = null, extra = {}) {
|
|
123
|
+
return {
|
|
124
|
+
state: 'deferred',
|
|
125
|
+
code,
|
|
126
|
+
health: 'deferred',
|
|
127
|
+
available: false,
|
|
128
|
+
ingested: null,
|
|
129
|
+
traces: 0,
|
|
130
|
+
lastIngestedAt: null,
|
|
131
|
+
...extra,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Probe one host's real adapter health through the sidecar.
|
|
137
|
+
*
|
|
138
|
+
* Returns `{ state, code, available, ingested, traces, lastIngestedAt, agentId }`:
|
|
139
|
+
* * `healthy` — a host trace exists at/after `installedAt` and ingest > 0;
|
|
140
|
+
* * `degraded` — the host produced recall/context evidence but ingest is 0
|
|
141
|
+
* (`HEALTH_NO_INGEST`);
|
|
142
|
+
* * `deferred` — no positive evidence yet, or the sidecar is unavailable
|
|
143
|
+
* (`HEALTH_UNAVAILABLE`); never falsely degraded.
|
|
144
|
+
*
|
|
145
|
+
* `options.fetchImpl` injects a fetch implementation for tests; `options.home`
|
|
146
|
+
* selects the Mebular home that owns `memory-runtime.json`.
|
|
147
|
+
*/
|
|
148
|
+
export async function probeAdapterHealth(hostId, options = {}) {
|
|
149
|
+
const home = options.home ?? homeDir();
|
|
150
|
+
const agentId = agentIdForHost(hostId);
|
|
151
|
+
if (!agentId) return deferred(null, { agentId: null });
|
|
152
|
+
|
|
153
|
+
const discovery = readRuntimeDiscovery(home);
|
|
154
|
+
const baseUrl = runtimeBaseUrl(discovery);
|
|
155
|
+
if (!baseUrl) return deferred('HEALTH_UNAVAILABLE', { agentId });
|
|
156
|
+
|
|
157
|
+
const fetchImpl = typeof options.fetchImpl === 'function' ? options.fetchImpl : globalThis.fetch;
|
|
158
|
+
if (typeof fetchImpl !== 'function') return deferred('HEALTH_UNAVAILABLE', { agentId });
|
|
159
|
+
|
|
160
|
+
const token = readHostToken(discovery);
|
|
161
|
+
const timeoutMs = positiveInt(options.timeoutMs, DEFAULT_TIMEOUT_MS, 30_000);
|
|
162
|
+
const limit = positiveInt(options.traceLimit, DEFAULT_TRACE_LIMIT, MAX_TRACE_LIMIT);
|
|
163
|
+
const installedAt = timestamp(options.installedAt) ?? 0;
|
|
164
|
+
|
|
165
|
+
const status = await getJson(fetchImpl, `${baseUrl}/status`, token, timeoutMs);
|
|
166
|
+
if (!status.ok) return deferred('HEALTH_UNAVAILABLE', { agentId });
|
|
167
|
+
const counts = status.data && typeof status.data === 'object' ? status.data.counts : null;
|
|
168
|
+
const ingested = status.data && typeof status.data === 'object' ? timestamp(counts?.ingested) : null;
|
|
169
|
+
|
|
170
|
+
const traces = await getJson(fetchImpl, `${baseUrl}/traces?limit=${limit}`, token, timeoutMs);
|
|
171
|
+
if (!traces.ok) {
|
|
172
|
+
// Status alone cannot attribute evidence to this host; stay deferred.
|
|
173
|
+
return deferred('HEALTH_UNAVAILABLE', { agentId, ingested });
|
|
174
|
+
}
|
|
175
|
+
const list = Array.isArray(traces.data?.traces) ? traces.data.traces : [];
|
|
176
|
+
const hostTraces = list
|
|
177
|
+
.filter((trace) => trace && typeof trace === 'object' && trace.agentId === agentId)
|
|
178
|
+
.map((trace) => ({ at: timestamp(trace.at) }))
|
|
179
|
+
.filter((trace) => trace.at !== null && (installedAt <= 0 || trace.at >= installedAt));
|
|
180
|
+
const latest = hostTraces.reduce((max, trace) => (trace.at > max ? trace.at : max), 0);
|
|
181
|
+
|
|
182
|
+
if (hostTraces.length > 0 && ingested !== null && ingested > 0) {
|
|
183
|
+
return {
|
|
184
|
+
state: 'healthy',
|
|
185
|
+
code: null,
|
|
186
|
+
health: 'healthy',
|
|
187
|
+
available: true,
|
|
188
|
+
ingested,
|
|
189
|
+
traces: hostTraces.length,
|
|
190
|
+
lastIngestedAt: latest > 0 ? latest : null,
|
|
191
|
+
agentId,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (hostTraces.length > 0 && ingested === 0) {
|
|
195
|
+
return {
|
|
196
|
+
state: 'degraded',
|
|
197
|
+
code: 'HEALTH_NO_INGEST',
|
|
198
|
+
health: 'degraded',
|
|
199
|
+
available: true,
|
|
200
|
+
ingested,
|
|
201
|
+
traces: hostTraces.length,
|
|
202
|
+
lastIngestedAt: null,
|
|
203
|
+
agentId,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return deferred(null, {
|
|
207
|
+
agentId,
|
|
208
|
+
available: true,
|
|
209
|
+
ingested,
|
|
210
|
+
traces: hostTraces.length,
|
|
211
|
+
lastIngestedAt: null,
|
|
212
|
+
});
|
|
213
|
+
}
|