openxgen 0.3.1 → 0.4.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.
package/dist/index.js CHANGED
@@ -419,231 +419,6 @@ var init_list = __esm({
419
419
  }
420
420
  });
421
421
 
422
- // src/index.ts
423
- import { Command } from "commander";
424
- import chalk15 from "chalk";
425
-
426
- // src/commands/config.ts
427
- init_store();
428
- init_client();
429
- init_format();
430
- import chalk2 from "chalk";
431
- function registerConfigCommand(program2) {
432
- const config = program2.command("config").description("XGEN CLI \uC124\uC815 \uAD00\uB9AC");
433
- config.command("set-server <url>").description("XGEN \uC11C\uBC84 URL \uC124\uC815").action((url) => {
434
- if (!url.startsWith("http://") && !url.startsWith("https://")) {
435
- printError("URL\uC740 http:// \uB610\uB294 https://\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4");
436
- process.exit(1);
437
- }
438
- setServer(url);
439
- resetClient();
440
- printSuccess(`\uC11C\uBC84 \uC124\uC815 \uC644\uB8CC: ${chalk2.underline(url)}`);
441
- });
442
- config.command("get-server").description("\uD604\uC7AC \uC124\uC815\uB41C \uC11C\uBC84 URL \uD655\uC778").action(() => {
443
- const server = getServer();
444
- if (server) {
445
- console.log(server);
446
- } else {
447
- printError("\uC11C\uBC84\uAC00 \uC124\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4");
448
- console.log(" \uC124\uC815: xgen config set-server <url>");
449
- }
450
- });
451
- config.command("list").description("\uC804\uCCB4 \uC124\uC815 \uD655\uC778").action(() => {
452
- const cfg = getConfig();
453
- console.log(chalk2.bold("\nXGEN CLI \uC124\uC815"));
454
- console.log(chalk2.gray("\u2500".repeat(40)));
455
- printKeyValue("\uC11C\uBC84", cfg.server);
456
- printKeyValue("\uAE30\uBCF8 \uC6CC\uD06C\uD50C\uB85C\uC6B0", cfg.defaultWorkflow);
457
- printKeyValue("\uD14C\uB9C8", cfg.theme);
458
- printKeyValue("\uC2A4\uD2B8\uB9BC \uB85C\uADF8", String(cfg.streamLogs));
459
- console.log();
460
- });
461
- config.command("set <key> <value>").description("\uC124\uC815 \uAC12 \uBCC0\uACBD").action((key, value) => {
462
- const allowedKeys = ["defaultWorkflow", "theme", "streamLogs"];
463
- if (!allowedKeys.includes(key)) {
464
- printError(`\uC54C \uC218 \uC5C6\uB294 \uC124\uC815 \uD0A4: ${key}`);
465
- console.log(` \uC0AC\uC6A9 \uAC00\uB2A5: ${allowedKeys.join(", ")}`);
466
- process.exit(1);
467
- }
468
- const parsed = key === "streamLogs" ? value === "true" : value;
469
- setConfig({ [key]: parsed });
470
- printSuccess(`${key} = ${value}`);
471
- });
472
- }
473
-
474
- // src/commands/login.ts
475
- init_auth();
476
- init_store();
477
- init_format();
478
- import chalk3 from "chalk";
479
- import { createInterface } from "readline";
480
- function prompt(question, hidden = false) {
481
- return new Promise((resolve) => {
482
- const rl = createInterface({
483
- input: process.stdin,
484
- output: process.stdout
485
- });
486
- if (hidden) {
487
- process.stdout.write(question);
488
- const stdin = process.stdin;
489
- const wasRaw = stdin.isRaw;
490
- if (stdin.isTTY) stdin.setRawMode(true);
491
- let password = "";
492
- const onData = (ch) => {
493
- const c = ch.toString("utf8");
494
- if (c === "\n" || c === "\r" || c === "") {
495
- if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
496
- stdin.removeListener("data", onData);
497
- process.stdout.write("\n");
498
- rl.close();
499
- resolve(password);
500
- } else if (c === "") {
501
- process.exit(0);
502
- } else if (c === "\x7F" || c === "\b") {
503
- if (password.length > 0) {
504
- password = password.slice(0, -1);
505
- process.stdout.write("\b \b");
506
- }
507
- } else {
508
- password += c;
509
- process.stdout.write("*");
510
- }
511
- };
512
- stdin.on("data", onData);
513
- } else {
514
- rl.question(question, (answer) => {
515
- rl.close();
516
- resolve(answer.trim());
517
- });
518
- }
519
- });
520
- }
521
- function registerLoginCommand(program2) {
522
- program2.command("login").description("XGEN \uC11C\uBC84\uC5D0 \uB85C\uADF8\uC778").option("-e, --email <email>", "\uC774\uBA54\uC77C").option("-p, --password <password>", "\uBE44\uBC00\uBC88\uD638").action(async (opts) => {
523
- const server = requireServer();
524
- printHeader("XGEN Login");
525
- console.log(chalk3.gray(`\uC11C\uBC84: ${server}
526
- `));
527
- let email = opts.email;
528
- let password = opts.password;
529
- if (!email) {
530
- email = await prompt(chalk3.white("\uC774\uBA54\uC77C: "));
531
- }
532
- if (!password) {
533
- password = await prompt(chalk3.white("\uBE44\uBC00\uBC88\uD638: "), true);
534
- }
535
- if (!email || !password) {
536
- printError("\uC774\uBA54\uC77C\uACFC \uBE44\uBC00\uBC88\uD638\uB97C \uBAA8\uB450 \uC785\uB825\uD558\uC138\uC694");
537
- process.exit(1);
538
- }
539
- try {
540
- const result = await apiLogin(email, password);
541
- if (result.success && result.access_token) {
542
- setAuth({
543
- accessToken: result.access_token,
544
- refreshToken: result.refresh_token ?? "",
545
- userId: result.user_id ?? "",
546
- username: result.username ?? "",
547
- isAdmin: false,
548
- expiresAt: null
549
- });
550
- console.log();
551
- printSuccess(`\uB85C\uADF8\uC778 \uC131\uACF5! ${chalk3.bold(result.username ?? email)}`);
552
- } else {
553
- printError(result.message || "\uB85C\uADF8\uC778 \uC2E4\uD328");
554
- process.exit(1);
555
- }
556
- } catch (err) {
557
- const msg = err?.response?.data?.message ?? err?.response?.data?.detail ?? err.message;
558
- printError(`\uB85C\uADF8\uC778 \uC2E4\uD328: ${msg}`);
559
- process.exit(1);
560
- }
561
- });
562
- program2.command("logout").description("\uB85C\uADF8\uC544\uC6C3").action(async () => {
563
- const { clearAuth: clearAuth2 } = await Promise.resolve().then(() => (init_store(), store_exports));
564
- clearAuth2();
565
- printSuccess("\uB85C\uADF8\uC544\uC6C3 \uC644\uB8CC");
566
- });
567
- program2.command("whoami").description("\uD604\uC7AC \uB85C\uADF8\uC778\uB41C \uC0AC\uC6A9\uC790 \uC815\uBCF4").action(async () => {
568
- const auth = getAuth();
569
- if (!auth) {
570
- printError("\uB85C\uADF8\uC778\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. xgen login \uC2E4\uD589\uD558\uC138\uC694");
571
- process.exit(1);
572
- }
573
- const server = requireServer();
574
- console.log(chalk3.bold("\n\uD604\uC7AC \uC0AC\uC6A9\uC790"));
575
- console.log(chalk3.gray("\u2500".repeat(30)));
576
- console.log(` ${chalk3.gray("\uC11C\uBC84:")} ${server}`);
577
- console.log(` ${chalk3.gray("\uC0AC\uC6A9\uC790:")} ${chalk3.bold(auth.username)}`);
578
- console.log(` ${chalk3.gray("User ID:")} ${auth.userId}`);
579
- try {
580
- const { apiValidate: apiValidate2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
581
- const result = await apiValidate2(auth.accessToken);
582
- if (result.valid) {
583
- console.log(` ${chalk3.gray("\uC0C1\uD0DC:")} ${chalk3.green("\uD65C\uC131")}`);
584
- if (result.is_admin) {
585
- console.log(` ${chalk3.gray("\uAD8C\uD55C:")} ${chalk3.yellow("\uAD00\uB9AC\uC790")}`);
586
- }
587
- if (result.user_type) {
588
- console.log(` ${chalk3.gray("\uC720\uD615:")} ${result.user_type}`);
589
- }
590
- } else {
591
- console.log(` ${chalk3.gray("\uC0C1\uD0DC:")} ${chalk3.red("\uD1A0\uD070 \uB9CC\uB8CC")}`);
592
- }
593
- } catch {
594
- console.log(` ${chalk3.gray("\uC0C1\uD0DC:")} ${chalk3.yellow("\uAC80\uC99D \uBD88\uAC00 (\uC11C\uBC84 \uC5F0\uACB0 \uC2E4\uD328)")}`);
595
- }
596
- console.log();
597
- });
598
- }
599
-
600
- // src/commands/workflow/index.ts
601
- init_list();
602
-
603
- // src/commands/workflow/info.ts
604
- init_store();
605
- init_workflow();
606
- init_format();
607
- import chalk5 from "chalk";
608
- async function workflowInfo(workflowId) {
609
- requireAuth();
610
- try {
611
- const detail = await getWorkflowDetail(workflowId);
612
- printHeader(`\uC6CC\uD06C\uD50C\uB85C\uC6B0: ${detail.workflow_name ?? workflowId}`);
613
- console.log();
614
- printKeyValue("ID", detail.id);
615
- printKeyValue("\uC774\uB984", detail.workflow_name);
616
- printKeyValue("\uC124\uBA85", detail.description ?? "(\uC5C6\uC74C)");
617
- if (detail.nodes && Array.isArray(detail.nodes)) {
618
- console.log();
619
- console.log(chalk5.bold(" \uB178\uB4DC \uAD6C\uC131:"));
620
- for (const node of detail.nodes) {
621
- const label = node.data?.label ?? node.id;
622
- const type = node.data?.type ?? "unknown";
623
- console.log(` ${chalk5.cyan("\u2022")} ${label} ${chalk5.gray(`(${type})`)}`);
624
- }
625
- }
626
- if (detail.parameters && Object.keys(detail.parameters).length > 0) {
627
- console.log();
628
- console.log(chalk5.bold(" \uD30C\uB77C\uBBF8\uD130:"));
629
- for (const [key, val] of Object.entries(detail.parameters)) {
630
- console.log(` ${chalk5.gray(key)}: ${JSON.stringify(val)}`);
631
- }
632
- }
633
- console.log();
634
- } catch (err) {
635
- const msg = err.message;
636
- printError(`\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC870\uD68C \uC2E4\uD328: ${msg}`);
637
- process.exit(1);
638
- }
639
- }
640
-
641
- // src/commands/workflow/run.ts
642
- init_store();
643
- init_workflow();
644
- import chalk7 from "chalk";
645
- import { randomUUID } from "crypto";
646
-
647
422
  // src/utils/sse.ts
648
423
  async function parseSSEStream(stream, onEvent, onDone, onError) {
649
424
  let buffer = "";
@@ -694,219 +469,16 @@ async function parseSSEStream(stream, onEvent, onDone, onError) {
694
469
  });
695
470
  });
696
471
  }
