@xpert-ai/chatkit-types 0.9.0 → 0.10.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/dist/index.cjs +177 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.js +177 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,46 @@ export declare interface ApprovalHostReference {
|
|
|
36
36
|
expiresAt: number;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** IDs are resource identifiers, not a closed list of bundled presets. */
|
|
40
|
+
export declare type AssistantAppearance = {
|
|
41
|
+
version: 1;
|
|
42
|
+
kind: 'image';
|
|
43
|
+
} | {
|
|
44
|
+
version: 1;
|
|
45
|
+
kind: 'character';
|
|
46
|
+
id: string;
|
|
47
|
+
color: string;
|
|
48
|
+
config?: AssistantCharacterConfig;
|
|
49
|
+
} | {
|
|
50
|
+
version: 1;
|
|
51
|
+
kind: 'pet';
|
|
52
|
+
id: string;
|
|
53
|
+
/** Sprite layout version; omitted by legacy v1 avatars. */
|
|
54
|
+
spriteVersionNumber?: 1 | 2;
|
|
55
|
+
asset?: {
|
|
56
|
+
type: 'sprite-atlas' | 'animated-image';
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export declare type AssistantCharacterConfig = {
|
|
62
|
+
shape: 'round' | 'pebble' | 'pill' | 'drop' | 'flame' | 'triangle' | 'square' | 'bag' | 'star' | 'heart' | 'cloud' | 'clover';
|
|
63
|
+
eyes: 'oval' | 'toon' | 'pill' | 'dot' | 'ring' | 'happy' | 'sleepy' | 'wink' | 'plus' | 'slash' | 'squint';
|
|
64
|
+
mouth: 'none' | 'smile' | 'open' | 'neutral' | 'o';
|
|
65
|
+
motion: 'float' | 'bounce' | 'sway' | 'none';
|
|
66
|
+
eyeSize: number;
|
|
67
|
+
eyeSpacing: number;
|
|
68
|
+
brows?: 'none' | 'flat' | 'angry' | 'worried' | 'raised';
|
|
69
|
+
ink?: 'auto' | 'dark' | 'light';
|
|
70
|
+
tilt?: number;
|
|
71
|
+
speed?: number;
|
|
72
|
+
blink?: boolean;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export declare type AssistantCustomizeEffect = {
|
|
76
|
+
assistantId: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
39
79
|
/**
|
|
40
80
|
* strategies to host files before attaching them to messages.
|
|
41
81
|
*/
|
|
@@ -220,6 +260,8 @@ export declare type ChatFileChange = {
|
|
|
220
260
|
updatedAt?: string;
|
|
221
261
|
};
|
|
222
262
|
|
|
263
|
+
export declare const CHATKIT_ASSISTANT_CUSTOMIZE_EFFECT = "assistant.customize";
|
|
264
|
+
|
|
223
265
|
export declare const CHATKIT_TASK_SUMMARY_OPEN_RESOURCE_EFFECT: "task_summary.open_resource";
|
|
224
266
|
|
|
225
267
|
export declare interface ChatKitApprovalsOptions {
|
|
@@ -231,6 +273,18 @@ export declare interface ChatKitApprovalsOptions {
|
|
|
231
273
|
onAction?: (input: ApprovalActionRequest) => Promise<void> | void;
|
|
232
274
|
}
|
|
233
275
|
|
|
276
|
+
/** Computer shortcuts in the Assistant details dialog. Remote targets use registered View keys. */
|
|
277
|
+
export declare type ChatKitAssistantComputers = {
|
|
278
|
+
cloud?: {
|
|
279
|
+
viewKey: string;
|
|
280
|
+
};
|
|
281
|
+
/** Host-reported local Shell state; opening emits assistant.computer.open with kind: local. */
|
|
282
|
+
local?: {
|
|
283
|
+
name?: string;
|
|
284
|
+
status: 'loading' | 'unavailable' | 'disabled' | 'ready' | 'connected' | 'error';
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
|
|
234
288
|
export declare type ChatKitClientSecretObject = {
|
|
235
289
|
secret: string;
|
|
236
290
|
organizationId?: string;
|
|
@@ -581,6 +635,15 @@ export declare type ChatKitOptions = {
|
|
|
581
635
|
*/
|
|
582
636
|
header?: {
|
|
583
637
|
enabled?: boolean;
|
|
638
|
+
/** Center the published Assistant character in bubble mode. Defaults to true. */
|
|
639
|
+
character?: {
|
|
640
|
+
enabled?: boolean;
|
|
641
|
+
/** Shows customization actions, emitted as the assistant.customize public effect. */
|
|
642
|
+
customizable?: boolean;
|
|
643
|
+
computers?: ChatKitAssistantComputers;
|
|
644
|
+
/** Honor an explicit reduced-animation preference in addition to the OS setting. */
|
|
645
|
+
reducedMotion?: boolean;
|
|
646
|
+
};
|
|
584
647
|
/** Enable native Electron dragging/OS double-click behavior on unused chat and Workbench header space. Defaults to false. */
|
|
585
648
|
windowDrag?: boolean;
|
|
586
649
|
/**
|
|
@@ -796,6 +859,8 @@ export declare type ChatKitPetBoundsPadding = {
|
|
|
796
859
|
export declare type ChatKitPetCharacter = {
|
|
797
860
|
type: 'sprite-atlas';
|
|
798
861
|
src: string;
|
|
862
|
+
/** v1: 8 × 9; v2: 8 × 11, with 16 directional poses in the final two rows. */
|
|
863
|
+
spriteVersionNumber?: 1 | 2;
|
|
799
864
|
atlas?: ChatKitPetSpriteAtlas;
|
|
800
865
|
};
|
|
801
866
|
|
|
@@ -1434,6 +1499,10 @@ declare type CustomApiConfig = {
|
|
|
1434
1499
|
xpertId?: string;
|
|
1435
1500
|
};
|
|
1436
1501
|
|
|
1502
|
+
export declare function customCharacterSvg(appearance: Extract<AssistantAppearance, {
|
|
1503
|
+
kind: 'character';
|
|
1504
|
+
}>, state?: string, animate?: boolean): string;
|
|
1505
|
+
|
|
1437
1506
|
export declare type DatePicker = {
|
|
1438
1507
|
type: 'DatePicker';
|
|
1439
1508
|
key?: string;
|
|
@@ -1465,6 +1534,8 @@ export declare const DEFAULT_PET_SPRITESHEET_URL = "/pets/boba/spritesheet.webp"
|
|
|
1465
1534
|
|
|
1466
1535
|
export declare const DEFAULT_PET_STORAGE_KEY = "chatkit:pet:position:v1";
|
|
1467
1536
|
|
|
1537
|
+
export declare const defaultCharacterConfig: AssistantCharacterConfig;
|
|
1538
|
+
|
|
1468
1539
|
export declare type Divider = {
|
|
1469
1540
|
type: 'Divider';
|
|
1470
1541
|
key?: string;
|
|
@@ -1975,7 +2046,7 @@ export declare function mergeChatSkillUsages(...groups: ReadonlyArray<readonly C
|
|
|
1975
2046
|
/** Collapse observed operations to the net change, retaining immutable first/last review references. */
|
|
1976
2047
|
export declare function mergeFileChanges(items: ChatFileChange[]): ChatFileChange[];
|
|
1977
2048
|
|
|
1978
|
-
export declare function mergePetSpriteAtlas(override?: ChatKitPetSpriteAtlas): PetSpriteAtlasDefinition;
|
|
2049
|
+
export declare function mergePetSpriteAtlas(override?: ChatKitPetSpriteAtlas, spriteVersionNumber?: 1 | 2): PetSpriteAtlasDefinition;
|
|
1979
2050
|
|
|
1980
2051
|
export declare type MessageContentImageUrl = {
|
|
1981
2052
|
type: 'image_url';
|
|
@@ -2046,6 +2117,8 @@ export declare function normalizeRequestLanguage(locale?: string | null): string
|
|
|
2046
2117
|
|
|
2047
2118
|
export declare function normalizeThreadReference(value: unknown): ChatKitThreadReference | null;
|
|
2048
2119
|
|
|
2120
|
+
export declare function parseAssistantAppearance(value: unknown): AssistantAppearance | undefined;
|
|
2121
|
+
|
|
2049
2122
|
export declare function parseFileActivityContent(value: unknown): TMessageContentFileActivity | null;
|
|
2050
2123
|
|
|
2051
2124
|
export declare function parseFileChangeReport(value: unknown): FileChangeReport | null;
|
|
@@ -2063,6 +2136,12 @@ export declare type PetFrameAnimationDefinition = {
|
|
|
2063
2136
|
frameDurations: readonly number[];
|
|
2064
2137
|
};
|
|
2065
2138
|
|
|
2139
|
+
/** v2's 16 poses are clockwise from up; a central dead zone restores idle. */
|
|
2140
|
+
export declare function petLookFrame(dx: number, dy: number, deadZone?: number): {
|
|
2141
|
+
row: number;
|
|
2142
|
+
column: number;
|
|
2143
|
+
} | null;
|
|
2144
|
+
|
|
2066
2145
|
export declare type PetPosition = {
|
|
2067
2146
|
x: number;
|
|
2068
2147
|
y: number;
|
package/dist/index.js
CHANGED
|
@@ -415,6 +415,170 @@ function normalizeThreadReference(value) {
|
|
|
415
415
|
function isLocator(value) {
|
|
416
416
|
return typeof value === "string" && value.trim().length > 0 && value.length <= 128;
|
|
417
417
|
}
|
|
418
|
+
const CHATKIT_ASSISTANT_CUSTOMIZE_EFFECT = "assistant.customize";
|
|
419
|
+
function parseAssistantAppearance(value) {
|
|
420
|
+
if (!value || typeof value !== "object" || !("version" in value) || value.version !== 1 || !("kind" in value))
|
|
421
|
+
return;
|
|
422
|
+
if (value.kind === "image") return { version: 1, kind: "image" };
|
|
423
|
+
if (!("id" in value) || typeof value.id !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$/.test(value.id))
|
|
424
|
+
return;
|
|
425
|
+
if (value.kind === "character" && "color" in value && typeof value.color === "string" && /^#[0-9a-f]{6}$/i.test(value.color)) {
|
|
426
|
+
if ("config" in value && value.config !== void 0 && !isCharacterConfig(value.config))
|
|
427
|
+
return;
|
|
428
|
+
return value;
|
|
429
|
+
}
|
|
430
|
+
if (value.kind === "pet") {
|
|
431
|
+
if ("spriteVersionNumber" in value && value.spriteVersionNumber !== void 0 && value.spriteVersionNumber !== 1 && value.spriteVersionNumber !== 2) return;
|
|
432
|
+
if ("asset" in value && value.asset !== void 0) {
|
|
433
|
+
const asset = value.asset;
|
|
434
|
+
if (!asset || typeof asset !== "object" || !("type" in asset) || !["sprite-atlas", "animated-image"].includes(String(asset.type)) || !("url" in asset) || typeof asset.url !== "string" || asset.url.length > 4096 || !/^(https?:\/\/|\/(?!\/))/.test(asset.url))
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
return value;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function isCharacterConfig(value) {
|
|
441
|
+
return !!value && typeof value === "object" && "shape" in value && [
|
|
442
|
+
"round",
|
|
443
|
+
"pebble",
|
|
444
|
+
"pill",
|
|
445
|
+
"drop",
|
|
446
|
+
"flame",
|
|
447
|
+
"triangle",
|
|
448
|
+
"square",
|
|
449
|
+
"bag",
|
|
450
|
+
"star",
|
|
451
|
+
"heart",
|
|
452
|
+
"cloud",
|
|
453
|
+
"clover"
|
|
454
|
+
].includes(String(value.shape)) && "eyes" in value && [
|
|
455
|
+
"oval",
|
|
456
|
+
"toon",
|
|
457
|
+
"pill",
|
|
458
|
+
"dot",
|
|
459
|
+
"ring",
|
|
460
|
+
"happy",
|
|
461
|
+
"sleepy",
|
|
462
|
+
"wink",
|
|
463
|
+
"plus",
|
|
464
|
+
"slash",
|
|
465
|
+
"squint"
|
|
466
|
+
].includes(String(value.eyes)) && "mouth" in value && ["none", "smile", "open", "neutral", "o"].includes(String(value.mouth)) && "motion" in value && ["float", "bounce", "sway", "none"].includes(String(value.motion)) && "eyeSize" in value && typeof value.eyeSize === "number" && Number.isFinite(value.eyeSize) && value.eyeSize >= 0.6 && value.eyeSize <= 1.5 && "eyeSpacing" in value && typeof value.eyeSpacing === "number" && Number.isFinite(value.eyeSpacing) && value.eyeSpacing >= 0.55 && value.eyeSpacing <= 1.6 && (!("brows" in value) || value.brows === void 0 || ["none", "flat", "angry", "worried", "raised"].includes(
|
|
467
|
+
String(value.brows)
|
|
468
|
+
)) && (!("ink" in value) || value.ink === void 0 || ["auto", "dark", "light"].includes(String(value.ink))) && (!("tilt" in value) || value.tilt === void 0 || typeof value.tilt === "number" && Number.isFinite(value.tilt) && value.tilt >= -15 && value.tilt <= 15) && (!("speed" in value) || value.speed === void 0 || typeof value.speed === "number" && Number.isFinite(value.speed) && value.speed >= 0.5 && value.speed <= 2) && (!("blink" in value) || value.blink === void 0 || typeof value.blink === "boolean");
|
|
469
|
+
}
|
|
470
|
+
const defaultCharacterConfig = {
|
|
471
|
+
shape: "round",
|
|
472
|
+
eyes: "oval",
|
|
473
|
+
mouth: "smile",
|
|
474
|
+
motion: "float",
|
|
475
|
+
eyeSize: 1,
|
|
476
|
+
eyeSpacing: 1,
|
|
477
|
+
brows: "none",
|
|
478
|
+
ink: "auto",
|
|
479
|
+
tilt: 0,
|
|
480
|
+
speed: 1,
|
|
481
|
+
blink: true
|
|
482
|
+
};
|
|
483
|
+
const shapes = {
|
|
484
|
+
round: '<circle cx="100" cy="100" r="65"/>',
|
|
485
|
+
pebble: '<path d="M34 96 C37 49 77 28 114 38 C161 42 177 84 163 128 C155 164 109 176 68 157 C43 149 30 121 34 96Z"/>',
|
|
486
|
+
pill: '<rect x="26" y="51" width="148" height="99" rx="49"/>',
|
|
487
|
+
drop: '<path d="M100 24 C87 46 39 72 39 111 C39 174 161 174 161 111 C161 72 113 46 100 24Z"/>',
|
|
488
|
+
flame: '<path d="M114 22 C108 59 159 57 164 109 C174 179 35 187 35 118 C34 94 45 79 62 64 C59 89 71 92 74 75 C76 48 96 30 114 22Z"/>',
|
|
489
|
+
triangle: '<path d="M86 35 Q100 13 114 35 L177 142 Q188 165 161 167 L39 167 Q12 165 24 142Z"/>',
|
|
490
|
+
square: '<rect x="37" y="37" width="126" height="126" rx="34"/>',
|
|
491
|
+
bag: '<path d="M78 56 V37 Q78 30 86 30 H114 Q122 30 122 37 V56" fill="none" stroke="currentColor" stroke-width="8"/><rect x="29" y="52" width="142" height="111" rx="22"/>',
|
|
492
|
+
star: '<path d="M92 30 Q100 14 108 30 L126 64 L166 70 Q185 72 171 87 L143 113 L149 152 Q153 172 135 164 L100 144 L65 164 Q47 172 51 152 L57 113 L29 87 Q15 72 34 70 L74 64Z"/>',
|
|
493
|
+
heart: '<path d="M100 60 C58 2 6 49 32 101 C45 129 71 151 100 171 C129 151 155 129 168 101 C194 49 142 2 100 60Z"/>',
|
|
494
|
+
cloud: '<path d="M48 153 C3 152 15 92 45 87 C42 40 93 30 114 58 C150 27 182 68 168 99 C199 139 163 165 133 152 C108 174 75 168 65 152Z"/>',
|
|
495
|
+
clover: '<path d="M100 49 C143 -1 200 63 151 100 C201 141 140 200 100 151 C60 200 -1 141 49 100 C0 60 60 0 100 49Z"/>'
|
|
496
|
+
};
|
|
497
|
+
const finite = (value, fallback, min, max) => typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : fallback;
|
|
498
|
+
function customCharacterSvg(appearance, state = "idle", animate = false) {
|
|
499
|
+
const config = { ...defaultCharacterConfig, ...appearance.config };
|
|
500
|
+
const color = /^#[0-9a-f]{6}$/i.test(appearance.color) ? appearance.color : "#7c6ee6";
|
|
501
|
+
const luminance = [1, 3, 5].map((start) => {
|
|
502
|
+
const channel = parseInt(color.slice(start, start + 2), 16) / 255;
|
|
503
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
504
|
+
});
|
|
505
|
+
const darkBackground = luminance[0] * 0.2126 + luminance[1] * 0.7152 + luminance[2] * 0.0722 < 0.18;
|
|
506
|
+
const ink = config.ink === "light" ? "#ffffff" : config.ink === "dark" ? "#20212c" : darkBackground ? "#ffffff" : "#20212c";
|
|
507
|
+
const speed = finite(config.speed, 1, 0.5, 2);
|
|
508
|
+
const tilt = finite(config.tilt, 0, -15, 15);
|
|
509
|
+
const eyeSize = finite(config.eyeSize, 1, 0.6, 1.5);
|
|
510
|
+
const gap = finite(config.eyeSpacing, 1, 0.55, 1.6) * 18;
|
|
511
|
+
const moving = animate && config.motion !== "none";
|
|
512
|
+
const thinking = state === "review";
|
|
513
|
+
const working = state === "running" || state === "running-right" || state === "running-left";
|
|
514
|
+
const success = state === "waving" || state === "jumping";
|
|
515
|
+
const sleeping = state === "sleeping";
|
|
516
|
+
const alarm = state === "waiting";
|
|
517
|
+
const faceScale = [
|
|
518
|
+
"drop",
|
|
519
|
+
"flame",
|
|
520
|
+
"triangle",
|
|
521
|
+
"star",
|
|
522
|
+
"heart",
|
|
523
|
+
"clover"
|
|
524
|
+
].includes(config.shape) ? 0.78 : 1;
|
|
525
|
+
const faceY = ["drop", "triangle", "flame"].includes(config.shape) ? 10 : 0;
|
|
526
|
+
const eyes = sleeping ? "sleepy" : success ? "happy" : config.eyes;
|
|
527
|
+
const brows = alarm || state === "failed" ? "worried" : config.brows;
|
|
528
|
+
const blink = moving && config.blink !== false && !sleeping ? `<animateTransform attributeName="transform" type="scale" values="1 1;1 1;1 .1;1 1;1 1" keyTimes="0;.83;.87;.91;1" dur="${4.5 / speed}s" repeatCount="indefinite"/>` : "";
|
|
529
|
+
const eye = (x, right) => {
|
|
530
|
+
let drawing;
|
|
531
|
+
switch (eyes) {
|
|
532
|
+
case "happy":
|
|
533
|
+
drawing = '<path d="M-7 1 Q0 -11 7 1"/>';
|
|
534
|
+
break;
|
|
535
|
+
case "sleepy":
|
|
536
|
+
drawing = '<path d="M-7 0 Q0 4 7 0"/>';
|
|
537
|
+
break;
|
|
538
|
+
case "plus":
|
|
539
|
+
drawing = '<path d="M-7 0 H7 M0 -7 V7"/>';
|
|
540
|
+
break;
|
|
541
|
+
case "slash":
|
|
542
|
+
drawing = '<path d="M-5 7 L5 -7"/>';
|
|
543
|
+
break;
|
|
544
|
+
case "squint":
|
|
545
|
+
drawing = `<path d="${right ? "M5 -7 L-3 0 L5 7" : "M-5 -7 L3 0 L-5 7"}"/>`;
|
|
546
|
+
break;
|
|
547
|
+
case "ring":
|
|
548
|
+
drawing = '<ellipse rx="6" ry="8" stroke-width="3"/>';
|
|
549
|
+
break;
|
|
550
|
+
case "dot":
|
|
551
|
+
drawing = `<circle r="4.5" fill="${ink}" stroke="none"/>`;
|
|
552
|
+
break;
|
|
553
|
+
case "pill":
|
|
554
|
+
drawing = `<rect x="-3" y="-9" width="6" height="18" rx="3" fill="${ink}" stroke="none"/>`;
|
|
555
|
+
break;
|
|
556
|
+
case "wink":
|
|
557
|
+
if (right) {
|
|
558
|
+
drawing = '<path d="M-6 -5 L3 0 L-6 5"/>';
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
case "toon":
|
|
562
|
+
drawing = `<ellipse rx="9" ry="11" fill="#ffffff" stroke="#20212c" stroke-width="1"/><ellipse cx="${thinking ? 2 : 0}" cy="${thinking ? -3 : working ? 3 : 1}" rx="4" ry="6" fill="#20212c" stroke="none"/>`;
|
|
563
|
+
break;
|
|
564
|
+
default:
|
|
565
|
+
drawing = `<ellipse rx="5" ry="8" fill="${ink}" stroke="none"/>`;
|
|
566
|
+
}
|
|
567
|
+
return `<g transform="translate(${x} 97)"><g>${["oval", "toon", "dot", "ring", "pill", "wink"].includes(eyes) ? blink : ""}${drawing}</g></g>`;
|
|
568
|
+
};
|
|
569
|
+
const brow = (x, right) => {
|
|
570
|
+
const lift = right ? -1 : 1;
|
|
571
|
+
const path = brows === "flat" ? "M-8 -17 H8" : brows === "angry" ? `M-8 ${-21 - 4 * lift} L8 ${-21 + 4 * lift}` : brows === "worried" ? `M-8 ${-21 + 4 * lift} L8 ${-21 - 4 * lift}` : brows === "raised" ? right ? "M-8 -21 Q0 -30 8 -21" : "M-8 -18 H8" : "";
|
|
572
|
+
return path ? `<path transform="translate(${x} 97)" d="${path}" stroke-width="3"/>` : "";
|
|
573
|
+
};
|
|
574
|
+
const mouth = state === "failed" ? '<path d="M88 130 Q100 116 112 130"/>' : alarm || thinking ? '<ellipse cx="100" cy="127" rx="4" ry="5"/>' : success || config.mouth === "open" ? `<path d="M87 123 Q100 128 113 123 Q111 144 100 144 Q89 144 87 123Z" fill="${ink}"/>` : config.mouth === "none" ? "" : config.mouth === "neutral" || sleeping ? '<path d="M91 127 H109"/>' : config.mouth === "o" ? '<ellipse cx="100" cy="127" rx="5" ry="7"/>' : '<path d="M87 125 Q100 138 113 125"/>';
|
|
575
|
+
const animation = !moving ? "" : state === "failed" ? `<animateTransform attributeName="transform" type="translate" values="0 0;-3 0;3 0;0 0" dur="${0.4 / speed}s" repeatCount="2"/>` : config.motion === "sway" ? `<animateTransform attributeName="transform" type="rotate" values="-5 100 130;5 100 130;-5 100 130" dur="${2.4 / speed}s" repeatCount="indefinite"/>` : `<animateTransform attributeName="transform" type="translate" values="0 0;0 ${success || config.motion === "bounce" ? -12 : sleeping ? -2 : -5};0 0" dur="${(success || config.motion === "bounce" ? 1.1 : sleeping ? 4 : 3) / speed}s" repeatCount="indefinite"/>`;
|
|
576
|
+
const pulse = moving ? `<animate attributeName="opacity" values=".35;1;.35" dur="${1.5 / speed}s" repeatCount="indefinite"/>` : "";
|
|
577
|
+
const activity = thinking ? `<g fill="${ink}" opacity=".6"><circle cx="153" cy="49" r="3"/><circle cx="161" cy="39" r="5"/><circle cx="174" cy="26" r="7"/>${pulse}</g>` : working ? `<g fill="none" stroke="${ink}" stroke-width="3" stroke-linecap="round"><path d="M158 142 H175 M158 150 H183 M158 158 H171"/>${pulse}</g>` : alarm ? `<g fill="${ink}"><circle cx="161" cy="46" r="10"/><path d="M161 40 V47 M161 51 V52" stroke="${color}" stroke-width="2.5"/>${pulse}</g>` : sleeping ? `<path d="M150 60 H163 L151 72 H164 M169 35 H184 L170 48 H185" fill="none" stroke="${ink}" opacity=".5" stroke-width="3"/>` : state === "listening" ? `<g fill="none" stroke="${ink}" stroke-width="3" stroke-linecap="round"><path d="M167 84 V108 M175 91 V101"/>${pulse}</g>` : "";
|
|
578
|
+
const shift = thinking ? "3 -3" : working ? "1 3" : "0 0";
|
|
579
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200"><ellipse cx="100" cy="186" rx="42" ry="5" fill="${color}" opacity=".12"/><g>${animation}<g transform="rotate(${tilt} 100 100)"><g fill="${color}" color="${color}">${shapes[config.shape] ?? shapes.round}</g><g transform="translate(100 ${100 + faceY}) scale(${faceScale}) translate(-100 -100)"><g transform="translate(${shift})" fill="none" stroke="${ink}" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(100 97) scale(${eyeSize}) translate(-100 -97)">${eye(100 - gap, false)}${eye(100 + gap, true)}${brow(100 - gap, false)}${brow(100 + gap, true)}</g>${mouth}</g></g></g></g>${activity}</svg>`;
|
|
580
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
581
|
+
}
|
|
418
582
|
const PET_ANIMATION_NAMES = [
|
|
419
583
|
"idle",
|
|
420
584
|
"running-right",
|
|
@@ -483,6 +647,11 @@ const DEFAULT_PET_SIZE = {
|
|
|
483
647
|
width: petSpriteAtlas.cellWidth,
|
|
484
648
|
height: petSpriteAtlas.cellHeight
|
|
485
649
|
};
|
|
650
|
+
function petLookFrame(dx, dy, deadZone = 12) {
|
|
651
|
+
if (!Number.isFinite(dx) || !Number.isFinite(dy) || Math.hypot(dx, dy) <= deadZone) return null;
|
|
652
|
+
const index = (Math.round(Math.atan2(dx, -dy) / (Math.PI / 8)) + 16) % 16;
|
|
653
|
+
return { row: 9 + Math.floor(index / 8), column: index % 8 };
|
|
654
|
+
}
|
|
486
655
|
const DEFAULT_PET_BOUNDS_PADDING = {
|
|
487
656
|
top: 0,
|
|
488
657
|
right: 0,
|
|
@@ -509,7 +678,7 @@ function mergeFrameAnimation(base, override) {
|
|
|
509
678
|
frameDurations: (override == null ? void 0 : override.frameDurations) && override.frameDurations.length > 0 ? override.frameDurations : base.frameDurations
|
|
510
679
|
};
|
|
511
680
|
}
|
|
512
|
-
function mergePetSpriteAtlas(override) {
|
|
681
|
+
function mergePetSpriteAtlas(override, spriteVersionNumber = 1) {
|
|
513
682
|
var _a;
|
|
514
683
|
const animations = {};
|
|
515
684
|
for (const name of PET_ANIMATION_NAMES) {
|
|
@@ -520,7 +689,7 @@ function mergePetSpriteAtlas(override) {
|
|
|
520
689
|
}
|
|
521
690
|
return {
|
|
522
691
|
columns: (override == null ? void 0 : override.columns) ?? petSpriteAtlas.columns,
|
|
523
|
-
rows: (override == null ? void 0 : override.rows) ?? petSpriteAtlas.rows,
|
|
692
|
+
rows: (override == null ? void 0 : override.rows) ?? (spriteVersionNumber === 2 ? 11 : petSpriteAtlas.rows),
|
|
524
693
|
cellWidth: (override == null ? void 0 : override.cellWidth) ?? petSpriteAtlas.cellWidth,
|
|
525
694
|
cellHeight: (override == null ? void 0 : override.cellHeight) ?? petSpriteAtlas.cellHeight,
|
|
526
695
|
animations
|
|
@@ -569,7 +738,7 @@ function resolvePetCharacter(character) {
|
|
|
569
738
|
return {
|
|
570
739
|
kind: "atlas",
|
|
571
740
|
src: character.src,
|
|
572
|
-
atlas: mergePetSpriteAtlas(character.atlas)
|
|
741
|
+
atlas: mergePetSpriteAtlas(character.atlas, character.spriteVersionNumber)
|
|
573
742
|
};
|
|
574
743
|
}
|
|
575
744
|
function normalizeBoundsPadding(value) {
|
|
@@ -942,6 +1111,7 @@ function countFileChangeLines(report) {
|
|
|
942
1111
|
return { status: "ready", added: m - previous[m], removed: n - previous[m] };
|
|
943
1112
|
}
|
|
944
1113
|
export {
|
|
1114
|
+
CHATKIT_ASSISTANT_CUSTOMIZE_EFFECT,
|
|
945
1115
|
CHATKIT_TASK_SUMMARY_OPEN_RESOURCE_EFFECT,
|
|
946
1116
|
CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED,
|
|
947
1117
|
ChatMessageEventTypeEnum,
|
|
@@ -964,6 +1134,8 @@ export {
|
|
|
964
1134
|
clampPetPosition,
|
|
965
1135
|
countFileChangeLines,
|
|
966
1136
|
createResourceCardContent,
|
|
1137
|
+
customCharacterSvg,
|
|
1138
|
+
defaultCharacterConfig,
|
|
967
1139
|
fileChangeRangeKey,
|
|
968
1140
|
getFileActivityContribution,
|
|
969
1141
|
getLegacyFileActivityContribution,
|
|
@@ -1001,10 +1173,12 @@ export {
|
|
|
1001
1173
|
normalizePetOptions,
|
|
1002
1174
|
normalizeRequestLanguage,
|
|
1003
1175
|
normalizeThreadReference,
|
|
1176
|
+
parseAssistantAppearance,
|
|
1004
1177
|
parseFileActivityContent,
|
|
1005
1178
|
parseFileChangeReport,
|
|
1006
1179
|
parseResourceCard,
|
|
1007
1180
|
parseResourceCardContent,
|
|
1181
|
+
petLookFrame,
|
|
1008
1182
|
petSpriteAtlas,
|
|
1009
1183
|
projectMessageFileActivity,
|
|
1010
1184
|
resolveLocalizedText,
|