@akanjs/devkit 3.0.0-beta.19 → 3.0.0-beta.20
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/abstractDoc.test.ts +6 -15
- package/abstractDoc.ts +1 -4
- package/agentsIndex.test.ts +4 -7
- package/agentsIndex.ts +6 -22
- package/akanApp/BackendImportGraph.test.ts +8 -22
- package/akanApp/BackendImportGraph.ts +1 -20
- package/akanApp/akanApp.host.test.ts +1 -3
- package/akanApp/akanApp.host.ts +64 -250
- package/akanApp/devHostPolicy.test.ts +10 -34
- package/akanApp/devHostPolicy.ts +12 -98
- package/akanConfig/akanConfig.test.ts +30 -39
- package/akanConfig/akanConfig.ts +40 -136
- package/akanContext.ts +106 -159
- package/akanMcpContract.ts +28 -73
- package/appSelectionMemory.ts +1 -4
- package/applicationBuildReporter.ts +37 -5
- package/applicationBuildRunner.ts +25 -59
- package/applicationReleasePackager.ts +24 -44
- package/applicationTestPreload.ts +3 -12
- package/artifact/implicitRootLayout.test.ts +3 -19
- package/artifact/implicitRootLayout.ts +34 -91
- package/artifact/routeSeedIndex.ts +11 -44
- package/biomeBase.ts +2 -5
- package/capacitorApp.test.ts +4 -14
- package/capacitorApp.ts +86 -235
- package/cloud/cloudApi.test.ts +202 -0
- package/cloud/cloudApi.ts +33 -57
- package/cloud/configLock.test.ts +64 -0
- package/cloud/configLock.ts +96 -0
- package/cloud/constants.ts +3 -2
- package/cloud/globalConfig.ts +64 -31
- package/codeAgent/agent/AkanCodeServices.ts +15 -57
- package/codeAgent/agent/AkanContextFiles.ts +5 -28
- package/codeAgent/agent/CodeAgent.ts +33 -108
- package/codeAgent/agent/CodeAgentAsks.ts +7 -30
- package/codeAgent/agent/CodeAgentEventMapper.ts +9 -52
- package/codeAgent/agent/CodeAgentGate.ts +8 -34
- package/codeAgent/agent/CodeAgentProxy.ts +4 -13
- package/codeAgent/agent/CodeAgentRpcHost.ts +3 -16
- package/codeAgent/agent/CodeAgentRpcListener.ts +2 -10
- package/codeAgent/agent/CodeAgentStreamPrinter.ts +4 -15
- package/codeAgent/agent/CodeAgentSuspended.ts +1 -8
- package/codeAgent/agent/CodeAgentUi.ts +2 -7
- package/codeAgent/agent/CodeMailbox.ts +7 -34
- package/codeAgent/agent/CodeSessionFork.ts +4 -19
- package/codeAgent/agent/CodeSessionIndex.ts +5 -31
- package/codeAgent/agent/SubagentPool.ts +48 -58
- package/codeAgent/agent/akanCodeModel.ts +5 -39
- package/codeAgent/agent/akanCodePaths.ts +4 -24
- package/codeAgent/agent/akanContextFiles.test.ts +0 -2
- package/codeAgent/agent/akanSystemPrompt.ts +1 -9
- package/codeAgent/agent/codeAgent.test.ts +178 -0
- package/codeAgent/agent/codeAgentContract.test.ts +5 -28
- package/codeAgent/agent/codeMailbox.test.ts +0 -4
- package/codeAgent/agent/codeSessionFork.test.ts +0 -2
- package/codeAgent/agent/codeSessionIndex.test.ts +9 -4
- package/codeAgent/agent/consoleToStderr.ts +2 -12
- package/codeAgent/agent/jsonLines.ts +29 -0
- package/codeAgent/agent/stringArg.ts +5 -0
- package/codeAgent/feedback/DevLogFeedback.ts +3 -18
- package/codeAgent/feedback/PreviewChrome.ts +5 -29
- package/codeAgent/feedback/PreviewFeedback.ts +2 -9
- package/codeAgent/feedback/PreviewView.ts +3 -15
- package/codeAgent/feedback/TurnFeedback.ts +2 -17
- package/codeAgent/feedback/VerifyFeedback.ts +1 -7
- package/codeAgent/feedback/previewChrome.test.ts +1 -1
- package/codeAgent/index.ts +2 -10
- package/codeAgent/skills/akan-code/SKILL.md +12 -4
- package/codeAgent/tools/AkanCli.ts +4 -16
- package/codeAgent/tools/AkanCodePlugins.ts +21 -43
- package/codeAgent/tools/AkanEditScope.ts +2 -12
- package/codeAgent/tools/AkanEnvKeys.ts +3 -11
- package/codeAgent/tools/AkanToolPack.ts +6 -28
- package/codeAgent/tools/AkanVerifier.ts +1 -8
- package/codeAgent/tools/AskToolPack.ts +3 -15
- package/codeAgent/tools/MailToolPack.ts +0 -9
- package/codeAgent/tools/McpClient.ts +3 -24
- package/codeAgent/tools/McpOAuth.ts +6 -41
- package/codeAgent/tools/McpOAuthLoopback.ts +2 -15
- package/codeAgent/tools/McpServerConfig.ts +7 -26
- package/codeAgent/tools/McpSignIn.ts +46 -49
- package/codeAgent/tools/McpTokenStore.ts +6 -17
- package/codeAgent/tools/McpToolPack.ts +107 -35
- package/codeAgent/tools/SessionToolPack.ts +1 -11
- package/codeAgent/tools/WebToolPack.ts +1 -7
- package/codeAgent/tools/akanCodePlugins.test.ts +231 -63
- package/codeAgent/tools/askToolPack.test.ts +0 -3
- package/codeAgent/tools/mcpOAuth.test.ts +315 -27
- package/codeAgent/tools/mcpServerConfig.test.ts +21 -14
- package/codegenLock.test.ts +4 -13
- package/codegenLock.ts +3 -17
- package/commandDecorators/argMeta.ts +1 -5
- package/commandDecorators/camelToKebabCase.ts +1 -0
- package/commandDecorators/command.ts +44 -102
- package/commandDecorators/commandBuilder.ts +30 -61
- package/commandDecorators/commandDecorators.test.ts +1 -9
- package/commandDecorators/dependencyBuilder.ts +10 -1
- package/commandDecorators/helpFormatter.ts +66 -144
- package/commandDecorators/index.ts +0 -2
- package/commandDecorators/targetMeta.ts +9 -7
- package/createTunnel.ts +7 -14
- package/dependencyScanner.test.ts +4 -16
- package/dependencyScanner.ts +27 -78
- package/devkitUtils.test.ts +47 -19
- package/executors.test.ts +114 -60
- package/executors.ts +165 -484
- package/fileEditor.ts +9 -37
- package/{getDirname.test.ts → fileSys.test.ts} +1 -1
- package/fileSys.ts +6 -8
- package/formSetterScanner.ts +3 -16
- package/frontendBuild/allRoutesBuilder.ts +7 -21
- package/frontendBuild/autoImportSync.test.ts +14 -38
- package/frontendBuild/autoImportSync.ts +15 -67
- package/frontendBuild/buildRouteClient.test.ts +10 -36
- package/frontendBuild/bundleDefine.ts +12 -0
- package/frontendBuild/clientBuildTypes.ts +5 -36
- package/frontendBuild/clientEntriesBundler.ts +9 -40
- package/frontendBuild/clientEntryDiscovery.ts +6 -41
- package/frontendBuild/csrArtifactBuilder.ts +6 -25
- package/frontendBuild/cssCandidateCache.test.ts +0 -6
- package/frontendBuild/cssCandidateCache.ts +6 -41
- package/frontendBuild/cssCompiler.ts +29 -78
- package/frontendBuild/cssImportResolver.ts +5 -18
- package/frontendBuild/devChangePlanner.ts +7 -10
- package/frontendBuild/devGeneratedIndexSync.test.ts +12 -27
- package/frontendBuild/devGeneratedIndexSync.ts +1 -4
- package/frontendBuild/fontOptimizer.test.ts +5 -13
- package/frontendBuild/fontOptimizer.ts +15 -72
- package/frontendBuild/fontPruner.test.ts +5 -10
- package/frontendBuild/fontPruner.ts +5 -20
- package/frontendBuild/frontendBuild.test.ts +27 -52
- package/frontendBuild/hmrChangeClassifier.ts +2 -2
- package/frontendBuild/hmrWatcher.test.ts +7 -31
- package/frontendBuild/hmrWatcher.ts +14 -71
- package/frontendBuild/pagesBundleBuilder.ts +4 -29
- package/frontendBuild/precompressArtifacts.ts +5 -18
- package/frontendBuild/routeClientBuilder.ts +7 -47
- package/frontendBuild/routesManifestArtifactSerializer.ts +5 -36
- package/frontendBuild/sourceMtimeIndex.test.ts +37 -94
- package/frontendBuild/sourceMtimeIndex.ts +19 -130
- package/frontendBuild/ssrBaseArtifactBuilder.ts +2 -8
- package/frontendBuild/styleContract.ts +1 -8
- package/frontendBuild/themeValidator.ts +4 -26
- package/frontendBuild/watchRootResolver.test.ts +23 -42
- package/frontendBuild/watchRootResolver.ts +5 -27
- package/getRelatedCnsts.ts +12 -92
- package/incrementalBuilder/buildBatch.proc.ts +22 -57
- package/incrementalBuilder/buildBatchProtocol.ts +8 -36
- package/incrementalBuilder/buildBatchRunner.test.ts +34 -0
- package/incrementalBuilder/buildBatchRunner.ts +10 -31
- package/incrementalBuilder/builderChannel.test.ts +24 -49
- package/incrementalBuilder/builderChannel.ts +6 -37
- package/incrementalBuilder/builderRequestRouter.test.ts +0 -8
- package/incrementalBuilder/builderRequestRouter.ts +5 -24
- package/incrementalBuilder/devWatchBatch.test.ts +14 -18
- package/incrementalBuilder/incrementalBuilder.host.test.ts +18 -55
- package/incrementalBuilder/incrementalBuilder.host.ts +18 -76
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +81 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +48 -161
- package/index.ts +3 -15
- package/integration/devResourceProbe.ts +50 -56
- package/integration/devStability.integration.test.ts +47 -194
- package/integration/devStabilityHarness.test.ts +9 -29
- package/integration/devStabilityHarness.ts +65 -330
- package/integration/ssrMemoryProbe.ts +41 -167
- package/libSource.test.ts +4 -15
- package/libSource.ts +19 -31
- package/lint/gritRules.test.ts +6 -23
- package/linter.test.ts +1 -2
- package/linter.ts +22 -115
- package/mobile/mobileTarget.ts +14 -13
- package/package.json +2 -2
- package/packageExports.test.ts +3 -18
- package/packageExportsMap.ts +3 -19
- package/piDependencyPins.test.ts +3 -14
- package/platformTest/IdleWatchedProcess.test.ts +5 -13
- package/platformTest/IdleWatchedProcess.ts +1 -5
- package/platformTest/LinuxDockerTarget.ts +20 -35
- package/platformTest/PlatformTestRun.test.ts +5 -9
- package/platformTest/PlatformTestTarget.ts +24 -2
- package/platformTest/TestSnapshot.test.ts +6 -14
- package/platformTest/TestSnapshot.ts +1 -5
- package/platformTest/WindowsSshTarget.ts +6 -22
- package/prompter.ts +3 -6
- package/qualityScanner.test.ts +6 -24
- package/qualityScanner.ts +196 -284
- package/recipeScanner.test.ts +7 -12
- package/recipeScanner.ts +9 -38
- package/repoIdentity.ts +2 -9
- package/routeSourceValidator.ts +7 -30
- package/scanInfo.ts +82 -214
- package/selectModel.ts +1 -2
- package/semver.ts +3 -5
- package/slicePlanner.test.ts +6 -24
- package/slicePlanner.ts +11 -32
- package/spinner.test.ts +3 -8
- package/spinner.ts +4 -16
- package/sshTunnel.ts +1 -6
- package/ssrScanner.test.ts +1 -6
- package/ssrScanner.ts +103 -113
- package/subspace.test.ts +6 -25
- package/subspace.ts +31 -109
- package/subspaceConfig.ts +3 -11
- package/testHelpers.ts +49 -34
- package/transforms/asyncDefaultExportDetector.ts +3 -11
- package/transforms/barrelAnalyzer.ts +43 -135
- package/transforms/barrelImportsPlugin.ts +38 -175
- package/transforms/externalizeFrameworkPlugin.test.ts +39 -118
- package/transforms/externalizeFrameworkPlugin.ts +13 -87
- package/transforms/moduleSyntax.ts +32 -0
- package/transforms/rscUseClientTransform.ts +35 -20
- package/transforms/transforms.test.ts +153 -44
- package/transforms/tsconfigPackageResolver.test.ts +6 -24
- package/transforms/useClientBundlePlugin.ts +2 -22
- package/typeChecker.ts +7 -63
- package/uploadRelease.ts +10 -25
- package/workflow/artifacts.ts +18 -0
- package/workflow/executor.test.ts +1 -12
- package/workflow/executor.ts +85 -146
- package/workflow/index.ts +0 -1
- package/workflow/moduleIndex.test.ts +4 -15
- package/workflow/moduleIndex.ts +9 -49
- package/workflow/plan.ts +18 -25
- package/workflow/render.ts +80 -96
- package/workflow/source.ts +33 -56
- package/workflow/sourceAst.ts +50 -0
- package/workspaceLayout.ts +4 -19
- package/commandDecorators/commandMeta.ts +0 -7
- package/commandDecorators/types.ts +0 -10
- package/getDirname.ts +0 -4
- package/local/optimize-resource/ipcprobe/child.ts +0 -1
- package/local/optimize-resource/ipcprobe/parent.ts +0 -11
- package/workflow/primitive.ts +0 -59
|
@@ -17,47 +17,43 @@ export interface McpToolPackOptions {
|
|
|
17
17
|
onNotice?: (message: string) => void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
interface McpToolPackServer {
|
|
21
|
+
client: McpClient;
|
|
22
|
+
tools: McpToolInfo[];
|
|
23
|
+
token: string | undefined;
|
|
24
|
+
status: CodeAgentMcpStatus;
|
|
25
|
+
renewing: Promise<McpClient | undefined> | undefined;
|
|
26
|
+
refused: McpClient | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Tool names carry the server prefix: two servers offering `search` is the normal case, and a shadow is invisible.
|
|
29
30
|
export class McpToolPack {
|
|
30
|
-
readonly #clients:
|
|
31
|
+
readonly #clients: McpToolPackServer[] = [];
|
|
31
32
|
readonly #status: CodeAgentMcpStatus[] = [];
|
|
33
|
+
readonly #onNotice: ((message: string) => void) | undefined;
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
private constructor(onNotice: ((message: string) => void) | undefined) {
|
|
36
|
+
this.#onNotice = onNotice;
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
/**
|
|
37
|
-
* Connects every declared server before the session exists, because the session's tool allowlist has to name
|
|
38
|
-
* these tools and their names are only knowable from a live `tools/list`.
|
|
39
|
-
*
|
|
40
|
-
* A pack comes back whenever anything was declared, including when every server failed: what went wrong is
|
|
41
|
-
* the answer `/mcp` exists to give, and a pack that dissolves on failure has nowhere to keep it.
|
|
42
|
-
*/
|
|
39
|
+
/** Undefined only when nothing is declared; a pack whose every server failed still comes back to say why. */
|
|
43
40
|
static async connect(options: McpToolPackOptions) {
|
|
44
41
|
const refs = McpToolPack.#refs(options);
|
|
45
42
|
if (!refs.length) return undefined;
|
|
46
|
-
const pack = new McpToolPack();
|
|
43
|
+
const pack = new McpToolPack(options.onNotice);
|
|
47
44
|
for (const ref of refs) {
|
|
48
45
|
const base = { name: ref.name, transport: ref.transport, target: McpServerConfig.targetOf(ref) };
|
|
49
|
-
//
|
|
50
|
-
// trip there would hold the session on a screen that has not been drawn yet — see {@link McpSignIn}.
|
|
46
|
+
// Never an interactive sign-in: connect runs inside `CodeAgent.create`, before any screen is drawn.
|
|
51
47
|
const token = ref.transport === "http" ? await McpSignIn.token(ref, options.onNotice) : undefined;
|
|
52
48
|
try {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
pack.#clients.push({ client, tools });
|
|
56
|
-
pack.#status.push({
|
|
49
|
+
const opened = await McpToolPack.#openRefreshing(ref, token, options.onNotice);
|
|
50
|
+
const status: CodeAgentMcpStatus = {
|
|
57
51
|
...base,
|
|
58
|
-
tools: tools.map((tool) => McpToolPack.#nameOf(ref.name, tool.name)),
|
|
59
|
-
auth: token ? "authorized" : "none",
|
|
60
|
-
}
|
|
52
|
+
tools: opened.tools.map((tool) => McpToolPack.#nameOf(ref.name, tool.name)),
|
|
53
|
+
auth: opened.token ? "authorized" : "none",
|
|
54
|
+
};
|
|
55
|
+
pack.#clients.push({ ...opened, status, renewing: undefined, refused: undefined });
|
|
56
|
+
pack.#status.push(status);
|
|
61
57
|
} catch (error) {
|
|
62
58
|
if (error instanceof McpUnauthorized) {
|
|
63
59
|
options.onNotice?.(`MCP server "${ref.name}" needs signing in — /mcp login ${ref.name}`);
|
|
@@ -72,13 +68,33 @@ export class McpToolPack {
|
|
|
72
68
|
return pack;
|
|
73
69
|
}
|
|
74
70
|
|
|
71
|
+
// A token refused before its stated expiry, or issued with none, gets one refresh before a sign-in is asked for.
|
|
72
|
+
static async #openRefreshing(
|
|
73
|
+
ref: CodeAgentMcpServerRef,
|
|
74
|
+
token: string | undefined,
|
|
75
|
+
onNotice: ((message: string) => void) | undefined,
|
|
76
|
+
) {
|
|
77
|
+
try {
|
|
78
|
+
return await McpToolPack.#open(ref, token);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (!(error instanceof McpUnauthorized) || !token) throw error;
|
|
81
|
+
const retry = await McpSignIn.retryToken(ref, token, onNotice);
|
|
82
|
+
if (!retry) throw error;
|
|
83
|
+
return await McpToolPack.#open(ref, retry);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static async #open(ref: CodeAgentMcpServerRef, token: string | undefined) {
|
|
88
|
+
const client = await new McpClient(ref, token).connect();
|
|
89
|
+
return { client, tools: await client.listTools(), token };
|
|
90
|
+
}
|
|
91
|
+
|
|
75
92
|
get toolNames() {
|
|
76
93
|
return this.#clients.flatMap(({ client, tools }) =>
|
|
77
94
|
tools.map((tool) => McpToolPack.#nameOf(client.ref.name, tool.name)),
|
|
78
95
|
);
|
|
79
96
|
}
|
|
80
97
|
|
|
81
|
-
/** What each declared server turned out to be, for a host that offers to show it. */
|
|
82
98
|
get status(): CodeAgentMcpStatus[] {
|
|
83
99
|
return this.#status;
|
|
84
100
|
}
|
|
@@ -92,19 +108,19 @@ export class McpToolPack {
|
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
#register(pi: ExtensionAPI) {
|
|
95
|
-
for (const
|
|
96
|
-
for (const tool of tools) {
|
|
97
|
-
const name = McpToolPack.#nameOf(client.ref.name, tool.name);
|
|
111
|
+
for (const server of this.#clients)
|
|
112
|
+
for (const tool of server.tools) {
|
|
113
|
+
const name = McpToolPack.#nameOf(server.client.ref.name, tool.name);
|
|
98
114
|
const description = tool.description ?? tool.name;
|
|
99
115
|
pi.registerTool({
|
|
100
116
|
name,
|
|
101
|
-
label: `${client.ref.name}: ${tool.name}`,
|
|
117
|
+
label: `${server.client.ref.name}: ${tool.name}`,
|
|
102
118
|
description,
|
|
103
119
|
promptSnippet: `${name}: ${description.split(".")[0] ?? description}`,
|
|
104
120
|
// The server's own schema goes through untouched; it is the party that validates the call.
|
|
105
121
|
parameters: Type.Unsafe<Record<string, unknown>>(tool.inputSchema),
|
|
106
122
|
execute: async (_id, params) => {
|
|
107
|
-
const result = await
|
|
123
|
+
const result = await this.#call(server, tool.name, params ?? {});
|
|
108
124
|
return {
|
|
109
125
|
content: [{ type: "text", text: codeAgentClip(result.text, codeAgentOutputChars) }],
|
|
110
126
|
details: undefined,
|
|
@@ -115,6 +131,62 @@ export class McpToolPack {
|
|
|
115
131
|
}
|
|
116
132
|
}
|
|
117
133
|
|
|
134
|
+
async #call(server: McpToolPackServer, tool: string, args: Record<string, unknown>) {
|
|
135
|
+
const client = server.client;
|
|
136
|
+
try {
|
|
137
|
+
return await client.callTool(tool, args);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if (!(error instanceof McpUnauthorized)) throw error;
|
|
140
|
+
}
|
|
141
|
+
const renewed = await this.#renewed(server, client);
|
|
142
|
+
try {
|
|
143
|
+
if (renewed) return await renewed.callTool(tool, args);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (!(error instanceof McpUnauthorized)) throw error;
|
|
146
|
+
McpToolPack.#refuse(server, renewed);
|
|
147
|
+
}
|
|
148
|
+
throw new Error(`MCP server "${client.ref.name}" needs signing in — /mcp login ${client.ref.name}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Reported as a failed connect is; only a new pack, after `/mcp login` or `/mcp reload`, reads `authorized` again.
|
|
152
|
+
static #refuse(server: McpToolPackServer, client: McpClient | undefined) {
|
|
153
|
+
server.refused = client;
|
|
154
|
+
server.status.auth = "required";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// One refresh per refused token, shared by every call it refused; a server that refuses every token costs one.
|
|
158
|
+
async #renewed(server: McpToolPackServer, refused: McpClient) {
|
|
159
|
+
if (server.client === refused && server.refused !== refused)
|
|
160
|
+
server.renewing ??= this.#renew(server, refused).finally(() => {
|
|
161
|
+
server.renewing = undefined;
|
|
162
|
+
});
|
|
163
|
+
if (server.renewing) return await server.renewing;
|
|
164
|
+
return server.client === server.refused ? undefined : server.client;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async #renew(server: McpToolPackServer, refused: McpClient) {
|
|
168
|
+
const token = server.token ? await McpSignIn.retryToken(refused.ref, server.token, this.#onNotice) : undefined;
|
|
169
|
+
const client = token ? await McpToolPack.#reopen(refused.ref, token) : undefined;
|
|
170
|
+
if (!client) {
|
|
171
|
+
McpToolPack.#refuse(server, refused);
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
refused.close();
|
|
175
|
+
server.client = client;
|
|
176
|
+
server.token = token;
|
|
177
|
+
return client;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// A new client, so a new streamable HTTP session: a server may bind its session to the token that opened it.
|
|
181
|
+
static async #reopen(ref: CodeAgentMcpServerRef, token: string) {
|
|
182
|
+
try {
|
|
183
|
+
return await new McpClient(ref, token).connect();
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (error instanceof McpUnauthorized) return undefined;
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
118
190
|
static #nameOf(server: string, tool: string) {
|
|
119
191
|
return `mcp__${server.replace(/[^a-zA-Z0-9_]/g, "_")}__${tool}`;
|
|
120
192
|
}
|
|
@@ -14,13 +14,6 @@ export interface SessionToolPackOptions {
|
|
|
14
14
|
|
|
15
15
|
const snippetChars = 240;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Lets the agent reach its own earlier conversations in this workspace.
|
|
19
|
-
*
|
|
20
|
-
* Every past session is already on disk as JSONL under `.akan/code/sessions/`, so this is a reader, not a
|
|
21
|
-
* second store. "We decided last Tuesday to keep the adapter in `srvkit/`" is the kind of thing that exists
|
|
22
|
-
* nowhere else — not in the code, not in git, not in the guide.
|
|
23
|
-
*/
|
|
24
17
|
export class SessionToolPack {
|
|
25
18
|
readonly #options: SessionToolPackOptions;
|
|
26
19
|
|
|
@@ -91,10 +84,7 @@ export class SessionToolPack {
|
|
|
91
84
|
return codeAgentClip(session.allMessagesText, codeAgentOutputChars * 2);
|
|
92
85
|
}
|
|
93
86
|
|
|
94
|
-
|
|
95
|
-
* Sessions are listed for this workspace's directory only. A global list would reach another checkout's
|
|
96
|
-
* conversations, which is somebody else's project even when it is the same person's machine.
|
|
97
|
-
*/
|
|
87
|
+
// This workspace's directory only: a global list would reach another checkout's conversations.
|
|
98
88
|
async #list(): Promise<SessionInfo[]> {
|
|
99
89
|
return await SessionManager.list(this.#options.cwd, akanCodePaths.sessionsDir(this.#options.workspaceRoot));
|
|
100
90
|
}
|
|
@@ -12,13 +12,7 @@ interface SearchProvider {
|
|
|
12
12
|
search(key: string, query: string, count: number): Promise<string>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
* `web_fetch` and `web_search`, gated by the profile's network settings.
|
|
17
|
-
*
|
|
18
|
-
* Search needs a provider nobody ships a free key for, so the tool is registered only when one of the known
|
|
19
|
-
* environment keys is present. Registering it unconditionally and failing at call time costs prompt tokens for
|
|
20
|
-
* a capability that does not exist, and teaches the model to retry a tool that can never work.
|
|
21
|
-
*/
|
|
15
|
+
// web_search only with a provider key set: a tool that can never work costs prompt tokens and invites retries.
|
|
22
16
|
export class WebToolPack {
|
|
23
17
|
readonly #options: WebToolPackOptions;
|
|
24
18
|
|