@kodaris/krubble-app-components 1.0.154 → 1.0.156

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.
@@ -3172,6 +3172,18 @@ class KRChatbot extends i$3 {
3172
3172
  this._copiedIndex = -1;
3173
3173
  /** Whether the "Browse all skills" dialog is open. */
3174
3174
  this._skillBrowseOpened = false;
3175
+ /**
3176
+ * The skill whose detail view is showing inside the browse dialog, else null.
3177
+ * While set, the browse dialog shows that skill's summary, author, price, roles
3178
+ * and actions in place of the search field and tabs.
3179
+ */
3180
+ this._skillBrowseDetail = null;
3181
+ /**
3182
+ * The billable global skill awaiting the user's install confirmation, else null.
3183
+ * Set when Install is clicked on a billable skill; the confirm dialog renders
3184
+ * while it is set and the request only fires once the user confirms.
3185
+ */
3186
+ this._skillInstallConfirm = null;
3175
3187
  /**
3176
3188
  * Active tab in the browse dialog. `org` shows `_orgSkills` (this instance's
3177
3189
  * skills); `kodaris` shows `_globalSkills` (the shared global catalog).
@@ -4188,12 +4200,46 @@ class KRChatbot extends i$3 {
4188
4200
  if (this._globalSkillPending.has(skill.code)) {
4189
4201
  return;
4190
4202
  }
4203
+ const btn = e.currentTarget;
4204
+ // Installing a billable skill charges the account, so confirm before sending.
4205
+ // Uninstalling is never billed and free installs are one click to undo.
4206
+ if (!skill.enabled && skill.billable) {
4207
+ this._skillInstallConfirm = skill;
4208
+ return;
4209
+ }
4210
+ this._enableGlobalSkill(skill, btn);
4211
+ }
4212
+ /** Cancel the billable install confirmation without sending anything. */
4213
+ _handleSkillInstallCancel() {
4214
+ this._skillInstallConfirm = null;
4215
+ }
4216
+ /**
4217
+ * The user accepted the charge: run the install with the dialog's own Install
4218
+ * button spinning, and close the dialog once the server confirms. On failure
4219
+ * the button shows the error and the dialog stays open so they can retry or cancel.
4220
+ */
4221
+ _handleSkillInstallConfirm(e) {
4222
+ if (!this._skillInstallConfirm) {
4223
+ return;
4224
+ }
4225
+ this._enableGlobalSkill(this._skillInstallConfirm, e.currentTarget).then((ok) => {
4226
+ if (ok) {
4227
+ this._skillInstallConfirm = null;
4228
+ }
4229
+ });
4230
+ }
4231
+ /**
4232
+ * Send the enable/disable request for a global skill and reflect the server's
4233
+ * result on its card. `btn` is the button that triggered it (the card's
4234
+ * Install button, or the confirmation dialog's), whose spinner shows while the
4235
+ * request is in flight. Resolves true on success, false on failure.
4236
+ */
4237
+ _enableGlobalSkill(skill, btn) {
4191
4238
  // Drive the clicked button's own spinner (KRButton disables itself while
4192
4239
  // loading, so a second click can't fire until the request settles).
4193
- const btn = e.currentTarget;
4194
4240
  this._globalSkillPending.add(skill.code);
4195
4241
  btn?.showLoading();
4196
- KRHttp.fetch({
4242
+ return KRHttp.fetch({
4197
4243
  url: `/api/system/opensearch/aiskills/global/${encodeURIComponent(skill.code)}/enabled`,
4198
4244
  method: 'POST',
4199
4245
  body: { enabled: !skill.enabled },
@@ -4205,10 +4251,26 @@ class KRChatbot extends i$3 {
4205
4251
  skill.enabled = res?.data?.enabled;
4206
4252
  btn?.reset();
4207
4253
  this.requestUpdate();
4254
+ if (skill.enabled) {
4255
+ KRSnackbar.show({
4256
+ title: 'Skill Installed',
4257
+ message: `${skill.name} is now available to use.`,
4258
+ type: 'success',
4259
+ });
4260
+ }
4261
+ else {
4262
+ KRSnackbar.show({
4263
+ title: 'Skill Uninstalled',
4264
+ message: `${skill.name} is no longer available to use.`,
4265
+ type: 'success',
4266
+ });
4267
+ }
4268
+ return true;
4208
4269
  })
4209
4270
  .catch((error) => {
4210
4271
  console.error('kr-chatbot: global skill enable failed', error);
4211
4272
  btn?.showError('Error');
4273
+ return false;
4212
4274
  })
4213
4275
  .finally(() => {
4214
4276
  this._globalSkillPending.delete(skill.code);
@@ -4369,11 +4431,11 @@ class KRChatbot extends i$3 {
4369
4431
  this._skillBrowseOpened = false;
4370
4432
  this._inputEl?.focus();
4371
4433
  }
4372
- /** Activate a skill card via keyboard (Enter/Space), since it's a div role=button. */
4434
+ /** Open a skill card via keyboard (Enter/Space), since it's a div role=button. */
4373
4435
  _handleSkillCardKeydown(e, skill) {
4374
4436
  if (e.key === 'Enter' || e.key === ' ') {
4375
4437
  e.preventDefault();
4376
- this._handleSkillSelect(skill);
4438
+ this._handleSkillCardOpen(skill);
4377
4439
  }
4378
4440
  }
4379
4441
  /**
@@ -4411,6 +4473,29 @@ class KRChatbot extends i$3 {
4411
4473
  }
4412
4474
  _handleSkillBrowseClose() {
4413
4475
  this._skillBrowseOpened = false;
4476
+ this._skillBrowseDetail = null;
4477
+ }
4478
+ /** Open a skill's detail view inside the browse dialog. */
4479
+ _handleSkillCardOpen(skill) {
4480
+ this._skillBrowseDetail = skill;
4481
+ }
4482
+ /** Return from the detail view to the grid, keeping the tab and search text. */
4483
+ _handleSkillDetailBack() {
4484
+ this._skillBrowseDetail = null;
4485
+ }
4486
+ /** Try It on the detail view: insert the open skill into the composer. */
4487
+ _handleSkillDetailTry() {
4488
+ if (!this._skillBrowseDetail) {
4489
+ return;
4490
+ }
4491
+ this._handleSkillSelect(this._skillBrowseDetail);
4492
+ }
4493
+ /** Install/Uninstall on the detail view for the open global skill. */
4494
+ _handleSkillDetailEnable(e) {
4495
+ if (!this._skillBrowseDetail) {
4496
+ return;
4497
+ }
4498
+ this._handleGlobalSkillEnable(this._skillBrowseDetail, e);
4414
4499
  }
4415
4500
  _handleSkillBrowseSearch(e) {
4416
4501
  this._skillBrowseQuery = e.target.value;
@@ -5908,8 +5993,8 @@ class KRChatbot extends i$3 {
5908
5993
  @click=${() => this._handleSkillSelect(skill)}
5909
5994
  >
5910
5995
  <span class="skill-menu__name">${skill.name}</span>
5911
- ${skill.description ? b `
5912
- <span class="skill-menu__desc">${skill.description}</span>
5996
+ ${skill.summary ? b `
5997
+ <span class="skill-menu__desc">${skill.summary}</span>
5913
5998
  ` : A}
5914
5999
  </button>
5915
6000
  </li>
@@ -5931,43 +6016,134 @@ class KRChatbot extends i$3 {
5931
6016
  return b `
5932
6017
  <kr-dialog
5933
6018
  opened
5934
- label="Browse Skills"
5935
6019
  width="720px"
5936
6020
  @close=${this._handleSkillBrowseClose}
5937
6021
  >
6022
+ <kr-dialog-header>
6023
+ <div class="skill-browse__header">
6024
+ ${this._skillBrowseDetail ? b `
6025
+ <button
6026
+ type="button"
6027
+ class="skill-browse__back"
6028
+ aria-label="Back"
6029
+ @click=${this._handleSkillDetailBack}
6030
+ >
6031
+ <svg
6032
+ width="22"
6033
+ height="22"
6034
+ viewBox="0 0 24 24"
6035
+ fill="none"
6036
+ stroke="currentColor"
6037
+ stroke-width="2"
6038
+ stroke-linecap="round"
6039
+ stroke-linejoin="round"
6040
+ >
6041
+ <path d="M19 12H5M12 19l-7-7 7-7"/>
6042
+ </svg>
6043
+ </button>
6044
+ ` : b `
6045
+ <h2>Browse Skills</h2>
6046
+ `}
6047
+ <button
6048
+ type="button"
6049
+ class="skill-browse__close"
6050
+ aria-label="Close"
6051
+ @click=${this._handleSkillBrowseClose}
6052
+ >
6053
+ <svg
6054
+ viewBox="0 0 24 24"
6055
+ fill="none"
6056
+ stroke="currentColor"
6057
+ stroke-width="1.5"
6058
+ stroke-linecap="round"
6059
+ stroke-linejoin="round"
6060
+ >
6061
+ <path d="M6 18 18 6M6 6l12 12"/>
6062
+ </svg>
6063
+ </button>
6064
+ </div>
6065
+ </kr-dialog-header>
5938
6066
  <div class="skill-browse">
5939
- <kr-text-field
5940
- placeholder="Search skills..."
5941
- .value=${this._skillBrowseQuery}
5942
- @input=${this._handleSkillBrowseSearch}
5943
- ></kr-text-field>
5944
- <kr-tab-group
5945
- active-tab-id=${this._skillBrowseSource}
5946
- @tab-change=${this._handleSkillBrowseTabChange}
5947
- >
5948
- <kr-tab id="org" label="Your Org">
5949
- ${this._renderSkillGrid()}
5950
- </kr-tab>
5951
- ${this._aiFrameworkConfig.registryServer === true ? A : b `
5952
- <kr-tab id="kodaris" label="Kodaris">
5953
- ${this._renderSkillGrid(true)}
6067
+ ${this._skillBrowseDetail ? b `
6068
+ <div class="skill-detail">
6069
+ <div class="skill-detail__body">
6070
+ <div class="skill-detail__section">
6071
+ <span class="skill-detail__title">${this._skillBrowseDetail.name}</span>
6072
+ ${this._skillBrowseDetail.summary ? b `
6073
+ <p class="skill-detail__summary">${this._skillBrowseDetail.summary}</p>
6074
+ ` : A}
6075
+ </div>
6076
+ <div class="skill-detail__row">
6077
+ <span class="skill-detail__label">Author</span>
6078
+ <span class="skill-detail__value">${this._skillBrowseDetail.global ? 'Kodaris' : 'Your organization'}</span>
6079
+ </div>
6080
+ ${this._skillBrowseDetail.global ? b `
6081
+ <div class="skill-detail__row">
6082
+ <span class="skill-detail__label">Price</span>
6083
+ <span class="skill-detail__value">${this._skillBrowseDetail.priceLabel}</span>
6084
+ </div>
6085
+ ` : A}
6086
+ ${this._skillBrowseDetail.allowedRoles?.length ? b `
6087
+ <div class="skill-detail__row">
6088
+ <span class="skill-detail__label">Roles</span>
6089
+ <div class="skill-detail__chips">
6090
+ ${this._skillBrowseDetail.allowedRoles.map((role) => b `
6091
+ <span class="skill-detail__chip">${role}</span>
6092
+ `)}
6093
+ </div>
6094
+ </div>
6095
+ ` : A}
6096
+ </div>
6097
+ <div class="skill-detail__footer">
6098
+ ${this._skillBrowseDetail.canRun !== false && (!this._skillBrowseDetail.global || this._skillBrowseDetail.enabled) ? b `
6099
+ <kr-button
6100
+ variant="flat"
6101
+ color="primary"
6102
+ @click=${this._handleSkillDetailTry}
6103
+ >Try It</kr-button>
6104
+ ` : A}
6105
+ ${this._skillBrowseDetail.global ? b `
6106
+ <kr-button
6107
+ variant=${this._skillBrowseDetail.enabled ? 'outline' : 'flat'}
6108
+ color=${this._skillBrowseDetail.enabled ? 'secondary' : 'primary'}
6109
+ @click=${this._handleSkillDetailEnable}
6110
+ >${this._skillBrowseDetail.enabled ? 'Uninstall' : 'Install'}</kr-button>
6111
+ ` : A}
6112
+ </div>
6113
+ </div>
6114
+ ` : b `
6115
+ <kr-text-field
6116
+ placeholder="Search skills..."
6117
+ .value=${this._skillBrowseQuery}
6118
+ @input=${this._handleSkillBrowseSearch}
6119
+ ></kr-text-field>
6120
+ <kr-tab-group
6121
+ active-tab-id=${this._skillBrowseSource}
6122
+ @tab-change=${this._handleSkillBrowseTabChange}
6123
+ >
6124
+ <kr-tab id="org" label="Your Org">
6125
+ ${this._renderSkillGrid()}
5954
6126
  </kr-tab>
5955
- `}
5956
- </kr-tab-group>
6127
+ ${this._aiFrameworkConfig.registryServer === true ? A : b `
6128
+ <kr-tab id="kodaris" label="Kodaris">
6129
+ ${this._renderSkillGrid(true)}
6130
+ </kr-tab>
6131
+ `}
6132
+ </kr-tab-group>
6133
+ `}
5957
6134
  </div>
5958
6135
  </kr-dialog>
5959
6136
  `;
5960
6137
  }
5961
6138
  /**
5962
6139
  * The card grid of skill search results for the browse dialog. Clicking a card
5963
- * inserts `/code ` into the composer. In the shared-Kodaris (`global`) tab each
5964
- * card also gets a footer row with an Install/Uninstall button.
6140
+ * opens its detail view inside `_renderSkillBrowse`, which is where Try It lives.
6141
+ * In the shared-Kodaris (`global`) tab each card also gets a footer row with an
6142
+ * Install/Uninstall button as a shortcut.
5965
6143
  *
5966
6144
  * The Kodaris tab is the whole published catalog, deliberately NOT role-filtered so
5967
- * users can discover skills they don't have yet. So a card there can be in one of two
5968
- * non-runnable states — the user's roles don't allow it (`canRun: false`), or it isn't
5969
- * installed here (not `enabled`). Neither looks clickable; clicking either explains
5970
- * why via `_handleSkillSelect`.
6145
+ * users can discover skills they don't have yet. Every card is clickable; the detail
6146
+ * view lists the roles and shows Install when the skill isn't installed here.
5971
6147
  */
5972
6148
  _renderSkillGrid(global = false) {
5973
6149
  let skills = this._orgSkills;
@@ -5981,18 +6157,15 @@ class KRChatbot extends i$3 {
5981
6157
  <div class="skill-browse__grid">
5982
6158
  ${skills.map((skill) => b `
5983
6159
  <div
5984
- class=${e({
5985
- 'skill-card': true,
5986
- 'skill-card--unavailable': skill.canRun === false || (!!skill.global && !skill.enabled),
5987
- })}
6160
+ class="skill-card"
5988
6161
  role="button"
5989
6162
  tabindex="0"
5990
- @click=${() => this._handleSkillSelect(skill)}
6163
+ @click=${() => this._handleSkillCardOpen(skill)}
5991
6164
  @keydown=${(e) => this._handleSkillCardKeydown(e, skill)}
5992
6165
  >
5993
6166
  <span class="skill-card__name">${skill.name}</span>
5994
- ${skill.description ? b `
5995
- <span class="skill-card__desc">${skill.description}</span>
6167
+ ${skill.summary ? b `
6168
+ <span class="skill-card__desc">${skill.summary}</span>
5996
6169
  ` : A}
5997
6170
  ${!global && skill.global ? b `
5998
6171
  <span class="skill-card__badge">Global</span>
@@ -7264,6 +7437,32 @@ class KRChatbot extends i$3 {
7264
7437
  </div>
7265
7438
  </div>
7266
7439
  ${this._skillBrowseOpened ? this._renderSkillBrowse() : A}
7440
+ ${this._skillInstallConfirm ? b `
7441
+ <kr-dialog
7442
+ opened
7443
+ label="Install Paid Skill"
7444
+ width="480px"
7445
+ @close=${this._handleSkillInstallCancel}
7446
+ >
7447
+ <kr-dialog-content>
7448
+ <div class="skill-install-confirm">
7449
+ <p>
7450
+ <strong>${this._skillInstallConfirm.name}</strong> is a paid skill. Installing it will
7451
+ charge your account <strong>${this._skillInstallConfirm.priceLabel}</strong>.
7452
+ </p>
7453
+ <p>Please confirm you would like to proceed.</p>
7454
+ </div>
7455
+ </kr-dialog-content>
7456
+ <kr-dialog-footer>
7457
+ <kr-button color="secondary" @click=${this._handleSkillInstallCancel}>Cancel</kr-button>
7458
+ <kr-button
7459
+ variant="flat"
7460
+ color="primary"
7461
+ @click=${this._handleSkillInstallConfirm}
7462
+ >Install</kr-button>
7463
+ </kr-dialog-footer>
7464
+ </kr-dialog>
7465
+ ` : A}
7267
7466
  ${this._renderDrawer()}
7268
7467
  </div>
7269
7468
  `;
@@ -9011,6 +9210,70 @@ KRChatbot.styles = i$6 `
9011
9210
  height: 70vh;
9012
9211
  }
9013
9212
 
9213
+ /* Slotted replacement for the dialog's built-in header so the detail view can
9214
+ put its back control where the title normally sits. Mirrors kr-dialog's
9215
+ own header: title left, close on the right. */
9216
+ .skill-browse__header {
9217
+ display: flex;
9218
+ flex: 1;
9219
+ align-items: center;
9220
+ justify-content: space-between;
9221
+ gap: 16px;
9222
+ }
9223
+
9224
+ .skill-browse__header h2 {
9225
+ margin: 0;
9226
+ font-size: 18px;
9227
+ font-weight: 600;
9228
+ }
9229
+
9230
+ .skill-browse__back {
9231
+ display: flex;
9232
+ align-items: center;
9233
+ justify-content: center;
9234
+ width: 36px;
9235
+ height: 36px;
9236
+ margin-left: -8px;
9237
+ padding: 0;
9238
+ border: none;
9239
+ border-radius: 6px;
9240
+ background: none;
9241
+ color: #000000;
9242
+ cursor: pointer;
9243
+ transition: background-color 0.15s;
9244
+ }
9245
+
9246
+ .skill-browse__back:hover {
9247
+ background: rgba(0, 0, 0, 0.06);
9248
+ }
9249
+
9250
+ .skill-browse__close {
9251
+ flex-shrink: 0;
9252
+ display: flex;
9253
+ align-items: center;
9254
+ justify-content: center;
9255
+ width: 36px;
9256
+ height: 36px;
9257
+ margin-right: -8px;
9258
+ padding: 0;
9259
+ background: none;
9260
+ border: none;
9261
+ border-radius: 6px;
9262
+ color: #000000;
9263
+ cursor: pointer;
9264
+ transition: background-color 0.15s, color 0.15s;
9265
+ }
9266
+
9267
+ .skill-browse__close:hover {
9268
+ background: rgba(0, 0, 0, 0.06);
9269
+ color: #000000;
9270
+ }
9271
+
9272
+ .skill-browse__close svg {
9273
+ width: 22px;
9274
+ height: 22px;
9275
+ }
9276
+
9014
9277
  .skill-browse kr-text-field {
9015
9278
  display: block;
9016
9279
  margin: 20px 20px 16px;
@@ -9059,15 +9322,6 @@ KRChatbot.styles = i$6 `
9059
9322
  /* A Kodaris-tab card the user can't invoke — not in their roles, or not installed
9060
9323
  here yet. Clicking it does nothing, so it drops the pointer cursor and the hover
9061
9324
  highlight. The Install button inside keeps its own pointer cursor. */
9062
- .skill-card--unavailable {
9063
- cursor: default;
9064
- }
9065
-
9066
- .skill-card--unavailable:hover {
9067
- border-color: #e5e7eb;
9068
- box-shadow: none;
9069
- }
9070
-
9071
9325
  /* Marks a globally-published skill listed on the Your Org tab — only happens on
9072
9326
  kodaris.com, which has no Kodaris tab for its own published skills. */
9073
9327
  .skill-card__badge {
@@ -9103,6 +9357,18 @@ KRChatbot.styles = i$6 `
9103
9357
  color: #000000;
9104
9358
  }
9105
9359
 
9360
+ .skill-install-confirm {
9361
+ display: flex;
9362
+ flex-direction: column;
9363
+ gap: 12px;
9364
+ font-size: 14px;
9365
+ line-height: 1.5;
9366
+ }
9367
+
9368
+ .skill-install-confirm p {
9369
+ margin: 0;
9370
+ }
9371
+
9106
9372
  .skill-card__name {
9107
9373
  font-weight: 600;
9108
9374
  }
@@ -9118,6 +9384,88 @@ KRChatbot.styles = i$6 `
9118
9384
  overflow: hidden;
9119
9385
  }
9120
9386
 
9387
+ .skill-detail {
9388
+ display: flex;
9389
+ flex-direction: column;
9390
+ flex: 1;
9391
+ min-height: 0;
9392
+ }
9393
+
9394
+ .skill-detail__body {
9395
+ display: flex;
9396
+ flex-direction: column;
9397
+ flex: 1;
9398
+ min-height: 0;
9399
+ gap: 18px;
9400
+ padding: 24px;
9401
+ overflow-y: auto;
9402
+ }
9403
+
9404
+ /* Pinned to the bottom of the fixed-height dialog, mirroring kr-dialog-footer
9405
+ but left-aligned. */
9406
+ .skill-detail__footer {
9407
+ display: flex;
9408
+ justify-content: flex-start;
9409
+ flex-shrink: 0;
9410
+ gap: 8px;
9411
+ padding: 16px 24px;
9412
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
9413
+ }
9414
+
9415
+ .skill-detail__section {
9416
+ display: flex;
9417
+ flex-direction: column;
9418
+ gap: 6px;
9419
+ }
9420
+
9421
+ .skill-detail__row {
9422
+ display: flex;
9423
+ align-items: baseline;
9424
+ gap: 8px;
9425
+ }
9426
+
9427
+ /* Fixed label width so the Author and Price values start in the same column. */
9428
+ .skill-detail__row .skill-detail__label {
9429
+ flex-shrink: 0;
9430
+ width: 60px;
9431
+ }
9432
+
9433
+ .skill-detail__title {
9434
+ font-size: 16px;
9435
+ font-weight: 600;
9436
+ color: #000000;
9437
+ }
9438
+
9439
+ .skill-detail__label {
9440
+ font-size: 14px;
9441
+ font-weight: 600;
9442
+ color: #000000;
9443
+ }
9444
+
9445
+ .skill-detail__summary {
9446
+ margin: 0;
9447
+ color: #000000;
9448
+ white-space: pre-wrap;
9449
+ }
9450
+
9451
+ .skill-detail__value {
9452
+ color: #000000;
9453
+ }
9454
+
9455
+ .skill-detail__chips {
9456
+ display: flex;
9457
+ flex-wrap: wrap;
9458
+ gap: 6px;
9459
+ }
9460
+
9461
+ .skill-detail__chip {
9462
+ padding: 2px 8px;
9463
+ border-radius: 6px;
9464
+ background: #f3f4f6;
9465
+ font-size: 12px;
9466
+ color: #000000;
9467
+ }
9468
+
9121
9469
  .skill-browse__empty {
9122
9470
  height: 100%;
9123
9471
  padding: 32px;
@@ -9415,6 +9763,12 @@ __decorate$5([
9415
9763
  __decorate$5([
9416
9764
  r()
9417
9765
  ], KRChatbot.prototype, "_skillBrowseOpened", void 0);
9766
+ __decorate$5([
9767
+ r()
9768
+ ], KRChatbot.prototype, "_skillBrowseDetail", void 0);
9769
+ __decorate$5([
9770
+ r()
9771
+ ], KRChatbot.prototype, "_skillInstallConfirm", void 0);
9418
9772
  __decorate$5([
9419
9773
  r()
9420
9774
  ], KRChatbot.prototype, "_skillBrowseSource", void 0);