@eloqnt/cli 0.0.9 → 0.1.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/CHANGELOG.md +17 -0
- package/dist/bin/eloqnt.mjs +1 -1
- package/dist/createSpinner-BBkrpcrh.mjs +1 -0
- package/dist/login-C6wg_xYT.mjs +2 -0
- package/dist/logout-CzVVtihJ.mjs +1 -0
- package/dist/{translate-DfH-kzRD.mjs → translate-Bgr7scTs.mjs} +1 -1
- package/dist/urls-BrJoRsYB.mjs +1 -0
- package/dist/whoami-O271iSvl.mjs +2 -0
- package/package.json +2 -2
- package/dist/createSpinner-0uAr0__M.mjs +0 -1
- package/dist/login-DGT76noz.mjs +0 -2
- package/dist/logout-BI-HnLL5.mjs +0 -1
- package/dist/urls-DdV5qJFG.mjs +0 -1
- package/dist/whoami-VnvhpU5y.mjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @eloqnt/cli
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6dd6cb5: Identifies itself with a custom user agent so the studio's "Logged-in CLIs" list can show your device name and OS. CLI sessions logged in before this version still appear in the list — as "Unknown device" — and you can run `eloqnt logout && eloqnt login` to refresh the entry with the new metadata.
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 396e007: Split plans into "Hosted model" and "Bring your own model"
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [396e007]
|
|
18
|
+
- @eloqnt/sdk@0.1.0
|
|
19
|
+
|
|
3
20
|
## 0.0.9
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/bin/eloqnt.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"node:process";import{defineCommand as t,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{lint:r(()=>import(`../lint-DJ_-UKqz.mjs`)),translate:r(()=>import(`../translate-
|
|
2
|
+
import e from"node:process";import{defineCommand as t,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{lint:r(()=>import(`../lint-DJ_-UKqz.mjs`)),translate:r(()=>import(`../translate-Bgr7scTs.mjs`)),login:r(()=>import(`../login-C6wg_xYT.mjs`)),logout:r(()=>import(`../logout-CzVVtihJ.mjs`)),whoami:r(()=>import(`../whoami-O271iSvl.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"picocolors";import{spinner as t}from"@clack/prompts";function n({withGuide:n=!0}={}){let r=t({styleFrame:t=>e.dim(t),withGuide:n});return{...r,start:e=>r.start(e&&`${e} `),message:e=>r.message(e&&`${e} `)}}export{n as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{a as t,i as n,n as r,t as i}from"./urls-BrJoRsYB.mjs";import{t as a}from"./createSpinner-BBkrpcrh.mjs";import{EloqntSdkError as o,getAuthHeaders as s}from"@eloqnt/sdk";import c from"node:process";import{defineCommand as l}from"citty";import u from"picocolors";import{hostname as d}from"node:os";import{setTimeout as f}from"node:timers/promises";import{outro as p}from"@clack/prompts";import m from"open";var h=`0.1.1`;function g(e){m(e).catch(()=>{})}const _=`eloqnt-cli`,v=`eloqnt-cli/${h} (${d()}; ${c.platform} ${c.arch}; node ${c.version})`;var y=l({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=i(),s=await n();s&&await fetch(`${e}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${s}`,"content-type":`application/json`,"user-agent":v},body:JSON.stringify({token:s})}).catch(()=>{});let l=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({client_id:_})});if(!l.ok)throw new o(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${l.status}.`,hint:`Check your connection and run eloqnt login again.`});let d=await l.json();c.stderr.write(`\n${u.cyan(`Log in to eloqnt studio`)}\n`),c.stderr.write(u.dim(`${d.verification_uri_complete}\n\n`)),g(d.verification_uri_complete);let f=c.stderr.isTTY?a():void 0;f?f.start(`Waiting for approval in the browser`):c.stderr.write(u.dim(`Waiting for approval in the browser …
|
|
2
|
+
`));let m=await x(e,d);if(!m.access_token)throw f?.stop(u.dim(`Login cancelled`)),new o(`NOT_AUTHENTICATED`,m.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await t(m.access_token),f?(f.stop(u.dim(`Approved in the browser`)),p(u.green(`Logged in`))):c.stdout.write(`${u.green(`Logged in`)}\n`),await b(m.access_token)&&c.stderr.write(`\n${u.cyan(`→ Choose a plan at ${r()}/plans`)}\n`)})});async function b(e){try{let t=await fetch(new URL(`/api/engine/me`,r()),{headers:s(e)});if(!t.ok)return!1;let n=await t.json();return Array.isArray(n.plans)&&n.plans.length===0}catch{return!1}}async function x(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await f(r*1e3);let n=await(await fetch(`${e}/device/token`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t.device_code,client_id:_})})).json();if(n.access_token)return n;if(n.error!==`authorization_pending`){if(n.error===`slow_down`){r+=5;continue}return n}}return{error:`expired_token`,error_description:`The login request expired`}}export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{i as t,r as n,t as r}from"./urls-BrJoRsYB.mjs";import i from"node:process";import{defineCommand as a}from"citty";import o from"picocolors";var s=a({meta:{name:`logout`,description:`Logs out of eloqnt studio by removing a local auth token.`},run:()=>e(async()=>{let e=await t();e&&await fetch(`${r()}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${e}`,"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{});let a=await n();i.stdout.write(`${a||e?o.green(`Logged out`):o.dim(`Not logged in`)}\n`)})});export{s as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{t}from"./resolvePaths-Bc7dGH8a.mjs";import{i as n,n as r}from"./urls-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{t}from"./resolvePaths-Bc7dGH8a.mjs";import{i as n,n as r}from"./urls-BrJoRsYB.mjs";import{t as i}from"./createSpinner-BBkrpcrh.mjs";import{loadStyleguide as a,translate as o}from"@eloqnt/sdk";import s from"node:process";import{basename as c,dirname as l,relative as u}from"node:path";import d from"picocolors";function f(e,t={month:`short`,day:`numeric`}){return new Date(e).toLocaleDateString(`en-US`,t)}function p(e,t){s.stderr.write(`${e} ${d.dim(t)}\n`)}var m=e({meta:{name:`translate`,description:`Translate strings to target locales (defaults to missing ones).`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)translate these message ids (comma-separated)`},locale:{type:`string`,description:`Restrict to these target locales (comma-separated)`}},async execute({config:e,rootDir:c,args:l}){let{messages:f,srcPath:m}=e,h=t(f.path,c),g=m?t(m,c):void 0,_=await a({cwd:c}),v=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,y=typeof l.locale==`string`?l.locale.split(`,`):Array.isArray(f.locales)?f.locales.filter(e=>e!==f.sourceLocale):void 0,b=`${y?.length?`${y.join(`, `)} `:``}via ${v}`,x=s.stderr.isTTY&&!l.json,S;function C(e){if(!l.json){if(e.phase===`context-enrichment`){e.state===`started`?(s.stderr.write(`
|
|
2
2
|
`),x?(S=i({withGuide:!1}),S.start(`Context enrichment running`)):s.stderr.write(d.dim(`Context enrichment running …
|
|
3
3
|
`))):e.state===`completed`?(S?.clear(),S=void 0,p(d.green(`✔`),`Context enrichment complete`)):(s.stderr.write(`
|
|
4
4
|
`),p(d.dim(`–`),"Skipped context enrichment — set `srcPath` to enable"));return}if(e.phase===`translate`){e.state===`started`?x?(S=i({withGuide:!1}),S.start(`Translating ${b}`)):s.stderr.write(d.dim(`Translating ${b} …\n`)):(S?.clear(),S=void 0,p(d.green(`✔`),`Translated ${b}`));return}e.state===`started`?x?(S=i({withGuide:!1}),S.start(`Post-translation checks running`)):s.stderr.write(d.dim(`Post-translation checks running …
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:process";import{dirname as t,join as n}from"node:path";import{homedir as r}from"node:os";import{mkdir as i,readFile as a,rm as o,writeFile as s}from"node:fs/promises";function c(){return n(e.env.XDG_CONFIG_HOME??n(r(),`.config`),`eloqnt`,`credentials.json`)}async function l(){if(e.env.ELOQNT_TOKEN)return e.env.ELOQNT_TOKEN;try{let e=await a(c(),`utf8`),t=JSON.parse(e);return typeof t.token==`string`?t.token:void 0}catch{return}}async function u(e){let n=c();return await i(t(n),{recursive:!0}),await s(n,`${JSON.stringify({token:e},null,2)}\n`,{mode:384}),n}async function d(){try{return await o(c()),!0}catch{return!1}}function f(){return e.env.ELOQNT_STUDIO_URL??`https://studio.eloqnt.dev`}function p(){return`${f()}/api/auth`}export{u as a,l as i,f as n,d as r,p as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{i as t,n}from"./urls-BrJoRsYB.mjs";import{EloqntSdkError as r,getAuthHeaders as i}from"@eloqnt/sdk";import a from"picocolors";function o(e){return a.dim(e.padEnd(12))}var s=e({meta:{name:`whoami`,description:`Shows the logged-in user account.`},requiresConfig:!1,async execute(){let e=await t();if(!e)throw new r(`NOT_AUTHENTICATED`,`Not logged in`,{hint:`Run eloqnt login to authenticate.`});let a=await fetch(new URL(`/api/engine/me`,n()),{headers:i(e)});if(a.status===401)throw new r(`NOT_AUTHENTICATED`,`Your session has expired`,{hint:`Run eloqnt login to sign in again.`});if(!a.ok)throw new r(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API responded with ${a.status}.`,hint:`This is on our end. Try again in a few minutes.`});let o=await a.json();return{email:o.user.email,plans:o.plans,hosted:o.hosted}},render:({email:e,plans:t,hosted:r})=>{let i=[`${o(`Email:`)}${e}`,`${o(`Plan:`)}${c(t)}`];return r&&i.push(`${o(`Quota used:`)}${l(r)}`),t.length===0&&i.push(``,a.cyan(`→ Choose a plan at ${n()}/plans`)),i.join(`
|
|
2
|
+
`)},json:e=>e});function c(e){if(e.length===0)return a.yellow(`none`);let t=e.map(e=>e===`hosted`?`Hosted model`:`Bring your own model`);return a.green(t.join(` + `))}function l({status:e,usedPercent:t,resetsAt:n}){let r=`${t}%`;return`${t>=100?a.red(r):t>=80?a.yellow(r):a.green(r)} (resets ${new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}).format(new Date(n))})${e===`trialing`?a.dim(` (trial)`):``}`}export{s as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eloqnt/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI for eloqnt/studio",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"citty": "^0.1.6",
|
|
31
31
|
"open": "^11.0.0",
|
|
32
32
|
"picocolors": "^1.1.1",
|
|
33
|
-
"@eloqnt/sdk": "0.0
|
|
33
|
+
"@eloqnt/sdk": "0.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^25.9.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"picocolors";import{spinner as t}from"@clack/prompts";function n({withGuide:n=!0}={}){let r=t({styleFrame:t=>e.cyan(t),withGuide:n});return{...r,start:e=>r.start(e&&`${e} `),message:e=>r.message(e&&`${e} `)}}export{n as t};
|
package/dist/login-DGT76noz.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{a as t,t as n}from"./urls-DdV5qJFG.mjs";import{t as r}from"./createSpinner-0uAr0__M.mjs";import{EloqntSdkError as i}from"@eloqnt/sdk";import a from"node:process";import{defineCommand as o}from"citty";import s from"picocolors";import{setTimeout as c}from"node:timers/promises";import{outro as l}from"@clack/prompts";import u from"open";function d(e){u(e).catch(()=>{})}const f=`eloqnt-cli`;var p=o({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=n(),o=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({client_id:f})});if(!o.ok)throw new i(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${o.status}.`,hint:`Check your connection and run eloqnt login again.`});let c=await o.json();a.stderr.write(`\n${s.cyan(`Log in to eloqnt studio`)}\n`),a.stderr.write(s.dim(`${c.verification_uri_complete}\n\n`)),d(c.verification_uri_complete);let u=a.stderr.isTTY?r():void 0;u?u.start(`Waiting for approval in the browser`):a.stderr.write(s.dim(`Waiting for approval in the browser …
|
|
2
|
-
`));let p=await m(e,c);if(!p.access_token)throw u?.stop(s.dim(`Login cancelled`)),new i(`NOT_AUTHENTICATED`,p.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await t(p.access_token),u?(u.stop(s.dim(`Approved in the browser`)),l(s.green(`Logged in`))):a.stdout.write(`${s.green(`Logged in`)}\n`)})});async function m(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await c(r*1e3);let n=await(await fetch(`${e}/device/token`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t.device_code,client_id:f})})).json();if(n.access_token)return n;if(n.error!==`authorization_pending`){if(n.error===`slow_down`){r+=5;continue}return n}}return{error:`expired_token`,error_description:`The login request expired`}}export{p as default};
|
package/dist/logout-BI-HnLL5.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{i as t,r as n,t as r}from"./urls-DdV5qJFG.mjs";import i from"node:process";import{defineCommand as a}from"citty";import o from"picocolors";var s=a({meta:{name:`logout`,description:`Logs out of eloqnt studio by removing a local auth token.`},run:()=>e(async()=>{let e=await t();e&&await fetch(`${r()}/sign-out`,{method:`POST`,headers:{authorization:`Bearer ${e}`}}).catch(()=>{});let a=await n();i.stdout.write(`${a||e?o.green(`Logged out`):o.dim(`Not logged in`)}\n`)})});export{s as default};
|
package/dist/urls-DdV5qJFG.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"node:process";import{dirname as t,join as n}from"node:path";import{mkdir as r,readFile as i,rm as a,writeFile as o}from"node:fs/promises";import{homedir as s}from"node:os";function c(){return n(e.env.XDG_CONFIG_HOME??n(s(),`.config`),`eloqnt`,`credentials.json`)}async function l(){if(e.env.ELOQNT_TOKEN)return e.env.ELOQNT_TOKEN;try{let e=await i(c(),`utf8`),t=JSON.parse(e);return typeof t.token==`string`?t.token:void 0}catch{return}}async function u(e){let n=c();return await r(t(n),{recursive:!0}),await o(n,`${JSON.stringify({token:e},null,2)}\n`,{mode:384}),n}async function d(){try{return await a(c()),!0}catch{return!1}}function f(){return e.env.ELOQNT_STUDIO_URL??`https://studio.eloqnt.dev`}function p(){return`${f()}/api/auth`}export{u as a,l as i,f as n,d as r,p as t};
|
package/dist/whoami-VnvhpU5y.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{i as t,n}from"./urls-DdV5qJFG.mjs";import{EloqntSdkError as r,getAuthHeaders as i}from"@eloqnt/sdk";import a from"picocolors";function o(e){return a.dim(e.padEnd(14))}var s=e({meta:{name:`whoami`,description:`Shows the logged-in user account.`},requiresConfig:!1,async execute(){let e=await t();if(!e)throw new r(`NOT_AUTHENTICATED`,`Not logged in`,{hint:`Run eloqnt login to authenticate.`});let a=await fetch(new URL(`/api/engine/me`,n()),{headers:i(e)});if(a.status===401)throw new r(`NOT_AUTHENTICATED`,`Your session has expired`,{hint:`Run eloqnt login to sign in again.`});if(!a.ok)throw new r(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API responded with ${a.status}.`,hint:`This is on our end. Try again in a few minutes.`});let o=await a.json();return{email:o.user.email,subscription:o.subscription.status,usage:o.usage}},render:({email:e,subscription:t,usage:r})=>{let i=[`${o(`Email:`)}${e}`,`${o(`Subscription:`)}${c(t)}`];return r&&i.push(`${o(`Quota used:`)}${l(r)}`),t===`none`&&i.push(``,a.cyan(`→ Subscribe at ${n()}/app`)),i.join(`
|
|
2
|
-
`)},json:e=>e});function c(e){return e===`active`?a.green(`active`):e===`trialing`?a.yellow(`trialing`):e}function l({usedPercent:e,resetsAt:t}){let n=`${e}%`;return`${e>=100?a.red(n):e>=80?a.yellow(n):a.green(n)} (resets ${new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}).format(new Date(t))})`}export{s as default};
|