arial-cli 0.1.5 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +63 -19
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2795,9 +2795,10 @@ function isUnicodeSupported() {
2795
2795
  }
2796
2796
 
2797
2797
  // src/lib/config.ts
2798
- var VERSION = "0.1.5";
2798
+ var VERSION = "0.1.7";
2799
2799
  var PROMPT_LINE_PREFIX = "●";
2800
2800
  var PROMPT_LINE_PREFIX_SAFE = "ai>";
2801
+ var DEFAULT_PROVIDER = "byok";
2801
2802
  var DEFAULT_MODEL = "gpt-4o";
2802
2803
  var DEFAULT_CONFIG_DIR = ".arial";
2803
2804
  var DEFAULT_CONFIG_FILE = "config.json";
@@ -2980,6 +2981,9 @@ Error: Unknown action ${action}`));
2980
2981
  }
2981
2982
  }
2982
2983
  }
2984
+ function commandClear() {
2985
+ process.stdout.write("\x1Bc");
2986
+ }
2983
2987
  function commandHelp() {
2984
2988
  const s = getSymbols();
2985
2989
  console.log(source_default.bold.cyan(`
@@ -3002,6 +3006,7 @@ Available Commands
3002
3006
  args: " [add|remove] [name] [key]",
3003
3007
  desc: "Manage API keys"
3004
3008
  },
3009
+ { cmd: "/clear", args: "", desc: "Clear the screen" },
3005
3010
  { cmd: "/help", args: "", desc: "Show this help message" },
3006
3011
  { cmd: "/exit", args: " or /quit", desc: "Exit the interactive mode" }
3007
3012
  ];
