openxgen 0.6.0 → 0.6.1

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
@@ -400,6 +400,10 @@ async function executeWorkflowStream(request) {
400
400
  }
401
401
  async function executeWorkflow(request) {
402
402
  const client2 = getClient();
403
+ if (request.deploy_key) {
404
+ const res2 = await client2.post("/api/workflow/execute/deploy/result", request);
405
+ return res2.data;
406
+ }
403
407
  const res = await client2.post("/api/workflow/execute/based_id", request);
404
408
  return res.data;
405
409
  }
@@ -478,178 +482,6 @@ var init_sse = __esm({
478
482
  }
479
483
  });
480
484
 
481
- // src/utils/markdown.ts
482
- import chalk6 from "chalk";
483
- function renderMarkdown(text) {
484
- let result = text;
485
- result = result.replace(CODE_BLOCK_RE, (_match, lang, code) => {
486
- const trimmed = code.trimEnd();
487
- const header = lang ? chalk6.gray(` \u2500\u2500 ${lang} \u2500\u2500`) : chalk6.gray(" \u2500\u2500 code \u2500\u2500");
488
- const lines = trimmed.split("\n").map((l) => chalk6.white(` ${l}`)).join("\n");
489
- return `
490
- ${header}
491
- ${lines}
492
- ${chalk6.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
493
- `;
494
- });
495
- result = result.replace(INLINE_CODE_RE, (_m, code) => chalk6.cyan(`\`${code}\``));
496
- result = result.replace(BOLD_RE, (_m, text2) => chalk6.bold(text2));
497
- result = result.replace(HEADING_RE, (_m, hashes, text2) => {
498
- if (hashes.length === 1) return chalk6.bold.underline(text2);
499
- if (hashes.length === 2) return chalk6.bold(text2);
500
- return chalk6.bold.dim(text2);
501
- });
502
- result = result.replace(LIST_RE, (_m, indent, text2) => `${indent}${chalk6.cyan("\u2022")} ${text2}`);
503
- result = result.replace(LINK_RE, (_m, label, url) => `${chalk6.blue.underline(label)} ${chalk6.gray(`(${url})`)}`);
504
- return result;
505
- }
506
- var CODE_BLOCK_RE, INLINE_CODE_RE, BOLD_RE, HEADING_RE, LIST_RE, LINK_RE;
507
- var init_markdown = __esm({
508
- "src/utils/markdown.ts"() {
509
- "use strict";
510
- CODE_BLOCK_RE = /```(\w*)\n([\s\S]*?)```/g;
511
- INLINE_CODE_RE = /`([^`]+)`/g;
512
- BOLD_RE = /\*\*(.+?)\*\*/g;
513
- HEADING_RE = /^(#{1,3})\s+(.+)$/gm;
514
- LIST_RE = /^(\s*)[-*]\s+(.+)$/gm;
515
- LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
516
- }
517
- });
518
-
519
- // src/commands/workflow/run.ts
520
- var run_exports = {};
521
- __export(run_exports, {
522
- workflowRun: () => workflowRun
523
- });
524
- import chalk7 from "chalk";
525
- import { randomUUID } from "crypto";
526
- async function workflowRun(workflowId, input, opts) {
527
- const auth = requireAuth();
528
- let workflowName = workflowId;
529
- try {
530
- const detail = await getWorkflowDetail(workflowId);
531
- workflowName = detail.workflow_name ?? workflowId;
532
- } catch {
533
- }
534
- if (!input) {
535
- if (opts.interactive || !process.stdin.isTTY) {
536
- const { createInterface: createInterface7 } = await import("readline");
537
- const rl = createInterface7({ input: process.stdin, output: process.stdout });
538
- input = await new Promise((resolve) => {
539
- rl.question(chalk7.cyan("\uC785\uB825> "), (answer) => {
540
- rl.close();
541
- resolve(answer.trim());
542
- });
543
- });
544
- } else {
545
- printError("\uC785\uB825\uAC12\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \uC0AC\uC6A9\uBC95:");
546
- console.log(' xgen workflow run <id> "\uC785\uB825 \uD14D\uC2A4\uFFFD\uFFFD\uFFFD"');
547
- console.log(" xgen workflow run -i <id>");
548
- process.exit(1);
549
- }
550
- }
551
- if (!input) {
552
- printError("\uC785\uB825\uAC12\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
553
- process.exit(1);
554
- }
555
- const interactionId = `cli_${randomUUID().slice(0, 8)}`;
556
- printHeader(`\uC2E4\uD589: ${workflowName}`);
557
- printInfo(`\uC785\uB825: ${input}`);
558
- console.log();
559
- try {
560
- const stream = await executeWorkflowStream({
561
- workflow_id: workflowId,
562
- workflow_name: workflowName,
563
- input_data: input,
564
- interaction_id: interactionId
565
- });
566
- let hasOutput = false;
567
- let fullResponse = "";
568
- await parseSSEStream(
569
- stream,
570
- (event) => {
571
- switch (event.type) {
572
- case "token":
573
- if (event.content) {
574
- if (!hasOutput) {
575
- hasOutput = true;
576
- console.log();
577
- }
578
- process.stdout.write(event.content);
579
- fullResponse += event.content;
580
- }
581
- break;
582
- case "log":
583
- if (opts.logs && event.content) {
584
- process.stderr.write(chalk7.gray(`[LOG] ${event.content}
585
- `));
586
- }
587
- break;
588
- case "node_status":
589
- if (opts.logs) {
590
- const nodeName = event.node_name ?? event.node_id ?? "?";
591
- const status = event.status ?? "?";
592
- process.stderr.write(
593
- chalk7.gray(`[\uB178\uB4DC] ${nodeName}: ${status}
594
- `)
595
- );
596
- }
597
- break;
598
- case "tool":
599
- if (opts.logs) {
600
- process.stderr.write(chalk7.gray(`[\uB3C4\uAD6C] ${JSON.stringify(event.data)}
601
- `));
602
- }
603
- break;
604
- case "complete":
605
- break;
606
- case "error":
607
- console.log();
608
- printError(event.error ?? event.content ?? "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958");
609
- break;
610
- default:
611
- if (event.content) {
612
- if (!hasOutput) {
613
- process.stdout.write(chalk7.green("\uC751\uB2F5: "));
614
- hasOutput = true;
615
- }
616
- process.stdout.write(event.content);
617
- }
618
- }
619
- },
620
- () => {
621
- if (hasOutput) {
622
- console.log();
623
- if (fullResponse.includes("```") || fullResponse.includes("**")) {
624
- console.log(chalk7.gray("\u2500".repeat(40)));
625
- console.log(renderMarkdown(fullResponse));
626
- }
627
- }
628
- console.log();
629
- console.log(chalk7.gray(`\uC138\uC158: ${interactionId}`));
630
- },
631
- (err) => {
632
- console.log();
633
- printError(`\uC2A4\uD2B8\uB9AC\uBC0D \uC624\uB958: ${err.message}`);
634
- }
635
- );
636
- } catch (err) {
637
- const msg = err?.response?.data?.detail ?? err.message;
638
- printError(`\uC2E4\uD589 \uC2E4\uD328: ${msg}`);
639
- process.exit(1);
640
- }
641
- }
642
- var init_run = __esm({
643
- "src/commands/workflow/run.ts"() {
644
- "use strict";
645
- init_store();
646
- init_workflow();
647
- init_sse();
648
- init_format();
649
- init_markdown();
650
- }
651
- });
652
-
653
485
  // src/commands/chat.ts
