opencode-usage-coach 0.2.2 → 0.2.3
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 +12 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73,6 +73,7 @@ function readHarnessCfg(dir) {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
async function runModel(client, model, prompt, directory) {
|
|
76
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
76
77
|
try {
|
|
77
78
|
const slash = model.indexOf("/");
|
|
78
79
|
const providerID = slash >= 0 ? model.slice(0, slash) : model;
|
|
@@ -80,11 +81,20 @@ async function runModel(client, model, prompt, directory) {
|
|
|
80
81
|
const s = await client.session.create({ body: { title: "uc-harness-sub" }, query: { directory } });
|
|
81
82
|
const id = s?.data?.info?.id;
|
|
82
83
|
if (!id) return null;
|
|
83
|
-
|
|
84
|
+
await client.session.prompt({
|
|
84
85
|
path: { id },
|
|
85
86
|
body: { model: { providerID, modelID }, parts: [{ type: "text", text: prompt }] }
|
|
86
87
|
});
|
|
87
|
-
|
|
88
|
+
for (let i = 0; i < 600; i++) {
|
|
89
|
+
await sleep(1e3);
|
|
90
|
+
const st = await client.session.status({ path: { id } });
|
|
91
|
+
const status = st?.data?.[id]?.status ?? st?.data?.status;
|
|
92
|
+
if (status === "idle" || status === "completed" || !status) break;
|
|
93
|
+
}
|
|
94
|
+
const msgs = await client.session.messages({ path: { id } });
|
|
95
|
+
const all = msgs?.data ?? [];
|
|
96
|
+
const lastAssistant = all.filter((m) => m?.info?.role === "assistant").pop();
|
|
97
|
+
const parts = lastAssistant?.parts ?? [];
|
|
88
98
|
const text = parts.filter((p) => p?.type === "text").map((p) => p?.text ?? "").join("");
|
|
89
99
|
try {
|
|
90
100
|
await client.session.remove?.({ path: { id } });
|
package/package.json
CHANGED