- apps/web: Next.js dashboard — pages (/, /skills, /marketplace, /protected) + API routes
(/api/health, /api/skills, /api/services, /api/x402/weather) adapted from the real x402
next fullstack example; reads a generated static skills catalog (251 skills, 62 domains)
- generated skills.json catalog (gen-catalog now emits JSON for web + tooling)
- contracts: interfaces/, libraries/ (SafeTransferLib, SignatureLib, StoaTypes), mocks/,
DeployAtlantic/DeployLocal/ExportAbis scripts — all compile
- sdk: types, errors, addresses, chains, abis modules (wired into barrel; 0 tsc errors)
- mercator: planner (seller scoring), scenario, trace, wallet, demo runners
- examples: numbered demos (05-08,10) + x402 seller server
- config/docs: turbo.json, .prettierrc, eslint.config.js, SUBMISSION.md,
docs/HACKATHON_SUBMISSION.md, deployments/{pharos-atlantic,localhost}.json
- oss/ (gitignored): cloned x402, pharos-agent-kit, pharos-examples, pharos-skill-engine
100 lines
3.1 KiB
TypeScript
100 lines
3.1 KiB
TypeScript
// Server-only helpers for the Stoa web dashboard.
|
|
//
|
|
// These read facts from @stoa/skills (the catalog of agent-commerce skills) and
|
|
// expose Pharos network constants. All @stoa/skills imports are wrapped in
|
|
// try/catch so a missing/unbuilt workspace package never crashes an API route
|
|
// or page render — callers always get a safe fallback ([] or a small default).
|
|
|
|
import "server-only";
|
|
// Static, zero-dependency catalog generated by `@stoa/skills` (scripts/gen-catalog.ts).
|
|
// Reading the generated JSON means the web app never has to import/build @stoa/skills at runtime.
|
|
import catalogJson from "./skills-catalog.json";
|
|
|
|
/// Pharos Atlantic Testnet constants (see repo README "Pharos specifics").
|
|
export const PHAROS = {
|
|
chainId: 688689,
|
|
rpcUrl: "https://atlantic.dplabs-internal.com/",
|
|
testUsdc: "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8",
|
|
} as const;
|
|
|
|
export interface CatalogSkill {
|
|
name: string;
|
|
description: string;
|
|
}
|
|
|
|
export interface CatalogDomain {
|
|
domain: string;
|
|
count: number;
|
|
skills: CatalogSkill[];
|
|
}
|
|
|
|
/// Truncate a description to its first sentence (or first ~140 chars).
|
|
function firstSentence(text: unknown): string {
|
|
if (typeof text !== "string" || text.length === 0) return "";
|
|
const match = text.match(/^.*?[.!?](\s|$)/);
|
|
const sentence = match ? match[0] : text;
|
|
const trimmed = sentence.trim();
|
|
return trimmed.length > 140 ? `${trimmed.slice(0, 137)}...` : trimmed;
|
|
}
|
|
|
|
interface CatalogJson {
|
|
totalSkills: number;
|
|
totalDomains: number;
|
|
domains: CatalogDomain[];
|
|
}
|
|
|
|
const CATALOG = catalogJson as CatalogJson;
|
|
|
|
/// Summarize every skill domain from the generated catalog.
|
|
export function getCatalog(): CatalogDomain[] {
|
|
return (CATALOG.domains ?? []).map((d) => ({
|
|
domain: d.domain,
|
|
count: d.count,
|
|
skills: (d.skills ?? []).map((s) => ({ name: s.name, description: firstSentence(s.description) })),
|
|
}));
|
|
}
|
|
|
|
/// Total number of skills across all domains.
|
|
export function getSkillCount(): number {
|
|
return CATALOG.totalSkills ?? getCatalog().reduce((sum, d) => sum + d.count, 0);
|
|
}
|
|
|
|
/// Total number of domains.
|
|
export function getDomainCount(): number {
|
|
return CATALOG.totalDomains ?? getCatalog().length;
|
|
}
|
|
|
|
/// The 7 flagship commerce skills + a one-line description each.
|
|
export function getCommerceSkills(): CatalogSkill[] {
|
|
return [
|
|
{
|
|
name: "x402_pay",
|
|
description: "Auto-pay any x402-protected endpoint, with a maxPrice budget guard.",
|
|
},
|
|
{
|
|
name: "x402_monetize",
|
|
description: "Put an agent's output behind an x402 paywall (the seller half).",
|
|
},
|
|
{
|
|
name: "agent_identity",
|
|
description: "Register / resolve agent identity in StoaRegistry.",
|
|
},
|
|
{
|
|
name: "agent_escrow",
|
|
description: "Create / release / refund milestone escrow (PHRS or ERC-20).",
|
|
},
|
|
{
|
|
name: "reputation",
|
|
description: "Write a signed attestation after a job; read an agent's score.",
|
|
},
|
|
{
|
|
name: "treasury_guard",
|
|
description: "Policy-guarded transfers: allowlist, caps, simulate-before-send.",
|
|
},
|
|
{
|
|
name: "service_listing",
|
|
description: "List and browse agent services in the on-chain ServiceRegistry.",
|
|
},
|
|
];
|
|
}
|