@faapi/faapi 6.7.0 → 6.9.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AppRegistries, R as RouteManifest, F as FaapiContext, C as CorsOptions, T as TaskClient, H as HelmetOptions, L as LoggerOptions, a as FaapiMiddleware, I as InjectorMap, b as TaskFailedHandler, c as TaskQueueDeps, d as TaskQueue, e as TaskDriver, f as TaskRegistry, g as TaskManifest, h as ToolMetadata, i as AgentCore, j as AgentMetadata, W as WsRouteManifest } from './routeTypes-CsL7xtqu.js';
2
- export { k as AgentHandleFactory, l as AgentHandleStore, m as AgentPathMeta, n as AgentRegistry, o as AgentToolDescriptor, p as FaapiContextConfig, q as FaapiTaskMeta, r as FailOptions, s as Injector, t as RouteInfo, u as RouteInputSchema, v as RouteOutputSchema, w as RouteParamSchema, S as SkillRegistry, x as SseEvent, y as SseWriter, z as TaskContext, B as TaskDriverJob, D as TaskDriverProcess, E as TaskDriverRecord, G as TaskFailedInfo, J as TaskJob, K as TaskJobStatus, M as TaskMetadata, N as TaskModule, O as TaskRegistriesSnapshot, P as TaskRegistriesView, Q as ToolCore, U as ToolPathMeta, V as ToolRegistry, X as cors, Y as createAppRegistries, Z as createTaskRegistriesView, _ as createTaskRegistry, $ as helmet, a0 as logger } from './routeTypes-CsL7xtqu.js';
1
+ import { A as AppRegistries, R as RouteManifest, F as FaapiContext, C as CorsOptions, T as TaskClient, H as HelmetOptions, L as LoggerOptions, a as LogConfig, b as FaapiMiddleware, I as InjectorMap, c as TaskFailedHandler, d as TaskQueueDeps, e as TaskQueue, f as TaskDriver, g as TaskRegistry, h as TaskManifest, i as ToolMetadata, j as AgentCore, k as AgentMetadata, l as CreateLoggerOptions, m as Logger, W as WsRouteManifest } from './routeTypes-CuGMDCGB.js';
2
+ export { n as AgentHandleFactory, o as AgentHandleStore, p as AgentPathMeta, q as AgentRegistry, r as AgentToolDescriptor, s as FaapiContextConfig, t as FaapiTaskMeta, u as FailOptions, v as Injector, w as LogEntry, x as LogLevel, y as LogSink, z as RouteInfo, B as RouteInputSchema, D as RouteOutputSchema, E as RouteParamSchema, S as SkillRegistry, G as SseEvent, J as SseWriter, K as TaskContext, M as TaskDriverJob, N as TaskDriverProcess, O as TaskDriverRecord, P as TaskFailedInfo, Q as TaskJob, U as TaskJobStatus, V as TaskMetadata, X as TaskModule, Y as TaskRegistriesSnapshot, Z as TaskRegistriesView, _ as ToolCore, $ as ToolPathMeta, a0 as ToolRegistry, a1 as cors, a2 as createAppRegistries, a3 as createTaskRegistriesView, a4 as createTaskRegistry, a5 as helmet, a6 as logger } from './routeTypes-CuGMDCGB.js';
3
3
  import * as node_http from 'node:http';
4
4
  import { Server, IncomingMessage, ServerResponse } from 'node:http';
5
5
  import { Socket } from 'node:net';
