@eloqnt/cli 0.0.9 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @eloqnt/cli
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 396e007: Split plans into "Hosted model" and "Bring your own model"
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [396e007]
12
+ - @eloqnt/sdk@0.1.0
13
+
3
14
  ## 0.0.9
4
15
 
5
16
  ### Patch Changes
@@ -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-DfH-kzRD.mjs`)),login:r(()=>import(`../login-DGT76noz.mjs`)),logout:r(()=>import(`../logout-BI-HnLL5.mjs`)),whoami:r(()=>import(`../whoami-VnvhpU5y.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
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-CLvZhrUc.mjs`)),login:r(()=>import(`../login-BbvTqLIS.mjs`)),logout:r(()=>import(`../logout-BI-HnLL5.mjs`)),whoami:r(()=>import(`../whoami-DKSK_0pF.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,n,t as r}from"./urls-DdV5qJFG.mjs";import{t as i}from"./createSpinner-BBkrpcrh.mjs";import{EloqntSdkError as a,getAuthHeaders as o}from"@eloqnt/sdk";import s from"node:process";import{defineCommand as c}from"citty";import l from"picocolors";import{setTimeout as u}from"node:timers/promises";import{outro as d}from"@clack/prompts";import f from"open";function p(e){f(e).catch(()=>{})}const m=`eloqnt-cli`;var h=c({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=r(),o=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({client_id:m})});if(!o.ok)throw new a(`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();s.stderr.write(`\n${l.cyan(`Log in to eloqnt studio`)}\n`),s.stderr.write(l.dim(`${c.verification_uri_complete}\n\n`)),p(c.verification_uri_complete);let u=s.stderr.isTTY?i():void 0;u?u.start(`Waiting for approval in the browser`):s.stderr.write(l.dim(`Waiting for approval in the browser …
2
+ `));let f=await _(e,c);if(!f.access_token)throw u?.stop(l.dim(`Login cancelled`)),new a(`NOT_AUTHENTICATED`,f.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await t(f.access_token),u?(u.stop(l.dim(`Approved in the browser`)),d(l.green(`Logged in`))):s.stdout.write(`${l.green(`Logged in`)}\n`),await g(f.access_token)&&s.stderr.write(`\n${l.cyan(`→ Choose a plan at ${n()}/plans`)}\n`)})});async function g(e){try{let t=await fetch(new URL(`/api/engine/me`,n()),{headers:o(e)});if(!t.ok)return!1;let r=await t.json();return Array.isArray(r.plans)&&r.plans.length===0}catch{return!1}}async function _(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await u(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:m})})).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{h 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-DdV5qJFG.mjs";import{t as i}from"./createSpinner-0uAr0__M.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?`local eloqnt/engine running ${typeof e.model==`string`?e.model:e.model.modelId}`:`hosted eloqnt/engine`,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(`
1
+ import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{t}from"./resolvePaths-Bc7dGH8a.mjs";import{i as n,n as r}from"./urls-DdV5qJFG.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,2 @@
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(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.0.9",
3
+ "version": "0.1.0",
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.8"
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};
@@ -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};
@@ -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};