Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions apps/ade-cli/src/adeRpcServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2410,9 +2410,7 @@ function buildAdeInlineGuidanceForLane(laneWorktreePath: string | null | undefin
return buildAdeCliInlineGuidance(getAdeAgentSkillRootsForPrompt({ cwd: laneWorktreePath ?? undefined }));
}

function resolveRunContextLaneId(runtime: AdeRuntime, callerCtx: CallerContext): string | null {
void runtime;
void callerCtx;
function resolveRunContextLaneId(_runtime: AdeRuntime, _callerCtx: CallerContext): string | null {
return null;
}

Expand Down Expand Up @@ -2864,12 +2862,8 @@ async function resolveEffectiveCallerContext(
return callerCtx;
}

function isStandaloneChatCaller(callerCtx: CallerContext): boolean {
return callerCtx.standaloneChatSession;
}

function isToolHiddenForStandaloneChat(name: string, callerCtx: CallerContext): boolean {
return isStandaloneChatCaller(callerCtx) && STANDALONE_CHAT_HIDDEN_TOOL_NAMES.has(name);
return callerCtx.standaloneChatSession && STANDALONE_CHAT_HIDDEN_TOOL_NAMES.has(name);
}

function isLocalComputerUseAllowed(callerCtx: CallerContext): boolean {
Expand Down Expand Up @@ -2922,8 +2916,7 @@ async function listToolSpecsForSession(runtime: AdeRuntime, session: SessionStat
return allVisibleTools.filter((tool) => !isToolHiddenForStandaloneChat(tool.name, callerCtx));
}

function parseInitializeIdentity(runtime: AdeRuntime, params: unknown): SessionIdentity {
void runtime;
function parseInitializeIdentity(_runtime: AdeRuntime, params: unknown): SessionIdentity {
const data = safeObject(params);
const identity = safeObject(data.identity);
const envContext = resolveEnvCallerContext();
Expand Down Expand Up @@ -3094,7 +3087,6 @@ async function buildLaneStatus(runtime: AdeRuntime, laneId: string): Promise<Rec
};
}


// Global ask_user rate limit shared across all sessions to prevent
// bypass via session recycling. Limits to 20 calls per 60s globally.
const GLOBAL_ASK_USER_RATE_LIMIT = {
Expand Down Expand Up @@ -3217,9 +3209,7 @@ async function runTool(args: {
title: args.title,
path: args.artifactPath,
mimeType: args.mimeType,
metadata: {
...args.metadata,
},
metadata: args.metadata,
},
],
owners: resolveComputerUseOwners(args.sessionState, args.toolArgs),
Expand Down Expand Up @@ -3602,14 +3592,17 @@ async function runTool(args: {
const argsList = Array.isArray(toolArgs.argsList) ? toolArgs.argsList : null;
const hasScalarArg = Object.prototype.hasOwnProperty.call(toolArgs, "arg");
const rawObjectArgs = safeObject(toolArgs.args);
const result = argsList
? await (callable as (...params: unknown[]) => Promise<unknown>).apply(service, argsList)
: hasScalarArg
? await (callable as (arg: unknown) => Promise<unknown>).call(service, toolArgs.arg)
: await (callable as (args?: Record<string, unknown>) => Promise<unknown>).call(
service,
Object.keys(rawObjectArgs).length > 0 ? rawObjectArgs : undefined
);
let result: unknown;
if (argsList) {
result = await (callable as (...params: unknown[]) => Promise<unknown>).apply(service, argsList);
} else if (hasScalarArg) {
result = await (callable as (arg: unknown) => Promise<unknown>).call(service, toolArgs.arg);
} else {
result = await (callable as (args?: Record<string, unknown>) => Promise<unknown>).call(
service,
Object.keys(rawObjectArgs).length > 0 ? rawObjectArgs : undefined,
);
}
const record = isRecord(result) ? result : null;
const statusHints = {
operationId: typeof record?.operationId === "string" ? record.operationId : null,
Expand Down Expand Up @@ -4076,11 +4069,10 @@ async function runTool(args: {
});
}
const answered = result.decision !== "decline" && result.decision !== "cancel";
const outcome = result.decision === "decline"
? "declined"
: result.decision === "cancel"
? "cancelled"
: "answered";
let outcome: "answered" | "declined" | "cancelled";
if (result.decision === "decline") outcome = "declined";
else if (result.decision === "cancel") outcome = "cancelled";
else outcome = "answered";
return buildAskUserResult({
awaitingUserResponse: false,
blocking: false,
Expand Down
2 changes: 1 addition & 1 deletion apps/ade-cli/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ export async function createAdeRuntime(args: {
projectRoot,
logger,
onEvent: (event) => pushEvent("runtime", { type: "computer_use_event", event }),
} as Parameters<typeof createComputerUseArtifactBrokerService>[0]);
});
const iosSimulatorService = chatOnlyRuntime
? null
: createIosSimulatorService({
Expand Down
6 changes: 3 additions & 3 deletions apps/ade-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10127,10 +10127,10 @@ function readMachineRuntimeInfo(value: unknown): MachineRuntimeInfo {
}
const pid = value.runtimeInfo.pid;
return {
version: asString(value.runtimeInfo.version)?.trim() || null,
buildHash: asString(value.runtimeInfo.buildHash)?.trim() || null,
version: asString(value.runtimeInfo.version),
buildHash: asString(value.runtimeInfo.buildHash),
defaultRole: normalizeAdeRuntimeRole(value.runtimeInfo.defaultRole),
projectRoot: asString(value.runtimeInfo.projectRoot)?.trim() || null,
projectRoot: asString(value.runtimeInfo.projectRoot),
Comment thread
greptile-apps[bot] marked this conversation as resolved.
pid:
typeof pid === "number" && Number.isFinite(pid) && pid > 0
? Math.floor(pid)
Expand Down
4 changes: 2 additions & 2 deletions apps/ade-cli/src/headlessLinearServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ export function createHeadlessLinearServices(
outboundService,
prService,
computerUseArtifactBrokerService: args.computerUseArtifactBrokerService,
} as Parameters<typeof createLinearCloseoutServiceImpl>[0]);
});
const dispatcherService = createLinearDispatcherServiceImpl({
db: args.db,
projectId: args.projectId,
Expand All @@ -1662,7 +1662,7 @@ export function createHeadlessLinearServices(
workerTaskSessionService,
prService,
onEvent: args.onLinearWorkflowEvent ?? (() => {}),
} as Parameters<typeof createLinearDispatcherServiceImpl>[0]);
});
const syncService = createLinearSyncServiceImpl({
db: args.db,
logger: args.logger,
Expand Down
26 changes: 13 additions & 13 deletions apps/ade-cli/src/multiProjectRpcServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,19 @@ export function createMultiProjectRpcRequestHandler(
return syncService;
};

const resolveRuntimeEnvInfo = () => ({
buildHash:
typeof process.env.ADE_RUNTIME_BUILD_HASH === "string" &&
process.env.ADE_RUNTIME_BUILD_HASH.trim()
? process.env.ADE_RUNTIME_BUILD_HASH.trim()
: null,
defaultRole: normalizeAdeRuntimeRole(process.env.ADE_DEFAULT_ROLE),
projectRoot:
typeof process.env.ADE_PROJECT_ROOT === "string" &&
process.env.ADE_PROJECT_ROOT.trim()
? path.resolve(process.env.ADE_PROJECT_ROOT.trim())
: null,
});
const trimmedEnvOrNull = (key: string): string | null => {
const value = process.env[key];
return typeof value === "string" && value.trim() ? value.trim() : null;
};

const resolveRuntimeEnvInfo = () => {
const projectRoot = trimmedEnvOrNull("ADE_PROJECT_ROOT");
return {
buildHash: trimmedEnvOrNull("ADE_RUNTIME_BUILD_HASH"),
defaultRole: normalizeAdeRuntimeRole(process.env.ADE_DEFAULT_ROLE),
projectRoot: projectRoot ? path.resolve(projectRoot) : null,
};
};

const handler = (async (request: JsonRpcRequest): Promise<unknown | null> => {
const method = typeof request.method === "string" ? request.method : "";
Expand Down
22 changes: 10 additions & 12 deletions apps/ade-cli/src/tuiClient/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,22 +384,20 @@ class StaleAdeSocketError extends Error {
}
}

function trimmedStringOrNull(value: unknown): string | null {
if (typeof value !== "string") return null;
const trimmed = value.trim();
return trimmed || null;
}

function readAttachedRuntimeInfo(result: InitializeResult): AttachedRuntimeInfo {
const runtimeInfo = result.runtimeInfo;
const pid = runtimeInfo?.pid;
const projectRoot = trimmedStringOrNull(runtimeInfo?.projectRoot);
return {
buildHash:
typeof runtimeInfo?.buildHash === "string" && runtimeInfo.buildHash.trim()
? runtimeInfo.buildHash.trim()
: null,
defaultRole:
typeof runtimeInfo?.defaultRole === "string" && runtimeInfo.defaultRole.trim()
? runtimeInfo.defaultRole.trim()
: null,
projectRoot:
typeof runtimeInfo?.projectRoot === "string" && runtimeInfo.projectRoot.trim()
? path.resolve(runtimeInfo.projectRoot.trim())
: null,
buildHash: trimmedStringOrNull(runtimeInfo?.buildHash),
defaultRole: trimmedStringOrNull(runtimeInfo?.defaultRole),
projectRoot: projectRoot ? path.resolve(projectRoot) : null,
pid:
typeof pid === "number" && Number.isFinite(pid) && pid > 0
? Math.floor(pid)
Expand Down
23 changes: 10 additions & 13 deletions apps/desktop/src/main/services/config/projectConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,21 +594,18 @@ function coerceAutomationExecution(value: unknown): AutomationExecution | undefi

if (kind === "agent-session") {
const legacyTitle = kindRaw === "mission" ? legacyMissionPrompt(value) : undefined;
const session = isRecord(value.session)
const sessionTitle = isRecord(value.session)
? firstNonEmptyString(value.session.title, legacyTitle)
: legacyTitle;
const sessionReasoningEffort = isRecord(value.session) ? asString(value.session.reasoningEffort)?.trim() : undefined;
const sessionCodexFastMode = isRecord(value.session) ? asBool(value.session.codexFastMode) : undefined;
const session = sessionTitle || sessionReasoningEffort || sessionCodexFastMode != null
? {
...(asString(value.session.title)?.trim()
? { title: asString(value.session.title)!.trim() }
: legacyTitle
? { title: legacyTitle }
: {}),
...(asString(value.session.reasoningEffort)?.trim()
? { reasoningEffort: asString(value.session.reasoningEffort)!.trim() }
: {}),
...(asBool(value.session.codexFastMode) != null ? { codexFastMode: asBool(value.session.codexFastMode) } : {}),
...(sessionTitle ? { title: sessionTitle } : {}),
...(sessionReasoningEffort ? { reasoningEffort: sessionReasoningEffort } : {}),
...(sessionCodexFastMode != null ? { codexFastMode: sessionCodexFastMode } : {}),
}
: legacyTitle
? { title: legacyTitle }
: undefined;
: undefined;
return {
kind,
...sharedLaneFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2608,9 +2608,7 @@ export function AgentChatComposer({
captureRichSelection();
}, [captureRichSelection, getRichCursorTextOffset, onDraftChange, serializeRichEditor]);

const singleModelBlockedMessage = (modelUnavailableMessage?.trim() ?? "").length > 0
? modelUnavailableMessage
: null;
const singleModelBlockedMessage = modelUnavailableMessage?.trim() ? modelUnavailableMessage : null;
const singleModelReady = Boolean(modelId) && !singleModelBlockedMessage;

const submitComposerDraft = useCallback(() => {
Expand Down
Loading
Loading