@agentica/core 0.11.0 → 0.12.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 (49) hide show
  1. package/README.md +2 -2
  2. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +4 -3
  3. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
  4. package/lib/context/internal/AgenticaTokenUsageAggregator.d.ts +2 -2
  5. package/lib/events/AgenticaDescribeEvent.d.ts +4 -0
  6. package/lib/events/AgenticaDescribeEvent.js +4 -0
  7. package/lib/events/AgenticaDescribeEvent.js.map +1 -1
  8. package/lib/events/AgenticaTextEvent.d.ts +4 -0
  9. package/lib/events/AgenticaTextEvent.js +4 -0
  10. package/lib/events/AgenticaTextEvent.js.map +1 -1
  11. package/lib/functional/assertHttpLlmApplication.d.ts +32 -0
  12. package/lib/functional/assertHttpLlmApplication.js +9424 -0
  13. package/lib/functional/assertHttpLlmApplication.js.map +1 -0
  14. package/lib/functional/{createHttpLlmApplication.d.ts → validateHttpLlmApplication.d.ts} +7 -7
  15. package/lib/functional/{createHttpLlmApplication.js → validateHttpLlmApplication.js} +6 -6
  16. package/lib/functional/{createHttpLlmApplication.js.map → validateHttpLlmApplication.js.map} +1 -1
  17. package/lib/index.d.ts +2 -1
  18. package/lib/index.js +2 -1
  19. package/lib/index.js.map +1 -1
  20. package/lib/index.mjs +9220 -26
  21. package/lib/index.mjs.map +1 -1
  22. package/lib/internal/MPSCUtil.d.ts +16 -2
  23. package/lib/internal/MPSCUtil.js +26 -5
  24. package/lib/internal/MPSCUtil.js.map +1 -1
  25. package/lib/json/IAgenticaPromptJson.d.ts +1 -1
  26. package/lib/prompts/AgenticaDescribePrompt.js +1 -1
  27. package/lib/prompts/AgenticaDescribePrompt.js.map +1 -1
  28. package/lib/structures/IAgenticaConfig.d.ts +23 -23
  29. package/lib/structures/IAgenticaController.d.ts +1 -1
  30. package/lib/structures/IAgenticaProps.d.ts +1 -1
  31. package/lib/structures/IAgenticaSystemPrompt.d.ts +7 -7
  32. package/lib/transformers/AgenticaPromptTransformer.js +1 -1
  33. package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +4 -3
  36. package/src/context/internal/AgenticaTokenUsageAggregator.ts +2 -2
  37. package/src/events/AgenticaDescribeEvent.ts +5 -0
  38. package/src/events/AgenticaTextEvent.ts +5 -0
  39. package/src/functional/assertHttpLlmApplication.ts +55 -0
  40. package/src/functional/{createHttpLlmApplication.ts → validateHttpLlmApplication.ts} +13 -10
  41. package/src/index.ts +2 -1
  42. package/src/internal/MPSCUtil.ts +43 -7
  43. package/src/json/IAgenticaPromptJson.ts +1 -1
  44. package/src/prompts/AgenticaDescribePrompt.ts +1 -1
  45. package/src/structures/IAgenticaConfig.ts +27 -27
  46. package/src/structures/IAgenticaController.ts +1 -1
  47. package/src/structures/IAgenticaProps.ts +1 -1
  48. package/src/structures/IAgenticaSystemPrompt.ts +7 -7
  49. package/src/transformers/AgenticaPromptTransformer.ts +1 -1
@@ -73,7 +73,7 @@ var AgenticaPromptTransformer;
73
73
  });
