@mgamadeus/ddd-agents 0.12.0 → 0.14.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.
Files changed (65) hide show
  1. package/README.md +76 -0
  2. package/dist/admin.js +133 -6
  3. package/dist/admin.js.map +1 -1
  4. package/dist/chat.js +1303 -409
  5. package/dist/chat.js.map +1 -1
  6. package/dist/chunks/{agents-http-trace-mappers-LWNi-3a4.js → agents-http-trace-mappers-juBx_kw5.js} +64 -22
  7. package/dist/chunks/agents-http-trace-mappers-juBx_kw5.js.map +1 -0
  8. package/dist/chunks/{canvas-title-slot-context-BRGnFzYP.js → canvas-label-context-B54MYVLF.js} +16 -4
  9. package/dist/chunks/canvas-label-context-B54MYVLF.js.map +1 -0
  10. package/dist/chunks/{content-from-unified-diff-CovnmG2Q.js → content-from-unified-diff-lgH6CejC.js} +77 -46
  11. package/dist/chunks/content-from-unified-diff-lgH6CejC.js.map +1 -0
  12. package/dist/chunks/{contract-886XjdID.js → contract-CIXLnSqL.js} +2 -1
  13. package/dist/chunks/{contract-886XjdID.js.map → contract-CIXLnSqL.js.map} +1 -1
  14. package/dist/chunks/conversation-B7-evdj_.js.map +1 -1
  15. package/dist/chunks/conversation-trace-fVeh6Lg6.js +6 -0
  16. package/dist/chunks/conversation-trace-fVeh6Lg6.js.map +1 -0
  17. package/dist/chunks/index-DZovGMpG.js.map +1 -1
  18. package/dist/client.js +13 -8
  19. package/dist/client.js.map +1 -1
  20. package/dist/contract.js +3 -1
  21. package/dist/contract.js.map +1 -1
  22. package/dist/files/i18n-keys.json +671 -12
  23. package/dist/files/styles/_surfaces.scss +5 -0
  24. package/dist/renderer.js +10 -8
  25. package/dist/styles.css +920 -39
  26. package/dist/types/admin/connections/AgentConnectionsPanel.d.ts +9 -1
  27. package/dist/types/admin/connections/agent-connection-oauth.d.ts +17 -1
  28. package/dist/types/admin/skills/SkillLoadSourcesPanel.d.ts +20 -0
  29. package/dist/types/admin/skills/agent-skill-catalog-api.d.ts +14 -2
  30. package/dist/types/admin/skills/agent-skill-catalog-types.d.ts +36 -0
  31. package/dist/types/chat/CanvasResizeHandle/CanvasResizeHandle.d.ts +2 -0
  32. package/dist/types/chat/CanvasResizeHandle/use-canvas-resize.d.ts +4 -2
  33. package/dist/types/chat/ConversationMessage/ConversationCallMarkerChip/ConversationCallMarkerChip.d.ts +6 -1
  34. package/dist/types/chat/ConversationMessageList/ConversationMessageList.d.ts +8 -1
  35. package/dist/types/chat/ConversationMessageList/message-times.d.ts +55 -0
  36. package/dist/types/chat/ConversationView.d.ts +3 -0
  37. package/dist/types/chat/ConversationViewBody/ConversationViewBody.d.ts +3 -0
  38. package/dist/types/chat/canvas-layout.d.ts +13 -0
  39. package/dist/types/chat/controller/AgentChatController.d.ts +7 -0
  40. package/dist/types/chat/trace/TaskPlanDrawer.d.ts +45 -0
  41. package/dist/types/chat/trace/TaskPlanPane.d.ts +21 -12
  42. package/dist/types/chat/trace/ToolStepGroup.d.ts +2 -0
  43. package/dist/types/chat/trace/TraceViewModeSwitch.d.ts +10 -2
  44. package/dist/types/chat/trace/index.d.ts +4 -1
  45. package/dist/types/chat/trace/task-plan-tree.d.ts +55 -0
  46. package/dist/types/chat/trace/trace-collect.d.ts +15 -0
  47. package/dist/types/chat/trace/trace-types.d.ts +20 -0
  48. package/dist/types/chat/trace/trace-view-policy.d.ts +17 -0
  49. package/dist/types/client/http/agents-http-trace-mappers.d.ts +8 -1
  50. package/dist/types/client/http/agents-http-trace-wire.d.ts +27 -0
  51. package/dist/types/client/http/agents-http-wire.d.ts +4 -0
  52. package/dist/types/contract/conversation-trace.d.ts +63 -1
  53. package/dist/types/contract/conversation.d.ts +11 -0
  54. package/dist/types/entries/admin.d.ts +3 -2
  55. package/dist/types/entries/chat.d.ts +1 -0
  56. package/dist/types/entries/renderer.d.ts +1 -0
  57. package/dist/types/provider/components/types.d.ts +5 -0
  58. package/dist/types/provider/environment.d.ts +26 -0
  59. package/dist/types/provider/index.d.ts +1 -1
  60. package/dist/types/renderer/canvas/canvas-label-context.d.ts +10 -0
  61. package/package.json +1 -1
  62. package/public-api.json +51 -0
  63. package/dist/chunks/agents-http-trace-mappers-LWNi-3a4.js.map +0 -1
  64. package/dist/chunks/canvas-title-slot-context-BRGnFzYP.js.map +0 -1
  65. package/dist/chunks/content-from-unified-diff-CovnmG2Q.js.map +0 -1
