@autobe/agent 0.10.6 → 0.11.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 (144) hide show
  1. package/lib/AutoBeAgent.js +13 -46
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +11 -6
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/context/AutoBeContext.d.ts +3 -2
  6. package/lib/factory/getAutoBeGenerated.d.ts +5 -0
  7. package/lib/factory/getAutoBeGenerated.js +307 -0
  8. package/lib/factory/getAutoBeGenerated.js.map +1 -0
  9. package/lib/index.mjs +1631 -1389
  10. package/lib/index.mjs.map +1 -1
  11. package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.d.ts +2 -7
  12. package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.js +1 -9
  13. package/lib/orchestrate/analyze/AutoBeAnalyzeFileSystem.js.map +1 -1
  14. package/lib/orchestrate/analyze/AutoBeAnalyzeRole.d.ts +13 -0
  15. package/lib/orchestrate/analyze/AutoBeAnalyzeRole.js +3 -0
  16. package/lib/orchestrate/analyze/AutoBeAnalyzeRole.js.map +1 -0
  17. package/lib/orchestrate/analyze/orchestrateAnalyze.d.ts +0 -25
  18. package/lib/orchestrate/analyze/orchestrateAnalyze.js +22 -420
  19. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  20. package/lib/orchestrate/analyze/orchestrateAnalyzeComposer.d.ts +6 -0
  21. package/lib/orchestrate/analyze/orchestrateAnalyzeComposer.js +561 -0
  22. package/lib/orchestrate/analyze/orchestrateAnalyzeComposer.js.map +1 -0
  23. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.d.ts +6 -0
  24. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +41 -0
  25. package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -0
  26. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +14 -0
  27. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +468 -0
  28. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -0
  29. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeComposerApplication.d.ts +68 -0
  30. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeComposerApplication.js +3 -0
  31. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeComposerApplication.js.map +1 -0
  32. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.d.ts +5 -0
  33. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js +27 -0
  34. package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js.map +1 -0
  35. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.d.ts +12 -0
  36. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js +78 -0
  37. package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js.map +1 -0
  38. package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.d.ts +6 -0
  39. package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js +58 -0
  40. package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js.map +1 -0
  41. package/lib/orchestrate/interface/orchestrateInterface.js +0 -2
  42. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  43. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +17 -137
  44. package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
  45. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +92 -141
  46. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  47. package/lib/orchestrate/prisma/orchestratePrisma.js +9 -5
  48. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  49. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +54 -25
  50. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  51. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +4 -3
  52. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  53. package/lib/orchestrate/prisma/{orchestratePrismaSchema.d.ts → orchestratePrismaSchemas.d.ts} +2 -4
  54. package/lib/orchestrate/prisma/{orchestratePrismaSchema.js → orchestratePrismaSchemas.js} +269 -203
  55. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -0
  56. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +1 -1
  57. package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
  58. package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js +1 -1
  59. package/lib/orchestrate/prisma/transformPrismaHistories.js +1 -1
  60. package/lib/orchestrate/prisma/transformPrismaHistories.js.map +1 -1
  61. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.d.ts +2 -6
  62. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +24 -32
  63. package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
  64. package/lib/orchestrate/realize/RealizePipe.d.ts +5 -0
  65. package/lib/orchestrate/realize/RealizePipe.js +14 -0
  66. package/lib/orchestrate/realize/RealizePipe.js.map +1 -0
  67. package/lib/orchestrate/realize/orchestrateRealize.d.ts +0 -6
  68. package/lib/orchestrate/realize/orchestrateRealize.js +6 -43
  69. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  70. package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +3 -3
  71. package/lib/orchestrate/realize/orchestrateRealizeCoder.js +124 -59
  72. package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
  73. package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +188 -18
  74. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +23 -0
  75. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.js +3 -0
  76. package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.js.map +1 -0
  77. package/lib/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.d.ts +2 -0
  78. package/lib/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.js +5 -0
  79. package/lib/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.js.map +1 -0
  80. package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +2 -1
  81. package/lib/orchestrate/realize/transformRealizeCoderHistories.js +50 -36
  82. package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
  83. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.d.ts +5 -0
  84. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +123 -0
  85. package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -0
  86. package/lib/orchestrate/test/compile/getTestExternalDeclarations.js +4 -1
  87. package/lib/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  88. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +2 -1
  89. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  90. package/lib/orchestrate/test/orchestrateTest.js +11 -5
  91. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  92. package/lib/orchestrate/test/orchestrateTestCorrect.js +3 -2
  93. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  94. package/lib/structures/IAutoBeProps.d.ts +8 -8
  95. package/lib/utils/pipe.d.ts +5 -0
  96. package/lib/utils/pipe.js +14 -0
  97. package/lib/utils/pipe.js.map +1 -0
  98. package/package.json +6 -6
  99. package/src/AutoBeAgent.ts +22 -76
  100. package/src/constants/AutoBeSystemPromptConstant.ts +11 -6
  101. package/src/context/AutoBeContext.ts +3 -1
  102. package/src/factory/getAutoBeGenerated.ts +113 -0
  103. package/src/orchestrate/analyze/AutoBeAnalyzeFileSystem.ts +5 -13
  104. package/src/orchestrate/analyze/AutoBeAnalyzeRole.ts +14 -0
  105. package/src/orchestrate/analyze/orchestrateAnalyze.ts +30 -165
  106. package/src/orchestrate/analyze/orchestrateAnalyzeComposer.ts +115 -0
  107. package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +39 -0
  108. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +106 -0
  109. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeComposerApplication.ts +74 -0
  110. package/src/orchestrate/analyze/transformAnalyzeReviewerHistories.ts +31 -0
  111. package/src/orchestrate/analyze/transformAnalyzeWriteHistories.ts +94 -0
  112. package/src/orchestrate/analyze/writeDocumentUntilReviewPassed.ts +66 -0
  113. package/src/orchestrate/interface/orchestrateInterface.ts +0 -2
  114. package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +2 -3
  115. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +21 -0
  116. package/src/orchestrate/prisma/orchestratePrisma.ts +12 -5
  117. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +4 -13
  118. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +9 -4
  119. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +265 -0
  120. package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +26 -37
  121. package/src/orchestrate/realize/RealizePipe.ts +39 -0
  122. package/src/orchestrate/realize/orchestrateRealize.ts +3 -91
  123. package/src/orchestrate/realize/orchestrateRealizeCoder.ts +60 -25
  124. package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +192 -18
  125. package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +34 -0
  126. package/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.ts +2 -0
  127. package/src/orchestrate/realize/transformRealizeCoderHistories.ts +58 -34
  128. package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +178 -0
  129. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +5 -4
  130. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +7 -2
  131. package/src/orchestrate/test/orchestrateTest.ts +14 -12
  132. package/src/orchestrate/test/orchestrateTestCorrect.ts +10 -9
  133. package/src/structures/IAutoBeProps.ts +10 -7
  134. package/src/utils/pipe.ts +39 -0
  135. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.d.ts +0 -20
  136. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +0 -735
  137. package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +0 -1
  138. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.d.ts +0 -15
  139. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js +0 -44
  140. package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +0 -1
  141. package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +0 -1
  142. package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +0 -219
  143. package/src/orchestrate/analyze/AutoBeAnalyzeReviewer.ts +0 -62
  144. package/src/orchestrate/prisma/orchestratePrismaSchema.ts +0 -157
