@faapi/faapi 6.30.0 → 6.31.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 +76 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/{contextTypes-DhagvRH_.d.ts → contextTypes-BKQsSVMv.d.ts} +10 -1
- package/dist/index.d.ts +32 -19
- package/dist/index.js +83 -9
- package/dist/index.js.map +1 -1
- package/dist/{routeTypes-0rwuIws-.d.ts → routeTypes-Cc0P3CcU.d.ts} +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/workerEntry.d.ts +1 -1
- package/package.json +1 -1
|
@@ -130,6 +130,15 @@ interface AgentCore {
|
|
|
130
130
|
interface AgentMetadata extends AgentCore {
|
|
131
131
|
/** 源码相对路径(从 `pathMeta` 透传)——声明文件定位与清单可观测性用 */
|
|
132
132
|
filePath: string;
|
|
133
|
+
/**
|
|
134
|
+
* 派发入参 schema 声明(handler.ts 顶层 `interface Input` / `type Input` 检测)
|
|
135
|
+
*
|
|
136
|
+
* 声明时为 `'Input'`——[generateAgentArtifacts](../cli/generateAgentArtifacts.md)
|
|
137
|
+
* 据此生成 agent 的 zod.js,`@faapi/agent` 派发该 agent 时用富 JSON Schema 替代
|
|
138
|
+
* 默认单字段 `input` 交接单并在执行前校验;未声明为 `undefined`,派发行为不变
|
|
139
|
+
* (完全向后兼容)。DB-driven skill 无源文件,恒为 `undefined`。
|
|
140
|
+
*/
|
|
141
|
+
inputTypeName?: string;
|
|
133
142
|
}
|
|
134
143
|
/**
|
|
135
144
|
* 路径推导的 agent 元数据(由 [scanAgents](../agents/scanAgents.ts) 计算)
|
|
@@ -1159,4 +1168,4 @@ interface FaapiContext {
|
|
|
1159
1168
|
deleteCookie(name: string): void;
|
|
1160
1169
|
}
|
|
1161
1170
|
|
|
1162
|
-
export { type AppRegistries as A, type TaskDriverProcess as B, type CreateLoggerOptions as C, type TaskDriverRecord as D, type TaskFailedInfo as E, type FaapiContext as F, type TaskJob as G, type TaskJobStatus as H, type TaskMetadata as I, type TaskModule as J, type TaskRegistriesSnapshot as K, type LogConfig as L, type TaskRegistriesView as M, type ToolCore as N, type ToolPathMeta as O, type ToolRegistry as P, createAppRegistries as Q, createTaskRegistriesView as R, type SkillRegistry as S, type TaskClient as T, createTaskRegistry as U, type TaskFailedHandler as a, type TaskQueueDeps as b, type TaskQueue as c, type TaskDriver as d, type TaskRegistry as e, type TaskManifest as f, type
|
|
1171
|
+
export { type AppRegistries as A, type TaskDriverProcess as B, type CreateLoggerOptions as C, type TaskDriverRecord as D, type TaskFailedInfo as E, type FaapiContext as F, type TaskJob as G, type TaskJobStatus as H, type TaskMetadata as I, type TaskModule as J, type TaskRegistriesSnapshot as K, type LogConfig as L, type TaskRegistriesView as M, type ToolCore as N, type ToolPathMeta as O, type ToolRegistry as P, createAppRegistries as Q, createTaskRegistriesView as R, type SkillRegistry as S, type TaskClient as T, createTaskRegistry as U, type TaskFailedHandler as a, type TaskQueueDeps as b, type TaskQueue as c, type TaskDriver as d, type TaskRegistry as e, type TaskManifest as f, type AgentCore as g, type AgentMetadata as h, type ToolMetadata as i, type Logger as j, type AgentHandleFactory as k, type AgentHandleStore as l, type AgentPathMeta as m, type AgentRegistry as n, type AgentToolDescriptor as o, type FaapiContextConfig as p, type FaapiTaskMeta as q, type FailOptions as r, type LogEntry as s, type LogLevel as t, type LogSink as u, type SseEvent as v, type SseOptions as w, type SseWriter as x, type TaskContext as y, type TaskDriverJob as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as AppRegistries, F as FaapiContext, T as TaskClient, L as LogConfig, a as TaskFailedHandler, b as TaskQueueDeps, c as TaskQueue, d as TaskDriver, e as TaskRegistry, f as TaskManifest, g as
|
|
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 LogEntry, t as LogLevel, u as LogSink, S as SkillRegistry, v as SseEvent, w as SseOptions, x as SseWriter, y as TaskContext, z as TaskDriverJob, B as TaskDriverProcess, D as TaskDriverRecord, E as TaskFailedInfo, G as TaskJob, H as TaskJobStatus, I as TaskMetadata, J as TaskModule, K as TaskRegistriesSnapshot, M as TaskRegistriesView, N as ToolCore, O as ToolPathMeta, P as ToolRegistry, Q as createAppRegistries, R as createTaskRegistriesView, U as createTaskRegistry } from './contextTypes-
|
|
3
|
-
import { F as FaapiMiddleware, R as RouteManifest, C as CorsOptions, H as HelmetOptions, I as InjectorMap, W as WsRouteManifest } from './routeTypes-
|
|
4
|
-
export { a as Injector, b as RouteInfo, c as RouteInputSchema, d as RouteOutputSchema, e as RouteParamSchema, f as cors, h as helmet } from './routeTypes-
|
|
1
|
+
import { A as AppRegistries, F as FaapiContext, T as TaskClient, L as LogConfig, a as TaskFailedHandler, b as TaskQueueDeps, c as TaskQueue, d as TaskDriver, e as TaskRegistry, f as TaskManifest, g as AgentCore, h as AgentMetadata, i as ToolMetadata, C as CreateLoggerOptions, j as Logger } from './contextTypes-BKQsSVMv.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 LogEntry, t as LogLevel, u as LogSink, S as SkillRegistry, v as SseEvent, w as SseOptions, x as SseWriter, y as TaskContext, z as TaskDriverJob, B as TaskDriverProcess, D as TaskDriverRecord, E as TaskFailedInfo, G as TaskJob, H as TaskJobStatus, I as TaskMetadata, J as TaskModule, K as TaskRegistriesSnapshot, M as TaskRegistriesView, N as ToolCore, O as ToolPathMeta, P as ToolRegistry, Q as createAppRegistries, R as createTaskRegistriesView, U as createTaskRegistry } from './contextTypes-BKQsSVMv.js';
|
|
3
|
+
import { F as FaapiMiddleware, R as RouteManifest, C as CorsOptions, H as HelmetOptions, I as InjectorMap, W as WsRouteManifest } from './routeTypes-Cc0P3CcU.js';
|
|
4
|
+
export { a as Injector, b as RouteInfo, c as RouteInputSchema, d as RouteOutputSchema, e as RouteParamSchema, f as cors, h as helmet } from './routeTypes-Cc0P3CcU.js';
|
|
5
5
|
import * as node_http from 'node:http';
|
|
6
6
|
import { Server, IncomingMessage, ServerResponse } from 'node:http';
|
|
7
7
|
import { Socket } from 'node:net';
|
|
@@ -1299,31 +1299,44 @@ interface ToolSchemaModule {
|
|
|
1299
1299
|
* 计算 tool 的 zod.js 绝对路径(纯路径计算,无 fs 访问)
|
|
1300
1300
|
*
|
|
1301
1301
|
* 与 [loadToolSchema](./loadToolSchema.ts) 内部使用的路径逻辑同源(共享 `getDist()`),
|
|
1302
|
+
/**
|
|
1303
|
+
* zod.js 定位的最小来源结构——`ToolMetadata` 与 `AgentMetadata`(派发入参 schema
|
|
1304
|
+
* 声明场景)均满足,加载器无需感知来源差异
|
|
1305
|
+
*/
|
|
1306
|
+
interface SchemaSourceRef {
|
|
1307
|
+
/** 源码/产物相对路径(与 zod.js 同级,推导 zod.js 路径用) */
|
|
1308
|
+
filePath: string;
|
|
1309
|
+
/** schema 类型名(`undefined` = 无 schema 声明) */
|
|
1310
|
+
inputTypeName?: string;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* 计算 zod.js 的绝对路径(纯路径计算,无 fs 访问)
|
|
1314
|
+
*
|
|
1315
|
+
* 与 [loadToolSchema](./loadToolSchema.ts) 内部使用的路径逻辑同源(共享 `getDist()`),
|
|
1302
1316
|
* 供 `@faapi/agent` 的跨请求 schema 缓存用作缓存键 + mtime 校验目标。
|
|
1303
1317
|
*
|
|
1304
|
-
* @param
|
|
1305
|
-
* @param rootDir 项目根目录(`
|
|
1318
|
+
* @param ref schema 来源元数据(tool / agent 均可,含 `filePath`)
|
|
1319
|
+
* @param rootDir 项目根目录(`ref.filePath` 是相对路径时拼接)
|
|
1306
1320
|
*/
|
|
1307
|
-
declare function getToolSchemaPath(
|
|
1321
|
+
declare function getToolSchemaPath(ref: SchemaSourceRef, rootDir?: string): string;
|
|
1308
1322
|
/**
|
|
1309
|
-
* 动态加载
|
|
1323
|
+
* 动态加载 zod.js schema 模块(tool input 与 agent 派发入参共用)
|
|
1310
1324
|
*
|
|
1311
1325
|
* 与 [loadToolModule](./loadToolModule.md) 对称——一个加载 handler.js(tool 函数),
|
|
1312
|
-
* 一个加载 zod.js(tool
|
|
1326
|
+
* 一个加载 zod.js(schema 模块)。tool 的 zod.js 与 handler.js 同级;agent 声明
|
|
1327
|
+
* `Input` 时同样生成同级 zod.js(见 generateAgentArtifacts),同一加载器服务两类来源。
|
|
1313
1328
|
*
|
|
1314
1329
|
* 行为:
|
|
1315
|
-
* - `
|
|
1316
|
-
* - zod.js 文件不存在 → 返回 `undefined`(schema
|
|
1330
|
+
* - `ref.inputTypeName` 为 `undefined` → 返回 `undefined`(无 schema 声明)
|
|
1331
|
+
* - zod.js 文件不存在 → 返回 `undefined`(schema 缺失,调用方按各自语义处理——
|
|
1332
|
+
* tool 用自由 schema `{ type: 'object' }`;agent 派发入参在声明了 `inputTypeName`
|
|
1333
|
+
* 时视为产物异常,由 `@faapi/agent` 侧显式抛错)
|
|
1317
1334
|
* - import 失败 / 导出名不匹配 → 返回 `undefined`
|
|
1318
1335
|
*
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
* LLM 自由传参,handler 内部自行处理参数合法性。
|
|
1322
|
-
*
|
|
1323
|
-
* @param tool tool 元数据(含 `filePath` + `inputTypeName`)
|
|
1324
|
-
* @param rootDir 项目根目录(用于计算 zod.js 绝对路径,`tool.filePath` 是相对路径时拼接)
|
|
1336
|
+
* @param ref schema 来源元数据(tool / agent 均可,含 `filePath` + `inputTypeName`)
|
|
1337
|
+
* @param rootDir 项目根目录(用于计算 zod.js 绝对路径,`ref.filePath` 是相对路径时拼接)
|
|
1325
1338
|
*/
|
|
1326
|
-
declare function loadToolSchema(
|
|
1339
|
+
declare function loadToolSchema(ref: SchemaSourceRef, rootDir?: string): Promise<ToolSchemaModule | undefined>;
|
|
1327
1340
|
|
|
1328
1341
|
/**
|
|
1329
1342
|
* 按名查找单个 agent 的 LLM 可见元数据(默认实例)
|
|
@@ -1768,4 +1781,4 @@ type ProdApp = AppBase;
|
|
|
1768
1781
|
*/
|
|
1769
1782
|
declare function createProdApp(options?: CreateAppOptions): Promise<ProdApp>;
|
|
1770
1783
|
|
|
1771
|
-
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, LLM_TOOL_NAME_PATTERN, 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, SUB_AGENT_TOOL_PREFIX, 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, readResource, registerAgentHandleFactory, removeSkill, resolveAgentTools, resolveSubAgents, resolveTypeNode, scanTasks, subAgentToolName, upsertSkill };
|
|
1784
|
+
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, LLM_TOOL_NAME_PATTERN, 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, SUB_AGENT_TOOL_PREFIX, SchemaExtractionError, type SchemaSourceRef, 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, readResource, registerAgentHandleFactory, removeSkill, resolveAgentTools, resolveSubAgents, resolveTypeNode, scanTasks, subAgentToolName, upsertSkill };
|
package/dist/index.js
CHANGED
|
@@ -3926,18 +3926,18 @@ function getDist() {
|
|
|
3926
3926
|
}
|
|
3927
3927
|
return process.env.FAAPI_DIST ?? "dist";
|
|
3928
3928
|
}
|
|
3929
|
-
function getToolSchemaPath(
|
|
3929
|
+
function getToolSchemaPath(ref, rootDir) {
|
|
3930
3930
|
const dist = getDist();
|
|
3931
|
-
return getRuntimeSchemaPath(
|
|
3931
|
+
return getRuntimeSchemaPath(ref.filePath, dist, rootDir ?? process.cwd());
|
|
3932
3932
|
}
|
|
3933
|
-
async function loadToolSchema(
|
|
3934
|
-
if (!
|
|
3935
|
-
const schemaName = `${
|
|
3936
|
-
const zodPath = getToolSchemaPath(
|
|
3933
|
+
async function loadToolSchema(ref, rootDir) {
|
|
3934
|
+
if (!ref.inputTypeName) return void 0;
|
|
3935
|
+
const schemaName = `${ref.inputTypeName}Schema`;
|
|
3936
|
+
const zodPath = getToolSchemaPath(ref, rootDir);
|
|
3937
3937
|
if (!existsSync3(zodPath)) return void 0;
|
|
3938
3938
|
try {
|
|
3939
3939
|
const mod = await importWithCacheBust(zodPath, isDevOnDemandEnabled());
|
|
3940
|
-
const schema = mod[`${
|
|
3940
|
+
const schema = mod[`${ref.inputTypeName}Schema`];
|
|
3941
3941
|
if (!schema) return void 0;
|
|
3942
3942
|
return { schema, schemaName };
|
|
3943
3943
|
} catch {
|
|
@@ -6902,9 +6902,20 @@ function extractAgentMetadata(program, filePath, pathMeta) {
|
|
|
6902
6902
|
agents,
|
|
6903
6903
|
model,
|
|
6904
6904
|
maxTurns,
|
|
6905
|
-
inputDescription
|
|
6905
|
+
inputDescription,
|
|
6906
|
+
inputTypeName: findInputDeclaration(sourceFile) ? "Input" : void 0
|
|
6906
6907
|
};
|
|
6907
6908
|
}
|
|
6909
|
+
function findInputDeclaration(sourceFile) {
|
|
6910
|
+
let found = false;
|
|
6911
|
+
ts11.forEachChild(sourceFile, (node) => {
|
|
6912
|
+
if (found) return;
|
|
6913
|
+
if ((ts11.isInterfaceDeclaration(node) || ts11.isTypeAliasDeclaration(node)) && node.name.text === "Input") {
|
|
6914
|
+
found = true;
|
|
6915
|
+
}
|
|
6916
|
+
});
|
|
6917
|
+
return found;
|
|
6918
|
+
}
|
|
6908
6919
|
function findRunExportOwner(sourceFile) {
|
|
6909
6920
|
let result = null;
|
|
6910
6921
|
ts11.forEachChild(sourceFile, (node) => {
|
|
@@ -7111,6 +7122,9 @@ function extractStringArrayValue(expr) {
|
|
|
7111
7122
|
// src/cli/generateAgentArtifacts.ts
|
|
7112
7123
|
init_createProgram();
|
|
7113
7124
|
init_atomicWrite();
|
|
7125
|
+
init_extractHandlerTypes();
|
|
7126
|
+
init_generateZodSchema();
|
|
7127
|
+
init_generateZodArtifacts();
|
|
7114
7128
|
var AGENTS_FILE = "faapi-agents.js";
|
|
7115
7129
|
function serializeAgents(agents, dist = "dist") {
|
|
7116
7130
|
return agents.map((a) => ({
|
|
@@ -7123,6 +7137,7 @@ function serializeAgents(agents, dist = "dist") {
|
|
|
7123
7137
|
model: a.model,
|
|
7124
7138
|
maxTurns: a.maxTurns,
|
|
7125
7139
|
inputDescription: a.inputDescription,
|
|
7140
|
+
inputTypeName: a.inputTypeName,
|
|
7126
7141
|
filePath: toProdFilePath(a.filePath, dist)
|
|
7127
7142
|
}));
|
|
7128
7143
|
}
|
|
@@ -7143,7 +7158,8 @@ function hydrateAgents(manifest) {
|
|
|
7143
7158
|
agents: a.agents ?? void 0,
|
|
7144
7159
|
model: a.model ?? void 0,
|
|
7145
7160
|
maxTurns: a.maxTurns ?? void 0,
|
|
7146
|
-
inputDescription: a.inputDescription ?? void 0
|
|
7161
|
+
inputDescription: a.inputDescription ?? void 0,
|
|
7162
|
+
inputTypeName: a.inputTypeName ?? void 0
|
|
7147
7163
|
}));
|
|
7148
7164
|
}
|
|
7149
7165
|
function validateAgentList(metadata) {
|
|
@@ -7189,8 +7205,66 @@ async function generateAgentArtifacts(agents, rootDir, dist) {
|
|
|
7189
7205
|
const serialized = serializeAgents(metadata, dist);
|
|
7190
7206
|
const agentsPath = path24.resolve(rootDir, dist, AGENTS_FILE);
|
|
7191
7207
|
await writeAgentsModule(serialized, agentsPath);
|
|
7208
|
+
await generateAgentZodArtifacts(metadata, programByFile, rootDir, dist);
|
|
7192
7209
|
return metadata;
|
|
7193
7210
|
}
|
|
7211
|
+
async function generateAgentZodArtifacts(metadata, programByFile, rootDir, dist) {
|
|
7212
|
+
const declared = metadata.filter((a) => a.inputTypeName);
|
|
7213
|
+
if (declared.length === 0) return;
|
|
7214
|
+
const resolversByFile = /* @__PURE__ */ new Map();
|
|
7215
|
+
const sources = [];
|
|
7216
|
+
for (const agent of declared) {
|
|
7217
|
+
const absPath = path24.resolve(rootDir, agent.filePath);
|
|
7218
|
+
const program = programByFile.get(absPath);
|
|
7219
|
+
if (!program) {
|
|
7220
|
+
throw new Error(
|
|
7221
|
+
`agent "${agent.name}" \u6E90\u6587\u4EF6\u4E0D\u5728 Program \u4E2D: ${agent.filePath}\u2014\u2014\u65E0\u6CD5\u751F\u6210\u5165\u53C2 schema`
|
|
7222
|
+
);
|
|
7223
|
+
}
|
|
7224
|
+
if (!resolversByFile.has(absPath)) {
|
|
7225
|
+
resolversByFile.set(absPath, createLazyTypeResolver(program, absPath));
|
|
7226
|
+
}
|
|
7227
|
+
const typeInfo = extractTypeInfo(program, absPath, agent.inputTypeName);
|
|
7228
|
+
sources.push({
|
|
7229
|
+
name: agent.name,
|
|
7230
|
+
filePath: absPath,
|
|
7231
|
+
schemaName: agent.inputTypeName,
|
|
7232
|
+
typeInfo
|
|
7233
|
+
});
|
|
7234
|
+
}
|
|
7235
|
+
await generateZodArtifacts(sources, {
|
|
7236
|
+
generateFileSource: generateAgentSchemaFileSource,
|
|
7237
|
+
resolversByFile,
|
|
7238
|
+
rootDir,
|
|
7239
|
+
dist
|
|
7240
|
+
});
|
|
7241
|
+
}
|
|
7242
|
+
function generateAgentSchemaFileSource(sources, resolveType, helpersImportPath) {
|
|
7243
|
+
const lines = ["import { z } from 'zod';"];
|
|
7244
|
+
const schemaBlocks = [];
|
|
7245
|
+
for (const source of sources) {
|
|
7246
|
+
if (!source.typeInfo) continue;
|
|
7247
|
+
const block = [`// agent ${source.name} \u2192 ${source.schemaName}`];
|
|
7248
|
+
const schemaCode = generateZodSchemaSource(
|
|
7249
|
+
source.typeInfo,
|
|
7250
|
+
resolveType,
|
|
7251
|
+
source.schemaName,
|
|
7252
|
+
false
|
|
7253
|
+
).replace(/^import \{ z \} from 'zod';\s*\n\s*\n/, "");
|
|
7254
|
+
block.push(schemaCode);
|
|
7255
|
+
block.push("");
|
|
7256
|
+
schemaBlocks.push(block.join("\n"));
|
|
7257
|
+
}
|
|
7258
|
+
const allSchemaCode = schemaBlocks.join("\n");
|
|
7259
|
+
if (helpersImportPath && usesCoerceHelpers(allSchemaCode)) {
|
|
7260
|
+
lines.push(
|
|
7261
|
+
`import { coerceNumber, coerceBoolean, coerceMap, coerceSet } from '${helpersImportPath}';`
|
|
7262
|
+
);
|
|
7263
|
+
}
|
|
7264
|
+
lines.push("");
|
|
7265
|
+
lines.push(...schemaBlocks);
|
|
7266
|
+
return lines.join("\n").replace(/\n+$/, "\n");
|
|
7267
|
+
}
|
|
7194
7268
|
|
|
7195
7269
|
// src/cli/generateTaskArtifacts.ts
|
|
7196
7270
|
init_generateZodArtifacts();
|