@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
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// One WS entry point for every operator-prompt answer. The registry
|
|
4
|
+
// (lib/prompt-registry.js) settles the prompt; this module maps the wire
|
|
5
|
+
// message onto respond() and owns the session side effects a plan decision
|
|
6
|
+
// carries (permission mode, a fresh session, a feedback message). Those are
|
|
7
|
+
// installed as the registry's resolution effects, so an answer from any path
|
|
8
|
+
// (this handler, the push notification's HTTP route) applies them.
|
|
9
|
+
//
|
|
10
|
+
// prompt_response is the message every current client sends. The older
|
|
11
|
+
// per-kind messages are accepted as aliases so a page loaded before an
|
|
12
|
+
// upgrade can still answer; each alias is declared in lib/ws-schema.js.
|
|
13
|
+
|
|
14
|
+
var { promptsFor } = require("./prompt-registry");
|
|
15
|
+
var promptKinds = require("./prompt-kinds");
|
|
16
|
+
var { mayAnswerPrompt } = require("./prompt-access");
|
|
17
|
+
var { ownValue } = require("./prompt-kinds/codecs");
|
|
18
|
+
var { INITIATORS } = require("./turn-initiator");
|
|
19
|
+
|
|
20
|
+
// alias type -> { toPrompt(msg), kinds it may answer, stale reply type }
|
|
21
|
+
var LEGACY_RESPONSES = {
|
|
22
|
+
permission_response: {
|
|
23
|
+
toPrompt: function (msg) {
|
|
24
|
+
return { requestId: msg.requestId, decision: msg.decision, feedback: msg.feedback, planContent: msg.planContent };
|
|
25
|
+
},
|
|
26
|
+
kinds: ["permission", "plan"],
|
|
27
|
+
staleReplyType: "permission_cancel",
|
|
28
|
+
},
|
|
29
|
+
ask_user_response: {
|
|
30
|
+
toPrompt: function (msg) { return { requestId: msg.toolId, answers: msg.answers }; },
|
|
31
|
+
kinds: ["ask_user"],
|
|
32
|
+
staleReplyType: "prompt_cancel",
|
|
33
|
+
},
|
|
34
|
+
elicitation_response: {
|
|
35
|
+
toPrompt: function (msg) {
|
|
36
|
+
return { requestId: msg.requestId, action: msg.action, content: msg.content };
|
|
37
|
+
},
|
|
38
|
+
kinds: ["elicitation"],
|
|
39
|
+
staleReplyType: "prompt_cancel",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var CONFIG_STATE_DEFAULTS = { effort: "medium", thinking: "adaptive", thinkingBudget: 10000 };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* ctx fields: sm, sdk, send, sendTo, sendToSession, getSessionForWs,
|
|
47
|
+
* onProcessingChanged, ensureProjectAccessForSession
|
|
48
|
+
*/
|
|
49
|
+
function attachPromptResponses(ctx) {
|
|
50
|
+
var sm = ctx.sm;
|
|
51
|
+
var sdk = ctx.sdk;
|
|
52
|
+
var send = ctx.send;
|
|
53
|
+
var sendTo = ctx.sendTo;
|
|
54
|
+
var sendToSession = ctx.sendToSession;
|
|
55
|
+
var getSessionForWs = ctx.getSessionForWs;
|
|
56
|
+
var onProcessingChanged = ctx.onProcessingChanged || function () {};
|
|
57
|
+
var ensureProjectAccessForSession = ctx.ensureProjectAccessForSession;
|
|
58
|
+
|
|
59
|
+
function sendConfigState() {
|
|
60
|
+
send({
|
|
61
|
+
type: "config_state",
|
|
62
|
+
model: sm.currentModel || "",
|
|
63
|
+
mode: sm.currentPermissionMode,
|
|
64
|
+
effort: sm.currentEffort || CONFIG_STATE_DEFAULTS.effort,
|
|
65
|
+
betas: sm.currentBetas || [],
|
|
66
|
+
thinking: sm.currentThinking || CONFIG_STATE_DEFAULTS.thinking,
|
|
67
|
+
thinkingBudget: sm.currentThinkingBudget || CONFIG_STATE_DEFAULTS.thinkingBudget,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// A user message delivered to the session as if typed, starting a query
|
|
72
|
+
// when none is running.
|
|
73
|
+
function deliverUserMessage(session, text) {
|
|
74
|
+
var userMsg = { type: "user_message", text: text };
|
|
75
|
+
sm.recordHistoryEntry(session, userMsg, true);
|
|
76
|
+
sm.appendToSessionFile(session, userMsg);
|
|
77
|
+
sendToSession(session.localId, userMsg);
|
|
78
|
+
if (session.isProcessing) {
|
|
79
|
+
sdk.pushMessage(session, text, undefined, INITIATORS.HUMAN);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
session.isProcessing = true;
|
|
83
|
+
onProcessingChanged();
|
|
84
|
+
session.sentToolResults = {};
|
|
85
|
+
sendToSession(session.localId, { type: "status", status: "processing" });
|
|
86
|
+
if (!session.queryInstance && !session.worker) {
|
|
87
|
+
sdk.startQuery(session, text, undefined, ensureProjectAccessForSession(session), INITIATORS.HUMAN);
|
|
88
|
+
} else {
|
|
89
|
+
sdk.pushMessage(session, text, undefined, INITIATORS.HUMAN);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Ends the current session's turn and starts a fresh session that executes
|
|
94
|
+
// the approved plan with edits auto-accepted. ws is the answering
|
|
95
|
+
// connection, or null for an answer that did not come over a socket.
|
|
96
|
+
function executePlanInFreshContext(ws, session, prompt, planContent) {
|
|
97
|
+
// Deferred to the next tick so the SDK's deny write, scheduled as a
|
|
98
|
+
// microtask by the settle above, completes before the abort; aborting
|
|
99
|
+
// synchronously kills the subprocess mid-write ("Operation aborted").
|
|
100
|
+
session.isProcessing = false;
|
|
101
|
+
onProcessingChanged();
|
|
102
|
+
promptsFor(sm).cancelSession(session, "cleared");
|
|
103
|
+
sm.broadcastSessionList();
|
|
104
|
+
setImmediate(function () {
|
|
105
|
+
if (session.abortController) session.abortController.abort();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
sm.currentPermissionMode = "acceptEdits";
|
|
109
|
+
sendConfigState();
|
|
110
|
+
|
|
111
|
+
var planPrompt;
|
|
112
|
+
if (planContent) {
|
|
113
|
+
planPrompt = "Execute the following plan. Do NOT re-enter plan mode -- just implement it step by step.\n\n" + planContent;
|
|
114
|
+
} else {
|
|
115
|
+
var toolInput = prompt.request.toolInput;
|
|
116
|
+
var planFilePath = (toolInput && toolInput.planFilePath) || "";
|
|
117
|
+
planPrompt = "Execute the plan in " + planFilePath + ". Do NOT re-enter plan mode -- read the plan file and implement it step by step.";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var oldStreamPromise = session.streamPromise || Promise.resolve();
|
|
121
|
+
Promise.race([
|
|
122
|
+
oldStreamPromise,
|
|
123
|
+
new Promise(function (resolve) { setTimeout(resolve, 3000); }),
|
|
124
|
+
]).then(function () {
|
|
125
|
+
try {
|
|
126
|
+
var newSession = sm.createSession(null, ws);
|
|
127
|
+
var userMsg = { type: "user_message", text: planPrompt, planContent: planContent || null };
|
|
128
|
+
sm.recordHistoryEntry(newSession, userMsg, true);
|
|
129
|
+
sm.appendToSessionFile(newSession, userMsg);
|
|
130
|
+
newSession.title = "Plan execution (cleared context)";
|
|
131
|
+
sm.saveSessionFile(newSession);
|
|
132
|
+
sm.broadcastSessionList();
|
|
133
|
+
sendToSession(newSession.localId, userMsg);
|
|
134
|
+
|
|
135
|
+
newSession.isProcessing = true;
|
|
136
|
+
onProcessingChanged();
|
|
137
|
+
newSession.sentToolResults = {};
|
|
138
|
+
sendToSession(newSession.localId, { type: "status", status: "processing" });
|
|
139
|
+
newSession.acceptEditsAfterStart = true;
|
|
140
|
+
sdk.startQuery(newSession, planPrompt, undefined, ensureProjectAccessForSession(newSession), INITIATORS.HUMAN);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.error("[project] Error starting plan execution:", e);
|
|
143
|
+
if (ws) sendTo(ws, { type: "error", text: "Failed to start plan execution: " + (e.message || e) });
|
|
144
|
+
}
|
|
145
|
+
}).catch(function (e) {
|
|
146
|
+
console.error("[project] Plan execution stream wait failed:", e.message || e);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function applyPlanDecision(ws, session, prompt, response) {
|
|
151
|
+
if (response.decision === "allow_accept_edits") {
|
|
152
|
+
sdk.setPermissionMode(session, "acceptEdits");
|
|
153
|
+
sm.currentPermissionMode = "acceptEdits";
|
|
154
|
+
sendConfigState();
|
|
155
|
+
} else if (response.decision === "allow_clear_context") {
|
|
156
|
+
executePlanInFreshContext(ws, session, prompt, response.planContent || "");
|
|
157
|
+
} else if (response.decision === "deny_with_feedback" && response.feedback) {
|
|
158
|
+
// Lets the denied turn wind down before the feedback arrives as the
|
|
159
|
+
// next message.
|
|
160
|
+
setTimeout(function () { deliverUserMessage(session, response.feedback); }, 200);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function mayAnswer(ws, requestId) {
|
|
165
|
+
var found = promptsFor(sm).lookup(requestId, getSessionForWs(ws));
|
|
166
|
+
return mayAnswerPrompt(ws && ws._clagenticUser, found && found.session);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
promptsFor(sm).onResolved(function (outcome, responder) {
|
|
170
|
+
if (outcome.kind === "plan" && outcome.session) {
|
|
171
|
+
applyPlanDecision(responder, outcome.session, outcome.prompt, outcome.response);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// A browser-extension command belongs to the socket it was sent to, which
|
|
176
|
+
// answers with extension_result (project-user-message.js): a prompt_response
|
|
177
|
+
// naming one is no answer from anyone who could give it.
|
|
178
|
+
function answer(ws, msg, kinds, staleReplyType) {
|
|
179
|
+
var answerable = kinds.every(promptKinds.operatorMayAnswer) && mayAnswer(ws, msg.requestId);
|
|
180
|
+
var outcome = answerable
|
|
181
|
+
? promptsFor(sm).respond(msg.requestId, msg, { session: getSessionForWs(ws), kinds: kinds, responder: ws })
|
|
182
|
+
: { status: "stale" };
|
|
183
|
+
if (outcome.status === "resolved") return;
|
|
184
|
+
// Refused as it stands: still pending, so re-offer it to the responder,
|
|
185
|
+
// whose card goes back to answerable instead of waiting out its ack.
|
|
186
|
+
if (outcome.status === "invalid") {
|
|
187
|
+
if (outcome.pending) sendTo(ws, outcome.pending);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
// Gone: answered elsewhere, ended with its turn or query, or never
|
|
191
|
+
// existed. Tell the responder so its card stops looking actionable; the
|
|
192
|
+
// registry retires any banner offering it.
|
|
193
|
+
var reply = { type: staleReplyType, requestId: msg.requestId, reason: "stale" };
|
|
194
|
+
if (staleReplyType === "prompt_cancel" && kinds.length === 1) reply.kind = kinds[0];
|
|
195
|
+
sendTo(ws, reply);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Returns true when msg was a prompt answer (handled). */
|
|
199
|
+
function handlePromptMessage(ws, msg) {
|
|
200
|
+
if (msg.type === "prompt_response") {
|
|
201
|
+
// The kind is required: a response is only applied to the kind it was
|
|
202
|
+
// written for.
|
|
203
|
+
answer(ws, msg, [msg.kind], "prompt_cancel");
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
var legacy = ownValue(LEGACY_RESPONSES, msg.type);
|
|
207
|
+
if (legacy) {
|
|
208
|
+
answer(ws, legacy.toPrompt(msg), legacy.kinds, legacy.staleReplyType);
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return { handlePromptMessage: handlePromptMessage };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = { attachPromptResponses: attachPromptResponses };
|