arial-cli 0.1.6 → 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 +56 -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.6";
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";
@@ -3096,6 +3097,7 @@ function getConfigDir() {
3096
3097
  }
3097
3098
 
3098
3099
  class ConfigManager {
3100
+ provider;
3099
3101
  model;
3100
3102
  temperature;
3101
3103
  maxTokens;
@@ -3103,6 +3105,7 @@ class ConfigManager {
3103
3105
  systemPrompt;
3104
3106
  toolsEnabled;
3105
3107
  constructor(options = {}) {
3108
+ this.provider = options.provider || DEFAULT_PROVIDER;
3106
3109
  this.model = options.model || DEFAULT_MODEL;
3107
3110
  this.temperature = options.temperature || null;
3108
3111
  this.maxTokens = options.maxTokens || 1024;
@@ -3114,6 +3117,7 @@ class ConfigManager {
3114
3117
  this.getOrCreateConfig();
3115
3118
  const config = await this.getConfig();
3116
3119
  this.validateConfig(config);
3120
+ this.provider = config.provider;
3117
3121
  this.model = config.model;
3118
3122
  this.temperature = config.temperature;
3119
3123
  this.maxTokens = config.maxTokens;
@@ -3124,6 +3128,7 @@ class ConfigManager {
3124
3128
  async save() {
3125
3129
  const configPath = getConfigPath();
3126
3130
  const config = {
3131
+ provider: this.provider,
3127
3132
  model: this.model,
3128
3133
  temperature: this.temperature,
3129
3134
  maxTokens: this.maxTokens,
@@ -3155,6 +3160,7 @@ class ConfigManager {
3155
3160
  } catch {
3156
3161
  console.log(`Creating default config file at: ${configPath}`);
3157
3162
  const defaultConfig = {
3163
+ provider: DEFAULT_PROVIDER,
3158
3164
  model: DEFAULT_MODEL,
3159
3165
  temperature: null,
3160
3166
  maxTokens: 1024,
@@ -31777,17 +31783,20 @@ function createOpenAI(options = {}) {
31777
31783
  }
31778
31784
  var openai = createOpenAI();
31779
31785
 
31780
- // src/lib/ai.ts
31781
- 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
+ }
31782
31797
  async generateWithContext(session) {
31783
31798
  try {
31784
- const key = session.keys.get("OPENAI_API_KEY");
31785
- if (!key) {
31786
- throw new Error("No API key found. Please add an OpenAI API key using the /keys command.");
31787
- }
31788
- const openai2 = createOpenAI({
31789
- apiKey: key.key
31790
- });
31799
+ const openai2 = this.getClient(session);
31791
31800
  const toolsEnabled = await session.tools.getEnabledTools();
31792
31801
  const params = {
31793
31802
  model: openai2(session.model),
@@ -31807,15 +31816,9 @@ class Ai {
31807
31816
  throw error46;
31808
31817
  }
31809
31818
  }
31810
- static async* streamWithContext(session) {
31819
+ async* streamWithContext(session) {
31811
31820
  try {
31812
- const key = session.keys.get("OPENAI_API_KEY");
31813
- if (!key) {
31814
- throw new Error("No API key found. Please add an OpenAI API key using the /keys command.");
31815
- }
31816
- const openai2 = createOpenAI({
31817
- apiKey: key.key
31818
- });
31821
+ const openai2 = this.getClient(session);
31819
31822
  const toolsEnabled = await session.tools.getEnabledTools();
31820
31823
  const params = {
31821
31824
  model: openai2(session.model),
@@ -31841,6 +31844,37 @@ class Ai {
31841
31844
  }
31842
31845
  }
31843
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
+
31844
31878
  // node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist-node/stringify.js
31845
31879
  var byteToHex = [];
31846
31880
  for (let i = 0;i < 256; ++i) {
@@ -31899,6 +31933,7 @@ class SessionManager {
31899
31933
  currentConversationId = null;
31900
31934
  currentConversationTimestamp = null;
31901
31935
  messages = [];
31936
+ provider;
31902
31937
  model;
31903
31938
  streaming;
31904
31939
  systemPrompt;
@@ -31908,6 +31943,7 @@ class SessionManager {
31908
31943
  storage;
31909
31944
  config;
31910
31945
  constructor(config2) {
31946
+ this.provider = config2.provider;
31911
31947
  this.model = config2.model;
31912
31948
  this.streaming = config2.streaming;
31913
31949
  this.systemPrompt = config2.systemPrompt;
@@ -31974,7 +32010,8 @@ class SessionManager {
31974
32010
  }
31975
32011
  streamResponse(prompt) {
31976
32012
  this.addMessage({ role: "user", content: prompt });
31977
- return Ai.streamWithContext(this);
32013
+ const ai = new Ai;
32014
+ return ai.streamWithContext(this);
31978
32015
  }
31979
32016
  generateResponse(prompt) {
31980
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.6",
3
+ "version": "0.1.7",
4
4
  "description": "A CLI utility to interact with LLMs",
5
5
  "type": "module",
6
6
  "bin": {