@clagentic/console 1.12.0-beta.2 → 1.12.0
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/LICENSES/README.md +5 -0
- package/bin/cli.js +4 -2
- package/lib/agent-roster-ws.js +84 -0
- package/lib/agent-roster.js +312 -0
- package/lib/auth-required-notify.js +42 -0
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +3 -4
- package/lib/build-update-standing.js +34 -14
- package/lib/cli/session-subcommands.js +26 -8
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +25 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +16 -22
- package/lib/notify/core.js +53 -18
- package/lib/notify/payload.js +2 -3
- package/lib/notify/type-registry.js +17 -0
- package/lib/notify/types.js +38 -1
- package/lib/outbound-access.js +12 -1
- package/lib/outbound-entry.js +8 -1
- package/lib/project-connection.js +9 -8
- package/lib/project-filesystem.js +23 -0
- package/lib/project-loop.js +16 -19
- package/lib/project-notifications.js +68 -7
- package/lib/project-sessions.js +9 -0
- package/lib/project-user-mention.js +22 -34
- package/lib/project-user-message.js +208 -4
- package/lib/project-user-shell.js +298 -0
- package/lib/project.js +26 -4
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +24 -1
- package/lib/prompt-source.js +16 -0
- package/lib/public/app.js +31 -2
- package/lib/public/css/agent-messages.css +96 -0
- package/lib/public/css/agent-roster.css +93 -0
- package/lib/public/css/diagnostics.css +1 -1
- package/lib/public/css/input.css +20 -141
- package/lib/public/css/login-panel.css +73 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/sidebar.css +11 -0
- package/lib/public/css/team-panel.css +1 -6
- package/lib/public/css/team-view.css +101 -0
- package/lib/public/css/title-bar.css +10 -0
- package/lib/public/css/user-shell.css +144 -0
- package/lib/public/index.html +41 -7
- package/lib/public/modules/agent-avatar-picker.js +162 -0
- package/lib/public/modules/agent-avatar.js +153 -0
- package/lib/public/modules/agent-messages.js +285 -0
- package/lib/public/modules/agent-roster.js +157 -0
- package/lib/public/modules/app-connection.js +12 -0
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +59 -29
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +22 -7
- package/lib/public/modules/collapsible-text.js +33 -18
- package/lib/public/modules/compaction-state.js +34 -0
- package/lib/public/modules/custom-icons.js +23 -5
- package/lib/public/modules/diagnostics.js +52 -55
- package/lib/public/modules/injected-identity.js +24 -21
- package/lib/public/modules/input.js +176 -15
- package/lib/public/modules/login-panel.js +136 -0
- package/lib/public/modules/login-parser.js +73 -0
- package/lib/public/modules/login-tab.js +66 -0
- package/lib/public/modules/notifications.js +9 -1
- package/lib/public/modules/notify-client.js +114 -21
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/queued-button.js +11 -0
- package/lib/public/modules/scheduled-input-actions.js +12 -4
- package/lib/public/modules/scheduled-outbox.js +230 -0
- package/lib/public/modules/send-now.js +200 -0
- package/lib/public/modules/server-settings.js +47 -1
- package/lib/public/modules/shell-card.js +76 -0
- package/lib/public/modules/shell-line.js +49 -0
- package/lib/public/modules/shell-queue.js +253 -0
- package/lib/public/modules/shell-settings-controls.js +76 -0
- package/lib/public/modules/sidebar-mobile.js +3 -3
- package/lib/public/modules/sidebar-sessions.js +8 -0
- package/lib/public/modules/sidebar-users.js +5 -7
- package/lib/public/modules/team-panel.js +30 -88
- package/lib/public/modules/team-view.js +211 -0
- package/lib/public/modules/terminal-links.js +18 -0
- package/lib/public/modules/terminal.js +65 -4
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +35 -83
- package/lib/public/notify-target.js +70 -10
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +7 -3
- package/lib/queued-chat.js +392 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +122 -43
- package/lib/sdk-message-processor.js +46 -39
- package/lib/server-auth.js +6 -4
- package/lib/server-dm.js +11 -20
- package/lib/server-settings.js +39 -1
- package/lib/server.js +83 -19
- package/lib/session-directory.js +33 -8
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +26 -0
- package/lib/session-input.js +176 -9
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +49 -5
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +7 -0
- package/lib/user-shell-settings.js +105 -0
- package/lib/ws-schema.js +27 -4
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +6 -0
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +218 -6
- package/lib/yoke/adapters/codex-capabilities.js +6 -1
- package/lib/yoke/adapters/codex-user-shell.js +265 -0
- package/lib/yoke/adapters/codex-vendor.js +7 -0
- package/lib/yoke/adapters/codex.js +186 -52
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/registry.js +32 -0
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +1 -1
- package/lib/public/modules/build-notice-gate.js +0 -73
package/lib/sdk-bridge.js
CHANGED
|
@@ -5,6 +5,7 @@ var execFileSync = require("child_process").execFileSync;
|
|
|
5
5
|
var usersModule = require("./users");
|
|
6
6
|
var openSockets = require("./open-sockets");
|
|
7
7
|
var { notifyFor } = require("./notify");
|
|
8
|
+
var { notifyAuthRequired: notifyAuthRequiredCore } = require("./auth-required-notify");
|
|
8
9
|
var { getCodexConfig } = require("./codex-defaults");
|
|
9
10
|
var { isAutoApprovableSegment } = require("./bash-auto-approve");
|
|
10
11
|
var { splitShellSegments, hasUnapprovableShellSyntax, attachSkillDiscovery, discoverSkillsWithMeta, mergeSkillsWithMeta } = require("./sdk-skill-discovery");
|
|
@@ -14,9 +15,11 @@ var { parseFrontmatter, slugifyAgentName, AGENTS_SOURCE_DIR } = require("./agent
|
|
|
14
15
|
var { discoverWorkflows } = require("./sdk-workflow-discovery");
|
|
15
16
|
var { buildEnrichedSlashCommands } = require("./sdk-slash-enrichment");
|
|
16
17
|
var { runPreflight } = require("./settings-preflight");
|
|
18
|
+
var { composeSettings } = require("./session-settings-file");
|
|
17
19
|
var { promptsFor } = require("./prompt-registry");
|
|
18
20
|
var { toolApprovalKind } = require("./prompt-kinds");
|
|
19
21
|
var sessionActivity = require("./session-activity");
|
|
22
|
+
var queuedChat = require("./queued-chat");
|
|
20
23
|
var sessionReclaim = require("./session-reclaim");
|
|
21
24
|
var usageStore = require("./usage-store");
|
|
22
25
|
var { withPromptLabel } = require("./prompt-label");
|
|
@@ -424,7 +427,6 @@ function createSDKBridge(opts) {
|
|
|
424
427
|
}
|
|
425
428
|
var clayPort = opts.clayPort || 2633;
|
|
426
429
|
var clayTls = opts.clayTls || false;
|
|
427
|
-
var clayAuthToken = opts.clayAuthToken || null;
|
|
428
430
|
var onProcessingChanged = opts.onProcessingChanged || function () {};
|
|
429
431
|
|
|
430
432
|
// --- Environment saved in Settings ---
|
|
@@ -582,21 +584,16 @@ function createSDKBridge(opts) {
|
|
|
582
584
|
: "Interrupted.";
|
|
583
585
|
}
|
|
584
586
|
|
|
585
|
-
function notifyAuthRequired(session, title,
|
|
586
|
-
|
|
587
|
-
if (!_nm) return false;
|
|
588
|
-
_nm.notify("auth_required", {
|
|
589
|
-
title: title,
|
|
590
|
-
body: body,
|
|
587
|
+
function notifyAuthRequired(session, title, authLinuxUser, canAutoLogin, loginCommand) {
|
|
588
|
+
return notifyAuthRequiredCore(pushModule, getNotificationsModule(), {
|
|
591
589
|
slug: slug,
|
|
592
|
-
|
|
593
|
-
|
|
590
|
+
session: session,
|
|
591
|
+
title: title,
|
|
594
592
|
vendor: session.vendor || (adapter && adapter.vendor) || "claude",
|
|
595
593
|
loginCommand: loginCommand,
|
|
596
594
|
linuxUser: authLinuxUser,
|
|
597
595
|
canAutoLogin: canAutoLogin,
|
|
598
596
|
});
|
|
599
|
-
return true;
|
|
600
597
|
}
|
|
601
598
|
|
|
602
599
|
function logAuthDecision(stage, session, errDetail, authState) {
|
|
@@ -884,6 +881,7 @@ function createSDKBridge(opts) {
|
|
|
884
881
|
refreshAiTitle: refreshAiTitle,
|
|
885
882
|
onTeamCreate: opts.onTeamCreate || null,
|
|
886
883
|
onTeamDelete: opts.onTeamDelete || null,
|
|
884
|
+
onAgentSeen: opts.onAgentSeen || null,
|
|
887
885
|
opts: opts,
|
|
888
886
|
discoverSkillDirs: discoverSkillDirs,
|
|
889
887
|
mergeSkills: mergeSkills,
|
|
@@ -1097,6 +1095,12 @@ function createSDKBridge(opts) {
|
|
|
1097
1095
|
});
|
|
1098
1096
|
}
|
|
1099
1097
|
|
|
1098
|
+
// Whether the session's vendor declares the additive-settings capability.
|
|
1099
|
+
function supportsSettingsFile(session) {
|
|
1100
|
+
var vendor = sessionCapabilities.effectiveVendorId(sm, session, adapter && adapter.vendor);
|
|
1101
|
+
return sessionCapabilities.capabilitiesFor(sm, vendor).additiveSettings === true;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1100
1104
|
// checkModeFor, with a refusal logged under `what`; true when the mode is allowed.
|
|
1101
1105
|
function modeAllowed(session, mode, what, checkVendor) {
|
|
1102
1106
|
var verdict = checkModeFor(session, mode, checkVendor);
|
|
@@ -1175,16 +1179,8 @@ function createSDKBridge(opts) {
|
|
|
1175
1179
|
}
|
|
1176
1180
|
|
|
1177
1181
|
// Regular tool permission request: send to client and wait
|
|
1178
|
-
//
|
|
1179
|
-
//
|
|
1180
|
-
// resolver (e.g. one whose owning session/sub-agent tracking bug is not
|
|
1181
|
-
// yet known) wedges the turn forever instead of failing closed. Deferred
|
|
1182
|
-
// out of this PR: a uniform timeout here would also auto-deny normal
|
|
1183
|
-
// foreground human-review latency for every non-sub-agent permission
|
|
1184
|
-
// request in the in-process path, which is a broader behavior change than
|
|
1185
|
-
// this hang-fix should bundle silently. Needs a design pass (e.g. scope
|
|
1186
|
-
// the timeout to sub-agent-owned entries only, or make it operator-
|
|
1187
|
-
// configurable) rather than copying the worker's blanket 30s.
|
|
1182
|
+
// The registry bounds the wait (daemon.json promptExpiryMinutes) and
|
|
1183
|
+
// fails closed when it ends.
|
|
1188
1184
|
// The registry creates the notification and dismisses it when the
|
|
1189
1185
|
// prompt settles.
|
|
1190
1186
|
// A prompt raised by a background agent says so, on the card, the banner
|
|
@@ -1447,16 +1443,7 @@ function createSDKBridge(opts) {
|
|
|
1447
1443
|
canAutoLogin: canAutoLogin,
|
|
1448
1444
|
};
|
|
1449
1445
|
sendAndRecord(session, authMsg);
|
|
1450
|
-
|
|
1451
|
-
session,
|
|
1452
|
-
authFacts.title,
|
|
1453
|
-
"Open a terminal, then click the URL and follow the instructions.",
|
|
1454
|
-
authLinuxUser,
|
|
1455
|
-
canAutoLogin,
|
|
1456
|
-
authFacts.loginCommand
|
|
1457
|
-
)) {
|
|
1458
|
-
// chat message already sent above
|
|
1459
|
-
}
|
|
1446
|
+
notifyAuthRequired(session, authFacts.title, authLinuxUser, canAutoLogin, authFacts.loginCommand);
|
|
1460
1447
|
} else {
|
|
1461
1448
|
sendAndRecord(session, { type: "error", text: "Claude process error: " + err.message });
|
|
1462
1449
|
}
|
|
@@ -1474,6 +1461,13 @@ function createSDKBridge(opts) {
|
|
|
1474
1461
|
// Only clean up if the session still references OUR resources.
|
|
1475
1462
|
// A rewind + new startQuery may have already replaced these with
|
|
1476
1463
|
// a newer query — clobbering them would kill the new query.
|
|
1464
|
+
// Chat pushed into this query that it never took in will not be delivered
|
|
1465
|
+
// now that the query is over: the page is told, so it can hand the text
|
|
1466
|
+
// back instead of showing it as queued for ever. Not behind the ownership
|
|
1467
|
+
// check below: after a rewind unlinks this query the session may already
|
|
1468
|
+
// hold a newer one, and this query's messages are still orphans. Only this
|
|
1469
|
+
// query's own messages go; the newer query's are left alone.
|
|
1470
|
+
queuedChat.dropAll(session, myQueryInstance);
|
|
1477
1471
|
if (session.queryInstance === myQueryInstance) {
|
|
1478
1472
|
try {
|
|
1479
1473
|
if (typeof session.queryInstance.close === "function") {
|
|
@@ -1748,7 +1742,6 @@ function createSDKBridge(opts) {
|
|
|
1748
1742
|
linuxUser: linuxUser || undefined,
|
|
1749
1743
|
clayPort: clayPort,
|
|
1750
1744
|
clayTls: clayTls,
|
|
1751
|
-
clayAuthToken: clayAuthToken,
|
|
1752
1745
|
slug: slug,
|
|
1753
1746
|
}), recordInit);
|
|
1754
1747
|
} else if ((!sm.modelsByVendor || !sm.modelsByVendor[vendor]) && typeof vendorAdapter.init === "function") {
|
|
@@ -1757,7 +1750,6 @@ function createSDKBridge(opts) {
|
|
|
1757
1750
|
linuxUser: linuxUser || undefined,
|
|
1758
1751
|
clayPort: clayPort,
|
|
1759
1752
|
clayTls: clayTls,
|
|
1760
|
-
clayAuthToken: clayAuthToken,
|
|
1761
1753
|
slug: slug,
|
|
1762
1754
|
})));
|
|
1763
1755
|
}
|
|
@@ -1839,16 +1831,7 @@ function createSDKBridge(opts) {
|
|
|
1839
1831
|
canAutoLogin: canAutoLogin,
|
|
1840
1832
|
};
|
|
1841
1833
|
sendAndRecord(session, authMsg2);
|
|
1842
|
-
|
|
1843
|
-
session,
|
|
1844
|
-
authFacts2.title,
|
|
1845
|
-
"Open a terminal, then click the URL and follow the instructions.",
|
|
1846
|
-
authLinuxUser,
|
|
1847
|
-
canAutoLogin,
|
|
1848
|
-
authFacts2.loginCommand
|
|
1849
|
-
)) {
|
|
1850
|
-
// chat message already sent above
|
|
1851
|
-
}
|
|
1834
|
+
notifyAuthRequired(session, authFacts2.title, authLinuxUser, canAutoLogin, authFacts2.loginCommand);
|
|
1852
1835
|
sendAndRecord(session, { type: "done", code: 1 });
|
|
1853
1836
|
return;
|
|
1854
1837
|
}
|
|
@@ -1893,6 +1876,28 @@ function createSDKBridge(opts) {
|
|
|
1893
1876
|
return;
|
|
1894
1877
|
}
|
|
1895
1878
|
|
|
1879
|
+
// A session's additive settings file must still be usable on every turn,
|
|
1880
|
+
// a resumed one included: a missing or unreadable file fails the turn
|
|
1881
|
+
// rather than running without it.
|
|
1882
|
+
var sessionSettings = null;
|
|
1883
|
+
if (session.settingsFile) {
|
|
1884
|
+
var loopSettings = session.loopSettings || {};
|
|
1885
|
+
var fileCheck = composeSettings(
|
|
1886
|
+
session.settingsFile,
|
|
1887
|
+
loopSettings.disableAllHooks !== undefined ? { disableAllHooks: loopSettings.disableAllHooks } : null
|
|
1888
|
+
);
|
|
1889
|
+
if (!fileCheck.error) sessionSettings = fileCheck.settings;
|
|
1890
|
+
if (fileCheck.error) {
|
|
1891
|
+
console.warn("[sdk-bridge] " + fileCheck.error + " — refusing the turn for project " + slug + " session " + session.localId);
|
|
1892
|
+
session.isProcessing = false;
|
|
1893
|
+
onProcessingChanged();
|
|
1894
|
+
sendAndRecord(session, { type: "error", text: fileCheck.error });
|
|
1895
|
+
sendAndRecord(session, { type: "done", code: 1 });
|
|
1896
|
+
sm.broadcastSessionList();
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1896
1901
|
// lr-2d91: MemAvailable gate — check before claiming a slot so a rejected
|
|
1897
1902
|
// query never increments the live counter.
|
|
1898
1903
|
if (isNewQuery) {
|
|
@@ -2092,6 +2097,10 @@ function createSDKBridge(opts) {
|
|
|
2092
2097
|
var _injectionVendor = sessionCapabilities.effectiveVendorId(sm, session, sessionAdapter.vendor);
|
|
2093
2098
|
if (session.agentName && sessionCapabilities.capabilitiesFor(sm, _injectionVendor).agentInjection) {
|
|
2094
2099
|
claudeOpts.agent = session.agentName;
|
|
2100
|
+
// The agent the session runs as is an identity the roster records, as named.
|
|
2101
|
+
if (typeof opts.onAgentSeen === "function") {
|
|
2102
|
+
opts.onAgentSeen({ key: session.agentName, source: "session", project: slug, sessionId: String(session.localId) });
|
|
2103
|
+
}
|
|
2095
2104
|
|
|
2096
2105
|
// lr-3ccc78 — on a shared multi-user daemon (linuxUser set), read the
|
|
2097
2106
|
// session owner's own ~/.claude/agents, not the daemon process's
|
|
@@ -2156,6 +2165,8 @@ function createSDKBridge(opts) {
|
|
|
2156
2165
|
if (ls.disableAllHooks !== undefined) {
|
|
2157
2166
|
claudeOpts.settings = Object.assign({}, claudeOpts.settings || {}, { disableAllHooks: ls.disableAllHooks });
|
|
2158
2167
|
}
|
|
2168
|
+
// The session's settings file and the object above both apply (composed before the slot was claimed).
|
|
2169
|
+
if (sessionSettings !== null) claudeOpts.settings = sessionSettings;
|
|
2159
2170
|
|
|
2160
2171
|
var globalMode = session.permissionMode || sm.currentPermissionMode || "default";
|
|
2161
2172
|
// A stored mode (session file, saved default) is checked again here: a
|
|
@@ -2437,6 +2448,69 @@ function createSDKBridge(opts) {
|
|
|
2437
2448
|
}
|
|
2438
2449
|
}
|
|
2439
2450
|
|
|
2451
|
+
// Send-now: deliver a message into the running turn. Resolves
|
|
2452
|
+
// { steered, reason }. An agent whose resolved capabilities lack steering, or
|
|
2453
|
+
// a session with no live query, takes the message down the normal path
|
|
2454
|
+
// (steered false). An agent whose handle has no steerMessage of its own takes
|
|
2455
|
+
// the live input stream, which is where its running turn reads from.
|
|
2456
|
+
function canSteer(session) {
|
|
2457
|
+
var vendor = sessionCapabilities.effectiveVendorId(sm, session, adapter && adapter.vendor);
|
|
2458
|
+
return sessionCapabilities.capabilitiesFor(sm, vendor).steering === true;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
function steerMessage(session, text, images, initiator, messageId) {
|
|
2462
|
+
var canSteer_ = canSteer(session);
|
|
2463
|
+
var handle = session.queryInstance;
|
|
2464
|
+
if (!canSteer_ || !handle || typeof handle.pushMessage !== "function") {
|
|
2465
|
+
pushMessage(session, text, images, initiator, messageId);
|
|
2466
|
+
return Promise.resolve({ steered: false, reason: canSteer_ ? "no-running-turn" : "unsupported" });
|
|
2467
|
+
}
|
|
2468
|
+
bumpLastActivity(session, "push-message", slug);
|
|
2469
|
+
if (typeof handle.steerMessage === "function") {
|
|
2470
|
+
return handle.steerMessage(text, images, initiator, messageId);
|
|
2471
|
+
}
|
|
2472
|
+
handle.pushMessage(text, images, initiator, messageId);
|
|
2473
|
+
return Promise.resolve({ steered: true });
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
// Withdrawing a message pushed into a running turn (queuedMessageCancel).
|
|
2477
|
+
function canCancelQueued(session) {
|
|
2478
|
+
var vendor = sessionCapabilities.effectiveVendorId(sm, session, adapter && adapter.vendor);
|
|
2479
|
+
return sessionCapabilities.capabilitiesFor(sm, vendor).queuedMessageCancel === true;
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
// Resolves true when the message was withdrawn before the agent took it, false
|
|
2483
|
+
// when it was already taken or is unknown, and rejects when the agent cannot
|
|
2484
|
+
// say. A message still buffered between turns (no live query yet) is dropped
|
|
2485
|
+
// from the buffer, which is the same withdrawal.
|
|
2486
|
+
function cancelQueuedMessage(session, messageId) {
|
|
2487
|
+
var handle = session.queryInstance;
|
|
2488
|
+
if (handle && typeof handle.cancelQueuedMessage === "function") {
|
|
2489
|
+
return handle.cancelQueuedMessage(messageId);
|
|
2490
|
+
}
|
|
2491
|
+
var buffered = session.pendingMessages || [];
|
|
2492
|
+
for (var i = 0; i < buffered.length; i++) {
|
|
2493
|
+
if (buffered[i].messageId === messageId) {
|
|
2494
|
+
buffered.splice(i, 1);
|
|
2495
|
+
return Promise.resolve(true);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
return Promise.resolve(false);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
// Send now on a message already pushed into the running query: interrupts the
|
|
2502
|
+
// turn with the agent's queue kept (Stop, the AbortController, is a different
|
|
2503
|
+
// path and is not touched). Resolves { stillQueued: string[]|null }; rejects
|
|
2504
|
+
// when the agent cannot interrupt or no query is live.
|
|
2505
|
+
function interruptKeepingQueued(session) {
|
|
2506
|
+
var handle = session.queryInstance;
|
|
2507
|
+
if (!handle || typeof handle.interruptKeepingQueued !== "function") {
|
|
2508
|
+
return Promise.reject(new Error("This agent cannot interrupt the running turn."));
|
|
2509
|
+
}
|
|
2510
|
+
bumpLastActivity(session, "send-now-interrupt", slug);
|
|
2511
|
+
return handle.interruptKeepingQueued();
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2440
2514
|
function permissionPushTitle(toolName, input) {
|
|
2441
2515
|
if (!input) return "Claude wants to use " + toolName;
|
|
2442
2516
|
var file = input.file_path ? input.file_path.split(/[/\\]/).pop() : "";
|
|
@@ -2500,7 +2574,6 @@ function createSDKBridge(opts) {
|
|
|
2500
2574
|
linuxUser: linuxUser || undefined,
|
|
2501
2575
|
clayPort: clayPort,
|
|
2502
2576
|
clayTls: clayTls,
|
|
2503
|
-
clayAuthToken: clayAuthToken,
|
|
2504
2577
|
slug: slug,
|
|
2505
2578
|
}));
|
|
2506
2579
|
|
|
@@ -2727,10 +2800,16 @@ function createSDKBridge(opts) {
|
|
|
2727
2800
|
forkSession: forkSessionUnified,
|
|
2728
2801
|
startQuery: startQuery,
|
|
2729
2802
|
pushMessage: pushMessage,
|
|
2803
|
+
steerMessage: steerMessage,
|
|
2804
|
+
canSteer: canSteer,
|
|
2805
|
+
canCancelQueued: canCancelQueued,
|
|
2806
|
+
cancelQueuedMessage: cancelQueuedMessage,
|
|
2807
|
+
interruptKeepingQueued: interruptKeepingQueued,
|
|
2730
2808
|
setModel: setModel,
|
|
2731
2809
|
setEffort: setEffort,
|
|
2732
2810
|
setPermissionMode: setPermissionMode,
|
|
2733
2811
|
checkModeFor: checkModeFor,
|
|
2812
|
+
supportsSettingsFile: supportsSettingsFile,
|
|
2734
2813
|
isClaudeProcess: isClaudeProcess,
|
|
2735
2814
|
permissionPushTitle: permissionPushTitle,
|
|
2736
2815
|
permissionPushBody: permissionPushBody,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
var usersModule = require("./users");
|
|
2
|
-
var { pushForSession } = require("./push-audience");
|
|
3
2
|
var { notifyFor } = require("./notify");
|
|
3
|
+
var { notifyAuthRequired } = require("./auth-required-notify");
|
|
4
4
|
var { discoverWorkflows } = require("./sdk-workflow-discovery");
|
|
5
5
|
var { buildEnrichedSlashCommands } = require("./sdk-slash-enrichment");
|
|
6
6
|
var { promptsFor } = require("./prompt-registry");
|
|
7
7
|
var sessionActivity = require("./session-activity");
|
|
8
|
+
var queuedChat = require("./queued-chat");
|
|
8
9
|
var yokeRegistry = require("./yoke").registry;
|
|
9
10
|
var usageStore = require("./usage-store");
|
|
10
11
|
|
|
@@ -43,7 +44,10 @@ function formatTokens(n) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
function compactionNoticeText(ev) {
|
|
46
|
-
|
|
47
|
+
// Name only the trigger the vendor reported; any other value is left unnamed
|
|
48
|
+
// rather than guessed.
|
|
49
|
+
var triggerName = ev.trigger === "manual" ? "manual" : ev.trigger === "auto" ? "automatic" : null;
|
|
50
|
+
var text = "Context compacted" + (triggerName ? " (" + triggerName + ")" : "");
|
|
47
51
|
if (typeof ev.preTokens === "number" && typeof ev.postTokens === "number") {
|
|
48
52
|
text += ": " + formatTokens(ev.preTokens) + " to " + formatTokens(ev.postTokens) + " tokens";
|
|
49
53
|
} else if (typeof ev.preTokens === "number") {
|
|
@@ -66,6 +70,7 @@ function attachMessageProcessor(ctx) {
|
|
|
66
70
|
var refreshAiTitle = ctx.refreshAiTitle || null;
|
|
67
71
|
var onTeamCreate = ctx.onTeamCreate || null;
|
|
68
72
|
var onTeamDelete = ctx.onTeamDelete || null;
|
|
73
|
+
var onAgentSeen = ctx.onAgentSeen || null;
|
|
69
74
|
var opts = ctx.opts;
|
|
70
75
|
var discoverSkillDirs = ctx.discoverSkillDirs;
|
|
71
76
|
var mergeSkills = ctx.mergeSkills;
|
|
@@ -81,6 +86,14 @@ function attachMessageProcessor(ctx) {
|
|
|
81
86
|
sm.sendAndRecord(session, obj);
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
// A Task or Agent dispatch names the sub-agent it starts in subagent_type; the
|
|
90
|
+
// roster records that name exactly as the call gave it.
|
|
91
|
+
function observeSubagent(session, toolName, input) {
|
|
92
|
+
if (!onAgentSeen || !isAgentDispatchTool(toolName) || !input) return;
|
|
93
|
+
if (typeof input.subagent_type !== "string" || !input.subagent_type) return;
|
|
94
|
+
onAgentSeen({ key: input.subagent_type, source: "subagent", project: slug, sessionId: String(session.localId) });
|
|
95
|
+
}
|
|
96
|
+
|
|
84
97
|
// session.taskIdMap is keyed by the Task's tool-use id (the parentToolId
|
|
85
98
|
// task_started carries) and holds the SDK's task id; the registry tracks
|
|
86
99
|
// Tasks by that same tool-use id. At a turn boundary the mapping is kept
|
|
@@ -321,6 +334,11 @@ function attachMessageProcessor(ctx) {
|
|
|
321
334
|
}
|
|
322
335
|
|
|
323
336
|
function processSDKMessage(session, parsed) {
|
|
337
|
+
// The agent names the messages it has taken into the turn on its frames:
|
|
338
|
+
// each chat message tracked as queued is delivered once, here.
|
|
339
|
+
if (parsed.userMessageUuids) queuedChat.consume(session, parsed.userMessageUuids);
|
|
340
|
+
if (parsed.yokeType === "result") queuedChat.markTurnEnd(session);
|
|
341
|
+
|
|
324
342
|
// Timing: log key SDK milestones relative to query start
|
|
325
343
|
if (session._queryStartTs) {
|
|
326
344
|
var _elapsed = Date.now() - session._queryStartTs;
|
|
@@ -476,6 +494,7 @@ function attachMessageProcessor(ctx) {
|
|
|
476
494
|
name: parsed.toolName,
|
|
477
495
|
input: parsed.input || {},
|
|
478
496
|
});
|
|
497
|
+
observeSubagent(session, parsed.toolName, parsed.input);
|
|
479
498
|
|
|
480
499
|
// TeamCreate: record pending so we can extract the teamId from tool_result
|
|
481
500
|
if (parsed.toolName === "TeamCreate" && onTeamCreate) {
|
|
@@ -566,6 +585,7 @@ function attachMessageProcessor(ctx) {
|
|
|
566
585
|
var input = {};
|
|
567
586
|
try { input = JSON.parse(block.inputJson); } catch (e) {}
|
|
568
587
|
sendAndRecord(session, { type: "tool_executing", id: block.id, name: block.name, input: input });
|
|
588
|
+
observeSubagent(session, block.name, input);
|
|
569
589
|
|
|
570
590
|
// lr-6e20f7: acquire an activity token for EVERY Claude tool_use
|
|
571
591
|
// block, not only Task. Claude has turn-wide isProcessing coverage
|
|
@@ -789,7 +809,6 @@ function attachMessageProcessor(ctx) {
|
|
|
789
809
|
var authFacts = authRequiredFacts(loginVendor);
|
|
790
810
|
var authTitle = authFacts.title;
|
|
791
811
|
var loginCommand = authFacts.loginCommand;
|
|
792
|
-
var _nmLogin = getNotificationsModule();
|
|
793
812
|
var authMsg = {
|
|
794
813
|
type: "auth_required",
|
|
795
814
|
text: authTitle,
|
|
@@ -799,19 +818,15 @@ function attachMessageProcessor(ctx) {
|
|
|
799
818
|
canAutoLogin: canAutoLogin,
|
|
800
819
|
};
|
|
801
820
|
sendAndRecord(session, authMsg);
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
linuxUser: authLinuxUser,
|
|
812
|
-
canAutoLogin: canAutoLogin,
|
|
813
|
-
});
|
|
814
|
-
}
|
|
821
|
+
notifyAuthRequired(pushModule, getNotificationsModule(), {
|
|
822
|
+
slug: slug,
|
|
823
|
+
session: session,
|
|
824
|
+
title: authTitle,
|
|
825
|
+
vendor: authFacts.vendor,
|
|
826
|
+
loginCommand: loginCommand,
|
|
827
|
+
linuxUser: authLinuxUser,
|
|
828
|
+
canAutoLogin: canAutoLogin,
|
|
829
|
+
});
|
|
815
830
|
}
|
|
816
831
|
if (isLoginPrompt) {
|
|
817
832
|
// The CLI kept the canned reply as a turn of that session, so the next
|
|
@@ -826,29 +841,18 @@ function attachMessageProcessor(ctx) {
|
|
|
826
841
|
if (_donePreviewText.length > 140) _donePreviewText = _donePreviewText.substring(0, 140) + "...";
|
|
827
842
|
var _doneTitle = session.title || "Claude";
|
|
828
843
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
var _nm = getNotificationsModule();
|
|
842
|
-
if (_nm && !session.loop) {
|
|
843
|
-
_nm.notify("response_done", {
|
|
844
|
-
title: _doneTitle,
|
|
845
|
-
preview: _donePreviewText,
|
|
846
|
-
slug: slug,
|
|
847
|
-
sessionId: session.localId,
|
|
848
|
-
mateId: null,
|
|
849
|
-
ownerId: session.ownerId || null,
|
|
850
|
-
});
|
|
851
|
-
}
|
|
844
|
+
// One notify() per finished turn. The push carries the response preview,
|
|
845
|
+
// so it and the banner go to the session's owner alone (the core's
|
|
846
|
+
// audience rule), and a turn after a turn in the same session replaces
|
|
847
|
+
// the earlier notification. A turn of a loop's own session raises no
|
|
848
|
+
// banner: the loop's end does.
|
|
849
|
+
notifyFor(pushModule, getNotificationsModule()).notify("response_done", {
|
|
850
|
+
slug: slug,
|
|
851
|
+
sessionId: session.localId,
|
|
852
|
+
}, {
|
|
853
|
+
push: { title: _doneTitle, body: _donePreviewText || "Response ready" },
|
|
854
|
+
banner: session.loop ? null : { title: _doneTitle, preview: _donePreviewText },
|
|
855
|
+
}, { ownerId: session.ownerId || null });
|
|
852
856
|
// Reset for next turn in the same query
|
|
853
857
|
bumpLastActivity(session, "turn-result", slug);
|
|
854
858
|
session.turnCount = (session.turnCount || 0) + 1;
|
|
@@ -885,7 +889,10 @@ function attachMessageProcessor(ctx) {
|
|
|
885
889
|
});
|
|
886
890
|
}
|
|
887
891
|
}
|
|
892
|
+
var wasCompacting = !!session.compacting;
|
|
888
893
|
session.compacting = parsed.status === "compacting";
|
|
894
|
+
// The session list entry carries the flag, so the sidebar follows it.
|
|
895
|
+
if (wasCompacting !== session.compacting) sm.broadcastSessionList();
|
|
889
896
|
|
|
890
897
|
} else if (parsed.yokeType === "compact_boundary") {
|
|
891
898
|
// The vendor finished compacting this session's context. Recorded as a
|
package/lib/server-auth.js
CHANGED
|
@@ -5,6 +5,7 @@ var { CONFIG_DIR } = require("./config");
|
|
|
5
5
|
var _isDevMode = require("./config").isDevMode;
|
|
6
6
|
var store = require("./store");
|
|
7
7
|
var audit = require("./audit");
|
|
8
|
+
var { resolveClientAddress } = require("./client-address");
|
|
8
9
|
var { readCappedBody } = require("./utils");
|
|
9
10
|
|
|
10
11
|
// Default token TTL: 30 days. Tokens issued before expiry support was added are
|
|
@@ -36,6 +37,7 @@ function attachAuth(ctx) {
|
|
|
36
37
|
var osUsers = ctx.osUsers;
|
|
37
38
|
var provisionLinuxUser = ctx.provisionLinuxUser;
|
|
38
39
|
var onUserProvisioned = ctx.onUserProvisioned;
|
|
40
|
+
var trustedProxy = !!ctx.trustedProxy;
|
|
39
41
|
|
|
40
42
|
// --- Multi-user auth tokens (persisted to disk) ---
|
|
41
43
|
var TOKENS_NAME = _isDevMode ? "auth-tokens-dev.json" : "auth-tokens.json";
|
|
@@ -372,7 +374,7 @@ function attachAuth(ctx) {
|
|
|
372
374
|
return true;
|
|
373
375
|
}
|
|
374
376
|
if (req.method === "POST") {
|
|
375
|
-
var ip = req.
|
|
377
|
+
var ip = resolveClientAddress(req, trustedProxy).address;
|
|
376
378
|
var remaining = checkPinRateLimit(ip);
|
|
377
379
|
if (remaining !== null) {
|
|
378
380
|
res.writeHead(429, { "Content-Type": "application/json" });
|
|
@@ -505,7 +507,7 @@ function attachAuth(ctx) {
|
|
|
505
507
|
|
|
506
508
|
// Multi-user login
|
|
507
509
|
if (req.method === "POST" && fullUrl === "/auth/login") {
|
|
508
|
-
var ip = req.
|
|
510
|
+
var ip = resolveClientAddress(req, trustedProxy).address;
|
|
509
511
|
// IP-only pre-check (username not yet known — body not read)
|
|
510
512
|
var remaining = checkPinRateLimit(ip);
|
|
511
513
|
if (remaining !== null) {
|
|
@@ -562,7 +564,7 @@ function attachAuth(ctx) {
|
|
|
562
564
|
res.end('{"error":"OTP login not available"}');
|
|
563
565
|
return true;
|
|
564
566
|
}
|
|
565
|
-
var ip = req.
|
|
567
|
+
var ip = resolveClientAddress(req, trustedProxy).address;
|
|
566
568
|
var remaining = checkPinRateLimit(ip);
|
|
567
569
|
if (remaining !== null) {
|
|
568
570
|
res.writeHead(429, { "Content-Type": "application/json" });
|
|
@@ -615,7 +617,7 @@ function attachAuth(ctx) {
|
|
|
615
617
|
res.end('{"error":"OTP login not available"}');
|
|
616
618
|
return true;
|
|
617
619
|
}
|
|
618
|
-
var ip = req.
|
|
620
|
+
var ip = resolveClientAddress(req, trustedProxy).address;
|
|
619
621
|
var remaining = checkPinRateLimit(ip);
|
|
620
622
|
if (remaining !== null) {
|
|
621
623
|
res.writeHead(429, { "Content-Type": "application/json" });
|
package/lib/server-dm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var { notifyFor } = require("./notify");
|
|
2
|
+
|
|
1
3
|
// Strict allow-list for client-supplied dmKey values.
|
|
2
4
|
// Accepts exactly two segments separated by a single colon, each containing
|
|
3
5
|
// only alphanumeric characters, hyphens, and underscores. This prevents path
|
|
@@ -109,28 +111,17 @@ function attachDm(ctx) {
|
|
|
109
111
|
// Send push notification to target user
|
|
110
112
|
var senderName = ws._clagenticUser ? (ws._clagenticUser.displayName || ws._clagenticUser.username || "Someone") : "Someone";
|
|
111
113
|
var preview = (msg.text || "").substring(0, 140);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
type: "dm",
|
|
115
|
-
title: senderName,
|
|
116
|
-
body: preview,
|
|
117
|
-
tag: "dm-" + msg.dmKey,
|
|
118
|
-
dmKey: msg.dmKey,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// Create in-app notification via any project's notifications module
|
|
114
|
+
// The in-app banner store is shared by every project; any project's
|
|
115
|
+
// context reaches it.
|
|
122
116
|
var _nmCtx = null;
|
|
123
117
|
projects.forEach(function (pCtx) { if (!_nmCtx && pCtx.getNotificationsModule) _nmCtx = pCtx; });
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
118
|
+
var _nm = _nmCtx ? _nmCtx.getNotificationsModule() : null;
|
|
119
|
+
// One notify() per message: the push and the banner go to the recipient
|
|
120
|
+
// alone, and a tap opens the conversation with the sender.
|
|
121
|
+
notifyFor(pushModule, _nm).notify("mate_dm", { peerId: userId }, {
|
|
122
|
+
push: { title: senderName, body: preview },
|
|
123
|
+
banner: { senderName: senderName, preview: preview },
|
|
124
|
+
}, { ownerId: targetId });
|
|
134
125
|
return true;
|
|
135
126
|
}
|
|
136
127
|
|
package/lib/server-settings.js
CHANGED
|
@@ -453,6 +453,7 @@ function attachSettings(ctx) {
|
|
|
453
453
|
// POST /api/custom-emoji/:slug — upload a new custom emoji image
|
|
454
454
|
if (req.method === "POST" && fullUrl.startsWith("/api/custom-emoji/")) {
|
|
455
455
|
var postSlug = fullUrl.slice("/api/custom-emoji/".length).split("?")[0];
|
|
456
|
+
var postQuery = new URLSearchParams(fullUrl.indexOf("?") === -1 ? "" : fullUrl.slice(fullUrl.indexOf("?") + 1));
|
|
456
457
|
|
|
457
458
|
// Auth gate
|
|
458
459
|
var muPost = getMultiUserFromReq(req);
|
|
@@ -527,6 +528,32 @@ function attachSettings(ctx) {
|
|
|
527
528
|
return;
|
|
528
529
|
}
|
|
529
530
|
|
|
531
|
+
// ?create=1 is create-only: an existing slug is refused, never replaced.
|
|
532
|
+
// Callers that attach the icon to something of their own (the agent
|
|
533
|
+
// avatar picker) use it so they cannot overwrite an icon another surface
|
|
534
|
+
// already uses. Without it an upload replaces, as before.
|
|
535
|
+
var createOnly = postQuery.get("create") === "1";
|
|
536
|
+
if (createOnly) {
|
|
537
|
+
var slugTaken = false;
|
|
538
|
+
try {
|
|
539
|
+
slugTaken = fs.readdirSync(customEmojiDir).some(function (f) {
|
|
540
|
+
var fExt = path.extname(f).slice(1);
|
|
541
|
+
return !!CUSTOM_EMOJI_CT[fExt] && path.basename(f, "." + fExt) === postSlug;
|
|
542
|
+
});
|
|
543
|
+
} catch (e) {
|
|
544
|
+
slugTaken = false;
|
|
545
|
+
}
|
|
546
|
+
if (slugTaken) {
|
|
547
|
+
audit.log(CUSTOM_EMOJI_UPLOAD_ACTION, Object.assign({}, postActor, {
|
|
548
|
+
target: postSlug,
|
|
549
|
+
metadata: { status: 409, size: postSize, reason: "slug exists (create-only)" },
|
|
550
|
+
}));
|
|
551
|
+
res.writeHead(409, { "Content-Type": "application/json" });
|
|
552
|
+
res.end('{"error":"An icon with that name already exists"}');
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
530
557
|
// Remove any existing file for this slug (different ext)
|
|
531
558
|
try {
|
|
532
559
|
var existingAll = fs.readdirSync(customEmojiDir);
|
|
@@ -541,9 +568,20 @@ function attachSettings(ctx) {
|
|
|
541
568
|
} catch (e) {}
|
|
542
569
|
|
|
543
570
|
try {
|
|
544
|
-
|
|
571
|
+
// "wx" makes create-only hold even if the same name was taken between the
|
|
572
|
+
// check above and this write.
|
|
573
|
+
fs.writeFileSync(candidatePath, raw, createOnly ? { flag: "wx" } : undefined);
|
|
545
574
|
try { fs.chmodSync(candidatePath, 0o644); } catch (e) {}
|
|
546
575
|
} catch (e) {
|
|
576
|
+
if (createOnly && e && e.code === "EEXIST") {
|
|
577
|
+
audit.log(CUSTOM_EMOJI_UPLOAD_ACTION, Object.assign({}, postActor, {
|
|
578
|
+
target: postSlug,
|
|
579
|
+
metadata: { status: 409, size: postSize, reason: "slug exists (create-only)" },
|
|
580
|
+
}));
|
|
581
|
+
res.writeHead(409, { "Content-Type": "application/json" });
|
|
582
|
+
res.end('{"error":"An icon with that name already exists"}');
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
547
585
|
audit.log(CUSTOM_EMOJI_UPLOAD_ACTION, Object.assign({}, postActor, {
|
|
548
586
|
target: postSlug,
|
|
549
587
|
metadata: { status: 500, size: postSize, reason: "write failed: " + e.message },
|