@copilotkit/web-inspector 1.73.2 → 1.73.3

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
@@ -2404,7 +2404,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2404
2404
 
2405
2405
  //#endregion
2406
2406
  //#region package.json
2407
- var version = "1.73.2";
2407
+ var version = "1.73.3";
2408
2408
 
2409
2409
  //#endregion
2410
2410
  //#region src/lib/telemetry.ts
@@ -2851,12 +2851,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2851
2851
  * The CLI resolves `onboard start` against a prompt graph, so the two surfaces
2852
2852
  * must not drift — if the CLI's entry point changes, both change together.
2853
2853
  *
2854
- * Two lines, and deliberately nothing else. It used to open by telling the
2855
- * agent to identify itself and pass the slug as a flag -- two sentences of
2856
- * instruction to a machine, in the one piece of text a human reads, decides on
2857
- * and pastes. The graph asks for the slug itself now, with `onboard identify`,
2858
- * which is the surface that talks to the agent for the rest of the run
2859
- * (Intelligence OSS-1157).
2854
+ * One sentence, and deliberately nothing else. It used to carry the `npx`
2855
+ * command itself, which put a command line and a telemetry id in the one piece
2856
+ * of text a human reads, decides on and pastes. The command now lives in the
2857
+ * document the URL serves, with the run id already written into it
2858
+ * (PE-216/PE-217).
2860
2859
  *
2861
2860
  * This one stays generic, and so do the docs and Intelligence web-app copies
2862
2861
  * of it (OSS-1150). Those three are entry points for a developer with no
@@ -2867,9 +2866,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2867
2866
  * `FEATURE_ONBOARDING_PROMPT_TEMPLATE` below.
2868
2867
  */
2869
2868
  const RUN_ID_PLACEHOLDER = "<run-id>";
2870
- const ONBOARDING_PROMPT_TEMPLATE = `Help me get started with CopilotKit. Run this command and follow the instructions:
2871
-
2872
- npx --yes copilotkit@latest onboard start --run ${RUN_ID_PLACEHOLDER}`;
2869
+ const ONBOARDING_PROMPT_ORIGIN = "https://copilotkit.ai";
2870
+ const ONBOARDING_PROMPT_TEMPLATE = `Read ${ONBOARDING_PROMPT_ORIGIN}/onboarding-prompts/${RUN_ID_PLACEHOLDER} and help me get set up.`;
2873
2871
  /** Length and alphabet are the CLI's, so a run id copied here resolves there. */
2874
2872
  const RUN_ID_LENGTH = 12;
2875
2873
  /**
@@ -2930,15 +2928,11 @@ npx --yes copilotkit@latest onboard start --run ${RUN_ID_PLACEHOLDER}`;
2930
2928
  * here would duplicate all of that and then drift from it the next time the
2931
2929
  * underlying API changes.
2932
2930
  *
2933
- * What is left is the caller's own business: identify yourself, run this
2934
- * command, and the standing permission for the session check that the
2935
- * developer granted by copying the prompt.
2931
+ * The session-check permission the developer granted by copying this, and the
2932
+ * credentials warning beside it, moved with the command into the document the
2933
+ * URL serves. They are not dropped.
2936
2934
  */
2937
- const FEATURE_ONBOARDING_PROMPT_TEMPLATE = `Help me set this up in my CopilotKit app. Run this command and follow the instructions:
2938
-
2939
- npx --yes copilotkit@latest onboard start --run ${RUN_ID_PLACEHOLDER} --intent ${INTENT_PLACEHOLDER}
2940
-
2941
- If it requires a CopilotKit CLI session check, you have permission to run it. Never reveal credentials.`;
2935
+ const FEATURE_ONBOARDING_PROMPT_TEMPLATE = `Read ${ONBOARDING_PROMPT_ORIGIN}/onboarding-prompts/${RUN_ID_PLACEHOLDER}?intent=${INTENT_PLACEHOLDER} and help me set this up.`;
2942
2936
  /** Bind one run id and one tile's feature outcome into the copied prompt. */