@@ -3032,6 +3037,9 @@ ${s.prompt} `));
3032
3037
  case "/keys":
3033
3038
  await commandKeys(session, args);
3034
3039
  continue;
3040
+ case "/clear":
3041
+ commandClear();
3042
+ continue;
3035
3043
  case "/help":
3036
3044
  commandHelp();
3037
3045
  continue;
@@ -3089,6 +3097,7 @@ function getConfigDir() {
3089
3097
  }
3090
3098
 
3091
3099
  class ConfigManager {
3100
+ provider;
3092
3101
  model;
3093
3102
  temperature;
3094
3103
  maxTokens;
@@ -3096,6 +3105,7 @@ class ConfigManager {
3096
3105
  systemPrompt;
3097
3106
  toolsEnabled;
3098
3107
  constructor(options = {}) {
3108
+ this.provider = options.provider || DEFAULT_PROVIDER;
3099
3109
  this.model = options.model || DEFAULT_MODEL;
3100
3110
  this.temperature = options.temperature || null;
3101
3111
  this.maxTokens = options.maxTokens || 1024;
@@ -3107,6 +3117,7 @@ class ConfigManager {
3107
3117
  this.getOrCreateConfig();
3108
3118
  const config = await this.getConfig();
3109
3119
  this.validateConfig(config);
3120
+ this.provider = config.provider;
3110
3121
  this.model = config.model;
3111
3122
  this.temperature = config.temperature;
3112
3123
  this.maxTokens = config.maxTokens;
@@ -3117,6 +3128,7 @@ class ConfigManager {
3117
3128
  async save() {
3118
3129
  const configPath = getConfigPath();
3119
3130
  const config = {
3131
+ provider: this.provider,
3120
3132
  model: this.model,
3121
3133
  temperature: this.temperature,
3122
3134
  maxTokens: this.maxTokens,
@@ -3148,6 +3160,7 @@ class ConfigManager {
3148
3160
  } catch {
3149
3161
  console.log(`Creating default config file at: ${configPath}`);
3150
3162
  const defaultConfig = {
3163
+ provider: DEFAULT_PROVIDER,
3151
3164
  model: DEFAULT_MODEL,
3152
3165
  temperature: null,
3153
3166
  maxTokens: 1024,
@@ -31770,17 +31783,20 @@ function createOpenAI(options = {}) {
31770
31783
  }
31771
31784
  var openai = createOpenAI();
31772
31785
 
31773
- // src/lib/ai.ts
31774
- class Ai {
31786
+ // src/lib/providers/byok-provider.ts
31787
+ class ByokProvider {
31788
+ getClient(session) {
31789
+ const key = session.keys.get("OPENAI_API_KEY");
31790
+ if (!key) {
31791
+ throw new Error("No API key found. Please add an OpenAI API key using the /keys command.");
31792
+ }
31793
+ return createOpenAI({
31794
+ apiKey: key.key
31795
+ });
31796
+ }
31775
31797
  async generateWithContext(session) {
31776
31798
  try {
31777
- const key = session.keys.get("OPENAI_API_KEY");
31778
- if (!key) {
31779
- throw new Error("No API key found. Please add an OpenAI API key using the /keys command.");
31780
- }
31781
- const openai2 = createOpenAI({
31782
- apiKey: key.key
31783
- });
31799
+ const openai2 = this.getClient(session);
31784
31800
  const toolsEnabled = await session.tools.getEnabledTools();
31785
31801
  const params = {
31786
31802
  model: openai2(session.model),
@@ -31800,15 +31816,9 @@ class Ai {
31800
31816
  throw error46;
31801
31817
  }
31802
31818
  }
31803
- static async* streamWithContext(session) {
31819
+ async* streamWithContext(session) {
31804
31820
  try {
31805
- const key = session.keys.get("OPENAI_API_KEY");
31806
- if (!key) {
31807
- throw new Error("No API key found. Please add an OpenAI API key using the /keys command.");
31808
- }
31809
- const openai2 = createOpenAI({
31810
- apiKey: key.key
31811
- });
31821
+ const openai2 = this.getClient(session);
31812
31822
  const toolsEnabled = await session.tools.getEnabledTools();
31813
31823
  const params = {
31814
31824
  model: openai2(session.model),
@@ -31834,6 +31844,37 @@ class Ai {
31834
31844
  }
31835
31845
  }
31836
31846
 
31847
+ // src/lib/providers/arial-provider.ts
31848
+ class ArialProvider {
31849
+ async generateWithContext(session) {
31850
+ return "Generated text from ArialProvider";
31851
+ }
31852
+ async* streamWithContext(session) {
31853
+ yield "Streaming text from ArialProvider";
31854
+ }
31855
+ }
31856
+
31857
+ // src/lib/ai.ts
31858
+ class Ai {
31859
+ selectProvider(session) {
31860
+ if (session.provider === "byok") {
31861
+ return new ByokProvider;
31862
+ } else if (session.provider === "arial") {
31863
+ return new ArialProvider;
31864
+ } else {
31865
+ throw new Error(`Unsupported provider: ${session.provider}`);
31866
+ }
31867
+ }
31868
+ async generateWithContext(session) {
31869
+ const provider = this.selectProvider(session);
31870
+ return provider.generateWithContext(session);
31871
+ }
31872
+ async* streamWithContext(session) {
31873
+ const provider = this.selectProvider(session);
31874
+ yield* provider.streamWithContext(session);
31875
+ }
31876
+ }
31877
+
31837
31878
  // node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist-node/stringify.js
31838
31879
  var byteToHex = [];
31839
31880
  for (let i = 0;i < 256; ++i) {
@@ -31892,6 +31933,7 @@ class SessionManager {
31892
31933
  currentConversationId = null;
31893
31934
  currentConversationTimestamp = null;
31894
31935
  messages = [];
31936
+ provider;
31895
31937
  model;
31896
31938
  streaming;
31897
31939
  systemPrompt;
@@ -31901,6 +31943,7 @@ class SessionManager {
31901
31943
  storage;
31902
31944
  config;
31903
31945
  constructor(config2) {
31946
+ this.provider = config2.provider;
31904
31947
  this.model = config2.model;
31905
31948
  this.streaming = config2.streaming;
31906
31949
  this.systemPrompt = config2.systemPrompt;
@@ -31967,7 +32010,8 @@ class SessionManager {
31967
32010
  }
31968
32011
  streamResponse(prompt) {
31969
32012
  this.addMessage({ role: "user", content: prompt });
31970
- return Ai.streamWithContext(this);
32013
+ const ai = new Ai;
32014
+ return ai.streamWithContext(this);
31971
32015
  }
31972
32016
  generateResponse(prompt) {
31973
32017
  this.addMessage({ role: "user", content: prompt });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arial-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A CLI utility to interact with LLMs",
5
5
  "type": "module",
6
6
  "bin": {