@tellagen/mcp-server 0.4.2 → 0.5.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/LICENSE +21 -0
- package/README.md +334 -101
- package/SKILL.md +83 -17
- package/contracts/mcp-protocol.json +155 -0
- package/contracts/runbooks/manifest.json +26 -6
- package/contracts/runbooks/v2/cause-lead.guidance.json +37 -0
- package/contracts/runbooks/v2/client-protocol.json +926 -0
- package/contracts/runbooks/v2/client-writes.guidance.json +42 -0
- package/contracts/runbooks/v2/fixtures/timeline-event-blocks-rejected.json +30 -5
- package/contracts/runbooks/v2/result-summary.guidance.json +21 -0
- package/contracts/runbooks/v2/timeline-event-blocks.schema.json +18 -11
- package/contracts/tellagen-runbook-contracts.json +4 -4
- package/dist/active-run.d.ts +29 -0
- package/dist/active-run.js +67 -0
- package/dist/active-run.js.map +1 -0
- package/dist/bootstrap.d.ts +20 -0
- package/dist/bootstrap.js +29 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cause-lead.d.ts +25 -0
- package/dist/cause-lead.js +145 -0
- package/dist/cause-lead.js.map +1 -0
- package/dist/cli/auth.d.ts +22 -0
- package/dist/cli/auth.js +207 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/io.d.ts +16 -0
- package/dist/cli/io.js +53 -0
- package/dist/cli/io.js.map +1 -0
- package/dist/cli/listen-guard.d.ts +12 -0
- package/dist/cli/listen-guard.js +50 -0
- package/dist/cli/listen-guard.js.map +1 -0
- package/dist/cli/listen.d.ts +28 -0
- package/dist/cli/listen.js +205 -0
- package/dist/cli/listen.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +53 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/trace-hook.d.ts +23 -0
- package/dist/cli/trace-hook.js +99 -0
- package/dist/cli/trace-hook.js.map +1 -0
- package/dist/client.d.ts +92 -6
- package/dist/client.js +300 -23
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +17 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +120 -0
- package/dist/credentials.js +363 -0
- package/dist/credentials.js.map +1 -0
- package/dist/diagnosis-structure.d.ts +207 -147
- package/dist/diagnosis-structure.js +142 -1
- package/dist/diagnosis-structure.js.map +1 -1
- package/dist/diff-figure.d.ts +56 -0
- package/dist/diff-figure.js +276 -0
- package/dist/diff-figure.js.map +1 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +60 -0
- package/dist/errors.js.map +1 -1
- package/dist/figures.d.ts +281 -201
- package/dist/figures.js +189 -47
- package/dist/figures.js.map +1 -1
- package/dist/guide-resources.d.ts +28 -0
- package/dist/guide-resources.js +81 -0
- package/dist/guide-resources.js.map +1 -0
- package/dist/heartbeat.d.ts +24 -0
- package/dist/heartbeat.js +94 -0
- package/dist/heartbeat.js.map +1 -0
- package/dist/home.d.ts +8 -0
- package/dist/home.js +14 -0
- package/dist/home.js.map +1 -0
- package/dist/identity.d.ts +32 -0
- package/dist/identity.js +83 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/dist/listen-config.d.ts +67 -0
- package/dist/listen-config.js +83 -0
- package/dist/listen-config.js.map +1 -0
- package/dist/listen-probe.d.ts +57 -0
- package/dist/listen-probe.js +158 -0
- package/dist/listen-probe.js.map +1 -0
- package/dist/listen-rules.d.ts +88 -0
- package/dist/listen-rules.js +252 -0
- package/dist/listen-rules.js.map +1 -0
- package/dist/listen-settings.d.ts +18 -0
- package/dist/listen-settings.js +50 -0
- package/dist/listen-settings.js.map +1 -0
- package/dist/listen-wrap.d.ts +21 -0
- package/dist/listen-wrap.js +52 -0
- package/dist/listen-wrap.js.map +1 -0
- package/dist/listener.d.ts +195 -0
- package/dist/listener.js +600 -0
- package/dist/listener.js.map +1 -0
- package/dist/open-run.d.ts +2 -0
- package/dist/open-run.js +5 -0
- package/dist/open-run.js.map +1 -0
- package/dist/prompts.d.ts +12 -0
- package/dist/prompts.js +37 -0
- package/dist/prompts.js.map +1 -0
- package/dist/redact.d.ts +13 -0
- package/dist/redact.js +76 -0
- package/dist/redact.js.map +1 -0
- package/dist/run-events.d.ts +54 -0
- package/dist/run-events.js +210 -0
- package/dist/run-events.js.map +1 -0
- package/dist/run-state.d.ts +184 -0
- package/dist/run-state.js +207 -0
- package/dist/run-state.js.map +1 -0
- package/dist/server.d.ts +22 -2
- package/dist/server.js +137 -29
- package/dist/server.js.map +1 -1
- package/dist/session.d.ts +86 -0
- package/dist/session.js +155 -0
- package/dist/session.js.map +1 -0
- package/dist/shell-rules.d.ts +49 -0
- package/dist/shell-rules.js +335 -0
- package/dist/shell-rules.js.map +1 -0
- package/dist/signin-index.d.ts +164 -0
- package/dist/signin-index.js +116 -0
- package/dist/signin-index.js.map +1 -0
- package/dist/signin.d.ts +169 -0
- package/dist/signin.js +541 -0
- package/dist/signin.js.map +1 -0
- package/dist/start.d.ts +7 -6
- package/dist/start.js +14 -7
- package/dist/start.js.map +1 -1
- package/dist/tools/catalog.d.ts +44 -0
- package/dist/tools/catalog.js +105 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/tools/causes.d.ts +6 -6
- package/dist/tools/causes.js +4 -5
- package/dist/tools/causes.js.map +1 -1
- package/dist/tools/context.js +5 -5
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/datasources.js +1 -1
- package/dist/tools/datasources.js.map +1 -1
- package/dist/tools/diagnostics.js +2 -2
- package/dist/tools/diagnostics.js.map +1 -1
- package/dist/tools/figures.d.ts +3 -2
- package/dist/tools/figures.js +38 -13
- package/dist/tools/figures.js.map +1 -1
- package/dist/tools/findings.d.ts +28 -0
- package/dist/tools/findings.js +75 -12
- package/dist/tools/findings.js.map +1 -1
- package/dist/tools/incidents.js +5 -5
- package/dist/tools/incidents.js.map +1 -1
- package/dist/tools/index.d.ts +19 -2
- package/dist/tools/index.js +115 -14
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/investigations.d.ts +54 -0
- package/dist/tools/investigations.js +369 -68
- package/dist/tools/investigations.js.map +1 -1
- package/dist/tools/next.d.ts +20 -0
- package/dist/tools/next.js +136 -0
- package/dist/tools/next.js.map +1 -0
- package/dist/tools/postmortem-runbooks.d.ts +52 -52
- package/dist/tools/postmortem-runbooks.js +3 -10
- package/dist/tools/postmortem-runbooks.js.map +1 -1
- package/dist/tools/resume.d.ts +5 -0
- package/dist/tools/resume.js +136 -0
- package/dist/tools/resume.js.map +1 -0
- package/dist/tools/signin.d.ts +12 -0
- package/dist/tools/signin.js +54 -0
- package/dist/tools/signin.js.map +1 -0
- package/dist/tools/source-links.js +5 -3
- package/dist/tools/source-links.js.map +1 -1
- package/dist/tools/timeline.js +57 -11
- package/dist/tools/timeline.js.map +1 -1
- package/dist/trace-record.d.ts +36 -0
- package/dist/trace-record.js +283 -0
- package/dist/trace-record.js.map +1 -0
- package/dist/version.d.ts +10 -2
- package/dist/version.js +20 -1
- package/dist/version.js.map +1 -1
- package/package.json +23 -3
- package/server.json +5 -5
- package/contracts/runbooks/v1/fixtures/global-runbook.json +0 -7
- package/contracts/runbooks/v1/runbook-definition.schema.json +0 -25
- package/dist/auth.d.ts +0 -7
- package/dist/auth.js +0 -19
- package/dist/auth.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* The parts of the guide a model reads when it needs them. The server
|
|
4
|
+
* instructions stay short and name these; the pickup answer names the ones
|
|
5
|
+
* that apply to the run. Each resource is cut from SKILL.md by heading, so
|
|
6
|
+
* the guide has one source.
|
|
7
|
+
*/
|
|
8
|
+
export interface GuideResource {
|
|
9
|
+
name: string;
|
|
10
|
+
uri: string;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
/** The `## ` headings of SKILL.md that make up the resource, in order. */
|
|
14
|
+
headings: readonly string[];
|
|
15
|
+
/** When the pickup answer names it: on every run, or only with matched runbooks. */
|
|
16
|
+
when: "always" | "runbooks";
|
|
17
|
+
/** The moment to read it, as the pickup answer says it. */
|
|
18
|
+
readWhen: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const SKILL_GUIDE_URI = "resource://tellagen/skill-guide";
|
|
21
|
+
export declare const GUIDE_RESOURCES: readonly GuideResource[];
|
|
22
|
+
/** Guides the pickup answer does not name: they belong to other work. */
|
|
23
|
+
export declare const OTHER_GUIDE_RESOURCES: readonly GuideResource[];
|
|
24
|
+
/** The text of one `## ` section of the guide, with its heading, up to the next `## `. */
|
|
25
|
+
export declare function guideSection(guide: string, heading: string): string;
|
|
26
|
+
export declare function guideResourceText(guide: string, resource: GuideResource): string;
|
|
27
|
+
/** Registers every guide part as a resource the model can read on its own. */
|
|
28
|
+
export declare function registerGuideResources(server: McpServer, guide: string): void;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const SKILL_GUIDE_URI = "resource://tellagen/skill-guide";
|
|
2
|
+
export const GUIDE_RESOURCES = [
|
|
3
|
+
{
|
|
4
|
+
name: "guide-findings",
|
|
5
|
+
uri: "resource://tellagen/guide/findings",
|
|
6
|
+
title: "Tellagen Finding Rules",
|
|
7
|
+
description: "How to post a finding: the fields, finding types and roles, evidence refs with links or a command, screenshots, and the question form of a blocking gap.",
|
|
8
|
+
headings: ["## Posting findings", "## Choosing finding types"],
|
|
9
|
+
when: "always",
|
|
10
|
+
readWhen: "before you post your first finding",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: "guide-completion",
|
|
14
|
+
uri: "resource://tellagen/guide/completion",
|
|
15
|
+
title: "Tellagen Completion Rules",
|
|
16
|
+
description: "How to complete a run: the five things to do first, the result_summary with its headline, the causal chain, ruled out, coverage and unknowns, change refs for a regression, and the warnings.",
|
|
17
|
+
headings: ["## Before you complete a run", "## Diagnosis structure", "## Regression and CI failures"],
|
|
18
|
+
when: "always",
|
|
19
|
+
readWhen: "before you complete the run",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "guide-runbook-checks",
|
|
23
|
+
uri: "resource://tellagen/guide/runbook-checks",
|
|
24
|
+
title: "Tellagen Runbook Check Rules",
|
|
25
|
+
description: "How to cite the frozen runbooks of a run: the guidance basis of a trace step, structured check attempts, source resolutions and fallbacks, gaps, and reuse hints.",
|
|
26
|
+
headings: ["## Guidance lineage on trace steps", "## Structured v2 runbook checks"],
|
|
27
|
+
when: "runbooks",
|
|
28
|
+
readWhen: "before you run a check of a matched runbook",
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
/** Guides the pickup answer does not name: they belong to other work. */
|
|
32
|
+
export const OTHER_GUIDE_RESOURCES = [
|
|
33
|
+
{
|
|
34
|
+
name: "guide-sources",
|
|
35
|
+
uri: "resource://tellagen/guide/sources",
|
|
36
|
+
title: "Tellagen Guide to Other MCP Servers",
|
|
37
|
+
description: "How to combine Tellagen with Grafana, GitHub, PagerDuty and error tracking servers, and how to prove that evidence is about the same resource.",
|
|
38
|
+
headings: ["## Causal resource identity", "## Composing with other MCP servers"],
|
|
39
|
+
when: "always",
|
|
40
|
+
readWhen: "when you query another MCP server for evidence",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "guide-postmortem",
|
|
44
|
+
uri: "resource://tellagen/guide/postmortem",
|
|
45
|
+
title: "Tellagen Postmortem Rules",
|
|
46
|
+
description: "How to answer a postmortem revision request with a proposal, how the legacy import tools version a document, and how to submit runbook candidates from a postmortem.",
|
|
47
|
+
headings: ["## Postmortem writeback"],
|
|
48
|
+
when: "always",
|
|
49
|
+
readWhen: "when the prompt carries a revision_request_id or an analysis_request_id",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "guide-tool-check",
|
|
53
|
+
uri: "resource://tellagen/guide/tool-check",
|
|
54
|
+
title: "Tellagen MCP Tool Check",
|
|
55
|
+
description: "How to answer a tool check session (a diag_ id) from Tellagen settings.",
|
|
56
|
+
headings: ["## MCP diagnostic lifecycle"],
|
|
57
|
+
when: "always",
|
|
58
|
+
readWhen: "when the prompt carries a diagnostic_session_id",
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
/** The text of one `## ` section of the guide, with its heading, up to the next `## `. */
|
|
62
|
+
export function guideSection(guide, heading) {
|
|
63
|
+
const marker = `\n${heading}\n`;
|
|
64
|
+
const start = guide.indexOf(marker);
|
|
65
|
+
if (start < 0)
|
|
66
|
+
throw new Error(`the guide has no section ${heading}`);
|
|
67
|
+
const rest = guide.slice(start + 1);
|
|
68
|
+
const next = rest.indexOf("\n## ", heading.length);
|
|
69
|
+
return (next < 0 ? rest : rest.slice(0, next)).trimEnd();
|
|
70
|
+
}
|
|
71
|
+
export function guideResourceText(guide, resource) {
|
|
72
|
+
return `${resource.headings.map((heading) => guideSection(guide, heading)).join("\n\n")}\n`;
|
|
73
|
+
}
|
|
74
|
+
/** Registers every guide part as a resource the model can read on its own. */
|
|
75
|
+
export function registerGuideResources(server, guide) {
|
|
76
|
+
for (const resource of [...GUIDE_RESOURCES, ...OTHER_GUIDE_RESOURCES]) {
|
|
77
|
+
const text = guideResourceText(guide, resource);
|
|
78
|
+
server.registerResource(resource.name, resource.uri, { title: resource.title, description: resource.description, mimeType: "text/markdown" }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: "text/markdown", text }] }));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=guide-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide-resources.js","sourceRoot":"","sources":["../src/guide-resources.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD;QACE,IAAI,EAAE,gBAAgB;QACtB,GAAG,EAAE,oCAAoC;QACzC,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EACT,0JAA0J;QAC5J,QAAQ,EAAE,CAAC,qBA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,QAAQ,CAAC,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,EACvF,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CACpF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TellagenClient } from "./client.js";
|
|
2
|
+
export declare const HEARTBEAT_CAPABILITY = "client_heartbeat_v1";
|
|
3
|
+
export declare const HEARTBEAT_INTERVAL_MS = 30000;
|
|
4
|
+
export declare const HEARTBEAT_MISSED_LINE = "Tellagen has not heard from this client for 90 seconds.";
|
|
5
|
+
/**
|
|
6
|
+
* Tells Tellagen every 30 seconds that this client still holds its run, so
|
|
7
|
+
* the web can show "Client connected". It runs only while a run is active and
|
|
8
|
+
* the server lists client_heartbeat_v1. A failed heartbeat never fails a tool
|
|
9
|
+
* call: after three in a row the next tool answer carries one line.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Heartbeat {
|
|
12
|
+
private readonly client;
|
|
13
|
+
private readonly intervalMs;
|
|
14
|
+
private timer;
|
|
15
|
+
private runId;
|
|
16
|
+
private failures;
|
|
17
|
+
private sending;
|
|
18
|
+
constructor(client: TellagenClient, intervalMs?: number);
|
|
19
|
+
running(): boolean;
|
|
20
|
+
private start;
|
|
21
|
+
stop(): void;
|
|
22
|
+
/** Sends one heartbeat. It never throws. */
|
|
23
|
+
beat(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { TellagenAPIError } from "./errors.js";
|
|
2
|
+
import { pendingNotesOf, runEventLines } from "./run-events.js";
|
|
3
|
+
export const HEARTBEAT_CAPABILITY = "client_heartbeat_v1";
|
|
4
|
+
export const HEARTBEAT_INTERVAL_MS = 30_000;
|
|
5
|
+
const FAILURES_BEFORE_NOTICE = 3;
|
|
6
|
+
export const HEARTBEAT_MISSED_LINE = "Tellagen has not heard from this client for 90 seconds.";
|
|
7
|
+
/**
|
|
8
|
+
* Tells Tellagen every 30 seconds that this client still holds its run, so
|
|
9
|
+
* the web can show "Client connected". It runs only while a run is active and
|
|
10
|
+
* the server lists client_heartbeat_v1. A failed heartbeat never fails a tool
|
|
11
|
+
* call: after three in a row the next tool answer carries one line.
|
|
12
|
+
*/
|
|
13
|
+
export class Heartbeat {
|
|
14
|
+
client;
|
|
15
|
+
intervalMs;
|
|
16
|
+
timer;
|
|
17
|
+
runId;
|
|
18
|
+
failures = 0;
|
|
19
|
+
sending = false;
|
|
20
|
+
constructor(client, intervalMs = HEARTBEAT_INTERVAL_MS) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.intervalMs = intervalMs;
|
|
23
|
+
client.session.onRunStart((run) => {
|
|
24
|
+
this.stop();
|
|
25
|
+
if (run.serverCapabilities.includes(HEARTBEAT_CAPABILITY))
|
|
26
|
+
this.start(run.runId);
|
|
27
|
+
});
|
|
28
|
+
client.session.onRunEnd((runId) => {
|
|
29
|
+
if (runId === this.runId)
|
|
30
|
+
this.stop();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
running() {
|
|
34
|
+
return this.timer !== undefined;
|
|
35
|
+
}
|
|
36
|
+
start(runId) {
|
|
37
|
+
this.runId = runId;
|
|
38
|
+
this.failures = 0;
|
|
39
|
+
this.timer = setInterval(() => void this.beat(), this.intervalMs);
|
|
40
|
+
// The timer must not keep the process alive after the client closed.
|
|
41
|
+
this.timer.unref?.();
|
|
42
|
+
}
|
|
43
|
+
stop() {
|
|
44
|
+
if (this.timer)
|
|
45
|
+
clearInterval(this.timer);
|
|
46
|
+
this.timer = undefined;
|
|
47
|
+
this.runId = undefined;
|
|
48
|
+
this.failures = 0;
|
|
49
|
+
}
|
|
50
|
+
/** Sends one heartbeat. It never throws. */
|
|
51
|
+
async beat() {
|
|
52
|
+
const runId = this.runId;
|
|
53
|
+
if (!runId || this.sending)
|
|
54
|
+
return;
|
|
55
|
+
this.sending = true;
|
|
56
|
+
const session = this.client.session;
|
|
57
|
+
try {
|
|
58
|
+
const answer = await this.client.post(`/api/v1/investigation-runs/${encodeURIComponent(runId)}/heartbeat`,
|
|
59
|
+
// The computer name goes in its header, like on every call.
|
|
60
|
+
{ session_id: session.sessionId },
|
|
61
|
+
// The next beat is the retry.
|
|
62
|
+
{ safeToRepeat: false, timeoutMs: 10_000 });
|
|
63
|
+
this.failures = 0;
|
|
64
|
+
// A note can arrive with a heartbeat. It goes to the state file, so a restart of the client
|
|
65
|
+
// before the next tool answer does not lose it. Without a state file it waits in memory.
|
|
66
|
+
const record = (typeof answer === "object" && answer !== null ? answer : {});
|
|
67
|
+
const notes = pendingNotesOf(record);
|
|
68
|
+
let rest = answer;
|
|
69
|
+
if (notes.length > 0 && session.state.filePath()) {
|
|
70
|
+
session.state.addPendingNotes(runId, notes);
|
|
71
|
+
const { responder_notes: _kept, ...others } = record;
|
|
72
|
+
rest = others;
|
|
73
|
+
}
|
|
74
|
+
// A cancel request, or a run that ended, comes as a line.
|
|
75
|
+
for (const line of runEventLines(this.client, rest))
|
|
76
|
+
session.addPendingLine(line);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
if (err instanceof TellagenAPIError && (err.code === "run_taken_over" || err.code === "investigation_run_ended")) {
|
|
80
|
+
const lines = runEventLines(this.client, { ...(err.payload ?? {}), error: true, code: err.code, message: err.message, run_id: runId });
|
|
81
|
+
for (const line of lines)
|
|
82
|
+
session.addPendingLine(line);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.failures += 1;
|
|
86
|
+
if (this.failures === FAILURES_BEFORE_NOTICE)
|
|
87
|
+
session.addPendingLine(HEARTBEAT_MISSED_LINE);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
this.sending = false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
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9F,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
package/dist/home.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The folder where this server keeps what it must remember between runs:
|
|
3
|
+
* the sign-in index, the remembered run, the listener's settings and logs.
|
|
4
|
+
* `TELLAGEN_HOME` moves all of it, which is how a test avoids the real home
|
|
5
|
+
* folder. It never holds a key, except the 0600 fallback file on a computer
|
|
6
|
+
* with no keychain.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tellagenHome(env?: Record<string, string | undefined>): string;
|
package/dist/home.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* The folder where this server keeps what it must remember between runs:
|
|
5
|
+
* the sign-in index, the remembered run, the listener's settings and logs.
|
|
6
|
+
* `TELLAGEN_HOME` moves all of it, which is how a test avoids the real home
|
|
7
|
+
* folder. It never holds a key, except the 0600 fallback file on a computer
|
|
8
|
+
* with no keychain.
|
|
9
|
+
*/
|
|
10
|
+
export function tellagenHome(env = process.env) {
|
|
11
|
+
const fromEnv = (env.TELLAGEN_HOME ?? "").trim();
|
|
12
|
+
return fromEnv || join(homedir(), ".tellagen");
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=home.js.map
|
package/dist/home.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"home.js","sourceRoot":"","sources":["../src/home.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,MAA0C,OAAO,CAAC,GAAG;IAChF,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,OAAO,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who is on the other end of the MCP connection, as the client said in the
|
|
3
|
+
* `initialize` request.
|
|
4
|
+
*/
|
|
5
|
+
export interface ClientIdentity {
|
|
6
|
+
/** The short name Tellagen stores, such as "claude-code". */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The name a person reads, such as "Claude Code". */
|
|
9
|
+
label: string;
|
|
10
|
+
/** The client's own version; empty when it sent none. */
|
|
11
|
+
version: string;
|
|
12
|
+
}
|
|
13
|
+
/** Request headers that carry the client facts on every Tellagen call. */
|
|
14
|
+
export declare const CLIENT_HEADER_NAME = "X-Tellagen-Client";
|
|
15
|
+
export declare const CLIENT_HEADER_VERSION = "X-Tellagen-Client-Version";
|
|
16
|
+
export declare const CLIENT_HEADER_COMPUTER = "X-Tellagen-Computer";
|
|
17
|
+
export declare const CLIENT_HEADER_SERVER_VERSION = "X-Tellagen-Server-Version";
|
|
18
|
+
export declare const CLIENT_HEADER_SESSION = "X-Tellagen-Client-Session";
|
|
19
|
+
/**
|
|
20
|
+
* A value that is safe in a request header and in a JSON field: printable
|
|
21
|
+
* ASCII, single spaces, at most `max` characters. The client name comes from
|
|
22
|
+
* outside, so it is never trusted to be well formed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function cleanIdentityValue(value: unknown, max?: number): string;
|
|
25
|
+
/** The identity from the `clientInfo` of the MCP handshake, if it has a name. */
|
|
26
|
+
export declare function identityFromClientInfo(info: unknown): ClientIdentity | undefined;
|
|
27
|
+
/** The name for a Tellagen that accepts only `codex` or `claude`. */
|
|
28
|
+
export declare function legacyClientName(identity: ClientIdentity | undefined): "codex" | "claude";
|
|
29
|
+
/** The name sent to Tellagen: the handshake name, else the deprecated setting. */
|
|
30
|
+
export declare function reportedClientName(identity: ClientIdentity | undefined): string;
|
|
31
|
+
/** This computer's name, cleaned for a header. Empty when it has none. */
|
|
32
|
+
export declare function computerName(): string;
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { hostname } from "node:os";
|
|
2
|
+
/** Request headers that carry the client facts on every Tellagen call. */
|
|
3
|
+
export const CLIENT_HEADER_NAME = "X-Tellagen-Client";
|
|
4
|
+
export const CLIENT_HEADER_VERSION = "X-Tellagen-Client-Version";
|
|
5
|
+
export const CLIENT_HEADER_COMPUTER = "X-Tellagen-Computer";
|
|
6
|
+
export const CLIENT_HEADER_SERVER_VERSION = "X-Tellagen-Server-Version";
|
|
7
|
+
export const CLIENT_HEADER_SESSION = "X-Tellagen-Client-Session";
|
|
8
|
+
/**
|
|
9
|
+
* Names some clients send in `clientInfo.name`, the short name Tellagen
|
|
10
|
+
* knows them by, and how a person calls them.
|
|
11
|
+
*/
|
|
12
|
+
const KNOWN_CLIENTS = {
|
|
13
|
+
"claude-code": { name: "claude-code", label: "Claude Code" },
|
|
14
|
+
"claude-desktop": { name: "claude-desktop", label: "Claude Desktop" },
|
|
15
|
+
"claude-ai": { name: "claude-ai", label: "Claude" },
|
|
16
|
+
"codex-mcp-client": { name: "codex", label: "Codex" },
|
|
17
|
+
"codex-cli": { name: "codex", label: "Codex" },
|
|
18
|
+
codex: { name: "codex", label: "Codex" },
|
|
19
|
+
"cursor-vscode": { name: "cursor", label: "Cursor" },
|
|
20
|
+
cursor: { name: "cursor", label: "Cursor" },
|
|
21
|
+
};
|
|
22
|
+
const MAX_NAME = 64;
|
|
23
|
+
const MAX_VERSION = 40;
|
|
24
|
+
const MAX_COMPUTER = 120;
|
|
25
|
+
/**
|
|
26
|
+
* A value that is safe in a request header and in a JSON field: printable
|
|
27
|
+
* ASCII, single spaces, at most `max` characters. The client name comes from
|
|
28
|
+
* outside, so it is never trusted to be well formed.
|
|
29
|
+
*/
|
|
30
|
+
export function cleanIdentityValue(value, max = 100) {
|
|
31
|
+
if (typeof value !== "string")
|
|
32
|
+
return "";
|
|
33
|
+
return value
|
|
34
|
+
.replace(/[^\x20-\x7e]+/g, " ")
|
|
35
|
+
.replace(/\s+/g, " ")
|
|
36
|
+
.trim()
|
|
37
|
+
.slice(0, max)
|
|
38
|
+
.trim();
|
|
39
|
+
}
|
|
40
|
+
/** The identity from the `clientInfo` of the MCP handshake, if it has a name. */
|
|
41
|
+
export function identityFromClientInfo(info) {
|
|
42
|
+
if (typeof info !== "object" || info === null)
|
|
43
|
+
return undefined;
|
|
44
|
+
const record = info;
|
|
45
|
+
const rawName = cleanIdentityValue(record.name, MAX_NAME);
|
|
46
|
+
if (!rawName)
|
|
47
|
+
return undefined;
|
|
48
|
+
const version = cleanIdentityValue(record.version, MAX_VERSION);
|
|
49
|
+
const known = KNOWN_CLIENTS[rawName.toLowerCase()];
|
|
50
|
+
if (known)
|
|
51
|
+
return { ...known, version };
|
|
52
|
+
return { name: rawName, label: cleanIdentityValue(record.title, MAX_NAME) || rawName, version };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The deprecated TELLAGEN_MCP_CLIENT setting, read for one more release. It
|
|
56
|
+
* is used only when the client sent no name in the handshake, and for a
|
|
57
|
+
* Tellagen that still accepts only `codex` or `claude`.
|
|
58
|
+
*/
|
|
59
|
+
function legacyEnvClient() {
|
|
60
|
+
const value = (process.env.TELLAGEN_MCP_CLIENT ?? "").trim().toLowerCase();
|
|
61
|
+
return value === "codex" || value === "claude" ? value : undefined;
|
|
62
|
+
}
|
|
63
|
+
/** The name for a Tellagen that accepts only `codex` or `claude`. */
|
|
64
|
+
export function legacyClientName(identity) {
|
|
65
|
+
const fromEnv = legacyEnvClient();
|
|
66
|
+
if (fromEnv)
|
|
67
|
+
return fromEnv;
|
|
68
|
+
return identity && /claude/i.test(identity.name) ? "claude" : "codex";
|
|
69
|
+
}
|
|
70
|
+
/** The name sent to Tellagen: the handshake name, else the deprecated setting. */
|
|
71
|
+
export function reportedClientName(identity) {
|
|
72
|
+
return identity?.name ?? legacyEnvClient() ?? "mcp-client";
|
|
73
|
+
}
|
|
74
|
+
/** This computer's name, cleaned for a header. Empty when it has none. */
|
|
75
|
+
export function computerName() {
|
|
76
|
+
try {
|
|
77
|
+
return cleanIdentityValue(hostname(), MAX_COMPUTER);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAenC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAC5D,MAAM,CAAC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,MAAM,aAAa,GAAoD;IACrE,aAAa,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC5D,gBAAgB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,EAAE;IACrE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE;IACnD,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IACrD,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAC9C,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IACxC,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AAQ,CAAC,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC;AAClG,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe;IACtB,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3E,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,QAAoC;IACnE,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,OAAO,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,kBAAkB,CAAC,QAAoC;IACrE,OAAO,QAAQ,EAAE,IAAI,IAAI,eAAe,EAAE,IAAI,YAAY,CAAC;AAC7D,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { MCP_SERVER_VERSION } from "./version.js";
|
|
3
|
+
/**
|
|
4
|
+
* With no command this is the MCP server on standard input and output. The
|
|
5
|
+
* commands below are for a person, or for a hook of a client. They load only
|
|
6
|
+
* what they need, so a hook starts fast.
|
|
7
|
+
*/
|
|
8
|
+
const COMMANDS = new Set(["login", "logout", "status", "listen", "trace-hook", "listen-wrap", "listen-guard", "help", "--help", "-h", "--version", "-v"]);
|
|
9
|
+
async function serve() {
|
|
10
|
+
const [{ StdioServerTransport }, { readConfig }, { startTellagenServer }, { createRuntime }] = await Promise.all([
|
|
11
|
+
import("@modelcontextprotocol/sdk/server/stdio.js"),
|
|
12
|
+
import("./config.js"),
|
|
13
|
+
import("./start.js"),
|
|
14
|
+
import("./bootstrap.js"),
|
|
15
|
+
]);
|
|
16
|
+
const config = readConfig();
|
|
17
|
+
const { client, vault, index, credentials } = await createRuntime(process.env, { stateDir: config.stateDir });
|
|
18
|
+
if (!credentials.apiKey || !credentials.apiUrl) {
|
|
19
|
+
// The server still starts, so the client shows it as connected and the
|
|
20
|
+
// first tool call explains the setup. No value is written here.
|
|
21
|
+
process.stderr.write("Tellagen MCP: no sign-in and no TELLAGEN_API_KEY or TELLAGEN_API_URL. The server runs, and tellagen_sign_in or the setup steps in each tool answer explain what to do.\n");
|
|
11
22
|
}
|
|
12
|
-
|
|
13
|
-
process.stderr.write(
|
|
14
|
-
|
|
23
|
+
for (const warning of config.warnings) {
|
|
24
|
+
process.stderr.write(`Tellagen MCP: ${warning}\n`);
|
|
25
|
+
// The model also reads it, with its next tool answer.
|
|
26
|
+
client.session.addPendingLine(warning);
|
|
15
27
|
}
|
|
16
|
-
const client = new TellagenClient({ apiUrl, apiKey });
|
|
17
28
|
const transport = new StdioServerTransport();
|
|
18
|
-
await startTellagenServer(client, transport);
|
|
29
|
+
await startTellagenServer(client, transport, { toolsets: config.toolsets, signIn: { vault, index } });
|
|
30
|
+
}
|
|
31
|
+
async function main() {
|
|
32
|
+
const command = process.argv[2];
|
|
33
|
+
if (command && COMMANDS.has(command)) {
|
|
34
|
+
if (command === "--version" || command === "-v") {
|
|
35
|
+
process.stdout.write(`${MCP_SERVER_VERSION}\n`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (command === "listen-guard") {
|
|
39
|
+
// A guard that cannot finish passes nothing: exit 2 refuses the call.
|
|
40
|
+
setTimeout(() => process.exit(2), 10_000).unref();
|
|
41
|
+
}
|
|
42
|
+
if (command === "trace-hook") {
|
|
43
|
+
// A hook must never hold a tool call. If standard input never closes, leave anyway.
|
|
44
|
+
setTimeout(() => process.exit(0), 2_500).unref();
|
|
45
|
+
}
|
|
46
|
+
const { runCli } = await import("./cli/main.js");
|
|
47
|
+
process.exitCode = await runCli(command, process.argv.slice(3));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await serve();
|
|
19
51
|
}
|
|
20
52
|
main().catch((err) => {
|
|
21
53
|
process.stderr.write(`Fatal: ${err instanceof Error ? err.message : String(err)}\n`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD;;;;GAIG;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;AAE1J,KAAK,UAAU,KAAK;IAClB,MAAM,CAAC,EAAE,oBAAoB,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC/G,MAAM,CAAC,2CAA2C,CAAC;QACnD,MAAM,CAA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AC;YAChD,OAAO;QACT,CAAC;QACD,IAAI,OAAO,KAAK,cAAc,EAAE,CAAC;YAC/B,sEAAsE;YACtE,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;QACD,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;YAC7B,oFAAoF;YACpF,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QACnD,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;QACjD,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO;IACT,CAAC;IACD,MAAM,KAAK,EAAE,CAAC;AAChB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The settings of the listener: `~/.tellagen/listen.json`. The file is
|
|
4
|
+
* optional; every setting has a default. An unknown key is an error, so a
|
|
5
|
+
* mistyped setting is never silently ignored, and no setting can switch off
|
|
6
|
+
* the read-only rules.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_RUNS_LIMIT = 3;
|
|
9
|
+
export declare const DEFAULT_TIMEOUT_MINUTES = 45;
|
|
10
|
+
declare const configSchema: z.ZodObject<{
|
|
11
|
+
/** The client that runs a diagnosis. */
|
|
12
|
+
client: z.ZodDefault<z.ZodEnum<["claude", "codex"]>>;
|
|
13
|
+
/** The folder the client starts in. Default: the folder where `listen` was started. */
|
|
14
|
+
working_folder: z.ZodOptional<z.ZodString>;
|
|
15
|
+
/** The most runs at one time. */
|
|
16
|
+
max_runs: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
/** The time one run may take before it is stopped. */
|
|
18
|
+
run_time_limit_minutes: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
/** Names of the MCP servers of Grafana and GitHub, when they are not the usual ones. */
|
|
20
|
+
mcp_servers: z.ZodDefault<z.ZodObject<{
|
|
21
|
+
grafana: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
+
github: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
23
|
+
}, "strict", z.ZodTypeAny, {
|
|
24
|
+
grafana?: string[] | undefined;
|
|
25
|
+
github?: string[] | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
grafana?: string[] | undefined;
|
|
28
|
+
github?: string[] | undefined;
|
|
29
|
+
}>>;
|
|
30
|
+
/** Extra read tools, each `mcp__<server>__<tool>`. A tool that changes something is refused. */
|
|
31
|
+
extra_allowed_tools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
32
|
+
/** A file of MCP server settings for the client, when the servers are not set up for the user. */
|
|
33
|
+
mcp_config_file: z.ZodOptional<z.ZodString>;
|
|
34
|
+
/** The model the client uses; the client's own default when left out. */
|
|
35
|
+
model: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, "strict", z.ZodTypeAny, {
|
|
37
|
+
client: "codex" | "claude";
|
|
38
|
+
max_runs: number;
|
|
39
|
+
run_time_limit_minutes: number;
|
|
40
|
+
mcp_servers: {
|
|
41
|
+
grafana?: string[] | undefined;
|
|
42
|
+
github?: string[] | undefined;
|
|
43
|
+
};
|
|
44
|
+
extra_allowed_tools: string[];
|
|
45
|
+
model?: string | undefined;
|
|
46
|
+
working_folder?: string | undefined;
|
|
47
|
+
mcp_config_file?: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
client?: "codex" | "claude" | undefined;
|
|
50
|
+
model?: string | undefined;
|
|
51
|
+
working_folder?: string | undefined;
|
|
52
|
+
max_runs?: number | undefined;
|
|
53
|
+
run_time_limit_minutes?: number | undefined;
|
|
54
|
+
mcp_servers?: {
|
|
55
|
+
grafana?: string[] | undefined;
|
|
56
|
+
github?: string[] | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
extra_allowed_tools?: string[] | undefined;
|
|
59
|
+
mcp_config_file?: string | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
export type ListenConfig = z.infer<typeof configSchema>;
|
|
62
|
+
export declare class ListenConfigError extends Error {
|
|
63
|
+
}
|
|
64
|
+
export declare function listenConfigPath(home?: string): string;
|
|
65
|
+
/** Reads the settings. A missing file gives the defaults. A wrong file is an error that says what to fix. */
|
|
66
|
+
export declare function readListenConfig(home?: string): ListenConfig;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { tellagenHome } from "./home.js";
|
|
5
|
+
import { checkExtraTool } from "./listen-rules.js";
|
|
6
|
+
/**
|
|
7
|
+
* The settings of the listener: `~/.tellagen/listen.json`. The file is
|
|
8
|
+
* optional; every setting has a default. An unknown key is an error, so a
|
|
9
|
+
* mistyped setting is never silently ignored, and no setting can switch off
|
|
10
|
+
* the read-only rules.
|
|
11
|
+
*/
|
|
12
|
+
export const MAX_RUNS_LIMIT = 3;
|
|
13
|
+
export const DEFAULT_TIMEOUT_MINUTES = 45;
|
|
14
|
+
const serverName = z.string().regex(/^[A-Za-z0-9_-]{1,60}$/, "an MCP server name has letters, digits, - and _ only");
|
|
15
|
+
const configSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
/** The client that runs a diagnosis. */
|
|
18
|
+
client: z.enum(["claude", "codex"]).default("claude"),
|
|
19
|
+
/** The folder the client starts in. Default: the folder where `listen` was started. */
|
|
20
|
+
working_folder: z.string().min(1).max(500).optional(),
|
|
21
|
+
/** The most runs at one time. */
|
|
22
|
+
max_runs: z.number().int().min(1).max(MAX_RUNS_LIMIT).default(1),
|
|
23
|
+
/** The time one run may take before it is stopped. */
|
|
24
|
+
run_time_limit_minutes: z.number().int().min(5).max(240).default(DEFAULT_TIMEOUT_MINUTES),
|
|
25
|
+
/** Names of the MCP servers of Grafana and GitHub, when they are not the usual ones. */
|
|
26
|
+
mcp_servers: z
|
|
27
|
+
.object({
|
|
28
|
+
grafana: z.array(serverName).max(5).optional(),
|
|
29
|
+
github: z.array(serverName).max(5).optional(),
|
|
30
|
+
})
|
|
31
|
+
.strict()
|
|
32
|
+
.default({}),
|
|
33
|
+
/** Extra read tools, each `mcp__<server>__<tool>`. A tool that changes something is refused. */
|
|
34
|
+
extra_allowed_tools: z.array(z.string().max(200)).max(100).default([]),
|
|
35
|
+
/** A file of MCP server settings for the client, when the servers are not set up for the user. */
|
|
36
|
+
mcp_config_file: z.string().min(1).max(500).optional(),
|
|
37
|
+
/** The model the client uses; the client's own default when left out. */
|
|
38
|
+
model: z.string().regex(/^[A-Za-z0-9._:/-]{1,80}$/).optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
export class ListenConfigError extends Error {
|
|
42
|
+
}
|
|
43
|
+
export function listenConfigPath(home = tellagenHome()) {
|
|
44
|
+
return join(home, "listen.json");
|
|
45
|
+
}
|
|
46
|
+
/** Reads the settings. A missing file gives the defaults. A wrong file is an error that says what to fix. */
|
|
47
|
+
export function readListenConfig(home = tellagenHome()) {
|
|
48
|
+
const path = listenConfigPath(home);
|
|
49
|
+
let raw = {};
|
|
50
|
+
if (existsSync(path)) {
|
|
51
|
+
const stat = lstatSync(path);
|
|
52
|
+
if (!stat.isFile() || stat.size > 64 * 1024)
|
|
53
|
+
throw new ListenConfigError(`${path} is not a settings file.`);
|
|
54
|
+
try {
|
|
55
|
+
raw = JSON.parse(readFileSync(path, "utf8"));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new ListenConfigError(`${path} is not valid JSON.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const parsed = configSchema.safeParse(raw);
|
|
62
|
+
if (!parsed.success) {
|
|
63
|
+
const first = parsed.error.issues[0];
|
|
64
|
+
throw new ListenConfigError(`${path}: ${first?.path.join(".") || "settings"}: ${first?.message ?? "not valid"}.`);
|
|
65
|
+
}
|
|
66
|
+
for (const tool of parsed.data.extra_allowed_tools) {
|
|
67
|
+
const problem = checkExtraTool(tool);
|
|
68
|
+
if (problem)
|
|
69
|
+
throw new ListenConfigError(`${path}: extra_allowed_tools: ${problem}`);
|
|
70
|
+
}
|
|
71
|
+
const folder = parsed.data.working_folder;
|
|
72
|
+
if (folder) {
|
|
73
|
+
try {
|
|
74
|
+
if (!statSync(folder).isDirectory())
|
|
75
|
+
throw new Error();
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
throw new ListenConfigError(`${path}: working_folder: ${folder.slice(0, 120)} is not a folder.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return parsed.data;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=listen-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listen-config.js","sourceRoot":"","sources":["../src/listen-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,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