@danforthh/aimprint-sync 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -152,19 +152,24 @@ var REAL_PROJECTS_DIR = (() => {
|
|
|
152
152
|
})();
|
|
153
153
|
var MACHINE = import_node_os2.default.hostname();
|
|
154
154
|
var BATCH_SIZE = 100;
|
|
155
|
-
function
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
function detectLineSepSize(filePath) {
|
|
156
|
+
const buf = Buffer.alloc(1024);
|
|
157
|
+
let fd;
|
|
158
|
+
try {
|
|
159
|
+
fd = import_node_fs2.default.openSync(filePath, "r");
|
|
160
|
+
const n = import_node_fs2.default.readSync(fd, buf, 0, 1024, 0);
|
|
161
|
+
for (let i = 0; i < n - 1; i++) {
|
|
162
|
+
if (buf[i] === 13 && buf[i + 1] === 10) return 2;
|
|
163
|
+
}
|
|
164
|
+
return 1;
|
|
165
|
+
} catch {
|
|
166
|
+
return 1;
|
|
167
|
+
} finally {
|
|
168
|
+
if (fd !== void 0) try {
|
|
169
|
+
import_node_fs2.default.closeSync(fd);
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
}
|
|
168
173
|
}
|
|
169
174
|
var TICKET_RE = /\b(PROTOP-\d+|PORTV4-\d+|NODE20-\d+)\b/i;
|
|
170
175
|
function extractTicket(branch) {
|
|
@@ -175,6 +180,7 @@ function extractTicket(branch) {
|
|
|
175
180
|
async function parseFile(filePath, offset) {
|
|
176
181
|
const stat = import_node_fs2.default.statSync(filePath);
|
|
177
182
|
if (stat.size <= offset) return { records: /* @__PURE__ */ new Map(), sessions: /* @__PURE__ */ new Map(), newOffset: offset };
|
|
183
|
+
const sepSize = detectLineSepSize(filePath);
|
|
178
184
|
const fd = import_node_fs2.default.openSync(filePath, "r");
|
|
179
185
|
const stream = import_node_fs2.default.createReadStream(filePath, { start: offset, fd, autoClose: true });
|
|
180
186
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
@@ -183,7 +189,7 @@ async function parseFile(filePath, offset) {
|
|
|
183
189
|
let newOffset = offset;
|
|
184
190
|
const lastUserMessage = /* @__PURE__ */ new Map();
|
|
185
191
|
for await (const line of rl) {
|
|
186
|
-
newOffset += Buffer.byteLength(line +
|
|
192
|
+
newOffset += Buffer.byteLength(line) + sepSize;
|
|
187
193
|
if (!line.trim()) continue;
|
|
188
194
|
let d;
|
|
189
195
|
try {
|
|
@@ -283,7 +289,8 @@ async function parseFile(filePath, offset) {
|
|
|
283
289
|
cache_read: cacheR,
|
|
284
290
|
cache_creation: cacheC,
|
|
285
291
|
is_sidechain: d.isSidechain ? 1 : 0,
|
|
286
|
-
cost_usd:
|
|
292
|
+
cost_usd: 0,
|
|
293
|
+
// worker recomputes server-side from its own pricing table
|
|
287
294
|
request_category: reqCategory
|
|
288
295
|
});
|
|
289
296
|
}
|