654
486
  import chalk9 from "chalk";
655
487
  import { createInterface as createInterface2 } from "readline";
@@ -2012,8 +1844,8 @@ async function homeMenu() {
2012
1844
  label: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uAD00\uB9AC",
2013
1845
  hint: "\uBAA9\uB85D \uC870\uD68C \u2192 \uC120\uD0DD \u2192 \uC2E4\uD589/\uC815\uBCF4",
2014
1846
  action: async () => {
2015
- const { listWorkflows: listWorkflows2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2016
- const wfs = await listWorkflows2();
1847
+ const { getWorkflowListDetail: getWorkflowListDetail2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
1848
+ const wfs = await getWorkflowListDetail2();
2017
1849
  if (!wfs.length) {
2018
1850
  console.log(chalk12.yellow("\n \uC6CC\uD06C\uD50C\uB85C\uC6B0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.\n"));
2019
1851
  return;
@@ -2041,8 +1873,34 @@ async function homeMenu() {
2041
1873
  `));
2042
1874
  const input = await ask(chalk12.white(" \uBA54\uC2DC\uC9C0: "));
2043
1875
  if (!input) return;
2044
- const { workflowRun: workflowRun2 } = await Promise.resolve().then(() => (init_run(), run_exports));
2045
- await workflowRun2(wfId, input, { logs: false, interactive: false });
1876
+ const deployKey = selected2.deploy_key;
1877
+ const isDeployed = selected2.is_deployed;
1878
+ try {
1879
+ console.log(chalk12.gray("\n \uC2E4\uD589 \uC911...\n"));
1880
+ const { executeWorkflow: executeWorkflow2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
1881
+ const { randomUUID: randomUUID4 } = await import("crypto");
1882
+ const result = await executeWorkflow2({
1883
+ workflow_id: wfId,
1884
+ workflow_name: selected2.workflow_name,
1885
+ input_data: input,
1886
+ interaction_id: `cli_${randomUUID4().slice(0, 8)}`,
1887
+ deploy_key: isDeployed && deployKey ? deployKey : void 0
1888
+ });
1889
+ if (result.content) {
1890
+ console.log(chalk12.bold(" \uC751\uB2F5:"));
1891
+ console.log(` ${result.content}
1892
+ `);
1893
+ } else if (result.success === false) {
1894
+ console.log(chalk12.red(` \uC624\uB958: ${result.error ?? result.message}
1895
+ `));
1896
+ } else {
1897
+ console.log(chalk12.gray(JSON.stringify(result, null, 2).slice(0, 500)));
1898
+ console.log();
1899
+ }
1900
+ } catch (err) {
1901
+ console.log(chalk12.red(` \uC2E4\uD589 \uC2E4\uD328: ${err.message}
1902
+ `));
1903
+ }
2046
1904
  }
2047
1905
  });
2048
1906
  items.push({
@@ -2894,8 +2752,163 @@ async function workflowInfo(workflowId) {
2894
2752
  }
2895
2753
  }
2896
2754
 
2897
- // src/commands/workflow/index.ts
2898
- init_run();
2755
+ // src/commands/workflow/run.ts
2756
+ init_store();
2757
+ init_workflow();
2758
+ init_sse();
2759
+ init_format();
2760
+ import chalk7 from "chalk";
2761
+ import { randomUUID } from "crypto";
2762
+
2763
+ // src/utils/markdown.ts
2764
+ import chalk6 from "chalk";
2765
+ var CODE_BLOCK_RE = /```(\w*)\n([\s\S]*?)```/g;
2766
+ var INLINE_CODE_RE = /`([^`]+)`/g;
2767
+ var BOLD_RE = /\*\*(.+?)\*\*/g;
2768
+ var HEADING_RE = /^(#{1,3})\s+(.+)$/gm;
2769
+ var LIST_RE = /^(\s*)[-*]\s+(.+)$/gm;
2770
+ var LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
2771
+ function renderMarkdown(text) {
2772
+ let result = text;
2773
+ result = result.replace(CODE_BLOCK_RE, (_match, lang, code) => {
2774
+ const trimmed = code.trimEnd();
2775
+ const header = lang ? chalk6.gray(` \u2500\u2500 ${lang} \u2500\u2500`) : chalk6.gray(" \u2500\u2500 code \u2500\u2500");
2776
+ const lines = trimmed.split("\n").map((l) => chalk6.white(` ${l}`)).join("\n");
2777
+ return `
2778
+ ${header}
2779
+ ${lines}
2780
+ ${chalk6.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
2781
+ `;
2782
+ });
2783
+ result = result.replace(INLINE_CODE_RE, (_m, code) => chalk6.cyan(`\`${code}\``));
2784
+ result = result.replace(BOLD_RE, (_m, text2) => chalk6.bold(text2));
2785
+ result = result.replace(HEADING_RE, (_m, hashes, text2) => {
2786
+ if (hashes.length === 1) return chalk6.bold.underline(text2);
2787
+ if (hashes.length === 2) return chalk6.bold(text2);
2788
+ return chalk6.bold.dim(text2);
2789
+ });
2790
+ result = result.replace(LIST_RE, (_m, indent, text2) => `${indent}${chalk6.cyan("\u2022")} ${text2}`);
2791
+ result = result.replace(LINK_RE, (_m, label, url) => `${chalk6.blue.underline(label)} ${chalk6.gray(`(${url})`)}`);
2792
+ return result;
2793
+ }
2794
+
2795
+ // src/commands/workflow/run.ts
2796
+ async function workflowRun(workflowId, input, opts) {
2797
+ const auth = requireAuth();
2798
+ let workflowName = workflowId;
2799
+ try {
2800
+ const detail = await getWorkflowDetail(workflowId);
2801
+ workflowName = detail.workflow_name ?? workflowId;
2802
+ } catch {
2803
+ }
2804
+ if (!input) {
2805
+ if (opts.interactive || !process.stdin.isTTY) {
2806
+ const { createInterface: createInterface7 } = await import("readline");
2807
+ const rl = createInterface7({ input: process.stdin, output: process.stdout });
2808
+ input = await new Promise((resolve) => {
2809
+ rl.question(chalk7.cyan("\uC785\uB825> "), (answer) => {
2810
+ rl.close();
2811
+ resolve(answer.trim());
2812
+ });
2813
+ });
2814
+ } else {
2815
+ printError("\uC785\uB825\uAC12\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \uC0AC\uC6A9\uBC95:");
2816
+ console.log(' xgen workflow run <id> "\uC785\uB825 \uD14D\uC2A4\uFFFD\uFFFD\uFFFD"');
2817
+ console.log(" xgen workflow run -i <id>");
2818
+ process.exit(1);
2819
+ }
2820
+ }
2821
+ if (!input) {
2822
+ printError("\uC785\uB825\uAC12\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
2823
+ process.exit(1);
2824
+ }
2825
+ const interactionId = `cli_${randomUUID().slice(0, 8)}`;
2826
+ printHeader(`\uC2E4\uD589: ${workflowName}`);
2827
+ printInfo(`\uC785\uB825: ${input}`);
2828
+ console.log();
2829
+ try {
2830
+ const stream = await executeWorkflowStream({
2831
+ workflow_id: workflowId,
2832
+ workflow_name: workflowName,
2833
+ input_data: input,
2834
+ interaction_id: interactionId
2835
+ });
2836
+ let hasOutput = false;
2837
+ let fullResponse = "";
2838
+ await parseSSEStream(
2839
+ stream,
2840
+ (event) => {
2841
+ switch (event.type) {
2842
+ case "token":
2843
+ if (event.content) {
2844
+ if (!hasOutput) {
2845
+ hasOutput = true;
2846
+ console.log();
2847
+ }
2848
+ process.stdout.write(event.content);
2849
+ fullResponse += event.content;
2850
+ }
2851
+ break;
2852
+ case "log":
2853
+ if (opts.logs && event.content) {
2854
+ process.stderr.write(chalk7.gray(`[LOG] ${event.content}
2855
+ `));
2856
+ }
2857
+ break;
2858
+ case "node_status":
2859
+ if (opts.logs) {
2860
+ const nodeName = event.node_name ?? event.node_id ?? "?";
2861
+ const status = event.status ?? "?";
2862
+ process.stderr.write(
2863
+ chalk7.gray(`[\uB178\uB4DC] ${nodeName}: ${status}
2864
+ `)
2865
+ );
2866
+ }
2867
+ break;
2868
+ case "tool":
2869
+ if (opts.logs) {
2870
+ process.stderr.write(chalk7.gray(`[\uB3C4\uAD6C] ${JSON.stringify(event.data)}
2871
+ `));
2872
+ }
2873
+ break;
2874
+ case "complete":
2875
+ break;
2876
+ case "error":
2877
+ console.log();
2878
+ printError(event.error ?? event.content ?? "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958");
2879
+ break;
2880
+ default:
2881
+ if (event.content) {
2882
+ if (!hasOutput) {
2883
+ process.stdout.write(chalk7.green("\uC751\uB2F5: "));
2884
+ hasOutput = true;
2885
+ }
2886
+ process.stdout.write(event.content);
2887
+ }
2888
+ }
2889
+ },
2890
+ () => {
2891
+ if (hasOutput) {
2892
+ console.log();
2893
+ if (fullResponse.includes("```") || fullResponse.includes("**")) {
2894
+ console.log(chalk7.gray("\u2500".repeat(40)));
2895
+ console.log(renderMarkdown(fullResponse));
2896
+ }
2897
+ }
2898
+ console.log();
2899
+ console.log(chalk7.gray(`\uC138\uC158: ${interactionId}`));
2900
+ },
2901
+ (err) => {
2902
+ console.log();
2903
+ printError(`\uC2A4\uD2B8\uB9AC\uBC0D \uC624\uB958: ${err.message}`);
2904
+ }
2905
+ );
2906
+ } catch (err) {
2907
+ const msg = err?.response?.data?.detail ?? err.message;
2908
+ printError(`\uC2E4\uD589 \uC2E4\uD328: ${msg}`);
2909
+ process.exit(1);
2910
+ }
2911
+ }
2899
2912
 
2900
2913
  // src/commands/workflow/history.ts
2901
2914
  init_store();