@xuda.io/ai_module 1.1.5635 → 1.1.5636

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/index.mjs +14 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -201,6 +201,16 @@ const resolve_ai_model = function (m) {
201
201
  return _conf?.ai_models?.[code]?.model || _conf?.ai_models?.[m]?.model || m;
202
202
  };
203
203
 
204
+ // A catalog code a user may pick for Codex generation: an OpenAI text model
205
+ // flagged codex:true in ai_models. Guards generate_site_draft's model param so a
206
+ // non-codex pick (image/voice/unknown) falls back to the default rather than
207
+ // failing the codex exec. Codex is OpenAI-only, so only these codes are valid.
208
+ const _is_codex_model = function (code) {
209
+ if (!code) return false;
210
+ const e = _conf?.ai_models?.[canonical_ai_code(code)];
211
+ return !!(e && e.codex === true);
212
+ };
213
+
204
214
  const get_openai_codex_usage_model = function (codex_model, requested_codex_model) {
205
215
  // Bill by the catalog code actually used (requested selection or cheapest default).
206
216
  return codex_model || _conf.openai_codex_command || 'openai_codex_cli';
@@ -1742,7 +1752,10 @@ export const generate_site_draft = async (req, job_id) => {
1742
1752
  When done, briefly summarize what you built.`;
1743
1753
 
1744
1754
  const built_prompt = `[System]\n${gen_system}\n\n[User request]\n${prompt}`;
1745
- const codex_ret = await execute_codex_request({ uid, ip: undefined, local_cwd: dir, prompt: built_prompt, stream: false, sandbox: 'workspace-write', codex_timeout: 240000 });
1755
+ // Model pick from the generate screen (UI-13 #4): forward only a codex-eligible
1756
+ // catalog code; anything else (or none) uses the default model.
1757
+ const picked_model = _is_codex_model(data.model || data.codex_model) ? (data.model || data.codex_model) : null;
1758
+ const codex_ret = await execute_codex_request({ uid, ip: undefined, local_cwd: dir, prompt: built_prompt, stream: false, sandbox: 'workspace-write', codex_timeout: 240000, codex_model: picked_model });
1746
1759
  if (!codex_ret || codex_ret.code < 0) {
1747
1760
  // On a non-zero codex exit, codex_ret.data is an object whose real reason
1748
1761
  // lives in `stderr` (not `message`); only the early guards return a plain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5635",
3
+ "version": "1.1.5636",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",