package/README.md CHANGED
@@ -289,6 +289,48 @@ overflowing horizontally (`box-sizing: border-box`, the split clipped with `over
289
289
  thread at the top of the pane (`--agents-chat-top-padding: 24px` on its chat area); a host with a top bar floating over
290
290
  the thread sets that variable on `[data-agents-chat-scroll]` or through its own `chatAreaClassName`.
291
291
 
292
+ **A host that frames the canvas itself** (its own card, tabs and close control around the `SplitView` side pane) turns
293
+ the package's canvas chrome off with `AgentsEnvironment.canvasLayout` (`AgentsCanvasLayout`; every member optional, the
294
+ defaults are the package's chrome, so a host without the setting sees no change):
295
+
296
+ | Member | Default | Effect |
297
+ |---|---|---|
298
+ | `showsCloseButton` | `true` | the canvas pane's own "Close canvas" button; `false` leaves closing to the host (a tab's ×). A canvas with `titleBesideCloseButton` keeps its title row; without a title the row is gone |
299
+ | `showsDividerToggle` | `true` | the round canvas toggle on the divider (where the chat enables it) |
300
+ | `showsNarrowReopenControl` | `true` | the "Re-open canvas" control over a narrow chat |
301
+ | `chatColumnMinWidthPx` | `CHAT_COLUMN_MIN_WIDTH_PX` (360) | the narrowest chat beside the canvas: caps the default split (`min(<percent>%, calc(100% - <px>))`) and every pull of the resize handle |
302
+ | `boxedInsetPx` | `CANVAS_BOXED_INSET_PX` (8) | the inset of the boxed side-split canvas (`--agents-canvas-inset`, the handle sits on that edge) |
303
+ | `paneSurface` | `"card"` | `"none"`: the pane paints no surface, radius or padding of its own (the host's card does); its title row keeps a 12 px inset |
304
+
305
+ **The canvas's name for a host frame.** A canvas body reports a short name with `useCanvasLabel(label)` (from
306
+ `/renderer`; `null` while it loads; taken back on unmount); the chat hands it to the `SplitView` as `sideLabel` (only
307
+ while the canvas is open; the hook reports through `CanvasLabelContext`, which a host that mounts a canvas body outside
308
+ the chat may provide itself). A host tab shows the file's name instead of a generic label; the package's default
309
+ `SplitView` ignores it. ddd-clouddrive's file and folder canvases report the node's name.
310
+
311
+ Trap: the package's class names carry a build hash. Never hide or restyle package chrome through `[class*='agents_…']`
312
+ selectors; use `canvasLayout` (a renamed class silently brings the button back).
313
+
314
+ **Date and time in the message list (`messageTimes`).** `AgentChat` (through the controller props), `ConversationView`
315
+ and `ConversationMessageList` take `messageTimes` (`MessageTimesMode`): `null` (default, unchanged), `"turns"` or
316
+ `"everyMessage"`. Rules (pure `buildMessageTimeMarks()` in `message-times.ts`, one `MessageTimeMarks` per message:
317
+ `moment`, `daySeparator`, `timeHead`, `finishedAt`):
318
+ - a day separator (`role="separator"`) before the first row of each calendar day in the owner's zone, with the time
319
+ ("Today · 09:58") unless a voice call marker opens the day;
320
+ - a time head before a message that starts a turn (`isTurnInitiatorMessage`) more than 20 min
321
+ (`MESSAGE_TIME_PAUSE_MS`) after the message before it; the agent's steps and run time never cause one, the answer
322
+ stays with its question; a call marker after a pause is its own head;
323
+ - "finished HH:MM" under the last answer of a turn whose answer came more than 20 min after its start, never while the
324
+ newest turn runs; `everyMessage` adds a quiet `HH:MM` under each message;
325
+ - every timed row carries `<time dateTime>` with the exact moment (tooltip after 300 ms on hover devices, a tap line on
326
+ touch, always read by screen readers);
327
+ - a message without `createdAt` (optimistic, or a client that does not send it) gets no marks.
328
+ The moment is `AgentsConversationMessage.createdAt` (server date-time, UTC, from `ChangeHistory.createdTime`;
329
+ `createdDate` is the calendar date only). The package's HTTP client maps `changeHistory.createdTime`; a host client of
330
+ its own maps it too. Formats follow the owner settings (`dateLocale ?? locale`, `timeZone`): `createMessageTimeFormat()`
331
+ / `useMessageTimeFormat()` answer a `MessageTimeFormat` (`time`, `exact`, `day`, `dayKey`, `finished`). The day separator's text sits in one `span` (`daySeparatorLabel`, design role
332
+ `--agents-day-pill`). Text keys: `Yesterday` (`chat-day`), `finished %time%` (`chat-turn-end`), `Today`.
333
+
292
334
  ## The trace of a turn in the chat (`TurnTrace`)
293
335
 
294
336
  What the agent did between a message and its answer, as calm rows under the message that started the turn. `AgentChat`
@@ -306,6 +348,19 @@ const TurnTrace = (props: AgentChatTurnTraceProps) => (
306
348
 
307
349
  Pass one stable component (what changes comes through a context of the host), or every render mounts the traces anew.
308
350
 
351
+ - **Who may see which mode** comes from the server: the conversation read (`AgentsConversation.traceViewPolicy`) and
352
+ every trace read (`ConversationTurnTraces.traceViewPolicy`) carry the `ConversationTraceViewPolicy` of the app's
353
+ `AgentTraceViewPolicyService` (`maxDetailLevel`, `defaultDetailLevel`, `isSwitchShown`; levels RESULT < STEPS <
354
+ DEBUG ↔ `summary` / `normal` / `verbose`). Pass `TraceViewModeSwitch` `allowedViewModes =
355
+ resolveAllowedTraceViewModes(policy, isVerboseAllowed)`: one mode or none renders no switch; show
356
+ `clampTraceViewMode(choice, allowed)`. `isVerboseAllowed` is deprecated and only the fallback while a read carries no
357
+ policy. The server holds the lock (a read above the maximum is lowered, RESULT answers no steps); a host binding of
358
+ its own reads the field with `mapWireTraceViewPolicy` (`/client`). The pieces behind the two helpers, for a host that
359
+ builds its own switch: `traceViewModesOfPolicy(policy)` (the modes up to the maximum, Short first),
360
+ `defaultTraceViewModeOfPolicy(policy)` (the mode a reader starts in when they chose none: the policy's default level),
361
+ `TRACE_VIEW_MODE_OF_LEVEL` and `traceLevelOfViewMode(mode)` (the two directions of RESULT ↔ `summary`, STEPS ↔
362
+ `normal`, DEBUG ↔ `verbose`; `/chat`), and `CONVERSATION_TRACE_LEVELS` (`/contract`, the levels from the least to the
363
+ most).
309
364
  - **View modes** (`TraceViewMode`, switched with `TraceViewModeSwitch`; the host stores the choice). `summary`: one
310
365
  line "12 steps · 48 s" that opens the steps. `normal`: the steps folded, each with its narrated line; a row opens to
311
366
  its terminal, its file edits and its plain facts (tool, effect, state, time). `verbose` (only with `isDebugAllowed`,
@@ -596,3 +651,24 @@ so) and `foldEqualLines`.
596
651
  a host whose CTA colour is light in dark mode sets it dark there.
597
652
  - `--agents-fg-on-accent` is the text on an accent fill (white in light, dark in dark mode); `--agents-fg-on-dark` stays
598
653
  white for text over a dark scrim.
654
+ - `--agents-view-modes-track` is the rail of the view mode switch (`TraceViewModeSwitch`); unset it is a 6 % tint of
655
+ `--agents-fg`. A host whose neutral controls share one surface colour sets it to that colour.
656
+ - **Design roles** (all optional; unset, each keeps the look the package has without it, so a host sets only the ones
657
+ its design language needs):
658
+
659
+ | Role | What it colours | Unset |
660
+ |---|---|---|
661
+ | `--agents-steps-surface`, `--agents-steps-radius`, `--agents-steps-padding` | the steps of a turn in the thread (`TurnTrace`) as a card of their own | flat on the chat |
662
+ | `--agents-pill-active-bg`, `-fg`, `-shadow`, `-hover-bg` | the strong pill: the shown view mode (Kurz / Normal / Ausführlich) and the Stop button of a running turn | white raised pill; outlined Stop |
663
+ | `--agents-primary-action-bg`, `-fg`, `-hover-bg` | the primary action (`Button` variant `shimmer`: send, retry, submit) | the shimmer gradient |
664
+ | `--agents-composer-edge`, `--agents-composer-focus` | the composer's edge (`--ai-border-size` wide) and its edge while typing | `--ai-stroke-color` |
665
+ | `--agents-card-shadow` | the shadow of a card on the chat (widgets, markers, notices); popovers and tooltips keep theirs | the card shadow |
666
+ | `--agents-plan-done`, `-done-fg`, `--agents-plan-running`, `--agents-plan-you`, `-you-fg`, `-you-edge` | the task plan's marks, progress segments and the "waits for you" chip | `--agents-fg-cta`, the warning tint |
667
+ | `--agents-plan-section-running`, `--agents-plan-section-criterion`, `--agents-plan-detail-shadow` | the step drawer of the task plan: the "Running" and "Done when" sections, the drawer's shadow over the tree | the CTA tint, the neutral fill, the drawer shadow |
668
+ | `--agents-highlight`, `--agents-highlight-edge` | the row a plan item or a search hit jumps to (`data-trace-highlighted`) | an accent tint |
669
+ | `--agents-font-display`, `--agents-font-display-weight` | titles and big figures: the plan's title, a step's title, the widget text variants `hero`, `headline`, `title`, `gaugeValue` | the chat's face |
670
+ | `--agents-day-pill`, `-edge`, `-padding`, `-height`, `-gap`, `-mark`, `-mark-display` | the day separator's label as a pill with a small mark | bare text |
671
+ | `--agents-call-marker`, `-fg`, `-shadow`, `-height`, `-padding`, `-weight`, `-icon-bg`, `-icon-fg`, `-started-bg`, `-started-fg`, `-meta`, `-meta-weight` | the call marker in the thread ("voice call started · 10:12") | the raised surface pill with a state badge |
672
+
673
+ A host whose chat sits in a shadowed window sets `--agents-card-shadow` to a hairline (`0 0 0 1px …`): one shadowed
674
+ layer, the cards inside lift by their edge.
package/dist/admin.js CHANGED
@@ -12,8 +12,8 @@ import { normalizeDddError, parseDddDateTime } from "@mgamadeus/ddd-web/contract
12
12
  import { StatusCallout, PageHeader, EntityTabs, DefinitionList, EntityDetailShell, MoreActionsMenu, EntityListPage, StatusCalloutAction, PageToolbar } from "@mgamadeus/ddd-admin-ui/page";
13
13
  import { MarkdownPreview } from "@mgamadeus/ddd-admin-ui/markdown";
14
14
  import { NoteList, MetricGrid, MetricTile, DeltaText } from "@mgamadeus/ddd-admin-ui/data";
15
- import { o as mapWireTraceFileChange, q as mapWireTraceStep, t as mapWireTurnTrace, p as mapWireTraceMessage, s as mapWireTraceTaskPlanItems } from "./chunks/agents-http-trace-mappers-LWNi-3a4.js";
16
- import { a7 as describeTraceModelName, o as readTaskPlanCountsOfStep, w as readTaskPlanCounts, r as readTraceMoment, a5 as describeTraceDecisionSite, a9 as describeTraceSignal, B as readTraceStepState, a0 as createTraceFormat, al as describeTraceEffort, v as ToolStepGroup, t as TurnMetaLine, F as FileChangesSummary, L as LoadedSkillsDisclosure, aj as readTraceStateOfStatus, f as formatTraceClock, ai as readTraceRunResultText, R as TerminalBlock, ac as formatShortSha256, k as FileEditBlock, a8 as describeTraceMount, e as readTraceFileChangeLetter, af as readContentFromUnifiedDiff, am as readTraceFileName, V as ToolStepDetail, Z as TraceViewModeSwitch } from "./chunks/content-from-unified-diff-CovnmG2Q.js";
15
+ import { p as mapWireTraceFileChange, s as mapWireTraceStep, v as mapWireTurnTrace, q as mapWireTraceMessage, t as mapWireTraceTaskPlanItems } from "./chunks/agents-http-trace-mappers-juBx_kw5.js";
16
+ import { ab as describeTraceModelName, o as readTaskPlanCountsOfStep, w as readTaskPlanCounts, r as readTraceMoment, a9 as describeTraceDecisionSite, ad as describeTraceSignal, B as readTraceStepState, a3 as createTraceFormat, as as describeTraceEffort, v as ToolStepGroup, t as TurnMetaLine, F as FileChangesSummary, L as LoadedSkillsDisclosure, an as readTraceStateOfStatus, f as formatTraceClock, am as readTraceRunResultText, V as TerminalBlock, ag as formatShortSha256, k as FileEditBlock, ac as describeTraceMount, e as readTraceFileChangeLetter, aj as readContentFromUnifiedDiff, at as readTraceFileName, X as ToolStepDetail, $ as TraceViewModeSwitch } from "./chunks/content-from-unified-diff-lgH6CejC.js";
17
17
  import { FormDialog, FormErrors, FormFieldFrame, FormDrawer, FormActions } from "@mgamadeus/ddd-admin-ui/form";
18
18
  import { QuickFilterPills } from "@mgamadeus/ddd-admin-ui/glass";
19
19
  const CodeBlock = ({
@@ -1355,7 +1355,8 @@ const buildAgentSkillCatalogRequests = (apiPrefix) => {
1355
1355
  tool: ({ toolName }) => ({ url: `${prefix}/tools/${encodeURIComponent(toolName)}` }),
1356
1356
  sharedBlocks: () => ({ url: `${prefix}/sharedBlocks` }),
1357
1357
  purposes: (arg = {}) => ({ url: `${prefix}/purposes${toQueryString({ from: arg.from, to: arg.to })}` }),
1358
- skillLoadCounts: (arg = {}) => ({ url: `${prefix}/skillLoadCounts${toQueryString({ from: arg.from, to: arg.to })}` })
1358
+ skillLoadCounts: (arg = {}) => ({ url: `${prefix}/skillLoadCounts${toQueryString({ from: arg.from, to: arg.to })}` }),
1359
+ skillLoadSources: (arg = {}) => ({ url: `${prefix}/skillLoadSources${toQueryString({ from: arg.from, to: arg.to })}` })
1359
1360
  };
1360
1361
  };
1361
1362
  const CATALOG = { type: AGENT_SKILL_CATALOG_TAG, id: "CATALOG" };
@@ -1363,6 +1364,7 @@ const TOOL = { type: AGENT_SKILL_CATALOG_TAG, id: "TOOL" };
1363
1364
  const SHARED_BLOCKS = { type: AGENT_SKILL_CATALOG_TAG, id: "SHARED_BLOCKS" };
1364
1365
  const PURPOSES = { type: AGENT_SKILL_CATALOG_TAG, id: "PURPOSES" };
1365
1366
  const LOAD_COUNTS = { type: AGENT_SKILL_CATALOG_TAG, id: "LOAD_COUNTS" };
1367
+ const LOAD_SOURCES = { type: AGENT_SKILL_CATALOG_TAG, id: "LOAD_SOURCES" };
1366
1368
  const agentSkillCatalogEndpointDefinitions = (apiPrefix) => {
1367
1369
  const requests = buildAgentSkillCatalogRequests(apiPrefix);
1368
1370
  return {
@@ -1370,7 +1372,8 @@ const agentSkillCatalogEndpointDefinitions = (apiPrefix) => {
1370
1372
  adminUiAgentSkillToolDocumentation: { kind: "query", request: requests.tool, providesTags: [TOOL] },
1371
1373
  adminUiAgentSkillSharedBlocks: { kind: "query", request: requests.sharedBlocks, providesTags: [SHARED_BLOCKS] },
1372
1374
  adminUiAgentSkillPurposes: { kind: "query", request: requests.purposes, providesTags: [PURPOSES] },
1373
- adminUiAgentSkillLoadCounts: { kind: "query", request: requests.skillLoadCounts, providesTags: [LOAD_COUNTS] }
1375
+ adminUiAgentSkillLoadCounts: { kind: "query", request: requests.skillLoadCounts, providesTags: [LOAD_COUNTS] },
1376
+ adminUiAgentSkillLoadSources: { kind: "query", request: requests.skillLoadSources, providesTags: [LOAD_SOURCES] }
1374
1377
  };
1375
1378
  };
1376
1379
  const createAgentSkillCatalogApi = ({ baseApi, apiPrefix }) => injectEndpointsOnce(
@@ -1383,7 +1386,8 @@ const createAgentSkillCatalogApi = ({ baseApi, apiPrefix }) => injectEndpointsOn
1383
1386
  useSkillToolDocumentationQuery: hookOf("adminUiAgentSkillToolDocumentation"),
1384
1387
  useSkillSharedBlocksQuery: hookOf("adminUiAgentSkillSharedBlocks"),
1385
1388
  useSkillPurposesQuery: hookOf("adminUiAgentSkillPurposes"),
1386
- useSkillLoadCountsQuery: hookOf("adminUiAgentSkillLoadCounts")
1389
+ useSkillLoadCountsQuery: hookOf("adminUiAgentSkillLoadCounts"),
1390
+ useSkillLoadSourcesQuery: hookOf("adminUiAgentSkillLoadSources")
1387
1391
  })
1388
1392
  );
1389
1393
  const createStaticAgentSkillCatalogApi = (data) => ({
@@ -1391,7 +1395,8 @@ const createStaticAgentSkillCatalogApi = (data) => ({
1391
1395
  useSkillToolDocumentationQuery: staticQueryHook((arg) => data.tool?.(arg)),
1392
1396
  useSkillSharedBlocksQuery: staticQueryHook(() => data.sharedBlocks?.()),
1393
1397
  useSkillPurposesQuery: staticQueryHook((arg) => data.purposes?.(arg ?? {})),
1394
- useSkillLoadCountsQuery: staticQueryHook((arg) => data.skillLoadCounts?.(arg ?? {}))
1398
+ useSkillLoadCountsQuery: staticQueryHook((arg) => data.skillLoadCounts?.(arg ?? {})),
1399
+ useSkillLoadSourcesQuery: staticQueryHook((arg) => data.skillLoadSources?.(arg ?? {}))
1395
1400
  });
1396
1401
  const ADMIN_PERIOD_PRESETS = [
1397
1402
  { id: "7d", days: 7 },
@@ -1964,6 +1969,94 @@ const wireNumberOf = (value) => {
1964
1969
  return null;
1965
1970
  };
1966
1971
  const wireCreatedTimeOf = (row) => row?.changeHistory?.createdTime ?? row?.created ?? null;
1972
+ const SKILL_LOAD_SOURCES_COLLAPSED_ROW_COUNT = 12;
1973
+ const isSkillPreloadCandidate = (loadSource) => (loadSource.modelLoadCount ?? 0) > 0 && (loadSource.preloadCount ?? 0) + (loadSource.subPassPreloadCount ?? 0) === 0;
1974
+ const CountCell = ({ value }) => /* @__PURE__ */ jsx(TableCell, { className: cn("px-3 py-2 text-right align-top tabular-nums", value === 0 && "text-muted-foreground"), children: formatUiNumber(value) });
1975
+ const SkillLoadSourcesPanel = ({ api, period, className }) => {
1976
+ const { t } = useTranslate();
1977
+ const locale = getUiLocale();
1978
+ const [isShowingAll, setIsShowingAll] = useState(false);
1979
+ const query = api.useSkillLoadSourcesQuery({ from: period.from, to: period.to });
1980
+ const response = query.data ?? null;
1981
+ const loadSources = response?.loadSources ?? null;
1982
+ const rows = loadSources === null ? null : wireElementsOf(loadSources);
1983
+ if (query.isLoading || rows === null && query.isFetching) return /* @__PURE__ */ jsx(Skeleton, { className: cn("h-48 w-full rounded-2xl", className) });
1984
+ if (query.isError || rows === null || loadSources === null) {
1985
+ return /* @__PURE__ */ jsx(
1986
+ StatusCallout,
1987
+ {
1988
+ tone: "destructive",
1989
+ title: t("The skill load sources could not be loaded."),
1990
+ description: query.isError ? normalizeDddError(query.error, "").message : void 0,
1991
+ className
1992
+ }
1993
+ );
1994
+ }
1995
+ const percent = new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 });
1996
+ const usedTurnCount = loadSources.preloadUsedTurnCount ?? 0;
1997
+ const unusedTurnCount = loadSources.preloadUnusedTurnCount ?? 0;
1998
+ const usedShare = typeof loadSources.preloadUsedShare === "number" ? Math.min(1, Math.max(0, loadSources.preloadUsedShare)) : null;
1999
+ const shownRows = isShowingAll ? rows : rows.slice(0, SKILL_LOAD_SOURCES_COLLAPSED_ROW_COUNT);
2000
+ const notes = [
2001
+ ...response?.isLoadSourceDataAvailable === false ? [{ id: "sourcesUnavailable", tone: "warning", text: t("The turn events cannot be read on this database: no load sources.") }] : [],
2002
+ ...loadSources.isModelLoadCountAvailable === false ? [{ id: "modelLoadsUnavailable", tone: "warning", text: t("The loads of the chat model cannot be counted on this database: only the preloads are shown.") }] : [],
2003
+ ...loadSources.isTruncated === true ? [{ id: "sourcesTruncated", tone: "warning", text: t("The period holds more rows than one read counts: the newest were counted.") }] : []
2004
+ ];
2005
+ return /* @__PURE__ */ jsx(Card, { "data-slot": "skill-load-sources-panel", className: cn("gap-0 py-0 transition-opacity motion-reduce:transition-none", query.isFetching && "opacity-80", className), children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 px-2 py-4", children: [
2006
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4 px-3", children: [
2007
+ /* @__PURE__ */ jsxs("div", { className: "max-w-2xl", children: [
2008
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: t("Loads by source") }),
2009
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("How each skill came into the conversations: preloaded by the decision model (first pass, or the follow-up pass under a preloaded root) or loaded by the chat model itself with load_skills. A skill the model loads itself that no preload brought is a preload candidate.") })
2010
+ ] }),
2011
+ /* @__PURE__ */ jsxs("div", { "data-slot": "skill-preload-outcome", className: "w-60 shrink-0", children: [
2012
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("Preloads used") }),
2013
+ usedShare === null ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("no preloading turn") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2014
+ /* @__PURE__ */ jsxs("span", { className: "flex items-baseline justify-between gap-2 text-sm", children: [
2015
+ /* @__PURE__ */ jsx("span", { className: "font-semibold tabular-nums", children: percent.format(usedShare) }),
2016
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground tabular-nums", children: t("%used% used, %unused% unused", { replacements: { used: formatUiNumber(usedTurnCount), unused: formatUiNumber(unusedTurnCount) } }) })
2017
+ ] }),
2018
+ /* @__PURE__ */ jsx(
2019
+ "span",
2020
+ {
2021
+ role: "meter",
2022
+ "aria-label": t("Preloads used"),
2023
+ "aria-valuemin": 0,
2024
+ "aria-valuemax": 100,
2025
+ "aria-valuenow": Math.round(usedShare * 100),
2026
+ className: "mt-1 block h-1.5 overflow-hidden rounded-full bg-muted",
2027
+ children: /* @__PURE__ */ jsx("span", { className: "block h-full rounded-full bg-[color:var(--series-1,var(--brand))]", style: { width: `${usedShare * 100}%` } })
2028
+ }
2029
+ )
2030
+ ] })
2031
+ ] })
2032
+ ] }),
2033
+ notes.length > 0 && /* @__PURE__ */ jsx("div", { className: "px-3", children: /* @__PURE__ */ jsx(NoteList, { notes }) }),
2034
+ rows.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: t("No skill was loaded in this period.") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2035
+ /* @__PURE__ */ jsxs(Table, { children: [
2036
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
2037
+ /* @__PURE__ */ jsx(TableHead, { className: "px-3 text-xs text-muted-foreground", children: t("Skill", { context: "skill-catalog" }) }),
2038
+ /* @__PURE__ */ jsx(TableHead, { className: "px-3 text-right text-xs text-muted-foreground", children: t("Preload", { context: "skill-load-source" }) }),
2039
+ /* @__PURE__ */ jsx(TableHead, { className: "px-3 text-right text-xs text-muted-foreground", children: t("Follow-up pass", { context: "skill-load-source" }) }),
2040
+ /* @__PURE__ */ jsx(TableHead, { className: "px-3 text-right text-xs text-muted-foreground", children: /* @__PURE__ */ jsx("span", { className: "font-mono", children: "load_skills" }) }),
2041
+ /* @__PURE__ */ jsx(TableHead, { className: "px-3 text-right text-xs text-muted-foreground", children: t("Preload used", { context: "skill-load-source" }) }),
2042
+ /* @__PURE__ */ jsx(TableHead, { className: "px-3 text-right text-xs text-muted-foreground", children: t("Preload unused", { context: "skill-load-source" }) })
2043
+ ] }) }),
2044
+ /* @__PURE__ */ jsx(TableBody, { children: shownRows.map((loadSource) => /* @__PURE__ */ jsxs(TableRow, { "data-slot": "skill-load-source", "data-skill": loadSource.skillName, className: "hover:bg-transparent", children: [
2045
+ /* @__PURE__ */ jsx(TableCell, { className: "px-3 py-2 align-top whitespace-normal", children: /* @__PURE__ */ jsxs("span", { className: "flex flex-wrap items-center gap-2", children: [
2046
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-sm break-all", children: loadSource.skillName }),
2047
+ isSkillPreloadCandidate(loadSource) && /* @__PURE__ */ jsx(Badge, { variant: "warning", className: "text-[10px]", children: t("preload candidate") })
2048
+ ] }) }),
2049
+ /* @__PURE__ */ jsx(CountCell, { value: loadSource.preloadCount ?? 0 }),
2050
+ /* @__PURE__ */ jsx(CountCell, { value: loadSource.subPassPreloadCount ?? 0 }),
2051
+ /* @__PURE__ */ jsx(CountCell, { value: loadSource.modelLoadCount ?? 0 }),
2052
+ /* @__PURE__ */ jsx(CountCell, { value: loadSource.preloadUsedCount ?? 0 }),
2053
+ /* @__PURE__ */ jsx(CountCell, { value: loadSource.preloadUnusedCount ?? 0 })
2054
+ ] }, loadSource.skillName)) })
2055
+ ] }),
2056
+ rows.length > SKILL_LOAD_SOURCES_COLLAPSED_ROW_COUNT && /* @__PURE__ */ jsx("div", { className: "px-3", children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", "data-slot": "skill-load-sources-toggle", onClick: () => setIsShowingAll((value) => !value), children: isShowingAll ? t("Show fewer skills") : t("{count, plural, one {Show all # skill} other {Show all # skills}}", { count: rows.length }) }) })
2057
+ ] })
2058
+ ] }) });
2059
+ };
1967
2060
  const SkillNames = ({ names }) => /* @__PURE__ */ jsx("span", { className: "flex flex-wrap gap-1", children: names.map((name) => /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "font-mono text-[11px]", children: name }, name)) });
1968
2061
  const SkillPurposesPanel = ({ api, period, describeSkillPurpose, className }) => {
1969
2062
  const { t } = useTranslate();
@@ -2504,6 +2597,7 @@ const AgentSkillCatalogScreen = ({
2504
2597
  /* @__PURE__ */ jsx(NoteList, { notes: loadNotes })
2505
2598
  ] }),
2506
2599
  catalog.totals && /* @__PURE__ */ jsx(SkillCatalogTotalsCard, { totals: catalog.totals }),
2600
+ /* @__PURE__ */ jsx(SkillLoadSourcesPanel, { api, period }),
2507
2601
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2508
2602
  /* @__PURE__ */ jsx(
2509
2603
  SearchField,
@@ -10290,11 +10384,19 @@ const buildAgentConnectionDriveSearch = ({ connectionId, driveRootId }) => {
10290
10384
  return parameters.toString();
10291
10385
  };
10292
10386
  const readAgentConnectionDriveSelection = (parameters) => {
10387
+ if (parameters.get("reconnect") === "1") return null;
10293
10388
  const connection = parameters.get("connection");
10294
10389
  if (connection === null || !/^\d+$/.test(connection)) return null;
10295
10390
  const driveRoot = parameters.get("driveRoot");
10296
10391
  return { connectionId: Number(connection), driveRootId: driveRoot !== null && /^\d+$/.test(driveRoot) ? Number(driveRoot) : null };
10297
10392
  };
10393
+ const AGENT_CONNECTION_RECONNECT_LINK_PARAMETERS = ["connection", "reconnect"];
10394
+ const buildAgentConnectionReconnectSearch = ({ connectionId }) => new URLSearchParams({ connection: String(connectionId), reconnect: "1" }).toString();
10395
+ const readAgentConnectionReconnectRequest = (parameters) => {
10396
+ if (parameters.get("reconnect") !== "1") return null;
10397
+ const connection = parameters.get("connection");
10398
+ return connection !== null && /^\d+$/.test(connection) ? { connectionId: Number(connection) } : null;
10399
+ };
10298
10400
  const agentConnectionDriveRootDomId = (connectionId, driveRootId) => `connection-${connectionId}-drive-root-${driveRootId}`;
10299
10401
  const AGENT_CONNECTION_DRIVE_CONTEXT = "agent-connection-drive";
10300
10402
  const AGENT_CONNECTION_DRIVE_ROOT_STATUS = defineStatusMap(
@@ -12933,6 +13035,8 @@ const PanelContent = ({
12933
13035
  tableView = true,
12934
13036
  levelsRequest: hostLevelsRequest = null,
12935
13037
  onLevelsRequestHandled,
13038
+ reconnectRequest = null,
13039
+ onReconnectRequestHandled,
12936
13040
  driveRoots = true,
12937
13041
  selectedDrive: hostSelectedDrive,
12938
13042
  onSelectedDriveChange,
@@ -13038,6 +13142,23 @@ const PanelContent = ({
13038
13142
  notify.submitError(toFormSubmitError(error, t("Google could not be connected")));
13039
13143
  }
13040
13144
  };
13145
+ const startedReconnectOf = useRef(null);
13146
+ useEffect(() => {
13147
+ if (!isSuccess || reconnectRequest === null || startedReconnectOf.current === reconnectRequest.connectionId) return;
13148
+ startedReconnectOf.current = reconnectRequest.connectionId;
13149
+ onReconnectRequestHandled?.();
13150
+ const connection = connections.find((candidate) => candidate.connectionId === reconnectRequest.connectionId) ?? null;
13151
+ if (connection === null) {
13152
+ notify.error(t("This connection is not in your list."));
13153
+ return;
13154
+ }
13155
+ if (typeof document !== "undefined") document.querySelector(`[data-connection-id="${connection.connectionId}"]`)?.scrollIntoView?.({ block: "center", behavior: "smooth" });
13156
+ if (!writesAllowed || !canManageAgentConnection(connection, viewer) || connection.provider !== "GOOGLE" || !isOAuthAvailable) {
13157
+ notify.error(t("This connection cannot be reconnected here."));
13158
+ return;
13159
+ }
13160
+ void handleReconnect(connection);
13161
+ }, [isSuccess, reconnectRequest, connections, onReconnectRequestHandled, writesAllowed, viewer, isOAuthAvailable, t]);
13041
13162
  const handlersFor = (connection) => ({
13042
13163
  onChangeLevels: () => setLevelsId(connection.connectionId),
13043
13164
  onChangeSharing: () => setSharingId(connection.connectionId),
@@ -13342,6 +13463,7 @@ export {
13342
13463
  AGENT_CONNECTION_LEVEL_HELP,
13343
13464
  AGENT_CONNECTION_LEVEL_HELP_CONTEXT,
13344
13465
  AGENT_CONNECTION_LEVEL_LABEL,
13466
+ AGENT_CONNECTION_RECONNECT_LINK_PARAMETERS,
13345
13467
  AGENT_CONNECTION_STATUS,
13346
13468
  AGENT_CONNECTION_STATUS_GROUPS,
13347
13469
  AGENT_CONNECTION_STATUS_GROUP_LABEL,
@@ -13436,6 +13558,7 @@ export {
13436
13558
  ProportionBar,
13437
13559
  SERIES_FILL_CLASS_NAMES,
13438
13560
  SKILL_INSTRUCTIONS_FILL_CLASS_NAME,
13561
+ SKILL_LOAD_SOURCES_COLLAPSED_ROW_COUNT,
13439
13562
  SKILL_ROW_GRID_CLASS_NAME,
13440
13563
  SKILL_ROW_WITH_LOADS_GRID_CLASS_NAME,
13441
13564
  SKILL_TOOL_DEFINITIONS_FILL_CLASS_NAME,
@@ -13444,6 +13567,7 @@ export {
13444
13567
  SentPayloadPanel,
13445
13568
  SettingsTab,
13446
13569
  SharedBlocksPanel,
13570
+ SkillLoadSourcesPanel,
13447
13571
  SkillPurposesPanel,
13448
13572
  SkillTreeRowView,
13449
13573
  SlackLogo,
@@ -13510,6 +13634,7 @@ export {
13510
13634
  budgetMeterLevelOf,
13511
13635
  buildAgentConnectionDriveSearch,
13512
13636
  buildAgentConnectionLevelsSearch,
13637
+ buildAgentConnectionReconnectSearch,
13513
13638
  buildAgentConnectionsRequests,
13514
13639
  buildAgentContextCompositionEntries,
13515
13640
  buildAgentContextEntrySegmentViews,
@@ -13628,6 +13753,7 @@ export {
13628
13753
  isRuntimeSettingName,
13629
13754
  isRuntimeSettingSwitch,
13630
13755
  isRuntimeSettingText,
13756
+ isSkillPreloadCandidate,
13631
13757
  jsonChildCountOf,
13632
13758
  jsonChildEntriesOf,
13633
13759
  jsonValueKindOf,
@@ -13659,6 +13785,7 @@ export {
13659
13785
  readAgentConnectReturnParameters,
13660
13786
  readAgentConnectionDriveSelection,
13661
13787
  readAgentConnectionLevelsRequest,
13788
+ readAgentConnectionReconnectRequest,
13662
13789
  readAgentConversationListCost,
13663
13790
  readAgentConversationListIds,
13664
13791
  readAgentConversationListPage,