@codexhost/cli-win32-arm64 0.27.0 → 0.28.1
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 +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +369 -163
- package/app/console-web.js +223 -9
- package/app/desktop-controller.mjs +105 -4
- package/app/host-runtime.mjs +1938 -1024
- package/app/plugins/antigravity/plugin.mjs +390 -135
- package/app/plugins/claude-code/plugin.mjs +383 -32
- package/app/plugins/codebuddy/plugin.mjs +213 -30
- package/app/plugins/codex-usage/plugin.mjs +370 -52
- package/app/plugins/copilot/plugin.mjs +105 -4
- package/app/plugins/cursor-cli/plugin.mjs +126 -4
- package/app/plugins/deepseek-harness/plugin.mjs +107 -4
- package/app/plugins/devin/plugin.mjs +106 -4
- package/app/plugins/grok/plugin.mjs +186 -25
- package/app/plugins/hermes/plugin.mjs +107 -4
- package/app/plugins/kimi-code/plugin.mjs +105 -4
- package/app/plugins/kiro-cli/plugin.mjs +105 -4
- package/app/plugins/omp/plugin.mjs +261 -45
- package/app/plugins/opencode/plugin.mjs +107 -4
- package/app/plugins/pi/plugin.mjs +312 -48
- package/app/plugins/qoder/plugin.mjs +179 -18
- package/app/plugins/qoder-cn/plugin.mjs +179 -18
- package/app/plugins/qwen-code/plugin.mjs +105 -4
- package/app/plugins/workbuddy/plugin.mjs +213 -30
- package/app/plugins/zcode/plugin.mjs +225 -85
- package/app/renderer-extension.js +11973 -11468
- package/app/web/assets/index-BJq8mT6r.js +204 -0
- package/app/web/assets/index-CMDliP5b.css +1 -0
- package/app/web/codexhost-settings.js +110 -49
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +72 -72
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +14 -14
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +5 -5
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.pdf.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web-modules/server.mjs +2494 -1132
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-D9l7_ThH.js +0 -199
- package/app/web/assets/index-nw2RXcDu.css +0 -1
|
@@ -20120,11 +20120,21 @@ var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionS
|
|
|
20120
20120
|
ids.add(option.id);
|
|
20121
20121
|
}
|
|
20122
20122
|
});
|
|
20123
|
+
var harnessThinkingOptionsScopeSchema = external_exports.enum(["catalog", "activeModel"]);
|
|
20123
20124
|
var harnessModelCatalogSchema = external_exports.object({
|
|
20124
20125
|
models: external_exports.array(harnessModelSchema),
|
|
20125
20126
|
defaultModel: harnessModelRefSchema.optional(),
|
|
20126
20127
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
20127
|
-
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
20128
|
+
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
20129
|
+
/**
|
|
20130
|
+
* Scope of per-Model `supportedThinkingOptionIds` in this catalog.
|
|
20131
|
+
* Omitted or `"catalog"` means each Model's `supportedThinkingOptionIds`
|
|
20132
|
+
* reflects its own options (omitted or `[]` means none).
|
|
20133
|
+
* `"activeModel"` means only the active Model's Thinking options were
|
|
20134
|
+
* observed; other Models omit `supportedThinkingOptionIds` and must be
|
|
20135
|
+
* validated by the Adapter after selecting the Model.
|
|
20136
|
+
*/
|
|
20137
|
+
thinkingOptionsScope: harnessThinkingOptionsScopeSchema.optional()
|
|
20128
20138
|
}).strict().superRefine((catalog, context) => {
|
|
20129
20139
|
const refs = [];
|
|
20130
20140
|
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
@@ -21038,7 +21048,12 @@ var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
|
21038
21048
|
prompt: external_exports.string().max(16384).optional()
|
|
21039
21049
|
}).strict();
|
|
21040
21050
|
var clientWorkspaceSnapshotSchema = external_exports.object({
|
|
21041
|
-
projects: external_exports.array(external_exports.object({
|
|
21051
|
+
projects: external_exports.array(external_exports.object({
|
|
21052
|
+
id: external_exports.string(),
|
|
21053
|
+
name: external_exports.string(),
|
|
21054
|
+
rootPaths: external_exports.array(external_exports.string()),
|
|
21055
|
+
createdAt: external_exports.number().int().optional()
|
|
21056
|
+
})),
|
|
21042
21057
|
nativeProjects: external_exports.literal(true).optional(),
|
|
21043
21058
|
assignments: external_exports.record(external_exports.string(), external_exports.string()),
|
|
21044
21059
|
projectless: external_exports.array(external_exports.string()),
|
|
@@ -21451,6 +21466,7 @@ var delegationReadParamsSchema = external_exports.strictObject({
|
|
|
21451
21466
|
// ../../shared-contracts/dist/remote-peers.js
|
|
21452
21467
|
var REMOTE_PEER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/u;
|
|
21453
21468
|
var remotePeerIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
21469
|
+
var remotePeerNodeIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
21454
21470
|
var remotePeerHostIdSchema = external_exports.string().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u);
|
|
21455
21471
|
var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "custom"]);
|
|
21456
21472
|
var REMOTE_PEER_COLORS = [
|
|
@@ -21474,6 +21490,7 @@ var remotePeerStateSchema = external_exports.enum([
|
|
|
21474
21490
|
var remotePeerSummarySchema = external_exports.object({
|
|
21475
21491
|
peerId: remotePeerIdSchema,
|
|
21476
21492
|
hostId: remotePeerHostIdSchema,
|
|
21493
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21477
21494
|
name: external_exports.string().min(1).max(120),
|
|
21478
21495
|
color: remotePeerColorSchema.optional(),
|
|
21479
21496
|
origin: external_exports.string().min(1).max(2048),
|
|
@@ -21481,6 +21498,11 @@ var remotePeerSummarySchema = external_exports.object({
|
|
|
21481
21498
|
encrypted: external_exports.boolean(),
|
|
21482
21499
|
enabled: external_exports.boolean(),
|
|
21483
21500
|
state: remotePeerStateSchema,
|
|
21501
|
+
supportsPeerPairing: external_exports.boolean().optional(),
|
|
21502
|
+
/** Omitted when either side's node mapping is unknown. */
|
|
21503
|
+
pairedBack: external_exports.boolean().optional(),
|
|
21504
|
+
/** Other configured remote peerIds on this Hub present in this peer's `manifest.peerNodes`. */
|
|
21505
|
+
linkedPeerIds: external_exports.array(remotePeerIdSchema).max(128).optional(),
|
|
21484
21506
|
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
21485
21507
|
version: external_exports.string().max(128).optional(),
|
|
21486
21508
|
platform: external_exports.string().max(64).optional(),
|
|
@@ -21499,8 +21521,48 @@ var remotePeerAddParamsSchema = external_exports.object({
|
|
|
21499
21521
|
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21500
21522
|
token: external_exports.string().min(1).max(2048).optional(),
|
|
21501
21523
|
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21502
|
-
color: remotePeerColorSchema.optional()
|
|
21524
|
+
color: remotePeerColorSchema.optional(),
|
|
21525
|
+
pairBack: external_exports.boolean().optional(),
|
|
21526
|
+
meshPeerIds: external_exports.array(remotePeerIdSchema).max(64).optional(),
|
|
21527
|
+
selfOrigin: external_exports.string().min(1).max(2048).optional()
|
|
21503
21528
|
}).refine((input3) => Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide either connectionUrl or both origin and token");
|
|
21529
|
+
var remotePeerIntroduceParamsSchema = external_exports.strictObject({
|
|
21530
|
+
origin: external_exports.string().min(1).max(2048),
|
|
21531
|
+
token: external_exports.string().min(1).max(2048),
|
|
21532
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21533
|
+
color: remotePeerColorSchema.optional(),
|
|
21534
|
+
expectedNodeId: remotePeerNodeIdSchema.optional()
|
|
21535
|
+
});
|
|
21536
|
+
var remotePeerIntroduceResultSchema = external_exports.object({
|
|
21537
|
+
status: external_exports.enum(["added", "updated", "existing"]),
|
|
21538
|
+
peerId: remotePeerIdSchema,
|
|
21539
|
+
hostId: remotePeerHostIdSchema,
|
|
21540
|
+
nodeId: remotePeerNodeIdSchema.optional()
|
|
21541
|
+
});
|
|
21542
|
+
var remotePeerPairingStatusSchema = external_exports.enum([
|
|
21543
|
+
"added",
|
|
21544
|
+
"updated",
|
|
21545
|
+
"existing",
|
|
21546
|
+
"failed",
|
|
21547
|
+
"skipped"
|
|
21548
|
+
]);
|
|
21549
|
+
var remotePeerPairingStepSchema = external_exports.object({
|
|
21550
|
+
targetPeerId: remotePeerIdSchema,
|
|
21551
|
+
targetName: external_exports.string().min(1).max(120),
|
|
21552
|
+
introducedHost: external_exports.union([external_exports.literal("local"), remotePeerIdSchema]),
|
|
21553
|
+
introducedName: external_exports.string().min(1).max(120),
|
|
21554
|
+
status: remotePeerPairingStatusSchema,
|
|
21555
|
+
error: external_exports.string().max(1e3).optional()
|
|
21556
|
+
});
|
|
21557
|
+
var remotePeerPairingReportSchema = external_exports.object({
|
|
21558
|
+
results: external_exports.array(remotePeerPairingStepSchema)
|
|
21559
|
+
});
|
|
21560
|
+
var remotePeerSyncMeshParamsSchema = external_exports.object({
|
|
21561
|
+
peerIds: external_exports.array(remotePeerIdSchema).max(64).optional(),
|
|
21562
|
+
includeSelf: external_exports.boolean().optional(),
|
|
21563
|
+
includeMesh: external_exports.boolean().optional(),
|
|
21564
|
+
selfOrigin: external_exports.string().min(1).max(2048).optional()
|
|
21565
|
+
});
|
|
21504
21566
|
var remotePeerUpdateParamsSchema = external_exports.object({
|
|
21505
21567
|
peerId: remotePeerIdSchema,
|
|
21506
21568
|
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
@@ -21529,6 +21591,9 @@ var remotePeerTestProjectSchema = external_exports.object({
|
|
|
21529
21591
|
});
|
|
21530
21592
|
var remotePeerTestResultSchema = external_exports.object({
|
|
21531
21593
|
ok: external_exports.boolean(),
|
|
21594
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21595
|
+
supportsPeerPairing: external_exports.boolean().optional(),
|
|
21596
|
+
pairedBack: external_exports.boolean().optional(),
|
|
21532
21597
|
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
21533
21598
|
origin: external_exports.string().max(2048).optional(),
|
|
21534
21599
|
transportKind: remotePeerTransportKindSchema.optional(),
|
|
@@ -21555,7 +21620,9 @@ var remotePeerCapabilitiesSchema = external_exports.object({
|
|
|
21555
21620
|
/** Peer supports officeToPdf/render over /api/peer/v1/workspace-files/rpc. */
|
|
21556
21621
|
officePreview: external_exports.literal(1).optional(),
|
|
21557
21622
|
/** /api/peer/v1/delegation is available for fixed-whitelist cross-host delegation. */
|
|
21558
|
-
delegation: external_exports.literal(1).optional()
|
|
21623
|
+
delegation: external_exports.literal(1).optional(),
|
|
21624
|
+
/** POST /api/peer/v1/peers is available. */
|
|
21625
|
+
peerPairing: external_exports.literal(1).optional()
|
|
21559
21626
|
});
|
|
21560
21627
|
var remotePeerManifestSchema = external_exports.object({
|
|
21561
21628
|
version: external_exports.string().max(128),
|
|
@@ -21563,6 +21630,8 @@ var remotePeerManifestSchema = external_exports.object({
|
|
|
21563
21630
|
hostname: external_exports.string().max(255),
|
|
21564
21631
|
homeDir: external_exports.string().max(4096).optional(),
|
|
21565
21632
|
epoch: external_exports.string().min(1).max(256),
|
|
21633
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21634
|
+
peerNodes: external_exports.record(remotePeerHostIdSchema, remotePeerNodeIdSchema).refine((v) => Object.keys(v).length <= 128).optional(),
|
|
21566
21635
|
projects: external_exports.array(remotePeerManifestProjectSchema),
|
|
21567
21636
|
capabilities: remotePeerCapabilitiesSchema.optional()
|
|
21568
21637
|
});
|
|
@@ -21649,6 +21718,29 @@ var remotePeerWorkspaceMutationResultSchema = external_exports.object({
|
|
|
21649
21718
|
workspaceId: external_exports.string().min(1).max(1024).optional(),
|
|
21650
21719
|
manifest: remotePeerManifestSchema
|
|
21651
21720
|
});
|
|
21721
|
+
var delegationRemoteHostsParamsSchema = external_exports.object({
|
|
21722
|
+
sessionHostId: external_exports.string().min(1).max(128).optional()
|
|
21723
|
+
});
|
|
21724
|
+
var delegationRemoteHostOptionSchema = external_exports.object({
|
|
21725
|
+
hostId: external_exports.union([external_exports.literal("local"), remotePeerHostIdSchema]),
|
|
21726
|
+
name: external_exports.string().min(1).max(120),
|
|
21727
|
+
isLocal: external_exports.boolean().optional(),
|
|
21728
|
+
color: remotePeerColorSchema.optional(),
|
|
21729
|
+
hostname: external_exports.string().max(255).optional()
|
|
21730
|
+
});
|
|
21731
|
+
var delegationRemoteHostsResultSchema = external_exports.object({
|
|
21732
|
+
hosts: external_exports.array(delegationRemoteHostOptionSchema)
|
|
21733
|
+
});
|
|
21734
|
+
var delegationHostHarnessesParamsSchema = external_exports.object({
|
|
21735
|
+
hostId: external_exports.union([external_exports.literal("local"), remotePeerHostIdSchema])
|
|
21736
|
+
});
|
|
21737
|
+
var delegationHostHarnessOptionSchema = external_exports.object({
|
|
21738
|
+
id: external_exports.string().regex(/^[a-z0-9][a-z0-9-]*$/u),
|
|
21739
|
+
name: external_exports.string().min(1).max(120)
|
|
21740
|
+
});
|
|
21741
|
+
var delegationHostHarnessesResultSchema = external_exports.object({
|
|
21742
|
+
harnesses: external_exports.array(delegationHostHarnessOptionSchema)
|
|
21743
|
+
});
|
|
21652
21744
|
|
|
21653
21745
|
// ../../shared-contracts/dist/peer-delegation.js
|
|
21654
21746
|
var PEER_DELEGATION_BRIDGE_VERSION = 1;
|
|
@@ -21692,6 +21784,7 @@ var peerDelegationHostProjectSchema = external_exports.strictObject({
|
|
|
21692
21784
|
});
|
|
21693
21785
|
var peerDelegationHostSummarySchema = external_exports.strictObject({
|
|
21694
21786
|
hostId: remotePeerHostIdSchema,
|
|
21787
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21695
21788
|
displayName: external_exports.string().min(1).max(120),
|
|
21696
21789
|
online: external_exports.boolean(),
|
|
21697
21790
|
state: remotePeerStateSchema,
|
|
@@ -22579,6 +22672,13 @@ var updatePhaseSchema = external_exports.enum([
|
|
|
22579
22672
|
"succeeded",
|
|
22580
22673
|
"failed"
|
|
22581
22674
|
]);
|
|
22675
|
+
var npmDownloadProgressSchema = external_exports.strictObject({
|
|
22676
|
+
completed: external_exports.number().int().nonnegative(),
|
|
22677
|
+
total: external_exports.number().int().positive()
|
|
22678
|
+
}).refine((progress) => progress.completed <= progress.total, {
|
|
22679
|
+
path: ["completed"],
|
|
22680
|
+
message: "completed must not exceed total"
|
|
22681
|
+
});
|
|
22582
22682
|
var updateStatusSchema = external_exports.strictObject({
|
|
22583
22683
|
version: updateSemanticVersionSchema,
|
|
22584
22684
|
installation: updateInstallationSchema,
|
|
@@ -22586,6 +22686,7 @@ var updateStatusSchema = external_exports.strictObject({
|
|
|
22586
22686
|
updatedAt: external_exports.number().int().nonnegative(),
|
|
22587
22687
|
downloadedBytes: external_exports.number().int().nonnegative().optional(),
|
|
22588
22688
|
totalBytes: external_exports.number().int().positive().optional(),
|
|
22689
|
+
npmDownload: npmDownloadProgressSchema.optional(),
|
|
22589
22690
|
error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable(),
|
|
22590
22691
|
serviceStopOutput: external_exports.string().optional()
|
|
22591
22692
|
}).superRefine((status, context) => {
|
|
@@ -22928,11 +23029,11 @@ import { createHash } from "node:crypto";
|
|
|
22928
23029
|
import { lstat, readdir } from "node:fs/promises";
|
|
22929
23030
|
import os from "node:os";
|
|
22930
23031
|
import path from "node:path";
|
|
23032
|
+
import { performance } from "node:perf_hooks";
|
|
22931
23033
|
import { setImmediate as yieldToEventLoop } from "node:timers/promises";
|
|
22932
23034
|
|
|
22933
23035
|
// ../../harness-adapter/dist/usage-statistics.js
|
|
22934
23036
|
import { createReadStream } from "node:fs";
|
|
22935
|
-
import { createInterface } from "node:readline";
|
|
22936
23037
|
var HarnessUsageSourceChangedError = class extends Error {
|
|
22937
23038
|
code = "HARNESS_USAGE_SOURCE_CHANGED";
|
|
22938
23039
|
/** Plugins may bundle their own copy of this contract, so instanceof is insufficient. */
|
|
@@ -23031,12 +23132,59 @@ function parseHarnessUsageEntry(value) {
|
|
|
23031
23132
|
}
|
|
23032
23133
|
return entry;
|
|
23033
23134
|
}
|
|
23135
|
+
var JSONL_CHUNK_BYTES = 128 * 1024;
|
|
23136
|
+
var JSONL_HEADER_CHUNK_BYTES = 16 * 1024;
|
|
23137
|
+
function concatParts(parts, total) {
|
|
23138
|
+
const [single] = parts;
|
|
23139
|
+
return single && parts.length === 1 ? single : Buffer.concat(parts, total);
|
|
23140
|
+
}
|
|
23141
|
+
async function* jsonlLineSlices(file2, signal, highWaterMark) {
|
|
23142
|
+
const stream = createReadStream(file2, { highWaterMark, signal });
|
|
23143
|
+
let parts = [];
|
|
23144
|
+
let buffered = 0;
|
|
23145
|
+
try {
|
|
23146
|
+
for await (const raw of stream) {
|
|
23147
|
+
signal.throwIfAborted();
|
|
23148
|
+
const chunk = raw;
|
|
23149
|
+
let start = 0;
|
|
23150
|
+
let end;
|
|
23151
|
+
while ((end = chunk.indexOf(10, start)) >= 0) {
|
|
23152
|
+
const lineEnd = end > start && chunk[end - 1] === 13 ? end - 1 : end;
|
|
23153
|
+
const slice = chunk.subarray(start, lineEnd);
|
|
23154
|
+
if (buffered === 0) {
|
|
23155
|
+
yield slice;
|
|
23156
|
+
} else {
|
|
23157
|
+
if (slice.length > 0) {
|
|
23158
|
+
parts.push(slice);
|
|
23159
|
+
buffered += slice.length;
|
|
23160
|
+
}
|
|
23161
|
+
const combined = concatParts(parts, buffered);
|
|
23162
|
+
parts = [];
|
|
23163
|
+
buffered = 0;
|
|
23164
|
+
yield combined.length > 0 && combined[combined.length - 1] === 13 ? combined.subarray(0, combined.length - 1) : combined;
|
|
23165
|
+
}
|
|
23166
|
+
start = end + 1;
|
|
23167
|
+
}
|
|
23168
|
+
if (start < chunk.length) {
|
|
23169
|
+
const rest = chunk.subarray(start);
|
|
23170
|
+
parts.push(rest);
|
|
23171
|
+
buffered += rest.length;
|
|
23172
|
+
}
|
|
23173
|
+
}
|
|
23174
|
+
if (buffered > 0) {
|
|
23175
|
+
const combined = concatParts(parts, buffered);
|
|
23176
|
+
yield combined.length > 0 && combined[combined.length - 1] === 13 ? combined.subarray(0, combined.length - 1) : combined;
|
|
23177
|
+
}
|
|
23178
|
+
} finally {
|
|
23179
|
+
stream.destroy();
|
|
23180
|
+
}
|
|
23181
|
+
}
|
|
23034
23182
|
async function* jsonlRecords(file2, marker, signal) {
|
|
23035
|
-
const
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
|
|
23183
|
+
const markerBytes = marker.length > 0 ? Buffer.from(marker, "utf8") : null;
|
|
23184
|
+
for await (const rawLine of jsonlLineSlices(file2, signal, JSONL_CHUNK_BYTES)) {
|
|
23185
|
+
if (markerBytes && !rawLine.includes(markerBytes))
|
|
23186
|
+
continue;
|
|
23187
|
+
const line = rawLine.toString("utf8");
|
|
23040
23188
|
if (!line.includes(marker))
|
|
23041
23189
|
continue;
|
|
23042
23190
|
let value;
|
|
@@ -23459,7 +23607,6 @@ var CodexCounters = class {
|
|
|
23459
23607
|
|
|
23460
23608
|
// dist/rollout-io.js
|
|
23461
23609
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
23462
|
-
import { StringDecoder } from "node:string_decoder";
|
|
23463
23610
|
import { pipeline } from "node:stream/promises";
|
|
23464
23611
|
import { Readable } from "node:stream";
|
|
23465
23612
|
import { constants as zstdConstants, createZstdDecompress } from "node:zlib";
|
|
@@ -23485,10 +23632,16 @@ import { constants as zstdConstants, createZstdDecompress } from "node:zlib";
|
|
|
23485
23632
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23486
23633
|
* SOFTWARE.
|
|
23487
23634
|
*/
|
|
23635
|
+
var BLOCK_SIZE = 128 * 1024;
|
|
23636
|
+
var ZSTD_READ_SIZE = 512 * 1024;
|
|
23488
23637
|
var MAX_LINE = 128 * 1024 * 1024;
|
|
23638
|
+
var PEEK_BYTES = 4096;
|
|
23489
23639
|
async function* rolloutBytes(file2, signal) {
|
|
23490
23640
|
signal.throwIfAborted();
|
|
23491
|
-
const stream = createReadStream2(file2, {
|
|
23641
|
+
const stream = createReadStream2(file2, {
|
|
23642
|
+
highWaterMark: file2.endsWith(".zst") ? ZSTD_READ_SIZE : BLOCK_SIZE,
|
|
23643
|
+
signal
|
|
23644
|
+
});
|
|
23492
23645
|
try {
|
|
23493
23646
|
if (!file2.endsWith(".zst")) {
|
|
23494
23647
|
for await (const chunk of stream) {
|
|
@@ -23500,6 +23653,12 @@ async function* rolloutBytes(file2, signal) {
|
|
|
23500
23653
|
const input3 = stream[Symbol.asyncIterator]();
|
|
23501
23654
|
let pending = Buffer.alloc(0);
|
|
23502
23655
|
async function readExact(size, allowEof = false) {
|
|
23656
|
+
signal.throwIfAborted();
|
|
23657
|
+
if (pending.length >= size) {
|
|
23658
|
+
const slice = pending.subarray(0, size);
|
|
23659
|
+
pending = pending.subarray(size);
|
|
23660
|
+
return slice;
|
|
23661
|
+
}
|
|
23503
23662
|
const parts = [];
|
|
23504
23663
|
let length = 0;
|
|
23505
23664
|
while (length < size) {
|
|
@@ -23518,7 +23677,8 @@ async function* rolloutBytes(file2, signal) {
|
|
|
23518
23677
|
pending = pending.subarray(count2);
|
|
23519
23678
|
length += count2;
|
|
23520
23679
|
}
|
|
23521
|
-
|
|
23680
|
+
const [firstPart] = parts;
|
|
23681
|
+
return firstPart && parts.length === 1 ? firstPart : Buffer.concat(parts, length);
|
|
23522
23682
|
}
|
|
23523
23683
|
for (; ; ) {
|
|
23524
23684
|
const magicBytes = await readExact(4, true);
|
|
@@ -23528,7 +23688,7 @@ async function* rolloutBytes(file2, signal) {
|
|
|
23528
23688
|
if ((magic & 4294967280) === 407710288) {
|
|
23529
23689
|
let size = (await readExact(4)).readUInt32LE(0);
|
|
23530
23690
|
while (size) {
|
|
23531
|
-
const count2 = Math.min(size,
|
|
23691
|
+
const count2 = Math.min(size, ZSTD_READ_SIZE);
|
|
23532
23692
|
await readExact(count2);
|
|
23533
23693
|
size -= count2;
|
|
23534
23694
|
}
|
|
@@ -23545,17 +23705,44 @@ async function* rolloutBytes(file2, signal) {
|
|
|
23545
23705
|
const header = Buffer.concat([magicBytes, descriptorBytes, await readExact(headerSize)]);
|
|
23546
23706
|
async function* frameChunks() {
|
|
23547
23707
|
yield header;
|
|
23548
|
-
|
|
23708
|
+
let done = false;
|
|
23709
|
+
while (!done) {
|
|
23710
|
+
signal.throwIfAborted();
|
|
23711
|
+
let batchEnd = 0;
|
|
23712
|
+
while (pending.length - batchEnd >= 3) {
|
|
23713
|
+
const block2 = pending.readUIntLE(batchEnd, 3);
|
|
23714
|
+
const type2 = block2 >> 1 & 3;
|
|
23715
|
+
if (type2 === 3)
|
|
23716
|
+
throw new Error("Reserved Codex zstd block");
|
|
23717
|
+
const blockSize2 = block2 >>> 3;
|
|
23718
|
+
if (blockSize2 > BLOCK_SIZE)
|
|
23719
|
+
throw new Error("Invalid Codex zstd block size");
|
|
23720
|
+
const step = 3 + (type2 === 1 ? 1 : blockSize2);
|
|
23721
|
+
if (pending.length - batchEnd < step)
|
|
23722
|
+
break;
|
|
23723
|
+
batchEnd += step;
|
|
23724
|
+
if (block2 & 1) {
|
|
23725
|
+
done = true;
|
|
23726
|
+
break;
|
|
23727
|
+
}
|
|
23728
|
+
}
|
|
23729
|
+
if (batchEnd > 0) {
|
|
23730
|
+
const batch = pending.subarray(0, batchEnd);
|
|
23731
|
+
pending = pending.subarray(batchEnd);
|
|
23732
|
+
yield batch;
|
|
23733
|
+
if (done)
|
|
23734
|
+
break;
|
|
23735
|
+
}
|
|
23549
23736
|
const blockBytes = await readExact(3);
|
|
23550
23737
|
const block = blockBytes.readUIntLE(0, 3);
|
|
23551
23738
|
const type = block >> 1 & 3;
|
|
23552
23739
|
if (type === 3)
|
|
23553
23740
|
throw new Error("Reserved Codex zstd block");
|
|
23554
23741
|
const blockSize = block >>> 3;
|
|
23555
|
-
if (blockSize >
|
|
23742
|
+
if (blockSize > BLOCK_SIZE)
|
|
23556
23743
|
throw new Error("Invalid Codex zstd block size");
|
|
23557
|
-
|
|
23558
|
-
yield
|
|
23744
|
+
const body = await readExact(type === 1 ? 1 : blockSize);
|
|
23745
|
+
yield Buffer.concat([blockBytes, body], 3 + body.length);
|
|
23559
23746
|
if (block & 1)
|
|
23560
23747
|
break;
|
|
23561
23748
|
}
|
|
@@ -23564,7 +23751,7 @@ async function* rolloutBytes(file2, signal) {
|
|
|
23564
23751
|
}
|
|
23565
23752
|
const frame = Readable.from(frameChunks(), { objectMode: false });
|
|
23566
23753
|
const decoder = createZstdDecompress({
|
|
23567
|
-
chunkSize:
|
|
23754
|
+
chunkSize: BLOCK_SIZE,
|
|
23568
23755
|
params: { [zstdConstants.ZSTD_d_windowLogMax]: 27 }
|
|
23569
23756
|
});
|
|
23570
23757
|
const completed = pipeline(frame, decoder, { signal }).then(() => null, (error62) => error62);
|
|
@@ -23586,25 +23773,98 @@ async function* rolloutBytes(file2, signal) {
|
|
|
23586
23773
|
stream.destroy();
|
|
23587
23774
|
}
|
|
23588
23775
|
}
|
|
23589
|
-
|
|
23590
|
-
const
|
|
23591
|
-
|
|
23776
|
+
function copyEdgeBytes(parts, total, take, head) {
|
|
23777
|
+
const length = Math.min(total, take);
|
|
23778
|
+
const out = Buffer.allocUnsafe(length);
|
|
23779
|
+
if (head) {
|
|
23780
|
+
let offset2 = 0;
|
|
23781
|
+
for (const part of parts) {
|
|
23782
|
+
const count2 = Math.min(part.length, length - offset2);
|
|
23783
|
+
part.copy(out, offset2, 0, count2);
|
|
23784
|
+
offset2 += count2;
|
|
23785
|
+
if (offset2 >= length)
|
|
23786
|
+
break;
|
|
23787
|
+
}
|
|
23788
|
+
return out;
|
|
23789
|
+
}
|
|
23790
|
+
let offset = length;
|
|
23791
|
+
for (let i = parts.length - 1; i >= 0 && offset > 0; i--) {
|
|
23792
|
+
const part = parts[i];
|
|
23793
|
+
if (!part)
|
|
23794
|
+
continue;
|
|
23795
|
+
const count2 = Math.min(part.length, offset);
|
|
23796
|
+
part.copy(out, offset - count2, part.length - count2, part.length);
|
|
23797
|
+
offset -= count2;
|
|
23798
|
+
}
|
|
23799
|
+
let start = 0;
|
|
23800
|
+
while (start < 3 && start < out.length && ((out[start] ?? 0) & 192) === 128)
|
|
23801
|
+
start += 1;
|
|
23802
|
+
return out.subarray(start);
|
|
23803
|
+
}
|
|
23804
|
+
async function* rolloutLines(file2, signal, shouldDecode) {
|
|
23805
|
+
let parts = [];
|
|
23806
|
+
let buffered = 0;
|
|
23807
|
+
const decodeMultiChunk = () => {
|
|
23808
|
+
if (shouldDecode && buffered > PEEK_BYTES * 2) {
|
|
23809
|
+
const head = copyEdgeBytes(parts, buffered, PEEK_BYTES, true).toString("utf8").slice(0, 1024);
|
|
23810
|
+
const tail = copyEdgeBytes(parts, buffered, PEEK_BYTES, false).toString("utf8").slice(-1024);
|
|
23811
|
+
if (!shouldDecode(head, tail)) {
|
|
23812
|
+
parts = [];
|
|
23813
|
+
buffered = 0;
|
|
23814
|
+
return null;
|
|
23815
|
+
}
|
|
23816
|
+
}
|
|
23817
|
+
const [single] = parts;
|
|
23818
|
+
const line = (single && parts.length === 1 ? single : Buffer.concat(parts, buffered)).toString("utf8");
|
|
23819
|
+
parts = [];
|
|
23820
|
+
buffered = 0;
|
|
23821
|
+
return line;
|
|
23822
|
+
};
|
|
23592
23823
|
for await (const chunk of rolloutBytes(file2, signal)) {
|
|
23593
|
-
|
|
23594
|
-
let
|
|
23595
|
-
while ((end =
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23824
|
+
let start = 0;
|
|
23825
|
+
let end;
|
|
23826
|
+
while ((end = chunk.indexOf(10, start)) >= 0) {
|
|
23827
|
+
const slice = chunk.subarray(start, end);
|
|
23828
|
+
if (buffered === 0) {
|
|
23829
|
+
if (slice.length > MAX_LINE)
|
|
23830
|
+
throw new Error("Codex rollout line exceeds the safety limit");
|
|
23831
|
+
if (shouldDecode && slice.length > PEEK_BYTES * 2) {
|
|
23832
|
+
const head = slice.subarray(0, PEEK_BYTES).toString("utf8").slice(0, 1024);
|
|
23833
|
+
let tailStart = slice.length - PEEK_BYTES;
|
|
23834
|
+
while (tailStart < slice.length && ((slice[tailStart] ?? 0) & 192) === 128)
|
|
23835
|
+
tailStart += 1;
|
|
23836
|
+
const tail = slice.subarray(tailStart).toString("utf8").slice(-1024);
|
|
23837
|
+
if (!shouldDecode(head, tail)) {
|
|
23838
|
+
start = end + 1;
|
|
23839
|
+
continue;
|
|
23840
|
+
}
|
|
23841
|
+
}
|
|
23842
|
+
yield slice.toString("utf8");
|
|
23843
|
+
} else {
|
|
23844
|
+
buffered += slice.length;
|
|
23845
|
+
if (buffered > MAX_LINE)
|
|
23846
|
+
throw new Error("Codex rollout line exceeds the safety limit");
|
|
23847
|
+
if (slice.length > 0)
|
|
23848
|
+
parts.push(slice);
|
|
23849
|
+
const decoded = decodeMultiChunk();
|
|
23850
|
+
if (decoded !== null)
|
|
23851
|
+
yield decoded;
|
|
23852
|
+
}
|
|
23599
23853
|
start = end + 1;
|
|
23600
23854
|
}
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
|
|
23855
|
+
if (start < chunk.length) {
|
|
23856
|
+
const rest = chunk.subarray(start);
|
|
23857
|
+
buffered += rest.length;
|
|
23858
|
+
if (buffered > MAX_LINE)
|
|
23859
|
+
throw new Error("Codex rollout line exceeds the safety limit");
|
|
23860
|
+
parts.push(rest);
|
|
23861
|
+
}
|
|
23862
|
+
}
|
|
23863
|
+
if (buffered > 0) {
|
|
23864
|
+
const decoded = decodeMultiChunk();
|
|
23865
|
+
if (decoded !== null && decoded.trim())
|
|
23866
|
+
yield decoded;
|
|
23604
23867
|
}
|
|
23605
|
-
pending += decoder.end();
|
|
23606
|
-
if (pending.trim())
|
|
23607
|
-
yield pending;
|
|
23608
23868
|
}
|
|
23609
23869
|
async function copyRelation(a, b, signal) {
|
|
23610
23870
|
const left = rolloutBytes(a, signal), right = rolloutBytes(b, signal);
|
|
@@ -23657,14 +23917,32 @@ var HEAD_TYPE = /"type"\s*:\s*"([^"]+)"/u;
|
|
|
23657
23917
|
var TAIL_TYPE = /"type"\s*:\s*"([^"]+)"\s*\}\s*$/u;
|
|
23658
23918
|
var USER_ROLE = /"role"\s*:\s*"user"/u;
|
|
23659
23919
|
var EVENT_OF_INTEREST = /"type"\s*:\s*"(?:token_count|task_started|task_complete|thread_settings_applied|user_message)"/u;
|
|
23660
|
-
function
|
|
23661
|
-
const head = HEAD_TYPE.exec(
|
|
23920
|
+
function rowKindFromEdges(headSlice, tailSlice) {
|
|
23921
|
+
const head = HEAD_TYPE.exec(headSlice)?.[1];
|
|
23662
23922
|
if (head && ROW_KINDS.has(head))
|
|
23663
23923
|
return head;
|
|
23664
|
-
return TAIL_TYPE.exec(
|
|
23924
|
+
return TAIL_TYPE.exec(tailSlice)?.[1] ?? head;
|
|
23925
|
+
}
|
|
23926
|
+
function rowKind(line) {
|
|
23927
|
+
return rowKindFromEdges(line.slice(0, 1024), line.slice(-1024));
|
|
23928
|
+
}
|
|
23929
|
+
function markerInEdges(pattern, headSlice, tailSlice) {
|
|
23930
|
+
return pattern.test(headSlice) || pattern.test(tailSlice);
|
|
23665
23931
|
}
|
|
23666
23932
|
function markerIn(pattern, line) {
|
|
23667
|
-
return pattern
|
|
23933
|
+
return markerInEdges(pattern, line.slice(0, 1024), line.slice(-1024));
|
|
23934
|
+
}
|
|
23935
|
+
function shouldDecodeUnboundedLine(headSlice, tailSlice) {
|
|
23936
|
+
const kind = rowKindFromEdges(headSlice, tailSlice);
|
|
23937
|
+
if (!kind)
|
|
23938
|
+
return true;
|
|
23939
|
+
if (!ROW_KINDS.has(kind))
|
|
23940
|
+
return false;
|
|
23941
|
+
if (kind === "response_item")
|
|
23942
|
+
return markerInEdges(USER_ROLE, headSlice, tailSlice);
|
|
23943
|
+
if (kind === "event_msg")
|
|
23944
|
+
return markerInEdges(EVENT_OF_INTEREST, headSlice, tailSlice);
|
|
23945
|
+
return true;
|
|
23668
23946
|
}
|
|
23669
23947
|
async function stamp(file2) {
|
|
23670
23948
|
const s = await lstat(file2, { bigint: true });
|
|
@@ -23720,11 +23998,15 @@ async function readCodexRollouts(files, thread2, signal, options = {}) {
|
|
|
23720
23998
|
const counters = new CodexCounters();
|
|
23721
23999
|
let model2 = "", cwd = "", ownFrom = null, firstMeta = false, forkAt = 0, seen = 0, firstPrompt;
|
|
23722
24000
|
let lastOrdinal = -1;
|
|
24001
|
+
let yieldedAt = performance.now();
|
|
24002
|
+
const filterEdges = options.endOrdinalExclusive === void 0 ? shouldDecodeUnboundedLine : void 0;
|
|
23723
24003
|
reading: for (const file2 of files) {
|
|
23724
|
-
for await (const line of rolloutLines(file2, signal)) {
|
|
24004
|
+
for await (const line of rolloutLines(file2, signal, filterEdges)) {
|
|
23725
24005
|
signal.throwIfAborted();
|
|
23726
|
-
if (++seen
|
|
24006
|
+
if ((++seen & 511) === 0 && performance.now() - yieldedAt >= 12) {
|
|
23727
24007
|
await yieldToEventLoop(void 0, { signal });
|
|
24008
|
+
yieldedAt = performance.now();
|
|
24009
|
+
}
|
|
23728
24010
|
if (options.endOrdinalExclusive !== void 0) {
|
|
23729
24011
|
if (lastOrdinal >= options.endOrdinalExclusive - 1)
|
|
23730
24012
|
break reading;
|
|
@@ -23865,13 +24147,29 @@ function createCodexUsageStatistics(environment, options = {}) {
|
|
|
23865
24147
|
const groups = /* @__PURE__ */ new Map();
|
|
23866
24148
|
let names = /* @__PURE__ */ new Map();
|
|
23867
24149
|
let namesStamp = "";
|
|
24150
|
+
let namesLoading = null;
|
|
23868
24151
|
async function threadNames(signal) {
|
|
23869
24152
|
const current = await stamp(path.join(home, "session_index.jsonl")).catch(() => "-");
|
|
23870
24153
|
if (namesStamp === current)
|
|
23871
24154
|
return names;
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
|
|
24155
|
+
if (namesLoading?.stamp === current && namesLoading.signal === signal) {
|
|
24156
|
+
return namesLoading.promise;
|
|
24157
|
+
}
|
|
24158
|
+
const promise2 = readThreadNames(home, signal).then((loaded) => {
|
|
24159
|
+
if (namesLoading?.promise === promise2) {
|
|
24160
|
+
names = loaded;
|
|
24161
|
+
namesStamp = current;
|
|
24162
|
+
}
|
|
24163
|
+
return loaded;
|
|
24164
|
+
});
|
|
24165
|
+
const entry = { stamp: current, signal, promise: promise2 };
|
|
24166
|
+
namesLoading = entry;
|
|
24167
|
+
try {
|
|
24168
|
+
return await promise2;
|
|
24169
|
+
} finally {
|
|
24170
|
+
if (namesLoading === entry)
|
|
24171
|
+
namesLoading = null;
|
|
24172
|
+
}
|
|
23875
24173
|
}
|
|
23876
24174
|
return {
|
|
23877
24175
|
async listSources(signal) {
|
|
@@ -23883,31 +24181,45 @@ function createCodexUsageStatistics(environment, options = {}) {
|
|
|
23883
24181
|
return [];
|
|
23884
24182
|
throw error62;
|
|
23885
24183
|
});
|
|
23886
|
-
|
|
23887
|
-
|
|
24184
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
24185
|
+
const subdirectories = [];
|
|
24186
|
+
const candidates = [];
|
|
24187
|
+
for (const entry of entries) {
|
|
23888
24188
|
const file2 = path.join(directory, entry.name);
|
|
23889
24189
|
if (entry.isDirectory() && depth < 4)
|
|
23890
|
-
|
|
24190
|
+
subdirectories.push(file2);
|
|
23891
24191
|
if (!entry.isFile())
|
|
23892
24192
|
continue;
|
|
23893
24193
|
const thread2 = ROLLOUT.exec(entry.name)?.[1];
|
|
23894
24194
|
if (!thread2 || options.sessionId && thread2 !== options.sessionId)
|
|
23895
24195
|
continue;
|
|
24196
|
+
candidates.push({ thread: thread2, file: file2 });
|
|
24197
|
+
}
|
|
24198
|
+
const stamped = await Promise.all(candidates.map(async ({ thread: thread2, file: file2 }) => ({
|
|
24199
|
+
thread: thread2,
|
|
24200
|
+
file: file2,
|
|
24201
|
+
fingerprint: await stamp(file2)
|
|
24202
|
+
})));
|
|
24203
|
+
signal.throwIfAborted();
|
|
24204
|
+
for (const { thread: thread2, file: file2, fingerprint: fileStamp } of stamped) {
|
|
23896
24205
|
const list = found.get(thread2) ?? [];
|
|
23897
|
-
list.push({ file: file2, fingerprint:
|
|
24206
|
+
list.push({ file: file2, fingerprint: fileStamp });
|
|
23898
24207
|
found.set(thread2, list);
|
|
23899
24208
|
}
|
|
24209
|
+
for (const subdirectory of subdirectories)
|
|
24210
|
+
await visit2(subdirectory, depth + 1);
|
|
23900
24211
|
}
|
|
23901
24212
|
await visit2(path.join(home, "sessions"), 0);
|
|
23902
24213
|
await visit2(path.join(home, "archived_sessions"), 0);
|
|
23903
|
-
const
|
|
24214
|
+
const indexNames = options.sessionId ? void 0 : await threadNames(signal);
|
|
23904
24215
|
const result = [];
|
|
23905
24216
|
groups.clear();
|
|
23906
24217
|
for (const [thread2, files] of found) {
|
|
23907
24218
|
files.sort((a, b) => path.basename(a.file).localeCompare(path.basename(b.file)) || a.file.localeCompare(b.file));
|
|
24219
|
+
const named = indexNames?.get(thread2);
|
|
23908
24220
|
const id2 = path.join(home, `usage-thread-${thread2}`);
|
|
23909
|
-
groups.set(id2, { thread: thread2, files });
|
|
23910
|
-
result.push({ id: id2, fingerprint: fingerprint(files,
|
|
24221
|
+
groups.set(id2, { thread: thread2, files, named });
|
|
24222
|
+
result.push({ id: id2, fingerprint: fingerprint(files, named ?? "") });
|
|
23911
24223
|
}
|
|
23912
24224
|
return result;
|
|
23913
24225
|
},
|
|
@@ -23939,10 +24251,16 @@ function createCodexUsageStatistics(environment, options = {}) {
|
|
|
23939
24251
|
kept.push(candidate);
|
|
23940
24252
|
}
|
|
23941
24253
|
const entries = await readCodexRollouts(kept.map(({ file: file2 }) => file2), group.thread, signal, options);
|
|
23942
|
-
|
|
23943
|
-
|
|
24254
|
+
const currentStamps = await Promise.all(group.files.map(({ file: file2 }) => stamp(file2)));
|
|
24255
|
+
for (let i = 0; i < group.files.length; i++) {
|
|
24256
|
+
if (currentStamps[i] !== group.files[i]?.fingerprint) {
|
|
23944
24257
|
throw new HarnessUsageSourceChangedError("Codex rollout changed while reading; refresh to retry");
|
|
24258
|
+
}
|
|
24259
|
+
}
|
|
23945
24260
|
const named = options.sessionId ? void 0 : (await threadNames(signal)).get(group.thread);
|
|
24261
|
+
if (!options.sessionId && named !== group.named) {
|
|
24262
|
+
throw new HarnessUsageSourceChangedError("Codex session index changed while reading; refresh to retry");
|
|
24263
|
+
}
|
|
23946
24264
|
return named ? entries.map((entry) => withUsageSession(entry, {
|
|
23947
24265
|
sessionId: entry.sessionId,
|
|
23948
24266
|
cwd: entry.cwd,
|