@aigne/core 0.4.211-beta.2 → 1.0.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.
Files changed (99) hide show
  1. package/lib/cjs/agent.js +18 -11
  2. package/lib/cjs/constants.js +5 -5
  3. package/lib/cjs/definitions/data-type-schema.js +12 -11
  4. package/lib/cjs/definitions/memory.js +3 -1
  5. package/lib/cjs/function-agent.js +5 -6
  6. package/lib/cjs/function-runner.js +13 -13
  7. package/lib/cjs/llm-agent.js +16 -15
  8. package/lib/cjs/llm-decision-agent.js +15 -13
  9. package/lib/cjs/llm-model.js +11 -11
  10. package/lib/cjs/local-function-agent.js +3 -3
  11. package/lib/cjs/memorable.js +3 -3
  12. package/lib/cjs/open-api-agent.js +4 -4
  13. package/lib/cjs/pipeline-agent.js +26 -17
  14. package/lib/cjs/runnable.js +2 -2
  15. package/lib/cjs/utils/fetch-open-api.js +9 -8
  16. package/lib/cjs/utils/fetch.js +3 -2
  17. package/lib/cjs/utils/is-non-nullable.js +1 -4
  18. package/lib/cjs/utils/message-utils.js +23 -16
  19. package/lib/cjs/utils/mustache-utils.js +2 -5
  20. package/lib/cjs/utils/open-api-parameter.js +19 -22
  21. package/lib/cjs/utils/stream-utils.js +6 -5
  22. package/lib/cjs/utils/structured-output-schema.js +10 -9
  23. package/lib/esm/agent.js +20 -10
  24. package/lib/esm/constants.js +5 -5
  25. package/lib/esm/definitions/data-type-schema.js +14 -13
  26. package/lib/esm/definitions/memory.js +5 -3
  27. package/lib/esm/function-agent.js +11 -12
  28. package/lib/esm/function-runner.js +15 -15
  29. package/lib/esm/index.js +18 -18
  30. package/lib/esm/llm-agent.js +26 -25
  31. package/lib/esm/llm-decision-agent.js +22 -20
  32. package/lib/esm/llm-model.js +13 -13
  33. package/lib/esm/local-function-agent.js +9 -9
  34. package/lib/esm/memorable.js +6 -6
  35. package/lib/esm/open-api-agent.js +11 -11
  36. package/lib/esm/pipeline-agent.js +35 -23
  37. package/lib/esm/runnable.js +3 -3
  38. package/lib/esm/utils/fetch-open-api.js +11 -9
  39. package/lib/esm/utils/fetch.js +3 -2
  40. package/lib/esm/utils/index.js +10 -10
  41. package/lib/esm/utils/is-non-nullable.js +1 -1
  42. package/lib/esm/utils/message-utils.js +26 -16
  43. package/lib/esm/utils/mustache-utils.js +2 -2
  44. package/lib/esm/utils/open-api-parameter.js +21 -21
  45. package/lib/esm/utils/stream-utils.js +7 -6
  46. package/lib/esm/utils/structured-output-schema.js +12 -8
  47. package/lib/types/agent.d.ts +3 -3
  48. package/lib/types/context.d.ts +2 -2
  49. package/lib/types/definitions/data-type-schema.d.ts +14 -14
  50. package/lib/types/definitions/data-type.d.ts +8 -8
  51. package/lib/types/definitions/memory.d.ts +5 -5
  52. package/lib/types/definitions/open-api.d.ts +9 -9
  53. package/lib/types/function-agent.d.ts +9 -9
  54. package/lib/types/function-runner.d.ts +4 -4
  55. package/lib/types/index.d.ts +18 -18
  56. package/lib/types/llm-agent.d.ts +12 -12
  57. package/lib/types/llm-decision-agent.d.ts +20 -20
  58. package/lib/types/llm-model.d.ts +12 -12
  59. package/lib/types/local-function-agent.d.ts +14 -16
  60. package/lib/types/memorable.d.ts +51 -51
  61. package/lib/types/open-api-agent.d.ts +12 -12
  62. package/lib/types/pipeline-agent.d.ts +14 -14
  63. package/lib/types/runnable.d.ts +5 -5
  64. package/lib/types/utils/fetch-open-api.d.ts +2 -2
  65. package/lib/types/utils/index.d.ts +10 -10
  66. package/lib/types/utils/message-utils.d.ts +4 -4
  67. package/lib/types/utils/open-api-parameter.d.ts +3 -3
  68. package/lib/types/utils/runnable-type.d.ts +1 -1
  69. package/lib/types/utils/stream-utils.d.ts +1 -1
  70. package/lib/types/utils/structured-output-schema.d.ts +2 -2
  71. package/package.json +11 -10
  72. package/tsconfig.json +3 -1
  73. package/lib/cjs/api-agent.js +0 -70
  74. package/lib/cjs/data-type-schema.js +0 -46
  75. package/lib/cjs/data-type.js +0 -2
  76. package/lib/cjs/definitions/api-parameter.js +0 -10
  77. package/lib/cjs/memory.js +0 -32
  78. package/lib/cjs/tsconfig.tsbuildinfo +0 -1
  79. package/lib/cjs/utils/fetch-api.js +0 -35
  80. package/lib/cjs/utils/flatten-openapi.js +0 -14
  81. package/lib/cjs/utils/format-parameter.js +0 -126
  82. package/lib/esm/api-agent.js +0 -67
  83. package/lib/esm/data-type-schema.js +0 -43
  84. package/lib/esm/data-type.js +0 -1
  85. package/lib/esm/definitions/api-parameter.js +0 -7
  86. package/lib/esm/memory.js +0 -27
  87. package/lib/esm/tsconfig.tsbuildinfo +0 -1
  88. package/lib/esm/utils/fetch-api.js +0 -31
  89. package/lib/esm/utils/flatten-openapi.js +0 -11
  90. package/lib/esm/utils/format-parameter.js +0 -116
  91. package/lib/types/api-agent.d.ts +0 -53
  92. package/lib/types/data-type-schema.d.ts +0 -46
  93. package/lib/types/data-type.d.ts +0 -32
  94. package/lib/types/definitions/api-parameter.d.ts +0 -55
  95. package/lib/types/memory.d.ts +0 -184
  96. package/lib/types/tsconfig.tsbuildinfo +0 -1
  97. package/lib/types/utils/fetch-api.d.ts +0 -3
  98. package/lib/types/utils/flatten-openapi.d.ts +0 -25
  99. package/lib/types/utils/format-parameter.d.ts +0 -6
