Skip to content

Commit 45961b3

Browse files
committed
refactor(infra): remove internal deprecated helpers
1 parent 29781ab commit 45961b3

8 files changed

Lines changed: 7 additions & 85 deletions

‎src/auto-reply/reply/commands-session.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export const handleUsageCommand: CommandHandler = async (params, allowTextComman
323323
config: params.cfg,
324324
agentId: sessionAgentId,
325325
});
326-
const summary = await loadCostUsageSummary({ days: 30, config: params.cfg });
326+
const summary = await loadCostUsageSummary({ config: params.cfg });
327327

328328
const sessionCost = formatUsd(sessionSummary?.totalCost);
329329
const sessionTokens = sessionSummary?.totalTokens

‎src/infra/exec-approval-reply.ts‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
import { isWellFormedApprovalId } from "../../packages/gateway-protocol/src/schema/approval-id.js";
77
import type { ReplyPayload } from "../auto-reply/types.js";
88
import type {
9-
InteractiveReply,
10-
InteractiveReplyButton,
119
MessagePresentation,
1210
MessagePresentationAction,
1311
MessagePresentationButton,
@@ -229,22 +227,6 @@ export function buildTypedApprovalActionDescriptors(
229227
);
230228
}
231229

232-
function buildApprovalInteractiveButtons(
233-
descriptors: readonly ExecApprovalActionDescriptor[],
234-
): InteractiveReplyButton[] {
235-
return descriptors.map((descriptor) => {
236-
const action =
237-
descriptor.action ??
238-
({ type: "command", command: descriptor.command } satisfies MessagePresentationAction);
239-
return {
240-
label: descriptor.label,
241-
action,
242-
...(descriptor.action ? {} : { value: descriptor.command }),
243-
style: descriptor.style,
244-
};
245-
});
246-
}
247-
248230
function buildApprovalPresentationButtons(
249231
descriptors: readonly ExecApprovalActionDescriptor[],
250232
): MessagePresentationButton[] {
@@ -329,16 +311,6 @@ export function buildTypedExecApprovalPresentation(params: {
329311
});
330312
}
331313

332-
/**
333-
* @deprecated Use buildApprovalPresentationFromActionDescriptors.
334-
*/
335-
export function buildApprovalInteractiveReplyFromActionDescriptors(
336-
actions: readonly ExecApprovalActionDescriptor[],
337-
): InteractiveReply | undefined {
338-
const buttons = buildApprovalInteractiveButtons(actions);
339-
return buttons.length > 0 ? { blocks: [{ type: "buttons", buttons }] } : undefined;
340-
}
341-
342314
export function getExecApprovalApproverDmNoticeText(): string {
343315
return "Approval required. I sent approval DMs to the approvers for this account.";
344316
}

‎src/infra/exec-approvals-analysis.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export { analyzeArgvCommand } from "./exec-argv-analysis.js";
77
export {
88
matchAllowlist,
99
parseExecArgvToken,
10-
resolveAllowlistCandidatePath,
1110
resolveApprovalAuditCandidatePath,
1211
resolveApprovalAuditTrustPath,
1312
resolveCommandResolution,

‎src/infra/exec-command-resolution.test.ts‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
parseExecArgvToken,
1111
resolveCommandResolution,
1212
resolveCommandResolutionFromArgv,
13-
resolveAllowlistCandidatePath,
1413
resolveApprovalAuditTrustPath,
1514
resolveExecutionTargetCandidatePath,
1615
resolveExecutionTargetTrustPath,
@@ -509,28 +508,4 @@ describe("exec-command-resolution", () => {
509508
}
510509
});
511510

512-
it("does not synthesize cwd-joined allowlist candidates from drive-less windows roots", () => {
513-
if (process.platform !== "win32") {
514-
return;
515-
}
516-
517-
expect(
518-
resolveAllowlistCandidatePath(
519-
{
520-
rawExecutable: String.raw`:\Users\demo\AI\system\openclaw`,
521-
executableName: "openclaw",
522-
},
523-
String.raw`C:\Users\demo\AI\system\openclaw`,
524-
),
525-
).toBeUndefined();
526-
expect(
527-
resolveAllowlistCandidatePath(
528-
{
529-
rawExecutable: String.raw`:/Users/demo/AI/system/openclaw`,
530-
executableName: "openclaw",
531-
},
532-
String.raw`C:\Users\demo\AI\system\openclaw`,
533-
),
534-
).toBeUndefined();
535-
});
536511
});

‎src/infra/exec-command-resolution.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,6 @@ export function resolveApprovalAuditTrustPath(
270270
return resolvePolicyTargetTrustPath(resolution, cwd);
271271
}
272272

