@agent-native/core 0.109.3 → 0.109.4
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +8 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +46 -13
- package/corpus/core/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
- package/corpus/core/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
- package/corpus/core/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
- package/corpus/core/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
- package/corpus/core/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
- package/corpus/core/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
- package/corpus/core/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
- package/corpus/core/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/toolkit-capability-packages.mdx +52 -0
- package/corpus/core/docs/content/toolkit-context-knowledge.mdx +46 -0
- package/corpus/core/docs/content/toolkit-editors-canvases.mdx +55 -0
- package/corpus/core/package.json +35 -34
- package/corpus/core/src/cli/create.ts +39 -3
- package/corpus/core/src/cli/package-lifecycle.ts +2 -0
- package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +2 -0
- package/corpus/core/src/client/context-xray/ContextMeter.tsx +31 -111
- package/corpus/core/src/client/context-xray/ContextSegmentRow.tsx +8 -111
- package/corpus/core/src/client/context-xray/ContextTreemap.tsx +6 -111
- package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +31 -391
- package/corpus/core/src/client/context-xray/SegmentProvenancePopover.tsx +4 -52
- package/corpus/core/src/client/context-xray/format.ts +0 -33
- package/corpus/core/src/client/rich-markdown-editor/index.ts +42 -57
- package/corpus/core/src/client/rich-markdown-editor/uploadEditorImage.ts +2 -1
- package/corpus/core/src/client/visual-style-controls.tsx +1 -1088
- package/corpus/core/src/collab/agent-identity.ts +5 -22
- package/corpus/core/src/collab/client.ts +1 -53
- package/corpus/core/src/styles/rich-markdown-editor.css +1 -510
- package/corpus/core/src/testing.ts +1 -1
- package/corpus/core/src/vite/client.ts +3 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +5 -3
- package/corpus/templates/content/app/components/editor/extensions/DragHandle.tsx +4 -4
- package/corpus/templates/content/package.json +25 -25
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +2 -1
- package/corpus/templates/design/package.json +1 -1
- package/corpus/templates/mail/package.json +9 -9
- package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +2 -0
- package/corpus/templates/plan/app/components/editor/PlanDocumentEditor.tsx +8 -8
- package/corpus/templates/plan/app/components/editor/planSlashCommands.ts +6 -6
- package/corpus/templates/plan/app/components/plan/PlanImageNode.tsx +4 -7
- package/corpus/templates/plan/app/components/plan/PlanMarkdownEditor.tsx +6 -4
- package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +1 -1
- package/corpus/templates/plan/changelog/2026-07-18-visual-plans-now-open-on-wireframes-by-default-when-a-protot.md +6 -0
- package/corpus/templates/plan/package.json +3 -3
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +2 -2
- package/corpus/templates/slides/app/components/editor/TweaksPanel.tsx +2 -2
- package/corpus/templates/slides/package.json +13 -13
- package/dist/catalog.json +39 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +32 -3
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/package-lifecycle.d.ts.map +1 -1
- package/dist/cli/package-lifecycle.js +2 -0
- package/dist/cli/package-lifecycle.js.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.js +2 -0
- package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
- package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
- package/dist/client/context-xray/ContextMeter.js +8 -23
- package/dist/client/context-xray/ContextMeter.js.map +1 -1
- package/dist/client/context-xray/ContextSegmentRow.d.ts.map +1 -1
- package/dist/client/context-xray/ContextSegmentRow.js +3 -19
- package/dist/client/context-xray/ContextSegmentRow.js.map +1 -1
- package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
- package/dist/client/context-xray/ContextTreemap.js +3 -54
- package/dist/client/context-xray/ContextTreemap.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +21 -163
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/context-xray/SegmentProvenancePopover.d.ts.map +1 -1
- package/dist/client/context-xray/SegmentProvenancePopover.js +3 -4
- package/dist/client/context-xray/SegmentProvenancePopover.js.map +1 -1
- package/dist/client/context-xray/format.d.ts +0 -4
- package/dist/client/context-xray/format.d.ts.map +1 -1
- package/dist/client/context-xray/format.js +0 -49
- package/dist/client/context-xray/format.js.map +1 -1
- package/dist/client/rich-markdown-editor/index.d.ts +1 -12
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/index.js +1 -12
- package/dist/client/rich-markdown-editor/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +1 -1
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -1
- package/dist/client/visual-style-controls.d.ts +1 -89
- package/dist/client/visual-style-controls.d.ts.map +1 -1
- package/dist/client/visual-style-controls.js +1 -498
- package/dist/client/visual-style-controls.js.map +1 -1
- package/dist/collab/agent-identity.d.ts +1 -14
- package/dist/collab/agent-identity.d.ts.map +1 -1
- package/dist/collab/agent-identity.js +1 -13
- package/dist/collab/agent-identity.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/client.d.ts +1 -19
- package/dist/collab/client.d.ts.map +1 -1
- package/dist/collab/client.js +1 -53
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/styles/rich-markdown-editor.css +1 -510
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +3 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +46 -13
- package/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
- package/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
- package/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
- package/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
- package/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
- package/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
- package/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
- package/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/toolkit-capability-packages.mdx +52 -0
- package/docs/content/toolkit-context-knowledge.mdx +46 -0
- package/docs/content/toolkit-editors-canvases.mdx +55 -0
- package/package.json +27 -26
- package/corpus/core/src/client/rich-markdown-editor/BubbleToolbar.tsx +0 -253
- package/corpus/core/src/client/rich-markdown-editor/CodeBlockNode.tsx +0 -258
- package/corpus/core/src/client/rich-markdown-editor/DragHandle.ts +0 -1437
- package/corpus/core/src/client/rich-markdown-editor/ImageExtension.ts +0 -306
- package/corpus/core/src/client/rich-markdown-editor/RichMarkdownEditor.tsx +0 -80
- package/corpus/core/src/client/rich-markdown-editor/RunId.ts +0 -61
- package/corpus/core/src/client/rich-markdown-editor/SharedRichEditor.tsx +0 -321
- package/corpus/core/src/client/rich-markdown-editor/SlashCommandMenu.tsx +0 -310
- package/corpus/core/src/client/rich-markdown-editor/extensions.ts +0 -402
- package/corpus/core/src/client/rich-markdown-editor/gfmDoc.ts +0 -92
- package/corpus/core/src/client/rich-markdown-editor/surgical-apply.ts +0 -192
- package/corpus/core/src/client/rich-markdown-editor/useCollabReconcile.ts +0 -590
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +0 -37
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.js +0 -171
- package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +0 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts +0 -49
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.js +0 -127
- package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +0 -1
- package/dist/client/rich-markdown-editor/DragHandle.d.ts +0 -97
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/DragHandle.js +0 -1066
- package/dist/client/rich-markdown-editor/DragHandle.js.map +0 -1
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts +0 -63
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/ImageExtension.js +0 -243
- package/dist/client/rich-markdown-editor/ImageExtension.js.map +0 -1
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +0 -51
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +0 -37
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +0 -1
- package/dist/client/rich-markdown-editor/RunId.d.ts +0 -28
- package/dist/client/rich-markdown-editor/RunId.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/RunId.js +0 -60
- package/dist/client/rich-markdown-editor/RunId.js.map +0 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +0 -110
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +0 -144
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +0 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +0 -41
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js +0 -221
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +0 -1
- package/dist/client/rich-markdown-editor/extensions.d.ts +0 -178
- package/dist/client/rich-markdown-editor/extensions.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/extensions.js +0 -224
- package/dist/client/rich-markdown-editor/extensions.js.map +0 -1
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts +0 -24
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/gfmDoc.js +0 -83
- package/dist/client/rich-markdown-editor/gfmDoc.js.map +0 -1
- package/dist/client/rich-markdown-editor/surgical-apply.d.ts +0 -66
- package/dist/client/rich-markdown-editor/surgical-apply.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/surgical-apply.js +0 -147
- package/dist/client/rich-markdown-editor/surgical-apply.js.map +0 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +0 -110
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +0 -441
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +0 -1
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ContextMeterView } from "@agent-native/toolkit/context-ui";
|
|
2
3
|
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
3
4
|
import { manifestConversationTokens, manifestSystemTokens, } from "../../shared/context-xray.js";
|
|
4
|
-
import { Popover, PopoverContent, PopoverTrigger, } from "../components/ui/popover.js";
|
|
5
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../components/ui/tooltip.js";
|
|
6
5
|
import { useActionMutation, useActionQuery } from "../use-action.js";
|
|
7
|
-
import {
|
|
8
|
-
import { formatTokens, resolveContextWindow } from "./format.js";
|
|
6
|
+
import { resolveContextWindow } from "./format.js";
|
|
9
7
|
const ContextXRayPanel = lazy(() => import("./ContextXRayPanel.js").then((m) => ({
|
|
10
8
|
default: m.ContextXRayPanel,
|
|
11
9
|
})));
|
|
12
|
-
function ContextDonut({ pct, advisory }) {
|
|
13
|
-
const radius = 7.5;
|
|
14
|
-
const circumference = 2 * Math.PI * radius;
|
|
15
|
-
const displayPct = Math.max(3, Math.min(100, pct));
|
|
16
|
-
const dashOffset = circumference - (displayPct / 100) * circumference;
|
|
17
|
-
return (_jsxs("span", { className: "relative flex size-5 items-center justify-center", children: [_jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 20 20", className: "-rotate-90 size-5", children: [_jsx("circle", { cx: "10", cy: "10", r: radius, className: "stroke-muted", fill: "none", strokeWidth: "3" }), _jsx("circle", { cx: "10", cy: "10", r: radius, className: cn(advisory ? "stroke-amber-500" : "stroke-[#00B5FF]"), fill: "none", strokeLinecap: "round", strokeWidth: "3", strokeDasharray: circumference, strokeDashoffset: dashOffset })] }), _jsx("span", { className: "absolute size-2 rounded-full bg-background" })] }));
|
|
18
|
-
}
|
|
19
10
|
export function ContextMeter({ threadId, manifest: providedManifest, enabled = true, }) {
|
|
20
11
|
const [open, setOpen] = useState(false);
|
|
21
12
|
const [optimistic, setOptimistic] = useState(new Map());
|
|
@@ -43,14 +34,6 @@ export function ContextMeter({ threadId, manifest: providedManifest, enabled = t
|
|
|
43
34
|
}
|
|
44
35
|
}, [enabled, threadId]);
|
|
45
36
|
const manifest = providedManifest ?? query.data;
|
|
46
|
-
const contextWindow = resolveContextWindow(manifest?.model);
|
|
47
|
-
const pct = manifest
|
|
48
|
-
? Math.min(100, Math.round((manifest.totalTokens / contextWindow) * 100))
|
|
49
|
-
: 0;
|
|
50
|
-
const systemTokens = manifest ? manifestSystemTokens(manifest) : 0;
|
|
51
|
-
const conversationTokens = manifest
|
|
52
|
-
? manifestConversationTokens(manifest)
|
|
53
|
-
: 0;
|
|
54
37
|
if ((!shouldQuery && !providedManifest) ||
|
|
55
38
|
!manifest ||
|
|
56
39
|
(manifest.rawTokens <= 0 && manifest.totalTokens <= 0)) {
|
|
@@ -74,8 +57,10 @@ export function ContextMeter({ threadId, manifest: providedManifest, enabled = t
|
|
|
74
57
|
if (action === "restore")
|
|
75
58
|
restore.mutate(params, options);
|
|
76
59
|
};
|
|
77
|
-
return (_jsx(
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
return (_jsx(ContextMeterView, { manifest: {
|
|
61
|
+
...manifest,
|
|
62
|
+
systemTokens: manifestSystemTokens(manifest),
|
|
63
|
+
conversationTokens: manifestConversationTokens(manifest),
|
|
64
|
+
}, contextWindow: resolveContextWindow(manifest.model), open: open, onOpenChange: setOpen, children: open ? (_jsx(Suspense, { fallback: _jsx("div", { className: "flex h-52 items-center justify-center text-xs text-muted-foreground", children: "Loading context view\u2026" }), children: _jsx(ContextXRayPanel, { manifest: manifest, optimistic: optimistic, onPin: (segmentId) => mutateStatus(segmentId, "pinned", "pin"), onEvict: (segmentId) => mutateStatus(segmentId, "evicted", "evict"), onRestore: (segmentId) => mutateStatus(segmentId, "active", "restore") }) })) : null }));
|
|
80
65
|
}
|
|
81
66
|
//# sourceMappingURL=ContextMeter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMeter.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextMeter.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMpE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CACjC,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,EAA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AAgB;oCAC9F,CAAC,CAAC,EAAE,IACS,IACT,EACV,KAAC,cAAc,IACb,KAAK,EAAC,KAAK,EACX,IAAI,EAAC,KAAK,EACV,UAAU,EAAE,CAAC,EACb,SAAS,EAAC,0DAA0D,YAEnE,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,QAAQ,IACP,QAAQ,EACN,cAAK,SAAS,EAAC,qEAAqE,2CAE9E,YAGR,KAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,EAC9D,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CACrB,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAE7C,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CACvB,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,GAE9C,GACO,CACZ,CAAC,CAAC,CAAC,IAAI,GACO,IACT,GACM,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { lazy, Suspense, useEffect, useRef, useState } from \"react\";\n\nimport type {\n ContextManifest,\n ContextSegmentStatus,\n} from \"../../shared/context-xray.js\";\nimport {\n manifestConversationTokens,\n manifestSystemTokens,\n} from \"../../shared/context-xray.js\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../components/ui/popover.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { useActionMutation, useActionQuery } from \"../use-action.js\";\nimport { cn } from \"../utils.js\";\nimport { formatTokens, resolveContextWindow } from \"./format.js\";\n\nconst ContextXRayPanel = lazy(() =>\n import(\"./ContextXRayPanel.js\").then((m) => ({\n default: m.ContextXRayPanel,\n })),\n);\n\nfunction ContextDonut({ pct, advisory }: { pct: number; advisory: boolean }) {\n const radius = 7.5;\n const circumference = 2 * Math.PI * radius;\n const displayPct = Math.max(3, Math.min(100, pct));\n const dashOffset = circumference - (displayPct / 100) * circumference;\n\n return (\n <span className=\"relative flex size-5 items-center justify-center\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" className=\"-rotate-90 size-5\">\n <circle\n cx=\"10\"\n cy=\"10\"\n r={radius}\n className=\"stroke-muted\"\n fill=\"none\"\n strokeWidth=\"3\"\n />\n <circle\n cx=\"10\"\n cy=\"10\"\n r={radius}\n className={cn(advisory ? \"stroke-amber-500\" : \"stroke-[#00B5FF]\")}\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth=\"3\"\n strokeDasharray={circumference}\n strokeDashoffset={dashOffset}\n />\n </svg>\n <span className=\"absolute size-2 rounded-full bg-background\" />\n </span>\n );\n}\n\nexport function ContextMeter({\n threadId,\n manifest: providedManifest,\n enabled = true,\n}: {\n threadId?: string | null;\n manifest?: ContextManifest | null;\n enabled?: boolean;\n}) {\n const [open, setOpen] = useState(false);\n const [optimistic, setOptimistic] = useState<\n Map<string, ContextSegmentStatus>\n >(new Map());\n const currentThreadId = useRef(threadId);\n const shouldQuery = Boolean(threadId && enabled && !providedManifest);\n const query = useActionQuery(\n \"context-manifest-get\",\n shouldQuery && threadId ? { threadId } : undefined,\n {\n enabled: shouldQuery,\n staleTime: 1000,\n },\n ) as { data?: ContextManifest };\n const pin = useActionMutation(\"context-pin\");\n const evict = useActionMutation(\"context-evict\");\n const restore = useActionMutation(\"context-restore\");\n\n useEffect(() => {\n currentThreadId.current = threadId;\n setOptimistic(new Map());\n }, [threadId]);\n\n useEffect(() => {\n if (!threadId || !enabled || typeof window === \"undefined\") return;\n const params = new URLSearchParams(window.location.search);\n const wantsXray = params.get(\"contextXray\") === \"1\";\n const targetThread = params.get(\"threadId\");\n if (wantsXray && (!targetThread || targetThread === threadId)) {\n setOpen(true);\n }\n }, [enabled, threadId]);\n\n const manifest = providedManifest ?? query.data;\n const contextWindow = resolveContextWindow(manifest?.model);\n const pct = manifest\n ? Math.min(100, Math.round((manifest.totalTokens / contextWindow) * 100))\n : 0;\n const systemTokens = manifest ? manifestSystemTokens(manifest) : 0;\n const conversationTokens = manifest\n ? manifestConversationTokens(manifest)\n : 0;\n\n if (\n (!shouldQuery && !providedManifest) ||\n !manifest ||\n (manifest.rawTokens <= 0 && manifest.totalTokens <= 0)\n ) {\n return null;\n }\n\n const mutateStatus = (\n segmentId: string,\n status: ContextSegmentStatus,\n action: \"pin\" | \"evict\" | \"restore\",\n ) => {\n const previous = new Map(optimistic);\n setOptimistic((prev) => new Map(prev).set(segmentId, status));\n const params = { threadId, segmentId };\n const options = {\n onError: () => {\n if (currentThreadId.current === threadId) {\n setOptimistic(previous);\n }\n },\n };\n if (action === \"pin\") pin.mutate(params, options);\n if (action === \"evict\") evict.mutate(params, options);\n if (action === \"restore\") restore.mutate(params, options);\n };\n\n return (\n <TooltipProvider delayDuration={200}>\n <Popover open={open} onOpenChange={setOpen}>\n <Tooltip>\n <TooltipTrigger asChild>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-label={`Context ${pct}%, ${formatTokens(\n manifest.totalTokens,\n )}${systemTokens > 0 ? ` total: ${formatTokens(systemTokens)} system + ${formatTokens(conversationTokens)} conversation` : \"\"}. Open Context X-Ray.`}\n className={cn(\n \"flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n open && \"bg-accent/60 text-foreground\",\n )}\n >\n <ContextDonut pct={pct} advisory={!manifest.enforceable} />\n </button>\n </PopoverTrigger>\n </TooltipTrigger>\n <TooltipContent>\n Context {pct}% · {formatTokens(manifest.totalTokens)}\n {systemTokens > 0\n ? ` (${formatTokens(systemTokens)} system + ${formatTokens(conversationTokens)} conversation)`\n : \"\"}\n </TooltipContent>\n </Tooltip>\n <PopoverContent\n align=\"end\"\n side=\"top\"\n sideOffset={8}\n className=\"w-[min(92vw,380px)] overflow-hidden border-border/70 p-0\"\n >\n {open ? (\n <Suspense\n fallback={\n <div className=\"flex h-52 items-center justify-center text-xs text-muted-foreground\">\n Loading context view…\n </div>\n }\n >\n <ContextXRayPanel\n manifest={manifest}\n optimistic={optimistic}\n onPin={(segmentId) => mutateStatus(segmentId, \"pinned\", \"pin\")}\n onEvict={(segmentId) =>\n mutateStatus(segmentId, \"evicted\", \"evict\")\n }\n onRestore={(segmentId) =>\n mutateStatus(segmentId, \"active\", \"restore\")\n }\n />\n </Suspense>\n ) : null}\n </PopoverContent>\n </Popover>\n </TooltipProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContextMeter.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextMeter.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMpE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CACjC,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,gBAAgB;CAC5B,CAAC,CAAC,CACJ,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAG,IAAI,GAKf;IACC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAA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E,oBAAoB,CAAC,QAAQ,CAAC;YAC5C,kBAAkB,EAAE,0BAA0B,CAAC,QAAQ,CAAC;SACzD,EACD,aAAa,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,EACnD,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,OAAO,YAEpB,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,QAAQ,IACP,QAAQ,EACN,cAAK,SAAS,EAAC,qEAAqE,2CAE9E,YAGR,KAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,EAC9D,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EACnE,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CACvB,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,GAE9C,GACO,CACZ,CAAC,CAAC,CAAC,IAAI,GACS,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { ContextMeterView } from \"@agent-native/toolkit/context-ui\";\nimport { lazy, Suspense, useEffect, useRef, useState } from \"react\";\n\nimport type {\n ContextManifest,\n ContextSegmentStatus,\n} from \"../../shared/context-xray.js\";\nimport {\n manifestConversationTokens,\n manifestSystemTokens,\n} from \"../../shared/context-xray.js\";\nimport { useActionMutation, useActionQuery } from \"../use-action.js\";\nimport { resolveContextWindow } from \"./format.js\";\n\nconst ContextXRayPanel = lazy(() =>\n import(\"./ContextXRayPanel.js\").then((m) => ({\n default: m.ContextXRayPanel,\n })),\n);\n\nexport function ContextMeter({\n threadId,\n manifest: providedManifest,\n enabled = true,\n}: {\n threadId?: string | null;\n manifest?: ContextManifest | null;\n enabled?: boolean;\n}) {\n const [open, setOpen] = useState(false);\n const [optimistic, setOptimistic] = useState<\n Map<string, ContextSegmentStatus>\n >(new Map());\n const currentThreadId = useRef(threadId);\n const shouldQuery = Boolean(threadId && enabled && !providedManifest);\n const query = useActionQuery(\n \"context-manifest-get\",\n shouldQuery && threadId ? { threadId } : undefined,\n {\n enabled: shouldQuery,\n staleTime: 1000,\n },\n ) as { data?: ContextManifest };\n const pin = useActionMutation(\"context-pin\");\n const evict = useActionMutation(\"context-evict\");\n const restore = useActionMutation(\"context-restore\");\n\n useEffect(() => {\n currentThreadId.current = threadId;\n setOptimistic(new Map());\n }, [threadId]);\n\n useEffect(() => {\n if (!threadId || !enabled || typeof window === \"undefined\") return;\n const params = new URLSearchParams(window.location.search);\n const wantsXray = params.get(\"contextXray\") === \"1\";\n const targetThread = params.get(\"threadId\");\n if (wantsXray && (!targetThread || targetThread === threadId)) {\n setOpen(true);\n }\n }, [enabled, threadId]);\n\n const manifest = providedManifest ?? query.data;\n if (\n (!shouldQuery && !providedManifest) ||\n !manifest ||\n (manifest.rawTokens <= 0 && manifest.totalTokens <= 0)\n ) {\n return null;\n }\n\n const mutateStatus = (\n segmentId: string,\n status: ContextSegmentStatus,\n action: \"pin\" | \"evict\" | \"restore\",\n ) => {\n const previous = new Map(optimistic);\n setOptimistic((prev) => new Map(prev).set(segmentId, status));\n const params = { threadId, segmentId };\n const options = {\n onError: () => {\n if (currentThreadId.current === threadId) {\n setOptimistic(previous);\n }\n },\n };\n if (action === \"pin\") pin.mutate(params, options);\n if (action === \"evict\") evict.mutate(params, options);\n if (action === \"restore\") restore.mutate(params, options);\n };\n\n return (\n <ContextMeterView\n manifest={{\n ...manifest,\n systemTokens: manifestSystemTokens(manifest),\n conversationTokens: manifestConversationTokens(manifest),\n }}\n contextWindow={resolveContextWindow(manifest.model)}\n open={open}\n onOpenChange={setOpen}\n >\n {open ? (\n <Suspense\n fallback={\n <div className=\"flex h-52 items-center justify-center text-xs text-muted-foreground\">\n Loading context view…\n </div>\n }\n >\n <ContextXRayPanel\n manifest={manifest}\n optimistic={optimistic}\n onPin={(segmentId) => mutateStatus(segmentId, \"pinned\", \"pin\")}\n onEvict={(segmentId) => mutateStatus(segmentId, \"evicted\", \"evict\")}\n onRestore={(segmentId) =>\n mutateStatus(segmentId, \"active\", \"restore\")\n }\n />\n </Suspense>\n ) : null}\n </ContextMeterView>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextSegmentRow.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextSegmentRow.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextSegmentRow.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextSegmentRow.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,sBAAsB,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,+BAUA"}
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Tooltip, TooltipContent, TooltipTrigger, } from "../components/ui/tooltip.js";
|
|
4
|
-
import { cn } from "../utils.js";
|
|
5
|
-
import { formatTokens, statusLabel } from "./format.js";
|
|
6
|
-
import { SegmentProvenancePopover } from "./SegmentProvenancePopover.js";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ContextSegmentRowView } from "@agent-native/toolkit/context-ui";
|
|
7
3
|
export function ContextSegmentRow({ segment, advisory, onPin, onEvict, onRestore, }) {
|
|
8
|
-
|
|
9
|
-
return (_jsxs("div", { tabIndex: 0, onKeyDown: (event) => {
|
|
10
|
-
if (event.key === "p")
|
|
11
|
-
onPin();
|
|
12
|
-
if (event.key === "e" && !disabled)
|
|
13
|
-
onEvict();
|
|
14
|
-
if (event.key === "u" && segment.status !== "active")
|
|
15
|
-
onRestore();
|
|
16
|
-
}, className: cn("group flex min-h-11 items-center gap-2 rounded-sm px-2 py-1.5 outline-none transition-colors hover:bg-accent/35 focus-visible:bg-accent/35 focus-visible:ring-1 focus-visible:ring-ring", segment.status === "evicted" && "opacity-60"), children: [_jsx(SegmentProvenancePopover, { segment: segment, children: _jsxs("button", { type: "button", className: "min-w-0 flex-1 text-left", "aria-label": `Inspect ${segment.label}`, children: [_jsx("div", { className: cn("truncate text-[13px] font-medium leading-5 text-foreground", segment.status === "evicted" && "line-through"), children: segment.label }), _jsxs("div", { className: "flex items-center gap-1.5 text-[11px] text-muted-foreground", children: [_jsx("span", { children: formatTokens(segment.tokenCount) }), segment.tokenMethod === "estimate" && _jsx("span", { children: "~" }), _jsx("span", { children: "\u00B7" }), _jsx("span", { children: statusLabel(segment) }), advisory && _jsx("span", { children: "\u00B7 advisory" })] })] }) }), _jsx("div", { className: "flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100", children: segment.protected ? (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("span", { className: "flex size-6 items-center justify-center rounded-md text-muted-foreground", children: _jsx(IconLock, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: "Protected during active turn" })] })) : segment.status === "evicted" ||
|
|
17
|
-
segment.status === "summarized" ||
|
|
18
|
-
segment.status === "pinned" ? (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: onRestore, className: "flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground", "aria-label": segment.status === "pinned"
|
|
19
|
-
? "Unpin segment"
|
|
20
|
-
: "Restore segment", children: _jsx(IconRotate2, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: segment.status === "pinned" ? "Unpin" : "Restore" })] })) : (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: onPin, className: "flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground", "aria-label": "Pin segment", children: _jsx(IconPin, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: "Pin" })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: onEvict, className: "flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-destructive", "aria-label": "Evict segment", children: _jsx(IconX, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: advisory ? "Record eviction intent" : "Evict" })] })] })) })] }));
|
|
4
|
+
return (_jsx(ContextSegmentRowView, { segment: segment, advisory: advisory, onPin: onPin, onEvict: onEvict, onRestore: onRestore }));
|
|
21
5
|
}
|
|
22
6
|
//# sourceMappingURL=ContextSegmentRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextSegmentRow.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextSegmentRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ContextSegmentRow.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextSegmentRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAIzE,MAAM,UAAU,iBAAiB,CAAC,EAChC,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,EACP,SAAS,GAOV;IACC,OAAO,CACL,KAAC,qBAAqB,IACpB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { ContextSegmentRowView } from \"@agent-native/toolkit/context-ui\";\n\nimport type { ContextManifestSegment } from \"../../shared/context-xray.js\";\n\nexport function ContextSegmentRow({\n segment,\n advisory,\n onPin,\n onEvict,\n onRestore,\n}: {\n segment: ContextManifestSegment;\n advisory: boolean;\n onPin: () => void;\n onEvict: () => void;\n onRestore: () => void;\n}) {\n return (\n <ContextSegmentRowView\n segment={segment}\n advisory={advisory}\n onPin={onPin}\n onEvict={onEvict}\n onRestore={onRestore}\n />\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextTreemap.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextTreemap.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextTreemap.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextTreemap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AAEtC,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,cAAmB,EACnB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,cAAc,CAAC,EAAE,4BAA4B,EAAE,CAAC;IAChD,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,+BAQA"}
|
|
@@ -1,57 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { Treemap } from "recharts";
|
|
4
|
-
import { formatTokens, groupFill } from "./format.js";
|
|
5
|
-
function TreemapContent(props) {
|
|
6
|
-
const { x, y, width, height, name, group, size } = props;
|
|
7
|
-
if (width < 8 || height < 8)
|
|
8
|
-
return null;
|
|
9
|
-
const showLabel = width > 90 && height > 42;
|
|
10
|
-
return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y, width: width, height: height, rx: 3, ry: 3, fill: groupFill(group), stroke: "var(--background)", strokeWidth: 2 }), showLabel && (_jsx("foreignObject", { x: x + 6, y: y + 6, width: width - 12, height: height - 12, children: _jsxs("div", { className: "flex h-full flex-col justify-between overflow-hidden text-[11px] leading-tight text-white", children: [_jsx("div", { className: "truncate font-medium", children: name }), _jsx("div", { className: "text-white/85", children: formatTokens(size) })] }) }))] }));
|
|
11
|
-
}
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ContextTreemapView } from "@agent-native/toolkit/context-ui";
|
|
12
3
|
export function ContextTreemap({ segments, systemSections = [], onSelect, }) {
|
|
13
|
-
|
|
14
|
-
const [chartWidth, setChartWidth] = useState(0);
|
|
15
|
-
const data = segments
|
|
16
|
-
.filter((segment) => segment.status !== "evicted" && segment.tokenCount > 0)
|
|
17
|
-
.map((segment) => ({
|
|
18
|
-
name: segment.label,
|
|
19
|
-
size: segment.tokenCount,
|
|
20
|
-
group: segment.group,
|
|
21
|
-
segmentId: segment.segmentId,
|
|
22
|
-
}));
|
|
23
|
-
data.push(...systemSections
|
|
24
|
-
.filter((section) => section.tokenCount > 0)
|
|
25
|
-
.map((section) => ({
|
|
26
|
-
name: section.label,
|
|
27
|
-
size: section.tokenCount,
|
|
28
|
-
group: `System · ${section.governance}`,
|
|
29
|
-
segmentId: section.segmentId,
|
|
30
|
-
})));
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const element = containerRef.current;
|
|
33
|
-
if (!element)
|
|
34
|
-
return;
|
|
35
|
-
const updateWidth = () => {
|
|
36
|
-
setChartWidth(Math.max(0, Math.floor(element.clientWidth - 8)));
|
|
37
|
-
};
|
|
38
|
-
updateWidth();
|
|
39
|
-
const observer = typeof ResizeObserver !== "undefined"
|
|
40
|
-
? new ResizeObserver(updateWidth)
|
|
41
|
-
: null;
|
|
42
|
-
observer?.observe(element);
|
|
43
|
-
window.addEventListener("resize", updateWidth);
|
|
44
|
-
return () => {
|
|
45
|
-
observer?.disconnect();
|
|
46
|
-
window.removeEventListener("resize", updateWidth);
|
|
47
|
-
};
|
|
48
|
-
}, []);
|
|
49
|
-
if (data.length === 0) {
|
|
50
|
-
return (_jsx("div", { className: "flex h-52 items-center justify-center rounded-md bg-muted/30 text-xs text-muted-foreground", children: "No active segments" }));
|
|
51
|
-
}
|
|
52
|
-
return (_jsx("div", { ref: containerRef, className: "h-56 min-w-0 rounded-md bg-muted/25 p-1", children: chartWidth > 0 && (_jsx(Treemap, { width: chartWidth, height: 216, data: data, dataKey: "size", nameKey: "name", aspectRatio: 4 / 3, isAnimationActive: false, content: _jsx(TreemapContent, {}), onClick: (datum) => {
|
|
53
|
-
if (datum?.segmentId)
|
|
54
|
-
onSelect?.(datum.segmentId);
|
|
55
|
-
} })) }));
|
|
4
|
+
return (_jsx(ContextTreemapView, { segments: segments, systemSections: systemSections, onSelect: onSelect }));
|
|
56
5
|
}
|
|
57
6
|
//# sourceMappingURL=ContextTreemap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextTreemap.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextTreemap.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ContextTreemap.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextTreemap.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAOtE,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,cAAc,GAAG,EAAE,EACnB,QAAQ,GAKT;IACC,OAAO,CACL,KAAC,kBAAkB,IACjB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { ContextTreemapView } from \"@agent-native/toolkit/context-ui\";\n\nimport type {\n ContextManifestSegment,\n ContextManifestSystemSection,\n} from \"../../shared/context-xray.js\";\n\nexport function ContextTreemap({\n segments,\n systemSections = [],\n onSelect,\n}: {\n segments: ContextManifestSegment[];\n systemSections?: ContextManifestSystemSection[];\n onSelect?: (segmentId: string) => void;\n}) {\n return (\n <ContextTreemapView\n segments={segments}\n systemSections={systemSections}\n onSelect={onSelect}\n />\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextXRayPanel.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextXRayPanel.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAQtC,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC9C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,+BAiCA"}
|
|
@@ -1,170 +1,28 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ContextXRayPanelView } from "@agent-native/toolkit/context-ui";
|
|
4
3
|
import { manifestConversationTokens, manifestSystemTokens, } from "../../shared/context-xray.js";
|
|
5
|
-
import { Tooltip, TooltipContent, TooltipTrigger, } from "../components/ui/tooltip.js";
|
|
6
4
|
import { useT } from "../i18n.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const map = new Map();
|
|
21
|
-
for (const segment of segments) {
|
|
22
|
-
const groupName = segment.status === "pinned"
|
|
23
|
-
? "Pinned"
|
|
24
|
-
: segment.status === "evicted"
|
|
25
|
-
? "Evicted"
|
|
26
|
-
: segment.group;
|
|
27
|
-
const group = map.get(groupName) ?? {
|
|
28
|
-
name: groupName,
|
|
29
|
-
tokens: 0,
|
|
30
|
-
segments: [],
|
|
31
|
-
};
|
|
32
|
-
group.tokens += segment.tokenCount;
|
|
33
|
-
group.segments.push(segment);
|
|
34
|
-
map.set(groupName, group);
|
|
35
|
-
}
|
|
36
|
-
const order = [
|
|
37
|
-
"Pinned",
|
|
38
|
-
"Tool results",
|
|
39
|
-
"Files read",
|
|
40
|
-
"Conversation",
|
|
41
|
-
"Thinking",
|
|
42
|
-
"Evicted",
|
|
43
|
-
];
|
|
44
|
-
return [...map.values()].sort((a, b) => {
|
|
45
|
-
const ai = order.indexOf(a.name);
|
|
46
|
-
const bi = order.indexOf(b.name);
|
|
47
|
-
if (ai >= 0 || bi >= 0)
|
|
48
|
-
return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);
|
|
49
|
-
return b.tokens - a.tokens;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const GOVERNANCE_ORDER = ["required", "inherited", "user"];
|
|
53
|
-
function governanceLabel(governance, t) {
|
|
54
|
-
switch (governance) {
|
|
55
|
-
case "required":
|
|
56
|
-
return t("contextXray.governance.required", {
|
|
5
|
+
import { resolveContextWindow } from "./format.js";
|
|
6
|
+
export function ContextXRayPanel({ manifest, optimistic, onPin, onEvict, onRestore, }) {
|
|
7
|
+
const t = useT();
|
|
8
|
+
return (_jsx(ContextXRayPanelView, { manifest: {
|
|
9
|
+
...manifest,
|
|
10
|
+
systemTokens: manifestSystemTokens(manifest),
|
|
11
|
+
conversationTokens: manifestConversationTokens(manifest),
|
|
12
|
+
}, contextWindow: resolveContextWindow(manifest.model), optimistic: optimistic, onPin: onPin, onEvict: onEvict, onRestore: onRestore, titleLabel: t("contextXray.pageTitle", {
|
|
13
|
+
defaultValue: "Context X-Ray",
|
|
14
|
+
}), systemOrderedLabel: t("contextXray.systemOrdered", {
|
|
15
|
+
defaultValue: "System · ordered, not evictable",
|
|
16
|
+
}), governanceLabels: {
|
|
17
|
+
required: t("contextXray.governance.required", {
|
|
57
18
|
defaultValue: "Required",
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
return t("contextXray.governance.inherited", {
|
|
19
|
+
}),
|
|
20
|
+
inherited: t("contextXray.governance.inherited", {
|
|
61
21
|
defaultValue: "Inherited",
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
return t("contextXray.governance.user", {
|
|
22
|
+
}),
|
|
23
|
+
user: t("contextXray.governance.user", {
|
|
65
24
|
defaultValue: "Your context",
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
function sourceLabel(section) {
|
|
70
|
-
return (section.sourceRef?.path ??
|
|
71
|
-
section.sourceRef?.resourceId ??
|
|
72
|
-
section.sourceRef?.scope ??
|
|
73
|
-
"framework");
|
|
74
|
-
}
|
|
75
|
-
function SystemSectionRow({ section, totalTokens, }) {
|
|
76
|
-
const share = totalTokens > 0 ? Math.round((section.tokenCount / totalTokens) * 100) : 0;
|
|
77
|
-
return (_jsxs("div", { className: "flex min-h-12 items-start gap-2 rounded-sm px-2 py-1.5", children: [_jsx("span", { className: "mt-1 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground", children: _jsx(IconLock, { className: "h-3.5 w-3.5" }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "truncate text-[13px] font-medium leading-5 text-foreground", children: section.label }), _jsxs("div", { className: "truncate text-[11px] text-muted-foreground", children: [sourceLabel(section), " \u00B7 ", formatTokens(section.tokenCount), " tokens \u00B7", " ", share, "%", section.tokenMethod === "estimate" ? " · estimated" : ""] }), section.preview ? (_jsx("div", { className: "mt-0.5 line-clamp-2 text-[11px] text-muted-foreground/80", children: section.preview })) : null] })] }));
|
|
78
|
-
}
|
|
79
|
-
export function ContextXRayPanel({ manifest, optimistic, onPin, onEvict, onRestore, }) {
|
|
80
|
-
const t = useT();
|
|
81
|
-
const [mode, setMode] = useState("list");
|
|
82
|
-
const [collapsed, setCollapsed] = useState(new Set());
|
|
83
|
-
const segments = useMemo(() => applyOptimisticStatus(manifest.segments, optimistic), [manifest.segments, optimistic]);
|
|
84
|
-
const groups = useMemo(() => groupedSegments(segments), [segments]);
|
|
85
|
-
const systemSections = manifest.systemSections ?? [];
|
|
86
|
-
const systemGroups = useMemo(() => {
|
|
87
|
-
const grouped = new Map();
|
|
88
|
-
for (const section of systemSections) {
|
|
89
|
-
const list = grouped.get(section.governance) ?? [];
|
|
90
|
-
list.push(section);
|
|
91
|
-
grouped.set(section.governance, list);
|
|
92
|
-
}
|
|
93
|
-
return GOVERNANCE_ORDER.flatMap((governance) => {
|
|
94
|
-
const sections = grouped.get(governance);
|
|
95
|
-
return sections && sections.length > 0
|
|
96
|
-
? [
|
|
97
|
-
{
|
|
98
|
-
governance,
|
|
99
|
-
sections,
|
|
100
|
-
tokens: sections.reduce((sum, section) => sum + section.tokenCount, 0),
|
|
101
|
-
},
|
|
102
|
-
]
|
|
103
|
-
: [];
|
|
104
|
-
});
|
|
105
|
-
}, [systemSections]);
|
|
106
|
-
const contextWindow = resolveContextWindow(manifest.model);
|
|
107
|
-
const pct = Math.min(100, Math.round((manifest.totalTokens / contextWindow) * 100));
|
|
108
|
-
const headroom = Math.max(0, contextWindow - manifest.totalTokens);
|
|
109
|
-
const pinned = segments.filter((s) => s.status === "pinned").length;
|
|
110
|
-
const evicted = segments.filter((s) => s.status === "evicted").length;
|
|
111
|
-
const systemTokens = manifestSystemTokens(manifest);
|
|
112
|
-
const conversationTokens = manifestConversationTokens(manifest);
|
|
113
|
-
const details = [
|
|
114
|
-
`${formatTokens(headroom)} free`,
|
|
115
|
-
systemTokens > 0 ? `${formatTokens(systemTokens)} system` : null,
|
|
116
|
-
`${formatTokens(conversationTokens)} conversation`,
|
|
117
|
-
pinned > 0 ? `${pinned} pinned` : null,
|
|
118
|
-
evicted > 0 ? `${evicted} evicted` : null,
|
|
119
|
-
manifest.tokenCountMethod === "estimate" ? "estimated" : null,
|
|
120
|
-
!manifest.enforceable ? "advisory" : null,
|
|
121
|
-
].filter((item) => Boolean(item));
|
|
122
|
-
return (_jsxs("div", { className: "flex max-h-[min(72vh,520px)] flex-col", children: [_jsxs("div", { className: "border-b border-border/60 px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("h2", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: "Context X-Ray" }), _jsxs("div", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: [formatTokens(manifest.totalTokens), " \u00B7 ", pct, "%"] })] }), _jsx("div", { className: "mt-2 h-1 overflow-hidden rounded-full bg-muted/70", children: _jsx("div", { className: "h-full rounded-full bg-foreground origin-left transition-transform duration-200", style: {
|
|
123
|
-
transform: `scaleX(${Math.min(1, pct / 100)})`,
|
|
124
|
-
width: "100%",
|
|
125
|
-
} }) }), _jsxs("div", { className: "mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground", children: [details.map((detail) => (_jsx("span", { children: detail }, detail))), manifest.reclaimedTokens > 0 && (_jsxs("span", { className: "font-medium text-emerald-600 dark:text-emerald-400", children: ["-", formatTokens(manifest.reclaimedTokens)] }))] })] }), _jsxs("div", { className: "overflow-y-auto px-2 py-2", children: [_jsx("div", { className: "mb-1 flex items-center justify-end", children: _jsxs("div", { className: "inline-flex rounded-md bg-muted/40 p-0.5", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => setMode("list"), "aria-label": "Show context list", className: cn("flex size-7 cursor-pointer items-center justify-center rounded text-muted-foreground", mode === "list"
|
|
126
|
-
? "bg-background text-foreground shadow-sm"
|
|
127
|
-
: "hover:text-foreground"), children: _jsx(IconListDetails, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: "List" })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => setMode("map"), "aria-label": "Show context map", className: cn("flex size-7 cursor-pointer items-center justify-center rounded text-muted-foreground", mode === "map"
|
|
128
|
-
? "bg-background text-foreground shadow-sm"
|
|
129
|
-
: "hover:text-foreground"), children: _jsx(IconChartTreemap, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: "Map" })] })] }) }), mode === "map" ? (_jsx(ContextTreemap, { segments: segments, systemSections: systemSections, onSelect: (segmentId) => {
|
|
130
|
-
const segment = segments.find((s) => s.segmentId === segmentId);
|
|
131
|
-
if (segment)
|
|
132
|
-
setCollapsed(new Set());
|
|
133
|
-
} })) : (_jsxs("div", { className: "divide-y divide-border/60", children: [systemGroups.length > 0 && (_jsxs("div", { children: [_jsx("div", { className: "px-1.5 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground", children: t("contextXray.systemOrdered", {
|
|
134
|
-
defaultValue: "System · ordered, not evictable",
|
|
135
|
-
}) }), systemGroups.map((group) => {
|
|
136
|
-
const groupKey = `system:${group.governance}`;
|
|
137
|
-
const isCollapsed = collapsed.has(groupKey);
|
|
138
|
-
return (_jsxs("div", { children: [_jsxs("button", { type: "button", onClick: () => {
|
|
139
|
-
setCollapsed((prev) => {
|
|
140
|
-
const next = new Set(prev);
|
|
141
|
-
if (next.has(groupKey))
|
|
142
|
-
next.delete(groupKey);
|
|
143
|
-
else
|
|
144
|
-
next.add(groupKey);
|
|
145
|
-
return next;
|
|
146
|
-
});
|
|
147
|
-
}, className: "flex w-full cursor-pointer items-center gap-2 rounded-sm px-1.5 py-2 text-left hover:bg-accent/35", children: [isCollapsed ? (_jsx(IconChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" })) : (_jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" })), _jsx(IconLock, { className: "h-3 w-3 text-muted-foreground" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-xs font-medium", children: governanceLabel(group.governance, t) }), _jsxs("span", { className: "text-[11px] text-muted-foreground", children: [formatTokens(group.tokens), " \u00B7", " ", manifest.totalTokens > 0
|
|
148
|
-
? Math.round((group.tokens / manifest.totalTokens) * 100)
|
|
149
|
-
: 0, "%"] })] }), !isCollapsed && (_jsx("div", { className: "pb-1", children: group.sections
|
|
150
|
-
.slice()
|
|
151
|
-
.sort((a, b) => b.tokenCount - a.tokenCount)
|
|
152
|
-
.map((section) => (_jsx(SystemSectionRow, { section: section, totalTokens: manifest.totalTokens }, section.segmentId))) }))] }, groupKey));
|
|
153
|
-
})] })), groups.map((group) => {
|
|
154
|
-
const isCollapsed = collapsed.has(group.name);
|
|
155
|
-
return (_jsxs("div", { children: [_jsxs("button", { type: "button", onClick: () => {
|
|
156
|
-
setCollapsed((prev) => {
|
|
157
|
-
const next = new Set(prev);
|
|
158
|
-
if (next.has(group.name))
|
|
159
|
-
next.delete(group.name);
|
|
160
|
-
else
|
|
161
|
-
next.add(group.name);
|
|
162
|
-
return next;
|
|
163
|
-
});
|
|
164
|
-
}, className: "flex w-full cursor-pointer items-center gap-2 rounded-sm px-1.5 py-2 text-left hover:bg-accent/35", children: [isCollapsed ? (_jsx(IconChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" })) : (_jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" })), _jsx("span", { className: cn("h-2 w-2 rounded-full", groupColor(group.name)) }), _jsx("span", { className: "min-w-0 flex-1 truncate text-xs font-medium", children: group.name }), _jsx("span", { className: "text-[11px] text-muted-foreground", children: formatTokens(group.tokens) })] }), !isCollapsed && (_jsx("div", { className: "pb-1", children: group.segments
|
|
165
|
-
.slice()
|
|
166
|
-
.sort((a, b) => b.tokenCount - a.tokenCount)
|
|
167
|
-
.map((segment) => (_jsx(ContextSegmentRow, { segment: segment, advisory: !manifest.enforceable, onPin: () => onPin(segment.segmentId), onEvict: () => onEvict(segment.segmentId), onRestore: () => onRestore(segment.segmentId) }, segment.segmentId))) }))] }, group.name));
|
|
168
|
-
})] }))] })] }));
|
|
25
|
+
}),
|
|
26
|
+
} }));
|
|
169
27
|
}
|
|
170
28
|
//# sourceMappingURL=ContextXRayPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextXRayPanel.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQ1C,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQ7E,SAAS,qBAAqB,CAC5B,QAAkC,EAClC,UAA6C;IAE7C,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,QAAQ,C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AC,iBAAiB,IAEhB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,QAAQ,CAAC,WAAW,EAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EACrC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EACzC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IALxC,OAAO,CAAC,SAAS,CAMtB,CACH,CAAC,GACA,CACP,KA/CO,KAAK,CAAC,IAAI,CAgDd,CACP,CAAC;4BACJ,CAAC,CAAC,IACE,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconChartTreemap,\n IconChevronDown,\n IconChevronRight,\n IconLock,\n IconListDetails,\n} from \"@tabler/icons-react\";\nimport { useMemo, useState } from \"react\";\n\nimport type {\n ContextManifest,\n ContextManifestSegment,\n ContextManifestSystemSection,\n ContextSegmentStatus,\n} from \"../../shared/context-xray.js\";\nimport {\n manifestConversationTokens,\n manifestSystemTokens,\n} from \"../../shared/context-xray.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { useT } from \"../i18n.js\";\nimport { cn } from \"../utils.js\";\nimport { ContextSegmentRow } from \"./ContextSegmentRow.js\";\nimport { ContextTreemap } from \"./ContextTreemap.js\";\nimport { formatTokens, groupColor, resolveContextWindow } from \"./format.js\";\n\ninterface Group {\n name: string;\n tokens: number;\n segments: ContextManifestSegment[];\n}\n\nfunction applyOptimisticStatus(\n segments: ContextManifestSegment[],\n optimistic: Map<string, ContextSegmentStatus>,\n): ContextManifestSegment[] {\n if (optimistic.size === 0) return segments;\n return segments.map((segment) => {\n const status = optimistic.get(segment.segmentId);\n return status ? { ...segment, status } : segment;\n });\n}\n\nfunction groupedSegments(segments: ContextManifestSegment[]): Group[] {\n const map = new Map<string, Group>();\n for (const segment of segments) {\n const groupName =\n segment.status === \"pinned\"\n ? \"Pinned\"\n : segment.status === \"evicted\"\n ? \"Evicted\"\n : segment.group;\n const group = map.get(groupName) ?? {\n name: groupName,\n tokens: 0,\n segments: [],\n };\n group.tokens += segment.tokenCount;\n group.segments.push(segment);\n map.set(groupName, group);\n }\n const order = [\n \"Pinned\",\n \"Tool results\",\n \"Files read\",\n \"Conversation\",\n \"Thinking\",\n \"Evicted\",\n ];\n return [...map.values()].sort((a, b) => {\n const ai = order.indexOf(a.name);\n const bi = order.indexOf(b.name);\n if (ai >= 0 || bi >= 0) return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);\n return b.tokens - a.tokens;\n });\n}\n\nconst GOVERNANCE_ORDER = [\"required\", \"inherited\", \"user\"] as const;\n\nfunction governanceLabel(\n governance: ContextManifestSystemSection[\"governance\"],\n t: (key: string, options?: Record<string, unknown>) => string,\n): string {\n switch (governance) {\n case \"required\":\n return t(\"contextXray.governance.required\", {\n defaultValue: \"Required\",\n });\n case \"inherited\":\n return t(\"contextXray.governance.inherited\", {\n defaultValue: \"Inherited\",\n });\n case \"user\":\n return t(\"contextXray.governance.user\", {\n defaultValue: \"Your context\",\n });\n }\n}\n\nfunction sourceLabel(section: ContextManifestSystemSection): string {\n return (\n section.sourceRef?.path ??\n section.sourceRef?.resourceId ??\n section.sourceRef?.scope ??\n \"framework\"\n );\n}\n\nfunction SystemSectionRow({\n section,\n totalTokens,\n}: {\n section: ContextManifestSystemSection;\n totalTokens: number;\n}) {\n const share =\n totalTokens > 0 ? Math.round((section.tokenCount / totalTokens) * 100) : 0;\n return (\n <div className=\"flex min-h-12 items-start gap-2 rounded-sm px-2 py-1.5\">\n <span className=\"mt-1 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground\">\n <IconLock className=\"h-3.5 w-3.5\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-[13px] font-medium leading-5 text-foreground\">\n {section.label}\n </div>\n <div className=\"truncate text-[11px] text-muted-foreground\">\n {sourceLabel(section)} · {formatTokens(section.tokenCount)} tokens ·{\" \"}\n {share}%{section.tokenMethod === \"estimate\" ? \" · estimated\" : \"\"}\n </div>\n {section.preview ? (\n <div className=\"mt-0.5 line-clamp-2 text-[11px] text-muted-foreground/80\">\n {section.preview}\n </div>\n ) : null}\n </div>\n </div>\n );\n}\n\nexport function ContextXRayPanel({\n manifest,\n optimistic,\n onPin,\n onEvict,\n onRestore,\n}: {\n manifest: ContextManifest;\n optimistic: Map<string, ContextSegmentStatus>;\n onPin: (segmentId: string) => void;\n onEvict: (segmentId: string) => void;\n onRestore: (segmentId: string) => void;\n}) {\n const t = useT();\n const [mode, setMode] = useState<\"list\" | \"map\">(\"list\");\n const [collapsed, setCollapsed] = useState<Set<string>>(new Set());\n const segments = useMemo(\n () => applyOptimisticStatus(manifest.segments, optimistic),\n [manifest.segments, optimistic],\n );\n const groups = useMemo(() => groupedSegments(segments), [segments]);\n const systemSections = manifest.systemSections ?? [];\n const systemGroups = useMemo(() => {\n const grouped = new Map<\n ContextManifestSystemSection[\"governance\"],\n ContextManifestSystemSection[]\n >();\n for (const section of systemSections) {\n const list = grouped.get(section.governance) ?? [];\n list.push(section);\n grouped.set(section.governance, list);\n }\n return GOVERNANCE_ORDER.flatMap((governance) => {\n const sections = grouped.get(governance);\n return sections && sections.length > 0\n ? [\n {\n governance,\n sections,\n tokens: sections.reduce(\n (sum, section) => sum + section.tokenCount,\n 0,\n ),\n },\n ]\n : [];\n });\n }, [systemSections]);\n const contextWindow = resolveContextWindow(manifest.model);\n const pct = Math.min(\n 100,\n Math.round((manifest.totalTokens / contextWindow) * 100),\n );\n const headroom = Math.max(0, contextWindow - manifest.totalTokens);\n const pinned = segments.filter((s) => s.status === \"pinned\").length;\n const evicted = segments.filter((s) => s.status === \"evicted\").length;\n const systemTokens = manifestSystemTokens(manifest);\n const conversationTokens = manifestConversationTokens(manifest);\n const details = [\n `${formatTokens(headroom)} free`,\n systemTokens > 0 ? `${formatTokens(systemTokens)} system` : null,\n `${formatTokens(conversationTokens)} conversation`,\n pinned > 0 ? `${pinned} pinned` : null,\n evicted > 0 ? `${evicted} evicted` : null,\n manifest.tokenCountMethod === \"estimate\" ? \"estimated\" : null,\n !manifest.enforceable ? \"advisory\" : null,\n ].filter((item): item is string => Boolean(item));\n\n return (\n <div className=\"flex max-h-[min(72vh,520px)] flex-col\">\n <div className=\"border-b border-border/60 px-3 py-2.5\">\n <div className=\"flex items-center justify-between gap-3\">\n <h2 className=\"min-w-0 truncate text-sm font-medium text-foreground\">\n Context X-Ray\n </h2>\n <div className=\"shrink-0 text-xs tabular-nums text-muted-foreground\">\n {formatTokens(manifest.totalTokens)} · {pct}%\n </div>\n </div>\n <div className=\"mt-2 h-1 overflow-hidden rounded-full bg-muted/70\">\n <div\n className=\"h-full rounded-full bg-foreground origin-left transition-transform duration-200\"\n style={{\n transform: `scaleX(${Math.min(1, pct / 100)})`,\n width: \"100%\",\n }}\n />\n </div>\n <div className=\"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground\">\n {details.map((detail) => (\n <span key={detail}>{detail}</span>\n ))}\n {manifest.reclaimedTokens > 0 && (\n <span className=\"font-medium text-emerald-600 dark:text-emerald-400\">\n -{formatTokens(manifest.reclaimedTokens)}\n </span>\n )}\n </div>\n </div>\n\n <div className=\"overflow-y-auto px-2 py-2\">\n <div className=\"mb-1 flex items-center justify-end\">\n <div className=\"inline-flex rounded-md bg-muted/40 p-0.5\">\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n aria-label=\"Show context list\"\n className={cn(\n \"flex size-7 cursor-pointer items-center justify-center rounded text-muted-foreground\",\n mode === \"list\"\n ? \"bg-background text-foreground shadow-sm\"\n : \"hover:text-foreground\",\n )}\n >\n <IconListDetails className=\"h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>List</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setMode(\"map\")}\n aria-label=\"Show context map\"\n className={cn(\n \"flex size-7 cursor-pointer items-center justify-center rounded text-muted-foreground\",\n mode === \"map\"\n ? \"bg-background text-foreground shadow-sm\"\n : \"hover:text-foreground\",\n )}\n >\n <IconChartTreemap className=\"h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>Map</TooltipContent>\n </Tooltip>\n </div>\n </div>\n\n {mode === \"map\" ? (\n <ContextTreemap\n segments={segments}\n systemSections={systemSections}\n onSelect={(segmentId) => {\n const segment = segments.find((s) => s.segmentId === segmentId);\n if (segment) setCollapsed(new Set());\n }}\n />\n ) : (\n <div className=\"divide-y divide-border/60\">\n {systemGroups.length > 0 && (\n <div>\n <div className=\"px-1.5 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground\">\n {t(\"contextXray.systemOrdered\", {\n defaultValue: \"System · ordered, not evictable\",\n })}\n </div>\n {systemGroups.map((group) => {\n const groupKey = `system:${group.governance}`;\n const isCollapsed = collapsed.has(groupKey);\n return (\n <div key={groupKey}>\n <button\n type=\"button\"\n onClick={() => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(groupKey)) next.delete(groupKey);\n else next.add(groupKey);\n return next;\n });\n }}\n className=\"flex w-full cursor-pointer items-center gap-2 rounded-sm px-1.5 py-2 text-left hover:bg-accent/35\"\n >\n {isCollapsed ? (\n <IconChevronRight className=\"h-3.5 w-3.5 text-muted-foreground\" />\n ) : (\n <IconChevronDown className=\"h-3.5 w-3.5 text-muted-foreground\" />\n )}\n <IconLock className=\"h-3 w-3 text-muted-foreground\" />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium\">\n {governanceLabel(group.governance, t)}\n </span>\n <span className=\"text-[11px] text-muted-foreground\">\n {formatTokens(group.tokens)} ·{\" \"}\n {manifest.totalTokens > 0\n ? Math.round(\n (group.tokens / manifest.totalTokens) * 100,\n )\n : 0}\n %\n </span>\n </button>\n {!isCollapsed && (\n <div className=\"pb-1\">\n {group.sections\n .slice()\n .sort((a, b) => b.tokenCount - a.tokenCount)\n .map((section) => (\n <SystemSectionRow\n key={section.segmentId}\n section={section}\n totalTokens={manifest.totalTokens}\n />\n ))}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n {groups.map((group) => {\n const isCollapsed = collapsed.has(group.name);\n return (\n <div key={group.name}>\n <button\n type=\"button\"\n onClick={() => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(group.name)) next.delete(group.name);\n else next.add(group.name);\n return next;\n });\n }}\n className=\"flex w-full cursor-pointer items-center gap-2 rounded-sm px-1.5 py-2 text-left hover:bg-accent/35\"\n >\n {isCollapsed ? (\n <IconChevronRight className=\"h-3.5 w-3.5 text-muted-foreground\" />\n ) : (\n <IconChevronDown className=\"h-3.5 w-3.5 text-muted-foreground\" />\n )}\n <span\n className={cn(\n \"h-2 w-2 rounded-full\",\n groupColor(group.name),\n )}\n />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium\">\n {group.name}\n </span>\n <span className=\"text-[11px] text-muted-foreground\">\n {formatTokens(group.tokens)}\n </span>\n </button>\n {!isCollapsed && (\n <div className=\"pb-1\">\n {group.segments\n .slice()\n .sort((a, b) => b.tokenCount - a.tokenCount)\n .map((segment) => (\n <ContextSegmentRow\n key={segment.segmentId}\n segment={segment}\n advisory={!manifest.enforceable}\n onPin={() => onPin(segment.segmentId)}\n onEvict={() => onEvict(segment.segmentId)}\n onRestore={() => onRestore(segment.segmentId)}\n />\n ))}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContextXRayPanel.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,GAOV;IACC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;IACjB,OAAO,CACL,KAAC,oBAAoB,IACnB,QAAQ,EAAE;YACR,GAAG,QAAQ;YACX,YAAY,EAAE,oBAAoB,CAAC,QAAQ,CAAC;YAC5C,kBAAkB,EAAE,0BAA0B,CAAC,QAAQ,CAAC;SACzD,EACD,aAAa,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,EACnD,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,CAAC,CAAC,uBAAuB,EAAE;YACrC,YAAY,EAAE,eAAe;SAC9B,CAAC,EACF,kBAAkB,EAAE,CAAC,CAAC,2BAA2B,EAAE;YACjD,YAAY,EAAE,iCAAiC;SAChD,CAAC,EACF,gBAAgB,EAAE;YAChB,QAAQ,EAAE,CAAC,CAAC,iCAAiC,EAAE;gBAC7C,YAAY,EAAE,UAAU;aACzB,CAAC;YACF,SAAS,EAAE,CAAC,CAAC,kCAAkC,EAAE;gBAC/C,YAAY,EAAE,WAAW;aAC1B,CAAC;YACF,IAAI,EAAE,CAAC,CAAC,6BAA6B,EAAE;gBACrC,YAAY,EAAE,cAAc;aAC7B,CAAC;SACH,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { ContextXRayPanelView } from \"@agent-native/toolkit/context-ui\";\n\nimport type {\n ContextManifest,\n ContextSegmentStatus,\n} from \"../../shared/context-xray.js\";\nimport {\n manifestConversationTokens,\n manifestSystemTokens,\n} from \"../../shared/context-xray.js\";\nimport { useT } from \"../i18n.js\";\nimport { resolveContextWindow } from \"./format.js\";\n\nexport function ContextXRayPanel({\n manifest,\n optimistic,\n onPin,\n onEvict,\n onRestore,\n}: {\n manifest: ContextManifest;\n optimistic: Map<string, ContextSegmentStatus>;\n onPin: (segmentId: string) => void;\n onEvict: (segmentId: string) => void;\n onRestore: (segmentId: string) => void;\n}) {\n const t = useT();\n return (\n <ContextXRayPanelView\n manifest={{\n ...manifest,\n systemTokens: manifestSystemTokens(manifest),\n conversationTokens: manifestConversationTokens(manifest),\n }}\n contextWindow={resolveContextWindow(manifest.model)}\n optimistic={optimistic}\n onPin={onPin}\n onEvict={onEvict}\n onRestore={onRestore}\n titleLabel={t(\"contextXray.pageTitle\", {\n defaultValue: \"Context X-Ray\",\n })}\n systemOrderedLabel={t(\"contextXray.systemOrdered\", {\n defaultValue: \"System · ordered, not evictable\",\n })}\n governanceLabels={{\n required: t(\"contextXray.governance.required\", {\n defaultValue: \"Required\",\n }),\n inherited: t(\"contextXray.governance.inherited\", {\n defaultValue: \"Inherited\",\n }),\n user: t(\"contextXray.governance.user\", {\n defaultValue: \"Your context\",\n }),\n }}\n />\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentProvenancePopover.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/SegmentProvenancePopover.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SegmentProvenancePopover.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/SegmentProvenancePopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,sBAAsB,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAMA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { formatTokens, statusLabel } from "./format.js";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SegmentProvenancePopoverView } from "@agent-native/toolkit/context-ui";
|
|
4
3
|
export function SegmentProvenancePopover({ segment, children, }) {
|
|
5
|
-
return (
|
|
4
|
+
return (_jsx(SegmentProvenancePopoverView, { segment: segment, children: children }));
|
|
6
5
|
}
|
|
7
6
|
//# sourceMappingURL=SegmentProvenancePopover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentProvenancePopover.js","sourceRoot":"","sources":["../../../src/client/context-xray/SegmentProvenancePopover.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SegmentProvenancePopover.js","sourceRoot":"","sources":["../../../src/client/context-xray/SegmentProvenancePopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAKhF,MAAM,UAAU,wBAAwB,CAAC,EACvC,OAAO,EACP,QAAQ,GAIT;IACC,OAAO,CACL,KAAC,4BAA4B,IAAC,OAAO,EAAE,OAAO,YAC3C,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC","sourcesContent":["import { SegmentProvenancePopoverView } from \"@agent-native/toolkit/context-ui\";\nimport type React from \"react\";\n\nimport type { ContextManifestSegment } from \"../../shared/context-xray.js\";\n\nexport function SegmentProvenancePopover({\n segment,\n children,\n}: {\n segment: ContextManifestSegment;\n children: React.ReactNode;\n}) {\n return (\n <SegmentProvenancePopoverView segment={segment}>\n {children}\n </SegmentProvenancePopoverView>\n );\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ContextManifestSegment } from "../../shared/context-xray.js";
|
|
2
1
|
/**
|
|
3
2
|
* Fallback context-window limit used when no model ID is available.
|
|
4
3
|
* Kept as a named export so existing callers that import this constant
|
|
@@ -12,7 +11,4 @@ export declare const CONTEXT_XRAY_MODEL_LIMIT = 200000;
|
|
|
12
11
|
*/
|
|
13
12
|
export declare function resolveContextWindow(modelId?: string | null): number;
|
|
14
13
|
export declare function formatTokens(tokens: number | undefined): string;
|
|
15
|
-
export declare function statusLabel(segment: ContextManifestSegment): string;
|
|
16
|
-
export declare function groupColor(group: string): string;
|
|
17
|
-
export declare function groupFill(group: string): string;
|
|
18
14
|
//# sourceMappingURL=format.d.ts.map
|