2943
2937
  function createFeatureOnboardingPrompt(serviceId, runId) {
2944
2938
  return FEATURE_ONBOARDING_PROMPT_TEMPLATE.replace(RUN_ID_PLACEHOLDER, runId).replace(INTENT_PLACEHOLDER, FEATURE_ONBOARDING_INTENT[serviceId]);
@@ -4195,6 +4189,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4195
4189
  this._loadingEvents = false;
4196
4190
  this._loadingState = false;
4197
4191
  this._messagesError = null;
4192
+ this._messageRefreshError = null;
4198
4193
  this._eventsError = null;
4199
4194
  this._stateError = null;
4200
4195
  this._expandedTools = /* @__PURE__ */ new Set();
@@ -4289,7 +4284,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4289
4284
  </div>`;
4290
4285
  }
4291
4286
  renderTabContent(id) {
4292
- if (id === "timeline") return lit.html`${this._showEventTimeline ? lit.html`<div class="cpk-td__timeline-toolbar">${this.renderTimelineBulkButtons()}</div>${this.renderTimeline()}` : this._conversation.length || this._loadingMessages || this._messagesError ? this.renderConversation() : this.renderTimeline()}`;
4287
+ if (id === "timeline") return lit.html`${this._messageRefreshError ? lit.html`<div class="cpk-td__status cpk-td__status--error" role="status">${this._messageRefreshError}</div>` : lit.nothing}${this._showEventTimeline ? lit.html`<div class="cpk-td__timeline-toolbar">${this.renderTimelineBulkButtons()}</div>${this.renderTimeline()}` : this._conversation.length || this._loadingMessages || this._messagesError ? this.renderConversation() : this.renderTimeline()}`;
4293
4288
  if (id === "state") return this.renderState();
4294
4289
  return this.renderEvents();
4295
4290
  }
@@ -4382,7 +4377,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4382
4377
  scrollToFocusedMessage() {
4383
4378
  var _this$shadowRoot$quer, _this$shadowRoot3, _message$scrollIntoVi;
4384
4379
  if (!this.focusMessageId) return;
4385
- const message = Array.from((_this$shadowRoot$quer = (_this$shadowRoot3 = this.shadowRoot) === null || _this$shadowRoot3 === void 0 ? void 0 : _this$shadowRoot3.querySelectorAll("[data-message-id]")) !== null && _this$shadowRoot$quer !== void 0 ? _this$shadowRoot$quer : []).find((candidate) => candidate.dataset.messageId === this.focusMessageId);
4380
+ const message = Array.from((_this$shadowRoot$quer = (_this$shadowRoot3 = this.shadowRoot) === null || _this$shadowRoot3 === void 0 ? void 0 : _this$shadowRoot3.querySelectorAll(`#${this.panelDomId(this._tab)}:not([hidden]) [data-message-id]`)) !== null && _this$shadowRoot$quer !== void 0 ? _this$shadowRoot$quer : []).find((candidate) => candidate.dataset.messageId === this.focusMessageId);
4386
4381
  if (!message) return;
4387
4382
  (_message$scrollIntoVi = message.scrollIntoView) === null || _message$scrollIntoVi === void 0 || _message$scrollIntoVi.call(message, { block: "center" });
4388
4383
  this._scrolledFocusRequestId = this.focusRequestId;
@@ -4455,6 +4450,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4455
4450
  this._loadingEvents = false;
4456
4451
  this._loadingState = false;
4457
4452
  this._messagesError = null;
4453
+ this._messageRefreshError = null;
4458
4454
  this._eventsError = null;
4459
4455
  this._stateError = null;
4460
4456
  this._fetchedMetadata = null;
@@ -4474,7 +4470,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4474
4470
  this._fetchedMetadata = metadata;
4475
4471
  } catch (err) {
4476
4472
  if (err instanceof Error && err.name === "AbortError") return;
4477
- if (this.threadId !== threadId) return;
4473
+ if (controller.signal.aborted || this.threadId !== threadId) return;
4478
4474
  this._fetchedMetadata = null;
4479
4475
  }
4480
4476
  }
@@ -4500,20 +4496,24 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4500
4496
  if (!silent) {
4501
4497
  this._loadingMessages = true;
4502
4498
  this._messagesError = null;
4499
+ this._messageRefreshError = null;
4503
4500
  }
