codesesh 1.0.9 → 1.0.10
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/README.md +3 -0
- package/dist/{chunk-MOZLVHCC.js → chunk-2LXZFMSH.js} +10 -2
- package/dist/{chunk-MOZLVHCC.js.map → chunk-2LXZFMSH.js.map} +1 -1
- package/dist/{chunk-5YY675UR.js → chunk-543OWZIC.js} +2 -2
- package/dist/{chunk-CIMPLUT6.js → chunk-56FKVL5K.js} +5 -5
- package/dist/{chunk-QFG33PKR.js → chunk-CYZ6OC6J.js} +2 -2
- package/dist/{chunk-RDTQ2WPR.js → chunk-DWY4HWVI.js} +2 -2
- package/dist/{chunk-ZLU7ODBV.js → chunk-R6QKSHPH.js} +2 -2
- package/dist/{chunk-ZDH2BKQK.js → chunk-WRVILHZR.js} +366 -25
- package/dist/chunk-WRVILHZR.js.map +1 -0
- package/dist/{discovery-MS2ZSMZ5.js → discovery-NTMSA6UE.js} +5 -5
- package/dist/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/project-identity-worker.js +4 -4
- package/dist/scan-refresh-worker.js +6 -6
- package/dist/search-index-worker.js +6 -6
- package/dist/session-detail-worker.js +6 -6
- package/dist/smart-tag-worker.js +3 -3
- package/dist/web/assets/{DetailLanding-Dgb2Qg8H.js → DetailLanding-D1FLK4EW.js} +1 -1
- package/dist/web/assets/{InteractiveReceipt-SckXLiPB.js → InteractiveReceipt-C7FJhzdv.js} +1 -1
- package/dist/web/assets/{OverviewScreen-D44AMeDu.js → OverviewScreen-DX7F_6dH.js} +1 -1
- package/dist/web/assets/{PrismHighlighter-D7JLjKja.js → PrismHighlighter-DZ2CWVc0.js} +1 -1
- package/dist/web/assets/{Projects-DVHOqH2Z.js → Projects-B_7w5TDw.js} +1 -1
- package/dist/web/assets/{SearchResultsPanel-B1WEw9Q5.js → SearchResultsPanel-BMBhKuPS.js} +1 -1
- package/dist/web/assets/SessionDetail-wJYzzF0i.js +53 -0
- package/dist/web/assets/{index-BIpTq_7T.js → index-DUcpWdzX.js} +2 -2
- package/dist/web/icon/agent/minimax-code.svg +1 -0
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-ZDH2BKQK.js.map +0 -1
- package/dist/web/assets/SessionDetail-J00I4QfE.js +0 -53
- /package/dist/{chunk-5YY675UR.js.map → chunk-543OWZIC.js.map} +0 -0
- /package/dist/{chunk-CIMPLUT6.js.map → chunk-56FKVL5K.js.map} +0 -0
- /package/dist/{chunk-QFG33PKR.js.map → chunk-CYZ6OC6J.js.map} +0 -0
- /package/dist/{chunk-RDTQ2WPR.js.map → chunk-DWY4HWVI.js.map} +0 -0
- /package/dist/{chunk-ZLU7ODBV.js.map → chunk-R6QKSHPH.js.map} +0 -0
- /package/dist/{discovery-MS2ZSMZ5.js.map → discovery-NTMSA6UE.js.map} +0 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getSessionAgentKey,
|
|
9
9
|
getSessionReferenceKey,
|
|
10
10
|
toCalendarDayKey
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2LXZFMSH.js";
|
|
12
12
|
|
|
13
13
|
// ../core/dist/chunk-XNDXGBK6.mjs
|
|
14
14
|
var COST_ABSOLUTE_TOLERANCE = 1e-8;
|
|
@@ -666,4 +666,4 @@ export {
|
|
|
666
666
|
summarizeProjects,
|
|
667
667
|
attachProjectMetricsFromTree
|
|
668
668
|
};
|
|
669
|
-
//# sourceMappingURL=chunk-
|
|
669
|
+
//# sourceMappingURL=chunk-543OWZIC.js.map
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
normalizeProjectDirectory,
|
|
9
9
|
normalizeProjectScopePath,
|
|
10
10
|
realFs
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DWY4HWVI.js";
|
|
12
12
|
import {
|
|
13
13
|
SessionScanError,
|
|
14
14
|
createAgentScanFailure,
|
|
15
15
|
createRegisteredAgents,
|
|
16
16
|
reportAgentScanFailure
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WRVILHZR.js";
|
|
18
18
|
import {
|
|
19
19
|
SMART_TAG_CLASSIFIER_REVISION,
|
|
20
20
|
assertIdentifiedSessionHead,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
setUserVersion,
|
|
42
42
|
sortSessionsByActivity,
|
|
43
43
|
tableExists
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-2LXZFMSH.js";
|
|
45
45
|
|
|
46
46
|
// ../core/dist/chunk-SU7BSXP6.mjs
|
|
47
47
|
var CACHE_SCHEMA_VERSION = 34;
|
|
@@ -4097,7 +4097,7 @@ function matchesSessionQueryScope(session, scope) {
|
|
|
4097
4097
|
return !scope?.projectScope || matchesProjectScope(session, scope.projectScope);
|
|
4098
4098
|
}
|
|
4099
4099
|
|
|
4100
|
-
// ../core/dist/chunk-
|
|
4100
|
+
// ../core/dist/chunk-P5WKPT24.mjs
|
|
4101
4101
|
import { existsSync as existsSync2, rmSync, unlinkSync } from "fs";
|
|
4102
4102
|
import { availableParallelism } from "os";
|
|
4103
4103
|
import { Worker } from "worker_threads";
|
|
@@ -6194,4 +6194,4 @@ export {
|
|
|
6194
6194
|
commitDurableSessionPublication,
|
|
6195
6195
|
listDashboardActiveHours
|
|
6196
6196
|
};
|
|
6197
|
-
//# sourceMappingURL=chunk-
|
|
6197
|
+
//# sourceMappingURL=chunk-56FKVL5K.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
WORKER_LOG_MESSAGE_TYPE,
|
|
7
7
|
isWorkerLogMessage,
|
|
8
8
|
setCoreDiagnostics
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2LXZFMSH.js";
|
|
10
10
|
|
|
11
11
|
// src/logging.ts
|
|
12
12
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -1269,4 +1269,4 @@ export {
|
|
|
1269
1269
|
appLogger,
|
|
1270
1270
|
logSearchIndexSync
|
|
1271
1271
|
};
|
|
1272
|
-
//# sourceMappingURL=chunk-
|
|
1272
|
+
//# sourceMappingURL=chunk-CYZ6OC6J.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getProjectIdentityKey,
|
|
5
5
|
getSessionAgentKey,
|
|
6
6
|
matchesProjectIdentity
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-2LXZFMSH.js";
|
|
8
8
|
|
|
9
9
|
// ../core/dist/chunk-O3HCRG2L.mjs
|
|
10
10
|
import * as os from "os";
|
|
@@ -324,4 +324,4 @@ export {
|
|
|
324
324
|
normalizeProjectScopePath,
|
|
325
325
|
buildProjectGroups
|
|
326
326
|
};
|
|
327
|
-
//# sourceMappingURL=chunk-
|
|
327
|
+
//# sourceMappingURL=chunk-DWY4HWVI.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
appLogger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CYZ6OC6J.js";
|
|
5
5
|
|
|
6
6
|
// src/worker-log-drain.ts
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
acknowledgeWorkerLogDrain,
|
|
87
87
|
terminateWorkerAfterLogDrain
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-R6QKSHPH.js.map
|
|
@@ -32,9 +32,9 @@ import {
|
|
|
32
32
|
reportFieldMismatch,
|
|
33
33
|
resolveSessionTitle,
|
|
34
34
|
safeParseJsonRecord
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-2LXZFMSH.js";
|
|
36
36
|
|
|
37
|
-
// ../core/dist/chunk-
|
|
37
|
+
// ../core/dist/chunk-XW3NUJH2.mjs
|
|
38
38
|
import { statSync } from "fs";
|
|
39
39
|
import { readdirSync, statSync as statSync2 } from "fs";
|
|
40
40
|
import { join } from "path";
|
|
@@ -74,6 +74,9 @@ import { join as join15 } from "path";
|
|
|
74
74
|
import { createHash as createHash4 } from "crypto";
|
|
75
75
|
import { homedir as homedir5, platform as platform5 } from "os";
|
|
76
76
|
import { join as join16 } from "path";
|
|
77
|
+
import { createHash as createHash5 } from "crypto";
|
|
78
|
+
import { homedir as homedir6 } from "os";
|
|
79
|
+
import { join as join17 } from "path";
|
|
77
80
|
function fingerprintMatches(ref, cached) {
|
|
78
81
|
return typeof cached?.sourceFingerprint === "string" && cached.sourceFingerprint === ref.fingerprint;
|
|
79
82
|
}
|
|
@@ -919,9 +922,9 @@ var ClaudeRecordConverter = class {
|
|
|
919
922
|
if (partType !== "tool_use") continue;
|
|
920
923
|
const toolCallId = String(part["id"] ?? "").trim();
|
|
921
924
|
const subagentId = childSessionIdByToolUseId.get(toolCallId);
|
|
922
|
-
const
|
|
925
|
+
const toolPart3 = this.buildToolPart(part, timestampMs);
|
|
923
926
|
const message = builder.appendToolCall(
|
|
924
|
-
|
|
927
|
+
toolPart3,
|
|
925
928
|
{ id: uuid, timestampMs, agent: "claude", subagentId, model },
|
|
926
929
|
{ modeOnCreate: "tool" }
|
|
927
930
|
);
|
|
@@ -2437,12 +2440,12 @@ var KimiUsageAccumulator = class {
|
|
|
2437
2440
|
totalCost = 0;
|
|
2438
2441
|
applyContextRecord(record) {
|
|
2439
2442
|
if (record.role !== "_usage") return;
|
|
2440
|
-
const
|
|
2441
|
-
if (
|
|
2443
|
+
const tokenCount3 = asNumber(record.token_count);
|
|
2444
|
+
if (tokenCount3 === void 0) {
|
|
2442
2445
|
reportFieldMismatch("kimi", "usage.token_count");
|
|
2443
2446
|
return;
|
|
2444
2447
|
}
|
|
2445
|
-
this.stats.total_tokens =
|
|
2448
|
+
this.stats.total_tokens = tokenCount3;
|
|
2446
2449
|
}
|
|
2447
2450
|
applyWireRecord(record) {
|
|
2448
2451
|
if (this.usesWireTotalFallback) this.applyContextRecord(record);
|
|
@@ -2859,7 +2862,7 @@ var KimiAgent = class extends FileSystemSessionSource {
|
|
|
2859
2862
|
const rawArgs = function_.arguments;
|
|
2860
2863
|
const normalizedArgs = normalizeToolArguments(rawArgs);
|
|
2861
2864
|
const buffer = typeof rawArgs === "string" && typeof normalizedArgs !== "string" ? rawArgs : null;
|
|
2862
|
-
const
|
|
2865
|
+
const toolPart3 = {
|
|
2863
2866
|
type: "tool",
|
|
2864
2867
|
tool: toolName,
|
|
2865
2868
|
callID: callId,
|
|
@@ -2868,7 +2871,7 @@ var KimiAgent = class extends FileSystemSessionSource {
|
|
|
2868
2871
|
time_created: timestampMs
|
|
2869
2872
|
};
|
|
2870
2873
|
builder.appendToolCall(
|
|
2871
|
-
|
|
2874
|
+
toolPart3,
|
|
2872
2875
|
{ id: `wire-${seq}`, timestampMs, agent: "kimi" },
|
|
2873
2876
|
{ markModeAsTool: true, target: "current" }
|
|
2874
2877
|
);
|
|
@@ -4192,7 +4195,7 @@ var CodexRecordConverter = class {
|
|
|
4192
4195
|
if (!name) return;
|
|
4193
4196
|
const toolIdentity = resolveToolIdentity(name, payload["namespace"]);
|
|
4194
4197
|
const arguments_ = normalizeToolArguments(payload["arguments"]);
|
|
4195
|
-
const
|
|
4198
|
+
const toolPart3 = {
|
|
4196
4199
|
type: "tool",
|
|
4197
4200
|
tool: toolIdentity.tool,
|
|
4198
4201
|
callID: callId,
|
|
@@ -4206,7 +4209,7 @@ var CodexRecordConverter = class {
|
|
|
4206
4209
|
time_created: timestampMs
|
|
4207
4210
|
};
|
|
4208
4211
|
transcript.appendToolCall(
|
|
4209
|
-
|
|
4212
|
+
toolPart3,
|
|
4210
4213
|
{ id: "", timestampMs, agent: "codex", model: activeModel },
|
|
4211
4214
|
{ markModeAsTool: true }
|
|
4212
4215
|
);
|
|
@@ -4238,7 +4241,7 @@ var CodexRecordConverter = class {
|
|
|
4238
4241
|
const toolIdentity = resolveToolIdentity(name, payload["namespace"]);
|
|
4239
4242
|
const rawInput = payload["input"];
|
|
4240
4243
|
const normalizedInput = normalizeCustomToolArguments(name, rawInput);
|
|
4241
|
-
const
|
|
4244
|
+
const toolPart3 = {
|
|
4242
4245
|
type: "tool",
|
|
4243
4246
|
tool: toolIdentity.tool,
|
|
4244
4247
|
callID: callId,
|
|
@@ -4252,7 +4255,7 @@ var CodexRecordConverter = class {
|
|
|
4252
4255
|
time_created: timestampMs
|
|
4253
4256
|
};
|
|
4254
4257
|
transcript.appendToolCall(
|
|
4255
|
-
|
|
4258
|
+
toolPart3,
|
|
4256
4259
|
{ id: "", timestampMs, agent: "codex", model: activeModel },
|
|
4257
4260
|
{ markModeAsTool: true }
|
|
4258
4261
|
);
|
|
@@ -4269,7 +4272,7 @@ var CodexRecordConverter = class {
|
|
|
4269
4272
|
const { name, namespace } = splitExecToolName(call.name);
|
|
4270
4273
|
const toolIdentity = resolveToolIdentity(name, namespace);
|
|
4271
4274
|
const arguments_ = name === "apply_patch" ? parseApplyPatchInput(getExecPatchText(call.args)) : call.args;
|
|
4272
|
-
const
|
|
4275
|
+
const toolPart3 = {
|
|
4273
4276
|
type: "tool",
|
|
4274
4277
|
tool: toolIdentity.tool,
|
|
4275
4278
|
callID: callId,
|
|
@@ -4283,7 +4286,7 @@ var CodexRecordConverter = class {
|
|
|
4283
4286
|
time_created: timestampMs
|
|
4284
4287
|
};
|
|
4285
4288
|
transcript.appendToolCall(
|
|
4286
|
-
|
|
4289
|
+
toolPart3,
|
|
4287
4290
|
{ id: "", timestampMs, agent: "codex", model: activeModel },
|
|
4288
4291
|
{ markModeAsTool: true }
|
|
4289
4292
|
);
|
|
@@ -5125,7 +5128,7 @@ function parseBubbleRow(value) {
|
|
|
5125
5128
|
const record = safeParseJsonRecord(value);
|
|
5126
5129
|
if (!record) return null;
|
|
5127
5130
|
const timingInfo = asRecord(record.timingInfo);
|
|
5128
|
-
const
|
|
5131
|
+
const tokenCount3 = asRecord(record.tokenCount);
|
|
5129
5132
|
const modelInfo = asRecord(record.modelInfo);
|
|
5130
5133
|
const toolFormerData = asRecord(record.toolFormerData);
|
|
5131
5134
|
return {
|
|
@@ -5149,9 +5152,9 @@ function parseBubbleRow(value) {
|
|
|
5149
5152
|
),
|
|
5150
5153
|
clientEndTime: narrowNumber("bubble.timingInfo.clientEndTime", timingInfo.clientEndTime)
|
|
5151
5154
|
} : void 0,
|
|
5152
|
-
tokenCount:
|
|
5153
|
-
inputTokens: narrowNumber("bubble.tokenCount.inputTokens",
|
|
5154
|
-
outputTokens: narrowNumber("bubble.tokenCount.outputTokens",
|
|
5155
|
+
tokenCount: tokenCount3 ? {
|
|
5156
|
+
inputTokens: narrowNumber("bubble.tokenCount.inputTokens", tokenCount3.inputTokens),
|
|
5157
|
+
outputTokens: narrowNumber("bubble.tokenCount.outputTokens", tokenCount3.outputTokens)
|
|
5155
5158
|
} : void 0,
|
|
5156
5159
|
modelInfo: modelInfo ? { modelName: narrowString("bubble.modelInfo.modelName", modelInfo.modelName) } : void 0,
|
|
5157
5160
|
toolFormerData: toolFormerData ? {
|
|
@@ -5733,9 +5736,9 @@ var CursorAgent = class extends DatabaseSessionSource {
|
|
|
5733
5736
|
parts.push({ type: "text", text, time_created: timestampMs });
|
|
5734
5737
|
}
|
|
5735
5738
|
if (bubble.toolFormerData) {
|
|
5736
|
-
const
|
|
5737
|
-
if (
|
|
5738
|
-
parts.push(
|
|
5739
|
+
const toolPart3 = this.convertToolFormerData(bubble.toolFormerData, timestampMs);
|
|
5740
|
+
if (toolPart3) {
|
|
5741
|
+
parts.push(toolPart3);
|
|
5739
5742
|
}
|
|
5740
5743
|
}
|
|
5741
5744
|
if (parts.length === 0) continue;
|
|
@@ -6209,7 +6212,7 @@ var PiAgent = class extends SingleFileSessionSource {
|
|
|
6209
6212
|
if (type === "toolCall") {
|
|
6210
6213
|
const callId = String(item["id"] ?? "").trim();
|
|
6211
6214
|
const toolName = String(item["name"] ?? "").trim() || "tool";
|
|
6212
|
-
const
|
|
6215
|
+
const toolPart3 = {
|
|
6213
6216
|
type: "tool",
|
|
6214
6217
|
tool: toolName,
|
|
6215
6218
|
title: `Tool: ${toolName}`,
|
|
@@ -6220,7 +6223,7 @@ var PiAgent = class extends SingleFileSessionSource {
|
|
|
6220
6223
|
input: item["arguments"] ?? {}
|
|
6221
6224
|
}
|
|
6222
6225
|
};
|
|
6223
|
-
parts.push(
|
|
6226
|
+
parts.push(toolPart3);
|
|
6224
6227
|
}
|
|
6225
6228
|
}
|
|
6226
6229
|
return parts;
|
|
@@ -8989,7 +8992,345 @@ var CherryStudioAgent = class extends DatabaseSessionSource {
|
|
|
8989
8992
|
return { session, fingerprint: signature.digest("hex"), unpricedModels };
|
|
8990
8993
|
}
|
|
8991
8994
|
};
|
|
8995
|
+
function parseToolJson(value) {
|
|
8996
|
+
if (typeof value !== "string") return value;
|
|
8997
|
+
try {
|
|
8998
|
+
return JSON.parse(value);
|
|
8999
|
+
} catch {
|
|
9000
|
+
return value;
|
|
9001
|
+
}
|
|
9002
|
+
}
|
|
9003
|
+
function toolPart2(value) {
|
|
9004
|
+
const call = asRecord(value);
|
|
9005
|
+
if (!call) return null;
|
|
9006
|
+
const tool = asString(call.tool_name);
|
|
9007
|
+
if (!tool) return null;
|
|
9008
|
+
const input = parseToolJson(call.tool_call_args);
|
|
9009
|
+
const output = parseToolJson(call.tool_call_result_data);
|
|
9010
|
+
const result = asRecord(output);
|
|
9011
|
+
const failed = call.tool_call_status === 3 || result?.isError === true || result?.error != null;
|
|
9012
|
+
return {
|
|
9013
|
+
type: "tool",
|
|
9014
|
+
tool,
|
|
9015
|
+
callID: asString(call.tool_call_id),
|
|
9016
|
+
state: {
|
|
9017
|
+
status: failed ? "error" : call.tool_call_status === 2 ? "completed" : "running",
|
|
9018
|
+
input,
|
|
9019
|
+
output,
|
|
9020
|
+
error: failed ? result?.error ?? result?.text ?? output : void 0,
|
|
9021
|
+
metadata: {
|
|
9022
|
+
...asRecord(result?.details),
|
|
9023
|
+
minimax_status: call.tool_call_status
|
|
9024
|
+
}
|
|
9025
|
+
}
|
|
9026
|
+
};
|
|
9027
|
+
}
|
|
9028
|
+
function attachmentPart(value) {
|
|
9029
|
+
const attachment = asRecord(value);
|
|
9030
|
+
if (!attachment) return null;
|
|
9031
|
+
const path = asString(attachment.file_path) ?? asString(attachment.desktop_path);
|
|
9032
|
+
const mime = asString(attachment.mime_type);
|
|
9033
|
+
const name = path ?? asString(attachment.file_name) ?? asString(attachment.asset_id) ?? asString(attachment.url);
|
|
9034
|
+
return name ? { type: "text", text: `Attachment: ${name}${mime ? ` (${mime})` : ""}` } : null;
|
|
9035
|
+
}
|
|
9036
|
+
var EVENT_LABELS = {
|
|
9037
|
+
compaction_start: "Context compaction started",
|
|
9038
|
+
compaction: "Context compacted",
|
|
9039
|
+
compaction_failed: "Context compaction failed",
|
|
9040
|
+
review_start: "Review started",
|
|
9041
|
+
review_result: "Review result",
|
|
9042
|
+
review_failed: "Review failed",
|
|
9043
|
+
review_aborted: "Review aborted",
|
|
9044
|
+
review_interrupted: "Review interrupted"
|
|
9045
|
+
};
|
|
9046
|
+
var AUTOMATED_SOURCES = /* @__PURE__ */ new Set(["cron", "thread-goal", "team", "background-task", "system"]);
|
|
9047
|
+
function miniMaxMessage(row, agent) {
|
|
9048
|
+
const data = asRecord(JSON.parse(String(row.data_json)));
|
|
9049
|
+
const id = asString(row.msg_id);
|
|
9050
|
+
if (!data || !id || data.msg_id !== id) throw new Error("Invalid MiniMax display message");
|
|
9051
|
+
const role = row.role ?? data.role ?? "assistant";
|
|
9052
|
+
if (role !== "user" && role !== "assistant") throw new Error(`Invalid MiniMax role: ${role}`);
|
|
9053
|
+
const kind = asString(data.kind);
|
|
9054
|
+
const parts = [];
|
|
9055
|
+
if (kind) parts.push({ type: "text", text: EVENT_LABELS[kind] ?? `Event: ${kind}` });
|
|
9056
|
+
const thinking = asString(data.thinking_content);
|
|
9057
|
+
if (thinking) parts.push({ type: "reasoning", text: thinking });
|
|
9058
|
+
const text = asString(data.msg_content);
|
|
9059
|
+
if (text) parts.push({ type: "text", text });
|
|
9060
|
+
for (const value of Array.isArray(data.attachments) ? data.attachments : []) {
|
|
9061
|
+
const part = attachmentPart(value);
|
|
9062
|
+
if (part) parts.push(part);
|
|
9063
|
+
}
|
|
9064
|
+
const children = /* @__PURE__ */ new Set();
|
|
9065
|
+
for (const value of Array.isArray(data.tool_calls) ? data.tool_calls : []) {
|
|
9066
|
+
const part = toolPart2(value);
|
|
9067
|
+
if (!part) continue;
|
|
9068
|
+
parts.push(part);
|
|
9069
|
+
if (part.tool === "task" || part.tool.startsWith("task_")) {
|
|
9070
|
+
const metadata = asRecord(part.state.metadata);
|
|
9071
|
+
const child = asString(metadata?.sub_session_id) ?? asString(metadata?.session_id);
|
|
9072
|
+
if (child) children.add(child);
|
|
9073
|
+
}
|
|
9074
|
+
}
|
|
9075
|
+
const error = asString(data.error);
|
|
9076
|
+
if (error) parts.push({ type: "text", text: error });
|
|
9077
|
+
const timestamp = asNumber(row.created_at_ms) ?? asNumber(data.timestamp) ?? 0;
|
|
9078
|
+
return {
|
|
9079
|
+
id,
|
|
9080
|
+
role,
|
|
9081
|
+
agent: role === "assistant" ? agent : void 0,
|
|
9082
|
+
time_created: timestamp,
|
|
9083
|
+
time_completed: data.finish_reason ? timestamp : void 0,
|
|
9084
|
+
mode: kind,
|
|
9085
|
+
automated: role === "user" && (Boolean(kind) || AUTOMATED_SOURCES.has(String(row.source))) ? true : void 0,
|
|
9086
|
+
subagent_id: children.size === 1 ? children.values().next().value : void 0,
|
|
9087
|
+
parts
|
|
9088
|
+
};
|
|
9089
|
+
}
|
|
9090
|
+
function tokenCount2(value) {
|
|
9091
|
+
return Math.max(0, asNumber(value) ?? 0);
|
|
9092
|
+
}
|
|
9093
|
+
function miniMaxUsage(row) {
|
|
9094
|
+
const model = asString(row.model) || void 0;
|
|
9095
|
+
const tokens = {
|
|
9096
|
+
input: tokenCount2(row.input_tokens),
|
|
9097
|
+
output: tokenCount2(row.output_tokens),
|
|
9098
|
+
reasoning: tokenCount2(row.reasoning_tokens),
|
|
9099
|
+
cache_read: tokenCount2(row.cache_read_tokens),
|
|
9100
|
+
cache_create: tokenCount2(row.cache_write_tokens)
|
|
9101
|
+
};
|
|
9102
|
+
const recorded = asNumber(row.cost_usd);
|
|
9103
|
+
const cost = recorded !== void 0 && recorded >= 0 ? recorded : estimateTokenCost(model, tokens);
|
|
9104
|
+
return {
|
|
9105
|
+
turnId: asString(row.turn_id),
|
|
9106
|
+
model,
|
|
9107
|
+
time: tokenCount2(row.ts),
|
|
9108
|
+
tokens,
|
|
9109
|
+
total: Object.values(tokens).reduce((sum, value) => sum + value, 0),
|
|
9110
|
+
cost: cost ?? 0,
|
|
9111
|
+
costSource: recorded !== void 0 && recorded >= 0 ? "recorded" : cost !== null ? "estimated" : void 0
|
|
9112
|
+
};
|
|
9113
|
+
}
|
|
9114
|
+
function attachMiniMaxUsage(message, usages) {
|
|
9115
|
+
const models = new Set(usages.map((usage) => usage.model));
|
|
9116
|
+
if (models.size !== 1) return;
|
|
9117
|
+
message.model = usages[0]?.model;
|
|
9118
|
+
message.tokens = {};
|
|
9119
|
+
message.cost = 0;
|
|
9120
|
+
for (const usage of usages) {
|
|
9121
|
+
for (const key of ["input", "output", "reasoning", "cache_read", "cache_create"]) {
|
|
9122
|
+
message.tokens[key] = (message.tokens[key] ?? 0) + (usage.tokens[key] ?? 0);
|
|
9123
|
+
}
|
|
9124
|
+
message.cost += usage.cost;
|
|
9125
|
+
if (usage.costSource === "estimated" || !message.cost_source)
|
|
9126
|
+
message.cost_source = usage.costSource;
|
|
9127
|
+
}
|
|
9128
|
+
}
|
|
9129
|
+
var AGENT_METADATA13 = getAgentCatalogEntry("minimax-code");
|
|
9130
|
+
var DATABASE_PATH = join17("v2", "sqlite", "runtime-state.sqlite");
|
|
9131
|
+
var SESSION_FILTER = "(s.visibility <> 'hidden' OR s.parent_session_id IS NOT NULL) AND s.session_kind NOT IN ('peek', 'cron', 'channel')";
|
|
9132
|
+
function dataRoots() {
|
|
9133
|
+
const configured = readEnvPath("MINIMAX_DATA_DIR") ?? readEnvPath("MAVIS_DATA_DIR");
|
|
9134
|
+
return configured ? [configured] : [join17(homedir6(), ".minimax"), join17(homedir6(), ".minimax-code")];
|
|
9135
|
+
}
|
|
9136
|
+
function resolveMiniMaxCodeDataRoot() {
|
|
9137
|
+
const roots = dataRoots();
|
|
9138
|
+
return roots.find((root) => firstExisting(join17(root, DATABASE_PATH))) ?? roots[0];
|
|
9139
|
+
}
|
|
9140
|
+
var MiniMaxCodeAgent = class extends DatabaseSessionSource {
|
|
9141
|
+
name = AGENT_METADATA13.name;
|
|
9142
|
+
displayName = AGENT_METADATA13.displayName;
|
|
9143
|
+
roots;
|
|
9144
|
+
constructor(options = {}) {
|
|
9145
|
+
super();
|
|
9146
|
+
this.roots = options.sourceRoot ? [options.sourceRoot] : dataRoots();
|
|
9147
|
+
}
|
|
9148
|
+
getDatabasePath() {
|
|
9149
|
+
return firstExisting(...this.roots.map((root) => join17(root, DATABASE_PATH)));
|
|
9150
|
+
}
|
|
9151
|
+
isAvailable() {
|
|
9152
|
+
return isSqliteAvailable() && this.getDatabasePath() !== null;
|
|
9153
|
+
}
|
|
9154
|
+
getSessionWatchPlan() {
|
|
9155
|
+
return {
|
|
9156
|
+
status: "supported",
|
|
9157
|
+
targets: this.roots.flatMap(
|
|
9158
|
+
(root) => ["", "-wal", "-journal"].map((suffix) => ({
|
|
9159
|
+
path: `${join17(root, DATABASE_PATH)}${suffix}`,
|
|
9160
|
+
pollForChanges: true
|
|
9161
|
+
}))
|
|
9162
|
+
)
|
|
9163
|
+
};
|
|
9164
|
+
}
|
|
9165
|
+
readDatabase(read) {
|
|
9166
|
+
const path = this.getDatabasePath();
|
|
9167
|
+
if (!path) throw new Error("MiniMax Code runtime-state.sqlite is missing");
|
|
9168
|
+
return this.scanStep("reading MiniMax Code 0.4.12 sessions", path, () => {
|
|
9169
|
+
const db = openDbReadOnly(path);
|
|
9170
|
+
if (!db) throw new Error("Cannot open MiniMax Code database");
|
|
9171
|
+
try {
|
|
9172
|
+
return db.transaction(() => read(db))();
|
|
9173
|
+
} finally {
|
|
9174
|
+
db.close();
|
|
9175
|
+
}
|
|
9176
|
+
});
|
|
9177
|
+
}
|
|
9178
|
+
scan(options) {
|
|
9179
|
+
if (!this.getDatabasePath()) return [];
|
|
9180
|
+
return this.readDatabase((db) => {
|
|
9181
|
+
const projections = this.readProjections(db);
|
|
9182
|
+
const selected = /* @__PURE__ */ new Set();
|
|
9183
|
+
const children = /* @__PURE__ */ new Map();
|
|
9184
|
+
for (const [id, { head }] of projections) {
|
|
9185
|
+
const parent = head.parent_reference?.sessionId;
|
|
9186
|
+
if (parent && projections.has(parent)) {
|
|
9187
|
+
const siblings = children.get(parent) ?? [];
|
|
9188
|
+
siblings.push(id);
|
|
9189
|
+
children.set(parent, siblings);
|
|
9190
|
+
} else if (matchesScanWindow(head.time_updated ?? head.time_created, options)) {
|
|
9191
|
+
selected.add(id);
|
|
9192
|
+
}
|
|
9193
|
+
}
|
|
9194
|
+
if (options?.includeRelatedSessions !== false) {
|
|
9195
|
+
for (const id of selected) {
|
|
9196
|
+
for (const child of children.get(id) ?? []) selected.add(child);
|
|
9197
|
+
}
|
|
9198
|
+
}
|
|
9199
|
+
const sessions = [];
|
|
9200
|
+
for (const id of selected) {
|
|
9201
|
+
const projection = projections.get(id);
|
|
9202
|
+
if (!projection.head.stats.message_count) continue;
|
|
9203
|
+
this.rememberSession(id, {
|
|
9204
|
+
sourceFingerprint: projection.signature.digest("hex"),
|
|
9205
|
+
headParserVersion: "minimax-code-v1",
|
|
9206
|
+
unpricedModels: [...projection.unpricedModels]
|
|
9207
|
+
});
|
|
9208
|
+
sessions.push(projection.head);
|
|
9209
|
+
}
|
|
9210
|
+
sessions.sort(
|
|
9211
|
+
(left, right) => (right.time_updated ?? 0) - (left.time_updated ?? 0) || left.reference.sessionId.localeCompare(right.reference.sessionId)
|
|
9212
|
+
);
|
|
9213
|
+
options?.onProgress?.({
|
|
9214
|
+
total: selected.size,
|
|
9215
|
+
processed: selected.size,
|
|
9216
|
+
sessions: sessions.length
|
|
9217
|
+
});
|
|
9218
|
+
return sessions;
|
|
9219
|
+
});
|
|
9220
|
+
}
|
|
9221
|
+
getSessionData(sessionId) {
|
|
9222
|
+
return this.readDatabase((db) => {
|
|
9223
|
+
const projection = this.readProjections(db, sessionId).get(sessionId);
|
|
9224
|
+
if (!projection) throw new Error(`MiniMax Code session not found: ${sessionId}`);
|
|
9225
|
+
for (const [turnId, usage] of projection.usageByTurn) {
|
|
9226
|
+
const message = projection.lastAssistantByTurn.get(turnId);
|
|
9227
|
+
if (message) attachMiniMaxUsage(message, usage);
|
|
9228
|
+
}
|
|
9229
|
+
return { ...projection.head, messages: projection.messages };
|
|
9230
|
+
});
|
|
9231
|
+
}
|
|
9232
|
+
readProjections(db, sessionId) {
|
|
9233
|
+
const filter = `${SESSION_FILTER}${sessionId ? " AND s.session_id = ?" : ""}`;
|
|
9234
|
+
const bindings = sessionId ? [sessionId] : [];
|
|
9235
|
+
const projections = /* @__PURE__ */ new Map();
|
|
9236
|
+
const sessions = db.prepare(`
|
|
9237
|
+
SELECT s.session_id, s.columnar_version, s.title, s.workspace_dir, s.parent_session_id,
|
|
9238
|
+
s.created_at_ms, s.updated_at_ms, s.agent_name, s.status, s.archived, s.extra_data_json
|
|
9239
|
+
FROM local_runtime_sessions s WHERE ${filter} ORDER BY s.session_id
|
|
9240
|
+
`).iterate(...bindings);
|
|
9241
|
+
for (const row of sessions) {
|
|
9242
|
+
if (row.columnar_version !== 3)
|
|
9243
|
+
throw new Error("Unsupported MiniMax session columnar version");
|
|
9244
|
+
const id = String(row.session_id);
|
|
9245
|
+
const parent = asString(row.parent_session_id);
|
|
9246
|
+
projections.set(id, {
|
|
9247
|
+
head: {
|
|
9248
|
+
...this.sessionIdentity(id),
|
|
9249
|
+
title: asString(row.title) ?? "",
|
|
9250
|
+
directory: asString(row.workspace_dir) ?? "",
|
|
9251
|
+
parent_reference: parent && parent !== id ? { agentName: this.name, sessionId: parent } : void 0,
|
|
9252
|
+
time_created: Number(row.created_at_ms ?? row.updated_at_ms),
|
|
9253
|
+
time_updated: Number(row.updated_at_ms),
|
|
9254
|
+
stats: { message_count: 0, total_input_tokens: 0, total_output_tokens: 0, total_cost: 0 }
|
|
9255
|
+
},
|
|
9256
|
+
agent: asString(row.agent_name) ?? this.displayName,
|
|
9257
|
+
signature: createHash5("sha256").update(JSON.stringify(row)),
|
|
9258
|
+
unpricedModels: /* @__PURE__ */ new Set(),
|
|
9259
|
+
messages: [],
|
|
9260
|
+
lastAssistantByTurn: /* @__PURE__ */ new Map(),
|
|
9261
|
+
usageByTurn: /* @__PURE__ */ new Map()
|
|
9262
|
+
});
|
|
9263
|
+
}
|
|
9264
|
+
const messages = db.prepare(`
|
|
9265
|
+
SELECT m.id, m.session_id, m.msg_id, m.role, m.turn_id, m.source, m.created_at_ms, m.data_json
|
|
9266
|
+
FROM local_runtime_message_rows m JOIN local_runtime_sessions s ON s.session_id = m.session_id
|
|
9267
|
+
WHERE ${filter} ORDER BY m.session_id, m.id
|
|
9268
|
+
`).iterate(...bindings);
|
|
9269
|
+
for (const row of messages) {
|
|
9270
|
+
const projection = projections.get(String(row.session_id));
|
|
9271
|
+
projection.signature.update(JSON.stringify(row));
|
|
9272
|
+
const message = miniMaxMessage(row, projection.agent);
|
|
9273
|
+
projection.head.stats.message_count += 1;
|
|
9274
|
+
projection.head.time_updated = Math.max(
|
|
9275
|
+
projection.head.time_updated ?? 0,
|
|
9276
|
+
message.time_created
|
|
9277
|
+
);
|
|
9278
|
+
if (message.role === "user" && !message.automated && !projection.firstUserText) {
|
|
9279
|
+
projection.firstUserText = message.parts.find((part) => part.type === "text")?.text;
|
|
9280
|
+
}
|
|
9281
|
+
if (sessionId) {
|
|
9282
|
+
projection.messages.push(message);
|
|
9283
|
+
const turnId = asString(row.turn_id);
|
|
9284
|
+
if (turnId && message.role === "assistant" && !message.mode)
|
|
9285
|
+
projection.lastAssistantByTurn.set(turnId, message);
|
|
9286
|
+
}
|
|
9287
|
+
}
|
|
9288
|
+
const usages = db.prepare(`
|
|
9289
|
+
SELECT u.id, u.session_id, u.turn_id, u.model, u.ts, u.input_tokens, u.output_tokens,
|
|
9290
|
+
u.reasoning_tokens, u.cache_read_tokens, u.cache_write_tokens, u.cost_usd
|
|
9291
|
+
FROM local_runtime_token_usage u JOIN local_runtime_sessions s ON s.session_id = u.session_id
|
|
9292
|
+
WHERE ${filter} ORDER BY u.session_id, u.id
|
|
9293
|
+
`).iterate(...bindings);
|
|
9294
|
+
for (const row of usages) {
|
|
9295
|
+
const projection = projections.get(String(row.session_id));
|
|
9296
|
+
projection.signature.update(JSON.stringify(row));
|
|
9297
|
+
const { result: usage, unpricedModels } = capturePricingMisses(() => miniMaxUsage(row));
|
|
9298
|
+
for (const model of unpricedModels) projection.unpricedModels.add(model);
|
|
9299
|
+
const stats = projection.head.stats;
|
|
9300
|
+
stats.total_input_tokens += usage.tokens.input ?? 0;
|
|
9301
|
+
stats.total_output_tokens += usage.tokens.output ?? 0;
|
|
9302
|
+
stats.total_tokens = (stats.total_tokens ?? 0) + usage.total;
|
|
9303
|
+
stats.total_cache_read_tokens = (stats.total_cache_read_tokens ?? 0) + (usage.tokens.cache_read ?? 0);
|
|
9304
|
+
stats.total_cache_create_tokens = (stats.total_cache_create_tokens ?? 0) + (usage.tokens.cache_create ?? 0);
|
|
9305
|
+
stats.total_cost += usage.cost;
|
|
9306
|
+
if (usage.costSource === "estimated" || !stats.cost_source)
|
|
9307
|
+
stats.cost_source = usage.costSource;
|
|
9308
|
+
if (usage.model) {
|
|
9309
|
+
const modelUsage = projection.head.model_usage ??= /* @__PURE__ */ Object.create(null);
|
|
9310
|
+
modelUsage[usage.model] = (modelUsage[usage.model] ?? 0) + usage.total;
|
|
9311
|
+
}
|
|
9312
|
+
projection.head.time_updated = Math.max(projection.head.time_updated ?? 0, usage.time);
|
|
9313
|
+
if (sessionId && usage.turnId) {
|
|
9314
|
+
const turnUsage = projection.usageByTurn.get(usage.turnId) ?? [];
|
|
9315
|
+
turnUsage.push(usage);
|
|
9316
|
+
projection.usageByTurn.set(usage.turnId, turnUsage);
|
|
9317
|
+
}
|
|
9318
|
+
}
|
|
9319
|
+
for (const projection of projections.values()) {
|
|
9320
|
+
projection.head.title = resolveSessionTitle(
|
|
9321
|
+
projection.head.title,
|
|
9322
|
+
projection.firstUserText ?? null,
|
|
9323
|
+
null
|
|
9324
|
+
);
|
|
9325
|
+
}
|
|
9326
|
+
return projections;
|
|
9327
|
+
}
|
|
9328
|
+
};
|
|
8992
9329
|
var RUNTIME_REGISTRATIONS = {
|
|
9330
|
+
"minimax-code": {
|
|
9331
|
+
create: () => new MiniMaxCodeAgent(),
|
|
9332
|
+
resolveDataRoot: resolveMiniMaxCodeDataRoot
|
|
9333
|
+
},
|
|
8993
9334
|
claudecode: {
|
|
8994
9335
|
create: () => new ClaudeCodeAgent(),
|
|
8995
9336
|
resolveDataRoot: resolveClaudeCodeDataRoot
|
|
@@ -9079,4 +9420,4 @@ export {
|
|
|
9079
9420
|
createRegisteredAgents,
|
|
9080
9421
|
getAgentInfoMap
|
|
9081
9422
|
};
|
|
9082
|
-
//# sourceMappingURL=chunk-
|
|
9423
|
+
//# sourceMappingURL=chunk-WRVILHZR.js.map
|