@autobe/agent 0.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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/lib/AutoBeAgent.d.ts +29 -0
  3. package/lib/AutoBeAgent.js +88 -0
  4. package/lib/AutoBeAgent.js.map +1 -0
  5. package/lib/context/AutoBeContext.d.ts +13 -0
  6. package/lib/context/AutoBeContext.js +3 -0
  7. package/lib/context/AutoBeContext.js.map +1 -0
  8. package/lib/context/AutoBeState.d.ts +8 -0
  9. package/lib/context/AutoBeState.js +3 -0
  10. package/lib/context/AutoBeState.js.map +1 -0
  11. package/lib/context/AutoBeTokenUsage.d.ts +2 -0
  12. package/lib/context/AutoBeTokenUsage.js +6 -0
  13. package/lib/context/AutoBeTokenUsage.js.map +1 -0
  14. package/lib/context/IAutoBeApplication.d.ts +67 -0
  15. package/lib/context/IAutoBeApplication.js +3 -0
  16. package/lib/context/IAutoBeApplication.js.map +1 -0
  17. package/lib/context/IAutoBeApplicationProps.d.ts +6 -0
  18. package/lib/context/IAutoBeApplicationProps.js +3 -0
  19. package/lib/context/IAutoBeApplicationProps.js.map +1 -0
  20. package/lib/context/IAutoBeApplicationResult.d.ts +4 -0
  21. package/lib/context/IAutoBeApplicationResult.js +3 -0
  22. package/lib/context/IAutoBeApplicationResult.js.map +1 -0
  23. package/lib/factory/transformRouteDocument.d.ts +3 -0
  24. package/lib/factory/transformRouteDocument.js +50 -0
  25. package/lib/factory/transformRouteDocument.js.map +1 -0
  26. package/lib/index.d.ts +9 -0
  27. package/lib/index.js +49 -0
  28. package/lib/index.js.map +1 -0
  29. package/lib/index.mjs +1548 -0
  30. package/lib/index.mjs.map +1 -0
  31. package/lib/internal/createAutoBeApplication.d.ts +7 -0
  32. package/lib/internal/createAutoBeApplication.js +1452 -0
  33. package/lib/internal/createAutoBeApplication.js.map +1 -0
  34. package/lib/internal/createAutoBeState.d.ts +3 -0
  35. package/lib/internal/createAutoBeState.js +16 -0
  36. package/lib/internal/createAutoBeState.js.map +1 -0
  37. package/lib/internal/transformAgenticaHistory.d.ts +7 -0
  38. package/lib/internal/transformAgenticaHistory.js +27 -0
  39. package/lib/internal/transformAgenticaHistory.js.map +1 -0
  40. package/lib/orchestrate/index.d.ts +5 -0
  41. package/lib/orchestrate/index.js +14 -0
  42. package/lib/orchestrate/index.js.map +1 -0
  43. package/lib/orchestrate/interface/AutoBeInterfaceAgent.d.ts +0 -0
  44. package/lib/orchestrate/interface/AutoBeInterfaceAgent.js +2 -0
  45. package/lib/orchestrate/interface/AutoBeInterfaceAgent.js.map +1 -0
  46. package/lib/orchestrate/orchestrateAnalyze.d.ts +8 -0
  47. package/lib/orchestrate/orchestrateAnalyze.js +22 -0
  48. package/lib/orchestrate/orchestrateAnalyze.js.map +1 -0
  49. package/lib/orchestrate/orchestrateInterface.d.ts +8 -0
  50. package/lib/orchestrate/orchestrateInterface.js +22 -0
  51. package/lib/orchestrate/orchestrateInterface.js.map +1 -0
  52. package/lib/orchestrate/orchestratePrisma.d.ts +8 -0
  53. package/lib/orchestrate/orchestratePrisma.js +22 -0
  54. package/lib/orchestrate/orchestratePrisma.js.map +1 -0
  55. package/lib/orchestrate/orchestrateRealize.d.ts +5 -0
  56. package/lib/orchestrate/orchestrateRealize.js +19 -0
  57. package/lib/orchestrate/orchestrateRealize.js.map +1 -0
  58. package/lib/orchestrate/orchestrateTest.d.ts +5 -0
  59. package/lib/orchestrate/orchestrateTest.js +19 -0
  60. package/lib/orchestrate/orchestrateTest.js.map +1 -0
  61. package/lib/structures/IAutoBeConfig.d.ts +24 -0
  62. package/lib/structures/IAutoBeConfig.js +3 -0
  63. package/lib/structures/IAutoBeConfig.js.map +1 -0
  64. package/lib/structures/IAutoBeProps.d.ts +11 -0
  65. package/lib/structures/IAutoBeProps.js +3 -0
  66. package/lib/structures/IAutoBeProps.js.map +1 -0
  67. package/lib/structures/IAutoBeVendor.d.ts +2 -0
  68. package/lib/structures/IAutoBeVendor.js +3 -0
  69. package/lib/structures/IAutoBeVendor.js.map +1 -0
  70. package/package.json +67 -0
  71. package/src/AutoBeAgent.ts +101 -0
  72. package/src/context/AutoBeContext.ts +15 -0
  73. package/src/context/AutoBeState.ts +15 -0
  74. package/src/context/AutoBeTokenUsage.ts +3 -0
  75. package/src/context/IAutoBeApplication.ts +72 -0
  76. package/src/context/IAutoBeApplicationProps.ts +6 -0
  77. package/src/context/IAutoBeApplicationResult.ts +4 -0
  78. package/src/factory/transformRouteDocument.ts +49 -0
  79. package/src/index.ts +12 -0
  80. package/src/internal/createAutoBeApplication.ts +47 -0
  81. package/src/internal/createAutoBeState.ts +14 -0
  82. package/src/internal/transformAgenticaHistory.ts +54 -0
  83. package/src/orchestrate/index.ts +5 -0
  84. package/src/orchestrate/interface/AutoBeInterfaceAgent.ts +0 -0
  85. package/src/orchestrate/orchestrateAnalyze.ts +21 -0
  86. package/src/orchestrate/orchestrateInterface.ts +21 -0
  87. package/src/orchestrate/orchestratePrisma.ts +21 -0
  88. package/src/orchestrate/orchestrateRealize.ts +18 -0
  89. package/src/orchestrate/orchestrateTest.ts +18 -0
  90. package/src/structures/IAutoBeConfig.ts +25 -0
  91. package/src/structures/IAutoBeProps.ts +13 -0
  92. package/src/structures/IAutoBeVendor.ts +3 -0
