lunel-cli 0.1.48 → 0.1.49

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.
@@ -58,6 +58,7 @@ export declare class CodexProvider implements AIProvider {
58
58
  private ensureAssistantMessage;
59
59
  private upsertLocalMessagePart;
60
60
  private fetchServerThreads;
61
+ private fetchModels;
61
62
  private parseThreadListEntry;
62
63
  private hasNextCursor;
63
64
  private ingestThreadMetadata;
package/dist/ai/codex.js CHANGED
@@ -119,7 +119,7 @@ export class CodexProvider {
119
119
  await this.call("turn/start", {
120
120
  threadId: session.id,
121
121
  input: [{ type: "text", text }],
122
- ...(model ? { model: `${model.providerID}/${model.modelID}` } : {}),
122
+ ...(model ? { model: model.providerID === "codex" ? model.modelID : `${model.providerID}/${model.modelID}` } : {}),
123
123
  ...(agent ? { agent } : {}),
124
124
  });
125
125
  }
@@ -145,7 +145,23 @@ export class CodexProvider {
145
145
  return { agents: [] };
146
146
  }
147
147
  async providers() {
148
- return { providers: [], default: {} };
148
+ const items = await this.fetchModels();
149
+ const models = Object.fromEntries(items.map((item) => [
150
+ item.model,
151
+ {
152
+ id: item.model,
153
+ name: item.displayName || item.model,
154
+ provider: "codex",
155
+ description: item.description,
156
+ },
157
+ ]));
158
+ const defaultModel = items.find((item) => item.isDefault)?.model;
159
+ return {
160
+ providers: items.length > 0
161
+ ? [{ id: "codex", name: "Codex", models }]
162
+ : [],
163
+ default: defaultModel ? { codex: defaultModel } : {},
164
+ };
149
165
  }
150
166
  async setAuth(providerId, key) {
151
167
  throw new Error("Codex auth configuration is not supported by Lunel yet");
@@ -589,7 +605,13 @@ export class CodexProvider {
589
605
  cursor: nextCursor,
590
606
  });
591
607
  const payload = this.asRecord(result);
592
- const page = this.readArray(payload.data) ?? this.readArray(payload.items) ?? this.readArray(payload.threads) ?? [];
608
+ const page = Array.isArray(payload.data)
609
+ ? payload.data
610
+ : Array.isArray(payload.items)
611
+ ? payload.items
612
+ : Array.isArray(payload.threads)
613
+ ? payload.threads
614
+ : [];
593
615
  for (const entry of page) {
594
616
  const parsed = this.parseThreadListEntry(entry);
595
617
  if (parsed)
@@ -600,6 +622,39 @@ export class CodexProvider {
600
622
  } while (hasRequestedFirstPage && this.hasNextCursor(nextCursor));
601
623
  return threads;
602
624
  }
625
+ async fetchModels() {
626
+ const result = await this.call("model/list", {
627
+ cursor: null,
628
+ limit: 50,
629
+ includeHidden: false,
630
+ });
631
+ const payload = this.asRecord(result);
632
+ const items = Array.isArray(payload.items)
633
+ ? payload.items
634
+ : Array.isArray(payload.data)
635
+ ? payload.data
636
+ : Array.isArray(payload.models)
637
+ ? payload.models
638
+ : [];
639
+ return items
640
+ .map((value) => {
641
+ const obj = this.asRecord(value);
642
+ const model = this.readString(obj.model) ?? this.readString(obj.id);
643
+ if (!model)
644
+ return undefined;
645
+ const displayName = this.readString(obj.displayName)
646
+ ?? this.readString(obj.display_name)
647
+ ?? model;
648
+ return {
649
+ id: this.readString(obj.id) ?? model,
650
+ model,
651
+ displayName,
652
+ description: this.readString(obj.description) ?? "",
653
+ isDefault: Boolean(obj.isDefault ?? obj.is_default),
654
+ };
655
+ })
656
+ .filter((value) => Boolean(value));
657
+ }
603
658
  parseThreadListEntry(value) {
604
659
  const obj = this.asRecord(value);
605
660
  const id = this.extractThreadId(obj);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunel-cli",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "author": [
5
5
  {
6
6
  "name": "Soham Bharambe",