@ottocode/web-sdk 0.1.297 → 0.1.299
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/common/UsageModal.d.ts.map +1 -1
- package/dist/components/common/UsageRing.d.ts.map +1 -1
- package/dist/components/file-browser/FileViewerPanel.d.ts.map +1 -1
- package/dist/components/index.js +153 -29
- package/dist/components/index.js.map +11 -11
- package/dist/components/messages/UserMessageGroup.d.ts.map +1 -1
- package/dist/components/workspace/ToolPreviewPanel.d.ts.map +1 -1
- package/dist/components/workspace/ViewerTabs.d.ts.map +1 -1
- package/dist/hooks/index.js +113 -6
- package/dist/hooks/index.js.map +5 -5
- package/dist/hooks/useProviderUsage.d.ts.map +1 -1
- package/dist/hooks/useSessionStream.d.ts.map +1 -1
- package/dist/index.js +153 -29
- package/dist/index.js.map +11 -11
- package/dist/stores/index.js +7 -4
- package/dist/stores/index.js.map +3 -3
- package/dist/stores/viewerTabsStore.d.ts +4 -3
- package/dist/stores/viewerTabsStore.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMessageGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/UserMessageGroup.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAS/C,UAAU,qBAAqB;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"UserMessageGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/UserMessageGroup.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAS/C,UAAU,qBAAqB;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAkBD,eAAO,MAAM,gBAAgB,6DAsV5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolPreviewPanel.d.ts","sourceRoot":"","sources":["../../../src/components/workspace/ToolPreviewPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,SAAS,EAEd,MAAM,8BAA8B,CAAC;AAUtC,UAAU,qBAAqB;IAC9B,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;CAClD;AAOD,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"ToolPreviewPanel.d.ts","sourceRoot":"","sources":["../../../src/components/workspace/ToolPreviewPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,SAAS,EAEd,MAAM,8BAA8B,CAAC;AAUtC,UAAU,qBAAqB;IAC9B,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;CAClD;AAOD,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAukBD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,UAAU,EAAE,MAAM,GAChB,gBAAgB,GAAG,IAAI,CAsGzB;AAwFD,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE,qBAAqB,+BAgR9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewerTabs.d.ts","sourceRoot":"","sources":["../../../src/components/workspace/ViewerTabs.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ViewerTabs.d.ts","sourceRoot":"","sources":["../../../src/components/workspace/ViewerTabs.tsx"],"names":[],"mappings":"AA2PA,eAAO,MAAM,UAAU,8CA+LrB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1535,6 +1535,9 @@ function upsertTab(tabs, tab) {
|
|
|
1535
1535
|
next[existingIndex] = tab;
|
|
1536
1536
|
return next;
|
|
1537
1537
|
}
|
|
1538
|
+
function isPatchPreviewTool(toolName) {
|
|
1539
|
+
return toolName === "apply_patch" || toolName === "edit" || toolName === "multiedit";
|
|
1540
|
+
}
|
|
1538
1541
|
function isSamePatchCall(existing, preview) {
|
|
1539
1542
|
if (!existing)
|
|
1540
1543
|
return false;
|
|
@@ -1707,8 +1710,8 @@ var useViewerTabsStore = create((set) => ({
|
|
|
1707
1710
|
const targetPath = existingFile?.path ?? preview.path;
|
|
1708
1711
|
const existing = state.tabs.find((tab) => tab.type === "tool-preview" && viewerPathsMatch(tab.path, preview.path));
|
|
1709
1712
|
const tabs = state.tabs.filter((tab) => !((tab.type === "tool-preview" || tab.type === "file") && tab.id !== targetId && (viewerPathsMatch(tab.path, preview.path) || Boolean(preview.callId && "toolName" in tab && tab.callId === preview.callId))));
|
|
1710
|
-
if (preview.toolName
|
|
1711
|
-
const existingPatchPreview = existingFile?.patchPreview ?? (existing
|
|
1713
|
+
if (isPatchPreviewTool(preview.toolName)) {
|
|
1714
|
+
const existingPatchPreview = existingFile?.patchPreview ?? (existing && isPatchPreviewTool(existing.toolName) ? existing : undefined);
|
|
1712
1715
|
const samePatchCall = isSamePatchCall(existingPatchPreview, preview);
|
|
1713
1716
|
const baseContent = preview.baseContent ?? (samePatchCall ? existingPatchPreview?.baseContent : existingPatchPreview?.resultContent ?? existingPatchPreview?.baseContent);
|
|
1714
1717
|
const changedLines = samePatchCall ? preview.changedLines ?? existingPatchPreview?.changedLines : mergeChangedLines(existingPatchPreview?.changedLines, preview.changedLines);
|
|
@@ -1729,7 +1732,7 @@ var useViewerTabsStore = create((set) => ({
|
|
|
1729
1732
|
writePreview: undefined,
|
|
1730
1733
|
patchPreview: {
|
|
1731
1734
|
path: targetPath,
|
|
1732
|
-
toolName:
|
|
1735
|
+
toolName: preview.toolName,
|
|
1733
1736
|
callId: preview.callId ?? existingPatchPreview?.callId,
|
|
1734
1737
|
baseContent,
|
|
1735
1738
|
patch: preview.patch ?? existingPatchPreview?.patch,
|
|
@@ -3170,7 +3173,13 @@ ${argPatch.slice(-STREAMING_PATCH_PREVIEW_TAIL_CHARS)}`;
|
|
|
3170
3173
|
${bestEffortUnescapeJsonString(rawTail)}`;
|
|
3171
3174
|
};
|
|
3172
3175
|
const getResultRecord = (payload) => payload?.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? payload.result : null;
|
|
3173
|
-
const getArtifactRecord = (payload) =>
|
|
3176
|
+
const getArtifactRecord = (payload) => {
|
|
3177
|
+
if (payload?.artifact && typeof payload.artifact === "object" && !Array.isArray(payload.artifact)) {
|
|
3178
|
+
return payload.artifact;
|
|
3179
|
+
}
|
|
3180
|
+
const result = getResultRecord(payload);
|
|
3181
|
+
return result?.artifact && typeof result.artifact === "object" && !Array.isArray(result.artifact) ? result.artifact : null;
|
|
3182
|
+
};
|
|
3174
3183
|
const extractErrorMessage2 = (payload) => {
|
|
3175
3184
|
const result = getResultRecord(payload);
|
|
3176
3185
|
if (typeof payload?.error === "string")
|
|
@@ -3307,6 +3316,56 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
3307
3316
|
}
|
|
3308
3317
|
return lines.size > 0 ? [...lines] : undefined;
|
|
3309
3318
|
};
|
|
3319
|
+
const getPatchTextLines = (value) => {
|
|
3320
|
+
if (value.length === 0)
|
|
3321
|
+
return [];
|
|
3322
|
+
const lines = value.split(`
|
|
3323
|
+
`);
|
|
3324
|
+
if (value.endsWith(`
|
|
3325
|
+
`))
|
|
3326
|
+
lines.pop();
|
|
3327
|
+
return lines;
|
|
3328
|
+
};
|
|
3329
|
+
const appendStringEditPatchHunk = (lines, edit) => {
|
|
3330
|
+
lines.push("@@");
|
|
3331
|
+
for (const line of getPatchTextLines(edit.oldString)) {
|
|
3332
|
+
lines.push(`-${line}`);
|
|
3333
|
+
}
|
|
3334
|
+
for (const line of getPatchTextLines(edit.newString)) {
|
|
3335
|
+
lines.push(`+${line}`);
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
const buildStringEditPatchPreview = (path, edits) => {
|
|
3339
|
+
const validEdits = edits.filter((edit) => edit.oldString.length > 0 || edit.newString.length > 0);
|
|
3340
|
+
if (validEdits.length === 0)
|
|
3341
|
+
return;
|
|
3342
|
+
const lines = ["*** Begin Patch", `*** Update File: ${path}`];
|
|
3343
|
+
for (const edit of validEdits)
|
|
3344
|
+
appendStringEditPatchHunk(lines, edit);
|
|
3345
|
+
lines.push("*** End Patch", "");
|
|
3346
|
+
return lines.join(`
|
|
3347
|
+
`);
|
|
3348
|
+
};
|
|
3349
|
+
const getMultiEditPreviewEdits = (args) => {
|
|
3350
|
+
const edits = Array.isArray(args?.edits) ? args.edits : [];
|
|
3351
|
+
return edits.flatMap((edit) => {
|
|
3352
|
+
if (!edit || typeof edit !== "object" || Array.isArray(edit))
|
|
3353
|
+
return [];
|
|
3354
|
+
const record = edit;
|
|
3355
|
+
return typeof record.oldString === "string" && typeof record.newString === "string" ? [{ oldString: record.oldString, newString: record.newString }] : [];
|
|
3356
|
+
});
|
|
3357
|
+
};
|
|
3358
|
+
const getEditPreviewPatch = (toolName, path, args, buffer, artifact) => {
|
|
3359
|
+
if (typeof artifact?.patch === "string")
|
|
3360
|
+
return artifact.patch;
|
|
3361
|
+
if (toolName === "edit") {
|
|
3362
|
+
const oldString = getStringArg(args, buffer, "oldString");
|
|
3363
|
+
const newString = getStringArg(args, buffer, "newString");
|
|
3364
|
+
return oldString !== undefined && newString !== undefined ? buildStringEditPatchPreview(path, [{ oldString, newString }]) : undefined;
|
|
3365
|
+
}
|
|
3366
|
+
const edits = getMultiEditPreviewEdits(args);
|
|
3367
|
+
return buildStringEditPatchPreview(path, edits);
|
|
3368
|
+
};
|
|
3310
3369
|
const handleReadToolActivity = (eventType, payload, delta) => {
|
|
3311
3370
|
const name = getToolEventName(payload);
|
|
3312
3371
|
if (name !== "read")
|
|
@@ -3441,6 +3500,51 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
3441
3500
|
});
|
|
3442
3501
|
}
|
|
3443
3502
|
};
|
|
3503
|
+
const handleEditToolActivity = (eventType, payload, delta) => {
|
|
3504
|
+
const name = getToolEventName(payload);
|
|
3505
|
+
if (name !== "edit" && name !== "multiedit")
|
|
3506
|
+
return;
|
|
3507
|
+
const args = getToolArgsForViewer(payload, delta);
|
|
3508
|
+
const buffer = getBufferedToolInput(payload);
|
|
3509
|
+
const artifact = getArtifactRecord(payload);
|
|
3510
|
+
const result = getResultRecord(payload);
|
|
3511
|
+
const path = (typeof result?.path === "string" ? result.path : undefined) ?? getStringArg(args, buffer, "path", true);
|
|
3512
|
+
if (!path)
|
|
3513
|
+
return;
|
|
3514
|
+
const failed = result?.ok === false || eventType === "error";
|
|
3515
|
+
const status = failed ? "error" : eventType === "tool.result" ? "success" : "streaming";
|
|
3516
|
+
const callId = getToolEventCallId(payload) ?? undefined;
|
|
3517
|
+
const patch = getEditPreviewPatch(name, path, args, buffer, artifact);
|
|
3518
|
+
if (status === "success")
|
|
3519
|
+
invalidateFileContentCache(path);
|
|
3520
|
+
if (!patch)
|
|
3521
|
+
return;
|
|
3522
|
+
const previewKey = callId ?? `${name}:${path}`;
|
|
3523
|
+
const lineSignature = status === "streaming" ? getCompletedPatchChangeLineSignature(patch) : undefined;
|
|
3524
|
+
if (status === "streaming") {
|
|
3525
|
+
const last = toolPreviewEmitRef.current.get(previewKey);
|
|
3526
|
+
if (last?.lineSignature === lineSignature)
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
const viewerStore = useViewerTabsStore.getState();
|
|
3530
|
+
if (!viewerStore.followToolActivity)
|
|
3531
|
+
return;
|
|
3532
|
+
viewerStore.openToolPreviewTab({
|
|
3533
|
+
path,
|
|
3534
|
+
toolName: name,
|
|
3535
|
+
callId,
|
|
3536
|
+
patch,
|
|
3537
|
+
status,
|
|
3538
|
+
error: extractErrorMessage2(payload)
|
|
3539
|
+
});
|
|
3540
|
+
if (status === "streaming") {
|
|
3541
|
+
toolPreviewEmitRef.current.set(previewKey, {
|
|
3542
|
+
emittedAt: Date.now(),
|
|
3543
|
+
contentLength: buffer.length,
|
|
3544
|
+
lineSignature
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3444
3548
|
const handleSimulatorToolActivity = (eventType, payload) => {
|
|
3445
3549
|
if (eventType !== "tool.result")
|
|
3446
3550
|
return;
|
|
@@ -3471,6 +3575,9 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
3471
3575
|
handleReadToolActivity(eventType, payload, delta);
|
|
3472
3576
|
if (name === "write")
|
|
3473
3577
|
handleWriteToolActivity(eventType, payload, delta);
|
|
3578
|
+
if (name === "edit" || name === "multiedit") {
|
|
3579
|
+
handleEditToolActivity(eventType, payload, delta);
|
|
3580
|
+
}
|
|
3474
3581
|
if (name === "apply_patch") {
|
|
3475
3582
|
handleApplyPatchToolActivity(eventType, payload, delta);
|
|
3476
3583
|
}
|
|
@@ -6787,7 +6894,7 @@ function useProviderUsage(provider, authType) {
|
|
|
6787
6894
|
const isModalOpen = useUsageStore((s) => s.isModalOpen);
|
|
6788
6895
|
const modalProvider = useUsageStore((s) => s.modalProvider);
|
|
6789
6896
|
const usage = useUsageStore((s) => provider ? s.usage[provider] : undefined);
|
|
6790
|
-
const isOAuthProvider = authType === "oauth" && (provider === "anthropic" || provider === "openai");
|
|
6897
|
+
const isOAuthProvider = authType === "oauth" && (provider === "anthropic" || provider === "openai" || provider === "xai");
|
|
6791
6898
|
const fetchUsage = useCallback10(async (force = false) => {
|
|
6792
6899
|
if (!provider || !isOAuthProvider)
|
|
6793
6900
|
return;
|
|
@@ -7658,4 +7765,4 @@ export {
|
|
|
7658
7765
|
normalizeQueueState
|
|
7659
7766
|
};
|
|
7660
7767
|
|
|
7661
|
-
//# debugId=
|
|
7768
|
+
//# debugId=0B45BD1AEF54C11064756E2164756E21
|