@@ -0,0 +1,6 @@
1
+ export interface IAutoBeApplicationProps {
2
+ /**
3
+ * The reason of the function call.
4
+ */
5
+ reason: string;
6
+ }
@@ -0,0 +1,4 @@
1
+ export interface IAutoBeApplicationResult {
2
+ success: boolean;
3
+ description: string;
4
+ }
@@ -0,0 +1,49 @@
1
+ import { IAutoBeRouteDocument } from "@autobe/interface";
2
+ import { OpenApi } from "@samchon/openapi";
3
+
4
+ export function transformRouteDocument(
5
+ route: IAutoBeRouteDocument,
6
+ ): OpenApi.IDocument {
7
+ const paths: Record<string, OpenApi.IPath> = {};
8
+ for (const op of route.operations) {
9
+ paths[op.path] ??= {};
10
+ paths[op.path][op.method] = {
11
+ parameters: op.parameters.map((p) => ({
12
+ name: p.name,
13
+ in: "path",
14
+ schema: p.schema,
15
+ description: p.description,
16
+ required: true,
17
+ })),
18
+ requestBody: op.body
19
+ ? {
20
+ content: {
21
+ "application/json": {
22
+ schema: op.body.schema,
23
+ },
24
+ },
25
+ description: op.description,
26
+ required: true,
27
+ }
28
+ : undefined,
29
+ responses: op.response
30
+ ? {
31
+ [op.method === "post" ? 201 : 200]: {
32
+ content: {
33
+ "application/json": {
34
+ schema: op.response.schema,
35
+ },
36
+ },
37
+ description: op.description,
38
+ },
39
+ }
40
+ : undefined,
41
+ };
42
+ }
43
+ return {
44
+ openapi: "3.1.0",
45
+ paths,
46
+ components: route.components,
47
+ "x-samchon-emended-v4": true,
48
+ };
49
+ }
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from "./AutoBeAgent";
2
+
3
+ export * from "./context/AutoBeTokenUsage";
4
+
5
+ export * from "./structures/IAutoBeProps";
6
+ export * from "./structures/IAutoBeConfig";
7
+ export * from "./structures/IAutoBeVendor";
8
+
9
+ /**
10
+ * @internal
11
+ */
12
+ export * as orchestrate from "./orchestrate";
@@ -0,0 +1,47 @@
1
+ import { IAgenticaController } from "@agentica/core";
2
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
3
+ import typia from "typia";
4
+
5
+ import { AutoBeContext } from "../context/AutoBeContext";
6
+ import { IAutoBeApplication } from "../context/IAutoBeApplication";
7
+ import { orchestrateAnalyze } from "../orchestrate/orchestrateAnalyze";
8
+ import { orchestrateInterface } from "../orchestrate/orchestrateInterface";
9
+ import { orchestratePrisma } from "../orchestrate/orchestratePrisma";
10
+ import { orchestrateRealize } from "../orchestrate/orchestrateRealize";
11
+ import { orchestrateTest } from "../orchestrate/orchestrateTest";
12
+
13
+ export const createAutoBeController = <Model extends ILlmSchema.Model>(props: {
14
+ model: Model;
15
+ context: AutoBeContext<Model>;
16
+ }): IAgenticaController.IClass<Model> => {
17
+ const application: ILlmApplication<Model> = collection[
18
+ props.model
19
+ ] as unknown as ILlmApplication<Model>;
20
+ return {
21
+ protocol: "class",
22
+ name: "autobe",
23
+ application,
24
+ execute: {
25
+ analyze: orchestrateAnalyze(props.context),
26
+ prisma: orchestratePrisma(props.context),
27
+ interface: orchestrateInterface(props.context),
28
+ test: orchestrateTest(props.context),
29
+ realize: orchestrateRealize(props.context),
30
+ },
31
+ };
32
+ };
33
+
34
+ const claude = typia.llm.application<IAutoBeApplication, "claude">();
35
+ const collection = {
36
+ chatgpt: typia.llm.application<
37
+ IAutoBeApplication,
38
+ "chatgpt",
39
+ { reference: true }
40
+ >(),
41
+ gemini: typia.llm.application<IAutoBeApplication, "gemini">(),
42
+ claude,
43
+ llama: claude,
44
+ deepseek: claude,
45
+ "3.1": claude,
46
+ "3.0": typia.llm.application<IAutoBeApplication, "3.0">(),
47
+ };
@@ -0,0 +1,14 @@
1
+ import { AutoBeHistory } from "@autobe/interface";
2
+
3
+ import { AutoBeState } from "../context/AutoBeState";
4
+
5
+ export const createAutoBeState = (histories: AutoBeHistory[]): AutoBeState => {
6
+ const reversed = histories.slice().reverse();
7
+ return {
8
+ analyze: reversed.find((h) => h.type === "analyze") ?? null,
9
+ prisma: reversed.find((h) => h.type === "prisma") ?? null,
10
+ interface: reversed.find((h) => h.type === "interface") ?? null,
11
+ test: reversed.find((h) => h.type === "test") ?? null,
12
+ realize: reversed.find((h) => h.type === "realize") ?? null,
13
+ };
14
+ };
@@ -0,0 +1,54 @@
1
+ import { AgenticaOperation, MicroAgenticaHistory } from "@agentica/core";
2
+ import {
3
+ AutoBeAssistantMessageHistory,
4
+ AutoBeHistory,
5
+ AutoBeUserMessageHistory,
6
+ } from "@autobe/interface";
7
+ import { ILlmSchema } from "@samchon/openapi";
8
+
9
+ export function transformAgenticaHistory<
10
+ Model extends ILlmSchema.Model,
11
+ >(props: {
12
+ operations: readonly AgenticaOperation<Model>[];
13
+ history: AutoBeHistory;
14
+ }): MicroAgenticaHistory<Model> | null {
15
+ if (props.history.type === "userMessage")
16
+ return {
17
+ ...props.history,
18
+ toJSON: () => props.history as AutoBeUserMessageHistory,
19
+ };
20
+ else if (props.history.type === "assistantMessage")
21
+ return {
22
+ ...props.history,
23
+ toJSON: () => props.history as AutoBeAssistantMessageHistory,
24
+ };
25
+
26
+ const operation: AgenticaOperation<Model> | undefined = props.operations.find(
27
+ (op) => op.function.name === props.history.type,
28
+ );
29
+ if (operation === undefined) return null;
30
+ const partial = {
31
+ id: props.history.id,
32
+ type: "execute" as const,
33
+ arguments: {
34
+ reason: props.history.reason,
35
+ },
36
+ value: {
37
+ success:
38
+ props.history.type === "analyze" || props.history.type === "interface"
39
+ ? true
40
+ : props.history.result.type === "success",
41
+ description: props.history.description,
42
+ },
43
+ };
44
+ return {
45
+ ...partial,
46
+ protocol: operation.protocol as "class",
47
+ operation: operation as AgenticaOperation.Class<Model>,
48
+ toJSON: () => ({
49
+ ...partial,
50
+ protocol: operation.protocol as "class",
51
+ operation: operation.toJSON(),
52
+ }),
53
+ };
54
+ }
@@ -0,0 +1,5 @@
1
+ export { orchestrateAnalyze as analyze } from "./orchestrateAnalyze";
2
+ export { orchestrateInterface as interface } from "./orchestrateInterface";
3
+ export { orchestratePrisma as prisma } from "./orchestratePrisma";
4
+ export { orchestrateTest as test } from "./orchestrateTest";
5
+ export { orchestrateRealize as realize } from "./orchestrateRealize";
@@ -0,0 +1,21 @@
1
+ import {
2
+ AutoBeAnalyzeHistory,
3
+ AutoBeAssistantMessageHistory,
4
+ } from "@autobe/interface";
5
+ import { ILlmSchema } from "@samchon/openapi";
6
+
7
+ import { AutoBeContext } from "../context/AutoBeContext";
8
+ import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
9
+
10
+ /**
11
+ * @todo Kakasoo
12
+ */
13
+ export const orchestrateAnalyze =
14
+ <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
15
+ async (
16
+ props: IAutoBeApplicationProps,
17
+ ): Promise<AutoBeAssistantMessageHistory | AutoBeAnalyzeHistory> => {
18
+ ctx;
19
+ props;
20
+ return null!;
21
+ };
@@ -0,0 +1,21 @@
1
+ import {
2
+ AutoBeAnalyzeHistory,
3
+ AutoBeAssistantMessageHistory,
4
+ } from "@autobe/interface";
5
+ import { ILlmSchema } from "@samchon/openapi";
6
+
7
+ import { AutoBeContext } from "../context/AutoBeContext";
8
+ import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
9
+
10
+ /**
11
+ * @todo Samchon
12
+ */
13
+ export const orchestrateInterface =
14
+ <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
15
+ async (
16
+ props: IAutoBeApplicationProps,
17
+ ): Promise<AutoBeAssistantMessageHistory | AutoBeAnalyzeHistory> => {
18
+ ctx;
19
+ props;
20
+ return null!;
21
+ };
@@ -0,0 +1,21 @@
1
+ import {
2
+ AutoBeAssistantMessageHistory,
3
+ AutoBePrismaHistory,
4
+ } from "@autobe/interface";
5
+ import { ILlmSchema } from "@samchon/openapi";
6
+
7
+ import { AutoBeContext } from "../context/AutoBeContext";
8
+ import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
9
+
10
+ /**
11
+ * @todo Michael
12
+ */
13
+ export const orchestratePrisma =
14
+ <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
15
+ async (
16
+ props: IAutoBeApplicationProps,
17
+ ): Promise<AutoBeAssistantMessageHistory | AutoBePrismaHistory> => {
18
+ ctx;
19
+ props;
20
+ return null!;
21
+ };
@@ -0,0 +1,18 @@
1
+ import {
2
+ AutoBeAssistantMessageHistory,
3
+ AutoBeRealizeHistory,
4
+ } from "@autobe/interface";
5
+ import { ILlmSchema } from "@samchon/openapi";
6
+
7
+ import { AutoBeContext } from "../context/AutoBeContext";
8
+ import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
9
+
10
+ export const orchestrateRealize =
11
+ <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
12
+ async (
13
+ props: IAutoBeApplicationProps,
14
+ ): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
15
+ ctx;
16
+ props;
17
+ return null!;
18
+ };
@@ -0,0 +1,18 @@
1
+ import {
2
+ AutoBeAssistantMessageHistory,
3
+ AutoBeTestHistory,
4
+ } from "@autobe/interface";
5
+ import { ILlmSchema } from "@samchon/openapi";
6
+
7
+ import { AutoBeContext } from "../context/AutoBeContext";
8
+ import { IAutoBeApplicationProps } from "../context/IAutoBeApplicationProps";
9
+
10
+ export const orchestrateTest =
11
+ <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
12
+ async (
13
+ props: IAutoBeApplicationProps,
14
+ ): Promise<AutoBeAssistantMessageHistory | AutoBeTestHistory> => {
15
+ ctx;
16
+ props;
17
+ return null!;
18
+ };
@@ -0,0 +1,25 @@
1
+ export interface IAutoBeConfig {
2
+ /**
3
+ * Locale of the A.I. chatbot.
4
+ *
5
+ * If you configure this property, the A.I. chatbot will conversate with
6
+ * the given locale. You can get the locale value by
7
+ *
8
+ * - Browser: `navigator.language`
9
+ * - NodeJS: `process.env.LANG.split(".")[0]`
10
+ *
11
+ * @default your_locale
12
+ */
13
+ locale?: string;
14
+
15
+ /**
16
+ * Timezone of the A.I. chatbot.
17
+ *
18
+ * If you configure this property, the A.I. chatbot will consider the
19
+ * given timezone. You can get the timezone value by
20
+ * `Intl.DateTimeFormat().resolvedOptions().timeZone`.
21
+ *
22
+ * @default your_timezone
23
+ */
24
+ timezone?: string;
25
+ }
@@ -0,0 +1,13 @@
1
+ import { AutoBeHistory, IAutoBeCompiler } from "@autobe/interface";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+
4
+ import { IAutoBeConfig } from "./IAutoBeConfig";
5
+ import { IAutoBeVendor } from "./IAutoBeVendor";
6
+
7
+ export interface IAutoBeProps<Model extends ILlmSchema.Model> {
8
+ model: Model;
9
+ vendor: IAutoBeVendor;
10
+ compiler: IAutoBeCompiler;
11
+ histories?: AutoBeHistory[] | undefined;
12
+ config?: IAutoBeConfig | undefined;
13
+ }
@@ -0,0 +1,3 @@
1
+ import { IAgenticaVendor } from "@agentica/core";
2
+
3
+ export type IAutoBeVendor = IAgenticaVendor;