Skip to content
English

Support ​

SUPPORT · namespace · 运行时值

导入 ​

ts
import { Support } from '@jangts/agent-core';
js
import { Support } from '@jangts/agent-core';

其他公开入口:@jangts/agent-core、@jangts/agent-core/types。

定义 ​

命名空间: 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('你好'));

相关定义 ​

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