@taico/worker 0.0.2 → 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.
package/README.md
CHANGED
|
@@ -18,6 +18,27 @@ The worker is intentionally decoupled from the backend. You can run workers anyw
|
|
|
18
18
|
|
|
19
19
|
The worker has access to whatever the host machine has access to. If you have Claude Code installed and authenticated, the Claude runner can use it. Same for OpenCode and GitHub Copilot.
|
|
20
20
|
|
|
21
|
+
## Design Constraints (Aspirational)
|
|
22
|
+
|
|
23
|
+
These are the intended design constraints for the worker runtime. They are not implemented yet.
|
|
24
|
+
Today the worker just runs a Claude Code, OpenCode, or GitHub Copilot process on your machine and can do whatever that process can do.
|
|
25
|
+
This early version requires you to be authenticated to tools, which means you are exposing keys to the LLM. Treat it with caution.
|
|
26
|
+
|
|
27
|
+
1. The shell is disposable.
|
|
28
|
+
The agent may destroy its own environment and nothing outside it is affected.
|
|
29
|
+
|
|
30
|
+
2. The shell has zero ambient authority.
|
|
31
|
+
No credentials, no identities, no implicit cloud access, no inherited power.
|
|
32
|
+
|
|
33
|
+
3. Authority is external.
|
|
34
|
+
All cost-bearing or state-changing actions are mediated by a trusted service.
|
|
35
|
+
|
|
36
|
+
4. The agent cannot gain power by exploration.
|
|
37
|
+
Scanning the filesystem, env, or network must not reveal new capabilities.
|
|
38
|
+
|
|
39
|
+
5. Capabilities are explicit and task-scoped.
|
|
40
|
+
If a task needs power, it must be declared up front and granted narrowly.
|
|
41
|
+
|
|
21
42
|
## Setup
|
|
22
43
|
|
|
23
44
|
### 1. Create an Agent
|
package/dist/Coordinator.js
CHANGED
|
@@ -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
|
}
|