@clagentic/console 1.9.0 → 1.10.0-beta.2
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/LICENSE +117 -12
- package/LICENSES/MIT-legacy.txt +22 -0
- package/LICENSES/README.md +15 -0
- package/README.md +9 -3
- package/bin/cli.js +40 -5
- package/deploy/clagentic-console.service +10 -6
- package/lib/agent-dispatch-tool.js +20 -0
- package/lib/audit.js +3 -2
- package/lib/build-changes.js +79 -0
- package/lib/build-identity.js +192 -0
- package/lib/build-monitor.js +125 -0
- package/lib/build-sha.json +2 -2
- package/lib/build-update-check.js +138 -0
- package/lib/build-update-offer.js +141 -0
- package/lib/build-update-restart.js +142 -0
- package/lib/build-update-standing.js +184 -0
- package/lib/cli/daemon-launch.js +25 -22
- package/lib/cli/ipc-subcommands.js +6 -0
- package/lib/cli/session-subcommands.js +122 -0
- package/lib/cli-sessions.js +8 -1
- package/lib/codex-defaults.js +8 -2
- package/lib/config.js +32 -20
- package/lib/daemon-env-settings.js +84 -0
- package/lib/daemon-projects.js +57 -0
- package/lib/daemon.js +288 -205
- package/lib/drain.js +74 -17
- package/lib/env-compat.js +61 -0
- package/lib/extension-commands.js +45 -0
- package/lib/history-visibility.js +4 -0
- package/lib/idle-adapter-reaper.js +71 -0
- package/lib/link-trap.js +78 -0
- package/lib/mcp-local.js +8 -6
- package/lib/mcp-tool-input.js +116 -0
- package/lib/mcp-tool-schema.js +179 -0
- package/lib/memory-limits.js +61 -5
- package/lib/memory-setting-validate.js +65 -0
- package/lib/memory-shed.js +13 -32
- package/lib/new-work-gate.js +47 -0
- package/lib/os-users.js +5 -3
- package/lib/project-access.js +139 -0
- package/lib/project-connection.js +37 -22
- package/lib/project-external-trigger.js +166 -105
- package/lib/project-file-scope.js +172 -0
- package/lib/project-file-watch.js +86 -61
- package/lib/project-filesystem.js +144 -128
- package/lib/project-git.js +119 -0
- package/lib/project-http.js +44 -28
- package/lib/project-loop.js +17 -9
- package/lib/project-mcp.js +53 -72
- package/lib/project-message-gate.js +70 -0
- package/lib/project-notifications.js +31 -4
- package/lib/project-prompt-responses.js +217 -0
- package/lib/project-sessions.js +192 -355
- package/lib/project-user-message.js +27 -15
- package/lib/project.js +212 -147
- package/lib/projects-dir.js +90 -0
- package/lib/prompt-access.js +22 -0
- package/lib/prompt-kinds/answer-limits.js +15 -0
- package/lib/prompt-kinds/ask-user.js +58 -0
- package/lib/prompt-kinds/codecs.js +97 -0
- package/lib/prompt-kinds/elicitation.js +77 -0
- package/lib/prompt-kinds/extension.js +39 -0
- package/lib/prompt-kinds/index.js +68 -0
- package/lib/prompt-kinds/permission.js +114 -0
- package/lib/prompt-kinds/plan.js +79 -0
- package/lib/prompt-kinds/tool-call.js +38 -0
- package/lib/prompt-registry.js +680 -0
- package/lib/public/app.js +1 -1
- package/lib/public/css/diagnostics.css +80 -0
- package/lib/public/css/input.css +17 -3
- package/lib/public/css/menus.css +10 -0
- package/lib/public/css/messages.css +5 -0
- package/lib/public/css/rewind.css +22 -0
- package/lib/public/index.html +4 -12
- package/lib/public/modules/agent-dispatch-tool.js +9 -0
- package/lib/public/modules/app-connection.js +7 -0
- package/lib/public/modules/app-cursors.js +7 -5
- package/lib/public/modules/app-messages.js +52 -47
- package/lib/public/modules/app-notifications.js +47 -71
- package/lib/public/modules/app-panels.js +61 -59
- package/lib/public/modules/app-projects.js +2 -1
- package/lib/public/modules/app-rendering.js +4 -10
- package/lib/public/modules/build-update-detail.js +54 -0
- package/lib/public/modules/diagnostics.js +170 -20
- package/lib/public/modules/filebrowser.js +18 -16
- package/lib/public/modules/history-visibility.js +4 -0
- package/lib/public/modules/mention.js +3 -2
- package/lib/public/modules/mode-options.js +38 -0
- package/lib/public/modules/project-settings.js +19 -8
- package/lib/public/modules/prompt-banner.js +78 -0
- package/lib/public/modules/prompt-card.js +201 -0
- package/lib/public/modules/prompt-kinds/ask-user-codec.js +131 -0
- package/lib/public/modules/prompt-kinds/ask-user.js +213 -0
- package/lib/public/modules/prompt-kinds/elicitation-codec.js +343 -0
- package/lib/public/modules/prompt-kinds/elicitation.js +176 -0
- package/lib/public/modules/prompt-kinds/index.js +18 -0
- package/lib/public/modules/prompt-kinds/own-key.js +29 -0
- package/lib/public/modules/prompt-kinds/package.json +3 -0
- package/lib/public/modules/prompt-kinds/permission-choices.js +31 -0
- package/lib/public/modules/prompt-kinds/permission.js +209 -0
- package/lib/public/modules/prompt-kinds/plan.js +102 -0
- package/lib/public/modules/prompt-state.js +142 -0
- package/lib/public/modules/prompts.js +134 -0
- package/lib/public/modules/rewind.js +4 -1
- package/lib/public/modules/server-settings.js +2 -4
- package/lib/public/modules/sidebar-mobile.js +19 -9
- package/lib/public/modules/sidebar-sessions.js +21 -14
- package/lib/public/modules/sticky-notes.js +3 -2
- package/lib/public/modules/team-panel.js +5 -4
- package/lib/public/modules/tools.js +81 -906
- package/lib/public/modules/vendor-picker.js +53 -0
- package/lib/public/modules/vendor-registry.js +142 -0
- package/lib/public/sw.js +3 -1
- package/lib/rc-migrate.js +44 -0
- package/lib/runtime-env-keys.js +109 -0
- package/lib/runtime-env.js +236 -0
- package/lib/sdk-bridge.js +348 -284
- package/lib/sdk-message-processor.js +117 -146
- package/lib/sdk-skill-discovery.js +65 -60
- package/lib/server-hub-sessions.js +13 -10
- package/lib/server-palette.js +28 -19
- package/lib/server.js +156 -115
- package/lib/service-install.js +96 -0
- package/lib/session-capabilities.js +76 -0
- package/lib/session-id.js +33 -0
- package/lib/session-input-ipc.js +32 -0
- package/lib/session-input.js +379 -0
- package/lib/session-reclaim.js +284 -0
- package/lib/session-resume.js +172 -0
- package/lib/sessions.js +61 -30
- package/lib/supervisor.js +39 -0
- package/lib/turn-initiator.js +108 -0
- package/lib/users-permissions.js +9 -6
- package/lib/users.js +9 -0
- package/lib/utils.js +4 -2
- package/lib/vendor-auth.js +22 -0
- package/lib/vendor-registry-message.js +66 -0
- package/lib/ws-origin.js +99 -0
- package/lib/ws-schema.js +36 -23
- package/lib/yoke/adapters/claude-capabilities.js +38 -0
- package/lib/yoke/adapters/claude-vendor.js +34 -0
- package/lib/yoke/adapters/claude-worker.js +57 -87
- package/lib/yoke/adapters/claude.js +182 -88
- package/lib/yoke/adapters/codex-capabilities.js +40 -0
- package/lib/yoke/adapters/codex-vendor.js +46 -0
- package/lib/yoke/adapters/codex.js +462 -211
- package/lib/yoke/adapters/effort-control.js +34 -0
- package/lib/yoke/adapters/permission-relay.js +58 -0
- package/lib/yoke/adapters/worker-mcp-servers.js +81 -0
- package/lib/yoke/auth-checks.js +91 -0
- package/lib/yoke/capabilities.js +49 -0
- package/lib/yoke/codex-app-server.js +30 -56
- package/lib/yoke/codex-binary.js +254 -0
- package/lib/yoke/codex-command.js +122 -0
- package/lib/yoke/codex-protocol.js +96 -0
- package/lib/yoke/codex-version.js +135 -0
- package/lib/yoke/env-ownership.js +40 -0
- package/lib/yoke/index.js +84 -174
- package/lib/yoke/install-probe.js +136 -0
- package/lib/yoke/instructions.js +7 -11
- package/lib/yoke/interface.js +206 -4
- package/lib/yoke/package.json +1 -1
- package/lib/yoke/provider-credentials.js +96 -0
- package/lib/yoke/registry.js +377 -0
- package/package.json +12 -9
- package/scripts/check-sdk-lock-drift.js +160 -0
- package/scripts/check-test-count.js +76 -1
- package/scripts/postinstall.js +218 -136
- package/scripts/prompt-harness-history.js +202 -0
- package/scripts/verify-installed-build.js +59 -17
- package/scripts/verify-installed.js +67 -0
- package/lib/sdk-permission-ownership.js +0 -136
|
@@ -13,6 +13,11 @@ var { spawn } = require("child_process");
|
|
|
13
13
|
var { resolveOsUserInfo } = require("../../os-users");
|
|
14
14
|
var modelFamilies = require("../../model-families");
|
|
15
15
|
var modelCatalog = require("../../model-catalog");
|
|
16
|
+
var permissionRelay = require("./permission-relay");
|
|
17
|
+
var effortControl = require("./effort-control");
|
|
18
|
+
var runtimeEnv = require("../../runtime-env");
|
|
19
|
+
var turnInitiator = require("../../turn-initiator");
|
|
20
|
+
var claudeCapabilities = require("./claude-capabilities").claudeCapabilities;
|
|
16
21
|
|
|
17
22
|
// --- SDK loading ---
|
|
18
23
|
// Async loader (ESM dynamic import, same pattern as current project.js getSDK)
|
|
@@ -338,6 +343,22 @@ function flattenEvent(raw) {
|
|
|
338
343
|
return base;
|
|
339
344
|
}
|
|
340
345
|
|
|
346
|
+
// The streamed user message for one turn, stamped with who initiated it. Shared
|
|
347
|
+
// by the in-process and worker handles so both deliver the same provenance.
|
|
348
|
+
function buildUserMessage(text, images, initiator) {
|
|
349
|
+
var content = [];
|
|
350
|
+
if (images && images.length > 0) {
|
|
351
|
+
for (var i = 0; i < images.length; i++) {
|
|
352
|
+
content.push({
|
|
353
|
+
type: "image",
|
|
354
|
+
source: { type: "base64", media_type: images[i].mediaType, data: images[i].data },
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (text) content.push({ type: "text", text: text });
|
|
359
|
+
return turnInitiator.stampClaudeUserMessage({ type: "user", message: { role: "user", content: content } }, initiator);
|
|
360
|
+
}
|
|
361
|
+
|
|
341
362
|
// --- QueryHandle ---
|
|
342
363
|
// Wraps a raw SDK query object with the YOKE QueryHandle interface.
|
|
343
364
|
// Events are flattened via flattenEvent before yielding.
|
|
@@ -359,18 +380,8 @@ function createQueryHandle(rawQuery, messageQueue, abortController) {
|
|
|
359
380
|
};
|
|
360
381
|
},
|
|
361
382
|
|
|
362
|
-
pushMessage: function(text, images) {
|
|
363
|
-
|
|
364
|
-
if (images && images.length > 0) {
|
|
365
|
-
for (var i = 0; i < images.length; i++) {
|
|
366
|
-
content.push({
|
|
367
|
-
type: "image",
|
|
368
|
-
source: { type: "base64", media_type: images[i].mediaType, data: images[i].data },
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
if (text) content.push({ type: "text", text: text });
|
|
373
|
-
messageQueue.push({ type: "user", message: { role: "user", content: content } });
|
|
383
|
+
pushMessage: function(text, images, initiator) {
|
|
384
|
+
messageQueue.push(buildUserMessage(text, images, initiator));
|
|
374
385
|
},
|
|
375
386
|
|
|
376
387
|
setModel: function(model) {
|
|
@@ -380,10 +391,11 @@ function createQueryHandle(rawQuery, messageQueue, abortController) {
|
|
|
380
391
|
return Promise.resolve();
|
|
381
392
|
},
|
|
382
393
|
|
|
394
|
+
// The SDK's Query has no setEffort; applyFlagSettings is the live control.
|
|
395
|
+
// Rejects when the change did not take effect, so the caller never
|
|
396
|
+
// reports an effort the session is not running at.
|
|
383
397
|
setEffort: function(effort) {
|
|
384
|
-
|
|
385
|
-
// Stored at the console level for next query.
|
|
386
|
-
return Promise.resolve();
|
|
398
|
+
return effortControl.applyEffort(rawQuery, effort);
|
|
387
399
|
},
|
|
388
400
|
|
|
389
401
|
setToolPolicy: function(policy) {
|
|
@@ -792,7 +804,9 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
792
804
|
// Pending request/response correlation for handle methods that need a
|
|
793
805
|
// result from the worker (e.g. rewindFiles). Each entry is keyed by a
|
|
794
806
|
// requestId and holds { resolve, reject } of the in-flight Promise.
|
|
795
|
-
|
|
807
|
+
// These three tables are keyed by ids the worker echoes back, so they have
|
|
808
|
+
// no prototype to answer for "constructor" or "__proto__".
|
|
809
|
+
var pendingRewinds = Object.create(null);
|
|
796
810
|
|
|
797
811
|
// lr-f22787: same correlation pattern as pendingRewinds, for setModel.
|
|
798
812
|
// Without this, an invalid/unentitled model ID sent to a worker session
|
|
@@ -802,7 +816,65 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
802
816
|
// Promise.resolve() immediately without ever waiting for that reply, so
|
|
803
817
|
// the failure had no path back to the caller (sdk-bridge.js's setModel,
|
|
804
818
|
// then project-sessions.js) to surface to the user.
|
|
805
|
-
var pendingSetModel =
|
|
819
|
+
var pendingSetModel = Object.create(null);
|
|
820
|
+
|
|
821
|
+
// Same correlation for setEffort: the returned promise settles on the
|
|
822
|
+
// worker's real outcome, or rejects when the worker never answers.
|
|
823
|
+
var pendingSetEffort = Object.create(null);
|
|
824
|
+
var SET_EFFORT_TIMEOUT_MS = 15000;
|
|
825
|
+
|
|
826
|
+
function settleSetEffort(requestId, error) {
|
|
827
|
+
var pending = pendingSetEffort[requestId];
|
|
828
|
+
if (!pending) return;
|
|
829
|
+
delete pendingSetEffort[requestId];
|
|
830
|
+
clearTimeout(pending.timer);
|
|
831
|
+
if (error) pending.reject(error);
|
|
832
|
+
else pending.resolve();
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// The worker's query is over: no pending effort change can still land.
|
|
836
|
+
function failPendingEfforts() {
|
|
837
|
+
Object.keys(pendingSetEffort).forEach(function (requestId) {
|
|
838
|
+
settleSetEffort(requestId, new Error("The Claude query ended before the effort change took effect"));
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// "<kind>:<worker prompt id>" -> AbortController whose signal is handed to
|
|
843
|
+
// the daemon-side callback, so the daemon-side prompt ends when the worker
|
|
844
|
+
// stops waiting for it: its own timeout, the SDK cancelling the callback,
|
|
845
|
+
// or the worker's query ending.
|
|
846
|
+
var promptAborts = Object.create(null);
|
|
847
|
+
|
|
848
|
+
function abortPrompt(key, reason) {
|
|
849
|
+
var ac = promptAborts[key];
|
|
850
|
+
if (ac) ac.abort(reason);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function abortAllPrompts() {
|
|
854
|
+
Object.keys(promptAborts).forEach(function (key) { abortPrompt(key); });
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// Relays one worker prompt to a daemon-side callback and its answer back.
|
|
858
|
+
// The abort entry lives exactly as long as the callback is pending, on
|
|
859
|
+
// every path out of it.
|
|
860
|
+
function relayPrompt(key, ask, reply, label) {
|
|
861
|
+
var ac = new AbortController();
|
|
862
|
+
promptAborts[key] = ac;
|
|
863
|
+
var pending;
|
|
864
|
+
try {
|
|
865
|
+
pending = Promise.resolve(ask(ac.signal));
|
|
866
|
+
} catch (e) {
|
|
867
|
+
pending = Promise.reject(e);
|
|
868
|
+
}
|
|
869
|
+
pending
|
|
870
|
+
.then(reply)
|
|
871
|
+
.catch(function (e) {
|
|
872
|
+
console.error("[yoke/claude] " + label + " send failed:", (e && e.message) || e);
|
|
873
|
+
})
|
|
874
|
+
.finally(function () {
|
|
875
|
+
if (promptAborts[key] === ac) delete promptAborts[key];
|
|
876
|
+
});
|
|
877
|
+
}
|
|
806
878
|
|
|
807
879
|
function pushToIter(value) {
|
|
808
880
|
if (iterEnded) return;
|
|
@@ -846,47 +918,51 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
846
918
|
|
|
847
919
|
case "permission_request":
|
|
848
920
|
if (canUseTool) {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
signal: { addEventListener: function() {} },
|
|
853
|
-
}).then(function(result) {
|
|
921
|
+
relayPrompt("permission:" + msg.requestId, function (signal) {
|
|
922
|
+
return canUseTool(msg.toolName, msg.input, permissionRelay.toCanUseToolOptions(msg, signal));
|
|
923
|
+
}, function (result) {
|
|
854
924
|
worker.send({ type: "permission_response", requestId: msg.requestId, result: result });
|
|
855
|
-
})
|
|
856
|
-
console.error("[yoke/claude] permission_response send failed:", e.message || e);
|
|
857
|
-
});
|
|
925
|
+
}, "permission_response");
|
|
858
926
|
}
|
|
859
927
|
break;
|
|
860
928
|
|
|
929
|
+
// The worker stopped waiting for a prompt; ending it daemon-side keeps
|
|
930
|
+
// a card from offering an answer that can no longer take effect.
|
|
931
|
+
case "permission_expired":
|
|
932
|
+
abortPrompt("permission:" + msg.requestId, "expired");
|
|
933
|
+
break;
|
|
934
|
+
|
|
935
|
+
case "prompt_cancelled":
|
|
936
|
+
abortPrompt(msg.kind + ":" + msg.id);
|
|
937
|
+
break;
|
|
938
|
+
|
|
861
939
|
case "ask_user_request":
|
|
862
940
|
if (canUseTool) {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
941
|
+
relayPrompt("ask_user:" + msg.toolUseId, function (signal) {
|
|
942
|
+
return canUseTool("AskUserQuestion", msg.input, {
|
|
943
|
+
toolUseID: msg.toolUseId,
|
|
944
|
+
signal: signal,
|
|
945
|
+
});
|
|
946
|
+
}, function (result) {
|
|
867
947
|
worker.send({ type: "ask_user_response", toolUseId: msg.toolUseId, result: result });
|
|
868
|
-
})
|
|
869
|
-
console.error("[yoke/claude] ask_user_response send failed:", e.message || e);
|
|
870
|
-
});
|
|
948
|
+
}, "ask_user_response");
|
|
871
949
|
}
|
|
872
950
|
break;
|
|
873
951
|
|
|
874
952
|
case "elicitation_request":
|
|
875
953
|
if (onElicitation) {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
}
|
|
954
|
+
relayPrompt("elicitation:" + msg.requestId, function (signal) {
|
|
955
|
+
return onElicitation({
|
|
956
|
+
serverName: msg.serverName,
|
|
957
|
+
message: msg.message,
|
|
958
|
+
mode: msg.mode,
|
|
959
|
+
url: msg.url,
|
|
960
|
+
elicitationId: msg.elicitationId,
|
|
961
|
+
requestedSchema: msg.requestedSchema,
|
|
962
|
+
}, { signal: signal });
|
|
963
|
+
}, function (result) {
|
|
886
964
|
worker.send({ type: "elicitation_response", requestId: msg.requestId, result: result });
|
|
887
|
-
})
|
|
888
|
-
console.error("[yoke/claude] elicitation_response send failed:", e.message || e);
|
|
889
|
-
});
|
|
965
|
+
}, "elicitation_response");
|
|
890
966
|
}
|
|
891
967
|
break;
|
|
892
968
|
|
|
@@ -905,12 +981,16 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
905
981
|
break;
|
|
906
982
|
|
|
907
983
|
case "context_usage":
|
|
908
|
-
case "effort_changed":
|
|
909
984
|
case "permission_mode_changed":
|
|
910
985
|
// Yield these as _worker_meta events so processQueryStream can handle them
|
|
911
986
|
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
912
987
|
break;
|
|
913
988
|
|
|
989
|
+
case "effort_changed":
|
|
990
|
+
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
991
|
+
settleSetEffort(msg.requestId, null);
|
|
992
|
+
break;
|
|
993
|
+
|
|
914
994
|
case "model_changed":
|
|
915
995
|
// lr-f22787: still yielded as a _worker_meta event (unchanged
|
|
916
996
|
// consumer contract for sdk-bridge.js), AND resolves the pending
|
|
@@ -926,11 +1006,18 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
926
1006
|
break;
|
|
927
1007
|
|
|
928
1008
|
case "worker_error":
|
|
1009
|
+
// A failure of an in-flight set_effort request is reported by the
|
|
1010
|
+
// rejection of setEffort() alone: also yielding it as a _worker_meta
|
|
1011
|
+
// event would show the operator the same error twice.
|
|
1012
|
+
if (msg.requestId && pendingSetEffort[msg.requestId]) {
|
|
1013
|
+
settleSetEffort(msg.requestId, new Error(msg.error || "Failed to set effort"));
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
929
1016
|
// Yielded as a _worker_meta event (unchanged consumer contract), AND
|
|
930
1017
|
// rejects the pending setModel() promise when this worker_error
|
|
931
|
-
// belongs to an in-flight set_model request (lr-f22787).
|
|
932
|
-
//
|
|
933
|
-
//
|
|
1018
|
+
// belongs to an in-flight set_model request (lr-f22787). A
|
|
1019
|
+
// permission-mode failure carries no requestId and so never matches
|
|
1020
|
+
// a pendingSetModel entry.
|
|
934
1021
|
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
935
1022
|
if (msg.requestId && pendingSetModel[msg.requestId]) {
|
|
936
1023
|
var smErr = pendingSetModel[msg.requestId];
|
|
@@ -952,6 +1039,9 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
952
1039
|
case "query_done":
|
|
953
1040
|
console.log("[yoke/claude] IPC query_done received, pid=" + (worker.process ? worker.process.pid : "?"));
|
|
954
1041
|
worker._queryEnded = true;
|
|
1042
|
+
// The worker's query is over; nothing in it waits for an answer.
|
|
1043
|
+
abortAllPrompts();
|
|
1044
|
+
failPendingEfforts();
|
|
955
1045
|
endIter();
|
|
956
1046
|
break;
|
|
957
1047
|
|
|
@@ -960,6 +1050,8 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
960
1050
|
// Skip fallback errors from exit handler if we already handled the real one
|
|
961
1051
|
if (msg._fallback && worker._queryEnded) break;
|
|
962
1052
|
worker._queryEnded = true;
|
|
1053
|
+
abortAllPrompts();
|
|
1054
|
+
failPendingEfforts();
|
|
963
1055
|
var err = new Error(msg.error || "Worker query error");
|
|
964
1056
|
err.exitCode = msg.exitCode;
|
|
965
1057
|
err.stderr = msg.stderr;
|
|
@@ -1012,19 +1104,8 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
1012
1104
|
};
|
|
1013
1105
|
},
|
|
1014
1106
|
|
|
1015
|
-
pushMessage: function(text, images) {
|
|
1016
|
-
|
|
1017
|
-
if (images && images.length > 0) {
|
|
1018
|
-
for (var i = 0; i < images.length; i++) {
|
|
1019
|
-
content.push({
|
|
1020
|
-
type: "image",
|
|
1021
|
-
source: { type: "base64", media_type: images[i].mediaType, data: images[i].data },
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
if (text) content.push({ type: "text", text: text });
|
|
1026
|
-
var userMsg = { type: "user", message: { role: "user", content: content } };
|
|
1027
|
-
worker.send({ type: "push_message", content: userMsg });
|
|
1107
|
+
pushMessage: function(text, images, initiator) {
|
|
1108
|
+
worker.send({ type: "push_message", content: buildUserMessage(text, images, initiator) });
|
|
1028
1109
|
},
|
|
1029
1110
|
|
|
1030
1111
|
// lr-f22787: correlated by requestId (mirrors rewindFiles below) so the
|
|
@@ -1045,8 +1126,18 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
1045
1126
|
},
|
|
1046
1127
|
|
|
1047
1128
|
setEffort: function(effort) {
|
|
1048
|
-
|
|
1049
|
-
return Promise
|
|
1129
|
+
var requestId = crypto.randomUUID();
|
|
1130
|
+
return new Promise(function(resolve, reject) {
|
|
1131
|
+
var timer = setTimeout(function() {
|
|
1132
|
+
settleSetEffort(requestId, new Error("The Claude worker did not confirm the effort change"));
|
|
1133
|
+
}, SET_EFFORT_TIMEOUT_MS);
|
|
1134
|
+
pendingSetEffort[requestId] = { resolve: resolve, reject: reject, timer: timer };
|
|
1135
|
+
try {
|
|
1136
|
+
worker.send({ type: "set_effort", requestId: requestId, effort: effort });
|
|
1137
|
+
} catch (e) {
|
|
1138
|
+
settleSetEffort(requestId, e);
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1050
1141
|
},
|
|
1051
1142
|
|
|
1052
1143
|
setToolPolicy: function(policy) {
|
|
@@ -1149,7 +1240,7 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
1149
1240
|
// vendor-reported list always wins outright when present (see
|
|
1150
1241
|
// enrichClaudeModel below) — this table exists purely to cover the case
|
|
1151
1242
|
// where the vendor reports no levels at all, not as the primary source.
|
|
1152
|
-
var CLAUDE_EFFORT_LEVELS =
|
|
1243
|
+
var CLAUDE_EFFORT_LEVELS = effortControl.EFFORT_LEVELS;
|
|
1153
1244
|
|
|
1154
1245
|
// Display name, thinking/effort capability heuristics, and family/version
|
|
1155
1246
|
// parsing all live in ../../model-families.js (lr-d91ecf) — the single
|
|
@@ -1556,6 +1647,12 @@ function createClaudeAdapter(opts) {
|
|
|
1556
1647
|
if (co.resumeSessionAt) sdkOptions.resumeSessionAt = co.resumeSessionAt;
|
|
1557
1648
|
if (co.settings) sdkOptions.settings = co.settings;
|
|
1558
1649
|
|
|
1650
|
+
// options.env REPLACES the subprocess environment, so the query is handed
|
|
1651
|
+
// the whole environment (the process's own, the Settings variables, and
|
|
1652
|
+
// the product identity), not the additions. queryOpts.initiator is the
|
|
1653
|
+
// initiator of the turn that starts this process.
|
|
1654
|
+
sdkOptions.env = turnInitiator.claudeProcessEnv(process.env, queryOpts.runtimeEnv, queryOpts.initiator);
|
|
1655
|
+
|
|
1559
1656
|
var rawQuery = sdk.query({ prompt: mq, options: sdkOptions });
|
|
1560
1657
|
return createQueryHandle(rawQuery, mq, ac);
|
|
1561
1658
|
},
|
|
@@ -1577,10 +1674,15 @@ function createClaudeAdapter(opts) {
|
|
|
1577
1674
|
adapterOptions: {
|
|
1578
1675
|
CLAUDE: {
|
|
1579
1676
|
settingSources: ["user"],
|
|
1580
|
-
|
|
1677
|
+
// A title needs no tool. bypassPermissions makes the SDK pass
|
|
1678
|
+
// --dangerously-skip-permissions, which the CLI refuses under
|
|
1679
|
+
// root, so every title failed there; dontAsk denies anything
|
|
1680
|
+
// not pre-approved and starts the same under any uid.
|
|
1681
|
+
permissionMode: "dontAsk",
|
|
1581
1682
|
}
|
|
1582
1683
|
},
|
|
1583
1684
|
abortController: ac,
|
|
1685
|
+
runtimeEnv: opts && opts.runtimeEnv,
|
|
1584
1686
|
});
|
|
1585
1687
|
console.log("[auto-title/claude] Query created, pushing message...");
|
|
1586
1688
|
handle.pushMessage(prompt);
|
|
@@ -1720,6 +1822,11 @@ function createClaudeAdapter(opts) {
|
|
|
1720
1822
|
if (claudeOpts.permissionMode) queryOptions.permissionMode = claudeOpts.permissionMode;
|
|
1721
1823
|
if (claudeOpts.allowDangerouslySkipPermissions) queryOptions.allowDangerouslySkipPermissions = true;
|
|
1722
1824
|
if (claudeOpts.settings) queryOptions.settings = claudeOpts.settings;
|
|
1825
|
+
// The worker lays these over its own environment (the OS user's), then
|
|
1826
|
+
// hands the SDK the complete result.
|
|
1827
|
+
if (runtimeEnv.hasOverlay(queryOpts.runtimeEnv)) queryOptions.runtimeEnv = queryOpts.runtimeEnv;
|
|
1828
|
+
// The worker builds the environment (see applyRuntimeEnv in claude-worker.js).
|
|
1829
|
+
if (queryOpts.initiator) queryOptions.initiator = queryOpts.initiator;
|
|
1723
1830
|
|
|
1724
1831
|
if (queryOpts.toolServerDescriptors) queryOptions.mcpServerDescriptors = queryOpts.toolServerDescriptors;
|
|
1725
1832
|
if (queryOpts.model) queryOptions.model = queryOpts.model;
|
|
@@ -1768,6 +1875,8 @@ function createClaudeAdapter(opts) {
|
|
|
1768
1875
|
warmupOptions.permissionMode = "bypassPermissions";
|
|
1769
1876
|
warmupOptions.allowDangerouslySkipPermissions = true;
|
|
1770
1877
|
}
|
|
1878
|
+
// The warmup starts the same CLI a query does, so it gets the same environment.
|
|
1879
|
+
warmupOptions.env = turnInitiator.claudeProcessEnv(process.env, initOpts && initOpts.runtimeEnv);
|
|
1771
1880
|
|
|
1772
1881
|
var result = {
|
|
1773
1882
|
models: [],
|
|
@@ -1775,17 +1884,7 @@ function createClaudeAdapter(opts) {
|
|
|
1775
1884
|
skills: [],
|
|
1776
1885
|
slashCommands: [],
|
|
1777
1886
|
fastModeState: null,
|
|
1778
|
-
capabilities:
|
|
1779
|
-
thinking: true,
|
|
1780
|
-
betas: true,
|
|
1781
|
-
rewind: true,
|
|
1782
|
-
sessionResume: true,
|
|
1783
|
-
promptSuggestions: true,
|
|
1784
|
-
elicitation: true,
|
|
1785
|
-
fileCheckpointing: true,
|
|
1786
|
-
contextCompacting: true,
|
|
1787
|
-
toolPolicy: ["ask", "allow-all"],
|
|
1788
|
-
},
|
|
1887
|
+
capabilities: claudeCapabilities(),
|
|
1789
1888
|
};
|
|
1790
1889
|
|
|
1791
1890
|
try {
|
|
@@ -1849,6 +1948,7 @@ function createClaudeAdapter(opts) {
|
|
|
1849
1948
|
warmupOptions.permissionMode = "bypassPermissions";
|
|
1850
1949
|
warmupOptions.allowDangerouslySkipPermissions = true;
|
|
1851
1950
|
}
|
|
1951
|
+
if (initOpts && runtimeEnv.hasOverlay(initOpts.runtimeEnv)) warmupOptions.runtimeEnv = initOpts.runtimeEnv;
|
|
1852
1952
|
|
|
1853
1953
|
return new Promise(function(resolve, reject) {
|
|
1854
1954
|
var warmupDone = false;
|
|
@@ -1865,17 +1965,7 @@ function createClaudeAdapter(opts) {
|
|
|
1865
1965
|
skills: r.skills || [],
|
|
1866
1966
|
slashCommands: r.slashCommands || [],
|
|
1867
1967
|
fastModeState: r.fastModeState || null,
|
|
1868
|
-
capabilities:
|
|
1869
|
-
thinking: true,
|
|
1870
|
-
betas: true,
|
|
1871
|
-
rewind: true,
|
|
1872
|
-
sessionResume: true,
|
|
1873
|
-
promptSuggestions: true,
|
|
1874
|
-
elicitation: true,
|
|
1875
|
-
fileCheckpointing: true,
|
|
1876
|
-
contextCompacting: true,
|
|
1877
|
-
toolPolicy: ["ask", "allow-all"],
|
|
1878
|
-
},
|
|
1968
|
+
capabilities: claudeCapabilities(),
|
|
1879
1969
|
});
|
|
1880
1970
|
worker.kill();
|
|
1881
1971
|
} else if (msg.type === "warmup_error" && !warmupDone) {
|
|
@@ -1912,5 +2002,9 @@ module.exports = {
|
|
|
1912
2002
|
// alias untouched, not a substituted concrete ID.)
|
|
1913
2003
|
_test_mergeStaticCatalog: mergeStaticCatalog,
|
|
1914
2004
|
_test_enrichClaudeModelsWithCatalog: enrichClaudeModelsWithCatalog,
|
|
2005
|
+
// Test seams: drive the in-process query handle over a fake SDK Query and
|
|
2006
|
+
// the worker IPC relay over a fake worker.
|
|
2007
|
+
_test_createQueryHandle: createQueryHandle,
|
|
2008
|
+
_test_createWorkerQueryHandle: createWorkerQueryHandle,
|
|
1915
2009
|
};
|
|
1916
2010
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// What a Codex session can do: the declaration the Codex adapter registers and
|
|
4
|
+
// the capabilities its init advertises. Every key is one of the YOKE
|
|
5
|
+
// capability ledger (lib/yoke/interface.js). A Codex thread is resumed and
|
|
6
|
+
// forked through the app-server; it has no thinking budget, file checkpoints,
|
|
7
|
+
// beta switches or subagents, and no permission modes beyond the approval
|
|
8
|
+
// policy Codex owns, so those are declared off and the UI shows them disabled.
|
|
9
|
+
//
|
|
10
|
+
// Rewinding a thread in place (rewind, rollback) is not offered: the app-server
|
|
11
|
+
// call the console used was removed from the supported releases, and its
|
|
12
|
+
// replacement cannot be made safe against a turn appended while it runs.
|
|
13
|
+
|
|
14
|
+
function codexCapabilities() {
|
|
15
|
+
return {
|
|
16
|
+
thinking: false,
|
|
17
|
+
betas: false,
|
|
18
|
+
effort: true,
|
|
19
|
+
rewind: false,
|
|
20
|
+
fork: true,
|
|
21
|
+
rollback: false,
|
|
22
|
+
sessionResume: true,
|
|
23
|
+
sessionList: false,
|
|
24
|
+
sessionRename: false,
|
|
25
|
+
sessionArchive: false,
|
|
26
|
+
promptSuggestions: true,
|
|
27
|
+
elicitation: true,
|
|
28
|
+
fileCheckpointing: false,
|
|
29
|
+
contextCompacting: false,
|
|
30
|
+
mcpPanel: true,
|
|
31
|
+
backgroundTasks: false,
|
|
32
|
+
steering: false,
|
|
33
|
+
agentInjection: false,
|
|
34
|
+
executionPolicy: true,
|
|
35
|
+
toolPolicy: ["ask", "allow-all"],
|
|
36
|
+
permissionModes: [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { codexCapabilities: codexCapabilities };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Registers the Codex vendor with the YOKE registry. Kept apart from codex.js so
|
|
2
|
+
// that asking the registry which agents exist does not load the adapter; it is
|
|
3
|
+
// required only when an adapter is actually created.
|
|
4
|
+
|
|
5
|
+
var registry = require("../registry");
|
|
6
|
+
var authChecks = require("../auth-checks");
|
|
7
|
+
var codexBinary = require("../codex-binary");
|
|
8
|
+
var codexCapabilities = require("./codex-capabilities").codexCapabilities;
|
|
9
|
+
|
|
10
|
+
// The console ships no Codex: the agent is installed when the user's own Codex
|
|
11
|
+
// resolves and is new enough. When it does not, the picker shows the reason
|
|
12
|
+
// (not installed, too old, an override that points nowhere) and, when one is
|
|
13
|
+
// usable, which binary and version will run.
|
|
14
|
+
function probeCodexInstalled() {
|
|
15
|
+
return codexBinary.describe(codexBinary.resolveCached());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
registry.register({
|
|
19
|
+
id: "codex",
|
|
20
|
+
displayName: "Codex",
|
|
21
|
+
icon: "/codex-avatar.png",
|
|
22
|
+
priority: 20,
|
|
23
|
+
binaryNames: ["codex"],
|
|
24
|
+
probeInstalled: probeCodexInstalled,
|
|
25
|
+
recheck: codexBinary.invalidate,
|
|
26
|
+
checkAuth: authChecks.checkCodexAuth,
|
|
27
|
+
installHint: "Install the Codex CLI (npm install -g @openai/codex), then sign in.",
|
|
28
|
+
loginCommand: "codex login --device-auth",
|
|
29
|
+
// The app-server is not started per OS user, so under per-user isolation the
|
|
30
|
+
// agent is disabled (yoke/index.js, install-probe.js) and never started.
|
|
31
|
+
osUsersSupported: false,
|
|
32
|
+
needsRuntimeEnv: true,
|
|
33
|
+
perProjectRuntime: true,
|
|
34
|
+
activityTokens: true,
|
|
35
|
+
ownedEnvNames: ["OPENAI_API_KEY", "OPENAI_BASE_URL"],
|
|
36
|
+
credentialGroups: [{ id: "openai-endpoint", envNames: ["OPENAI_API_KEY", "OPENAI_BASE_URL"] }],
|
|
37
|
+
nativeInstructionFiles: ["AGENTS.md"],
|
|
38
|
+
interruptMessage: "■ Conversation interrupted - tell the model what to do differently.",
|
|
39
|
+
// Rewinding a Codex thread in place is not offered yet.
|
|
40
|
+
capabilityReasons: {
|
|
41
|
+
rewind: "Rewind is not available for Codex sessions yet",
|
|
42
|
+
rollback: "Rewind is not available for Codex sessions yet",
|
|
43
|
+
},
|
|
44
|
+
capabilities: codexCapabilities(),
|
|
45
|
+
createAdapter: function(opts) { return require("./codex").createCodexAdapter(opts); },
|
|
46
|
+
});
|