Skip to content
English

Support:推荐用法的聚合入口 ​

Support 聚合推荐的构造、策略与同源配置生成;Core 运行不依赖这个命名空间。

最常见的导入是根入口的 Support 命名空间。已有清晰模块依赖时,也可从 /support、/support/model 或 /support/context 显式导入所需实现。它们是相同公开实现的不同导航入口,不是不同层次的执行器。

各个构造函数的输入、补全、策略与示例在相应条目展开;不需要先学完整个 Support 再运行 Agent。纯对象或类实现只要满足 Core 合同同样有效,Support 产物无需转成普通对象。

由简到繁的同业务示例 ​

通过聚合命名空间使用推荐实现 ​

入门 · Node.js

ts
import { Support } from '@jangts/agent-core';
const schema = Support.defineSchema({ jsonSchema: { type: 'string' },
  parse(value: unknown) { if (typeof value !== 'string') throw new TypeError('需要文本'); return value; },
});
console.log(schema.parse('你好'));
js
import { Support } from '@jangts/agent-core';
const schema = Support.defineSchema({ jsonSchema: { type: 'string' },
    parse(value) { if (typeof value !== 'string')
        throw new TypeError('需要文本'); return value; },
});
console.log(schema.parse('你好'));

只改变导入粒度,合同与调用不变 ​

配置 · Node.js

ts
import { defineSchema } from '@jangts/agent-core/support';
const schema = defineSchema({ jsonSchema: { type: 'string' },
  parse(value: unknown) { if (typeof value !== 'string') throw new TypeError('需要文本'); return value; },
});
console.log(schema.parse('你好'));
js
import { defineSchema } from '@jangts/agent-core/support';
const schema = defineSchema({ jsonSchema: { type: 'string' },
    parse(value) { if (typeof value !== 'string')
        throw new TypeError('需要文本'); return value; },
});
console.log(schema.parse('你好'));

接口参考、使用示例与开发指南。