@aigne/core 0.4.205-1 → 0.4.206

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 (58) hide show
  1. package/lib/cjs/agent.js +37 -6
  2. package/lib/cjs/definitions/data-type-schema.js +2 -2
  3. package/lib/cjs/definitions/memory.js +2 -2
  4. package/lib/cjs/function-agent.js +34 -29
  5. package/lib/cjs/function-runner.js +6 -4
  6. package/lib/cjs/index.js +1 -1
  7. package/lib/cjs/llm-agent.js +23 -55
  8. package/lib/cjs/llm-decision-agent.js +8 -12
  9. package/lib/cjs/llm-model.js +2 -2
  10. package/lib/cjs/local-function-agent.js +7 -21
  11. package/lib/cjs/pipeline-agent.js +29 -32
  12. package/lib/cjs/runnable.js +1 -0
  13. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  14. package/lib/cjs/utils/index.js +5 -2
  15. package/lib/cjs/utils/stream-utils.js +36 -14
  16. package/lib/esm/agent.js +39 -8
  17. package/lib/esm/definitions/data-type-schema.js +2 -2
  18. package/lib/esm/definitions/memory.js +2 -2
  19. package/lib/esm/function-agent.js +33 -28
  20. package/lib/esm/function-runner.js +6 -4
  21. package/lib/esm/index.js +1 -1
  22. package/lib/esm/llm-agent.js +23 -54
  23. package/lib/esm/llm-decision-agent.js +8 -11
  24. package/lib/esm/llm-model.js +2 -2
  25. package/lib/esm/local-function-agent.js +7 -20
  26. package/lib/esm/pipeline-agent.js +29 -31
  27. package/lib/esm/runnable.js +1 -0
  28. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  29. package/lib/esm/utils/index.js +5 -2
  30. package/lib/esm/utils/stream-utils.js +34 -14
  31. package/lib/types/agent.d.ts +9 -10
  32. package/lib/types/context.d.ts +2 -0
  33. package/lib/types/definitions/data-type-schema.d.ts +7 -5
  34. package/lib/types/{data-type.d.ts → definitions/data-type.d.ts} +2 -2
  35. package/lib/types/function-agent.d.ts +33 -20
  36. package/lib/types/function-runner.d.ts +20 -7
  37. package/lib/types/index.d.ts +1 -1
  38. package/lib/types/llm-agent.d.ts +27 -30
  39. package/lib/types/llm-decision-agent.d.ts +15 -22
  40. package/lib/types/llm-model.d.ts +2 -2
  41. package/lib/types/local-function-agent.d.ts +31 -34
  42. package/lib/types/memorable.d.ts +1 -1
  43. package/lib/types/pipeline-agent.d.ts +40 -33
  44. package/lib/types/runnable.d.ts +3 -3
  45. package/lib/types/tsconfig.tsbuildinfo +1 -1
  46. package/lib/types/utils/index.d.ts +5 -2
  47. package/lib/types/utils/message-utils.d.ts +3 -3
  48. package/lib/types/utils/stream-utils.d.ts +5 -3
  49. package/lib/types/utils/union.d.ts +1 -2
  50. package/package.json +3 -2
  51. package/lib/cjs/data-type-schema.js +0 -46
  52. package/lib/cjs/memory.js +0 -32
  53. package/lib/esm/data-type-schema.js +0 -43
  54. package/lib/esm/memory.js +0 -27
  55. package/lib/types/data-type-schema.d.ts +0 -46
  56. package/lib/types/memory.d.ts +0 -184
  57. /package/lib/cjs/{data-type.js → definitions/data-type.js} +0 -0
  58. /package/lib/esm/{data-type.js → definitions/data-type.js} +0 -0
@@ -1,51 +1,57 @@
1
- import type { Context } from './context';
1
+ import { Agent, AgentProcessOptions } from './agent';
2
+ import type { Context, ContextState } from './context';
2
3
  import { DataTypeSchema, SchemaMapType } from './definitions/data-type-schema';
3
- import { RunOptions, Runnable, RunnableDefinition, RunnableOutput, RunnableResponseStream } from './runnable';
4
+ import { CreateRunnableMemory } from './definitions/memory';
5
+ import { MemorableSearchOutput, MemoryItemWithScore } from './memorable';
6
+ import { Runnable, RunnableDefinition, RunnableOutput, RunnableResponseDelta } from './runnable';
7
+ import { MakeNullablePropertyOptional } from './utils/nullable';
4
8
  import { OrderedRecord } from './utils/ordered-map';