@@ -1,4 +1,4 @@
1
- import isNil from 'lodash/isNil';
1
+ import isNil from "lodash/isNil";
2
2
  export function isNonNullable(value) {
3
3
  return !isNil(value);
4
4
  }
@@ -1,21 +1,29 @@
1
- import omit from 'lodash/omit';
2
- import { isNonNullable } from './is-non-nullable';
3
- import { renderMessage } from './mustache-utils';
4
- import { OrderedRecord } from './ordered-map';
1
+ import omit from "lodash/omit";
2
+ import { isNonNullable } from "./is-non-nullable";
3
+ import { renderMessage } from "./mustache-utils";
4
+ import { OrderedRecord } from "./ordered-map";
5
5
  export function mergeHistoryMessages(messages, history) {
6
- const firstUserMessageIndex = messages.findIndex((m) => m.role === 'user');
6
+ const firstUserMessageIndex = messages.findIndex((m) => m.role === "user");
7
7
  if (firstUserMessageIndex >= 0) {
8
- return [...messages.slice(0, firstUserMessageIndex), ...history, ...messages.slice(firstUserMessageIndex)];
8
+ return [
9
+ ...messages.slice(0, firstUserMessageIndex),
10
+ ...history,
11
+ ...messages.slice(firstUserMessageIndex),
12
+ ];
9
13
  }
10
14
  return [...history, ...messages];
11
15
  }
