claude-mcp-bridge 0.2.0 → 0.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.
- package/README.md +50 -0
- package/dist/annotations.d.ts +24 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/annotations.js +53 -0
- package/dist/annotations.js.map +1 -0
- package/dist/descriptions.d.ts +15 -0
- package/dist/descriptions.d.ts.map +1 -0
- package/dist/descriptions.js +56 -0
- package/dist/descriptions.js.map +1 -0
- package/dist/index.js +251 -143
- package/dist/index.js.map +1 -1
- package/dist/utils/meta.d.ts +18 -0
- package/dist/utils/meta.d.ts.map +1 -0
- package/dist/utils/meta.js +29 -0
- package/dist/utils/meta.js.map +1 -0
- package/dist/utils/progress.d.ts +37 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +49 -0
- package/dist/utils/progress.js.map +1 -0
- package/dist/utils/session.d.ts +58 -0
- package/dist/utils/session.d.ts.map +1 -0
- package/dist/utils/session.js +98 -0
- package/dist/utils/session.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -203,6 +203,25 @@ Web search via Claude Code CLI using WebSearch and WebFetch tools.
|
|
|
203
203
|
| `maxBudgetUsd` | number | | Cost cap in USD |
|
|
204
204
|
| `effort` | string | `medium` | `low`, `medium`, `high`, or `max` |
|
|
205
205
|
|
|
206
|
+
### `listSessions`
|
|
207
|
+
|
|
208
|
+
List active Claude CLI sessions tracked by this server. Returns session metadata for orchestration.
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
[
|
|
212
|
+
{
|
|
213
|
+
"sessionId": "abc-123",
|
|
214
|
+
"model": "sonnet",
|
|
215
|
+
"createdAt": 1712700000000,
|
|
216
|
+
"lastUsedAt": 1712703600000,
|
|
217
|
+
"turnCount": 5,
|
|
218
|
+
"totalCostUsd": 0.23
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
No parameters. Sessions are stored in-memory (TTL 24h, LRU eviction at 100). Use to check available sessions before resuming with `sessionId`.
|
|
224
|
+
|
|
206
225
|
### `ping`
|
|
207
226
|
|
|
208
227
|
Health check. No parameters. Returns CLI availability, auth status, configured models, server version, and capability flags.
|
|
@@ -296,6 +315,37 @@ CLI output is scanned for sensitive patterns before being returned: Anthropic AP
|
|
|
296
315
|
| Hard timeout cap | 10 minutes |
|
|
297
316
|
| Concurrency queue timeout | 30 seconds |
|
|
298
317
|
|
|
318
|
+
## Response metadata
|
|
319
|
+
|
|
320
|
+
Every tool response includes a `_meta` object with execution metadata:
|
|
321
|
+
|
|
322
|
+
| Field | Type | Description |
|
|
323
|
+
|-------|------|-------------|
|
|
324
|
+
| `durationMs` | number | Wall-clock execution time |
|
|
325
|
+
| `model` | string? | Model used (e.g. "sonnet", "opus") |
|
|
326
|
+
| `sessionId` | string? | Session ID for resume |
|
|
327
|
+
| `totalCostUsd` | number? | Cost for this call in USD |
|
|
328
|
+
| `inputTokens` | number? | Input tokens consumed |
|
|
329
|
+
| `outputTokens` | number? | Output tokens generated |
|
|
330
|
+
| `cacheReadTokens` | number? | Tokens read from prompt cache |
|
|
331
|
+
| `timedOut` | boolean? | `true` if subprocess exceeded timeout (omitted otherwise) |
|
|
332
|
+
|
|
333
|
+
All tools also declare [MCP annotations](https://modelcontextprotocol.io/specification/2025-06-18/server/tools#annotations) (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) so clients can make informed permission and safety decisions.
|
|
334
|
+
|
|
335
|
+
## Sessions
|
|
336
|
+
|
|
337
|
+
Session state is tracked in-memory across calls. When a tool returns a `sessionId` in `_meta`, pass it back on subsequent calls to resume the conversation via Claude CLI's `--resume` flag.
|
|
338
|
+
|
|
339
|
+
- **Cumulative cost**: `totalCostUsd` in `_meta` is the cost for that call only. Cumulative cost across turns is tracked per-session and visible via `listSessions`
|
|
340
|
+
- **Reset**: Pass `resetSession: true` on the query tool to clear stored state and start fresh
|
|
341
|
+
- **TTL**: Sessions expire after 24 hours of inactivity
|
|
342
|
+
- **Capacity**: LRU eviction at 100 sessions (oldest by `lastUsedAt` is evicted)
|
|
343
|
+
- **Ephemeral**: Session state is in-memory only, lost on server restart
|
|
344
|
+
|
|
345
|
+
## Progress notifications
|
|
346
|
+
|
|
347
|
+
Query, review, and search tools emit MCP [`notifications/progress`](https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/progress) during subprocess execution when the client provides a `progressToken` in the request's `_meta`. Heartbeats fire every 15 seconds with elapsed time. Notifications are fire-and-forget; clients that don't support progress notifications are unaffected.
|
|
348
|
+
|
|
299
349
|
## Concurrency
|
|
300
350
|
|
|
301
351
|
Requests are queued with a FIFO scheduler. Default: 3 concurrent Claude CLI processes. If all slots are busy, new requests wait up to 30 seconds before being rejected. Timed-out processes are killed with SIGTERM, then SIGKILL after 5 seconds. On Unix, the entire process group is killed to clean up child processes.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* MCP tool annotations for all claude-mcp-bridge tools.
|
|
4
|
+
*
|
|
5
|
+
* Annotations are hints that help MCP clients understand tool behavior
|
|
6
|
+
* for permission prompts, safety checks, and orchestration decisions.
|
|
7
|
+
*
|
|
8
|
+
* readOnly: query/review/search/structured are false because they can persist
|
|
9
|
+
* Claude CLI session state to disk (~/.claude/) when sessionId is used.
|
|
10
|
+
* ping is true (purely local, no side effects).
|
|
11
|
+
*
|
|
12
|
+
* review: destructive=false because the default --allowed-tools list is read-only
|
|
13
|
+
* (Read, Grep, Glob, git). Callers that pass custom tools including write access
|
|
14
|
+
* should treat it as potentially destructive.
|
|
15
|
+
*
|
|
16
|
+
* Titles are set on the registerTool config in index.ts, not here (avoid duplication).
|
|
17
|
+
*/
|
|
18
|
+
export declare const queryAnnotations: ToolAnnotations;
|
|
19
|
+
export declare const reviewAnnotations: ToolAnnotations;
|
|
20
|
+
export declare const searchAnnotations: ToolAnnotations;
|
|
21
|
+
export declare const structuredAnnotations: ToolAnnotations;
|
|
22
|
+
export declare const listSessionsAnnotations: ToolAnnotations;
|
|
23
|
+
export declare const pingAnnotations: ToolAnnotations;
|
|
24
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,gBAAgB,EAAE,eAK9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAK/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAK/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,eAKnC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAKrC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAK7B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool annotations for all claude-mcp-bridge tools.
|
|
3
|
+
*
|
|
4
|
+
* Annotations are hints that help MCP clients understand tool behavior
|
|
5
|
+
* for permission prompts, safety checks, and orchestration decisions.
|
|
6
|
+
*
|
|
7
|
+
* readOnly: query/review/search/structured are false because they can persist
|
|
8
|
+
* Claude CLI session state to disk (~/.claude/) when sessionId is used.
|
|
9
|
+
* ping is true (purely local, no side effects).
|
|
10
|
+
*
|
|
11
|
+
* review: destructive=false because the default --allowed-tools list is read-only
|
|
12
|
+
* (Read, Grep, Glob, git). Callers that pass custom tools including write access
|
|
13
|
+
* should treat it as potentially destructive.
|
|
14
|
+
*
|
|
15
|
+
* Titles are set on the registerTool config in index.ts, not here (avoid duplication).
|
|
16
|
+
*/
|
|
17
|
+
export const queryAnnotations = {
|
|
18
|
+
readOnlyHint: false,
|
|
19
|
+
destructiveHint: false,
|
|
20
|
+
idempotentHint: false,
|
|
21
|
+
openWorldHint: true,
|
|
22
|
+
};
|
|
23
|
+
export const reviewAnnotations = {
|
|
24
|
+
readOnlyHint: false,
|
|
25
|
+
destructiveHint: false,
|
|
26
|
+
idempotentHint: false,
|
|
27
|
+
openWorldHint: true,
|
|
28
|
+
};
|
|
29
|
+
export const searchAnnotations = {
|
|
30
|
+
readOnlyHint: false,
|
|
31
|
+
destructiveHint: false,
|
|
32
|
+
idempotentHint: true,
|
|
33
|
+
openWorldHint: true,
|
|
34
|
+
};
|
|
35
|
+
export const structuredAnnotations = {
|
|
36
|
+
readOnlyHint: false,
|
|
37
|
+
destructiveHint: false,
|
|
38
|
+
idempotentHint: false,
|
|
39
|
+
openWorldHint: true,
|
|
40
|
+
};
|
|
41
|
+
export const listSessionsAnnotations = {
|
|
42
|
+
readOnlyHint: true,
|
|
43
|
+
destructiveHint: false,
|
|
44
|
+
idempotentHint: true,
|
|
45
|
+
openWorldHint: false,
|
|
46
|
+
};
|
|
47
|
+
export const pingAnnotations = {
|
|
48
|
+
readOnlyHint: true,
|
|
49
|
+
destructiveHint: false,
|
|
50
|
+
idempotentHint: true,
|
|
51
|
+
openWorldHint: false,
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC/C,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAChD,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAChD,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAoB;IACpD,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAoB;IACtD,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,KAAK;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,KAAK;CACrB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich tool descriptions for MCP clients.
|
|
3
|
+
*
|
|
4
|
+
* Descriptions include capability summaries, cost guidance, and prompt tips
|
|
5
|
+
* so calling LLMs can make informed tool selection and parameterization decisions.
|
|
6
|
+
*
|
|
7
|
+
* Keep each description at or under 2048 bytes to avoid bloating tool listings.
|
|
8
|
+
*/
|
|
9
|
+
export declare const queryDescription = "Execute a prompt via Claude Code CLI with optional file context and session resume. Claude is an AI coding agent that can generate, analyze, refactor, and explain code.\n\nCapabilities: code generation and refactoring, code analysis and explanation, file understanding (text and images), multi-turn conversations via sessionId.\n\nCost: Default model is Sonnet (~$0.01-0.10/call). Use effort=\"low\" for simple tasks, effort=\"high\" + model=\"opus\" for complex analysis. Set maxBudgetUsd to cap per-call cost (recommended for effort=\"max\" or model=\"opus\").\n\nTips:\n- Set workingDirectory to the target repo for project-aware responses.\n- Break complex tasks into focused prompts rather than one large request.\n- Resume multi-turn conversations with sessionId from a previous response's metadata.\n- Include relevant files via the files parameter for targeted context (text files inlined in prompt, images trigger allowed-tools mode).\n- Use noSessionPersistence=true for stateless one-shot calls.";
|
|
10
|
+
export declare const reviewDescription = "Repo-aware code review powered by Claude Code CLI. Returns structured feedback on code changes with two modes:\n\n- Agentic (default): Claude explores the repo with Read, Grep, Glob, and git tools. Reads changed files, follows imports, and examines related code before reviewing. Best for thorough reviews. Default timeout: 5 minutes.\n- Quick (quick: true): Receives only the diff text. Fast single-pass review without repo exploration. Default timeout: 2 minutes.\n\nCost: Both modes default to Opus (~$0.05-0.15 quick, ~$0.25-0.50 agentic). Override with model parameter. Use maxBudgetUsd to cap cost on large diffs.\n\nTips:\n- Use the focus parameter to direct attention: \"security\", \"performance\", \"error handling\", \"test coverage\".\n- Set workingDirectory to the repo being reviewed (auto-resolves to git root).\n- Default reviews uncommitted changes (staged + unstaged). Use base to review a branch diff (e.g. base: \"main\").\n- Prefer agentic mode for important reviews, quick mode for rapid feedback during development.";
|
|
11
|
+
export declare const searchDescription = "Web search via Claude Code CLI using WebSearch and WebFetch tools. Searches the web and synthesizes a comprehensive answer with source URLs.\n\nUse for: current information, documentation lookups, API references, comparing libraries, and research questions.\n\nCost: Typically ~$0.02-0.05/search with Sonnet.\n\nTips:\n- Ask specific, focused questions for best results.\n- Results include source URLs for verification.\n- Use maxResponseLength to control response verbosity.\n- Increase timeout for complex research queries that may require multiple web fetches.";
|
|
12
|
+
export declare const structuredDescription = "Generate JSON conforming to a provided JSON Schema. Uses Claude CLI's native --json-schema flag for validated output (not client-side validation).\n\nUse for: data extraction from text/files, classification, entity parsing, or any task needing machine-parseable output.\n\nCost: Similar to query (~$0.01-0.10/call). Schema complexity doesn't significantly affect cost.\n\nTips:\n- Pass the JSON Schema as a JSON string in the schema parameter.\n- Schema max size: 20KB. Keep schemas focused for reliable output.\n- For extraction tasks, include source text via the files parameter or inline in the prompt.";
|
|
13
|
+
export declare const listSessionsDescription = "List active Claude CLI sessions tracked by this server. Returns session metadata (IDs, models, timing, turn counts, cumulative cost) for orchestration. Use to check available sessions before resuming with sessionId. No cost (local lookup only).";
|
|
14
|
+
export declare const pingDescription = "Health check: verifies Claude CLI is installed and authenticated, reports versions, capabilities, and configuration. No cost (local check only).";
|
|
15
|
+
//# sourceMappingURL=descriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["../src/descriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,m/BAWiC,CAAC;AAE/D,eAAO,MAAM,iBAAiB,mhCAWiE,CAAC;AAEhG,eAAO,MAAM,iBAAiB,wjBAUyD,CAAC;AAExF,eAAO,MAAM,qBAAqB,kmBAS2D,CAAC;AAE9F,eAAO,MAAM,uBAAuB,yPAAyP,CAAC;AAE9R,eAAO,MAAM,eAAe,qJAAqJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich tool descriptions for MCP clients.
|
|
3
|
+
*
|
|
4
|
+
* Descriptions include capability summaries, cost guidance, and prompt tips
|
|
5
|
+
* so calling LLMs can make informed tool selection and parameterization decisions.
|
|
6
|
+
*
|
|
7
|
+
* Keep each description at or under 2048 bytes to avoid bloating tool listings.
|
|
8
|
+
*/
|
|
9
|
+
export const queryDescription = `Execute a prompt via Claude Code CLI with optional file context and session resume. Claude is an AI coding agent that can generate, analyze, refactor, and explain code.
|
|
10
|
+
|
|
11
|
+
Capabilities: code generation and refactoring, code analysis and explanation, file understanding (text and images), multi-turn conversations via sessionId.
|
|
12
|
+
|
|
13
|
+
Cost: Default model is Sonnet (~$0.01-0.10/call). Use effort="low" for simple tasks, effort="high" + model="opus" for complex analysis. Set maxBudgetUsd to cap per-call cost (recommended for effort="max" or model="opus").
|
|
14
|
+
|
|
15
|
+
Tips:
|
|
16
|
+
- Set workingDirectory to the target repo for project-aware responses.
|
|
17
|
+
- Break complex tasks into focused prompts rather than one large request.
|
|
18
|
+
- Resume multi-turn conversations with sessionId from a previous response's metadata.
|
|
19
|
+
- Include relevant files via the files parameter for targeted context (text files inlined in prompt, images trigger allowed-tools mode).
|
|
20
|
+
- Use noSessionPersistence=true for stateless one-shot calls.`;
|
|
21
|
+
export const reviewDescription = `Repo-aware code review powered by Claude Code CLI. Returns structured feedback on code changes with two modes:
|
|
22
|
+
|
|
23
|
+
- Agentic (default): Claude explores the repo with Read, Grep, Glob, and git tools. Reads changed files, follows imports, and examines related code before reviewing. Best for thorough reviews. Default timeout: 5 minutes.
|
|
24
|
+
- Quick (quick: true): Receives only the diff text. Fast single-pass review without repo exploration. Default timeout: 2 minutes.
|
|
25
|
+
|
|
26
|
+
Cost: Both modes default to Opus (~$0.05-0.15 quick, ~$0.25-0.50 agentic). Override with model parameter. Use maxBudgetUsd to cap cost on large diffs.
|
|
27
|
+
|
|
28
|
+
Tips:
|
|
29
|
+
- Use the focus parameter to direct attention: "security", "performance", "error handling", "test coverage".
|
|
30
|
+
- Set workingDirectory to the repo being reviewed (auto-resolves to git root).
|
|
31
|
+
- Default reviews uncommitted changes (staged + unstaged). Use base to review a branch diff (e.g. base: "main").
|
|
32
|
+
- Prefer agentic mode for important reviews, quick mode for rapid feedback during development.`;
|
|
33
|
+
export const searchDescription = `Web search via Claude Code CLI using WebSearch and WebFetch tools. Searches the web and synthesizes a comprehensive answer with source URLs.
|
|
34
|
+
|
|
35
|
+
Use for: current information, documentation lookups, API references, comparing libraries, and research questions.
|
|
36
|
+
|
|
37
|
+
Cost: Typically ~$0.02-0.05/search with Sonnet.
|
|
38
|
+
|
|
39
|
+
Tips:
|
|
40
|
+
- Ask specific, focused questions for best results.
|
|
41
|
+
- Results include source URLs for verification.
|
|
42
|
+
- Use maxResponseLength to control response verbosity.
|
|
43
|
+
- Increase timeout for complex research queries that may require multiple web fetches.`;
|
|
44
|
+
export const structuredDescription = `Generate JSON conforming to a provided JSON Schema. Uses Claude CLI's native --json-schema flag for validated output (not client-side validation).
|
|
45
|
+
|
|
46
|
+
Use for: data extraction from text/files, classification, entity parsing, or any task needing machine-parseable output.
|
|
47
|
+
|
|
48
|
+
Cost: Similar to query (~$0.01-0.10/call). Schema complexity doesn't significantly affect cost.
|
|
49
|
+
|
|
50
|
+
Tips:
|
|
51
|
+
- Pass the JSON Schema as a JSON string in the schema parameter.
|
|
52
|
+
- Schema max size: 20KB. Keep schemas focused for reliable output.
|
|
53
|
+
- For extraction tasks, include source text via the files parameter or inline in the prompt.`;
|
|
54
|
+
export const listSessionsDescription = `List active Claude CLI sessions tracked by this server. Returns session metadata (IDs, models, timing, turn counts, cumulative cost) for orchestration. Use to check available sessions before resuming with sessionId. No cost (local lookup only).`;
|
|
55
|
+
export const pingDescription = `Health check: verifies Claude CLI is installed and authenticated, reports versions, capabilities, and configuration. No cost (local check only).`;
|
|
56
|
+
//# sourceMappingURL=descriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../src/descriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;8DAW8B,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;+FAW8D,CAAC;AAEhG,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;uFAUsD,CAAC;AAExF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;6FASwD,CAAC;AAE9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,sPAAsP,CAAC;AAE9R,MAAM,CAAC,MAAM,eAAe,GAAG,kJAAkJ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,73 +9,99 @@ import { executeSearch } from "./tools/search.js";
|
|
|
9
9
|
import { executePing } from "./tools/ping.js";
|
|
10
10
|
import { executeStructured } from "./tools/structured.js";
|
|
11
11
|
import { getErrorMessage } from "./utils/errors.js";
|
|
12
|
+
import { buildMeta } from "./utils/meta.js";
|
|
13
|
+
import { queryAnnotations, reviewAnnotations, searchAnnotations, structuredAnnotations, listSessionsAnnotations, pingAnnotations, } from "./annotations.js";
|
|
14
|
+
import { queryDescription, reviewDescription, searchDescription, structuredDescription, listSessionsDescription, pingDescription, } from "./descriptions.js";
|
|
15
|
+
import { sessionStore, persist } from "./utils/session.js";
|
|
16
|
+
import { maybeStartHeartbeat } from "./utils/progress.js";
|
|
12
17
|
const require = createRequire(import.meta.url);
|
|
13
18
|
const { version: PKG_VERSION } = require("../package.json");
|
|
14
19
|
const server = new McpServer({
|
|
15
20
|
name: "claude-mcp-bridge",
|
|
16
21
|
version: PKG_VERSION,
|
|
17
22
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
// --- query tool ---
|
|
24
|
+
server.registerTool("query", {
|
|
25
|
+
title: "Claude Query",
|
|
26
|
+
description: queryDescription,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
prompt: z.string().describe("The prompt to send to Claude"),
|
|
29
|
+
files: z
|
|
30
|
+
.array(z.string())
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("File paths (text or images) relative to workingDirectory"),
|
|
33
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
34
|
+
sessionId: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("Claude session ID to resume with --resume"),
|
|
38
|
+
resetSession: z
|
|
39
|
+
.boolean()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Clear stored session state before execution (use with sessionId to start fresh)"),
|
|
42
|
+
noSessionPersistence: z
|
|
43
|
+
.boolean()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Disable session persistence for ephemeral print calls"),
|
|
46
|
+
workingDirectory: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("Working directory for file resolution and CLI execution"),
|
|
50
|
+
timeout: z
|
|
51
|
+
.number()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Timeout in milliseconds (default: 60000, image queries: 120000)"),
|
|
54
|
+
maxResponseLength: z
|
|
55
|
+
.number()
|
|
56
|
+
.int()
|
|
57
|
+
.positive()
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("Soft limit on response length in words"),
|
|
60
|
+
maxBudgetUsd: z
|
|
61
|
+
.number()
|
|
62
|
+
.positive()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
65
|
+
effort: z
|
|
66
|
+
.string()
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("Effort level: low, medium, high, or max (passed to --effort)"),
|
|
69
|
+
},
|
|
70
|
+
annotations: queryAnnotations,
|
|
71
|
+
}, async (input, extra) => {
|
|
72
|
+
const start = Date.now();
|
|
73
|
+
const heartbeat = maybeStartHeartbeat(extra._meta, extra.sendNotification);
|
|
60
74
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
if (input.resetSession && input.sessionId) {
|
|
76
|
+
sessionStore.delete(input.sessionId);
|
|
77
|
+
}
|
|
78
|
+
const result = await executeQuery(input.resetSession ? { ...input, sessionId: undefined } : input);
|
|
79
|
+
const sessionId = result.sessionId ?? (input.resetSession ? undefined : input.sessionId);
|
|
80
|
+
if (sessionId) {
|
|
81
|
+
persist(sessionStore, sessionId, result);
|
|
82
|
+
}
|
|
83
|
+
const textMeta = [];
|
|
63
84
|
if (result.filesIncluded.length > 0)
|
|
64
|
-
|
|
85
|
+
textMeta.push(`Files included: ${result.filesIncluded.join(", ")}`);
|
|
65
86
|
if (result.imagesIncluded.length > 0)
|
|
66
|
-
|
|
87
|
+
textMeta.push(`Images included: ${result.imagesIncluded.join(", ")}`);
|
|
67
88
|
if (result.filesSkipped.length > 0)
|
|
68
|
-
|
|
69
|
-
if (result.model)
|
|
70
|
-
meta.push(`Model: ${result.model}`);
|
|
71
|
-
if (result.sessionId)
|
|
72
|
-
meta.push(`Session: ${result.sessionId}`);
|
|
73
|
-
if (typeof result.totalCostUsd === "number")
|
|
74
|
-
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
89
|
+
textMeta.push(`Files skipped: ${result.filesSkipped.join(", ")}`);
|
|
75
90
|
if (result.timedOut)
|
|
76
|
-
|
|
91
|
+
textMeta.push("(timed out)");
|
|
92
|
+
const text = textMeta.length > 0
|
|
93
|
+
? `${result.response}\n\n---\n${textMeta.join("\n")}`
|
|
94
|
+
: result.response;
|
|
77
95
|
return {
|
|
78
|
-
content: [{ type: "text", text
|
|
96
|
+
content: [{ type: "text", text }],
|
|
97
|
+
_meta: buildMeta({
|
|
98
|
+
durationMs: Date.now() - start,
|
|
99
|
+
model: result.model,
|
|
100
|
+
sessionId: result.sessionId,
|
|
101
|
+
totalCostUsd: result.totalCostUsd,
|
|
102
|
+
usage: result.usage,
|
|
103
|
+
timedOut: result.timedOut,
|
|
104
|
+
}),
|
|
79
105
|
};
|
|
80
106
|
}
|
|
81
107
|
catch (e) {
|
|
@@ -83,106 +109,140 @@ server.tool("query", "Execute a prompt via Claude Code CLI with optional file co
|
|
|
83
109
|
return {
|
|
84
110
|
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
85
111
|
isError: true,
|
|
112
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
86
113
|
};
|
|
87
114
|
}
|
|
115
|
+
finally {
|
|
116
|
+
heartbeat.stop();
|
|
117
|
+
}
|
|
88
118
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.
|
|
95
|
-
.describe("
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.describe("
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
// --- structured tool ---
|
|
120
|
+
server.registerTool("structured", {
|
|
121
|
+
title: "Structured Output",
|
|
122
|
+
description: structuredDescription,
|
|
123
|
+
inputSchema: {
|
|
124
|
+
prompt: z.string().describe("What to generate or extract"),
|
|
125
|
+
schema: z.string().describe("JSON Schema as a JSON string"),
|
|
126
|
+
files: z
|
|
127
|
+
.array(z.string())
|
|
128
|
+
.optional()
|
|
129
|
+
.describe("Text file paths to include as context"),
|
|
130
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
131
|
+
sessionId: z
|
|
132
|
+
.string()
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("Claude session ID to resume with --resume"),
|
|
135
|
+
noSessionPersistence: z
|
|
136
|
+
.boolean()
|
|
137
|
+
.optional()
|
|
138
|
+
.describe("Disable session persistence for ephemeral print calls"),
|
|
139
|
+
workingDirectory: z
|
|
140
|
+
.string()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe("Working directory for file resolution and CLI execution"),
|
|
143
|
+
timeout: z
|
|
144
|
+
.number()
|
|
145
|
+
.optional()
|
|
146
|
+
.describe("Timeout in milliseconds (default: 60000)"),
|
|
147
|
+
maxBudgetUsd: z
|
|
148
|
+
.number()
|
|
149
|
+
.positive()
|
|
150
|
+
.optional()
|
|
151
|
+
.describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
152
|
+
},
|
|
153
|
+
annotations: structuredAnnotations,
|
|
118
154
|
}, async (input) => {
|
|
155
|
+
const start = Date.now();
|
|
119
156
|
try {
|
|
120
157
|
const result = await executeStructured(input);
|
|
158
|
+
const sessionId = result.sessionId ?? input.sessionId;
|
|
159
|
+
if (sessionId) {
|
|
160
|
+
persist(sessionStore, sessionId, result);
|
|
161
|
+
}
|
|
162
|
+
const meta = buildMeta({
|
|
163
|
+
durationMs: Date.now() - start,
|
|
164
|
+
model: result.model,
|
|
165
|
+
sessionId: result.sessionId,
|
|
166
|
+
totalCostUsd: result.totalCostUsd,
|
|
167
|
+
usage: result.usage,
|
|
168
|
+
timedOut: result.timedOut,
|
|
169
|
+
});
|
|
121
170
|
if (!result.valid) {
|
|
122
171
|
return {
|
|
123
172
|
content: [{ type: "text", text: `Error: ${result.errors ?? "Invalid response"}` }],
|
|
124
173
|
isError: true,
|
|
174
|
+
_meta: meta,
|
|
125
175
|
};
|
|
126
176
|
}
|
|
127
177
|
const content = [
|
|
128
178
|
{ type: "text", text: result.response },
|
|
129
179
|
];
|
|
130
|
-
const
|
|
180
|
+
const textMeta = [];
|
|
131
181
|
if (result.filesIncluded.length > 0)
|
|
132
|
-
|
|
133
|
-
if (result.model)
|
|
134
|
-
meta.push(`Model: ${result.model}`);
|
|
135
|
-
if (result.sessionId)
|
|
136
|
-
meta.push(`Session: ${result.sessionId}`);
|
|
137
|
-
if (typeof result.totalCostUsd === "number")
|
|
138
|
-
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
182
|
+
textMeta.push(`Files: ${result.filesIncluded.join(", ")}`);
|
|
139
183
|
if (result.timedOut)
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
content.push({ type: "text", text:
|
|
184
|
+
textMeta.push("(timed out)");
|
|
185
|
+
if (textMeta.length > 0) {
|
|
186
|
+
content.push({ type: "text", text: textMeta.join("\n") });
|
|
143
187
|
}
|
|
144
|
-
return { content };
|
|
188
|
+
return { content, _meta: meta };
|
|
145
189
|
}
|
|
146
190
|
catch (e) {
|
|
147
191
|
console.error("[structured]", e);
|
|
148
192
|
return {
|
|
149
193
|
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
150
194
|
isError: true,
|
|
195
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
151
196
|
};
|
|
152
197
|
}
|
|
153
198
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
199
|
+
// --- review tool ---
|
|
200
|
+
server.registerTool("review", {
|
|
201
|
+
title: "Code Review",
|
|
202
|
+
description: reviewDescription,
|
|
203
|
+
inputSchema: {
|
|
204
|
+
uncommitted: z.boolean().optional().describe("Review uncommitted changes. Default: true"),
|
|
205
|
+
base: z.string().optional().describe("Base branch/ref to diff against. Overrides uncommitted."),
|
|
206
|
+
focus: z.string().optional().describe("Optional review focus area"),
|
|
207
|
+
quick: z.boolean().optional().describe("Use diff-only quick review mode"),
|
|
208
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
209
|
+
sessionId: z.string().optional().describe("Claude session ID to resume with --resume"),
|
|
210
|
+
noSessionPersistence: z.boolean().optional().describe("Disable session persistence for ephemeral print calls"),
|
|
211
|
+
workingDirectory: z.string().optional().describe("Repository directory"),
|
|
212
|
+
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
213
|
+
maxResponseLength: z.number().int().positive().optional().describe("Soft limit on response length in words"),
|
|
214
|
+
maxBudgetUsd: z.number().positive().optional().describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
215
|
+
effort: z.string().optional().describe("Effort level: low, medium, high, or max (default: high for agentic)"),
|
|
216
|
+
},
|
|
217
|
+
annotations: reviewAnnotations,
|
|
218
|
+
}, async (input, extra) => {
|
|
219
|
+
const start = Date.now();
|
|
220
|
+
const heartbeat = maybeStartHeartbeat(extra._meta, extra.sendNotification);
|
|
168
221
|
try {
|
|
169
222
|
const result = await executeReview(input);
|
|
170
|
-
const
|
|
223
|
+
const sessionId = result.sessionId ?? input.sessionId;
|
|
224
|
+
if (sessionId) {
|
|
225
|
+
persist(sessionStore, sessionId, result);
|
|
226
|
+
}
|
|
227
|
+
const textMeta = [
|
|
171
228
|
`Diff source: ${result.diffSource}`,
|
|
172
229
|
`Mode: ${result.mode}`,
|
|
173
230
|
];
|
|
174
231
|
if (result.base)
|
|
175
|
-
|
|
176
|
-
if (result.model)
|
|
177
|
-
meta.push(`Model: ${result.model}`);
|
|
178
|
-
if (result.sessionId)
|
|
179
|
-
meta.push(`Session: ${result.sessionId}`);
|
|
180
|
-
if (typeof result.totalCostUsd === "number")
|
|
181
|
-
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
232
|
+
textMeta.push(`Base: ${result.base}`);
|
|
182
233
|
if (result.timedOut)
|
|
183
|
-
|
|
234
|
+
textMeta.push("(timed out)");
|
|
235
|
+
const text = `${result.response}\n\n---\n${textMeta.join("\n")}`;
|
|
184
236
|
return {
|
|
185
|
-
content: [{ type: "text", text
|
|
237
|
+
content: [{ type: "text", text }],
|
|
238
|
+
_meta: buildMeta({
|
|
239
|
+
durationMs: Date.now() - start,
|
|
240
|
+
model: result.model,
|
|
241
|
+
sessionId: result.sessionId,
|
|
242
|
+
totalCostUsd: result.totalCostUsd,
|
|
243
|
+
usage: result.usage,
|
|
244
|
+
timedOut: result.timedOut,
|
|
245
|
+
}),
|
|
186
246
|
};
|
|
187
247
|
}
|
|
188
248
|
catch (e) {
|
|
@@ -190,33 +250,51 @@ server.tool("review", "Repo-aware code review. Quick mode reviews a precomputed
|
|
|
190
250
|
return {
|
|
191
251
|
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
192
252
|
isError: true,
|
|
253
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
193
254
|
};
|
|
194
255
|
}
|
|
256
|
+
finally {
|
|
257
|
+
heartbeat.stop();
|
|
258
|
+
}
|
|
195
259
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
260
|
+
// --- search tool ---
|
|
261
|
+
server.registerTool("search", {
|
|
262
|
+
title: "Web Search",
|
|
263
|
+
description: searchDescription,
|
|
264
|
+
inputSchema: {
|
|
265
|
+
query: z.string().describe("Search query or question"),
|
|
266
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
267
|
+
sessionId: z.string().optional().describe("Claude session ID to resume with --resume"),
|
|
268
|
+
noSessionPersistence: z.boolean().optional().describe("Disable session persistence for ephemeral print calls"),
|
|
269
|
+
workingDirectory: z.string().optional().describe("Working directory for the CLI"),
|
|
270
|
+
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
271
|
+
maxResponseLength: z.number().int().positive().optional().describe("Soft limit on response length in words"),
|
|
272
|
+
maxBudgetUsd: z.number().positive().optional().describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
273
|
+
effort: z.string().optional().describe("Effort level: low, medium, high, or max (default: medium for search)"),
|
|
274
|
+
},
|
|
275
|
+
annotations: searchAnnotations,
|
|
276
|
+
}, async (input, extra) => {
|
|
277
|
+
const start = Date.now();
|
|
278
|
+
const heartbeat = maybeStartHeartbeat(extra._meta, extra.sendNotification);
|
|
207
279
|
try {
|
|
208
280
|
const result = await executeSearch(input);
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (result.timedOut)
|
|
217
|
-
meta.push("(timed out)");
|
|
281
|
+
const sessionId = result.sessionId ?? input.sessionId;
|
|
282
|
+
if (sessionId) {
|
|
283
|
+
persist(sessionStore, sessionId, result);
|
|
284
|
+
}
|
|
285
|
+
const text = result.timedOut
|
|
286
|
+
? `${result.response}\n\n---\n(timed out)`
|
|
287
|
+
: result.response;
|
|
218
288
|
return {
|
|
219
|
-
content: [{ type: "text", text
|
|
289
|
+
content: [{ type: "text", text }],
|
|
290
|
+
_meta: buildMeta({
|
|
291
|
+
durationMs: Date.now() - start,
|
|
292
|
+
model: result.model,
|
|
293
|
+
sessionId: result.sessionId,
|
|
294
|
+
totalCostUsd: result.totalCostUsd,
|
|
295
|
+
usage: result.usage,
|
|
296
|
+
timedOut: result.timedOut,
|
|
297
|
+
}),
|
|
220
298
|
};
|
|
221
299
|
}
|
|
222
300
|
catch (e) {
|
|
@@ -224,10 +302,35 @@ server.tool("search", "Web search via Claude Code CLI using WebSearch and WebFet
|
|
|
224
302
|
return {
|
|
225
303
|
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
226
304
|
isError: true,
|
|
305
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
227
306
|
};
|
|
228
307
|
}
|
|
308
|
+
finally {
|
|
309
|
+
heartbeat.stop();
|
|
310
|
+
}
|
|
229
311
|
});
|
|
230
|
-
|
|
312
|
+
// --- listSessions tool ---
|
|
313
|
+
server.registerTool("listSessions", {
|
|
314
|
+
title: "List Sessions",
|
|
315
|
+
description: listSessionsDescription,
|
|
316
|
+
inputSchema: {},
|
|
317
|
+
annotations: listSessionsAnnotations,
|
|
318
|
+
}, async () => {
|
|
319
|
+
const start = Date.now();
|
|
320
|
+
const sessions = sessionStore.list();
|
|
321
|
+
return {
|
|
322
|
+
content: [{ type: "text", text: JSON.stringify(sessions, null, 2) }],
|
|
323
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
// --- ping tool ---
|
|
327
|
+
server.registerTool("ping", {
|
|
328
|
+
title: "Health Check",
|
|
329
|
+
description: pingDescription,
|
|
330
|
+
inputSchema: {},
|
|
331
|
+
annotations: pingAnnotations,
|
|
332
|
+
}, async () => {
|
|
333
|
+
const start = Date.now();
|
|
231
334
|
try {
|
|
232
335
|
const result = await executePing();
|
|
233
336
|
const lines = [
|
|
@@ -242,16 +345,21 @@ server.tool("ping", "Check whether Claude CLI is installed and what auth method
|
|
|
242
345
|
`maxConcurrent: ${result.maxConcurrent}`,
|
|
243
346
|
`capabilities: bareMode=${result.capabilities.bareMode}, jsonOutput=${result.capabilities.jsonOutput}, jsonSchema=${result.capabilities.jsonSchema}, sessionResume=${result.capabilities.sessionResume}`,
|
|
244
347
|
];
|
|
245
|
-
return {
|
|
348
|
+
return {
|
|
349
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
350
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
351
|
+
};
|
|
246
352
|
}
|
|
247
353
|
catch (e) {
|
|
248
354
|
console.error("[ping]", e);
|
|
249
355
|
return {
|
|
250
356
|
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
251
357
|
isError: true,
|
|
358
|
+
_meta: buildMeta({ durationMs: Date.now() - start }),
|
|
252
359
|
};
|
|
253
360
|
}
|
|
254
361
|
});
|
|
362
|
+
// --- Start server ---
|
|
255
363
|
const transport = new StdioServerTransport();
|
|
256
364
|
await server.connect(transport);
|
|
257
365
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,O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,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;SACrD,CAAC;IACJ,CAAC;AACH,CAAC,CACF,CAAC;AAEF,uBAAuB;AAEvB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ClaudeUsage } from "./parse.js";
|
|
2
|
+
export interface MetaFields {
|
|
3
|
+
durationMs: number;
|
|
4
|
+
model?: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
totalCostUsd?: number;
|
|
7
|
+
usage?: ClaudeUsage;
|
|
8
|
+
timedOut?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Build execution metadata attached as `_meta` on CallToolResult.
|
|
12
|
+
*
|
|
13
|
+
* Provides orchestrating agents with timing, model, cost, and token usage.
|
|
14
|
+
* Claude-mcp-bridge returns the richest metadata of the three bridges:
|
|
15
|
+
* totalCostUsd + full token breakdown (input, output, cache read).
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildMeta(fields: MetaFields): Record<string, unknown>;
|
|
18
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/utils/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAcrE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build execution metadata attached as `_meta` on CallToolResult.
|
|
3
|
+
*
|
|
4
|
+
* Provides orchestrating agents with timing, model, cost, and token usage.
|
|
5
|
+
* Claude-mcp-bridge returns the richest metadata of the three bridges:
|
|
6
|
+
* totalCostUsd + full token breakdown (input, output, cache read).
|
|
7
|
+
*/
|
|
8
|
+
export function buildMeta(fields) {
|
|
9
|
+
const meta = {
|
|
10
|
+
durationMs: fields.durationMs,
|
|
11
|
+
};
|
|
12
|
+
if (fields.model)
|
|
13
|
+
meta.model = fields.model;
|
|
14
|
+
if (fields.sessionId)
|
|
15
|
+
meta.sessionId = fields.sessionId;
|
|
16
|
+
if (typeof fields.totalCostUsd === "number")
|
|
17
|
+
meta.totalCostUsd = fields.totalCostUsd;
|
|
18
|
+
if (fields.usage?.input_tokens !== undefined)
|
|
19
|
+
meta.inputTokens = fields.usage.input_tokens;
|
|
20
|
+
if (fields.usage?.output_tokens !== undefined)
|
|
21
|
+
meta.outputTokens = fields.usage.output_tokens;
|
|
22
|
+
if (fields.usage?.cache_read_input_tokens !== undefined) {
|
|
23
|
+
meta.cacheReadTokens = fields.usage.cache_read_input_tokens;
|
|
24
|
+
}
|
|
25
|
+
if (fields.timedOut)
|
|
26
|
+
meta.timedOut = true;
|
|
27
|
+
return meta;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/utils/meta.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,MAAkB;IAC1C,MAAM,IAAI,GAA4B;QACpC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;IACF,IAAI,MAAM,CAAC,KAAK;QAAE,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC5C,IAAI,MAAM,CAAC,SAAS;QAAE,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACxD,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ;QAAE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IACrF,IAAI,MAAM,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS;QAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;IAC3F,IAAI,MAAM,CAAC,KAAK,EAAE,aAAa,KAAK,SAAS;QAAE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC;IAC9F,IAAI,MAAM,CAAC,KAAK,EAAE,uBAAuB,KAAK,SAAS,EAAE,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ;QAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface ProgressHeartbeat {
|
|
2
|
+
stop: () => void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Function signature for sending MCP progress notifications.
|
|
6
|
+
* Matches the shape of `extra.sendNotification` from tool handlers.
|
|
7
|
+
*/
|
|
8
|
+
export type ProgressNotificationSender = (notification: {
|
|
9
|
+
method: "notifications/progress";
|
|
10
|
+
params: {
|
|
11
|
+
progressToken: string | number;
|
|
12
|
+
progress: number;
|
|
13
|
+
total?: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Start a periodic progress heartbeat that emits MCP `notifications/progress`.
|
|
19
|
+
*
|
|
20
|
+
* Used for long-running operations (review, search, query) to signal liveness
|
|
21
|
+
* to the MCP client. The first notification fires after `intervalMs`.
|
|
22
|
+
* Notifications are fire-and-forget; failures are silently ignored (not all
|
|
23
|
+
* clients support progress notifications).
|
|
24
|
+
*
|
|
25
|
+
* @param progressToken - Opaque token from the client's request `_meta.progressToken`
|
|
26
|
+
* @param sendNotification - The notification sender from the tool handler's `extra` context
|
|
27
|
+
* @param intervalMs - Milliseconds between heartbeats (default: 15000)
|
|
28
|
+
*/
|
|
29
|
+
export declare function startProgressHeartbeat(progressToken: string | number, sendNotification: ProgressNotificationSender, intervalMs?: number): ProgressHeartbeat;
|
|
30
|
+
/**
|
|
31
|
+
* Helper to conditionally start a heartbeat only when the client provided a progress token.
|
|
32
|
+
* Returns a no-op stop function when no token is present.
|
|
33
|
+
*/
|
|
34
|
+
export declare function maybeStartHeartbeat(meta: {
|
|
35
|
+
progressToken?: string | number;
|
|
36
|
+
} | undefined, sendNotification: ProgressNotificationSender, intervalMs?: number): ProgressHeartbeat;
|
|
37
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/utils/progress.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,YAAY,EAAE;IACtD,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE;QACN,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GAAG,MAAM,EAC9B,gBAAgB,EAAE,0BAA0B,EAC5C,UAAU,GAAE,MAA4B,GACvC,iBAAiB,CAwBnB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,SAAS,EACrD,gBAAgB,EAAE,0BAA0B,EAC5C,UAAU,CAAC,EAAE,MAAM,GAClB,iBAAiB,CAMnB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Default interval between heartbeat notifications. */
|
|
2
|
+
const DEFAULT_INTERVAL_MS = 15_000;
|
|
3
|
+
/**
|
|
4
|
+
* Start a periodic progress heartbeat that emits MCP `notifications/progress`.
|
|
5
|
+
*
|
|
6
|
+
* Used for long-running operations (review, search, query) to signal liveness
|
|
7
|
+
* to the MCP client. The first notification fires after `intervalMs`.
|
|
8
|
+
* Notifications are fire-and-forget; failures are silently ignored (not all
|
|
9
|
+
* clients support progress notifications).
|
|
10
|
+
*
|
|
11
|
+
* @param progressToken - Opaque token from the client's request `_meta.progressToken`
|
|
12
|
+
* @param sendNotification - The notification sender from the tool handler's `extra` context
|
|
13
|
+
* @param intervalMs - Milliseconds between heartbeats (default: 15000)
|
|
14
|
+
*/
|
|
15
|
+
export function startProgressHeartbeat(progressToken, sendNotification, intervalMs = DEFAULT_INTERVAL_MS) {
|
|
16
|
+
const startTime = Date.now();
|
|
17
|
+
let tick = 0;
|
|
18
|
+
const timer = setInterval(() => {
|
|
19
|
+
tick++;
|
|
20
|
+
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
21
|
+
sendNotification({
|
|
22
|
+
method: "notifications/progress",
|
|
23
|
+
params: {
|
|
24
|
+
progressToken,
|
|
25
|
+
progress: tick,
|
|
26
|
+
message: `Processing... (${elapsed}s elapsed)`,
|
|
27
|
+
},
|
|
28
|
+
}).catch(() => {
|
|
29
|
+
// Fire-and-forget: client may not support progress notifications
|
|
30
|
+
});
|
|
31
|
+
}, intervalMs);
|
|
32
|
+
return {
|
|
33
|
+
stop() {
|
|
34
|
+
clearInterval(timer);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Helper to conditionally start a heartbeat only when the client provided a progress token.
|
|
40
|
+
* Returns a no-op stop function when no token is present.
|
|
41
|
+
*/
|
|
42
|
+
export function maybeStartHeartbeat(meta, sendNotification, intervalMs) {
|
|
43
|
+
const token = meta?.progressToken;
|
|
44
|
+
if (token === undefined) {
|
|
45
|
+
return { stop() { } };
|
|
46
|
+
}
|
|
47
|
+
return startProgressHeartbeat(token, sendNotification, intervalMs);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/utils/progress.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAoBnC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACpC,aAA8B,EAC9B,gBAA4C,EAC5C,aAAqB,mBAAmB;IAExC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,IAAI,EAAE,CAAC;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5D,gBAAgB,CAAC;YACf,MAAM,EAAE,wBAAwB;YAChC,MAAM,EAAE;gBACN,aAAa;gBACb,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,kBAAkB,OAAO,YAAY;aAC/C;SACF,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACZ,iEAAiE;QACnE,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,UAAU,CAAC,CAAC;IAEf,OAAO;QACL,IAAI;YACF,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAqD,EACrD,gBAA4C,EAC5C,UAAmB;IAEnB,MAAM,KAAK,GAAG,IAAI,EAAE,aAAa,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,IAAI,KAAI,CAAC,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory session storage for Claude CLI conversations.
|
|
3
|
+
*
|
|
4
|
+
* Tracks session IDs, models, timing, turn counts, and cumulative cost.
|
|
5
|
+
* Claude CLI returns session_id directly (no indirection like codex's conversationId),
|
|
6
|
+
* and total_cost_usd per call enables cumulative cost tracking.
|
|
7
|
+
*/
|
|
8
|
+
/** Validate a session ID format. */
|
|
9
|
+
export declare function isValidSessionId(id: string): boolean;
|
|
10
|
+
export interface SessionEntry {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
model?: string;
|
|
13
|
+
createdAt: number;
|
|
14
|
+
lastUsedAt: number;
|
|
15
|
+
turnCount: number;
|
|
16
|
+
totalCostUsd: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionStorage {
|
|
19
|
+
get(id: string): SessionEntry | undefined;
|
|
20
|
+
set(id: string, entry: SessionEntry): void;
|
|
21
|
+
delete(id: string): void;
|
|
22
|
+
list(): SessionEntry[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* In-memory session storage with TTL and LRU eviction.
|
|
26
|
+
*
|
|
27
|
+
* - TTL checked lazily on get/list (expired entries cleaned up on access)
|
|
28
|
+
* - LRU eviction when at capacity (oldest by lastUsedAt)
|
|
29
|
+
*/
|
|
30
|
+
export declare class SessionStore implements SessionStorage {
|
|
31
|
+
private store;
|
|
32
|
+
private ttl;
|
|
33
|
+
private maxSessions;
|
|
34
|
+
constructor(ttl?: number, maxSessions?: number);
|
|
35
|
+
get(id: string): SessionEntry | undefined;
|
|
36
|
+
set(id: string, entry: SessionEntry): void;
|
|
37
|
+
delete(id: string): void;
|
|
38
|
+
/** List all active sessions, sorted by lastUsedAt descending (most recent first). */
|
|
39
|
+
list(): SessionEntry[];
|
|
40
|
+
private evictExpired;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Persist session state from a tool result.
|
|
44
|
+
*
|
|
45
|
+
* Creates or updates the session entry:
|
|
46
|
+
* - createdAt preserved on resume (not overwritten)
|
|
47
|
+
* - totalCostUsd accumulated across calls
|
|
48
|
+
* - turnCount incremented by 1
|
|
49
|
+
*
|
|
50
|
+
* Best-effort: never throws (try/catch wrapper).
|
|
51
|
+
*/
|
|
52
|
+
export declare function persist(store: SessionStore, sessionId: string, result: {
|
|
53
|
+
model?: string;
|
|
54
|
+
totalCostUsd?: number;
|
|
55
|
+
}): void;
|
|
56
|
+
/** Global session store singleton. */
|
|
57
|
+
export declare const sessionStore: SessionStore;
|
|
58
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,oCAAoC;AACpC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IAC1C,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,IAAI,YAAY,EAAE,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,cAAc;IACjD,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,WAAW,CAAS;gBAEhB,GAAG,SAAc,EAAE,WAAW,SAAuB;IAKjE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAKzC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAgB1C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIxB,qFAAqF;IACrF,IAAI,IAAI,YAAY,EAAE;IAKtB,OAAO,CAAC,YAAY;CAQrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAChD,IAAI,CAgBN;AAED,sCAAsC;AACtC,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory session storage for Claude CLI conversations.
|
|
3
|
+
*
|
|
4
|
+
* Tracks session IDs, models, timing, turn counts, and cumulative cost.
|
|
5
|
+
* Claude CLI returns session_id directly (no indirection like codex's conversationId),
|
|
6
|
+
* and total_cost_usd per call enables cumulative cost tracking.
|
|
7
|
+
*/
|
|
8
|
+
const SESSION_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
9
|
+
const MAX_SESSION_ID_LENGTH = 256;
|
|
10
|
+
const DEFAULT_TTL = 24 * 60 * 60 * 1000; // 24 hours
|
|
11
|
+
const DEFAULT_MAX_SESSIONS = 100;
|
|
12
|
+
/** Validate a session ID format. */
|
|
13
|
+
export function isValidSessionId(id) {
|
|
14
|
+
return id.length > 0 && id.length <= MAX_SESSION_ID_LENGTH && SESSION_ID_PATTERN.test(id);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* In-memory session storage with TTL and LRU eviction.
|
|
18
|
+
*
|
|
19
|
+
* - TTL checked lazily on get/list (expired entries cleaned up on access)
|
|
20
|
+
* - LRU eviction when at capacity (oldest by lastUsedAt)
|
|
21
|
+
*/
|
|
22
|
+
export class SessionStore {
|
|
23
|
+
store = new Map();
|
|
24
|
+
ttl;
|
|
25
|
+
maxSessions;
|
|
26
|
+
constructor(ttl = DEFAULT_TTL, maxSessions = DEFAULT_MAX_SESSIONS) {
|
|
27
|
+
this.ttl = ttl;
|
|
28
|
+
this.maxSessions = maxSessions;
|
|
29
|
+
}
|
|
30
|
+
get(id) {
|
|
31
|
+
this.evictExpired();
|
|
32
|
+
return this.store.get(id);
|
|
33
|
+
}
|
|
34
|
+
set(id, entry) {
|
|
35
|
+
this.evictExpired();
|
|
36
|
+
if (this.store.size >= this.maxSessions && !this.store.has(id)) {
|
|
37
|
+
let oldestKey;
|
|
38
|
+
let oldestTime = Infinity;
|
|
39
|
+
for (const [key, val] of this.store) {
|
|
40
|
+
if (val.lastUsedAt < oldestTime) {
|
|
41
|
+
oldestTime = val.lastUsedAt;
|
|
42
|
+
oldestKey = key;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (oldestKey)
|
|
46
|
+
this.store.delete(oldestKey);
|
|
47
|
+
}
|
|
48
|
+
this.store.set(id, entry);
|
|
49
|
+
}
|
|
50
|
+
delete(id) {
|
|
51
|
+
this.store.delete(id);
|
|
52
|
+
}
|
|
53
|
+
/** List all active sessions, sorted by lastUsedAt descending (most recent first). */
|
|
54
|
+
list() {
|
|
55
|
+
this.evictExpired();
|
|
56
|
+
return Array.from(this.store.values()).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
|
|
57
|
+
}
|
|
58
|
+
evictExpired() {
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
for (const [key, entry] of this.store) {
|
|
61
|
+
if (now - entry.lastUsedAt > this.ttl) {
|
|
62
|
+
this.store.delete(key);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Persist session state from a tool result.
|
|
69
|
+
*
|
|
70
|
+
* Creates or updates the session entry:
|
|
71
|
+
* - createdAt preserved on resume (not overwritten)
|
|
72
|
+
* - totalCostUsd accumulated across calls
|
|
73
|
+
* - turnCount incremented by 1
|
|
74
|
+
*
|
|
75
|
+
* Best-effort: never throws (try/catch wrapper).
|
|
76
|
+
*/
|
|
77
|
+
export function persist(store, sessionId, result) {
|
|
78
|
+
try {
|
|
79
|
+
if (!sessionId || !isValidSessionId(sessionId))
|
|
80
|
+
return;
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
const existing = store.get(sessionId);
|
|
83
|
+
store.set(sessionId, {
|
|
84
|
+
sessionId,
|
|
85
|
+
model: result.model ?? existing?.model,
|
|
86
|
+
createdAt: existing?.createdAt ?? now,
|
|
87
|
+
lastUsedAt: now,
|
|
88
|
+
turnCount: (existing?.turnCount ?? 0) + 1,
|
|
89
|
+
totalCostUsd: (existing?.totalCostUsd ?? 0) + (result.totalCostUsd ?? 0),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Best-effort: session storage must never break tool execution
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Global session store singleton. */
|
|
97
|
+
export const sessionStore = new SessionStore();
|
|
98
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot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