refactor(copilot): drop unused exported helpers · openclaw/openclaw@96dbd1c
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,6 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
5 | 5 | import { |
6 | 6 | COPILOT_DEFAULT_AGENT_ID, |
7 | 7 | COPILOT_TOKEN_PROFILE_ERROR, |
8 | | -normalizeCopilotHomePath, |
9 | 8 | resolveCopilotAuth, |
10 | 9 | sanitizeAgentId, |
11 | 10 | tokenFingerprint, |
@@ -508,18 +507,3 @@ describe("resolveCopilotAuth - defaults wiring", () => {
|
508 | 507 | ); |
509 | 508 | }); |
510 | 509 | }); |
511 | | - |
512 | | -describe("normalizeCopilotHomePath", () => { |
513 | | -it("resolves to absolute and strips trailing separators", () => { |
514 | | -const normalized = normalizeCopilotHomePath("./foo/bar/"); |
515 | | -expect(normalized).toBe(resolve("./foo/bar")); |
516 | | -expect(normalized.endsWith("/")).toBe(false); |
517 | | -expect(normalized.endsWith("\\")).toBe(false); |
518 | | -}); |
519 | | - |
520 | | -it("is idempotent", () => { |
521 | | -const once = normalizeCopilotHomePath("/some/path/"); |
522 | | -const twice = normalizeCopilotHomePath(once); |
523 | | -expect(twice).toBe(once); |
524 | | -}); |
525 | | -}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Copilot plugin module implements auth bridge behavior. |
2 | 2 | import { createHash } from "node:crypto"; |
3 | 3 | import { homedir as osHomedir } from "node:os"; |
4 | | -import { join, normalize, resolve, sep } from "node:path"; |
| 4 | +import { join, resolve } from "node:path"; |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Pure functional auth resolver for the copilot agent runtime. |
@@ -307,16 +307,3 @@ export function tokenFingerprint(token: string): string {
|
307 | 307 | function readString(value: unknown): string | undefined { |
308 | 308 | return typeof value === "string" && value.length > 0 ? value : undefined; |
309 | 309 | } |
310 | | - |
311 | | -/** |
312 | | - * Normalize a copilotHome path for cross-platform pool keying. |
313 | | - * Re-exported so attempt.ts / runtime.ts can share the same |
314 | | - * normalization without re-implementing. |
315 | | - */ |
316 | | -export function normalizeCopilotHomePath(value: string): string { |
317 | | -return normalize(resolve(value)).replace(new RegExp(`${escapeForRegex(sep)}+$`), ""); |
318 | | -} |
319 | | - |
320 | | -function escapeForRegex(value: string): string { |
321 | | -return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); |
322 | | -} |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,6 @@ import { tmpdir } from "node:os";
|
4 | 4 | import path from "node:path"; |
5 | 5 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
6 | 6 | import { |
7 | | -COPILOT_SDK_FALLBACK_DIR, |
8 | 7 | COPILOT_SDK_SPEC, |
9 | 8 | resetCopilotSdkCacheForTests, |
10 | 9 | loadCopilotSdk, |
@@ -201,10 +200,6 @@ describe("sdk-loader", () => {
|
201 | 200 | expect(primaryImport).toHaveBeenCalledTimes(2); |
202 | 201 | }); |
203 | 202 | |
204 | | -it("default fallback dir points at ~/.openclaw/npm-runtime/copilot", () => { |
205 | | -expect(COPILOT_SDK_FALLBACK_DIR).toMatch(/\.openclaw[\\/]+npm-runtime[\\/]+copilot$/); |
206 | | -}); |
207 | | - |
208 | 203 | it("resolves the fallback dir from OPENCLAW_STATE_DIR for relocated profiles", () => { |
209 | 204 | expect( |
210 | 205 | resolveCopilotSdkFallbackDir({ |
@@ -220,9 +215,6 @@ describe("sdk-loader", () => {
|
220 | 215 | }); |
221 | 216 | |
222 | 217 | describe("sdk dependency constants", () => { |
223 | | -it("COPILOT_SDK_FALLBACK_DIR keeps the legacy fallback path stable", () => { |
224 | | -expect(COPILOT_SDK_FALLBACK_DIR).toMatch(/\.openclaw[\\/]+npm-runtime[\\/]+copilot$/); |
225 | | -}); |
226 | 218 | it("COPILOT_SDK_SPEC pins the canonical SDK spec", () => { |
227 | 219 | expect(COPILOT_SDK_SPEC).toBe("@github/copilot-sdk@1.0.0-beta.9"); |
228 | 220 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,8 +10,6 @@ export function resolveCopilotSdkFallbackDir(env: NodeJS.ProcessEnv = process.en
|
10 | 10 | return path.join(resolveStateDir(env), "npm-runtime", "copilot"); |
11 | 11 | } |
12 | 12 | |
13 | | -export const COPILOT_SDK_FALLBACK_DIR = resolveCopilotSdkFallbackDir(); |
14 | | - |
15 | 13 | export const COPILOT_SDK_SPEC = "@github/copilot-sdk@1.0.0-beta.9"; |
16 | 14 | |
17 | 15 | let cached: Promise<typeof Sdk> | undefined; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。