@xpert-ai/chatkit-types 0.8.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 +298 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +148 -10
- package/dist/index.js +299 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,121 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const constants = require("./constants.cjs");
|
|
4
4
|
require("@langchain/core/messages/tool");
|
|
5
|
+
function resourceCardId(card) {
|
|
6
|
+
return JSON.stringify([
|
|
7
|
+
card.resource.namespace,
|
|
8
|
+
card.resource.type,
|
|
9
|
+
card.resource.id
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
function nonempty(value) {
|
|
13
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
14
|
+
}
|
|
15
|
+
function scalar(value) {
|
|
16
|
+
return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
17
|
+
}
|
|
18
|
+
function parseResourceCard(value) {
|
|
19
|
+
if (!value || typeof value !== "object" || !("resource" in value) || !("title" in value) || !nonempty(value.title) || !("open" in value))
|
|
20
|
+
return null;
|
|
21
|
+
const resource = value.resource;
|
|
22
|
+
if (!resource || typeof resource !== "object" || !("namespace" in resource) || !nonempty(resource.namespace) || !("type" in resource) || !nonempty(resource.type) || !("id" in resource) || !nonempty(resource.id))
|
|
23
|
+
return null;
|
|
24
|
+
if ("artifactId" in resource && !nonempty(resource.artifactId)) return null;
|
|
25
|
+
const open = value.open;
|
|
26
|
+
if (!open || typeof open !== "object" || !("target" in open) || open.target !== "workbench.view" && open.target !== "assistant.project" || !("viewKey" in open) || !nonempty(open.viewKey))
|
|
27
|
+
return null;
|
|
28
|
+
if (Object.keys(open).some(
|
|
29
|
+
(key) => ![
|
|
30
|
+
"target",
|
|
31
|
+
"viewKey",
|
|
32
|
+
"selectionId",
|
|
33
|
+
"parameters",
|
|
34
|
+
"projectId"
|
|
35
|
+
].includes(key)
|
|
36
|
+
))
|
|
37
|
+
return null;
|
|
38
|
+
if ("selectionId" in open && !nonempty(open.selectionId)) return null;
|
|
39
|
+
const parameters = {};
|
|
40
|
+
if ("parameters" in open) {
|
|
41
|
+
if (!open.parameters || typeof open.parameters !== "object" || Array.isArray(open.parameters))
|
|
42
|
+
return null;
|
|
43
|
+
for (const [key, item] of Object.entries(open.parameters)) {
|
|
44
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) return null;
|
|
45
|
+
if (scalar(item)) parameters[key] = item;
|
|
46
|
+
else if (Array.isArray(item) && item.every(scalar))
|
|
47
|
+
parameters[key] = item;
|
|
48
|
+
else return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const common = {
|
|
52
|
+
viewKey: open.viewKey,
|
|
53
|
+
..."selectionId" in open && nonempty(open.selectionId) ? { selectionId: open.selectionId } : {},
|
|
54
|
+
..."parameters" in open ? { parameters } : {}
|
|
55
|
+
};
|
|
56
|
+
let target;
|
|
57
|
+
if (open.target === "assistant.project") {
|
|
58
|
+
if (!("projectId" in open) || !nonempty(open.projectId)) return null;
|
|
59
|
+
target = {
|
|
60
|
+
...common,
|
|
61
|
+
target: "assistant.project",
|
|
62
|
+
projectId: open.projectId
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
if ("projectId" in open) return null;
|
|
66
|
+
target = { ...common, target: "workbench.view" };
|
|
67
|
+
}
|
|
68
|
+
if ("description" in value && typeof value.description !== "string")
|
|
69
|
+
return null;
|
|
70
|
+
let icon;
|
|
71
|
+
if ("icon" in value) {
|
|
72
|
+
const candidate = value.icon;
|
|
73
|
+
if (!candidate || typeof candidate !== "object" || !("type" in candidate) || !("value" in candidate) || !nonempty(candidate.value))
|
|
74
|
+
return null;
|
|
75
|
+
if (candidate.type !== "svg" && candidate.type !== "emoji" && candidate.type !== "font")
|
|
76
|
+
return null;
|
|
77
|
+
icon = { type: candidate.type, value: candidate.value };
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
resource: {
|
|
81
|
+
namespace: resource.namespace,
|
|
82
|
+
type: resource.type,
|
|
83
|
+
id: resource.id,
|
|
84
|
+
..."artifactId" in resource && nonempty(resource.artifactId) ? { artifactId: resource.artifactId } : {}
|
|
85
|
+
},
|
|
86
|
+
title: value.title,
|
|
87
|
+
..."description" in value ? { description: value.description } : {},
|
|
88
|
+
...icon ? { icon } : {},
|
|
89
|
+
open: target
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function createResourceCardContent(card) {
|
|
93
|
+
const data = parseResourceCard(card);
|
|
94
|
+
if (!data) throw new Error("Invalid resource card");
|
|
95
|
+
return { type: "resource_card", id: resourceCardId(data), data };
|
|
96
|
+
}
|
|
97
|
+
function isResourceCardContent(value) {
|
|
98
|
+
return !!value && typeof value === "object" && "type" in value && value.type === "resource_card";
|
|
99
|
+
}
|
|
100
|
+
function parseResourceCardContent(value) {
|
|
101
|
+
if (!value || typeof value !== "object" || !("type" in value) || value.type !== "resource_card" || !("data" in value))
|
|
102
|
+
return null;
|
|
103
|
+
const card = parseResourceCard(value.data);
|
|
104
|
+
if (!card) return null;
|
|
105
|
+
return {
|
|
106
|
+
...createResourceCardContent(card),
|
|
107
|
+
..."messageId" in value && nonempty(value.messageId) ? { messageId: value.messageId } : {},
|
|
108
|
+
..."executionId" in value && nonempty(value.executionId) ? { executionId: value.executionId } : {}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function upsertResourceCardContent(parts, card) {
|
|
112
|
+
const index = parts.findIndex(
|
|
113
|
+
(part) => {
|
|
114
|
+
var _a;
|
|
115
|
+
return ((_a = parseResourceCardContent(part)) == null ? void 0 : _a.id) === card.id;
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
return index < 0 ? [...parts, card] : parts.map((part, i) => i === index ? card : part);
|
|
119
|
+
}
|
|
5
120
|
function isApprovalHostReference(value) {
|
|
6
121
|
return !!value && typeof value === "object" && "kind" in value && typeof value.kind === "string" && value.kind.length > 0 && "id" in value && typeof value.id === "string" && value.id.length > 0 && "expiresAt" in value && typeof value.expiresAt === "number" && Number.isFinite(value.expiresAt);
|
|
7
122
|
}
|
|
@@ -302,6 +417,170 @@ function normalizeThreadReference(value) {
|
|
|
302
417
|
function isLocator(value) {
|
|
303
418
|
return typeof value === "string" && value.trim().length > 0 && value.length <= 128;
|
|
304
419
|
}
|
|
420
|
+
const CHATKIT_ASSISTANT_CUSTOMIZE_EFFECT = "assistant.customize";
|
|
421
|
+
function parseAssistantAppearance(value) {
|
|
422
|
+
if (!value || typeof value !== "object" || !("version" in value) || value.version !== 1 || !("kind" in value))
|
|
423
|
+
return;
|
|
424
|
+
if (value.kind === "image") return { version: 1, kind: "image" };
|
|
425
|
+
if (!("id" in value) || typeof value.id !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$/.test(value.id))
|
|
426
|
+
return;
|
|
427
|
+
if (value.kind === "character" && "color" in value && typeof value.color === "string" && /^#[0-9a-f]{6}$/i.test(value.color)) {
|
|
428
|
+
if ("config" in value && value.config !== void 0 && !isCharacterConfig(value.config))
|
|
429
|
+
return;
|
|
430
|
+
return value;
|
|
431
|
+
}
|
|
432
|
+
if (value.kind === "pet") {
|
|
433
|
+
if ("spriteVersionNumber" in value && value.spriteVersionNumber !== void 0 && value.spriteVersionNumber !== 1 && value.spriteVersionNumber !== 2) return;
|
|
434
|
+
if ("asset" in value && value.asset !== void 0) {
|
|
435
|
+
const asset = value.asset;
|
|
436
|
+
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))
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
return value;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function isCharacterConfig(value) {
|
|
443
|
+
return !!value && typeof value === "object" && "shape" in value && [
|
|
444
|
+
"round",
|
|
445
|
+
"pebble",
|
|
446
|
+
"pill",
|
|
447
|
+
"drop",
|
|
448
|
+
"flame",
|
|
449
|
+
"triangle",
|
|
450
|
+
"square",
|
|
451
|
+
"bag",
|
|
452
|
+
"star",
|
|
453
|
+
"heart",
|
|
454
|
+
"cloud",
|
|
455
|
+
"clover"
|
|
456
|
+
].includes(String(value.shape)) && "eyes" in value && [
|
|
457
|
+
"oval",
|
|
458
|
+
"toon",
|
|
459
|
+
"pill",
|
|
460
|
+
"dot",
|
|
461
|
+
"ring",
|
|
462
|
+
"happy",
|
|
463
|
+
"sleepy",
|
|
464
|
+
"wink",
|
|
465
|
+
"plus",
|
|
466
|
+
"slash",
|
|
467
|
+
"squint"
|
|
468
|
+
].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(
|
|
469
|
+
String(value.brows)
|
|
470
|
+
)) && (!("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");
|
|
471
|
+
}
|
|
472
|
+
const defaultCharacterConfig = {
|
|
473
|
+
shape: "round",
|
|
474
|
+
eyes: "oval",
|
|
475
|
+
mouth: "smile",
|
|
476
|
+
motion: "float",
|
|
477
|
+
eyeSize: 1,
|
|
478
|
+
eyeSpacing: 1,
|
|
479
|
+
brows: "none",
|
|
480
|
+
ink: "auto",
|
|
481
|
+
tilt: 0,
|
|
482
|
+
speed: 1,
|
|
483
|
+
blink: true
|
|
484
|
+
};
|
|
485
|
+
const shapes = {
|
|
486
|
+
round: '<circle cx="100" cy="100" r="65"/>',
|
|
487
|
+
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"/>',
|
|
488
|
+
pill: '<rect x="26" y="51" width="148" height="99" rx="49"/>',
|
|
489
|
+
drop: '<path d="M100 24 C87 46 39 72 39 111 C39 174 161 174 161 111 C161 72 113 46 100 24Z"/>',
|
|
490
|
+
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"/>',
|
|
491
|
+
triangle: '<path d="M86 35 Q100 13 114 35 L177 142 Q188 165 161 167 L39 167 Q12 165 24 142Z"/>',
|
|
492
|
+
square: '<rect x="37" y="37" width="126" height="126" rx="34"/>',
|
|
493
|
+
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"/>',
|
|
494
|
+
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"/>',
|
|
495
|
+
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"/>',
|
|
496
|
+
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"/>',
|
|
497
|
+
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"/>'
|
|
498
|
+
};
|
|
499
|
+
const finite = (value, fallback, min, max) => typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : fallback;
|
|
500
|
+
function customCharacterSvg(appearance, state = "idle", animate = false) {
|
|
501
|
+
const config = { ...defaultCharacterConfig, ...appearance.config };
|
|
502
|
+
const color = /^#[0-9a-f]{6}$/i.test(appearance.color) ? appearance.color : "#7c6ee6";
|
|
503
|
+
const luminance = [1, 3, 5].map((start) => {
|
|
504
|
+
const channel = parseInt(color.slice(start, start + 2), 16) / 255;
|
|
505
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
506
|
+
});
|
|
507
|
+
const darkBackground = luminance[0] * 0.2126 + luminance[1] * 0.7152 + luminance[2] * 0.0722 < 0.18;
|
|
508
|
+
const ink = config.ink === "light" ? "#ffffff" : config.ink === "dark" ? "#20212c" : darkBackground ? "#ffffff" : "#20212c";
|
|
509
|
+
const speed = finite(config.speed, 1, 0.5, 2);
|
|
510
|
+
const tilt = finite(config.tilt, 0, -15, 15);
|
|
511
|
+
const eyeSize = finite(config.eyeSize, 1, 0.6, 1.5);
|
|
512
|
+
const gap = finite(config.eyeSpacing, 1, 0.55, 1.6) * 18;
|
|
513
|
+
const moving = animate && config.motion !== "none";
|
|
514
|
+
const thinking = state === "review";
|
|
515
|
+
const working = state === "running" || state === "running-right" || state === "running-left";
|
|
516
|
+
const success = state === "waving" || state === "jumping";
|
|
517
|
+
const sleeping = state === "sleeping";
|
|
518
|
+
const alarm = state === "waiting";
|
|
519
|
+
const faceScale = [
|
|
520
|
+
"drop",
|
|
521
|
+
"flame",
|
|
522
|
+
"triangle",
|
|
523
|
+
"star",
|
|
524
|
+
"heart",
|
|
525
|
+
"clover"
|
|
526
|
+
].includes(config.shape) ? 0.78 : 1;
|
|
527
|
+
const faceY = ["drop", "triangle", "flame"].includes(config.shape) ? 10 : 0;
|
|
528
|
+
const eyes = sleeping ? "sleepy" : success ? "happy" : config.eyes;
|
|
529
|
+
const brows = alarm || state === "failed" ? "worried" : config.brows;
|
|
530
|
+
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"/>` : "";
|
|
531
|
+
const eye = (x, right) => {
|
|
532
|
+
let drawing;
|
|
533
|
+
switch (eyes) {
|
|
534
|
+
case "happy":
|
|
535
|
+
drawing = '<path d="M-7 1 Q0 -11 7 1"/>';
|
|
536
|
+
break;
|
|
537
|
+
case "sleepy":
|
|
538
|
+
drawing = '<path d="M-7 0 Q0 4 7 0"/>';
|
|
539
|
+
break;
|
|
540
|
+
case "plus":
|
|
541
|
+
drawing = '<path d="M-7 0 H7 M0 -7 V7"/>';
|
|
542
|
+
break;
|
|
543
|
+
case "slash":
|
|
544
|
+
drawing = '<path d="M-5 7 L5 -7"/>';
|
|
545
|
+
break;
|
|
546
|
+
case "squint":
|
|
547
|
+
drawing = `<path d="${right ? "M5 -7 L-3 0 L5 7" : "M-5 -7 L3 0 L-5 7"}"/>`;
|
|
548
|
+
break;
|
|
549
|
+
case "ring":
|
|
550
|
+
drawing = '<ellipse rx="6" ry="8" stroke-width="3"/>';
|
|
551
|
+
break;
|
|
552
|
+
case "dot":
|
|
553
|
+
drawing = `<circle r="4.5" fill="${ink}" stroke="none"/>`;
|
|
554
|
+
break;
|
|
555
|
+
case "pill":
|
|
556
|
+
drawing = `<rect x="-3" y="-9" width="6" height="18" rx="3" fill="${ink}" stroke="none"/>`;
|
|
557
|
+
break;
|
|
558
|
+
case "wink":
|
|
559
|
+
if (right) {
|
|
560
|
+
drawing = '<path d="M-6 -5 L3 0 L-6 5"/>';
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
case "toon":
|
|
564
|
+
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"/>`;
|
|
565
|
+
break;
|
|
566
|
+
default:
|
|
567
|
+
drawing = `<ellipse rx="5" ry="8" fill="${ink}" stroke="none"/>`;
|
|
568
|
+
}
|
|
569
|
+
return `<g transform="translate(${x} 97)"><g>${["oval", "toon", "dot", "ring", "pill", "wink"].includes(eyes) ? blink : ""}${drawing}</g></g>`;
|
|
570
|
+
};
|
|
571
|
+
const brow = (x, right) => {
|
|
572
|
+
const lift = right ? -1 : 1;
|
|
573
|
+
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" : "";
|
|
574
|
+
return path ? `<path transform="translate(${x} 97)" d="${path}" stroke-width="3"/>` : "";
|
|
575
|
+
};
|
|
576
|
+
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"/>';
|
|
577
|
+
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"/>`;
|
|
578
|
+
const pulse = moving ? `<animate attributeName="opacity" values=".35;1;.35" dur="${1.5 / speed}s" repeatCount="indefinite"/>` : "";
|
|
579
|
+
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>` : "";
|
|
580
|
+
const shift = thinking ? "3 -3" : working ? "1 3" : "0 0";
|
|
581
|
+
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>`;
|
|
582
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
583
|
+
}
|
|
305
584
|
const PET_ANIMATION_NAMES = [
|
|
306
585
|
"idle",
|
|
307
586
|
"running-right",
|
|
@@ -370,6 +649,11 @@ const DEFAULT_PET_SIZE = {
|
|
|
370
649
|
width: petSpriteAtlas.cellWidth,
|
|
371
650
|
height: petSpriteAtlas.cellHeight
|
|
372
651
|
};
|
|
652
|
+
function petLookFrame(dx, dy, deadZone = 12) {
|
|
653
|
+
if (!Number.isFinite(dx) || !Number.isFinite(dy) || Math.hypot(dx, dy) <= deadZone) return null;
|
|
654
|
+
const index = (Math.round(Math.atan2(dx, -dy) / (Math.PI / 8)) + 16) % 16;
|
|
655
|
+
return { row: 9 + Math.floor(index / 8), column: index % 8 };
|
|
656
|
+
}
|
|
373
657
|
const DEFAULT_PET_BOUNDS_PADDING = {
|
|
374
658
|
top: 0,
|
|
375
659
|
right: 0,
|
|
@@ -396,7 +680,7 @@ function mergeFrameAnimation(base, override) {
|
|
|
396
680
|
frameDurations: (override == null ? void 0 : override.frameDurations) && override.frameDurations.length > 0 ? override.frameDurations : base.frameDurations
|
|
397
681
|
};
|
|
398
682
|
}
|
|
399
|
-
function mergePetSpriteAtlas(override) {
|
|
683
|
+
function mergePetSpriteAtlas(override, spriteVersionNumber = 1) {
|
|
400
684
|
var _a;
|
|
401
685
|
const animations = {};
|
|
402
686
|
for (const name of PET_ANIMATION_NAMES) {
|
|
@@ -407,7 +691,7 @@ function mergePetSpriteAtlas(override) {
|
|
|
407
691
|
}
|
|
408
692
|
return {
|
|
409
693
|
columns: (override == null ? void 0 : override.columns) ?? petSpriteAtlas.columns,
|
|
410
|
-
rows: (override == null ? void 0 : override.rows) ?? petSpriteAtlas.rows,
|
|
694
|
+
rows: (override == null ? void 0 : override.rows) ?? (spriteVersionNumber === 2 ? 11 : petSpriteAtlas.rows),
|
|
411
695
|
cellWidth: (override == null ? void 0 : override.cellWidth) ?? petSpriteAtlas.cellWidth,
|
|
412
696
|
cellHeight: (override == null ? void 0 : override.cellHeight) ?? petSpriteAtlas.cellHeight,
|
|
413
697
|
animations
|
|
@@ -456,7 +740,7 @@ function resolvePetCharacter(character) {
|
|
|
456
740
|
return {
|
|
457
741
|
kind: "atlas",
|
|
458
742
|
src: character.src,
|
|
459
|
-
atlas: mergePetSpriteAtlas(character.atlas)
|
|
743
|
+
atlas: mergePetSpriteAtlas(character.atlas, character.spriteVersionNumber)
|
|
460
744
|
};
|
|
461
745
|
}
|
|
462
746
|
function normalizeBoundsPadding(value) {
|
|
@@ -833,6 +1117,7 @@ exports.ChatMessageEventTypeEnum = constants.ChatMessageEventTypeEnum;
|
|
|
833
1117
|
exports.ChatMessageStepCategory = constants.ChatMessageStepCategory;
|
|
834
1118
|
exports.ChatMessageTypeEnum = constants.ChatMessageTypeEnum;
|
|
835
1119
|
exports.STATE_VARIABLE_HUMAN = constants.STATE_VARIABLE_HUMAN;
|
|
1120
|
+
exports.CHATKIT_ASSISTANT_CUSTOMIZE_EFFECT = CHATKIT_ASSISTANT_CUSTOMIZE_EFFECT;
|
|
836
1121
|
exports.CHATKIT_TASK_SUMMARY_OPEN_RESOURCE_EFFECT = CHATKIT_TASK_SUMMARY_OPEN_RESOURCE_EFFECT;
|
|
837
1122
|
exports.DEFAULT_PET_BOUNDS_PADDING = DEFAULT_PET_BOUNDS_PADDING;
|
|
838
1123
|
exports.DEFAULT_PET_SIZE = DEFAULT_PET_SIZE;
|
|
@@ -849,6 +1134,9 @@ exports.TOOL_OUTPUT_PRESENTATION_VERSION = TOOL_OUTPUT_PRESENTATION_VERSION;
|
|
|
849
1134
|
exports.chatSkillUsageKey = chatSkillUsageKey;
|
|
850
1135
|
exports.clampPetPosition = clampPetPosition;
|
|
851
1136
|
exports.countFileChangeLines = countFileChangeLines;
|
|
1137
|
+
exports.createResourceCardContent = createResourceCardContent;
|
|
1138
|
+
exports.customCharacterSvg = customCharacterSvg;
|
|
1139
|
+
exports.defaultCharacterConfig = defaultCharacterConfig;
|
|
852
1140
|
exports.fileChangeRangeKey = fileChangeRangeKey;
|
|
853
1141
|
exports.getFileActivityContribution = getFileActivityContribution;
|
|
854
1142
|
exports.getLegacyFileActivityContribution = getLegacyFileActivityContribution;
|
|
@@ -870,6 +1158,7 @@ exports.isInterruptRequest = isInterruptRequest;
|
|
|
870
1158
|
exports.isLangGraphInterrupt = isLangGraphInterrupt;
|
|
871
1159
|
exports.isLangGraphInterruptPayload = isLangGraphInterruptPayload;
|
|
872
1160
|
exports.isLangGraphInterruptTask = isLangGraphInterruptTask;
|
|
1161
|
+
exports.isResourceCardContent = isResourceCardContent;
|
|
873
1162
|
exports.isToolCallInterrupt = isToolCallInterrupt;
|
|
874
1163
|
exports.isToolCallInterruptPayload = isToolCallInterruptPayload;
|
|
875
1164
|
exports.isToolCallInterruptTask = isToolCallInterruptTask;
|
|
@@ -885,11 +1174,17 @@ exports.normalizeHITLRequest = normalizeHITLRequest;
|
|
|
885
1174
|
exports.normalizePetOptions = normalizePetOptions;
|
|
886
1175
|
exports.normalizeRequestLanguage = normalizeRequestLanguage;
|
|
887
1176
|
exports.normalizeThreadReference = normalizeThreadReference;
|
|
1177
|
+
exports.parseAssistantAppearance = parseAssistantAppearance;
|
|
888
1178
|
exports.parseFileActivityContent = parseFileActivityContent;
|
|
889
1179
|
exports.parseFileChangeReport = parseFileChangeReport;
|
|
1180
|
+
exports.parseResourceCard = parseResourceCard;
|
|
1181
|
+
exports.parseResourceCardContent = parseResourceCardContent;
|
|
1182
|
+
exports.petLookFrame = petLookFrame;
|
|
890
1183
|
exports.petSpriteAtlas = petSpriteAtlas;
|
|
891
1184
|
exports.projectMessageFileActivity = projectMessageFileActivity;
|
|
892
1185
|
exports.resolveLocalizedText = resolveLocalizedText;
|
|
893
1186
|
exports.resolvePetCharacter = resolvePetCharacter;
|
|
1187
|
+
exports.resourceCardId = resourceCardId;
|
|
894
1188
|
exports.upsertFileActivityContent = upsertFileActivityContent;
|
|
1189
|
+
exports.upsertResourceCardContent = upsertResourceCardContent;
|
|
895
1190
|
//# sourceMappingURL=index.cjs.map
|