warden-code 0.1.2 → 0.1.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 +6 -5
- package/dist/cli/commands/new.d.ts.map +1 -1
- package/dist/cli/commands/new.js +25 -7
- package/dist/cli/commands/new.js.map +1 -1
- package/dist/cli/services/scaffolder.d.ts.map +1 -1
- package/dist/cli/services/scaffolder.js +56 -74
- package/dist/cli/services/scaffolder.js.map +1 -1
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/ui/format.js +1 -1
- package/dist/cli/ui/format.js.map +1 -1
- package/dist/templates/Dockerfile.template +16 -0
- package/dist/templates/README.md.template +34 -0
- package/dist/templates/echo-multiturn/agent.ts.template +28 -0
- package/dist/templates/echo-streaming/agent.ts.template +28 -0
- package/dist/templates/env.example.template +4 -0
- package/dist/templates/gitignore.template +7 -0
- package/dist/templates/openai-multiturn/agent.ts.template +46 -90
- package/dist/templates/openai-streaming/agent.ts.template +48 -92
- package/dist/templates/package.json.template +19 -0
- package/dist/templates/server.ts.template +39 -0
- package/dist/templates/tsconfig.json.template +18 -0
- package/package.json +1 -1
- package/dist/templates/blank-multiturn/agent.ts.template +0 -62
- package/dist/templates/blank-streaming/agent.ts.template +0 -62
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Run `/new` to start the agent creation wizard:
|
|
|
33
33
|
|
|
34
34
|
1. **Agent name** - a name for your agent
|
|
35
35
|
2. **Description** - what your agent does
|
|
36
|
-
3. **Model** -
|
|
36
|
+
3. **Model** - Echo (echoes input) or OpenAI (GPT-powered)
|
|
37
37
|
4. **Capability** - Streaming or Multi-turn conversations
|
|
38
38
|
5. **Skills** - Define agent capabilities (optional)
|
|
39
39
|
|
|
@@ -43,8 +43,8 @@ After generation, your agent will be ready at `src/agent.ts`.
|
|
|
43
43
|
|
|
44
44
|
| Model | Description |
|
|
45
45
|
|----------|-------------|
|
|
46
|
-
| **
|
|
47
|
-
| **
|
|
46
|
+
| **Echo + Streaming** | Minimal streaming agent that echoes input |
|
|
47
|
+
| **Echo + Multi-turn** | Minimal multi-turn conversation agent |
|
|
48
48
|
| **OpenAI + Streaming** | GPT-powered agent with streaming responses |
|
|
49
49
|
| **OpenAI + Multi-turn** | GPT-powered agent with conversation history |
|
|
50
50
|
|
|
@@ -57,9 +57,11 @@ All options use `AgentServer` from `@wardenprotocol/agent-kit`, which exposes bo
|
|
|
57
57
|
```
|
|
58
58
|
my-agent/
|
|
59
59
|
├── src/
|
|
60
|
-
│
|
|
60
|
+
│ ├── agent.ts # Your agent logic (handler function)
|
|
61
|
+
│ └── server.ts # Server setup and configuration
|
|
61
62
|
├── package.json
|
|
62
63
|
├── tsconfig.json
|
|
64
|
+
├── Dockerfile
|
|
63
65
|
├── .env.example
|
|
64
66
|
└── .gitignore
|
|
65
67
|
```
|
|
@@ -68,7 +70,6 @@ my-agent/
|
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
72
|
cd my-agent
|
|
71
|
-
npm install
|
|
72
73
|
npm run build
|
|
73
74
|
npm run agent
|
|
74
75
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/new.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/new.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,aAAa,CAAC;AAmCrB,eAAO,MAAM,UAAU,EAAE,YA+NxB,CAAC"}
|
package/dist/cli/commands/new.js
CHANGED
|
@@ -4,6 +4,13 @@ import { input, select, confirm } from "@inquirer/prompts";
|
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { isDirectoryEmpty, createDirectory, directoryExists, } from "../services/project.js";
|
|
6
6
|
import { scaffoldAgent } from "../services/scaffolder.js";
|
|
7
|
+
const promptTheme = {
|
|
8
|
+
style: {
|
|
9
|
+
answer: (text) => chalk.rgb(199, 255, 142)(text),
|
|
10
|
+
highlight: (text) => chalk.rgb(199, 255, 142)(text),
|
|
11
|
+
description: (text) => chalk.rgb(199, 255, 142)(text),
|
|
12
|
+
},
|
|
13
|
+
};
|
|
7
14
|
function validateAgentName(value) {
|
|
8
15
|
if (!value.trim())
|
|
9
16
|
return "Agent name is required";
|
|
@@ -50,6 +57,7 @@ export const newCommand = {
|
|
|
50
57
|
const proceed = await confirm({
|
|
51
58
|
message: "Continue anyway?",
|
|
52
59
|
default: false,
|
|
60
|
+
theme: promptTheme,
|
|
53
61
|
});
|
|
54
62
|
if (!proceed) {
|
|
55
63
|
return;
|
|
@@ -59,16 +67,18 @@ export const newCommand = {
|
|
|
59
67
|
const name = await input({
|
|
60
68
|
message: "Agent name:",
|
|
61
69
|
validate: validateAgentName,
|
|
70
|
+
theme: promptTheme,
|
|
62
71
|
});
|
|
63
72
|
const description = await input({
|
|
64
73
|
message: "Agent description:",
|
|
65
74
|
default: `A helpful AI agent named ${name}`,
|
|
75
|
+
theme: promptTheme,
|
|
66
76
|
});
|
|
67
77
|
const template = await select({
|
|
68
78
|
message: "Select a model:",
|
|
69
79
|
choices: [
|
|
70
80
|
{
|
|
71
|
-
value: "
|
|
81
|
+
value: "echo",
|
|
72
82
|
name: "Blank",
|
|
73
83
|
description: "Minimal A2A server that echoes input",
|
|
74
84
|
},
|
|
@@ -78,6 +88,7 @@ export const newCommand = {
|
|
|
78
88
|
description: "Full-featured agent with OpenAI/GPT integration",
|
|
79
89
|
},
|
|
80
90
|
],
|
|
91
|
+
theme: promptTheme,
|
|
81
92
|
});
|
|
82
93
|
const capability = await select({
|
|
83
94
|
message: "Select capability:",
|
|
@@ -93,12 +104,14 @@ export const newCommand = {
|
|
|
93
104
|
description: "Support back-and-forth conversations",
|
|
94
105
|
},
|
|
95
106
|
],
|
|
107
|
+
theme: promptTheme,
|
|
96
108
|
});
|
|
97
109
|
// Skills configuration
|
|
98
110
|
const skills = [];
|
|
99
111
|
const addSkills = await confirm({
|
|
100
112
|
message: "Would you like to define skills?",
|
|
101
113
|
default: true,
|
|
114
|
+
theme: promptTheme,
|
|
102
115
|
});
|
|
103
116
|
if (addSkills) {
|
|
104
117
|
let addingSkills = true;
|
|
@@ -106,6 +119,7 @@ export const newCommand = {
|
|
|
106
119
|
const skillId = await input({
|
|
107
120
|
message: "Skill ID (e.g., general-assistant):",
|
|
108
121
|
validate: (v) => !!v || "Skill ID is required",
|
|
122
|
+
theme: promptTheme,
|
|
109
123
|
});
|
|
110
124
|
const skillName = await input({
|
|
111
125
|
message: "Skill name:",
|
|
@@ -113,10 +127,12 @@ export const newCommand = {
|
|
|
113
127
|
.split("-")
|
|
114
128
|
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
115
129
|
.join(" "),
|
|
130
|
+
theme: promptTheme,
|
|
116
131
|
});
|
|
117
132
|
const skillDescription = await input({
|
|
118
133
|
message: "Skill description:",
|
|
119
134
|
default: `${skillName} capability`,
|
|
135
|
+
theme: promptTheme,
|
|
120
136
|
});
|
|
121
137
|
skills.push({
|
|
122
138
|
id: skillId,
|
|
@@ -126,6 +142,7 @@ export const newCommand = {
|
|
|
126
142
|
addingSkills = await confirm({
|
|
127
143
|
message: "Add another skill?",
|
|
128
144
|
default: false,
|
|
145
|
+
theme: promptTheme,
|
|
129
146
|
});
|
|
130
147
|
}
|
|
131
148
|
}
|
|
@@ -147,17 +164,18 @@ export const newCommand = {
|
|
|
147
164
|
console.log(chalk.bold("Configuration Summary:"));
|
|
148
165
|
console.log(chalk.dim("─".repeat(40)));
|
|
149
166
|
console.log(` Name: ${chalk.rgb(199, 255, 142)(config.name)}`);
|
|
150
|
-
console.log(` Package: ${chalk.
|
|
151
|
-
console.log(` Description: ${chalk.
|
|
167
|
+
console.log(` Package: ${chalk.rgb(199, 255, 142)(config.packageName)}`);
|
|
168
|
+
console.log(` Description: ${chalk.rgb(199, 255, 142)(config.description)}`);
|
|
152
169
|
console.log(` Model: ${chalk.rgb(199, 255, 142)(config.template)}`);
|
|
153
|
-
console.log(` Streaming: ${config.capabilities.streaming ? chalk.
|
|
154
|
-
console.log(` Multi-turn: ${config.capabilities.multiTurn ? chalk.
|
|
155
|
-
console.log(` Skills: ${config.skills.length > 0 ? config.skills.map((s) => s.name).join(", ") : chalk.dim("None")}`);
|
|
170
|
+
console.log(` Streaming: ${config.capabilities.streaming ? chalk.rgb(199, 255, 142)("Yes") : chalk.dim("No")}`);
|
|
171
|
+
console.log(` Multi-turn: ${config.capabilities.multiTurn ? chalk.rgb(199, 255, 142)("Yes") : chalk.dim("No")}`);
|
|
172
|
+
console.log(` Skills: ${config.skills.length > 0 ? chalk.rgb(199, 255, 142)(config.skills.map((s) => s.name).join(", ")) : chalk.dim("None")}`);
|
|
156
173
|
console.log(chalk.dim("─".repeat(40)));
|
|
157
174
|
console.log();
|
|
158
175
|
const confirmed = await confirm({
|
|
159
176
|
message: "Generate agent with this configuration?",
|
|
160
177
|
default: true,
|
|
178
|
+
theme: promptTheme,
|
|
161
179
|
});
|
|
162
180
|
if (!confirmed) {
|
|
163
181
|
context.log.dim("Cancelled.");
|
|
@@ -168,7 +186,7 @@ export const newCommand = {
|
|
|
168
186
|
await scaffoldAgent(targetDir, config);
|
|
169
187
|
spinner.succeed("Agent generated!");
|
|
170
188
|
console.log();
|
|
171
|
-
context.log.success(`
|
|
189
|
+
context.log.success(`Agent files created successfully.`);
|
|
172
190
|
const installSpinner = context
|
|
173
191
|
.spinner("Installing dependencies...")
|
|
174
192
|
.start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/cli/commands/new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE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I,UAAU,EAAE,CAAC;oBACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,UAAU,EAAE,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBACnC,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;gBACzC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,mDAAmD;YACnD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAC/D,OAAO,CAAC,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBAC9B,OAAO;YACT,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffolder.d.ts","sourceRoot":"","sources":["../../../src/cli/services/scaffolder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtE;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAIjB;
|
|
1
|
+
{"version":3,"file":"scaffolder.d.ts","sourceRoot":"","sources":["../../../src/cli/services/scaffolder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtE;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAIjB;AAOD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAsD5E;AAUD,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA6Cf;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvE"}
|
|
@@ -12,14 +12,43 @@ export async function readTemplate(template, filename) {
|
|
|
12
12
|
const filePath = path.join(templateDir, filename);
|
|
13
13
|
return fs.readFile(filePath, "utf-8");
|
|
14
14
|
}
|
|
15
|
+
async function readSharedTemplate(filename) {
|
|
16
|
+
const filePath = path.resolve(__dirname, "../../templates", filename);
|
|
17
|
+
return fs.readFile(filePath, "utf-8");
|
|
18
|
+
}
|
|
15
19
|
export function processTemplate(content, config) {
|
|
16
20
|
const skillsStr = config.skills
|
|
17
21
|
.map((s) => `{\n id: "${s.id}",\n name: "${s.name}",\n description: "${s.description}",\n tags: [],\n }`)
|
|
18
22
|
.join(",\n ");
|
|
23
|
+
const modelStartupLog = config.template === "openai"
|
|
24
|
+
? `const hasApiKey = !!process.env.OPENAI_API_KEY;
|
|
25
|
+
const model = process.env.OPENAI_MODEL || "gpt-4o-mini";
|
|
26
|
+
console.log(\`Model: \${model}\`);
|
|
27
|
+
console.log(\`API Key: \${hasApiKey ? "configured" : "NOT SET"}\`);`
|
|
28
|
+
: "";
|
|
19
29
|
return content
|
|
20
30
|
.replace(/\{\{name\}\}/g, config.name)
|
|
21
31
|
.replace(/\{\{description\}\}/g, config.description)
|
|
22
|
-
.replace(/\{\{skills\}\}/g, skillsStr)
|
|
32
|
+
.replace(/\{\{skills\}\}/g, skillsStr)
|
|
33
|
+
.replace(/\{\{capabilities_streaming\}\}/g, String(config.capabilities.streaming))
|
|
34
|
+
.replace(/\{\{capabilities_multiturn\}\}/g, String(config.capabilities.multiTurn))
|
|
35
|
+
.replace(/\{\{model_startup_log\}\}/g, modelStartupLog)
|
|
36
|
+
.replace(/\{\{packageName\}\}/g, config.packageName)
|
|
37
|
+
.replace(/\{\{model_dependencies\}\}/g, config.template === "openai" ? `,\n "openai": "^4.69.0"` : "")
|
|
38
|
+
.replace(/\{\{env_setup\}\}/g, config.template === "openai"
|
|
39
|
+
? `Copy the example environment file and configure your API key:
|
|
40
|
+
|
|
41
|
+
\`\`\`bash
|
|
42
|
+
cp .env.example .env
|
|
43
|
+
\`\`\`
|
|
44
|
+
|
|
45
|
+
Edit \`.env\` and set your \`OPENAI_API_KEY\`.
|
|
46
|
+
|
|
47
|
+
`
|
|
48
|
+
: "")
|
|
49
|
+
.replace(/\{\{env_model_config\}\}/g, config.template === "openai"
|
|
50
|
+
? `OPENAI_API_KEY=your-api-key-here\nOPENAI_MODEL=gpt-4o-mini\n`
|
|
51
|
+
: "");
|
|
23
52
|
}
|
|
24
53
|
/**
|
|
25
54
|
* Get the template directory name based on base template and capability.
|
|
@@ -28,86 +57,39 @@ function getTemplateDirName(config) {
|
|
|
28
57
|
const capability = config.capabilities.streaming ? "streaming" : "multiturn";
|
|
29
58
|
return `${config.template}-${capability}`;
|
|
30
59
|
}
|
|
31
|
-
function generatePackageJson(config) {
|
|
32
|
-
const pkg = {
|
|
33
|
-
name: config.packageName,
|
|
34
|
-
version: "0.1.0",
|
|
35
|
-
type: "module",
|
|
36
|
-
main: "dist/agent.js",
|
|
37
|
-
scripts: {
|
|
38
|
-
build: "tsc",
|
|
39
|
-
dev: "tsc --watch",
|
|
40
|
-
agent: "node dist/agent.js",
|
|
41
|
-
},
|
|
42
|
-
dependencies: {
|
|
43
|
-
"@wardenprotocol/agent-kit": "^0.3.1",
|
|
44
|
-
dotenv: "^16.4.0",
|
|
45
|
-
},
|
|
46
|
-
devDependencies: {
|
|
47
|
-
"@types/node": "^22.8.1",
|
|
48
|
-
typescript: "^5.6.3",
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
// Add OpenAI dependency if using OpenAI template
|
|
52
|
-
if (config.template === "openai") {
|
|
53
|
-
pkg.dependencies["openai"] = "^4.69.0";
|
|
54
|
-
}
|
|
55
|
-
return JSON.stringify(pkg, null, 2);
|
|
56
|
-
}
|
|
57
|
-
function generateTsConfig() {
|
|
58
|
-
const tsconfig = {
|
|
59
|
-
compilerOptions: {
|
|
60
|
-
target: "ES2022",
|
|
61
|
-
module: "NodeNext",
|
|
62
|
-
moduleResolution: "NodeNext",
|
|
63
|
-
lib: ["ES2022"],
|
|
64
|
-
outDir: "./dist",
|
|
65
|
-
rootDir: "./src",
|
|
66
|
-
strict: true,
|
|
67
|
-
esModuleInterop: true,
|
|
68
|
-
skipLibCheck: true,
|
|
69
|
-
forceConsistentCasingInFileNames: true,
|
|
70
|
-
declaration: true,
|
|
71
|
-
sourceMap: true,
|
|
72
|
-
},
|
|
73
|
-
include: ["src/**/*"],
|
|
74
|
-
exclude: ["node_modules", "dist"],
|
|
75
|
-
};
|
|
76
|
-
return JSON.stringify(tsconfig, null, 2);
|
|
77
|
-
}
|
|
78
|
-
const GITIGNORE = `node_modules/
|
|
79
|
-
dist/
|
|
80
|
-
coverage/
|
|
81
|
-
*.log
|
|
82
|
-
.DS_Store
|
|
83
|
-
.env
|
|
84
|
-
.env.local
|
|
85
|
-
`;
|
|
86
|
-
const ENV_EXAMPLE_BLANK = `HOST=localhost
|
|
87
|
-
PORT=3000
|
|
88
|
-
`;
|
|
89
|
-
const ENV_EXAMPLE_OPENAI = `HOST=localhost
|
|
90
|
-
PORT=3000
|
|
91
|
-
OPENAI_API_KEY=your-api-key-here
|
|
92
|
-
OPENAI_MODEL=gpt-4o-mini
|
|
93
|
-
`;
|
|
94
60
|
export async function scaffoldAgent(targetDir, config) {
|
|
95
61
|
// Get the appropriate template directory based on template + capability
|
|
96
62
|
const templateDirName = getTemplateDirName(config);
|
|
97
|
-
// Read and process the agent template
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
//
|
|
101
|
-
await
|
|
63
|
+
// Read and process the agent handler template
|
|
64
|
+
const agentTemplate = await readTemplate(templateDirName, "agent.ts.template");
|
|
65
|
+
const agentContent = processTemplate(agentTemplate, config);
|
|
66
|
+
// Read and process the shared server template
|
|
67
|
+
const serverTemplate = await readSharedTemplate("server.ts.template");
|
|
68
|
+
const serverContent = processTemplate(serverTemplate, config);
|
|
69
|
+
// Write the agent and server files
|
|
70
|
+
await writeFile(path.join(targetDir, "src", "agent.ts"), agentContent);
|
|
71
|
+
await writeFile(path.join(targetDir, "src", "server.ts"), serverContent);
|
|
102
72
|
// Write package.json
|
|
103
|
-
await
|
|
73
|
+
const pkgTemplate = await readSharedTemplate("package.json.template");
|
|
74
|
+
const pkgContent = processTemplate(pkgTemplate, config);
|
|
75
|
+
await writeFile(path.join(targetDir, "package.json"), pkgContent);
|
|
104
76
|
// Write tsconfig.json
|
|
105
|
-
await
|
|
77
|
+
const tsconfig = await readSharedTemplate("tsconfig.json.template");
|
|
78
|
+
await writeFile(path.join(targetDir, "tsconfig.json"), tsconfig);
|
|
106
79
|
// Write .gitignore
|
|
107
|
-
await
|
|
80
|
+
const gitignore = await readSharedTemplate("gitignore.template");
|
|
81
|
+
await writeFile(path.join(targetDir, ".gitignore"), gitignore);
|
|
108
82
|
// Write .env.example
|
|
109
|
-
const
|
|
110
|
-
|
|
83
|
+
const envTemplate = await readSharedTemplate("env.example.template");
|
|
84
|
+
const envContent = processTemplate(envTemplate, config);
|
|
85
|
+
await writeFile(path.join(targetDir, ".env.example"), envContent);
|
|
86
|
+
// Write Dockerfile
|
|
87
|
+
const dockerfile = await readSharedTemplate("Dockerfile.template");
|
|
88
|
+
await writeFile(path.join(targetDir, "Dockerfile"), dockerfile);
|
|
89
|
+
// Write README.md
|
|
90
|
+
const readmeTemplate = await readSharedTemplate("README.md.template");
|
|
91
|
+
const readme = processTemplate(readmeTemplate, config);
|
|
92
|
+
await writeFile(path.join(targetDir, "README.md"), readme);
|
|
111
93
|
}
|
|
112
94
|
/**
|
|
113
95
|
* Check if a template exists.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffolder.js","sourceRoot":"","sources":["../../../src/cli/services/scaffolder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD,oDAAoD;IACpD,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,QAAgB;IAEhB,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,MAAmB;IAClE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM;SAC5B,GAAG,CACF,CAAC,CA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CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/cli/types.d.ts
CHANGED
package/dist/cli/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IAC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,OAAO,CAAC;KACpB,CAAC;IACF,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/cli/ui/format.js
CHANGED
|
@@ -14,7 +14,7 @@ export function banner() {
|
|
|
14
14
|
░████ ░████ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░████
|
|
15
15
|
░███ ░███ ░██ ░██ ░██ ░██ ░███████ ░██████████ ░██ ░███
|
|
16
16
|
|
|
17
|
-
`) + chalk.dim(`
|
|
17
|
+
`) + chalk.dim(`Agent Development CLI v${pkg.version}\n`));
|
|
18
18
|
}
|
|
19
19
|
export function prompt() {
|
|
20
20
|
return chalk.rgb(199, 255, 142)("warden") + chalk.dim("> ");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/cli/ui/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,YAAY,CACV,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EACzD,OAAO,CACR,CACF,CAAC;AAEF,MAAM,UAAU,MAAM;IACpB,OAAO,CACL,KAAK,CAAC,GAAG,CACP,GAAG,EACH,GAAG,EACH,GAAG,CACJ,CAAC;;;;;;;;;CASL,CAAC,GAA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AAK,EAAE,CAAC;QACV,MAAM,IAAI,SAAS,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
FROM node:22-alpine AS builder
|
|
2
|
+
WORKDIR /app
|
|
3
|
+
COPY package*.json ./
|
|
4
|
+
RUN npm install
|
|
5
|
+
COPY . .
|
|
6
|
+
RUN npm run build
|
|
7
|
+
|
|
8
|
+
FROM node:22-alpine
|
|
9
|
+
WORKDIR /app
|
|
10
|
+
COPY --from=builder /app/dist ./dist
|
|
11
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
12
|
+
COPY --from=builder /app/package.json ./
|
|
13
|
+
ENV HOST=0.0.0.0
|
|
14
|
+
ENV PORT=3000
|
|
15
|
+
EXPOSE 3000
|
|
16
|
+
CMD ["node", "dist/server.js"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Install dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
{{env_setup}}
|
|
14
|
+
## Development
|
|
15
|
+
|
|
16
|
+
Build and run the agent:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run build
|
|
20
|
+
npm run agent
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The agent will be available at `http://localhost:3000`.
|
|
24
|
+
|
|
25
|
+
## Docker
|
|
26
|
+
|
|
27
|
+
Build and run with Docker:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
docker build -t {{name}} .
|
|
31
|
+
docker run -p 3000:3000 -e AGENT_URL=http://your-public-url:3000 {{name}}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Set `AGENT_URL` to the public URL where the agent will be reachable. This is used in the agent card for discovery by other agents and clients.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TaskContext, TaskYieldUpdate } from "@wardenprotocol/agent-kit";
|
|
2
|
+
|
|
3
|
+
export async function* handler(context: TaskContext): AsyncGenerator<TaskYieldUpdate> {
|
|
4
|
+
const userMessage = context.message.parts
|
|
5
|
+
?.filter((p) => p.type === "text")
|
|
6
|
+
.map((p) => p.text)
|
|
7
|
+
.join("\n");
|
|
8
|
+
|
|
9
|
+
if (!userMessage) {
|
|
10
|
+
yield {
|
|
11
|
+
state: "completed",
|
|
12
|
+
message: {
|
|
13
|
+
role: "agent",
|
|
14
|
+
parts: [{ type: "text", text: "No message provided." }],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// TODO: Implement your agent logic here
|
|
21
|
+
yield {
|
|
22
|
+
state: "completed",
|
|
23
|
+
message: {
|
|
24
|
+
role: "agent",
|
|
25
|
+
parts: [{ type: "text", text: `Echo: ${userMessage}` }],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TaskContext, TaskYieldUpdate } from "@wardenprotocol/agent-kit";
|
|
2
|
+
|
|
3
|
+
export async function* handler(context: TaskContext): AsyncGenerator<TaskYieldUpdate> {
|
|
4
|
+
const userMessage = context.message.parts
|
|
5
|
+
?.filter((p) => p.type === "text")
|
|
6
|
+
.map((p) => p.text)
|
|
7
|
+
.join("\n");
|
|
8
|
+
|
|
9
|
+
if (!userMessage) {
|
|
10
|
+
yield {
|
|
11
|
+
state: "completed",
|
|
12
|
+
message: {
|
|
13
|
+
role: "agent",
|
|
14
|
+
parts: [{ type: "text", text: "No message provided." }],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// TODO: Implement your agent logic here
|
|
21
|
+
yield {
|
|
22
|
+
state: "completed",
|
|
23
|
+
message: {
|
|
24
|
+
role: "agent",
|
|
25
|
+
parts: [{ type: "text", text: `Echo: ${userMessage}` }],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,99 +1,55 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
1
|
import OpenAI from "openai";
|
|
3
|
-
import { AgentServer } from "@wardenprotocol/agent-kit";
|
|
4
2
|
import type { TaskContext, TaskYieldUpdate, MessagePart } from "@wardenprotocol/agent-kit";
|
|
5
3
|
|
|
6
|
-
const PORT = Number(process.env.PORT) || 3000;
|
|
7
|
-
const HOST = process.env.HOST || "localhost";
|
|
8
|
-
const BASE_URL = `http://${HOST}:${PORT}`;
|
|
9
|
-
|
|
10
4
|
const openai = new OpenAI({
|
|
11
5
|
apiKey: process.env.OPENAI_API_KEY,
|
|
12
6
|
});
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.join("\n");
|
|
31
|
-
|
|
32
|
-
if (!userMessage) {
|
|
33
|
-
yield {
|
|
34
|
-
state: "completed",
|
|
35
|
-
message: {
|
|
36
|
-
role: "agent",
|
|
37
|
-
parts: [{ type: "text", text: "No message provided." }],
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
yield { state: "working" };
|
|
45
|
-
|
|
46
|
-
const response = await openai.chat.completions.create({
|
|
47
|
-
model: process.env.OPENAI_MODEL || "gpt-4o-mini",
|
|
48
|
-
messages: [
|
|
49
|
-
{ role: "system", content: "{{description}}" },
|
|
50
|
-
{ role: "user", content: userMessage },
|
|
51
|
-
],
|
|
52
|
-
stream: false,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const fullResponse = response.choices[0]?.message?.content || "";
|
|
56
|
-
|
|
57
|
-
yield {
|
|
58
|
-
state: "completed",
|
|
59
|
-
message: {
|
|
60
|
-
role: "agent",
|
|
61
|
-
parts: [{ type: "text", text: fullResponse }],
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
} catch (error) {
|
|
65
|
-
yield {
|
|
66
|
-
state: "failed",
|
|
67
|
-
message: {
|
|
68
|
-
role: "agent",
|
|
69
|
-
parts: [{ type: "text", text: `Error: ${String(error)}` }],
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
server.listen(PORT).then(() => {
|
|
77
|
-
const hasApiKey = !!process.env.OPENAI_API_KEY;
|
|
78
|
-
const model = process.env.OPENAI_MODEL || "gpt-4o-mini";
|
|
79
|
-
|
|
80
|
-
console.log(`{{name}} (Dual Protocol)`);
|
|
81
|
-
console.log(`Server: ${BASE_URL}`);
|
|
82
|
-
console.log(`Model: ${model}`);
|
|
83
|
-
console.log(`API Key: ${hasApiKey ? "configured" : "NOT SET"}`);
|
|
84
|
-
console.log();
|
|
85
|
-
console.log("A2A Protocol:");
|
|
86
|
-
console.log(` Agent Card: ${BASE_URL}/.well-known/agent-card.json`);
|
|
87
|
-
console.log(` JSON-RPC: POST ${BASE_URL}/`);
|
|
88
|
-
console.log();
|
|
89
|
-
console.log("LangGraph Protocol:");
|
|
90
|
-
console.log(` Info: ${BASE_URL}/info`);
|
|
91
|
-
console.log(` Assistants: ${BASE_URL}/assistants`);
|
|
92
|
-
console.log(` Threads: ${BASE_URL}/threads`);
|
|
93
|
-
console.log(` Runs: ${BASE_URL}/runs`);
|
|
8
|
+
export async function* handler(context: TaskContext): AsyncGenerator<TaskYieldUpdate> {
|
|
9
|
+
const userMessage = context.message.parts
|
|
10
|
+
?.filter((p): p is MessagePart & { type: "text" } => p.type === "text")
|
|
11
|
+
.map((p) => p.text)
|
|
12
|
+
.join("\n");
|
|
13
|
+
|
|
14
|
+
if (!userMessage) {
|
|
15
|
+
yield {
|
|
16
|
+
state: "completed",
|
|
17
|
+
message: {
|
|
18
|
+
role: "agent",
|
|
19
|
+
parts: [{ type: "text", text: "No message provided." }],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
94
24
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
25
|
+
try {
|
|
26
|
+
yield { state: "working" };
|
|
27
|
+
|
|
28
|
+
const response = await openai.chat.completions.create({
|
|
29
|
+
model: process.env.OPENAI_MODEL || "gpt-4o-mini",
|
|
30
|
+
messages: [
|
|
31
|
+
{ role: "system", content: "{{description}}" },
|
|
32
|
+
{ role: "user", content: userMessage },
|
|
33
|
+
],
|
|
34
|
+
stream: false,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const fullResponse = response.choices[0]?.message?.content || "";
|
|
38
|
+
|
|
39
|
+
yield {
|
|
40
|
+
state: "completed",
|
|
41
|
+
message: {
|
|
42
|
+
role: "agent",
|
|
43
|
+
parts: [{ type: "text", text: fullResponse }],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
} catch (error) {
|
|
47
|
+
yield {
|
|
48
|
+
state: "failed",
|
|
49
|
+
message: {
|
|
50
|
+
role: "agent",
|
|
51
|
+
parts: [{ type: "text", text: `Error: ${String(error)}` }],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
98
54
|
}
|
|
99
|
-
}
|
|
55
|
+
}
|
|
@@ -1,103 +1,59 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
1
|
import OpenAI from "openai";
|
|
3
|
-
import { AgentServer } from "@wardenprotocol/agent-kit";
|
|
4
2
|
import type { TaskContext, TaskYieldUpdate, MessagePart } from "@wardenprotocol/agent-kit";
|
|
5
3
|
|
|
6
|
-
const PORT = Number(process.env.PORT) || 3000;
|
|
7
|
-
const HOST = process.env.HOST || "localhost";
|
|
8
|
-
const BASE_URL = `http://${HOST}:${PORT}`;
|
|
9
|
-
|
|
10
4
|
const openai = new OpenAI({
|
|
11
5
|
apiKey: process.env.OPENAI_API_KEY,
|
|
12
6
|
});
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.join("\n");
|
|
31
|
-
|
|
32
|
-
if (!userMessage) {
|
|
33
|
-
yield {
|
|
34
|
-
state: "completed",
|
|
35
|
-
message: {
|
|
36
|
-
role: "agent",
|
|
37
|
-
parts: [{ type: "text", text: "No message provided." }],
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
yield { state: "working" };
|
|
45
|
-
|
|
46
|
-
const stream = await openai.chat.completions.create({
|
|
47
|
-
model: process.env.OPENAI_MODEL || "gpt-4o-mini",
|
|
48
|
-
messages: [
|
|
49
|
-
{ role: "system", content: "{{description}}" },
|
|
50
|
-
{ role: "user", content: userMessage },
|
|
51
|
-
],
|
|
52
|
-
stream: true,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
let fullResponse = "";
|
|
56
|
-
for await (const chunk of stream) {
|
|
57
|
-
const content = chunk.choices[0]?.delta?.content || "";
|
|
58
|
-
fullResponse += content;
|
|
59
|
-
}
|
|
8
|
+
export async function* handler(context: TaskContext): AsyncGenerator<TaskYieldUpdate> {
|
|
9
|
+
const userMessage = context.message.parts
|
|
10
|
+
?.filter((p): p is MessagePart & { type: "text" } => p.type === "text")
|
|
11
|
+
.map((p) => p.text)
|
|
12
|
+
.join("\n");
|
|
13
|
+
|
|
14
|
+
if (!userMessage) {
|
|
15
|
+
yield {
|
|
16
|
+
state: "completed",
|
|
17
|
+
message: {
|
|
18
|
+
role: "agent",
|
|
19
|
+
parts: [{ type: "text", text: "No message provided." }],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
60
24
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
25
|
+
try {
|
|
26
|
+
yield { state: "working" };
|
|
27
|
+
|
|
28
|
+
const stream = await openai.chat.completions.create({
|
|
29
|
+
model: process.env.OPENAI_MODEL || "gpt-4o-mini",
|
|
30
|
+
messages: [
|
|
31
|
+
{ role: "system", content: "{{description}}" },
|
|
32
|
+
{ role: "user", content: userMessage },
|
|
33
|
+
],
|
|
34
|
+
stream: true,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
let fullResponse = "";
|
|
38
|
+
for await (const chunk of stream) {
|
|
39
|
+
const content = chunk.choices[0]?.delta?.content || "";
|
|
40
|
+
fullResponse += content;
|
|
76
41
|
}
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
server.listen(PORT).then(() => {
|
|
81
|
-
const hasApiKey = !!process.env.OPENAI_API_KEY;
|
|
82
|
-
const model = process.env.OPENAI_MODEL || "gpt-4o-mini";
|
|
83
42
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (!hasApiKey) {
|
|
100
|
-
console.log();
|
|
101
|
-
console.log("Warning: OPENAI_API_KEY not set. Set it in your .env file.");
|
|
43
|
+
yield {
|
|
44
|
+
state: "completed",
|
|
45
|
+
message: {
|
|
46
|
+
role: "agent",
|
|
47
|
+
parts: [{ type: "text", text: fullResponse }],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
} catch (error) {
|
|
51
|
+
yield {
|
|
52
|
+
state: "failed",
|
|
53
|
+
message: {
|
|
54
|
+
role: "agent",
|
|
55
|
+
parts: [{ type: "text", text: `Error: ${String(error)}` }],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
102
58
|
}
|
|
103
|
-
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/server.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"dev": "tsc --watch",
|
|
9
|
+
"agent": "node dist/server.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@wardenprotocol/agent-kit": "^0.3.1",
|
|
13
|
+
"dotenv": "^16.4.0"{{model_dependencies}}
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^22.8.1",
|
|
17
|
+
"typescript": "^5.6.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { AgentServer } from "@wardenprotocol/agent-kit";
|
|
3
|
+
import { handler } from "./agent.js";
|
|
4
|
+
|
|
5
|
+
const PORT = Number(process.env.PORT) || 3000;
|
|
6
|
+
const HOST = process.env.HOST || "localhost";
|
|
7
|
+
const BASE_URL = `http://${HOST}:${PORT}`;
|
|
8
|
+
const AGENT_URL = process.env.AGENT_URL || BASE_URL;
|
|
9
|
+
|
|
10
|
+
const server = new AgentServer({
|
|
11
|
+
agentCard: {
|
|
12
|
+
name: "{{name}}",
|
|
13
|
+
description: "{{description}}",
|
|
14
|
+
url: AGENT_URL,
|
|
15
|
+
version: "0.1.0",
|
|
16
|
+
capabilities: {
|
|
17
|
+
streaming: {{capabilities_streaming}},
|
|
18
|
+
multiTurn: {{capabilities_multiturn}},
|
|
19
|
+
},
|
|
20
|
+
skills: [{{skills}}],
|
|
21
|
+
},
|
|
22
|
+
handler,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
server.listen(PORT).then(() => {
|
|
26
|
+
{{model_startup_log}}
|
|
27
|
+
console.log(`{{name}} (Dual Protocol)`);
|
|
28
|
+
console.log(`Server: ${AGENT_URL}`);
|
|
29
|
+
console.log();
|
|
30
|
+
console.log("A2A Protocol:");
|
|
31
|
+
console.log(` Agent Card: ${AGENT_URL}/.well-known/agent-card.json`);
|
|
32
|
+
console.log(` JSON-RPC: POST ${AGENT_URL}/`);
|
|
33
|
+
console.log();
|
|
34
|
+
console.log("LangGraph Protocol:");
|
|
35
|
+
console.log(` Info: ${AGENT_URL}/info`);
|
|
36
|
+
console.log(` Assistants: ${AGENT_URL}/assistants`);
|
|
37
|
+
console.log(` Threads: ${AGENT_URL}/threads`);
|
|
38
|
+
console.log(` Runs: ${AGENT_URL}/runs`);
|
|
39
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"sourceMap": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { AgentServer } from "@wardenprotocol/agent-kit";
|
|
3
|
-
import type { TaskContext, TaskYieldUpdate } from "@wardenprotocol/agent-kit";
|
|
4
|
-
|
|
5
|
-
const PORT = Number(process.env.PORT) || 3000;
|
|
6
|
-
const HOST = process.env.HOST || "localhost";
|
|
7
|
-
const BASE_URL = `http://${HOST}:${PORT}`;
|
|
8
|
-
|
|
9
|
-
const server = new AgentServer({
|
|
10
|
-
agentCard: {
|
|
11
|
-
name: "{{name}}",
|
|
12
|
-
description: "{{description}}",
|
|
13
|
-
url: BASE_URL,
|
|
14
|
-
version: "0.1.0",
|
|
15
|
-
capabilities: {
|
|
16
|
-
streaming: false,
|
|
17
|
-
multiTurn: true,
|
|
18
|
-
},
|
|
19
|
-
skills: [{{skills}}],
|
|
20
|
-
},
|
|
21
|
-
handler: async function* (context: TaskContext): AsyncGenerator<TaskYieldUpdate> {
|
|
22
|
-
const userMessage = context.message.parts
|
|
23
|
-
?.filter((p) => p.type === "text")
|
|
24
|
-
.map((p) => p.text)
|
|
25
|
-
.join("\n");
|
|
26
|
-
|
|
27
|
-
if (!userMessage) {
|
|
28
|
-
yield {
|
|
29
|
-
state: "completed",
|
|
30
|
-
message: {
|
|
31
|
-
role: "agent",
|
|
32
|
-
parts: [{ type: "text", text: "No message provided." }],
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// TODO: Implement your agent logic here
|
|
39
|
-
yield {
|
|
40
|
-
state: "completed",
|
|
41
|
-
message: {
|
|
42
|
-
role: "agent",
|
|
43
|
-
parts: [{ type: "text", text: `Echo: ${userMessage}` }],
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
server.listen(PORT).then(() => {
|
|
50
|
-
console.log(`{{name}} (Dual Protocol)`);
|
|
51
|
-
console.log(`Server: ${BASE_URL}`);
|
|
52
|
-
console.log();
|
|
53
|
-
console.log("A2A Protocol:");
|
|
54
|
-
console.log(` Agent Card: ${BASE_URL}/.well-known/agent-card.json`);
|
|
55
|
-
console.log(` JSON-RPC: POST ${BASE_URL}/`);
|
|
56
|
-
console.log();
|
|
57
|
-
console.log("LangGraph Protocol:");
|
|
58
|
-
console.log(` Info: ${BASE_URL}/info`);
|
|
59
|
-
console.log(` Assistants: ${BASE_URL}/assistants`);
|
|
60
|
-
console.log(` Threads: ${BASE_URL}/threads`);
|
|
61
|
-
console.log(` Runs: ${BASE_URL}/runs`);
|
|
62
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { AgentServer } from "@wardenprotocol/agent-kit";
|
|
3
|
-
import type { TaskContext, TaskYieldUpdate } from "@wardenprotocol/agent-kit";
|
|
4
|
-
|
|
5
|
-
const PORT = Number(process.env.PORT) || 3000;
|
|
6
|
-
const HOST = process.env.HOST || "localhost";
|
|
7
|
-
const BASE_URL = `http://${HOST}:${PORT}`;
|
|
8
|
-
|
|
9
|
-
const server = new AgentServer({
|
|
10
|
-
agentCard: {
|
|
11
|
-
name: "{{name}}",
|
|
12
|
-
description: "{{description}}",
|
|
13
|
-
url: BASE_URL,
|
|
14
|
-
version: "0.1.0",
|
|
15
|
-
capabilities: {
|
|
16
|
-
streaming: true,
|
|
17
|
-
multiTurn: false,
|
|
18
|
-
},
|
|
19
|
-
skills: [{{skills}}],
|
|
20
|
-
},
|
|
21
|
-
handler: async function* (context: TaskContext): AsyncGenerator<TaskYieldUpdate> {
|
|
22
|
-
const userMessage = context.message.parts
|
|
23
|
-
?.filter((p) => p.type === "text")
|
|
24
|
-
.map((p) => p.text)
|
|
25
|
-
.join("\n");
|
|
26
|
-
|
|
27
|
-
if (!userMessage) {
|
|
28
|
-
yield {
|
|
29
|
-
state: "completed",
|
|
30
|
-
message: {
|
|
31
|
-
role: "agent",
|
|
32
|
-
parts: [{ type: "text", text: "No message provided." }],
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// TODO: Implement your agent logic here
|
|
39
|
-
yield {
|
|
40
|
-
state: "completed",
|
|
41
|
-
message: {
|
|
42
|
-
role: "agent",
|
|
43
|
-
parts: [{ type: "text", text: `Echo: ${userMessage}` }],
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
server.listen(PORT).then(() => {
|
|
50
|
-
console.log(`{{name}} (Dual Protocol)`);
|
|
51
|
-
console.log(`Server: ${BASE_URL}`);
|
|
52
|
-
console.log();
|
|
53
|
-
console.log("A2A Protocol:");
|
|
54
|
-
console.log(` Agent Card: ${BASE_URL}/.well-known/agent-card.json`);
|
|
55
|
-
console.log(` JSON-RPC: POST ${BASE_URL}/`);
|
|
56
|
-
console.log();
|
|
57
|
-
console.log("LangGraph Protocol:");
|
|
58
|
-
console.log(` Info: ${BASE_URL}/info`);
|
|
59
|
-
console.log(` Assistants: ${BASE_URL}/assistants`);
|
|
60
|
-
console.log(` Threads: ${BASE_URL}/threads`);
|
|
61
|
-
console.log(` Runs: ${BASE_URL}/runs`);
|
|
62
|
-
});
|