同步操作将从 ZeroFreeze/claude-code-source-code 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/* eslint-disable eslint-plugin-n/no-unsupported-features/node-builtins */import { errorMessage } from '../utils/errors.js'import { jsonStringify } from '../utils/slowOperations.js'import type { DirectConnectConfig } from './directConnectManager.js'import { connectResponseSchema } from './types.js'/*** Errors thrown by createDirectConnectSession when the connection fails.*/export class DirectConnectError extends Error {constructor(message: string) {super(message)this.name = 'DirectConnectError'}}/*** Create a session on a direct-connect server.** Posts to `${serverUrl}/sessions`, validates the response, and returns* a DirectConnectConfig ready for use by the REPL or headless runner.** Throws DirectConnectError on network, HTTP, or response-parsing failures.*/export async function createDirectConnectSession({serverUrl,authToken,cwd,dangerouslySkipPermissions,}: {serverUrl: stringauthToken?: stringcwd: stringdangerouslySkipPermissions?: boolean}): Promise<{config: DirectConnectConfigworkDir?: string}> {const headers: Record<string, string> = {'content-type': 'application/json',}if (authToken) {headers['authorization'] = `Bearer ${authToken}`}let resp: Responsetry {resp = await fetch(`${serverUrl}/sessions`, {method: 'POST',headers,body: jsonStringify({cwd,...(dangerouslySkipPermissions && {dangerously_skip_permissions: true,}),}),})} catch (err) {throw new DirectConnectError(`Failed to connect to server at ${serverUrl}: ${errorMessage(err)}`,)}if (!resp.ok) {throw new DirectConnectError(`Failed to create session: ${resp.status}${resp.statusText}`,)}const result = connectResponseSchema().safeParse(await resp.json())if (!result.success) {throw new DirectConnectError(`Invalid session response: ${result.error.message}`,)}const data = result.datareturn {config: {serverUrl,sessionId: data.session_id,wsUrl: data.ws_url,authToken,},workDir: data.work_dir,}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。