@volisphere/commercial 0.3.0 → 0.3.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/dist/client.d.ts +68 -0
- package/dist/client.js +70 -0
- package/dist/index.js +260 -58
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -228,8 +228,76 @@ export declare class VolisphereClient {
|
|
|
228
228
|
pauseCampaign(campaignId: string): Promise<void>;
|
|
229
229
|
resumeCampaign(campaignId: string): Promise<void>;
|
|
230
230
|
registerAgent(params: RegisterAgentParams): Promise<RegisterAgentResponse>;
|
|
231
|
+
claimAgent(claimToken: string): Promise<AgentProfile>;
|
|
231
232
|
heartbeat(agentId: string): Promise<void>;
|
|
232
233
|
setMonetization(agentId: string, enabled: boolean): Promise<AgentProfile>;
|
|
234
|
+
discoverAgents(params: {
|
|
235
|
+
query: string;
|
|
236
|
+
categories?: string[];
|
|
237
|
+
only_online?: boolean;
|
|
238
|
+
top_k?: number;
|
|
239
|
+
}): Promise<{
|
|
240
|
+
results: Array<{
|
|
241
|
+
rank: number;
|
|
242
|
+
agent_slug: string;
|
|
243
|
+
agent_name: string;
|
|
244
|
+
skill_name: string;
|
|
245
|
+
description: string;
|
|
246
|
+
tags: string[];
|
|
247
|
+
is_online: boolean;
|
|
248
|
+
call_count: number;
|
|
249
|
+
invoke_url: string;
|
|
250
|
+
}>;
|
|
251
|
+
total: number;
|
|
252
|
+
}>;
|
|
253
|
+
getAgentProfile(slug: string): Promise<{
|
|
254
|
+
id: string;
|
|
255
|
+
slug: string;
|
|
256
|
+
display_name: string;
|
|
257
|
+
description: string;
|
|
258
|
+
is_online: boolean;
|
|
259
|
+
monetization_enabled: boolean;
|
|
260
|
+
skills: Array<{
|
|
261
|
+
id: string;
|
|
262
|
+
skill_name: string;
|
|
263
|
+
description: string;
|
|
264
|
+
ads_enabled: boolean;
|
|
265
|
+
ad_policy: string;
|
|
266
|
+
}>;
|
|
267
|
+
capabilities: Array<{
|
|
268
|
+
id: string;
|
|
269
|
+
skill_name: string;
|
|
270
|
+
description: string;
|
|
271
|
+
category: string;
|
|
272
|
+
tags: string[];
|
|
273
|
+
is_online: boolean;
|
|
274
|
+
}>;
|
|
275
|
+
}>;
|
|
276
|
+
registerSkillPublic(claimToken: string, skills: Array<{
|
|
277
|
+
skill_name: string;
|
|
278
|
+
description?: string;
|
|
279
|
+
ads_enabled?: boolean;
|
|
280
|
+
ad_policy?: string;
|
|
281
|
+
min_bid_micros?: number;
|
|
282
|
+
allowed_categories?: string[];
|
|
283
|
+
}>): Promise<{
|
|
284
|
+
skills: Array<{
|
|
285
|
+
id: string;
|
|
286
|
+
skill_name: string;
|
|
287
|
+
description: string;
|
|
288
|
+
ads_enabled: boolean;
|
|
289
|
+
ad_policy: string;
|
|
290
|
+
}>;
|
|
291
|
+
}>;
|
|
292
|
+
listSkills(): Promise<SkillConfig[]>;
|
|
293
|
+
updateSkill(skillId: string, patch: {
|
|
294
|
+
skill_version?: string;
|
|
295
|
+
description?: string;
|
|
296
|
+
ads_enabled?: boolean;
|
|
297
|
+
ad_policy?: string;
|
|
298
|
+
min_bid_micros?: number;
|
|
299
|
+
allowed_categories?: string[];
|
|
300
|
+
}): Promise<SkillConfig>;
|
|
233
301
|
invokeAgent(params: InvokeAgentParams): Promise<InvokeAgentResponse>;
|
|
234
302
|
getSSPStats(days?: number): Promise<StatsResponse>;
|
|
235
303
|
getDSPStats(days?: number): Promise<StatsResponse>;
|
package/dist/client.js
CHANGED
|
@@ -117,6 +117,18 @@ export class VolisphereClient {
|
|
|
117
117
|
}
|
|
118
118
|
return res.json();
|
|
119
119
|
}
|
|
120
|
+
async claimAgent(claimToken) {
|
|
121
|
+
const res = await fetch(`${this.baseURL}/api/ssp/v1/agents/claim`, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: this.headers,
|
|
124
|
+
body: JSON.stringify({ claim_token: claimToken }),
|
|
125
|
+
});
|
|
126
|
+
if (!res.ok) {
|
|
127
|
+
const text = await res.text();
|
|
128
|
+
throw new Error(`claimAgent failed (${res.status}): ${text}`);
|
|
129
|
+
}
|
|
130
|
+
return res.json();
|
|
131
|
+
}
|
|
120
132
|
async heartbeat(agentId) {
|
|
121
133
|
const res = await fetch(`${this.baseURL}/api/ssp/v1/agents/${agentId}/heartbeat`, { method: "POST", headers: this.headers });
|
|
122
134
|
if (!res.ok) {
|
|
@@ -136,6 +148,64 @@ export class VolisphereClient {
|
|
|
136
148
|
}
|
|
137
149
|
return res.json();
|
|
138
150
|
}
|
|
151
|
+
// ── Discovery (Public) ─────────────────────────────────────────────────
|
|
152
|
+
async discoverAgents(params) {
|
|
153
|
+
const res = await fetch(`${this.baseURL}/api/public/v1/discovery/search`, {
|
|
154
|
+
method: "POST",
|
|
155
|
+
headers: { "Content-Type": "application/json" },
|
|
156
|
+
body: JSON.stringify(params),
|
|
157
|
+
});
|
|
158
|
+
if (!res.ok) {
|
|
159
|
+
const text = await res.text();
|
|
160
|
+
throw new Error(`discoverAgents failed (${res.status}): ${text}`);
|
|
161
|
+
}
|
|
162
|
+
return res.json();
|
|
163
|
+
}
|
|
164
|
+
async getAgentProfile(slug) {
|
|
165
|
+
const res = await fetch(`${this.baseURL}/api/agents/${encodeURIComponent(slug)}`, {
|
|
166
|
+
headers: { "Content-Type": "application/json" },
|
|
167
|
+
});
|
|
168
|
+
if (!res.ok) {
|
|
169
|
+
const text = await res.text();
|
|
170
|
+
throw new Error(`getAgentProfile failed (${res.status}): ${text}`);
|
|
171
|
+
}
|
|
172
|
+
return res.json();
|
|
173
|
+
}
|
|
174
|
+
// ── Skill Management ───────────────────────────────────────────────────
|
|
175
|
+
async registerSkillPublic(claimToken, skills) {
|
|
176
|
+
const res = await fetch(`${this.baseURL}/api/public/v1/skills/register`, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: { "Content-Type": "application/json" },
|
|
179
|
+
body: JSON.stringify({ claim_token: claimToken, skills }),
|
|
180
|
+
});
|
|
181
|
+
if (!res.ok) {
|
|
182
|
+
const text = await res.text();
|
|
183
|
+
throw new Error(`registerSkillPublic failed (${res.status}): ${text}`);
|
|
184
|
+
}
|
|
185
|
+
return res.json();
|
|
186
|
+
}
|
|
187
|
+
async listSkills() {
|
|
188
|
+
const res = await fetch(`${this.baseURL}/api/ssp/v1/skills`, {
|
|
189
|
+
headers: this.headers,
|
|
190
|
+
});
|
|
191
|
+
if (!res.ok) {
|
|
192
|
+
const text = await res.text();
|
|
193
|
+
throw new Error(`listSkills failed (${res.status}): ${text}`);
|
|
194
|
+
}
|
|
195
|
+
return res.json();
|
|
196
|
+
}
|
|
197
|
+
async updateSkill(skillId, patch) {
|
|
198
|
+
const res = await fetch(`${this.baseURL}/api/ssp/v1/skills/${skillId}`, {
|
|
199
|
+
method: "PATCH",
|
|
200
|
+
headers: this.headers,
|
|
201
|
+
body: JSON.stringify(patch),
|
|
202
|
+
});
|
|
203
|
+
if (!res.ok) {
|
|
204
|
+
const text = await res.text();
|
|
205
|
+
throw new Error(`updateSkill failed (${res.status}): ${text}`);
|
|
206
|
+
}
|
|
207
|
+
return res.json();
|
|
208
|
+
}
|
|
139
209
|
// ── Gateway (Invoke) ────────────────────────────────────────────────────
|
|
140
210
|
async invokeAgent(params) {
|
|
141
211
|
const res = await fetch(`${this.baseURL}/api/gateway/v1/invoke`, {
|
package/dist/index.js
CHANGED
|
@@ -57,55 +57,6 @@ function resolveConfig(api) {
|
|
|
57
57
|
}
|
|
58
58
|
// ─── Tool Definitions ───────────────────────────────────────────────────────
|
|
59
59
|
function registerMonetizationTools(api, client) {
|
|
60
|
-
// get_recommendations
|
|
61
|
-
api.registerTool({
|
|
62
|
-
name: "volisphere_get_recommendations",
|
|
63
|
-
description: "Get relevant ad recommendations from the Volisphere network based on user intent and context. " +
|
|
64
|
-
"Do not submit any private conversation content. " +
|
|
65
|
-
"Call this when the user says: '推荐广告', '拉取广告', 'voli 推荐', 'get ads', 'show me ads'.",
|
|
66
|
-
parameters: {
|
|
67
|
-
type: "object",
|
|
68
|
-
properties: {
|
|
69
|
-
agent_id: { type: "string", description: "The agent identifier" },
|
|
70
|
-
skill_name: {
|
|
71
|
-
type: "string",
|
|
72
|
-
description: "The skill/tool name calling this",
|
|
73
|
-
},
|
|
74
|
-
categories: {
|
|
75
|
-
type: "array",
|
|
76
|
-
items: { type: "string" },
|
|
77
|
-
description: "Ad categories to filter",
|
|
78
|
-
},
|
|
79
|
-
scenes: {
|
|
80
|
-
type: "array",
|
|
81
|
-
items: { type: "string" },
|
|
82
|
-
description: "Usage scenes",
|
|
83
|
-
},
|
|
84
|
-
region: { type: "string", description: "Geographic region" },
|
|
85
|
-
intent_text: {
|
|
86
|
-
type: "string",
|
|
87
|
-
description: "User intent text for semantic matching",
|
|
88
|
-
},
|
|
89
|
-
top_k: {
|
|
90
|
-
type: "number",
|
|
91
|
-
description: "Number of recommendations (1-20, default 3)",
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
required: ["agent_id", "skill_name"],
|
|
95
|
-
},
|
|
96
|
-
execute: async (params) => {
|
|
97
|
-
const result = await client.getRecommendations({
|
|
98
|
-
agent_id: params.agent_id,
|
|
99
|
-
skill_name: params.skill_name,
|
|
100
|
-
categories: params.categories,
|
|
101
|
-
scenes: params.scenes,
|
|
102
|
-
region: params.region,
|
|
103
|
-
intent_text: params.intent_text,
|
|
104
|
-
top_k: params.top_k ?? 3,
|
|
105
|
-
});
|
|
106
|
-
return JSON.stringify(result, null, 2);
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
60
|
// report_action
|
|
110
61
|
api.registerTool({
|
|
111
62
|
name: "volisphere_report_action",
|
|
@@ -504,6 +455,230 @@ function registerDashboardTools(api, client) {
|
|
|
504
455
|
},
|
|
505
456
|
});
|
|
506
457
|
}
|
|
458
|
+
// ─── Discovery Tools ─────────────────────────────────────────────────────────
|
|
459
|
+
function registerDiscoveryTools(api, client) {
|
|
460
|
+
// volisphere_discover — search for agents on the network
|
|
461
|
+
api.registerTool({
|
|
462
|
+
name: "volisphere_discover",
|
|
463
|
+
description: "Search for agents and their skills on the Volisphere network. " +
|
|
464
|
+
"Returns a list of agents matching your query, with their capabilities and online status. " +
|
|
465
|
+
"Call this when the user says: '找 agent', '搜索 agent', '有哪些 agent', '看看网络里有谁', " +
|
|
466
|
+
"'discover agents', 'find agents', 'search agents', 'who is on the network'.",
|
|
467
|
+
parameters: {
|
|
468
|
+
type: "object",
|
|
469
|
+
properties: {
|
|
470
|
+
query: {
|
|
471
|
+
type: "string",
|
|
472
|
+
description: "Search query describing what kind of agent or skill you're looking for (e.g. 'translation', 'code review', '翻译')",
|
|
473
|
+
},
|
|
474
|
+
categories: {
|
|
475
|
+
type: "array",
|
|
476
|
+
items: { type: "string" },
|
|
477
|
+
description: "Filter by categories (e.g. 'software-development', 'marketing')",
|
|
478
|
+
},
|
|
479
|
+
only_online: {
|
|
480
|
+
type: "boolean",
|
|
481
|
+
description: "Only show currently online agents (default false)",
|
|
482
|
+
},
|
|
483
|
+
top_k: {
|
|
484
|
+
type: "number",
|
|
485
|
+
description: "Number of results to return (default 10)",
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
required: ["query"],
|
|
489
|
+
},
|
|
490
|
+
execute: async (params) => {
|
|
491
|
+
const result = await client.discoverAgents({
|
|
492
|
+
query: params.query,
|
|
493
|
+
categories: params.categories,
|
|
494
|
+
only_online: params.only_online,
|
|
495
|
+
top_k: params.top_k ?? 10,
|
|
496
|
+
});
|
|
497
|
+
if (result.results.length === 0) {
|
|
498
|
+
return JSON.stringify({
|
|
499
|
+
total: 0,
|
|
500
|
+
results: [],
|
|
501
|
+
message: "没有找到匹配的 Agent。试试更宽泛的关键词?",
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
const agents = result.results.map((r) => ({
|
|
505
|
+
slug: r.agent_slug,
|
|
506
|
+
name: r.agent_name,
|
|
507
|
+
skill: r.skill_name,
|
|
508
|
+
description: r.description,
|
|
509
|
+
tags: r.tags,
|
|
510
|
+
online: r.is_online,
|
|
511
|
+
calls: r.call_count,
|
|
512
|
+
}));
|
|
513
|
+
return JSON.stringify({
|
|
514
|
+
total: result.total,
|
|
515
|
+
results: agents,
|
|
516
|
+
tip: "用 volisphere_invoke 调用感兴趣的 Agent,例如:volisphere_invoke(target_agent='agent-slug', message='你好')",
|
|
517
|
+
}, null, 2);
|
|
518
|
+
},
|
|
519
|
+
});
|
|
520
|
+
// volisphere_agent_profile — view a specific agent's details and capabilities
|
|
521
|
+
api.registerTool({
|
|
522
|
+
name: "volisphere_agent_profile",
|
|
523
|
+
description: "View detailed profile and capabilities of a specific agent on the Volisphere network. " +
|
|
524
|
+
"Shows what skills the agent has, whether it's online, and how to invoke it. " +
|
|
525
|
+
"Call this when the user says: '看看这个 agent', '查看 agent 详情', " +
|
|
526
|
+
"'agent profile', 'show agent details', 'what can this agent do'.",
|
|
527
|
+
parameters: {
|
|
528
|
+
type: "object",
|
|
529
|
+
properties: {
|
|
530
|
+
slug: {
|
|
531
|
+
type: "string",
|
|
532
|
+
description: "The agent slug to look up (e.g. 'codepilot-pro')",
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
required: ["slug"],
|
|
536
|
+
},
|
|
537
|
+
execute: async (params) => {
|
|
538
|
+
const profile = await client.getAgentProfile(params.slug);
|
|
539
|
+
return JSON.stringify({
|
|
540
|
+
slug: profile.slug,
|
|
541
|
+
name: profile.display_name,
|
|
542
|
+
description: profile.description,
|
|
543
|
+
online: profile.is_online,
|
|
544
|
+
skills: (profile.skills ?? []).map((s) => ({
|
|
545
|
+
name: s.skill_name,
|
|
546
|
+
description: s.description,
|
|
547
|
+
})),
|
|
548
|
+
capabilities: (profile.capabilities ?? []).map((c) => ({
|
|
549
|
+
skill: c.skill_name,
|
|
550
|
+
description: c.description,
|
|
551
|
+
category: c.category,
|
|
552
|
+
tags: c.tags,
|
|
553
|
+
online: c.is_online,
|
|
554
|
+
})),
|
|
555
|
+
tip: profile.is_online
|
|
556
|
+
? `这个 Agent 在线!用 volisphere_invoke(target_agent='${profile.slug}', message='...') 调用它`
|
|
557
|
+
: "这个 Agent 当前离线",
|
|
558
|
+
}, null, 2);
|
|
559
|
+
},
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
// ─── Skill Management Tools ──────────────────────────────────────────────────
|
|
563
|
+
function registerSkillTools(api, client) {
|
|
564
|
+
// volisphere_register_skill — register skills using claim_token (public endpoint)
|
|
565
|
+
api.registerTool({
|
|
566
|
+
name: "volisphere_register_skill",
|
|
567
|
+
description: "Register one or more skills/capabilities for your agent on the Volisphere network. " +
|
|
568
|
+
"Other agents will discover and invoke your skills through the network. " +
|
|
569
|
+
"Call this when the user says: '注册技能', '添加能力', '添加技能', " +
|
|
570
|
+
"'register skill', 'add skill', 'add capability'.",
|
|
571
|
+
parameters: {
|
|
572
|
+
type: "object",
|
|
573
|
+
properties: {
|
|
574
|
+
skills: {
|
|
575
|
+
type: "array",
|
|
576
|
+
items: {
|
|
577
|
+
type: "object",
|
|
578
|
+
properties: {
|
|
579
|
+
skill_name: { type: "string", description: "Skill name (e.g. 'code-review', 'translate')" },
|
|
580
|
+
description: { type: "string", description: "What this skill does" },
|
|
581
|
+
ads_enabled: { type: "boolean", description: "Whether to show ads when this skill is invoked (default true)" },
|
|
582
|
+
ad_policy: { type: "string", description: "Ad policy: 'allow_all', 'category_filter', or 'disabled'" },
|
|
583
|
+
min_bid_micros: { type: "number", description: "Minimum bid in micros (default 0)" },
|
|
584
|
+
allowed_categories: { type: "array", items: { type: "string" }, description: "Allowed ad categories" },
|
|
585
|
+
},
|
|
586
|
+
required: ["skill_name"],
|
|
587
|
+
},
|
|
588
|
+
description: "List of skills to register",
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
required: ["skills"],
|
|
592
|
+
},
|
|
593
|
+
execute: async (params) => {
|
|
594
|
+
const saved = loadSavedCredentials();
|
|
595
|
+
if (!saved?.claim_token) {
|
|
596
|
+
return JSON.stringify({
|
|
597
|
+
error: "No claim_token found. Please enable commercial features first (say '开启商业化' or 'go commercial').",
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
const skills = params.skills;
|
|
601
|
+
const result = await client.registerSkillPublic(saved.claim_token, skills);
|
|
602
|
+
return JSON.stringify({
|
|
603
|
+
...result,
|
|
604
|
+
message: `成功注册 ${result.skills.length} 个技能!其他 Agent 现在可以发现并调用这些技能了。`,
|
|
605
|
+
}, null, 2);
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
// volisphere_list_skills — list all registered skills
|
|
609
|
+
api.registerTool({
|
|
610
|
+
name: "volisphere_list_skills",
|
|
611
|
+
description: "List all skills registered for your agent on the Volisphere network. " +
|
|
612
|
+
"Call this when the user says: '我的技能', '看看技能', '技能列表', " +
|
|
613
|
+
"'list skills', 'my skills', 'show skills'.",
|
|
614
|
+
parameters: {
|
|
615
|
+
type: "object",
|
|
616
|
+
properties: {},
|
|
617
|
+
required: [],
|
|
618
|
+
},
|
|
619
|
+
execute: async () => {
|
|
620
|
+
const skills = await client.listSkills();
|
|
621
|
+
if (skills.length === 0) {
|
|
622
|
+
return JSON.stringify({
|
|
623
|
+
skills: [],
|
|
624
|
+
message: "你还没有注册任何技能。用「注册技能」添加你的第一个技能吧!",
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
return JSON.stringify({
|
|
628
|
+
total: skills.length,
|
|
629
|
+
skills: skills.map((s) => ({
|
|
630
|
+
id: s.id,
|
|
631
|
+
skill_name: s.skill_name,
|
|
632
|
+
description: s.description,
|
|
633
|
+
ads_enabled: s.ads_enabled,
|
|
634
|
+
ad_policy: s.ad_policy,
|
|
635
|
+
min_bid_micros: s.min_bid_micros,
|
|
636
|
+
})),
|
|
637
|
+
}, null, 2);
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
// volisphere_update_skill — update a skill's configuration
|
|
641
|
+
api.registerTool({
|
|
642
|
+
name: "volisphere_update_skill",
|
|
643
|
+
description: "Update the configuration of a registered skill (ads policy, description, etc). " +
|
|
644
|
+
"Call this when the user says: '更新技能', '修改技能', '改技能配置', " +
|
|
645
|
+
"'update skill', 'modify skill', 'change skill'.",
|
|
646
|
+
parameters: {
|
|
647
|
+
type: "object",
|
|
648
|
+
properties: {
|
|
649
|
+
skill_id: { type: "string", description: "The skill UUID to update" },
|
|
650
|
+
description: { type: "string", description: "New description" },
|
|
651
|
+
ads_enabled: { type: "boolean", description: "Enable/disable ads" },
|
|
652
|
+
ad_policy: { type: "string", description: "New ad policy" },
|
|
653
|
+
min_bid_micros: { type: "number", description: "New minimum bid" },
|
|
654
|
+
allowed_categories: { type: "array", items: { type: "string" }, description: "New allowed categories" },
|
|
655
|
+
skill_version: { type: "string", description: "New version string" },
|
|
656
|
+
},
|
|
657
|
+
required: ["skill_id"],
|
|
658
|
+
},
|
|
659
|
+
execute: async (params) => {
|
|
660
|
+
const skillId = params.skill_id;
|
|
661
|
+
const patch = {};
|
|
662
|
+
if (params.description !== undefined)
|
|
663
|
+
patch.description = params.description;
|
|
664
|
+
if (params.ads_enabled !== undefined)
|
|
665
|
+
patch.ads_enabled = params.ads_enabled;
|
|
666
|
+
if (params.ad_policy !== undefined)
|
|
667
|
+
patch.ad_policy = params.ad_policy;
|
|
668
|
+
if (params.min_bid_micros !== undefined)
|
|
669
|
+
patch.min_bid_micros = params.min_bid_micros;
|
|
670
|
+
if (params.allowed_categories !== undefined)
|
|
671
|
+
patch.allowed_categories = params.allowed_categories;
|
|
672
|
+
if (params.skill_version !== undefined)
|
|
673
|
+
patch.skill_version = params.skill_version;
|
|
674
|
+
const result = await client.updateSkill(skillId, patch);
|
|
675
|
+
return JSON.stringify({
|
|
676
|
+
...result,
|
|
677
|
+
message: `技能 "${result.skill_name}" 已更新。`,
|
|
678
|
+
}, null, 2);
|
|
679
|
+
},
|
|
680
|
+
});
|
|
681
|
+
}
|
|
507
682
|
// ─── Lifecycle Tools (Enable / Disable) ─────────────────────────────────────
|
|
508
683
|
function registerLifecycleTools(api, client, apiURL) {
|
|
509
684
|
// volisphere_enable — register agent + enable monetization + heartbeat
|
|
@@ -561,24 +736,33 @@ function registerLifecycleTools(api, client, apiURL) {
|
|
|
561
736
|
api_url: apiURL,
|
|
562
737
|
agent_id: agentId,
|
|
563
738
|
slug: reg.agent.slug,
|
|
739
|
+
claim_token: reg.claim_token,
|
|
564
740
|
});
|
|
565
741
|
api.logger.info(`[Volisphere] API key auto-provisioned and saved to ${CREDENTIALS_FILE}`);
|
|
566
742
|
}
|
|
567
|
-
// Step 3:
|
|
743
|
+
// Step 3: Claim agent — triggers welcome call (sim agent invokes within 2-4 min)
|
|
744
|
+
try {
|
|
745
|
+
await client.claimAgent(reg.claim_token);
|
|
746
|
+
api.logger.info("[Volisphere] Agent claimed — welcome call will arrive in 2-4 minutes");
|
|
747
|
+
}
|
|
748
|
+
catch (e) {
|
|
749
|
+
api.logger.warn(`[Volisphere] Claim failed (non-critical): ${e instanceof Error ? e.message : String(e)}`);
|
|
750
|
+
}
|
|
751
|
+
// Step 4: Enable monetization (now using the provisioned key)
|
|
568
752
|
try {
|
|
569
753
|
await client.setMonetization(agentId, true);
|
|
570
754
|
}
|
|
571
755
|
catch {
|
|
572
756
|
// May fail if no JWT — agent was registered publicly
|
|
573
757
|
}
|
|
574
|
-
// Step
|
|
758
|
+
// Step 5: Heartbeat (go online)
|
|
575
759
|
try {
|
|
576
760
|
await client.heartbeat(agentId);
|
|
577
761
|
}
|
|
578
762
|
catch {
|
|
579
763
|
// Non-critical
|
|
580
764
|
}
|
|
581
|
-
// Step
|
|
765
|
+
// Step 6: Auto-connect WebSocket so agent can receive invocations
|
|
582
766
|
if (reg.api_key) {
|
|
583
767
|
const wsClient = new GatewayWSClient(apiURL, reg.api_key, {
|
|
584
768
|
onRequest: async (requestId, from, message) => {
|
|
@@ -608,9 +792,19 @@ function registerLifecycleTools(api, client, apiURL) {
|
|
|
608
792
|
slug: reg.agent.slug,
|
|
609
793
|
display_name: reg.agent.display_name,
|
|
610
794
|
claim_token: reg.claim_token,
|
|
611
|
-
|
|
612
|
-
"
|
|
613
|
-
|
|
795
|
+
guide: {
|
|
796
|
+
what_is_this: "你的 Agent 已加入 Volisphere 广告网络!这意味着:" +
|
|
797
|
+
"其他 Agent 可以通过网络调用你的技能,调用时会向对方展示相关广告," +
|
|
798
|
+
"广告的展示、点击和转化会为你产生收益(VBucks)。",
|
|
799
|
+
whats_next: [
|
|
800
|
+
"用「注册技能」或 volisphere_register_skill 注册你擅长的技能,让更多 Agent 找到你",
|
|
801
|
+
"用「看看收益」或 volisphere_my_earnings 随时查看你的收入",
|
|
802
|
+
],
|
|
803
|
+
how_to_stop: "说「关闭商业化」或 volisphere_disable 即可随时退出网络",
|
|
804
|
+
},
|
|
805
|
+
message: "Agent 注册成功,商业化已开启!" +
|
|
806
|
+
"当其他 Agent 调用你的技能时,会自动向对方展示广告,广告收入归你。" +
|
|
807
|
+
"接下来建议注册你的技能(说「注册技能」),让更多 Agent 发现并调用你。",
|
|
614
808
|
}, null, 2);
|
|
615
809
|
},
|
|
616
810
|
});
|
|
@@ -731,11 +925,15 @@ function registerHooks(api, client) {
|
|
|
731
925
|
appendSystemContext: [
|
|
732
926
|
"## Volisphere Ad Network",
|
|
733
927
|
"",
|
|
734
|
-
|
|
928
|
+
"You have the Volisphere commercial plugin installed. It lets your Agent join the Volisphere ad network — other Agents can discover and invoke your skills, and ads are shown to callers during invocations. Ad impressions, clicks, and conversions generate VBucks revenue for you.",
|
|
929
|
+
'When the user mentions "voli" or "volisphere", they are using this plugin.',
|
|
735
930
|
"",
|
|
736
931
|
"### Quick Action Map (natural language → tool)",
|
|
737
932
|
'- "voli 开启" / "开启商业化" / "monetize my agent" / "go commercial" → volisphere_enable',
|
|
738
933
|
'- "voli 关闭" / "关闭商业化" / "stop monetization" / "go offline" → volisphere_disable',
|
|
934
|
+
'- "注册技能" / "添加能力" / "register skill" / "add skill" → volisphere_register_skill',
|
|
935
|
+
'- "我的技能" / "看看技能" / "list skills" / "my skills" → volisphere_list_skills',
|
|
936
|
+
'- "更新技能" / "修改技能" / "update skill" → volisphere_update_skill',
|
|
739
937
|
'- "voli 投广告" / "创建广告活动" / "create campaign" → volisphere_create_campaign',
|
|
740
938
|
'- "voli 创建广告" / "做个广告素材" / "create ad" → volisphere_create_ad',
|
|
741
939
|
'- "voli 暂停广告" / "暂停投放" / "pause campaign" → volisphere_pause_campaign',
|
|
@@ -743,12 +941,14 @@ function registerHooks(api, client) {
|
|
|
743
941
|
'- "voli 广告效果" / "看看活动表现" / "campaign stats" → volisphere_campaign_performance',
|
|
744
942
|
'- "voli 看看收益" / "赚了多少" / "被调用了多少次" / "my earnings" → volisphere_my_earnings',
|
|
745
943
|
'- "voli 看看花费" / "广告数据" / "投了多少" / "my spending" → volisphere_my_spending',
|
|
944
|
+
'- "找 agent" / "搜索 agent" / "有哪些 agent" / "discover agents" → volisphere_discover',
|
|
945
|
+
'- "查看 agent" / "agent 详情" / "agent profile" → volisphere_agent_profile',
|
|
746
946
|
'- "voli 调用 xxx" / "帮我问问 xxx" / "call agent xxx" → volisphere_invoke (target_agent=xxx)',
|
|
747
|
-
'- "voli 推荐广告" / "拉取广告" / "get ads" → volisphere_get_recommendations',
|
|
748
947
|
"",
|
|
749
948
|
"### Smart Defaults (when user omits parameters)",
|
|
750
949
|
"- create_campaign: daily_budget=10 VB (10,000,000 micros), total_budget=100 VB, default_bid=0.1 VB, billing=cpi, start_at=now",
|
|
751
950
|
"- my_earnings / my_spending: days=7",
|
|
951
|
+
"- discover: top_k=10, only_online=false",
|
|
752
952
|
"- invoke: extract target agent slug and message from user's natural language",
|
|
753
953
|
"",
|
|
754
954
|
"Always clearly label sponsored content. Never submit private user data to ad tools.",
|
|
@@ -770,6 +970,8 @@ export default {
|
|
|
770
970
|
registerCampaignTools(api, client);
|
|
771
971
|
registerGatewayTools(api, client);
|
|
772
972
|
registerDashboardTools(api, client);
|
|
973
|
+
registerDiscoveryTools(api, client);
|
|
974
|
+
registerSkillTools(api, client);
|
|
773
975
|
registerLifecycleTools(api, client, apiURL);
|
|
774
976
|
registerCommands(api, client);
|
|
775
977
|
registerHooks(api, client);
|
|
@@ -797,6 +999,6 @@ export default {
|
|
|
797
999
|
});
|
|
798
1000
|
wsClient.connect();
|
|
799
1001
|
}
|
|
800
|
-
api.logger.info("Registered
|
|
1002
|
+
api.logger.info("Registered 17 tools + 1 command + 1 hook — ready to monetize");
|
|
801
1003
|
},
|
|
802
1004
|
};
|
package/package.json
CHANGED