@evandu/super-pi 0.1.272 → 0.1.274

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.
Files changed (75) hide show
  1. package/agents/group-rsi.md +18 -0
  2. package/agents/super-pi-task/core.ts +7 -7
  3. package/bin/completion.js +19 -5
  4. package/bin/super-pi.js +3 -0
  5. package/desktop/runtime.cjs +28 -4
  6. package/dist/client/.super-pi-client-sources.json +26 -18
  7. package/dist/client/assets/CodeMirrorEditor-DjMbNm7l.js +2 -0
  8. package/dist/client/assets/GitDiffEditor-Cwim9Ua1.js +29 -0
  9. package/dist/client/assets/{dist-DGBjhKI9.js → dist-AW5lyI3I.js} +1 -1
  10. package/dist/client/assets/dist-B3-a6uF0.js +7 -0
  11. package/dist/client/assets/dist-BGxkyh6e.js +1 -0
  12. package/dist/client/assets/dist-BJxfd7yb.js +11 -0
  13. package/dist/client/assets/{dist-BvjUKkwy.js → dist-BRVQKlcp.js} +1 -1
  14. package/dist/client/assets/dist-BV64A9Ji.js +1 -0
  15. package/dist/client/assets/{dist-BlRuQIg1.js → dist-BXAOrsjq.js} +1 -1
  16. package/dist/client/assets/dist-CKF2Jksy.js +1 -0
  17. package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
  18. package/dist/client/assets/{dist-i79xiXVk.js → dist-Cus6_oaF.js} +2 -2
  19. package/dist/client/assets/dist-Cx00EZKR.js +23 -0
  20. package/dist/client/assets/dist-D71y2EI1.js +1 -0
  21. package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
  22. package/dist/client/assets/dist-Dds-qLxY.js +9 -0
  23. package/dist/client/assets/dist-DeD9copn.js +1 -0
  24. package/dist/client/assets/dist-DuvGReu-.js +6 -0
  25. package/dist/client/assets/{dist-D5u1uPmZ.js → dist-Dvb0SqcK.js} +2 -2
  26. package/dist/client/assets/dist-J6XWqRpB.js +3 -0
  27. package/dist/client/assets/{dist-CQncCwUc.js → dist-QzbOCAU6.js} +1 -1
  28. package/dist/client/assets/{dist-DjI7p99D.js → dist-moiMRpw_.js} +1 -1
  29. package/dist/client/assets/dist-scBkrwv-.js +2 -0
  30. package/dist/client/assets/index-BL9o4WZN.js +350 -0
  31. package/dist/client/assets/index-D1qJmoVY.css +1 -0
  32. package/dist/client/index.html +2 -2
  33. package/dist/server/application/conversation-service.d.ts +1 -1
  34. package/dist/server/application/conversation-service.js +3 -2
  35. package/dist/server/application/group-chat-service.d.ts +17 -0
  36. package/dist/server/application/group-chat-service.js +168 -3
  37. package/dist/server/application/group-rsi.d.ts +13 -0
  38. package/dist/server/application/group-rsi.js +69 -0
  39. package/dist/server/application/worktree-service.js +6 -2
  40. package/dist/server/http-server.js +61 -8
  41. package/dist/server/index.js +15 -2
  42. package/dist/server/managed-http.js +38 -2
  43. package/dist/server/managed-model-adapter.d.ts +4 -0
  44. package/dist/server/managed-model-adapter.js +2 -2
  45. package/dist/server/managed-model-relay.d.ts +12 -0
  46. package/dist/server/managed-model-relay.js +185 -0
  47. package/dist/server/managed-servers.d.ts +13 -1
  48. package/dist/server/managed-servers.js +140 -8
  49. package/dist/server/remote-bootstrap.d.ts +11 -0
  50. package/dist/server/remote-bootstrap.js +105 -29
  51. package/dist/server/update.d.ts +6 -0
  52. package/dist/server/update.js +16 -1
  53. package/dist/server/ws-server.js +14 -0
  54. package/dist/shared/group-chat.d.ts +40 -0
  55. package/dist/shared/managed-servers.d.ts +1 -0
  56. package/dist/shared/update-status.d.ts +1 -0
  57. package/package.json +2 -1
  58. package/dist/client/assets/CodeMirrorEditor-BOfFOmcv.js +0 -2
  59. package/dist/client/assets/GitDiffEditor-DaN0Ye4q.js +0 -29
  60. package/dist/client/assets/dist-3qQVP6l8.js +0 -6
  61. package/dist/client/assets/dist-CZ4PyxQu.js +0 -9
  62. package/dist/client/assets/dist-CfTFp0AF.js +0 -2
  63. package/dist/client/assets/dist-CxmJXjJI.js +0 -1
  64. package/dist/client/assets/dist-D8HpMxmZ.js +0 -1
  65. package/dist/client/assets/dist-DRBIy9A1.js +0 -1
  66. package/dist/client/assets/dist-Dcww9FSw.js +0 -1
  67. package/dist/client/assets/dist-DlPa5gNa.js +0 -7
  68. package/dist/client/assets/dist-DxPJ1PN-.js +0 -1
  69. package/dist/client/assets/dist-HXD8sSA4.js +0 -23
  70. package/dist/client/assets/dist-LbeLCeoq.js +0 -1
  71. package/dist/client/assets/dist-ONdtnupI.js +0 -1
  72. package/dist/client/assets/dist-YqmXusLA.js +0 -11
  73. package/dist/client/assets/dist-ZAR1Tu2c.js +0 -3
  74. package/dist/client/assets/index-BsfNx6DV.js +0 -350
  75. package/dist/client/assets/index-DV3qc1Hh.css +0 -1
