@clagentic/console 1.11.0 → 1.12.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/README.md +1 -0
- package/bin/cli.js +14 -2
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +31 -7
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/duration.js +27 -0
- package/lib/cli/ipc-subcommands.js +26 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +38 -7
- package/lib/daemon.js +26 -0
- package/lib/notification-prefs.js +257 -0
- package/lib/notify/core.js +175 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +63 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +64 -0
- package/lib/notify/types.js +20 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +74 -0
- package/lib/outbound-entry.js +109 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +40 -1
- package/lib/project-filesystem.js +20 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +25 -13
- package/lib/project-notifications.js +206 -42
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +30 -1
- package/lib/project.js +15 -1
- package/lib/prompt-registry.js +92 -24
- package/lib/prompt-reminders.js +282 -0
- package/lib/prompt-source.js +43 -8
- package/lib/public/app.js +1 -0
- package/lib/public/css/diagnostics.css +28 -0
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +93 -0
- package/lib/public/css/menus.css +22 -0
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/server-settings.css +24 -0
- package/lib/public/css/sidebar.css +24 -0
- package/lib/public/index.html +6 -0
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/app-connection.js +22 -5
- package/lib/public/modules/app-header.js +2 -0
- package/lib/public/modules/app-messages.js +6 -2
- package/lib/public/modules/app-notifications.js +65 -40
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +12 -6
- package/lib/public/modules/app-rendering.js +26 -3
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +77 -0
- package/lib/public/modules/diagnostics.js +9 -2
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/keep-alive.js +66 -0
- package/lib/public/modules/notification-prefs.js +151 -0
- package/lib/public/modules/notify-client.js +153 -0
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-reminders-setting.js +13 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/server-settings.js +3 -0
- package/lib/public/modules/sidebar-mobile.js +8 -0
- package/lib/public/modules/sidebar-sessions.js +27 -0
- package/lib/public/modules/terminal-links.js +175 -0
- package/lib/public/modules/terminal.js +19 -103
- package/lib/public/notify-sw-logic.js +300 -0
- package/lib/public/notify-target.js +97 -0
- package/lib/public/sw.js +15 -62
- package/lib/push-audience.js +84 -0
- package/lib/push.js +87 -20
- package/lib/runtime-env.js +1 -0
- package/lib/sdk-bridge.js +83 -36
- package/lib/sdk-message-processor.js +148 -49
- package/lib/sender-ref.js +3 -0
- package/lib/server.js +80 -4
- package/lib/session-directory.js +6 -4
- package/lib/session-input-ipc.js +11 -1
- package/lib/session-input.js +95 -14
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/sessions.js +58 -4
- package/lib/usage-store.js +403 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +13 -2
- package/lib/yoke/adapters/claude-vendor.js +11 -1
- package/lib/yoke/adapters/claude.js +17 -0
- package/lib/yoke/adapters/codex.js +5 -1
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +8 -1
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
package/lib/pending-prompts.js
CHANGED
|
@@ -24,11 +24,9 @@ function ageSeconds(createdAt, now) {
|
|
|
24
24
|
return Math.max(0, Math.floor((now - createdAt) / 1000));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
function pendingPrompts(session, now) {
|
|
31
|
-
var out = [];
|
|
27
|
+
// Calls visit(id, record, kind) for every operator-facing prompt (kind.journal,
|
|
28
|
+
// the ones a banner is raised for) a session holds in the registry's maps.
|
|
29
|
+
function eachPending(session, visit) {
|
|
32
30
|
STORES.forEach(function (store) {
|
|
33
31
|
var map = session && session[store];
|
|
34
32
|
if (!map) return;
|
|
@@ -37,19 +35,36 @@ function pendingPrompts(session, now) {
|
|
|
37
35
|
if (!record) return;
|
|
38
36
|
var kind = promptKinds.kindOfRecord(record, store);
|
|
39
37
|
if (!kind || !kind.journal) return;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
visit(id, record, kind);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// How many operator prompts the session waits on. Cheap: no summary is built,
|
|
44
|
+
// so the session list can ask it of every session on every broadcast.
|
|
45
|
+
function countPending(session) {
|
|
46
|
+
var n = 0;
|
|
47
|
+
eachPending(session, function () { n += 1; });
|
|
48
|
+
return n;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Returns [{ requestId, kind, tool, summary, ageSeconds }], oldest first;
|
|
52
|
+
// empty when the session waits on nothing.
|
|
53
|
+
function pendingPrompts(session, now) {
|
|
54
|
+
var out = [];
|
|
55
|
+
eachPending(session, function (id, record, kind) {
|
|
56
|
+
out.push({
|
|
57
|
+
createdAt: typeof record.createdAt === "number" ? record.createdAt : 0,
|
|
58
|
+
view: {
|
|
59
|
+
requestId: id,
|
|
60
|
+
kind: kind.name,
|
|
61
|
+
tool: typeof record.toolName === "string" ? record.toolName : null,
|
|
62
|
+
summary: TOOL_KINDS[kind.name] ? summarize(record.toolName, record.toolInput) : "",
|
|
63
|
+
ageSeconds: ageSeconds(record.createdAt, now),
|
|
64
|
+
},
|
|
50
65
|
});
|
|
51
66
|
});
|
|
52
67
|
return out.sort(function (a, b) { return a.createdAt - b.createdAt; }).map(function (e) { return e.view; });
|
|
53
68
|
}
|
|
54
69
|
|
|
55
|
-
module.exports = { pendingPrompts: pendingPrompts };
|
|
70
|
+
module.exports = { pendingPrompts: pendingPrompts, countPending: countPending };
|
|
@@ -5,11 +5,15 @@ var userPresence = require("./user-presence");
|
|
|
5
5
|
var { authOf } = require("./project-access");
|
|
6
6
|
var { getCodexConfig } = require("./codex-defaults");
|
|
7
7
|
var { promptsFor } = require("./prompt-registry");
|
|
8
|
+
var { snapshotLivePrompts } = require("./notify/live-prompts");
|
|
8
9
|
var { settingsMessage } = require("./permission-settings");
|
|
9
10
|
var { effectiveSessionMode } = require("./sessions");
|
|
10
11
|
var sessionReclaim = require("./session-reclaim");
|
|
11
12
|
var clientBuildId = require("./client-build-id");
|
|
12
13
|
var { buildVendorRegistryMessage } = require("./vendor-registry-message");
|
|
14
|
+
var { logField } = require("./log-field");
|
|
15
|
+
var { clientIdOf } = require("./prompt-source");
|
|
16
|
+
var openSockets = require("./open-sockets");
|
|
13
17
|
// detectLite is cached per-project in project.js and passed via ctx.liteStatus.
|
|
14
18
|
// This import is retained only for backward compat if ctx.liteStatus is absent.
|
|
15
19
|
var { detectLite } = require("./lite-detect");
|
|
@@ -181,7 +185,14 @@ function attachConnection(ctx) {
|
|
|
181
185
|
sendTo(ws, { type: "loop_registry_updated", records: getHubSchedules(_userId, authOf(ws)) });
|
|
182
186
|
_loop.sendConnectionState(ws);
|
|
183
187
|
if (_mcp) _mcp.sendConnectionState(ws);
|
|
184
|
-
if (_notifications)
|
|
188
|
+
if (_notifications) {
|
|
189
|
+
_notifications.sendConnectionState(ws, sendTo, snapshotLivePrompts({
|
|
190
|
+
slug: slug,
|
|
191
|
+
sessions: sm.sessions,
|
|
192
|
+
prompts: promptsFor(sm),
|
|
193
|
+
viewerId: wsUser ? wsUser.id : null,
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
185
196
|
// A client that connects is told the current offer state: the held offer, or
|
|
186
197
|
// an explicit retraction when none stands, so a missed retraction cannot
|
|
187
198
|
// leave a dead restart action on screen.
|
|
@@ -306,6 +317,16 @@ function attachConnection(ctx) {
|
|
|
306
317
|
}
|
|
307
318
|
broadcastPresence();
|
|
308
319
|
|
|
320
|
+
// One journal line per socket, so a tab holding more than one is visible
|
|
321
|
+
// from the daemon. Identifiers only: never the ticket, cookies, headers or
|
|
322
|
+
// remote address. The client id is the same label prompt sources carry.
|
|
323
|
+
ws._clagenticConnectedAt = Date.now();
|
|
324
|
+
openSockets.opened(slug);
|
|
325
|
+
console.log("[connection] connect: project=" + logField(slug)
|
|
326
|
+
+ " client=" + logField(clientIdOf(ws))
|
|
327
|
+
+ " user=" + logField(_userId)
|
|
328
|
+
+ " session=" + logField(ws._clagenticActiveSession));
|
|
329
|
+
|
|
309
330
|
ws.on("message", function (raw) {
|
|
310
331
|
var msg;
|
|
311
332
|
try { msg = JSON.parse(raw.toString()); } catch (e) { return; }
|
|
@@ -329,7 +350,24 @@ function attachConnection(ctx) {
|
|
|
329
350
|
});
|
|
330
351
|
}
|
|
331
352
|
|
|
353
|
+
// Logs the disconnect and leaves the open-socket count, once per socket, so
|
|
354
|
+
// a repeated close cannot drive the count below the truth. Project destroy
|
|
355
|
+
// calls it too: its ws.close() only starts the handshake, and the close
|
|
356
|
+
// event can arrive long after the project is gone.
|
|
357
|
+
function recordDisconnect(ws) {
|
|
358
|
+
if (!ws._clagenticConnectedAt) return;
|
|
359
|
+
var _seconds = Math.round((Date.now() - ws._clagenticConnectedAt) / 1000);
|
|
360
|
+
ws._clagenticConnectedAt = 0;
|
|
361
|
+
openSockets.closed(slug);
|
|
362
|
+
console.log("[connection] disconnect: project=" + logField(slug)
|
|
363
|
+
+ " client=" + logField(clientIdOf(ws))
|
|
364
|
+
+ " user=" + logField(ws._clagenticUser ? ws._clagenticUser.id : null)
|
|
365
|
+
+ " session=" + logField(ws._clagenticActiveSession)
|
|
366
|
+
+ " duration_s=" + _seconds);
|
|
367
|
+
}
|
|
368
|
+
|
|
332
369
|
function handleDisconnection(ws) {
|
|
370
|
+
recordDisconnect(ws);
|
|
333
371
|
if (ws._clagenticActiveSession) {
|
|
334
372
|
var dcPresKey = ws._clagenticUser ? ws._clagenticUser.id : "_default";
|
|
335
373
|
var dcExisting = userPresence.getPresence(slug, dcPresKey);
|
|
@@ -347,6 +385,7 @@ function attachConnection(ctx) {
|
|
|
347
385
|
return {
|
|
348
386
|
handleConnection: handleConnection,
|
|
349
387
|
handleDisconnection: handleDisconnection,
|
|
388
|
+
recordDisconnect: recordDisconnect,
|
|
350
389
|
};
|
|
351
390
|
}
|
|
352
391
|
|
|
@@ -2,6 +2,9 @@ var fs = require("fs");
|
|
|
2
2
|
var path = require("path");
|
|
3
3
|
var fileScope = require("./project-file-scope");
|
|
4
4
|
var projectGit = require("./project-git");
|
|
5
|
+
var claudeSettingsEnv = require("./claude-settings-env");
|
|
6
|
+
var runtimeEnv = require("./runtime-env");
|
|
7
|
+
var { REAL_HOME } = require("./config");
|
|
5
8
|
|
|
6
9
|
// Settings that act on the whole machine (not on this project), so the
|
|
7
10
|
// per-user projectSettings permission is not enough: administrators only.
|
|
@@ -56,6 +59,18 @@ function attachFilesystem(ctx) {
|
|
|
56
59
|
var IMAGE_EXTS = ctx.IMAGE_EXTS;
|
|
57
60
|
var fileAccess = ctx.fileAccess;
|
|
58
61
|
|
|
62
|
+
// Names a Settings text sets that the daemon user's Claude settings file
|
|
63
|
+
// sets too; the file wins at the runtime, so the editor says so. The one file
|
|
64
|
+
// is located from the daemon's own environment (claude-settings-env.js), never
|
|
65
|
+
// from the text, and os-users mode reads none. configDirNote tells the editor
|
|
66
|
+
// to say the check covers that file only when the text sets CLAUDE_CONFIG_DIR.
|
|
67
|
+
function shadowInfoFor(text) {
|
|
68
|
+
return {
|
|
69
|
+
shadowedKeys: claudeSettingsEnv.shadowedKeys(text, { homeDir: REAL_HOME, osUsers: !!osUsers }),
|
|
70
|
+
shadowConfigDirNote: claudeSettingsEnv.setsConfigDir(text),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
// In multi-user mode the project's environment text applies to the project
|
|
60
75
|
// owner's sessions (lib/runtime-env.js projectEnvApplies), so only the owner
|
|
61
76
|
// or an administrator may read or change it: anyone else would be writing
|
|
@@ -242,10 +257,10 @@ function attachFilesystem(ctx) {
|
|
|
242
257
|
} catch (e) {}
|
|
243
258
|
// appliesTo tells the Settings page whom the text reaches; canEdit that
|
|
244
259
|
// this user may see and change it. No value goes to a user who may not.
|
|
245
|
-
sendTo(ws, {
|
|
260
|
+
sendTo(ws, Object.assign({
|
|
246
261
|
type: "project_env_result", slug: slug, envrc: envrc, hasEnvrc: hasEnvrc,
|
|
247
262
|
appliesTo: envMultiUser ? "owner" : "everyone", canEdit: canManageEnv,
|
|
248
|
-
});
|
|
263
|
+
}, canManageEnv ? shadowInfoFor(envrc) : { shadowedKeys: [] }));
|
|
249
264
|
return true;
|
|
250
265
|
}
|
|
251
266
|
|
|
@@ -266,7 +281,7 @@ function attachFilesystem(ctx) {
|
|
|
266
281
|
return true;
|
|
267
282
|
}
|
|
268
283
|
var setResult = opts.onSetProjectEnv(envSlug, envText);
|
|
269
|
-
sendTo(ws, { type: "set_project_env_result", ok: setResult.ok, slug: slug, error: setResult.error });
|
|
284
|
+
sendTo(ws, Object.assign({ type: "set_project_env_result", ok: setResult.ok, slug: slug, error: setResult.error }, setResult.ok ? shadowInfoFor(envText) : { shadowedKeys: [] }));
|
|
270
285
|
} else {
|
|
271
286
|
sendTo(ws, { type: "set_project_env_result", ok: false, error: "Not supported" });
|
|
272
287
|
}
|
|
@@ -307,7 +322,7 @@ function attachFilesystem(ctx) {
|
|
|
307
322
|
var sharedResult = opts.onGetSharedEnv();
|
|
308
323
|
sharedEnvrc = sharedResult.envrc || "";
|
|
309
324
|
}
|
|
310
|
-
sendTo(ws, { type: "shared_env_result", envrc: sharedEnvrc });
|
|
325
|
+
sendTo(ws, Object.assign({ type: "shared_env_result", envrc: sharedEnvrc }, shadowInfoFor(sharedEnvrc)));
|
|
311
326
|
return true;
|
|
312
327
|
}
|
|
313
328
|
|
|
@@ -323,7 +338,7 @@ function attachFilesystem(ctx) {
|
|
|
323
338
|
return true;
|
|
324
339
|
}
|
|
325
340
|
var sharedSetResult = opts.onSetSharedEnv(msg.envrc || "");
|
|
326
|
-
sendTo(ws, { type: "set_shared_env_result", ok: sharedSetResult.ok, error: sharedSetResult.error });
|
|
341
|
+
sendTo(ws, Object.assign({ type: "set_shared_env_result", ok: sharedSetResult.ok, error: sharedSetResult.error }, sharedSetResult.ok ? shadowInfoFor(msg.envrc || "") : { shadowedKeys: [] }));
|
|
327
342
|
} else {
|
|
328
343
|
sendTo(ws, { type: "set_shared_env_result", ok: false, error: "Not supported" });
|
|
329
344
|
}
|
package/lib/project-http.js
CHANGED
|
@@ -205,7 +205,15 @@ function attachHTTP(ctx) {
|
|
|
205
205
|
if (req.method === "POST" && urlPath === "/api/push-subscribe") {
|
|
206
206
|
parseJsonBody(req).then(function (body) {
|
|
207
207
|
var sub = body.subscription || body;
|
|
208
|
-
|
|
208
|
+
// The user is resolved as the top-level route resolves it (the login
|
|
209
|
+
// cookie, set on req by lib/server.js); a subscription stored without
|
|
210
|
+
// one reaches no user-targeted push.
|
|
211
|
+
var pushUser = req._clagenticUser || null;
|
|
212
|
+
if (pushModule && pushModule.addSubscription(sub, body.replaceEndpoint, pushUser ? pushUser.id : null) === false && sub && sub.endpoint) {
|
|
213
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
214
|
+
res.end('{"error":"sign in to enable push notifications"}');
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
209
217
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
210
218
|
res.end('{"ok":true}');
|
|
211
219
|
}).catch(function () {
|
package/lib/project-loop.js
CHANGED
|
@@ -3,8 +3,10 @@ var path = require("path");
|
|
|
3
3
|
var crypto = require("crypto");
|
|
4
4
|
var { execFileSync } = require("child_process");
|
|
5
5
|
var { createLoopRegistry } = require("./scheduler");
|
|
6
|
+
var sessionLiveness = require("./session-liveness");
|
|
6
7
|
var store = require("./store");
|
|
7
8
|
var usersModule = require("./users");
|
|
9
|
+
var { pushForSession } = require("./push-audience");
|
|
8
10
|
var { writeHandoff, buildHandoffPreamble } = require("./loop-handoff");
|
|
9
11
|
var { authOf } = require("./project-access");
|
|
10
12
|
var { INITIATORS } = require("./turn-initiator");
|
|
@@ -101,8 +103,21 @@ function attachLoop(ctx) {
|
|
|
101
103
|
// runNextIteration(), and on stop/finish so nothing leaks into a
|
|
102
104
|
// future run.
|
|
103
105
|
pendingUserMessages: [],
|
|
106
|
+
// The browser tab that sent loop_start. In memory only, never persisted:
|
|
107
|
+
// a cron, schedule, rerun or resume has no starter. Runner sessions switch
|
|
108
|
+
// only this tab, and only while it is still connected.
|
|
109
|
+
starterWs: null,
|
|
104
110
|
};
|
|
105
111
|
|
|
112
|
+
// createSession arguments for a session the runner creates (iteration or
|
|
113
|
+
// judge). A connected starter tab is the one tab that follows the loop;
|
|
114
|
+
// with no starter, or one that has gone, nothing switches.
|
|
115
|
+
function runnerSessionArgs() {
|
|
116
|
+
var starter = loopState.starterWs;
|
|
117
|
+
if (starter && starter.readyState === 1) return [undefined, starter];
|
|
118
|
+
return [{ activate: false }];
|
|
119
|
+
}
|
|
120
|
+
|
|
106
121
|
function loopDir() {
|
|
107
122
|
var id = loopState.loopFilesId || loopState.loopId;
|
|
108
123
|
if (!id) return null;
|
|
@@ -459,6 +474,7 @@ function attachLoop(ctx) {
|
|
|
459
474
|
loopState.settings = loopConfig.settings || null;
|
|
460
475
|
loopState.startedAt = Date.now();
|
|
461
476
|
loopState.pendingUserMessages = [];
|
|
477
|
+
loopState.starterWs = loopOpts.starterWs || null;
|
|
462
478
|
saveLoopState();
|
|
463
479
|
|
|
464
480
|
stopClaudeDirWatch();
|
|
@@ -489,7 +505,7 @@ function attachLoop(ctx) {
|
|
|
489
505
|
return;
|
|
490
506
|
}
|
|
491
507
|
|
|
492
|
-
var session = sm.createSession();
|
|
508
|
+
var session = sm.createSession.apply(sm, runnerSessionArgs());
|
|
493
509
|
var loopSource = loopRegistry.getById(loopState.loopId);
|
|
494
510
|
var loopName = (loopState.wizardData && loopState.wizardData.name) || (loopSource && loopSource.name) || "";
|
|
495
511
|
var loopSourceTag = (loopSource && loopSource.source) || null;
|
|
@@ -670,7 +686,7 @@ function attachLoop(ctx) {
|
|
|
670
686
|
"- PASS: [brief explanation]\n" +
|
|
671
687
|
"- FAIL: [brief explanation of what is still missing]";
|
|
672
688
|
|
|
673
|
-
var judgeSession = sm.createSession();
|
|
689
|
+
var judgeSession = sm.createSession.apply(sm, runnerSessionArgs());
|
|
674
690
|
var judgeSource = loopRegistry.getById(loopState.loopId);
|
|
675
691
|
var judgeName = (loopState.wizardData && loopState.wizardData.name) || (judgeSource && judgeSource.name) || "";
|
|
676
692
|
var judgeSourceTag = (judgeSource && judgeSource.source) || null;
|
|
@@ -822,6 +838,7 @@ function attachLoop(ctx) {
|
|
|
822
838
|
loopState.stopping = false;
|
|
823
839
|
loopState.currentSessionId = null;
|
|
824
840
|
loopState.judgeSessionId = null;
|
|
841
|
+
loopState.starterWs = null;
|
|
825
842
|
// Drop any messages queued but never delivered to an iteration — the loop
|
|
826
843
|
// is done, so there is no future boundary to deliver them at (lr-e31b).
|
|
827
844
|
var _hadUndelivered = loopState.pendingUserMessages && loopState.pendingUserMessages.length > 0;
|
|
@@ -860,12 +877,8 @@ function attachLoop(ctx) {
|
|
|
860
877
|
var _loopDonePayload = {
|
|
861
878
|
type: "done", slug: slug, title: "Loop Complete", body: _finishBody, tag: "ralph-loop-done",
|
|
862
879
|
};
|
|
863
|
-
//
|
|
864
|
-
|
|
865
|
-
pushModule.sendPushToUser(_loopOwnerUserId, _loopDonePayload);
|
|
866
|
-
} else {
|
|
867
|
-
pushModule.sendPush(_loopDonePayload);
|
|
868
|
-
}
|
|
880
|
+
// Body carries iteration status: loop owner only, never a blind broadcast.
|
|
881
|
+
pushForSession(pushModule, _loopOwnerUserId, _loopDonePayload);
|
|
869
882
|
}
|
|
870
883
|
|
|
871
884
|
if (notificationsModule) {
|
|
@@ -992,7 +1005,7 @@ function attachLoop(ctx) {
|
|
|
992
1005
|
fs.writeFileSync(ljPath, JSON.stringify(lj, null, 2), "utf8");
|
|
993
1006
|
}
|
|
994
1007
|
}
|
|
995
|
-
startLoop({ maxIterations: msg.maxIterations });
|
|
1008
|
+
startLoop({ maxIterations: msg.maxIterations, starterWs: ws });
|
|
996
1009
|
return true;
|
|
997
1010
|
}
|
|
998
1011
|
|
|
@@ -1158,12 +1171,11 @@ function attachLoop(ctx) {
|
|
|
1158
1171
|
"## Task\n" + (wData.task || "") +
|
|
1159
1172
|
"\n\n## Loop Directory\n" + lDir;
|
|
1160
1173
|
|
|
1161
|
-
var judgeCraftSession = sm.createSession();
|
|
1174
|
+
var judgeCraftSession = sm.createSession(undefined, ws);
|
|
1162
1175
|
judgeCraftSession.title = (isRalphCraft ? "Ralph" : "Task") + (craftName ? " " + craftName : "") + " Crafting";
|
|
1163
1176
|
judgeCraftSession.ralphCraftingMode = true;
|
|
1164
1177
|
judgeCraftSession.loop = { active: true, iteration: 0, role: "crafting", loopId: newLoopId, name: craftName, source: recordSource, startedAt: loopState.startedAt };
|
|
1165
1178
|
sm.saveSessionFile(judgeCraftSession);
|
|
1166
|
-
sm.switchSession(judgeCraftSession.localId, null, hydrateImageRefs);
|
|
1167
1179
|
loopState.craftingSessionId = judgeCraftSession.localId;
|
|
1168
1180
|
|
|
1169
1181
|
loopRegistry.updateRecord(newLoopId, { craftingSessionId: judgeCraftSession.localId });
|
|
@@ -1234,12 +1246,11 @@ function attachLoop(ctx) {
|
|
|
1234
1246
|
}
|
|
1235
1247
|
|
|
1236
1248
|
// Create a new session for crafting
|
|
1237
|
-
var craftingSession = sm.createSession();
|
|
1249
|
+
var craftingSession = sm.createSession(undefined, ws);
|
|
1238
1250
|
craftingSession.title = (isRalphCraft ? "Ralph" : "Task") + (craftName ? " " + craftName : "") + " Crafting";
|
|
1239
1251
|
craftingSession.ralphCraftingMode = true;
|
|
1240
1252
|
craftingSession.loop = { active: true, iteration: 0, role: "crafting", loopId: newLoopId, name: craftName, source: recordSource, startedAt: loopState.startedAt };
|
|
1241
1253
|
sm.saveSessionFile(craftingSession);
|
|
1242
|
-
sm.switchSession(craftingSession.localId, null, hydrateImageRefs);
|
|
1243
1254
|
loopState.craftingSessionId = craftingSession.localId;
|
|
1244
1255
|
|
|
1245
1256
|
// Store crafting session ID in the registry record
|
|
@@ -1466,6 +1477,7 @@ function attachLoop(ctx) {
|
|
|
1466
1477
|
// needs it to distinguish "my activity" from "another user's
|
|
1467
1478
|
// activity" the same way session_list already does.
|
|
1468
1479
|
ownerId: s.ownerId || null,
|
|
1480
|
+
waiting: sessionLiveness.activityOf(s) === sessionLiveness.ACTIVITY.WAITING,
|
|
1469
1481
|
};
|
|
1470
1482
|
});
|
|
1471
1483
|
sendTo(ws, { type: "hub_recent_sessions", sessions: mapped });
|