12
16
  export function memoriesToMessages(memories, { primaryMemoryName } = {}) {
13
17
  const primary = (primaryMemoryName && memories[primaryMemoryName]) || [];
14
- const otherMemories = primaryMemoryName ? omit(memories, primaryMemoryName) : memories;
18
+ const otherMemories = primaryMemoryName
19
+ ? omit(memories, primaryMemoryName)
20
+ : memories;
15
21
  const primaryMemory = primary
16
22
  .map((i) => {
17
- const content = renderMessage('{{memory}}', { memory: i.memory }).trim();
18
- const role = ['user', 'assistant'].includes(i.metadata.role) ? i.metadata.role : undefined;
23
+ const content = renderMessage("{{memory}}", { memory: i.memory }).trim();
24
+ const role = ["user", "assistant"].includes(i.metadata.role)
25
+ ? i.metadata.role
26
+ : undefined;
19
27
  if (!role || !content)
20
28
  return null;
21
29
  return { role, content };
@@ -23,10 +31,10 @@ export function memoriesToMessages(memories, { primaryMemoryName } = {}) {
23
31
  .filter(isNonNullable);
24
32
  const memory = Object.values(otherMemories)
25
33
  .map((i) => i
26
- .map((j) => renderMessage('{{memory}}\n{{metadata}}', j).trim() || null)
34
+ .map((j) => renderMessage("{{memory}}\n{{metadata}}", j).trim() || null)
27
35
  .filter(isNonNullable)
28
- .join('\n'))
29
- .join('\n');
36
+ .join("\n"))
37
+ .join("\n");
30
38
  return {
31
39
  primaryMemory,
32
40
  memory,
@@ -36,10 +44,12 @@ export function prepareMessages(definition, input, memories) {
36
44
  const variables = { ...input, ...memories };
37
45
  const originalMessages = OrderedRecord.toArray(definition.messages).map(({ role, content }) => ({
38
46
  role,
39
- content: typeof content === 'string' ? renderMessage(content, variables) : content,
47
+ content: typeof content === "string"
48
+ ? renderMessage(content, variables)
49
+ : content,
40
50
  }));
41
51
  if (!originalMessages.length)
42
- throw new Error('Messages are required');
52
+ throw new Error("Messages are required");
43
53
  const { primaryMemory, memory } = memoriesToMessages(memories, {
44
54
  primaryMemoryName: OrderedRecord.find(definition.memories, (i) => i.id === definition.primaryMemoryId)?.name,
45
55
  });
@@ -47,13 +57,13 @@ export function prepareMessages(definition, input, memories) {
47
57
  // Add memory to a system message
48
58
  if (memory) {
49
59
  const message = {
50
- role: 'system',
60
+ role: "system",
51
61
  content: `\
52
62
  Here are the memories about the user:
53
63
  ${memory}
54
64
  `,
55
65
  };
56
- const lastSystemMessageIndex = messagesWithMemory.findLastIndex((i) => i.role === 'assistant');
66
+ const lastSystemMessageIndex = messagesWithMemory.findLastIndex((i) => i.role === "assistant");
57
67
  messagesWithMemory.splice(lastSystemMessageIndex + 1, 0, message);
58
68
  }
59
69
  // Add primary memory to messages
@@ -1,8 +1,8 @@
1
- import Mustache from 'mustache';
1
+ import Mustache from "mustache";
2
2
  export function renderMessage(template, variables) {
3
3
  return Mustache.render(template, variables, undefined, {
4
4
  escape: (v) => {
5
- return typeof v === 'object' ? JSON.stringify(v) : v;
5
+ return typeof v === "object" ? JSON.stringify(v) : v;
6
6
  },
7
7
  });
8
8
  }
@@ -1,11 +1,11 @@
1
- import { isEmpty, omitBy } from 'lodash';
2
- import logger from '../logger';
3
- import { OrderedRecord } from './ordered-map';
1
+ import { isEmpty, omitBy } from "lodash";
2
+ import logger from "../logger";
3
+ import { OrderedRecord } from "./ordered-map";
4
4
  export async function formatOpenAPIRequest(api, inputs, input) {
5
5
  const { url, method, ...inputParams } = processParameters(api, inputs, input);
6
- logger.debug('inputParams', inputParams);
6
+ logger.debug("inputParams", inputParams);
7
7
  const authParams = await getAuthParams(api.auth);
8
- logger.debug('authParams', authParams);
8
+ logger.debug("authParams", authParams);
9
9
  return {
10
10
  url,
11
11
  method,
@@ -20,18 +20,18 @@ export async function formatOpenAPIRequest(api, inputs, input) {
20
20
  async function getAuthParams(auth) {
21
21
  if (!auth)
22
22
  return {};
23
- if (auth.type === 'custom') {
23
+ if (auth.type === "custom") {
24
24
  return await auth.getValue();
25
25
  }
26
26
  const { type, key, token } = auth;
27
27
  switch (auth.in) {
28
- case 'query':
29
- return { query: { [key || 'token']: token } };
30
- case 'cookie':
31
- return { cookies: { [key || 'token']: token } };
28
+ case "query":
29
+ return { query: { [key || "token"]: token } };
30
+ case "cookie":
31
+ return { cookies: { [key || "token"]: token } };
32
32
  default: {
33
- const prefix = type === 'bearer' ? 'Bearer ' : type === 'basic' ? 'Basic ' : '';
34
- return { headers: { [key || 'Authorization']: `${prefix}${token}` } };
33
+ const prefix = type === "bearer" ? "Bearer " : type === "basic" ? "Basic " : "";
34
+ return { headers: { [key || "Authorization"]: `${prefix}${token}` } };
35
35
  }
36
36
  }
37
37
  }
@@ -44,35 +44,35 @@ function processParameters(api, inputs, input) {
44
44
  cookies: {},
45
45
  body: {},
46
46
  };
47
- Object.entries(input).forEach(([key, value]) => {
47
+ for (const [key, value] of Object.entries(input)) {
48
48
  const schema = OrderedRecord.find(inputs, (x) => x.name === key);
49
49
  if (!schema)
50
- return;
50
+ continue;
51
51
  switch (schema.in) {
52
- case 'query':
52
+ case "query":
53
53
  result.query[key] = value;
54
54
  break;
55
- case 'header':
55
+ case "header":
56
56
  result.headers[key] = value;
57
57
  break;
58
- case 'cookie':
58
+ case "cookie":
59
59
  result.cookies[key] = value;
60
60
  break;
61
- case 'body':
61
+ case "body":
62
62
  result.body[key] = value;
63
63
  break;
64
- case 'path':
64
+ case "path":
65
65
  result.url = result.url.replace(`{${key}}`, String(value));
66
66
  break;
67
67
  default:
68
68
  // 没有指定 in 的情况
69
- if (result.method.toLowerCase() === 'get') {
69
+ if (result.method.toLowerCase() === "get") {
70
70
  result.query[key] = value;
71
71
  }
72
72
  else {
73
73
  result.body[key] = value;
74
74
  }
75
75
  }
76
- });
76
+ }
77
77
  return result;
78
78
  }
@@ -1,4 +1,4 @@
1
- import { isRunnableResponseDelta } from '../runnable';
1
+ import { isRunnableResponseDelta, } from "../runnable";
2
2
  export function objectToRunnableResponseStream(obj) {
3
3
  return new ReadableStream({
4
4
  start(controller) {
@@ -8,11 +8,11 @@ export function objectToRunnableResponseStream(obj) {
8
8
  });
9
9
  }
10
10
  export async function runnableResponseStreamToObject(stream) {
11
- let $text = '';
11
+ let $text = "";
12
12
  const result = {};
13
13
  for await (const value of stream) {
14
14
  if (isRunnableResponseDelta(value)) {
15
- $text += value.$text || '';
15
+ $text += value.$text || "";
16
16
  Object.assign(result, value.delta);
17
17
  }
18
18
  }
@@ -28,16 +28,17 @@ export async function runnableResponseStreamToObject(stream) {
28
28
  * @returns The runnable output stream or object
29
29
  */
30
30
  export async function extractOutputsFromRunnableOutput(output, resolve) {
31
- if (output instanceof ReadableStream || isAsyncGenerator(output)) {
31
+ if (output instanceof ReadableStream ||
32
+ isAsyncGenerator(output)) {
32
33
  return new ReadableStream({
33
34
  async start(controller) {
34
35
  try {
35
36
  const result = {};
36
- let $text = '';
37
+ let $text = "";
37
38
  for await (const value of output) {
38
39
  if (isRunnableResponseDelta(value)) {
39
40
  controller.enqueue(value);
40
- $text += value.$text || '';
41
+ $text += value.$text || "";
41
42
  Object.assign(result, value.delta);
42
43
  }
43
44
  }
@@ -1,9 +1,9 @@
1
- import omitBy from 'lodash/omitBy';
2
- import { isNonNullable } from './is-non-nullable';
3
- import { OrderedRecord } from './ordered-map';
1
+ import omitBy from "lodash/omitBy";
2
+ import { isNonNullable } from "./is-non-nullable";
3
+ import { OrderedRecord } from "./ordered-map";
4
4
  export function outputsToJsonSchema(outputs) {
5
5
  const outputToSchema = (output) => {
6
- const properties = output.type === 'object' && output.properties?.$indexes.length
6
+ const properties = output.type === "object" && output.properties?.$indexes.length
7
7
  ? OrderedRecord.map(output.properties, (property) => {
8
8
  if (!property.name)
9
9
  return null;
@@ -19,15 +19,19 @@ export function outputsToJsonSchema(outputs) {
19
19
  properties: properties?.length
20
20
  ? Object.fromEntries(properties.map((p) => [p.property.name, p.schema]))
21
21
  : undefined,
22
- items: output.type === 'array' && output.items ? outputToSchema(output.items) : undefined,
23
- additionalProperties: output.type === 'object' ? false : undefined,
22
+ items: output.type === "array" && output.items
23
+ ? outputToSchema(output.items)
24
+ : undefined,
25
+ additionalProperties: output.type === "object" ? false : undefined,
24
26
  required: properties?.length
25
- ? properties.filter((i) => i.property.required).map((i) => i.property.name)
27
+ ? properties
28
+ .filter((i) => i.property.required)
29
+ .map((i) => i.property.name)
26
30
  : undefined,
27
31
  }, (v) => v === undefined);
28
32
  };
29
33
  return outputToSchema({
30
- type: 'object',
34
+ type: "object",
31
35
  properties: outputs,
32
36
  });
33
37
  }
@@ -1,6 +1,6 @@
1
- import { Context, ContextState } from './context';
2
- import { MemoryItemWithScore, MemoryMessage } from './memorable';
3
- import { RunOptions, Runnable, RunnableResponse, RunnableResponseChunk, RunnableResponseStream } from './runnable';
1
+ import type { Context, ContextState } from "./context";
2
+ import type { MemoryItemWithScore, MemoryMessage } from "./memorable";
3
+ import { type RunOptions, Runnable, type RunnableResponse, type RunnableResponseChunk, type RunnableResponseStream } from "./runnable";
4
4
  export interface AgentProcessOptions<Memories extends {
5
5
  [name: string]: MemoryItemWithScore[];
6
6
  }> {
@@ -1,5 +1,5 @@
1
- import type { LLMModelConfiguration } from './llm-model';
2
- import { Runnable, RunnableDefinition } from './runnable';
1
+ import type { LLMModelConfiguration } from "./llm-model";
2
+ import type { Runnable, RunnableDefinition } from "./runnable";
3
3
  export interface ContextState {
4
4
  userId?: string;
5
5
  sessionId?: string;
@@ -1,6 +1,6 @@
1
- import { MakeNullablePropertyOptional } from '../utils/nullable';
2
- import { OrderedRecord } from '../utils/ordered-map';
3
- import { DataType } from './data-type';
1
+ import type { MakeNullablePropertyOptional } from "../utils/nullable";
2
+ import { OrderedRecord } from "../utils/ordered-map";
3
+ import type { DataType } from "./data-type";
4
4
  export declare function schemaToDataType(dataType: {
5
5
  [name: string]: DataTypeSchema;
6
6
  }): OrderedRecord<DataType>;
@@ -10,32 +10,32 @@ export interface DataTypeSchemaBase {
10
10
  required?: boolean;
11
11
  }
12
12
  export interface DataTypeSchemaString extends DataTypeSchemaBase {
13
- type: 'string';
13
+ type: "string";
14
14
  }
15
15
  export interface DataTypeSchemaNumber extends DataTypeSchemaBase {
16
- type: 'number';
16
+ type: "number";
17
17
  }
18
18
  export interface DataTypeSchemaBoolean extends DataTypeSchemaBase {
19
- type: 'boolean';
19
+ type: "boolean";
20
20
  }
21
21
  export interface DataTypeSchemaObject extends DataTypeSchemaBase {
22
- type: 'object';
22
+ type: "object";
23
23
  properties?: {
24
24
  [key: string]: DataTypeSchema;
25
25
  };
26
26
  }
27
27
  export interface DataTypeSchemaArray extends DataTypeSchemaBase {
28
- type: 'array';
28
+ type: "array";
29
29
  items?: DataTypeSchema;
30
30
  }
31
31
  type SchemaTypeInner<T extends DataTypeSchema> = T extends DataTypeSchemaString ? string : T extends DataTypeSchemaNumber ? number : T extends DataTypeSchemaBoolean ? boolean : T extends DataTypeSchemaObject ? MakeNullablePropertyOptional<{
32
- [K in keyof T['properties']]: SchemaType<NonNullable<T['properties']>[K]>;
33
- }> : T extends DataTypeSchemaArray ? T['items'] extends null | undefined ? SchemaType<{
34
- type: 'object';
35
- }>[] : SchemaType<NonNullable<T['items']>>[] : never;
36
- export type SchemaType<T extends DataTypeSchema> = T['required'] extends true ? SchemaTypeInner<T> : SchemaTypeInner<T> | undefined | null;
32
+ [K in keyof T["properties"]]: SchemaType<NonNullable<T["properties"]>[K]>;
33
+ }> : T extends DataTypeSchemaArray ? T["items"] extends null | undefined ? SchemaType<{
34
+ type: "object";
35
+ }>[] : SchemaType<NonNullable<T["items"]>>[] : never;
36
+ export type SchemaType<T extends DataTypeSchema> = T["required"] extends true ? SchemaTypeInner<T> : SchemaTypeInner<T> | undefined | null;
37
37
  export type SchemaMapType<T extends Record<string, DataTypeSchema>> = SchemaType<{
38
- type: 'object';
38
+ type: "object";
39
39
  required: true;
40
40
  properties: T;
41
41
  }>;
@@ -1,5 +1,5 @@
1
- import { OmitPropsFromUnion } from '../utils/omit';
2
- import { OrderedRecord } from '../utils/ordered-map';
1
+ import type { OmitPropsFromUnion } from "../utils/omit";
2
+ import type { OrderedRecord } from "../utils/ordered-map";
3
3
  export type DataType = DataTypeString | DataTypeNumber | DataTypeBoolean | DataTypeObject | DataTypeArray;
4
4
  export interface DataTypeBase {
5
5
  id: string;
@@ -8,25 +8,25 @@ export interface DataTypeBase {
8
8
  required?: boolean;
9
9
  }
10
10
  export interface DataTypeString extends DataTypeBase {
11
- type: 'string';
11
+ type: "string";
12
12
  defaultValue?: string;
13
13
  multiline?: boolean;
14
14
  }
15
15
  export interface DataTypeNumber extends DataTypeBase {
16
- type: 'number';
16
+ type: "number";
17
17
  defaultValue?: number;
18
18
  }
19
19
  export interface DataTypeBoolean extends DataTypeBase {
20
- type: 'boolean';
20
+ type: "boolean";
21
21
  defaultValue?: boolean;
22
22
  }
23
23
  export interface DataTypeObject extends DataTypeBase {
24
- type: 'object';
24
+ type: "object";
25
25
  defaultValue?: object;
26
26
  properties?: OrderedRecord<DataType>;
27
27
  }
28
28
  export interface DataTypeArray extends DataTypeBase {
29
- type: 'array';
29
+ type: "array";
30
30
  defaultValue?: object[];
31
- items?: OmitPropsFromUnion<DataType, 'id'>;
31
+ items?: OmitPropsFromUnion<DataType, "id">;
32
32
  }
@@ -1,7 +1,7 @@
1
- import { Memorable } from '../memorable';
2
- import { RunnableInput, RunnableMemory } from '../runnable';
3
- import { OrderedRecord } from '../utils';
4
- import { DataTypeSchema } from './data-type-schema';
1
+ import type { Memorable } from "../memorable";
2
+ import type { RunnableInput, RunnableMemory } from "../runnable";
3
+ import { OrderedRecord } from "../utils";
4
+ import type { DataTypeSchema } from "./data-type-schema";
5
5
  export interface CreateRunnableMemory<I extends {
6
6
  [key: string]: DataTypeSchema;
7
7
  } = {}> {
@@ -22,7 +22,7 @@ export interface CreateRunnableMemory<I extends {
22
22
  * Variable name from input used to query memory.
23
23
  */
24
24
  fromVariable?: keyof {
25
- [key in keyof I as I[key]['type'] extends 'string' ? key : never]: any;
25
+ [key in keyof I as I[key]["type"] extends "string" ? key : never]: any;
26
26
  };
27
27
  };
28
28
  /**
@@ -1,24 +1,24 @@
1
- import type { DataType } from './data-type';
2
- import type { DataTypeSchema } from './data-type-schema';
1
+ import type { DataType } from "./data-type";
2
+ import type { DataTypeSchema } from "./data-type-schema";
3
3
  export interface BaseAuthConfig {
4
- type: 'bearer' | 'basic';
4
+ type: "bearer" | "basic";
5
5
  token: string;
6
- in?: 'header' | 'query' | 'cookie';
6
+ in?: "header" | "query" | "cookie";
7
7
  /**
8
8
  * The key to use for the token. Default `Authorization` in header and `token` in query and cookie.
9
9
  */
10
10
  key?: string;
11
11
  }
12
12
  export interface CustomAuthConfig {
13
- type: 'custom';
13
+ type: "custom";
14
14
  getValue: () => Promise<AuthResult> | AuthResult;
15
15
  }
16
16
  export type AuthConfig = BaseAuthConfig | CustomAuthConfig;
17
- export type AuthType = AuthConfig['type'];
18
- export type AuthResult = Pick<FetchRequest, 'headers' | 'query' | 'cookies'>;
19
- type HTTPMethodLowercase = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options';
17
+ export type AuthType = AuthConfig["type"];
18
+ export type AuthResult = Pick<FetchRequest, "headers" | "query" | "cookies">;
19
+ type HTTPMethodLowercase = "get" | "post" | "put" | "delete" | "patch" | "head" | "options";
20
20
  export type HTTPMethod = Uppercase<HTTPMethodLowercase> | Lowercase<HTTPMethodLowercase>;
21
- export type ParameterLocation = 'path' | 'query' | 'body' | 'header' | 'cookie';
21
+ export type ParameterLocation = "path" | "query" | "body" | "header" | "cookie";
22
22
  export type OpenAPIDataType = DataType & {
23
23
  in?: ParameterLocation;
24
24
  };
@@ -1,10 +1,10 @@
1
- import { Agent, AgentProcessOptions } from './agent';
2
- import type { Context, ContextState } from './context';
3
- import { DataTypeSchema, SchemaMapType } from './definitions/data-type-schema';
4
- import { CreateRunnableMemory } from './definitions/memory';
5
- import { FunctionRunner } from './function-runner';
6
- import { MemorableSearchOutput, MemoryItemWithScore } from './memorable';
7
- import { RunnableDefinition } from './runnable';
1
+ import { Agent, type AgentProcessOptions } from "./agent";
2
+ import type { Context, ContextState } from "./context";
3
+ import { type DataTypeSchema, type SchemaMapType } from "./definitions/data-type-schema";
4
+ import { type CreateRunnableMemory } from "./definitions/memory";
5
+ import type { FunctionRunner } from "./function-runner";
6
+ import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
7
+ import type { RunnableDefinition } from "./runnable";
8
8
  export declare class FunctionAgent<I extends {
9
9
  [name: string]: any;
10
10
  } = {}, O extends {
@@ -40,10 +40,10 @@ export declare function create<I extends {
40
40
  }, Memories extends {
41
41
  [name: string]: CreateRunnableMemory<I>;
42
42
  }, State extends ContextState>({ context, ...options }: CreateFunctionAgentOptions<I, O, Memories, State>): FunctionAgent<SchemaMapType<I>, SchemaMapType<O>, {
43
- [name in keyof Memories]: MemorableSearchOutput<Memories[name]['memory']>;
43
+ [name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
44
44
  }, State>;
45
45
  export interface FunctionAgentDefinition extends RunnableDefinition {
46
- type: 'function_agent';
46
+ type: "function_agent";
47
47
  language?: string;
48
48
  code?: string;
49
49
  }
@@ -1,6 +1,6 @@
1
- import { Agent } from './agent';
2
- import { Context, ContextState } from './context';
3
- import { MemoryItemWithScore } from './memorable';
1
+ import { Agent } from "./agent";
2
+ import type { Context, ContextState } from "./context";
3
+ import type { MemoryItemWithScore } from "./memorable";
4
4
  export interface FunctionRunnerInput<I extends {
5
5
  [name: string]: any;
6
6
  } = {}, Memories extends {
@@ -11,7 +11,7 @@ export interface FunctionRunnerInput<I extends {
11
11
  code: string;
12
12
  input: I;
13
13
  memories: Memories;
14
- context: Pick<Context<State>, 'state'>;
14
+ context: Pick<Context<State>, "state">;
15
15
  }
16
16
  export type FunctionRunnerOutput<O> = O;
17
17
  export declare abstract class FunctionRunner<I extends {
@@ -1,18 +1,18 @@
1
- export * from './utils';
2
- export * from './constants';
3
- export * from './definitions/data-type';
4
- export * from './definitions/data-type-schema';
5
- export * from './definitions/open-api';
6
- export * from './definitions/memory';
7
- export * from './context';
8
- export * from './runnable';
9
- export * from './agent';
10
- export * from './pipeline-agent';
11
- export * from './llm-agent';
12
- export * from './llm-model';
13
- export * from './function-agent';
14
- export * from './function-runner';
15
- export * from './llm-decision-agent';
16
- export * from './local-function-agent';
17
- export * from './open-api-agent';
18
- export * from './memorable';
1
+ export * from "./utils";
2
+ export * from "./constants";
3
+ export * from "./definitions/data-type";
4
+ export * from "./definitions/data-type-schema";
5
+ export * from "./definitions/open-api";
6
+ export * from "./definitions/memory";
7
+ export * from "./context";
8
+ export * from "./runnable";
9
+ export * from "./agent";
10
+ export * from "./pipeline-agent";
11
+ export * from "./llm-agent";
12
+ export * from "./llm-model";
13
+ export * from "./function-agent";
14
+ export * from "./function-runner";
15
+ export * from "./llm-decision-agent";
16
+ export * from "./local-function-agent";
17
+ export * from "./open-api-agent";
18
+ export * from "./memorable";
@@ -1,11 +1,11 @@
1
- import { Agent, AgentProcessOptions } from './agent';
2
- import type { Context, ContextState } from './context';
3
- import { DataTypeSchema, SchemaMapType } from './definitions/data-type-schema';
4
- import { CreateRunnableMemory } from './definitions/memory';
5
- import { LLMModel, LLMModelInputMessage, LLMModelInputs } from './llm-model';
6
- import { MemorableSearchOutput, MemoryItemWithScore } from './memorable';
7
- import { RunnableDefinition } from './runnable';
8
- import { OrderedRecord } from './utils/ordered-map';
1
+ import { Agent, type AgentProcessOptions } from "./agent";
2
+ import type { Context, ContextState } from "./context";
3
+ import { type DataTypeSchema, type SchemaMapType } from "./definitions/data-type-schema";
4
+ import { type CreateRunnableMemory } from "./definitions/memory";
5
+ import type { LLMModel, LLMModelInputMessage, LLMModelInputs } from "./llm-model";
6
+ import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
7
+ import type { RunnableDefinition } from "./runnable";
8
+ import { OrderedRecord } from "./utils/ordered-map";
9
9
  export declare class LLMAgent<I extends {
10
10
  [name: string]: any;
11
11
  } = {}, O extends {
@@ -28,12 +28,12 @@ export declare class LLMAgent<I extends {
28
28
  private runWithTextOutput;
29
29
  }
30
30
  export interface LLMAgentDefinition extends RunnableDefinition {
31
- type: 'llm_agent';
31
+ type: "llm_agent";
32
32
  primaryMemoryId?: string;
33
33
  messages?: OrderedRecord<LLMModelInputMessage & {
34
34
  id: string;
35
35
  }>;
36
- modelOptions?: LLMModelInputs['modelOptions'];
36
+ modelOptions?: LLMModelInputs["modelOptions"];
37
37
  }
38
38
  /**
39
39
  * Options to create LLMAgent.
@@ -65,7 +65,7 @@ export interface CreateLLMAgentOptions<I extends {
65
65
  /**
66
66
  * Options for LLM chat model.
67
67
  */
68
- modelOptions?: LLMModelInputs['modelOptions'];
68
+ modelOptions?: LLMModelInputs["modelOptions"];
69
69
  /**
70
70
  * Messages to be passed to LLM chat model.
71
71
  */
@@ -91,6 +91,6 @@ declare function create<I extends {
91
91
  primary?: boolean;
92
92
  };
93
93
  }, State extends ContextState>({ context, ...options }: CreateLLMAgentOptions<I, O, Memories, State>): LLMAgent<SchemaMapType<I>, SchemaMapType<O>, {
94
- [name in keyof Memories]: MemorableSearchOutput<Memories[name]['memory']>;
94
+ [name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
95
95
  }, State>;
96
96
  export {};