@clwnd/opencode 0.15.5 → 0.15.7
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 +23 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,7 +17,8 @@ var DEFAULTS = {
|
|
|
17
17
|
smallModel: "",
|
|
18
18
|
permissionDusk: 6e4,
|
|
19
19
|
droned: false,
|
|
20
|
-
droneModel: { providerID: "opencode-clwnd", modelID: "claude-haiku-4-5" }
|
|
20
|
+
droneModel: { providerID: "opencode-clwnd", modelID: "claude-haiku-4-5" },
|
|
21
|
+
ocCompaction: false
|
|
21
22
|
};
|
|
22
23
|
var CONFIG_PATHS = [
|
|
23
24
|
join(process.env.XDG_CONFIG_HOME ?? join(process.env.HOME ?? "/", ".config"), "clwnd", "clwnd.json")
|
|
@@ -34,7 +35,8 @@ function loadConfig() {
|
|
|
34
35
|
smallModel: raw.smallModel ?? DEFAULTS.smallModel,
|
|
35
36
|
permissionDusk: raw.permissionDusk ?? DEFAULTS.permissionDusk,
|
|
36
37
|
droned: raw.droned ?? DEFAULTS.droned,
|
|
37
|
-
droneModel: raw.droneModel ?? DEFAULTS.droneModel
|
|
38
|
+
droneModel: raw.droneModel ?? DEFAULTS.droneModel,
|
|
39
|
+
ocCompaction: raw.ocCompaction ?? DEFAULTS.ocCompaction
|
|
38
40
|
};
|
|
39
41
|
return cached;
|
|
40
42
|
} catch {
|
|
@@ -474,7 +476,7 @@ function defaultSocketPath() {
|
|
|
474
476
|
var HUM_PATH = (process.env.CLWND_SOCKET ?? defaultSocketPath()) + ".hum";
|
|
475
477
|
var humSocket = null;
|
|
476
478
|
var humEcho = "";
|
|
477
|
-
var
|
|
479
|
+
var humHearers = /* @__PURE__ */ new Map();
|
|
478
480
|
var humAlive = false;
|
|
479
481
|
var humReady = null;
|
|
480
482
|
var humAwaken = awakenHum();
|
|
@@ -552,7 +554,11 @@ async function awakenHum() {
|
|
|
552
554
|
trace("hum.pulse", { kind: msg.kind, sid: msg.sid });
|
|
553
555
|
continue;
|
|
554
556
|
}
|
|
555
|
-
|
|
557
|
+
const msgSid = typeof msg.sid === "string" ? msg.sid : void 0;
|
|
558
|
+
if (msgSid) {
|
|
559
|
+
const h = humHearers.get(msgSid);
|
|
560
|
+
if (h) h(msg);
|
|
561
|
+
}
|
|
556
562
|
} catch {
|
|
557
563
|
}
|
|
558
564
|
}
|
|
@@ -594,15 +600,15 @@ function hum(msg) {
|
|
|
594
600
|
writeLog("trace", "hum.send.failed", { err: String(e) });
|
|
595
601
|
}
|
|
596
602
|
}
|
|
597
|
-
function humHear(onMessage) {
|
|
603
|
+
function humHear(sid, onMessage) {
|
|
598
604
|
return new Promise((resolve) => {
|
|
599
|
-
|
|
605
|
+
humHearers.set(sid, (incoming) => {
|
|
600
606
|
onMessage(incoming);
|
|
601
607
|
if (incoming.chi === "finish" || incoming.chi === "error") {
|
|
602
|
-
|
|
608
|
+
humHearers.delete(sid);
|
|
603
609
|
resolve();
|
|
604
610
|
}
|
|
605
|
-
};
|
|
611
|
+
});
|
|
606
612
|
});
|
|
607
613
|
}
|
|
608
614
|
function extractContent(prompt, sessionId) {
|
|
@@ -996,7 +1002,8 @@ var ClwndModel = class {
|
|
|
996
1002
|
if (!lt || !Array.isArray(lt.content)) return false;
|
|
997
1003
|
for (const p of lt.content) {
|
|
998
1004
|
if (p.type === "tool-result" && p.toolCallId?.startsWith("perm-")) {
|
|
999
|
-
const
|
|
1005
|
+
const loose = p;
|
|
1006
|
+
const rawOutput = loose.output ?? loose.result;
|
|
1000
1007
|
try {
|
|
1001
1008
|
const outer = typeof rawOutput === "string" ? JSON.parse(rawOutput) : rawOutput;
|
|
1002
1009
|
const inner = outer?.value ?? outer;
|
|
@@ -1125,6 +1132,7 @@ var ClwndModel = class {
|
|
|
1125
1132
|
function wilt() {
|
|
1126
1133
|
if (done) return;
|
|
1127
1134
|
done = true;
|
|
1135
|
+
humHearers.delete(sid);
|
|
1128
1136
|
try {
|
|
1129
1137
|
controller.close();
|
|
1130
1138
|
} catch {
|
|
@@ -1145,7 +1153,7 @@ var ClwndModel = class {
|
|
|
1145
1153
|
return;
|
|
1146
1154
|
}
|
|
1147
1155
|
petal({ type: "stream-start", warnings: [] });
|
|
1148
|
-
const humFade = humHear(onHummin);
|
|
1156
|
+
const humFade = humHear(sid, onHummin);
|
|
1149
1157
|
if (!promptSent) {
|
|
1150
1158
|
hum({
|
|
1151
1159
|
chi: "prompt",
|
|
@@ -1210,7 +1218,9 @@ var ClwndModel = class {
|
|
|
1210
1218
|
reasoningStarted = false;
|
|
1211
1219
|
}
|
|
1212
1220
|
sap.set(raw.toolCallId, "");
|
|
1213
|
-
|
|
1221
|
+
const ocToolName = mapToolName(raw.toolName);
|
|
1222
|
+
const isBrokered = streamBrokered.has(ocToolName);
|
|
1223
|
+
buds.push({ type: "tool-input-start", id: raw.toolCallId, toolName: ocToolName, providerExecuted: !isBrokered });
|
|
1214
1224
|
}
|
|
1215
1225
|
if (ct === "tool_input_delta" && raw.toolCallId && raw.partialJson) {
|
|
1216
1226
|
const prev = sap.get(raw.toolCallId) ?? "";
|
|
@@ -1220,7 +1230,8 @@ var ClwndModel = class {
|
|
|
1220
1230
|
if (ct === "tool_call" && raw.toolCallId && raw.toolName) {
|
|
1221
1231
|
const ocToolName = mapToolName(raw.toolName);
|
|
1222
1232
|
if (!sap.has(raw.toolCallId)) {
|
|
1223
|
-
|
|
1233
|
+
const isBrokeredLate = streamBrokered.has(ocToolName);
|
|
1234
|
+
buds.push({ type: "tool-input-start", id: raw.toolCallId, toolName: ocToolName, providerExecuted: !isBrokeredLate });
|
|
1224
1235
|
}
|
|
1225
1236
|
const accumulated = sap.get(raw.toolCallId);
|
|
1226
1237
|
let rawInput;
|