@opengeni/react 0.9.1 → 0.12.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.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  CONNECTION_STATUS_META,
3
+ CREDIT_EXHAUSTION_MESSAGE,
3
4
  ConnectionDot,
4
5
  ConnectionStatusPill,
5
6
  EnrollmentConsent,
@@ -17,6 +18,7 @@ import {
17
18
  formatBytes,
18
19
  formatRelativeTime,
19
20
  humanizeFailureReason,
21
+ isCreditExhaustion,
20
22
  stringifyPayload,
21
23
  truncate,
22
24
  tryParseJson,
@@ -27,7 +29,7 @@ import {
27
29
  useOpenGeniClient,
28
30
  usePolledValue,
29
31
  useSessionEventTrigger
30
- } from "./chunk-5C7RGAWA.js";
32
+ } from "./chunk-5TIXRCSI.js";
31
33
 
32
34
  // src/hooks/use-session.ts
33
35
  import { useCallback, useState } from "react";
@@ -308,7 +310,7 @@ ${message}` : message;
308
310
  break;
309
311
  }
310
312
  case "sandbox.command.output.delta": {
311
- const text = typeof payload.text === "string" ? payload.text : typeof payload.output === "string" ? payload.output : "";
313
+ const text = typeof payload.chunk === "string" ? payload.chunk : typeof payload.text === "string" ? payload.text : typeof payload.output === "string" ? payload.output : "";
312
314
  if (!text) {
313
315
  break;
314
316
  }
@@ -344,14 +346,39 @@ ${message}` : message;
344
346
  });
345
347
  break;
346
348
  }
349
+ case "tool.auth_needed": {
350
+ closeStreamingTail();
351
+ const authorizationUrl = typeof payload.authorizationUrl === "string" ? payload.authorizationUrl : null;
352
+ items.push({
353
+ kind: "notice",
354
+ id: event.id,
355
+ tone: "waiting",
356
+ text: authNeededNoticeText(payload),
357
+ ...authorizationUrl ? { action: { label: "Connect", url: authorizationUrl } } : {},
358
+ occurredAt: event.occurredAt
359
+ });
360
+ break;
361
+ }
347
362
  case "turn.completed": {
363
+ if (isCreditExhaustionPayload(payload)) {
364
+ finalizeOpen(turnId);
365
+ items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE));
366
+ items.push({
367
+ kind: "notice",
368
+ id: event.id,
369
+ tone: "failed",
370
+ text: CREDIT_EXHAUSTION_MESSAGE,
371
+ occurredAt: event.occurredAt
372
+ });
373
+ break;
374
+ }
348
375
  finalizeOpen(turnId);
349
376
  items.push(turnEndItem(event, "complete", null));
350
377
  break;
351
378
  }
