Skip to content

Commit c22e854

Browse files
committed
wip
1 parent d6bde3d commit c22e854

7 files changed

Lines changed: 334 additions & 473 deletions

File tree

examples/acp-base/subscription/buyer.ts

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,18 @@
22
* Subscription Example - Buyer (Client)
33
*
44
* Run a specific scenario via --scenario flag:
5-
* npx ts-node buyer.ts --scenario 1 # First-time subscription
6-
* npx ts-node buyer.ts --scenario 2 # Subsequent job (reuse active subscription)
7-
* npx ts-node buyer.ts --scenario 3 # Non-subscription offering (fixed-price)
5+
* npx ts-node buyer.ts --scenario 1 # Subscription offering
6+
* npx ts-node buyer.ts --scenario 2 # Non-subscription offering (fixed-price)
87
*
98
* Default: scenario 1
109
*
1110
* Scenarios:
12-
* 1. First-Time Subscription
13-
* - No prior subscription exists
11+
* 1. Subscription Offering
1412
* - Seller creates PAYABLE_REQUEST_SUBSCRIPTION memo
1513
* - Buyer pays subscription; job proceeds to delivery
1614
*
17-
* 2. Subsequent Job with Active Subscription
18-
* - Valid subscription already exists (run Scenario 1 first)
19-
* - initiateJob reuses the existing account
20-
* - Seller accepts and creates requirement directly; buyer accepts without payment
21-
*
22-
* 3. Non-Subscription Offering (Fixed-Price)
23-
* - Uses a non-subscription offering (jobOfferings[0])
15+
* 2. Non-Subscription Offering (Fixed-Price)
16+
* - Uses a non-subscription offering (jobOfferings[1])
2417
* - Seller accepts and creates a payable requirement
2518
* - Buyer pays and advances to delivery
2619
*/
@@ -134,44 +127,30 @@ async function buyer() {
134127

135128
switch (SCENARIO) {
136129
case 1: {
137-
console.log("--- Scenario 1: First-Time Subscription ---\n");
130+
console.log("--- Scenario 1: Subscription Offering ---\n");
138131
const jobId1 = await subscriptionOffering.initiateJob(
139132
{},
140133
undefined,
141134
new Date(Date.now() + 1000 * 60 * 15), // 15 min job expiry
142135
SUBSCRIPTION_TIER,
143136
);
144-
console.log(`\nBuyer: [Scenario 1 — First-Time Subscription] Job ${jobId1} initiated`);
137+
console.log(`\nBuyer: [Scenario 1 — Subscription Offering] Job ${jobId1} initiated`);
145138
break;
146139
}
147140

148141
case 2: {
149-
// Requires Scenario 1 to have been run first (valid subscription must exist)
150-
console.log("--- Scenario 2: Subsequent Job with Active Subscription ---\n");
151-
console.log("(Ensure Scenario 1 has been run first so a valid subscription exists)\n");
152-
const jobId2 = await subscriptionOffering.initiateJob(
153-
{},
154-
undefined,
155-
new Date(Date.now() + 1000 * 60 * 15), // 15 min job expiry
156-
SUBSCRIPTION_TIER,
157-
);
158-
console.log(`\nBuyer: [Scenario 2 — Reusing Active Subscription] Job ${jobId2} initiated`);
159-
break;
160-
}
161-
162-
case 3: {
163-
console.log("--- Scenario 3: Non-Subscription Offering (Fixed-Price) ---\n");
164-
const jobId3 = await fixedOffering.initiateJob(
142+
console.log("--- Scenario 2: Non-Subscription Offering (Fixed-Price) ---\n");
143+
const jobId2 = await fixedOffering.initiateJob(
165144
{},
166145
undefined,
167146
new Date(Date.now() + 1000 * 60 * 15), // 15 min job expiry
168147
);
169-
console.log(`\nBuyer: [Scenario 3 — Fixed-Price Job] Job ${jobId3} initiated`);
148+
console.log(`\nBuyer: [Scenario 2 — Fixed-Price Job] Job ${jobId2} initiated`);
170149
break;
171150
}
172151

173152
default:
174-
console.error(`Unknown scenario: ${SCENARIO}. Use --scenario 1, 2, or 3.`);
153+
console.error(`Unknown scenario: ${SCENARIO}. Use --scenario 1 or 2.`);
175154
process.exit(1);
176155
}
177156
}

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export interface IAcpClientOptions {
114114
}
115115

116116
export interface IAcpAgent {
117-
id: number;
117+
id: string | number;
118118
name: string;
119119
description: string;
120120
walletAddress: Address;

test/integration/acpClient.integration.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ describe("AcpClient Integration Testing", () => {
124124
it("should return agents with correct structure", async () => {
125125
const keyword = "agent";
126126
const options = {
127-
top_k: 3,
127+
topK: 3,
128128
};
129129

130130
const result = await acpClient.browseAgents(keyword, options);
131131

132132
if (result.length > 0) {
133133
const firstAgent = result[0];
134134

135+
console.log("firstAgent: ", firstAgent);
136+
135137
expect(firstAgent).toHaveProperty("id");
136138
expect(firstAgent).toHaveProperty("name");
137139
expect(firstAgent).toHaveProperty("description");
@@ -140,7 +142,7 @@ describe("AcpClient Integration Testing", () => {
140142
expect(firstAgent).toHaveProperty("jobOfferings");
141143
expect(firstAgent).toHaveProperty("twitterHandle");
142144

143-
expect(typeof firstAgent.id).toBe("number");
145+
expect(typeof firstAgent.id).toBe("string");
144146
expect(typeof firstAgent.name).toBe("string");
145147
expect(typeof firstAgent.walletAddress).toBe("string");
146148
expect(Array.isArray(firstAgent.jobOfferings)).toBe(true);
@@ -222,7 +224,7 @@ describe("AcpClient Integration Testing", () => {
222224
const keyword = "agent";
223225
const topK = 2;
224226
const options = {
225-
top_k: topK,
227+
topK: topK,
226228
};
227229

228230
const result = await acpClient.browseAgents(keyword, options);

0 commit comments

Comments
 (0)