@@ -552,6 +552,32 @@ interface FaapiConfig {
552
552
  bodyLimit?: number;
553
553
  /** 日志中间件配置 */
554
554
  logger?: LoggerOptions | boolean;
555
+ /**
556
+ * 业务日志器全局配置(详见 logger/logger.md)
557
+ *
558
+ * - `false`:完全静默(含 error,测试降噪;不影响请求日志,关闭用 `logger: false`)
559
+ * - `true` / 缺省:默认级别(显式 level > LOG_LEVEL env > 'info')+ console 文本输出
560
+ * - `LogConfig`:精细配置——`sink` 自定义管道(接 pino/winston)或 `dir` egg 风格
561
+ * 文件输出(app.log 全量 + error.log 仅 error,splitByLevel 按级别四文件),
562
+ * 两者互斥;`dir` 模式请求日志自动并入(`accessLog` 缺省 true),未显式配置
563
+ * level 时不过滤(全量落盘)
564
+ *
565
+ * 生效范围:`ctx.log` / 参数注入 `log` / `createLogger` / `taskCtx.log`,
566
+ * `dir`/`accessLog` 模式下含请求日志中间件。
567
+ * 日志全局配置是进程级资源,多 app 同进程时后启动覆盖先启动。
568
+ *
569
+ * ```ts
570
+ * export default {
571
+ * log: {
572
+ * // 方式一:egg 风格文件输出(请求日志自动并入)
573
+ * dir: 'logs',
574
+ * // 方式二:自定义管道接管
575
+ * // sink: (entry) => pinoLogger[entry.level]({ scope: entry.scope, ...entry.fields }, entry.message),
576
+ * },
577
+ * } satisfies FaapiConfig;
578
+ * ```
579
+ */
580
+ log?: LogConfig | boolean;
555
581
  /** HTTP/2 配置,false 禁用(默认 http/1.1) */
556
582
  http2?: Http2Options | boolean;
557
583
  /**
@@ -1466,6 +1492,27 @@ declare function loadConfig(rootDir: string, dist: string): Promise<Partial<Faap
1466
1492
  */
1467
1493
  declare function loadEnv(rootDir: string): void;
1468
1494
 
1495
+ /**
1496
+ * 设置全局日志配置(进程级,`createAppBase` 启动时以 `config.log` 调用)
1497
+ *
1498
+ * - `false`:完全静默(含 error,测试降噪场景)
1499
+ * - `true` / `{}`:默认级别(显式 level > LOG_LEVEL env > 模式默认)+ 默认 console sink
1500
+ * - `{ level, sink }`:自定义管道接管(与 dir 互斥,同时配置抛错)
1501
+ * - `{ dir, splitByLevel?, stdout?, accessLog? }`:egg 风格文件输出(fileSink.md)
1502
+ * - `undefined`:重置为默认(编程式多 app 切换全局配置用)
1503
+ *
1504
+ * LOG_LEVEL env 仅在本函数读取——app 启动路径必经此处(env 非法在启动期报错);
1505
+ * 纯编程式不调本函数时 env 不生效。
1506
+ */
1507
+ declare function configureLogging(config?: LogConfig | boolean | undefined): void;
1508
+ /**
1509
+ * 创建日志器
1510
+ *
1511
+ * @param scope 分类标签(如 'db'、'http'),默认无分类
1512
+ * @param options 实例级覆盖(level/sink/构造 fields)
1513
+ */
1514
+ declare function createLogger(scope?: string, options?: CreateLoggerOptions): Logger;
1515
+
1469
1516
  declare const VALIDATION_ERROR = "VALIDATION_ERROR";
1470
1517
  declare const ROUTE_NOT_FOUND = "ROUTE_NOT_FOUND";
1471
1518
  declare const METHOD_NOT_ALLOWED = "METHOD_NOT_ALLOWED";
@@ -1666,4 +1713,4 @@ type ProdApp = AppBase;
1666
1713
  */
1667
1714
  declare function createProdApp(options?: CreateAppOptions): Promise<ProdApp>;
1668
1715
 
1669
- export { type AgentConfig, AgentCore, AgentMetadata, type AgentModule, type ProdApp as App, AppRegistries, CorsOptions, type CreateAppOptions, type CronScheduler, type DevApp, type FaapiConfig, FaapiContext, FaapiError, FaapiMiddleware, type FaapiPlugin, type HandlerTypeInfo, HelmetOptions, type InjectOptions, type InjectResponse, InjectorMap, InternalError, type LifecycleContext, type LifecycleHooks, type LlmConfig, type LlmModelConfig, LoggerOptions, MethodNotAllowedError, ModuleLoadError, type PluginContext, type PluginDeclaration, type ProdApp, type PropertyType, type RequestHandler, type ResponseConfig, RouteManifest, RouteNotFoundError, type RouteSchemaSource, type RuntimeType, SchemaExtractionError, TASK_PATTERNS, type TaskBullMqOptions, TaskClient, type TaskConfig, TaskDriver, TaskFailedHandler, TaskManifest, type TaskPgBossOptions, TaskQueue, TaskRegistry, ToolMetadata, type ToolModule, type ToolSchemaModule, type TypeConstraint, type UpgradeHandler, ValidationError, type ValidationErrorCode, type ValidationIssue, type WsContext, type WsEventHandlers, type WsHandler, type WsSocket, clearAgentHandleFactory, collectRouteSchemaSources, createProdApp as createApp, createCronScheduler, createDevApp, createProdApp, createProgram, createPrograms, createTaskQueue, extractTypeInfo, getAgent, getAgentEntry, getApp, getInputTypeForMethod, getSkill, getTool, getToolSchemaPath, hydrateSkillRegistry, invalidateProgramCache, listSkills, loadAgentModule, loadConfig, loadEnv, loadTaskDriver, loadToolModule, loadToolSchema, registerAgentHandleFactory, removeSkill, resolveAgentTools, resolveSubAgents, resolveTypeNode, scanTasks, upsertSkill };
1716
+ export { type AgentConfig, AgentCore, AgentMetadata, type AgentModule, type ProdApp as App, AppRegistries, CorsOptions, type CreateAppOptions, CreateLoggerOptions, type CronScheduler, type DevApp, type FaapiConfig, FaapiContext, FaapiError, FaapiMiddleware, type FaapiPlugin, type HandlerTypeInfo, HelmetOptions, type InjectOptions, type InjectResponse, InjectorMap, InternalError, type LifecycleContext, type LifecycleHooks, type LlmConfig, type LlmModelConfig, LogConfig, Logger, LoggerOptions, MethodNotAllowedError, ModuleLoadError, type PluginContext, type PluginDeclaration, type ProdApp, type PropertyType, type RequestHandler, type ResponseConfig, RouteManifest, RouteNotFoundError, type RouteSchemaSource, type RuntimeType, SchemaExtractionError, TASK_PATTERNS, type TaskBullMqOptions, TaskClient, type TaskConfig, TaskDriver, TaskFailedHandler, TaskManifest, type TaskPgBossOptions, TaskQueue, TaskRegistry, ToolMetadata, type ToolModule, type ToolSchemaModule, type TypeConstraint, type UpgradeHandler, ValidationError, type ValidationErrorCode, type ValidationIssue, type WsContext, type WsEventHandlers, type WsHandler, type WsSocket, clearAgentHandleFactory, collectRouteSchemaSources, configureLogging, createProdApp as createApp, createCronScheduler, createDevApp, createLogger, createProdApp, createProgram, createPrograms, createTaskQueue, extractTypeInfo, getAgent, getAgentEntry, getApp, getInputTypeForMethod, getSkill, getTool, getToolSchemaPath, hydrateSkillRegistry, invalidateProgramCache, listSkills, loadAgentModule, loadConfig, loadEnv, loadTaskDriver, loadToolModule, loadToolSchema, registerAgentHandleFactory, removeSkill, resolveAgentTools, resolveSubAgents, resolveTypeNode, scanTasks, upsertSkill };