@songsid/agend 2.4.0-beta.15 → 2.4.0-beta.17
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/dist/accounts-profiles.d.ts +1 -1
- package/dist/accounts-view.d.ts +3 -0
- package/dist/accounts-view.js.map +1 -1
- package/dist/auth-api.js +6 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +15 -1
- package/dist/backend/claude-code.js +64 -8
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/kiro.js +6 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +8 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-command.d.ts +4 -2
- package/dist/backend-command.js +3 -0
- package/dist/backend-command.js.map +1 -1
- package/dist/browser-backend-signins.d.ts +1 -0
- package/dist/browser-backend-signins.js +3 -1
- package/dist/browser-backend-signins.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/classic-channel-manager.d.ts +1 -0
- package/dist/classic-channel-manager.js +4 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/claude-credential-change.d.ts +22 -0
- package/dist/claude-credential-change.js +47 -0
- package/dist/claude-credential-change.js.map +1 -0
- package/dist/claude-credential-launch.d.ts +63 -0
- package/dist/claude-credential-launch.js +315 -0
- package/dist/claude-credential-launch.js.map +1 -0
- package/dist/claude-credential-runner.d.ts +1 -0
- package/dist/claude-credential-runner.js +56 -0
- package/dist/claude-credential-runner.js.map +1 -0
- package/dist/claude-credential-vault.d.ts +57 -0
- package/dist/claude-credential-vault.js +277 -0
- package/dist/claude-credential-vault.js.map +1 -0
- package/dist/claude-request-observation.d.ts +7 -0
- package/dist/claude-request-observation.js +26 -0
- package/dist/claude-request-observation.js.map +1 -0
- package/dist/claude-setup-token-transport.d.ts +9 -0
- package/dist/claude-setup-token-transport.js +82 -0
- package/dist/claude-setup-token-transport.js.map +1 -0
- package/dist/claude-setup-token.d.ts +51 -0
- package/dist/claude-setup-token.js +83 -0
- package/dist/claude-setup-token.js.map +1 -0
- package/dist/cli-audited.js +15 -12
- package/dist/cli-audited.js.map +1 -1
- package/dist/command-report.d.ts +11 -0
- package/dist/command-report.js +2 -0
- package/dist/command-report.js.map +1 -0
- package/dist/config-validator.js +9 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +5 -0
- package/dist/daemon.js +65 -3
- package/dist/daemon.js.map +1 -1
- package/dist/fleet-level-config.d.ts +1 -1
- package/dist/fleet-level-config.js +1 -0
- package/dist/fleet-level-config.js.map +1 -1
- package/dist/fleet-manager.d.ts +53 -2
- package/dist/fleet-manager.js +511 -22
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +4 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +25 -6
- package/dist/host-monitoring-config.d.ts +15 -0
- package/dist/host-monitoring-config.js +36 -0
- package/dist/host-monitoring-config.js.map +1 -0
- package/dist/host-monitoring-history-files.d.ts +2 -0
- package/dist/host-monitoring-history-files.js +16 -0
- package/dist/host-monitoring-history-files.js.map +1 -0
- package/dist/host-monitoring-history-policy.d.ts +55 -0
- package/dist/host-monitoring-history-policy.js +93 -0
- package/dist/host-monitoring-history-policy.js.map +1 -0
- package/dist/host-monitoring-history-store.d.ts +52 -0
- package/dist/host-monitoring-history-store.js +176 -0
- package/dist/host-monitoring-history-store.js.map +1 -0
- package/dist/host-monitoring-history-worker.d.ts +1 -0
- package/dist/host-monitoring-history-worker.js +50 -0
- package/dist/host-monitoring-history-worker.js.map +1 -0
- package/dist/host-monitoring-history.d.ts +71 -0
- package/dist/host-monitoring-history.js +265 -0
- package/dist/host-monitoring-history.js.map +1 -0
- package/dist/host-monitoring-platform.d.ts +73 -0
- package/dist/host-monitoring-platform.js +273 -0
- package/dist/host-monitoring-platform.js.map +1 -0
- package/dist/host-monitoring-runtime.d.ts +34 -0
- package/dist/host-monitoring-runtime.js +80 -0
- package/dist/host-monitoring-runtime.js.map +1 -0
- package/dist/host-monitoring-settings-store.d.ts +5 -0
- package/dist/host-monitoring-settings-store.js +49 -0
- package/dist/host-monitoring-settings-store.js.map +1 -0
- package/dist/host-monitoring.d.ts +106 -0
- package/dist/host-monitoring.js +157 -0
- package/dist/host-monitoring.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +1 -1
- package/dist/instance-config-impact.js +1 -1
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instructions.js +1 -0
- package/dist/instructions.js.map +1 -1
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +13 -1
- package/dist/locale.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/profile-signins.d.ts +1 -0
- package/dist/profile-signins.js +3 -1
- package/dist/profile-signins.js.map +1 -1
- package/dist/public-web-gateway.js +6 -0
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +21 -2
- package/dist/public-web-link.js +22 -2
- package/dist/public-web-link.js.map +1 -1
- package/dist/runtime-cli-install.js +17 -16
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/settings-api.d.ts +15 -0
- package/dist/settings-api.js +154 -8
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +1 -0
- package/dist/settings-baseline.js +5 -4
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +10 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.d.ts +2 -0
- package/dist/settings-effect.js +15 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/topic-commands.d.ts +7 -1
- package/dist/topic-commands.js +98 -88
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.d.ts +1 -0
- package/dist/transcript-monitor.js +18 -0
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/ui/accounts-view.js +16 -8
- package/dist/ui/backend-signin.js +3 -1
- package/dist/ui/chat-commands.js +2 -0
- package/dist/ui/chat-popout-transport.js +49 -19
- package/dist/ui/chat-popout.js +15 -1
- package/dist/ui/chat-store.js +1 -1
- package/dist/ui/claude-credentials.js +123 -0
- package/dist/ui/claude-setup-token.js +36 -0
- package/dist/ui/contact-auth-client.js +7 -2
- package/dist/ui/contact-auth-strings.js +45 -14
- package/dist/ui/contact-authorizations.js +47 -26
- package/dist/ui/contact-needs.js +4 -4
- package/dist/ui/fleet-canvas.js +3 -2
- package/dist/ui/fleet-office-card.js +414 -41
- package/dist/ui/fleet-office-dialogue.js +3 -3
- package/dist/ui/fleet-office-pack.d.ts +67 -1
- package/dist/ui/fleet-office-pack.js +412 -18
- package/dist/ui/fleet-office-play.js +401 -3
- package/dist/ui/fleet-office-skin.js +133 -21
- package/dist/ui/fleet-office-store.js +41 -0
- package/dist/ui/fleet-office-zones.js +34 -9
- package/dist/ui/fleet-office.js +513 -62
- package/dist/ui/host-health-model.js +42 -0
- package/dist/ui/host-health.js +74 -0
- package/dist/ui/office-share-page.js +5 -1
- package/dist/ui/panel-chat.js +146 -46
- package/dist/ui/panel-fleet.js +24 -11
- package/dist/ui/panel-hub.js +5 -1
- package/dist/ui/panel-settings.js +5 -4
- package/dist/ui/preview-popout.js +134 -0
- package/dist/ui/reply-file-preview.js +1 -1
- package/dist/ui/search-dialog.js +8 -1
- package/dist/ui/settings-capabilities.js +2 -0
- package/dist/ui/settings-host-monitoring.js +69 -0
- package/dist/ui/settings-registry.js +4 -1
- package/dist/ui/settings-shared.js +3 -2
- package/dist/ui/shared/accounts.css +8 -4
- package/dist/ui/shared/agent-sheet.js +5 -2
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app.css +248 -27
- package/dist/ui/shared/app.js +8 -1
- package/dist/ui/shared/chat-strings.js +10 -4
- package/dist/ui/shared/chat-thread.js +42 -10
- package/dist/ui/shared/info-tip.js +64 -0
- package/dist/ui/shared/instance-nav.js +47 -5
- package/dist/ui/shared/jump-idle.js +36 -0
- package/dist/ui/shared/office-dialogue.css +12 -0
- package/dist/ui/shared/preview-panel.js +44 -18
- package/dist/ui/shared/preview-popout.css +11 -0
- package/dist/ui/shared/theme.js +15 -1
- package/dist/ui/shared/ui-menu.js +17 -11
- package/dist/ui/shared/usage-dialog.js +9 -34
- package/dist/ui/shared/view-strings.js +2 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +1 -1
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/providers.d.ts +1 -0
- package/dist/usage/providers.js +14 -1
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.js +5 -2
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +6 -1
- package/dist/web-api.js +83 -9
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +7 -1
- package/dist/web-chat-history.js +19 -3
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-claude-credentials.d.ts +31 -0
- package/dist/web-claude-credentials.js +138 -0
- package/dist/web-claude-credentials.js.map +1 -0
- package/dist/web-commands.d.ts +5 -2
- package/dist/web-commands.js +4 -2
- package/dist/web-commands.js.map +1 -1
- package/dist/web-office-skins.d.ts +7 -2
- package/dist/web-office-skins.js +42 -16
- package/dist/web-office-skins.js.map +1 -1
- package/dist/web-session.d.ts +20 -1
- package/dist/web-session.js +27 -0
- package/dist/web-session.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +1 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-terminal.d.ts +4 -0
- package/dist/web-terminal.js +16 -1
- package/dist/web-terminal.js.map +1 -1
- package/package.json +1 -1
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
// among them by base y), then the foreground, then the crowd counts, tags and bubbles.
|
|
46
46
|
import { t } from "/assets/app-i18n.js";
|
|
47
47
|
import { frameAt, nameHash } from "./fleet-office-model.js";
|
|
48
|
-
import { CHAR_DEPTH, LOGICAL, checkSkinPack, own, packPortraitImages, packSceneImages, poseStrip, stripBox, walkStrip } from "./fleet-office-pack.js";
|
|
48
|
+
import { CHAR_DEPTH, LOGICAL, checkSkinPack, own, packPortraitImages, packSceneImages, poseStrip, stripBox, stripCell, stripFrameAt, stripImages, walkStrip } from "./fleet-office-pack.js";
|
|
49
49
|
import { tierColours } from "./fleet-office-levels.js";
|
|
50
50
|
import { assetUrl } from "/assets/asset-url.js";
|
|
51
51
|
|
|
@@ -154,6 +154,12 @@ function drawDeskBack(ctx, d, look) {
|
|
|
154
154
|
ctx.restore();
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/** M-3445 (#4267): default lifted/dangling motion when a character is dragged without a custom `dragged` strip (zero sway when ms <= 0). */
|
|
158
|
+
export function draggedMotion(ms) {
|
|
159
|
+
if (!(ms > 0)) return { lift: 10, tilt: 0 };
|
|
160
|
+
return { lift: 10 + Math.sin(ms * 0.011) * 1.5, tilt: Math.sin(ms * 0.009) * 0.14 };
|
|
161
|
+
}
|
|
162
|
+
|
|
157
163
|
function drawCharacter(ctx, d, look, ms, env) {
|
|
158
164
|
if (look.pose === "away") return;
|
|
159
165
|
const h = nameHash(look.name), skin = SKIN_TONES[h % SKIN_TONES.length], hair = HAIR[(h >>> 3) % HAIR.length];
|
|
@@ -168,6 +174,31 @@ function drawCharacter(ctx, d, look, ms, env) {
|
|
|
168
174
|
art(ctx, d, 2.6, 4.6, 0.7, 0.5, "rgba(255, 120, 120, 0.45)", dy); art(ctx, d, 6.7, 4.6, 0.7, 0.5, "rgba(255, 120, 120, 0.45)", dy);
|
|
169
175
|
};
|
|
170
176
|
const body = (dy) => { art(ctx, d, 1, 6, 8, 5, coat, dy); art(ctx, d, 4, 6, 2, 2, shirt, dy); };
|
|
177
|
+
if (look.pose === "dragged") {
|
|
178
|
+
// M-3445 (#4267): lifted off the ground shadow, swaying gently with flailing arms and kicking legs (still when ms <= 0).
|
|
179
|
+
const sx = d.seat ? d.seat.x : d.x + CX, sy = d.seat ? d.seat.y : d.y + 53;
|
|
180
|
+
ctx.save();
|
|
181
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.22)";
|
|
182
|
+
ctx.beginPath(); ctx.ellipse(sx, sy, 12, 4.5, 0, 0, Math.PI * 2); ctx.fill();
|
|
183
|
+
ctx.restore();
|
|
184
|
+
const { lift, tilt } = draggedMotion(ms);
|
|
185
|
+
const px0 = d.x + CX, py0 = d.y + TOP + 4 - lift;
|
|
186
|
+
ctx.translate(px0, py0);
|
|
187
|
+
if (tilt) ctx.rotate(tilt);
|
|
188
|
+
ctx.translate(-px0, -py0 - lift);
|
|
189
|
+
head(0, false); body(0);
|
|
190
|
+
// Surprised tiny "o" mouth & arms raised/flailing alternately.
|
|
191
|
+
art(ctx, d, 4.6, 4.7, 0.8, 0.7, eye);
|
|
192
|
+
const alt = ms > 0 && (f % 2 === 1);
|
|
193
|
+
art(ctx, d, 0, alt ? 4.5 : 6, 1, 3, coat); art(ctx, d, -0.4, alt ? 3.8 : 5.3, 1.2, 1, skin);
|
|
194
|
+
art(ctx, d, 9, alt ? 6 : 4.5, 1, 3, coat); art(ctx, d, 9.2, alt ? 5.3 : 3.8, 1.2, 1, skin);
|
|
195
|
+
// Dangling kicking legs.
|
|
196
|
+
const legs = "#3a3f4b";
|
|
197
|
+
art(ctx, d, alt ? 2.1 : 2.7, 11, 2, alt ? 2.2 : 1.7, legs);
|
|
198
|
+
art(ctx, d, alt ? 5.3 : 5.9, 11, 2, alt ? 1.7 : 2.2, legs);
|
|
199
|
+
ctx.restore();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
171
202
|
if (look.pose === "working") {
|
|
172
203
|
head(0, false); body(0);
|
|
173
204
|
// Typing: the hands take turns on the keyboard; the screen's lines change.
|
|
@@ -268,7 +299,7 @@ function drawProp(ctx, it, ms, env) {
|
|
|
268
299
|
}
|
|
269
300
|
|
|
270
301
|
/** Frames per pose and the loop's speed (the built-in strips). */
|
|
271
|
-
export const FRAMES = { working: 4, idle: 4, paused: 3, needs: 2, walk: 2 };
|
|
302
|
+
export const FRAMES = { working: 4, idle: 4, paused: 3, needs: 2, walk: 2, dragged: 4 };
|
|
272
303
|
export const FPS = 4;
|
|
273
304
|
|
|
274
305
|
const BUBBLE_FONT = "600 11px system-ui, sans-serif";
|
|
@@ -318,11 +349,12 @@ export function tagBox(ctx, x, y, label, compact = false) {
|
|
|
318
349
|
ctx.restore();
|
|
319
350
|
return { x: Math.round(x - w / 2), y: y + k.top, w, h: k.h, text: t };
|
|
320
351
|
}
|
|
321
|
-
/** #2860: what a tag covers with its level badge: on a full tag's top-left corner (
|
|
352
|
+
/** #2860: what a tag covers with its level badge: on a full tag's top-left corner (clear of the first letter); left of a compact one. */
|
|
322
353
|
export function tagFootprint(ctx, box, badge, compact = false) {
|
|
323
354
|
if (!badge) return box;
|
|
324
355
|
if (compact) { const w = badgeWidth(ctx, badge) + 1; return { x: box.x - w, y: box.y, w: box.w + w, h: box.h }; }
|
|
325
|
-
|
|
356
|
+
const left = badge.mark ? 6 : Math.max(10, badgeWidth(ctx, badge) - 3);
|
|
357
|
+
return { x: box.x - left, y: box.y - 7, w: box.w + left, h: box.h + 7 };
|
|
326
358
|
}
|
|
327
359
|
function badgeWidth(ctx, badge) {
|
|
328
360
|
if (badge.mark) return 8;
|
|
@@ -339,13 +371,12 @@ function badgeWidth(ctx, badge) {
|
|
|
339
371
|
*/
|
|
340
372
|
export function drawBadge(ctx, x, y, badge, pal, inline = false) {
|
|
341
373
|
if (!badge) return;
|
|
342
|
-
// #2860 inline (a compact tag): (x, y) is the tag's left edge and middle; the badge sits just left of it, whole.
|
|
343
|
-
if (inline) { const w = badgeWidth(ctx, badge); x = x - 1 - w + (badge.mark ? w / 2 : w / 2 - 3); y = y + (badge.mark ? 0 : 1); }
|
|
344
374
|
const c = tierColours(badge.tier, pal);
|
|
345
375
|
ctx.save();
|
|
346
376
|
ctx.globalAlpha = 1;
|
|
347
377
|
if (badge.mark) {
|
|
348
|
-
|
|
378
|
+
const mx = inline ? x - 1 - 4 : x;
|
|
379
|
+
ctx.translate(mx, y); ctx.rotate(Math.PI / 4);
|
|
349
380
|
ctx.fillStyle = pal.surface; ctx.fillRect(-4, -4, 8, 8);
|
|
350
381
|
ctx.fillStyle = c.bg; ctx.fillRect(-4, -4, 8, 8);
|
|
351
382
|
ctx.strokeStyle = c.line; ctx.lineWidth = 1; ctx.strokeRect(-3.5, -3.5, 7, 7);
|
|
@@ -354,7 +385,9 @@ export function drawBadge(ctx, x, y, badge, pal, inline = false) {
|
|
|
354
385
|
}
|
|
355
386
|
ctx.font = BADGE_FONT;
|
|
356
387
|
const w = Math.max(12, Math.ceil((ctx.measureText ? ctx.measureText(badge.text).width : badge.text.length * 5) + 6)), h = 11;
|
|
357
|
-
|
|
388
|
+
// Normal tag: badge overlaps only the left border corner (right edge at x + 3), leaving the first letter at x + 5 unobstructed.
|
|
389
|
+
const bx = inline ? Math.round(x - 1 - w) : Math.round(x - w + 3);
|
|
390
|
+
const by = inline ? Math.round(y - h / 2) : Math.round(y - h / 2 - 1);
|
|
358
391
|
// An opaque surface first, so a tint reads the same over any picture.
|
|
359
392
|
ctx.fillStyle = pal.surface; ctx.fillRect(bx, by, w, h);
|
|
360
393
|
ctx.fillStyle = c.bg; ctx.fillRect(bx, by, w, h);
|
|
@@ -526,23 +559,48 @@ export const studioSkin = { ...pixelSkin, id: "studio", pack: STUDIO_PACK, drawB
|
|
|
526
559
|
*/
|
|
527
560
|
export function spriteSkin(pack, images, base = pixelSkin) {
|
|
528
561
|
const img = (src) => (src && images.get(src)) || null;
|
|
562
|
+
const ready = (st) => !!st && (Array.isArray(st.sheets) ? stripImages(st).every((s) => !!img(s)) : !!img(st.src));
|
|
563
|
+
const clipMs = (env, key, st, ms) => (ms > 0 && env && typeof env.clock === "function" ? env.clock(key, st, ms) : ms);
|
|
529
564
|
// A strip's frame at its displayed size (dw × dh, unsmoothed), its anchor on (x, y); mirrored about the anchor.
|
|
530
565
|
const strip = (ctx, st, ms, x, y, frame = null, mirror = false) => {
|
|
531
|
-
|
|
566
|
+
if (!ready(st)) return false;
|
|
567
|
+
const f = frame ?? stripFrameAt(st, ms), cell = stripCell(st, f), im = img(cell.src);
|
|
532
568
|
if (!im) return false;
|
|
533
|
-
const
|
|
569
|
+
const b = stripBox(st, x, y, mirror);
|
|
534
570
|
ctx.save();
|
|
535
571
|
ctx.imageSmoothingEnabled = false;
|
|
536
|
-
if (mirror) { ctx.translate(b.x + b.w, b.y); ctx.scale(-1, 1); ctx.drawImage(im,
|
|
537
|
-
else ctx.drawImage(im,
|
|
572
|
+
if (mirror) { ctx.translate(b.x + b.w, b.y); ctx.scale(-1, 1); ctx.drawImage(im, cell.col * st.w, 0, st.w, st.h, 0, 0, b.w, b.h); }
|
|
573
|
+
else ctx.drawImage(im, cell.col * st.w, 0, st.w, st.h, b.x, b.y, b.w, b.h);
|
|
538
574
|
ctx.restore();
|
|
539
575
|
return true;
|
|
540
576
|
};
|
|
541
577
|
const setOf = (look) => own(pack.characters, own(pack.byInstance, look.name)) || own(pack.characters, "default");
|
|
542
|
-
/**
|
|
578
|
+
/** M-3432 (#4255): eating strip for `name` (their set's `eat`, else `default.eat`, else null). */
|
|
579
|
+
const eatStripOf = (name) => {
|
|
580
|
+
const st = own(setOf({ name }) || {}, "eat") || own(own(pack.characters, "default") || {}, "eat") || null;
|
|
581
|
+
return st && ready(st) ? st : null;
|
|
582
|
+
};
|
|
583
|
+
/** M-3445 (#4267): dragged strip for `name` (their set's `dragged`, else `default.dragged`, else null). */
|
|
584
|
+
const draggedStripOf = (name) => {
|
|
585
|
+
const st = own(setOf({ name }) || {}, "dragged") || own(own(pack.characters, "default") || {}, "dragged") || null;
|
|
586
|
+
return st && ready(st) ? st : null;
|
|
587
|
+
};
|
|
588
|
+
/** The strip a look shows (its pose; walking, by its heading), when all its pictures are loaded. */
|
|
543
589
|
const shown = (look, walking = look.pose === "walk") => {
|
|
590
|
+
if (!walking && look.pose === "dragged") {
|
|
591
|
+
const dragSt = draggedStripOf(look.name);
|
|
592
|
+
if (dragSt) return { strip: dragSt, mirror: false, customDragged: true };
|
|
593
|
+
const fallback = poseStrip(setOf(look), look.basePose || "idle", look.heading);
|
|
594
|
+
return fallback && ready(fallback.strip) ? { ...fallback, customDragged: false } : null;
|
|
595
|
+
}
|
|
596
|
+
if (!walking && look.pose === "eat") {
|
|
597
|
+
const eatSt = eatStripOf(look.name);
|
|
598
|
+
if (eatSt) return { strip: eatSt, mirror: false };
|
|
599
|
+
const fallback = poseStrip(setOf(look), look.basePose || "idle", look.heading);
|
|
600
|
+
return fallback && ready(fallback.strip) ? fallback : null;
|
|
601
|
+
}
|
|
544
602
|
const ps = poseStrip(setOf(look), walking ? "walk" : look.pose, look.heading);
|
|
545
|
-
return ps &&
|
|
603
|
+
return ps && ready(ps.strip) ? ps : null;
|
|
546
604
|
};
|
|
547
605
|
return {
|
|
548
606
|
...base,
|
|
@@ -586,10 +644,10 @@ export function spriteSkin(pack, images, base = pixelSkin) {
|
|
|
586
644
|
if (f.shape) { drawFurniture(ctx, f, active, ms, env); return; }
|
|
587
645
|
// An NPC walking (#2596): its walk strip for its heading (walkSide mirrored going left), when its picture is loaded.
|
|
588
646
|
const ws = walkStrip(f);
|
|
589
|
-
if (ws && strip(ctx, ws.strip, ms, f.x, f.y, null, ws.mirror)) return;
|
|
647
|
+
if (ws && ready(ws.strip) && strip(ctx, ws.strip, clipMs(env, `fw:${f.id}`, ws.strip, ms), f.x, f.y, null, ws.mirror)) return;
|
|
590
648
|
// Active: its activeSprite (or its strip) plays; otherwise its strip loops ("loop", #2570) or its first frame holds.
|
|
591
|
-
if (active)
|
|
592
|
-
else if (f.loop) strip(ctx, f.sprite, ms, f.x, f.y);
|
|
649
|
+
if (active) { const st = f.activeSprite || f.sprite; strip(ctx, st, clipMs(env, `fa:${f.id}`, st, ms), f.x, f.y); }
|
|
650
|
+
else if (f.loop) strip(ctx, f.sprite, clipMs(env, `fl:${f.id}`, f.sprite, ms), f.x, f.y);
|
|
593
651
|
else strip(ctx, f.sprite, 0, f.x, f.y, 0);
|
|
594
652
|
},
|
|
595
653
|
drawCharacter(ctx, d, look, ms, env) {
|
|
@@ -597,9 +655,56 @@ export function spriteSkin(pack, images, base = pixelSkin) {
|
|
|
597
655
|
const ps = shown(look);
|
|
598
656
|
ctx.save();
|
|
599
657
|
if (look.dim) ctx.globalAlpha = 0.35;
|
|
600
|
-
const
|
|
658
|
+
const cms = ps ? clipMs(env, `c:${look.name || (d && d.key) || ""}`, ps.strip, ms) : ms;
|
|
659
|
+
let done = false;
|
|
660
|
+
if (ps && look.pose === "dragged") {
|
|
661
|
+
// M-3445 (#4267): ground shadow under feet; custom `dragged` strip plays as authored, otherwise built-in lifted dangle.
|
|
662
|
+
ctx.save();
|
|
663
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.22)";
|
|
664
|
+
ctx.beginPath(); ctx.ellipse(d.seat.x, d.seat.y, Math.max(10, Math.round(ps.strip.dw * 0.24)), 4.5, 0, 0, Math.PI * 2); ctx.fill();
|
|
665
|
+
ctx.restore();
|
|
666
|
+
if (ps.customDragged) {
|
|
667
|
+
done = strip(ctx, ps.strip, cms, d.seat.x, d.seat.y, null, ps.mirror);
|
|
668
|
+
} else {
|
|
669
|
+
const { lift, tilt } = draggedMotion(ms);
|
|
670
|
+
const b = stripBox(ps.strip, d.seat.x, d.seat.y);
|
|
671
|
+
const px0 = d.seat.x, py0 = b.y + Math.min(10, b.h * 0.22) - lift;
|
|
672
|
+
ctx.translate(px0, py0);
|
|
673
|
+
if (tilt) ctx.rotate(tilt);
|
|
674
|
+
ctx.scale(0.96, 1.04);
|
|
675
|
+
ctx.translate(-px0, -py0 - lift);
|
|
676
|
+
done = strip(ctx, ps.strip, cms, d.seat.x, d.seat.y, null, ps.mirror);
|
|
677
|
+
}
|
|
678
|
+
} else {
|
|
679
|
+
done = !!ps && strip(ctx, ps.strip, cms, d.seat.x, d.seat.y, null, ps.mirror);
|
|
680
|
+
}
|
|
601
681
|
ctx.restore();
|
|
602
|
-
if (!done) base.drawCharacter(ctx, d, look, ms, env);
|
|
682
|
+
if (!done) base.drawCharacter(ctx, d, look.pose === "eat" ? { ...look, pose: look.basePose || "idle" } : look, ms, env);
|
|
683
|
+
},
|
|
684
|
+
/** M-3432 (#4255): character's eating strip (set.eat → default.eat → null) when loaded. */
|
|
685
|
+
eatStrip: eatStripOf,
|
|
686
|
+
/** M-3445 (#4267): character's dragged strip (set.dragged → default.dragged → null) when loaded. */
|
|
687
|
+
draggedStrip: draggedStripOf,
|
|
688
|
+
/** M-3432 (#4255): draw a snack strip (placed on floor or eat overlay) at logical (x, y). */
|
|
689
|
+
drawSnack(ctx, st, ms, x, y, env, clipKey = null) {
|
|
690
|
+
if (!st || !ready(st)) return false;
|
|
691
|
+
const sms = clipKey ? clipMs(env, clipKey, st, ms) : ms;
|
|
692
|
+
return strip(ctx, st, sms, x, y);
|
|
693
|
+
},
|
|
694
|
+
/** M-3432 (#4255): draw frame 0 of a snack strip fitted cleanly inside a square tray/ghost icon canvas. */
|
|
695
|
+
drawSnackIcon(ctx, st, size) {
|
|
696
|
+
if (!st || !ready(st)) return false;
|
|
697
|
+
const cell = stripCell(st, 0), im = img(cell.src);
|
|
698
|
+
if (!im) return false;
|
|
699
|
+
const pad = 2, avail = Math.max(1, size - pad * 2);
|
|
700
|
+
const scale = Math.min(avail / st.w, avail / st.h);
|
|
701
|
+
const dw = Math.max(1, Math.round(st.w * scale)), dh = Math.max(1, Math.round(st.h * scale));
|
|
702
|
+
const dx = Math.round((size - dw) / 2), dy = Math.round((size - dh) / 2);
|
|
703
|
+
ctx.save();
|
|
704
|
+
ctx.imageSmoothingEnabled = false;
|
|
705
|
+
ctx.drawImage(im, cell.col * st.w, 0, st.w, st.h, dx, dy, dw, dh);
|
|
706
|
+
ctx.restore();
|
|
707
|
+
return true;
|
|
603
708
|
},
|
|
604
709
|
charBox(look, at) {
|
|
605
710
|
const ps = shown({ ...look, heading: at.heading }, !!at.walking);
|
|
@@ -608,7 +713,9 @@ export function spriteSkin(pack, images, base = pixelSkin) {
|
|
|
608
713
|
// An item in the air: its sender's own (their set's "prop", #2562), else the pack's for its kind, else the built-in one.
|
|
609
714
|
drawProp(ctx, it, ms, env) {
|
|
610
715
|
const mine = it.from ? own(setOf({ name: it.from }) || {}, "prop") : null;
|
|
611
|
-
|
|
716
|
+
const st = mine || own(pack.props, it.hue);
|
|
717
|
+
const pms = st && it.id ? clipMs(env, `p:${it.id}`, st, ms) : ms;
|
|
718
|
+
if (!strip(ctx, st, pms, it.x, it.y)) base.drawProp(ctx, it, ms, env);
|
|
612
719
|
},
|
|
613
720
|
};
|
|
614
721
|
}
|
|
@@ -770,7 +877,12 @@ const MAX_LOADED = 24;
|
|
|
770
877
|
const defaultImage = (url) => new Promise((resolve) => {
|
|
771
878
|
if (typeof Image !== "function") { resolve(null); return; }
|
|
772
879
|
const im = new Image();
|
|
773
|
-
im.onload = () =>
|
|
880
|
+
im.onload = () => {
|
|
881
|
+
// M-3394 (#4231): pre-decode each sheet before handing the skin to the renderer so multi-sheet
|
|
882
|
+
// boundaries never trigger a synchronous decode hitch on desktop or phone.
|
|
883
|
+
if (typeof im.decode === "function") im.decode().then(() => resolve(im), () => resolve(im));
|
|
884
|
+
else resolve(im);
|
|
885
|
+
};
|
|
774
886
|
im.onerror = () => resolve(null);
|
|
775
887
|
im.src = url;
|
|
776
888
|
});
|
|
@@ -39,6 +39,30 @@ const CAROUSEL_KEY = "agend_org_office_carousel";
|
|
|
39
39
|
const VIEW_KEY = "agend_org_office_view", VIEWS_MAX = 32;
|
|
40
40
|
/** #2540: { "<office>@<style>": "cover" } — the offices whose fit fills the panel (the rest: "contain"), the last VIEWS_MAX. */
|
|
41
41
|
const FIT_KEY = "agend_org_office_fit";
|
|
42
|
+
/** M-3445 (#4266): { "<office>@<style>": { "<name>": { "<area>": slot } } } — per-device seat choices from dragging an agent onto another seat. */
|
|
43
|
+
const SEATS_KEY = "agend_org_office_seats", SEATS_MAX = 32, SEAT_AGENTS_MAX = 500, SEAT_AREAS_MAX = 32, SEAT_SLOT_MAX = 64;
|
|
44
|
+
const UNSAFE_KEY = new Set(["__proto__", "constructor", "prototype"]);
|
|
45
|
+
const safeKey = (k, max = 200) => typeof k === "string" && k.length > 0 && k.length <= max && !UNSAFE_KEY.has(k);
|
|
46
|
+
/** M-3445 (#4266): validate a per-office seat preference map ({ [name]: { [area]: slot } }). */
|
|
47
|
+
export function seatPrefsOk(raw) {
|
|
48
|
+
const out = {};
|
|
49
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return out;
|
|
50
|
+
let agents = 0;
|
|
51
|
+
for (const [name, areas] of Object.entries(raw)) {
|
|
52
|
+
if (agents >= SEAT_AGENTS_MAX) break;
|
|
53
|
+
if (!safeKey(name, 200) || !areas || typeof areas !== "object" || Array.isArray(areas)) continue;
|
|
54
|
+
const clean = {};
|
|
55
|
+
let count = 0;
|
|
56
|
+
for (const [area, slot] of Object.entries(areas)) {
|
|
57
|
+
if (count >= SEAT_AREAS_MAX) break;
|
|
58
|
+
if (!safeKey(area, 64) || !Number.isInteger(slot) || slot < 0 || slot >= SEAT_SLOT_MAX) continue;
|
|
59
|
+
clean[area] = slot;
|
|
60
|
+
count++;
|
|
61
|
+
}
|
|
62
|
+
if (count > 0) { out[name] = clean; agents++; }
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
42
66
|
const PACK_ID = /^[A-Za-z0-9_-]{1,40}$/;
|
|
43
67
|
/** #2692: GET /ui/office-pack-changes, checked: { approval, agents: [names], pending: [views], log: [entries] } (anything odd dropped). */
|
|
44
68
|
export function packChangesOk(d) {
|
|
@@ -271,5 +295,22 @@ export function createOfficeStore({ fetch: get = globalThis.fetch, storage } = {
|
|
|
271
295
|
const next = Object.entries(m).filter(([k2, v]) => k2 !== key && v === "cover").slice(-(VIEWS_MAX - 1));
|
|
272
296
|
write(FIT_KEY, JSON.stringify(Object.fromEntries(fitModeOk(mode) === "cover" ? [...next, [key, "cover"]] : next)));
|
|
273
297
|
},
|
|
298
|
+
/** M-3445 (#4266): per-device seat choices for `key` (`<office>@<style>`): { [name]: { [area]: slot } }. */
|
|
299
|
+
seats: (key) => {
|
|
300
|
+
if (!safeKey(key, 100)) return {};
|
|
301
|
+
try {
|
|
302
|
+
const m = JSON.parse(read(SEATS_KEY) || "{}");
|
|
303
|
+
return m && typeof m === "object" && !Array.isArray(m) && Object.prototype.hasOwnProperty.call(m, key) ? seatPrefsOk(m[key]) : {};
|
|
304
|
+
} catch { return {}; }
|
|
305
|
+
},
|
|
306
|
+
/** M-3445 (#4266): save per-device seat choices for `key`, LRU-capped at SEATS_MAX offices. */
|
|
307
|
+
saveSeats: (key, prefs) => {
|
|
308
|
+
if (!safeKey(key, 100)) return;
|
|
309
|
+
let m = {};
|
|
310
|
+
try { const o = JSON.parse(read(SEATS_KEY) || "{}"); if (o && typeof o === "object" && !Array.isArray(o)) m = o; } catch { m = {}; }
|
|
311
|
+
const clean = seatPrefsOk(prefs);
|
|
312
|
+
const next = Object.entries(m).filter(([k2, v]) => k2 !== key && safeKey(k2, 100) && v && typeof v === "object" && !Array.isArray(v)).slice(-(SEATS_MAX - 1));
|
|
313
|
+
write(SEATS_KEY, JSON.stringify(Object.fromEntries(Object.keys(clean).length ? [...next, [key, clean]] : next)));
|
|
314
|
+
},
|
|
274
315
|
};
|
|
275
316
|
}
|
|
@@ -50,9 +50,16 @@ export function overflowSpots(area, need = 0) {
|
|
|
50
50
|
* `lend` (one no owner of it took). A reserved seat not lent, none of whose owners wants the area, is unavailable:
|
|
51
51
|
* the area's overflow spots and `over` count without it. Seats without `for` work as before.
|
|
52
52
|
*/
|
|
53
|
-
export function assignSeats(pack, wants, prev = new Map()) {
|
|
53
|
+
export function assignSeats(pack, wants, prev = new Map(), seatPrefs = null) {
|
|
54
54
|
const seats = new Map(), crowd = new Map(), taken = new Map(), spill = new Map(), demand = new Map(), wanting = new Map();
|
|
55
55
|
const areaOf = (a) => own(pack.areas, a);
|
|
56
|
+
const prefOf = (name, area) => {
|
|
57
|
+
const p = prev.get(name);
|
|
58
|
+
if (p && p.area === area) return p;
|
|
59
|
+
const byArea = seatPrefs && own(seatPrefs, name);
|
|
60
|
+
const slot = byArea && own(byArea, area);
|
|
61
|
+
return Number.isInteger(slot) && slot >= 0 ? { area, slot } : null;
|
|
62
|
+
};
|
|
56
63
|
for (const w of wants) {
|
|
57
64
|
demand.set(w.area, (demand.get(w.area) || 0) + 1);
|
|
58
65
|
if (!wanting.has(w.area)) wanting.set(w.area, new Set());
|
|
@@ -70,9 +77,9 @@ export function assignSeats(pack, wants, prev = new Map()) {
|
|
|
70
77
|
const usedIn = (area) => { if (!taken.has(area)) taken.set(area, new Set()); return taken.get(area); };
|
|
71
78
|
const give = (name, area, slot) => { const p = pos(area, slot); usedIn(area).add(slot); seats.set(name, { area, slot, x: p.x, y: p.y }); };
|
|
72
79
|
const free = (w) => !seats.has(w.name) && !!areaOf(w.area);
|
|
73
|
-
// Owners first: their own seat from last time, then their first free one.
|
|
80
|
+
// Owners first: their own seat from last time (or saved seat pref), then their first free one.
|
|
74
81
|
for (const w of wants) {
|
|
75
|
-
const p =
|
|
82
|
+
const p = prefOf(w.name, w.area), s = p && p.slot >= 0 && areaOf(w.area) ? areaOf(w.area).seats[p.slot] : null;
|
|
76
83
|
if (s && mine(s, w.name) && !usedIn(w.area).has(p.slot)) give(w.name, w.area, p.slot);
|
|
77
84
|
}
|
|
78
85
|
for (const w of wants) {
|
|
@@ -81,8 +88,8 @@ export function assignSeats(pack, wants, prev = new Map()) {
|
|
|
81
88
|
if (slot >= 0) give(w.name, w.area, slot);
|
|
82
89
|
}
|
|
83
90
|
for (const w of wants) {
|
|
84
|
-
const p =
|
|
85
|
-
if (!free(w) || !p ||
|
|
91
|
+
const p = prefOf(w.name, w.area);
|
|
92
|
+
if (!free(w) || !p || !pos(w.area, p.slot) || usedIn(w.area).has(p.slot)) continue;
|
|
86
93
|
const s = p.slot >= 0 ? areaOf(w.area).seats[p.slot] : null;
|
|
87
94
|
if (s && s.for && !lent(s)) continue; // reserved for someone else (theirs would be taken above)
|
|
88
95
|
give(w.name, w.area, p.slot);
|
|
@@ -106,11 +113,11 @@ export function assignSeats(pack, wants, prev = new Map()) {
|
|
|
106
113
|
* the desks layout (rooms → desks with a seat), in logical units, plus `mode: "zones"`, the pack's areas and graph (and
|
|
107
114
|
* its `straight`, #2634, and `idleVisits`, #3685), the seats given (`seats`, the next call's `prev`), `crowd` and `over` (the areas over capacity).
|
|
108
115
|
*/
|
|
109
|
-
export function zonesLayout(pack, nodes, prev = new Map(), { night = false } = {}) {
|
|
116
|
+
export function zonesLayout(pack, nodes, prev = new Map(), { night = false, seatPrefs = null } = {}) {
|
|
110
117
|
// At night (#2568) the idle go to bed: the area asleep people go to while it has a free seat; the rest doze where they are.
|
|
111
118
|
const bed = zoneOf(pack, "paused"), bedSeats = own(pack.areas, bed)?.seats || [], sleepers = new Set(), inBed = new Set();
|
|
112
119
|
const wantsOf = (beds) => nodes.filter((n) => n.state !== "missing").map((n) => ({ name: n.name, area: beds.has(n.name) ? bed : zoneOf(pack, n.state) }));
|
|
113
|
-
let placed = assignSeats(pack, wantsOf(inBed), prev);
|
|
120
|
+
let placed = assignSeats(pack, wantsOf(inBed), prev, seatPrefs);
|
|
114
121
|
if (night) {
|
|
115
122
|
// #2691 review: who goes to bed is decided by the seat assignment itself (assignSeats' reservation rules), one
|
|
116
123
|
// sleeper at a time — whoever has a bed of their own there first, then the rest in the fleet's order. A sleeper
|
|
@@ -122,7 +129,7 @@ export function zonesLayout(pack, nodes, prev = new Map(), { night = false } = {
|
|
|
122
129
|
const hasBed = (n) => bedSeats.some((s) => s.for && s.for.includes(n.name));
|
|
123
130
|
for (const n of idle) sleepers.add(n.name);
|
|
124
131
|
for (const n of [...idle.filter(hasBed), ...idle.filter((n) => !hasBed(n))]) {
|
|
125
|
-
const trial = assignSeats(pack, wantsOf(new Set([...inBed, n.name])), prev), s = trial.seats.get(n.name);
|
|
132
|
+
const trial = assignSeats(pack, wantsOf(new Set([...inBed, n.name])), prev, seatPrefs), s = trial.seats.get(n.name);
|
|
126
133
|
if (!s || s.area !== bed || s.slot < 0) {
|
|
127
134
|
if (!hasBed(n)) break; // no bed free for anyone without one: none for the rest either
|
|
128
135
|
continue;
|
|
@@ -216,6 +223,23 @@ function withinArea(near, seat, graph, home) {
|
|
|
216
223
|
const others = Object.keys(areas).filter((k) => k !== home && areas[k].rect).map((k) => areas[k].rect);
|
|
217
224
|
return inside.filter((w) => legs(w).every((pts) => pts.every((p, i) => !i || !others.some((r) => crosses(r, pts[i - 1], p)))));
|
|
218
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* M-3286 / M-3432: whether walking from `from` to `to` (and returning to `returnTo`) keeps a person in area `home`:
|
|
228
|
+
* `to` is inside `home`'s rect, and both outbound and return walks (including straightened legs on `graph.straight`)
|
|
229
|
+
* either stay inside `home`'s rect or pass through no other area's interior.
|
|
230
|
+
*/
|
|
231
|
+
export function routeStaysInArea(from, to, graph, home, returnTo = from) {
|
|
232
|
+
if (!graph || typeof graph !== "object") return true;
|
|
233
|
+
const areas = graph.areas || {}, a = own(areas, home);
|
|
234
|
+
if (!a || !a.rect) return false;
|
|
235
|
+
if (!inRect(a.rect, to)) return false;
|
|
236
|
+
const legs = [walkPts(graph, from, to)];
|
|
237
|
+
if (returnTo) legs.push(walkPts(graph, to, returnTo));
|
|
238
|
+
if (legs.every((pts) => pts.every((p) => inRect(a.rect, p)))) return true;
|
|
239
|
+
const others = Object.keys(areas).filter((k) => k !== home && areas[k].rect).map((k) => areas[k].rect);
|
|
240
|
+
const strictIn = (r, p) => p.x > r.x && p.x < r.x + r.w && p.y > r.y && p.y < r.y + r.h;
|
|
241
|
+
return legs.every((pts) => pts.every((p, i) => !others.some((r) => strictIn(r, p) || (i > 0 && crosses(r, pts[i - 1], p)))));
|
|
242
|
+
}
|
|
219
243
|
/**
|
|
220
244
|
* Where `name`, seated at `seat`, should be at `t` (ms) while idle: a spot near the seat, or the seat. `area` (M-3286:
|
|
221
245
|
* the office keeps idle people in their own area): the id of the area they are seated in — only spots inside it, and
|
|
@@ -487,7 +511,8 @@ export function createWalkers() {
|
|
|
487
511
|
if (w.to.x === to.x && w.to.y === to.y) continue;
|
|
488
512
|
const here = posAt(w, now), via = routeVia(graph, { x: here.x, y: here.y }, { x: to.x, y: to.y });
|
|
489
513
|
const pts = graph.straight ? straighten(via) : via; // #2634: timed along the longer way
|
|
490
|
-
|
|
514
|
+
const speed = to.speed > 0 ? to.speed : WALK.SPEED;
|
|
515
|
+
by.set(name, { pts, start: now, ms: Math.max(1, pathLength(pts) / speed), to });
|
|
491
516
|
}
|
|
492
517
|
},
|
|
493
518
|
at(name, now) { const w = by.get(name); return w ? posAt(w, now) : null; },
|