@aixyz/config 0.1.2 → 0.2.4
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/index.ts +72 -19
- package/package.json +2 -3
package/index.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { resolve } from "path";
|
|
2
|
-
import { loadEnvConfig } from "@next/env";
|
|
3
2
|
|
|
4
3
|
import { z } from "zod";
|
|
5
4
|
|
|
6
5
|
export type Network = `${string}:${string}`;
|
|
7
6
|
|
|
8
7
|
export type AixyzConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the agent will be used in the agent card.
|
|
10
|
+
*/
|
|
9
11
|
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* A short description of the agent.
|
|
14
|
+
* This will be used in the agent card.
|
|
15
|
+
*/
|
|
10
16
|
description: string;
|
|
11
17
|
/**
|
|
12
18
|
* Version of the agent.
|
|
13
19
|
*/
|
|
14
20
|
version: string;
|
|
21
|
+
/**
|
|
22
|
+
* The URL of the agent, required for canonical urls.
|
|
23
|
+
* Defaults to `process.env.VERCEL_URL` for Vercel deployments.
|
|
24
|
+
*/
|
|
15
25
|
url?: string;
|
|
16
26
|
x402: {
|
|
17
27
|
/**
|
|
@@ -25,7 +35,16 @@ export type AixyzConfig = {
|
|
|
25
35
|
*/
|
|
26
36
|
network: string;
|
|
27
37
|
};
|
|
28
|
-
|
|
38
|
+
build?: {
|
|
39
|
+
/**
|
|
40
|
+
* Output format for `aixyz build`.
|
|
41
|
+
* - `"standalone"`: Bundles into a single executable file (default).
|
|
42
|
+
* - `"vercel"`: Generates Vercel Build Output API v3 structure.
|
|
43
|
+
* Overrides the `VERCEL=1` environment variable, but is overridden by the `--output` CLI flag.
|
|
44
|
+
*/
|
|
45
|
+
output?: "standalone" | "vercel";
|
|
46
|
+
};
|
|
47
|
+
skills?: InferredAixyzConfig["skills"];
|
|
29
48
|
};
|
|
30
49
|
|
|
31
50
|
const NetworkSchema = z.custom<Network>((val) => {
|
|
@@ -58,26 +77,43 @@ const AixyzConfigSchema = z.object({
|
|
|
58
77
|
payTo: z.string(),
|
|
59
78
|
network: NetworkSchema,
|
|
60
79
|
}),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
build: z
|
|
81
|
+
.object({
|
|
82
|
+
output: z.enum(["standalone", "vercel"]).optional(),
|
|
83
|
+
})
|
|
84
|
+
.optional(),
|
|
85
|
+
skills: z
|
|
86
|
+
.array(
|
|
87
|
+
z.object({
|
|
88
|
+
id: z.string().nonempty(),
|
|
89
|
+
name: z.string().nonempty(),
|
|
90
|
+
description: z.string().nonempty(),
|
|
91
|
+
tags: z.array(z.string()),
|
|
92
|
+
examples: z.array(z.string()).optional(),
|
|
93
|
+
inputModes: z.array(z.string()).optional(),
|
|
94
|
+
outputModes: z.array(z.string()).optional(),
|
|
95
|
+
security: z.array(z.record(z.string(), z.array(z.string()))).optional(),
|
|
96
|
+
}),
|
|
97
|
+
)
|
|
98
|
+
.default([]),
|
|
73
99
|
});
|
|
74
100
|
|
|
101
|
+
type InferredAixyzConfig = z.infer<typeof AixyzConfigSchema>;
|
|
102
|
+
|
|
75
103
|
/**
|
|
104
|
+
* Subset of `AixyzConfig` that is expose and materialized at runtime.
|
|
105
|
+
*
|
|
76
106
|
* This is the materialized config object that is cached for performance.
|
|
77
107
|
* It is the result of parsing and validating the user's `aixyz.config.ts` file,
|
|
78
108
|
* with environment variables loaded and applied.
|
|
79
109
|
*/
|
|
80
|
-
export type
|
|
110
|
+
export type AixyzConfigRuntime = {
|
|
111
|
+
name: AixyzConfig["name"];
|
|
112
|
+
description: AixyzConfig["description"];
|
|
113
|
+
version: AixyzConfig["version"];
|
|
114
|
+
url: AixyzConfig["url"];
|
|
115
|
+
skills: NonNullable<AixyzConfig["skills"]>;
|
|
116
|
+
};
|
|
81
117
|
|
|
82
118
|
/**
|
|
83
119
|
* Environment variables are looked up in the following places, in order, stopping once the variable is found.
|
|
@@ -92,11 +128,12 @@ export type GetAixyzConfig = z.infer<typeof AixyzConfigSchema>;
|
|
|
92
128
|
*
|
|
93
129
|
* In production:
|
|
94
130
|
* This is a materialized config object that is cached for performance.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated Use `getAixyzConfigRuntime()` instead, which is designed for runtime use.
|
|
133
|
+
* This will be deprecated in the next major version—when we materialize the config for downstream.
|
|
95
134
|
*/
|
|
96
|
-
export function getAixyzConfig():
|
|
135
|
+
export function getAixyzConfig(): InferredAixyzConfig {
|
|
97
136
|
const cwd = process.cwd();
|
|
98
|
-
loadEnvConfig(cwd);
|
|
99
|
-
|
|
100
137
|
const configPath = resolve(cwd, "aixyz.config.ts");
|
|
101
138
|
const mod = require(configPath);
|
|
102
139
|
const config = mod.default;
|
|
@@ -110,5 +147,21 @@ export function getAixyzConfig(): GetAixyzConfig {
|
|
|
110
147
|
throw new Error(`aixyz.config.ts: ${parsedConfig.error}`);
|
|
111
148
|
}
|
|
112
149
|
|
|
113
|
-
return parsedConfig.data as
|
|
150
|
+
return parsedConfig.data as InferredAixyzConfig;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns the subset of `aixyz.config.ts` that is safe to expose at runtime.
|
|
155
|
+
* Unlike `getAixyzConfig()`, which is intended for the build/CLI phase only,
|
|
156
|
+
* this function is designed to be available in the deployed runtime bundle.
|
|
157
|
+
*/
|
|
158
|
+
export function getAixyzConfigRuntime(): AixyzConfigRuntime {
|
|
159
|
+
const config = getAixyzConfig();
|
|
160
|
+
return {
|
|
161
|
+
name: config.name,
|
|
162
|
+
description: config.description,
|
|
163
|
+
version: config.version,
|
|
164
|
+
url: config.url,
|
|
165
|
+
skills: config.skills,
|
|
166
|
+
};
|
|
114
167
|
}
|
package/package.json
CHANGED