mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 08:15:53 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { config } from "../config";
|
||||
import { config } from '../config'
|
||||
import {
|
||||
storeCreateEnvironment,
|
||||
storeCreateSession,
|
||||
@@ -7,9 +7,12 @@ import {
|
||||
storeListActiveEnvironments,
|
||||
storeListActiveEnvironmentsByUsername,
|
||||
storeListSessionsByEnvironment,
|
||||
} from "../store";
|
||||
import type { RegisterEnvironmentRequest, EnvironmentResponse } from "../types/api";
|
||||
import type { EnvironmentRecord } from "../store";
|
||||
} from '../store'
|
||||
import type {
|
||||
RegisterEnvironmentRequest,
|
||||
EnvironmentResponse,
|
||||
} from '../types/api'
|
||||
import type { EnvironmentRecord } from '../store'
|
||||
|
||||
function toResponse(row: EnvironmentRecord): EnvironmentResponse {
|
||||
return {
|
||||
@@ -23,12 +26,17 @@ function toResponse(row: EnvironmentRecord): EnvironmentResponse {
|
||||
worker_type: row.workerType,
|
||||
channel_group_id: row.bridgeId,
|
||||
capabilities: row.capabilities,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function registerEnvironment(req: RegisterEnvironmentRequest & { metadata?: { worker_type?: string }; username?: string }) {
|
||||
const secret = config.apiKeys[0] || "";
|
||||
const workerType = req.worker_type || req.metadata?.worker_type;
|
||||
export function registerEnvironment(
|
||||
req: RegisterEnvironmentRequest & {
|
||||
metadata?: { worker_type?: string }
|
||||
username?: string
|
||||
},
|
||||
) {
|
||||
const secret = config.apiKeys[0] || ''
|
||||
const workerType = req.worker_type || req.metadata?.worker_type
|
||||
const record = storeCreateEnvironment({
|
||||
secret,
|
||||
machineName: req.machine_name,
|
||||
@@ -40,51 +48,58 @@ export function registerEnvironment(req: RegisterEnvironmentRequest & { metadata
|
||||
bridgeId: req.bridge_id,
|
||||
username: req.username,
|
||||
capabilities: req.capabilities,
|
||||
});
|
||||
})
|
||||
|
||||
let sessionId: string | undefined;
|
||||
let sessionId: string | undefined
|
||||
// ACP agents: reuse existing session or create one
|
||||
if (workerType === "acp") {
|
||||
const existing = storeListSessionsByEnvironment(record.id);
|
||||
if (workerType === 'acp') {
|
||||
const existing = storeListSessionsByEnvironment(record.id)
|
||||
if (existing.length > 0) {
|
||||
sessionId = existing[0].id;
|
||||
sessionId = existing[0].id
|
||||
} else {
|
||||
const session = storeCreateSession({
|
||||
environmentId: record.id,
|
||||
title: req.machine_name || "ACP Agent",
|
||||
source: "acp",
|
||||
});
|
||||
sessionId = session.id;
|
||||
title: req.machine_name || 'ACP Agent',
|
||||
source: 'acp',
|
||||
})
|
||||
sessionId = session.id
|
||||
}
|
||||
}
|
||||
|
||||
return { environment_id: record.id, environment_secret: record.secret, status: record.status as "active", session_id: sessionId };
|
||||
return {
|
||||
environment_id: record.id,
|
||||
environment_secret: record.secret,
|
||||
status: record.status as 'active',
|
||||
session_id: sessionId,
|
||||
}
|
||||
}
|
||||
|
||||
export function deregisterEnvironment(envId: string) {
|
||||
storeUpdateEnvironment(envId, { status: "deregistered" });
|
||||
storeUpdateEnvironment(envId, { status: 'deregistered' })
|
||||
}
|
||||
|
||||
export function getEnvironment(envId: string) {
|
||||
return storeGetEnvironment(envId);
|
||||
return storeGetEnvironment(envId)
|
||||
}
|
||||
|
||||
export function updatePollTime(envId: string) {
|
||||
storeUpdateEnvironment(envId, { lastPollAt: new Date() });
|
||||
storeUpdateEnvironment(envId, { lastPollAt: new Date() })
|
||||
}
|
||||
|
||||
export function listActiveEnvironments() {
|
||||
return storeListActiveEnvironments();
|
||||
return storeListActiveEnvironments()
|
||||
}
|
||||
|
||||
export function listActiveEnvironmentsResponse(): EnvironmentResponse[] {
|
||||
return storeListActiveEnvironments().map(toResponse);
|
||||
return storeListActiveEnvironments().map(toResponse)
|
||||
}
|
||||
|
||||
export function listActiveEnvironmentsByUsername(username: string): EnvironmentResponse[] {
|
||||
return storeListActiveEnvironmentsByUsername(username).map(toResponse);
|
||||
export function listActiveEnvironmentsByUsername(
|
||||
username: string,
|
||||
): EnvironmentResponse[] {
|
||||
return storeListActiveEnvironmentsByUsername(username).map(toResponse)
|
||||
}
|
||||
|
||||
export function reconnectEnvironment(envId: string) {
|
||||
storeUpdateEnvironment(envId, { status: "active" });
|
||||
storeUpdateEnvironment(envId, { status: 'active' })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user