273-
/** @deprecated Use resolveExecutionTargetCandidatePath. */
274-
export function resolveAllowlistCandidatePath(
275-
resolution: CommandResolution | ExecutableResolution | null,
276-
cwd?: string,
277-
): string | undefined {
278-
return resolveExecutionTargetCandidatePath(resolution, cwd);
279-
}
280-
281273
export function resolvePolicyAllowlistCandidatePath(
282274
resolution: CommandResolution | ExecutableResolution | null,
283275
cwd?: string,

‎src/infra/home-dir.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,6 @@ export function resolveHomeRelativePath(
143143
return path.resolve(trimmed);
144144
}
145145

146-
/**
147-
* Backward-compatible alias for resolving user paths against the effective home.
148-
*
149-
* @deprecated Use resolveHomeRelativePath.
150-
*/
151-
export function resolveUserPath(
152-
input: string,
153-
env: NodeJS.ProcessEnv = process.env,
154-
homedir: () => string = os.homedir,
155-
): string {
156-
return resolveHomeRelativePath(input, { env, homedir });
157-
}
158-
159146
/** Resolves a user-supplied path against the OS home, ignoring OPENCLAW_HOME. */
160147
export function resolveOsHomeRelativePath(
161148
input: string,

‎src/infra/session-cost-usage.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe("session cost usage", () => {
161161
} as unknown as OpenClawConfig;
162162

163163
await withStateDir(root, async () => {
164-
const summary = await loadCostUsageSummary({ days: 30, config });
164+
const summary = await loadCostUsageSummary({ config });
165165
// Daily series fills every calendar day in the requested range, even
166166
// days with zero activity, so the chart shows one bar per day.
167167
expect(summary.daily.length).toBe(summary.days);
@@ -405,7 +405,7 @@ describe("session cost usage", () => {
405405
const costSpy = vi.spyOn(usageFormat, "resolveModelCostConfig");
406406
try {
407407
await withStateDir(root, async () => {
408-
const summary = await loadCostUsageSummary({ days: 30, config });
408+
const summary = await loadCostUsageSummary({ config });
409409
expect(summary.totals.totalTokens).toBe(360);
410410
expect(summary.totals.totalCost).toBeCloseTo(0.0006, 8);
411411
});
@@ -451,7 +451,7 @@ describe("session cost usage", () => {
451451
// not an intentional "free" price.
452452
clearGatewayModelPricingCacheState();
453453
await withStateDir(root, async () => {
454-
const summary = await loadCostUsageSummary({ days: 30 });
454+
const summary = await loadCostUsageSummary();
455455
expect(summary.totals.totalTokens).toBe(23287);
456456
expect(summary.totals.totalCost).toBe(0);
457457
// Unknown pricing must be surfaced as missing rather than reported as a
@@ -511,7 +511,7 @@ describe("session cost usage", () => {
511511

512512
clearGatewayModelPricingCacheState();
513513
await withStateDir(root, async () => {
514-
const summary = await loadCostUsageSummary({ days: 30, config });
514+
const summary = await loadCostUsageSummary({ config });
515515
expect(summary.totals.totalTokens).toBe(23287);
516516
expect(summary.totals.totalCost).toBe(0);
517517
expect(summary.totals.missingCostEntries).toBe(1);
@@ -1056,7 +1056,7 @@ describe("session cost usage", () => {
10561056
);
10571057

10581058
await withStateDir(root, async () => {
1059-
const summary = await loadCostUsageSummary({ days: 30 });
1059+
const summary = await loadCostUsageSummary();
10601060
expect(summary.daily.length).toBe(summary.days);
10611061
const populated = summary.daily.filter((d) => d.totalTokens > 0);
10621062
expect(populated).toHaveLength(1);

‎src/infra/session-cost-usage.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,8 +1458,6 @@ export async function loadCostUsageSummary(params?: {
14581458
startMs?: number;
14591459
endMs?: number;
14601460
dayBucket?: UsageDailyBucket;
1461-
/** @deprecated Use startMs/endMs. */
1462-
days?: number;
14631461
config?: OpenClawConfig;
14641462
agentId?: string;
14651463
}): Promise<CostUsageSummary> {
@@ -1471,8 +1469,7 @@ export async function loadCostUsageSummary(params?: {
14711469
sinceTime = params.startMs;
14721470
untilTime = params.endMs;
14731471
} else {
1474-
// Fallback to days-based calculation for backwards compatibility
1475-
const days = Math.max(1, Math.floor(params?.days ?? 30));
1472+
const days = 30;
14761473
const since = new Date(now);
14771474
since.setDate(since.getDate() - (days - 1));
14781475
sinceTime = since.getTime();

0 commit comments

Comments
 (0)