@faapi/faapi 6.23.0 → 6.24.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/cli/index.js +364 -333
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +13 -51
- package/dist/index.js +118 -127
- package/dist/index.js.map +1 -1
- package/dist/{routeTypes-CJV5M90s.d.ts → routeTypes-D1swYDVC.d.ts} +41 -19
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FaapiMiddleware, A as AppRegistries, R as RouteManifest, a as FaapiContext, C as CorsOptions, T as TaskClient, H as HelmetOptions, L as LogConfig, I as InjectorMap, b as TaskFailedHandler, W as WsRouteManifest, c as TaskQueueDeps, d as TaskQueue, e as TaskDriver, f as TaskRegistry, g as TaskManifest, h as ToolMetadata, i as AgentCore, j as AgentMetadata, k as CreateLoggerOptions, l as Logger } from './routeTypes-
|
|
2
|
-
export { m as AgentHandleFactory, n as AgentHandleStore, o as AgentPathMeta, p as AgentRegistry, q as AgentToolDescriptor, r as FaapiContextConfig, s as FaapiTaskMeta, t as FailOptions, u as Injector, v as LogEntry, w as LogLevel, x as LogSink, y as RouteInfo, z as RouteInputSchema, B as RouteOutputSchema, D as RouteParamSchema, S as SkillRegistry, E as SseEvent, G as SseOptions, 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 } from './routeTypes-
|
|
1
|
+
import { F as FaapiMiddleware, A as AppRegistries, R as RouteManifest, a as FaapiContext, C as CorsOptions, T as TaskClient, H as HelmetOptions, L as LogConfig, I as InjectorMap, b as TaskFailedHandler, W as WsRouteManifest, c as TaskQueueDeps, d as TaskQueue, e as TaskDriver, f as TaskRegistry, g as TaskManifest, h as ToolMetadata, i as AgentCore, j as AgentMetadata, k as CreateLoggerOptions, l as Logger } from './routeTypes-D1swYDVC.js';
|
|
2
|
+
export { m as AgentHandleFactory, n as AgentHandleStore, o as AgentPathMeta, p as AgentRegistry, q as AgentToolDescriptor, r as FaapiContextConfig, s as FaapiTaskMeta, t as FailOptions, u as Injector, v as LogEntry, w as LogLevel, x as LogSink, y as RouteInfo, z as RouteInputSchema, B as RouteOutputSchema, D as RouteParamSchema, S as SkillRegistry, E as SseEvent, G as SseOptions, 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 } from './routeTypes-D1swYDVC.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';
|
|
@@ -48,6 +48,14 @@ type UpgradeHandler = (req: IncomingMessage, socket: Socket, head: Buffer) => vo
|
|
|
48
48
|
interface PluginContext {
|
|
49
49
|
/** 项目根目录 */
|
|
50
50
|
rootDir: string;
|
|
51
|
+
/**
|
|
52
|
+
* 产物 resources 目录绝对路径(`<rootDir>/<dist>/resources`)
|
|
53
|
+
*
|
|
54
|
+
* `src/resources/` 经 dev/build 复制进产物后的位置——插件 setup 时读静态
|
|
55
|
+
* 资源用;`@faapi/agent` 插件据此注入 AgentDeps(agent config 的
|
|
56
|
+
* systemPromptFile 相对此目录解析)。
|
|
57
|
+
*/
|
|
58
|
+
resourcesDir: string;
|
|
51
59
|
/** app 级注册表(tool/agent/skill/agentHandle 实例,随 app 生命周期) */
|
|
52
60
|
registries: AppRegistries;
|
|
53
61
|
/** 当前路由清单(setup 时的快照,reloadRoutes 后不会更新;需最新路由用 getRoutes()) */
|
|
@@ -1258,52 +1266,6 @@ declare const TASK_PATTERNS: string[];
|
|
|
1258
1266
|
*/
|
|
1259
1267
|
declare function scanTasks(rootDir: string, patterns: string[]): Promise<TaskManifest[]>;
|
|
1260
1268
|
|
|
1261
|
-
/**
|
|
1262
|
-
* 加载后的 agent 模块
|
|
1263
|
-
*
|
|
1264
|
-
* 与 [ToolModule](./loadToolModule.md) 对称——agent 的代码本体只有可选的 `run` 函数
|
|
1265
|
-
* (自定义 agent 运行逻辑,替代默认 reactLoop)。
|
|
1266
|
-
*
|
|
1267
|
-
* > `config` 字段已移除——`AgentMetadata` 已含 AST 提取的字面量字段
|
|
1268
|
-
* > (systemPrompt / tools / agents / model / maxTurns),`AgentModule.config`
|
|
1269
|
-
* > 原本用于运行时拿到完整 config 对象(含动态字段),但 `executeSubAgent`
|
|
1270
|
-
* > 拿到 `mod.config` 后从不读取(run 函数在自己模块内直接引用 config 变量),
|
|
1271
|
-
* > 属于死链路,故移除。
|
|
1272
|
-
*
|
|
1273
|
-
* `AgentMetadata`(从 `faapi-agents.js` 水合)已含字面量字段,本模块仅用于
|
|
1274
|
-
* 在运行时拿到 `run` 函数引用。
|
|
1275
|
-
*/
|
|
1276
|
-
interface AgentModule {
|
|
1277
|
-
/**
|
|
1278
|
-
* 自定义 agent 运行函数(可选)
|
|
1279
|
-
*
|
|
1280
|
-
* `hasRun` 为 true 时一定为 function;为 false 时为 `undefined`。
|
|
1281
|
-
* 调用方式由 `@faapi/agent` 子包的 Agent 类定义(Phase 3.x)。
|
|
1282
|
-
*/
|
|
1283
|
-
run: ((...args: unknown[]) => unknown) | undefined;
|
|
1284
|
-
}
|
|
1285
|
-
/**
|
|
1286
|
-
* 动态 import agent handler 文件并提取 `run` 导出
|
|
1287
|
-
*
|
|
1288
|
-
* Dev 按需编译模式(Vite 风格):先 `ensureCompiled` 确保产物存在再 import,
|
|
1289
|
-
* 避免 import 不存在的文件污染 Vite SSR 内部状态(详见 [loadRouteModule](./loadRouteModule.md))。
|
|
1290
|
-
* Prod 模式:产物在 build 阶段已固化,直接 import,失败即报错。
|
|
1291
|
-
*
|
|
1292
|
-
* 与 [loadToolModule](./loadToolModule.md) 的差异:
|
|
1293
|
-
* - tool 按 `functionName` 提取单个函数(校验为 function)
|
|
1294
|
-
* - agent 只提取 `run`(函数,可选)——config 块字段已在 AST 阶段提取为字面量,
|
|
1295
|
-
* 运行时无需再加载 config 对象
|
|
1296
|
-
*
|
|
1297
|
-
* 错误传递:
|
|
1298
|
-
* - 编译失败 → 抛 "Failed to compile agent module"
|
|
1299
|
-
* - import 失败 → 抛 "Failed to load agent module"
|
|
1300
|
-
*
|
|
1301
|
-
* @param filePath agent handler 文件的绝对路径(产物形式,如 `dist/agents/researcher/handler.js`)
|
|
1302
|
-
* @param hasRun 是否应提取 run 导出(来自 `AgentMetadata.hasRun`)
|
|
1303
|
-
* @param rootDir 项目根目录(按需编译模式用,可选)
|
|
1304
|
-
*/
|
|
1305
|
-
declare function loadAgentModule(filePath: string, hasRun: boolean, rootDir?: string): Promise<AgentModule>;
|
|
1306
|
-
|
|
1307
1269
|
/**
|
|
1308
1270
|
* 加载后的 tool 模块
|
|
1309
1271
|
*
|
|
@@ -1382,14 +1344,14 @@ declare function loadToolSchema(tool: ToolMetadata, rootDir?: string): Promise<T
|
|
|
1382
1344
|
/**
|
|
1383
1345
|
* 按名查找单个 agent 的 LLM 可见元数据(默认实例)
|
|
1384
1346
|
*
|
|
1385
|
-
* 返回 [AgentCore](../ast/extractAgentMetadata.md)(不含 filePath
|
|
1347
|
+
* 返回 [AgentCore](../ast/extractAgentMetadata.md)(不含 filePath)。
|
|
1386
1348
|
* 加载 handler.js 执行 `run` 函数请用 [getAgentEntry](#getAgentEntry)。
|
|
1387
1349
|
*
|
|
1388
1350
|
* @param name agent 名(如 `researcher`,含 `@agent` 覆盖值)
|
|
1389
1351
|
*/
|
|
1390
1352
|
declare function getAgent(name: string): AgentCore | undefined;
|
|
1391
1353
|
/**
|
|
1392
|
-
* 按名查找单个 agent 的完整元数据(默认实例,含 filePath
|
|
1354
|
+
* 按名查找单个 agent 的完整元数据(默认实例,含 filePath)
|
|
1393
1355
|
*/
|
|
1394
1356
|
declare function getAgentEntry(name: string): AgentMetadata | undefined;
|
|
1395
1357
|
/**
|
|
@@ -1790,4 +1752,4 @@ type ProdApp = AppBase;
|
|
|
1790
1752
|
*/
|
|
1791
1753
|
declare function createProdApp(options?: CreateAppOptions): Promise<ProdApp>;
|
|
1792
1754
|
|
|
1793
|
-
export { type AgentConfig, AgentCore, AgentMetadata, type
|
|
1755
|
+
export { type AgentConfig, AgentCore, AgentMetadata, 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, type 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, flushLogging, getAgent, getAgentEntry, getApp, getInputTypeForMethod, getSkill, getTool, getToolSchemaPath, hydrateSkillRegistry, invalidateProgramCache, listSkills, loadConfig, loadEnv, loadTaskDriver, loadToolModule, loadToolSchema, logger, registerAgentHandleFactory, removeSkill, resolveAgentTools, resolveSubAgents, resolveTypeNode, scanTasks, upsertSkill };
|