@copilotkit/web-inspector 1.79.1 → 1.80.0

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.umd.js CHANGED
@@ -927,6 +927,54 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
927
927
 
928
928
  //#endregion
929
929
  //#region src/components/learning-view.ts
930
+ const plural = (count, singular, pluralForm) => `${count} ${count === 1 ? singular : pluralForm}`;
931
+ /** Rows shown per evidence kind before the panel asks to show more. */
932
+ const EVIDENCE_PREVIEW_LIMIT = 10;
933
+ const EVIDENCE_NOUNS = {
934
+ threads: ["Thread", "Threads"],
935
+ trajectories: ["Trajectory", "Trajectories"]
936
+ };
937
+ const trajectoryTimeFormat = new Intl.DateTimeFormat(void 0, {
938
+ month: "short",
939
+ day: "numeric",
940
+ hour: "numeric",
941
+ minute: "2-digit"
942
+ });
943
+ /**
944
+ * Reads the creation time from a UUIDv7 Trajectory id, whose first 48 bits
945
+ * are Unix milliseconds. Returns null for ids of any other version.
946
+ */
947
+ const trajectoryCreatedAt = (trajectoryId) => {
948
+ const hex = trajectoryId.replace(/-/g, "");
949
+ if (!/^[0-9a-f]{12}7[0-9a-f]{19}$/i.test(hex)) return null;
950
+ return new Date(Number.parseInt(hex.slice(0, 12), 16));
951
+ };
952
+ /**
953
+ * "Showing 100 of 412 Trajectories" for each kind the response shortened,
954
+ * or null when every cited source is listed.
955
+ */
956
+ function evidenceCoverageLabel(insight) {
957
+ var _insight$trajectoryEv, _insight$trajectoryEv2;
958
+ if (!insight.evidenceTruncated) return null;
959
+ const parts = [];
960
+ if (insight.evidence.length < insight.totalThreadCount) parts.push(`${insight.evidence.length} of ${plural(insight.totalThreadCount, ...EVIDENCE_NOUNS.threads)}`);
961
+ const trajectoriesShown = (_insight$trajectoryEv = (_insight$trajectoryEv2 = insight.trajectoryEvidence) === null || _insight$trajectoryEv2 === void 0 ? void 0 : _insight$trajectoryEv2.length) !== null && _insight$trajectoryEv !== void 0 ? _insight$trajectoryEv : 0;
962
+ if (insight.totalTrajectoryCount !== void 0 && trajectoriesShown < insight.totalTrajectoryCount) parts.push(`${trajectoriesShown} of ${plural(insight.totalTrajectoryCount, ...EVIDENCE_NOUNS.trajectories)}`);
963
+ return parts.length === 0 ? null : `Showing ${parts.join(" · ")}`;
964
+ }
965
+ /**
966
+ * Labels the sources an Insight cites. Trajectories are named only when
967
+ * cited, so Thread-only Insights and older Intelligence versions read as
968
+ * before.
969
+ */
970
+ function evidenceCountLabel(insight) {
971
+ var _ref, _insight$totalTraject, _insight$trajectoryEv3;
972
+ const threads = plural(insight.totalThreadCount, "Thread", "Threads");
973
+ const trajectoryCount = (_ref = (_insight$totalTraject = insight.totalTrajectoryCount) !== null && _insight$totalTraject !== void 0 ? _insight$totalTraject : (_insight$trajectoryEv3 = insight.trajectoryEvidence) === null || _insight$trajectoryEv3 === void 0 ? void 0 : _insight$trajectoryEv3.length) !== null && _ref !== void 0 ? _ref : 0;
974
+ if (trajectoryCount === 0) return threads;
975
+ const trajectories = plural(trajectoryCount, "Trajectory", "Trajectories");
976
+ return insight.totalThreadCount === 0 ? trajectories : `${threads} · ${trajectories}`;
977
+ }
930
978
  function deriveLearningViewState(input) {
931
979
  if (!input.supported) return input.setupActive ? "setup" : "landing";
932
980
  if (!input.snapshot && input.loading) return "loading";
@@ -958,6 +1006,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
958
1006
  this.promptTrigger = null;
959
1007
  this.expandedSkillId = null;
960
1008
  this.selectedInsightId = null;
1009
+ this.expandedEvidence = /* @__PURE__ */ new Set();
961
1010
  this.skillPageKey = "";
962
1011
  this.handlePromptKeydown = (event) => {
963
1012
  if (event.key === "Escape") {
@@ -1156,6 +1205,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1156
1205
  </nav>`;
1157
1206
  }
1158
1207
  renderEvidence(insight) {
1208
+ var _insight$trajectoryEv4;
1209
+ const threads = insight.evidence;
1210
+ const trajectories = (_insight$trajectoryEv4 = insight.trajectoryEvidence) !== null && _insight$trajectoryEv4 !== void 0 ? _insight$trajectoryEv4 : [];
1211
+ const mixed = threads.length > 0 && trajectories.length > 0;
1212
+ const coverage = evidenceCoverageLabel(insight);
1159
1213
  return lit.html`<section class="detail-panel" aria-label="Insight evidence">
1160
1214
  <div class="detail-head">
1161
1215
  <div>
@@ -1174,14 +1228,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1174
1228
  ×
1175
1229
  </button>
1176
1230
  </div>
1231
+ ${coverage ? lit.html`<p class="evidence-coverage">${coverage}</p>` : lit.nothing}
1177
1232
  <div class="evidence-list">
1178
- ${insight.evidence.length === 0 ? lit.html`
1233
+ ${threads.length === 0 && trajectories.length === 0 ? lit.html`
1179
1234
  <div class="evidence-unavailable">Evidence is no longer available</div>
1180
- ` : insight.evidence.map((evidence) => {
1235
+ ` : lit.html`${this.renderEvidenceGroup(insight.id, "threads", threads, mixed, (evidence) => {
1181
1236
  var _evidence$threadName;
1182
- return evidence.status === "unavailable" ? lit.html`
1183
- <div class="evidence-unavailable">Evidence is no longer available</div>
1184
- ` : lit.html`<button
1237
+ return lit.html`<button
1185
1238
  class="evidence-link"
1186
1239
  type="button"
1187
1240
  @click=${() => this.emit("learning-open-evidence", {
@@ -1193,12 +1246,63 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1193
1246
  ${(_evidence$threadName = evidence.threadName) !== null && _evidence$threadName !== void 0 ? _evidence$threadName : `Thread ${evidence.threadId.slice(0, 8)}`}
1194
1247
  <span>Open Thread →</span>
1195
1248
  </button>`;
1196
- })}
1249
+ })}${this.renderEvidenceGroup(insight.id, "trajectories", trajectories, mixed, (evidence) => this.renderTrajectoryEvidence(evidence))}`}
1197
1250
  </div>
1198
- ${insight.evidenceTruncated ? lit.html`
1251
+ ${insight.evidenceTruncated && !coverage ? lit.html`
1199
1252
  <p class="supporting-unavailable">Evidence response shortened</p>
1200
1253
  ` : lit.nothing}