@@ -1,5 +1,6 @@
1
- import { createHash } from "node:crypto";
2
- import { mkdir, readFile, writeFile } from "node:fs/promises";
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { mkdir, readFile, open, rename, rm } from "node:fs/promises";
3
+ import { setTimeout as delay } from "node:timers/promises";
3
4
  import { join, basename, posix } from "node:path";
4
5
  import { sh, sshExec, sshSftp, sshWrite } from "./managed-ssh.js";
5
6
  import { isServiceListenHost } from "../shared/managed-servers.js";
@@ -12,30 +13,93 @@ export async function uploadFile(client, local, remote) {
12
13
  sftp.end();
13
14
  }
14
15
  }
15
- async function nodeArchive(platform, arch, directory) {
16
- const version = "v22.20.0", filename = `node-${version}-${platform}-${arch}.tar.gz`;
17
- const path = join(directory, filename);
18
- await mkdir(directory, { recursive: true });
19
- const sums = await fetch(`https://nodejs.org/dist/${version}/SHASUMS256.txt`, { signal: AbortSignal.timeout(30_000) });
20
- if (!sums.ok)
21
- throw new Error("无法下载 Node.js 校验信息,请检查本地网络");
22
- const expected = (await sums.text()).split("\n").find(line => line.endsWith(` ${filename}`))?.trim().split(/\s+/)[0];
16
+ export const NODE_RUNTIME_VERSION = "v22.20.0";
17
+ // Pinned from https://nodejs.org/dist/v22.20.0/SHASUMS256.txt.
18
+ export const NODE_RUNTIME_CHECKSUMS = Object.freeze({
19
+ "darwin-arm64": "cc04a76a09f79290194c0646f48fec40354d88969bec467789a5d55dd097f949",
20
+ "darwin-x64": "00df9c5df3e4ec6848c26b70fb47bf96492f342f4bed6b17f12d99b3a45eeecc",
21
+ "linux-arm64": "4181609e03dcb9880e7e5bf956061ecc0503c77a480c6631d868cb1f65a2c7dd",
22
+ "linux-x64": "eeaccb0378b79406f2208e8b37a62479c70595e20be6b659125eb77dd1ab2a29",
23
+ });
24
+ export async function nodeArchive(platform, arch, directory, options = {}) {
25
+ const expected = NODE_RUNTIME_CHECKSUMS[`${platform}-${arch}`];
23
26
  if (!expected)
24
27
  throw new Error("Node.js 官方未提供该平台的安装包");
28
+ return downloadVerifiedNodeArchive(`node-${NODE_RUNTIME_VERSION}-${platform}-${arch}.tar.gz`, expected, directory, options);
29
+ }
30
+ export async function downloadVerifiedNodeArchive(filename, expected, directory, options = {}) {
31
+ if (basename(filename) !== filename || !/^node-v\d+\.\d+\.\d+-(linux|darwin)-(x64|arm64)\.tar\.gz$/.test(filename)
32
+ || !/^[a-f0-9]{64}$/i.test(expected))
33
+ throw new Error("Node.js 安装包或校验值无效");
34
+ expected = expected.toLowerCase();
35
+ const request = options.fetch ?? globalThis.fetch;
36
+ const version = NODE_RUNTIME_VERSION;
37
+ const path = join(directory, filename);
38
+ await mkdir(directory, { recursive: true });
25
39
  try {
26
40
  const bytes = await readFile(path);
27
41
  if (createHash("sha256").update(bytes).digest("hex") === expected)
28
42
  return path;
29
43
  }
30
44
  catch { }
31
- const result = await fetch(`https://nodejs.org/dist/${version}/${filename}`, { signal: AbortSignal.timeout(10 * 60_000) });
32
- if (!result.ok)
33
- throw new Error("下载 Node.js 失败");
34
- const data = Buffer.from(await result.arrayBuffer());
35
- if (data.length > 150 * 1024 * 1024 || createHash("sha256").update(data).digest("hex") !== expected)
36
- throw new Error("Node.js 安装包校验失败");
37
- await writeFile(path, data);
38
- return path;
45
+ const sources = [
46
+ [`https://nodejs.org/dist/${version}/${filename}`, "官方源"],
47
+ [`https://npmmirror.com/mirrors/node/${version}/${filename}`, "备用源 1"],
48
+ [`https://mirrors.huaweicloud.com/nodejs/${version}/${filename}`, "备用源 2"],
49
+ ];
50
+ const stop = new AbortController(), temporaries = [];
51
+ const signal = AbortSignal.any([stop.signal, AbortSignal.timeout(10 * 60_000)]);
52
+ const maximum = 150 * 1024 * 1024;
53
+ const downloads = sources.map(async ([url, label], index) => {
54
+ // A slow first source must not consume the entire deployment deadline.
55
+ if (index)
56
+ await delay(index * (options.fallbackDelayMs ?? 15_000), undefined, { signal });
57
+ signal.throwIfAborted();
58
+ options.progress?.(`下载并校验 Node.js · ${label}`);
59
+ const response = await request(url, { signal });
60
+ if (!response.ok || !response.body)
61
+ throw new Error(`Node.js ${label}下载失败(${response.status})`);
62
+ if (Number(response.headers.get("content-length")) > maximum) {
63
+ await response.body.cancel();
64
+ throw new Error("Node.js 安装包超过大小上限");
65
+ }
66
+ const temporary = `${path}.download-${randomUUID()}`;
67
+ temporaries.push(temporary);
68
+ const file = await open(temporary, "wx", 0o600);
69
+ const hash = createHash("sha256");
70
+ let bytes = 0;
71
+ try {
72
+ for await (const chunk of response.body) {
73
+ signal.throwIfAborted();
74
+ bytes += chunk.length;
75
+ if (bytes > maximum)
76
+ throw new Error("Node.js 安装包超过大小上限");
77
+ hash.update(chunk);
78
+ await file.writeFile(chunk);
79
+ }
80
+ if (hash.digest("hex") !== expected.toLowerCase())
81
+ throw new Error("Node.js 安装包校验失败");
82
+ return temporary;
83
+ }
84
+ finally {
85
+ await file.close();
86
+ }
87
+ });
88
+ try {
89
+ const verified = await Promise.any(downloads);
90
+ stop.abort();
91
+ await Promise.allSettled(downloads);
92
+ await rename(verified, path);
93
+ return path;
94
+ }
95
+ catch (cause) {
96
+ throw new Error("下载 Node.js 失败:官方源及备用源未返回校验通过的完整文件,请检查入口网络后重试", { cause });
97
+ }
98
+ finally {
99
+ stop.abort();
100
+ await Promise.allSettled(downloads);
101
+ await Promise.all(temporaries.map(temporary => rm(temporary, { force: true })));
102
+ }
39
103
  }
40
104
  export async function installRemote(options) {
41
105
  const { client, progress } = options;
@@ -52,17 +116,24 @@ export async function installRemote(options) {
52
116
  const root = posix.join(home, ".super-pi", "managed", options.id);
53
117
  await sshExec(client, `umask 077; mkdir -p ${sh(root)} ${sh(posix.join(root, "data"))} ${sh(posix.join(root, "agent"))}`);
54
118
  let node = "", npm = "";
55
- try {
56
- const found = JSON.parse((await sshExec(client, "node -p 'JSON.stringify({version:process.versions.node,path:process.execPath})'")).trim());
57
- const [major, minor] = String(found.version).split(".").map(Number);
58
- npm = (await sshExec(client, "command -v npm")).trim();
59
- if (major > 22 || (major === 22 && minor >= 19))
60
- node = found.path;
119
+ for (const executable of [sh(posix.join(root, "node", "bin", "node")), "node"]) {
120
+ try {
121
+ const found = JSON.parse((await sshExec(client, `${executable} -p 'JSON.stringify({version:process.versions.node,path:process.execPath})'`)).trim());
122
+ const [major, minor] = String(found.version).split(".").map(Number);
123
+ if (!(major > 22 || (major === 22 && minor >= 19)))
124
+ continue;
125
+ const adjacentNpm = posix.join(posix.dirname(found.path), "npm");
126
+ npm = (await sshExec(client, `if [ -x ${sh(adjacentNpm)} ]; then printf '%s' ${sh(adjacentNpm)}; else command -v npm; fi`)).trim();
127
+ if (npm) {
128
+ node = found.path;
129
+ break;
130
+ }
131
+ }
132
+ catch { /* Bootstrap only when neither the private nor login runtime is usable. */ }
61
133
  }
62
- catch { /* A private Node runtime is installed when the login environment lacks a usable one. */ }
63
134
  if (!node || !npm) {
64
135
  progress("下载并校验 Node.js(仅首次需要)");
65
- const local = await nodeArchive(platform, arch, options.cacheDir), remote = posix.join(root, basename(local));
136
+ const local = await nodeArchive(platform, arch, options.cacheDir, { progress: step => progress(step) }), remote = posix.join(root, basename(local));
66
137
  await uploadFile(client, local, remote);
67
138
  const nodeRoot = posix.join(root, "node");
68
139
  progress("安装用户目录内的 Node.js,无需管理员权限");
@@ -74,10 +145,15 @@ export async function installRemote(options) {
74
145
  progress("上传纯服务安装包");
75
146
  const remoteArchive = posix.join(root, "server.tgz");
76
147
  await uploadFile(client, options.archive, remoteArchive);
77
- const runtime = posix.join(root, `runtime-${options.archiveHash.slice(0, 16)}`);
148
+ // A repair must not depend on npm noticing missing files in an existing package.
149
+ const runtimeTag = createHash("sha256").update(options.archiveHash + randomUUID()).digest("hex").slice(0, 16);
150
+ const runtime = posix.join(root, `runtime-${runtimeTag}`);
78
151
  const packageRoot = posix.join(runtime, "node_modules", "@evandu", "super-pi-server");
152
+ const policy = `const{execFileSync}=require('node:child_process');const keys=['ONNXRUNTIME_NODE_INSTALL','ONNXRUNTIME_NODE_INSTALL_CUDA','npm_config_onnxruntime_node_install','npm_config_onnxruntime_node_install_cuda'];const configured=name=>{try{const value=execFileSync(${JSON.stringify(npm)},['config','get',name],{encoding:'utf8',stdio:['ignore','pipe','ignore']}).trim();return value!==''&&value!=='undefined'&&value!=='null';}catch{return false;}};process.stdout.write(keys.some(key=>Boolean(process.env[key]))||configured('onnxruntime-node-install')||configured('onnxruntime-node-install-cuda')?'configured':'cpu');`;
153
+ const mode = (await sshExec(client, `export PATH=${sh(posix.dirname(node))}:"$PATH"; ${sh(node)} -e ${sh(policy)}`)).trim();
154
+ const cpuRuntime = mode === "cpu" ? "ONNXRUNTIME_NODE_INSTALL=skip " : "";
79
155
  progress("安装远端服务依赖");
80
- await sshExec(client, `umask 077; export PATH=${sh(posix.dirname(node))}:"$PATH"; ${sh(npm)} install --prefix ${sh(runtime)} --omit=dev --no-audit --no-fund --fetch-timeout=900000 --fetch-retries=3 ${sh(remoteArchive)}`, { timeout: 20 * 60_000, onOutput: output => progress("安装远端服务依赖", output) });
156
+ await sshExec(client, `umask 077; export PATH=${sh(posix.dirname(node))}:"$PATH"; ${cpuRuntime}${sh(npm)} install --prefix ${sh(runtime)} --omit=dev --no-audit --no-fund --fetch-timeout=900000 --fetch-retries=3 ${sh(remoteArchive)}`, { timeout: 20 * 60_000, onOutput: output => progress("安装远端服务依赖", output) });
81
157
  const piCommand = posix.join(root, "pi-managed");
82
158
  progress("配置远端 Pi 启动器");
83
159
  const resolvePi = `import{fileURLToPath}from'node:url';import{dirname,resolve,join}from'node:path';import{readFileSync,accessSync}from'node:fs';const root=resolve(dirname(fileURLToPath(import.meta.resolve('@earendil-works/pi-coding-agent'))),'..');const bin=JSON.parse(readFileSync(join(root,'package.json'),'utf8')).bin.pi;const cli=resolve(root,bin);accessSync(cli);process.stdout.write(cli);`;
@@ -86,7 +162,7 @@ export async function installRemote(options) {
86
162
  throw new Error("远端 Pi 安装不完整,请重试部署");
87
163
  const extension = posix.join(packageRoot, "agents", "super-pi-managed-model", "index.ts");
88
164
  await sshWrite(client, piCommand, `#!/bin/sh\nexec ${sh(node)} ${sh(piCli)} --extension ${sh(extension)} "$@"\n`, 0o700);
89
- return { root, packageRoot, node, piCommand };
165
+ return { root, packageRoot, node, piCommand, archiveHash: options.archiveHash };
90
166
  }
91
167
  export function remoteStartScript(installation, port, host = "127.0.0.1") {
92
168
  if (!isServiceListenHost(host) || !Number.isInteger(port) || port < 1 || port > 65535)
@@ -40,6 +40,12 @@ export declare function packageUpdateArgs(rootDir: string, version?: string, pla
40
40
  args: string[];
41
41
  prefix?: string;
42
42
  };
43
+ /** Managed installs are private npm projects underneath the instance directory. */
44
+ export declare function managedUpdatePlan(rootDir: string, config: string, version?: string): {
45
+ launcher: string;
46
+ pidFile: string;
47
+ args: string[];
48
+ };
43
49
  /** Claims the update slot. False when an update is already running. */
44
50
  export declare function claimUpdateSlot(): boolean;
45
51
  /** Releases the update slot, so the next update can start. */
@@ -1,5 +1,5 @@
1
1
  import { readFileSync } from "node:fs";
2
- import { join, resolve } from "node:path";
2
+ import { basename, dirname, join, resolve } from "node:path";
3
3
  import { npmInstallPrefix } from "../../bin/npm-prefix.js";
4
4
  /**
5
5
  * Quote an argument for a shell on Windows.
@@ -82,6 +82,21 @@ export function packageUpdateArgs(rootDir, version, platform = process.platform)
82
82
  }
83
83
  return { args: ["install", "-g", "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", target] };
84
84
  }
85
+ /** Managed installs are private npm projects underneath the instance directory. */
86
+ export function managedUpdatePlan(rootDir, config, version) {
87
+ const instance = dirname(resolve(config));
88
+ const prefix = resolve(rootDir, "../../..");
89
+ if (basename(config) !== "models.json" || dirname(prefix) !== instance ||
90
+ !/^runtime-[a-f0-9]{16}$/.test(basename(prefix)) ||
91
+ resolve(rootDir) !== join(prefix, "node_modules", "@evandu", "super-pi-server")) {
92
+ throw new Error("当前服务的安装路径与托管实例不匹配,无法确定升级位置。");
93
+ }
94
+ return {
95
+ launcher: join(instance, "start-service.sh"),
96
+ pidFile: join(instance, "service.pid"),
97
+ args: ["install", "--prefix", prefix, "--omit=dev", "--no-audit", "--no-fund", "--fetch-timeout=900000", "--fetch-retries=3", `@evandu/super-pi-server@${version ?? "latest"}`],
98
+ };
99
+ }
85
100
  /**
86
101
  * ONE UPDATE AT A TIME.
87
102
  *
@@ -1,5 +1,6 @@
1
1
  import { isBrowserAuthorized } from "./browser-access.js";
2
2
  import { WebSocket, WebSocketServer } from "ws";
3
+ import { remoteModelRelay } from "./managed-model-relay.js";
3
4
  import { isAuthorized, isLoopbackAddress } from "./http-server.js";
4
5
  import { describeThrown, describeThrownWithStack } from "./failure-text.js";
5
6
  import { isRecordedTurnFailure } from "./turn-failure.js";
@@ -390,6 +391,18 @@ export class WsServer {
390
391
  return;
391
392
  }
392
393
  const url = new URL(request.url ?? "/", `http://${request.headers.host ?? "localhost"}`);
394
+ if (url.pathname === "/api/managed-model/channel") {
395
+ if (!process.env.SUPER_PI_MANAGED_CONFIG || !browserAuthorized) {
396
+ socket.destroy();
397
+ return;
398
+ }
399
+ this.websocketServer.handleUpgrade(request, socket, head, ws => {
400
+ const release = this.browserAccess.onRevoke(() => ws.terminate());
401
+ ws.once("close", release);
402
+ remoteModelRelay.attach(ws);
403
+ });
404
+ return;
405
+ }
393
406
  const managed = /^\/managed\/([a-f0-9-]+)(\/ws)$/.exec(url.pathname);
394
407
  if (managed) {
395
408
  if (!this.managedServers || !isAuthorized(request, this.accessToken)
@@ -638,6 +651,7 @@ export class WsServer {
638
651
  // A pending state window must not outlive the server: the timer holds the event loop
639
652
  // open, and a flush after the sockets are closed would send to a dead peer.
640
653
  this.broadcaster.dispose();
654
+ remoteModelRelay.close();
641
655
  for (const socket of this.broadcaster.getSockets()) {
642
656
  socket.close(1001, "server-shutdown");
643
657
  }
@@ -4,6 +4,45 @@ export type GroupModel = {
4
4
  modelId: string;
5
5
  label: string;
6
6
  };
7
+ export type GroupRsiCategory = "division" | "prompt" | "tools" | "mechanism" | "execution";
8
+ export type GroupRsiFinding = {
9
+ id: string;
10
+ category: GroupRsiCategory;
11
+ priority: "high" | "medium" | "low";
12
+ observation: string;
13
+ evidence: {
14
+ messageId: string;
15
+ quote: string;
16
+ }[];
17
+ recommendation: string;
18
+ verification: string;
19
+ applicability: string;
20
+ disposition?: "accepted" | "dismissed";
21
+ feedback?: string;
22
+ };
23
+ export type GroupRsiReport = {
24
+ id: string;
25
+ createdAt: string;
26
+ sourceKey: string;
27
+ observedMessages: number;
28
+ totalMessages: number;
29
+ compressed: boolean;
30
+ summary: string;
31
+ retrospective: string;
32
+ findings: GroupRsiFinding[];
33
+ model?: GroupModel;
34
+ };
35
+ export type GroupRsi = {
36
+ enabled: boolean;
37
+ model?: GroupModel;
38
+ prompt: string;
39
+ status: "idle" | "running" | "completed" | "failed" | "interrupted";
40
+ error?: string;
41
+ startedAt?: string;
42
+ sourceKey?: string;
43
+ reports: GroupRsiReport[];
44
+ pending?: boolean;
45
+ };
7
46
  export type GroupModerator = {
8
47
  model?: GroupModel;
9
48
  prompt: string;
@@ -128,6 +167,7 @@ export type GroupRoom = GroupIdentity & {
128
167
  revision: number;
129
168
  messages: GroupMessage[];
130
169
  cloneRequests?: GroupCloneRequest[];
170
+ rsi?: GroupRsi;
131
171
  };
132
172
  export type GroupSnapshot = Omit<GroupRoom, "revision"> & {
133
173
  revision: string;
@@ -46,6 +46,7 @@ export interface ManagedServerProfile {
46
46
  ssh: "offline" | "connecting" | "online" | "needsTrust" | "awaitingVerification";
47
47
  service: "unknown" | "offline" | "online";
48
48
  modelChannel: "offline" | "online";
49
+ modelTransport?: "direct";
49
50
  modelChannelPaused?: boolean;
50
51
  phase: "idle" | "connecting" | "needsTrust" | "awaitingVerification" | "deploying" | "ready" | "failed";
51
52
  verification?: SshVerification;
@@ -19,6 +19,7 @@ export type UpdateOperation = {
19
19
  };
20
20
  };
21
21
  export type UpdateStatus = UpdateVersions & {
22
+ serviceSelfUpdate?: boolean;
22
23
  operation: UpdateOperation | null;
23
24
  };
24
25
  export type UpdateCheck = UpdateStatus & {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "superPi": {
4
4
  "managedDirectListener": true
5
5
  },
6
- "version": "0.1.272",
6
+ "version": "0.1.274",
7
7
  "description": "Web control plane and companion for Pi",
8
8
  "license": "MIT",
9
9
  "type": "module",
@@ -37,6 +37,7 @@
37
37
  "node": ">=22.19.0"
38
38
  },
39
39
  "scripts": {
40
+ "postinstall": "node --input-type=module -e \"import('./bin/completion.js').then(m => m.installGlobalCompletion()).catch(() => console.warn('Super Pi shell completion registration could not finish.'))\"",
40
41
  "prepack": "node scripts/clean-build.mjs",
41
42
  "prepublishOnly": "node scripts/clean-build.mjs && cross-env SUPER_PI_REQUIRE_REAL_PI=1 node scripts/extension-load.test.mjs",
42
43
  "dev": "concurrently --kill-others-on-fail \"npm:dev:server\" \"npm:dev:client\"",
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-ZAR1Tu2c.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-i79xiXVk.js","assets/dist-D978o95T.js","assets/dist-DlPa5gNa.js","assets/dist-DRBIy9A1.js","assets/dist-BlRuQIg1.js","assets/dist-HXD8sSA4.js","assets/dist-DjI7p99D.js","assets/dist-CZ4PyxQu.js","assets/dist-DGBjhKI9.js","assets/dist-LbeLCeoq.js","assets/dist-D8HpMxmZ.js","assets/dist-Dcww9FSw.js","assets/dist-D5u1uPmZ.js","assets/dist-CxmJXjJI.js","assets/dist-ONdtnupI.js","assets/dist-CQncCwUc.js","assets/dist-3qQVP6l8.js","assets/dist-BvjUKkwy.js","assets/dist-YqmXusLA.js","assets/dist-DxPJ1PN-.js","assets/dist-CfTFp0AF.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{c as t,l as n,n as r,r as i,t as a}from"./index-BsfNx6DV.js";var o=e(n(),1);async function s(e,t){let[{StreamLanguage:n},r]=await Promise.all([i(()=>import(`./dist-ZAR1Tu2c.js`).then(e=>e.d),__vite__mapDeps([0,1,2,3,4])),e()]),a=r[t]??r.default??r;return n.define(a)}var c={cpp:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),cc:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),cxx:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),hpp:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),hh:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),hxx:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),c:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),h:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),cu:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),cuh:()=>i(()=>import(`./dist-DRBIy9A1.js`).then(e=>e.cpp()),__vite__mapDeps([5,6,2,1,0,3,4])),js:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,6,2,0,3,4,8])),jsx:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,1,6,2,0,3,4,8])),mjs:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,6,2,0,3,4,8])),cjs:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,6,2,0,3,4,8])),ts:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,6,2,0,3,4,8])),tsx:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([7,1,6,2,0,3,4,8])),mts:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,6,2,0,3,4,8])),cts:()=>i(()=>import(`./dist-HXD8sSA4.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,6,2,0,3,4,8])),py:()=>i(()=>import(`./dist-CZ4PyxQu.js`).then(e=>e.python()),__vite__mapDeps([9,6,2,1,0,3,4,8])),pyi:()=>i(()=>import(`./dist-CZ4PyxQu.js`).then(e=>e.python()),__vite__mapDeps([9,6,2,1,0,3,4,8])),java:()=>i(()=>import(`./dist-DGBjhKI9.js`).then(e=>e.java()),__vite__mapDeps([10,6,2,1,0,3,4])),php:()=>i(()=>import(`./dist-LbeLCeoq.js`).then(e=>e.php()),__vite__mapDeps([11,6,2,1,12,13,0,3,4,7,8])),sql:()=>i(()=>import(`./dist-D5u1uPmZ.js`).then(e=>e.sql()),__vite__mapDeps([14,0,1,2,3,4,6,8])),yaml:()=>i(()=>import(`./dist-CxmJXjJI.js`).then(e=>e.yaml()),__vite__mapDeps([15,6,2,1,0,3,4])),yml:()=>i(()=>import(`./dist-CxmJXjJI.js`).then(e=>e.yaml()),__vite__mapDeps([15,6,2,1,0,3,4])),xml:()=>i(()=>import(`./dist-ONdtnupI.js`).then(e=>e.xml()),__vite__mapDeps([16,6,2,1,0,3,4])),json:()=>i(()=>import(`./dist-CQncCwUc.js`).then(e=>e.json()),__vite__mapDeps([17,6,2,1,0,3,4])),jsonc:()=>i(()=>import(`./dist-CQncCwUc.js`).then(e=>e.json()),__vite__mapDeps([17,6,2,1,0,3,4])),json5:()=>i(()=>import(`./dist-CQncCwUc.js`).then(e=>e.json()),__vite__mapDeps([17,6,2,1,0,3,4])),html:()=>i(()=>import(`./dist-D8HpMxmZ.js`).then(e=>e.html()),__vite__mapDeps([12,6,2,1,13,0,3,4,7,8])),htm:()=>i(()=>import(`./dist-D8HpMxmZ.js`).then(e=>e.html()),__vite__mapDeps([12,6,2,1,13,0,3,4,7,8])),vue:()=>i(()=>import(`./dist-D8HpMxmZ.js`).then(e=>e.html()),__vite__mapDeps([12,6,2,1,13,0,3,4,7,8])),svelte:()=>i(()=>import(`./dist-D8HpMxmZ.js`).then(e=>e.html()),__vite__mapDeps([12,6,2,1,13,0,3,4,7,8])),css:()=>i(()=>import(`./dist-Dcww9FSw.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([13,1,6,2,0,3,4])),md:()=>i(()=>import(`./dist-3qQVP6l8.js`).then(e=>e.markdown()),__vite__mapDeps([18,3,1,4,0,2,8,12,6,13,7])),markdown:()=>i(()=>import(`./dist-3qQVP6l8.js`).then(e=>e.markdown()),__vite__mapDeps([18,3,1,4,0,2,8,12,6,13,7])),mdx:()=>i(()=>import(`./dist-3qQVP6l8.js`).then(e=>e.markdown()),__vite__mapDeps([18,3,1,4,0,2,8,12,6,13,7])),rs:()=>i(()=>import(`./dist-BvjUKkwy.js`).then(e=>e.rust()),__vite__mapDeps([19,6,2,1,0,3,4])),go:()=>i(()=>import(`./dist-YqmXusLA.js`).then(e=>e.go()),__vite__mapDeps([20,6,2,1,0,3,4,8])),sh:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>i(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>i(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>i(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>i(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>i(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>i(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>i(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>i(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>i(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>i(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:n,jumpToLine:s,onSave:c,workspaceId:l,blame:g,onPosition:v,readOnly:y=!1}){let b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(null),D=(0,o.useRef)(null),O=(0,o.useRef)(n),k=(0,o.useRef)(c);O.current=n,k.current=c;let[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(!1),[P,F]=(0,o.useState)(`0,0`),[I,L]=(0,o.useState)(0);(0,o.useEffect)(()=>{let n=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,v,A,M,P,I,R]=await Promise.all([i(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([3,1])),i(()=>import(`./dist-DlPa5gNa.js`).then(e=>e.s),__vite__mapDeps([4,1,3])),i(()=>import(`./dist-DxPJ1PN-.js`),__vite__mapDeps([21,3,1,4,0,2])),i(()=>import(`./dist-CfTFp0AF.js`),__vite__mapDeps([22,4,1,3])),i(()=>import(`./dist-ZAR1Tu2c.js`).then(e=>e.d),__vite__mapDeps([0,1,2,3,4])),i(()=>import(`./dist-i79xiXVk.js`).then(e=>e.n),__vite__mapDeps([2,1])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),r().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(n||!b.current)return;c=M,l=P,C.current=m.Annotation.define(),w.current=m.Transaction.addToHistory;let z=t.length<=p&&I!==null;o=new m.Compartment;let B=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),v.history(),g.keymap.of([v.indentWithTab,...v.defaultKeymap,...v.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(k.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(C.current&&e.transactions.some(e=>e.annotation(C.current)===!0))&&O.current(e.state.doc.toString()),e.selectionSet&&F(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(y&&B.push(m.EditorState.readOnly.of(!0),g.EditorView.editable.of(!1)),R&&!y&&(s=new m.Compartment,B.splice(1,0,s.of([])),B.push(R.base)),I)try{B.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),z=!1}if(z&&o&&c&&l)try{B.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),z=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:B}),parent:b.current}),n){a.destroy();return}x.current=a,j(z),N(!0),T.current=R,E.current=s??null,D.current=null,L(e=>e+1);let V=new MutationObserver(()=>{let e=x.current;if(e&&z&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});S.current=V,V.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),n||N(!0)}})(),()=>{n=!0,S.current?.disconnect(),S.current=null,a?.destroy(),x.current=null,N(!1),b.current&&(b.current.textContent=``)}},[e,y]),(0,o.useEffect)(()=>{let e=x.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:C.current?C.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=x.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines)),n=Math.min(t.to,t.from+(s.column??1)-1);e.dispatch({selection:{anchor:t.to,head:n},scrollIntoView:!0}),e.focus()},[s,M]);let R=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=x.current,n=T.current,r=E.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;D.current!==o&&(D.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,I]);let z=x.current?.state.doc.toString()??t,B=z.length<=m?z:z.slice(0,m),V=h(e),H=d(V),U=x.current?.state,W=U?.selection.main.head,G=W===void 0?void 0:U?.doc.lineAt(W),K=G?.number,q=W!==void 0&&G?W-G.from+1:void 0;return(0,o.useEffect)(()=>{M&&K!==void 0&&q!==void 0&&v?.({line:K,column:q,language:A&&H||`纯文本`,highlight:A?V:`plain`})},[M,K,q,A,H,V,v]),(0,o.useEffect)(()=>()=>v?.(),[v]),(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":B,"data-file-content-truncated":z.length>m?`1`:`0`,"data-file-selection":P,"data-file-editor-ready":M?`1`:`0`,"data-file-blame-gutter":R?`1`:void 0,onMouseDown:()=>x.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:b,"aria-label":`${y?`查看`:`编辑`} ${e}`}),(!M||!v)&&(0,f.jsxs)(`div`,{className:`file-editor-status`,children:[!M&&(0,f.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),M&&W!==void 0&&G&&(0,f.jsxs)(`span`,{children:[`第 `,G.number,` 行,第 `,W-G.from+1,` 列`]}),M&&!A&&(0,f.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),M&&A&&H&&(0,f.jsx)(`span`,{"data-file-highlight-status":V,children:H})]})]})}export{v as CodeMirrorEditor,u as t,_ as themeHighlightStyle};