@openagentmarket/create-agent 1.1.0 → 1.2.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/dist/index.js +34 -5
- package/package.json +1 -1
- package/src/index.ts +37 -5
package/dist/index.js
CHANGED
|
@@ -29,14 +29,30 @@ async function main() {
|
|
|
29
29
|
}
|
|
30
30
|
// ── Hirer Flow (zero-config) ─────────────────────────────────────────────────
|
|
31
31
|
async function scaffoldHirer() {
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const { folderName } = await prompts({
|
|
33
|
+
type: 'text',
|
|
34
|
+
name: 'folderName',
|
|
35
|
+
message: 'Folder name:',
|
|
36
|
+
initial: 'my-hirer'
|
|
37
|
+
});
|
|
38
|
+
if (!folderName) {
|
|
39
|
+
console.log(kleur.red('Cancelled.'));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
const dirName = folderName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
43
|
+
const targetDir = path.join(process.cwd(), dirName);
|
|
44
|
+
if (fs.existsSync(targetDir)) {
|
|
45
|
+
console.log(kleur.red(`Error: Directory ${dirName} already exists!`));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
console.log(`\nCreating hirer project in ${kleur.green(targetDir)}...\n`);
|
|
49
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
34
50
|
// Auto-generate wallet
|
|
35
51
|
const wallet = Wallet.createRandom();
|
|
36
52
|
const mnemonic = wallet.mnemonic.phrase;
|
|
37
53
|
// 1. package.json
|
|
38
54
|
const packageJson = {
|
|
39
|
-
name:
|
|
55
|
+
name: dirName,
|
|
40
56
|
version: "1.0.0",
|
|
41
57
|
description: "Hire agents on OpenAgent Market",
|
|
42
58
|
type: "module",
|
|
@@ -86,7 +102,15 @@ async function scaffoldHirer() {
|
|
|
86
102
|
` const rl = readline.createInterface({`,
|
|
87
103
|
` input: process.stdin,`,
|
|
88
104
|
` output: process.stdout,`,
|
|
89
|
-
` prompt: "
|
|
105
|
+
` prompt: "> "`,
|
|
106
|
+
` });`,
|
|
107
|
+
``,
|
|
108
|
+
` // ── Background message listener ──`,
|
|
109
|
+
` await client.streamAllMessages((sender, content, convId) => {`,
|
|
110
|
+
` if (!content || !content.trim()) return;`,
|
|
111
|
+
` process.stdout.write("\\r\\x1b[K");`,
|
|
112
|
+
` console.log("📨 [" + sender.slice(0, 10) + "...] " + content);`,
|
|
113
|
+
` rl.prompt(true);`,
|
|
90
114
|
` });`,
|
|
91
115
|
``,
|
|
92
116
|
` rl.prompt();`,
|
|
@@ -111,7 +135,11 @@ async function scaffoldHirer() {
|
|
|
111
135
|
` } else {`,
|
|
112
136
|
` console.log("📤 Sending to " + address + "...");`,
|
|
113
137
|
` const reply = await client.chat(address, message);`,
|
|
114
|
-
`
|
|
138
|
+
` if (reply.success) {`,
|
|
139
|
+
` console.log("📩 Reply:", reply.result ?? reply.raw ?? "(empty)");`,
|
|
140
|
+
` } else {`,
|
|
141
|
+
` console.log("❌ Error:", reply.error ?? "Unknown error");`,
|
|
142
|
+
` }`,
|
|
115
143
|
` }`,
|
|
116
144
|
` }`,
|
|
117
145
|
` else if (input.startsWith("/task ")) {`,
|
|
@@ -247,6 +275,7 @@ async function scaffoldHirer() {
|
|
|
247
275
|
console.log(` ${kleur.bold('Wallet address:')} ${kleur.cyan(wallet.address)}`);
|
|
248
276
|
console.log(` ${kleur.bold('Mnemonic:')} saved to ${kleur.yellow('.env')}\n`);
|
|
249
277
|
console.log(kleur.bold('Next steps:'));
|
|
278
|
+
console.log(` cd ${dirName}`);
|
|
250
279
|
console.log(' npm install');
|
|
251
280
|
console.log(' npm start');
|
|
252
281
|
console.log(' # Then type /discover to find agents\n');
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -34,9 +34,28 @@ async function main() {
|
|
|
34
34
|
// ── Hirer Flow (zero-config) ─────────────────────────────────────────────────
|
|
35
35
|
|
|
36
36
|
async function scaffoldHirer() {
|
|
37
|
-
const
|
|
37
|
+
const { folderName } = await prompts({
|
|
38
|
+
type: 'text',
|
|
39
|
+
name: 'folderName',
|
|
40
|
+
message: 'Folder name:',
|
|
41
|
+
initial: 'my-hirer'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!folderName) {
|
|
45
|
+
console.log(kleur.red('Cancelled.'));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
const dirName = folderName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
50
|
+
const targetDir = path.join(process.cwd(), dirName);
|
|
51
|
+
|
|
52
|
+
if (fs.existsSync(targetDir)) {
|
|
53
|
+
console.log(kleur.red(`Error: Directory ${dirName} already exists!`));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log(`\nCreating hirer project in ${kleur.green(targetDir)}...\n`);
|
|
58
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
40
59
|
|
|
41
60
|
// Auto-generate wallet
|
|
42
61
|
const wallet = Wallet.createRandom();
|
|
@@ -44,7 +63,7 @@ async function scaffoldHirer() {
|
|
|
44
63
|
|
|
45
64
|
// 1. package.json
|
|
46
65
|
const packageJson = {
|
|
47
|
-
name:
|
|
66
|
+
name: dirName,
|
|
48
67
|
version: "1.0.0",
|
|
49
68
|
description: "Hire agents on OpenAgent Market",
|
|
50
69
|
type: "module",
|
|
@@ -98,7 +117,15 @@ async function scaffoldHirer() {
|
|
|
98
117
|
` const rl = readline.createInterface({`,
|
|
99
118
|
` input: process.stdin,`,
|
|
100
119
|
` output: process.stdout,`,
|
|
101
|
-
` prompt: "
|
|
120
|
+
` prompt: "> "`,
|
|
121
|
+
` });`,
|
|
122
|
+
``,
|
|
123
|
+
` // ── Background message listener ──`,
|
|
124
|
+
` await client.streamAllMessages((sender, content, convId) => {`,
|
|
125
|
+
` if (!content || !content.trim()) return;`,
|
|
126
|
+
` process.stdout.write("\\r\\x1b[K");`,
|
|
127
|
+
` console.log("📨 [" + sender.slice(0, 10) + "...] " + content);`,
|
|
128
|
+
` rl.prompt(true);`,
|
|
102
129
|
` });`,
|
|
103
130
|
``,
|
|
104
131
|
` rl.prompt();`,
|
|
@@ -123,7 +150,11 @@ async function scaffoldHirer() {
|
|
|
123
150
|
` } else {`,
|
|
124
151
|
` console.log("📤 Sending to " + address + "...");`,
|
|
125
152
|
` const reply = await client.chat(address, message);`,
|
|
126
|
-
`
|
|
153
|
+
` if (reply.success) {`,
|
|
154
|
+
` console.log("📩 Reply:", reply.result ?? reply.raw ?? "(empty)");`,
|
|
155
|
+
` } else {`,
|
|
156
|
+
` console.log("❌ Error:", reply.error ?? "Unknown error");`,
|
|
157
|
+
` }`,
|
|
127
158
|
` }`,
|
|
128
159
|
` }`,
|
|
129
160
|
` else if (input.startsWith("/task ")) {`,
|
|
@@ -261,6 +292,7 @@ async function scaffoldHirer() {
|
|
|
261
292
|
console.log(` ${kleur.bold('Wallet address:')} ${kleur.cyan(wallet.address)}`);
|
|
262
293
|
console.log(` ${kleur.bold('Mnemonic:')} saved to ${kleur.yellow('.env')}\n`);
|
|
263
294
|
console.log(kleur.bold('Next steps:'));
|
|
295
|
+
console.log(` cd ${dirName}`);
|
|
264
296
|
console.log(' npm install');
|
|
265
297
|
console.log(' npm start');
|
|
266
298
|
console.log(' # Then type /discover to find agents\n');
|