@aigne/core 0.4.201-6 → 0.4.201-7

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.
@@ -1,47 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchemaToDataType = SchemaToDataType;
3
+ exports.schemaToDataType = schemaToDataType;
4
4
  const nanoid_1 = require("nanoid");
5
5
  const utils_1 = require("./utils");
6
- function SchemaToDataType(dataType) {
6
+ function schemaToDataType(dataType) {
7
7
  return utils_1.OrderedRecord.fromArray(Object.entries(dataType).map(([name, schema]) => {
8
+ const base = {
9
+ ...schema,
10
+ id: (0, nanoid_1.nanoid)(),
11
+ name,
12
+ };
8
13
  switch (schema.type) {
9
14
  case 'string':
10
15
  return {
11
- id: (0, nanoid_1.nanoid)(),
12
- name,
16
+ ...base,
13
17
  type: 'string',
14
- required: schema.required,
15
18
  };
16
19
  case 'number':
17
20
  return {
18
- id: (0, nanoid_1.nanoid)(),
19
- name,
21
+ ...base,
20
22
  type: 'number',
21
- required: schema.required,
22
23
  };
23
24
  case 'boolean':
24
25
  return {
25
- id: (0, nanoid_1.nanoid)(),
26
- name,
26
+ ...base,
27
27
  type: 'boolean',
28
- required: schema.required,
29
28
  };
30
29
  case 'object':
31
30
  return {
32
- id: (0, nanoid_1.nanoid)(),
33
- name,
31
+ ...base,
34
32
  type: 'object',
35
- required: schema.required,
36
- properties: SchemaToDataType(schema.properties),
33
+ properties: schemaToDataType(schema.properties),
37
34
  };
38
35
  case 'array':
39
36
  return {
40
- id: (0, nanoid_1.nanoid)(),
41
- name,
37
+ ...base,
42
38
  type: 'array',
43
- required: schema.required,
44
- items: SchemaToDataType({ items: schema.items })['items'],
39
+ items: utils_1.OrderedRecord.find(schemaToDataType({ items: schema.items }), (i) => i.name === 'items'),
45
40
  };
46
41
  default: {
47
42
  throw new Error(`Unknown data type: ${schema.type}`);
@@ -62,8 +62,8 @@ function createFunctionAgentDefinition(options) {
62
62
  id: options.id || options.name || (0, nanoid_1.nanoid)(),
63
63
  name: options.name,
64
64
  type: 'function_agent',
65
- inputs: (0, data_type_schema_1.SchemaToDataType)(options.inputs),
66
- outputs: (0, data_type_schema_1.SchemaToDataType)(options.outputs),
65
+ inputs: (0, data_type_schema_1.schemaToDataType)(options.inputs),
66
+ outputs: (0, data_type_schema_1.schemaToDataType)(options.outputs),
67
67
  language: options.language,
68
68
  code: options.code,
69
69
  };
@@ -117,8 +117,8 @@ function createLLMAgentDefinition(options) {
117
117
  id: options.id || options.name || (0, nanoid_1.nanoid)(),
118
118
  name: options.name,
119
119
  type: 'llm_agent',
120
- inputs: (0, data_type_schema_1.SchemaToDataType)(options.inputs),
121
- outputs: (0, data_type_schema_1.SchemaToDataType)(options.outputs),
120
+ inputs: (0, data_type_schema_1.schemaToDataType)(options.inputs),
121
+ outputs: (0, data_type_schema_1.schemaToDataType)(options.outputs),
122
122
  modelOptions: options.modelOptions,
123
123
  messages: ordered_map_1.OrderedRecord.fromArray(options.messages?.map((i) => ({
124
124
  id: (0, nanoid_1.nanoid)(),
@@ -58,8 +58,8 @@ exports.LocalFunctionAgent = LocalFunctionAgent = LocalFunctionAgent_1 = __decor
58
58
  __metadata("design:paramtypes", [Object, Object])
59
59
  ], LocalFunctionAgent);
60
60
  function createLocalFunctionAgentDefinition(options) {
61
- const inputs = (0, data_type_schema_1.SchemaToDataType)(options.inputs);
62
- const outputs = (0, data_type_schema_1.SchemaToDataType)(options.outputs);
61
+ const inputs = (0, data_type_schema_1.schemaToDataType)(options.inputs);
62
+ const outputs = (0, data_type_schema_1.schemaToDataType)(options.outputs);
63
63
  return {
64
64
  id: options.id || options.name || (0, nanoid_1.nanoid)(),
65
65
  name: options.name,
@@ -146,7 +146,7 @@ exports.PipelineAgent = PipelineAgent = PipelineAgent_1 = __decorate([
146
146
  __metadata("design:paramtypes", [Object, Object])
147
147
  ], PipelineAgent);
148
148
  function createPipelineAgentDefinition(options) {
149
- const inputs = (0, data_type_schema_1.SchemaToDataType)(options.inputs);
149
+ const inputs = (0, data_type_schema_1.schemaToDataType)(options.inputs);
150
150
  const processes = ordered_map_1.OrderedRecord.fromArray([]);
151
151
  for (const p of options.processes || []) {
152
152
  ordered_map_1.OrderedRecord.push(processes, {
@@ -177,7 +177,7 @@ function createPipelineAgentDefinition(options) {
177
177
  }).filter(is_non_nullable_1.isNonNullable)),
178
178
  });
179
179
  }
180
- const outputs = ordered_map_1.OrderedRecord.fromArray(ordered_map_1.OrderedRecord.map((0, data_type_schema_1.SchemaToDataType)(options.outputs), (output) => {
180
+ const outputs = ordered_map_1.OrderedRecord.fromArray(ordered_map_1.OrderedRecord.map((0, data_type_schema_1.schemaToDataType)(options.outputs), (output) => {
181
181
  const { fromVariable, fromVariablePropPath } = options.outputs[output.name];
182
182
  const from = ordered_map_1.OrderedRecord.find(inputs, (i) => i.name === fromVariable) ||
183
183
  ordered_map_1.OrderedRecord.find(processes, (p) => p.name === fromVariable);