@xpert-ai/chatkit-types 0.11.1 → 0.12.1

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.d.ts CHANGED
@@ -514,6 +514,25 @@ export declare interface ChatkitMessage {
514
514
  visibleAt?: string | Date | null;
515
515
  }
516
516
 
517
+ /**
518
+ * A Web Component that serves as the entry point for a ChatKit integration.
519
+ * * @noInheritDoc
520
+ */
521
+ export declare type ChatKitMessageFocusRequest = {
522
+ conversationId: string;
523
+ threadId: string;
524
+ messageId: string;
525
+ };
526
+
527
+ export declare type ChatKitMessageFocusResult = {
528
+ success: true;
529
+ status: 'opened';
530
+ } | {
531
+ success: false;
532
+ code: string;
533
+ message?: string;
534
+ };
535
+
517
536
  export declare type ChatKitMessageNavigationOptions = {
518
537
  /**
519
538
  * Whether to show the message quick navigation rail.
@@ -780,6 +799,8 @@ export declare type ChatKitOptions = {
780
799
  selection?: ProjectSelection;
781
800
  /** Offer automatic creation on first send when the Assistant supports it. */
782
801
  autoNewEnabled?: boolean;
802
+ /** Describe applications that create only after a setup App is confirmed. */
803
+ autoNewMode?: 'on-send' | 'after-confirmation';
783
804
  /** Hide the no-Project choice for Assistants requiring a Project workspace. */
784
805
  allowNone?: boolean;
785
806
  /**
@@ -1477,6 +1498,8 @@ export declare interface ConversationResourceCard {
1477
1498
  title: string;
1478
1499
  description?: string;
1479
1500
  icon?: IconDefinition;
1501
+ /** Ordered content blocks; unknown kinds degrade to the base resource card. */
1502
+ content?: ResourceCardContent[];
1480
1503
  open: ResourceCardOpenTarget;
1481
1504
  }
1482
1505
 
@@ -2378,8 +2401,48 @@ export declare function resolveLocalizedText(value: unknown, language?: string):
2378
2401
 
2379
2402
  export declare function resolvePetCharacter(character: ChatKitPetCharacter): ResolvedPetCharacter | null;
2380
2403
 
2404
+ /** Ordered presentation blocks, independent of the business resource's type. */
2405
+ export declare type ResourceCardContent = {
2406
+ title?: string;
2407
+ } & ({
2408
+ kind: 'image-gallery';
2409
+ images: ResourceCardImage[];
2410
+ } | {
2411
+ kind: 'file-list';
2412
+ files: ResourceCardFile[];
2413
+ } | {
2414
+ kind: 'fields';
2415
+ fields: ResourceCardField[];
2416
+ });
2417
+
2418
+ export declare interface ResourceCardField {
2419
+ label: string;
2420
+ value: string;
2421
+ }
2422
+
2423
+ export declare interface ResourceCardFile {
2424
+ id: string;
2425
+ title: string;
2426
+ description?: string;
2427
+ file: ResourceCardFileReference;
2428
+ }
2429
+
2430
+ /** Stable provider references; credentials, temporary URLs and bytes never enter messages. */
2431
+ export declare interface ResourceCardFileReference {
2432
+ viewKey: string;
2433
+ fileKey: string;
2434
+ targetId: string;
2435
+ }
2436
+
2381
2437
  export declare function resourceCardId(card: ConversationResourceCard): string;
2382
2438
 
2439
+ export declare interface ResourceCardImage {
2440
+ id: string;
2441
+ title: string;
2442
+ alt?: string;
2443
+ file: ResourceCardFileReference;
2444
+ }
2445
+
2383
2446
  export declare type ResourceCardOpenTarget = {
2384
2447
  viewKey: string;
2385
2448
  selectionId?: string;
@@ -2389,6 +2452,11 @@ export declare type ResourceCardOpenTarget = {
2389
2452
  } | {
2390
2453
  target: 'assistant.project';
2391
2454
  projectId: string;
2455
+ } | {
2456
+ target: 'workbench.file';
2457
+ fileKey: string;
2458
+ targetId: string;
2459
+ previewFile?: ResourceCardFileReference;
2392
2460
  });
2393
2461
 
2394
2462
  export declare type ResourceCardScalar = string | number | boolean | null;
@@ -2527,6 +2595,22 @@ export declare type SurfaceColors = {
2527
2595
  foreground: string;
2528
2596
  };
2529
2597
 
