@epam/ai-dial-chat-hooks 1.2.0-dev.3 → 1.2.0-dev.300

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.
Files changed (104) hide show
  1. package/api-error/api-error.js +7 -4
  2. package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
  3. package/attachments.d.ts +10 -4
  4. package/catalog/catalog-derivations.js +1 -1
  5. package/catalog/deployment-id.js +8 -2
  6. package/catalog/map-deployment-limits-to-catalog.js +16 -24
  7. package/catalog/map-deployment-limits-to-input.js +81 -9
  8. package/catalog/map-deployment-to-catalog-item.js +34 -34
  9. package/catalog/map-entity-details-to-catalog.js +7 -0
  10. package/catalog/map-skill-to-catalog-item.js +55 -48
  11. package/catalog/publish.js +6 -5
  12. package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
  13. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +122 -101
  14. package/catalog/usePublishFolders/usePublishFolders.js +1 -1
  15. package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
  16. package/catalog/useSkillItemDetails.js +19 -17
  17. package/catalog.d.ts +159 -35
  18. package/catalog.js +23 -22
  19. package/conversation/announcement-message.js +16 -5
  20. package/conversation/conversation-transfer/export-conversation.js +24 -16
  21. package/conversation/conversation-transfer/import-conversation.js +80 -31
  22. package/conversation/conversation-transfer/queue.js +8 -5
  23. package/conversation/create-chat-stream-api.js +85 -49
  24. package/conversation/message-utils.js +44 -2
  25. package/conversation/stage.js +27 -0
  26. package/conversation/useActiveConversationSync/useActiveConversationSync.js +7 -8
  27. package/conversation/useAttachmentUpload/useAttachmentUpload.js +12 -5
  28. package/conversation/useConversationExport/useConversationExport.js +9 -9
  29. package/conversation/useConversationHandlers/message-utils.js +8 -5
  30. package/conversation/useConversationHandlers/useConversationHandlers.js +187 -177
  31. package/conversation/useConversationImport/useConversationImport.js +123 -121
  32. package/conversation/useConversationPanelItems/useConversationPanelItems.js +50 -32
  33. package/conversation/useConversationScroll/useConversationScroll.js +68 -64
  34. package/conversation/useConversationStream/apply-chunk.js +1 -1
  35. package/conversation/useConversationStream/frame-scheduler.js +39 -0
  36. package/conversation/useConversationStream/generation-resume.js +122 -64
  37. package/conversation/useConversationStream/useConversationStream.js +279 -116
  38. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
  39. package/conversation/useTranscribeAudio/transcription-retry.js +5 -4
  40. package/conversation-overlay.d.ts +7 -0
  41. package/conversation-overlay.js +2 -0
  42. package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
  43. package/conversation-sources.d.ts +1 -1
  44. package/conversation-transfer.d.ts +2 -1
  45. package/conversation.d.ts +328 -25
  46. package/conversation.js +32 -30
  47. package/file-manager-canvas.d.ts +418 -0
  48. package/file-manager-canvas.js +2 -0
  49. package/file-manager.d.ts +155 -359
  50. package/file-manager.js +25 -24
  51. package/files/attachment-canvas.js +116 -55
  52. package/files/attachment-types.js +14 -13
  53. package/files/dial-file-manager-copy-move.util.js +9 -8
  54. package/files/dial-file-manager-mapping.util.js +2 -1
  55. package/files/dial-file-manager-path.util.js +24 -2
  56. package/files/dial-file-manager.model.js +23 -19
  57. package/files/dial-file-manager.types.js +3 -3
  58. package/files/file-manager-variant.js +1 -1
  59. package/files/resolve-dial-file-api-path.js +11 -12
  60. package/files/useDialFileListing/useDialFileListing.js +140 -127
  61. package/files/useDialFileManager/useDialFileManager.js +139 -135
  62. package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
  63. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -19
  64. package/files/useDialFileMutations/useDialFileMutations.js +65 -60
  65. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
  66. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +48 -0
  67. package/index.d.ts +1281 -136
  68. package/index.js +136 -122
  69. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
  70. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
  71. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
  72. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
  73. package/mcp-apps.d.ts +8 -6
  74. package/oauth/toolset-id.js +5 -3
  75. package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
  76. package/oauth.d.ts +32 -0
  77. package/oauth.js +9 -9
  78. package/package.json +37 -22
  79. package/scheduled-task/scheduled-task-description.js +81 -0
  80. package/scheduled-task/scheduled-task-preparation.js +24 -0
  81. package/scheduled-task/scheduled-task-trigger.js +74 -71
  82. package/scheduled-task/scheduled-tasks-api-client.js +19 -0
  83. package/scheduled-task/use-scheduled-task-runs.js +194 -0
  84. package/scheduled-task/use-scheduled-tasks.js +93 -0
  85. package/scheduled-tasks.d.ts +197 -3
  86. package/scheduled-tasks.js +7 -2
  87. package/shared/application-schema.js +5 -2
  88. package/shared/cron-day-of-month.js +13 -0
  89. package/skill/skill-archive.js +19 -0
  90. package/skill/skill-types.js +8 -7
  91. package/skill/skill.js +53 -27
  92. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +79 -0
  93. package/skill/useSkillEditorLoad.js +65 -59
  94. package/skill/useSkillEditorSubmit.js +108 -84
  95. package/skill/useSkillFileActions.js +70 -58
  96. package/skill-editor.d.ts +160 -8
  97. package/skill-editor.js +9 -8
  98. package/usage/map-usage-data-to-dashboard.js +66 -0
  99. package/usage/map-user-usage-to-model-limits.js +202 -0
  100. package/usage.d.ts +125 -0
  101. package/usage.js +3 -0
  102. package/usePageFileDrag/usePageFileDrag.js +3 -3
  103. package/utils.d.ts +26 -6
  104. package/utils.js +10 -10
