backeer-opencode 0.8.2 → 0.10.0
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/CHANGELOG.md +19 -0
- package/dist/backeer-permission.js +227 -284
- package/docs/live-control.md +25 -12
- package/package.json +1 -1
- package/src/delivery-tracker.js +4 -4
- package/src/diagnostics.js +3 -3
- package/src/event-publishers.js +33 -34
- package/src/feedback-session-store.js +3 -14
- package/src/http.js +14 -16
- package/src/lifecycle-controller.js +5 -5
- package/src/lifecycle-publishers.js +8 -9
- package/src/live-bridge-client.js +3 -4
- package/src/live-bridge-config.js +3 -4
- package/src/live-bridge-events.js +6 -9
- package/src/live-bridge.js +53 -76
- package/src/live-control-client.js +84 -38
- package/src/live-control-mcp.js +10 -10
- package/src/live-diagnostics.js +42 -0
- package/src/live-discovery.js +11 -3
- package/src/live-errors.js +4 -0
- package/src/live-managed-mcp.js +16 -10
- package/src/live-profiles.js +6 -6
- package/src/live-question-tools.js +5 -5
- package/src/live-questions.js +4 -5
- package/src/live-session-manager.js +101 -15
- package/src/live-session-scope.js +3 -4
- package/src/permission-controller.js +4 -4
- package/src/plugin.js +3 -0
- package/src/reporter.js +4 -8
- package/src/session-messages.js +3 -3
- package/src/sse.js +7 -7
- package/src/updates.js +1 -1
- package/src/utilities.js +3 -6
package/src/reporter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatText } from "./utilities.js"
|
|
2
2
|
|
|
3
3
|
const LOG_LEVELS = new Set(["silent", "error", "info", "debug"])
|
|
4
4
|
const LOG_RANK = { silent: 0, error: 1, info: 2, debug: 3 }
|
|
@@ -36,13 +36,10 @@ export function createConsoleReporter(levelValue) {
|
|
|
36
36
|
if (previous && now - previous < LOG_DEDUPLICATION_MS) return
|
|
37
37
|
recentlyEmitted.delete(key)
|
|
38
38
|
recentlyEmitted.set(key, now)
|
|
39
|
-
while (recentlyEmitted.size > 100) {
|
|
40
|
-
recentlyEmitted.delete(recentlyEmitted.keys().next().value)
|
|
41
|
-
}
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
const technical = level === "debug" && detail
|
|
45
|
-
? decorate("2", ` · ${
|
|
42
|
+
? decorate("2", ` · ${formatText(detail)}`)
|
|
46
43
|
: ""
|
|
47
44
|
const line = `${symbols[kind]} ${brand} ${message}${technical}`
|
|
48
45
|
if (kind === "error" || kind === "warning") console.error(line)
|
|
@@ -80,10 +77,10 @@ export function createOpenCodeReporter(client, levelValue) {
|
|
|
80
77
|
level: kind === "warning" ? "warn" : kind === "applied" || kind === "success"
|
|
81
78
|
? "info"
|
|
82
79
|
: kind,
|
|
83
|
-
message:
|
|
80
|
+
message: formatText(message),
|
|
84
81
|
}
|
|
85
82
|
if (level === "debug" && detail) {
|
|
86
|
-
body.extra = { detail:
|
|
83
|
+
body.extra = { detail: formatText(detail?.message ?? detail) }
|
|
87
84
|
}
|
|
88
85
|
|
|
89
86
|
// Logging during plugin initialization can deadlock older OpenCode builds.
|
|
@@ -106,5 +103,4 @@ export function createOpenCodeReporter(client, levelValue) {
|
|
|
106
103
|
function rememberRecent(map, key, value) {
|
|
107
104
|
map.delete(key)
|
|
108
105
|
map.set(key, value)
|
|
109
|
-
while (map.size > 100) map.delete(map.keys().next().value)
|
|
110
106
|
}
|
package/src/session-messages.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FeedbackSessionStore } from "./feedback-session-store.js"
|
|
2
|
-
import {
|
|
2
|
+
import { formatText } from "./utilities.js"
|
|
3
3
|
|
|
4
4
|
const FEEDBACK_SYMBOLS = {
|
|
5
5
|
info: "•",
|
|
@@ -82,7 +82,7 @@ export async function sendSessionMessage(client, sessionID, text) {
|
|
|
82
82
|
|
|
83
83
|
export function formatBackeerFeedback(kind, message) {
|
|
84
84
|
const symbol = FEEDBACK_SYMBOLS[kind] ?? FEEDBACK_SYMBOLS.info
|
|
85
|
-
return `▣ Backeer | ${symbol} ${
|
|
85
|
+
return `▣ Backeer | ${symbol} ${formatText(message)}`
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export function formatBackeerFeedbackBatch(items) {
|
|
@@ -93,7 +93,7 @@ export function formatBackeerFeedbackBatch(items) {
|
|
|
93
93
|
"▣ Backeer",
|
|
94
94
|
...items.map((item) => {
|
|
95
95
|
const symbol = FEEDBACK_SYMBOLS[item.kind] ?? FEEDBACK_SYMBOLS.info
|
|
96
|
-
return `${symbol} ${
|
|
96
|
+
return `${symbol} ${formatText(item.message)}`
|
|
97
97
|
}),
|
|
98
98
|
].join("\n")
|
|
99
99
|
}
|
package/src/sse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpError, isAbortError, sleep } from "./http.js"
|
|
2
|
-
import {
|
|
2
|
+
import { formatText } from "./utilities.js"
|
|
3
3
|
|
|
4
4
|
export function parseSseFrame(frame) {
|
|
5
5
|
const data = []
|
|
@@ -87,7 +87,7 @@ async function openCommandStream(config, state, signal, fetchImplementation) {
|
|
|
87
87
|
signal,
|
|
88
88
|
})
|
|
89
89
|
if (!response.ok) {
|
|
90
|
-
const responseBody =
|
|
90
|
+
const responseBody = formatText(await response.text())
|
|
91
91
|
throw new HttpError(
|
|
92
92
|
`Backeer command stream failed with status ${response.status}`,
|
|
93
93
|
response.status,
|
|
@@ -123,7 +123,7 @@ async function consumeConnection({
|
|
|
123
123
|
function streamErrorState(error, lastLoggedError, reconnectDelay, reporter) {
|
|
124
124
|
const message = error instanceof HttpError
|
|
125
125
|
? `${error.message}: ${error.responseBody}`
|
|
126
|
-
:
|
|
126
|
+
: formatText(error)
|
|
127
127
|
if (message !== lastLoggedError) {
|
|
128
128
|
const authenticationFailure = error instanceof HttpError &&
|
|
129
129
|
[401, 403].includes(error.status)
|
|
@@ -137,7 +137,7 @@ function streamErrorState(error, lastLoggedError, reconnectDelay, reporter) {
|
|
|
137
137
|
return {
|
|
138
138
|
lastLoggedError: message,
|
|
139
139
|
reconnectDelay: error instanceof HttpError && [401, 403, 404].includes(error.status)
|
|
140
|
-
?
|
|
140
|
+
? 3000
|
|
141
141
|
: reconnectDelay,
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -156,7 +156,7 @@ export async function runCommandStream(
|
|
|
156
156
|
},
|
|
157
157
|
) {
|
|
158
158
|
const state = { lastEventID: "", framesReceived: 0 }
|
|
159
|
-
let reconnectDelay =
|
|
159
|
+
let reconnectDelay = 3000
|
|
160
160
|
let lastLoggedError = ""
|
|
161
161
|
|
|
162
162
|
while (!signal.aborted && hasPending()) {
|
|
@@ -176,7 +176,7 @@ export async function runCommandStream(
|
|
|
176
176
|
now,
|
|
177
177
|
stableConnectionMs,
|
|
178
178
|
onStable: () => {
|
|
179
|
-
reconnectDelay =
|
|
179
|
+
reconnectDelay = 3000
|
|
180
180
|
lastLoggedError = ""
|
|
181
181
|
},
|
|
182
182
|
})
|
|
@@ -189,7 +189,7 @@ export async function runCommandStream(
|
|
|
189
189
|
|
|
190
190
|
if (!signal.aborted && hasPending()) {
|
|
191
191
|
await sleepImplementation(reconnectDelay, signal)
|
|
192
|
-
reconnectDelay =
|
|
192
|
+
reconnectDelay = 3000
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
package/src/updates.js
CHANGED
package/src/utilities.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const limit = (value, length = 1000) =>
|
|
4
|
-
String(value ?? "").slice(0, length)
|
|
1
|
+
// Legacy formatting API: normalize text without truncating it.
|
|
2
|
+
export const formatText = value => String(value ?? "")
|
|
5
3
|
|
|
6
4
|
export function enabled(value, fallback = true) {
|
|
7
5
|
if (typeof value === "boolean") return value
|
|
@@ -18,8 +16,7 @@ export function stableHash(value) {
|
|
|
18
16
|
return (hash >>> 0).toString(16).padStart(8, "0")
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
export function
|
|
19
|
+
export function remember(map, key, value) {
|
|
22
20
|
map.delete(key)
|
|
23
21
|
map.set(key, value)
|
|
24
|
-
while (map.size > MAX_TRACKED_ITEMS) map.delete(map.keys().next().value)
|
|
25
22
|
}
|