@cortexkit/pi-magic-context 0.49.9 → 0.49.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/dist/index.js +39 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3432,7 +3432,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3432
3432
|
// package.json
|
|
3433
3433
|
var package_default = {
|
|
3434
3434
|
name: "@cortexkit/pi-magic-context",
|
|
3435
|
-
version: "0.49.
|
|
3435
|
+
version: "0.49.10",
|
|
3436
3436
|
type: "module",
|
|
3437
3437
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3438
3438
|
main: "dist/index.js",
|
|
@@ -34576,16 +34576,25 @@ function piResponsesAssistantTexts(value, model) {
|
|
|
34576
34576
|
blocks.push(block);
|
|
34577
34577
|
}
|
|
34578
34578
|
const payload = object4(message.providerPayload);
|
|
34579
|
-
if (message.api !== model?.api || typeof model?.id !== "string" || typeof model?.provider !== "string" || message.model !== model?.id || (payload?.provider ?? message.provider) !== model?.provider || payload?.type !== "openaiResponsesHistory" || payload.dt !== true || !Array.isArray(payload.items)
|
|
34579
|
+
if (message.api !== model?.api || typeof model?.id !== "string" || typeof model?.provider !== "string" || message.model !== model?.id || (payload?.provider ?? message.provider) !== model?.provider || payload?.type !== "openaiResponsesHistory" || payload.dt !== true || !Array.isArray(payload.items))
|
|
34580
34580
|
return texts;
|
|
34581
34581
|
const replay = [];
|
|
34582
|
+
let bound = 0;
|
|
34583
|
+
let output = false;
|
|
34582
34584
|
for (const value of payload.items) {
|
|
34583
34585
|
const item = object4(value);
|
|
34586
|
+
if (item?.type === "reasoning")
|
|
34587
|
+
continue;
|
|
34588
|
+
if (item?.type === "function_call" || item?.type === "custom_tool_call") {
|
|
34589
|
+
output = true;
|
|
34590
|
+
continue;
|
|
34591
|
+
}
|
|
34584
34592
|
if (item?.type !== "message" || item.role !== "assistant" || !Array.isArray(item.content))
|
|
34585
34593
|
return texts;
|
|
34594
|
+
const itemTexts = [];
|
|
34586
34595
|
for (const value of item.content) {
|
|
34587
34596
|
const part = object4(value);
|
|
34588
|
-
const block = blocks[
|
|
34597
|
+
const block = blocks[bound];
|
|
34589
34598
|
if (!block || part?.type !== "output_text" || typeof part.text !== "string")
|
|
34590
34599
|
return texts;
|
|
34591
34600
|
let signature;
|
|
@@ -34597,10 +34606,16 @@ function piResponsesAssistantTexts(value, model) {
|
|
|
34597
34606
|
}
|
|
34598
34607
|
if (signature?.v !== 1 || typeof signature.id !== "string" || item.id !== signature.id || item.phase !== signature.phase || part.text !== block.text.replace(/^§\d+§ /u, ""))
|
|
34599
34608
|
return texts;
|
|
34600
|
-
|
|
34609
|
+
bound++;
|
|
34610
|
+
itemTexts.push(part.text);
|
|
34601
34611
|
}
|
|
34612
|
+
if (!itemTexts.some((text) => /\S/u.test(text)))
|
|
34613
|
+
continue;
|
|
34614
|
+
output = true;
|
|
34615
|
+
for (const text of itemTexts)
|
|
34616
|
+
replay.push(textIdentity2(wellFormed(text), item.phase));
|
|
34602
34617
|
}
|
|
34603
|
-
return
|
|
34618
|
+
return output && bound === blocks.length ? replay : texts;
|
|
34604
34619
|
}
|
|
34605
34620
|
function piResponsesWireTexts(value, phase) {
|
|
34606
34621
|
if (phase !== undefined && phase !== null && phase !== "commentary" && phase !== "final_answer")
|
|
@@ -35313,6 +35328,10 @@ function trimPreparedImageRows(rows, budget, drops) {
|
|
|
35313
35328
|
return projected;
|
|
35314
35329
|
}
|
|
35315
35330
|
function piPreparedStructureMismatch(payload, prepared, onImageTrim) {
|
|
35331
|
+
let stage = "image count";
|
|
35332
|
+
let row = 0;
|
|
35333
|
+
let expectedRows;
|
|
35334
|
+
let rows;
|
|
35316
35335
|
try {
|
|
35317
35336
|
if (prepared?.structuralSkipReason)
|
|
35318
35337
|
return;
|
|
@@ -35322,21 +35341,25 @@ function piPreparedStructureMismatch(payload, prepared, onImageTrim) {
|
|
|
35322
35341
|
if (trimmed < 0)
|
|
35323
35342
|
return "comparison=image count";
|
|
35324
35343
|
const imageProjection = trimmed > 0;
|
|
35344
|
+
stage = "wire rows";
|
|
35325
35345
|
const body = object5(payload);
|
|
35326
35346
|
const ollama = prepared?.api === "ollama-chat" && !!body && Array.isArray(body.messages) && body.input === undefined && body.system === undefined && body.inferenceConfig === undefined;
|
|
35327
35347
|
const responses = body?.messages === undefined && Array.isArray(body?.input);
|
|
35328
|
-
|
|
35348
|
+
rows = payloadStructure(payload, ollama, responses && !!prepared?.responsesMessages, imageProjection);
|
|
35329
35349
|
const chat = !!body && Array.isArray(body.messages) && (prepared?.api === "openai-completions" || body.system === undefined) && body.input === undefined && body.inferenceConfig === undefined;
|
|
35330
|
-
|
|
35350
|
+
stage = "prepared rows";
|
|
35351
|
+
expectedRows = responses && prepared?.responsesMessages ? prepared.responsesMessages : chat && prepared?.chatMessages ? prepared.chatMessages : prepared?.messages;
|
|
35331
35352
|
if (expectedRows && imageProjection && imageBudget)
|
|
35332
35353
|
expectedRows = trimPreparedImageRows(expectedRows, imageBudget, trimmed);
|
|
35333
35354
|
if (!rows || !expectedRows)
|
|
35334
35355
|
return structureDetail(0, expectedRows, rows, "count");
|
|
35335
35356
|
if (!body)
|
|
35336
35357
|
return structureDetail(0, expectedRows, rows, "count");
|
|
35358
|
+
stage = "row comparison";
|
|
35337
35359
|
const google = !!piGoogleConversation(payload);
|
|
35338
35360
|
const anthropic = google || body.inferenceConfig !== undefined || prepared?.api === "anthropic-messages" || !prepared?.api && body.max_tokens !== undefined && Array.isArray(body.system);
|
|
35339
35361
|
for (let i = 0;i < Math.min(rows.length, expectedRows.length); i++) {
|
|
35362
|
+
row = i;
|
|
35340
35363
|
const expected = expectedRows[i];
|
|
35341
35364
|
const actual = rows[i];
|
|
35342
35365
|
if (actual.role !== expected.role)
|
|
@@ -35371,8 +35394,15 @@ function piPreparedStructureMismatch(payload, prepared, onImageTrim) {
|
|
|
35371
35394
|
trimmed
|
|
35372
35395
|
});
|
|
35373
35396
|
return;
|
|
35374
|
-
} catch {
|
|
35375
|
-
|
|
35397
|
+
} catch (error) {
|
|
35398
|
+
const name = error instanceof Error && [
|
|
35399
|
+
"Error",
|
|
35400
|
+
"TypeError",
|
|
35401
|
+
"RangeError",
|
|
35402
|
+
"SyntaxError",
|
|
35403
|
+
"ReferenceError"
|
|
35404
|
+
].includes(error.constructor.name) ? error.constructor.name : "unknown";
|
|
35405
|
+
return `${structureDetail(row, expectedRows, rows, "exception")} stage=${stage} error=${name}`;
|
|
35376
35406
|
}
|
|
35377
35407
|
}
|
|
35378
35408
|
|
package/package.json
CHANGED