@@ -1,24 +1,27 @@
1
1
  import { safeDecodeURIComponent as e, stripSurroundingSlashes as t } from "../shared/string-utils.js";
2
2
  import { formatCalendarDate as n } from "../shared/formatting.js";
3
- import "../skill/skill.js";
4
- import { SkillSource as r } from "../skill/skill-types.js";
5
- import { CatalogEntityType as i, formatLastUsed as a } from "@epam/ai-dial-chat-shared";
6
- import { CatalogContentNodeType as o } from "@epam/ai-dial-catalog";
7
- import { SkillMetadataItemDtoNodeTypeEnum as s } from "@epam/ai-dial-chat-api-client";
3
+ import { SKILL_FOLDER_MARKER as r } from "../skill/skill.js";
4
+ import { SkillSource as i } from "../skill/skill-types.js";
5
+ import { CatalogEntityType as a, formatLastUsed as o } from "@epam/ai-dial-chat-shared";
6
+ import { CatalogContentNodeType as s } from "@epam/ai-dial-catalog";
7
+ import { SkillMetadataItemDtoNodeTypeEnum as c } from "@epam/ai-dial-chat-api-client";
8
8
  //#region src/catalog/map-skill-to-catalog-item.ts
9
- var c = {
10
- [r.Personal]: "personal",
11
- [r.SharedWithMe]: "shared",
12
- [r.Public]: "public"
13
- }, l = (t, n, r) => [r[c[n]], ...(t ?? "").split("/").filter(Boolean).map(e)], u = (e, { folderLabels: t, source: n, favoriteIds: o }) => {
14
- let s = o.has(e.url), c = n === r.Public, u = n === r.Personal;
9
+ var l = {
10
+ [i.Personal]: "personal",
11
+ [i.SharedWithMe]: "shared",
12
+ [i.Public]: "public"
13
+ }, u = (t, n) => {
14
+ let r = (n ?? "").split("/").filter(Boolean), i = t.split("/").filter(Boolean).slice(2, -1);
15
+ return i.length === r.length ? i.map(e) : r;
16
+ }, d = (e, t, n) => [n[l[t]], ...u(e.url, e.parentPath)], f = (e, { folderLabels: t, source: n, favoriteIds: r }) => {
17
+ let s = r.has(e.url), c = n === i.Public, l = n === i.Personal;
15
18
  return {
16
19
  id: e.url,
17
- type: i.Skill,
20
+ type: a.Skill,
18
21
  name: e.name,
19
22
  description: e.description ?? "",
20
23
  version: "",
21
- lastUsed: a(e.updatedAt),
24
+ lastUsed: o(e.updatedAt),
22
25
  createdAt: e.createdAt,
23
26
  updatedAt: e.updatedAt,
24
27
  isFeatured: !1,
@@ -26,12 +29,12 @@ var c = {
26
29
  topics: [],
27
30
  isUserFavorite: s,
28
31
  isStarred: s,
29
- isMyApp: u && (e.isMy ?? !0),
30
- sharedWithMe: e.sharedWithMe ?? n === r.SharedWithMe,
31
- isEditable: !c && (e.canEdit ?? u),
32
- folder: l(e.parentPath, n, t)
32
+ isMyApp: l && (e.isMy ?? !0),
33
+ sharedWithMe: e.sharedWithMe ?? n === i.SharedWithMe,
34
+ isEditable: !c && (e.canEdit ?? l),
35
+ folder: d(e, n, t)
33
36
  };
34
- }, d = (e) => e.join(" · "), f = (e, t) => {
37
+ }, p = (e) => e.join(" · "), m = (e, t) => {
35
38
  if (e == null) return null;
36
39
  let n = [];
37
40
  return e.whenToUse != null && n.push({
@@ -39,25 +42,25 @@ var c = {
39
42
  value: e.whenToUse
40
43
  }), e.allowedTools?.length && n.push({
41
44
  label: t.allowedToolsLabel,
42
- value: d(e.allowedTools)
45
+ value: p(e.allowedTools)
43
46
  }), e.bundledResources?.length && n.push({
44
47
  label: t.bundledResourcesLabel,
45
- value: d(e.bundledResources)
48
+ value: p(e.bundledResources)
46
49
  }), n.length === 0 ? null : {
47
50
  title: t.specificationSectionTitle,
48
51
  specs: n
49
52
  };
50
- }, p = (e) => e.filter((e) => e.nodeType === s.Item), m = (e, n) => {
53
+ }, h = (e) => e.filter((e) => e.nodeType === c.Item), g = (e, n) => {
51
54
  let r = t(n), i = r ? `${r}/files` : "files";
52
- return p(e).find((e) => {
55
+ return h(e).find((e) => {
53
56
  let n = t(e.path);
54
57
  return n === "SKILL.md" || n === "files/SKILL.md" || n === `${i}/SKILL.md`;
55
58
  })?.path ?? "SKILL.md";
56
- }, h = (e, n) => {
59
+ }, _ = (e, n) => {
57
60
  let r = t(e), i = t(n), a = i ? `${i}/files` : "files";
58
61
  return r === "" || r === "files" || r === a ? null : r.startsWith(`${a}/`) ? r.slice(a.length + 1) : r.startsWith("files/") ? r.slice(6) : r;
59
- }, g = (e, t) => h(e, t), _ = (e, t, r, i) => {
60
- let a = [], o = f(r, i);
62
+ }, v = (e, t) => _(e, t), y = (e, t, r, i) => {
63
+ let a = [], o = m(r, i);
61
64
  o != null && a.push(o);
62
65
  let s = [];
63
66
  return e?.author && s.push({
@@ -68,23 +71,23 @@ var c = {
68
71
  value: e?.updatedAt ? n(e.updatedAt) : ""
69
72
  }), s.push({
70
73
  label: i.fileCountLabel,
71
- value: String(p(t).length)
74
+ value: String(h(t).length)
72
75
  }), a.push({
73
76
  title: i.detailsSectionTitle,
74
77
  specs: s
75
78
  }), { sections: a };
76
- }, v = (e, t, n) => {
79
+ }, b = (e, t, n) => {
77
80
  if (e === "") return n;
78
81
  let r = t.get(e);
79
82
  if (r != null) return r.items;
80
- let i = e.split("/"), a = v(i.slice(0, -1).join("/"), t, n), s = {
81
- type: o.Folder,
83
+ let i = e.split("/"), a = b(i.slice(0, -1).join("/"), t, n), o = {
84
+ type: s.Folder,
82
85
  id: e,
83
86
  name: i[i.length - 1],
84
87
  items: []
85
88
  };
86
- return t.set(e, s), a.push(s), s.items;
87
- }, y = (e, t) => {
89
+ return t.set(e, o), a.push(o), o.items;
90
+ }, x = (e, t) => {
88
91
  e.sort((e, n) => {
89
92
  if (t) {
90
93
  if (e.name === "SKILL.md") return -1;
@@ -92,32 +95,36 @@ var c = {
92
95
  }
93
96
  return e.name.localeCompare(n.name);
94
97
  });
95
- for (let t of e) t.type === o.Folder && y(t.items, !1);
96
- }, b = (e, t) => {
97
- let n = /* @__PURE__ */ new Map(), r = [];
98
- for (let i of e) {
99
- let e = h(i.path, t);
98
+ for (let t of e) t.type === s.Folder && x(t.items, !1);
99
+ }, S = (e, t) => {
100
+ let n = /* @__PURE__ */ new Map(), i = [];
101
+ for (let a of e) {
102
+ let e = _(a.path, t);
100
103
  if (e == null) continue;
101
- if (i.nodeType === s.Folder) {
102
- v(e, n, r);
104
+ if (a.nodeType === c.Folder) {
105
+ b(e, n, i);
103
106
  continue;
104
107
  }
105
- let a = e.lastIndexOf("/");
106
- v(a === -1 ? "" : e.slice(0, a), n, r).push({
107
- type: o.File,
108
- id: i.path,
109
- name: i.name
108
+ let o = e.lastIndexOf("/"), l = o === -1 ? "" : e.slice(0, o);
109
+ if (a.name === r) {
110
+ b(l, n, i);
111
+ continue;
112
+ }
113
+ b(l, n, i).push({
114
+ type: s.File,
115
+ id: a.path,
116
+ name: a.name
110
117
  });
111
118
  }
112
- return y(r, !0), r;
113
- }, x = async (e) => {
119
+ return x(i, !0), i;
120
+ }, C = async (e) => {
114
121
  let t = Number(e.headers.get("content-length"));
115
122
  if (Number.isFinite(t) && t > 262144) return null;
116
123
  let n = await e.arrayBuffer();
117
124
  return n.byteLength > 262144 ? null : new Uint8Array(n);
118
- }, S = async (e) => {
119
- let t = await x(e);
125
+ }, w = async (e) => new Uint8Array(await e.arrayBuffer()), T = async (e) => {
126
+ let t = await C(e);
120
127
  return t == null ? null : new TextDecoder().decode(t);
121
128
  };
122
129
  //#endregion
123
- export { b as buildSkillContentTree, _ as buildSkillOverview, u as mapSkillToCatalogItem, x as readSkillFileBytes, S as readSkillManifest, g as resolveSkillFileDownloadPath, m as resolveSkillManifestFileId };
130
+ export { S as buildSkillContentTree, y as buildSkillOverview, f as mapSkillToCatalogItem, C as readSkillFileBytes, w as readSkillFilePreviewBytes, T as readSkillManifest, v as resolveSkillFileDownloadPath, g as resolveSkillManifestFileId };
@@ -1,19 +1,20 @@
1
1
  import { safeDecodeURIComponent as e } from "../shared/string-utils.js";
2
- import { CatalogEntityType as t } from "@epam/ai-dial-chat-shared";
2
+ import { CatalogEntityType as t, PUBLIC_BUCKET as n } from "@epam/ai-dial-chat-shared";
3
3
  //#region src/catalog/publish.ts
4
- var n = {
4
+ var r = {
5
5
  [t.Model]: "model",
6
6
  [t.Toolset]: "toolset",
7
7
  [t.Agent]: "application",
8
8
  [t.Prompt]: "prompt",
9
9
  [t.Skill]: "skill"
10
- }, r = (e) => n[e], i = "public", a = (e) => e.split("/")[1] === i, o = (t) => a(t) ? t.split("/").slice(2, -1).map(e) : [], s = (e) => ({
10
+ }, i = (e) => r[e], a = (e) => e.split("/")[1] === n, o = (t) => a(t) ? t.split("/").slice(2, -1).map(e) : [], s = (e) => ({
11
11
  version: e.version,
12
12
  publishedAt: Date.parse(e.publishedAt),
13
- folderPath: e.folderPath.split("/").filter(Boolean)
13
+ folderPath: e.folderPath.split("/").filter(Boolean),
14
+ publishCredentials: e.publishCredentials
14
15
  }), c = (e) => ({
15
16
  publishedAt: Date.parse(e.publishedAt),
16
17
  folderPath: e.folderPath.split("/").filter(Boolean)
17
18
  });
18
19
  //#endregion
19
- export { o as getPublicCatalogEntityFolderPath, a as isPublicCatalogEntityId, c as mapPublishConversationResultDto, s as mapPublishHistoryEntryDto, r as toPublishEntityType };
20
+ export { o as getPublicCatalogEntityFolderPath, a as isPublicCatalogEntityId, c as mapPublishConversationResultDto, s as mapPublishHistoryEntryDto, i as toPublishEntityType };
@@ -0,0 +1,39 @@
1
+ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
+ //#region src/catalog/useApplicationCredentials/useApplicationCredentials.ts
3
+ var i = ({ appId: i, externalServicesClient: a, offlineCredentialsClient: o }) => {
4
+ let [s, c] = r([]), [l, u] = r(!1), [d, f] = r(!0), [p, m] = r(!1), h = n(0), g = n(null), _ = e(async () => {
5
+ if (g.current !== i) return;
6
+ let e = ++h.current;
7
+ f(!0), m(!1);
8
+ try {
9
+ let t = await a.listExternalServices({ appId: i });
10
+ if (h.current !== e) return;
11
+ let n = t.some((e) => e.authenticationType === "DIAL_NATIVE") ? await o.getOfflineCredentials() : void 0;
12
+ if (h.current !== e) return;
13
+ c(t.filter((e) => e.authenticationType !== "NONE")), u(n?.connected ?? !1);
14
+ } catch {
15
+ h.current === e && m(!0);
16
+ } finally {
17
+ h.current === e && f(!1);
18
+ }
19
+ }, [
20
+ i,
21
+ a,
22
+ o
23
+ ]), v = e(() => {
24
+ g.current = null, h.current++;
25
+ }, []);
26
+ return t(() => (g.current = i, c([]), f(!0), u(!1), _(), v), [
27
+ i,
28
+ _,
29
+ v
30
+ ]), {
31
+ services: s,
32
+ isOfflineConnected: l,
33
+ isLoading: d,
34
+ hasError: p,
35
+ refresh: _
36
+ };
37
+ };
38
+ //#endregion
39
+ export { i as useApplicationCredentials };
@@ -1,109 +1,130 @@
1
1
  import { getApiErrorDetails as e } from "../../api-error/api-error.js";
2
2
  import { findDeploymentByIdOrReference as t } from "../deployment-id.js";
3
3
  import { parseSkillResourceUrl as n } from "../../skill/skill-types.js";
4
- import { CatalogEntityType as r } from "@epam/ai-dial-chat-shared";
5
- import { useCallback as i, useMemo as a } from "react";
4
+ import { getRunnerSchemas as r, isQuickAppSchema as i } from "../../shared/application-schema.js";
5
+ import { CatalogEntityType as a } from "@epam/ai-dial-chat-shared";
6
+ import { useCallback as o, useMemo as s, useState as c } from "react";
6
7
  //#region src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts
7
- var o = ({ deployments: o, isCustomAppsEnabled: s, isSchemaAppsEnabled: c, isHideCustomAppCreationEnabled: l, isToolsetsEnabled: u, isPromptsEnabled: d, quickAppSchemaId: f, urls: p, onNavigate: m, deletePrompt: h, deleteToolset: g, deleteSkill: _, deleteApplication: v, refetchPrompts: y, refetchToolsets: b, refetchSkills: x, refetchDeployments: S, onDeleteSuccess: C, labels: w, onNotify: T, onSkillUploadClick: E }) => ({
8
- handleEdit: i((e) => {
9
- if (e.type === r.Prompt) {
10
- m(p.buildPromptEditUrl(e.id));
11
- return;
12
- }
13
- if (e.type === r.Skill) {
14
- m(p.buildSkillEditUrl(e.id));
15
- return;
16
- }
17
- if (e.type === r.Toolset) {
18
- m(p.buildToolsetEditUrl(e.id));
19
- return;
20
- }
21
- let n = t(o, e.id);
22
- if (s && n != null && !n.applicationTypeSchemaId) {
23
- m(p.buildCustomAppEditUrl(e.id));
24
- return;
25
- }
26
- f && m(p.buildQuickAppEditUrl(f, e.id));
27
- }, [
28
- o,
29
- s,
30
- f,
31
- m,
32
- p
33
- ]),
34
- handleDelete: i(async (t) => {
35
- try {
36
- if (t.type === r.Prompt) await h(t.id), await y();
37
- else if (t.type === r.Toolset) await g(t.id), await b();
38
- else if (t.type === r.Skill) {
39
- let e = n(t.id);
40
- if (e == null) throw Error(`Invalid skill resource url: ${t.id}`);
41
- await _(e.bucket, e.path), await x();
42
- } else await v(t.id), await S();
43
- C(t);
44
- } catch (t) {
45
- let { traceId: n } = await e(t);
46
- throw T({
47
- message: w.deleteError,
48
- requestId: n
49
- }), t;
50
- }
51
- }, [
52
- h,
53
- g,
54
- _,
55
- v,
56
- b,
57
- S,
58
- y,
59
- x,
60
- C,
61
- w,
62
- T
63
- ]),
64
- createOptions: a(() => {
65
- let e = [];
66
- return f && c && !l && e.push({
67
- key: "quick-app",
68
- label: w.createQuickApp,
69
- onClick: () => m(p.buildQuickAppCreateUrl(f))
70
- }), u && e.push({
71
- key: "toolset",
72
- label: w.createToolset,
73
- onClick: () => m(p.buildToolsetCreateUrl())
74
- }), s && !l && e.push({
75
- key: "custom-app",
76
- label: w.createCustomApp,
77
- onClick: () => m(p.buildCustomAppCreateUrl())
78
- }), e.push({
79
- key: "skill",
80
- label: w.createSkill,
81
- children: [{
8
+ var l = ({ deployments: l, isCustomAppsEnabled: u, isSchemaAppsEnabled: d, isHideCustomAppCreationEnabled: f, isToolsetsEnabled: p, isPromptsEnabled: m, schemas: h, urls: g, onNavigate: _, deletePrompt: v, deleteToolset: y, deleteSkill: b, deleteApplication: x, refetchPrompts: S, refetchToolsets: C, refetchSkills: w, refetchDeployments: T, onDeleteSuccess: E, labels: D, onNotify: O, onSkillUploadClick: k }) => {
9
+ let A = s(() => r(h), [h]), [j, M] = c(""), N = d && !f;
10
+ return {
11
+ handleEdit: o((e) => {
12
+ if (e.type === a.Prompt) {
13
+ _(g.buildPromptEditUrl(e.id));
14
+ return;
15
+ }
16
+ if (e.type === a.Skill) {
17
+ _(g.buildSkillEditUrl(e.id));
18
+ return;
19
+ }
20
+ if (e.type === a.Toolset) {
21
+ _(g.buildToolsetEditUrl(e.id));
22
+ return;
23
+ }
24
+ let n = t(l, e.id);
25
+ if (u && n != null && !n.applicationTypeSchemaId) {
26
+ _(g.buildCustomAppEditUrl(e.id));
27
+ return;
28
+ }
29
+ let r = A.find((e) => e.id === n?.applicationTypeSchemaId)?.id ?? A.find((e) => i(e))?.id;
30
+ r && _(g.buildQuickAppEditUrl(r, e.id));
31
+ }, [
32
+ l,
33
+ u,
34
+ A,
35
+ _,
36
+ g
37
+ ]),
38
+ handleDelete: o(async (t) => {
39
+ try {
40
+ if (t.type === a.Prompt) await v(t.id), await S();
41
+ else if (t.type === a.Toolset) await y(t.id), await C();
42
+ else if (t.type === a.Skill) {
43
+ let e = n(t.id);
44
+ if (e == null) throw Error(`Invalid skill resource url: ${t.id}`);
45
+ await b(e.bucket, e.path), await w();
46
+ } else await x(t.id), await T();
47
+ E(t);
48
+ } catch (t) {
49
+ let { traceId: n } = await e(t);
50
+ throw O({
51
+ message: D.deleteError,
52
+ requestId: n
53
+ }), t;
54
+ }
55
+ }, [
56
+ v,
57
+ y,
58
+ b,
59
+ x,
60
+ C,
61
+ T,
62
+ S,
63
+ w,
64
+ E,
65
+ D,
66
+ O
67
+ ]),
68
+ createOptions: s(() => {
69
+ let e = j.trim().toLocaleLowerCase(), t = (t) => !e || t.toLocaleLowerCase().includes(e), n = [];
70
+ N && A.map((e) => ({
71
+ id: e.id,
72
+ label: e.displayName || e.id
73
+ })).filter((e) => t(e.label)).forEach((e) => {
74
+ n.push({
75
+ key: `runner:${e.id}`,
76
+ label: e.label,
77
+ onClick: () => _(g.buildQuickAppCreateUrl(e.id))
78
+ });
79
+ }), p && t(D.createToolset) && n.push({
80
+ key: "toolset",
81
+ label: D.createToolset,
82
+ onClick: () => _(g.buildToolsetCreateUrl())
83
+ }), u && !f && t(D.createCustomApp) && n.push({
84
+ key: "custom-app",
85
+ label: D.createCustomApp,
86
+ onClick: () => _(g.buildCustomAppCreateUrl())
87
+ });
88
+ let r = [{
82
89
  key: "skill-write-instructions",
83
- label: w.createSkillWriteInstructions,
84
- onClick: () => m(p.buildSkillCreateUrl())
90
+ label: D.createSkillWriteInstructions,
91
+ onClick: () => _(g.buildSkillCreateUrl())
85
92
  }, {
86
93
  key: "skill-upload",
87
- label: w.createSkillUpload,
88
- onClick: E
89
- }]
90
- }), d && e.push({
91
- key: "prompt",
92
- label: w.createPrompt,
93
- onClick: () => m(p.buildPromptCreateUrl())
94
- }), e;
95
- }, [
96
- f,
97
- m,
98
- p,
99
- d,
100
- w,
101
- c,
102
- l,
103
- u,
104
- s,
105
- E
106
- ])
107
- });
94
+ label: D.createSkillUpload,
95
+ onClick: k
96
+ }], i = t(D.createSkill) ? r : r.filter((e) => t(String(e.label)));
97
+ return i.length > 0 && n.push({
98
+ key: "skill",
99
+ label: D.createSkill,
100
+ children: i
101
+ }), m && t(D.createPrompt) && n.push({
102
+ key: "prompt",
103
+ label: D.createPrompt,
104
+ onClick: () => _(g.buildPromptCreateUrl())
105
+ }), n.sort((e, t) => String(e.label ?? "").localeCompare(String(t.label ?? ""), void 0, { sensitivity: "base" }));
106
+ }, [
107
+ j,
108
+ N,
109
+ A,
110
+ _,
111
+ g,
112
+ m,
113
+ D,
114
+ f,
115
+ p,
116
+ u,
117
+ k
118
+ ]),
119
+ createSearch: s(() => N && A.length > 0 ? {
120
+ value: j,
121
+ onChange: M
122
+ } : void 0, [
123
+ N,
124
+ A.length,
125
+ j
126
+ ])
127
+ };
128
+ };
108
129
  //#endregion
109
- export { o as useCatalogEditNavigation };
130
+ export { l as useCatalogEditNavigation };
@@ -48,7 +48,7 @@ var c = "Production", l = 50, u = (e, t, n) => {
48
48
  return b((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
49
49
  }, []), T = e((e) => {
50
50
  let t = s(e), n = Array.isArray(d) ? d : [];
51
- !t || n.includes(t) || f?.([t, ...n].slice(0, l));
51
+ !t || n[0] === t || f?.([t, ...n.filter((e) => e !== t)].slice(0, l));
52
52
  }, [d, f]), E = e((e) => !e.includes(c), []);
53
53
  return {
54
54
  folderItems: n(() => {
@@ -1,59 +1,59 @@
1
1
  import { SkillSource as e } from "../../skill/skill-types.js";
2
2
  import { mapSkillToCatalogItem as t } from "../map-skill-to-catalog-item.js";
3
3
  import { useSkillItemDetails as n } from "../useSkillItemDetails.js";
4
- import { useEffect as r, useMemo as i, useState as a } from "react";
4
+ import { useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
5
5
  //#region src/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.ts
6
- var o = ({ api: o, skills: s, sharedWithMe: c, publicSkills: l, skillId: u, folderLabels: d, skillOverviewLabels: f, favoriteIds: p }) => {
7
- let m = i(() => [
8
- ...s,
9
- ...c ?? [],
10
- ...l ?? []
6
+ var s = ({ api: s, skills: c, sharedWithMe: l, publicSkills: u, skillId: d, folderLabels: f, skillOverviewLabels: p, favoriteIds: m }) => {
7
+ let h = i(() => [
8
+ ...c,
9
+ ...l ?? [],
10
+ ...u ?? []
11
11
  ], [
12
- s,
13
- c,
14
- l
15
- ]), { onFetchSkillDetails: h, onLoadSkillDetailsFile: g } = n({
16
- api: o,
17
- skills: m,
18
- skillOverviewLabels: f
19
- }), _ = i(() => m.find((e) => e.url === u) ?? null, [m, u]), v = i(() => s.some((e) => e.url === u) ? e.Personal : c?.some((e) => e.url === u) ? e.SharedWithMe : e.Public, [
20
- s,
21
12
  c,
13
+ l,
22
14
  u
23
- ]), y = i(() => _ == null ? null : t(_, {
24
- folderLabels: d,
25
- source: v,
26
- favoriteIds: p
15
+ ]), { onFetchSkillDetails: g, onLoadSkillDetailsFile: _ } = n({
16
+ api: s,
17
+ skills: h,
18
+ skillOverviewLabels: p
19
+ }), v = i(() => h.find((e) => e.url === d) ?? null, [h, d]), y = i(() => c.some((e) => e.url === d) ? e.Personal : l?.some((e) => e.url === d) ? e.SharedWithMe : e.Public, [
20
+ c,
21
+ l,
22
+ d
23
+ ]), b = i(() => v == null ? null : t(v, {
24
+ folderLabels: f,
25
+ source: y,
26
+ favoriteIds: m
27
27
  }), [
28
- _,
29
28
  v,
30
- d,
31
- p
32
- ]), [b, x] = a(null), [S, C] = a(!1);
29
+ y,
30
+ f,
31
+ m
32
+ ]), [x, S] = o(null), [C, w] = o(!1), T = a(0);
33
33
  return r(() => {
34
- if (y == null) return;
35
- C(!0), x(null);
36
- let e = !1;
37
- return h(y).then((t) => {
38
- e || (x(t ?? null), C(!1));
34
+ if (b == null) return;
35
+ w(!0), S(null);
36
+ let e = !1, t = ++T.current;
37
+ return g(b).then((n) => {
38
+ e || T.current !== t || (S(n ?? null), w(!1));
39
39
  }), () => {
40
40
  e = !0;
41
41
  };
42
- }, [y?.id]), {
42
+ }, [b?.id]), {
43
43
  detailsPanelItem: i(() => {
44
- if (y == null) return null;
45
- if (b == null) return y;
46
- let { credentials: e, ...t } = b;
44
+ if (b == null) return null;
45
+ if (x == null) return b;
46
+ let { credentials: e, ...t } = x;
47
47
  return {
48
- ...y,
48
+ ...b,
49
49
  details: t,
50
- credentials: e ?? y.credentials
50
+ credentials: e ?? b.credentials
51
51
  };
52
- }, [y, b]),
53
- isDetailsLoading: S,
54
- isStarred: y != null && p.has(y.id),
55
- onLoadSkillDetailsFile: g
52
+ }, [b, x]),
53
+ isDetailsLoading: C,
54
+ isStarred: b != null && m.has(b.id),
55
+ onLoadSkillDetailsFile: _
56
56
  };
57
57
  };
58
58
  //#endregion
59
- export { o as useSkillDetailsPanelData };
59
+ export { s as useSkillDetailsPanelData };
@@ -1,6 +1,6 @@
1
1
  import { SKILL_MANIFEST_FILE as e } from "../skill/skill.js";
2
2
  import { parseSkillResourceUrl as t } from "../skill/skill-types.js";
3
- import { buildSkillContentTree as n, buildSkillOverview as r, readSkillFileBytes as i, readSkillManifest as a, resolveSkillFileDownloadPath as o, resolveSkillManifestFileId as s } from "./map-skill-to-catalog-item.js";
3
+ import { buildSkillContentTree as n, buildSkillOverview as r, readSkillFilePreviewBytes as i, readSkillManifest as a, resolveSkillFileDownloadPath as o, resolveSkillManifestFileId as s } from "./map-skill-to-catalog-item.js";
4
4
  import { parseSkillManifestDocument as c } from "../skill/skill-manifest.js";
5
5
  import { useCallback as l, useRef as u } from "react";
6
6
  //#region src/catalog/useSkillItemDetails.ts
@@ -12,20 +12,24 @@ var d = ({ api: d, skills: f, skillOverviewLabels: p }) => {
12
12
  if (o == null) return;
13
13
  let { bucket: l, path: u } = o;
14
14
  m.current = o;
15
- let [h, g] = await Promise.allSettled([d.downloadSkillFile(l, u, e).then(a), d.listSkillFiles({
16
- bucket: l,
17
- path: u,
18
- filePath: "",
19
- recursive: !0
20
- })]), _ = h.status === "fulfilled" && h.value != null ? c(h.value) : void 0, v = f.find((e) => e.url === i.id), y = g.status === "fulfilled" ? r(v, g.value.items, _?.about, p) : void 0, b = g.status === "fulfilled" ? n(g.value.items, u) : [], x = g.status === "fulfilled" ? s(g.value.items, u) : e;
21
- if (!(_ == null && y == null)) return {
22
- ..._ == null ? {} : { promptContent: {
23
- content: _.body,
24
- ..._.description == null ? {} : { description: _.description },
25
- files: b,
26
- selectedFileId: x
15
+ let [h, g, _] = await Promise.allSettled([
16
+ d.downloadSkillFile(l, u, e).then(a),
17
+ d.listSkillFiles({
18
+ bucket: l,
19
+ path: u,
20
+ filePath: "",
21
+ recursive: !0
22
+ }),
23
+ d.getSkillMetadata(l, u)
24
+ ]), v = h.status === "fulfilled" && h.value != null ? c(h.value) : void 0, y = _.status === "fulfilled" ? _.value : f.find((e) => e.url === i.id), b = g.status === "fulfilled" ? r(y, g.value.items, v?.about, p) : void 0, x = g.status === "fulfilled" ? n(g.value.items, u) : [], S = g.status === "fulfilled" ? s(g.value.items, u) : e;
25
+ if (!(v == null && b == null)) return {
26
+ ...v == null ? {} : { promptContent: {
27
+ content: v.body,
28
+ ...v.description == null ? {} : { description: v.description },
29
+ files: x,
30
+ selectedFileId: S
27
31
  } },
28
- ...y == null ? {} : { overview: y }
32
+ ...b == null ? {} : { overview: b }
29
33
  };
30
34
  }, [
31
35
  d,
@@ -47,9 +51,7 @@ var d = ({ api: d, skills: f, skillOverviewLabels: p }) => {
47
51
  if (n == null) throw Error("A folder cannot be previewed");
48
52
  let r = await d.downloadSkillFile(t.bucket, t.path, n);
49
53
  if (!r.ok) throw Object.assign(/* @__PURE__ */ Error(`File preview failed with status ${r.status}`), { status: r.status });
50
- let a = await i(r);
51
- if (a == null) throw Error("File exceeds the preview size limit");
52
- let s = r.headers.get("content-type")?.split(";")[0].trim() || void 0;
54
+ let a = await i(r), s = r.headers.get("content-type")?.split(";")[0].trim() || void 0;
53
55
  return {
54
56
  bytes: a,
55
57
  mimeType: s === "application/octet-stream" ? void 0 : s