74
74
  AgenticaPromptTransformer.transformDescribe = (props) => new AgenticaDescribePrompt_1.AgenticaDescribePrompt({
75
75
  text: props.prompt.text,
76
- executes: props.prompt.executions.map((next) => AgenticaPromptTransformer.transformExecute({
76
+ executes: props.prompt.executes.map((next) => AgenticaPromptTransformer.transformExecute({
77
77
  operations: props.operations,
78
78
  prompt: next,
79
79
  })),
@@ -1 +1 @@
1
- {"version":3,"file":"AgenticaPromptTransformer.js","sourceRoot":"","sources":["../../src/transformers/AgenticaPromptTransformer.ts"],"names":[],"mappings":";;;AAGA,sFAAmF;AAEnF,0EAAuE;AACvE,8EAA2E;AAC3E,4EAAyE;AAEzE,0EAAuE;AACvE,sEAAmE;AAEnE,IAAiB,yBAAyB,CAwGzC;AAxGD,WAAiB,yBAAyB;IAC3B,mCAAS,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GAAG,CAAiC,KAMtD,EAA4B,EAAE;;IAC7B,MAAM,KAAK,GAAyC,MAAA,KAAK,CAAC,UAAU;SACjE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,0CAC1B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,KAAK,KAAK,SAAS;QACrB,MAAM,IAAI,KAAK,CACb,oCAAoC,KAAK,CAAC,KAAK,CAAC,UAAU,eAAe,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CACjG,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentica/core",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "main": "lib/index.js",
5
5
  "description": "Agentic AI Library specialized in LLM Function Calling",
6
6
  "scripts": {
@@ -64,7 +64,7 @@ export namespace ChatGptDescribeFunctionAgent {
64
64
  continue;
65
65
  }
66
66
 
67
- const { consumer, produce, close, waitClose, done } =
67
+ const { consumer, produce, close, waitClosed, waitUntilEmpty, done } =
68
68
  MPSCUtil.create<string>();
69
69
 
70
70
  describeContext[choice.index] = {
@@ -72,7 +72,8 @@ export namespace ChatGptDescribeFunctionAgent {
72
72
  consumer,
73
73
  produce,
74
74
  close,
75
- waitClose,
75
+ waitClosed,
76
+ waitUntilEmpty,
76
77
  done,
77
78
  };
78
79
  produce(choice.delta.content);
@@ -84,7 +85,7 @@ export namespace ChatGptDescribeFunctionAgent {
84
85
  done,
85
86
  get: () => describeContext[choice.index]?.content ?? "",
86
87
  join: async () => {
87
- await waitClose();
88
+ await waitClosed();
88
89
  return describeContext[choice.index]!.content;
89
90
  },
90
91
  }),
@@ -1,11 +1,11 @@
1
1
  import { CompletionUsage } from "openai/resources";
2
- import { Primitive } from "typia";
3
2
 
3
+ import { IAgenticaTokenUsageJson } from "../../json/IAgenticaTokenUsageJson";
4
4
  import { AgenticaTokenUsage } from "../AgenticaTokenUsage";
5
5
 
6
6
  export namespace AgenticaTokenUsageAggregator {
7
7
  export const aggregate = (props: {
8
- kind: Exclude<keyof Primitive<AgenticaTokenUsage>, "aggregate">;
8
+ kind: Exclude<keyof IAgenticaTokenUsageJson, "aggregate">;
9
9
  completionUsage: CompletionUsage;
10
10
  usage: AgenticaTokenUsage;
11
11
  }): void => {
@@ -13,6 +13,11 @@ export class AgenticaDescribeEvent<
13
13
  public get text(): string {
14
14
  return this.get_();
15
15
  }
16
+
17
+ /**
18
+ * Check if the join method can return a response immediately.
19
+ * Returns true if the response is ready to be returned by the join method.
20
+ */
16
21
  public get done(): boolean {
17
22
  return this.done_();
18
23
  }
@@ -8,6 +8,11 @@ export class AgenticaTextEvent extends AgenticaEventBase<"text"> {
8
8
  public get text(): string {
9
9
  return this.get_();
10
10
  }
11
+
12
+ /**
13
+ * Check if the join method can return a response immediately.
14
+ * Returns true if the response is ready to be returned by the join method.
15
+ */
11
16
  public get done(): boolean {
12
17
  return this.done_();
13
18
  }
@@ -0,0 +1,55 @@
1
+ import {
2
+ HttpLlm,
3
+ IHttpLlmApplication,
4
+ ILlmSchema,
5
+ OpenApi,
6
+ OpenApiV3,
7
+ OpenApiV3_1,
8
+ SwaggerV2,
9
+ } from "@samchon/openapi";
10
+ import typia from "typia";
11
+
12
+ /**
13
+ * Create an HTTP LLM application instance with type assertion.
14
+ *
15
+ * Create an {@link IHttpLlmApplication} instance which represents
16
+ * the LLM (Large Language Model) function calling application schema
17
+ * from the given Swagger/OpenAPI document and the target LLM model.
18
+ *
19
+ * By the way, even though this `assertHttpLlmApplication` function
20
+ * supports every version of Swagger/OpenAPI specification, there can
21
+ * be a type error in the given document. In that case, the function
22
+ * will throw an error with detailed type error tracing information.
23
+ *
24
+ * @param props Properties to create the HTTP LLM application instance
25
+ * @returns HTTP LLM application instance
26
+ * @throws {@link TypeGuardError} when the given document is invalid
27
+ * @author Samchon
28
+ */
29
+ export const assertHttpLlmApplication = <
30
+ Model extends ILlmSchema.Model,
31
+ >(props: {
32
+ /**
33
+ * Target LLM model.
34
+ */
35
+ model: Model;
36
+
37
+ /**
38
+ * Swagger/OpenAPI document.
39
+ */
40
+ document:
41
+ | SwaggerV2.IDocument
42
+ | OpenApiV3.IDocument
43
+ | OpenApiV3_1.IDocument
44
+ | OpenApi.IDocument;
45
+
46
+ /**
47
+ * Options for the LLM function calling schema composition.
48
+ */
49
+ options?: Partial<IHttpLlmApplication.IOptions<Model>>;
50
+ }): IHttpLlmApplication<Model> =>
51
+ HttpLlm.application({
52
+ model: props.model,
53
+ document: OpenApi.convert(typia.assert(props.document)),
54
+ options: props.options,
55
+ });
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  HttpLlm,
3
3
  IHttpLlmApplication,
4
+ ILlmSchema,
4
5
  OpenApi,
5
6
  OpenApiV3,
6
7
  OpenApiV3_1,
@@ -9,27 +10,29 @@ import {
9
10
  import typia, { IValidation } from "typia";
10
11
 
11
12
  /**
12
- * Create an HTTP LLM application instance.
13
- *
13
+ * Create an HTTP LLM application instance with type validation.
14
+ *
14
15
  * Create an {@link IHttpLlmApplication} instance which represents
15
- * the LLM (Large Language Model) function calling application schema
16
+ * the LLM (Large Language Model) function calling application schema
16
17
  * from the given Swagger/OpenAPI document and the target LLM model.
17
- *
18
- * By the way, even though this `createHttpLlmApplication` function
18
+ *
19
+ * By the way, even though this `validateHttpLlmApplication` function
19
20
  * supports every version of Swagger/OpenAPI specification, there can
20
21
  * be a type error in the given document. In that case, the function
21
22
  * will return {@link IValidation.IFailure} instance with detailed
22
23
  * type error tracing information.
23
- *
24
+ *
24
25
  * @param props Properties to create the HTTP LLM application instance
25
26
  * @returns Validation result of the HTTP LLM application composition
26
27
  * @author Samchon
27
28
  */
28
- export const createHttpLlmApplication = (props: {
29
+ export const validateHttpLlmApplication = <
30
+ Model extends ILlmSchema.Model,
31
+ >(props: {
29
32
  /**
30
33
  * Target LLM model.
31
34
  */
32
- model: "chatgpt";
35
+ model: Model;
33
36
 
34
37
  /**
35
38
  * Swagger/OpenAPI document.
@@ -43,8 +46,8 @@ export const createHttpLlmApplication = (props: {
43
46
  /**
44
47
  * Options for the LLM function calling schema composition.
45
48
  */
46
- options?: Partial<IHttpLlmApplication.IOptions<"chatgpt">>;
47
- }): IValidation<IHttpLlmApplication<"chatgpt">> => {
49
+ options?: Partial<IHttpLlmApplication.IOptions<Model>>;
50
+ }): IValidation<IHttpLlmApplication<Model>> => {
48
51
  const inspect: IValidation<
49
52
  | SwaggerV2.IDocument
50
53
  | OpenApiV3.IDocument
package/src/index.ts CHANGED
@@ -39,5 +39,6 @@ export * from "./events/AgenticaSelectEvent";
39
39
  export * from "./events/AgenticaTextEvent";
40
40
 
41
41
  // FACADE CLASS
42
- export * from "./functional/createHttpLlmApplication";
42
+ export * from "./functional/assertHttpLlmApplication";
43
+ export * from "./functional/validateHttpLlmApplication";
43
44
  export * from "./Agentica";
@@ -3,7 +3,18 @@ export namespace MPSCUtil {
3
3
  consumer: ReadableStream<T>;
4
4
  produce: (chunk: T) => void;
5
5
  close: () => void;
6
- waitClose: () => Promise<void>;
6
+ /**
7
+ * Wait until the producing is finished.
8
+ */
9
+ waitClosed: () => Promise<void>;
10
+ /**
11
+ * Wait until the consuming is finished.(finished producing and consuming)
12
+ */
13
+ waitUntilEmpty: () => Promise<void>;
14
+
15
+ /**
16
+ * Check if producing is done and consuming is finished.
17
+ */
7
18
  done: () => boolean;
8
19
  }
9
20
 
@@ -19,12 +30,14 @@ export namespace MPSCUtil {
19
30
  }
20
31
  },
21
32
  });
33
+
22
34
  return {
23
35
  consumer,
24
36
  produce: (chunk: T) => queue.enqueue(chunk),
25
37
  close: () => queue.close(),
26
38
  done: () => queue.done(),
27
- waitClose: () => queue.waitClose(),
39
+ waitClosed: () => queue.waitClosed(),
40
+ waitUntilEmpty: () => queue.waitUntilEmpty(),
28
41
  };
29
42
  };
30
43
 
@@ -32,7 +45,7 @@ export namespace MPSCUtil {
32
45
  private queue: T[] = [];
33
46
  private resolvers: ((value: IteratorResult<T, undefined>) => void)[] = [];
34
47
  private closeResolvers: (() => void)[] = [];
35
-
48
+ private emptyResolvers: (() => void)[] = [];
36
49
  private closed = false;
37
50
 
38
51
  enqueue(item: T) {
@@ -46,14 +59,28 @@ export namespace MPSCUtil {
46
59
  if (this.queue.length > 0) {
47
60
  return { value: this.queue.shift()!, done: false };
48
61
  }
49
- if (this.closed) return { value: undefined, done: true };
62
+ if (this.closed) {
63
+ if (this.emptyResolvers.length > 0) {
64
+ this.emptyResolvers.forEach((resolve) => resolve());
65
+ this.emptyResolvers = [];
66
+ }
67
+ return { value: undefined, done: true };
68
+ }
50
69
  return new Promise((resolve) => this.resolvers.push(resolve));
51
70
  }
52
71
 
53
- done() {
72
+ isEmpty() {
73
+ return this.queue.length === 0;
74
+ }
75
+
76
+ isClosed() {
54
77
  return this.closed;
55
78
  }
56
79
 
80
+ done() {
81
+ return this.isClosed() && this.isEmpty();
82
+ }
83
+
57
84
  close() {
58
85
  this.closed = true;
59
86
  while (this.resolvers.length > 0) {
@@ -62,8 +89,17 @@ export namespace MPSCUtil {
62
89
  this.closeResolvers.forEach((resolve) => resolve());
63
90
  }
64
91
 
65
- waitClose() {
66
- if (this.closed) {
92
+ waitUntilEmpty() {
93
+ if (this.isEmpty()) {
94
+ return Promise.resolve();
95
+ }
96
+ return new Promise<void>((resolve) => {
97
+ this.emptyResolvers.push(resolve);
98
+ });
99
+ }
100
+
101
+ waitClosed() {
102
+ if (this.isClosed()) {
67
103
  return Promise.resolve();
68
104
  }
69
105
 
@@ -96,7 +96,7 @@ export namespace IAgenticaPromptJson {
96
96
  *
97
97
  * This prompt describes the return value of them.
98
98
  */
99
- executions: IExecute[];
99
+ executes: IExecute[];
100
100
 
101
101
  /**
102
102
  * Description text.
@@ -28,7 +28,7 @@ export class AgenticaDescribePrompt<
28
28
  public toJSON(): IAgenticaPromptJson.IDescribe {
29
29
  return {
30
30
  type: this.type,
31
- executions: this.executes.map((e) => e.toJSON()),
31
+ executes: this.executes.map((e) => e.toJSON()),
32
32
  text: this.text,
33
33
  };
34
34
  }
@@ -22,6 +22,33 @@ import { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
22
22
  * @author Samchon
23
23
  */
24
24
  export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
25
+ /**
26
+ * Agent executor.
27
+ *
28
+ * Executor function of Agentic AI's iteration plan to internal agents
29
+ * running by the {@link Agentica.conversate} function.
30
+ *
31
+ * If you want to customize the agent execution plan, you can do it
32
+ * by assigning you logic function of entire or partial to this property.
33
+ * When customizing it, it would better to reference the
34
+ * {@link ChatGptAgent.execute} function.
35
+ *
36
+ * @param ctx Context of the agent
37
+ * @returns Lit of prompts generated by the executor
38
+ * @default ChatGptAgent.execute
39
+ */
40
+ executor?:
41
+ | Partial<IAgenticaExecutor<Model>>
42
+ | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
43
+
44
+ /**
45
+ * System prompt messages.
46
+ *
47
+ * System prompt messages if you want to customize the system prompt
48
+ * messages for each situation.
49
+ */
50
+ systemPrompt?: IAgenticaSystemPrompt<Model>;
51
+
25
52
  /**
26
53
  * Locale of the A.I. chatbot.
27
54
  *
@@ -93,31 +120,4 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
93
120
  * @default true
94
121
  */
95
122
  eliticism?: boolean;
96
-
97
- /**
98
- * System prompt messages.
99
- *
100
- * System prompt messages if you want to customize the system prompt
101
- * messages for each situation.
102
- */
103
- systemPrompt?: IAgenticaSystemPrompt<Model>;
104
-
105
- /**
106
- * Agent executor.
107
- *
108
- * Executor function of Agentic AI's iteration plan to internal agents
109
- * running by the {@link Agentica.conversate} function.
110
- *
111
- * If you want to customize the agent execution plan, you can do it
112
- * by assigning you logic function of entire or partial to this property.
113
- * When customizing it, it would better to reference the
114
- * {@link ChatGptAgent.execute} function.
115
- *
116
- * @param ctx Context of the agent
117
- * @returns Lit of prompts generated by the executor
118
- * @default ChatGptAgent.execute
119
- */
120
- executor?:
121
- | Partial<IAgenticaExecutor<Model>>
122
- | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
123
123
  }
@@ -30,7 +30,7 @@ export namespace IAgenticaController {
30
30
  /**
31
31
  * HTTP controller.
32
32
  *
33
- * You can make it by {@link createHttpLlmApplication} function with
33
+ * You can make it by {@link validateHttpLlmApplication} function with
34
34
  * the Swagger or OpenAPI document.
35
35
  */
36
36
  export interface IHttp<Model extends ILlmSchema.Model>
@@ -55,7 +55,7 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
55
55
  * - `locale`: your system's locale and timezone
56
56
  * - `timezone`: your system's timezone
57
57
  * - `systemPrompt`: default prompts written in markdown
58
- * - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
58
+ * - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
59
59
  */
60
60
  config?: IAgenticaConfig<Model>;
61
61
 
@@ -18,7 +18,7 @@ import { IAgenticaConfig } from "./IAgenticaConfig";
18
18
  * would be used which are written in the below directory as markdown
19
19
  * documents.
20
20
  *
21
- * - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
21
+ * - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
22
22
  *
23
23
  * @author Samchon
24
24
  */
@@ -28,7 +28,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
28
28
  *
29
29
  * @param config Configuration of the agent
30
30
  * @returns The common system prompt
31
- * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/common.md
31
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/common.md
32
32
  */
33
33
  common?: (config?: IAgenticaConfig<Model> | undefined) => string;
34
34
 
@@ -46,7 +46,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
46
46
  *
47
47
  * @param histories Histories of the previous prompts
48
48
  * @returns initialize system prompt
49
- * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
49
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/initialize.md
50
50
  */
51
51
  initialize?: (histories: AgenticaPrompt<Model>[]) => string;
52
52
 
@@ -67,7 +67,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
67
67
  *
68
68
  * @param histories Histories of the previous prompts
69
69
  * @returns select system promopt
70
- * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
70
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/select.md
71
71
  */
72
72
  select?: (histories: AgenticaPrompt<Model>[]) => string;
73
73
 
@@ -84,7 +84,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
84
84
  *
85
85
  * @param histories Histories of the previous prompts
86
86
  * @returns cancel system prompt
87
- * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
87
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/cancel.md
88
88
  */
89
89
  cancel?: (histories: AgenticaPrompt<Model>[]) => string;
90
90
 
@@ -102,7 +102,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
102
102
  *
103
103
  * @param histories Histories of the previous prompts
104
104
  * @returns execute system prompt
105
- * https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
105
+ * https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
106
106
  */
107
107
  execute?: (histories: AgenticaPrompt<Model>[]) => string;
108
108
 
@@ -119,7 +119,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
119
119
  *
120
120
  * @param histories Histories of the previous prompts
121
121
  * @returns describe system prompt
122
- * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
122
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
123
123
  */
124
124
  describe?: (histories: AgenticaExecutePrompt<Model>[]) => string;
125
125
  }
@@ -107,7 +107,7 @@ export namespace AgenticaPromptTransformer {
107
107
  }): AgenticaDescribePrompt<Model> =>
108
108
  new AgenticaDescribePrompt({
109
109
  text: props.prompt.text,
110
- executes: props.prompt.executions.map((next) =>
110
+ executes: props.prompt.executes.map((next) =>
111
111
  transformExecute({
112
112
  operations: props.operations,
113
113
  prompt: next,