create-tacit-agent 0.1.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/README.md +54 -0
- package/dist/index.js +216 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# create-tacit-agent
|
|
2
|
+
|
|
3
|
+
Scaffold a new [Tacit Protocol](https://tacitprotocol.com) agent in one command.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-tacit-agent my-agent
|
|
9
|
+
cd my-agent
|
|
10
|
+
npm start
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
That's it. Your agent will:
|
|
14
|
+
|
|
15
|
+
1. Generate a cryptographic identity (W3C DID)
|
|
16
|
+
2. Publish an intent to the network
|
|
17
|
+
3. Listen for compatible matches
|
|
18
|
+
4. Broker introductions with double opt-in
|
|
19
|
+
|
|
20
|
+
## What You Get
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
my-agent/
|
|
24
|
+
src/
|
|
25
|
+
agent.ts # Your agent — edit this to customize
|
|
26
|
+
package.json
|
|
27
|
+
tsconfig.json
|
|
28
|
+
.gitignore
|
|
29
|
+
README.md
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Customize
|
|
33
|
+
|
|
34
|
+
Edit `src/agent.ts` to set your agent's domain, intent, and preferences:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const agent = await TacitAgent.create({
|
|
38
|
+
domain: 'professional', // or 'commerce', 'dating', 'local-services', 'learning'
|
|
39
|
+
preferences: {
|
|
40
|
+
languages: ['en'],
|
|
41
|
+
introductionStyle: 'professional',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Links
|
|
47
|
+
|
|
48
|
+
- [Tacit Protocol](https://tacitprotocol.com)
|
|
49
|
+
- [SDK Docs](https://www.npmjs.com/package/@tacitprotocol/sdk)
|
|
50
|
+
- [GitHub](https://github.com/tacitprotocol/tacit)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
var import_node_fs = require("fs");
|
|
6
|
+
var import_node_path = require("path");
|
|
7
|
+
var import_node_child_process = require("child_process");
|
|
8
|
+
var import_node_crypto = require("crypto");
|
|
9
|
+
var bold = (s) => `\x1B[1m${s}\x1B[0m`;
|
|
10
|
+
var green = (s) => `\x1B[32m${s}\x1B[0m`;
|
|
11
|
+
var cyan = (s) => `\x1B[36m${s}\x1B[0m`;
|
|
12
|
+
var dim = (s) => `\x1B[2m${s}\x1B[0m`;
|
|
13
|
+
var red = (s) => `\x1B[31m${s}\x1B[0m`;
|
|
14
|
+
var args = process.argv.slice(2);
|
|
15
|
+
var projectName = args[0];
|
|
16
|
+
if (!projectName || projectName === "--help" || projectName === "-h") {
|
|
17
|
+
console.log(`
|
|
18
|
+
${bold("create-tacit-agent")} \u2014 scaffold a new Tacit Protocol agent
|
|
19
|
+
|
|
20
|
+
${bold("Usage:")}
|
|
21
|
+
npx create-tacit-agent ${cyan("<project-name>")}
|
|
22
|
+
|
|
23
|
+
${bold("Example:")}
|
|
24
|
+
npx create-tacit-agent my-agent
|
|
25
|
+
cd my-agent
|
|
26
|
+
npm start
|
|
27
|
+
`);
|
|
28
|
+
process.exit(projectName ? 0 : 1);
|
|
29
|
+
}
|
|
30
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(projectName)) {
|
|
31
|
+
console.error(red(`Invalid project name: "${projectName}". Use only letters, numbers, hyphens, and underscores.`));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
var projectDir = (0, import_node_path.resolve)(process.cwd(), projectName);
|
|
35
|
+
if ((0, import_node_fs.existsSync)(projectDir)) {
|
|
36
|
+
console.error(red(`Directory "${projectName}" already exists.`));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
console.log(`
|
|
40
|
+
${bold("Tacit Protocol")} ${dim("v0.1")}
|
|
41
|
+
${dim("The trust layer for the internet")}
|
|
42
|
+
`);
|
|
43
|
+
console.log(`Creating ${cyan(projectName)}...`);
|
|
44
|
+
console.log();
|
|
45
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.join)(projectDir, "src"), { recursive: true });
|
|
46
|
+
(0, import_node_fs.writeFileSync)(
|
|
47
|
+
(0, import_node_path.join)(projectDir, "package.json"),
|
|
48
|
+
JSON.stringify(
|
|
49
|
+
{
|
|
50
|
+
name: projectName,
|
|
51
|
+
version: "0.1.0",
|
|
52
|
+
private: true,
|
|
53
|
+
type: "module",
|
|
54
|
+
scripts: {
|
|
55
|
+
start: "npx tsx src/agent.ts",
|
|
56
|
+
dev: "npx tsx --watch src/agent.ts"
|
|
57
|
+
},
|
|
58
|
+
dependencies: {
|
|
59
|
+
"@tacitprotocol/sdk": "^0.1.0"
|
|
60
|
+
},
|
|
61
|
+
devDependencies: {
|
|
62
|
+
typescript: "^5.4.0",
|
|
63
|
+
tsx: "^4.7.0",
|
|
64
|
+
"@types/node": "^20.11.0"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
null,
|
|
68
|
+
2
|
|
69
|
+
) + "\n"
|
|
70
|
+
);
|
|
71
|
+
(0, import_node_fs.writeFileSync)(
|
|
72
|
+
(0, import_node_path.join)(projectDir, "tsconfig.json"),
|
|
73
|
+
JSON.stringify(
|
|
74
|
+
{
|
|
75
|
+
compilerOptions: {
|
|
76
|
+
target: "ES2022",
|
|
77
|
+
module: "ESNext",
|
|
78
|
+
moduleResolution: "bundler",
|
|
79
|
+
lib: ["ES2022", "DOM"],
|
|
80
|
+
strict: true,
|
|
81
|
+
esModuleInterop: true,
|
|
82
|
+
skipLibCheck: true,
|
|
83
|
+
outDir: "./dist",
|
|
84
|
+
rootDir: "./src"
|
|
85
|
+
},
|
|
86
|
+
include: ["src/**/*"]
|
|
87
|
+
},
|
|
88
|
+
null,
|
|
89
|
+
2
|
|
90
|
+
) + "\n"
|
|
91
|
+
);
|
|
92
|
+
var agentSeed = (0, import_node_crypto.randomBytes)(16).toString("hex");
|
|
93
|
+
(0, import_node_fs.writeFileSync)(
|
|
94
|
+
(0, import_node_path.join)(projectDir, "src", "agent.ts"),
|
|
95
|
+
`/**
|
|
96
|
+
* ${projectName} \u2014 Tacit Protocol Agent
|
|
97
|
+
*
|
|
98
|
+
* Your AI agent that verifies identity, prevents fraud,
|
|
99
|
+
* and brokers trusted introductions with cryptographic proof.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
import {
|
|
103
|
+
TacitAgent,
|
|
104
|
+
IntentBuilder,
|
|
105
|
+
MatchScorer,
|
|
106
|
+
} from '@tacitprotocol/sdk';
|
|
107
|
+
|
|
108
|
+
async function main() {
|
|
109
|
+
console.log('Initializing Tacit agent...');
|
|
110
|
+
|
|
111
|
+
// Create your agent with a fresh cryptographic identity
|
|
112
|
+
const agent = await TacitAgent.create({
|
|
113
|
+
domain: 'professional',
|
|
114
|
+
preferences: {
|
|
115
|
+
languages: ['en'],
|
|
116
|
+
introductionStyle: 'professional',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
console.log(\`Agent created: \${agent.did}\`);
|
|
121
|
+
console.log(\`Authenticity score: \${agent.card.authenticity.score}/100\`);
|
|
122
|
+
|
|
123
|
+
// Build and publish an intent
|
|
124
|
+
const intent = new IntentBuilder(agent.did)
|
|
125
|
+
.type('introduction')
|
|
126
|
+
.domain('professional')
|
|
127
|
+
.seeking({
|
|
128
|
+
what: 'collaboration',
|
|
129
|
+
skills: ['ai', 'distributed-systems'],
|
|
130
|
+
})
|
|
131
|
+
.context({
|
|
132
|
+
offering: 'Your expertise here',
|
|
133
|
+
urgency: 'moderate',
|
|
134
|
+
})
|
|
135
|
+
.minAuthenticity(50)
|
|
136
|
+
.build();
|
|
137
|
+
|
|
138
|
+
console.log(\`Intent published: \${intent.id}\`);
|
|
139
|
+
|
|
140
|
+
// Listen for matches
|
|
141
|
+
agent.on('match', async (event) => {
|
|
142
|
+
console.log(\`Match found! Score: \${(event as any).match?.score?.overall}/100\`);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Listen for introduction proposals
|
|
146
|
+
agent.on('intro:proposed', async (event) => {
|
|
147
|
+
console.log('Introduction proposed \u2014 review and approve in your agent dashboard');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
console.log();
|
|
151
|
+
console.log('Agent is running. Listening for matches...');
|
|
152
|
+
console.log('Press Ctrl+C to stop.');
|
|
153
|
+
|
|
154
|
+
// Connect to the relay network
|
|
155
|
+
await agent.connect();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
main().catch(console.error);
|
|
159
|
+
`
|
|
160
|
+
);
|
|
161
|
+
(0, import_node_fs.writeFileSync)(
|
|
162
|
+
(0, import_node_path.join)(projectDir, ".gitignore"),
|
|
163
|
+
`node_modules/
|
|
164
|
+
dist/
|
|
165
|
+
.env
|
|
166
|
+
*.local
|
|
167
|
+
`
|
|
168
|
+
);
|
|
169
|
+
(0, import_node_fs.writeFileSync)(
|
|
170
|
+
(0, import_node_path.join)(projectDir, "README.md"),
|
|
171
|
+
`# ${projectName}
|
|
172
|
+
|
|
173
|
+
A [Tacit Protocol](https://tacitprotocol.com) agent \u2014 verify identity, prevent fraud, and broker trusted introductions.
|
|
174
|
+
|
|
175
|
+
## Getting Started
|
|
176
|
+
|
|
177
|
+
\`\`\`bash
|
|
178
|
+
npm install
|
|
179
|
+
npm start
|
|
180
|
+
\`\`\`
|
|
181
|
+
|
|
182
|
+
Your agent will:
|
|
183
|
+
1. Generate a cryptographic identity (W3C DID)
|
|
184
|
+
2. Publish an intent to the network
|
|
185
|
+
3. Listen for compatible matches
|
|
186
|
+
4. Broker introductions with double opt-in
|
|
187
|
+
|
|
188
|
+
## Customize
|
|
189
|
+
|
|
190
|
+
Edit \`src/agent.ts\` to configure your agent's domain, intent, and preferences.
|
|
191
|
+
|
|
192
|
+
## Learn More
|
|
193
|
+
|
|
194
|
+
- [Tacit Protocol Docs](https://github.com/tacitprotocol/tacit)
|
|
195
|
+
- [SDK Reference](https://www.npmjs.com/package/@tacitprotocol/sdk)
|
|
196
|
+
- [Protocol Spec](https://github.com/tacitprotocol/tacit/blob/main/docs/PROTOCOL_SPEC.md)
|
|
197
|
+
`
|
|
198
|
+
);
|
|
199
|
+
console.log(`${dim("Installing dependencies...")}`);
|
|
200
|
+
console.log();
|
|
201
|
+
try {
|
|
202
|
+
(0, import_node_child_process.execSync)("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
203
|
+
} catch {
|
|
204
|
+
console.log();
|
|
205
|
+
console.log(dim("npm install failed \u2014 you can run it manually:"));
|
|
206
|
+
console.log(` cd ${projectName} && npm install`);
|
|
207
|
+
}
|
|
208
|
+
console.log();
|
|
209
|
+
console.log(green("Done!") + ` Your Tacit agent is ready.`);
|
|
210
|
+
console.log();
|
|
211
|
+
console.log(` ${bold("cd")} ${cyan(projectName)}`);
|
|
212
|
+
console.log(` ${bold("npm start")}`);
|
|
213
|
+
console.log();
|
|
214
|
+
console.log(dim("Your agent will create a cryptographic identity and start listening for matches."));
|
|
215
|
+
console.log(dim("Edit src/agent.ts to customize your intent and preferences."));
|
|
216
|
+
console.log();
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-tacit-agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Create a new Tacit Protocol agent in one command",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-tacit-agent": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"templates"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup src/index.ts --format cjs --target node18 --clean",
|
|
14
|
+
"dev": "tsup src/index.ts --format cjs --target node18 --watch"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"tacit",
|
|
18
|
+
"protocol",
|
|
19
|
+
"agent",
|
|
20
|
+
"ai-agent",
|
|
21
|
+
"create",
|
|
22
|
+
"cli",
|
|
23
|
+
"did",
|
|
24
|
+
"identity",
|
|
25
|
+
"trust"
|
|
26
|
+
],
|
|
27
|
+
"author": "Tacit Protocol Contributors",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/tacitprotocol/tacit",
|
|
32
|
+
"directory": "packages/create-tacit-agent"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^5.4.0",
|
|
39
|
+
"tsup": "^8.0.0",
|
|
40
|
+
"@types/node": "^20.11.0"
|
|
41
|
+
}
|
|
42
|
+
}
|