create-event-agent 0.0.1
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/index.js +115 -0
- package/package.json +13 -0
package/index.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require('node:child_process');
|
|
3
|
+
const { dirname, join } = require('node:path');
|
|
4
|
+
|
|
5
|
+
function resolveInstalledAspCreate() {
|
|
6
|
+
try {
|
|
7
|
+
const packageJsonPath = require.resolve('asp-create/package.json');
|
|
8
|
+
return join(dirname(packageJsonPath), 'dist', 'index.js');
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function resolveInstalledAspCli() {
|
|
15
|
+
try {
|
|
16
|
+
const packageJsonPath = require.resolve('asp-protocol/package.json');
|
|
17
|
+
return join(dirname(packageJsonPath), 'dist', 'bin', 'asp.js');
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function runCreateIdentity(args) {
|
|
24
|
+
const env = {
|
|
25
|
+
...process.env,
|
|
26
|
+
ASP_CREATE_EMBEDDED: '1',
|
|
27
|
+
ASP_CREATE_HOSTING_MODE: 'managed',
|
|
28
|
+
ASP_HUB_WEB_URL: process.env.ASP_HUB_WEB_URL ?? 'https://letus.social',
|
|
29
|
+
ASP_HUB_API_URL: process.env.ASP_HUB_API_URL ?? 'https://letus.social/api',
|
|
30
|
+
ASP_HOSTED_HANDLE_DOMAIN: process.env.ASP_HOSTED_HANDLE_DOMAIN ?? 'letus.social',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let result = spawnSync('asp-create', args, { stdio: 'inherit', env });
|
|
34
|
+
if (result.error && result.error.code === 'ENOENT') {
|
|
35
|
+
const installedAspCreate = resolveInstalledAspCreate();
|
|
36
|
+
if (installedAspCreate) {
|
|
37
|
+
result = spawnSync(process.execPath, [installedAspCreate, ...args], { stdio: 'inherit', env });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (result.error && result.error.code === 'ENOENT') {
|
|
41
|
+
result = spawnSync('npx', ['-y', 'asp-create', ...args], { stdio: 'inherit', env });
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function runAsp(args, options = {}) {
|
|
47
|
+
let result = spawnSync('asp', args, options);
|
|
48
|
+
if (result.error && result.error.code === 'ENOENT') {
|
|
49
|
+
const installedAspCli = resolveInstalledAspCli();
|
|
50
|
+
if (installedAspCli) {
|
|
51
|
+
result = spawnSync(process.execPath, [installedAspCli, ...args], options);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (result.error && result.error.code === 'ENOENT') {
|
|
55
|
+
result = spawnSync('npx', ['-y', '-p', 'asp-protocol', 'asp', ...args], options);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getHandle() {
|
|
61
|
+
try {
|
|
62
|
+
const result = runAsp(['status', '--json'], { stdio: 'pipe', encoding: 'utf-8' });
|
|
63
|
+
if (result.status !== 0) return null;
|
|
64
|
+
const data = JSON.parse(result.stdout);
|
|
65
|
+
return data.identity?.handle || null;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function localPart(handle) {
|
|
72
|
+
const domain = process.env.ASP_HOSTED_HANDLE_DOMAIN ?? 'letus.social';
|
|
73
|
+
if (handle.endsWith('.' + domain)) {
|
|
74
|
+
return handle.slice(0, -(domain.length + 1));
|
|
75
|
+
}
|
|
76
|
+
return handle;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function ensureIdentity(args) {
|
|
80
|
+
const identityArgs = [...args];
|
|
81
|
+
if (!identityArgs.includes('--identity-only')) {
|
|
82
|
+
identityArgs.push('--identity-only');
|
|
83
|
+
}
|
|
84
|
+
if (!identityArgs.includes('--no-tools-setup')) {
|
|
85
|
+
identityArgs.push('--no-tools-setup');
|
|
86
|
+
}
|
|
87
|
+
const result = runCreateIdentity(identityArgs);
|
|
88
|
+
if (result.status !== 0) {
|
|
89
|
+
process.exit(result.status ?? 1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function main() {
|
|
94
|
+
const args = process.argv.slice(2);
|
|
95
|
+
|
|
96
|
+
console.log('\n ✦ create-event-agent — spin up an AI agent for your event\n');
|
|
97
|
+
console.log(' Powered by Agent Social Protocol\n');
|
|
98
|
+
ensureIdentity(args);
|
|
99
|
+
|
|
100
|
+
const handle = getHandle();
|
|
101
|
+
console.log('\n ─────────────────────────────────\n');
|
|
102
|
+
if (handle) {
|
|
103
|
+
const local = localPart(handle);
|
|
104
|
+
console.log(` Your event agent: @${handle}`);
|
|
105
|
+
console.log(' Attendees can interact with your agent to join, RSVP, and coordinate.\n');
|
|
106
|
+
console.log(` Event page: https://letus.social/@${local}\n`);
|
|
107
|
+
console.log(' Share with attendees:');
|
|
108
|
+
console.log(` npx letusmeet @${handle}`);
|
|
109
|
+
} else {
|
|
110
|
+
console.log(' Event agent is ready.');
|
|
111
|
+
}
|
|
112
|
+
console.log('');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-event-agent",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Create an AI agent for your event — powered by Agent Social Protocol",
|
|
5
|
+
"bin": { "create-event-agent": "index.js" },
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"asp-create": "^0.2.2",
|
|
8
|
+
"asp-protocol": "^0.2.2"
|
|
9
|
+
},
|
|
10
|
+
"keywords": ["agent", "event", "scheduling", "asp", "ai"],
|
|
11
|
+
"author": "jz2014",
|
|
12
|
+
"license": "MIT"
|
|
13
|
+
}
|