claude-code-infinite 1.0.11 → 1.0.16
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 +214 -47
- package/dist/cc-request.d.ts +94 -0
- package/dist/cc-request.d.ts.map +1 -0
- package/dist/cc-request.js +194 -0
- package/dist/cc-request.js.map +1 -0
- package/dist/claude-env.d.ts +30 -0
- package/dist/claude-env.d.ts.map +1 -0
- package/dist/claude-env.js +55 -0
- package/dist/claude-env.js.map +1 -0
- package/dist/cli-args.d.ts +32 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +72 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli-lifecycle.d.ts +17 -0
- package/dist/cli-lifecycle.d.ts.map +1 -0
- package/dist/cli-lifecycle.js +30 -0
- package/dist/cli-lifecycle.js.map +1 -0
- package/dist/cli-main.d.ts +15 -0
- package/dist/cli-main.d.ts.map +1 -0
- package/dist/cli-main.js +464 -0
- package/dist/cli-main.js.map +1 -0
- package/dist/cli.js +13 -178
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -3
- package/dist/config.js.map +1 -1
- package/dist/count-tokens.d.ts +78 -0
- package/dist/count-tokens.d.ts.map +1 -0
- package/dist/count-tokens.js +277 -0
- package/dist/count-tokens.js.map +1 -0
- package/dist/final-index.d.ts +10 -0
- package/dist/final-index.d.ts.map +1 -0
- package/dist/final-index.js +37 -0
- package/dist/final-index.js.map +1 -0
- package/dist/hooks.d.ts +239 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +618 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/memtree-fetch.d.ts +24 -0
- package/dist/memtree-fetch.d.ts.map +1 -0
- package/dist/memtree-fetch.js +121 -0
- package/dist/memtree-fetch.js.map +1 -0
- package/dist/memtree-finder.d.ts +99 -0
- package/dist/memtree-finder.d.ts.map +1 -0
- package/dist/memtree-finder.js +235 -0
- package/dist/memtree-finder.js.map +1 -0
- package/dist/memtree-links.d.ts +16 -0
- package/dist/memtree-links.d.ts.map +1 -0
- package/dist/memtree-links.js +66 -0
- package/dist/memtree-links.js.map +1 -0
- package/dist/memtree-mcp-config.d.ts +28 -0
- package/dist/memtree-mcp-config.d.ts.map +1 -0
- package/dist/memtree-mcp-config.js +121 -0
- package/dist/memtree-mcp-config.js.map +1 -0
- package/dist/memtree-mcp.d.ts +265 -0
- package/dist/memtree-mcp.d.ts.map +1 -0
- package/dist/memtree-mcp.js +667 -0
- package/dist/memtree-mcp.js.map +1 -0
- package/dist/memtree-newest.d.ts +74 -0
- package/dist/memtree-newest.d.ts.map +1 -0
- package/dist/memtree-newest.js +217 -0
- package/dist/memtree-newest.js.map +1 -0
- package/dist/memtree-tools.d.ts +105 -0
- package/dist/memtree-tools.d.ts.map +1 -0
- package/dist/memtree-tools.js +408 -0
- package/dist/memtree-tools.js.map +1 -0
- package/dist/memtree.d.ts +430 -0
- package/dist/memtree.d.ts.map +1 -0
- package/dist/memtree.js +1286 -0
- package/dist/memtree.js.map +1 -0
- package/dist/notices.d.ts +177 -0
- package/dist/notices.d.ts.map +1 -0
- package/dist/notices.js +469 -0
- package/dist/notices.js.map +1 -0
- package/dist/payment-gate.d.ts +53 -0
- package/dist/payment-gate.d.ts.map +1 -0
- package/dist/payment-gate.js +97 -0
- package/dist/payment-gate.js.map +1 -0
- package/dist/project-meta.d.ts +15 -0
- package/dist/project-meta.d.ts.map +1 -0
- package/dist/project-meta.js +80 -0
- package/dist/project-meta.js.map +1 -0
- package/dist/prompt-accounting.d.ts +12 -0
- package/dist/prompt-accounting.d.ts.map +1 -0
- package/dist/prompt-accounting.js +70 -0
- package/dist/prompt-accounting.js.map +1 -0
- package/dist/proxy.d.ts +204 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +4299 -0
- package/dist/proxy.js.map +1 -0
- package/dist/reqlog.d.ts +427 -0
- package/dist/reqlog.d.ts.map +1 -0
- package/dist/reqlog.js +146 -0
- package/dist/reqlog.js.map +1 -0
- package/dist/request-sizing.d.ts +74 -0
- package/dist/request-sizing.d.ts.map +1 -0
- package/dist/request-sizing.js +121 -0
- package/dist/request-sizing.js.map +1 -0
- package/dist/resume-repair-file.d.ts +17 -0
- package/dist/resume-repair-file.d.ts.map +1 -0
- package/dist/resume-repair-file.js +100 -0
- package/dist/resume-repair-file.js.map +1 -0
- package/dist/resume-repair.d.ts +27 -0
- package/dist/resume-repair.d.ts.map +1 -0
- package/dist/resume-repair.js +198 -0
- package/dist/resume-repair.js.map +1 -0
- package/dist/route-cache.d.ts +5 -0
- package/dist/route-cache.d.ts.map +1 -0
- package/dist/route-cache.js +63 -0
- package/dist/route-cache.js.map +1 -0
- package/dist/route-fallback.d.ts +67 -0
- package/dist/route-fallback.d.ts.map +1 -0
- package/dist/route-fallback.js +126 -0
- package/dist/route-fallback.js.map +1 -0
- package/dist/route-identity.d.ts +6 -0
- package/dist/route-identity.d.ts.map +1 -0
- package/dist/route-identity.js +100 -0
- package/dist/route-identity.js.map +1 -0
- package/dist/transcript-usage.d.ts +57 -0
- package/dist/transcript-usage.d.ts.map +1 -0
- package/dist/transcript-usage.js +570 -0
- package/dist/transcript-usage.js.map +1 -0
- package/dist/turns.d.ts +77 -0
- package/dist/turns.d.ts.map +1 -0
- package/dist/turns.js +330 -0
- package/dist/turns.js.map +1 -0
- package/dist/update-check.d.ts +38 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +67 -0
- package/dist/update-check.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** `x-memtree-tools` value. */
|
|
2
|
+
export declare const MEMTREE_TOOLS_HEADER_VALUE: string;
|
|
3
|
+
/** Claude Code's names for the tools, for `--allowedTools`. */
|
|
4
|
+
export declare const MEMTREE_ALLOWED_TOOLS: string[];
|
|
5
|
+
export declare const MEMTREE_MCP_SCRIPT: string;
|
|
6
|
+
export declare function memtreeMcpEnabledByEnv(env: NodeJS.ProcessEnv): boolean;
|
|
7
|
+
/** The `--mcp-config` JSON for this ccc's server, bound to its proxy. */
|
|
8
|
+
export declare function memtreeMcpConfig(proxyUrl: string): object;
|
|
9
|
+
export interface MemtreeMcpConfigFile {
|
|
10
|
+
path: string;
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function writeMemtreeMcpConfig(proxyUrl: string, tempRoot?: string): MemtreeMcpConfigFile;
|
|
14
|
+
/** Prepend the options; `=` forms so no variadic option swallows user argv. */
|
|
15
|
+
export declare function withMemtreeMcpArgs(args: readonly string[], configPath: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* The `--mcp-config` values in Claude's argv (before `--`): each is a file
|
|
18
|
+
* path or an inline JSON string. Handles `--mcp-config a b` (variadic, up to
|
|
19
|
+
* the next option) and `--mcp-config=a`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function mcpConfigArgs(args: readonly string[]): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether Claude's argv already configures ccc's `memtree` server: a server
|
|
24
|
+
* named `memtree` whose command line runs `memtree-mcp` (`ccc memtree-mcp` or
|
|
25
|
+
* dist/memtree-mcp.js). Unreadable or malformed configs count as no.
|
|
26
|
+
*/
|
|
27
|
+
export declare function argsConfigureMemtreeMcp(args: readonly string[], cwd?: string): boolean;
|
|
28
|
+
//# sourceMappingURL=memtree-mcp-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memtree-mcp-config.d.ts","sourceRoot":"","sources":["../src/memtree-mcp-config.ts"],"names":[],"mappings":"AA2BA,+BAA+B;AAC/B,eAAO,MAAM,0BAA0B,QAA+B,CAAC;AACvE,+DAA+D;AAC/D,eAAO,MAAM,qBAAqB,UAEjC,CAAC;AACF,eAAO,MAAM,kBAAkB,QAA8D,CAAC;AAE9F,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAEtE;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWzD;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAoB,GAC7B,oBAAoB,CAatB;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAa/D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAqBT"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registering the `memtree` MCP server (memtree-mcp.ts) with Claude Code, and
|
|
3
|
+
* telling whether it is registered, which decides the `x-memtree-tools`
|
|
4
|
+
* header on MemTree compress calls: MemTree then adds a short how-to naming
|
|
5
|
+
* the tools to the memory it returns, so it must never be sent when the tools
|
|
6
|
+
* are absent.
|
|
7
|
+
*
|
|
8
|
+
* - Interactive ccc sessions: ccc writes a one-server config to a temp dir
|
|
9
|
+
* and passes `--mcp-config=<file>`. `--mcp-config` (unlike a plugin's
|
|
10
|
+
* `.mcp.json`, whose tools Claude Code would name `mcp__plugin_ccc_…`) keeps
|
|
11
|
+
* the tool names `mcp__memtree__*` and still loads under a user's
|
|
12
|
+
* `--strict-mcp-config`. The `=` form matters: `--mcp-config` is variadic,
|
|
13
|
+
* and a following positional prompt would otherwise be read as a config.
|
|
14
|
+
* The tools are read-only views of the user's own session, so they are
|
|
15
|
+
* pre-allowed with `--allowedTools=` as well. `CCC_MEMTREE_MCP=0` turns this
|
|
16
|
+
* off.
|
|
17
|
+
* - Print (`-p`) and non-TTY runs get nothing automatically (their output and
|
|
18
|
+
* tool set stay vanilla). A caller that wants the tools passes its own
|
|
19
|
+
* `--mcp-config` naming a server `memtree` run by `ccc memtree-mcp` (or
|
|
20
|
+
* dist/memtree-mcp.js); ccc detects it and sends the header.
|
|
21
|
+
*/
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
import os from "node:os";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
import { MEMTREE_MCP_SERVER_NAME, MEMTREE_TOOL_NAMES } from "./memtree-mcp.js";
|
|
27
|
+
/** `x-memtree-tools` value. */
|
|
28
|
+
export const MEMTREE_TOOLS_HEADER_VALUE = MEMTREE_TOOL_NAMES.join(",");
|
|
29
|
+
/** Claude Code's names for the tools, for `--allowedTools`. */
|
|
30
|
+
export const MEMTREE_ALLOWED_TOOLS = MEMTREE_TOOL_NAMES.map((tool) => `mcp__${MEMTREE_MCP_SERVER_NAME}__${tool}`);
|
|
31
|
+
export const MEMTREE_MCP_SCRIPT = fileURLToPath(new URL("./memtree-mcp.js", import.meta.url));
|
|
32
|
+
export function memtreeMcpEnabledByEnv(env) {
|
|
33
|
+
return env.CCC_MEMTREE_MCP !== "0";
|
|
34
|
+
}
|
|
35
|
+
/** The `--mcp-config` JSON for this ccc's server, bound to its proxy. */
|
|
36
|
+
export function memtreeMcpConfig(proxyUrl) {
|
|
37
|
+
return {
|
|
38
|
+
mcpServers: {
|
|
39
|
+
[MEMTREE_MCP_SERVER_NAME]: {
|
|
40
|
+
type: "stdio",
|
|
41
|
+
command: process.execPath,
|
|
42
|
+
args: [MEMTREE_MCP_SCRIPT],
|
|
43
|
+
env: { CCC_MEMTREE_PROXY: proxyUrl },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function writeMemtreeMcpConfig(proxyUrl, tempRoot = os.tmpdir()) {
|
|
49
|
+
const dir = fs.mkdtempSync(path.join(tempRoot, "ccc-memtree-mcp-"));
|
|
50
|
+
const file = path.join(dir, "mcp.json");
|
|
51
|
+
fs.writeFileSync(file, JSON.stringify(memtreeMcpConfig(proxyUrl)), { mode: 0o600 });
|
|
52
|
+
let closed = false;
|
|
53
|
+
return {
|
|
54
|
+
path: file,
|
|
55
|
+
close() {
|
|
56
|
+
if (closed)
|
|
57
|
+
return;
|
|
58
|
+
closed = true;
|
|
59
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Prepend the options; `=` forms so no variadic option swallows user argv. */
|
|
64
|
+
export function withMemtreeMcpArgs(args, configPath) {
|
|
65
|
+
return [
|
|
66
|
+
`--mcp-config=${configPath}`,
|
|
67
|
+
`--allowedTools=${MEMTREE_ALLOWED_TOOLS.join(",")}`,
|
|
68
|
+
...args,
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The `--mcp-config` values in Claude's argv (before `--`): each is a file
|
|
73
|
+
* path or an inline JSON string. Handles `--mcp-config a b` (variadic, up to
|
|
74
|
+
* the next option) and `--mcp-config=a`.
|
|
75
|
+
*/
|
|
76
|
+
export function mcpConfigArgs(args) {
|
|
77
|
+
const values = [];
|
|
78
|
+
for (let i = 0; i < args.length; i++) {
|
|
79
|
+
const arg = args[i];
|
|
80
|
+
if (arg === "--")
|
|
81
|
+
break;
|
|
82
|
+
if (arg.startsWith("--mcp-config=")) {
|
|
83
|
+
values.push(arg.slice("--mcp-config=".length));
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (arg !== "--mcp-config")
|
|
87
|
+
continue;
|
|
88
|
+
while (i + 1 < args.length && !args[i + 1].startsWith("-"))
|
|
89
|
+
values.push(args[++i]);
|
|
90
|
+
}
|
|
91
|
+
return values;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Whether Claude's argv already configures ccc's `memtree` server: a server
|
|
95
|
+
* named `memtree` whose command line runs `memtree-mcp` (`ccc memtree-mcp` or
|
|
96
|
+
* dist/memtree-mcp.js). Unreadable or malformed configs count as no.
|
|
97
|
+
*/
|
|
98
|
+
export function argsConfigureMemtreeMcp(args, cwd = process.cwd()) {
|
|
99
|
+
for (const value of mcpConfigArgs(args)) {
|
|
100
|
+
let parsed;
|
|
101
|
+
try {
|
|
102
|
+
const text = value.trim().startsWith("{")
|
|
103
|
+
? value
|
|
104
|
+
: fs.readFileSync(path.resolve(cwd, value), "utf-8");
|
|
105
|
+
parsed = JSON.parse(text);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const server = parsed?.mcpServers?.[MEMTREE_MCP_SERVER_NAME];
|
|
111
|
+
if (!server || typeof server !== "object")
|
|
112
|
+
continue;
|
|
113
|
+
const commandLine = [server.command, ...(Array.isArray(server.args) ? server.args : [])]
|
|
114
|
+
.filter((part) => typeof part === "string")
|
|
115
|
+
.join(" ");
|
|
116
|
+
if (/memtree-mcp/.test(commandLine))
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=memtree-mcp-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memtree-mcp-config.js","sourceRoot":"","sources":["../src/memtree-mcp-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EA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P_SERVER_NAME = "memtree";
|
|
3
|
+
/** Sent to MemTree as `x-memtree-tools` when this server is configured. */
|
|
4
|
+
export declare const MEMTREE_TOOL_NAMES: readonly ["search", "read_node", "read_lines", "list"];
|
|
5
|
+
/** `tree` value naming this session's own current tree. */
|
|
6
|
+
export declare const CURRENT_TREE = "current";
|
|
7
|
+
/**
|
|
8
|
+
* The MCP server's instructions, which Claude Code places in the system prompt
|
|
9
|
+
* from the first request: the one place that explains the agent's situation
|
|
10
|
+
* before any memory message exists. Constant, so the prompt cache holds.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MEMTREE_MCP_INSTRUCTIONS: string;
|
|
13
|
+
export declare const MEMTREE_TOOLS: ({
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: string;
|
|
18
|
+
properties: {
|
|
19
|
+
query: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
tree: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
mode: {
|
|
28
|
+
type: string;
|
|
29
|
+
enum: string[];
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
project: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
since: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
until: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
cursor: {
|
|
45
|
+
type: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
limit: {
|
|
49
|
+
type: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
node?: undefined;
|
|
53
|
+
id?: undefined;
|
|
54
|
+
block?: undefined;
|
|
55
|
+
start?: undefined;
|
|
56
|
+
end?: undefined;
|
|
57
|
+
tail?: undefined;
|
|
58
|
+
q?: undefined;
|
|
59
|
+
};
|
|
60
|
+
required: string[];
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
name: string;
|
|
64
|
+
description: string;
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: string;
|
|
67
|
+
properties: {
|
|
68
|
+
node: {
|
|
69
|
+
type: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
id: {
|
|
73
|
+
type: string;
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
tree: {
|
|
77
|
+
type: string;
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
query?: undefined;
|
|
81
|
+
mode?: undefined;
|
|
82
|
+
project?: undefined;
|
|
83
|
+
since?: undefined;
|
|
84
|
+
until?: undefined;
|
|
85
|
+
cursor?: undefined;
|
|
86
|
+
limit?: undefined;
|
|
87
|
+
block?: undefined;
|
|
88
|
+
start?: undefined;
|
|
89
|
+
end?: undefined;
|
|
90
|
+
tail?: undefined;
|
|
91
|
+
q?: undefined;
|
|
92
|
+
};
|
|
93
|
+
required?: undefined;
|
|
94
|
+
};
|
|
95
|
+
} | {
|
|
96
|
+
name: string;
|
|
97
|
+
description: string;
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: string;
|
|
100
|
+
properties: {
|
|
101
|
+
node: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
105
|
+
block: {
|
|
106
|
+
type: string;
|
|
107
|
+
description: string;
|
|
108
|
+
};
|
|
109
|
+
start: {
|
|
110
|
+
type: string;
|
|
111
|
+
description: string;
|
|
112
|
+
};
|
|
113
|
+
end: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
tree: {
|
|
118
|
+
type: string;
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
tail: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
query?: undefined;
|
|
126
|
+
mode?: undefined;
|
|
127
|
+
project?: undefined;
|
|
128
|
+
since?: undefined;
|
|
129
|
+
until?: undefined;
|
|
130
|
+
cursor?: undefined;
|
|
131
|
+
limit?: undefined;
|
|
132
|
+
id?: undefined;
|
|
133
|
+
q?: undefined;
|
|
134
|
+
};
|
|
135
|
+
required?: undefined;
|
|
136
|
+
};
|
|
137
|
+
} | {
|
|
138
|
+
name: string;
|
|
139
|
+
description: string;
|
|
140
|
+
inputSchema: {
|
|
141
|
+
type: string;
|
|
142
|
+
properties: {
|
|
143
|
+
since: {
|
|
144
|
+
type: string;
|
|
145
|
+
description: string;
|
|
146
|
+
};
|
|
147
|
+
until: {
|
|
148
|
+
type: string;
|
|
149
|
+
description: string;
|
|
150
|
+
};
|
|
151
|
+
project: {
|
|
152
|
+
type: string;
|
|
153
|
+
description: string;
|
|
154
|
+
};
|
|
155
|
+
q: {
|
|
156
|
+
type: string;
|
|
157
|
+
description: string;
|
|
158
|
+
};
|
|
159
|
+
cursor: {
|
|
160
|
+
type: string;
|
|
161
|
+
description: string;
|
|
162
|
+
};
|
|
163
|
+
limit: {
|
|
164
|
+
type: string;
|
|
165
|
+
description: string;
|
|
166
|
+
};
|
|
167
|
+
query?: undefined;
|
|
168
|
+
tree?: undefined;
|
|
169
|
+
mode?: undefined;
|
|
170
|
+
node?: undefined;
|
|
171
|
+
id?: undefined;
|
|
172
|
+
block?: undefined;
|
|
173
|
+
start?: undefined;
|
|
174
|
+
end?: undefined;
|
|
175
|
+
tail?: undefined;
|
|
176
|
+
};
|
|
177
|
+
required?: undefined;
|
|
178
|
+
};
|
|
179
|
+
})[];
|
|
180
|
+
export interface MemtreeMcpDeps {
|
|
181
|
+
/** The ccc loopback proxy, e.g. http://127.0.0.1:1234. */
|
|
182
|
+
proxyUrl?: string;
|
|
183
|
+
sessionId?: string;
|
|
184
|
+
fetch?: typeof fetch;
|
|
185
|
+
now?: () => number;
|
|
186
|
+
}
|
|
187
|
+
/** What the tree tools read: this session's current tree, or another one by id. */
|
|
188
|
+
export interface TreeSource {
|
|
189
|
+
get(tree?: string): Promise<MemtreeIndex>;
|
|
190
|
+
/** This session's current tree id (for searches scoped to it on the server). */
|
|
191
|
+
currentId?(validatePage?: boolean): Promise<string>;
|
|
192
|
+
/** Term search, formatted; optional so a plain index can stand in (tests). */
|
|
193
|
+
search?(query: string, limit: number | undefined, tree?: string): Promise<string>;
|
|
194
|
+
/** The un-indexed messages after the tree, read fresh from the server. */
|
|
195
|
+
tail?(tree: string | undefined, start?: number, end?: number): Promise<string>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Resolves, fetches and caches the current page, and other sessions' pages
|
|
199
|
+
* by request id.
|
|
200
|
+
*/
|
|
201
|
+
export declare class CurrentTree implements TreeSource {
|
|
202
|
+
private readonly deps;
|
|
203
|
+
private cached?;
|
|
204
|
+
/** Temporary prefix pages: when each may be fetched again. */
|
|
205
|
+
private readonly prefixRetryAt;
|
|
206
|
+
/** The last fetched temporary prefix per page, served during its cooldown. */
|
|
207
|
+
private readonly prefixes;
|
|
208
|
+
private inFlight?;
|
|
209
|
+
/** Other trees, least recently used first. */
|
|
210
|
+
private readonly others;
|
|
211
|
+
/** Set once the server answered 404 to a tree search the page JSON could answer. */
|
|
212
|
+
private serverSearchMissing;
|
|
213
|
+
private readonly fetchImpl;
|
|
214
|
+
private readonly now;
|
|
215
|
+
constructor(deps: MemtreeMcpDeps);
|
|
216
|
+
get(tree?: string): Promise<MemtreeIndex>;
|
|
217
|
+
/**
|
|
218
|
+
* The server's term search over the tree when it has the endpoint (no page
|
|
219
|
+
* download), else the same search over the page JSON here.
|
|
220
|
+
*/
|
|
221
|
+
search(query: string, limit: number | undefined, tree?: string): Promise<string>;
|
|
222
|
+
/**
|
|
223
|
+
* The server's un-indexed tail after the tree (`/messages`), never cached:
|
|
224
|
+
* it grows with the conversation. With no range, the newest messages.
|
|
225
|
+
*/
|
|
226
|
+
tail(tree: string | undefined, start?: number, end?: number): Promise<string>;
|
|
227
|
+
private loadCurrent;
|
|
228
|
+
private requireSessionId;
|
|
229
|
+
/** The proxy's current page for the calling session; fails closed on any other session. */
|
|
230
|
+
currentId(validatePage?: boolean): Promise<string>;
|
|
231
|
+
private checkSession;
|
|
232
|
+
private getOther;
|
|
233
|
+
/**
|
|
234
|
+
* Fetch one page. ``sessionId`` (the current tree only) must match the page's
|
|
235
|
+
* session. A temporary prefix (the newest completed tree for an earlier part
|
|
236
|
+
* of the conversation, shown until the request's own tree is built) is not
|
|
237
|
+
* cached for good: it is refetched at most every PREFIX_RETRY_INTERVAL_MS, and
|
|
238
|
+
* the last copy is served in between, so successive tools neither hammer the
|
|
239
|
+
* page endpoint nor get an error for a tree they could read.
|
|
240
|
+
*/
|
|
241
|
+
private loadPage;
|
|
242
|
+
private prefixRetryError;
|
|
243
|
+
}
|
|
244
|
+
/** The cross-session tools: formatted text from the proxy's finder relay. */
|
|
245
|
+
export interface SessionFinderSource {
|
|
246
|
+
listSessions(args: Record<string, unknown>): Promise<string>;
|
|
247
|
+
/** Server search across sessions, or within ``tree`` (any mode). */
|
|
248
|
+
searchSessions(args: Record<string, unknown>, tree?: string): Promise<string>;
|
|
249
|
+
}
|
|
250
|
+
export declare class SessionFinder implements SessionFinderSource {
|
|
251
|
+
private readonly deps;
|
|
252
|
+
private readonly fetchImpl;
|
|
253
|
+
constructor(deps: MemtreeMcpDeps);
|
|
254
|
+
listSessions(args: Record<string, unknown>): Promise<string>;
|
|
255
|
+
searchSessions(args: Record<string, unknown>, tree?: string): Promise<string>;
|
|
256
|
+
private get;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* One JSON-RPC message in, the response out (undefined for notifications).
|
|
260
|
+
* Exposed for tests; the stdio loop below is only framing.
|
|
261
|
+
*/
|
|
262
|
+
export declare function handleMcpMessage(input: unknown, tree: TreeSource, finder?: SessionFinderSource): Promise<object | undefined>;
|
|
263
|
+
/** Serve MCP over this process's stdin/stdout until stdin closes. */
|
|
264
|
+
export declare function runMemtreeMcpServer(env?: NodeJS.ProcessEnv): void;
|
|
265
|
+
//# sourceMappingURL=memtree-mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memtree-mcp.d.ts","sourceRoot":"","sources":["../src/memtree-mcp.ts"],"names":[],"mappings":"AA+CA,OAAO,EAML,YAAY,EASb,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,uBAAuB,YAAY,CAAC;AACjD,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,wDAKrB,CAAC;AACX,2DAA2D;AAC3D,eAAO,MAAM,YAAY,YAAY,CAAC;AAKtC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAwBjB,CAAC;AAIrB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4EzB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAuED,mFAAmF;AACnF,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC1C,gFAAgF;IAChF,SAAS,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,8EAA8E;IAC9E,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,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