352
379
  case "turn.failed": {
353
380
  const hadActivity = hasTurnActivity(items, turnId);
354
- const failureText = failureMessage(payload);
381
+ const failureText = isCreditExhaustionPayload(payload) ? CREDIT_EXHAUSTION_MESSAGE : failureMessage(payload);
355
382
  finalizeOpen(turnId, "cancelled");
356
383
  items.push(turnEndItem(event, "failed", failureText));
357
384
  if (!hadActivity) {
@@ -404,6 +431,24 @@ ${message}` : message;
404
431
  }
405
432
  return items;
406
433
  }
434
+ function isCreditExhaustionPayload(payload) {
435
+ return isCreditExhaustion({
436
+ error: typeof payload.error === "string" ? payload.error : null,
437
+ detail: typeof payload.detail === "string" ? payload.detail : null,
438
+ segmentLimit: typeof payload.segmentLimit === "string" ? payload.segmentLimit : null
439
+ });
440
+ }
441
+ function creditExhaustedFromEvents(events) {
442
+ const ordered = [...events].sort((a, b) => a.sequence - b.sequence);
443
+ for (let index = ordered.length - 1; index >= 0; index -= 1) {
444
+ const event = ordered[index];
445
+ if (event?.type !== "turn.completed" && event?.type !== "turn.failed" && event?.type !== "turn.cancelled") {
446
+ continue;
447
+ }
448
+ return isCreditExhaustionPayload(asRecord(event.payload));
449
+ }
450
+ return false;
451
+ }
407
452
  function sessionStatusFromEvents(events) {
408
453
  for (let index = events.length - 1; index >= 0; index -= 1) {
409
454
  const event = events[index];
@@ -757,6 +802,17 @@ function goalText(payload) {
757
802
  }
758
803
  return null;
759
804
  }
805
+ function authNeededNoticeText(payload) {
806
+ const provider = typeof payload.providerDomain === "string" && payload.providerDomain.trim().length > 0 ? payload.providerDomain.trim() : "This service";
807
+ const scopes = Array.isArray(payload.scopes) ? payload.scopes.filter((scope) => typeof scope === "string" && scope.trim().length > 0) : [];
808
+ if (payload.reason === "insufficient_scope") {
809
+ return scopes.length > 0 ? `${provider} needs additional access (${scopes.join(", ")}).` : `${provider} needs additional access.`;
810
+ }
811
+ if (payload.reason === "expired" || payload.reason === "refresh_failed") {
812
+ return `${provider} needs to be reconnected.`;
813
+ }
814
+ return `${provider} needs a connection.`;
815
+ }
760
816
  function reasoningText(payload) {
761
817
  const record = asRecord(payload);
762
818
  if (typeof record.text === "string") {
@@ -2674,7 +2730,7 @@ function TurnSummary({ items, outcome, failureText, durationMs, defaultOpen, chi
2674
2730
  "inline-flex size-5 shrink-0 items-center justify-center rounded-full",
2675
2731
  outcome === "failed" ? "bg-og-status-failed/15 text-og-status-failed" : outcome === "cancelled" ? "bg-og-fg-subtle/15 text-og-fg-subtle" : "text-og-fg-subtle"
2676
2732
  ),
2677
- children: outcome === "failed" ? /* @__PURE__ */ jsx9(TriangleAlertIcon, { className: "size-3" }) : outcome === "cancelled" ? /* @__PURE__ */ jsx9(CircleSlashIcon, { className: "size-3" }) : /* @__PURE__ */ jsx9(CheckIcon, { className: "size-3.5" })
2733
+ children: outcome === "failed" ? /* @__PURE__ */ jsx9(TriangleAlertIcon, { className: "size-3" }) : outcome === "cancelled" ? /* @__PURE__ */ jsx9(CircleSlashIcon, { className: "size-3" }) : outcome === "complete" ? /* @__PURE__ */ jsx9(CheckIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx9("span", { className: "size-1.5 animate-og-pulse rounded-full bg-og-fg-subtle" })
2678
2734
  }
2679
2735
  ),
2680
2736
  /* @__PURE__ */ jsxs7("span", { className: "min-w-0 flex-1 truncate text-og-fg-muted", children: [
@@ -6613,13 +6669,14 @@ function MessageTimeline({
6613
6669
  groups.length === 0 && !working ? emptyState ?? /* @__PURE__ */ jsx15("p", { className: "py-10 text-center text-sm text-og-fg-subtle", children: "No activity yet." }) : null,
6614
6670
  hasOlder ? /* @__PURE__ */ jsx15("div", { ref: topSentinelRef, "data-og-top-sentinel": "", "data-og-timeline-chrome": "", "aria-hidden": "true", className: "h-px w-full shrink-0" }) : null,
6615
6671
  loadingOlder ? /* @__PURE__ */ jsx15("div", { "data-og-timeline-chrome": "", className: "flex items-center gap-2 text-sm", children: /* @__PURE__ */ jsx15("span", { className: "og-shimmer-text font-medium", children: "Loading earlier activity\u2026" }) }) : null,
6616
- groups.map((group) => /* @__PURE__ */ jsx15(
6672
+ groups.map((group, index) => /* @__PURE__ */ jsx15(
6617
6673
  TimelineGroupView,
6618
6674
  {
6619
6675
  group,
6620
6676
  renderMessageText,
6621
6677
  onOpenSession,
6622
- toolRegistry
6678
+ toolRegistry,
6679
+ foldLiveCluster: isAgentProgress(groups[index + 1])
6623
6680
  },
6624
6681
  timelineGroupKey(group)
6625
6682
  )),
@@ -6675,11 +6732,12 @@ function TimelineGroupView({
6675
6732
  renderMessageText,
6676
6733
  onOpenSession,
6677
6734
  toolRegistry,
6678
- insideTurn = false
6735
+ insideTurn = false,
6736
+ foldLiveCluster = false
6679
6737
  }) {
6680
6738
  switch (group.kind) {
6681
6739
  case "activity":
6682
- return group.outcome ? /* @__PURE__ */ jsx15(
6740
+ return group.outcome || foldLiveCluster && clusterIsSettled(group) ? /* @__PURE__ */ jsx15(
6683
6741
  TurnSummary,
6684
6742
  {
6685
6743
  items: group.items,
@@ -6727,6 +6785,20 @@ function timelineGroupKey(group) {
6727
6785
  return group.id;
6728
6786
  }
6729
6787
  }
6788
+ function isAgentProgress(next) {
6789
+ if (!next) {
6790
+ return false;
6791
+ }
6792
+ return next.kind === "activity" || next.kind === "turn" || next.kind === "item" && next.item.kind === "agent-message";
6793
+ }
6794
+ function clusterIsSettled(group) {
6795
+ return group.items.every((item) => {
6796
+ if (item.kind === "reasoning") {
6797
+ return !item.streaming;
6798
+ }
6799
+ return item.status !== "running";
6800
+ });
6801
+ }
6730
6802
  function flattenActivityItems(groups) {
6731
6803
  const items = [];
6732
6804
  for (const group of groups) {
@@ -6833,7 +6905,17 @@ function NoticeRow({ item }) {
6833
6905
  const tone = item.tone === "failed" ? "border-og-status-failed/35 bg-og-status-failed/10 text-og-status-failed" : item.tone === "waiting" ? "border-og-status-waiting/35 bg-og-status-waiting/10 text-og-status-waiting" : "border-og-border bg-og-surface-1 text-og-fg-muted";
6834
6906
  return /* @__PURE__ */ jsxs12("div", { className: cn(enter && "animate-og-enter", "flex items-start gap-2.5 rounded-og-md border px-3.5 py-2.5 text-sm", tone), role: "status", children: [
6835
6907
  /* @__PURE__ */ jsx15(TriangleAlertIcon2, { className: cn("mt-0.5 size-4 shrink-0", item.tone === "cancelled" && "opacity-60") }),
6836
- /* @__PURE__ */ jsx15("span", { className: "min-w-0 whitespace-pre-wrap break-words", children: item.text })
6908
+ /* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1 whitespace-pre-wrap break-words", children: item.text }),
6909
+ item.action ? /* @__PURE__ */ jsx15(
6910
+ "a",
6911
+ {
6912
+ className: "shrink-0 rounded-og-sm border border-current/25 px-2 py-1 text-xs font-medium hover:bg-current/10",
6913
+ href: item.action.url,
6914
+ rel: "noreferrer",
6915
+ target: "_blank",
6916
+ children: item.action.label
6917
+ }
6918
+ ) : null
6837
6919
  ] });
6838
6920
  }
6839
6921
 
@@ -9310,6 +9392,7 @@ export {
9310
9392
  ActivityRail,
9311
9393
  BodyNote,
9312
9394
  CONNECTION_STATUS_META,
9395
+ CREDIT_EXHAUSTION_MESSAGE,
9313
9396
  ChatComposer,
9314
9397
  CodeEditor,
9315
9398
  CommandPalette,
@@ -9365,6 +9448,7 @@ export {
9365
9448
  controlCaret,
9366
9449
  createDefaultToolRegistry,
9367
9450
  createToolRegistry,
9451
+ creditExhaustedFromEvents,
9368
9452
  defaultCommands,
9369
9453
  defaultToolRegistry,
9370
9454
  execTruncated,
@@ -9379,6 +9463,7 @@ export {
9379
9463
  humanizeFailureReason,
9380
9464
  isApplyPatch,
9381
9465
  isCodexAccountEvent,
9466
+ isCreditExhaustion,
9382
9467
  isExecSessionLostBanner,
9383
9468
  isGoalEvent,
9384
9469
  isTitleEvent,