@yusho/server 0.0.0-stage → 0.1.16
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 +135 -2
- package/app/appguide.mjs +33 -0
- package/app/asr.mjs +82 -0
- package/app/assets/agents/claude-192.webp +0 -0
- package/app/assets/agents/claude-96.webp +0 -0
- package/app/assets/agents/codex-192.webp +0 -0
- package/app/assets/agents/codex-96.webp +0 -0
- package/app/assets/agents/default-192.webp +0 -0
- package/app/assets/agents/default-96.webp +0 -0
- package/app/assets/agents/dsh-192.webp +0 -0
- package/app/assets/agents/dsh-96.webp +0 -0
- package/app/assets/brand/logo.webp +0 -0
- package/app/assets/lib/THIRD-PARTY.txt +1 -0
- package/app/assets/lib/jsqr.js +10102 -0
- package/app/assets/linux/alpine-arm64.tar.gz +0 -0
- package/app/assets/linux/alpine-x64.tar.gz +0 -0
- package/app/assets/live/claude.livliv +0 -0
- package/app/assets/live/dafeiyu.livliv +0 -0
- package/app/assets/live/gpt.livliv +0 -0
- package/app/assets/live/sho.livliv +0 -0
- package/app/assets/live//345/275/242/350/261/241/346/235/245/346/272/220.md +5 -0
- package/app/assets/livliv/LICENSE +202 -0
- package/app/assets/livliv/NOTICE +7 -0
- package/app/assets/livliv/player.mjs +15 -0
- package/app/assets/looks/claude.webp +0 -0
- package/app/assets/looks/dafeiyu.webp +0 -0
- package/app/assets/looks/gpt.webp +0 -0
- package/app/assets/looks//345/275/242/350/261/241/346/235/245/346/272/220.md +5 -0
- package/app/assets/sho/avatar.webp +0 -0
- package/app/assets/sho/done.webp +0 -0
- package/app/assets/sho/eat.webp +0 -0
- package/app/assets/sho/idle-blink.webp +0 -0
- package/app/assets/sho/idle.webp +0 -0
- package/app/assets/sho/listen.webp +0 -0
- package/app/assets/sho/need.webp +0 -0
- package/app/assets/sho/work.webp +0 -0
- package/app/companion.mjs +519 -0
- package/app/diag.mjs +51 -0
- package/app/index.html +497 -0
- package/app/judge.mjs +103 -0
- package/app/lanxfer.mjs +157 -0
- package/app/launcher.mjs +2711 -0
- package/app/linux.mjs +97 -0
- package/app/livliv-pack.mjs +12 -0
- package/app/memory.mjs +53 -0
- package/app/net.mjs +717 -0
- package/app/office.mjs +172 -0
- package/app/p2plink.mjs +134 -0
- package/app/pcupdate.mjs +55 -0
- package/app/plans.mjs +126 -0
- package/app/plugins.mjs +79 -0
- package/app/realtime.mjs +67 -0
- package/app/skills/app-icon/SKILL.md +31 -0
- package/app/skills/daily-brief/SKILL.md +29 -0
- package/app/skills/expense-review/SKILL.md +28 -0
- package/app/skills/make-app/SKILL.md +92 -0
- package/app/skills/make-skin/SKILL.md +51 -0
- package/app/skills/meeting-notes/SKILL.md +23 -0
- package/app/skills/reading-notes/SKILL.md +25 -0
- package/app/skills/sho-stickers/SKILL.md +34 -0
- package/app/skills/sho-stickers/stickers/eat.webp +0 -0
- package/app/skills/sho-stickers/stickers/got-it.webp +0 -0
- package/app/skills/sho-stickers/stickers/hi.webp +0 -0
- package/app/skills/sho-stickers/stickers/huh.webp +0 -0
- package/app/skills/sho-stickers/stickers/on-it.webp +0 -0
- package/app/skills/sho-stickers/stickers/yay.webp +0 -0
- package/app/skills/sho-stickers/stickers.json +12 -0
- package/app/skills/study-plan/SKILL.md +30 -0
- package/app/skills/trip-planner/SKILL.md +29 -0
- package/app/skills/weekly-report/SKILL.md +30 -0
- package/app/skills/workout-plan/SKILL.md +30 -0
- package/app/skills/writing-polish/SKILL.md +33 -0
- package/app/skills.mjs +173 -0
- package/app/skins.mjs +40 -0
- package/app/social.mjs +1067 -0
- package/app/storage.mjs +143 -0
- package/app/tts.mjs +68 -0
- package/app/ttslocal.mjs +77 -0
- package/app/voices.mjs +102 -0
- package/backup.mjs +109 -0
- package/bin/yusho.mjs +141 -0
- package/connector/lib/api.mjs +14 -0
- package/connector/lib/autostart.mjs +40 -0
- package/connector/lib/client.js +165 -0
- package/connector/lib/connector.mjs +468 -0
- package/connector/lib/dsh-acp.mjs +129 -0
- package/connector/lib/dsh-headless.patch.yml +4 -0
- package/connector/lib/dsh-plugin.mjs +80 -0
- package/connector/lib/lanfile.mjs +151 -0
- package/connector/lib/nostr.mjs +53 -0
- package/connector/lib/page.html +121 -0
- package/connector/lib/qr.mjs +4 -0
- package/connector/lib/service.mjs +54 -0
- package/node_modules/@local/shoal-mobile/lib/index.js +485 -0
- package/node_modules/@local/shoal-mobile/lib/polyfill.js +82 -0
- package/node_modules/@local/shoal-mobile/lib/session-context.js +34 -0
- package/node_modules/@local/shoal-mobile/lib/shell.js +60 -0
- package/node_modules/@local/shoal-mobile/lib/web-startup.js +33 -0
- package/node_modules/@local/shoal-mobile/package.json +24 -0
- package/node_modules/@local/yusho-pc/lib/client.js +9100 -0
- package/node_modules/@local/yusho-pc/lib/index.js +3 -0
- package/node_modules/@local/yusho-pc/package.json +28 -0
- package/node_modules/@local/yusho-web-login/brand/icon-192.webp +0 -0
- package/node_modules/@local/yusho-web-login/brand/logo-dark.svg +25 -0
- package/node_modules/@local/yusho-web-login/brand.mjs +8 -0
- package/node_modules/@local/yusho-web-login/dsh-web-login.mjs +974 -0
- package/node_modules/@local/yusho-web-login/lib/client.js +607 -0
- package/node_modules/@local/yusho-web-login/login-page.mjs +609 -0
- package/node_modules/@local/yusho-web-login/login-store.mjs +708 -0
- package/node_modules/@local/yusho-web-login/package.json +25 -0
- package/node_modules/@local/yusho-web-login/whale-scene.mjs +509 -0
- package/node_modules/@local/yusho-web-login/yusho-scene.mjs +227 -0
- package/package.json +38 -4
- package/pc.patch.yml +83 -0
- package/run.mjs +136 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 鱼Sho:每件任务的“工作秘书”和“交给谁”,作为 DSH 的运行时上下文交给模型(不往对话里插文字)。
|
|
3
|
+
*
|
|
4
|
+
* 用的是 DSH 自己的 agent/pre-step 钩子(和 @deepseek-ai/dsh-time-context 同一种做法):每一步进模型之前,
|
|
5
|
+
* 在这一批消息后面加一条来源是 yusho-session-context 的上下文。只在设置变了时加(打开、关掉、换了交给谁),没变不重复发。
|
|
6
|
+
* 设置存在鱼Sho 内核里(电脑版界面上的开关、“交给谁”),内核把读取函数挂在 globalThis.__yushoSessionCtx(sid) 上:
|
|
7
|
+
* 返回要交给模型的一段话,或者 null(这件任务没设过)。
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from 'node:crypto'
|
|
10
|
+
// 不从 @deepseek-ai/dsh-llm 引 createUserMessage:插件版装在用户 DSH 的配置目录里,那里解析不到 DSH 的内部包。
|
|
11
|
+
// 照它的写法自己建一条(带唯一 id、冻结)
|
|
12
|
+
const createUserMessage = (input) => Object.freeze(structuredClone({ ...input, role: 'user', id: randomUUID() }))
|
|
13
|
+
|
|
14
|
+
export const name = 'yusho-session-context'
|
|
15
|
+
export const inject = ['agents']
|
|
16
|
+
|
|
17
|
+
export function apply(ctx) {
|
|
18
|
+
const sent = new Map() // sid → 上次交给模型的那段话(进程重启后忘掉,会再交一次,和 DSH 自己恢复会话时一样)
|
|
19
|
+
ctx.on('agent/pre-step', async ({ agent, signal }, next) => {
|
|
20
|
+
const decision = await next()
|
|
21
|
+
if (decision.kind === 'reject' || signal?.aborted) return decision
|
|
22
|
+
const read = globalThis.__yushoSessionCtx
|
|
23
|
+
if (typeof read !== 'function') return decision
|
|
24
|
+
const sid = String(agent?.id ?? '')
|
|
25
|
+
let text = null
|
|
26
|
+
try { text = read(sid) } catch { return decision }
|
|
27
|
+
if (!text || sent.get(sid) === text) return decision
|
|
28
|
+
sent.set(sid, text)
|
|
29
|
+
return {
|
|
30
|
+
...decision,
|
|
31
|
+
messages: [...decision.messages, createUserMessage({ content: [{ type: 'text', text }], source: { kind: name, form: 'snapshot', sections: [{ name, text }] } })],
|
|
32
|
+
}
|
|
33
|
+
}, { prepend: true })
|
|
34
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 手机上的 shell:命令在 App 内置的 Linux(proot + Alpine)里跑。
|
|
3
|
+
* App 的工作目录按原路径挂进 Linux,助理的文件工具和命令行看到的是同一批文件。
|
|
4
|
+
* 内置 Linux 还没装好时,第一次跑命令会先装(解开基础系统 + 从国内镜像装 bash、git、node、python)。
|
|
5
|
+
* 用不了内置 Linux 的设备(比如电脑上测试),明确告诉它把活交给电脑。
|
|
6
|
+
*/
|
|
7
|
+
import { ShellExecutor } from '@deepseek-ai/dsh-shell'
|
|
8
|
+
|
|
9
|
+
export const name = 'shoal-mobile-shell'
|
|
10
|
+
|
|
11
|
+
const ENV_OVERRIDES = { NO_COLOR: '1', FORCE_COLOR: '0', TERM: 'dumb', PAGER: 'cat', GIT_PAGER: 'cat', GIT_TERMINAL_PROMPT: '0', CI: '1' }
|
|
12
|
+
|
|
13
|
+
/** 收一路输出:留前 max 字节,超了记“截断”;reader 按字节偏移增量读 */
|
|
14
|
+
function collector(max) {
|
|
15
|
+
let buf = Buffer.alloc(0), total = 0, truncated = false
|
|
16
|
+
return {
|
|
17
|
+
push(d) { total += d.length; if (buf.length < max) { const room = max - buf.length; buf = Buffer.concat([buf, d.length > room ? d.subarray(0, room) : d]); if (d.length > room) truncated = true } else truncated = true },
|
|
18
|
+
get text() { return buf.toString('utf8') }, get truncated() { return truncated }, get total() { return total },
|
|
19
|
+
reader: { readFrom(from) { const f = Math.max(0, Math.min(from, buf.length)); return { text: buf.subarray(f).toString('utf8'), nextOffset: buf.length, lossy: truncated || from > buf.length } } },
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default class PhoneShell extends ShellExecutor {
|
|
24
|
+
constructor(ctx) { super(ctx) }
|
|
25
|
+
/** 命令关在 App 自己的私有目录里(内置 Linux + 工作目录),按“只能写工作区”对待 */
|
|
26
|
+
get sandboxMode() { return 'workspace-write' }
|
|
27
|
+
resolve(request) {
|
|
28
|
+
const lx = globalThis.__shoalLinux
|
|
29
|
+
const timeoutMs = Math.min(Math.max(1000, Number(request.timeoutMs) || 120_000), 600_000)
|
|
30
|
+
return { command: String(request.command ?? ''), workdir: request.workdir ?? lx?.workspace ?? process.cwd(), timeoutMs, onExpiry: request.onExpiry ?? 'kill', stdoutMaxBytes: request.stdoutMaxBytes ?? 64_000, signal: request.signal, stdin: request.stdin, env: request.env, dshEnv: request.dshEnv, sandboxPolicy: request.sandboxPolicy }
|
|
31
|
+
}
|
|
32
|
+
async execute(spec) {
|
|
33
|
+
const lx = globalThis.__shoalLinux
|
|
34
|
+
if (!lx?.linux?.supported()) throw new Error('这台设备上用不了内置 Linux。需要跑命令、改项目、跑测试时,用 dispatch_to_computer 交给用户电脑上的 Agent。')
|
|
35
|
+
await lx.linux.ensure()
|
|
36
|
+
const out = collector(spec.stdoutMaxBytes), err = collector(64_000)
|
|
37
|
+
let timedOut = false, aborted = false, readOut = 0, readErr = 0, settle
|
|
38
|
+
const proc = lx.linux.spawnIn(spec.command, { cwd: spec.workdir, env: { ...ENV_OVERRIDES, ...(spec.env ?? {}), ...(spec.dshEnv ?? {}) } })
|
|
39
|
+
const done = new Promise((ok) => (settle = ok))
|
|
40
|
+
const h = {
|
|
41
|
+
status: 'running', exitCode: null, signal: null, done,
|
|
42
|
+
observed: { stdout: out.reader, stderr: err.reader },
|
|
43
|
+
readOutput() { const a = out.reader.readFrom(readOut), b = err.reader.readFrom(readErr); readOut = a.nextOffset; readErr = b.nextOffset; return { delta: a.text + b.text, lossy: a.lossy || b.lossy } },
|
|
44
|
+
kill() { if (h.status !== 'running') return false; try { proc.kill('SIGKILL') } catch {} return true },
|
|
45
|
+
async result() {
|
|
46
|
+
await done
|
|
47
|
+
if (h.spawnError) throw h.spawnError
|
|
48
|
+
return { exitCode: h.exitCode, signal: h.signal, timedOut, aborted, timeoutMs: spec.timeoutMs, stdout: { text: out.text, truncated: out.truncated }, stderr: { text: err.text, truncated: err.truncated }, sandbox: { mode: 'workspace-write', denied: false } }
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
proc.stdout.on('data', (d) => out.push(d)); proc.stderr.on('data', (d) => err.push(d))
|
|
52
|
+
if (spec.stdin !== undefined) proc.stdin.end(spec.stdin); else proc.stdin.end()
|
|
53
|
+
const timer = spec.onExpiry === 'kill' ? setTimeout(() => { timedOut = true; h.kill() }, spec.timeoutMs) : null
|
|
54
|
+
const onAbort = () => { aborted = true; h.kill() }
|
|
55
|
+
spec.signal?.addEventListener?.('abort', onAbort, { once: true })
|
|
56
|
+
proc.on('error', (e) => { h.spawnError = e; h.status = 'killed'; clearTimeout(timer); settle() })
|
|
57
|
+
proc.on('close', (code, sig) => { clearTimeout(timer); spec.signal?.removeEventListener?.('abort', onAbort); h.exitCode = code; h.signal = sig; h.status = sig || timedOut || aborted ? 'killed' : 'completed'; settle() })
|
|
58
|
+
return h
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 鱼Sho 服务器版 / 电脑版的网页启动参数:替换 DSH 自己的 web-startup(@deepseek-ai/dsh-web-app/startup)。
|
|
3
|
+
* DSH 的那一个从命令行读 --host / --port / --public-url / --trusted-host / --tls-cert / --tls-key;
|
|
4
|
+
* 鱼Sho 的内核是在进程里起 DSH 的,命令行解析会被 SDK 那一行抢先(不认这些参数就报错),所以这几个值改从环境变量来
|
|
5
|
+
* (yusho 命令把自己的参数换成这些变量),提供的服务名和内容跟 DSH 的一模一样(webStartup):
|
|
6
|
+
* YUSHO_WEB_HOST 监听地址(不接受 0.0.0.0 这种通配地址,和 DSH 一样)
|
|
7
|
+
* SHOAL_WEB_PORT 端口
|
|
8
|
+
* YUSHO_WEB_PUBLIC_URL 对外公告的地址(放在反向代理后面时)
|
|
9
|
+
* YUSHO_WEB_TRUSTED 浏览器用来访问的域名,多个用逗号分开
|
|
10
|
+
* YUSHO_WEB_TLS_CERT / YUSHO_WEB_TLS_KEY 自己提供 HTTPS(两个都要给)
|
|
11
|
+
*/
|
|
12
|
+
export const name = 'shoal-web-startup'
|
|
13
|
+
|
|
14
|
+
const WILDCARD = new Set(['0.0.0.0', '::', '[::]', '0', ''])
|
|
15
|
+
export function apply(ctx) {
|
|
16
|
+
const env = process.env
|
|
17
|
+
const host = env.YUSHO_WEB_HOST?.trim()
|
|
18
|
+
if (host !== undefined && host !== '' && WILDCARD.has(host)) throw new Error('YUSHO_WEB_HOST=' + host + ' 是通配地址:会把能跑命令的界面暴露给整个网络。请写一个具体的网卡地址')
|
|
19
|
+
const port = env.SHOAL_WEB_PORT ? Number(env.SHOAL_WEB_PORT) : undefined
|
|
20
|
+
if (port !== undefined && !(Number.isInteger(port) && port > 0 && port < 65536)) throw new Error('端口不对:' + env.SHOAL_WEB_PORT)
|
|
21
|
+
const cert = env.YUSHO_WEB_TLS_CERT?.trim(), key = env.YUSHO_WEB_TLS_KEY?.trim()
|
|
22
|
+
if (!!cert !== !!key) throw new Error('--tls-cert 和 --tls-key 要一起给')
|
|
23
|
+
const pub = env.YUSHO_WEB_PUBLIC_URL?.trim()
|
|
24
|
+
if (pub) { let u; try { u = new URL(pub) } catch { throw new Error('--public-url 不是一个地址:' + pub) } if (u.protocol !== 'http:' && u.protocol !== 'https:') throw new Error('--public-url 要用 http:// 或 https://') }
|
|
25
|
+
ctx.provide('webStartup', {
|
|
26
|
+
openBrowser: false,
|
|
27
|
+
...(host ? { host } : {}),
|
|
28
|
+
...(port !== undefined ? { port } : {}),
|
|
29
|
+
...(pub ? { publicUrl: pub.endsWith('/') ? pub : pub + '/' } : {}),
|
|
30
|
+
...(cert && key ? { tls: { certFile: cert, keyFile: key } } : {}),
|
|
31
|
+
trustedHosts: (env.YUSHO_WEB_TRUSTED ?? '').split(',').map((x) => x.trim()).filter(Boolean),
|
|
32
|
+
})
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@local/shoal-mobile",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "鱼Sho 手机版:让手机上的助理把活交给已连上的电脑上的 Agent(经 Nostr 加密私聊)。网络连接由启动器(launcher.mjs → net.mjs)负责,这里只注册给模型用的工具",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./shell": {
|
|
14
|
+
"default": "./lib/shell.js"
|
|
15
|
+
},
|
|
16
|
+
"./web-startup": {
|
|
17
|
+
"default": "./lib/web-startup.js"
|
|
18
|
+
},
|
|
19
|
+
"./session-context": {
|
|
20
|
+
"default": "./lib/session-context.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
}
|
|
24
|
+
}
|