697
-
698
- // src/commands/workflow/run.ts
699
- init_format();
700
-
701
- // src/utils/markdown.ts
702
- import chalk6 from "chalk";
703
- var CODE_BLOCK_RE = /```(\w*)\n([\s\S]*?)```/g;
704
- var INLINE_CODE_RE = /`([^`]+)`/g;
705
- var BOLD_RE = /\*\*(.+?)\*\*/g;
706
- var HEADING_RE = /^(#{1,3})\s+(.+)$/gm;
707
- var LIST_RE = /^(\s*)[-*]\s+(.+)$/gm;
708
- var LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
709
- function renderMarkdown(text) {
710
- let result = text;
711
- result = result.replace(CODE_BLOCK_RE, (_match, lang, code) => {
712
- const trimmed = code.trimEnd();
713
- const header = lang ? chalk6.gray(` \u2500\u2500 ${lang} \u2500\u2500`) : chalk6.gray(" \u2500\u2500 code \u2500\u2500");
714
- const lines = trimmed.split("\n").map((l) => chalk6.white(` ${l}`)).join("\n");
715
- return `
716
- ${header}
717
- ${lines}
718
- ${chalk6.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
719
- `;
720
- });
721
- result = result.replace(INLINE_CODE_RE, (_m, code) => chalk6.cyan(`\`${code}\``));
722
- result = result.replace(BOLD_RE, (_m, text2) => chalk6.bold(text2));
723
- result = result.replace(HEADING_RE, (_m, hashes, text2) => {
724
- if (hashes.length === 1) return chalk6.bold.underline(text2);
725
- if (hashes.length === 2) return chalk6.bold(text2);
726
- return chalk6.bold.dim(text2);
727
- });
728
- result = result.replace(LIST_RE, (_m, indent, text2) => `${indent}${chalk6.cyan("\u2022")} ${text2}`);
729
- result = result.replace(LINK_RE, (_m, label, url) => `${chalk6.blue.underline(label)} ${chalk6.gray(`(${url})`)}`);
730
- return result;
731
- }
732
-
733
- // src/commands/workflow/run.ts
734
- async function workflowRun(workflowId, input, opts) {
735
- const auth = requireAuth();
736
- let workflowName = workflowId;
737
- try {
738
- const detail = await getWorkflowDetail(workflowId);
739
- workflowName = detail.workflow_name ?? workflowId;
740
- } catch {
741
- }
742
- if (!input) {
743
- if (opts.interactive || !process.stdin.isTTY) {
744
- const { createInterface: createInterface8 } = await import("readline");
745
- const rl = createInterface8({ input: process.stdin, output: process.stdout });
746
- input = await new Promise((resolve) => {
747
- rl.question(chalk7.cyan("\uC785\uB825> "), (answer) => {
748
- rl.close();
749
- resolve(answer.trim());
750
- });
751
- });
752
- } else {
753
- printError("\uC785\uB825\uAC12\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \uC0AC\uC6A9\uBC95:");
754
- console.log(' xgen workflow run <id> "\uC785\uB825 \uD14D\uC2A4\uFFFD\uFFFD\uFFFD"');
755
- console.log(" xgen workflow run -i <id>");
756
- process.exit(1);
757
- }
758
- }
759
- if (!input) {
760
- printError("\uC785\uB825\uAC12\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
761
- process.exit(1);
762
- }
763
- const interactionId = `cli_${randomUUID().slice(0, 8)}`;
764
- printHeader(`\uC2E4\uD589: ${workflowName}`);
765
- printInfo(`\uC785\uB825: ${input}`);
766
- console.log();
767
- try {
768
- const stream = await executeWorkflowStream({
769
- workflow_id: workflowId,
770
- workflow_name: workflowName,
771
- input_data: input,
772
- interaction_id: interactionId
773
- });
774
- let hasOutput = false;
775
- let fullResponse = "";
776
- await parseSSEStream(
777
- stream,
778
- (event) => {
779
- switch (event.type) {
780
- case "token":
781
- if (event.content) {
782
- if (!hasOutput) {
783
- hasOutput = true;
784
- console.log();
785
- }
786
- process.stdout.write(event.content);
787
- fullResponse += event.content;
788
- }
789
- break;
790
- case "log":
791
- if (opts.logs && event.content) {
792
- process.stderr.write(chalk7.gray(`[LOG] ${event.content}
793
- `));
794
- }
795
- break;
796
- case "node_status":
797
- if (opts.logs) {
798
- const nodeName = event.node_name ?? event.node_id ?? "?";
799
- const status = event.status ?? "?";
800
- process.stderr.write(
801
- chalk7.gray(`[\uB178\uB4DC] ${nodeName}: ${status}
802
- `)
803
- );
804
- }
805
- break;
806
- case "tool":
807
- if (opts.logs) {
808
- process.stderr.write(chalk7.gray(`[\uB3C4\uAD6C] ${JSON.stringify(event.data)}
809
- `));
810
- }
811
- break;
812
- case "complete":
813
- break;
814
- case "error":
815
- console.log();
816
- printError(event.error ?? event.content ?? "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958");
817
- break;
818
- default:
819
- if (event.content) {
820
- if (!hasOutput) {
821
- process.stdout.write(chalk7.green("\uC751\uB2F5: "));
822
- hasOutput = true;
823
- }
824
- process.stdout.write(event.content);
825
- }
826
- }
827
- },
828
- () => {
829
- if (hasOutput) {
830
- console.log();
831
- if (fullResponse.includes("```") || fullResponse.includes("**")) {
832
- console.log(chalk7.gray("\u2500".repeat(40)));
833
- console.log(renderMarkdown(fullResponse));
834
- }
835
- }
836
- console.log();
837
- console.log(chalk7.gray(`\uC138\uC158: ${interactionId}`));
838
- },
839
- (err) => {
840
- console.log();
841
- printError(`\uC2A4\uD2B8\uB9AC\uBC0D \uC624\uB958: ${err.message}`);
842
- }
843
- );
844
- } catch (err) {
845
- const msg = err?.response?.data?.detail ?? err.message;
846
- printError(`\uC2E4\uD589 \uC2E4\uD328: ${msg}`);
847
- process.exit(1);
848
- }
849
- }
850
-
851
- // src/commands/workflow/history.ts
852
- init_store();
853
- init_workflow();
854
- init_format();
855
- import chalk8 from "chalk";
856
- async function workflowHistory(workflowId, opts = {}) {
857
- requireAuth();
858
- const limit = opts.limit ?? 20;
859
- try {
860
- const logs = await getIOLogs(workflowId, limit);
861
- if (!logs || logs.length === 0) {
862
- console.log(chalk8.yellow("\n\uC2E4\uD589 \uC774\uB825\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.\n"));
863
- return;
864
- }
865
- printHeader(`\uC2E4\uD589 \uC774\uB825 (\uCD5C\uADFC ${logs.length}\uAC74)`);
866
- console.log();
867
- for (const log of logs) {
868
- console.log(
869
- ` ${chalk8.gray(formatDate(log.created_at))} ${chalk8.cyan(log.interaction_id)}`
870
- );
871
- console.log(` ${chalk8.white("\uC785\uB825:")} ${truncate(log.input_data, 60)}`);
872
- console.log(
873
- ` ${chalk8.green("\uCD9C\uB825:")} ${truncate(log.output_data, 60)}`
874
- );
875
- if (log.execution_time) {
876
- console.log(
877
- ` ${chalk8.gray("\uC2DC\uAC04:")} ${(log.execution_time / 1e3).toFixed(1)}s`
878
- );
879
- }
880
- console.log();
881
- }
882
- } catch (err) {
883
- const msg = err.message;
884
- printError(`\uC774\uB825 \uC870\uD68C \uC2E4\uD328: ${msg}`);
885
- process.exit(1);
886
- }
887
- }
888
-
889
- // src/commands/workflow/index.ts
890
- function registerWorkflowCommand(program2) {
891
- const wf = program2.command("workflow").alias("wf").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uAD00\uB9AC \uBC0F \uC2E4\uD589");
892
- wf.command("list").alias("ls").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D \uC870\uD68C").option("-d, --detail", "\uC0C1\uC138 \uC815\uBCF4 \uD3EC\uD568").action((opts) => workflowList(opts));
893
- wf.command("info <workflow-id>").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC0C1\uC138 \uC815\uBCF4").action((id) => workflowInfo(id));
894
- wf.command("run <workflow-id> [input]").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589").option("-i, --interactive", "\uC778\uD130\uB799\uD2F0\uBE0C \uBAA8\uB4DC (\uC785\uB825 \uD504\uB86C\uD504\uD2B8)").option("-l, --logs", "\uB514\uBC84\uADF8 \uB85C\uADF8 \uD45C\uC2DC").action((id, input, opts) => workflowRun(id, input, opts));
895
- wf.command("history [workflow-id]").description("\uC2E4\uD589 \uC774\uB825 \uC870\uD68C").option("-n, --limit <number>", "\uC870\uD68C \uAC74\uC218", "20").action((id, opts) => workflowHistory(id, { limit: parseInt(opts.limit) }));
896
- }
472
+ var init_sse = __esm({
473
+ "src/utils/sse.ts"() {
474
+ "use strict";
475
+ }
476
+ });
897
477
 
898
478
  // src/commands/chat.ts
899
- init_store();
900
- init_workflow();
901
479
  import chalk9 from "chalk";
902
480
  import { createInterface as createInterface2 } from "readline";
903
481
  import { randomUUID as randomUUID2 } from "crypto";
904
- init_format();
905
- var CHAT_BANNER = `
906
- ${chalk9.cyan("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E")}
907
- ${chalk9.cyan("\u2502")} ${chalk9.white.bold("XGEN")} ${chalk9.gray("\u2014 \uC6CC\uD06C\uD50C\uB85C\uC6B0 AI \uD130\uBBF8\uB110")} ${chalk9.cyan("\u2502")}
908
- ${chalk9.cyan("\u2502")} ${chalk9.gray("/help \uB3C4\uC6C0\uB9D0 /workflows \uC804\uD658 /exit")} ${chalk9.cyan("\u2502")}
909
- ${chalk9.cyan("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F")}`;
910
482
  function printHelp() {
911
483
  console.log(`
912
484
  ${chalk9.bold("\uC2AC\uB798\uC2DC \uCEE4\uB9E8\uB4DC")}
@@ -1118,10 +690,23 @@ async function chat(workflowId) {
1118
690
  function registerChatCommand(program2) {
1119
691
  program2.command("chat [workflow-id]").description("\uC778\uD130\uB799\uD2F0\uBE0C \uB300\uD654 \uBAA8\uB4DC").action((workflowId) => chat(workflowId));
1120
692
  }
693
+ var CHAT_BANNER;
694
+ var init_chat = __esm({
695
+ "src/commands/chat.ts"() {
696
+ "use strict";
697
+ init_store();
698
+ init_workflow();
699
+ init_sse();
700
+ init_format();
701
+ CHAT_BANNER = `
702
+ ${chalk9.cyan("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E")}
703
+ ${chalk9.cyan("\u2502")} ${chalk9.white.bold("XGEN")} ${chalk9.gray("\u2014 \uC6CC\uD06C\uD50C\uB85C\uC6B0 AI \uD130\uBBF8\uB110")} ${chalk9.cyan("\u2502")}
704
+ ${chalk9.cyan("\u2502")} ${chalk9.gray("/help \uB3C4\uC6C0\uB9D0 /workflows \uC804\uD658 /exit")} ${chalk9.cyan("\u2502")}
705
+ ${chalk9.cyan("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F")}`;
706
+ }
707
+ });
1121
708
 
1122
709
  // src/commands/provider.ts
1123
- init_store();
1124
- init_format();
1125
710
  import chalk10 from "chalk";
1126
711
  import { createInterface as createInterface3 } from "readline";
1127
712
  import OpenAI from "openai";
@@ -1134,51 +719,6 @@ function prompt2(question) {
1134
719
  });
1135
720
  });
1136
721
  }
1137
- var PRESETS = [
1138
- {
1139
- label: "OpenAI",
1140
- type: "openai",
1141
- defaultModel: "gpt-4o-mini",
1142
- models: ["gpt-4o", "gpt-4o-mini", "gpt-4.1", "gpt-4.1-mini", "o3-mini"],
1143
- needsKey: true,
1144
- keyHint: "https://platform.openai.com/api-keys \uC5D0\uC11C \uBC1C\uAE09"
1145
- },
1146
- {
1147
- label: "Google Gemini",
1148
- type: "gemini",
1149
- baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
1150
- defaultModel: "gemini-2.0-flash",
1151
- models: ["gemini-2.0-flash", "gemini-2.5-pro-preview-06-05", "gemini-2.5-flash-preview-05-20"],
1152
- needsKey: true,
1153
- keyHint: "https://aistudio.google.com/apikey \uC5D0\uC11C \uBC1C\uAE09"
1154
- },
1155
- {
1156
- label: "Ollama (\uB85C\uCEEC)",
1157
- type: "ollama",
1158
- baseUrl: "http://localhost:11434/v1",
1159
- defaultModel: "llama3.1",
1160
- models: ["llama3.1", "llama3.2", "codellama", "mistral", "qwen2.5-coder"],
1161
- needsKey: false,
1162
- keyHint: "https://ollama.ai \uC5D0\uC11C \uC124\uCE58"
1163
- },
1164
- {
1165
- label: "Anthropic (Claude)",
1166
- type: "anthropic",
1167
- baseUrl: "https://api.anthropic.com/v1",
1168
- defaultModel: "claude-sonnet-4-20250514",
1169
- models: ["claude-sonnet-4-20250514", "claude-opus-4-20250514", "claude-haiku-4-5-20251001"],
1170
- needsKey: true,
1171
- keyHint: "https://console.anthropic.com/settings/keys \uC5D0\uC11C \uBC1C\uAE09"
1172
- },
1173
- {
1174
- label: "Custom (OpenAI \uD638\uD658 \uC11C\uBC84)",
1175
- type: "custom",
1176
- defaultModel: "gpt-4o-mini",
1177
- models: [],
1178
- needsKey: true,
1179
- keyHint: "\uC11C\uBC84\uC5D0\uC11C \uBC1C\uAE09\uBC1B\uC740 API Key"
1180
- }
1181
- ];
1182
722
  async function guidedProviderSetup() {
1183
723
  console.log(chalk10.cyan.bold("\n \u26A1 OPEN XGEN \u2014 \uD504\uB85C\uBC14\uC774\uB354 \uC124\uC815\n"));
1184
724
  console.log(chalk10.gray(" AI \uC5D0\uC774\uC804\uD2B8\uB97C \uC0AC\uC6A9\uD558\uB824\uBA74 \uD504\uB85C\uBC14\uC774\uB354\uB97C \uC124\uC815\uD558\uC138\uC694.\n"));
@@ -1324,11 +864,59 @@ function registerProviderCommand(program2) {
1324
864
  }
1325
865
  });
1326
866
  }
1327
-
1328
- // src/commands/agent.ts
1329
- init_store();
1330
- import chalk11 from "chalk";
1331
- import { createInterface as createInterface5 } from "readline";
867
+ var PRESETS;
868
+ var init_provider = __esm({
869
+ "src/commands/provider.ts"() {
870
+ "use strict";
871
+ init_store();
872
+ init_format();
873
+ PRESETS = [
874
+ {
875
+ label: "OpenAI",
876
+ type: "openai",
877
+ defaultModel: "gpt-4o-mini",
878
+ models: ["gpt-4o", "gpt-4o-mini", "gpt-4.1", "gpt-4.1-mini", "o3-mini"],
879
+ needsKey: true,
880
+ keyHint: "https://platform.openai.com/api-keys \uC5D0\uC11C \uBC1C\uAE09"
881
+ },
882
+ {
883
+ label: "Google Gemini",
884
+ type: "gemini",
885
+ baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
886
+ defaultModel: "gemini-2.0-flash",
887
+ models: ["gemini-2.0-flash", "gemini-2.5-pro-preview-06-05", "gemini-2.5-flash-preview-05-20"],
888
+ needsKey: true,
889
+ keyHint: "https://aistudio.google.com/apikey \uC5D0\uC11C \uBC1C\uAE09"
890
+ },
891
+ {
892
+ label: "Ollama (\uB85C\uCEEC)",
893
+ type: "ollama",
894
+ baseUrl: "http://localhost:11434/v1",
895
+ defaultModel: "llama3.1",
896
+ models: ["llama3.1", "llama3.2", "codellama", "mistral", "qwen2.5-coder"],
897
+ needsKey: false,
898
+ keyHint: "https://ollama.ai \uC5D0\uC11C \uC124\uCE58"
899
+ },
900
+ {
901
+ label: "Anthropic (Claude)",
902
+ type: "anthropic",
903
+ baseUrl: "https://api.anthropic.com/v1",
904
+ defaultModel: "claude-sonnet-4-20250514",
905
+ models: ["claude-sonnet-4-20250514", "claude-opus-4-20250514", "claude-haiku-4-5-20251001"],
906
+ needsKey: true,
907
+ keyHint: "https://console.anthropic.com/settings/keys \uC5D0\uC11C \uBC1C\uAE09"
908
+ },
909
+ {
910
+ label: "Custom (OpenAI \uD638\uD658 \uC11C\uBC84)",
911
+ type: "custom",
912
+ defaultModel: "gpt-4o-mini",
913
+ models: [],
914
+ needsKey: true,
915
+ keyHint: "\uC11C\uBC84\uC5D0\uC11C \uBC1C\uAE09\uBC1B\uC740 API Key"
916
+ }
917
+ ];
918
+ }
919
+ });
1332
920
 
1333
921
  // src/agent/llm.ts
1334
922
  import OpenAI2 from "openai";
@@ -1378,6 +966,11 @@ async function streamChat(client2, model, messages, tools2, onDelta) {
1378
966
  toolCalls: [...toolCallMap.values()]
1379
967
  };
1380
968
  }
969
+ var init_llm = __esm({
970
+ "src/agent/llm.ts"() {
971
+ "use strict";
972
+ }
973
+ });
1381
974
 
1382
975
  // src/agent/tools/file-read.ts
1383
976
  var file_read_exports = {};
@@ -1386,22 +979,6 @@ __export(file_read_exports, {
1386
979
  execute: () => execute
1387
980
  });
1388
981
  import { readFileSync as readFileSync2 } from "fs";
1389
- var definition = {
1390
- type: "function",
1391
- function: {
1392
- name: "file_read",
1393
- description: "\uD30C\uC77C \uB0B4\uC6A9\uC744 \uC77D\uC2B5\uB2C8\uB2E4. \uC904 \uBC88\uD638\uAC00 \uD3EC\uD568\uB429\uB2C8\uB2E4.",
1394
- parameters: {
1395
- type: "object",
1396
- properties: {
1397
- path: { type: "string", description: "\uD30C\uC77C \uACBD\uB85C" },
1398
- start_line: { type: "number", description: "\uC2DC\uC791 \uC904 \uBC88\uD638 (\uC120\uD0DD)" },
1399
- end_line: { type: "number", description: "\uB05D \uC904 \uBC88\uD638 (\uC120\uD0DD)" }
1400
- },
1401
- required: ["path"]
1402
- }
1403
- }
1404
- };
1405
982
  async function execute(args) {
1406
983
  const path = args.path;
1407
984
  const startLine = args.start_line || 1;
@@ -1415,6 +992,28 @@ async function execute(args) {
1415
992
  return `Error: ${err.message}`;
1416
993
  }
1417
994
  }
995
+ var definition;
996
+ var init_file_read = __esm({
997
+ "src/agent/tools/file-read.ts"() {
998
+ "use strict";
999
+ definition = {
1000
+ type: "function",
1001
+ function: {
1002
+ name: "file_read",
1003
+ description: "\uD30C\uC77C \uB0B4\uC6A9\uC744 \uC77D\uC2B5\uB2C8\uB2E4. \uC904 \uBC88\uD638\uAC00 \uD3EC\uD568\uB429\uB2C8\uB2E4.",
1004
+ parameters: {
1005
+ type: "object",
1006
+ properties: {
1007
+ path: { type: "string", description: "\uD30C\uC77C \uACBD\uB85C" },
1008
+ start_line: { type: "number", description: "\uC2DC\uC791 \uC904 \uBC88\uD638 (\uC120\uD0DD)" },
1009
+ end_line: { type: "number", description: "\uB05D \uC904 \uBC88\uD638 (\uC120\uD0DD)" }
1010
+ },
1011
+ required: ["path"]
1012
+ }
1013
+ }
1014
+ };
1015
+ }
1016
+ });
1418
1017
 
1419
1018
  // src/agent/tools/file-write.ts
1420
1019
  var file_write_exports = {};
@@ -1424,21 +1023,6 @@ __export(file_write_exports, {
1424
1023
  });
1425
1024
  import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
1426
1025
  import { dirname } from "path";
1427
- var definition2 = {
1428
- type: "function",
1429
- function: {
1430
- name: "file_write",
1431
- description: "\uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uAC70\uB098 \uB36E\uC5B4\uC501\uB2C8\uB2E4.",
1432
- parameters: {
1433
- type: "object",
1434
- properties: {
1435
- path: { type: "string", description: "\uD30C\uC77C \uACBD\uB85C" },
1436
- content: { type: "string", description: "\uD30C\uC77C \uB0B4\uC6A9" }
1437
- },
1438
- required: ["path", "content"]
1439
- }
1440
- }
1441
- };
1442
1026
  async function execute2(args) {
1443
1027
  const path = args.path;
1444
1028
  const content = args.content;
@@ -1450,6 +1034,27 @@ async function execute2(args) {
1450
1034
  return `Error: ${err.message}`;
1451
1035
  }
1452
1036
  }
1037
+ var definition2;
1038
+ var init_file_write = __esm({
1039
+ "src/agent/tools/file-write.ts"() {
1040
+ "use strict";
1041
+ definition2 = {
1042
+ type: "function",
1043
+ function: {
1044
+ name: "file_write",
1045
+ description: "\uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uAC70\uB098 \uB36E\uC5B4\uC501\uB2C8\uB2E4.",
1046
+ parameters: {
1047
+ type: "object",
1048
+ properties: {
1049
+ path: { type: "string", description: "\uD30C\uC77C \uACBD\uB85C" },
1050
+ content: { type: "string", description: "\uD30C\uC77C \uB0B4\uC6A9" }
1051
+ },
1052
+ required: ["path", "content"]
1053
+ }
1054
+ }
1055
+ };
1056
+ }
1057
+ });
1453
1058
 
1454
1059
  // src/agent/tools/file-edit.ts
1455
1060
  var file_edit_exports = {};
@@ -1458,22 +1063,6 @@ __export(file_edit_exports, {
1458
1063
  execute: () => execute3
1459
1064
  });
1460
1065
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
1461
- var definition3 = {
1462
- type: "function",
1463
- function: {
1464
- name: "file_edit",
1465
- description: "\uD30C\uC77C\uC5D0\uC11C \uD2B9\uC815 \uD14D\uC2A4\uD2B8\uB97C \uCC3E\uC544 \uAD50\uCCB4\uD569\uB2C8\uB2E4.",
1466
- parameters: {
1467
- type: "object",
1468
- properties: {
1469
- path: { type: "string", description: "\uD30C\uC77C \uACBD\uB85C" },
1470
- old_text: { type: "string", description: "\uAD50\uCCB4\uD560 \uAE30\uC874 \uD14D\uC2A4\uD2B8" },
1471
- new_text: { type: "string", description: "\uC0C8 \uD14D\uC2A4\uD2B8" }
1472
- },
1473
- required: ["path", "old_text", "new_text"]
1474
- }
1475
- }
1476
- };
1477
1066
  async function execute3(args) {
1478
1067
  const path = args.path;
1479
1068
  const oldText = args.old_text;
@@ -1490,6 +1079,28 @@ async function execute3(args) {
1490
1079
  return `Error: ${err.message}`;
1491
1080
  }
1492
1081
  }
1082
+ var definition3;
1083
+ var init_file_edit = __esm({
1084
+ "src/agent/tools/file-edit.ts"() {
1085
+ "use strict";
1086
+ definition3 = {
1087
+ type: "function",
1088
+ function: {
1089
+ name: "file_edit",
1090
+ description: "\uD30C\uC77C\uC5D0\uC11C \uD2B9\uC815 \uD14D\uC2A4\uD2B8\uB97C \uCC3E\uC544 \uAD50\uCCB4\uD569\uB2C8\uB2E4.",
1091
+ parameters: {
1092
+ type: "object",
1093
+ properties: {
1094
+ path: { type: "string", description: "\uD30C\uC77C \uACBD\uB85C" },
1095
+ old_text: { type: "string", description: "\uAD50\uCCB4\uD560 \uAE30\uC874 \uD14D\uC2A4\uD2B8" },
1096
+ new_text: { type: "string", description: "\uC0C8 \uD14D\uC2A4\uD2B8" }
1097
+ },
1098
+ required: ["path", "old_text", "new_text"]
1099
+ }
1100
+ }
1101
+ };
1102
+ }
1103
+ });
1493
1104
 
1494
1105
  // src/agent/tools/bash.ts
1495
1106
  var bash_exports = {};
@@ -1498,20 +1109,6 @@ __export(bash_exports, {
1498
1109
  execute: () => execute4
1499
1110
  });
1500
1111
  import { execSync } from "child_process";
1501
- var definition4 = {
1502
- type: "function",
1503
- function: {
1504
- name: "bash",
1505
- description: "\uC178 \uBA85\uB839\uC5B4\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4. stdout + stderr\uB97C \uBC18\uD658\uD569\uB2C8\uB2E4.",
1506
- parameters: {
1507
- type: "object",
1508
- properties: {
1509
- command: { type: "string", description: "\uC2E4\uD589\uD560 \uBA85\uB839\uC5B4" }
1510
- },
1511
- required: ["command"]
1512
- }
1513
- }
1514
- };
1515
1112
  async function execute4(args) {
1516
1113
  const command = args.command;
1517
1114
  try {
@@ -1527,30 +1124,34 @@ async function execute4(args) {
1527
1124
  return (e.stdout || "") + (e.stderr || "") || `Error: ${e.message}`;
1528
1125
  }
1529
1126
  }
1530
-
1531
- // src/agent/tools/grep.ts
1532
- var grep_exports = {};
1533
- __export(grep_exports, {
1534
- definition: () => definition5,
1535
- execute: () => execute5
1536
- });
1537
- import { execSync as execSync2 } from "child_process";
1538
- var definition5 = {
1539
- type: "function",
1540
- function: {
1541
- name: "grep",
1542
- description: "\uD30C\uC77C\uC5D0\uC11C \uD328\uD134\uC744 \uAC80\uC0C9\uD569\uB2C8\uB2E4 (\uC7AC\uADC0, \uC904 \uBC88\uD638 \uD3EC\uD568).",
1543
- parameters: {
1544
- type: "object",
1545
- properties: {
1546
- pattern: { type: "string", description: "\uAC80\uC0C9 \uD328\uD134 (\uC815\uADDC\uC2DD)" },
1547
- path: { type: "string", description: "\uAC80\uC0C9 \uB514\uB809\uD1A0\uB9AC \uB610\uB294 \uD30C\uC77C (\uAE30\uBCF8: .)" },
1548
- glob: { type: "string", description: "\uD30C\uC77C \uD544\uD130 (\uC608: *.ts)" }
1549
- },
1550
- required: ["pattern"]
1551
- }
1127
+ var definition4;
1128
+ var init_bash = __esm({
1129
+ "src/agent/tools/bash.ts"() {
1130
+ "use strict";
1131
+ definition4 = {
1132
+ type: "function",
1133
+ function: {
1134
+ name: "bash",
1135
+ description: "\uC178 \uBA85\uB839\uC5B4\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4. stdout + stderr\uB97C \uBC18\uD658\uD569\uB2C8\uB2E4.",
1136
+ parameters: {
1137
+ type: "object",
1138
+ properties: {
1139
+ command: { type: "string", description: "\uC2E4\uD589\uD560 \uBA85\uB839\uC5B4" }
1140
+ },
1141
+ required: ["command"]
1142
+ }
1143
+ }
1144
+ };
1552
1145
  }
1553
- };
1146
+ });
1147
+
1148
+ // src/agent/tools/grep.ts
1149
+ var grep_exports = {};
1150
+ __export(grep_exports, {
1151
+ definition: () => definition5,
1152
+ execute: () => execute5
1153
+ });
1154
+ import { execSync as execSync2 } from "child_process";
1554
1155
  async function execute5(args) {
1555
1156
  const pattern = args.pattern;
1556
1157
  const path = args.path || ".";
@@ -1570,6 +1171,28 @@ async function execute5(args) {
1570
1171
  return "\uC77C\uCE58\uD558\uB294 \uACB0\uACFC \uC5C6\uC74C";
1571
1172
  }
1572
1173
  }
1174
+ var definition5;
1175
+ var init_grep = __esm({
1176
+ "src/agent/tools/grep.ts"() {
1177
+ "use strict";
1178
+ definition5 = {
1179
+ type: "function",
1180
+ function: {
1181
+ name: "grep",
1182
+ description: "\uD30C\uC77C\uC5D0\uC11C \uD328\uD134\uC744 \uAC80\uC0C9\uD569\uB2C8\uB2E4 (\uC7AC\uADC0, \uC904 \uBC88\uD638 \uD3EC\uD568).",
1183
+ parameters: {
1184
+ type: "object",
1185
+ properties: {
1186
+ pattern: { type: "string", description: "\uAC80\uC0C9 \uD328\uD134 (\uC815\uADDC\uC2DD)" },
1187
+ path: { type: "string", description: "\uAC80\uC0C9 \uB514\uB809\uD1A0\uB9AC \uB610\uB294 \uD30C\uC77C (\uAE30\uBCF8: .)" },
1188
+ glob: { type: "string", description: "\uD30C\uC77C \uD544\uD130 (\uC608: *.ts)" }
1189
+ },
1190
+ required: ["pattern"]
1191
+ }
1192
+ }
1193
+ };
1194
+ }
1195
+ });
1573
1196
 
1574
1197
  // src/agent/tools/list-files.ts
1575
1198
  var list_files_exports = {};
@@ -1578,20 +1201,6 @@ __export(list_files_exports, {
1578
1201
  execute: () => execute6
1579
1202
  });
1580
1203
  import { execSync as execSync3 } from "child_process";
1581
- var definition6 = {
1582
- type: "function",
1583
- function: {
1584
- name: "list_files",
1585
- description: "\uB514\uB809\uD1A0\uB9AC\uC758 \uD30C\uC77C/\uD3F4\uB354 \uBAA9\uB85D\uC744 \uBC18\uD658\uD569\uB2C8\uB2E4. glob \uD328\uD134 \uC9C0\uC6D0.",
1586
- parameters: {
1587
- type: "object",
1588
- properties: {
1589
- path: { type: "string", description: "\uB514\uB809\uD1A0\uB9AC \uACBD\uB85C (\uAE30\uBCF8: .)" },
1590
- pattern: { type: "string", description: "glob \uD328\uD134 (\uC608: **/*.ts)" }
1591
- }
1592
- }
1593
- }
1594
- };
1595
1204
  async function execute6(args) {
1596
1205
  const path = args.path || ".";
1597
1206
  const pattern = args.pattern;
@@ -1612,6 +1221,26 @@ async function execute6(args) {
1612
1221
  return `Error: ${err.message}`;
1613
1222
  }
1614
1223
  }
1224
+ var definition6;
1225
+ var init_list_files = __esm({
1226
+ "src/agent/tools/list-files.ts"() {
1227
+ "use strict";
1228
+ definition6 = {
1229
+ type: "function",
1230
+ function: {
1231
+ name: "list_files",
1232
+ description: "\uB514\uB809\uD1A0\uB9AC\uC758 \uD30C\uC77C/\uD3F4\uB354 \uBAA9\uB85D\uC744 \uBC18\uD658\uD569\uB2C8\uB2E4. glob \uD328\uD134 \uC9C0\uC6D0.",
1233
+ parameters: {
1234
+ type: "object",
1235
+ properties: {
1236
+ path: { type: "string", description: "\uB514\uB809\uD1A0\uB9AC \uACBD\uB85C (\uAE30\uBCF8: .)" },
1237
+ pattern: { type: "string", description: "glob \uD328\uD134 (\uC608: **/*.ts)" }
1238
+ }
1239
+ }
1240
+ }
1241
+ };
1242
+ }
1243
+ });
1615
1244
 
1616
1245
  // src/agent/tools/sandbox.ts
1617
1246
  var sandbox_exports = {};
@@ -1623,37 +1252,12 @@ import { execSync as execSync4 } from "child_process";
1623
1252
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, existsSync as existsSync2, rmSync } from "fs";
1624
1253
  import { join as join2 } from "path";
1625
1254
  import { tmpdir } from "os";
1626
- var SANDBOX_DIR = join2(tmpdir(), "xgen-sandbox");
1627
1255
  function ensureSandbox() {
1628
1256
  if (!existsSync2(SANDBOX_DIR)) {
1629
1257
  mkdirSync3(SANDBOX_DIR, { recursive: true });
1630
1258
  }
1631
1259
  return SANDBOX_DIR;
1632
1260
  }
1633
- var definition7 = {
1634
- type: "function",
1635
- function: {
1636
- name: "sandbox_run",
1637
- description: "\uACA9\uB9AC\uB41C \uC0CC\uB4DC\uBC15\uC2A4\uC5D0\uC11C \uCF54\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4. Node.js \uB610\uB294 Python \uCF54\uB4DC\uB97C \uC548\uC804\uD558\uAC8C \uC2E4\uD589\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. npm \uD328\uD0A4\uC9C0 \uC124\uCE58\uB3C4 \uAC00\uB2A5\uD569\uB2C8\uB2E4.",
1638
- parameters: {
1639
- type: "object",
1640
- properties: {
1641
- language: {
1642
- type: "string",
1643
- enum: ["javascript", "typescript", "python"],
1644
- description: "\uC2E4\uD589\uD560 \uC5B8\uC5B4"
1645
- },
1646
- code: { type: "string", description: "\uC2E4\uD589\uD560 \uCF54\uB4DC" },
1647
- packages: {
1648
- type: "array",
1649
- items: { type: "string" },
1650
- description: "\uC124\uCE58\uD560 \uD328\uD0A4\uC9C0 (npm \uB610\uB294 pip)"
1651
- }
1652
- },
1653
- required: ["language", "code"]
1654
- }
1655
- }
1656
- };
1657
1261
  async function execute7(args) {
1658
1262
  const language = args.language;
1659
1263
  const code = args.code;
@@ -1716,13 +1320,39 @@ async function execute7(args) {
1716
1320
  }
1717
1321
  }
1718
1322
  }
1323
+ var SANDBOX_DIR, definition7;
1324
+ var init_sandbox = __esm({
1325
+ "src/agent/tools/sandbox.ts"() {
1326
+ "use strict";
1327
+ SANDBOX_DIR = join2(tmpdir(), "xgen-sandbox");
1328
+ definition7 = {
1329
+ type: "function",
1330
+ function: {
1331
+ name: "sandbox_run",
1332
+ description: "\uACA9\uB9AC\uB41C \uC0CC\uB4DC\uBC15\uC2A4\uC5D0\uC11C \uCF54\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4. Node.js \uB610\uB294 Python \uCF54\uB4DC\uB97C \uC548\uC804\uD558\uAC8C \uC2E4\uD589\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. npm \uD328\uD0A4\uC9C0 \uC124\uCE58\uB3C4 \uAC00\uB2A5\uD569\uB2C8\uB2E4.",
1333
+ parameters: {
1334
+ type: "object",
1335
+ properties: {
1336
+ language: {
1337
+ type: "string",
1338
+ enum: ["javascript", "typescript", "python"],
1339
+ description: "\uC2E4\uD589\uD560 \uC5B8\uC5B4"
1340
+ },
1341
+ code: { type: "string", description: "\uC2E4\uD589\uD560 \uCF54\uB4DC" },
1342
+ packages: {
1343
+ type: "array",
1344
+ items: { type: "string" },
1345
+ description: "\uC124\uCE58\uD560 \uD328\uD0A4\uC9C0 (npm \uB610\uB294 pip)"
1346
+ }
1347
+ },
1348
+ required: ["language", "code"]
1349
+ }
1350
+ }
1351
+ };
1352
+ }
1353
+ });
1719
1354
 
1720
1355
  // src/agent/tools/index.ts
1721
- var tools = [file_read_exports, file_write_exports, file_edit_exports, bash_exports, grep_exports, list_files_exports, sandbox_exports];
1722
- var toolMap = /* @__PURE__ */ new Map();
1723
- for (const t of tools) {
1724
- toolMap.set(t.definition.function.name, t);
1725
- }
1726
1356
  function getAllToolDefs() {
1727
1357
  return tools.map((t) => t.definition);
1728
1358
  }
@@ -1734,100 +1364,30 @@ async function executeTool(name, args) {
1734
1364
  function getToolNames() {
1735
1365
  return tools.map((t) => t.definition.function.name);
1736
1366
  }
1367
+ var tools, toolMap;
1368
+ var init_tools = __esm({
1369
+ "src/agent/tools/index.ts"() {
1370
+ "use strict";
1371
+ init_file_read();
1372
+ init_file_write();
1373
+ init_file_edit();
1374
+ init_bash();
1375
+ init_grep();
1376
+ init_list_files();
1377
+ init_sandbox();
1378
+ tools = [file_read_exports, file_write_exports, file_edit_exports, bash_exports, grep_exports, list_files_exports, sandbox_exports];
1379
+ toolMap = /* @__PURE__ */ new Map();
1380
+ for (const t of tools) {
1381
+ toolMap.set(t.definition.function.name, t);
1382
+ }
1383
+ }
1384
+ });
1737
1385
 
1738
1386
  // src/mcp/client.ts
1739
1387
  import { spawn } from "child_process";
1740
1388
  import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
1741
1389
  import { join as join3 } from "path";
1742
1390
  import { createInterface as createInterface4 } from "readline";
1743
- var McpClient = class {
1744
- process = null;
1745
- requestId = 0;
1746
- pending = /* @__PURE__ */ new Map();
1747
- serverName;
1748
- config;
1749
- tools = [];
1750
- constructor(serverName, config) {
1751
- this.serverName = serverName;
1752
- this.config = config;
1753
- }
1754
- async start() {
1755
- this.process = spawn(this.config.command, this.config.args ?? [], {
1756
- stdio: ["pipe", "pipe", "pipe"],
1757
- env: { ...process.env, ...this.config.env }
1758
- });
1759
- const rl = createInterface4({ input: this.process.stdout });
1760
- rl.on("line", (line) => {
1761
- try {
1762
- const msg = JSON.parse(line);
1763
- if (msg.id !== void 0 && this.pending.has(msg.id)) {
1764
- const p = this.pending.get(msg.id);
1765
- this.pending.delete(msg.id);
1766
- if (msg.error) {
1767
- p.reject(new Error(msg.error.message));
1768
- } else {
1769
- p.resolve(msg.result);
1770
- }
1771
- }
1772
- } catch {
1773
- }
1774
- });
1775
- this.process.on("error", (err) => {
1776
- console.error(`MCP [${this.serverName}] \uD504\uB85C\uC138\uC2A4 \uC624\uB958:`, err.message);
1777
- });
1778
- await this.send("initialize", {
1779
- protocolVersion: "2024-11-05",
1780
- capabilities: {},
1781
- clientInfo: { name: "open-xgen", version: "0.3.0" }
1782
- });
1783
- await this.send("notifications/initialized", {});
1784
- }
1785
- send(method, params) {
1786
- return new Promise((resolve, reject) => {
1787
- const id = ++this.requestId;
1788
- const request = { jsonrpc: "2.0", id, method, params };
1789
- this.pending.set(id, { resolve, reject });
1790
- const timeout = setTimeout(() => {
1791
- this.pending.delete(id);
1792
- reject(new Error(`MCP \uC694\uCCAD \uD0C0\uC784\uC544\uC6C3: ${method}`));
1793
- }, 15e3);
1794
- this.pending.set(id, {
1795
- resolve: (v) => {
1796
- clearTimeout(timeout);
1797
- resolve(v);
1798
- },
1799
- reject: (e) => {
1800
- clearTimeout(timeout);
1801
- reject(e);
1802
- }
1803
- });
1804
- this.process?.stdin?.write(JSON.stringify(request) + "\n");
1805
- });
1806
- }
1807
- async listTools() {
1808
- const result = await this.send("tools/list", {});
1809
- this.tools = result.tools ?? [];
1810
- return this.tools;
1811
- }
1812
- async callTool(name, args) {
1813
- const result = await this.send("tools/call", { name, arguments: args });
1814
- return result.content?.map((c) => c.text ?? "").join("\n") ?? "";
1815
- }
1816
- getOpenAITools() {
1817
- return this.tools.map((t) => ({
1818
- type: "function",
1819
- function: {
1820
- name: `mcp_${this.serverName}_${t.name}`,
1821
- description: `[MCP:${this.serverName}] ${t.description ?? t.name}`,
1822
- parameters: t.inputSchema ?? { type: "object", properties: {} }
1823
- }
1824
- }));
1825
- }
1826
- stop() {
1827
- this.process?.kill();
1828
- this.process = null;
1829
- }
1830
- };
1831
1391
  function loadMcpConfig(dir) {
1832
1392
  const searchPaths = [
1833
1393
  dir ? join3(dir, ".mcp.json") : null,
@@ -1845,139 +1405,558 @@ function loadMcpConfig(dir) {
1845
1405
  }
1846
1406
  return null;
1847
1407
  }
1848
- var McpManager = class {
1849
- clients = /* @__PURE__ */ new Map();
1850
- async startAll(config) {
1851
- for (const [name, serverConfig] of Object.entries(config.mcpServers)) {
1852
- if (serverConfig.type !== "stdio") continue;
1853
- try {
1854
- const client2 = new McpClient(name, serverConfig);
1855
- await client2.start();
1856
- await client2.listTools();
1857
- this.clients.set(name, client2);
1858
- } catch (err) {
1859
- console.error(`MCP [${name}] \uC2DC\uC791 \uC2E4\uD328:`, err.message);
1408
+ var McpClient, McpManager;
1409
+ var init_client2 = __esm({
1410
+ "src/mcp/client.ts"() {
1411
+ "use strict";
1412
+ McpClient = class {
1413
+ process = null;
1414
+ requestId = 0;
1415
+ pending = /* @__PURE__ */ new Map();
1416
+ serverName;
1417
+ config;
1418
+ tools = [];
1419
+ constructor(serverName, config) {
1420
+ this.serverName = serverName;
1421
+ this.config = config;
1860
1422
  }
1861
- }
1862
- }
1863
- getAllTools() {
1864
- const tools2 = [];
1865
- for (const client2 of this.clients.values()) {
1866
- tools2.push(...client2.getOpenAITools());
1867
- }
1868
- return tools2;
1869
- }
1870
- async callTool(fullName, args) {
1871
- const parts = fullName.split("_");
1872
- if (parts.length < 3 || parts[0] !== "mcp") return `Unknown MCP tool: ${fullName}`;
1873
- const serverName = parts[1];
1874
- const toolName = parts.slice(2).join("_");
1875
- const client2 = this.clients.get(serverName);
1876
- if (!client2) return `MCP \uC11C\uBC84\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${serverName}`;
1877
- return client2.callTool(toolName, args);
1878
- }
1879
- isMcpTool(name) {
1880
- return name.startsWith("mcp_");
1881
- }
1882
- stopAll() {
1883
- for (const client2 of this.clients.values()) {
1884
- client2.stop();
1885
- }
1886
- this.clients.clear();
1423
+ async start() {
1424
+ this.process = spawn(this.config.command, this.config.args ?? [], {
1425
+ stdio: ["pipe", "pipe", "pipe"],
1426
+ env: { ...process.env, ...this.config.env }
1427
+ });
1428
+ const rl = createInterface4({ input: this.process.stdout });
1429
+ rl.on("line", (line) => {
1430
+ try {
1431
+ const msg = JSON.parse(line);
1432
+ if (msg.id !== void 0 && this.pending.has(msg.id)) {
1433
+ const p = this.pending.get(msg.id);
1434
+ this.pending.delete(msg.id);
1435
+ if (msg.error) {
1436
+ p.reject(new Error(msg.error.message));
1437
+ } else {
1438
+ p.resolve(msg.result);
1439
+ }
1440
+ }
1441
+ } catch {
1442
+ }
1443
+ });
1444
+ this.process.on("error", (err) => {
1445
+ console.error(`MCP [${this.serverName}] \uD504\uB85C\uC138\uC2A4 \uC624\uB958:`, err.message);
1446
+ });
1447
+ await this.send("initialize", {
1448
+ protocolVersion: "2024-11-05",
1449
+ capabilities: {},
1450
+ clientInfo: { name: "open-xgen", version: "0.3.0" }
1451
+ });
1452
+ await this.send("notifications/initialized", {});
1453
+ }
1454
+ send(method, params) {
1455
+ return new Promise((resolve, reject) => {
1456
+ const id = ++this.requestId;
1457
+ const request = { jsonrpc: "2.0", id, method, params };
1458
+ this.pending.set(id, { resolve, reject });
1459
+ const timeout = setTimeout(() => {
1460
+ this.pending.delete(id);
1461
+ reject(new Error(`MCP \uC694\uCCAD \uD0C0\uC784\uC544\uC6C3: ${method}`));
1462
+ }, 15e3);
1463
+ this.pending.set(id, {
1464
+ resolve: (v) => {
1465
+ clearTimeout(timeout);
1466
+ resolve(v);
1467
+ },
1468
+ reject: (e) => {
1469
+ clearTimeout(timeout);
1470
+ reject(e);
1471
+ }
1472
+ });
1473
+ this.process?.stdin?.write(JSON.stringify(request) + "\n");
1474
+ });
1475
+ }
1476
+ async listTools() {
1477
+ const result = await this.send("tools/list", {});
1478
+ this.tools = result.tools ?? [];
1479
+ return this.tools;
1480
+ }
1481
+ async callTool(name, args) {
1482
+ const result = await this.send("tools/call", { name, arguments: args });
1483
+ return result.content?.map((c) => c.text ?? "").join("\n") ?? "";
1484
+ }
1485
+ getOpenAITools() {
1486
+ return this.tools.map((t) => ({
1487
+ type: "function",
1488
+ function: {
1489
+ name: `mcp_${this.serverName}_${t.name}`,
1490
+ description: `[MCP:${this.serverName}] ${t.description ?? t.name}`,
1491
+ parameters: t.inputSchema ?? { type: "object", properties: {} }
1492
+ }
1493
+ }));
1494
+ }
1495
+ stop() {
1496
+ this.process?.kill();
1497
+ this.process = null;
1498
+ }
1499
+ };
1500
+ McpManager = class {
1501
+ clients = /* @__PURE__ */ new Map();
1502
+ async startAll(config) {
1503
+ for (const [name, serverConfig] of Object.entries(config.mcpServers)) {
1504
+ if (serverConfig.type !== "stdio") continue;
1505
+ try {
1506
+ const client2 = new McpClient(name, serverConfig);
1507
+ await client2.start();
1508
+ await client2.listTools();
1509
+ this.clients.set(name, client2);
1510
+ } catch (err) {
1511
+ console.error(`MCP [${name}] \uC2DC\uC791 \uC2E4\uD328:`, err.message);
1512
+ }
1513
+ }
1514
+ }
1515
+ getAllTools() {
1516
+ const tools2 = [];
1517
+ for (const client2 of this.clients.values()) {
1518
+ tools2.push(...client2.getOpenAITools());
1519
+ }
1520
+ return tools2;
1521
+ }
1522
+ async callTool(fullName, args) {
1523
+ const parts = fullName.split("_");
1524
+ if (parts.length < 3 || parts[0] !== "mcp") return `Unknown MCP tool: ${fullName}`;
1525
+ const serverName = parts[1];
1526
+ const toolName = parts.slice(2).join("_");
1527
+ const client2 = this.clients.get(serverName);
1528
+ if (!client2) return `MCP \uC11C\uBC84\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${serverName}`;
1529
+ return client2.callTool(toolName, args);
1530
+ }
1531
+ isMcpTool(name) {
1532
+ return name.startsWith("mcp_");
1533
+ }
1534
+ stopAll() {
1535
+ for (const client2 of this.clients.values()) {
1536
+ client2.stop();
1537
+ }
1538
+ this.clients.clear();
1539
+ }
1540
+ get serverCount() {
1541
+ return this.clients.size;
1542
+ }
1543
+ getServerNames() {
1544
+ return [...this.clients.keys()];
1545
+ }
1546
+ };
1887
1547
  }
1888
- get serverCount() {
1889
- return this.clients.size;
1548
+ });
1549
+
1550
+ // src/utils/ui.ts
1551
+ import chalk11 from "chalk";
1552
+ import { createInterface as createInterface5 } from "readline";
1553
+ function box(lines, color = "cyan") {
1554
+ const c = chalk11[color];
1555
+ const inner = W - 4;
1556
+ const top = c(" \u256D" + "\u2500".repeat(inner) + "\u256E");
1557
+ const bot = c(" \u2570" + "\u2500".repeat(inner) + "\u256F");
1558
+ const body = lines.map((line) => {
1559
+ const clean = line.replace(/\x1b\[[0-9;]*m/g, "");
1560
+ const pad = Math.max(0, inner - clean.length);
1561
+ return c(" \u2502 ") + line + " ".repeat(pad) + c(" \u2502");
1562
+ });
1563
+ return [top, ...body, bot].join("\n");
1564
+ }
1565
+ function divider(label) {
1566
+ if (label) {
1567
+ const rest = W - label.length - 6;
1568
+ return chalk11.gray(` \u2500\u2500 ${label} ${"\u2500".repeat(Math.max(0, rest))}`);
1890
1569
  }
1891
- getServerNames() {
1892
- return [...this.clients.keys()];
1570
+ return chalk11.gray(" " + "\u2500".repeat(W - 2));
1571
+ }
1572
+ function statusDot(active, label, detail) {
1573
+ const dot = active ? chalk11.green("\u25CF") : chalk11.gray("\u25CB");
1574
+ const d = detail ? chalk11.gray(` ${detail}`) : "";
1575
+ return ` ${dot} ${label}${d}`;
1576
+ }
1577
+ function ask(question) {
1578
+ return new Promise((resolve) => {
1579
+ const rl = createInterface5({ input: process.stdin, output: process.stdout });
1580
+ rl.question(question, (answer) => {
1581
+ rl.close();
1582
+ resolve(answer.trim());
1583
+ });
1584
+ });
1585
+ }
1586
+ function welcome() {
1587
+ const logo = chalk11.cyan(`
1588
+ \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
1589
+ \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588
1590
+ \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
1591
+ \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
1592
+ \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588`) + chalk11.white.bold(`
1593
+ \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
1594
+ \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588
1595
+ \u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
1596
+ \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
1597
+ \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588`);
1598
+ return logo;
1599
+ }
1600
+ var W;
1601
+ var init_ui = __esm({
1602
+ "src/utils/ui.ts"() {
1603
+ "use strict";
1604
+ W = Math.min(process.stdout.columns || 60, 70);
1893
1605
  }
1894
- };
1606
+ });
1895
1607
 
1896
- // src/commands/agent.ts
1897
- var SYSTEM_PROMPT = `You are OPEN XGEN Agent, an AI coding assistant running in the user's terminal.
1898
- You have access to tools for reading/writing files, executing commands, searching code, and running sandboxed code.
1899
- You can also use MCP (Model Context Protocol) tools if available.
1900
- Always respond in the same language as the user.
1901
- When using tools, be concise about what you're doing.
1902
- For file edits, show what you changed briefly.
1903
- For sandbox_run, you can install npm/pip packages and run isolated code.`;
1904
- var mcpManager = null;
1905
- async function agentRepl() {
1906
- let provider = getDefaultProvider();
1907
- if (!provider) {
1908
- provider = await guidedProviderSetup();
1909
- if (!provider) {
1910
- process.exit(1);
1911
- }
1608
+ // src/commands/home.ts
1609
+ var home_exports = {};
1610
+ __export(home_exports, {
1611
+ homeMenu: () => homeMenu
1612
+ });
1613
+ import chalk12 from "chalk";
1614
+ function showStatus() {
1615
+ const provider = getDefaultProvider();
1616
+ const server = getServer();
1617
+ const auth = getAuth();
1618
+ console.log(divider("\uC0C1\uD0DC"));
1619
+ console.log();
1620
+ if (provider) {
1621
+ console.log(statusDot(true, chalk12.bold("AI \uC5D0\uC774\uC804\uD2B8"), `${provider.name} \xB7 ${provider.model}`));
1622
+ } else {
1623
+ console.log(statusDot(false, "AI \uC5D0\uC774\uC804\uD2B8", "\uBBF8\uC124\uC815"));
1912
1624
  }
1913
- const client2 = createLLMClient(provider);
1914
- const builtinTools = getAllToolDefs();
1915
- const allTools = [...builtinTools];
1916
- const allToolNames = [...getToolNames()];
1917
- const mcpConfig = loadMcpConfig();
1918
- if (mcpConfig && Object.keys(mcpConfig.mcpServers).length > 0) {
1919
- mcpManager = new McpManager();
1920
- try {
1921
- await mcpManager.startAll(mcpConfig);
1922
- if (mcpManager.serverCount > 0) {
1923
- const mcpTools = mcpManager.getAllTools();
1924
- allTools.push(...mcpTools);
1925
- allToolNames.push(...mcpTools.map((t) => t.function.name));
1926
- }
1927
- } catch {
1928
- }
1625
+ if (server && auth) {
1626
+ console.log(statusDot(true, chalk12.bold("XGEN \uC11C\uBC84"), `${auth.username} \xB7 ${server.replace("https://", "")}`));
1627
+ } else if (server) {
1628
+ console.log(statusDot(false, "XGEN \uC11C\uBC84", `${server.replace("https://", "")} \xB7 \uB85C\uADF8\uC778 \uD544\uC694`));
1629
+ } else {
1630
+ console.log(statusDot(false, "XGEN \uC11C\uBC84", "\uBBF8\uC5F0\uACB0"));
1929
1631
  }
1930
- const messages = [{ role: "system", content: SYSTEM_PROMPT }];
1931
- console.log(chalk11.cyan.bold("\n OPEN XGEN Agent"));
1932
- console.log(chalk11.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
1933
- console.log(chalk11.gray(` \uD504\uB85C\uBC14\uC774\uB354: ${provider.name} (${provider.model})`));
1934
- console.log(chalk11.gray(` \uB3C4\uAD6C: ${getToolNames().join(", ")}`));
1935
- if (mcpManager && mcpManager.serverCount > 0) {
1936
- console.log(chalk11.gray(` MCP: ${mcpManager.getServerNames().join(", ")} (${mcpManager.getAllTools().length}\uAC1C \uB3C4\uAD6C)`));
1937
- }
1938
- console.log(chalk11.gray(` \uC885\uB8CC: exit | Ctrl+C`));
1939
1632
  console.log();
1940
- const rl = createInterface5({ input: process.stdin, output: process.stdout });
1941
- const ask = () => new Promise((resolve) => rl.question(chalk11.green("\u276F "), (a) => resolve(a.trim())));
1942
- process.on("SIGINT", () => {
1943
- console.log(chalk11.gray("\n\uC885\uB8CC\uD569\uB2C8\uB2E4."));
1944
- mcpManager?.stopAll();
1945
- rl.close();
1946
- process.exit(0);
1947
- });
1633
+ }
1634
+ async function homeMenu() {
1635
+ console.log(welcome());
1636
+ console.log(chalk12.gray(" v0.3.2\n"));
1637
+ showStatus();
1948
1638
  while (true) {
1949
- const input = await ask();
1950
- if (!input) continue;
1951
- if (input === "exit" || input === "/exit") {
1952
- console.log(chalk11.gray("\uC885\uB8CC\uD569\uB2C8\uB2E4."));
1953
- mcpManager?.stopAll();
1954
- rl.close();
1955
- break;
1956
- }
1957
- if (input === "/clear") {
1958
- messages.length = 1;
1959
- console.log(chalk11.gray("\uB300\uD654 \uCD08\uAE30\uD654\uB428.\n"));
1960
- continue;
1639
+ const provider = getDefaultProvider();
1640
+ const server = getServer();
1641
+ const auth = getAuth();
1642
+ const hasServer = !!(server && auth);
1643
+ const items = [];
1644
+ items.push({
1645
+ label: provider ? `${chalk12.bold("AI \uC5D0\uC774\uC804\uD2B8")} ${chalk12.gray(`(${provider.model})`)}` : chalk12.bold("AI \uC5D0\uC774\uC804\uD2B8 \uC2DC\uC791\uD558\uAE30"),
1646
+ hint: provider ? "\uB300\uD654 \uC2DC\uC791" : "\uD504\uB85C\uBC14\uC774\uB354 \uC124\uC815 \u2192 \uBC14\uB85C \uC2DC\uC791",
1647
+ action: async () => {
1648
+ await agentRepl();
1649
+ console.log();
1650
+ showStatus();
1651
+ return false;
1652
+ }
1653
+ });
1654
+ if (hasServer) {
1655
+ items.push({
1656
+ label: chalk12.bold("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uCC44\uD305"),
1657
+ hint: `${auth.username}@${server.replace("https://", "")}`,
1658
+ action: async () => {
1659
+ await chat();
1660
+ console.log();
1661
+ showStatus();
1662
+ return false;
1663
+ }
1664
+ });
1665
+ items.push({
1666
+ label: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D",
1667
+ hint: "\uC870\uD68C",
1668
+ action: async () => {
1669
+ const { workflowList: workflowList2 } = await Promise.resolve().then(() => (init_list(), list_exports));
1670
+ await workflowList2({ detail: false });
1671
+ return false;
1672
+ }
1673
+ });
1961
1674
  }
1962
- if (input === "/tools") {
1963
- console.log(chalk11.bold("\n\uB0B4\uC7A5 \uB3C4\uAD6C:"), getToolNames().join(", "));
1964
- if (mcpManager && mcpManager.serverCount > 0) {
1965
- console.log(chalk11.bold("MCP \uB3C4\uAD6C:"), mcpManager.getAllTools().map((t) => t.function.name).join(", "));
1675
+ items.push({
1676
+ label: hasServer ? "XGEN \uC11C\uBC84 \uC7AC\uC124\uC815" : chalk12.bold("XGEN \uC11C\uBC84 \uC5F0\uACB0"),
1677
+ hint: hasServer ? "\uC11C\uBC84 \uBCC0\uACBD / \uC7AC\uB85C\uADF8\uC778" : "\uC11C\uBC84 URL + \uB85C\uADF8\uC778",
1678
+ action: async () => {
1679
+ await serverSetup();
1680
+ showStatus();
1681
+ return false;
1966
1682
  }
1967
- console.log();
1968
- continue;
1683
+ });
1684
+ items.push({
1685
+ label: "\uD504\uB85C\uBC14\uC774\uB354 \uAD00\uB9AC",
1686
+ hint: `${getProviders().length}\uAC1C \uB4F1\uB85D\uB428`,
1687
+ action: async () => {
1688
+ await providerMenu();
1689
+ showStatus();
1690
+ return false;
1691
+ }
1692
+ });
1693
+ console.log(divider("\uBA54\uB274"));
1694
+ for (let i = 0; i < items.length; i++) {
1695
+ const num = chalk12.cyan.bold(` ${String(i + 1).padStart(2)}.`);
1696
+ console.log(` ${num} ${items[i].label}`);
1697
+ console.log(` ${chalk12.gray(items[i].hint)}`);
1969
1698
  }
1970
- if (input === "/provider") {
1971
- console.log(chalk11.gray(`\uD604\uC7AC: ${provider.name} (${provider.model})
1699
+ console.log(` ${chalk12.gray(" q. \uC885\uB8CC")}`);
1700
+ console.log();
1701
+ const choice = await ask(chalk12.cyan(" \u276F "));
1702
+ if (choice === "q" || choice === "exit" || choice === "") {
1703
+ if (choice === "") continue;
1704
+ console.log(chalk12.gray("\n \u{1F44B} \uB2E4\uC74C\uC5D0 \uB610.\n"));
1705
+ break;
1706
+ }
1707
+ const idx = parseInt(choice) - 1;
1708
+ if (isNaN(idx) || idx < 0 || idx >= items.length) {
1709
+ console.log(chalk12.red(` \uC798\uBABB\uB41C \uC785\uB825\uC785\uB2C8\uB2E4.
1972
1710
  `));
1973
1711
  continue;
1974
1712
  }
1975
- if (input === "/mcp") {
1976
- if (mcpManager && mcpManager.serverCount > 0) {
1977
- console.log(chalk11.bold("\nMCP \uC11C\uBC84:"), mcpManager.getServerNames().join(", "));
1978
- console.log(chalk11.gray("\uB3C4\uAD6C:"), mcpManager.getAllTools().map((t) => t.function.name).join(", "));
1979
- } else {
1980
- console.log(chalk11.gray("MCP \uC11C\uBC84 \uC5C6\uC74C. .mcp.json\uC744 \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8\uC5D0 \uCD94\uAC00\uD558\uC138\uC694."));
1713
+ try {
1714
+ const shouldExit = await items[idx].action();
1715
+ if (shouldExit) break;
1716
+ } catch (err) {
1717
+ console.log(chalk12.red(`
1718
+ \uC624\uB958: ${err.message}
1719
+ `));
1720
+ }
1721
+ }
1722
+ }
1723
+ async function serverSetup() {
1724
+ console.log();
1725
+ console.log(box(["XGEN \uC11C\uBC84 \uC5F0\uACB0"], "cyan"));
1726
+ console.log();
1727
+ const currentServer = getServer();
1728
+ const urlInput = await ask(
1729
+ chalk12.white(` \uC11C\uBC84 URL${currentServer ? chalk12.gray(` [${currentServer}]`) : ""}: `)
1730
+ );
1731
+ const url = urlInput || currentServer;
1732
+ if (!url) {
1733
+ console.log(chalk12.red(" URL\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.\n"));
1734
+ return;
1735
+ }
1736
+ const { setServer: setServer2 } = await Promise.resolve().then(() => (init_store(), store_exports));
1737
+ setServer2(url);
1738
+ console.log(chalk12.green(` \u2713 \uC11C\uBC84: ${url}
1739
+ `));
1740
+ console.log(chalk12.bold(" \uB85C\uADF8\uC778"));
1741
+ console.log();
1742
+ const email = await ask(chalk12.white(" \uC774\uBA54\uC77C: "));
1743
+ const password = await ask(chalk12.white(" \uBE44\uBC00\uBC88\uD638: "));
1744
+ if (!email || !password) {
1745
+ console.log(chalk12.red(" \uC774\uBA54\uC77C\uACFC \uBE44\uBC00\uBC88\uD638\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.\n"));
1746
+ return;
1747
+ }
1748
+ try {
1749
+ const { apiLogin: apiLogin2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
1750
+ const { setAuth: setAuth2 } = await Promise.resolve().then(() => (init_store(), store_exports));
1751
+ const result = await apiLogin2(email, password);
1752
+ if (result.success && result.access_token) {
1753
+ setAuth2({
1754
+ accessToken: result.access_token,
1755
+ refreshToken: result.refresh_token ?? "",
1756
+ userId: result.user_id ?? "",
1757
+ username: result.username ?? "",
1758
+ isAdmin: false,
1759
+ expiresAt: null
1760
+ });
1761
+ console.log(chalk12.green(`
1762
+ \u2713 \uB85C\uADF8\uC778 \uC131\uACF5! ${chalk12.bold(result.username ?? email)}
1763
+ `));
1764
+ } else {
1765
+ console.log(chalk12.red(`
1766
+ \u2717 ${result.message}
1767
+ `));
1768
+ }
1769
+ } catch (err) {
1770
+ console.log(chalk12.red(`
1771
+ \u2717 ${err.message}
1772
+ `));
1773
+ }
1774
+ }
1775
+ async function providerMenu() {
1776
+ const providers = getProviders();
1777
+ const defaultP = getDefaultProvider();
1778
+ console.log();
1779
+ console.log(box(["\uD504\uB85C\uBC14\uC774\uB354 \uAD00\uB9AC"], "cyan"));
1780
+ console.log();
1781
+ if (providers.length > 0) {
1782
+ for (const p of providers) {
1783
+ const mark = p.id === defaultP?.id ? chalk12.green("\u25CF ") : chalk12.gray(" ");
1784
+ console.log(` ${mark}${chalk12.bold(p.name)} ${chalk12.gray(`${p.type} \xB7 ${p.model}`)}`);
1785
+ }
1786
+ console.log();
1787
+ } else {
1788
+ console.log(chalk12.gray(" \uB4F1\uB85D\uB41C \uD504\uB85C\uBC14\uC774\uB354\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.\n"));
1789
+ }
1790
+ const items = ["\uC0C8\uB85C \uCD94\uAC00"];
1791
+ if (providers.length > 1) items.push("\uAE30\uBCF8 \uBCC0\uACBD");
1792
+ if (providers.length > 0) items.push("\uC0AD\uC81C");
1793
+ items.push("\uB3CC\uC544\uAC00\uAE30");
1794
+ items.forEach((item, i) => {
1795
+ console.log(` ${chalk12.cyan(`${i + 1}.`)} ${item}`);
1796
+ });
1797
+ console.log();
1798
+ const choice = await ask(chalk12.cyan(" \u276F "));
1799
+ const ci = parseInt(choice);
1800
+ if (ci === 1) {
1801
+ await guidedProviderSetup();
1802
+ } else if (items[ci - 1] === "\uAE30\uBCF8 \uBCC0\uACBD") {
1803
+ console.log();
1804
+ providers.forEach((p, i) => {
1805
+ console.log(` ${chalk12.cyan(`${i + 1}.`)} ${p.name} (${p.model})`);
1806
+ });
1807
+ console.log();
1808
+ const pc = await ask(chalk12.cyan(" \u276F "));
1809
+ const pi = parseInt(pc) - 1;
1810
+ if (pi >= 0 && pi < providers.length) {
1811
+ const { setDefaultProvider: setDefaultProvider2 } = await Promise.resolve().then(() => (init_store(), store_exports));
1812
+ setDefaultProvider2(providers[pi].id);
1813
+ console.log(chalk12.green(` \u2713 \uAE30\uBCF8: ${providers[pi].name}
1814
+ `));
1815
+ }
1816
+ } else if (items[ci - 1] === "\uC0AD\uC81C") {
1817
+ console.log();
1818
+ providers.forEach((p, i) => {
1819
+ console.log(` ${chalk12.cyan(`${i + 1}.`)} ${p.name} (${p.model})`);
1820
+ });
1821
+ console.log();
1822
+ const dc = await ask(chalk12.white(" \uC0AD\uC81C\uD560 \uBC88\uD638: "));
1823
+ const di = parseInt(dc) - 1;
1824
+ if (di >= 0 && di < providers.length) {
1825
+ const { removeProvider: removeProvider2 } = await Promise.resolve().then(() => (init_store(), store_exports));
1826
+ removeProvider2(providers[di].id);
1827
+ console.log(chalk12.green(` \u2713 \uC0AD\uC81C: ${providers[di].name}
1828
+ `));
1829
+ }
1830
+ }
1831
+ }
1832
+ var init_home = __esm({
1833
+ "src/commands/home.ts"() {
1834
+ "use strict";
1835
+ init_store();
1836
+ init_ui();
1837
+ init_agent();
1838
+ init_chat();
1839
+ init_provider();
1840
+ }
1841
+ });
1842
+
1843
+ // src/commands/agent.ts
1844
+ import chalk13 from "chalk";
1845
+ import { createInterface as createInterface6 } from "readline";
1846
+ async function agentRepl() {
1847
+ let provider = getDefaultProvider();
1848
+ if (!provider) {
1849
+ provider = await guidedProviderSetup();
1850
+ if (!provider) {
1851
+ process.exit(1);
1852
+ }
1853
+ }
1854
+ const client2 = createLLMClient(provider);
1855
+ const builtinTools = getAllToolDefs();
1856
+ const allTools = [...builtinTools];
1857
+ const allToolNames = [...getToolNames()];
1858
+ const mcpConfig = loadMcpConfig();
1859
+ if (mcpConfig && Object.keys(mcpConfig.mcpServers).length > 0) {
1860
+ mcpManager = new McpManager();
1861
+ try {
1862
+ await mcpManager.startAll(mcpConfig);
1863
+ if (mcpManager.serverCount > 0) {
1864
+ const mcpTools = mcpManager.getAllTools();
1865
+ allTools.push(...mcpTools);
1866
+ allToolNames.push(...mcpTools.map((t) => t.function.name));
1867
+ }
1868
+ } catch {
1869
+ }
1870
+ }
1871
+ const messages = [{ role: "system", content: SYSTEM_PROMPT }];
1872
+ console.log();
1873
+ console.log(box([
1874
+ `${chalk13.bold("OPEN XGEN Agent")}`,
1875
+ ``,
1876
+ `${chalk13.gray("\uD504\uB85C\uBC14\uC774\uB354")} ${provider.name} ${chalk13.gray("\xB7")} ${provider.model}`,
1877
+ `${chalk13.gray("\uB3C4\uAD6C")} ${getToolNames().length}\uAC1C \uB0B4\uC7A5${mcpManager && mcpManager.serverCount > 0 ? ` + ${mcpManager.getAllTools().length}\uAC1C MCP` : ""}`,
1878
+ ``,
1879
+ `${chalk13.gray("\uBB34\uC5C7\uC774\uB4E0 \uBB3C\uC5B4\uBCF4\uC138\uC694. \uD30C\uC77C \uC77D\uAE30/\uC4F0\uAE30, \uCF54\uB4DC \uC2E4\uD589, \uAC80\uC0C9 \uAC00\uB2A5.")}`,
1880
+ `${chalk13.gray("/help \uB3C4\uC6C0\uB9D0 \xB7 /home \uD648 \xB7 /exit \uC885\uB8CC")}`
1881
+ ]));
1882
+ console.log();
1883
+ const rl = createInterface6({ input: process.stdin, output: process.stdout });
1884
+ const askUser = () => new Promise((resolve) => rl.question(chalk13.cyan.bold(" \u276F "), (a) => resolve(a.trim())));
1885
+ process.on("SIGINT", () => {
1886
+ console.log(chalk13.gray("\n\uC885\uB8CC\uD569\uB2C8\uB2E4."));
1887
+ mcpManager?.stopAll();
1888
+ rl.close();
1889
+ process.exit(0);
1890
+ });
1891
+ while (true) {
1892
+ const input = await askUser();
1893
+ if (!input) continue;
1894
+ if (input === "exit" || input === "/exit") {
1895
+ console.log(chalk13.gray("\uC885\uB8CC\uD569\uB2C8\uB2E4."));
1896
+ mcpManager?.stopAll();
1897
+ rl.close();
1898
+ break;
1899
+ }
1900
+ if (input === "/help") {
1901
+ console.log();
1902
+ console.log(chalk13.bold(" \uC2AC\uB798\uC2DC \uCEE4\uB9E8\uB4DC"));
1903
+ console.log(chalk13.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
1904
+ console.log(` ${chalk13.cyan("/tools")} \uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uB3C4\uAD6C \uBAA9\uB85D`);
1905
+ console.log(` ${chalk13.cyan("/provider")} \uD604\uC7AC \uD504\uB85C\uBC14\uC774\uB354 \uC815\uBCF4`);
1906
+ console.log(` ${chalk13.cyan("/model")} \uB4F1\uB85D\uB41C \uD504\uB85C\uBC14\uC774\uB354 \uBAA9\uB85D`);
1907
+ console.log(` ${chalk13.cyan("/mcp")} MCP \uC11C\uBC84 \uC0C1\uD0DC`);
1908
+ console.log(` ${chalk13.cyan("/clear")} \uB300\uD654 \uCD08\uAE30\uD654`);
1909
+ console.log(` ${chalk13.cyan("/home")} \uD648 \uBA54\uB274\uB85C \uB3CC\uC544\uAC00\uAE30`);
1910
+ console.log(` ${chalk13.cyan("/exit")} \uC885\uB8CC`);
1911
+ console.log();
1912
+ continue;
1913
+ }
1914
+ if (input === "/clear") {
1915
+ messages.length = 1;
1916
+ console.log(chalk13.gray(" \uB300\uD654 \uCD08\uAE30\uD654\uB428.\n"));
1917
+ continue;
1918
+ }
1919
+ if (input === "/tools") {
1920
+ console.log(chalk13.bold("\n\uB0B4\uC7A5 \uB3C4\uAD6C:"), getToolNames().join(", "));
1921
+ if (mcpManager && mcpManager.serverCount > 0) {
1922
+ console.log(chalk13.bold("MCP \uB3C4\uAD6C:"), mcpManager.getAllTools().map((t) => t.function.name).join(", "));
1923
+ }
1924
+ console.log();
1925
+ continue;
1926
+ }
1927
+ if (input === "/provider") {
1928
+ console.log(chalk13.gray(`\uD604\uC7AC: ${provider.name} (${provider.model})`));
1929
+ console.log(chalk13.gray(`\uBCC0\uACBD: xgen provider add / xgen provider use <id>
1930
+ `));
1931
+ continue;
1932
+ }
1933
+ if (input === "/model") {
1934
+ const { getProviders: gp } = await Promise.resolve().then(() => (init_store(), store_exports));
1935
+ const all = gp();
1936
+ if (all.length > 0) {
1937
+ console.log(chalk13.bold("\n \uB4F1\uB85D\uB41C \uD504\uB85C\uBC14\uC774\uB354:\n"));
1938
+ all.forEach((p, i) => {
1939
+ const mark = p.id === provider.id ? chalk13.green("\u25CF ") : " ";
1940
+ console.log(` ${mark}${i + 1}) ${p.name} (${p.model})`);
1941
+ });
1942
+ console.log(chalk13.gray("\n \uBCC0\uACBD\uD558\uB824\uBA74 exit \uD6C4 xgen provider use <id>\n"));
1943
+ }
1944
+ continue;
1945
+ }
1946
+ if (input === "/home" || input === "/menu") {
1947
+ console.log(chalk13.gray("\uC5D0\uC774\uC804\uD2B8\uB97C \uC885\uB8CC\uD558\uACE0 \uD648\uC73C\uB85C \uB3CC\uC544\uAC11\uB2C8\uB2E4."));
1948
+ mcpManager?.stopAll();
1949
+ rl.close();
1950
+ const { homeMenu: homeMenu2 } = await Promise.resolve().then(() => (init_home(), home_exports));
1951
+ await homeMenu2();
1952
+ return;
1953
+ }
1954
+ if (input === "/mcp") {
1955
+ if (mcpManager && mcpManager.serverCount > 0) {
1956
+ console.log(chalk13.bold("\nMCP \uC11C\uBC84:"), mcpManager.getServerNames().join(", "));
1957
+ console.log(chalk13.gray("\uB3C4\uAD6C:"), mcpManager.getAllTools().map((t) => t.function.name).join(", "));
1958
+ } else {
1959
+ console.log(chalk13.gray("MCP \uC11C\uBC84 \uC5C6\uC74C. .mcp.json\uC744 \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8\uC5D0 \uCD94\uAC00\uD558\uC138\uC694."));
1981
1960
  }
1982
1961
  console.log();
1983
1962
  continue;
@@ -1986,77 +1965,531 @@ async function agentRepl() {
1986
1965
  try {
1987
1966
  await runAgentLoop(client2, provider.model, messages, allTools);
1988
1967
  } catch (err) {
1989
- console.log(chalk11.red(`
1968
+ console.log(chalk13.red(`
1990
1969
  \uC624\uB958: ${err.message}
1991
1970
  `));
1992
1971
  }
1993
1972
  }
1994
1973
  }
1995
- async function runAgentLoop(client2, model, messages, tools2) {
1996
- const MAX_ITERATIONS = 20;
1997
- for (let i = 0; i < MAX_ITERATIONS; i++) {
1998
- const result = await streamChat(client2, model, messages, tools2, (delta) => {
1999
- process.stdout.write(delta);
2000
- });
2001
- if (result.content) {
2002
- process.stdout.write("\n\n");
2003
- }
2004
- if (result.toolCalls.length === 0) {
2005
- if (result.content) {
2006
- messages.push({ role: "assistant", content: result.content });
2007
- }
1974
+ async function runAgentLoop(client2, model, messages, tools2) {
1975
+ const MAX_ITERATIONS = 20;
1976
+ for (let i = 0; i < MAX_ITERATIONS; i++) {
1977
+ let first = true;
1978
+ const result = await streamChat(client2, model, messages, tools2, (delta) => {
1979
+ if (first) {
1980
+ process.stdout.write(chalk13.green("\n AI \u203A") + " ");
1981
+ first = false;
1982
+ }
1983
+ process.stdout.write(delta);
1984
+ });
1985
+ if (result.content) {
1986
+ process.stdout.write("\n\n");
1987
+ }
1988
+ if (result.toolCalls.length === 0) {
1989
+ if (result.content) {
1990
+ messages.push({ role: "assistant", content: result.content });
1991
+ }
1992
+ return;
1993
+ }
1994
+ messages.push({
1995
+ role: "assistant",
1996
+ content: result.content || null,
1997
+ tool_calls: result.toolCalls.map((tc) => ({
1998
+ id: tc.id,
1999
+ type: "function",
2000
+ function: { name: tc.name, arguments: tc.arguments }
2001
+ }))
2002
+ });
2003
+ for (const tc of result.toolCalls) {
2004
+ let args;
2005
+ try {
2006
+ args = JSON.parse(tc.arguments);
2007
+ } catch {
2008
+ args = {};
2009
+ }
2010
+ console.log(chalk13.gray(` \u2699 `) + chalk13.white.bold(tc.name) + chalk13.gray(` ${summarizeArgs(args)}`));
2011
+ let toolResult;
2012
+ if (mcpManager?.isMcpTool(tc.name)) {
2013
+ toolResult = await mcpManager.callTool(tc.name, args);
2014
+ } else {
2015
+ toolResult = await executeTool(tc.name, args);
2016
+ }
2017
+ const truncated = toolResult.length > 4e3 ? toolResult.slice(0, 4e3) + "\n...(truncated)" : toolResult;
2018
+ messages.push({
2019
+ role: "tool",
2020
+ tool_call_id: tc.id,
2021
+ content: truncated
2022
+ });
2023
+ }
2024
+ }
2025
+ console.log(chalk13.yellow("\n\uCD5C\uB300 \uBC18\uBCF5 \uD69F\uC218\uC5D0 \uB3C4\uB2EC\uD588\uC2B5\uB2C8\uB2E4.\n"));
2026
+ }
2027
+ function summarizeArgs(args) {
2028
+ const parts = [];
2029
+ for (const [k, v] of Object.entries(args)) {
2030
+ const s = String(v);
2031
+ parts.push(`${k}: ${s.length > 40 ? s.slice(0, 40) + "..." : s}`);
2032
+ }
2033
+ return parts.join(", ");
2034
+ }
2035
+ function registerAgentCommand(program2) {
2036
+ program2.command("agent").description("OPEN XGEN AI \uCF54\uB529 \uC5D0\uC774\uC804\uD2B8").action(async () => {
2037
+ await agentRepl();
2038
+ });
2039
+ }
2040
+ var SYSTEM_PROMPT, mcpManager;
2041
+ var init_agent = __esm({
2042
+ "src/commands/agent.ts"() {
2043
+ "use strict";
2044
+ init_store();
2045
+ init_llm();
2046
+ init_tools();
2047
+ init_client2();
2048
+ init_provider();
2049
+ init_ui();
2050
+ SYSTEM_PROMPT = `You are OPEN XGEN Agent, an AI coding assistant running in the user's terminal.
2051
+ You have access to tools for reading/writing files, executing commands, searching code, and running sandboxed code.
2052
+ You can also use MCP (Model Context Protocol) tools if available.
2053
+ Always respond in the same language as the user.
2054
+ When using tools, be concise about what you're doing.
2055
+ For file edits, show what you changed briefly.
2056
+ For sandbox_run, you can install npm/pip packages and run isolated code.`;
2057
+ mcpManager = null;
2058
+ }
2059
+ });
2060
+
2061
+ // src/index.ts
2062
+ import { Command } from "commander";
2063
+ import chalk16 from "chalk";
2064
+
2065
+ // src/commands/config.ts
2066
+ init_store();
2067
+ init_client();
2068
+ init_format();
2069
+ import chalk2 from "chalk";
2070
+ function registerConfigCommand(program2) {
2071
+ const config = program2.command("config").description("XGEN CLI \uC124\uC815 \uAD00\uB9AC");
2072
+ config.command("set-server <url>").description("XGEN \uC11C\uBC84 URL \uC124\uC815").action((url) => {
2073
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
2074
+ printError("URL\uC740 http:// \uB610\uB294 https://\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4");
2075
+ process.exit(1);
2076
+ }
2077
+ setServer(url);
2078
+ resetClient();
2079
+ printSuccess(`\uC11C\uBC84 \uC124\uC815 \uC644\uB8CC: ${chalk2.underline(url)}`);
2080
+ });
2081
+ config.command("get-server").description("\uD604\uC7AC \uC124\uC815\uB41C \uC11C\uBC84 URL \uD655\uC778").action(() => {
2082
+ const server = getServer();
2083
+ if (server) {
2084
+ console.log(server);
2085
+ } else {
2086
+ printError("\uC11C\uBC84\uAC00 \uC124\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4");
2087
+ console.log(" \uC124\uC815: xgen config set-server <url>");
2088
+ }
2089
+ });
2090
+ config.command("list").description("\uC804\uCCB4 \uC124\uC815 \uD655\uC778").action(() => {
2091
+ const cfg = getConfig();
2092
+ console.log(chalk2.bold("\nXGEN CLI \uC124\uC815"));
2093
+ console.log(chalk2.gray("\u2500".repeat(40)));
2094
+ printKeyValue("\uC11C\uBC84", cfg.server);
2095
+ printKeyValue("\uAE30\uBCF8 \uC6CC\uD06C\uD50C\uB85C\uC6B0", cfg.defaultWorkflow);
2096
+ printKeyValue("\uD14C\uB9C8", cfg.theme);
2097
+ printKeyValue("\uC2A4\uD2B8\uB9BC \uB85C\uADF8", String(cfg.streamLogs));
2098
+ console.log();
2099
+ });
2100
+ config.command("set <key> <value>").description("\uC124\uC815 \uAC12 \uBCC0\uACBD").action((key, value) => {
2101
+ const allowedKeys = ["defaultWorkflow", "theme", "streamLogs"];
2102
+ if (!allowedKeys.includes(key)) {
2103
+ printError(`\uC54C \uC218 \uC5C6\uB294 \uC124\uC815 \uD0A4: ${key}`);
2104
+ console.log(` \uC0AC\uC6A9 \uAC00\uB2A5: ${allowedKeys.join(", ")}`);
2105
+ process.exit(1);
2106
+ }
2107
+ const parsed = key === "streamLogs" ? value === "true" : value;
2108
+ setConfig({ [key]: parsed });
2109
+ printSuccess(`${key} = ${value}`);
2110
+ });
2111
+ }
2112
+
2113
+ // src/commands/login.ts
2114
+ init_auth();
2115
+ init_store();
2116
+ init_format();
2117
+ import chalk3 from "chalk";
2118
+ import { createInterface } from "readline";
2119
+ function prompt(question, hidden = false) {
2120
+ return new Promise((resolve) => {
2121
+ const rl = createInterface({
2122
+ input: process.stdin,
2123
+ output: process.stdout
2124
+ });
2125
+ if (hidden) {
2126
+ process.stdout.write(question);
2127
+ const stdin = process.stdin;
2128
+ const wasRaw = stdin.isRaw;
2129
+ if (stdin.isTTY) stdin.setRawMode(true);
2130
+ let password = "";
2131
+ const onData = (ch) => {
2132
+ const c = ch.toString("utf8");
2133
+ if (c === "\n" || c === "\r" || c === "") {
2134
+ if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
2135
+ stdin.removeListener("data", onData);
2136
+ process.stdout.write("\n");
2137
+ rl.close();
2138
+ resolve(password);
2139
+ } else if (c === "") {
2140
+ process.exit(0);
2141
+ } else if (c === "\x7F" || c === "\b") {
2142
+ if (password.length > 0) {
2143
+ password = password.slice(0, -1);
2144
+ process.stdout.write("\b \b");
2145
+ }
2146
+ } else {
2147
+ password += c;
2148
+ process.stdout.write("*");
2149
+ }
2150
+ };
2151
+ stdin.on("data", onData);
2152
+ } else {
2153
+ rl.question(question, (answer) => {
2154
+ rl.close();
2155
+ resolve(answer.trim());
2156
+ });
2157
+ }
2158
+ });
2159
+ }
2160
+ function registerLoginCommand(program2) {
2161
+ program2.command("login").description("XGEN \uC11C\uBC84\uC5D0 \uB85C\uADF8\uC778").option("-e, --email <email>", "\uC774\uBA54\uC77C").option("-p, --password <password>", "\uBE44\uBC00\uBC88\uD638").action(async (opts) => {
2162
+ const server = requireServer();
2163
+ printHeader("XGEN Login");
2164
+ console.log(chalk3.gray(`\uC11C\uBC84: ${server}
2165
+ `));
2166
+ let email = opts.email;
2167
+ let password = opts.password;
2168
+ if (!email) {
2169
+ email = await prompt(chalk3.white("\uC774\uBA54\uC77C: "));
2170
+ }
2171
+ if (!password) {
2172
+ password = await prompt(chalk3.white("\uBE44\uBC00\uBC88\uD638: "), true);
2173
+ }
2174
+ if (!email || !password) {
2175
+ printError("\uC774\uBA54\uC77C\uACFC \uBE44\uBC00\uBC88\uD638\uB97C \uBAA8\uB450 \uC785\uB825\uD558\uC138\uC694");
2176
+ process.exit(1);
2177
+ }
2178
+ try {
2179
+ const result = await apiLogin(email, password);
2180
+ if (result.success && result.access_token) {
2181
+ setAuth({
2182
+ accessToken: result.access_token,
2183
+ refreshToken: result.refresh_token ?? "",
2184
+ userId: result.user_id ?? "",
2185
+ username: result.username ?? "",
2186
+ isAdmin: false,
2187
+ expiresAt: null
2188
+ });
2189
+ console.log();
2190
+ printSuccess(`\uB85C\uADF8\uC778 \uC131\uACF5! ${chalk3.bold(result.username ?? email)}`);
2191
+ } else {
2192
+ printError(result.message || "\uB85C\uADF8\uC778 \uC2E4\uD328");
2193
+ process.exit(1);
2194
+ }
2195
+ } catch (err) {
2196
+ const msg = err?.response?.data?.message ?? err?.response?.data?.detail ?? err.message;
2197
+ printError(`\uB85C\uADF8\uC778 \uC2E4\uD328: ${msg}`);
2198
+ process.exit(1);
2199
+ }
2200
+ });
2201
+ program2.command("logout").description("\uB85C\uADF8\uC544\uC6C3").action(async () => {
2202
+ const { clearAuth: clearAuth2 } = await Promise.resolve().then(() => (init_store(), store_exports));
2203
+ clearAuth2();
2204
+ printSuccess("\uB85C\uADF8\uC544\uC6C3 \uC644\uB8CC");
2205
+ });
2206
+ program2.command("whoami").description("\uD604\uC7AC \uB85C\uADF8\uC778\uB41C \uC0AC\uC6A9\uC790 \uC815\uBCF4").action(async () => {
2207
+ const auth = getAuth();
2208
+ if (!auth) {
2209
+ printError("\uB85C\uADF8\uC778\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. xgen login \uC2E4\uD589\uD558\uC138\uC694");
2210
+ process.exit(1);
2211
+ }
2212
+ const server = requireServer();
2213
+ console.log(chalk3.bold("\n\uD604\uC7AC \uC0AC\uC6A9\uC790"));
2214
+ console.log(chalk3.gray("\u2500".repeat(30)));
2215
+ console.log(` ${chalk3.gray("\uC11C\uBC84:")} ${server}`);
2216
+ console.log(` ${chalk3.gray("\uC0AC\uC6A9\uC790:")} ${chalk3.bold(auth.username)}`);
2217
+ console.log(` ${chalk3.gray("User ID:")} ${auth.userId}`);
2218
+ try {
2219
+ const { apiValidate: apiValidate2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
2220
+ const result = await apiValidate2(auth.accessToken);
2221
+ if (result.valid) {
2222
+ console.log(` ${chalk3.gray("\uC0C1\uD0DC:")} ${chalk3.green("\uD65C\uC131")}`);
2223
+ if (result.is_admin) {
2224
+ console.log(` ${chalk3.gray("\uAD8C\uD55C:")} ${chalk3.yellow("\uAD00\uB9AC\uC790")}`);
2225
+ }
2226
+ if (result.user_type) {
2227
+ console.log(` ${chalk3.gray("\uC720\uD615:")} ${result.user_type}`);
2228
+ }
2229
+ } else {
2230
+ console.log(` ${chalk3.gray("\uC0C1\uD0DC:")} ${chalk3.red("\uD1A0\uD070 \uB9CC\uB8CC")}`);
2231
+ }
2232
+ } catch {
2233
+ console.log(` ${chalk3.gray("\uC0C1\uD0DC:")} ${chalk3.yellow("\uAC80\uC99D \uBD88\uAC00 (\uC11C\uBC84 \uC5F0\uACB0 \uC2E4\uD328)")}`);
2234
+ }
2235
+ console.log();
2236
+ });
2237
+ }
2238
+
2239
+ // src/commands/workflow/index.ts
2240
+ init_list();
2241
+
2242
+ // src/commands/workflow/info.ts
2243
+ init_store();
2244
+ init_workflow();
2245
+ init_format();
2246
+ import chalk5 from "chalk";
2247
+ async function workflowInfo(workflowId) {
2248
+ requireAuth();
2249
+ try {
2250
+ const detail = await getWorkflowDetail(workflowId);
2251
+ printHeader(`\uC6CC\uD06C\uD50C\uB85C\uC6B0: ${detail.workflow_name ?? workflowId}`);
2252
+ console.log();
2253
+ printKeyValue("ID", detail.id);
2254
+ printKeyValue("\uC774\uB984", detail.workflow_name);
2255
+ printKeyValue("\uC124\uBA85", detail.description ?? "(\uC5C6\uC74C)");
2256
+ if (detail.nodes && Array.isArray(detail.nodes)) {
2257
+ console.log();
2258
+ console.log(chalk5.bold(" \uB178\uB4DC \uAD6C\uC131:"));
2259
+ for (const node of detail.nodes) {
2260
+ const label = node.data?.label ?? node.id;
2261
+ const type = node.data?.type ?? "unknown";
2262
+ console.log(` ${chalk5.cyan("\u2022")} ${label} ${chalk5.gray(`(${type})`)}`);
2263
+ }
2264
+ }
2265
+ if (detail.parameters && Object.keys(detail.parameters).length > 0) {
2266
+ console.log();
2267
+ console.log(chalk5.bold(" \uD30C\uB77C\uBBF8\uD130:"));
2268
+ for (const [key, val] of Object.entries(detail.parameters)) {
2269
+ console.log(` ${chalk5.gray(key)}: ${JSON.stringify(val)}`);
2270
+ }
2271
+ }
2272
+ console.log();
2273
+ } catch (err) {
2274
+ const msg = err.message;
2275
+ printError(`\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC870\uD68C \uC2E4\uD328: ${msg}`);
2276
+ process.exit(1);
2277
+ }
2278
+ }
2279
+
2280
+ // src/commands/workflow/run.ts
2281
+ init_store();
2282
+ init_workflow();
2283
+ init_sse();
2284
+ init_format();
2285
+ import chalk7 from "chalk";
2286
+ import { randomUUID } from "crypto";
2287
+
2288
+ // src/utils/markdown.ts
2289
+ import chalk6 from "chalk";
2290
+ var CODE_BLOCK_RE = /```(\w*)\n([\s\S]*?)```/g;
2291
+ var INLINE_CODE_RE = /`([^`]+)`/g;
2292
+ var BOLD_RE = /\*\*(.+?)\*\*/g;
2293
+ var HEADING_RE = /^(#{1,3})\s+(.+)$/gm;
2294
+ var LIST_RE = /^(\s*)[-*]\s+(.+)$/gm;
2295
+ var LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
2296
+ function renderMarkdown(text) {
2297
+ let result = text;
2298
+ result = result.replace(CODE_BLOCK_RE, (_match, lang, code) => {
2299
+ const trimmed = code.trimEnd();
2300
+ const header = lang ? chalk6.gray(` \u2500\u2500 ${lang} \u2500\u2500`) : chalk6.gray(" \u2500\u2500 code \u2500\u2500");
2301
+ const lines = trimmed.split("\n").map((l) => chalk6.white(` ${l}`)).join("\n");
2302
+ return `
2303
+ ${header}
2304
+ ${lines}
2305
+ ${chalk6.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
2306
+ `;
2307
+ });
2308
+ result = result.replace(INLINE_CODE_RE, (_m, code) => chalk6.cyan(`\`${code}\``));
2309
+ result = result.replace(BOLD_RE, (_m, text2) => chalk6.bold(text2));
2310
+ result = result.replace(HEADING_RE, (_m, hashes, text2) => {
2311
+ if (hashes.length === 1) return chalk6.bold.underline(text2);
2312
+ if (hashes.length === 2) return chalk6.bold(text2);
2313
+ return chalk6.bold.dim(text2);
2314
+ });
2315
+ result = result.replace(LIST_RE, (_m, indent, text2) => `${indent}${chalk6.cyan("\u2022")} ${text2}`);
2316
+ result = result.replace(LINK_RE, (_m, label, url) => `${chalk6.blue.underline(label)} ${chalk6.gray(`(${url})`)}`);
2317
+ return result;
2318
+ }
2319
+
2320
+ // src/commands/workflow/run.ts
2321
+ async function workflowRun(workflowId, input, opts) {
2322
+ const auth = requireAuth();
2323
+ let workflowName = workflowId;
2324
+ try {
2325
+ const detail = await getWorkflowDetail(workflowId);
2326
+ workflowName = detail.workflow_name ?? workflowId;
2327
+ } catch {
2328
+ }
2329
+ if (!input) {
2330
+ if (opts.interactive || !process.stdin.isTTY) {
2331
+ const { createInterface: createInterface8 } = await import("readline");
2332
+ const rl = createInterface8({ input: process.stdin, output: process.stdout });
2333
+ input = await new Promise((resolve) => {
2334
+ rl.question(chalk7.cyan("\uC785\uB825> "), (answer) => {
2335
+ rl.close();
2336
+ resolve(answer.trim());
2337
+ });
2338
+ });
2339
+ } else {
2340
+ printError("\uC785\uB825\uAC12\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \uC0AC\uC6A9\uBC95:");
2341
+ console.log(' xgen workflow run <id> "\uC785\uB825 \uD14D\uC2A4\uFFFD\uFFFD\uFFFD"');
2342
+ console.log(" xgen workflow run -i <id>");
2343
+ process.exit(1);
2344
+ }
2345
+ }
2346
+ if (!input) {
2347
+ printError("\uC785\uB825\uAC12\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
2348
+ process.exit(1);
2349
+ }
2350
+ const interactionId = `cli_${randomUUID().slice(0, 8)}`;
2351
+ printHeader(`\uC2E4\uD589: ${workflowName}`);
2352
+ printInfo(`\uC785\uB825: ${input}`);
2353
+ console.log();
2354
+ try {
2355
+ const stream = await executeWorkflowStream({
2356
+ workflow_id: workflowId,
2357
+ workflow_name: workflowName,
2358
+ input_data: input,
2359
+ interaction_id: interactionId
2360
+ });
2361
+ let hasOutput = false;
2362
+ let fullResponse = "";
2363
+ await parseSSEStream(
2364
+ stream,
2365
+ (event) => {
2366
+ switch (event.type) {
2367
+ case "token":
2368
+ if (event.content) {
2369
+ if (!hasOutput) {
2370
+ hasOutput = true;
2371
+ console.log();
2372
+ }
2373
+ process.stdout.write(event.content);
2374
+ fullResponse += event.content;
2375
+ }
2376
+ break;
2377
+ case "log":
2378
+ if (opts.logs && event.content) {
2379
+ process.stderr.write(chalk7.gray(`[LOG] ${event.content}
2380
+ `));
2381
+ }
2382
+ break;
2383
+ case "node_status":
2384
+ if (opts.logs) {
2385
+ const nodeName = event.node_name ?? event.node_id ?? "?";
2386
+ const status = event.status ?? "?";
2387
+ process.stderr.write(
2388
+ chalk7.gray(`[\uB178\uB4DC] ${nodeName}: ${status}
2389
+ `)
2390
+ );
2391
+ }
2392
+ break;
2393
+ case "tool":
2394
+ if (opts.logs) {
2395
+ process.stderr.write(chalk7.gray(`[\uB3C4\uAD6C] ${JSON.stringify(event.data)}
2396
+ `));
2397
+ }
2398
+ break;
2399
+ case "complete":
2400
+ break;
2401
+ case "error":
2402
+ console.log();
2403
+ printError(event.error ?? event.content ?? "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958");
2404
+ break;
2405
+ default:
2406
+ if (event.content) {
2407
+ if (!hasOutput) {
2408
+ process.stdout.write(chalk7.green("\uC751\uB2F5: "));
2409
+ hasOutput = true;
2410
+ }
2411
+ process.stdout.write(event.content);
2412
+ }
2413
+ }
2414
+ },
2415
+ () => {
2416
+ if (hasOutput) {
2417
+ console.log();
2418
+ if (fullResponse.includes("```") || fullResponse.includes("**")) {
2419
+ console.log(chalk7.gray("\u2500".repeat(40)));
2420
+ console.log(renderMarkdown(fullResponse));
2421
+ }
2422
+ }
2423
+ console.log();
2424
+ console.log(chalk7.gray(`\uC138\uC158: ${interactionId}`));
2425
+ },
2426
+ (err) => {
2427
+ console.log();
2428
+ printError(`\uC2A4\uD2B8\uB9AC\uBC0D \uC624\uB958: ${err.message}`);
2429
+ }
2430
+ );
2431
+ } catch (err) {
2432
+ const msg = err?.response?.data?.detail ?? err.message;
2433
+ printError(`\uC2E4\uD589 \uC2E4\uD328: ${msg}`);
2434
+ process.exit(1);
2435
+ }
2436
+ }
2437
+
2438
+ // src/commands/workflow/history.ts
2439
+ init_store();
2440
+ init_workflow();
2441
+ init_format();
2442
+ import chalk8 from "chalk";
2443
+ async function workflowHistory(workflowId, opts = {}) {
2444
+ requireAuth();
2445
+ const limit = opts.limit ?? 20;
2446
+ try {
2447
+ const logs = await getIOLogs(workflowId, limit);
2448
+ if (!logs || logs.length === 0) {
2449
+ console.log(chalk8.yellow("\n\uC2E4\uD589 \uC774\uB825\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.\n"));
2008
2450
  return;
2009
2451
  }
2010
- messages.push({
2011
- role: "assistant",
2012
- content: result.content || null,
2013
- tool_calls: result.toolCalls.map((tc) => ({
2014
- id: tc.id,
2015
- type: "function",
2016
- function: { name: tc.name, arguments: tc.arguments }
2017
- }))
2018
- });
2019
- for (const tc of result.toolCalls) {
2020
- let args;
2021
- try {
2022
- args = JSON.parse(tc.arguments);
2023
- } catch {
2024
- args = {};
2025
- }
2026
- console.log(chalk11.gray(` \u2699 ${tc.name}(`), chalk11.dim(summarizeArgs(args)), chalk11.gray(")"));
2027
- let toolResult;
2028
- if (mcpManager?.isMcpTool(tc.name)) {
2029
- toolResult = await mcpManager.callTool(tc.name, args);
2030
- } else {
2031
- toolResult = await executeTool(tc.name, args);
2452
+ printHeader(`\uC2E4\uD589 \uC774\uB825 (\uCD5C\uADFC ${logs.length}\uAC74)`);
2453
+ console.log();
2454
+ for (const log of logs) {
2455
+ console.log(
2456
+ ` ${chalk8.gray(formatDate(log.created_at))} ${chalk8.cyan(log.interaction_id)}`
2457
+ );
2458
+ console.log(` ${chalk8.white("\uC785\uB825:")} ${truncate(log.input_data, 60)}`);
2459
+ console.log(
2460
+ ` ${chalk8.green("\uCD9C\uB825:")} ${truncate(log.output_data, 60)}`
2461
+ );
2462
+ if (log.execution_time) {
2463
+ console.log(
2464
+ ` ${chalk8.gray("\uC2DC\uAC04:")} ${(log.execution_time / 1e3).toFixed(1)}s`
2465
+ );
2032
2466
  }
2033
- const truncated = toolResult.length > 4e3 ? toolResult.slice(0, 4e3) + "\n...(truncated)" : toolResult;
2034
- messages.push({
2035
- role: "tool",
2036
- tool_call_id: tc.id,
2037
- content: truncated
2038
- });
2467
+ console.log();
2039
2468
  }
2469
+ } catch (err) {
2470
+ const msg = err.message;
2471
+ printError(`\uC774\uB825 \uC870\uD68C \uC2E4\uD328: ${msg}`);
2472
+ process.exit(1);
2040
2473
  }
2041
- console.log(chalk11.yellow("\n\uCD5C\uB300 \uBC18\uBCF5 \uD69F\uC218\uC5D0 \uB3C4\uB2EC\uD588\uC2B5\uB2C8\uB2E4.\n"));
2042
- }
2043
- function summarizeArgs(args) {
2044
- const parts = [];
2045
- for (const [k, v] of Object.entries(args)) {
2046
- const s = String(v);
2047
- parts.push(`${k}: ${s.length > 40 ? s.slice(0, 40) + "..." : s}`);
2048
- }
2049
- return parts.join(", ");
2050
2474
  }
2051
- function registerAgentCommand(program2) {
2052
- program2.command("agent").description("OPEN XGEN AI \uCF54\uB529 \uC5D0\uC774\uC804\uD2B8").action(async () => {
2053
- await agentRepl();
2054
- });
2475
+
2476
+ // src/commands/workflow/index.ts
2477
+ function registerWorkflowCommand(program2) {
2478
+ const wf = program2.command("workflow").alias("wf").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uAD00\uB9AC \uBC0F \uC2E4\uD589");
2479
+ wf.command("list").alias("ls").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D \uC870\uD68C").option("-d, --detail", "\uC0C1\uC138 \uC815\uBCF4 \uD3EC\uD568").action((opts) => workflowList(opts));
2480
+ wf.command("info <workflow-id>").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC0C1\uC138 \uC815\uBCF4").action((id) => workflowInfo(id));
2481
+ wf.command("run <workflow-id> [input]").description("\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589").option("-i, --interactive", "\uC778\uD130\uB799\uD2F0\uBE0C \uBAA8\uB4DC (\uC785\uB825 \uD504\uB86C\uD504\uD2B8)").option("-l, --logs", "\uB514\uBC84\uADF8 \uB85C\uADF8 \uD45C\uC2DC").action((id, input, opts) => workflowRun(id, input, opts));
2482
+ wf.command("history [workflow-id]").description("\uC2E4\uD589 \uC774\uB825 \uC870\uD68C").option("-n, --limit <number>", "\uC870\uD68C \uAC74\uC218", "20").action((id, opts) => workflowHistory(id, { limit: parseInt(opts.limit) }));
2055
2483
  }
2056
2484
 
2485
+ // src/index.ts
2486
+ init_chat();
2487
+ init_provider();
2488
+ init_agent();
2489
+
2057
2490
  // src/commands/doc.ts
2058
2491
  init_store();
2059
- import chalk12 from "chalk";
2492
+ import chalk14 from "chalk";
2060
2493
 
2061
2494
  // src/api/document.ts
2062
2495
  init_client();
@@ -2100,7 +2533,7 @@ function registerDocCommand(program2) {
2100
2533
  try {
2101
2534
  const docs = await listDocuments(opts.collection);
2102
2535
  if (!docs.length) {
2103
- console.log(chalk12.yellow("\n\uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.\n"));
2536
+ console.log(chalk14.yellow("\n\uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.\n"));
2104
2537
  return;
2105
2538
  }
2106
2539
  printHeader(`\uBB38\uC11C \uBAA9\uB85D (${docs.length}\uAC1C)`);
@@ -2124,10 +2557,10 @@ function registerDocCommand(program2) {
2124
2557
  doc.command("upload <file>").description("\uBB38\uC11C \uC5C5\uB85C\uB4DC").option("-c, --collection <id>", "\uCEEC\uB809\uC158 ID").option("-n, --name <name>", "\uD30C\uC77C\uBA85").action(async (file, opts) => {
2125
2558
  requireAuth();
2126
2559
  try {
2127
- console.log(chalk12.gray(`\uC5C5\uB85C\uB4DC \uC911: ${file}`));
2560
+ console.log(chalk14.gray(`\uC5C5\uB85C\uB4DC \uC911: ${file}`));
2128
2561
  const result = await uploadDocument(file, opts.collection, opts.name);
2129
- console.log(chalk12.green("\u2713 \uC5C5\uB85C\uB4DC \uC644\uB8CC"));
2130
- console.log(chalk12.gray(JSON.stringify(result, null, 2)));
2562
+ console.log(chalk14.green("\u2713 \uC5C5\uB85C\uB4DC \uC644\uB8CC"));
2563
+ console.log(chalk14.gray(JSON.stringify(result, null, 2)));
2131
2564
  } catch (err) {
2132
2565
  printError(`\uC5C5\uB85C\uB4DC \uC2E4\uD328: ${err.message}`);
2133
2566
  }
@@ -2137,7 +2570,7 @@ function registerDocCommand(program2) {
2137
2570
  try {
2138
2571
  const d = await getDocumentInfo(id);
2139
2572
  printHeader("\uBB38\uC11C \uC815\uBCF4");
2140
- console.log(chalk12.gray(JSON.stringify(d, null, 2)));
2573
+ console.log(chalk14.gray(JSON.stringify(d, null, 2)));
2141
2574
  } catch (err) {
2142
2575
  printError(`\uC870\uD68C \uC2E4\uD328: ${err.message}`);
2143
2576
  }
@@ -2146,8 +2579,8 @@ function registerDocCommand(program2) {
2146
2579
 
2147
2580
  // src/commands/ontology.ts
2148
2581
  init_store();
2149
- import chalk13 from "chalk";
2150
- import { createInterface as createInterface6 } from "readline";
2582
+ import chalk15 from "chalk";
2583
+ import { createInterface as createInterface7 } from "readline";
2151
2584
 
2152
2585
  // src/api/ontology.ts
2153
2586
  init_client();
@@ -2184,19 +2617,19 @@ function registerOntologyCommand(program2) {
2184
2617
  ont.command("query <question>").alias("q").description("GraphRAG \uC6D0\uC0F7 \uC9C8\uC758").option("-g, --graph <id>", "\uADF8\uB798\uD504 ID").option("--no-scs", "SCS \uCEE8\uD14D\uC2A4\uD2B8 \uBE44\uD65C\uC131\uD654").action(async (question, opts) => {
2185
2618
  requireAuth();
2186
2619
  try {
2187
- console.log(chalk13.gray("\n\uC9C8\uC758 \uC911...\n"));
2620
+ console.log(chalk15.gray("\n\uC9C8\uC758 \uC911...\n"));
2188
2621
  const result = await queryGraphRAG(question, opts.graph, { scs: opts.scs });
2189
2622
  if (result.answer) {
2190
- console.log(chalk13.bold("\uB2F5\uBCC0:"));
2623
+ console.log(chalk15.bold("\uB2F5\uBCC0:"));
2191
2624
  console.log(result.answer);
2192
2625
  }
2193
2626
  if (result.sources?.length) {
2194
- console.log(chalk13.bold("\n\uCD9C\uCC98:"));
2195
- result.sources.forEach((s) => console.log(chalk13.gray(` - ${s}`)));
2627
+ console.log(chalk15.bold("\n\uCD9C\uCC98:"));
2628
+ result.sources.forEach((s) => console.log(chalk15.gray(` - ${s}`)));
2196
2629
  }
2197
2630
  if (result.triples_used?.length) {
2198
- console.log(chalk13.bold("\n\uC0AC\uC6A9\uB41C \uD2B8\uB9AC\uD50C:"));
2199
- result.triples_used.forEach((t) => console.log(chalk13.dim(` ${t}`)));
2631
+ console.log(chalk15.bold("\n\uC0AC\uC6A9\uB41C \uD2B8\uB9AC\uD50C:"));
2632
+ result.triples_used.forEach((t) => console.log(chalk15.dim(` ${t}`)));
2200
2633
  }
2201
2634
  console.log();
2202
2635
  } catch (err) {
@@ -2207,11 +2640,11 @@ function registerOntologyCommand(program2) {
2207
2640
  requireAuth();
2208
2641
  const sessionId = randomUUID3();
2209
2642
  printHeader("Ontology Chat");
2210
- console.log(chalk13.gray("\uBA40\uD2F0\uD134 GraphRAG \uB300\uD654. exit\uB85C \uC885\uB8CC.\n"));
2211
- const rl = createInterface6({ input: process.stdin, output: process.stdout });
2212
- const ask = () => new Promise((resolve) => rl.question(chalk13.green("\u276F "), (a) => resolve(a.trim())));
2643
+ console.log(chalk15.gray("\uBA40\uD2F0\uD134 GraphRAG \uB300\uD654. exit\uB85C \uC885\uB8CC.\n"));
2644
+ const rl = createInterface7({ input: process.stdin, output: process.stdout });
2645
+ const ask2 = () => new Promise((resolve) => rl.question(chalk15.green("\u276F "), (a) => resolve(a.trim())));
2213
2646
  while (true) {
2214
- const input = await ask();
2647
+ const input = await ask2();
2215
2648
  if (!input) continue;
2216
2649
  if (input === "exit") {
2217
2650
  rl.close();
@@ -2223,7 +2656,7 @@ function registerOntologyCommand(program2) {
2223
2656
  ${result.answer}
2224
2657
  `);
2225
2658
  } catch (err) {
2226
- console.log(chalk13.red(`\uC624\uB958: ${err.message}
2659
+ console.log(chalk15.red(`\uC624\uB958: ${err.message}
2227
2660
  `));
2228
2661
  }
2229
2662
  }
@@ -2233,7 +2666,7 @@ ${result.answer}
2233
2666
  try {
2234
2667
  const stats = await getGraphStats(graphId);
2235
2668
  printHeader("\uADF8\uB798\uD504 \uD1B5\uACC4");
2236
- console.log(chalk13.gray(JSON.stringify(stats, null, 2)));
2669
+ console.log(chalk15.gray(JSON.stringify(stats, null, 2)));
2237
2670
  console.log();
2238
2671
  } catch (err) {
2239
2672
  printError(`\uD1B5\uACC4 \uC870\uD68C \uC2E4\uD328: ${err.message}`);
@@ -2241,276 +2674,45 @@ ${result.answer}
2241
2674
  });
2242
2675
  }
2243
2676
 
2244
- // src/commands/home.ts
2245
- init_store();
2246
- import chalk14 from "chalk";
2247
- import { createInterface as createInterface7 } from "readline";
2248
- function prompt3(question) {
2249
- return new Promise((resolve) => {
2250
- const rl = createInterface7({ input: process.stdin, output: process.stdout });
2251
- rl.question(question, (answer) => {
2252
- rl.close();
2253
- resolve(answer.trim());
2254
- });
2255
- });
2256
- }
2257
- function showStatus() {
2258
- const provider = getDefaultProvider();
2259
- const server = getServer();
2260
- const auth = getAuth();
2261
- console.log(chalk14.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
2262
- console.log(chalk14.gray(" \uC0C1\uD0DC:"));
2263
- if (provider) {
2264
- console.log(` AI \uC5D0\uC774\uC804\uD2B8 ${chalk14.green("\u25CF")} ${provider.name} (${provider.model})`);
2265
- } else {
2266
- console.log(` AI \uC5D0\uC774\uC804\uD2B8 ${chalk14.red("\u25CB")} \uBBF8\uC124\uC815`);
2267
- }
2268
- if (server && auth) {
2269
- console.log(` XGEN \uC11C\uBC84 ${chalk14.green("\u25CF")} ${server} (${auth.username})`);
2270
- } else if (server) {
2271
- console.log(` XGEN \uC11C\uBC84 ${chalk14.yellow("\u25CB")} ${server} (\uB85C\uADF8\uC778 \uD544\uC694)`);
2272
- } else {
2273
- console.log(` XGEN \uC11C\uBC84 ${chalk14.red("\u25CB")} \uBBF8\uC124\uC815`);
2274
- }
2275
- console.log(chalk14.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"));
2276
- }
2277
- async function homeMenu() {
2278
- const provider = getDefaultProvider();
2279
- const server = getServer();
2280
- const auth = getAuth();
2281
- console.log(chalk14.cyan(`
2282
- \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
2283
- \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588
2284
- \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2285
- \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2286
- \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588`));
2287
- console.log(chalk14.white.bold(`
2288
- \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
2289
- \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588
2290
- \u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2291
- \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2292
- \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588`));
2293
- console.log(chalk14.gray(` v0.3.0
2294
- `));
2295
- showStatus();
2296
- while (true) {
2297
- const items = [];
2298
- items.push({
2299
- key: "1",
2300
- label: provider ? `AI \uC5D0\uC774\uC804\uD2B8 \uC2DC\uC791 ${chalk14.gray(`(${provider.name})`)}` : `AI \uC5D0\uC774\uC804\uD2B8 \uC124\uC815 + \uC2DC\uC791`,
2301
- available: true,
2302
- action: async () => {
2303
- await agentRepl();
2304
- }
2305
- });
2306
- if (server && auth) {
2307
- items.push({
2308
- key: "2",
2309
- label: `\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uCC44\uD305 ${chalk14.gray(`(${auth.username}@${server.replace("https://", "")})`)}`,
2310
- available: true,
2311
- action: async () => {
2312
- await chat();
2313
- }
2314
- });
2315
- items.push({
2316
- key: "3",
2317
- label: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D",
2318
- available: true,
2319
- action: async () => {
2320
- const { workflowList: workflowList2 } = await Promise.resolve().then(() => (init_list(), list_exports));
2321
- await workflowList2({ detail: false });
2322
- return;
2323
- }
2324
- });
2325
- } else {
2326
- items.push({
2327
- key: "2",
2328
- label: "XGEN \uC11C\uBC84 \uC5F0\uACB0 + \uB85C\uADF8\uC778",
2329
- available: true,
2330
- action: async () => {
2331
- await serverSetup();
2332
- }
2333
- });
2334
- }
2335
- items.push({
2336
- key: String(items.length + 1),
2337
- label: "\uD504\uB85C\uBC14\uC774\uB354 \uAD00\uB9AC",
2338
- available: true,
2339
- action: async () => {
2340
- await providerMenu();
2341
- }
2342
- });
2343
- items.push({
2344
- key: String(items.length + 1),
2345
- label: "\uC124\uC815 \uBCF4\uAE30",
2346
- available: true,
2347
- action: async () => {
2348
- showStatus();
2349
- const cfg = await Promise.resolve().then(() => (init_store(), store_exports));
2350
- const config = cfg.getConfig();
2351
- console.log(chalk14.gray(" \uC124\uC815 \uD30C\uC77C: ~/.xgen/\n"));
2352
- console.log(chalk14.gray(` \uC11C\uBC84: ${config.server ?? "(\uC5C6\uC74C)"}`));
2353
- console.log(chalk14.gray(` \uD14C\uB9C8: ${config.theme}`));
2354
- console.log(chalk14.gray(` \uC2A4\uD2B8\uB9BC \uB85C\uADF8: ${config.streamLogs}
2355
- `));
2356
- }
2357
- });
2358
- items.push({
2359
- key: "q",
2360
- label: "\uC885\uB8CC",
2361
- available: true,
2362
- action: async () => {
2363
- process.exit(0);
2364
- }
2365
- });
2366
- console.log(chalk14.bold(" \uBB58 \uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?\n"));
2367
- for (const item of items) {
2368
- console.log(` ${chalk14.cyan(item.key + ")")} ${item.label}`);
2369
- }
2370
- console.log();
2371
- const choice = await prompt3(chalk14.white(" \uC120\uD0DD: "));
2372
- if (choice === "q" || choice === "exit") {
2373
- console.log(chalk14.gray("\n \uC548\uB155\uD788.\n"));
2374
- break;
2375
- }
2376
- const selected = items.find((i) => i.key === choice);
2377
- if (!selected) {
2378
- console.log(chalk14.red(" \uC798\uBABB\uB41C \uC120\uD0DD\uC785\uB2C8\uB2E4.\n"));
2379
- continue;
2380
- }
2381
- try {
2382
- await selected.action();
2383
- } catch (err) {
2384
- console.log(chalk14.red(`
2385
- \uC624\uB958: ${err.message}
2386
- `));
2387
- }
2388
- console.log();
2389
- showStatus();
2390
- }
2391
- }
2392
- async function serverSetup() {
2393
- console.log(chalk14.cyan.bold("\n XGEN \uC11C\uBC84 \uC5F0\uACB0\n"));
2394
- const currentServer = getServer();
2395
- const urlInput = await prompt3(
2396
- chalk14.white(` \uC11C\uBC84 URL${currentServer ? ` [${currentServer}]` : ""}: `)
2397
- );
2398
- const url = urlInput || currentServer;
2399
- if (!url) {
2400
- console.log(chalk14.red(" URL\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.\n"));
2401
- return;
2402
- }
2403
- const { setServer: setServer2 } = await Promise.resolve().then(() => (init_store(), store_exports));
2404
- setServer2(url);
2405
- console.log(chalk14.green(` \u2713 \uC11C\uBC84 \uC124\uC815: ${url}
2406
- `));
2407
- console.log(chalk14.bold(" \uB85C\uADF8\uC778\n"));
2408
- const email = await prompt3(chalk14.white(" \uC774\uBA54\uC77C: "));
2409
- const password = await prompt3(chalk14.white(" \uBE44\uBC00\uBC88\uD638: "));
2410
- if (!email || !password) {
2411
- console.log(chalk14.red(" \uC774\uBA54\uC77C\uACFC \uBE44\uBC00\uBC88\uD638\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.\n"));
2412
- return;
2413
- }
2414
- try {
2415
- const { apiLogin: apiLogin2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
2416
- const { setAuth: setAuth2 } = await Promise.resolve().then(() => (init_store(), store_exports));
2417
- const result = await apiLogin2(email, password);
2418
- if (result.success && result.access_token) {
2419
- setAuth2({
2420
- accessToken: result.access_token,
2421
- refreshToken: result.refresh_token ?? "",
2422
- userId: result.user_id ?? "",
2423
- username: result.username ?? "",
2424
- isAdmin: false,
2425
- expiresAt: null
2426
- });
2427
- console.log(chalk14.green(` \u2713 \uB85C\uADF8\uC778 \uC131\uACF5! ${result.username ?? email}
2428
- `));
2429
- } else {
2430
- console.log(chalk14.red(` \u2717 \uB85C\uADF8\uC778 \uC2E4\uD328: ${result.message}
2431
- `));
2432
- }
2433
- } catch (err) {
2434
- console.log(chalk14.red(` \u2717 \uB85C\uADF8\uC778 \uC2E4\uD328: ${err.message}
2435
- `));
2436
- }
2437
- }
2438
- async function providerMenu() {
2439
- const { getProviders: getProviders2, getDefaultProvider: getDefault } = await Promise.resolve().then(() => (init_store(), store_exports));
2440
- const providers = getProviders2();
2441
- const defaultP = getDefault();
2442
- console.log(chalk14.cyan.bold("\n \uD504\uB85C\uBC14\uC774\uB354 \uAD00\uB9AC\n"));
2443
- if (providers.length > 0) {
2444
- for (const p of providers) {
2445
- const mark = p.id === defaultP?.id ? chalk14.green("\u25CF ") : chalk14.gray(" ");
2446
- console.log(` ${mark}${p.name} ${chalk14.gray(`(${p.type} \u2014 ${p.model})`)}`);
2447
- }
2448
- console.log();
2449
- }
2450
- console.log(` ${chalk14.cyan("1)")} \uC0C8 \uD504\uB85C\uBC14\uC774\uB354 \uCD94\uAC00`);
2451
- if (providers.length > 1) {
2452
- console.log(` ${chalk14.cyan("2)")} \uAE30\uBCF8 \uD504\uB85C\uBC14\uC774\uB354 \uBCC0\uACBD`);
2453
- }
2454
- console.log(` ${chalk14.cyan("b)")} \uB3CC\uC544\uAC00\uAE30`);
2455
- console.log();
2456
- const choice = await prompt3(chalk14.white(" \uC120\uD0DD: "));
2457
- if (choice === "1") {
2458
- await guidedProviderSetup();
2459
- } else if (choice === "2" && providers.length > 1) {
2460
- console.log();
2461
- providers.forEach((p, i) => {
2462
- console.log(` ${chalk14.cyan(`${i + 1})`)} ${p.name} (${p.model})`);
2463
- });
2464
- console.log();
2465
- const pc = await prompt3(chalk14.white(" \uBC88\uD638: "));
2466
- const pi = parseInt(pc) - 1;
2467
- if (pi >= 0 && pi < providers.length) {
2468
- const { setDefaultProvider: setDef } = await Promise.resolve().then(() => (init_store(), store_exports));
2469
- setDef(providers[pi].id);
2470
- console.log(chalk14.green(` \u2713 \uAE30\uBCF8 \uD504\uB85C\uBC14\uC774\uB354: ${providers[pi].name}
2471
- `));
2472
- }
2473
- }
2474
- }
2475
-
2476
2677
  // src/index.ts
2678
+ init_home();
2477
2679
  var VERSION = "0.3.0";
2478
- var LOGO = chalk15.cyan(`
2680
+ var LOGO = chalk16.cyan(`
2479
2681
  \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
2480
2682
  \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588
2481
2683
  \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2482
2684
  \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2483
2685
  \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588
2484
- `) + chalk15.white.bold(`
2686
+ `) + chalk16.white.bold(`
2485
2687
  \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
2486
2688
  \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588
2487
2689
  \u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2488
2690
  \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588
2489
2691
  \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588
2490
- `) + chalk15.gray(` v${VERSION}
2692
+ `) + chalk16.gray(` v${VERSION}
2491
2693
  `);
2492
2694
  var BANNER = LOGO;
2493
2695
  var program = new Command();
2494
2696
  program.name("xgen").description("OPEN XGEN \u2014 AI Coding Agent + XGEN Platform CLI").version(VERSION).addHelpText("before", BANNER).addHelpText(
2495
2697
  "after",
2496
2698
  `
2497
- ${chalk15.bold("\uC2DC\uC791\uD558\uAE30:")}
2498
- ${chalk15.cyan("xgen provider add")} AI \uD504\uB85C\uBC14\uC774\uB354 \uC124\uC815
2499
- ${chalk15.cyan("xgen agent")} AI \uCF54\uB529 \uC5D0\uC774\uC804\uD2B8
2500
- ${chalk15.cyan("xgen config set-server")} <url> XGEN \uC11C\uBC84 \uC5F0\uACB0
2501
- ${chalk15.cyan("xgen login")} \uC11C\uBC84 \uB85C\uADF8\uC778
2699
+ ${chalk16.bold("\uC2DC\uC791\uD558\uAE30:")}
2700
+ ${chalk16.cyan("xgen provider add")} AI \uD504\uB85C\uBC14\uC774\uB354 \uC124\uC815
2701
+ ${chalk16.cyan("xgen agent")} AI \uCF54\uB529 \uC5D0\uC774\uC804\uD2B8
2702
+ ${chalk16.cyan("xgen config set-server")} <url> XGEN \uC11C\uBC84 \uC5F0\uACB0
2703
+ ${chalk16.cyan("xgen login")} \uC11C\uBC84 \uB85C\uADF8\uC778
2502
2704
 
2503
- ${chalk15.bold("AI \uC5D0\uC774\uC804\uD2B8:")}
2504
- ${chalk15.cyan("xgen agent")} \uCF54\uB529 \uC5D0\uC774\uC804\uD2B8 (\uD30C\uC77C, \uD130\uBBF8\uB110, \uAC80\uC0C9)
2505
- ${chalk15.cyan("xgen provider ls")} \uD504\uB85C\uBC14\uC774\uB354 \uBAA9\uB85D
2506
- ${chalk15.cyan("xgen provider add")} \uD504\uB85C\uBC14\uC774\uB354 \uCD94\uAC00
2705
+ ${chalk16.bold("AI \uC5D0\uC774\uC804\uD2B8:")}
2706
+ ${chalk16.cyan("xgen agent")} \uCF54\uB529 \uC5D0\uC774\uC804\uD2B8 (\uD30C\uC77C, \uD130\uBBF8\uB110, \uAC80\uC0C9)
2707
+ ${chalk16.cyan("xgen provider ls")} \uD504\uB85C\uBC14\uC774\uB354 \uBAA9\uB85D
2708
+ ${chalk16.cyan("xgen provider add")} \uD504\uB85C\uBC14\uC774\uB354 \uCD94\uAC00
2507
2709
 
2508
- ${chalk15.bold("XGEN \uD50C\uB7AB\uD3FC:")}
2509
- ${chalk15.cyan("xgen chat")} \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uB300\uD654
2510
- ${chalk15.cyan("xgen wf ls")} \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D
2511
- ${chalk15.cyan("xgen wf run")} <id> "\uC9C8\uBB38" \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589
2512
- ${chalk15.cyan("xgen doc ls")} \uBB38\uC11C \uBAA9\uB85D
2513
- ${chalk15.cyan("xgen ont query")} "\uC9C8\uBB38" \uC628\uD1A8\uB85C\uC9C0 \uC9C8\uC758
2710
+ ${chalk16.bold("XGEN \uD50C\uB7AB\uD3FC:")}
2711
+ ${chalk16.cyan("xgen chat")} \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uB300\uD654
2712
+ ${chalk16.cyan("xgen wf ls")} \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D
2713
+ ${chalk16.cyan("xgen wf run")} <id> "\uC9C8\uBB38" \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589
2714
+ ${chalk16.cyan("xgen doc ls")} \uBB38\uC11C \uBAA9\uB85D
2715
+ ${chalk16.cyan("xgen ont query")} "\uC9C8\uBB38" \uC628\uD1A8\uB85C\uC9C0 \uC9C8\uC758
2514
2716
  `
2515
2717
  );
2516
2718
  registerConfigCommand(program);
@@ -2523,7 +2725,7 @@ registerDocCommand(program);
2523
2725
  registerOntologyCommand(program);
2524
2726
  if (process.argv.length <= 2) {
2525
2727
  homeMenu().catch((err) => {
2526
- console.error(chalk15.red(`\uC624\uB958: ${err.message}`));
2728
+ console.error(chalk16.red(`\uC624\uB958: ${err.message}`));
2527
2729
  process.exit(1);
2528
2730
  });
2529
2731
  } else {