2598
+ /** Business outcome reported by a server tool, independent of model/runtime completion. */
2599
+ export declare type TAgentExecutionOutcome = {
2600
+ status: 'accepted' | 'already_completed' | 'not_claimed' | 'blocked' | 'failed' | 'incomplete';
2601
+ subjectId: string;
2602
+ accepted: boolean;
2603
+ message?: string;
2604
+ versionId?: string;
2605
+ };
2606
+
2607
+ /** Only tool artifacts from this exact invocation may supply its business result. */
2608
+ export declare type TAgentExecutionOutcomeArtifact = {
2609
+ type: 'agent_execution_outcome';
2610
+ executionId: string;
2611
+ outcome: TAgentExecutionOutcome;
2612
+ };
2613
+
2530
2614
  /**
2531
2615
  * Data type for chat event message
2532
2616
  */
@@ -3258,10 +3342,6 @@ export declare type WorkspaceConnectorConnectResult = {
3258
3342
  status: 'connected' | 'cancelled';
3259
3343
  };
3260
3344
 
3261
- /**
3262
- * A Web Component that serves as the entry point for a ChatKit integration.
3263
- * * @noInheritDoc
3264
- */
3265
3345
  export declare interface XpertAIChatKit extends HTMLElement {
3266
3346
  /**
3267
3347
  * Applies configuration options to the ChatKit instance.
@@ -3273,6 +3353,8 @@ export declare interface XpertAIChatKit extends HTMLElement {
3273
3353
  focusComposer(): Promise<void>;
3274
3354
  /** Changes the active thread. Pass `null` to switch to a new thread. */
3275
3355
  setThreadId(threadId: string | null): Promise<void>;
3356
+ /** Locate an authorized message in the active branch, loading older history when necessary. */
3357
+ focusMessage(request: ChatKitMessageFocusRequest): Promise<ChatKitMessageFocusResult>;
3276
3358
  /**
3277
3359
  * Sends a custom application-defined action to your backend.
3278
3360
  */
package/dist/index.js CHANGED
@@ -1,5 +1,88 @@
1
1
  import { CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED, ChatMessageEventTypeEnum, ChatMessageStepCategory, ChatMessageTypeEnum, STATE_VARIABLE_HUMAN } from "./constants.js";
2
2
  import "@langchain/core/messages/tool";
3
+ function nonempty$1(value) {
4
+ return typeof value === "string" && value.trim().length > 0;
5
+ }
6
+ function parseFileReference(value) {
7
+ if (!value || typeof value !== "object" || !("viewKey" in value) || !nonempty$1(value.viewKey) || !("fileKey" in value) || !nonempty$1(value.fileKey) || !("targetId" in value) || !nonempty$1(value.targetId) || Object.keys(value).some(
8
+ (key) => !["viewKey", "fileKey", "targetId"].includes(key)
9
+ ))
10
+ return null;
11
+ return {
12
+ viewKey: value.viewKey,
13
+ fileKey: value.fileKey,
14
+ targetId: value.targetId
15
+ };
16
+ }
17
+ function parseFile(value) {
18
+ if (!value || typeof value !== "object" || !("id" in value) || !nonempty$1(value.id) || !("title" in value) || !nonempty$1(value.title) || !("file" in value) || "description" in value && typeof value.description !== "string")
19
+ return null;
20
+ const file = parseFileReference(value.file);
21
+ if (!file) return null;
22
+ return {
23
+ id: value.id,
24
+ title: value.title,
25
+ file,
26
+ ..."description" in value && typeof value.description === "string" ? { description: value.description } : {}
27
+ };
28
+ }
29
+ function parseImage(value) {
30
+ const item = parseFile(value);
31
+ if (!item || !value || typeof value !== "object" || "alt" in value && typeof value.alt !== "string")
32
+ return null;
33
+ return {
34
+ id: item.id,
35
+ title: item.title,
36
+ file: item.file,
37
+ ..."alt" in value && typeof value.alt === "string" ? { alt: value.alt } : {}
38
+ };
39
+ }
40
+ function parseField(value) {
41
+ if (!value || typeof value !== "object" || !("label" in value) || !nonempty$1(value.label) || !("value" in value) || typeof value.value !== "string")
42
+ return null;
43
+ return { label: value.label, value: value.value };
44
+ }
45
+ function parseItems(value, parse) {
46
+ if (!Array.isArray(value) || value.length > 100) return null;
47
+ const items = [];
48
+ for (const raw of value) {
49
+ const item = parse(raw);
50
+ if (!item) return null;
51
+ items.push(item);
52
+ }
53
+ return items;
54
+ }
55
+ function distinctIds(items) {
56
+ return new Set(items.map((item) => item.id)).size === items.length;
57
+ }
58
+ function parseBlock(value) {
59
+ if (!value || typeof value !== "object" || !("kind" in value) || "title" in value && typeof value.title !== "string")
60
+ return null;
61
+ const title = "title" in value && typeof value.title === "string" ? { title: value.title } : {};
62
+ switch (value.kind) {
63
+ case "image-gallery": {
64
+ const images = "images" in value ? parseItems(value.images, parseImage) : null;
65
+ return (images == null ? void 0 : images.length) && distinctIds(images) ? { kind: "image-gallery", ...title, images } : null;
66
+ }
67
+ case "file-list": {
68
+ const files = "files" in value ? parseItems(value.files, parseFile) : null;
69
+ return (files == null ? void 0 : files.length) && distinctIds(files) ? { kind: "file-list", ...title, files } : null;
70
+ }
71
+ case "fields": {
72
+ const fields = "fields" in value ? parseItems(value.fields, parseField) : null;
73
+ return (fields == null ? void 0 : fields.length) ? { kind: "fields", ...title, fields } : null;
74
+ }
75
+ default:
76
+ return null;
77
+ }
78
+ }
79
+ function parseResourceCardBlocks(value) {
80
+ if (!Array.isArray(value)) return [];
81
+ return value.slice(0, 32).flatMap((item) => {
82
+ const block = parseBlock(item);
83
+ return block ? [block] : [];
84
+ });
85
+ }
3
86
  function resourceCardId(card) {
4
87
  return JSON.stringify([
5
88
  card.resource.namespace,
@@ -21,7 +104,7 @@ function parseResourceCard(value) {
21
104
  return null;
22
105
  if ("artifactId" in resource && !nonempty(resource.artifactId)) return null;
23
106
  const open = value.open;
24
- if (!open || typeof open !== "object" || !("target" in open) || open.target !== "workbench.view" && open.target !== "assistant.project" || !("viewKey" in open) || !nonempty(open.viewKey))
107
+ if (!open || typeof open !== "object" || !("target" in open) || open.target !== "workbench.view" && open.target !== "assistant.project" && open.target !== "workbench.file" || !("viewKey" in open) || !nonempty(open.viewKey))
25
108
  return null;
26
109
  if (Object.keys(open).some(
27
110
  (key) => ![
@@ -29,7 +112,10 @@ function parseResourceCard(value) {
29
112
  "viewKey",
30
113
  "selectionId",
31
114
  "parameters",
32
- "projectId"
115
+ "projectId",
116
+ "fileKey",
117
+ "targetId",
118
+ "previewFile"
33
119
  ].includes(key)
34
120
  ))
35
121
  return null;
@@ -52,7 +138,21 @@ function parseResourceCard(value) {
52
138
  ..."parameters" in open ? { parameters } : {}
53
139
  };
54
140
  let target;
55
- if (open.target === "assistant.project") {
141
+ if (open.target === "workbench.file") {
142
+ if ("projectId" in open || "selectionId" in open || "parameters" in open || !("fileKey" in open) || !nonempty(open.fileKey) || !("targetId" in open) || !nonempty(open.targetId))
143
+ return null;
144
+ const previewFile = "previewFile" in open ? parseFileReference(open.previewFile) : void 0;
145
+ if (previewFile === null) return null;
146
+ target = {
147
+ viewKey: open.viewKey,
148
+ target: "workbench.file",
149
+ fileKey: open.fileKey,
150
+ targetId: open.targetId,
151
+ ...previewFile ? { previewFile } : {}
152
+ };
153
+ } else if ("fileKey" in open || "targetId" in open || "previewFile" in open) {
154
+ return null;
155
+ } else if (open.target === "assistant.project") {
56
156
  if (!("projectId" in open) || !nonempty(open.projectId)) return null;
57
157
  target = {
58
158
  ...common,
@@ -65,6 +165,9 @@ function parseResourceCard(value) {
65
165
  }
66
166
  if ("description" in value && typeof value.description !== "string")
67
167
  return null;
168
+ const content = parseResourceCardBlocks(
169
+ "content" in value ? value.content : "images" in value ? [{ kind: "image-gallery", images: value.images }] : []
170
+ );
68
171
  let icon;
69
172
  if ("icon" in value) {
70
173
  const candidate = value.icon;
@@ -84,6 +187,7 @@ function parseResourceCard(value) {
84
187
  title: value.title,
85
188
  ..."description" in value ? { description: value.description } : {},
86
189
  ...icon ? { icon } : {},
190
+ ...content.length ? { content } : {},
87
191
  open: target
88
192
  };
89
193
  }