4504
4501
  try {
4505
4502
  var _this$provider5;
4506
4503
  const messages = ((_this$provider5 = this.provider) === null || _this$provider5 === void 0 ? void 0 : _this$provider5.getMessages) ? await this.provider.getMessages(threadId, { signal: controller.signal }) : await this.fetchRuntimeMessages(threadId, controller.signal);
4507
4504
  if (controller.signal.aborted || this.threadId !== threadId) return;
4508
4505
  this._conversation = this.mapMessages(messages);
4506
+ this._messagesError = null;
4507
+ this._messageRefreshError = null;
4509
4508
  } catch (err) {
4509
+ if (controller.signal.aborted || this.threadId !== threadId) return;
4510
4510
  if (err instanceof Error && err.name === "AbortError") return;
4511
- if (!silent) {
4511
+ if (!silent || this._conversation.length === 0) {
4512
4512
  this._messagesError = err instanceof Error ? err.message : "Failed to load messages";
4513
4513
  this._conversation = [];
4514
- }
4514
+ } else this._messageRefreshError = "Could not refresh messages. Showing the last loaded conversation.";
4515
4515
  } finally {
4516
- if (!silent && !controller.signal.aborted) this._loadingMessages = false;
4516
+ if (!controller.signal.aborted && this.threadId === threadId) this._loadingMessages = false;
4517
4517
  }
4518
4518
  }
4519
4519
  async fetchEvents(threadId) {
@@ -4542,7 +4542,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4542
4542
  this._fetchedEvents = this.mapApiEvents(result.events);
4543
4543
  } catch (err) {
4544
4544
  if (err instanceof Error && err.name === "AbortError") return;
4545
- if (this.threadId !== threadId) return;
4545
+ if (controller.signal.aborted || this.threadId !== threadId) return;
4546
4546
  this._eventsError = err instanceof Error ? err.message : "Failed to load events";
4547
4547
  this._fetchedEvents = [];
4548
4548
  } finally {
@@ -4575,7 +4575,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4575
4575
  this._fetchedState = (_result$state = result.state) !== null && _result$state !== void 0 ? _result$state : null;
4576
4576
  } catch (err) {
4577
4577
  if (err instanceof Error && err.name === "AbortError") return;
4578
- if (this.threadId !== threadId) return;
4578
+ if (controller.signal.aborted || this.threadId !== threadId) return;
4579
4579
  this._stateError = err instanceof Error ? err.message : "Failed to load state";
4580
4580
  this._fetchedState = null;
4581
4581
  } finally {
@@ -4654,6 +4654,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4654
4654
  toolCallId: tc.id,
4655
4655
  arguments: args,
4656
4656
  result: null,
4657
+ hasResult: false,
4657
4658
  createdAt: ""
4658
4659
  };
4659
4660
  toolCallMap.set(tc.id, item);
@@ -4676,19 +4677,24 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4676
4677
  });