9
+ import { ExtractRunnableInputType } from './utils/runnable-type';
5
10
  export declare class PipelineAgent<I extends {
6
11
  [key: string]: any;
7
- } = {}, O extends {} = {}> extends Runnable<I, O> {
12
+ } = {}, O extends {
13
+ [name: string]: any;
14
+ } = {}, Memories extends {
15
+ [name: string]: MemoryItemWithScore[];
16
+ } = {}, State extends ContextState = ContextState> extends Agent<I, O, Memories, State> {
8
17
  definition: PipelineAgentDefinition;
9
- static create<I extends {
10
- [name: string]: DataTypeSchema;
11
- }, O extends {
12
- [name: string]: DataTypeSchema & {
13
- fromVariable: string;
14
- fromVariablePropPath?: string[];
15
- };
16
- }>(options: Parameters<typeof createPipelineAgentDefinition<I, O>>[0]): PipelineAgent<SchemaMapType<I>, SchemaMapType<O>>;
17
- constructor(definition: PipelineAgentDefinition, context?: Context);
18
- run(input: I, options: RunOptions & {
19
- stream: true;
20
- }): Promise<RunnableResponseStream<O>>;
21
- run(input: I, options?: RunOptions & {
22
- stream?: false;
23
- }): Promise<O>;
18
+ static create: typeof create;
19
+ constructor(definition: PipelineAgentDefinition, context?: Context<State>);
20
+ process(input: I, options: AgentProcessOptions<Memories>): Promise<ReadableStream<RunnableResponseDelta<O>>>;
24
21
  }
25
- export interface PipelineAgentProcessParameter<I extends {} = {}, O extends {} = {}, R = Runnable<I, O>> {
26
- name?: string;
22
+ type VariableWithPropPath = {
23
+ fromVariable: string;
24
+ fromVariablePropPath?: (string | number)[];
25
+ };
26
+ export type PipelineAgentProcessParameter<R extends Runnable = any, RI extends {
27
+ [name: string]: DataTypeSchema;
28
+ } = ExtractRunnableInputType<R>> = {
27
29
  runnable: R;
28
- input?: {
29
- [key: string]: {
30
- fromVariable: string;
31
- fromVariablePropPath?: string[];
32
- } | undefined;
33
- };
34
- }
35
- export declare function createPipelineAgentDefinition<I extends {
30
+ input: MakeNullablePropertyOptional<{
31
+ [key in keyof RI]: VariableWithPropPath;
32
+ }>;
33
+ };
34
+ declare function create<I extends {
36
35
  [name: string]: DataTypeSchema;
37
36
  }, O extends {
38
37
  [name: string]: DataTypeSchema & {
39
38
  fromVariable: string;
40
39
  fromVariablePropPath?: string[];
41
40
  };
42
- }>(options: {
43
- id?: string;
41
+ }, Memories extends {
42
+ [name: string]: CreateRunnableMemory<I>;
43
+ }, State extends ContextState, Processes extends {
44
+ [name: string]: PipelineAgentProcessParameter;
45
+ }>({ context, ...options }: {
46
+ context: Context<State>;
44
47
  name?: string;
45
48
  inputs: I;
46
49
  outputs: O;
47
- processes?: PipelineAgentProcessParameter[];
48
- }): PipelineAgentDefinition;
50
+ memories?: Memories;
51
+ processes: Processes;
52
+ }): PipelineAgent<SchemaMapType<I>, SchemaMapType<O>, {
53
+ [name in keyof Memories]: MemorableSearchOutput<Memories[name]['memory']>;
54
+ }, State>;
49
55
  export interface PipelineAgentDefinition extends RunnableDefinition {
50
56
  type: 'pipeline_agent';
51
57
  processes?: OrderedRecord<PipelineAgentProcess>;
@@ -66,7 +72,8 @@ export type PipelineAgentProcess = {
66
72
  [inputId: string]: {
67
73
  from: 'variable';
68
74
  fromVariableId?: string;
69
- fromVariablePropPath?: (string | number)[];
75
+ fromVariablePropPath?: (string | number | symbol)[];
70
76
  };
71
77
  };
72
78
  };
79
+ export {};
@@ -1,6 +1,6 @@
1
- import { Context, ContextState } from './context';
2
- import { DataType } from './data-type';
3
- import { Memorable } from './memorable';
1
+ import type { Context, ContextState } from './context';
2
+ import type { DataType } from './definitions/data-type';
3
+ import type { Memorable } from './memorable';
4
4
  import { OrderedRecord } from './utils/ordered-map';
5
5
  export interface RunOptions {
6
6
  stream?: boolean;