chore: update dependencies and enhance mobile-voice functionality
- Updated package dependencies in bun.lock and package.json for mobile-voice and opencode. - Added expo-camera and improved camera permission handling in mobile-voice. - Introduced QR code generation for relay setup in opencode serve command. - Enhanced server management and logging in DictationScreen component.
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
"@types/bun": "catalog:",
|
||||
"@types/cross-spawn": "6.0.6",
|
||||
"@types/mime-types": "3.0.1",
|
||||
"@types/qrcode": "1.5.5",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/turndown": "5.0.5",
|
||||
"@types/which": "3.0.4",
|
||||
@@ -137,6 +138,7 @@
|
||||
"opencode-poe-auth": "0.0.1",
|
||||
"opentui-spinner": "0.0.6",
|
||||
"partial-json": "0.1.7",
|
||||
"qrcode": "1.5.4",
|
||||
"remeda": "catalog:",
|
||||
"semver": "^7.6.3",
|
||||
"solid-js": "catalog:",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { randomBytes } from "node:crypto"
|
||||
import os from "node:os"
|
||||
import { Server } from "../../server/server"
|
||||
import { cmd } from "./cmd"
|
||||
import { withNetworkOptions, resolveNetworkOptions } from "../network"
|
||||
@@ -6,6 +8,25 @@ import { Workspace } from "../../control-plane/workspace"
|
||||
import { Project } from "../../project/project"
|
||||
import { Installation } from "../../installation"
|
||||
import { PushRelay } from "../../server/push-relay"
|
||||
import * as QRCode from "qrcode"
|
||||
|
||||
function hosts(hostname: string, port: number) {
|
||||
const list = new Set<string>()
|
||||
const add = (item: string) => {
|
||||
if (!item) return
|
||||
if (item === "0.0.0.0") return
|
||||
if (item === "::") return
|
||||
list.add(`http://${item}:${port}`)
|
||||
}
|
||||
add(hostname)
|
||||
add("127.0.0.1")
|
||||
Object.values(os.networkInterfaces())
|
||||
.flatMap((item) => item ?? [])
|
||||
.filter((item) => item.family === "IPv4" && !item.internal)
|
||||
.map((item) => item.address)
|
||||
.forEach(add)
|
||||
return [...list]
|
||||
}
|
||||
|
||||
export const ServeCommand = cmd({
|
||||
command: "serve",
|
||||
@@ -33,18 +54,40 @@ export const ServeCommand = cmd({
|
||||
process.env.OPENCODE_EXPERIMENTAL_PUSH_RELAY_URL ??
|
||||
"https://apn.dev.opencode.ai"
|
||||
).trim()
|
||||
const relaySecret = (args["relay-secret"] ?? process.env.OPENCODE_EXPERIMENTAL_PUSH_RELAY_SECRET ?? "").trim()
|
||||
const input = (args["relay-secret"] ?? process.env.OPENCODE_EXPERIMENTAL_PUSH_RELAY_SECRET ?? "").trim()
|
||||
const relaySecret = input || randomBytes(18).toString("base64url")
|
||||
if (!input) {
|
||||
console.log("experimental push relay secret generated")
|
||||
}
|
||||
if (relayURL && relaySecret) {
|
||||
const host = server.hostname ?? opts.hostname
|
||||
const port = server.port || opts.port || 4096
|
||||
const pair = PushRelay.start({
|
||||
const started = PushRelay.start({
|
||||
relayURL,
|
||||
relaySecret,
|
||||
hostname: host,
|
||||
port,
|
||||
})
|
||||
const pair = started ??
|
||||
PushRelay.pair() ?? {
|
||||
v: 1 as const,
|
||||
relayURL,
|
||||
relaySecret,
|
||||
hosts: hosts(host, port),
|
||||
}
|
||||
if (!started) {
|
||||
console.log("experimental push relay failed to initialize; showing setup qr anyway")
|
||||
}
|
||||
if (pair) {
|
||||
console.log("experimental push relay enabled")
|
||||
const payload = JSON.stringify(pair)
|
||||
const code = await QRCode.toString(payload, {
|
||||
type: "terminal",
|
||||
small: true,
|
||||
errorCorrectionLevel: "M",
|
||||
})
|
||||
console.log("scan qr code in mobile app")
|
||||
console.log(code)
|
||||
console.log("qr payload")
|
||||
console.log(JSON.stringify(pair, null, 2))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import os from "node:os"
|
||||
import { Bus } from "@/bus"
|
||||
import { GlobalBus } from "@/bus/global"
|
||||
import { Log } from "@/util/log"
|
||||
|
||||
type Type = "complete" | "permission" | "error"
|
||||
@@ -183,20 +183,15 @@ export namespace PushRelay {
|
||||
hosts: list(input.hostname, input.port),
|
||||
}
|
||||
|
||||
let unsub: (() => void) | undefined
|
||||
try {
|
||||
unsub = Bus.subscribeAll((event) => {
|
||||
const next = map(event)
|
||||
if (!next) return
|
||||
post(next)
|
||||
})
|
||||
} catch (error) {
|
||||
log.warn("failed to subscribe", {
|
||||
error: String(error),
|
||||
})
|
||||
return
|
||||
const callback = (event: { payload: Event }) => {
|
||||
const next = map(event.payload)
|
||||
if (!next) return
|
||||
post(next)
|
||||
}
|
||||
GlobalBus.on("event", callback)
|
||||
const unsub = () => {
|
||||
GlobalBus.off("event", callback)
|
||||
}
|
||||
if (!unsub) return
|
||||
|
||||
state = {
|
||||
relayURL,
|
||||
|
||||
Reference in New Issue
Block a user