edgeone 1.6.28 → 1.6.30

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/README.md CHANGED
@@ -210,6 +210,92 @@ edgeone makers env rm ENV_VAR_KEY
210
210
 
211
211
  ```
212
212
 
213
+ ## 5. Project Configuration
214
+
215
+ The CLI reads your project config from the project root, in priority order:
216
+
217
+ 1. `edgeone.config.ts` — TypeScript programmatic config (recommended, requires CLI ≥ 1.7.0)
218
+ 2. `edgeone.json` / `edgeone.json5` — JSON config
219
+
220
+ If `edgeone.config.ts` coexists with a JSON config, the TS file takes precedence (a warning is printed).
221
+
222
+ ### edgeone.config.ts
223
+
224
+ ```ts
225
+ import { defineConfig } from '@edgeone/types/config';
226
+
227
+ export default defineConfig({
228
+ outputDirectory: 'dist',
229
+ buildCommand: 'npm run build',
230
+ installCommand: 'npm install',
231
+ nodeVersion: '20',
232
+ schedules: [{ name: 'tick', cron: '*/5 * * * *', path: '/api/cron/tick' }],
233
+ });
234
+ ```
235
+
236
+ Install the package (devDependency) to get type checking / IDE completion:
237
+
238
+ ```bash
239
+ npm install -D @edgeone/types
240
+ ```
241
+
242
+ TypeScript configs are transpiled with esbuild at load time; the exported default
243
+ object (or named `config` export) is used. The CLI is **self-contained** for config
244
+ handling — the schema and `@edgeone/types/config` code ship inside the CLI binary,
245
+ so you do NOT need `@edgeone/types` installed to *run* `edgeone compile/validate/schema`.
246
+ Install it only for editor type support / your own TS usage.
247
+
248
+ ### Function handler types
249
+
250
+ For typed `onRequest` handlers (cloud/node functions, agents, edge functions), use
251
+ `@edgeone/types` (the `@vercel/node` equivalent):
252
+
253
+ ```ts
254
+ import type { AgentHandler } from '@edgeone/types';
255
+
256
+ export const onRequest: AgentHandler = async (context) => {
257
+ await context.store.appendMessage({
258
+ conversationId: context.conversation_id,
259
+ role: 'user',
260
+ content: 'hello',
261
+ });
262
+ return new Response('ok');
263
+ };
264
+ ```
265
+
266
+ `@edgeone/types` exports `CloudFunctionContext` / `AgentContext` / `EdgeFunctionContext`
267
+ plus `CloudFunctionHandler` / `AgentHandler` / `EdgeFunctionHandler` / `EdgeMiddlewareHandler`.
268
+ Config types live under the `@edgeone/types/config` subpath.
269
+
270
+ ### Config commands
271
+
272
+ ```bash
273
+ # Compile edgeone.config.ts to edgeone.json
274
+ edgeone compile
275
+
276
+ # Validate the current config (prints warnings/errors, exit code 1 on errors)
277
+ edgeone validate
278
+
279
+ # Write edgeone.schema.json into the project for IDE validation of edgeone.json
280
+ edgeone schema
281
+ ```
282
+
283
+ To enable IDE validation for `edgeone.json`, add the `$schema` field. This is now added
284
+ **automatically** when the CLI generates the config (`edgeone init`, `edgeone compile`),
285
+ pointing at the hosted schema URL:
286
+
287
+ ```json
288
+ {
289
+ "$schema": "https://cdnstatic.tencentcs.com/edgeone/pages/docs/edgeone.schema.json",
290
+ "outputDirectory": "dist"
291
+ }
292
+ ```
293
+
294
+ Run `edgeone schema` to also register a VS Code `json.schemas` association
295
+ (`.vscode/settings.json`) so **manually created** `edgeone.json` files get hints without a
296
+ `$schema` field. For offline use, reference the schema shipped with `@edgeone/types`
297
+ (`node_modules/@edgeone/types/edgeone.schema.json`).
298
+
213
299
  ## References
214
300
 
215
301
  [Makers Introduction](https://pages.edgeone.ai/document/product-introduction) | [Makers Functions](https://pages.edgeone.ai/document/pages-functions-overview)