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