aixyz 0.2.0 → 0.3.0

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/accepts.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  import { FacilitatorClient, HTTPFacilitatorClient } from "@x402/core/server";
2
3
  import { getFacilitatorClient } from "./facilitator";
3
4
 
@@ -14,6 +15,18 @@ export type AcceptsFree = {
14
15
  scheme: "free";
15
16
  };
16
17
 
18
+ export const AcceptsScheme = z.discriminatedUnion("scheme", [
19
+ z.object({
20
+ scheme: z.literal("exact"),
21
+ price: z.string(),
22
+ network: z.string().optional(),
23
+ payTo: z.string().optional(),
24
+ }),
25
+ z.object({
26
+ scheme: z.literal("free"),
27
+ }),
28
+ ]);
29
+
17
30
  export type { FacilitatorClient };
18
31
 
19
32
  export { HTTPFacilitatorClient };
package/package.json CHANGED
@@ -1,20 +1,15 @@
1
1
  {
2
2
  "name": "aixyz",
3
- "version": "0.2.0",
4
- "description": "AI agent framework for building autonomous agents with X402 and ERC-8004 support.",
3
+ "version": "0.3.0",
4
+ "description": "Payment-native SDK for AI Agent",
5
5
  "keywords": [
6
6
  "ai",
7
+ "payments",
7
8
  "agent",
8
- "a2a",
9
- "mcp",
10
- "x402",
11
- "erc-8004",
12
- "framework"
9
+ "aixyz"
13
10
  ],
14
11
  "homepage": "https://ai-xyz.dev",
15
- "bugs": {
16
- "url": "https://github.com/AgentlyHQ/aixyz/issues"
17
- },
12
+ "bugs": "https://github.com/AgentlyHQ/aixyz/issues",
18
13
  "repository": {
19
14
  "type": "git",
20
15
  "url": "git+https://github.com/AgentlyHQ/aixyz.git"
@@ -28,8 +23,8 @@
28
23
  ],
29
24
  "dependencies": {
30
25
  "@a2a-js/sdk": "^0.3.10",
31
- "@aixyz/cli": "workspace:*",
32
- "@aixyz/config": "workspace:*",
26
+ "@aixyz/cli": "0.3.0",
27
+ "@aixyz/config": "0.3.0",
33
28
  "@modelcontextprotocol/sdk": "^1.26.0",
34
29
  "@x402/core": "^2.3.1",
35
30
  "@x402/evm": "^2.3.1",
@@ -9,10 +9,10 @@ import {
9
9
  } from "@a2a-js/sdk/server";
10
10
  import { AgentCard, Message, TextPart } from "@a2a-js/sdk";
11
11
  import type { ToolLoopAgent, ToolSet } from "ai";
12
- import { getAixyzConfig } from "../../config";
12
+ import { getAixyzConfigRuntime } from "../../config";
13
13
  import { AixyzServer } from "../index";
14
14
  import { agentCardHandler, jsonRpcHandler, UserBuilder } from "@a2a-js/sdk/server/express";
15
- import { Accepts } from "../../accepts";
15
+ import { Accepts, AcceptsScheme } from "../../accepts";
16
16
 
17
17
  export class ToolLoopAgentExecutor<TOOLS extends ToolSet = ToolSet> implements AgentExecutor {
18
18
  constructor(private agent: ToolLoopAgent<never, TOOLS>) {}
@@ -63,7 +63,7 @@ export class ToolLoopAgentExecutor<TOOLS extends ToolSet = ToolSet> implements A
63
63
  }
64
64
 
65
65
  export function getAgentCard(): AgentCard {
66
- const config = getAixyzConfig();
66
+ const config = getAixyzConfigRuntime();
67
67
  return {
68
68
  name: config.name,
69
69
  description: config.description,
@@ -88,7 +88,10 @@ export function useA2A<TOOLS extends ToolSet = ToolSet>(
88
88
  },
89
89
  taskStore: TaskStore = new InMemoryTaskStore(),
90
90
  ): void {
91
- if (!exports.accepts) {
91
+ if (exports.accepts) {
92
+ // TODO(@fuxingloh): validation should be done at build stage
93
+ AcceptsScheme.parse(exports.accepts);
94
+ } else {
92
95
  // TODO(@fuxingloh): right now we just don't register the agent if accepts is not provided,
93
96
  // but it might be a better idea to do it in aixyz-cli (aixyz-pack).
94
97
  return;
@@ -105,7 +108,7 @@ export function useA2A<TOOLS extends ToolSet = ToolSet>(
105
108
  );
106
109
 
107
110
  if (exports.accepts.scheme === "exact") {
108
- app.withX402("POST /agent", exports.accepts);
111
+ app.withX402Exact("POST /agent", exports.accepts);
109
112
  }
110
113
 
111
114
  app.express.use(
@@ -5,7 +5,7 @@ import express from "express";
5
5
  import type { IncomingMessage, ServerResponse } from "node:http";
6
6
  import { AixyzServer } from "../index";
7
7
  import { createPaymentWrapper } from "@x402/mcp";
8
- import { Accepts, AcceptsX402 } from "../../accepts";
8
+ import { Accepts, AcceptsScheme, AcceptsX402 } from "../../accepts";
9
9
 
10
10
  export class AixyzMCP {
11
11
  private registeredTools: Array<{
@@ -60,7 +60,10 @@ export class AixyzMCP {
60
60
  accepts?: Accepts;
61
61
  },
62
62
  ) {
63
- if (!exports.accepts) {
63
+ if (exports.accepts) {
64
+ // TODO(@fuxingloh): validation should be done at build stage
65
+ AcceptsScheme.parse(exports.accepts);
66
+ } else {
64
67
  // TODO(@fuxingloh): right now we just don't register the agent if accepts is not provided,
65
68
  // but it might be a better idea to do it in aixyz-cli (aixyz-pack).
66
69
  return;
package/server/index.ts CHANGED
@@ -58,7 +58,7 @@ export class AixyzServer extends x402ResourceServer {
58
58
 
59
59
  // TODO(@fuxingloh): add back x402 Bazaar compatibility
60
60
 
61
- private withAccepts(accepts: AcceptsX402) {
61
+ private withSchemeExact(accepts: AcceptsX402) {
62
62
  const schema = z.object({
63
63
  scheme: z.literal("exact"),
64
64
  price: z.string(),
@@ -73,12 +73,12 @@ export class AixyzServer extends x402ResourceServer {
73
73
  return schema.parse(accepts);
74
74
  }
75
75
 
76
- withX402(route: `${"GET" | "POST"} /${string}`, accepts: AcceptsX402) {
76
+ withX402Exact(route: `${"GET" | "POST"} /${string}`, accepts: AcceptsX402) {
77
77
  this.express.use(
78
78
  paymentMiddleware(
79
79
  {
80
80
  [route]: {
81
- accepts: this.withAccepts(accepts),
81
+ accepts: this.withSchemeExact(accepts),
82
82
  mimeType: "application/json",
83
83
  description: `A2A Payment: ${this.config.description}`,
84
84
  },
@@ -92,6 +92,6 @@ export class AixyzServer extends x402ResourceServer {
92
92
  }
93
93
 
94
94
  async withPaymentRequirements(accepts: AcceptsX402): Promise<PaymentRequirements[]> {
95
- return this.buildPaymentRequirements(this.withAccepts(accepts));
95
+ return this.buildPaymentRequirements(this.withSchemeExact(accepts));
96
96
  }
97
97
  }