@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.
package/dist/chatbot.js CHANGED
@@ -451,6 +451,18 @@ export class KRChatbot extends LitElement {
451
451
  this._copiedIndex = -1;
452
452
  /** Whether the "Browse all skills" dialog is open. */
453
453
  this._skillBrowseOpened = false;
454
+ /**
455
+ * The skill whose detail view is showing inside the browse dialog, else null.
456
+ * While set, the browse dialog shows that skill's summary, author, price, roles
457
+ * and actions in place of the search field and tabs.
458
+ */
459
+ this._skillBrowseDetail = null;
460
+ /**
461
+ * The billable global skill awaiting the user's install confirmation, else null.
462
+ * Set when Install is clicked on a billable skill; the confirm dialog renders
463
+ * while it is set and the request only fires once the user confirms.
464
+ */
465
+ this._skillInstallConfirm = null;
454
466
  /**
455
467
  * Active tab in the browse dialog. `org` shows `_orgSkills` (this instance's
456
468
  * skills); `kodaris` shows `_globalSkills` (the shared global catalog).
@@ -1467,12 +1479,46 @@ export class KRChatbot extends LitElement {
1467
1479
  if (this._globalSkillPending.has(skill.code)) {
1468
1480
  return;
1469
1481
  }
1482
+ const btn = e.currentTarget;
1483
+ // Installing a billable skill charges the account, so confirm before sending.
1484
+ // Uninstalling is never billed and free installs are one click to undo.
1485
+ if (!skill.enabled && skill.billable) {
1486
+ this._skillInstallConfirm = skill;
1487
+ return;
1488
+ }
1489
+ this._enableGlobalSkill(skill, btn);
1490
+ }
1491
+ /** Cancel the billable install confirmation without sending anything. */
1492
+ _handleSkillInstallCancel() {
1493
+ this._skillInstallConfirm = null;
1494
+ }
1495
+ /**
1496
+ * The user accepted the charge: run the install with the dialog's own Install
1497
+ * button spinning, and close the dialog once the server confirms. On failure
1498
+ * the button shows the error and the dialog stays open so they can retry or cancel.
1499
+ */
1500
+ _handleSkillInstallConfirm(e) {
1501
+ if (!this._skillInstallConfirm) {
1502
+ return;
1503
+ }
1504
+ this._enableGlobalSkill(this._skillInstallConfirm, e.currentTarget).then((ok) => {
1505
+ if (ok) {
1506
+ this._skillInstallConfirm = null;
1507
+ }
1508
+ });
1509
+ }
1510
+ /**
1511
+ * Send the enable/disable request for a global skill and reflect the server's
1512
+ * result on its card. `btn` is the button that triggered it (the card's
1513
+ * Install button, or the confirmation dialog's), whose spinner shows while the
1514
+ * request is in flight. Resolves true on success, false on failure.
1515
+ */
1516
+ _enableGlobalSkill(skill, btn) {
1470
1517
  // Drive the clicked button's own spinner (KRButton disables itself while
1471
1518
  // loading, so a second click can't fire until the request settles).
1472
- const btn = e.currentTarget;
1473
1519
  this._globalSkillPending.add(skill.code);
1474
1520
  btn?.showLoading();
1475
- KRHttp.fetch({
1521
+ return KRHttp.fetch({
1476
1522
  url: `/api/system/opensearch/aiskills/global/${encodeURIComponent(skill.code)}/enabled`,
1477
1523
  method: 'POST',
1478
1524
  body: { enabled: !skill.enabled },
@@ -1484,10 +1530,26 @@ export class KRChatbot extends LitElement {
1484
1530
  skill.enabled = res?.data?.enabled;
1485
1531
  btn?.reset();
1486
1532
  this.requestUpdate();
1533
+ if (skill.enabled) {
1534
+ KRSnackbar.show({
1535
+ title: 'Skill Installed',
1536
+ message: `${skill.name} is now available to use.`,
1537
+ type: 'success',
1538
+ });
1539
+ }
1540
+ else {
1541
+ KRSnackbar.show({
1542
+ title: 'Skill Uninstalled',
1543
+ message: `${skill.name} is no longer available to use.`,
1544
+ type: 'success',
1545
+ });
1546
+ }
1547
+ return true;
1487
1548
  })
1488
1549
  .catch((error) => {
1489
1550
  console.error('kr-chatbot: global skill enable failed', error);
1490
1551
  btn?.showError('Error');
1552
+ return false;
1491
1553
  })
1492
1554
  .finally(() => {
1493
1555
  this._globalSkillPending.delete(skill.code);
@@ -1648,11 +1710,11 @@ export class KRChatbot extends LitElement {
1648
1710
  this._skillBrowseOpened = false;
1649
1711
  this._inputEl?.focus();
1650
1712
  }
1651
- /** Activate a skill card via keyboard (Enter/Space), since it's a div role=button. */
1713
+ /** Open a skill card via keyboard (Enter/Space), since it's a div role=button. */
1652
1714
  _handleSkillCardKeydown(e, skill) {
1653
1715
  if (e.key === 'Enter' || e.key === ' ') {
1654
1716
  e.preventDefault();
1655
- this._handleSkillSelect(skill);
1717
+ this._handleSkillCardOpen(skill);
1656
1718
  }
1657
1719
  }
1658
1720
  /**
@@ -1690,6 +1752,29 @@ export class KRChatbot extends LitElement {
1690
1752
  }
1691
1753
  _handleSkillBrowseClose() {
1692
1754
  this._skillBrowseOpened = false;
1755
+ this._skillBrowseDetail = null;
1756
+ }
1757
+ /** Open a skill's detail view inside the browse dialog. */
1758
+ _handleSkillCardOpen(skill) {
1759
+ this._skillBrowseDetail = skill;
1760
+ }
1761
+ /** Return from the detail view to the grid, keeping the tab and search text. */
1762
+ _handleSkillDetailBack() {
1763
+ this._skillBrowseDetail = null;
1764
+ }
1765
+ /** Try It on the detail view: insert the open skill into the composer. */
1766
+ _handleSkillDetailTry() {
1767
+ if (!this._skillBrowseDetail) {
1768
+ return;
1769
+ }
1770
+ this._handleSkillSelect(this._skillBrowseDetail);
1771
+ }
1772
+ /** Install/Uninstall on the detail view for the open global skill. */
1773
+ _handleSkillDetailEnable(e) {
1774
+ if (!this._skillBrowseDetail) {
1775
+ return;
1776
+ }
1777
+ this._handleGlobalSkillEnable(this._skillBrowseDetail, e);
1693
1778
  }
1694
1779
  _handleSkillBrowseSearch(e) {
1695
1780
  this._skillBrowseQuery = e.target.value;
@@ -3189,8 +3274,8 @@ export class KRChatbot extends LitElement {
3189
3274
  @click=${() => this._handleSkillSelect(skill)}
3190
3275
  >
3191
3276
  <span class="skill-menu__name">${skill.name}</span>
3192
- ${skill.description ? html `
3193
- <span class="skill-menu__desc">${skill.description}</span>
3277
+ ${skill.summary ? html `
3278
+ <span class="skill-menu__desc">${skill.summary}</span>
3194
3279
  ` : nothing}
3195
3280
  </button>
3196
3281
  </li>
@@ -3212,43 +3297,134 @@ export class KRChatbot extends LitElement {
3212
3297
  return html `
3213
3298
  <kr-dialog
3214
3299
  opened
3215
- label="Browse Skills"
3216
3300
  width="720px"
3217
3301
  @close=${this._handleSkillBrowseClose}
3218
3302
  >
3303
+ <kr-dialog-header>
3304
+ <div class="skill-browse__header">
3305
+ ${this._skillBrowseDetail ? html `
3306
+ <button
3307
+ type="button"
3308
+ class="skill-browse__back"
3309
+ aria-label="Back"
3310
+ @click=${this._handleSkillDetailBack}
3311
+ >
3312
+ <svg
3313
+ width="22"
3314
+ height="22"
3315
+ viewBox="0 0 24 24"
3316
+ fill="none"
3317
+ stroke="currentColor"
3318
+ stroke-width="2"
3319
+ stroke-linecap="round"
3320
+ stroke-linejoin="round"
3321
+ >
3322
+ <path d="M19 12H5M12 19l-7-7 7-7"/>
3323
+ </svg>
3324
+ </button>
3325
+ ` : html `
3326
+ <h2>Browse Skills</h2>
3327
+ `}
3328
+ <button
3329
+ type="button"
3330
+ class="skill-browse__close"
3331
+ aria-label="Close"
3332
+ @click=${this._handleSkillBrowseClose}
3333
+ >
3334
+ <svg
3335
+ viewBox="0 0 24 24"
3336
+ fill="none"
3337
+ stroke="currentColor"
3338
+ stroke-width="1.5"
3339
+ stroke-linecap="round"
3340
+ stroke-linejoin="round"
3341
+ >
3342
+ <path d="M6 18 18 6M6 6l12 12"/>
3343
+ </svg>
3344
+ </button>
3345
+ </div>
3346
+ </kr-dialog-header>
3219
3347
  <div class="skill-browse">
3220
- <kr-text-field
3221
- placeholder="Search skills..."
3222
- .value=${this._skillBrowseQuery}
3223
- @input=${this._handleSkillBrowseSearch}
3224
- ></kr-text-field>
3225
- <kr-tab-group
3226
- active-tab-id=${this._skillBrowseSource}
3227
- @tab-change=${this._handleSkillBrowseTabChange}
3228
- >
3229
- <kr-tab id="org" label="Your Org">
3230
- ${this._renderSkillGrid()}
3231
- </kr-tab>
3232
- ${this._aiFrameworkConfig.registryServer === true ? nothing : html `
3233
- <kr-tab id="kodaris" label="Kodaris">
3234
- ${this._renderSkillGrid(true)}
3348
+ ${this._skillBrowseDetail ? html `
3349
+ <div class="skill-detail">
3350
+ <div class="skill-detail__body">
3351
+ <div class="skill-detail__section">
3352
+ <span class="skill-detail__title">${this._skillBrowseDetail.name}</span>
3353
+ ${this._skillBrowseDetail.summary ? html `
3354
+ <p class="skill-detail__summary">${this._skillBrowseDetail.summary}</p>
3355
+ ` : nothing}
3356
+ </div>
3357
+ <div class="skill-detail__row">
3358
+ <span class="skill-detail__label">Author</span>
3359
+ <span class="skill-detail__value">${this._skillBrowseDetail.global ? 'Kodaris' : 'Your organization'}</span>
3360
+ </div>
3361
+ ${this._skillBrowseDetail.global ? html `
3362
+ <div class="skill-detail__row">
3363
+ <span class="skill-detail__label">Price</span>
3364
+ <span class="skill-detail__value">${this._skillBrowseDetail.priceLabel}</span>
3365
+ </div>
3366
+ ` : nothing}
3367
+ ${this._skillBrowseDetail.allowedRoles?.length ? html `
3368
+ <div class="skill-detail__row">
3369
+ <span class="skill-detail__label">Roles</span>
3370
+ <div class="skill-detail__chips">
3371
+ ${this._skillBrowseDetail.allowedRoles.map((role) => html `
3372
+ <span class="skill-detail__chip">${role}</span>
3373
+ `)}
3374
+ </div>
3375
+ </div>
3376
+ ` : nothing}
3377
+ </div>
3378
+ <div class="skill-detail__footer">
3379
+ ${this._skillBrowseDetail.canRun !== false && (!this._skillBrowseDetail.global || this._skillBrowseDetail.enabled) ? html `
3380
+ <kr-button
3381
+ variant="flat"
3382
+ color="primary"
3383
+ @click=${this._handleSkillDetailTry}
3384
+ >Try It</kr-button>
3385
+ ` : nothing}
3386
+ ${this._skillBrowseDetail.global ? html `
3387
+ <kr-button
3388
+ variant=${this._skillBrowseDetail.enabled ? 'outline' : 'flat'}
3389
+ color=${this._skillBrowseDetail.enabled ? 'secondary' : 'primary'}
3390
+ @click=${this._handleSkillDetailEnable}
3391
+ >${this._skillBrowseDetail.enabled ? 'Uninstall' : 'Install'}</kr-button>
3392
+ ` : nothing}
3393
+ </div>
3394
+ </div>
3395
+ ` : html `
3396
+ <kr-text-field
3397
+ placeholder="Search skills..."
3398
+ .value=${this._skillBrowseQuery}
3399
+ @input=${this._handleSkillBrowseSearch}
3400
+ ></kr-text-field>
3401
+ <kr-tab-group
3402
+ active-tab-id=${this._skillBrowseSource}
3403
+ @tab-change=${this._handleSkillBrowseTabChange}
3404
+ >
3405
+ <kr-tab id="org" label="Your Org">
3406
+ ${this._renderSkillGrid()}
3235
3407
  </kr-tab>
3236
- `}
3237
- </kr-tab-group>
3408
+ ${this._aiFrameworkConfig.registryServer === true ? nothing : html `
3409
+ <kr-tab id="kodaris" label="Kodaris">
3410
+ ${this._renderSkillGrid(true)}
3411
+ </kr-tab>
3412
+ `}
3413
+ </kr-tab-group>
3414
+ `}
3238
3415
  </div>
3239
3416
  </kr-dialog>
3240
3417
  `;
3241
3418
  }
3242
3419
  /**
3243
3420
  * The card grid of skill search results for the browse dialog. Clicking a card
3244
- * inserts `/code ` into the composer. In the shared-Kodaris (`global`) tab each
3245
- * card also gets a footer row with an Install/Uninstall button.
3421
+ * opens its detail view inside `_renderSkillBrowse`, which is where Try It lives.
3422
+ * In the shared-Kodaris (`global`) tab each card also gets a footer row with an
3423
+ * Install/Uninstall button as a shortcut.
3246
3424
  *
3247
3425
  * The Kodaris tab is the whole published catalog, deliberately NOT role-filtered so
3248
- * users can discover skills they don't have yet. So a card there can be in one of two
3249
- * non-runnable states — the user's roles don't allow it (`canRun: false`), or it isn't
3250
- * installed here (not `enabled`). Neither looks clickable; clicking either explains
3251
- * why via `_handleSkillSelect`.
3426
+ * users can discover skills they don't have yet. Every card is clickable; the detail
3427
+ * view lists the roles and shows Install when the skill isn't installed here.
3252
3428
  */
3253
3429
  _renderSkillGrid(global = false) {
3254
3430
  let skills = this._orgSkills;
@@ -3262,18 +3438,15 @@ export class KRChatbot extends LitElement {
3262
3438
  <div class="skill-browse__grid">
3263
3439
  ${skills.map((skill) => html `
3264
3440
  <div
3265
- class=${classMap({
3266
- 'skill-card': true,
3267
- 'skill-card--unavailable': skill.canRun === false || (!!skill.global && !skill.enabled),
3268
- })}
3441
+ class="skill-card"
3269
3442
  role="button"
3270
3443
  tabindex="0"
3271
- @click=${() => this._handleSkillSelect(skill)}
3444
+ @click=${() => this._handleSkillCardOpen(skill)}
3272
3445
  @keydown=${(e) => this._handleSkillCardKeydown(e, skill)}
3273
3446
  >
3274
3447
  <span class="skill-card__name">${skill.name}</span>
3275
- ${skill.description ? html `
3276
- <span class="skill-card__desc">${skill.description}</span>
3448
+ ${skill.summary ? html `
3449
+ <span class="skill-card__desc">${skill.summary}</span>
3277
3450
  ` : nothing}
3278
3451
  ${!global && skill.global ? html `
3279
3452
  <span class="skill-card__badge">Global</span>
@@ -4545,6 +4718,32 @@ export class KRChatbot extends LitElement {
4545
4718
  </div>
4546
4719
  </div>
4547
4720
  ${this._skillBrowseOpened ? this._renderSkillBrowse() : nothing}
4721
+ ${this._skillInstallConfirm ? html `
4722
+ <kr-dialog
4723
+ opened
4724
+ label="Install Paid Skill"
4725
+ width="480px"
4726
+ @close=${this._handleSkillInstallCancel}
4727
+ >
4728
+ <kr-dialog-content>
4729
+ <div class="skill-install-confirm">
4730
+ <p>
4731
+ <strong>${this._skillInstallConfirm.name}</strong> is a paid skill. Installing it will
4732
+ charge your account <strong>${this._skillInstallConfirm.priceLabel}</strong>.
4733
+ </p>
4734
+ <p>Please confirm you would like to proceed.</p>
4735
+ </div>
4736
+ </kr-dialog-content>
4737
+ <kr-dialog-footer>
4738
+ <kr-button color="secondary" @click=${this._handleSkillInstallCancel}>Cancel</kr-button>
4739
+ <kr-button
4740
+ variant="flat"
4741
+ color="primary"
4742
+ @click=${this._handleSkillInstallConfirm}
4743
+ >Install</kr-button>
4744
+ </kr-dialog-footer>
4745
+ </kr-dialog>
4746
+ ` : nothing}
4548
4747
  ${this._renderDrawer()}
4549
4748
  </div>
4550
4749
  `;
@@ -6292,6 +6491,70 @@ KRChatbot.styles = css `
6292
6491
  height: 70vh;
6293
6492
  }
6294
6493
 
6494
+ /* Slotted replacement for the dialog's built-in header so the detail view can
6495
+ put its back control where the title normally sits. Mirrors kr-dialog's
6496
+ own header: title left, close on the right. */
6497
+ .skill-browse__header {
6498
+ display: flex;
6499
+ flex: 1;
6500
+ align-items: center;
6501
+ justify-content: space-between;
6502
+ gap: 16px;
6503
+ }
6504
+
6505
+ .skill-browse__header h2 {
6506
+ margin: 0;
6507
+ font-size: 18px;
6508
+ font-weight: 600;
6509
+ }
6510
+
6511
+ .skill-browse__back {
6512
+ display: flex;
6513
+ align-items: center;
6514
+ justify-content: center;
6515
+ width: 36px;
6516
+ height: 36px;
6517
+ margin-left: -8px;
6518
+ padding: 0;
6519
+ border: none;
6520
+ border-radius: 6px;
6521
+ background: none;
6522
+ color: #000000;
6523
+ cursor: pointer;
6524
+ transition: background-color 0.15s;
6525
+ }
6526
+
6527
+ .skill-browse__back:hover {
6528
+ background: rgba(0, 0, 0, 0.06);
6529
+ }
6530
+
6531
+ .skill-browse__close {
6532
+ flex-shrink: 0;
6533
+ display: flex;
6534
+ align-items: center;
6535
+ justify-content: center;
6536
+ width: 36px;
6537
+ height: 36px;
6538
+ margin-right: -8px;
6539
+ padding: 0;
6540
+ background: none;
6541
+ border: none;
6542
+ border-radius: 6px;
6543
+ color: #000000;
6544
+ cursor: pointer;
6545
+ transition: background-color 0.15s, color 0.15s;
6546
+ }
6547
+
6548
+ .skill-browse__close:hover {
6549
+ background: rgba(0, 0, 0, 0.06);
6550
+ color: #000000;
6551
+ }
6552
+
6553
+ .skill-browse__close svg {
6554
+ width: 22px;
6555
+ height: 22px;
6556
+ }
6557
+
6295
6558
  .skill-browse kr-text-field {
6296
6559
  display: block;
6297
6560
  margin: 20px 20px 16px;
@@ -6340,15 +6603,6 @@ KRChatbot.styles = css `
6340
6603
  /* A Kodaris-tab card the user can't invoke — not in their roles, or not installed
6341
6604
  here yet. Clicking it does nothing, so it drops the pointer cursor and the hover
6342
6605
  highlight. The Install button inside keeps its own pointer cursor. */
6343
- .skill-card--unavailable {
6344
- cursor: default;
6345
- }
6346
-
6347
- .skill-card--unavailable:hover {
6348
- border-color: #e5e7eb;
6349
- box-shadow: none;
6350
- }
6351
-
6352
6606
  /* Marks a globally-published skill listed on the Your Org tab — only happens on
6353
6607
  kodaris.com, which has no Kodaris tab for its own published skills. */
6354
6608
  .skill-card__badge {
@@ -6384,6 +6638,18 @@ KRChatbot.styles = css `
6384
6638
  color: #000000;
6385
6639
  }
6386
6640
 
6641
+ .skill-install-confirm {
6642
+ display: flex;
6643
+ flex-direction: column;
6644
+ gap: 12px;
6645
+ font-size: 14px;
6646
+ line-height: 1.5;
6647
+ }
6648
+
6649
+ .skill-install-confirm p {
6650
+ margin: 0;
6651
+ }
6652
+
6387
6653
  .skill-card__name {
6388
6654
  font-weight: 600;
6389
6655
  }
@@ -6399,6 +6665,88 @@ KRChatbot.styles = css `
6399
6665
  overflow: hidden;
6400
6666
  }
6401
6667
 
6668
+ .skill-detail {
6669
+ display: flex;
6670
+ flex-direction: column;
6671
+ flex: 1;
6672
+ min-height: 0;
6673
+ }
6674
+
6675
+ .skill-detail__body {
6676
+ display: flex;
6677
+ flex-direction: column;
6678
+ flex: 1;
6679
+ min-height: 0;
6680
+ gap: 18px;
6681
+ padding: 24px;
6682
+ overflow-y: auto;
6683
+ }
6684
+
6685
+ /* Pinned to the bottom of the fixed-height dialog, mirroring kr-dialog-footer
6686
+ but left-aligned. */
6687
+ .skill-detail__footer {
6688
+ display: flex;
6689
+ justify-content: flex-start;
6690
+ flex-shrink: 0;
6691
+ gap: 8px;
6692
+ padding: 16px 24px;
6693
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
6694
+ }
6695
+
6696
+ .skill-detail__section {
6697
+ display: flex;
6698
+ flex-direction: column;
6699
+ gap: 6px;
6700
+ }
6701
+
6702
+ .skill-detail__row {
6703
+ display: flex;
6704
+ align-items: baseline;
6705
+ gap: 8px;
6706
+ }
6707
+
6708
+ /* Fixed label width so the Author and Price values start in the same column. */
6709
+ .skill-detail__row .skill-detail__label {
6710
+ flex-shrink: 0;
6711
+ width: 60px;
6712
+ }
6713
+
6714
+ .skill-detail__title {
6715
+ font-size: 16px;
6716
+ font-weight: 600;
6717
+ color: #000000;
6718
+ }
6719
+
6720
+ .skill-detail__label {
6721
+ font-size: 14px;
6722
+ font-weight: 600;
6723
+ color: #000000;
6724
+ }
6725
+
6726
+ .skill-detail__summary {
6727
+ margin: 0;
6728
+ color: #000000;
6729
+ white-space: pre-wrap;
6730
+ }
6731
+
6732
+ .skill-detail__value {
6733
+ color: #000000;
6734
+ }
6735
+
6736
+ .skill-detail__chips {
6737
+ display: flex;
6738
+ flex-wrap: wrap;
6739
+ gap: 6px;
6740
+ }
6741
+
6742
+ .skill-detail__chip {
6743
+ padding: 2px 8px;
6744
+ border-radius: 6px;
6745
+ background: #f3f4f6;
6746
+ font-size: 12px;
6747
+ color: #000000;
6748
+ }
6749
+
6402
6750
  .skill-browse__empty {
6403
6751
  height: 100%;
6404
6752
  padding: 32px;
@@ -6696,6 +7044,12 @@ __decorate([
6696
7044
  __decorate([
6697
7045
  state()
6698
7046
  ], KRChatbot.prototype, "_skillBrowseOpened", void 0);
7047
+ __decorate([
7048
+ state()
7049
+ ], KRChatbot.prototype, "_skillBrowseDetail", void 0);
7050
+ __decorate([
7051
+ state()
7052
+ ], KRChatbot.prototype, "_skillInstallConfirm", void 0);
6699
7053
  __decorate([
6700
7054
  state()
6701
7055
  ], KRChatbot.prototype, "_skillBrowseSource", void 0);