4677
4678
  } else if (msg.role === "tool" && msg.toolCallId) {
4678
4679
  const tc = toolCallMap.get(msg.toolCallId);
4679
- if (tc) try {
4680
- tc.result = this.parseToolCallContent(msg.content);
4681
- } catch (err) {
4682
- var _msg$content;
4683
- console.error("[CopilotKit Inspector] Failed to parse tool-call result content", {
4684
- toolCallId: msg.toolCallId,
4685
- raw: msg.content,
4686
- error: err
4687
- });
4688
- tc.result = {
4689
- __parseError: true,
4690
- __raw: (_msg$content = msg.content) !== null && _msg$content !== void 0 ? _msg$content : null
4691
- };
4680
+ if (tc) {
4681
+ tc.hasResult = true;
4682
+ tc.resultUnreadable = false;
4683
+ try {
4684
+ tc.result = this.parseToolCallContent(msg.content);
4685
+ } catch (err) {
4686
+ var _msg$content;
4687
+ console.error("[CopilotKit Inspector] Failed to parse tool-call result content", {
4688
+ toolCallId: msg.toolCallId,
4689
+ raw: msg.content,
4690
+ error: err
4691
+ });
4692
+ tc.resultUnreadable = true;
4693
+ tc.result = {
4694
+ __parseError: true,
4695
+ __raw: (_msg$content = msg.content) !== null && _msg$content !== void 0 ? _msg$content : null
4696
+ };
4697
+ }
4692
4698
  }
4693
4699
  }
4694
4700
  return items;
@@ -5468,14 +5474,65 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5468
5474
  <span>No messages yet</span>
5469
5475
  </div>
5470
5476
  `;
5477
+ const items = this.renderItems;
5478
+ const errors = this.conversationRunErrors(items);
5471
5479
  return this.cachedPanelTpl("timeline-fallback", [
5472
5480
  this._conversation,
5473
5481
  this._expandedTools,
5474
- this._expandedMessages
5482
+ this._expandedMessages,
5483
+ JSON.stringify(errors),
5484
+ this._expandedTimelineDetails
5475
5485
  ], () => {
5476
- return lit.html`${this.renderItems.map((item) => this.renderRenderItem(item))}`;
5486
+ const errorsAfter = /* @__PURE__ */ new Map();
5487
+ for (const { after, item } of errors) {
5488
+ var _errorsAfter$get;
5489
+ const group = (_errorsAfter$get = errorsAfter.get(after)) !== null && _errorsAfter$get !== void 0 ? _errorsAfter$get : [];
5490
+ group.push(item);
5491
+ errorsAfter.set(after, group);
5492
+ }
5493
+ const renderErrors = (after) => {
5494
+ var _errorsAfter$get2;
5495
+ return (_errorsAfter$get2 = errorsAfter.get(after)) === null || _errorsAfter$get2 === void 0 ? void 0 : _errorsAfter$get2.map((item) => this.renderTimelineItem(item));
5496
+ };
5497
+ return lit.html`
5498
+ ${renderErrors(-1)}
5499
+ ${items.map((item, index) => lit.html`${this.renderRenderItem(item)}${renderErrors(index)}`)}
5500
+ `;
5477
5501
  });
5478
5502
  }
5503
+ conversationRunErrors(items) {
5504
+ const positions = /* @__PURE__ */ new Map();
5505
+ items.forEach((item, index) => {
5506
+ positions.set(item.id, index);
5507
+ if (item.type === "tool_call_group") for (const tool of item.items) positions.set(tool.id, index);
5508
+ });
5509
+ const errors = [];
5510
+ let after = -1;
5511
+ let hasAnchor = false;
5512
+ for (const event of this.activeEvents) {
5513
+ const id = (event.type.startsWith("TOOL_CALL") ? [
5514
+ "toolCallId",
5515
+ "tool_call_id",
5516
+ "callId",
5517
+ "id"
5518
+ ] : event.type.startsWith("TEXT_MESSAGE") || event.type.startsWith("ACTIVITY") ? [
5519
+ "messageId",
5520
+ "message_id",
5521
+ "id"
5522
+ ] : []).map((key) => event.payload[key]).find((value) => typeof value === "string");
5523
+ const position = id == null ? void 0 : positions.get(id);
5524
+ if (position !== void 0) {
5525
+ after = Math.max(after, position);
5526
+ hasAnchor = true;
5527
+ }
5528
+ if (event.type === "RUN_ERROR" || event.type === "ERROR") for (const item of this.timelineItemsFromEvents([event])) errors.push({
5529
+ after,
5530
+ item
5531
+ });
5532
+ }
5533
+ if (!hasAnchor) for (const error of errors) error.after = items.length - 1;
5534
+ return errors;
5535
+ }
5479
5536
  /**
5480
5537
  * Memoize the rendered TemplateResult for `slot` keyed by tuple
5481
5538
  * element-wise reference equality. The hot path for tab switches: when
@@ -5548,32 +5605,40 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5548
5605
  const expanded = this._expandedTools.has(item.id);
5549
5606
  return lit.html`
5550
5607
  <div class="cpk-td__tool-block">
5551
- <div
5608
+ <button
5609
+ type="button"
5552
5610
  class="cpk-td__tool-header"
5611
+ aria-expanded=${expanded}
5553
5612
  @click=${() => this.toggleToolExpand(item.id)}
5554
5613
  >
5555
- <svg width="10" height="10" viewBox="0 0 10 10" fill="none">
5614
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true">
5556
5615
  <path
5557
- d="M1 9C1 9 2 7 5 7C8 7 9 9 9 9M5 1C5 1 7 2.5 7 4.5C7 6.5 5 7 5 7C5 7 3 6.5 3 4.5C3 2.5 5 1 5 1Z"
5616
+ d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94z"
5558
5617
  stroke="currentColor"
5559
- stroke-width="1.2"
5618
+ stroke-width="2"
5560
5619
  stroke-linecap="round"
5561
5620
  stroke-linejoin="round"
5562
5621
  />
5563
5622
  </svg>
5564
5623
  <span class="cpk-td__tool-name">${item.toolName}</span>
5565
- ${item.result || Object.keys(item.arguments).length > 0 ? lit.html`
5566
- <span class="cpk-td__tool-status">Complete</span>
5567
- ` : lit.html`
5568
- <span class="cpk-td__tool-status cpk-td__tool-status--pending">Pending</span>
5569
- `}
5624
+ ${item.resultUnreadable ? lit.html`
5625
+ <span class="cpk-td__tool-status cpk-td__tool-status--pending"
5626
+ >Result unreadable</span
5627
+ >
5628
+ ` : item.hasResult ? lit.html`
5629
+ <span class="cpk-td__tool-status">Result received</span>
5630
+ ` : lit.html`
5631
+ <span class="cpk-td__tool-status cpk-td__tool-status--pending"
5632
+ >No result recorded</span
5633
+ >
5634
+ `}
5570
5635
  <span class="cpk-td__tool-chevron">${expanded ? "▾" : "▸"}</span>
5571
- </div>
5636
+ </button>
5572
5637
  ${expanded ? lit.html`
5573
5638
  <div class="cpk-td__tool-body">
5574
5639
  <div class="cpk-td__tool-section-label">Arguments</div>
5575
5640
  ${renderHighlightedJsonBlock(item.arguments)}
5576
- ${item.result ? lit.html`
5641
+ ${item.hasResult ? lit.html`
5577
5642
  <div
5578
5643
  class="cpk-td__tool-section-label"
5579
5644
  style="margin-top:8px"
@@ -5884,6 +5949,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5884
5949
  _loadingEvents: { state: true },
5885
5950
  _loadingState: { state: true },
5886
5951
  _messagesError: { state: true },
5952
+ _messageRefreshError: { state: true },
5887
5953
  _eventsError: { state: true },
5888
5954
  _stateError: { state: true },
5889
5955
  _expandedTools: { state: true },
@@ -6413,10 +6479,19 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
6413
6479
  background: #ffffff;
6414
6480
  color: #71717a;
6415
6481
  cursor: pointer;
6482
+ width: 100%;
6483
+ border: 0;
6484
+ font-family: inherit;
6485
+ text-align: left;
6416
6486
  font-size: 11px;
6417
6487
  user-select: none;
6418
6488
  }
6419
6489
 
6490
+ .cpk-td__tool-header:focus-visible {
6491
+ outline: 2px solid var(--cpk-primary-color, #7076b3);
6492
+ outline-offset: -2px;
6493
+ }
6494
+
6420
6495
  .cpk-td__tool-header:hover {
6421
6496
  background: #fafafa;
6422
6497
  }
@@ -11201,19 +11276,16 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11201
11276
  });
11202
11277
  }
11203
11278
  renderHomeView() {
11204
- var _model$project$projec, _model$project3;
11205
11279
  const model = this.getHomeModel();
11206
- const connected = model.hero.connection === "connected";
11207
11280
  return lit.html`
11208
11281
  <div
11209
11282
  class="inspector-home"
11210
11283
  data-inspector-home
11211
- data-inspector-home-state=${connected ? "connected" : "disconnected"}
11284
+ data-inspector-home-state=${model.hero.connection === "connected" ? "connected" : "disconnected"}
11212
11285
  >
11213
11286
  ${this.renderHomeWhatsNewPreview(model.news)}
11214
- <header class="inspector-home-heading"><div><h1>${connected ? (_model$project$projec = (_model$project3 = model.project) === null || _model$project3 === void 0 ? void 0 : _model$project3.projectName) !== null && _model$project$projec !== void 0 ? _model$project$projec : "Your agent workspace" : "Welcome to Intelligence"}</h1><p>${connected ? "Inspect conversations and see what your agent is learning." : "Connect your agent. Intelligence learns from experience."}</p></div></header>
11215
- ${connected ? this.renderHomeSystemHealth(model) : this.renderHomeIntelligenceHud(model)}
11216
- ${connected ? this.renderHomeIntelligenceHud(model) : this.renderHomeSystemHealth(model)}
11287
+ ${this.renderHomeSystemHealth(model)}
11288
+ ${this.renderHomeIntelligenceHud(model)}
11217
11289
  ${this.renderHomeFeatures(model)}
11218
11290
  </div>
11219
11291
  `;