lunel-cli 0.1.49 → 0.1.50
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 +56 -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,
|
|
@@ -1083,10 +1083,61 @@ export class CodexProvider {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
return this.readString(item.name) ?? method.replace(/^.*\//, "");
|
|
1085
1085
|
}
|
|
1086
|
+
normalizeStructuredType(rawType) {
|
|
1087
|
+
const normalized = this.normalizedItemType(rawType);
|
|
1088
|
+
if (normalized.includes("turndiff") || normalized === "diff")
|
|
1089
|
+
return "diff";
|
|
1090
|
+
if (normalized.includes("filechange"))
|
|
1091
|
+
return "filechange";
|
|
1092
|
+
if (normalized.includes("toolcall"))
|
|
1093
|
+
return "toolcall";
|
|
1094
|
+
if (normalized.includes("commandexecution"))
|
|
1095
|
+
return "commandexecution";
|
|
1096
|
+
return normalized;
|
|
1097
|
+
}
|
|
1098
|
+
extractStructuredOutput(params, item, normalizedType) {
|
|
1099
|
+
if (normalizedType === "filechange" || normalizedType === "toolcall" || normalizedType === "diff") {
|
|
1100
|
+
return this.extractDiffLikePayload(params, item) ?? this.extractTextPayload(params);
|
|
1101
|
+
}
|
|
1102
|
+
return this.extractTextPayload(params);
|
|
1103
|
+
}
|
|
1104
|
+
extractDiffLikePayload(params, item) {
|
|
1105
|
+
const event = this.asRecord(params.event);
|
|
1106
|
+
const nestedItem = this.asRecord(event.item);
|
|
1107
|
+
const sources = [params, item, event, nestedItem];
|
|
1108
|
+
for (const source of sources) {
|
|
1109
|
+
const direct = this.firstString(source, [
|
|
1110
|
+
"diff",
|
|
1111
|
+
"unified_diff",
|
|
1112
|
+
"unifiedDiff",
|
|
1113
|
+
"patch",
|
|
1114
|
+
"text",
|
|
1115
|
+
"message",
|
|
1116
|
+
"summary",
|
|
1117
|
+
"output",
|
|
1118
|
+
"output_text",
|
|
1119
|
+
"outputText",
|
|
1120
|
+
]);
|
|
1121
|
+
if (direct)
|
|
1122
|
+
return direct;
|
|
1123
|
+
}
|
|
1124
|
+
const changes = this.readArray(item.changes ?? params.changes ?? event.changes ?? nestedItem.changes);
|
|
1125
|
+
if (changes.length === 0)
|
|
1126
|
+
return undefined;
|
|
1127
|
+
return changes
|
|
1128
|
+
.map((change) => {
|
|
1129
|
+
const obj = this.asRecord(change);
|
|
1130
|
+
const path = this.readString(obj.path) ?? this.readString(obj.filePath) ?? this.readString(obj.file_path) ?? "file";
|
|
1131
|
+
const kind = this.readString(obj.kind) ?? "change";
|
|
1132
|
+
const diff = this.firstString(obj, ["diff", "unified_diff", "unifiedDiff", "patch"]) ?? "";
|
|
1133
|
+
return diff ? `Path: ${path}\nKind: ${kind}\n\n\`\`\`diff\n${diff}\n\`\`\`` : `Path: ${path}\nKind: ${kind}`;
|
|
1134
|
+
})
|
|
1135
|
+
.join("\n\n---\n\n");
|
|
1136
|
+
}
|
|
1086
1137
|
extractToolInput(item, params) {
|
|
1087
1138
|
return item.input ?? item.command ?? item.path ?? item.args ?? params.command ?? params.path ?? undefined;
|
|
1088
1139
|
}
|
|
1089
|
-
describeCompletedItemOutput(item, normalizedType) {
|
|
1140
|
+
describeCompletedItemOutput(item, params, normalizedType) {
|
|
1090
1141
|
if (normalizedType === "commandexecution") {
|
|
1091
1142
|
return this.firstString(item, ["stdout", "stderr", "text", "message", "summary"]);
|
|
1092
1143
|
}
|
|
@@ -1094,7 +1145,7 @@ export class CodexProvider {
|
|
|
1094
1145
|
return this.decodePlanItemText(item);
|
|
1095
1146
|
}
|
|
1096
1147
|
if (normalizedType === "filechange" || normalizedType === "toolcall" || normalizedType === "diff") {
|
|
1097
|
-
return this.decodeFileLikeItemText(item);
|
|
1148
|
+
return this.extractDiffLikePayload(params, item) ?? this.decodeFileLikeItemText(item);
|
|
1098
1149
|
}
|
|
1099
1150
|
if (normalizedType === "enteredreviewmode") {
|
|
1100
1151
|
return `Reviewing ${this.readString(item.review) ?? "changes"}...`;
|