@@ -3,6 +3,7 @@ import {
3
3
  AutoBeEvent,
4
4
  AutoBeHistory,
5
5
  IAutoBeCompiler,
6
+ IAutoBeCompilerListener,
6
7
  IAutoBeGetFilesOptions,
7
8
  } from "@autobe/interface";
8
9
  import { ILlmSchema } from "@samchon/openapi";
@@ -15,7 +16,8 @@ export interface AutoBeContext<Model extends ILlmSchema.Model> {
15
16
  model: Model;
16
17
  vendor: IAgenticaVendor;
17
18
  config: IAutoBeConfig | undefined;
18
- compiler: IAutoBeCompiler;
19
+ compilerListener: IAutoBeCompilerListener;
20
+ compiler: () => Promise<IAutoBeCompiler>;
19
21
  files: (options: IAutoBeGetFilesOptions) => Promise<Record<string, string>>;
20
22
  histories: () => AutoBeHistory[];
21
23
  state: () => AutoBeState;
@@ -0,0 +1,113 @@
1
+ import {
2
+ AutoBeHistory,
3
+ IAutoBeCompiler,
4
+ IAutoBeGetFilesOptions,
5
+ } from "@autobe/interface";
6
+ import { ILlmSchema } from "@samchon/openapi";
7
+ import typia from "typia";
8
+
9
+ import { AutoBeContext } from "../context/AutoBeContext";
10
+ import { AutoBeState } from "../context/AutoBeState";
11
+ import { AutoBeTokenUsage } from "../context/AutoBeTokenUsage";
12
+
13
+ export async function getAutoBeGenerated<Model extends ILlmSchema.Model>(
14
+ ctx: AutoBeContext<Model>,
15
+ histories: AutoBeHistory[],
16
+ tokenUsage: AutoBeTokenUsage,
17
+ options?: Partial<IAutoBeGetFilesOptions>,
18
+ ): Promise<Record<string, string>> {
19
+ const state: AutoBeState = ctx.state();
20
+ const ret: Record<string, string> = {};
21
+
22
+ // ANALYZE
23
+ if (state.analyze === null) return {};
24
+ Object.assign<Record<string, string>, Record<string, string>>(
25
+ ret,
26
+ Object.fromEntries(
27
+ Object.entries(state.analyze.files).map(([key, value]) => [
28
+ `docs/analysis/${key.split("/").at(-1)}`,
29
+ value,
30
+ ]),
31
+ ),
32
+ );
33
+
34
+ // PRISMA
35
+ const compiler: IAutoBeCompiler = await ctx.compiler();
36
+ if (state.prisma?.step === state.analyze.step) {
37
+ const schemaFiles: Record<string, string> =
38
+ (options?.dbms ?? "postgres") === "postgres"
39
+ ? state.prisma.schemas
40
+ : await compiler.prisma.write(state.prisma.result.data, options!.dbms!);
41
+ Object.assign<
42
+ Record<string, string>,
43
+ Record<string, string>,
44
+ Record<string, string>
45
+ >(
46
+ ret,
47
+ Object.fromEntries(
48
+ Object.entries(schemaFiles).map(([key, value]) => [
49
+ `prisma/schema/${key.split("/").at(-1)}`,
50
+ value,
51
+ ]),
52
+ ),
53
+ {
54
+ "autobe/prisma.json": typia.json.stringify(state.prisma.result.data),
55
+ },
56
+ );
57
+ if (state.prisma.compiled.type === "success")
58
+ ret["docs/ERD.md"] = state.prisma.compiled.document;
59
+ else if (state.prisma.compiled.type === "failure")
60
+ ret["prisma/compile-error-reason.log"] = state.prisma.compiled.reason;
61
+ }
62
+
63
+ // INTERFACE
64
+ if (state.interface?.step === state.analyze.step) {
65
+ const files: Record<string, string> = await compiler.interface.write(
66
+ state.interface.document,
67
+ );
68
+ Object.assign<
69
+ Record<string, string>,
70
+ Record<string, string>,
71
+ Record<string, string>
72
+ >(
73
+ ret,
74
+ state.test?.step === state.interface.step
75
+ ? Object.fromEntries(
76
+ Object.entries(files).filter(
77
+ ([key]) => key.startsWith("test/features/") === false,
78
+ ),
79
+ )
80
+ : files,
81
+ {
82
+ "autobe/document.json": typia.json.stringify(state.interface.document),
83
+ },
84
+ );
85
+ }
86
+
87
+ // TEST
88
+ if (state.test?.step === state.analyze.step)
89
+ Object.assign<
90
+ Record<string, string>,
91
+ Record<string, string>,
92
+ Record<string, string>
93
+ >(
94
+ ret,
95
+ Object.fromEntries(state.test.files.map((f) => [f.location, f.content])),
96
+ await compiler.test.getTemplate(),
97
+ );
98
+
99
+ // REALIZE
100
+ if (state.realize?.step === state.analyze.step)
101
+ Object.assign<
102
+ Record<string, string>,
103
+ Record<string, string>,
104
+ Record<string, string>
105
+ >(ret, state.realize.files, await compiler.realize.getTemplate());
106
+
107
+ // LOGGING
108
+ Object.assign<Record<string, string>, Record<string, string>>(ret, {
109
+ "autobe/histories.json": typia.json.stringify(histories),
110
+ "autobe/tokenUsage.json": typia.json.stringify(tokenUsage),
111
+ });
112
+ return ret;
113
+ }
@@ -39,10 +39,9 @@ export interface IAutoBeAnalyzeFileSystem {
39
39
  * overwrite it. Generate several markdown files at once. It is recommended
40
40
  * that you create multiple files at a time.
41
41
  */
42
- createOrUpdateFiles(input: ICreateOrUpdateInput): Promise<void>;
43
-
44
- /** Remove markdown file. */
45
- removeFile(input: Pick<IFile, "filename">): Promise<void>;
42
+ createOrUpdateFiles(
43
+ input: ICreateOrUpdateInput,
44
+ ): Promise<Record<string, string>>;
46
45
 
47
46
  /**
48
47
  * If you decide that you no longer need any reviews, or if the reviewer
@@ -60,22 +59,15 @@ export class AutoBeAnalyzeFileSystem implements IAutoBeAnalyzeFileSystem {
60
59
  constructor(private readonly fileMap: Record<Filename, FileContent> = {}) {}
61
60
  async createOrUpdateFiles(input: {
62
61
  files: Array<IFile> & tags.MinItems<1>;
63
- }): Promise<void> {
62
+ }): Promise<Record<string, string>> {
64
63
  input.files.forEach((file) => {
65
64
  this.fileMap[file.filename] = file.markdown;
66
65
  });
67
- }
68
66
 
69
- async removeFile(input: Pick<IFile, "filename">): Promise<void> {
70
- delete this.fileMap[input.filename];
67
+ return this.fileMap;
71
68
  }
72
69
 
73
70
  abort(_input: { reason: string }): "OK" {
74
71
  return "OK";
75
72
  }
76
-
77
- /** @ignore */
78
- allFiles(): Record<string, string> {
79
- return this.fileMap;
80
- }
81
73
  }
@@ -0,0 +1,14 @@
1
+ export interface AutoBeAnalyzeRole {
2
+ /**
3
+ * Role name representing user types that can authenticate via API. These are
4
+ * user roles that can register and login to the service. This will be used as
5
+ * reference when creating Prisma schema for user authentication.
6
+ */
7
+ name: string;
8
+
9
+ /**
10
+ * Description of what this user role can do in the system. Describes the
11
+ * permissions and capabilities of this authenticated user type.
12
+ */
13
+ description: string;
14
+ }
@@ -1,21 +1,17 @@
1
- import { IAgenticaController, MicroAgentica } from "@agentica/core";
2
1
  import {
3
2
  AutoBeAnalyzeHistory,
4
3
  AutoBeAssistantMessageHistory,
5
4
  } from "@autobe/interface";
6
- import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
7
- import typia from "typia";
5
+ import { ILlmSchema } from "@samchon/openapi";
6
+ import { IPointer } from "tstl";
8
7
  import { v4 } from "uuid";
9
8
 
10
- import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
11
9
  import { AutoBeContext } from "../../context/AutoBeContext";
12
10
  import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
13
- import { assertSchemaModel } from "../../context/assertSchemaModel";
14
- import { enforceToolCall } from "../../utils/enforceToolCall";
15
- import { AutoBeAnalyzeAgent } from "./AutoBeAnalyzeAgent";
16
- import { IFile } from "./AutoBeAnalyzeFileSystem";
17
11
  import { AutoBeAnalyzePointer } from "./AutoBeAnalyzePointer";
18
- import { AutoBeAnalyzeReviewer } from "./AutoBeAnalyzeReviewer";
12
+ import { orchestrateAnalyzeComposer } from "./orchestrateAnalyzeComposer";
13
+ import { IComposeInput } from "./structures/IAutoBeAnalyzeComposerApplication";
14
+ import { writeDocumentUntilReviewPassed } from "./writeDocumentUntilReviewPassed";
19
15
 
20
16
  /** @todo Kakasoo */
21
17
  export const orchestrateAnalyze =
@@ -23,8 +19,8 @@ export const orchestrateAnalyze =
23
19
  async (
24
20
  props: IAutoBeApplicationProps,
25
21
  ): Promise<AutoBeAssistantMessageHistory | AutoBeAnalyzeHistory> => {
26
- const step = ctx.state().analyze?.step ?? 0;
27
- const created_at = new Date().toISOString();
22
+ const step: number = ctx.state().analyze?.step ?? 0;
23
+ const created_at: string = new Date().toISOString();
28
24
  ctx.dispatch({
29
25
  type: "analyzeStart",
30
26
  reason: props.reason,
@@ -32,66 +28,33 @@ export const orchestrateAnalyze =
32
28
  created_at,
33
29
  });
34
30
 
35
- const controller = createController<Model>({
36
- model: ctx.model,
37
- execute: new DeterminingFiles(),
38
- });
39
-
40
- const agentica = new MicroAgentica({
41
- model: ctx.model,
42
- vendor: ctx.vendor,
43
- controllers: [controller],
44
- config: {
45
- locale: ctx.config?.locale,
46
- executor: {
47
- describe: null,
48
- },
49
- systemPrompt: {
50
- common: () => AutoBeSystemPromptConstant.ANALYZE_PLANNER,
51
- },
52
- },
53
- histories: [
54
- ...ctx
55
- .histories()
56
- .filter(
57
- (el) => el.type === "assistantMessage" || el.type === "userMessage",
58
- ),
59
- ],
60
- });
61
- enforceToolCall(agentica);
62
-
31
+ const pointer: IPointer<IComposeInput | null> = { value: null };
32
+ const agentica = orchestrateAnalyzeComposer(ctx, pointer);
63
33
  const determined = await agentica
64
- .conversate("Design a complete list of documents for that document")
34
+ .conversate(
35
+ [
36
+ `Design a complete list of documents and user roles for this project.`,
37
+ `Define user roles that can authenticate via API and create appropriate documentation files.`,
38
+ `You must respect the number of documents specified by the user.`,
39
+ ].join("\n"),
40
+ )
65
41
  .finally(() => {
66
42
  const tokenUsage = agentica.getTokenUsage();
67
43
  ctx.usage().record(tokenUsage, ["analyze"]);
68
44
  });
69
-
70
- const lastMessage = determined[determined.length - 1]!;
71
- if (lastMessage.type === "assistantMessage") {
72
- const history: AutoBeAssistantMessageHistory = {
45
+ if (pointer.value === null) {
46
+ return {
73
47
  id: v4(),
48
+ text: "Failed to analyze your request. please request again.",
74
49
  type: "assistantMessage",
75
- text: lastMessage.text,
76
- created_at,
77
50
  completed_at: new Date().toISOString(),
51
+ created_at: new Date().toISOString(),
78
52
  };
79
- ctx.dispatch({
80
- type: "assistantMessage",
81
- text: lastMessage.text,
82
- created_at,
83
- });
84
- return history;
85
53
  }
86
54
 
87
- const described = determined.find((el) => el.type === "describe");
88
- const determinedOutput = described?.executes.find(
89
- (el) => el.protocol === "class" && typia.is<IDeterminingInput>(el.value),
90
- )?.value as IDeterminingInput;
55
+ const { files: tableOfContents, prefix, roles } = pointer.value;
91
56
 
92
- const prefix = determinedOutput.prefix;
93
- const describedFiles = determinedOutput.files;
94
- if (describedFiles.length === 0) {
57
+ if (tableOfContents.length === 0) {
95
58
  const history: AutoBeAssistantMessageHistory = {
96
59
  id: v4(),
97
60
  type: "assistantMessage",
@@ -108,31 +71,16 @@ export const orchestrateAnalyze =
108
71
  }
109
72
 
110
73
  const pointers = await Promise.all(
111
- describedFiles.map(async ({ filename, reason }) => {
112
- const pointer: AutoBeAnalyzePointer = { value: null };
113
-
114
- const agent = new AutoBeAnalyzeAgent(
115
- AutoBeAnalyzeReviewer,
74
+ tableOfContents.map(async ({ filename }) => {
75
+ const pointer: AutoBeAnalyzePointer = { value: { files: {} } };
76
+ await writeDocumentUntilReviewPassed(
116
77
  ctx,
117
78
  pointer,
118
- describedFiles.map((el) => el.filename),
119
- );
120
-
121
- await agent.conversate(
122
- [
123
- `# Instruction`,
124
- `The names of all the files are as follows: ${describedFiles.join(",")}`,
125
- "Assume that all files are in the same folder. Also, when pointing to the location of a file, go to the relative path.",
126
- "",
127
- `Among the various documents, the part you decided to take care of is as follows.: ${filename}`,
128
- `Only write this document named '${filename}'.`,
129
- "Never write other documents.",
130
- "",
131
- "The reason why this document needs to be written is as follows.",
132
- `- reason: ${reason}`,
133
- ].join("\n"),
79
+ tableOfContents,
80
+ filename,
81
+ roles,
82
+ 3,
134
83
  );
135
-
136
84
  return pointer;
137
85
  }),
138
86
  );
@@ -149,6 +97,7 @@ export const orchestrateAnalyze =
149
97
  type: "analyze",
150
98
  reason: props.reason,
151
99
  prefix,
100
+ roles: roles,
152
101
  files: files,
153
102
  step,
154
103
  created_at,
@@ -180,87 +129,3 @@ export const orchestrateAnalyze =
180
129
  });
181
130
  return history;
182
131
  };
183
-
184
- export interface IDeterminingInput {
185
- /**
186
- * Prefix for file names and all prisma schema files, table, interface, and
187
- * variable names. For example, if you were to create a bulletin board
188
- * service, the prefix would be bbs. At this time, the name of the document
189
- * would be, for example, 00_bbs_table_of_contents, and bbs would have to be
190
- * attached to the name of all documents. This value would then be passed to
191
- * other agents as well, in the form of bbs_article, bbs_article_snapshot, and
192
- * bbs_comments in the table name. Interfaces will likewise be used in
193
- * interfaces and tests because they originate from the name of prisma scheme.
194
- * Do not use prefixes that are related to the technology stack (e.g., ts_,
195
- * api_, react_) or unnatural prefixes that typically wouldn’t appear in table
196
- * names or domain models (e.g., zz_, my_, dev_).
197
- *
198
- * @title Prefix
199
- */
200
- prefix: string;
201
-
202
- /**
203
- * File name must be English. and it must contains the numbering and prefix.
204
- *
205
- * @title file names and reason to create.
206
- */
207
- files: Array<Pick<IFile, "filename" | "reason">>;
208
- }
209
-
210
- class DeterminingFiles {
211
- /**
212
- * Determining the Initial File List.
213
- *
214
- * Design a list of initial documents that you need to create for that
215
- * requirement. The list of documents is determined only by the name of the
216
- * file. If you determine from the conversation that the user's requirements
217
- * have not been fully gathered, you must stop the analysis and continue
218
- * collecting the remaining requirements. In this case, you do not need to
219
- * generate any files. Simply pass an empty array to `input.files`, which is
220
- * the input value for the `determine` tool.
221
- *
222
- * @param input Prefix and files
223
- * @returns
224
- */
225
- determine(input: IDeterminingInput): IDeterminingInput {
226
- return input;
227
- }
228
- }
229
-
230
- function createController<Model extends ILlmSchema.Model>(props: {
231
- model: Model;
232
- execute: DeterminingFiles;
233
- }): IAgenticaController.IClass<Model> {
234
- assertSchemaModel(props.model);
235
- const application: ILlmApplication<Model> = collection[
236
- props.model
237
- ] as unknown as ILlmApplication<Model>;
238
- return {
239
- protocol: "class",
240
- name: "Planning",
241
- application,
242
- // execute: props.execute,
243
- execute: {
244
- determine: (input) => {
245
- return input;
246
- },
247
- } satisfies DeterminingFiles,
248
- };
249
- }
250
-
251
- const claude = typia.llm.application<
252
- DeterminingFiles,
253
- "claude",
254
- { reference: true }
255
- >();
256
- const collection = {
257
- chatgpt: typia.llm.application<
258
- DeterminingFiles,
259
- "chatgpt",
260
- { reference: true }
261
- >(),
262
- claude,
263
- llama: claude,
264
- deepseek: claude,
265
- "3.1": claude,
266
- };
@@ -0,0 +1,115 @@
1
+ import { IAgenticaController, MicroAgentica } from "@agentica/core";
2
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
3
+ import { IPointer } from "tstl";
4
+ import typia from "typia";
5
+ import { v4 } from "uuid";
6
+
7
+ import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
8
+ import { AutoBeContext } from "../../context/AutoBeContext";
9
+ import { assertSchemaModel } from "../../context/assertSchemaModel";
10
+ import { enforceToolCall } from "../../utils/enforceToolCall";
11
+ import {
12
+ IAutoBeAnalyzeComposerApplication,
13
+ IComposeInput,
14
+ } from "./structures/IAutoBeAnalyzeComposerApplication";
15
+
16
+ export const orchestrateAnalyzeComposer = <Model extends ILlmSchema.Model>(
17
+ ctx: AutoBeContext<Model>,
18
+ pointer: IPointer<IComposeInput | null>,
19
+ ) => {
20
+ const controller = createController<Model>({
21
+ model: ctx.model,
22
+ execute: new AutoBeAnalyzeComposerApplication(),
23
+ build: (value: IComposeInput) => {
24
+ pointer.value = value;
25
+ },
26
+ });
27
+
28
+ const agent = new MicroAgentica({
29
+ model: ctx.model,
30
+ vendor: ctx.vendor,
31
+ controllers: [controller],
32
+ config: {
33
+ locale: ctx.config?.locale,
34
+ executor: {
35
+ describe: null,
36
+ },
37
+ },
38
+ histories: [
39
+ ...ctx
40
+ .histories()
41
+ .filter(
42
+ (h) => h.type === "userMessage" || h.type === "assistantMessage",
43
+ ),
44
+ {
45
+ id: v4(),
46
+ type: "systemMessage",
47
+ text: AutoBeSystemPromptConstant.ANALYZE_PLANNER,
48
+ created_at: new Date().toISOString(),
49
+ },
50
+ ],
51
+ });
52
+ enforceToolCall(agent);
53
+ return agent;
54
+ };
55
+
56
+ class AutoBeAnalyzeComposerApplication
57
+ implements IAutoBeAnalyzeComposerApplication
58
+ {
59
+ /**
60
+ * Compose project structure with roles and files.
61
+ *
62
+ * Design a list of roles and initial documents that you need to create for
63
+ * that requirement. Roles define team member responsibilities, while files
64
+ * define the documentation structure. These are managed separately. If you
65
+ * determine from the conversation that the user's requirements have not been
66
+ * fully gathered, you must stop the analysis and continue collecting the
67
+ * remaining requirements. In this case, you do not need to generate any files
68
+ * or roles. Simply pass an empty array to `input.files` and `input.roles`.
69
+ *
70
+ * @param input Prefix, roles, and files
71
+ * @returns
72
+ */
73
+ compose(input: IComposeInput): IComposeInput {
74
+ return input;
75
+ }
76
+ }
77
+
78
+ function createController<Model extends ILlmSchema.Model>(props: {
79
+ model: Model;
80
+ execute: AutoBeAnalyzeComposerApplication;
81
+ build: (input: IComposeInput) => void;
82
+ }): IAgenticaController.IClass<Model> {
83
+ assertSchemaModel(props.model);
84
+ const application: ILlmApplication<Model> = collection[
85
+ props.model
86
+ ] as unknown as ILlmApplication<Model>;
87
+ return {
88
+ protocol: "class",
89
+ name: "Compose",
90
+ application,
91
+ execute: {
92
+ compose: (input) => {
93
+ props.build(input);
94
+ return props.execute.compose(input);
95
+ },
96
+ } satisfies IAutoBeAnalyzeComposerApplication,
97
+ };
98
+ }
99
+
100
+ const claude = typia.llm.application<
101
+ AutoBeAnalyzeComposerApplication,
102
+ "claude",
103
+ { reference: true }
104
+ >();
105
+ const collection = {
106
+ chatgpt: typia.llm.application<
107
+ AutoBeAnalyzeComposerApplication,
108
+ "chatgpt",
109
+ { reference: true }
110
+ >(),
111
+ claude,
112
+ llama: claude,
113
+ deepseek: claude,
114
+ "3.1": claude,
115
+ };
@@ -0,0 +1,39 @@
1
+ import { MicroAgentica } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+
4
+ import { AutoBeContext } from "../../context/AutoBeContext";
5
+ import { randomBackoffStrategy } from "../../utils/backoffRetry";
6
+ import { enforceToolCall } from "../../utils/enforceToolCall";
7
+ import { transformAnalyzeReviewerHistories } from "./transformAnalyzeReviewerHistories";
8
+
9
+ export const orchestrateAnalyzeReviewer = async <
10
+ Model extends ILlmSchema.Model,
11
+ >(
12
+ ctx: AutoBeContext<Model>,
13
+ input: {
14
+ /** Total file names */
15
+ files: Record<string, string>;
16
+ },
17
+ ): Promise<string | null> => {
18
+ const agent = new MicroAgentica({
19
+ model: ctx.model,
20
+ vendor: ctx.vendor,
21
+ controllers: [],
22
+ config: {
23
+ locale: ctx.config?.locale,
24
+ backoffStrategy: randomBackoffStrategy,
25
+ executor: {
26
+ describe: null,
27
+ },
28
+ },
29
+ histories: [...transformAnalyzeReviewerHistories(input)],
30
+ });
31
+ enforceToolCall(agent);
32
+
33
+ const command = `proceed with the review of these files only.` as const;
34
+ const histories = await agent.conversate(command).finally(() => {
35
+ const tokenUsage = agent.getTokenUsage();
36
+ ctx.usage().record(tokenUsage, ["analyze"]);
37
+ });
38
+ return histories.find((h) => h.type === "assistantMessage")?.text ?? null;
39
+ };