lunel-cli 0.1.49 → 0.1.51
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/ai/codex.d.ts +3 -0
- package/dist/ai/codex.js +72 -5
- package/package.json +1 -1
package/dist/ai/codex.d.ts
CHANGED
|
@@ -95,6 +95,9 @@ export declare class CodexProvider implements AIProvider {
|
|
|
95
95
|
private isAssistantMessageItem;
|
|
96
96
|
private extractIncomingItem;
|
|
97
97
|
private describeToolPart;
|
|
98
|
+
private normalizeStructuredType;
|
|
99
|
+
private extractStructuredOutput;
|
|
100
|
+
private extractDiffLikePayload;
|
|
98
101
|
private extractToolInput;
|
|
99
102
|
private describeCompletedItemOutput;
|
|
100
103
|
}
|
package/dist/ai/codex.js
CHANGED
|
@@ -502,10 +502,10 @@ export class CodexProvider {
|
|
|
502
502
|
const turnId = this.extractTurnId(params) ?? session.activeTurnId ?? `session:${session.id}`;
|
|
503
503
|
const messageId = this.ensureAssistantMessage(session, turnId);
|
|
504
504
|
const item = this.extractIncomingItem(params);
|
|
505
|
-
const normalizedType = this.
|
|
505
|
+
const normalizedType = this.normalizeStructuredType(this.readString(item.type) ?? method);
|
|
506
506
|
const itemId = this.extractItemId(params) ?? this.readString(item.id) ?? normalizedType ?? "tool";
|
|
507
507
|
const partId = `${messageId}:tool:${itemId}`;
|
|
508
|
-
const nextText = this.
|
|
508
|
+
const nextText = this.extractStructuredOutput(params, item, normalizedType);
|
|
509
509
|
const prevOutput = this.partTextById.get(partId) ?? "";
|
|
510
510
|
const output = completed
|
|
511
511
|
? nextText ?? prevOutput
|
|
@@ -516,7 +516,7 @@ export class CodexProvider {
|
|
|
516
516
|
const state = completed ? "completed" : "running";
|
|
517
517
|
const name = this.describeToolPart(normalizedType, method, item);
|
|
518
518
|
const input = this.extractToolInput(item, params);
|
|
519
|
-
const outputValue = output || this.describeCompletedItemOutput(item, normalizedType) || undefined;
|
|
519
|
+
const outputValue = output || this.describeCompletedItemOutput(item, params, normalizedType) || undefined;
|
|
520
520
|
const part = {
|
|
521
521
|
id: partId,
|
|
522
522
|
sessionID: session.id,
|
|
@@ -969,11 +969,20 @@ export class CodexProvider {
|
|
|
969
969
|
extractItemId(payload) {
|
|
970
970
|
return (this.readString(payload.itemId)
|
|
971
971
|
?? this.readString(payload.item_id)
|
|
972
|
+
?? this.readString(payload.call_id)
|
|
973
|
+
?? this.readString(payload.callId)
|
|
974
|
+
?? this.readString(payload.id)
|
|
972
975
|
?? this.readString(payload.messageId)
|
|
973
976
|
?? this.readString(payload.message_id)
|
|
974
977
|
?? this.readString(this.asRecord(payload.item).id)
|
|
975
978
|
?? this.readString(this.asRecord(payload.item).itemId)
|
|
979
|
+
?? this.readString(this.asRecord(payload.item).call_id)
|
|
980
|
+
?? this.readString(this.asRecord(payload.item).callId)
|
|
976
981
|
?? this.readString(this.asRecord(payload.item).messageId)
|
|
982
|
+
?? this.readString(this.asRecord(payload.event).itemId)
|
|
983
|
+
?? this.readString(this.asRecord(payload.event).item_id)
|
|
984
|
+
?? this.readString(this.asRecord(payload.event).call_id)
|
|
985
|
+
?? this.readString(this.asRecord(payload.event).callId)
|
|
977
986
|
?? this.readString(this.asRecord(payload.event).id)
|
|
978
987
|
?? this.readString(this.asRecord(this.asRecord(payload.event).item).id));
|
|
979
988
|
}
|
|
@@ -1083,10 +1092,68 @@ export class CodexProvider {
|
|
|
1083
1092
|
}
|
|
1084
1093
|
return this.readString(item.name) ?? method.replace(/^.*\//, "");
|
|
1085
1094
|
}
|
|
1095
|
+
normalizeStructuredType(rawType) {
|
|
1096
|
+
const normalized = this.normalizedItemType(rawType);
|
|
1097
|
+
if (normalized.includes("turndiff") || normalized === "diff")
|
|
1098
|
+
return "diff";
|
|
1099
|
+
if (normalized.includes("filechange"))
|
|
1100
|
+
return "filechange";
|
|
1101
|
+
if (normalized.includes("toolcall"))
|
|
1102
|
+
return "toolcall";
|
|
1103
|
+
if (normalized.includes("commandexecution"))
|
|
1104
|
+
return "commandexecution";
|
|
1105
|
+
return normalized;
|
|
1106
|
+
}
|
|
1107
|
+
extractStructuredOutput(params, item, normalizedType) {
|
|
1108
|
+
if (normalizedType === "filechange" || normalizedType === "toolcall" || normalizedType === "diff") {
|
|
1109
|
+
return this.extractDiffLikePayload(params, item) ?? this.extractTextPayload(params);
|
|
1110
|
+
}
|
|
1111
|
+
return this.extractTextPayload(params);
|
|
1112
|
+
}
|
|
1113
|
+
extractDiffLikePayload(params, item) {
|
|
1114
|
+
const event = this.asRecord(params.event);
|
|
1115
|
+
const nestedItem = this.asRecord(event.item);
|
|
1116
|
+
const sources = [params, item, event, nestedItem];
|
|
1117
|
+
for (const source of sources) {
|
|
1118
|
+
const direct = this.firstString(source, [
|
|
1119
|
+
"diff",
|
|
1120
|
+
"unified_diff",
|
|
1121
|
+
"unifiedDiff",
|
|
1122
|
+
"patch",
|
|
1123
|
+
]);
|
|
1124
|
+
if (direct)
|
|
1125
|
+
return direct;
|
|
1126
|
+
}
|
|
1127
|
+
const changes = this.readArray(item.changes ?? params.changes ?? event.changes ?? nestedItem.changes);
|
|
1128
|
+
if (changes.length > 0) {
|
|
1129
|
+
return changes
|
|
1130
|
+
.map((change) => {
|
|
1131
|
+
const obj = this.asRecord(change);
|
|
1132
|
+
const path = this.readString(obj.path) ?? this.readString(obj.filePath) ?? this.readString(obj.file_path) ?? "file";
|
|
1133
|
+
const kind = this.readString(obj.kind) ?? "change";
|
|
1134
|
+
const diff = this.firstString(obj, ["diff", "unified_diff", "unifiedDiff", "patch"]) ?? "";
|
|
1135
|
+
return diff ? `Path: ${path}\nKind: ${kind}\n\n\`\`\`diff\n${diff}\n\`\`\`` : `Path: ${path}\nKind: ${kind}`;
|
|
1136
|
+
})
|
|
1137
|
+
.join("\n\n---\n\n");
|
|
1138
|
+
}
|
|
1139
|
+
for (const source of sources) {
|
|
1140
|
+
const direct = this.firstString(source, [
|
|
1141
|
+
"text",
|
|
1142
|
+
"message",
|
|
1143
|
+
"summary",
|
|
1144
|
+
"output",
|
|
1145
|
+
"output_text",
|
|
1146
|
+
"outputText",
|
|
1147
|
+
]);
|
|
1148
|
+
if (direct)
|
|
1149
|
+
return direct;
|
|
1150
|
+
}
|
|
1151
|
+
return undefined;
|
|
1152
|
+
}
|
|
1086
1153
|
extractToolInput(item, params) {
|
|
1087
1154
|
return item.input ?? item.command ?? item.path ?? item.args ?? params.command ?? params.path ?? undefined;
|
|
1088
1155
|
}
|
|
1089
|
-
describeCompletedItemOutput(item, normalizedType) {
|
|
1156
|
+
describeCompletedItemOutput(item, params, normalizedType) {
|
|
1090
1157
|
if (normalizedType === "commandexecution") {
|
|
1091
1158
|
return this.firstString(item, ["stdout", "stderr", "text", "message", "summary"]);
|
|
1092
1159
|
}
|
|
@@ -1094,7 +1161,7 @@ export class CodexProvider {
|
|
|
1094
1161
|
return this.decodePlanItemText(item);
|
|
1095
1162
|
}
|
|
1096
1163
|
if (normalizedType === "filechange" || normalizedType === "toolcall" || normalizedType === "diff") {
|
|
1097
|
-
return this.decodeFileLikeItemText(item);
|
|
1164
|
+
return this.extractDiffLikePayload(params, item) ?? this.decodeFileLikeItemText(item);
|
|
1098
1165
|
}
|
|
1099
1166
|
if (normalizedType === "enteredreviewmode") {
|
|
1100
1167
|
return `Reviewing ${this.readString(item.review) ?? "changes"}...`;
|