@taico/worker 0.0.3 → 0.0.4
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.
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
// ADKAgentRunner.ts
|
|
2
2
|
import { BaseAgentRunner } from "./BaseAgentRunner.js";
|
|
3
|
-
import { LlmAgent, Runner, InMemorySessionService, MCPToolset } from "@google/adk";
|
|
3
|
+
import { LlmAgent, Runner, InMemorySessionService, MCPToolset, BaseTool, } from "@google/adk";
|
|
4
4
|
import { ADKMessageFormatter } from "../formatters/ADKMessageFormatter.js";
|
|
5
5
|
import { ACCESS_TOKEN, BASE_URL, RUN_ID_HEADER } from "../helpers/config.js";
|
|
6
|
+
class NamespacedTool extends BaseTool {
|
|
7
|
+
wrappedTool;
|
|
8
|
+
namespacedName;
|
|
9
|
+
constructor(wrappedTool, namespacedName) {
|
|
10
|
+
super({
|
|
11
|
+
name: namespacedName,
|
|
12
|
+
description: wrappedTool.description,
|
|
13
|
+
isLongRunning: wrappedTool.isLongRunning,
|
|
14
|
+
});
|
|
15
|
+
this.wrappedTool = wrappedTool;
|
|
16
|
+
this.namespacedName = namespacedName;
|
|
17
|
+
}
|
|
18
|
+
_getDeclaration() {
|
|
19
|
+
const declaration = this.wrappedTool._getDeclaration();
|
|
20
|
+
if (!declaration) {
|
|
21
|
+
return declaration;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
...declaration,
|
|
25
|
+
name: this.namespacedName,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async runAsync(request) {
|
|
29
|
+
return this.wrappedTool.runAsync(request);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class NamespacedMCPToolset extends MCPToolset {
|
|
33
|
+
serverName;
|
|
34
|
+
constructor(connectionParams, serverName) {
|
|
35
|
+
super(connectionParams);
|
|
36
|
+
this.serverName = serverName;
|
|
37
|
+
}
|
|
38
|
+
async getTools(context) {
|
|
39
|
+
const tools = await super.getTools(context);
|
|
40
|
+
return tools.map((tool) => new NamespacedTool(tool, `mcp__${this.serverName}__${tool.name}`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
6
43
|
export class ADKAgentRunner extends BaseAgentRunner {
|
|
7
44
|
kind = 'adk';
|
|
8
45
|
formatter = new ADKMessageFormatter();
|
|
@@ -26,14 +63,22 @@ export class ADKAgentRunner extends BaseAgentRunner {
|
|
|
26
63
|
description: '',
|
|
27
64
|
instruction: '',
|
|
28
65
|
tools: [
|
|
29
|
-
new
|
|
66
|
+
new NamespacedMCPToolset({
|
|
30
67
|
type: 'StreamableHTTPConnectionParams',
|
|
31
68
|
url: `${BASE_URL}/api/v1/tasks/tasks/mcp`,
|
|
32
69
|
header: {
|
|
33
70
|
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
34
71
|
[RUN_ID_HEADER]: ctx.runId,
|
|
35
72
|
},
|
|
36
|
-
})
|
|
73
|
+
}, 'tasks'),
|
|
74
|
+
new NamespacedMCPToolset({
|
|
75
|
+
type: 'StreamableHTTPConnectionParams',
|
|
76
|
+
url: `${BASE_URL}/api/v1/context/blocks/mcp`,
|
|
77
|
+
header: {
|
|
78
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
79
|
+
[RUN_ID_HEADER]: ctx.runId,
|
|
80
|
+
},
|
|
81
|
+
}, 'context')
|
|
37
82
|
]
|
|
38
83
|
});
|
|
39
84
|
const runner = new Runner({
|
|
@@ -27,10 +27,19 @@ export class ClaudeAgentRunner extends BaseAgentRunner {
|
|
|
27
27
|
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
28
28
|
[RUN_ID_HEADER]: ctx.runId,
|
|
29
29
|
},
|
|
30
|
+
},
|
|
31
|
+
context: {
|
|
32
|
+
type: "http",
|
|
33
|
+
url: `${BASE_URL}/api/v1/context/blocks/mcp`,
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
36
|
+
[RUN_ID_HEADER]: ctx.runId,
|
|
37
|
+
},
|
|
30
38
|
}
|
|
31
39
|
},
|
|
32
40
|
allowedTools: [
|
|
33
41
|
'mcp__tasks__*',
|
|
42
|
+
'mcp__context__*',
|
|
34
43
|
'SlashCommand',
|
|
35
44
|
'Bash',
|
|
36
45
|
'Read',
|
|
@@ -26,11 +26,21 @@ export class GitHubCopilotAgentRunner extends BaseAgentRunner {
|
|
|
26
26
|
},
|
|
27
27
|
tools: ["*"],
|
|
28
28
|
};
|
|
29
|
+
const contextMcpServer = {
|
|
30
|
+
type: "http",
|
|
31
|
+
url: `${BASE_URL}/api/v1/context/blocks/mcp`,
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
34
|
+
[RUN_ID_HEADER]: ctx.runId,
|
|
35
|
+
},
|
|
36
|
+
tools: ["*"],
|
|
37
|
+
};
|
|
29
38
|
// Create a session for this work
|
|
30
39
|
const session = await this.client.createSession({
|
|
31
40
|
model: this.model,
|
|
32
41
|
mcpServers: {
|
|
33
42
|
tasks: taskMcpServer,
|
|
43
|
+
context: contextMcpServer,
|
|
34
44
|
},
|
|
35
45
|
});
|
|
36
46
|
if (session?.sessionId) {
|
|
@@ -79,6 +79,15 @@ export class OpencodeAgentRunner extends BaseAgentRunner {
|
|
|
79
79
|
[RUN_ID_HEADER]: runId,
|
|
80
80
|
},
|
|
81
81
|
enabled: true,
|
|
82
|
+
},
|
|
83
|
+
context: {
|
|
84
|
+
type: "remote",
|
|
85
|
+
url: `${BASE_URL}/api/v1/context/blocks/mcp`,
|
|
86
|
+
headers: {
|
|
87
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
88
|
+
[RUN_ID_HEADER]: runId,
|
|
89
|
+
},
|
|
90
|
+
enabled: true,
|
|
82
91
|
}
|
|
83
92
|
}
|
|
84
93
|
}
|