dwkim 3.4.0 → 3.5.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 +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -119,7 +119,7 @@ ${g.dim(g.muted("Enter: \uC804\uC1A1 \xB7 \uBE48\uAC12 Enter: \uB118\uC5B4\uAC00
|
|
|
119
119
|
`)),oe=new qe,oe.onSubmit=dt=>ti(dt),oe.onEscape=()=>v({type:"EMAIL_DISMISS"}),Ie=new W("",2,0),Ie.setText(`
|
|
120
120
|
${g.dim(g.muted("Enter: \uC804\uC1A1 \xB7 \uBE48\uAC12 Enter: \uB118\uC5B4\uAC00\uAE30 \xB7 ESC: \uB2E4\uC2DC\uBCF4\uC9C0\uC54A\uAE30"))}`),t.addChild(Te),t.addChild(oe),t.addChild(Ie),D=!0,t.setFocus(oe);break}case"feedback":{Mn(f),t.addChild(f),I=!0,t.setFocus(null);break}case"feedbackConfirmed":{Rn(f),t.addChild(f),I=!0,t.setFocus(null),setTimeout(()=>v({type:"FEEDBACK_CONFIRMED_DONE"}),1e3);break}case"exitFeedback":{let b=En();C=t.showOverlay(b,{anchor:"center",width:"60%"}),t.setFocus(null);break}case"error":{let b=new W("",1,0);b.setText(`
|
|
121
121
|
${g.error(`${te.error} ${x.errorMessage}`)}`),t.addChild(b);break}}}function Ns(x){let b=e.columns||80;m.setText(`
|
|
122
|
-
${g.surface("\u2500".repeat(b-2))}`),k.setText(x),k.disableSubmit=!1,t.addChild(m),t.addChild(k),w=!0,t.setFocus(k)}function Xn(x,b){b.mode==="loading"&&x.mode==="loading"&&(x.streamContent!==b.streamContent&&Ws(c,b.streamContent),x.progressItems!==b.progressItems&&Os(h,b.progressItems,!!b.streamContent),x.loadingState!==b.loadingState&&Ps(d,b.loadingState),b.streamContent&&H&&(t.removeChild(d),H=!1)),b.mode==="idle"&&x.mode==="idle"&&x.suggestedQuestions!==b.suggestedQuestions&&(b.suggestedQuestions.length>0?(Y&&u&&t.removeChild(u),u=Ds(b.suggestedQuestions),u.onSelect=B=>ct(B.value),u.onCancel=()=>v({type:"SUGGESTION_DISMISS"}),t.addChild(u),Y=!0,t.setFocus(u)):Y&&(u&&t.removeChild(u),u=null,Y=!1,t.setFocus(k)))}k.onSubmit=x=>{let b=x.trim();if(b){if(k.addToHistory(b),b.startsWith("/")){ei(b);return}if(r.lastExchange&&Sn(b)){si(b);return}v({type:"SUBMIT",value:b}),ht(b)}};let Oe=t.handleInput.bind(t);t.handleInput=x=>{if(x===""){if(r.mode==="loading"&&(s.abort(),v({type:"STREAM_CANCEL"})),r.feedbackResponseCount>0){v({type:"EXIT_FEEDBACK_SHOW"});return}Qt(),process.exit(0)}if(r.mode==="exitFeedback"){_n(x);return}if(x==="\x1B"){if(r.mode==="feedback"){v({type:"FEEDBACK_DISABLE"});return}if(r.mode==="loading"){s.abort(),v({type:"STREAM_CANCEL"});return}}if(r.mode==="welcome"){let b=Number(x);if(b>=1&&b<=be.length){v({type:"STARTER_SELECT",index:b-1}),ht(be[b-1]);return}if(x.length===1&&x>=" "){v({type:"WELCOME_DISMISS"}),Oe(x);return}Oe(x);return}if(r.mode==="idle"&&r.suggestedQuestions.length>0){if(x==="1"&&r.suggestedQuestions.length>=1){ct(r.suggestedQuestions[0]);return}if(x==="2"&&r.suggestedQuestions.length>=2){ct(r.suggestedQuestions[1]);return}if(x.length===1&&x>=" "&&x!=="1"&&x!=="2"){v({type:"SUGGESTION_DISMISS"}),Oe(x);return}Oe(x);return}if(r.mode==="idle"&&x==="s"&&r.suggestedQuestions.length===0&&(r.messages.some(B=>B.role==="assistant"&&B.sources&&B.sources.length>0)||r.expandedSourcesMsgId!==null)){v({type:"TOGGLE_SOURCES"});return}if(r.mode==="feedback"){$n(x);return}Oe(x)};function ct(x){v({type:"SUBMIT",value:x}),ht(x)}function $n(x){if(x==="1"){v({type:"FEEDBACK_RATE",rating:1}),s.submitFeedback(1,r.sessionId);return}if(x==="2"){v({type:"FEEDBACK_RATE",rating:2}),s.submitFeedback(2,r.sessionId);return}if(x==="3"){v({type:"FEEDBACK_RATE",rating:3}),s.submitFeedback(3,r.sessionId);return}if(x==="d"||x==="D"){v({type:"FEEDBACK_SKIP"});return}x.length===1&&x>=" "&&(v({type:"FEEDBACK_SKIP"}),Oe(x))}function _n(x){let b=async B=>{await s.submitFeedback(B,r.sessionId),Qt(),process.exit(0)};if(x==="1"){b(1);return}if(x==="2"){b(2);return}if(x==="3"){b(3);return}(x==="d"||x==="D"||x==="\x1B")&&b(null)}async function ht(x){try{let b=[],B="",X=0,ut=!1,dt,Le={icon:"\u23F3",message:"\uCC98\uB9AC \uC911...",toolCalls:[]};for await(let N of s.chatStream(x,r.sessionId))switch(N.type){case"session":v({type:"STREAM_SESSION",sessionId:N.sessionId});break;case"status":Le={icon:N.icon,message:N.message,toolCalls:Le.toolCalls},v({type:"STREAM_STATUS",loadingState:Le});break;case"tool_call":{let ft=[...Le.toolCalls],js=ft.findIndex(ri=>ri.tool===N.tool),Ks={tool:N.tool,displayName:N.displayName,icon:N.icon,phase:N.phase,query:N.metadata?.query,resultCount:N.metadata?.resultCount};js>=0?ft[js]=Ks:ft.push(Ks),Le={...Le,toolCalls:ft},v({type:"STREAM_TOOL_CALL",loadingState:Le});break}case"sources":b=N.sources;break;case"progress":v({type:"STREAM_PROGRESS",items:N.items});break;case"clarification":v({type:"STREAM_CLARIFICATION",questions:N.suggestedQuestions});break;case"escalation":v({type:"STREAM_ESCALATION",reason:N.reason});break;case"followup":v({type:"STREAM_FOLLOWUP",questions:N.suggestedQuestions});break;case"content":B+=N.content,v({type:"STREAM_CONTENT",fullContent:B});break;case"done":X=N.metadata.processingTime,ut=N.metadata.shouldSuggestContact??!1,dt=N.metadata.confidence;break;case"error":throw new J(N.error)}v({type:"STREAM_DONE",fullContent:B,sources:b,processingTime:X,shouldSuggestContact:ut,confidence:dt})}catch(b){if(b instanceof Error&&b.name==="AbortError")return;let B=b instanceof J?b.message:"\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.";v({type:"STREAM_ERROR",error:B})}}async function ei(x){let[b]=x.slice(1).split(" ");switch(b){case"help":v({type:"CMD_HELP",helpText:`
|
|
122
|
+
${g.surface("\u2500".repeat(b-2))}`),k.setText(x),k.disableSubmit=!1,t.addChild(m),t.addChild(k),w=!0,t.setFocus(k)}function Xn(x,b){b.mode==="loading"&&x.mode==="loading"&&(x.streamContent!==b.streamContent&&Ws(c,b.streamContent),x.progressItems!==b.progressItems&&Os(h,b.progressItems,!!b.streamContent),x.loadingState!==b.loadingState&&Ps(d,b.loadingState),b.streamContent&&H&&(t.removeChild(d),H=!1)),b.mode==="idle"&&x.mode==="idle"&&x.suggestedQuestions!==b.suggestedQuestions&&(b.suggestedQuestions.length>0?(Y&&u&&t.removeChild(u),u=Ds(b.suggestedQuestions),u.onSelect=B=>ct(B.value),u.onCancel=()=>v({type:"SUGGESTION_DISMISS"}),t.addChild(u),Y=!0,t.setFocus(u)):Y&&(u&&t.removeChild(u),u=null,Y=!1,t.setFocus(k)))}k.onSubmit=x=>{let b=x.trim();if(b){if(k.addToHistory(b),b.startsWith("/")){ei(b);return}if(r.lastExchange&&Sn(b)){si(b);return}v({type:"SUBMIT",value:b}),ht(b)}};let Oe=t.handleInput.bind(t);t.handleInput=x=>{if(x===""){if(r.mode==="loading"&&(s.abort(),v({type:"STREAM_CANCEL"})),r.feedbackResponseCount>0){v({type:"EXIT_FEEDBACK_SHOW"});return}Qt(),process.exit(0)}if(r.mode==="exitFeedback"){_n(x);return}if(x==="\x1B"){if(r.mode==="feedback"){v({type:"FEEDBACK_DISABLE"});return}if(r.mode==="loading"){s.abort(),v({type:"STREAM_CANCEL"});return}if(r.mode==="idle"&&r.suggestedQuestions.length===0&&k.getText().trim()){k.setText("");return}}if(r.mode==="welcome"){let b=Number(x);if(b>=1&&b<=be.length){v({type:"STARTER_SELECT",index:b-1}),ht(be[b-1]);return}if(x.length===1&&x>=" "){v({type:"WELCOME_DISMISS"}),Oe(x);return}Oe(x);return}if(r.mode==="idle"&&r.suggestedQuestions.length>0){if(x==="1"&&r.suggestedQuestions.length>=1){ct(r.suggestedQuestions[0]);return}if(x==="2"&&r.suggestedQuestions.length>=2){ct(r.suggestedQuestions[1]);return}if(x.length===1&&x>=" "&&x!=="1"&&x!=="2"){v({type:"SUGGESTION_DISMISS"}),Oe(x);return}Oe(x);return}if(r.mode==="idle"&&x==="s"&&r.suggestedQuestions.length===0&&(r.messages.some(B=>B.role==="assistant"&&B.sources&&B.sources.length>0)||r.expandedSourcesMsgId!==null)){v({type:"TOGGLE_SOURCES"});return}if(r.mode==="feedback"){$n(x);return}Oe(x)};function ct(x){v({type:"SUBMIT",value:x}),ht(x)}function $n(x){if(x==="1"){v({type:"FEEDBACK_RATE",rating:1}),s.submitFeedback(1,r.sessionId);return}if(x==="2"){v({type:"FEEDBACK_RATE",rating:2}),s.submitFeedback(2,r.sessionId);return}if(x==="3"){v({type:"FEEDBACK_RATE",rating:3}),s.submitFeedback(3,r.sessionId);return}if(x==="d"||x==="D"){v({type:"FEEDBACK_SKIP"});return}x.length===1&&x>=" "&&(v({type:"FEEDBACK_SKIP"}),Oe(x))}function _n(x){let b=async B=>{await s.submitFeedback(B,r.sessionId),Qt(),process.exit(0)};if(x==="1"){b(1);return}if(x==="2"){b(2);return}if(x==="3"){b(3);return}(x==="d"||x==="D"||x==="\x1B")&&b(null)}async function ht(x){try{let b=[],B="",X=0,ut=!1,dt,Le={icon:"\u23F3",message:"\uCC98\uB9AC \uC911...",toolCalls:[]};for await(let N of s.chatStream(x,r.sessionId))switch(N.type){case"session":v({type:"STREAM_SESSION",sessionId:N.sessionId});break;case"status":Le={icon:N.icon,message:N.message,toolCalls:Le.toolCalls},v({type:"STREAM_STATUS",loadingState:Le});break;case"tool_call":{let ft=[...Le.toolCalls],js=ft.findIndex(ri=>ri.tool===N.tool),Ks={tool:N.tool,displayName:N.displayName,icon:N.icon,phase:N.phase,query:N.metadata?.query,resultCount:N.metadata?.resultCount};js>=0?ft[js]=Ks:ft.push(Ks),Le={...Le,toolCalls:ft},v({type:"STREAM_TOOL_CALL",loadingState:Le});break}case"sources":b=N.sources;break;case"progress":v({type:"STREAM_PROGRESS",items:N.items});break;case"clarification":v({type:"STREAM_CLARIFICATION",questions:N.suggestedQuestions});break;case"escalation":v({type:"STREAM_ESCALATION",reason:N.reason});break;case"followup":v({type:"STREAM_FOLLOWUP",questions:N.suggestedQuestions});break;case"content":B+=N.content,v({type:"STREAM_CONTENT",fullContent:B});break;case"done":X=N.metadata.processingTime,ut=N.metadata.shouldSuggestContact??!1,dt=N.metadata.confidence;break;case"error":throw new J(N.error)}v({type:"STREAM_DONE",fullContent:B,sources:b,processingTime:X,shouldSuggestContact:ut,confidence:dt})}catch(b){if(b instanceof Error&&b.name==="AbortError")return;let B=b instanceof J?b.message:"\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.";v({type:"STREAM_ERROR",error:B})}}async function ei(x){let[b]=x.slice(1).split(" ");switch(b){case"help":v({type:"CMD_HELP",helpText:`
|
|
123
123
|
\uBA85\uB839\uC5B4
|
|
124
124
|
/help \uB3C4\uC6C0\uB9D0
|
|
125
125
|
/status \uC11C\uBC84 \uC0C1\uD0DC
|
|
@@ -132,7 +132,7 @@ ${g.surface("\u2500".repeat(b-2))}`),k.setText(x),k.disableSubmit=!1,t.addChild(
|
|
|
132
132
|
\uC608\uC2DC \uC9C8\uBB38
|
|
133
133
|
\uC5B4\uB5A4 \uAE30\uC220\uC744 \uC0AC\uC6A9\uD558\uB098\uC694?
|
|
134
134
|
\uACBD\uB825\uC5D0 \uB300\uD574 \uC54C\uB824\uC8FC\uC138\uC694`});break;case"status":try{let B=await s.getStatus();v({type:"CMD_STATUS_OK",statusText:`${te.check} ${B.status} \xB7 \uBB38\uC11C ${B.rag_engine?.total_documents||0}\uAC1C`})}catch{v({type:"CMD_STATUS_FAIL"})}break;case"clear":v({type:"CMD_CLEAR"});break;case"exit":case"quit":case"bye":r.feedbackResponseCount>0?v({type:"EXIT_FEEDBACK_SHOW"}):(Qt(),process.exit(0));break;default:v({type:"CMD_HELP",helpText:`${te.error} /${b} \u2014 /help \uCC38\uACE0`})}}async function ti(x){let b=x.trim();if(!b){v({type:"EMAIL_DISMISS"});return}if(!b.includes("@")||!b.includes(".")){v({type:"EMAIL_SUBMIT_ERROR",message:"\uC62C\uBC14\uB978 \uC774\uBA54\uC77C \uC8FC\uC18C\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694."});return}try{let X=await(await fetch(`${Hn}/api/v1/contact`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:b,sessionId:r.sessionId})})).json();if(X.success)v({type:"EMAIL_SUBMIT_SUCCESS",message:X.message});else throw new Error(X.error||"\uC774\uBA54\uC77C \uC804\uC1A1 \uC2E4\uD328")}catch{v({type:"EMAIL_SUBMIT_ERROR",message:"\uC774\uBA54\uC77C \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694. \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694."})}}async function si(x){if(!r.lastExchange)return;let{query:b,response:B}=r.lastExchange;k.setText("");try{let X=await s.submitCorrection(b,B,x,r.sessionId);X.success?v({type:"CORRECTION_SUCCESS",message:X.message}):v({type:"CORRECTION_FAIL",message:X.message})}catch{v({type:"CORRECTION_FAIL",message:"\uC218\uC815 \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694."})}}function Qt(){Ut(),M&&F.stop(),t.stop()}try{await s.checkHealth(3,2e3),v({type:"HEALTH_OK"})}catch{v({type:"HEALTH_FAIL",error:"API \uC5F0\uACB0 \uC2E4\uD328. \uC7A0\uC2DC \uD6C4 \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694."})}}var $o,Hn,Yn=A(()=>{"use strict";ae();un();fn();mn();xn();Cn();An();vn();Fn();Pn();Vn();qt();zs();fe();Kn();$o="https://persona-api.fly.dev",Hn=process.env.DWKIM_API_URL||$o});var qs=process.argv[2];function el(){console.log(`
|
|
135
|
-
\u{1F4DA} dwkim CLI v3.
|
|
135
|
+
\u{1F4DA} dwkim CLI v3.4.0
|
|
136
136
|
|
|
137
137
|
\uC0AC\uC6A9\uBC95: dwkim [\uBA85\uB839\uC5B4]
|
|
138
138
|
|
|
@@ -144,4 +144,4 @@ ${g.surface("\u2500".repeat(b-2))}`),k.setText(x),k.disableSubmit=!1,t.addChild(
|
|
|
144
144
|
\uC608\uC2DC:
|
|
145
145
|
dwkim # \uCC44\uD305 \uC2DC\uC791
|
|
146
146
|
npx dwkim # npm\uC5D0\uC11C \uC2E4\uD589
|
|
147
|
-
`)}async function tl(){if(qs==="--version"||qs==="-v"){console.log("3.
|
|
147
|
+
`)}async function tl(){if(qs==="--version"||qs==="-v"){console.log("3.4.0");return}if(qs==="help"){el();return}let{startApp:e}=await Promise.resolve().then(()=>(Yn(),Gn));await e()}tl().catch(e=>{console.error("Fatal error:",e),process.exit(1)});
|