@clagentic/console 1.3.0 → 1.4.0-beta.1
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/lib/project-loop.js +9 -9
- package/lib/project-sessions.js +8 -8
- package/lib/public/css/home-hub.css +15 -1
- package/lib/public/index.html +7 -7
- package/lib/public/modules/app-connection.js +5 -0
- package/lib/public/modules/app-home-hub.js +2 -0
- package/lib/public/modules/app-loop-wizard.js +1 -1
- package/lib/public/modules/app-panels.js +1 -0
- package/lib/public/modules/settings-defaults.js +2 -1
- package/lib/scheduler.js +1 -1
- package/lib/sdk-bridge.js +105 -1
- package/lib/server.js +1 -1
- package/lib/yoke/adapters/codex.js +53 -7
- package/package.json +1 -1
package/lib/project-loop.js
CHANGED
|
@@ -901,9 +901,9 @@ function attachLoop(ctx) {
|
|
|
901
901
|
loopState.phase = "crafting";
|
|
902
902
|
saveLoopState();
|
|
903
903
|
|
|
904
|
-
var judgeCraftPrompt = "Use the /
|
|
904
|
+
var judgeCraftPrompt = "Use the /ralph-loop skill to design ONLY a JUDGE.md for an existing Ralph Loop. " +
|
|
905
905
|
"The user has already provided PROMPT.md, so do NOT create or modify PROMPT.md. " +
|
|
906
|
-
"You MUST invoke the
|
|
906
|
+
"You MUST invoke the ralph-loop skill — do NOT execute the task yourself. " +
|
|
907
907
|
"Your job is to read the existing PROMPT.md and create a JUDGE.md " +
|
|
908
908
|
"that will evaluate whether the coder session completed the task successfully.\n\n" +
|
|
909
909
|
"## Task\n" + (wData.task || "") +
|
|
@@ -944,26 +944,26 @@ function attachLoop(ctx) {
|
|
|
944
944
|
return true;
|
|
945
945
|
}
|
|
946
946
|
|
|
947
|
-
// Default: "draft" mode — crafts files via the
|
|
947
|
+
// Default: "draft" mode — crafts files via the ralph-loop skill
|
|
948
948
|
var _draftIsSimple = wData.loopMode === "simple";
|
|
949
949
|
var craftingPrompt;
|
|
950
950
|
if (_draftIsSimple) {
|
|
951
|
-
craftingPrompt = "Use the /
|
|
952
|
-
"You MUST invoke the
|
|
951
|
+
craftingPrompt = "Use the /ralph-loop skill to design a Ralph Loop for the following task. " +
|
|
952
|
+
"You MUST invoke the ralph-loop skill — do NOT execute the task yourself. " +
|
|
953
953
|
"This is a Simple Loop (no judge). Your job is to create ONLY a PROMPT.md file " +
|
|
954
954
|
"that a future autonomous session will execute. Do NOT create a JUDGE.md file.\n\n" +
|
|
955
955
|
"## Task\n" + (wData.task || "") +
|
|
956
956
|
"\n\n## Loop Directory\n" + lDir;
|
|
957
957
|
} else if (wData.judgeAuthor === "me") {
|
|
958
|
-
craftingPrompt = "Use the /
|
|
959
|
-
"You MUST invoke the
|
|
958
|
+
craftingPrompt = "Use the /ralph-loop skill to design a Ralph Loop for the following task. " +
|
|
959
|
+
"You MUST invoke the ralph-loop skill — do NOT execute the task yourself. " +
|
|
960
960
|
"The user will provide their own JUDGE.md, so create ONLY a PROMPT.md file " +
|
|
961
961
|
"that a future autonomous session will execute. Do NOT create a JUDGE.md file.\n\n" +
|
|
962
962
|
"## Task\n" + (wData.task || "") +
|
|
963
963
|
"\n\n## Loop Directory\n" + lDir;
|
|
964
964
|
} else {
|
|
965
|
-
craftingPrompt = "Use the /
|
|
966
|
-
"You MUST invoke the
|
|
965
|
+
craftingPrompt = "Use the /ralph-loop skill to design a Ralph Loop for the following task. " +
|
|
966
|
+
"You MUST invoke the ralph-loop skill — do NOT execute the task yourself. " +
|
|
967
967
|
"Your job is to interview me, then create PROMPT.md and JUDGE.md files " +
|
|
968
968
|
"that a future autonomous session will execute.\n\n" +
|
|
969
969
|
"## Task\n" + (wData.task || "") +
|
package/lib/project-sessions.js
CHANGED
|
@@ -15,7 +15,10 @@ agentsModule.refresh().catch(function (e) {
|
|
|
15
15
|
|
|
16
16
|
// Format a user's answer to an ask_user_questions card as a plain user
|
|
17
17
|
// message so the MCP path can feed it back to the agent on the next turn.
|
|
18
|
-
//
|
|
18
|
+
// Always use "- Q → A" form and prefix with a header so the model can
|
|
19
|
+
// connect the answer to its earlier AskUserQuestion call even across a
|
|
20
|
+
// turn break. A bare answer with no context reads as a non-sequitur and
|
|
21
|
+
// triggers "I don't see an answer" responses from the model.
|
|
19
22
|
function formatAskUserAnswerAsMessage(input, answers) {
|
|
20
23
|
var questions = (input && Array.isArray(input.questions)) ? input.questions : [];
|
|
21
24
|
if (questions.length === 0) {
|
|
@@ -29,15 +32,12 @@ function formatAskUserAnswerAsMessage(input, answers) {
|
|
|
29
32
|
var qText = (q && q.question) ? q.question : ("Question " + (i + 1));
|
|
30
33
|
var ans = (answers && answers[i] != null) ? String(answers[i]) : "";
|
|
31
34
|
if (!ans) continue;
|
|
32
|
-
|
|
33
|
-
// Single question: keep it tight.
|
|
34
|
-
lines.push(ans);
|
|
35
|
-
} else {
|
|
36
|
-
lines.push("- " + qText + " → " + ans);
|
|
37
|
-
}
|
|
35
|
+
lines.push("- " + qText + " → " + ans);
|
|
38
36
|
}
|
|
39
37
|
if (lines.length === 0) return "(no answer provided)";
|
|
40
|
-
|
|
38
|
+
// Prefix tells the model this is a structured answer to its previous
|
|
39
|
+
// AskUserQuestion call — unambiguous even when read out of turn context.
|
|
40
|
+
return "[Answer to your AskUserQuestion]\n" + lines.join("\n");
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
|
|
423
423
|
/* --- Recent Sessions --- */
|
|
424
424
|
.hub-recent-sessions {
|
|
425
|
-
animation: hubCardIn 0.4s ease 0.
|
|
425
|
+
animation: hubCardIn 0.4s ease 0.08s both;
|
|
426
426
|
}
|
|
427
427
|
.hub-recent-sessions-list {
|
|
428
428
|
display: flex;
|
|
@@ -441,6 +441,20 @@
|
|
|
441
441
|
.hub-recent-item:hover {
|
|
442
442
|
background: rgba(var(--overlay-rgb), 0.06);
|
|
443
443
|
}
|
|
444
|
+
.hub-recent-dot {
|
|
445
|
+
width: 7px;
|
|
446
|
+
height: 7px;
|
|
447
|
+
border-radius: 50%;
|
|
448
|
+
flex-shrink: 0;
|
|
449
|
+
background: var(--text-dimmer);
|
|
450
|
+
opacity: 0.35;
|
|
451
|
+
transition: background 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
|
|
452
|
+
}
|
|
453
|
+
.hub-recent-dot.processing {
|
|
454
|
+
background: var(--success);
|
|
455
|
+
opacity: 1;
|
|
456
|
+
box-shadow: 0 0 6px rgba(80, 250, 123, 0.4);
|
|
457
|
+
}
|
|
444
458
|
.hub-recent-project-icon {
|
|
445
459
|
font-size: 14px;
|
|
446
460
|
width: 20px;
|
package/lib/public/index.html
CHANGED
|
@@ -151,6 +151,13 @@
|
|
|
151
151
|
|
|
152
152
|
<div id="home-hub-mates" class="home-hub-mates hidden"></div>
|
|
153
153
|
|
|
154
|
+
<div class="hub-card hub-recent-sessions">
|
|
155
|
+
<div class="hub-card-header">
|
|
156
|
+
<span class="hub-card-title">Recent Sessions</span>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="hub-recent-sessions-list" id="hub-recent-sessions-list"></div>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
154
161
|
<div class="hub-columns">
|
|
155
162
|
<div class="hub-card hub-upcoming">
|
|
156
163
|
<div class="hub-card-header">
|
|
@@ -174,13 +181,6 @@
|
|
|
174
181
|
<div class="hub-week-strip" id="hub-week-strip"></div>
|
|
175
182
|
</div>
|
|
176
183
|
|
|
177
|
-
<div class="hub-card hub-recent-sessions">
|
|
178
|
-
<div class="hub-card-header">
|
|
179
|
-
<span class="hub-card-title">Recent Sessions</span>
|
|
180
|
-
</div>
|
|
181
|
-
<div class="hub-recent-sessions-list" id="hub-recent-sessions-list"></div>
|
|
182
|
-
</div>
|
|
183
|
-
|
|
184
184
|
</div>
|
|
185
185
|
</div>
|
|
186
186
|
<div id="sidebar-column">
|
|
@@ -198,6 +198,11 @@ export function connect() {
|
|
|
198
198
|
closeDmUserPicker();
|
|
199
199
|
setStatus("disconnected");
|
|
200
200
|
setActivity(null);
|
|
201
|
+
// lr-0446: Discard any pending cross-project session switch. If the WS
|
|
202
|
+
// closed before the target project's session_list fired, the key is now
|
|
203
|
+
// stale — leaving it would cause the *next* successful session_list (on
|
|
204
|
+
// any project reconnect) to switch to a wrong session.
|
|
205
|
+
try { sessionStorage.removeItem("pending-hub-session"); } catch (e) {}
|
|
201
206
|
scheduleReconnect();
|
|
202
207
|
};
|
|
203
208
|
|
|
@@ -423,7 +423,9 @@ export function handleHubRecentSessions(msg) {
|
|
|
423
423
|
var agentBadge = sess.agentName
|
|
424
424
|
? '<span class="hub-recent-agent">' + escapeHtml(sess.agentName) + '</span>'
|
|
425
425
|
: '';
|
|
426
|
+
var dotClass = "hub-recent-dot" + (sess.isProcessing ? " processing" : "");
|
|
426
427
|
item.innerHTML =
|
|
428
|
+
'<span class="' + dotClass + '"></span>' +
|
|
427
429
|
iconHtml +
|
|
428
430
|
'<span class="hub-recent-title">' + escapeHtml(sess.title) + '</span>' +
|
|
429
431
|
agentBadge +
|
|
@@ -120,7 +120,7 @@ function requireClayRalph(cb) {
|
|
|
120
120
|
requireSkills({
|
|
121
121
|
title: "Skill Installation Required",
|
|
122
122
|
reason: "This feature requires the following skill to be installed.",
|
|
123
|
-
skills: [{ name: "
|
|
123
|
+
skills: [{ name: "ralph-loop", scope: "global" }]
|
|
124
124
|
}, cb);
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -27,7 +27,8 @@ export var MODEL_DESCRIPTIONS = {
|
|
|
27
27
|
"haiku": "Fastest model. Best for quick tasks and simple questions.",
|
|
28
28
|
"opus": "Most powerful model. Best for complex reasoning and analysis.",
|
|
29
29
|
// Codex/OpenAI families
|
|
30
|
-
"gpt-5.
|
|
30
|
+
"gpt-5.5": "Latest GPT-5.5. Frontier model for complex coding and agentic workflows.",
|
|
31
|
+
"gpt-5.4": "GPT-5.4. Strong reasoning and agentic coding.",
|
|
31
32
|
"gpt-5.4-mini": "Faster, lighter GPT-5.4 variant. Great for most coding tasks.",
|
|
32
33
|
"gpt-5.3-codex": "GPT-5.3 Codex. Strong at agentic coding and tool use.",
|
|
33
34
|
"gpt-5.3-codex-spark": "Lean GPT-5.3 Codex. Optimized for speed.",
|
package/lib/scheduler.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Loop Registry — unified storage for all Ralph Loops (one-off + scheduled).
|
|
3
3
|
*
|
|
4
4
|
* Stores loop records in ~/.clay/loops/{encodedCwd}.jsonl
|
|
5
|
-
* Each record represents a job defined via
|
|
5
|
+
* Each record represents a job defined via ralph-loop (PROMPT.md + JUDGE.md).
|
|
6
6
|
* Records with a `cron` field are checked every 30s and auto-triggered.
|
|
7
7
|
* Records without cron are one-off (standard Ralph Loop behavior).
|
|
8
8
|
*/
|
package/lib/sdk-bridge.js
CHANGED
|
@@ -10,6 +10,17 @@ var { createMessageQueue } = require("./sdk-message-queue");
|
|
|
10
10
|
var { attachMessageProcessor } = require("./sdk-message-processor");
|
|
11
11
|
var { readAgentToolsFromFile } = require("./agents");
|
|
12
12
|
|
|
13
|
+
// --- lr-29f9: Global concurrent-session ceiling ---
|
|
14
|
+
// Counts queries that are actively running (startQuery entered, processQueryStream
|
|
15
|
+
// finally not yet reached) across ALL project bridge instances in this daemon process.
|
|
16
|
+
// Each project's sdk-bridge instance shares this module-level counter.
|
|
17
|
+
// Env override: CLAGENTIC_MAX_CONCURRENT_SESSIONS (must be a positive integer).
|
|
18
|
+
var _activeLiveCount = 0;
|
|
19
|
+
var MAX_CONCURRENT_SESSIONS = (function () {
|
|
20
|
+
var env = parseInt(process.env.CLAGENTIC_MAX_CONCURRENT_SESSIONS, 10);
|
|
21
|
+
return (env > 0) ? env : 6;
|
|
22
|
+
})();
|
|
23
|
+
|
|
13
24
|
// Extract serializable tool descriptors from MCP server instances.
|
|
14
25
|
// Used for IPC to worker processes (McpSdkServerConfigWithInstance is not serializable).
|
|
15
26
|
function extractMcpDescriptors(mcpServers) {
|
|
@@ -900,9 +911,48 @@ function createSDKBridge(opts) {
|
|
|
900
911
|
}
|
|
901
912
|
session.messageQueue = null;
|
|
902
913
|
if (session.abortController === myAbortController) session.abortController = null;
|
|
914
|
+
|
|
915
|
+
// lr-29f9: Reap the worker process immediately on query completion.
|
|
916
|
+
// The worker is kept alive between turns by _adapterWorkerState reuse, but
|
|
917
|
+
// once processQueryStream exits there is nothing left to receive from it.
|
|
918
|
+
// Kill it now so dead processes do not accumulate. Session history is on
|
|
919
|
+
// disk and unaffected; startQuery will spawn a fresh worker next turn.
|
|
920
|
+
// We use the exitPromise stored at query-start time so startQuery's
|
|
921
|
+
// _workerExitPromise guard (which serialises consecutive queries) still works.
|
|
922
|
+
if (session._adapterWorkerState && session._adapterWorkerState.worker) {
|
|
923
|
+
var doneWorker = session._adapterWorkerState.worker;
|
|
924
|
+
var doneExitPromise = session._adapterWorkerState.exitPromise;
|
|
925
|
+
// Hand the exitPromise to startQuery so it can await worker termination
|
|
926
|
+
// before spawning the next one (prevents session-file race on resume).
|
|
927
|
+
session._workerExitPromise = doneExitPromise || null;
|
|
928
|
+
// Null out worker state so the next startQuery spawns fresh.
|
|
929
|
+
session._adapterWorkerState = null;
|
|
930
|
+
session.worker = null;
|
|
931
|
+
console.log("[sdk-bridge] Reaping worker pid=" + (doneWorker.process ? doneWorker.process.pid : "?") + " for session " + session.localId + " on query completion");
|
|
932
|
+
try { doneWorker.kill(); } catch (e) {}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// lr-29f9: Release the live-session slot claimed in startQuery.
|
|
936
|
+
if (session._isCountedLive) {
|
|
937
|
+
session._isCountedLive = false;
|
|
938
|
+
_activeLiveCount = Math.max(0, _activeLiveCount - 1);
|
|
939
|
+
console.log("[sdk-bridge] Live query count: " + _activeLiveCount + "/" + MAX_CONCURRENT_SESSIONS + " (session " + session.localId + " done)");
|
|
940
|
+
}
|
|
903
941
|
session.taskStopRequested = false;
|
|
904
942
|
session.pendingPermissions = {};
|
|
905
|
-
|
|
943
|
+
// Preserve MCP-mode AskUserQuestion entries across turn boundaries.
|
|
944
|
+
// The MCP path is intentionally stateless: ask_user returns immediately
|
|
945
|
+
// ("card posted, end your turn") and the answer arrives as a new
|
|
946
|
+
// user_message on the next turn. Those entries MUST survive this finally
|
|
947
|
+
// block so ask_user_response can find the toolId and inject the answer.
|
|
948
|
+
// canUseTool-mode entries hold an open SDK callback that dies with the
|
|
949
|
+
// query anyway, so those are correctly cleared here.
|
|
950
|
+
var _keepAskUser = {};
|
|
951
|
+
for (var _tid in session.pendingAskUser) {
|
|
952
|
+
var _pau = session.pendingAskUser[_tid];
|
|
953
|
+
if (_pau && _pau.mode === "mcp") _keepAskUser[_tid] = _pau;
|
|
954
|
+
}
|
|
955
|
+
session.pendingAskUser = _keepAskUser;
|
|
906
956
|
session.pendingElicitations = {};
|
|
907
957
|
|
|
908
958
|
// Auto-continue on rate limit (scheduler sessions, or user setting)
|
|
@@ -1142,6 +1192,44 @@ function createSDKBridge(opts) {
|
|
|
1142
1192
|
|
|
1143
1193
|
var t0 = session._queryStartTs || Date.now();
|
|
1144
1194
|
|
|
1195
|
+
// lr-29f9: Enforce concurrent-session ceiling.
|
|
1196
|
+
// Count only NEW queries (session has no active queryInstance).
|
|
1197
|
+
// Multi-turn pushes to an existing query are not new processes — don't gate them.
|
|
1198
|
+
var isNewQuery = !session.queryInstance;
|
|
1199
|
+
if (isNewQuery && _activeLiveCount >= MAX_CONCURRENT_SESSIONS) {
|
|
1200
|
+
console.warn("[sdk-bridge] Concurrent session ceiling hit (" + _activeLiveCount + "/" + MAX_CONCURRENT_SESSIONS + ") — rejecting new query for session " + session.localId);
|
|
1201
|
+
session.isProcessing = false;
|
|
1202
|
+
onProcessingChanged();
|
|
1203
|
+
sendAndRecord(session, {
|
|
1204
|
+
type: "error",
|
|
1205
|
+
text: "Too many active sessions (" + _activeLiveCount + "/" + MAX_CONCURRENT_SESSIONS + "). Wait for another session to finish, or increase CLAGENTIC_MAX_CONCURRENT_SESSIONS.",
|
|
1206
|
+
});
|
|
1207
|
+
sendAndRecord(session, { type: "done", code: 1 });
|
|
1208
|
+
sm.broadcastSessionList();
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
// Claim the slot now so concurrent callers see the updated count immediately.
|
|
1212
|
+
// Set _isCountedLive on the session at the same time so any early-return path
|
|
1213
|
+
// below (sync throw, createQuery failure) can release it via releaseSlot().
|
|
1214
|
+
// A local helper is used so there is no window where the slot is claimed but
|
|
1215
|
+
// _isCountedLive is not yet set — the two always move together.
|
|
1216
|
+
function releaseSlot() {
|
|
1217
|
+
if (session._isCountedLive) {
|
|
1218
|
+
session._isCountedLive = false;
|
|
1219
|
+
_activeLiveCount = Math.max(0, _activeLiveCount - 1);
|
|
1220
|
+
console.log("[sdk-bridge] Live query count: " + _activeLiveCount + "/" + MAX_CONCURRENT_SESSIONS + " (session " + session.localId + " slot released)");
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
if (isNewQuery) {
|
|
1224
|
+
_activeLiveCount++;
|
|
1225
|
+
session._isCountedLive = true;
|
|
1226
|
+
console.log("[sdk-bridge] Live query count: " + _activeLiveCount + "/" + MAX_CONCURRENT_SESSIONS + " (session " + session.localId + " starting)");
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// Guard the rest of startQuery so any unexpected synchronous throw releases
|
|
1230
|
+
// the slot claimed above and surfaces a visible error (no spinner-forever).
|
|
1231
|
+
try {
|
|
1232
|
+
|
|
1145
1233
|
// Wait for previous worker to fully exit before spawning a new one.
|
|
1146
1234
|
// Without this, the new worker may try to resume the SDK session file
|
|
1147
1235
|
// while the old worker is still flushing it to disk, causing
|
|
@@ -1333,6 +1421,7 @@ function createSDKBridge(opts) {
|
|
|
1333
1421
|
console.error("[sdk-bridge] Failed to create query for session " + session.localId + ":", e.message || e);
|
|
1334
1422
|
console.error("[sdk-bridge] cliSessionId:", session.cliSessionId, "resume:", !!session.cliSessionId);
|
|
1335
1423
|
console.error("[sdk-bridge] Stack:", e.stack || "(no stack)");
|
|
1424
|
+
releaseSlot();
|
|
1336
1425
|
session.isProcessing = false;
|
|
1337
1426
|
onProcessingChanged();
|
|
1338
1427
|
session.queryInstance = null;
|
|
@@ -1396,6 +1485,21 @@ function createSDKBridge(opts) {
|
|
|
1396
1485
|
sendToSession(session, { type: "error", text: "Stream error: " + (err && err.message || String(err)) });
|
|
1397
1486
|
sendToSession(session, { type: "done", code: 1 });
|
|
1398
1487
|
});
|
|
1488
|
+
|
|
1489
|
+
} catch (startErr) {
|
|
1490
|
+
// Unexpected synchronous throw anywhere in the post-slot-claim body.
|
|
1491
|
+
// Release the slot and surface the error so the UI does not spin forever.
|
|
1492
|
+
releaseSlot();
|
|
1493
|
+
session.isProcessing = false;
|
|
1494
|
+
onProcessingChanged();
|
|
1495
|
+
session.queryInstance = null;
|
|
1496
|
+
session.messageQueue = null;
|
|
1497
|
+
session.abortController = null;
|
|
1498
|
+
console.error("[sdk-bridge] Unexpected error in startQuery for session " + session.localId + ":", startErr && startErr.message || startErr);
|
|
1499
|
+
sendAndRecord(session, { type: "error", text: "Failed to start query: " + (startErr && startErr.message || String(startErr)) });
|
|
1500
|
+
sendAndRecord(session, { type: "done", code: 1 });
|
|
1501
|
+
sm.broadcastSessionList();
|
|
1502
|
+
}
|
|
1399
1503
|
}
|
|
1400
1504
|
|
|
1401
1505
|
function pushMessage(session, text, images) {
|
package/lib/server.js
CHANGED
|
@@ -957,7 +957,7 @@ function createServer(opts) {
|
|
|
957
957
|
var projectTitle = status.title || status.project || pSlug;
|
|
958
958
|
var projectIcon = status.icon || null;
|
|
959
959
|
pSm.sessions.forEach(function (s) {
|
|
960
|
-
if (!s.hidden
|
|
960
|
+
if (!s.hidden) {
|
|
961
961
|
// Push a shallow copy annotated with project metadata rather than
|
|
962
962
|
// mutating the live session object with transient UI fields.
|
|
963
963
|
allSessions.push(Object.assign({}, s, {
|
|
@@ -586,7 +586,7 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
586
586
|
done: false,
|
|
587
587
|
aborted: false,
|
|
588
588
|
loopStarted: false,
|
|
589
|
-
model: queryOpts.model ||
|
|
589
|
+
model: queryOpts.model || _defaultModel,
|
|
590
590
|
// Track incremental text deltas
|
|
591
591
|
textBlocks: {}, // itemId -> true (text_start sent)
|
|
592
592
|
textLengths: {}, // itemId -> last sent length
|
|
@@ -834,7 +834,7 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
834
834
|
try {
|
|
835
835
|
// Start or resume thread
|
|
836
836
|
var threadParams = {
|
|
837
|
-
model: queryOpts.model ||
|
|
837
|
+
model: queryOpts.model || _defaultModel,
|
|
838
838
|
sandbox: queryOpts.sandboxMode || "workspace-write",
|
|
839
839
|
approvalPolicy: queryOpts.approvalPolicy || "on-failure",
|
|
840
840
|
cwd: queryOpts.cwd,
|
|
@@ -1065,6 +1065,13 @@ var CODEX_EFFORT_LEVELS = ["minimal", "low", "medium", "high", "xhigh"];
|
|
|
1065
1065
|
var CODEX_EFFORT_LEVELS_STANDARD = ["low", "medium", "high"]; // models without xhigh/minimal
|
|
1066
1066
|
|
|
1067
1067
|
var CODEX_DEFAULT_MODELS = [
|
|
1068
|
+
{
|
|
1069
|
+
value: "gpt-5.5",
|
|
1070
|
+
displayName: "GPT-5.5",
|
|
1071
|
+
supportsEffort: true,
|
|
1072
|
+
supportedEffortLevels: CODEX_EFFORT_LEVELS,
|
|
1073
|
+
supportsThinking: false,
|
|
1074
|
+
},
|
|
1068
1075
|
{
|
|
1069
1076
|
value: "gpt-5.4",
|
|
1070
1077
|
displayName: "GPT-5.4",
|
|
@@ -1109,6 +1116,7 @@ function createCodexAdapter(opts) {
|
|
|
1109
1116
|
var _slug = (opts && opts.slug) || "";
|
|
1110
1117
|
var _defaultInitOpts = Object.assign({}, opts || {});
|
|
1111
1118
|
var _cachedModels = [];
|
|
1119
|
+
var _defaultModel = "gpt-5.5";
|
|
1112
1120
|
var _appServer = null;
|
|
1113
1121
|
var _initPromise = null;
|
|
1114
1122
|
var _shutdownPromise = null;
|
|
@@ -1146,7 +1154,7 @@ function createCodexAdapter(opts) {
|
|
|
1146
1154
|
function buildReadyResponse(skillNames) {
|
|
1147
1155
|
return {
|
|
1148
1156
|
models: _cachedModels,
|
|
1149
|
-
defaultModel:
|
|
1157
|
+
defaultModel: _defaultModel,
|
|
1150
1158
|
skills: skillNames || [],
|
|
1151
1159
|
slashCommands: skillNames || [],
|
|
1152
1160
|
fastModeState: null,
|
|
@@ -1358,9 +1366,47 @@ function createCodexAdapter(opts) {
|
|
|
1358
1366
|
throw createShutdownError();
|
|
1359
1367
|
}
|
|
1360
1368
|
|
|
1361
|
-
//
|
|
1362
|
-
// rich
|
|
1363
|
-
|
|
1369
|
+
// Query the app-server for the live model list. The v2 protocol exposes
|
|
1370
|
+
// "model/list" which returns rich Model objects with displayName, isDefault,
|
|
1371
|
+
// supportedReasoningEfforts, and upgrade (non-null when a newer model exists).
|
|
1372
|
+
// Fall back to CODEX_DEFAULT_MODELS if the call fails or returns nothing.
|
|
1373
|
+
try {
|
|
1374
|
+
var modelListResult = await _appServer.send("model/list", {}, 10000);
|
|
1375
|
+
// Response shape: { data: [Model, ...], nextCursor }
|
|
1376
|
+
if (modelListResult && Array.isArray(modelListResult.data) && modelListResult.data.length > 0) {
|
|
1377
|
+
_cachedModels = modelListResult.data
|
|
1378
|
+
.filter(function(m) { return !m.hidden; })
|
|
1379
|
+
.map(function(m) {
|
|
1380
|
+
var efforts = Array.isArray(m.supportedReasoningEfforts)
|
|
1381
|
+
? m.supportedReasoningEfforts.map(function(r) { return r.reasoningEffort; })
|
|
1382
|
+
: CODEX_EFFORT_LEVELS;
|
|
1383
|
+
return {
|
|
1384
|
+
value: m.model || m.id,
|
|
1385
|
+
displayName: m.displayName || m.model || m.id,
|
|
1386
|
+
supportsEffort: efforts.length > 0,
|
|
1387
|
+
supportedEffortLevels: efforts,
|
|
1388
|
+
supportsThinking: false,
|
|
1389
|
+
isLatest: !m.upgrade,
|
|
1390
|
+
};
|
|
1391
|
+
});
|
|
1392
|
+
// Derive default model: first isDefault entry, or first non-hidden entry
|
|
1393
|
+
var defaultEntry = null;
|
|
1394
|
+
for (var mi = 0; mi < modelListResult.data.length; mi++) {
|
|
1395
|
+
if (!modelListResult.data[mi].hidden && modelListResult.data[mi].isDefault) {
|
|
1396
|
+
defaultEntry = modelListResult.data[mi];
|
|
1397
|
+
break;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
_defaultModel = (defaultEntry && (defaultEntry.model || defaultEntry.id)) || _defaultModel;
|
|
1401
|
+
console.log("[codex] model/list: " + _cachedModels.length + " models, default=" + _defaultModel);
|
|
1402
|
+
} else {
|
|
1403
|
+
throw new Error("empty or missing data");
|
|
1404
|
+
}
|
|
1405
|
+
} catch (e) {
|
|
1406
|
+
console.warn("[codex] model/list failed (" + e.message + "); using built-in model table");
|
|
1407
|
+
_cachedModels = CODEX_DEFAULT_MODELS.slice();
|
|
1408
|
+
// _defaultModel stays "gpt-5.5" (set at init)
|
|
1409
|
+
}
|
|
1364
1410
|
console.log("[codex] App-server initialized, models: " + _cachedModels.map(function(m) { return m.value; }).join(", "));
|
|
1365
1411
|
|
|
1366
1412
|
// Discover skills: built-in Codex skills + Claude skills
|
|
@@ -1443,7 +1489,7 @@ function createCodexAdapter(opts) {
|
|
|
1443
1489
|
throw new Error("[yoke/codex] Adapter not initialized. Call init() first.");
|
|
1444
1490
|
}
|
|
1445
1491
|
|
|
1446
|
-
var model = queryOpts.model ||
|
|
1492
|
+
var model = queryOpts.model || _defaultModel;
|
|
1447
1493
|
var ac = queryOpts.abortController || new AbortController();
|
|
1448
1494
|
var activeEntry = {
|
|
1449
1495
|
abort: function() {
|
package/package.json
CHANGED