@tryvira/opencode 0.1.18 → 0.1.19
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/dist/index.js +22 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1326,13 +1326,31 @@ var required2 = (value, code) => {
|
|
|
1326
1326
|
var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1327
1327
|
var canonical2 = (value) => Array.isArray(value) ? "[" + value.map(canonical2).join(",") + "]" : value && typeof value === "object" ? "{" + Object.entries(value).filter(([, child]) => child !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => JSON.stringify(key) + ":" + canonical2(child)).join(",") + "}" : JSON.stringify(value);
|
|
1328
1328
|
var digest2 = (value) => createHash2("sha256").update(canonical2(value), "utf8").digest("hex");
|
|
1329
|
+
var messageContentText = (value) => {
|
|
1330
|
+
if (typeof value === "string") return value.trim();
|
|
1331
|
+
if (!value || typeof value !== "object") return "";
|
|
1332
|
+
if (Array.isArray(value)) return value.map(messageContentText).filter(Boolean).join("\n").trim();
|
|
1333
|
+
const record2 = asRecord(value);
|
|
1334
|
+
return text2(record2.text ?? record2.content);
|
|
1335
|
+
};
|
|
1329
1336
|
var lastUserText = (event) => {
|
|
1330
1337
|
const messages = Array.isArray(event.messages) ? event.messages : [];
|
|
1331
1338
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
1332
1339
|
const message = asRecord(messages[index]);
|
|
1333
|
-
if (message.role === "user")
|
|
1340
|
+
if (message.role === "user") {
|
|
1341
|
+
const content = messageContentText(message.content ?? message.text);
|
|
1342
|
+
if (content) return content;
|
|
1343
|
+
}
|
|
1334
1344
|
}
|
|
1335
|
-
return
|
|
1345
|
+
return messageContentText(event.input ?? event.prompt);
|
|
1346
|
+
};
|
|
1347
|
+
var toolExecutionSucceeded = (input, output) => {
|
|
1348
|
+
const error = output.error ?? input.error;
|
|
1349
|
+
if (error !== void 0 && error !== null && error !== "") return false;
|
|
1350
|
+
const status = text2(output.status ?? input.status).toLowerCase();
|
|
1351
|
+
if (["failed", "failure", "error", "cancelled", "canceled", "blocked"].includes(status)) return false;
|
|
1352
|
+
if (["completed", "complete", "success", "succeeded", "ok"].includes(status)) return true;
|
|
1353
|
+
return output.ok === true || input.ok === true;
|
|
1336
1354
|
};
|
|
1337
1355
|
var ViraOpenCodeActionError = class extends Error {
|
|
1338
1356
|
decision;
|
|
@@ -1522,7 +1540,7 @@ var v1Fallback = { async server() {
|
|
|
1522
1540
|
const decision = actionDecisions.get(contextKey(proposal) + ":" + proposal.callId);
|
|
1523
1541
|
actionDecisions.delete(contextKey(proposal) + ":" + proposal.callId);
|
|
1524
1542
|
try {
|
|
1525
|
-
await runtime.afterTool({ ...proposal, ok:
|
|
1543
|
+
await runtime.afterTool({ ...proposal, ok: toolExecutionSucceeded(input, output), result: output.output, errorCode: text2(asRecord(output.error ?? input.error).code), ...decision?.authorityReceiptDigest ? { authorityReceiptDigest: decision.authorityReceiptDigest } : {}, ...decision?.decisionDigest ? { decisionDigest: decision.decisionDigest } : {} });
|
|
1526
1544
|
} catch (error) {
|
|
1527
1545
|
if (mode === "enforce") throw error;
|
|
1528
1546
|
}
|
|
@@ -1533,5 +1551,6 @@ var index_default = { ...v2Plugin, ...v1Fallback };
|
|
|
1533
1551
|
export {
|
|
1534
1552
|
ViraOpenCodeActionError,
|
|
1535
1553
|
index_default as default,
|
|
1554
|
+
toolExecutionSucceeded,
|
|
1536
1555
|
v1Fallback
|
|
1537
1556
|
};
|