agentica 0.1.0 → 0.12.4
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.
- package/README.md +67 -67
- package/bin/bases/Connector.d.ts +9 -0
- package/bin/bases/Connector.js +67 -0
- package/bin/bases/Connector.js.map +1 -0
- package/bin/bases/Package.d.ts +11 -0
- package/bin/bases/Package.js +74 -0
- package/bin/bases/Package.js.map +1 -0
- package/bin/bases/Tsconfig.d.ts +5 -0
- package/bin/bases/Tsconfig.js +135 -0
- package/bin/bases/Tsconfig.js.map +1 -0
- package/bin/executable/AgenticaStart.d.ts +7 -0
- package/bin/executable/AgenticaStart.js +324 -0
- package/bin/executable/AgenticaStart.js.map +1 -0
- package/bin/index.js +24 -43
- package/bin/index.js.map +1 -1
- package/bin/structures/IAgenticaStart.d.ts +31 -0
- package/bin/structures/IAgenticaStart.js +3 -0
- package/bin/structures/IAgenticaStart.js.map +1 -0
- package/bin/structures/IAgenticaStartOption.d.ts +13 -0
- package/bin/structures/IAgenticaStartOption.js +3 -0
- package/bin/structures/IAgenticaStartOption.js.map +1 -0
- package/bin/utils/capitalize.d.ts +1 -0
- package/bin/utils/capitalize.js +12 -0
- package/bin/utils/capitalize.js.map +1 -0
- package/bin/utils/createProjectDirectory.d.ts +3 -0
- package/bin/utils/createProjectDirectory.js +16 -0
- package/bin/utils/createProjectDirectory.js.map +1 -0
- package/bin/utils/getNpmPackages.d.ts +14 -0
- package/bin/utils/getNpmPackages.js +147 -0
- package/bin/utils/getNpmPackages.js.map +1 -0
- package/bin/utils/getQuestions.d.ts +8 -0
- package/bin/utils/getQuestions.js +45 -0
- package/bin/utils/getQuestions.js.map +1 -0
- package/bin/utils/types/PackageManager.d.ts +1 -0
- package/bin/utils/types/PackageManager.js +3 -0
- package/bin/utils/types/PackageManager.js.map +1 -0
- package/bin/utils/types/ProjectOption.d.ts +4 -0
- package/bin/utils/types/ProjectOption.js +3 -0
- package/bin/utils/types/ProjectOption.js.map +1 -0
- package/package.json +11 -3
- package/src/bases/Connector.ts +80 -0
- package/src/bases/Package.ts +75 -0
- package/src/bases/Tsconfig.ts +122 -0
- package/src/executable/AgenticaStart.ts +301 -0
- package/src/index.ts +39 -60
- package/src/structures/IAgenticaStart.ts +35 -0
- package/src/structures/IAgenticaStartOption.ts +13 -0
- package/src/utils/capitalize.ts +7 -0
- package/src/utils/createProjectDirectory.ts +14 -0
- package/src/utils/getNpmPackages.ts +45 -0
- package/src/utils/getQuestions.ts +48 -0
- package/src/utils/types/PackageManager.ts +1 -0
- package/src/utils/types/ProjectOption.ts +4 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.getNpmPackages = void 0;
|
|
49
|
+
const __typia_transform__isFormatDateTime = __importStar(require("typia/lib/internal/_isFormatDateTime.js"));
|
|
50
|
+
const __typia_transform__assertGuard = __importStar(require("typia/lib/internal/_assertGuard.js"));
|
|
51
|
+
const axios_1 = __importDefault(require("axios"));
|
|
52
|
+
const typia_1 = __importDefault(require("typia"));
|
|
53
|
+
const getNpmPackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
try {
|
|
55
|
+
const response = yield axios_1.default.get("https://registry.npmjs.org/-/v1/search?text=scope:@wrtnlabs&size=10000");
|
|
56
|
+
const data = (() => { const _io0 = input => Array.isArray(input.objects) && input.objects.every(elem => "object" === typeof elem && null !== elem && _io1(elem)) && "number" === typeof input.total && ("string" === typeof input.time && __typia_transform__isFormatDateTime._isFormatDateTime(input.time)); const _io1 = input => "object" === typeof input["package"] && null !== input["package"] && _io2(input["package"]); const _io2 = input => "string" === typeof input.name; const _ao0 = (input, _path, _exceptionable = true) => ((Array.isArray(input.objects) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
57
|
+
method: "typia.assert",
|
|
58
|
+
path: _path + ".objects",
|
|
59
|
+
expected: "Array<__type>",
|
|
60
|
+
value: input.objects
|
|
61
|
+
}, _errorFactory)) && input.objects.every((elem, _index2) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
62
|
+
method: "typia.assert",
|
|
63
|
+
path: _path + ".objects[" + _index2 + "]",
|
|
64
|
+
expected: "__type",
|
|
65
|
+
value: elem
|
|
66
|
+
}, _errorFactory)) && _ao1(elem, _path + ".objects[" + _index2 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
67
|
+
method: "typia.assert",
|
|
68
|
+
path: _path + ".objects[" + _index2 + "]",
|
|
69
|
+
expected: "__type",
|
|
70
|
+
value: elem
|
|
71
|
+
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
72
|
+
method: "typia.assert",
|
|
73
|
+
path: _path + ".objects",
|
|
74
|
+
expected: "Array<__type>",
|
|
75
|
+
value: input.objects
|
|
76
|
+
}, _errorFactory)) && ("number" === typeof input.total || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
77
|
+
method: "typia.assert",
|
|
78
|
+
path: _path + ".total",
|
|
79
|
+
expected: "number",
|
|
80
|
+
value: input.total
|
|
81
|
+
}, _errorFactory)) && ("string" === typeof input.time && (__typia_transform__isFormatDateTime._isFormatDateTime(input.time) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
82
|
+
method: "typia.assert",
|
|
83
|
+
path: _path + ".time",
|
|
84
|
+
expected: "string & Format<\"date-time\">",
|
|
85
|
+
value: input.time
|
|
86
|
+
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
87
|
+
method: "typia.assert",
|
|
88
|
+
path: _path + ".time",
|
|
89
|
+
expected: "(string & Format<\"date-time\">)",
|
|
90
|
+
value: input.time
|
|
91
|
+
}, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => ("object" === typeof input["package"] && null !== input["package"] || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
92
|
+
method: "typia.assert",
|
|
93
|
+
path: _path + "[\"package\"]",
|
|
94
|
+
expected: "__type.o1",
|
|
95
|
+
value: input["package"]
|
|
96
|
+
}, _errorFactory)) && _ao2(input["package"], _path + "[\"package\"]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
97
|
+
method: "typia.assert",
|
|
98
|
+
path: _path + "[\"package\"]",
|
|
99
|
+
expected: "__type.o1",
|
|
100
|
+
value: input["package"]
|
|
101
|
+
}, _errorFactory); const _ao2 = (input, _path, _exceptionable = true) => "string" === typeof input.name || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
102
|
+
method: "typia.assert",
|
|
103
|
+
path: _path + ".name",
|
|
104
|
+
expected: "string",
|
|
105
|
+
value: input.name
|
|
106
|
+
}, _errorFactory); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
107
|
+
if (false === __is(input)) {
|
|
108
|
+
_errorFactory = errorFactory;
|
|
109
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
|
|
110
|
+
method: "typia.assert",
|
|
111
|
+
path: _path + "",
|
|
112
|
+
expected: "INpmPackages",
|
|
113
|
+
value: input
|
|
114
|
+
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
|
|
115
|
+
method: "typia.assert",
|
|
116
|
+
path: _path + "",
|
|
117
|
+
expected: "INpmPackages",
|
|
118
|
+
value: input
|
|
119
|
+
}, _errorFactory))(input, "$input", true);
|
|
120
|
+
}
|
|
121
|
+
return input;
|
|
122
|
+
}; })()(response.data);
|
|
123
|
+
return data.objects
|
|
124
|
+
.map((pkg) => pkg.package.name)
|
|
125
|
+
.filter((name) => {
|
|
126
|
+
// shared is not connector package. This is connector util package.
|
|
127
|
+
if (name === "@wrtnlabs/connector-shared") {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const regex = /^@wrtnlabs\/connector-(?:[a-z0-9-]+)+$/;
|
|
131
|
+
return regex.test(name);
|
|
132
|
+
})
|
|
133
|
+
.map((name) => {
|
|
134
|
+
const serviceName = name.replace("@wrtnlabs/connector-", "");
|
|
135
|
+
return {
|
|
136
|
+
name: serviceName.replace("-", " ").toUpperCase(),
|
|
137
|
+
value: serviceName,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.error("Error occurred while fetching package list:", error);
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
exports.getNpmPackages = getNpmPackages;
|
|
147
|
+
//# sourceMappingURL=getNpmPackages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNpmPackages.js","sourceRoot":"","sources":["../../src/utils/getNpmPackages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,kDAAoC;AAY7B,MAAM,cAAc,GAAG,GAE5B,EAAE;IACF,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,wEAAwE,CACzE,CAAC;QACF,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAA8B,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO;aAChB,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;aACnC,MAAM,CAAC,CAAC,IAAY,EAAE,EAAE;YACvB,mEAAmE;YACnE,IAAI,IAAI,KAAK,4BAA4B,EAAE,CAAC;gBAC1C,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,KAAK,GAAG,wCAAwC,CAAC;YACvD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;YACpB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;YAC7D,OAAO;gBACL,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;gBACjD,KAAK,EAAE,WAAW;aACnB,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;QACpE,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAA,CAAC;AA/BW,QAAA,cAAc,kBA+BzB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getQuestions = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const getQuestions = (input) => {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
type: "list",
|
|
12
|
+
name: "packageManager",
|
|
13
|
+
message: "Package Manager",
|
|
14
|
+
choices: [
|
|
15
|
+
"npm",
|
|
16
|
+
"pnpm",
|
|
17
|
+
`yarn (berry ${chalk_1.default.blueBright("is not supported")})`,
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "list",
|
|
22
|
+
name: "projectType",
|
|
23
|
+
message: "Project Type",
|
|
24
|
+
choices: [
|
|
25
|
+
`NodeJS ${chalk_1.default.blueBright("Agent Server")}`,
|
|
26
|
+
`NestJS ${chalk_1.default.blueBright("Agent Server")}`,
|
|
27
|
+
`React ${chalk_1.default.blueBright("Client Application")}`,
|
|
28
|
+
`Standard ${chalk_1.default.blueBright("Application")}`,
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "checkbox",
|
|
33
|
+
name: "services",
|
|
34
|
+
message: "Embedded Controllers",
|
|
35
|
+
choices: input.services,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "input",
|
|
39
|
+
name: "openAIKey",
|
|
40
|
+
message: "Please enter your OPEN_AI_API_KEY:",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
exports.getQuestions = getQuestions;
|
|
45
|
+
//# sourceMappingURL=getQuestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getQuestions.js","sourceRoot":"","sources":["../../src/utils/getQuestions.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAUnB,MAAM,YAAY,GAAG,CAC1B,KAAwB,EACF,EAAE;IACxB,OAAO;QACL;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE;gBACP,KAAK;gBACL,MAAM;gBACN,eAAe,eAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG;aACvD;SACF;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,cAAc;YACvB,OAAO,EAAE;gBACP,UAAU,eAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;gBAC5C,UAAU,eAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;gBAC5C,SAAS,eAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;gBACjD,YAAY,eAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;aAC9C;SACF;QACD;YACE,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,sBAAsB;YAC/B,OAAO,EAAE,KAAK,CAAC,QAAQ;SACxB;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,oCAAoC;SAC9C;KACF,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,YAAY,gBAqCvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type PackageManager = "npm" | "yarn" | "pnpm";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageManager.js","sourceRoot":"","sources":["../../../src/utils/types/PackageManager.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectOption.js","sourceRoot":"","sources":["../../../src/utils/types/ProjectOption.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentica",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"main": "bin/index.js",
|
|
5
5
|
"typings": "bin/index.d.ts",
|
|
6
6
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
"nestia": "bin/index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
+
"prepare": "ts-patch install",
|
|
11
12
|
"build": "rimraf bin && tsc",
|
|
12
|
-
"dev": "rimraf bin && tsc --watch"
|
|
13
|
+
"dev": "rimraf bin && tsc --watch",
|
|
14
|
+
"start:dev": "ts-node src/index.ts"
|
|
13
15
|
},
|
|
14
16
|
"author": "Wrtn Technologies",
|
|
15
17
|
"homepage": "https://wrtnlabs.io/agentica",
|
|
@@ -40,15 +42,21 @@
|
|
|
40
42
|
"src"
|
|
41
43
|
],
|
|
42
44
|
"dependencies": {
|
|
45
|
+
"axios": "^1.8.2",
|
|
46
|
+
"chalk": "^4.1.2",
|
|
43
47
|
"commander": "^10.0.0",
|
|
44
48
|
"comment-json": "^4.2.3",
|
|
45
49
|
"inquirer": "^8.2.5",
|
|
46
50
|
"package-manager-detector": "^0.2.0"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
53
|
+
"@types/axios": "^0.14.4",
|
|
49
54
|
"@types/inquirer": "^9.0.3",
|
|
50
55
|
"@types/node": "^18.19.76",
|
|
51
56
|
"rimraf": "^6.0.1",
|
|
52
|
-
"
|
|
57
|
+
"ts-node": "^10.9.2",
|
|
58
|
+
"ts-patch": "^3.3.0",
|
|
59
|
+
"typescript": "~5.8.2",
|
|
60
|
+
"typia": "^8.0.0"
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { capitalize } from "../utils/capitalize";
|
|
2
|
+
|
|
3
|
+
export namespace Connector {
|
|
4
|
+
export type Code = "import" | "connector";
|
|
5
|
+
|
|
6
|
+
export const createAll = (input: { services: string[] }): string => {
|
|
7
|
+
// Generate import statements for selected services
|
|
8
|
+
const serviceImports = create("import")({ services: input.services });
|
|
9
|
+
|
|
10
|
+
// Create Connector
|
|
11
|
+
const serviceConnectors = create("connector")({ services: input.services });
|
|
12
|
+
|
|
13
|
+
// Generate agentica code
|
|
14
|
+
const codeTemplate = `
|
|
15
|
+
import { Agentica } from "@agentica/core";
|
|
16
|
+
import typia from "typia";
|
|
17
|
+
import dotenv from "dotenv";
|
|
18
|
+
import { OpenAI } from "openai";
|
|
19
|
+
${serviceImports}
|
|
20
|
+
|
|
21
|
+
dotenv.config();
|
|
22
|
+
|
|
23
|
+
export const agent = new Agentica({
|
|
24
|
+
model: "chatgpt",
|
|
25
|
+
vendor: {
|
|
26
|
+
api: new OpenAI({
|
|
27
|
+
apiKey: process.env.OPENAI_API_KEY!
|
|
28
|
+
}),
|
|
29
|
+
model: "gpt-4o-mini",
|
|
30
|
+
},
|
|
31
|
+
controllers: [
|
|
32
|
+
${serviceConnectors}
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
return codeTemplate;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const create =
|
|
41
|
+
(code: Code) =>
|
|
42
|
+
(input: { services: string[] }): string => {
|
|
43
|
+
switch (code) {
|
|
44
|
+
case "import":
|
|
45
|
+
return createImport(input);
|
|
46
|
+
case "connector":
|
|
47
|
+
return createConnector(input);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const createConnector = (input: { services: string[] }): string => {
|
|
52
|
+
const serviceConnectors = input.services
|
|
53
|
+
.map((service) => {
|
|
54
|
+
const serviceName = capitalize(service);
|
|
55
|
+
return `{
|
|
56
|
+
name: "${serviceName} Connector",
|
|
57
|
+
protocol: "class",
|
|
58
|
+
application: typia.llm.application<${serviceName}Service, "chatgpt">(),
|
|
59
|
+
execute: new ${serviceName}Service(),
|
|
60
|
+
}`;
|
|
61
|
+
})
|
|
62
|
+
.join(",\n");
|
|
63
|
+
|
|
64
|
+
return serviceConnectors;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const createImport = (input: { services: string[] }) => {
|
|
68
|
+
// Generate import statements for selected services
|
|
69
|
+
const serviceImports = input.services
|
|
70
|
+
.map(
|
|
71
|
+
(service) =>
|
|
72
|
+
`import { ${capitalize(
|
|
73
|
+
service,
|
|
74
|
+
)}Service } from "@wrtnlabs/connector-${service}";`,
|
|
75
|
+
)
|
|
76
|
+
.join("\n");
|
|
77
|
+
|
|
78
|
+
return serviceImports;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { PackageManager } from "../utils/types/PackageManager";
|
|
6
|
+
|
|
7
|
+
export namespace Package {
|
|
8
|
+
export const create = async (input: {
|
|
9
|
+
projectName: string;
|
|
10
|
+
projectPath: string;
|
|
11
|
+
}): Promise<void> => {
|
|
12
|
+
const packageJson = {
|
|
13
|
+
name: input.projectName,
|
|
14
|
+
version: "0.0.1",
|
|
15
|
+
description: "",
|
|
16
|
+
scripts: {
|
|
17
|
+
build: "tsc",
|
|
18
|
+
dev: `ts-node ${input.projectName}/cli.ts`,
|
|
19
|
+
start: `node ${input.projectName}/cli.js`,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
await fs.writeFile(
|
|
24
|
+
path.join(input.projectPath, "package.json"),
|
|
25
|
+
JSON.stringify(packageJson, null, 2),
|
|
26
|
+
);
|
|
27
|
+
console.log("✅ package.json created");
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const installPackage =
|
|
31
|
+
(packageManager: PackageManager) =>
|
|
32
|
+
(input: { projectPath: string; services: string[] }) => {
|
|
33
|
+
const installCmd = (pkg: string) => {
|
|
34
|
+
switch (packageManager) {
|
|
35
|
+
case "npm":
|
|
36
|
+
return `npm install ${pkg}`;
|
|
37
|
+
case "yarn":
|
|
38
|
+
return `yarn add ${pkg}`;
|
|
39
|
+
case "pnpm":
|
|
40
|
+
return `pnpm add ${pkg}`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const dependencies = [
|
|
45
|
+
"openai",
|
|
46
|
+
"typia",
|
|
47
|
+
"dotenv",
|
|
48
|
+
"@agentica/core",
|
|
49
|
+
"readline",
|
|
50
|
+
...input.services.map((s) => `@wrtnlabs/connector-${s}`),
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const devDependencies = ["ts-node", "typescript"];
|
|
54
|
+
|
|
55
|
+
// install existing dependencies
|
|
56
|
+
console.log("🚀 Installing existing dependencies...");
|
|
57
|
+
execSync(`${packageManager} install`, {
|
|
58
|
+
cwd: input.projectPath,
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
dependencies.forEach((dep) => {
|
|
63
|
+
console.log(`🚀 Installing ${dep}...`);
|
|
64
|
+
execSync(installCmd(dep), { cwd: input.projectPath, stdio: "inherit" });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
devDependencies.forEach((dep) => {
|
|
68
|
+
console.log(`🚀 Installing ${dep}...`);
|
|
69
|
+
execSync(`${installCmd(dep)} -D`, {
|
|
70
|
+
cwd: input.projectPath,
|
|
71
|
+
stdio: "inherit",
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export namespace Tsconfig {
|
|
5
|
+
export const create = async (input: {
|
|
6
|
+
projectPath: string;
|
|
7
|
+
}): Promise<void> => {
|
|
8
|
+
await fs.writeFile(path.join(input.projectPath, "tsconfig.json"), tsconfig);
|
|
9
|
+
console.log("✅ tsconfig.json created");
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const tsconfig = `{
|
|
13
|
+
"compilerOptions": {
|
|
14
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
15
|
+
/* Projects */
|
|
16
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
17
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
18
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
19
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
20
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
21
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
22
|
+
/* Language and Environment */
|
|
23
|
+
"target": "es2015" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
24
|
+
"lib": [
|
|
25
|
+
"ES2021"
|
|
26
|
+
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
|
|
27
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
28
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
29
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
30
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
31
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
32
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
33
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
34
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
35
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
36
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
37
|
+
/* Modules */
|
|
38
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
39
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
40
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
41
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
42
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
43
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
44
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
45
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
46
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
47
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
48
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
49
|
+
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
50
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
51
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
52
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
53
|
+
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
54
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
55
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
56
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
57
|
+
/* JavaScript Support */
|
|
58
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
59
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
60
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
61
|
+
/* Emit */
|
|
62
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
63
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
64
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
65
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
66
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
67
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
68
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
69
|
+
"outDir": "./lib" /* Specify an output folder for all emitted files. */,
|
|
70
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
71
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
72
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
73
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
74
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
75
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
76
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
77
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
78
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
79
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
80
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
81
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
82
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
83
|
+
/* Interop Constraints */
|
|
84
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
85
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
86
|
+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
87
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
88
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
89
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
90
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
91
|
+
/* Type Checking */
|
|
92
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
93
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
94
|
+
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
|
|
95
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
96
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
97
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
98
|
+
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
99
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
100
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
101
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
102
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
103
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
104
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
105
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
106
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
107
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
108
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
109
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
110
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
111
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
112
|
+
/* Completeness */
|
|
113
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
114
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
115
|
+
"plugins": [
|
|
116
|
+
{
|
|
117
|
+
"transform": "typia/lib/transform"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}`;
|
|
122
|
+
}
|