1201
1254
  </section>`;
1255
+ }
1256
+ /**
1257
+ * Lists one kind of evidence: the first rows with a toggle for the rest,
1258
+ * then one line counting the sources that are no longer available.
1259
+ */
1260
+ renderEvidenceGroup(insightId, kind, entries, showHeading, renderRow) {
1261
+ if (entries.length === 0) return lit.nothing;
1262
+ const available = entries.filter((entry) => entry.status === "available");
1263
+ const unavailable = entries.length - available.length;
1264
+ const key = `${insightId}:${kind}`;
1265
+ const expanded = this.expandedEvidence.has(key);
1266
+ const hidden = Math.max(0, available.length - EVIDENCE_PREVIEW_LIMIT);
1267
+ const [singular, pluralForm] = EVIDENCE_NOUNS[kind];
1268
+ return lit.html`
1269
+ ${showHeading ? lit.html`<h4 class="evidence-group-heading">${pluralForm}</h4>` : lit.nothing}
1270
+ ${(expanded ? available : available.slice(0, EVIDENCE_PREVIEW_LIMIT)).map(renderRow)}
1271
+ ${hidden > 0 ? lit.html`<button
1272
+ class="evidence-more"
1273
+ type="button"
1274
+ aria-expanded=${expanded}
1275
+ @click=${() => {
1276
+ if (expanded) this.expandedEvidence.delete(key);
1277
+ else this.expandedEvidence.add(key);
1278
+ this.requestUpdate();
1279
+ }}
1280
+ >
1281
+ ${expanded ? `Show fewer ${pluralForm}` : `Show ${plural(hidden, `more ${singular}`, `more ${pluralForm}`)}`}
1282
+ </button>` : lit.nothing}
1283
+ ${unavailable > 0 ? lit.html`<div class="evidence-unavailable">
1284
+ ${plural(unavailable, singular, pluralForm)}
1285
+ ${unavailable === 1 ? "is" : "are"} no longer available
1286
+ </div>` : lit.nothing}
1287
+ `;
1288
+ }
1289
+ renderTrajectoryEvidence(evidence) {
1290
+ const createdAt = trajectoryCreatedAt(evidence.trajectoryId);
1291
+ const idTail = evidence.trajectoryId.slice(-8);
1292
+ return lit.html`<a
1293
+ class="evidence-link"
1294
+ href=${evidence.url}
1295
+ target="_blank"
1296
+ rel="noopener noreferrer"
1297
+ title=${evidence.trajectoryId}
1298
+ @click=${() => this.emit("learning-web-link", { category: "trajectory" })}
1299
+ >
1300
+ ⌁
1301
+ ${createdAt ? `Trajectory · ${trajectoryTimeFormat.format(createdAt)}` : `Trajectory ${idTail}`}
1302
+ · ${plural(evidence.eventCount, "cited event", "cited events")}
1303
+ ${createdAt ? lit.html`<small class="evidence-id">${idTail}</small>` : lit.nothing}
1304
+ <span>Open Trajectory ↗</span>
1305
+ </a>`;
1202
1306
  }
1203
1307
  selectInsight(insight) {
1204
1308
  this.selectedInsightId = insight.id;
@@ -1242,8 +1346,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1242
1346
  @click=${() => this.selectInsight(skill.sourceInsight)}
1243
1347
  >
1244
1348
  ${this.supportingInsightLabel(skill.sourceInsight.statement)}<small
1245
- >${skill.sourceInsight.totalThreadCount}
1246
- ${skill.sourceInsight.totalThreadCount === 1 ? "Thread" : "Threads"}</small
1349
+ >${evidenceCountLabel(skill.sourceInsight)}</small
1247
1350
  >
1248
1351
  </button>` : lit.html`
1249
1352
  <div class="supporting-unavailable">Supporting Insight unavailable</div>
@@ -1298,8 +1401,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1298
1401
  <p>${insight.impact}</p>
1299
1402
  </div>
1300
1403
  <span class="evidence-count"
1301
- >${insight.totalThreadCount}
1302
- ${insight.totalThreadCount === 1 ? "Thread" : "Threads"}</span
1404
+ >${evidenceCountLabel(insight)}</span
1303
1405
  >
1304
1406
  </button>`)}
