@fdcn/sourcefed 0.2.5 → 0.2.6
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 +2 -2
- package/dist/opencode.js +20 -0
- package/dist.dts/adapters/opencode/bridge.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,12 +33,12 @@ OpenCode loads this package as both a server and a TUI plugin:
|
|
|
33
33
|
|
|
34
34
|
```json
|
|
35
35
|
// opencode.json
|
|
36
|
-
{ "plugin": ["@fdcn/sourcefed@0.2.
|
|
36
|
+
{ "plugin": ["@fdcn/sourcefed@0.2.6"] }
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
```json
|
|
40
40
|
// tui.json
|
|
41
|
-
{ "plugin": ["@fdcn/sourcefed@0.2.
|
|
41
|
+
{ "plugin": ["@fdcn/sourcefed@0.2.6"] }
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
The package exposes `./server`, `./tui`, `./opencode`, `./opencode/tui`, and `./pi` entrypoints for hosts that load them directly.
|
package/dist/opencode.js
CHANGED
|
@@ -75,13 +75,33 @@ var OpenCodeBridge = class {
|
|
|
75
75
|
}
|
|
76
76
|
async routeEvents(events) {
|
|
77
77
|
for (const queued of events) {
|
|
78
|
+
const model = await this.currentModel(queued.target.id);
|
|
78
79
|
const body = {
|
|
79
80
|
...queued.event.actionable ? {} : { noReply: true },
|
|
81
|
+
...model ? { model } : {},
|
|
80
82
|
parts: [{ type: "text", text: eventText(queued.event) }]
|
|
81
83
|
};
|
|
82
84
|
await this.opencode.session.prompt({ path: { id: queued.target.id }, body });
|
|
83
85
|
}
|
|
84
86
|
}
|
|
87
|
+
// A prompt without an explicit model makes OpenCode fall back to the default
|
|
88
|
+
// model, silently switching the session off whatever it was using. Reuse the
|
|
89
|
+
// model from the session's last assistant turn so a notification never
|
|
90
|
+
// changes the active model.
|
|
91
|
+
async currentModel(sessionID) {
|
|
92
|
+
try {
|
|
93
|
+
const result = await this.opencode.session.messages({ path: { id: sessionID } });
|
|
94
|
+
const messages = result.data ?? [];
|
|
95
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
96
|
+
const info = messages[i].info;
|
|
97
|
+
if (info.role === "assistant" && info.providerID && info.modelID) {
|
|
98
|
+
return { providerID: info.providerID, modelID: info.modelID };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
85
105
|
target(sessionID) {
|
|
86
106
|
return { kind: "opencode-session", id: sessionID };
|
|
87
107
|
}
|