spiracha 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +48 -5
- package/README.md +40 -5
- package/apps/ui/AGENTS.md +23 -4
- package/apps/ui/README.md +49 -2
- package/apps/ui/dist/client/assets/analytics-DOy1b6Sh.js +1 -0
- package/apps/ui/dist/client/assets/{antigravity-conversations._conversationId-DmD0sN8X.js → antigravity-conversations._conversationId-DqySVO2K.js} +2 -2
- package/apps/ui/dist/client/assets/antigravity-keychain-panel-B77qJz6f.js +1 -0
- package/apps/ui/dist/client/assets/antigravity._workspaceKey-B3NM6gRH.js +1 -0
- package/apps/ui/dist/client/assets/{antigravity.index-DEEkjlZa.js → antigravity.index-DP9JC2P9.js} +1 -1
- package/apps/ui/dist/client/assets/{badge-DfWvPfKF.js → badge-C3i4OKs8.js} +1 -1
- package/apps/ui/dist/client/assets/claude-code-sessions._sessionId-8pQ55ci2.js +1 -0
- package/apps/ui/dist/client/assets/claude-code-sessions._sessionId-DVz5UmtU.js +1 -0
- package/apps/ui/dist/client/assets/claude-code._workspaceKey-BBKskSum.js +1 -0
- package/apps/ui/dist/client/assets/claude-code._workspaceKey-OkikMUFs.js +1 -0
- package/apps/ui/dist/client/assets/claude-code.index-Cwu76dbb.js +1 -0
- package/apps/ui/dist/client/assets/claude-code.index-D6eMd08t.js +1 -0
- package/apps/ui/dist/client/assets/createServerFn-B-KkwmHU.js +3 -0
- package/apps/ui/dist/client/assets/cursor-threads._composerId-hBWlP1D-.js +1 -0
- package/apps/ui/dist/client/assets/cursor._workspaceKey-BFPkIRi-.js +1 -0
- package/apps/ui/dist/client/assets/cursor.index-8y4o20kb.js +2 -0
- package/apps/ui/dist/client/assets/delete-confirm-dialog-Bxs07u-j.js +7 -0
- package/apps/ui/dist/client/assets/dist-BrJhN2A0.js +5 -0
- package/apps/ui/dist/client/assets/{dist-BhZOxAPP.js → dist-Cmd3AIfD.js} +1 -1
- package/apps/ui/dist/client/assets/dropdown-menu-D5cvPaZt.js +1 -0
- package/apps/ui/dist/client/assets/{es2015-BkCWttyM.js → es2015-ad6040dw.js} +1 -1
- package/apps/ui/dist/client/assets/export-dialog-Dr8d2MqD.js +1 -0
- package/apps/ui/dist/client/assets/{formatters-BM9kB7ed.js → formatters-BtqyrX_c.js} +1 -1
- package/apps/ui/dist/client/assets/index-C-STgIH4.js +166 -0
- package/apps/ui/dist/client/assets/kiro-sessions._sessionId-CKgfJ7GR.js +1 -0
- package/apps/ui/dist/client/assets/kiro-sessions._sessionId-zvIJHtQF.js +1 -0
- package/apps/ui/dist/client/assets/kiro._workspaceKey-DhVuJuZB.js +1 -0
- package/apps/ui/dist/client/assets/kiro._workspaceKey-QArsjkTY.js +1 -0
- package/apps/ui/dist/client/assets/kiro.index-C-fr4m7i.js +1 -0
- package/apps/ui/dist/client/assets/kiro.index-OYgAdtZd.js +1 -0
- package/apps/ui/dist/client/assets/opencode-sessions._sessionId-DLjiTst-.js +1 -0
- package/apps/ui/dist/client/assets/opencode-sessions._sessionId-biBwrRbt.js +8 -0
- package/apps/ui/dist/client/assets/opencode._workspaceKey-C7OIzMOJ.js +1 -0
- package/apps/ui/dist/client/assets/opencode._workspaceKey-sBakX0oI.js +1 -0
- package/apps/ui/dist/client/assets/opencode.index-Bl_kNs9N.js +1 -0
- package/apps/ui/dist/client/assets/opencode.index-CN53bVmb.js +1 -0
- package/apps/ui/dist/client/assets/preload-helper-B8fFrdxC.js +1 -0
- package/apps/ui/dist/client/assets/projects._project-D8WloxQN.js +1 -0
- package/apps/ui/dist/client/assets/projects.index-5xRtuJdX.js +3 -0
- package/apps/ui/dist/client/assets/routes-DnzF_9CX.js +1 -0
- package/apps/ui/dist/client/assets/select-CYF6pF37.js +1 -0
- package/apps/ui/dist/client/assets/settings-Dx70jgP_.js +1 -0
- package/apps/ui/dist/client/assets/styles-B7Zi9EFA.css +1 -0
- package/apps/ui/dist/client/assets/tabs-CmuhkT-c.js +7 -0
- package/apps/ui/dist/client/assets/thread-transcript-stats-BUNz6u7F.js +1 -0
- package/apps/ui/dist/client/assets/threads._threadId-BMRSFow3.js +1 -0
- package/apps/ui/dist/client/assets/useMutation-BSFult2i.js +1 -0
- package/apps/ui/dist/client/assets/useQuery-CjINKZf1.js +1 -0
- package/apps/ui/dist/client/icon.svg +2 -1
- package/apps/ui/dist/server/assets/_tanstack-start-manifest_v-CQ8Jjs3B.js +387 -0
- package/apps/ui/dist/server/assets/{antigravity-conversations._conversationId-BtexWY-K.js → antigravity-conversations._conversationId-BKOyL2T6.js} +2 -2
- package/apps/ui/dist/server/assets/{antigravity-conversations._conversationId-zMrR6v6R.js → antigravity-conversations._conversationId-eS87Dx7g.js} +1 -1
- package/apps/ui/dist/server/assets/claude-code-db-Ik3VStKZ.js +361 -0
- package/apps/ui/dist/server/assets/claude-code-queries-Cgzi4K-e.js +37 -0
- package/apps/ui/dist/server/assets/claude-code-server-PfraClXS.js +72 -0
- package/apps/ui/dist/server/assets/claude-code-sessions._sessionId-C55oe6zj.js +18 -0
- package/apps/ui/dist/server/assets/claude-code-sessions._sessionId-D1RYYi3j.js +473 -0
- package/apps/ui/dist/server/assets/claude-code-sessions._sessionId-DSvPLEUL.js +11 -0
- package/apps/ui/dist/server/assets/claude-code-transcript-C-bxh3cS.js +139 -0
- package/apps/ui/dist/server/assets/claude-code-transcript-phase-DmUMc8VU.js +10 -0
- package/apps/ui/dist/server/assets/claude-code._workspaceKey-B5Xg_-tE.js +28 -0
- package/apps/ui/dist/server/assets/claude-code._workspaceKey-BPlzyXPa.js +11 -0
- package/apps/ui/dist/server/assets/claude-code._workspaceKey-DqDve2wl.js +191 -0
- package/apps/ui/dist/server/assets/claude-code.index-B7yYR7dD.js +92 -0
- package/apps/ui/dist/server/assets/claude-code.index-BUHThG1W.js +11 -0
- package/apps/ui/dist/server/assets/{codex-server-CNXSJuc2.js → codex-server-CGXU4H8-.js} +319 -29
- package/apps/ui/dist/server/assets/{cursor-db-cYZEU3WQ.js → cursor-db-CZnYy7aT.js} +3 -3
- package/apps/ui/dist/server/assets/{cursor-recovery-nq-kR62j.js → cursor-recovery-CXpO8KcD.js} +2 -2
- package/apps/ui/dist/server/assets/{cursor-server-C3q7hrp-.js → cursor-server-DNu52A3K.js} +13 -13
- package/apps/ui/dist/server/assets/{cursor-threads._composerId-BkMMTQ3v.js → cursor-threads._composerId-Ckn6ItHI.js} +3 -3
- package/apps/ui/dist/server/assets/{cursor-threads._composerId-BPJFWfJj.js → cursor-threads._composerId-p9-ARAzc.js} +1 -1
- package/apps/ui/dist/server/assets/{cursor-transcript-2iL3KFSK.js → cursor-transcript-B7tGnqtn.js} +1 -1
- package/apps/ui/dist/server/assets/{cursor._workspaceKey-C5PdTaKB.js → cursor._workspaceKey-CZuohIUL.js} +1 -1
- package/apps/ui/dist/server/assets/{cursor._workspaceKey-Ckj7apKI.js → cursor._workspaceKey-DPp5JSjy.js} +2 -2
- package/apps/ui/dist/server/assets/{export-dialog-BItjWgkZ.js → export-dialog-D88ze9Gy.js} +2 -2
- package/apps/ui/dist/server/assets/kiro-db--fXrED_-.js +552 -0
- package/apps/ui/dist/server/assets/kiro-queries-CzNlM2ok.js +37 -0
- package/apps/ui/dist/server/assets/kiro-server-9WRxg2Au.js +72 -0
- package/apps/ui/dist/server/assets/kiro-sessions._sessionId-CRY2c7YO.js +11 -0
- package/apps/ui/dist/server/assets/kiro-sessions._sessionId-F1UlwxmR.js +449 -0
- package/apps/ui/dist/server/assets/kiro-sessions._sessionId-bvTulT7C.js +18 -0
- package/apps/ui/dist/server/assets/kiro-transcript-DoekQBaH.js +112 -0
- package/apps/ui/dist/server/assets/kiro-transcript-phase-CJG40nQg.js +27 -0
- package/apps/ui/dist/server/assets/kiro._workspaceKey-BDe9sQwo.js +11 -0
- package/apps/ui/dist/server/assets/kiro._workspaceKey-CJsjgNwO.js +28 -0
- package/apps/ui/dist/server/assets/kiro._workspaceKey-D_-4Qb7y.js +193 -0
- package/apps/ui/dist/server/assets/kiro.index-C__-UROk.js +11 -0
- package/apps/ui/dist/server/assets/kiro.index-CmTbqeYj.js +93 -0
- package/apps/ui/dist/server/assets/opencode-db-BM7KjOzc.js +397 -0
- package/apps/ui/dist/server/assets/opencode-queries-BeNYXnQv.js +50 -0
- package/apps/ui/dist/server/assets/opencode-server-BpQ_kRze.js +72 -0
- package/apps/ui/dist/server/assets/opencode-sessions._sessionId-CGQ-t0vD.js +518 -0
- package/apps/ui/dist/server/assets/opencode-sessions._sessionId-D8Q7in_Z.js +18 -0
- package/apps/ui/dist/server/assets/opencode-sessions._sessionId-DKOvi0lV.js +11 -0
- package/apps/ui/dist/server/assets/opencode-think-tags-CAoD-EcZ.js +87 -0
- package/apps/ui/dist/server/assets/opencode-transcript-BNTcGNym.js +141 -0
- package/apps/ui/dist/server/assets/opencode-transcript-phase-OqLkiQD0.js +32 -0
- package/apps/ui/dist/server/assets/opencode._workspaceKey-BdqcWHw1.js +11 -0
- package/apps/ui/dist/server/assets/opencode._workspaceKey-CfH96HTT.js +28 -0
- package/apps/ui/dist/server/assets/opencode._workspaceKey-DdbHPDrO.js +207 -0
- package/apps/ui/dist/server/assets/opencode.index-BbVzkJXP.js +11 -0
- package/apps/ui/dist/server/assets/opencode.index-Vh_Gq_1L.js +93 -0
- package/apps/ui/dist/server/assets/{projects._project-Bpbc3C-L.js → projects._project-4io5LO0E.js} +1 -1
- package/apps/ui/dist/server/assets/{projects._project-CvZho6EQ.js → projects._project-D6ZoGhJ8.js} +2 -2
- package/apps/ui/dist/server/assets/{router-6m-ihwqA.js → router-Sac2DGk6.js} +157 -49
- package/apps/ui/dist/server/assets/{shared-CPRNYIql.js → shared-DyhChtHf.js} +4 -1
- package/apps/ui/dist/server/assets/source-session-export-server-DNutCawb.js +38 -0
- package/apps/ui/dist/server/assets/{start-CI_0bSiY.js → start-B_HFwkkk.js} +1 -1
- package/apps/ui/dist/server/assets/{tabs-CGA13IZM.js → tabs-DkaChNVg.js} +0 -1
- package/apps/ui/dist/server/assets/thread-transcript-stats-Dh34mt2u.js +45 -0
- package/apps/ui/dist/server/assets/{threads._threadId-D2GYkVn6.js → threads._threadId-BeXEc4Lo.js} +15 -6
- package/apps/ui/dist/server/assets/{threads._threadId-Bs0yuqO9.js → threads._threadId-Ci0S4mKU.js} +1 -1
- package/apps/ui/dist/server/server.js +72 -24
- package/package.json +21 -4
- package/src/lib/claude-code-db.ts +655 -0
- package/src/lib/claude-code-exporter-types.ts +110 -0
- package/src/lib/claude-code-transcript-phase.ts +25 -0
- package/src/lib/claude-code-transcript.ts +180 -0
- package/src/lib/codex-browser-db.ts +490 -31
- package/src/lib/codex-browser-export.ts +18 -2
- package/src/lib/codex-thread-cache.ts +17 -1
- package/src/lib/concurrency.ts +25 -0
- package/src/lib/kiro-db.ts +949 -0
- package/src/lib/kiro-exporter-types.ts +100 -0
- package/src/lib/kiro-transcript-phase.ts +41 -0
- package/src/lib/kiro-transcript.ts +115 -0
- package/src/lib/opencode-db.ts +610 -0
- package/src/lib/opencode-exporter-types.ts +129 -0
- package/src/lib/opencode-think-tags.ts +126 -0
- package/src/lib/opencode-transcript-phase.ts +50 -0
- package/src/lib/opencode-transcript.ts +194 -0
- package/src/lib/shared.ts +25 -0
- package/src/lib/ui-export-archive.ts +61 -0
- package/apps/ui/dist/client/assets/analytics-DK2jdvmI.js +0 -1
- package/apps/ui/dist/client/assets/antigravity-keychain-panel-BRHVjFAM.js +0 -1
- package/apps/ui/dist/client/assets/antigravity._workspaceKey-CGV7amas.js +0 -1
- package/apps/ui/dist/client/assets/createServerFn-CgRRVpBH.js +0 -3
- package/apps/ui/dist/client/assets/cursor-threads._composerId-Ti2gTm63.js +0 -1
- package/apps/ui/dist/client/assets/cursor._workspaceKey-DzD_c6j9.js +0 -1
- package/apps/ui/dist/client/assets/cursor.index-PkCFVcl4.js +0 -2
- package/apps/ui/dist/client/assets/delete-confirm-dialog-BHRmyLHr.js +0 -11
- package/apps/ui/dist/client/assets/dropdown-menu-Dy5cLzTy.js +0 -1
- package/apps/ui/dist/client/assets/export-dialog-C86SYHJn.js +0 -1
- package/apps/ui/dist/client/assets/index-CPvAP-jk.js +0 -149
- package/apps/ui/dist/client/assets/projects._project-Ckf6muWZ.js +0 -1
- package/apps/ui/dist/client/assets/projects.index-V5ibNZII.js +0 -3
- package/apps/ui/dist/client/assets/routes-Df2tgpyd.js +0 -1
- package/apps/ui/dist/client/assets/select-Bf2GwfPR.js +0 -1
- package/apps/ui/dist/client/assets/settings-5VQIzME0.js +0 -1
- package/apps/ui/dist/client/assets/styles-BhRkXgwB.css +0 -1
- package/apps/ui/dist/client/assets/tabs-OO4VU5KR.js +0 -7
- package/apps/ui/dist/client/assets/threads._threadId-BgDhFj2I.js +0 -1
- package/apps/ui/dist/client/assets/useMutation-CC_B7uy5.js +0 -1
- package/apps/ui/dist/client/assets/useQuery-C5By6WKU.js +0 -1
- package/apps/ui/dist/server/assets/_tanstack-start-manifest_v-CRW2kqj0.js +0 -232
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { t as Button } from "./button-CmTDnzOn.js";
|
|
2
|
+
import { i as exportOpenCodeSessionFn, t as openCodeSessionDetailQueryOptions } from "./opencode-queries-BeNYXnQv.js";
|
|
3
|
+
import { t as Route } from "./opencode-sessions._sessionId-D8Q7in_Z.js";
|
|
4
|
+
import { t as Checkbox } from "./checkbox-C0hovF41.js";
|
|
5
|
+
import { t as MetricCard } from "./metric-card-ByEeLu0r.js";
|
|
6
|
+
import { t as PageHeader } from "./page-header-VNSaM3xd.js";
|
|
7
|
+
import { i as formatList, o as formatNumber, r as formatDateTime, s as formatTokens } from "./formatters-FJaGZgJk.js";
|
|
8
|
+
import { a as TranscriptView, c as Breadcrumbs, i as TabsTrigger, n as TabsContent, o as MetadataSection, r as TabsList, s as JsonPanel, t as Tabs } from "./tabs-DkaChNVg.js";
|
|
9
|
+
import { n as downloadUrlFile, t as downloadTextFile } from "./download-DMmiy1xf.js";
|
|
10
|
+
import { t as ExportDialog } from "./export-dialog-D88ze9Gy.js";
|
|
11
|
+
import { t as getThreadTranscriptStats } from "./thread-transcript-stats-Dh34mt2u.js";
|
|
12
|
+
import { t as splitOpenCodeThinkTaggedText } from "./opencode-think-tags-CAoD-EcZ.js";
|
|
13
|
+
import { n as getOpenCodeTextPartPhase, t as getFinalOpenCodeAssistantTextPartIds } from "./opencode-transcript-phase-OqLkiQD0.js";
|
|
14
|
+
import { useMemo, useState } from "react";
|
|
15
|
+
import { Link } from "@tanstack/react-router";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { useMutation, useSuspenseQuery } from "@tanstack/react-query";
|
|
18
|
+
import { Download } from "lucide-react";
|
|
19
|
+
//#region src/lib/opencode-transcript-events.ts
|
|
20
|
+
var toTimestamp = (value) => {
|
|
21
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return null;
|
|
22
|
+
return new Date(value).toISOString();
|
|
23
|
+
};
|
|
24
|
+
var buildRaw = (part, eventType) => ({
|
|
25
|
+
eventType,
|
|
26
|
+
messageId: part.messageId,
|
|
27
|
+
partId: part.partId,
|
|
28
|
+
role: part.role,
|
|
29
|
+
source: "opencode_part",
|
|
30
|
+
type: part.type,
|
|
31
|
+
...part.raw
|
|
32
|
+
});
|
|
33
|
+
var buildMessageEvent = (part, sequence, text, phase) => ({
|
|
34
|
+
isHiddenByDefault: part.role !== "assistant" && part.role !== "user",
|
|
35
|
+
kind: "message",
|
|
36
|
+
memoryCitation: null,
|
|
37
|
+
model: null,
|
|
38
|
+
phase,
|
|
39
|
+
raw: buildRaw(part, "message"),
|
|
40
|
+
role: part.role,
|
|
41
|
+
sequence,
|
|
42
|
+
text,
|
|
43
|
+
timestamp: toTimestamp(part.createdAtMs),
|
|
44
|
+
variant: part.role === "user" ? "user_message" : part.role === "assistant" ? "agent_message" : "message"
|
|
45
|
+
});
|
|
46
|
+
var buildReasoningEventFromText = (part, sequence, textValue) => {
|
|
47
|
+
const text = textValue?.trim();
|
|
48
|
+
if (!text) return null;
|
|
49
|
+
return {
|
|
50
|
+
content: text,
|
|
51
|
+
hasEncryptedContent: false,
|
|
52
|
+
kind: "reasoning",
|
|
53
|
+
raw: buildRaw(part, "reasoning"),
|
|
54
|
+
sequence,
|
|
55
|
+
summary: [text],
|
|
56
|
+
timestamp: toTimestamp(part.createdAtMs)
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
var buildReasoningEvent = (part, sequence) => {
|
|
60
|
+
const { reasoningBlocks, visibleText } = splitOpenCodeThinkTaggedText(part.text ?? "");
|
|
61
|
+
return buildReasoningEventFromText(part, sequence, [...reasoningBlocks, visibleText].filter(Boolean).join("\n\n"));
|
|
62
|
+
};
|
|
63
|
+
var buildToolCallCommand = (part) => {
|
|
64
|
+
const toolName = part.toolName ?? "unknown";
|
|
65
|
+
if (!part.argumentsText?.trim()) return toolName;
|
|
66
|
+
return `${toolName}\n${part.argumentsText}`;
|
|
67
|
+
};
|
|
68
|
+
var buildToolCallEvent = (part, sequence) => ({
|
|
69
|
+
argumentsParseFailed: false,
|
|
70
|
+
argumentsText: part.argumentsText ?? null,
|
|
71
|
+
callId: part.callId ?? null,
|
|
72
|
+
command: buildToolCallCommand(part),
|
|
73
|
+
kind: "tool_call",
|
|
74
|
+
name: part.toolName ?? "unknown",
|
|
75
|
+
raw: buildRaw(part, "tool_call"),
|
|
76
|
+
sequence,
|
|
77
|
+
timestamp: toTimestamp(part.createdAtMs),
|
|
78
|
+
workdir: null
|
|
79
|
+
});
|
|
80
|
+
var buildToolOutputEvent = (part, sequence) => {
|
|
81
|
+
const outputText = part.outputText?.trim();
|
|
82
|
+
if (!outputText) return null;
|
|
83
|
+
return {
|
|
84
|
+
callId: part.callId ?? null,
|
|
85
|
+
exitCode: null,
|
|
86
|
+
kind: "tool_output",
|
|
87
|
+
outputText,
|
|
88
|
+
raw: buildRaw(part, "tool_output"),
|
|
89
|
+
sequence,
|
|
90
|
+
summary: outputText,
|
|
91
|
+
timestamp: toTimestamp(part.createdAtMs),
|
|
92
|
+
wallTime: null
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var buildStepStartedEvent = (part, sequence) => ({
|
|
96
|
+
collaborationModeKind: null,
|
|
97
|
+
kind: "task_started",
|
|
98
|
+
modelContextWindow: null,
|
|
99
|
+
raw: buildRaw(part, "step_start"),
|
|
100
|
+
sequence,
|
|
101
|
+
startedAt: part.startTimeMs ?? part.createdAtMs,
|
|
102
|
+
timestamp: toTimestamp(part.createdAtMs),
|
|
103
|
+
turnId: part.messageId
|
|
104
|
+
});
|
|
105
|
+
var buildStepCompleteEvent = (part, sequence) => ({
|
|
106
|
+
completedAt: part.endTimeMs ?? part.updatedAtMs,
|
|
107
|
+
durationMs: part.startTimeMs && part.endTimeMs ? part.endTimeMs - part.startTimeMs : null,
|
|
108
|
+
kind: "task_complete",
|
|
109
|
+
lastAgentMessage: part.reason ?? null,
|
|
110
|
+
raw: buildRaw(part, "step_finish"),
|
|
111
|
+
sequence,
|
|
112
|
+
timestamp: toTimestamp(part.updatedAtMs),
|
|
113
|
+
timeToFirstTokenMs: null,
|
|
114
|
+
turnId: part.messageId
|
|
115
|
+
});
|
|
116
|
+
var flattenParts = (transcript) => {
|
|
117
|
+
return transcript.messages.flatMap((message) => message.parts);
|
|
118
|
+
};
|
|
119
|
+
var textPartToEvents = (part, sequence, finalAssistantTextPartIds) => {
|
|
120
|
+
const { reasoningBlocks, visibleText } = part.role === "assistant" ? splitOpenCodeThinkTaggedText(part.text ?? "") : {
|
|
121
|
+
reasoningBlocks: [],
|
|
122
|
+
visibleText: part.text ?? ""
|
|
123
|
+
};
|
|
124
|
+
const events = [];
|
|
125
|
+
if (part.role === "assistant") events.push(...reasoningBlocks.map((block, index) => buildReasoningEventFromText(part, sequence + index, block)).filter((event) => event !== null));
|
|
126
|
+
const text = visibleText.trim();
|
|
127
|
+
if (!text) return events;
|
|
128
|
+
const messageSequence = sequence + events.length;
|
|
129
|
+
const phase = getOpenCodeTextPartPhase(part, finalAssistantTextPartIds);
|
|
130
|
+
events.push(buildMessageEvent(part, messageSequence, text, phase));
|
|
131
|
+
return events;
|
|
132
|
+
};
|
|
133
|
+
var toolPartToEvents = (part, sequence) => {
|
|
134
|
+
const output = buildToolOutputEvent(part, sequence + 1);
|
|
135
|
+
return [buildToolCallEvent(part, sequence), output].filter((event) => event !== null);
|
|
136
|
+
};
|
|
137
|
+
var partToEvents = (part, sequence, finalAssistantTextPartIds) => {
|
|
138
|
+
if (part.type === "text") return textPartToEvents(part, sequence, finalAssistantTextPartIds);
|
|
139
|
+
if (part.type === "reasoning") {
|
|
140
|
+
const event = buildReasoningEvent(part, sequence);
|
|
141
|
+
return event ? [event] : [];
|
|
142
|
+
}
|
|
143
|
+
if (part.type === "tool") return toolPartToEvents(part, sequence);
|
|
144
|
+
if (part.type === "step-start") return [buildStepStartedEvent(part, sequence)];
|
|
145
|
+
if (part.type === "step-finish") return [buildStepCompleteEvent(part, sequence)];
|
|
146
|
+
return [];
|
|
147
|
+
};
|
|
148
|
+
var openCodeTranscriptToThreadEvents = (transcript) => {
|
|
149
|
+
const parts = flattenParts(transcript);
|
|
150
|
+
const finalAssistantTextPartIds = getFinalOpenCodeAssistantTextPartIds(parts);
|
|
151
|
+
const events = [];
|
|
152
|
+
let sequence = 0;
|
|
153
|
+
for (const part of parts) {
|
|
154
|
+
const partEvents = partToEvents(part, sequence, finalAssistantTextPartIds);
|
|
155
|
+
events.push(...partEvents);
|
|
156
|
+
sequence += Math.max(partEvents.length, 1);
|
|
157
|
+
}
|
|
158
|
+
return events;
|
|
159
|
+
};
|
|
160
|
+
var getOpenCodeThreadTranscriptStats = (events) => {
|
|
161
|
+
return getThreadTranscriptStats(events);
|
|
162
|
+
};
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/routes/opencode-sessions.$sessionId.tsx?tsr-split=component
|
|
165
|
+
var buildSessionMetadata = (detail) => [
|
|
166
|
+
{
|
|
167
|
+
label: "Session ID",
|
|
168
|
+
value: /* @__PURE__ */ jsx("span", {
|
|
169
|
+
"data-mono": "true",
|
|
170
|
+
children: detail.session.sessionId
|
|
171
|
+
})
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: "Workspace",
|
|
175
|
+
value: /* @__PURE__ */ jsx(Link, {
|
|
176
|
+
className: "text-[var(--accent)]",
|
|
177
|
+
params: { workspaceKey: detail.session.workspaceKey },
|
|
178
|
+
to: "/opencode/$workspaceKey",
|
|
179
|
+
children: detail.session.workspaceLabel
|
|
180
|
+
})
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
label: "Worktree",
|
|
184
|
+
value: detail.session.worktree
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: "Directory",
|
|
188
|
+
value: detail.session.directory
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: "Slug",
|
|
192
|
+
value: detail.session.slug
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: "Agent",
|
|
196
|
+
value: detail.session.agent ?? "unknown"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
label: "Model",
|
|
200
|
+
value: detail.session.modelLabel ?? "unknown"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
label: "Created",
|
|
204
|
+
value: /* @__PURE__ */ jsx("span", {
|
|
205
|
+
suppressHydrationWarning: true,
|
|
206
|
+
children: formatDateTime(detail.session.createdAtMs)
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
label: "Updated",
|
|
211
|
+
value: /* @__PURE__ */ jsx("span", {
|
|
212
|
+
suppressHydrationWarning: true,
|
|
213
|
+
children: formatDateTime(detail.session.lastUpdatedAtMs)
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
label: "Archived",
|
|
218
|
+
value: /* @__PURE__ */ jsx("span", {
|
|
219
|
+
suppressHydrationWarning: true,
|
|
220
|
+
children: formatDateTime(detail.session.archivedAtMs)
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
var buildTranscriptStatsItems = (detail, events, stats) => [
|
|
225
|
+
{
|
|
226
|
+
label: "Event kinds",
|
|
227
|
+
value: formatList([...new Set(events.map((event) => event.kind))])
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
label: "Messages",
|
|
231
|
+
value: formatNumber(stats.messageCount)
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: "User messages",
|
|
235
|
+
value: formatNumber(stats.userMessageCount)
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
label: "Assistant messages",
|
|
239
|
+
value: formatNumber(stats.assistantMessageCount)
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
label: "Reasoning events",
|
|
243
|
+
value: formatNumber(events.filter((event) => event.kind === "reasoning").length)
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
label: "Final answers",
|
|
247
|
+
value: formatNumber(stats.finalAnswerCount)
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
label: "Tool calls",
|
|
251
|
+
value: formatNumber(stats.toolCallCount)
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
label: "Tool outputs",
|
|
255
|
+
value: formatNumber(stats.toolOutputCount)
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
label: "Renderable parts",
|
|
259
|
+
value: formatNumber(detail.renderablePartCount)
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
var OpenCodeTranscriptControls = ({ rawJsonDisabled = false, showCommentary, showExtraEvents, showRawJson, showToolCalls, showUserMessages, onShowCommentaryChange, onShowExtraEventsChange, onShowRawJsonChange, onShowToolCallsChange, onShowUserMessagesChange }) => {
|
|
263
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
264
|
+
className: "flex flex-wrap gap-4 rounded-xl border border-[var(--border)] bg-[var(--panel)] px-4 py-3 shadow-[var(--panel-shadow)]",
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsxs("div", {
|
|
267
|
+
className: "flex items-center gap-2 text-sm",
|
|
268
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
269
|
+
checked: showToolCalls,
|
|
270
|
+
id: "opencode-transcript-show-tool-calls",
|
|
271
|
+
onCheckedChange: (checked) => onShowToolCallsChange(checked === true)
|
|
272
|
+
}), /* @__PURE__ */ jsx("label", {
|
|
273
|
+
htmlFor: "opencode-transcript-show-tool-calls",
|
|
274
|
+
children: "Show tool calls"
|
|
275
|
+
})]
|
|
276
|
+
}),
|
|
277
|
+
/* @__PURE__ */ jsxs("div", {
|
|
278
|
+
className: "flex items-center gap-2 text-sm",
|
|
279
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
280
|
+
checked: showCommentary,
|
|
281
|
+
id: "opencode-transcript-show-commentary",
|
|
282
|
+
onCheckedChange: (checked) => onShowCommentaryChange(checked === true)
|
|
283
|
+
}), /* @__PURE__ */ jsx("label", {
|
|
284
|
+
htmlFor: "opencode-transcript-show-commentary",
|
|
285
|
+
children: "Show commentary"
|
|
286
|
+
})]
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ jsxs("div", {
|
|
289
|
+
className: "flex items-center gap-2 text-sm",
|
|
290
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
291
|
+
checked: showExtraEvents,
|
|
292
|
+
id: "opencode-transcript-show-extra-events",
|
|
293
|
+
onCheckedChange: (checked) => onShowExtraEventsChange(checked === true)
|
|
294
|
+
}), /* @__PURE__ */ jsx("label", {
|
|
295
|
+
htmlFor: "opencode-transcript-show-extra-events",
|
|
296
|
+
children: "Show extra events"
|
|
297
|
+
})]
|
|
298
|
+
}),
|
|
299
|
+
/* @__PURE__ */ jsxs("div", {
|
|
300
|
+
className: "flex items-center gap-2 text-sm",
|
|
301
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
302
|
+
checked: showRawJson,
|
|
303
|
+
disabled: rawJsonDisabled,
|
|
304
|
+
id: "opencode-transcript-show-raw-json",
|
|
305
|
+
onCheckedChange: (checked) => onShowRawJsonChange(checked === true)
|
|
306
|
+
}), /* @__PURE__ */ jsx("label", {
|
|
307
|
+
htmlFor: "opencode-transcript-show-raw-json",
|
|
308
|
+
children: "Raw JSON"
|
|
309
|
+
})]
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsxs("div", {
|
|
312
|
+
className: "flex items-center gap-2 text-sm",
|
|
313
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
314
|
+
checked: showUserMessages,
|
|
315
|
+
id: "opencode-transcript-show-user-messages",
|
|
316
|
+
onCheckedChange: (checked) => onShowUserMessagesChange(checked === true)
|
|
317
|
+
}), /* @__PURE__ */ jsx("label", {
|
|
318
|
+
htmlFor: "opencode-transcript-show-user-messages",
|
|
319
|
+
children: "User"
|
|
320
|
+
})]
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
var OpenCodeRawPanels = ({ detail, events }) => {
|
|
326
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
327
|
+
className: "space-y-4",
|
|
328
|
+
children: [
|
|
329
|
+
/* @__PURE__ */ jsx(JsonPanel, {
|
|
330
|
+
title: "Session summary",
|
|
331
|
+
value: detail.session
|
|
332
|
+
}),
|
|
333
|
+
/* @__PURE__ */ jsx(JsonPanel, {
|
|
334
|
+
title: "OpenCode messages",
|
|
335
|
+
value: detail.messages
|
|
336
|
+
}),
|
|
337
|
+
/* @__PURE__ */ jsx(JsonPanel, {
|
|
338
|
+
title: "Transcript events",
|
|
339
|
+
value: events
|
|
340
|
+
})
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
var OpenCodeSessionDetailPage = () => {
|
|
345
|
+
const detail = useSuspenseQuery(openCodeSessionDetailQueryOptions(Route.useParams().sessionId)).data;
|
|
346
|
+
const [pendingExport, setPendingExport] = useState(false);
|
|
347
|
+
const [showToolCalls, setShowToolCalls] = useState(false);
|
|
348
|
+
const [showCommentary, setShowCommentary] = useState(false);
|
|
349
|
+
const [showExtraEvents, setShowExtraEvents] = useState(false);
|
|
350
|
+
const [showRawJson, setShowRawJson] = useState(false);
|
|
351
|
+
const [showUserMessages, setShowUserMessages] = useState(true);
|
|
352
|
+
const transcriptEvents = useMemo(() => openCodeTranscriptToThreadEvents(detail), [detail]);
|
|
353
|
+
const transcriptStats = useMemo(() => getOpenCodeThreadTranscriptStats(transcriptEvents), [transcriptEvents]);
|
|
354
|
+
const exportSessionMutation = useMutation({
|
|
355
|
+
mutationFn: async (options) => {
|
|
356
|
+
const download = await exportOpenCodeSessionFn({ data: {
|
|
357
|
+
includeCommentary: options.includeCommentary,
|
|
358
|
+
includeMetadata: options.includeMetadata,
|
|
359
|
+
includeTools: options.includeTools,
|
|
360
|
+
outputFormat: options.outputFormat,
|
|
361
|
+
sessionId: detail.session.sessionId,
|
|
362
|
+
zipArchive: options.zipArchive
|
|
363
|
+
} });
|
|
364
|
+
if (download.mode === "download") {
|
|
365
|
+
downloadTextFile(download.fileName, download.content, download.mimeType);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
await downloadUrlFile(download.fileName, download.downloadUrl);
|
|
369
|
+
},
|
|
370
|
+
onSuccess: () => {
|
|
371
|
+
setPendingExport(false);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
375
|
+
className: "space-y-6",
|
|
376
|
+
children: [
|
|
377
|
+
/* @__PURE__ */ jsx(PageHeader, {
|
|
378
|
+
actions: /* @__PURE__ */ jsxs(Button, {
|
|
379
|
+
className: "rounded-full",
|
|
380
|
+
type: "button",
|
|
381
|
+
variant: "outline",
|
|
382
|
+
onClick: () => setPendingExport(true),
|
|
383
|
+
children: [/* @__PURE__ */ jsx(Download, { className: "mr-2 size-4" }), "Export"]
|
|
384
|
+
}),
|
|
385
|
+
breadcrumb: /* @__PURE__ */ jsx(Breadcrumbs, { items: [
|
|
386
|
+
{
|
|
387
|
+
label: "OpenCode",
|
|
388
|
+
to: "/opencode"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
label: detail.session.workspaceLabel,
|
|
392
|
+
params: { workspaceKey: detail.session.workspaceKey },
|
|
393
|
+
to: "/opencode/$workspaceKey"
|
|
394
|
+
},
|
|
395
|
+
{ label: detail.session.title }
|
|
396
|
+
] }),
|
|
397
|
+
eyebrow: "OpenCode session",
|
|
398
|
+
subtitle: "Session detail for the selected OpenCode project conversation.",
|
|
399
|
+
title: detail.session.title
|
|
400
|
+
}),
|
|
401
|
+
/* @__PURE__ */ jsxs("div", {
|
|
402
|
+
className: "grid gap-3 md:grid-cols-2 xl:grid-cols-4",
|
|
403
|
+
children: [
|
|
404
|
+
/* @__PURE__ */ jsx(MetricCard, {
|
|
405
|
+
label: "Messages",
|
|
406
|
+
value: formatNumber(detail.session.messageCount)
|
|
407
|
+
}),
|
|
408
|
+
/* @__PURE__ */ jsx(MetricCard, {
|
|
409
|
+
label: "Parts",
|
|
410
|
+
value: formatNumber(detail.partCount)
|
|
411
|
+
}),
|
|
412
|
+
/* @__PURE__ */ jsx(MetricCard, {
|
|
413
|
+
label: "Tool calls",
|
|
414
|
+
value: formatNumber(detail.session.toolPartCount)
|
|
415
|
+
}),
|
|
416
|
+
/* @__PURE__ */ jsx(MetricCard, {
|
|
417
|
+
label: "Tokens",
|
|
418
|
+
value: formatTokens(detail.session.totalTokens)
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ jsxs(Tabs, {
|
|
423
|
+
className: "space-y-4",
|
|
424
|
+
defaultValue: "transcript",
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ jsxs(TabsList, {
|
|
427
|
+
className: "grid w-fit min-w-[24rem] grid-cols-3 rounded-full border border-[var(--border)] bg-[var(--panel)] p-1",
|
|
428
|
+
children: [
|
|
429
|
+
/* @__PURE__ */ jsx(TabsTrigger, {
|
|
430
|
+
className: "rounded-full px-5 text-sm",
|
|
431
|
+
value: "transcript",
|
|
432
|
+
children: "Transcript"
|
|
433
|
+
}),
|
|
434
|
+
/* @__PURE__ */ jsx(TabsTrigger, {
|
|
435
|
+
className: "rounded-full px-5 text-sm",
|
|
436
|
+
value: "metadata",
|
|
437
|
+
children: "Metadata"
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsx(TabsTrigger, {
|
|
440
|
+
className: "rounded-full px-5 text-sm",
|
|
441
|
+
value: "raw",
|
|
442
|
+
children: "Raw"
|
|
443
|
+
})
|
|
444
|
+
]
|
|
445
|
+
}),
|
|
446
|
+
/* @__PURE__ */ jsxs(TabsContent, {
|
|
447
|
+
className: "space-y-3",
|
|
448
|
+
value: "transcript",
|
|
449
|
+
children: [/* @__PURE__ */ jsx(OpenCodeTranscriptControls, {
|
|
450
|
+
rawJsonDisabled: transcriptEvents.length === 0,
|
|
451
|
+
showCommentary,
|
|
452
|
+
showExtraEvents,
|
|
453
|
+
showRawJson,
|
|
454
|
+
showToolCalls,
|
|
455
|
+
showUserMessages,
|
|
456
|
+
onShowCommentaryChange: setShowCommentary,
|
|
457
|
+
onShowExtraEventsChange: setShowExtraEvents,
|
|
458
|
+
onShowRawJsonChange: setShowRawJson,
|
|
459
|
+
onShowToolCallsChange: setShowToolCalls,
|
|
460
|
+
onShowUserMessagesChange: setShowUserMessages
|
|
461
|
+
}), transcriptEvents.length > 0 ? /* @__PURE__ */ jsx(TranscriptView, {
|
|
462
|
+
assistantModel: detail.session.modelLabel,
|
|
463
|
+
events: transcriptEvents,
|
|
464
|
+
projectPath: detail.session.worktree,
|
|
465
|
+
showCommentary,
|
|
466
|
+
showExtraEvents,
|
|
467
|
+
showRawJson,
|
|
468
|
+
showToolCalls,
|
|
469
|
+
showUserMessages
|
|
470
|
+
}) : /* @__PURE__ */ jsxs("section", {
|
|
471
|
+
className: "rounded-[1.6rem] border border-[var(--border)] bg-[var(--panel)] p-5 shadow-[var(--panel-shadow)]",
|
|
472
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
473
|
+
className: "font-semibold text-[var(--muted-foreground)] text-sm uppercase tracking-[0.18em]",
|
|
474
|
+
children: "Transcript"
|
|
475
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
476
|
+
className: "mt-4 text-[var(--muted-foreground)] text-sm",
|
|
477
|
+
children: "No renderable OpenCode transcript content was found for this session."
|
|
478
|
+
})]
|
|
479
|
+
})]
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsx(TabsContent, {
|
|
482
|
+
value: "metadata",
|
|
483
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
484
|
+
className: "grid gap-4 xl:grid-cols-[0.95fr_1.05fr]",
|
|
485
|
+
children: [/* @__PURE__ */ jsx(MetadataSection, {
|
|
486
|
+
items: buildSessionMetadata(detail),
|
|
487
|
+
title: "Session metadata"
|
|
488
|
+
}), /* @__PURE__ */ jsx(MetadataSection, {
|
|
489
|
+
items: buildTranscriptStatsItems(detail, transcriptEvents, transcriptStats),
|
|
490
|
+
title: "Transcript stats"
|
|
491
|
+
})]
|
|
492
|
+
})
|
|
493
|
+
}),
|
|
494
|
+
/* @__PURE__ */ jsx(TabsContent, {
|
|
495
|
+
value: "raw",
|
|
496
|
+
children: /* @__PURE__ */ jsx(OpenCodeRawPanels, {
|
|
497
|
+
detail,
|
|
498
|
+
events: transcriptEvents
|
|
499
|
+
})
|
|
500
|
+
})
|
|
501
|
+
]
|
|
502
|
+
}),
|
|
503
|
+
/* @__PURE__ */ jsx(ExportDialog, {
|
|
504
|
+
errorMessage: exportSessionMutation.isError ? exportSessionMutation.error instanceof Error ? exportSessionMutation.error.message : "Export failed" : null,
|
|
505
|
+
open: pendingExport,
|
|
506
|
+
pending: exportSessionMutation.isPending,
|
|
507
|
+
title: `Export ${detail.session.title}`,
|
|
508
|
+
onExport: (options) => exportSessionMutation.mutate(options),
|
|
509
|
+
onOpenChange: (open) => {
|
|
510
|
+
setPendingExport(open);
|
|
511
|
+
if (!open) exportSessionMutation.reset();
|
|
512
|
+
}
|
|
513
|
+
})
|
|
514
|
+
]
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
//#endregion
|
|
518
|
+
export { OpenCodeSessionDetailPage as component };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { t as openCodeSessionDetailQueryOptions } from "./opencode-queries-BeNYXnQv.js";
|
|
2
|
+
import { t as LoadingPanel } from "./loading-panel-BGFnWseS.js";
|
|
3
|
+
import { createFileRoute, lazyRouteComponent } from "@tanstack/react-router";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/routes/opencode-sessions.$sessionId.tsx
|
|
6
|
+
var $$splitErrorComponentImporter = () => import("./opencode-sessions._sessionId-DKOvi0lV.js");
|
|
7
|
+
var $$splitComponentImporter = () => import("./opencode-sessions._sessionId-CGQ-t0vD.js");
|
|
8
|
+
var Route = createFileRoute("/opencode-sessions/$sessionId")({
|
|
9
|
+
component: lazyRouteComponent($$splitComponentImporter, "component"),
|
|
10
|
+
errorComponent: lazyRouteComponent($$splitErrorComponentImporter, "errorComponent"),
|
|
11
|
+
loader: ({ context, params }) => context.queryClient.ensureQueryData(openCodeSessionDetailQueryOptions(params.sessionId)),
|
|
12
|
+
pendingComponent: () => /* @__PURE__ */ jsx(LoadingPanel, {
|
|
13
|
+
description: "Loading the OpenCode transcript, parts, and session metadata.",
|
|
14
|
+
title: "Loading session"
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Route as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as ReloadErrorPanel } from "./reload-error-panel-BJMxY3U1.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/routes/opencode-sessions.$sessionId.tsx?tsr-split=errorComponent
|
|
4
|
+
var OpenCodeSessionDetailErrorComponent = ({ error }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(ReloadErrorPanel, {
|
|
6
|
+
description: error.message,
|
|
7
|
+
title: "Failed to load OpenCode session"
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OpenCodeSessionDetailErrorComponent as errorComponent };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region ../../src/lib/opencode-think-tags.ts
|
|
2
|
+
var THINK_OPEN_PATTERN = /<think\b[^>]*>/iy;
|
|
3
|
+
var THINK_CLOSE_PATTERN = /<\/think>/gi;
|
|
4
|
+
var THINK_CLOSE_TAG_LENGTH = 8;
|
|
5
|
+
var normalizeExtractedText = (text) => {
|
|
6
|
+
return text.replace(/\n{3,}/g, "\n\n").trim();
|
|
7
|
+
};
|
|
8
|
+
var getBacktickRunLength = (text, start) => {
|
|
9
|
+
let end = start;
|
|
10
|
+
while (text[end] === "`") end += 1;
|
|
11
|
+
return end - start;
|
|
12
|
+
};
|
|
13
|
+
var findClosingBackticks = (text, start, runLength) => {
|
|
14
|
+
const marker = "`".repeat(runLength);
|
|
15
|
+
const index = text.indexOf(marker, start + runLength);
|
|
16
|
+
return index === -1 ? text.length : index + runLength;
|
|
17
|
+
};
|
|
18
|
+
var findThinkCloseIndex = (text, start) => {
|
|
19
|
+
THINK_CLOSE_PATTERN.lastIndex = start;
|
|
20
|
+
const match = THINK_CLOSE_PATTERN.exec(text);
|
|
21
|
+
return match ? match.index : -1;
|
|
22
|
+
};
|
|
23
|
+
var getLastVisibleChar = (parts) => {
|
|
24
|
+
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
25
|
+
const part = parts[index];
|
|
26
|
+
if (part) return part.at(-1) ?? "";
|
|
27
|
+
}
|
|
28
|
+
return "";
|
|
29
|
+
};
|
|
30
|
+
var getThinkReplacement = (previous, next) => {
|
|
31
|
+
if (previous === "\n" || next === "\n") return "\n";
|
|
32
|
+
if (previous && /\s/u.test(previous) || next && /\s/u.test(next)) return "";
|
|
33
|
+
return " ";
|
|
34
|
+
};
|
|
35
|
+
var shouldSkipFollowingSpace = (replacement, previous, next) => {
|
|
36
|
+
return (replacement === " " || Boolean(previous && /[^\S\n]/u.test(previous))) && /[^\S\n]/u.test(next);
|
|
37
|
+
};
|
|
38
|
+
var readThinkBlock = (text, cursor, visibleParts) => {
|
|
39
|
+
THINK_OPEN_PATTERN.lastIndex = cursor;
|
|
40
|
+
if (THINK_OPEN_PATTERN.exec(text)?.index !== cursor) return null;
|
|
41
|
+
const reasoningStart = THINK_OPEN_PATTERN.lastIndex;
|
|
42
|
+
const closeIndex = findThinkCloseIndex(text, reasoningStart);
|
|
43
|
+
const reasoningEnd = closeIndex === -1 ? text.length : closeIndex;
|
|
44
|
+
const normalizedReasoning = normalizeExtractedText(text.slice(reasoningStart, reasoningEnd));
|
|
45
|
+
let nextCursor = closeIndex === -1 ? text.length : closeIndex + THINK_CLOSE_TAG_LENGTH;
|
|
46
|
+
const previous = getLastVisibleChar(visibleParts);
|
|
47
|
+
const replacement = getThinkReplacement(previous, text[nextCursor] ?? "");
|
|
48
|
+
if (shouldSkipFollowingSpace(replacement, previous, text[nextCursor] ?? "")) nextCursor += 1;
|
|
49
|
+
return {
|
|
50
|
+
nextCursor,
|
|
51
|
+
reasoning: normalizedReasoning || null,
|
|
52
|
+
replacement
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* OpenCode can store MiniMax reasoning inline as <think> blocks. Preserve literal
|
|
57
|
+
* examples in Markdown code while extracting model-emitted tags as commentary.
|
|
58
|
+
*/
|
|
59
|
+
var splitOpenCodeThinkTaggedText = (text) => {
|
|
60
|
+
const reasoningBlocks = [];
|
|
61
|
+
const visibleParts = [];
|
|
62
|
+
let cursor = 0;
|
|
63
|
+
while (cursor < text.length) {
|
|
64
|
+
if (text[cursor] === "`") {
|
|
65
|
+
const runLength = getBacktickRunLength(text, cursor);
|
|
66
|
+
const end = findClosingBackticks(text, cursor, runLength);
|
|
67
|
+
visibleParts.push(text.slice(cursor, end));
|
|
68
|
+
cursor = end;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const thinkBlock = readThinkBlock(text, cursor, visibleParts);
|
|
72
|
+
if (thinkBlock) {
|
|
73
|
+
if (thinkBlock.reasoning) reasoningBlocks.push(thinkBlock.reasoning);
|
|
74
|
+
visibleParts.push(thinkBlock.replacement);
|
|
75
|
+
cursor = thinkBlock.nextCursor;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
visibleParts.push(text[cursor]);
|
|
79
|
+
cursor += 1;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
reasoningBlocks,
|
|
83
|
+
visibleText: normalizeExtractedText(visibleParts.join(""))
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { splitOpenCodeThinkTaggedText as t };
|