agentica 0.12.16 → 0.12.19

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/bin/index.js +4 -5
  3. package/package.json +6 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Wrtn Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/index.js CHANGED
@@ -12,7 +12,7 @@ Expecting one of '${r.join("', '")}'`);let i=`${e}Help`;return this.on(i,e=>{let
12
12
  `)}),this}}function f(e,t){e._hasHelpOption&&t.find(t=>t===e._helpLongFlag||t===e._helpShortFlag)&&(e.outputHelp(),e._exit(0,"commander.helpDisplayed","(outputHelp)"))}function b(e){return e.map(e=>{let t,r;if(!e.startsWith("--inspect"))return e;let i="127.0.0.1",s="9229";return(null!==(r=e.match(/^(--inspect(-brk)?)$/))?t=r[1]:null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=r[1],/^\d+$/.test(r[3])?s=r[3]:i=r[3]):null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=r[1],i=r[3],s=r[4]),t&&"0"!==s)?`${t}=${i}:${parseInt(s)+1}`:e})}function v(e){let t=[];for(let r=e;r;r=r.parent)t.push(r);return t}t.Command=g},"../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/lib/error.js":function(e,t){class r extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}t.CommanderError=r,t.InvalidArgumentError=class extends r{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}},"../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/lib/help.js":function(e,t,r){let{humanReadableArgName:i}=r("../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/lib/argument.js");t.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden);if(e._hasImplicitHelpCommand()){let[,r,i]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=e.createCommand(r).helpOption(!1);s.description(e._helpCommandDescription),i&&s.arguments(i),t.push(s)}return this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let r=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),r=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),i=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(r||i){let s;s=r?i?e.createOption(e._helpFlags,e._helpDescription):e.createOption(e._helpShortFlag,e._helpDescription):e.createOption(e._helpLongFlag,e._helpDescription),t.push(s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let e=r.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return(e._argsDescription&&e._args.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e._args.find(e=>e.description))?e._args:[]}subcommandTerm(e){let t=e._args.map(e=>i(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,r)=>Math.max(e,t.subcommandTerm(r).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,r)=>Math.max(e,t.optionTerm(r).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,r)=>Math.max(e,t.optionTerm(r).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,r)=>Math.max(e,t.argumentTerm(r).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let t=e.parent;t;t=t.parent)r=t.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0)?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth||80;function s(e,s){if(s){let n=`${e.padEnd(r+2)}${s}`;return t.wrap(n,i-2,r+2)}return e}function n(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""],a=t.commandDescription(e);a.length>0&&(o=o.concat([t.wrap(a,i,0),""]));let l=t.visibleArguments(e).map(e=>s(t.argumentTerm(e),t.argumentDescription(e)));l.length>0&&(o=o.concat(["Arguments:",n(l),""]));let p=t.visibleOptions(e).map(e=>s(t.optionTerm(e),t.optionDescription(e)));if(p.length>0&&(o=o.concat(["Options:",n(p),""])),this.showGlobalOptions){let r=t.visibleGlobalOptions(e).map(e=>s(t.optionTerm(e),t.optionDescription(e)));r.length>0&&(o=o.concat(["Global Options:",n(r),""]))}let c=t.visibleCommands(e).map(e=>s(t.subcommandTerm(e),t.subcommandDescription(e)));return c.length>0&&(o=o.concat(["Commands:",n(c),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,r,i=40){let s=RegExp(`[\\n][ \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]+`);if(e.match(s))return e;let n=t-r;if(n<i)return e;let o=e.slice(0,r),a=e.slice(r).replace("\r\n","\n"),l=" ".repeat(r),p=`\\s\u200B`,c=RegExp(`
13
13
  |.{1,${n-1}}([${p}]|$)|[^${p}]+?([${p}]|$)`,"g");return o+(a.match(c)||[]).map((e,t)=>"\n"===e?"":(t>0?l:"")+e.trimEnd()).join("\n")}}},"../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/lib/option.js":function(e,t,r){let{InvalidArgumentError:i}=r("../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/lib/error.js");function s(e){let t,r;let i=e.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(t=i.shift()),r=i.shift(),!t&&/^-[^-]$/.test(r)&&(t=r,r=void 0),{shortFlag:t,longFlag:r}}t.Option=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=s(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new i(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},t.splitOptionFlags=s,t.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let i=this.negativeOptions.get(r).presetArg;return t.negate===((void 0!==i&&i)===e)}}},"../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/lib/suggestSimilar.js":function(e,t){t.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));let r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let i=[],s=3;return(t.forEach(t=>{if(t.length<=1)return;let r=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let t=0;t<=e.length;t++)r[t]=[t];for(let e=0;e<=t.length;e++)r[0][e]=e;for(let i=1;i<=t.length;i++)for(let s=1;s<=e.length;s++){let n=1;n=+(e[s-1]!==t[i-1]),r[s][i]=Math.min(r[s-1][i]+1,r[s][i-1]+1,r[s-1][i-1]+n),s>1&&i>1&&e[s-1]===t[i-2]&&e[s-2]===t[i-1]&&(r[s][i]=Math.min(r[s][i],r[s-2][i-2]+1))}return r[e.length][t.length]}(e,t),n=Math.max(e.length,t.length);(n-r)/n>.4&&(r<s?(s=r,i=[t]):r===s&&i.push(t))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1)?`
14
14
  (Did you mean one of ${i.join(", ")}?)`:1===i.length?`
15
- (Did you mean ${i[0]}?)`:""}},"../../node_modules/.pnpm/typia@8.0.0_@samchon+openapi@3.0.0_typescript@5.8.2/node_modules/typia/lib/TypeGuardError.mjs":function(e,t,r){"use strict";r.r(t),r.d(t,{TypeGuardError:()=>i});class i extends Error{method;path;expected;value;fake_expected_typed_value_;constructor(e){super(e.message||`Error on ${e.method}(): invalid type${e.path?` on ${e.path}`:""}, expect to be ${e.expected}`);let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.method=e.method,this.path=e.path,this.expected=e.expected,this.value=e.value}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";let{program:e,createCommand:t,createArgument:r,createOption:i,CommanderError:s,InvalidArgumentError:n,InvalidOptionArgumentError:o,Command:a,Argument:l,Option:p,Help:c}=__webpack_require__("../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/index.js");var h,u,m,d,_=__webpack_require__("../../node_modules/.pnpm/typia@8.0.0_@samchon+openapi@3.0.0_typescript@5.8.2/node_modules/typia/lib/internal/_assertGuard.js");let g=require("fs/promises");var f=__webpack_require__.n(g);let b=require("inquirer");var v=__webpack_require__.n(b),y=__webpack_require__("path"),O=__webpack_require__.n(y),w=__webpack_require__("child_process");!function(e){e.create=async e=>{let t={name:e.projectName,version:"0.0.1",description:"",scripts:{prepare:"ts-patch install",build:"tsc",dev:"ts-node src/index.ts",start:"node dist/index.js"}};await f().writeFile(O().join(e.projectPath,"package.json"),JSON.stringify(t,null,2)),console.log("✅ package.json created")},e.installPackage=e=>t=>{let r=t=>{switch(e){case"npm":return`npm install ${t}`;case"yarn":return`yarn add ${t}`;case"pnpm":return`pnpm add ${t}`;case"bun":return`bun add ${t}`;default:throw Error(`Unsupported package manager: ${e}`)}},i=t.services.map(e=>`@wrtnlabs/connector-${e}`);console.log("\uD83D\uDE80 Installing existing dependencies..."),(0,w.execSync)(`${e} install`,{cwd:t.projectPath,stdio:"inherit"}),i.forEach(e=>{console.log(`🚀 Installing ${e}...`),(0,w.execSync)(r(e),{cwd:t.projectPath,stdio:"inherit"})})}}(h||(h={}));let A=require("giget"),C=require("node:path");var x=__webpack_require__.n(C);let j=e=>e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("");!function(e){e.createAll=t=>{let r=e.create("import")({services:t.services}),i=e.create("connector")({services:t.services});return`
15
+ (Did you mean ${i[0]}?)`:""}},"../../node_modules/.pnpm/typia@8.0.0_@samchon+openapi@3.0.0_typescript@5.8.2/node_modules/typia/lib/TypeGuardError.mjs":function(e,t,r){"use strict";r.r(t),r.d(t,{TypeGuardError:()=>i});class i extends Error{method;path;expected;value;fake_expected_typed_value_;constructor(e){super(e.message||`Error on ${e.method}(): invalid type${e.path?` on ${e.path}`:""}, expect to be ${e.expected}`);let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.method=e.method,this.path=e.path,this.expected=e.expected,this.value=e.value}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";let{program:e,createCommand:t,createArgument:r,createOption:i,CommanderError:s,InvalidArgumentError:n,InvalidOptionArgumentError:o,Command:a,Argument:l,Option:p,Help:c}=__webpack_require__("../../node_modules/.pnpm/commander@10.0.1/node_modules/commander/index.js");var h,u,m,d,_=__webpack_require__("../../node_modules/.pnpm/typia@8.0.0_@samchon+openapi@3.0.0_typescript@5.8.2/node_modules/typia/lib/internal/_assertGuard.js");let g=require("fs/promises");var f=__webpack_require__.n(g);let b=require("inquirer");var v=__webpack_require__.n(b),y=__webpack_require__("path"),w=__webpack_require__.n(y);let O=require("giget"),j=require("node:path");var A=__webpack_require__.n(j);let C=e=>e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("");!function(e){e.createAll=t=>{let r=e.create("import")({services:t.services}),i=e.create("connector")({services:t.services});return`
16
16
  import { Agentica } from "@agentica/core";
17
17
  import typia from "typia";
18
18
  import dotenv from "dotenv";
@@ -33,13 +33,12 @@ export const agent = new Agentica({
33
33
  ${i}
34
34
  ],
35
35
  });
36
- `},e.create=e=>i=>{switch(e){case"import":return r(i);case"connector":return t(i)}};let t=e=>e.services.map(e=>{let t=j(e);return`{
36
+ `},e.create=e=>i=>{switch(e){case"import":return r(i);case"connector":return t(i)}};let t=e=>e.services.map(e=>{let t=C(e);return`{
37
37
  name: "${t} Connector",
38
38
  protocol: "class",
39
39
  application: typia.llm.application<${t}Service, "chatgpt">(),
40
40
  execute: new ${t}Service(),
41
- }`}).join(",\n"),r=e=>e.services.map(e=>`import { ${j(e)}Service } from "@wrtnlabs/connector-${e}";`).join("\n")}(u||(u={}));let k=require("node:util");function $(e){return(0,k.styleText)("blueBright",e)}function E(e){return(0,k.styleText)("redBright",e)}!function(e){e.execute=t=>{let r=e.PROJECT[t].runner;if(!r)throw Error(`Not supported project type: ${t}`);return r},e.PROJECT={standalone:{title:`Standalone ${$("Application")}`,key:"standalone",runner:async e=>t("standalone")(e)(async()=>{let t=x().join(e.projectPath,"src/index.ts"),r=await f().readFile(t,"utf-8");return{indexFilePath:t,indexFileContent:r}})},nodejs:{title:`NodeJS ${$("Agent Server")}`,key:"nodejs",runner:async e=>t("nodejs")(e)(async()=>{let t=x().join(e.projectPath,"src/index.ts"),r=await f().readFile(t,"utf-8").then(t=>0!==e.services.length?t.replace(/import { BbsArticleService }.*;\n/g,"").replace(/controllers:\s*\[[\s\S]*?\],\n/,"controllers: [/// INSERT CONTROLLER HERE],\n"):t);return{indexFilePath:t,indexFileContent:r}})},nestjs:{title:`NestJS ${$("Agent Server")}`,key:"nestjs",runner:async e=>t("nestjs")(e)(async()=>{let t=x().join(e.projectPath,"src/controllers/chat/ChatController.ts"),r=await f().readFile(t,"utf-8");return{indexFilePath:t,indexFileContent:r}})},react:{title:`React ${$("Client Application")}`,key:"react",runner:async t=>{await e.writeTemplate("react",t.projectName)}}};let t=t=>s=>async n=>{await e.writeTemplate(t,s.projectName);let o=u.create("import")({services:s.services}),a=u.create("connector")({services:s.services}),{indexFilePath:l,indexFileContent:p}=await n(),c=p.replace("/// INSERT IMPORT HERE",o).replace("/// INSERT CONTROLLER HERE",a);await r({filePath:l,taskName:"Agentica code",content:c}),await i(s)},r=async e=>{let t=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"prettier")).then(t=>t.format(e.content,{parser:"typescript"})).catch(()=>e.content);await f().writeFile(e.filePath,t),console.log(`✅ ${e.taskName} created`)},i=async e=>{let t=`OPENAI_API_KEY=${e.openAIKey}
42
- `;await f().writeFile(x().join(e.projectPath,".env"),t),console.log("✅ .env created")};e.writeTemplate=async(e,t)=>{await (0,A.downloadTemplate)(`github:wrtnlabs/agentica.template.${e}`,{dir:t}),console.log("✅ Template downloaded");let r=x().join(t,".github/dependabot.yml");await f().access(r).then(()=>!0).catch(()=>!1)&&await f().rm(r)}}(m||(m={}));var S=__webpack_require__("../../node_modules/.pnpm/typia@8.0.0_@samchon+openapi@3.0.0_typescript@5.8.2/node_modules/typia/lib/internal/_isFormatDateTime.js");let H=async()=>{try{let e=await fetch("https://registry.npmjs.org/-/v1/search?text=scope:@wrtnlabs&size=10000"),t=await e.json();return(()=>{let e;let t=e=>Array.isArray(e.objects)&&e.objects.every(e=>"object"==typeof e&&null!==e&&r(e))&&"number"==typeof e.total&&"string"==typeof e.time&&S._isFormatDateTime(e.time),r=e=>"object"==typeof e.package&&null!==e.package&&i(e.package),i=e=>"string"==typeof e.name,s=(t,r,i=!0)=>((Array.isArray(t.objects)||_._assertGuard(i,{method:"typia.assert",path:r+".objects",expected:"Array<__type>",value:t.objects},e))&&t.objects.every((t,s)=>("object"==typeof t&&null!==t||_._assertGuard(i,{method:"typia.assert",path:r+".objects["+s+"]",expected:"__type",value:t},e))&&n(t,r+".objects["+s+"]",i)||_._assertGuard(i,{method:"typia.assert",path:r+".objects["+s+"]",expected:"__type",value:t},e))||_._assertGuard(i,{method:"typia.assert",path:r+".objects",expected:"Array<__type>",value:t.objects},e))&&("number"==typeof t.total||_._assertGuard(i,{method:"typia.assert",path:r+".total",expected:"number",value:t.total},e))&&("string"==typeof t.time&&(S._isFormatDateTime(t.time)||_._assertGuard(i,{method:"typia.assert",path:r+".time",expected:'string & Format<"date-time">',value:t.time},e))||_._assertGuard(i,{method:"typia.assert",path:r+".time",expected:'(string & Format<"date-time">)',value:t.time},e)),n=(t,r,i=!0)=>("object"==typeof t.package&&null!==t.package||_._assertGuard(i,{method:"typia.assert",path:r+'["package"]',expected:"__type.o1",value:t.package},e))&&o(t.package,r+'["package"]',i)||_._assertGuard(i,{method:"typia.assert",path:r+'["package"]',expected:"__type.o1",value:t.package},e),o=(t,r,i=!0)=>"string"==typeof t.name||_._assertGuard(i,{method:"typia.assert",path:r+".name",expected:"string",value:t.name},e),a=e=>"object"==typeof e&&null!==e&&t(e);return(t,r)=>(!1===a(t)&&(e=r,((t,r,i=!0)=>("object"==typeof t&&null!==t||_._assertGuard(!0,{method:"typia.assert",path:r+"",expected:"INpmPackages",value:t},e))&&s(t,r+"",!0)||_._assertGuard(!0,{method:"typia.assert",path:r+"",expected:"INpmPackages",value:t},e))(t,"$input",!0)),t)})()(t).objects.map(e=>e.package.name).filter(e=>"@wrtnlabs/connector-shared"!==e&&/^@wrtnlabs\/connector-(?:[a-z0-9-]+)+$/.test(e)).map(e=>{let t=e.replace("@wrtnlabs/connector-","");return{name:t.replace("-"," ").toUpperCase(),value:t}})}catch(e){return console.error("Error occurred while fetching package list:",e),[]}},T=e=>[{type:"list",name:"packageManager",message:"Package Manager",choices:["npm","pnpm",{name:`yarn (berry ${$("is not supported")})`,value:"yarn"},"bun"]},e.options.project?null:{type:"list",name:"projectType",message:"Project Type",choices:Object.values(m.PROJECT).map(e=>({name:e.title,value:e.key}))},0===e.services.length?null:{type:"checkbox",name:"services",message:"Embedded Controllers",choices:e.services,when:e=>"react"!==e.projectType},{type:"input",name:"openAIKey",message:"Please enter your OPENAI_API_KEY:"}].filter(e=>null!==e);!function(e){async function t({projectName:e,options:t}){var r;let i=O().join(process.cwd(),e);if(await f().access(O().join(process.cwd(),e)).then(()=>!0).catch(()=>!1)){console.error(`❌ Project ${E(e)} already exists`);return}let s=T({services:"react"===t.project?[]:(await H()).sort((e,t)=>e.name.localeCompare(t.name)),options:t}),n=await v().prompt(s),o={...n,...t.project?{projectType:t.project}:{},...n.services?{services:n.services}:{services:[]}},{packageManager:a,openAIKey:l,projectType:p,services:c}=(()=>{let e;let t=e=>Array.isArray(e.services)&&e.services.every(e=>"string"==typeof e)&&("nodejs"===e.projectType||"nestjs"===e.projectType||"react"===e.projectType||"standalone"===e.projectType)&&("npm"===e.packageManager||"yarn"===e.packageManager||"pnpm"===e.packageManager||"bun"===e.packageManager)&&"string"==typeof e.openAIKey,r=(t,r,i=!0)=>((Array.isArray(t.services)||_._assertGuard(i,{method:"typia.assert",path:r+".services",expected:"Array<string>",value:t.services},e))&&t.services.every((t,s)=>"string"==typeof t||_._assertGuard(i,{method:"typia.assert",path:r+".services["+s+"]",expected:"string",value:t},e))||_._assertGuard(i,{method:"typia.assert",path:r+".services",expected:"Array<string>",value:t.services},e))&&("nodejs"===t.projectType||"nestjs"===t.projectType||"react"===t.projectType||"standalone"===t.projectType||_._assertGuard(i,{method:"typia.assert",path:r+".projectType",expected:'("nestjs" | "nodejs" | "react" | "standalone")',value:t.projectType},e))&&("npm"===t.packageManager||"yarn"===t.packageManager||"pnpm"===t.packageManager||"bun"===t.packageManager||_._assertGuard(i,{method:"typia.assert",path:r+".packageManager",expected:'("bun" | "npm" | "pnpm" | "yarn")',value:t.packageManager},e))&&("string"==typeof t.openAIKey||_._assertGuard(i,{method:"typia.assert",path:r+".openAIKey",expected:"string",value:t.openAIKey},e)),i=e=>"object"==typeof e&&null!==e&&t(e);return(t,s)=>(!1===i(t)&&(e=s,((t,i,s=!0)=>("object"==typeof t&&null!==t||_._assertGuard(!0,{method:"typia.assert",path:i+"",expected:"__object",value:t},e))&&r(t,i+"",!0)||_._assertGuard(!0,{method:"typia.assert",path:i+"",expected:"__object",value:t},e))(t,"$input",!0)),t)})()(o);await m.execute(p)({projectName:e,projectPath:i,openAIKey:l,services:c}),process.chdir(i),console.log("\uD83D\uDCE6 Package installation in progress..."),h.installPackage(a)({projectPath:i,services:c}),console.log(`
41
+ }`}).join(",\n"),r=e=>e.services.map(e=>`import { ${C(e)}Service } from "@wrtnlabs/connector-${e}";`).join("\n")}(h||(h={}));var x=__webpack_require__("child_process");!function(e){e.create=async e=>{let t={name:e.projectName,version:"0.0.1",description:"",scripts:{prepare:"ts-patch install",build:"tsc",dev:"ts-node src/index.ts",start:"node dist/index.js"}};await f().writeFile(w().join(e.projectPath,"package.json"),JSON.stringify(t,null,2)),console.log("✅ package.json created")},e.installPackage=e=>t=>{let r=t=>{switch(e){case"npm":return`npm install ${t}`;case"yarn":return`yarn add ${t}`;case"pnpm":return`pnpm add ${t}`;case"bun":return`bun add ${t}`;default:throw Error(`Unsupported package manager: ${e}`)}},i=t.services.map(e=>`@wrtnlabs/connector-${e}`);console.log("\uD83D\uDE80 Installing existing dependencies..."),(0,x.execSync)(`${e} install`,{cwd:t.projectPath,stdio:"inherit"}),i.forEach(e=>{console.log(`🚀 Installing ${e}...`),(0,x.execSync)(r(e),{cwd:t.projectPath,stdio:"inherit"})})}}(u||(u={}));let k=require("node:util");function $(e){return(0,k.styleText)("blueBright",e)}function E(e){return(0,k.styleText)("redBright",e)}!function(e){e.execute=t=>r=>async i=>{let s=e.PROJECT[t].runner;if(!s)throw Error(`Not supported project type: ${t}`);let{projectPaths:n}=await s(i);console.log("\uD83D\uDCE6 Package installation in progress..."),n.forEach(e=>{process.chdir(e),u.installPackage(r)({projectPath:e,services:i.services})})},e.PROJECT={standalone:{title:`Standalone ${$("Application")}`,key:"standalone",runner:async e=>(await t("standalone")(e)(async()=>{let t=A().join(e.projectPath,"src/index.ts"),r=await f().readFile(t,"utf-8");return{indexFilePath:t,indexFileContent:r}}),{projectPaths:[e.projectPath]})},nodejs:{title:`NodeJS ${$("Agent Server")}`,key:"nodejs",runner:async e=>(await t("nodejs")(e)(async()=>{let t=A().join(e.projectPath,"src/index.ts"),r=await f().readFile(t,"utf-8").then(t=>0!==e.services.length?t.replace(/import { BbsArticleService }.*;\n/g,"").replace(/controllers:\s*\[[\s\S]*?\],\n/,"controllers: [/// INSERT CONTROLLER HERE],\n"):t);return{indexFilePath:t,indexFileContent:r}}),{projectPaths:[e.projectPath]})},nestjs:{title:`NestJS ${$("Agent Server")}`,key:"nestjs",runner:async e=>(await t("nestjs")(e)(async()=>{let t=A().join(e.projectPath,"src/controllers/chat/ChatController.ts"),r=await f().readFile(t,"utf-8");return{indexFilePath:t,indexFileContent:r}}),{projectPaths:[e.projectPath]})},react:{title:`React ${$("Client Application")}`,key:"react",runner:async t=>(await e.writeTemplate("react",t.projectName),await i("react")(t),{projectPaths:[t.projectPath]})},"nestjs+react":{title:`NestJS + React ${$("Agent Server + Client Application")}`,key:"nestjs+react",runner:async r=>(await t("nestjs")({...r,projectPath:`${r.projectPath}/server`,projectName:`${r.projectName}/server`})(async()=>{let e=A().join(r.projectPath,"server","src/controllers/chat/ChatController.ts"),t=await f().readFile(e,"utf-8");return{indexFilePath:e,indexFileContent:t}}),await e.writeTemplate("react",`${r.projectName}/client`),await i("react")({...r,projectPath:`${r.projectPath}/client`,projectName:`${r.projectName}/client`}),{projectPaths:[`${r.projectPath}/server`,`${r.projectPath}/client`]})}};let t=t=>s=>async n=>{await e.writeTemplate(t,s.projectName);let o=h.create("import")({services:s.services}),a=h.create("connector")({services:s.services}),{indexFilePath:l,indexFileContent:p}=await n(),c=p.replace("/// INSERT IMPORT HERE",o).replace("/// INSERT CONTROLLER HERE",a);await r({filePath:l,taskName:"Agentica code",content:c}),await i(t)(s)},r=async e=>{let t=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"prettier")).then(t=>t.format(e.content,{parser:"typescript"})).catch(()=>e.content);await f().writeFile(e.filePath,t),console.log(`✅ ${e.taskName} created`)},i=e=>async t=>{let r=A().join(t.projectPath,".env"),i=Object.entries({standalone:{OPENAI_API_KEY:t.openAIKey},nodejs:{OPENAI_API_KEY:t.openAIKey,PORT:t.port},nestjs:{OPENAI_API_KEY:t.openAIKey,API_PORT:t.port},react:{VITE_AGENTICA_WS_URL:`ws://localhost:${t.port}/chat`}}[e]).map(([e,t])=>`${e}=${t}`).join("\n");try{await f().access(r),await f().appendFile(r,i),console.log("✅ .env updated")}catch(e){await f().writeFile(r,i),console.log("✅ .env created")}};e.writeTemplate=async(e,t)=>{await (0,O.downloadTemplate)(`github:wrtnlabs/agentica.template.${e}`,{dir:t}),console.log("✅ Template downloaded");let r=A().join(t,".github/dependabot.yml");await f().access(r).then(()=>!0).catch(()=>!1)&&await f().rm(r)}}(m||(m={}));var S=__webpack_require__("../../node_modules/.pnpm/typia@8.0.0_@samchon+openapi@3.0.0_typescript@5.8.2/node_modules/typia/lib/internal/_isFormatDateTime.js");let P=async()=>{try{let e=await fetch("https://registry.npmjs.org/-/v1/search?text=scope:@wrtnlabs&size=10000"),t=await e.json();return(()=>{let e;let t=e=>Array.isArray(e.objects)&&e.objects.every(e=>"object"==typeof e&&null!==e&&r(e))&&"number"==typeof e.total&&"string"==typeof e.time&&S._isFormatDateTime(e.time),r=e=>"object"==typeof e.package&&null!==e.package&&i(e.package),i=e=>"string"==typeof e.name,s=(t,r,i=!0)=>((Array.isArray(t.objects)||_._assertGuard(i,{method:"typia.assert",path:r+".objects",expected:"Array<__type>",value:t.objects},e))&&t.objects.every((t,s)=>("object"==typeof t&&null!==t||_._assertGuard(i,{method:"typia.assert",path:r+".objects["+s+"]",expected:"__type",value:t},e))&&n(t,r+".objects["+s+"]",i)||_._assertGuard(i,{method:"typia.assert",path:r+".objects["+s+"]",expected:"__type",value:t},e))||_._assertGuard(i,{method:"typia.assert",path:r+".objects",expected:"Array<__type>",value:t.objects},e))&&("number"==typeof t.total||_._assertGuard(i,{method:"typia.assert",path:r+".total",expected:"number",value:t.total},e))&&("string"==typeof t.time&&(S._isFormatDateTime(t.time)||_._assertGuard(i,{method:"typia.assert",path:r+".time",expected:'string & Format<"date-time">',value:t.time},e))||_._assertGuard(i,{method:"typia.assert",path:r+".time",expected:'(string & Format<"date-time">)',value:t.time},e)),n=(t,r,i=!0)=>("object"==typeof t.package&&null!==t.package||_._assertGuard(i,{method:"typia.assert",path:r+'["package"]',expected:"__type.o1",value:t.package},e))&&o(t.package,r+'["package"]',i)||_._assertGuard(i,{method:"typia.assert",path:r+'["package"]',expected:"__type.o1",value:t.package},e),o=(t,r,i=!0)=>"string"==typeof t.name||_._assertGuard(i,{method:"typia.assert",path:r+".name",expected:"string",value:t.name},e),a=e=>"object"==typeof e&&null!==e&&t(e);return(t,r)=>(!1===a(t)&&(e=r,((t,r,i=!0)=>("object"==typeof t&&null!==t||_._assertGuard(!0,{method:"typia.assert",path:r+"",expected:"INpmPackages",value:t},e))&&s(t,r+"",!0)||_._assertGuard(!0,{method:"typia.assert",path:r+"",expected:"INpmPackages",value:t},e))(t,"$input",!0)),t)})()(t).objects.map(e=>e.package.name).filter(e=>"@wrtnlabs/connector-shared"!==e&&/^@wrtnlabs\/connector-(?:[a-z0-9-]+)+$/.test(e)).map(e=>{let t=e.replace("@wrtnlabs/connector-","");return{name:t.replace("-"," ").toUpperCase(),value:t}})}catch(e){return console.error("Error occurred while fetching package list:",e),[]}},T=e=>[{type:"list",name:"packageManager",message:"Package Manager",choices:["npm","pnpm",{name:`yarn (berry ${$("is not supported")})`,value:"yarn"},"bun"]},e.options.project?null:{type:"list",name:"projectType",message:"Project Type",choices:Object.values(m.PROJECT).map(e=>({name:e.title,value:e.key}))},"standalone"===e.options.project?null:{type:"input",name:"port",message:"Server Port(if project is client app, this port mean ws server port):",default:"3000",when:e=>"standalone"!==e.projectType},0===e.services.length?null:{type:"checkbox",name:"services",message:"Embedded Controllers",choices:e.services,when:e=>"react"!==e.projectType},{type:"input",name:"openAIKey",message:"Please enter your OPENAI_API_KEY:"}].filter(e=>null!==e);!function(e){async function t({projectName:e,options:t}){var r;let i=w().join(process.cwd(),e);if(await f().access(w().join(process.cwd(),e)).then(()=>!0).catch(()=>!1)){console.error(`❌ Project ${E(e)} already exists`);return}let s=T({services:"react"===t.project?[]:(await P()).sort((e,t)=>e.name.localeCompare(t.name)),options:t}),n=await v().prompt(s),o={...n,...t.project?{projectType:t.project}:{},...n.services?{services:n.services}:{services:[]}},{packageManager:a,openAIKey:l,projectType:p,services:c,port:h="3000"}=(()=>{let e;let t=e=>Array.isArray(e.services)&&e.services.every(e=>"string"==typeof e)&&("nodejs"===e.projectType||"nestjs"===e.projectType||"react"===e.projectType||"standalone"===e.projectType||"nestjs+react"===e.projectType)&&("npm"===e.packageManager||"yarn"===e.packageManager||"pnpm"===e.packageManager||"bun"===e.packageManager)&&"string"==typeof e.openAIKey&&(void 0===e.port||"string"==typeof e.port),r=(t,r,i=!0)=>((Array.isArray(t.services)||_._assertGuard(i,{method:"typia.assert",path:r+".services",expected:"Array<string>",value:t.services},e))&&t.services.every((t,s)=>"string"==typeof t||_._assertGuard(i,{method:"typia.assert",path:r+".services["+s+"]",expected:"string",value:t},e))||_._assertGuard(i,{method:"typia.assert",path:r+".services",expected:"Array<string>",value:t.services},e))&&("nodejs"===t.projectType||"nestjs"===t.projectType||"react"===t.projectType||"standalone"===t.projectType||"nestjs+react"===t.projectType||_._assertGuard(i,{method:"typia.assert",path:r+".projectType",expected:'("nestjs" | "nestjs+react" | "nodejs" | "react" | "standalone")',value:t.projectType},e))&&("npm"===t.packageManager||"yarn"===t.packageManager||"pnpm"===t.packageManager||"bun"===t.packageManager||_._assertGuard(i,{method:"typia.assert",path:r+".packageManager",expected:'("bun" | "npm" | "pnpm" | "yarn")',value:t.packageManager},e))&&("string"==typeof t.openAIKey||_._assertGuard(i,{method:"typia.assert",path:r+".openAIKey",expected:"string",value:t.openAIKey},e))&&(void 0===t.port||"string"==typeof t.port||_._assertGuard(i,{method:"typia.assert",path:r+".port",expected:"(string | undefined)",value:t.port},e)),i=e=>"object"==typeof e&&null!==e&&t(e);return(t,s)=>(!1===i(t)&&(e=s,((t,i,s=!0)=>("object"==typeof t&&null!==t||_._assertGuard(!0,{method:"typia.assert",path:i+"",expected:"__object",value:t},e))&&r(t,i+"",!0)||_._assertGuard(!0,{method:"typia.assert",path:i+"",expected:"__object",value:t},e))(t,"$input",!0)),t)})()(o);await m.execute(p)(a)({projectName:e,projectPath:i,openAIKey:l,services:c,port:h}),console.log(`
43
42
  🎉 Project ${e} created`),console.log(`
44
- ⚠️ ${(r="Note:",(0,k.styleText)("yellow",r))} Please implement constructor values for each controller generated in agent.ts or index.ts`)}e.execute=t}(d||(d={})),(async function(){let e=new a;e.command("start <directory>").description("Start a new project").option("-p, --project [nodejs|nestjs|react|standalone]","The project type").action(async(e,t)=>{if(!0===t.project){console.error(`
43
+ ⚠️ ${(r="Note:",(0,k.styleText)("yellow",r))} Please implement constructor values for each controller generated in agent.ts or index.ts`)}e.execute=t}(d||(d={})),(async function(){let e=new a;e.command("start <directory>").description("Start a new project").option("-p, --project [nodejs|nestjs|react|nestjs+react|standalone]","The project type").action(async(e,t)=>{if(!0===t.project){console.error(`
45
44
  ❌ The value of ${E("--project")} is required`);return}d.execute({projectName:e,options:t})}),console.log("--------------------------------"),console.log(` 🚀 Agentica ${$("Setup Wizard")}`),console.log("--------------------------------"),e.parse(process.argv)})().catch(e=>{console.error(e.message),process.exit(-1)})})();var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentica",
3
- "version": "0.12.16",
3
+ "version": "0.12.19",
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,12 +8,6 @@
8
8
  "exports": {
9
9
  ".": "./bin/index.js"
10
10
  },
11
- "scripts": {
12
- "prepare": "ts-patch install",
13
- "build": "rslib build",
14
- "dev": "rslib build --watch",
15
- "typecheck": "tsc --noEmit"
16
- },
17
11
  "author": "Wrtn Technologies",
18
12
  "homepage": "https://wrtnlabs.io/agentica",
19
13
  "license": "MIT",
@@ -61,5 +55,10 @@
61
55
  "ts-patch": "^3.3.0",
62
56
  "typia": "^8.0.0",
63
57
  "typescript": "~5.8.2"
58
+ },
59
+ "scripts": {
60
+ "build": "rslib build",
61
+ "dev": "rslib build --watch",
62
+ "typecheck": "tsc --noEmit"
64
63
  }
65
64
  }