1305
1407
  </div>`}
@@ -2221,7 +2323,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2221
2323
  text-align: left;
2222
2324
  }
2223
2325
  .evidence-link {
2326
+ box-sizing: border-box;
2224
2327
  width: 100%;
2328
+ text-decoration: none;
2225
2329
  cursor: pointer;
2226
2330
  }
2227
2331
  .evidence-link span {
@@ -2232,6 +2336,40 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2232
2336
  color: var(--learning-muted-strong);
2233
2337
  font-style: italic;
2234
2338
  }
2339
+ .evidence-coverage {
2340
+ margin: 12px 0 0;
2341
+ color: var(--learning-muted-strong);
2342
+ font-size: 11px;
2343
+ }
2344
+ .evidence-group-heading {
2345
+ margin: 6px 0 0;
2346
+ color: var(--learning-muted-strong);
2347
+ font-size: 10px;
2348
+ font-weight: 800;
2349
+ letter-spacing: 0.06em;
2350
+ text-transform: uppercase;
2351
+ }
2352
+ .evidence-group-heading:first-child {
2353
+ margin-top: 0;
2354
+ }
2355
+ .evidence-id {
2356
+ color: var(--learning-muted-strong);
2357
+ font:
2358
+ 10px ui-monospace,
2359
+ SFMono-Regular,
2360
+ Menlo,
2361
+ monospace;
2362
+ }
2363
+ .evidence-more {
2364
+ justify-self: start;
2365
+ padding: 2px 0;
2366
+ color: var(--learning-purple-dark);
2367
+ background: none;
2368
+ border: 0;
2369
+ font-size: 11px;
2370
+ font-weight: 700;
2371
+ cursor: pointer;
2372
+ }
2235
2373
  .pagination {
2236
2374
  display: flex;
2237
2375
  align-items: center;
@@ -3064,7 +3202,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3064
3202
 
3065
3203
  //#endregion
3066
3204
  //#region package.json
3067
- var version = "1.79.1";
3205
+ var version = "1.80.0";
3068
3206
 
3069
3207
  //#endregion
3070
3208
  //#region src/lib/telemetry.ts