@ottocode/web-sdk 0.1.246 → 0.1.247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/file-browser/FileViewerPanel.d.ts.map +1 -1
- package/dist/components/index.js +102 -25
- package/dist/components/index.js.map +10 -10
- package/dist/components/messages/ActionToolBox.d.ts.map +1 -1
- package/dist/components/messages/AssistantMessageGroup.d.ts.map +1 -1
- package/dist/components/messages/MessagePartItem.d.ts.map +1 -1
- package/dist/components/messages/ToolApprovalCard.d.ts.map +1 -1
- package/dist/components/messages/renderers/index.d.ts.map +1 -1
- package/dist/components/ui/ToolApprovalDialog.d.ts.map +1 -1
- package/dist/index.js +102 -25
- package/dist/index.js.map +10 -10
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileViewerPanel.d.ts","sourceRoot":"","sources":["../../../src/components/file-browser/FileViewerPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileViewerPanel.d.ts","sourceRoot":"","sources":["../../../src/components/file-browser/FileViewerPanel.tsx"],"names":[],"mappings":"AA+DA,eAAO,MAAM,eAAe,8CAkJ1B,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -383,6 +383,7 @@ var useToolApprovalStore = create3((set) => ({
|
|
|
383
383
|
import { Shield, Check, X as X2, Terminal, FileEdit, GitCommit } from "lucide-react";
|
|
384
384
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
385
385
|
var TOOL_ICONS = {
|
|
386
|
+
shell: Terminal,
|
|
386
387
|
bash: Terminal,
|
|
387
388
|
edit: FileEdit,
|
|
388
389
|
multiedit: FileEdit,
|
|
@@ -6860,6 +6861,12 @@ function getLanguageFromPath2(path) {
|
|
|
6860
6861
|
};
|
|
6861
6862
|
return langMap[ext || ""] || "javascript";
|
|
6862
6863
|
}
|
|
6864
|
+
function normalizeToolName(toolName) {
|
|
6865
|
+
return toolName === "bash" ? "shell" : toolName;
|
|
6866
|
+
}
|
|
6867
|
+
function isShellTool(toolName) {
|
|
6868
|
+
return normalizeToolName(toolName) === "shell";
|
|
6869
|
+
}
|
|
6863
6870
|
function normalizeToolTarget(toolName, args) {
|
|
6864
6871
|
if (!args)
|
|
6865
6872
|
return null;
|
|
@@ -6872,6 +6879,7 @@ function normalizeToolTarget(toolName, args) {
|
|
|
6872
6879
|
glob: ["pattern"],
|
|
6873
6880
|
grep: ["query", "pattern"],
|
|
6874
6881
|
ripgrep: ["query", "pattern"],
|
|
6882
|
+
shell: ["cmd", "command"],
|
|
6875
6883
|
bash: ["cmd", "command"],
|
|
6876
6884
|
terminal: ["command"],
|
|
6877
6885
|
git_commit: ["message"],
|
|
@@ -6915,9 +6923,10 @@ var ToolApprovalCard = memo7(function ToolApprovalCard2({
|
|
|
6915
6923
|
onReject
|
|
6916
6924
|
}) {
|
|
6917
6925
|
const [isProcessing, setIsProcessing] = useState16(false);
|
|
6918
|
-
const
|
|
6919
|
-
const
|
|
6920
|
-
const
|
|
6926
|
+
const normalizedToolName = normalizeToolName(toolName);
|
|
6927
|
+
const toolLabel = normalizedToolName.replace(/_/g, " ");
|
|
6928
|
+
const primary = normalizeToolTarget(normalizedToolName, args);
|
|
6929
|
+
const command = isShellTool(normalizedToolName) ? getPrimaryCommand(args) : null;
|
|
6921
6930
|
const approvalTarget = command || primary?.value;
|
|
6922
6931
|
const filePath = typeof args?.path === "string" ? args.path : "";
|
|
6923
6932
|
const language = getLanguageFromPath2(filePath);
|
|
@@ -6980,7 +6989,7 @@ var ToolApprovalCard = memo7(function ToolApprovalCard2({
|
|
|
6980
6989
|
children: toolName === "multiedit" ? "Multiple exact replacements will be applied atomically." : "An exact text replacement will be applied to this file."
|
|
6981
6990
|
});
|
|
6982
6991
|
}
|
|
6983
|
-
if (
|
|
6992
|
+
if (isShellTool(normalizedToolName) && args?.cmd) {
|
|
6984
6993
|
const cmd = String(args.cmd);
|
|
6985
6994
|
return /* @__PURE__ */ jsx24("div", {
|
|
6986
6995
|
className: "ml-6 max-w-full overflow-hidden",
|
|
@@ -7018,7 +7027,7 @@ var ToolApprovalCard = memo7(function ToolApprovalCard2({
|
|
|
7018
7027
|
className: "font-medium text-foreground text-sm",
|
|
7019
7028
|
children: toolLabel
|
|
7020
7029
|
}),
|
|
7021
|
-
approvalTarget &&
|
|
7030
|
+
approvalTarget && !isShellTool(normalizedToolName) && /* @__PURE__ */ jsx24("code", {
|
|
7022
7031
|
className: "text-xs font-mono text-foreground/80 bg-muted/50 px-1.5 py-0.5 rounded truncate max-w-xs",
|
|
7023
7032
|
children: approvalTarget
|
|
7024
7033
|
}),
|
|
@@ -7710,7 +7719,7 @@ function BashRenderer({
|
|
|
7710
7719
|
className: "text-xs",
|
|
7711
7720
|
children: [
|
|
7712
7721
|
/* @__PURE__ */ jsxs25(ToolHeader, {
|
|
7713
|
-
toolName: "
|
|
7722
|
+
toolName: "shell",
|
|
7714
7723
|
isExpanded,
|
|
7715
7724
|
onToggle,
|
|
7716
7725
|
isError,
|
|
@@ -10991,7 +11000,9 @@ var TOOL_NAME_ALIASES = {
|
|
|
10991
11000
|
Pwd: "pwd",
|
|
10992
11001
|
Glob: "glob",
|
|
10993
11002
|
Grep: "ripgrep",
|
|
10994
|
-
|
|
11003
|
+
Shell: "shell",
|
|
11004
|
+
Bash: "shell",
|
|
11005
|
+
bash: "shell",
|
|
10995
11006
|
Terminal: "terminal",
|
|
10996
11007
|
GitStatus: "git_status",
|
|
10997
11008
|
GitDiff: "git_diff",
|
|
@@ -11005,11 +11016,11 @@ var TOOL_NAME_ALIASES = {
|
|
|
11005
11016
|
LoadMcpTools: "load_mcp_tools",
|
|
11006
11017
|
Skill: "skill"
|
|
11007
11018
|
};
|
|
11008
|
-
function
|
|
11019
|
+
function normalizeToolName2(name) {
|
|
11009
11020
|
return TOOL_NAME_ALIASES[name] ?? name;
|
|
11010
11021
|
}
|
|
11011
11022
|
var COMPACT_DETAIL_TOOL_NAMES = new Set([
|
|
11012
|
-
"
|
|
11023
|
+
"shell",
|
|
11013
11024
|
"edit",
|
|
11014
11025
|
"multiedit",
|
|
11015
11026
|
"write",
|
|
@@ -11028,7 +11039,7 @@ function ToolResultRenderer({
|
|
|
11028
11039
|
onCompact
|
|
11029
11040
|
}) {
|
|
11030
11041
|
const [isExpanded, setIsExpanded] = useState22(false);
|
|
11031
|
-
const normalizedName =
|
|
11042
|
+
const normalizedName = normalizeToolName2(toolName);
|
|
11032
11043
|
const rendererCompact = compact && !COMPACT_DETAIL_TOOL_NAMES.has(normalizedName);
|
|
11033
11044
|
const handleToggle = () => setIsExpanded(!isExpanded);
|
|
11034
11045
|
const props = {
|
|
@@ -11059,7 +11070,7 @@ function ToolResultRenderer({
|
|
|
11059
11070
|
return /* @__PURE__ */ jsx53(WriteRenderer, {
|
|
11060
11071
|
...props
|
|
11061
11072
|
});
|
|
11062
|
-
case "
|
|
11073
|
+
case "shell":
|
|
11063
11074
|
return /* @__PURE__ */ jsx53(BashRenderer, {
|
|
11064
11075
|
...props
|
|
11065
11076
|
});
|
|
@@ -11198,6 +11209,12 @@ function getPatchedFileFromPatch(patch) {
|
|
|
11198
11209
|
const match = patch.match(/^\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+)$/m);
|
|
11199
11210
|
return match?.[1]?.trim() || null;
|
|
11200
11211
|
}
|
|
11212
|
+
function normalizeToolName3(toolName) {
|
|
11213
|
+
return toolName === "bash" ? "shell" : toolName;
|
|
11214
|
+
}
|
|
11215
|
+
function isShellTool2(toolName) {
|
|
11216
|
+
return normalizeToolName3(toolName) === "shell";
|
|
11217
|
+
}
|
|
11201
11218
|
function normalizeToolTarget2(toolName, args) {
|
|
11202
11219
|
if (!args)
|
|
11203
11220
|
return null;
|
|
@@ -11217,7 +11234,7 @@ function normalizeToolTarget2(toolName, args) {
|
|
|
11217
11234
|
return { key, value: value.trim() };
|
|
11218
11235
|
}
|
|
11219
11236
|
}
|
|
11220
|
-
if (toolName
|
|
11237
|
+
if (isShellTool2(toolName)) {
|
|
11221
11238
|
const command = args.command;
|
|
11222
11239
|
if (typeof command === "string" && command.trim().length > 0) {
|
|
11223
11240
|
return { key: "command", value: command.trim() };
|
|
@@ -11352,7 +11369,7 @@ var MessagePartItem = memo8(function MessagePartItem2({
|
|
|
11352
11369
|
return /* @__PURE__ */ jsx54(FolderTree2, {
|
|
11353
11370
|
className: "h-4 w-4 text-cyan-600 dark:text-cyan-300"
|
|
11354
11371
|
});
|
|
11355
|
-
if (toolName
|
|
11372
|
+
if (isShellTool2(toolName))
|
|
11356
11373
|
return /* @__PURE__ */ jsx54(Terminal5, {
|
|
11357
11374
|
className: "h-4 w-4 text-muted-foreground"
|
|
11358
11375
|
});
|
|
@@ -11568,13 +11585,14 @@ var MessagePartItem = memo8(function MessagePartItem2({
|
|
|
11568
11585
|
if (part.type === "tool_call") {
|
|
11569
11586
|
const payload = getToolCallPayload(part);
|
|
11570
11587
|
const rawToolName = part.toolName || (typeof payload?.name === "string" ? payload.name : "tool");
|
|
11571
|
-
const
|
|
11588
|
+
const normalizedToolName = normalizeToolName3(rawToolName);
|
|
11589
|
+
const toolLabel = normalizedToolName.includes("__") ? normalizedToolName.replace("__", " › ") : normalizedToolName.replace(/_/g, " ");
|
|
11572
11590
|
const partArgs = getToolCallArgs(part);
|
|
11573
11591
|
const approvalArgs = pendingApproval?.args;
|
|
11574
11592
|
const args = partArgs || approvalArgs;
|
|
11575
|
-
const primary = normalizeToolTarget2(
|
|
11593
|
+
const primary = normalizeToolTarget2(normalizedToolName, args);
|
|
11576
11594
|
const argsPreview = formatArgsPreview(args, primary?.key);
|
|
11577
|
-
const command =
|
|
11595
|
+
const command = isShellTool2(normalizedToolName) ? getPrimaryCommand2(args) : null;
|
|
11578
11596
|
const segments = [];
|
|
11579
11597
|
if (command) {
|
|
11580
11598
|
segments.push({
|
|
@@ -12238,6 +12256,7 @@ function getPatchTarget(patch) {
|
|
|
12238
12256
|
return match?.[1]?.trim() || null;
|
|
12239
12257
|
}
|
|
12240
12258
|
var TOOL_CONFIG = {
|
|
12259
|
+
shell: { Icon: Terminal6, color: "text-muted-foreground", label: "Running" },
|
|
12241
12260
|
bash: { Icon: Terminal6, color: "text-muted-foreground", label: "Running" },
|
|
12242
12261
|
write: {
|
|
12243
12262
|
Icon: FileEdit3,
|
|
@@ -12265,10 +12284,16 @@ var TOOL_CONFIG = {
|
|
|
12265
12284
|
label: "Terminal"
|
|
12266
12285
|
}
|
|
12267
12286
|
};
|
|
12287
|
+
function normalizeToolName4(toolName) {
|
|
12288
|
+
return toolName === "bash" ? "shell" : toolName;
|
|
12289
|
+
}
|
|
12290
|
+
function isShellTool3(toolName) {
|
|
12291
|
+
return normalizeToolName4(toolName) === "shell";
|
|
12292
|
+
}
|
|
12268
12293
|
function getTargetFromArgs(toolName, args) {
|
|
12269
12294
|
if (!args)
|
|
12270
12295
|
return "";
|
|
12271
|
-
if (toolName
|
|
12296
|
+
if (isShellTool3(toolName)) {
|
|
12272
12297
|
const cmd = String(args.cmd || "");
|
|
12273
12298
|
return cmd.length > 80 ? `${cmd.slice(0, 77)}…` : cmd;
|
|
12274
12299
|
}
|
|
@@ -12283,7 +12308,7 @@ function getTargetFromArgs(toolName, args) {
|
|
|
12283
12308
|
return "";
|
|
12284
12309
|
}
|
|
12285
12310
|
function getTargetFromStream(toolName, raw) {
|
|
12286
|
-
if (toolName
|
|
12311
|
+
if (isShellTool3(toolName)) {
|
|
12287
12312
|
const cmd = extractJsonStringField(raw, "cmd");
|
|
12288
12313
|
if (cmd) {
|
|
12289
12314
|
return cmd.length > 80 ? `${cmd.slice(0, 77)}…` : cmd;
|
|
@@ -12319,7 +12344,7 @@ function ActionToolBox({ part, showLine }) {
|
|
|
12319
12344
|
const hoveredRef = useRef11(false);
|
|
12320
12345
|
const previousContentLengthRef = useRef11(0);
|
|
12321
12346
|
const [contentHeight, setContentHeight] = useState24(0);
|
|
12322
|
-
const toolName = part.toolName || "";
|
|
12347
|
+
const toolName = normalizeToolName4(part.toolName || "");
|
|
12323
12348
|
const isComplete = part.type === "tool_result";
|
|
12324
12349
|
const config2 = TOOL_CONFIG[toolName] || {
|
|
12325
12350
|
Icon: Terminal6,
|
|
@@ -12333,7 +12358,7 @@ function ActionToolBox({ part, showLine }) {
|
|
|
12333
12358
|
const streamedOutput = getStreamedOutput(part);
|
|
12334
12359
|
const target = getTargetFromArgs(toolName, args) || getTargetFromStream(toolName, streamedInput);
|
|
12335
12360
|
const streamedContent = getContentFromStream(toolName, streamedInput);
|
|
12336
|
-
const displayContent = toolName
|
|
12361
|
+
const displayContent = isShellTool3(toolName) ? streamedOutput || streamedContent || (args ? getContentFromArgs(toolName, args) : "") : args ? getContentFromArgs(toolName, args) : streamedContent;
|
|
12337
12362
|
const hasDisplayContent = displayContent.trim().length > 0;
|
|
12338
12363
|
useEffect18(() => {
|
|
12339
12364
|
if (!isComplete && !latched) {
|
|
@@ -12546,7 +12571,7 @@ function ActionToolBox({ part, showLine }) {
|
|
|
12546
12571
|
});
|
|
12547
12572
|
}
|
|
12548
12573
|
function getContentFromArgs(toolName, args) {
|
|
12549
|
-
if (toolName
|
|
12574
|
+
if (isShellTool3(toolName))
|
|
12550
12575
|
return String(args.cmd || "");
|
|
12551
12576
|
if (toolName === "write")
|
|
12552
12577
|
return String(args.content || "");
|
|
@@ -12593,7 +12618,7 @@ function extractJsonStringField(raw, field) {
|
|
|
12593
12618
|
function getContentFromStream(toolName, raw) {
|
|
12594
12619
|
if (!raw)
|
|
12595
12620
|
return "";
|
|
12596
|
-
if (toolName
|
|
12621
|
+
if (isShellTool3(toolName))
|
|
12597
12622
|
return extractJsonStringField(raw, "cmd");
|
|
12598
12623
|
if (toolName === "write")
|
|
12599
12624
|
return extractJsonStringField(raw, "content");
|
|
@@ -12956,6 +12981,7 @@ var AssistantMessageGroup = memo9(function AssistantMessageGroup2({
|
|
|
12956
12981
|
const latestProgressUpdateIndex = parts.reduce((lastIndex, part, index) => part.type === "tool_result" && part.toolName === "progress_update" ? index : lastIndex, -1);
|
|
12957
12982
|
const latestProgressUpdatePart = latestProgressUpdateIndex >= 0 ? parts[latestProgressUpdateIndex] : null;
|
|
12958
12983
|
const liveActionToolCallIds = new Set(parts.filter((part) => part.ephemeral && [
|
|
12984
|
+
"shell",
|
|
12959
12985
|
"bash",
|
|
12960
12986
|
"edit",
|
|
12961
12987
|
"multiedit",
|
|
@@ -13156,6 +13182,7 @@ var AssistantMessageGroup = memo9(function AssistantMessageGroup2({
|
|
|
13156
13182
|
const { part, index } = item;
|
|
13157
13183
|
const isLastPart = index === parts.length - 1;
|
|
13158
13184
|
const isActionTool = part.ephemeral && (part.type === "tool_call" || part.type === "tool_result") && [
|
|
13185
|
+
"shell",
|
|
13159
13186
|
"bash",
|
|
13160
13187
|
"edit",
|
|
13161
13188
|
"multiedit",
|
|
@@ -24708,11 +24735,13 @@ var FileBrowserSidebarToggle = memo43(function FileBrowserSidebarToggle2() {
|
|
|
24708
24735
|
// src/components/file-browser/FileViewerPanel.tsx
|
|
24709
24736
|
import { memo as memo44, useEffect as useEffect44 } from "react";
|
|
24710
24737
|
import { X as X17 } from "lucide-react";
|
|
24738
|
+
import ReactMarkdown3 from "react-markdown";
|
|
24711
24739
|
import { Prism as SyntaxHighlighter12 } from "react-syntax-highlighter";
|
|
24712
24740
|
import {
|
|
24713
24741
|
prism as prism12,
|
|
24714
24742
|
vscDarkPlus as vscDarkPlus12
|
|
24715
24743
|
} from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
24744
|
+
import remarkGfm3 from "remark-gfm";
|
|
24716
24745
|
import { jsx as jsx101, jsxs as jsxs89 } from "react/jsx-runtime";
|
|
24717
24746
|
var LANGUAGE_MAP3 = {
|
|
24718
24747
|
js: "javascript",
|
|
@@ -24742,15 +24771,24 @@ var LANGUAGE_MAP3 = {
|
|
|
24742
24771
|
css: "css",
|
|
24743
24772
|
scss: "scss",
|
|
24744
24773
|
md: "markdown",
|
|
24774
|
+
markdown: "markdown",
|
|
24775
|
+
mdx: "markdown",
|
|
24745
24776
|
txt: "plaintext",
|
|
24746
24777
|
svelte: "svelte",
|
|
24747
24778
|
toml: "toml",
|
|
24748
24779
|
lock: "plaintext"
|
|
24749
24780
|
};
|
|
24781
|
+
function getFileExtension(path) {
|
|
24782
|
+
return path.split(".").pop()?.toLowerCase() ?? "";
|
|
24783
|
+
}
|
|
24750
24784
|
function inferLanguage2(path) {
|
|
24751
|
-
const ext = path
|
|
24785
|
+
const ext = getFileExtension(path);
|
|
24752
24786
|
return LANGUAGE_MAP3[ext] ?? "plaintext";
|
|
24753
24787
|
}
|
|
24788
|
+
function isMarkdownFile(path) {
|
|
24789
|
+
const ext = getFileExtension(path);
|
|
24790
|
+
return ext === "md" || ext === "markdown" || ext === "mdx";
|
|
24791
|
+
}
|
|
24754
24792
|
var FileViewerPanel = memo44(function FileViewerPanel2() {
|
|
24755
24793
|
const isViewerOpen = useFileBrowserStore((s) => s.isViewerOpen);
|
|
24756
24794
|
const selectedFile = useFileBrowserStore((s) => s.selectedFile);
|
|
@@ -24771,6 +24809,7 @@ var FileViewerPanel = memo44(function FileViewerPanel2() {
|
|
|
24771
24809
|
return null;
|
|
24772
24810
|
const syntaxTheme = document?.documentElement.classList.contains("dark") ? vscDarkPlus12 : prism12;
|
|
24773
24811
|
const language = inferLanguage2(selectedFile);
|
|
24812
|
+
const renderMarkdown = isMarkdownFile(selectedFile);
|
|
24774
24813
|
return /* @__PURE__ */ jsxs89("div", {
|
|
24775
24814
|
className: "absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",
|
|
24776
24815
|
children: [
|
|
@@ -24814,7 +24853,45 @@ var FileViewerPanel = memo44(function FileViewerPanel2() {
|
|
|
24814
24853
|
children: isLoading ? /* @__PURE__ */ jsx101("div", {
|
|
24815
24854
|
className: "h-full flex items-center justify-center text-muted-foreground",
|
|
24816
24855
|
children: "Loading file..."
|
|
24817
|
-
}) : data ? /* @__PURE__ */ jsx101("div", {
|
|
24856
|
+
}) : data ? renderMarkdown ? /* @__PURE__ */ jsx101("div", {
|
|
24857
|
+
className: "p-4 text-sm text-foreground leading-6 markdown-content max-w-full overflow-x-auto",
|
|
24858
|
+
children: /* @__PURE__ */ jsx101(ReactMarkdown3, {
|
|
24859
|
+
remarkPlugins: [remarkGfm3],
|
|
24860
|
+
components: {
|
|
24861
|
+
a: ({
|
|
24862
|
+
href,
|
|
24863
|
+
children,
|
|
24864
|
+
...props
|
|
24865
|
+
}) => /* @__PURE__ */ jsx101("a", {
|
|
24866
|
+
href,
|
|
24867
|
+
target: "_blank",
|
|
24868
|
+
rel: "noopener noreferrer",
|
|
24869
|
+
onClick: (e) => {
|
|
24870
|
+
if (window.self !== window.top && href) {
|
|
24871
|
+
e.preventDefault();
|
|
24872
|
+
window.parent.postMessage({
|
|
24873
|
+
type: "otto-open-url",
|
|
24874
|
+
url: href
|
|
24875
|
+
}, "*");
|
|
24876
|
+
}
|
|
24877
|
+
},
|
|
24878
|
+
...props,
|
|
24879
|
+
children
|
|
24880
|
+
}),
|
|
24881
|
+
table: ({
|
|
24882
|
+
children,
|
|
24883
|
+
...props
|
|
24884
|
+
}) => /* @__PURE__ */ jsx101("div", {
|
|
24885
|
+
className: "overflow-x-auto max-w-full min-w-0 my-3",
|
|
24886
|
+
children: /* @__PURE__ */ jsx101("table", {
|
|
24887
|
+
...props,
|
|
24888
|
+
children
|
|
24889
|
+
})
|
|
24890
|
+
})
|
|
24891
|
+
},
|
|
24892
|
+
children: data.content
|
|
24893
|
+
})
|
|
24894
|
+
}) : /* @__PURE__ */ jsx101("div", {
|
|
24818
24895
|
className: "code-with-line-numbers",
|
|
24819
24896
|
children: /* @__PURE__ */ jsx101(SyntaxHighlighter12, {
|
|
24820
24897
|
language,
|
|
@@ -26674,4 +26751,4 @@ export {
|
|
|
26674
26751
|
AssistantMessageGroup
|
|
26675
26752
|
};
|
|
26676
26753
|
|
|
26677
|
-
//# debugId=
|
|
26754
|
+
//# debugId=7F0EBE4B932F92B664756E2164756E21
|