imprint-mcp 0.6.6 → 0.7.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/CHANGELOG.md +22 -0
- package/README.md +278 -16
- package/package.json +2 -2
- package/prompts/audit-agent.md +25 -4
- package/prompts/auth-compile-agent.md +28 -12
- package/prompts/build-planning.md +3 -3
- package/prompts/compile-agent.md +895 -180
- package/prompts/live-verifier-agent.md +10 -3
- package/prompts/master-teach-api-researcher.md +813 -0
- package/prompts/master-teach-baseline-mvp-review.md +217 -0
- package/prompts/master-teach-completion-review.md +188 -0
- package/prompts/master-teach-decision.md +885 -0
- package/prompts/master-teach-focused-planner.md +764 -0
- package/prompts/master-teach-parameter-advisor.md +58 -0
- package/prompts/master-teach-recording-evidence.md +19 -0
- package/prompts/master-teach-refine-plan.md +7 -0
- package/prompts/master-teach-tool-advisor.md +130 -0
- package/prompts/playbook-compilation.md +45 -54
- package/prompts/prereq-builder.md +28 -6
- package/prompts/prereq-planner.md +2 -2
- package/prompts/tool-candidate-detection.md +70 -39
- package/prompts/tool-planning.md +3 -3
- package/src/cli.ts +190 -150
- package/src/imprint/agent.ts +47 -33
- package/src/imprint/api-research-agent.ts +933 -0
- package/src/imprint/audit.ts +49 -2
- package/src/imprint/auth-compile-agent.ts +125 -55
- package/src/imprint/auth-compile-tools.ts +20 -48
- package/src/imprint/auth-verifier.ts +8 -19
- package/src/imprint/backend-ladder.ts +499 -367
- package/src/imprint/body-structure.ts +656 -0
- package/src/imprint/build-plan.ts +33 -323
- package/src/imprint/cdp-browser-fetch.ts +734 -29
- package/src/imprint/cdp-jar-cache.ts +7 -12
- package/src/imprint/claude-cli-compile.ts +276 -320
- package/src/imprint/codex-cli-compile.ts +476 -350
- package/src/imprint/codex-sdk-turn.ts +102 -0
- package/src/imprint/compile-agent-types.ts +49 -10
- package/src/imprint/compile-agent.ts +189 -274
- package/src/imprint/compile-done-sentinel.ts +211 -0
- package/src/imprint/compile-provider-control.ts +401 -0
- package/src/imprint/compile-provider-recovery.ts +142 -0
- package/src/imprint/compile-strategy.ts +5 -0
- package/src/imprint/compile-tools.ts +1695 -3097
- package/src/imprint/compile-verification.ts +9 -1
- package/src/imprint/compile.ts +107 -29
- package/src/imprint/compiler-log.ts +12 -0
- package/src/imprint/compiler-process.ts +440 -0
- package/src/imprint/concurrency.ts +43 -58
- package/src/imprint/credential-extract.ts +1 -88
- package/src/imprint/emit.ts +18 -2
- package/src/imprint/evidence-inspection.ts +55 -0
- package/src/imprint/freeform-redact.ts +34 -234
- package/src/imprint/import-module-fresh.ts +30 -0
- package/src/imprint/live-finesse-runner.ts +299 -0
- package/src/imprint/live-verifier.ts +299 -358
- package/src/imprint/llm.ts +466 -422
- package/src/imprint/log.ts +1 -9
- package/src/imprint/master-teach-agent-contracts.ts +875 -0
- package/src/imprint/master-teach-agents.ts +2850 -0
- package/src/imprint/master-teach-checks.ts +341 -0
- package/src/imprint/master-teach-controller.ts +7159 -0
- package/src/imprint/master-teach-plan.ts +1410 -0
- package/src/imprint/master-teach-prompt-projections.ts +347 -0
- package/src/imprint/master-teach-store.ts +961 -0
- package/src/imprint/mcp-cdp-sessions.ts +60 -0
- package/src/imprint/mcp-compile-server.ts +519 -668
- package/src/imprint/mcp-live-verifier-server.ts +246 -190
- package/src/imprint/mcp-server.ts +46 -57
- package/src/imprint/native-agent-pass.ts +260 -0
- package/src/imprint/native-agent-usage.ts +141 -0
- package/src/imprint/native-teach-agents.ts +495 -0
- package/src/imprint/param-grounding.ts +488 -347
- package/src/imprint/playbook-runner.ts +254 -63
- package/src/imprint/prereq-builder.ts +55 -543
- package/src/imprint/private-file.ts +18 -0
- package/src/imprint/probe-backends.ts +129 -33
- package/src/imprint/provider-retry.ts +501 -0
- package/src/imprint/provider-terminal.ts +214 -0
- package/src/imprint/recording-request.ts +290 -1
- package/src/imprint/recording-verification.ts +444 -0
- package/src/imprint/redact.ts +33 -749
- package/src/imprint/refine-worker.ts +326 -0
- package/src/imprint/refine.ts +241 -0
- package/src/imprint/replay-capture.ts +41 -12
- package/src/imprint/replay-evidence.ts +1007 -0
- package/src/imprint/research-response-evidence.ts +45 -0
- package/src/imprint/runtime.ts +514 -106
- package/src/imprint/sensitive-keys.ts +0 -6
- package/src/imprint/session-merge.ts +103 -7
- package/src/imprint/stealth-fetch.ts +25 -8
- package/src/imprint/stealth-token-cache.ts +16 -16
- package/src/imprint/teach-plan.ts +0 -242
- package/src/imprint/teach-research-memory.ts +229 -0
- package/src/imprint/teach-state.ts +47 -625
- package/src/imprint/teach.ts +12 -3699
- package/src/imprint/tool-candidates.ts +58 -210
- package/src/imprint/tool-loader.ts +3 -0
- package/src/imprint/tool-plan.ts +1 -134
- package/src/imprint/tracing.ts +24 -7
- package/src/imprint/types.ts +68 -4
- package/src/imprint/endpoint-key.ts +0 -23
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { cdpReplayPoolKey } from './backend-ladder.ts';
|
|
2
|
+
import type { CdpBrowserFetch } from './cdp-browser-fetch.ts';
|
|
3
|
+
import type { ConcreteBackend } from './types.ts';
|
|
4
|
+
|
|
5
|
+
/** Lifecycle of the MCP server's tool-scoped CDP sessions and backend memo. */
|
|
6
|
+
export class McpCdpSessions {
|
|
7
|
+
readonly pool = new Map<string, CdpBrowserFetch>();
|
|
8
|
+
readonly winners = new Map<string, ConcreteBackend>();
|
|
9
|
+
private readonly timers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
10
|
+
|
|
11
|
+
constructor(private readonly idleMs = 5 * 60 * 1000) {}
|
|
12
|
+
|
|
13
|
+
beginCall(site: string, toolName: string): void {
|
|
14
|
+
const prefix = cdpReplayPoolKey(site, toolName, '');
|
|
15
|
+
for (const [key, timer] of this.timers) {
|
|
16
|
+
if (!key.startsWith(prefix)) continue;
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
this.timers.delete(key);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
finishCall(site: string, toolName: string): void {
|
|
23
|
+
this.beginCall(site, toolName);
|
|
24
|
+
const prefix = cdpReplayPoolKey(site, toolName, '');
|
|
25
|
+
for (const [key, session] of this.pool) {
|
|
26
|
+
if (!key.startsWith(prefix)) continue;
|
|
27
|
+
const timer = setTimeout(() => {
|
|
28
|
+
this.timers.delete(key);
|
|
29
|
+
if (this.pool.get(key) !== session) return;
|
|
30
|
+
this.pool.delete(key);
|
|
31
|
+
this.winners.delete(`${site}:${toolName}`);
|
|
32
|
+
void session.close().catch(() => {});
|
|
33
|
+
}, this.idleMs);
|
|
34
|
+
timer.unref();
|
|
35
|
+
this.timers.set(key, timer);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async closeTool(site: string, toolName: string): Promise<void> {
|
|
40
|
+
this.beginCall(site, toolName);
|
|
41
|
+
this.winners.delete(`${site}:${toolName}`);
|
|
42
|
+
const prefix = cdpReplayPoolKey(site, toolName, '');
|
|
43
|
+
const closing: Promise<void>[] = [];
|
|
44
|
+
for (const [key, session] of this.pool) {
|
|
45
|
+
if (!key.startsWith(prefix)) continue;
|
|
46
|
+
this.pool.delete(key);
|
|
47
|
+
closing.push(session.close().catch(() => {}));
|
|
48
|
+
}
|
|
49
|
+
await Promise.all(closing);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async closeAll(): Promise<void> {
|
|
53
|
+
for (const timer of this.timers.values()) clearTimeout(timer);
|
|
54
|
+
this.timers.clear();
|
|
55
|
+
const sessions = [...this.pool.values()];
|
|
56
|
+
this.pool.clear();
|
|
57
|
+
this.winners.clear();
|
|
58
|
+
await Promise.all(sessions.map((session) => session.close().catch(() => {})));
|
|
59
|
+
}
|
|
60
|
+
}
|