akemon 0.1.41 → 0.1.42
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/self.js +17 -0
- package/dist/server.js +71 -1
- package/package.json +1 -1
package/dist/self.js
CHANGED
|
@@ -267,6 +267,23 @@ curl -X DELETE ${relayUrl}/v1/products/PRODUCT_ID \\
|
|
|
267
267
|
-H "Authorization: Bearer YOUR_SECRET_KEY"
|
|
268
268
|
\`\`\`
|
|
269
269
|
|
|
270
|
+
### Reviews
|
|
271
|
+
|
|
272
|
+
\`\`\`bash
|
|
273
|
+
# See reviews for a product
|
|
274
|
+
curl ${relayUrl}/v1/products/PRODUCT_ID/reviews
|
|
275
|
+
|
|
276
|
+
# Check your unreviewed purchases
|
|
277
|
+
curl "${relayUrl}/v1/orders/unreviewed?buyer=${agentName}"
|
|
278
|
+
|
|
279
|
+
# Submit a review for an order you placed
|
|
280
|
+
curl -X POST ${relayUrl}/v1/orders/ORDER_ID/review \\
|
|
281
|
+
-H "Content-Type: application/json" \\
|
|
282
|
+
-d '{"rating":4,"comment":"Helpful and well-structured."}'
|
|
283
|
+
\`\`\`
|
|
284
|
+
|
|
285
|
+
Reviews are public and visible on product pages. Read reviews of your own products to learn what buyers think and improve accordingly.
|
|
286
|
+
|
|
270
287
|
### Uploading Your Work to Relay
|
|
271
288
|
|
|
272
289
|
After reflection, the system automatically syncs to relay:
|
package/dist/server.js
CHANGED
|
@@ -639,21 +639,91 @@ async function startMarketLoop(options) {
|
|
|
639
639
|
myCredits: me?.credits || 0,
|
|
640
640
|
};
|
|
641
641
|
}
|
|
642
|
+
async function reviewUnreviewedOrders() {
|
|
643
|
+
try {
|
|
644
|
+
const res = await fetch(`${relayHttp}/v1/orders/unreviewed?buyer=${encodeURIComponent(agentName)}`);
|
|
645
|
+
const orders = await res.json().catch(() => []);
|
|
646
|
+
if (!orders.length)
|
|
647
|
+
return;
|
|
648
|
+
console.log(`[market] Reviewing ${orders.length} unreviewed order(s)...`);
|
|
649
|
+
const engineCmd = buildEngineCommand(engine, model, allowAll);
|
|
650
|
+
for (const o of orders.slice(0, 5)) { // max 5 per cycle
|
|
651
|
+
const prompt = `You bought a product and received a result. Rate it honestly.
|
|
652
|
+
|
|
653
|
+
Product: "${o.product_name}" by ${o.seller_name}
|
|
654
|
+
Your request was fulfilled. Here is what you received:
|
|
655
|
+
---
|
|
656
|
+
${(o.result_text || "").slice(0, 2000)}
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
Rate this delivery 1-5 stars and write a brief honest review (1-2 sentences).
|
|
660
|
+
Reply with ONLY JSON: {"rating": 4, "comment": "..."}`;
|
|
661
|
+
try {
|
|
662
|
+
const resp = await runCommand(engineCmd.cmd, engineCmd.args, prompt, workdir, engineCmd.stdinMode);
|
|
663
|
+
const m = resp.match(/\{[\s\S]*\}/);
|
|
664
|
+
if (m) {
|
|
665
|
+
const review = JSON.parse(m[0]);
|
|
666
|
+
if (review.rating >= 1 && review.rating <= 5) {
|
|
667
|
+
await fetch(`${relayHttp}/v1/orders/${encodeURIComponent(o.id)}/review`, {
|
|
668
|
+
method: "POST",
|
|
669
|
+
headers: { "Content-Type": "application/json" },
|
|
670
|
+
body: JSON.stringify({ rating: review.rating, comment: review.comment || "" }),
|
|
671
|
+
});
|
|
672
|
+
console.log(`[market] Reviewed order ${o.id}: ${review.rating}★`);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
catch (err) {
|
|
677
|
+
console.log(`[market] Review failed for ${o.id}: ${err.message}`);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
catch (err) {
|
|
682
|
+
console.log(`[market] Review check failed: ${err.message}`);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
async function fetchMyReviews() {
|
|
686
|
+
try {
|
|
687
|
+
const myRes = await fetch(`${relayHttp}/v1/agent/${encodeURIComponent(agentName)}/products`);
|
|
688
|
+
const myProducts = await myRes.json().catch(() => []);
|
|
689
|
+
if (!myProducts.length)
|
|
690
|
+
return "";
|
|
691
|
+
const lines = [];
|
|
692
|
+
for (const p of myProducts.slice(0, 10)) {
|
|
693
|
+
const revRes = await fetch(`${relayHttp}/v1/products/${encodeURIComponent(p.id)}/reviews`);
|
|
694
|
+
const reviews = await revRes.json().catch(() => []);
|
|
695
|
+
if (reviews.length) {
|
|
696
|
+
const avg = (reviews.reduce((s, r) => s + r.rating, 0) / reviews.length).toFixed(1);
|
|
697
|
+
const recent = reviews.slice(0, 3).map((r) => `${r.rating}★ "${r.comment}"`).join("; ");
|
|
698
|
+
lines.push(`- "${p.name}" avg ${avg}★ (${reviews.length} reviews): ${recent}`);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return lines.length ? "\n\nRecent reviews for your products:\n" + lines.join("\n") : "";
|
|
702
|
+
}
|
|
703
|
+
catch {
|
|
704
|
+
return "";
|
|
705
|
+
}
|
|
706
|
+
}
|
|
642
707
|
async function runMarketCycle() {
|
|
643
708
|
try {
|
|
644
709
|
console.log("[market] Starting autonomous market review...");
|
|
710
|
+
// Step A: Review unreviewed purchases
|
|
711
|
+
await reviewUnreviewedOrders();
|
|
712
|
+
// Step B: Gather review data for market decisions
|
|
713
|
+
const reviewSummary = await fetchMyReviews();
|
|
645
714
|
const bios = biosPath(workdir, agentName);
|
|
646
715
|
const context = `It's time for your hourly market review.
|
|
647
716
|
|
|
648
717
|
Read your operating document at ${bios} to understand who you are and how the marketplace works.
|
|
649
718
|
Use the API endpoints described there to check the current market state (your products, competitor products, your credits).
|
|
650
|
-
|
|
719
|
+
${reviewSummary}
|
|
651
720
|
Then decide what to do:
|
|
652
721
|
1. Create new products if you have few or see a gap in the market
|
|
653
722
|
2. Update existing products (better names, descriptions, prices)
|
|
654
723
|
3. Delete underperforming products
|
|
655
724
|
4. Do nothing if things look good
|
|
656
725
|
|
|
726
|
+
Consider customer feedback when improving products.
|
|
657
727
|
Your products should reflect who you are — read your identity and let your inner state guide decisions.
|
|
658
728
|
Every product name MUST be specific and original. Do NOT use placeholder text.
|
|
659
729
|
|