diff --git a/src/cli/commands/corps-bind.test.ts b/src/cli/commands/corps-bind.test.ts index 7e86488..7f68281 100644 --- a/src/cli/commands/corps-bind.test.ts +++ b/src/cli/commands/corps-bind.test.ts @@ -335,30 +335,30 @@ describe("corps sync-test", () => { const postPref = requests.find((r) => (r.method === "POST" || r.method === "PATCH") && r.path.includes("config")); expect(postPref).toBeDefined(); - expect((postPref?.body as any).decisionPreferences?.explicitApprove).toBe("Prod approve note"); + expect((postPref!.body as any).decisionPreferences?.explicitApprove).toBe("Prod approve note"); const deleteDoc = requests.find((r) => r.method === "DELETE" && r.path === "/api/v1/knowledge/articles/test-doc-old"); expect(deleteDoc).toBeDefined(); const patchDoc = requests.find((r) => r.method === "PATCH" && r.path === "/api/v1/knowledge/articles/test-doc-2"); expect(patchDoc).toBeDefined(); - expect((patchDoc?.body as any).attributes?.content).toBe("Content Beta Updated"); + expect((patchDoc!.body as any).attributes?.content).toBe("Content Beta Updated"); const postDoc = requests.find((r) => r.method === "POST" && r.path === "/api/v1/knowledge/articles"); expect(postDoc).toBeDefined(); - expect((postDoc?.body as any).title).toBe("Doc Alpha"); + expect((postDoc!.body as any).title).toBe("Doc Alpha"); const deleteRule = requests.find((r) => r.method === "DELETE" && r.path === "/api/v1/rules/test-rule-old"); expect(deleteRule).toBeDefined(); const createdRules = requests.filter((r) => r.method === "POST" && r.path === "/api/v1/rules"); expect(createdRules.length).toBe(2); - expect((createdRules[0]?.body as any).description).toBe("Production Rule A"); - expect((createdRules[1]?.body as any).description).toBe("Production Rule B"); + expect((createdRules[0]!.body as any).description).toBe("Production Rule A"); + expect((createdRules[1]!.body as any).description).toBe("Production Rule B"); const publishVersion = requests.find((r) => r.method === "POST" && r.path === "/api/v1/rule-set-versions/publish"); expect(publishVersion).toBeDefined(); - expect((publishVersion?.body as any).versionName).toBe("v1.5-staging"); + expect((publishVersion!.body as any).versionName).toBe("v1.5-staging"); const allPublishCalls = requests.filter((r) => r.path === "/api/v1/rule-set-versions/publish"); expect(allPublishCalls.length).toBe(1); diff --git a/src/cli/commands/corps.test.ts b/src/cli/commands/corps.test.ts index e329e2c..269f267 100644 --- a/src/cli/commands/corps.test.ts +++ b/src/cli/commands/corps.test.ts @@ -694,7 +694,7 @@ describe("Hose OpenAPI key extraction from assistance link", () => { ).toString("base64url"); const fakeJwt = `header.${jwtPayload}.signature`; - globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { + globalThis.fetch = (async (input: RequestInfo | URL) => { const urlStr = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url; const url = new URL(urlStr); diff --git a/src/cli/commands/corps/onboarding.ts b/src/cli/commands/corps/onboarding.ts index e5030b3..58a969a 100644 --- a/src/cli/commands/corps/onboarding.ts +++ b/src/cli/commands/corps/onboarding.ts @@ -326,7 +326,7 @@ async function addLinkAsHoseCorp(link: string, name: string | undefined, overwri console.error("ℹ️ [合思子域提权] 正在通过合思协助链接提取 OpenAPI 开发者密钥并提升企业权限等级..."); let elevated; try { - elevated = await elevateHoseLink({ link, name, overwrite, force, dryRun, ...(selection ?? {}) }); + elevated = await elevateHoseLink({ link, name, overwrite, force, dryRun, ...selection }); } catch (error) { if (error instanceof HoseKeySelectionError) throw new CliError(error.message, 2, error.nextAction); throw error; diff --git a/src/cli/commands/corps/overview.ts b/src/cli/commands/corps/overview.ts index 48a2abb..b9e73f8 100644 --- a/src/cli/commands/corps/overview.ts +++ b/src/cli/commands/corps/overview.ts @@ -10,7 +10,7 @@ import { sortCorpsByUsageAndRecency } from "../../../core/stats/usage-tracker.js import type { CorpEnvironment } from "../../../core/config/types.js"; import { selectCorp } from "../../helpers.js"; import { confirmationRequired, usageError } from "../../errors.js"; -import { booleanOption, numberOption, optionalString, stringOption } from "../../parser.js"; +import { booleanOption, numberOption, stringOption } from "../../parser.js"; import { printJson } from "../../printer.js"; import type { ParsedArgs } from "../../types.js"; import { formatSafeSourceDetail, resolveCorpSealUrl } from "./shared.js"; diff --git a/src/cli/commands/corps/sync.ts b/src/cli/commands/corps/sync.ts index a6a430b..db65506 100644 --- a/src/cli/commands/corps/sync.ts +++ b/src/cli/commands/corps/sync.ts @@ -1,6 +1,6 @@ import { createSealClient } from "../../../core/http/factory.js"; import type { CorpConfig } from "../../../core/config/types.js"; -import { syncTestEnterprise, buildTestHosecloudOutboundName } from "../../../domains/seal/test-sync.js"; +import { syncTestEnterprise } from "../../../domains/seal/test-sync.js"; import { executeApprovalRunsReplay, type ReplayRecordsQuery } from "../../../domains/seal/webhook-replay.js"; import { selectCorp } from "../../helpers.js"; import { CliError, confirmationRequired, usageError } from "../../errors.js"; diff --git a/src/cli/commands/update.ts b/src/cli/commands/update.ts index 8486e9e..adfec94 100644 --- a/src/cli/commands/update.ts +++ b/src/cli/commands/update.ts @@ -13,8 +13,6 @@ import type { CliRuntime } from "../types.js"; const DEFAULT_GITHUB_REPO = "yunyingk/seal-use"; const LEGACY_GITHUB_REPO = "yunyingk/seal-home"; -const UPDATE_URL_ENV = "SEAL_USE_UPDATE_URL"; -const LEGACY_UPDATE_URL_ENV = "SEAL_HOME_UPDATE_URL"; const GITHUB_REPO_ENV = "SEAL_USE_GITHUB_REPO"; const LEGACY_GITHUB_REPO_ENV = "SEAL_HOME_GITHUB_REPO"; diff --git a/src/core/agent-hosts/agent-hosts.test.ts b/src/core/agent-hosts/agent-hosts.test.ts index 0277ce7..d7b2555 100644 --- a/src/core/agent-hosts/agent-hosts.test.ts +++ b/src/core/agent-hosts/agent-hosts.test.ts @@ -1,6 +1,5 @@ import { describe, expect, test } from "bun:test"; import { - existsSync, lstatSync, mkdirSync, mkdtempSync, @@ -14,7 +13,6 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { getAllAgentHostsStatus, - getAllLinkableHostsStatus, getAntigravitySkillsStatus, getHostSkillsStatus, KNOWN_LINKABLE_HOSTS, diff --git a/src/core/auth/hose.test.ts b/src/core/auth/hose.test.ts index c9c7be3..330f2b8 100644 --- a/src/core/auth/hose.test.ts +++ b/src/core/auth/hose.test.ts @@ -8,7 +8,6 @@ import { assertHoseAssistTenantMatches, defaultSealUrl, exchangeHoseAssistLink, - fetchHoseOpenApiKeysFromLink, fetchHoseStaffDetails, getHoseEnterpriseUrl, getHoseProvisionalAuthLink, diff --git a/src/core/config/types.ts b/src/core/config/types.ts index 1fbd273..98fcfdb 100644 --- a/src/core/config/types.ts +++ b/src/core/config/types.ts @@ -79,6 +79,7 @@ export const SealHeaderMapSchema = z.record( export const SealCookieMapSchema = z.record( z.string().regex(HTTP_TOKEN_PATTERN, "Invalid cookie name"), + // oxlint-disable-next-line no-control-regex -- rejecting control chars IS the check. z.string().refine((value) => !/[\u0000-\u001f\u007f;]/.test(value), { message: "Cookie value cannot contain control characters or semicolons" }) diff --git a/src/core/http/request-headers.ts b/src/core/http/request-headers.ts index 1c6674e..d0c2471 100644 --- a/src/core/http/request-headers.ts +++ b/src/core/http/request-headers.ts @@ -13,7 +13,7 @@ export function formatCookieHeader(cookies: Record | undefined): // same-named entry, while Authorization is always left to the caller so the // session bearer token can never be silently replaced by config. export function resolveSealCustomHeaders(seal: SealCustomHeaderSource | undefined): Record { - const headers: Record = { ...(seal?.headers ?? {}) }; + const headers: Record = { ...seal?.headers }; const cookieHeader = formatCookieHeader(seal?.cookies); if (cookieHeader) headers.Cookie = cookieHeader; return headers; diff --git a/src/core/runtime.ts b/src/core/runtime.ts index d3824b7..ed52725 100644 --- a/src/core/runtime.ts +++ b/src/core/runtime.ts @@ -1,4 +1,4 @@ -import { existsSync, symlinkSync, rmSync } from "node:fs"; +import { existsSync, symlinkSync } from "node:fs"; import { homedir } from "node:os"; import { basename, dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; diff --git a/src/core/search/fuzzy.test.ts b/src/core/search/fuzzy.test.ts index 76f9d14..9e630c1 100644 --- a/src/core/search/fuzzy.test.ts +++ b/src/core/search/fuzzy.test.ts @@ -4,7 +4,6 @@ import { filterCorpsFuzzy, fuzzyMatchString, levenshteinDistance, - matchCorp, minSubstringLevenshtein, normalizeFuzzyPinyin } from "./fuzzy.js"; diff --git a/src/core/search/fuzzy.ts b/src/core/search/fuzzy.ts index c019223..e8d5528 100644 --- a/src/core/search/fuzzy.ts +++ b/src/core/search/fuzzy.ts @@ -46,7 +46,7 @@ export function levenshteinDistance(a: string, b: string): number { if (n === 0) return m; let prevRow = Array.from({ length: n + 1 }, (_, j) => j); - let currRow = new Array(n + 1).fill(0); + let currRow: number[] = Array.from({ length: n + 1 }, () => 0); for (let i = 1; i <= m; i += 1) { currRow[0] = i; diff --git a/src/core/stats/usage-tracker.test.ts b/src/core/stats/usage-tracker.test.ts index 1446fbd..10854a5 100644 --- a/src/core/stats/usage-tracker.test.ts +++ b/src/core/stats/usage-tracker.test.ts @@ -1,12 +1,11 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { mkdirSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; import { computeWindowCutoff, getRecentCorpUsageScores, loadUsageStats, - pruneExpiredStats, recordCorpUsage, resolveUsageFilePath, sortCorpsByUsageAndRecency, diff --git a/src/core/update-cache.test.ts b/src/core/update-cache.test.ts index 4cb9170..251edaf 100644 --- a/src/core/update-cache.test.ts +++ b/src/core/update-cache.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { diff --git a/src/core/update-cache.ts b/src/core/update-cache.ts index ec89ed7..1432619 100644 --- a/src/core/update-cache.ts +++ b/src/core/update-cache.ts @@ -1,4 +1,4 @@ -import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs"; +import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs"; import { homedir } from "node:os"; import { dirname, join } from "node:path"; import { spawn } from "node:child_process"; diff --git a/src/domains/hose/client.ts b/src/domains/hose/client.ts index c19718c..59cef51 100644 --- a/src/domains/hose/client.ts +++ b/src/domains/hose/client.ts @@ -1,12 +1,9 @@ import type { KyInstance } from "ky"; import type { CorpConfig } from "../../core/config/types.js"; import { - createHoseOpenClient, - createHoseOpenClientWithCredentials, - type HoseOpenClientCredentials + createHoseOpenClient } from "./open/client.js"; import { - createHoseCloseClient, createHoseCloseClientWithCredentials, getHoseCloseHeaders, type HoseCloseClientCredentials diff --git a/src/domains/hose/flow.test.ts b/src/domains/hose/flow.test.ts index 133fd91..b814157 100644 --- a/src/domains/hose/flow.test.ts +++ b/src/domains/hose/flow.test.ts @@ -7,45 +7,26 @@ import { extractFlowPerson, isEbotOperator, formatOperator, - parseHoseTimeline, - parseHosePending, parseHoseOpenPending, - calculateFlowMetrics, - extractStaffOpinions, - extractRejections, parseHoseFlow, parseHoseOpenComposite, - getHoseFlow, getHoseOpenFlow, getHoseCloseFlow, alignApprovalRunsWithHoseFlow, formatAiDecision, - formatHumanOpinionLines, formatNumberedHumanOpinions, formatRejectionComment } from "./flow.js"; import { searchCloseBacklogs, getCloseBacklogDetailById, - resolveCloseBacklogId, - fetchRawCloseHoseFlow, HOSE_CLOSE_LOOKUP_SELECT, HOSE_CLOSE_DETAIL_SELECT, HOSE_CLOSE_JOINS } from "./close/index.js"; import { - fetchHoseOpenFlowDetails, - fetchHoseOpenAllLogs, - fetchHoseOpenVersioned, - fetchHoseOpenCompositeFlow -} from "./open/index.js"; -import { - createHoseClientWithCredentials, createHoseClient, - createHoseOpenClient, - createHoseCloseClient, - getHoseHeaders, - getHoseCloseHeaders + getHoseHeaders } from "./client.js"; import type { CorpConfig } from "../../core/config/types.js"; diff --git a/src/domains/hose/flow.ts b/src/domains/hose/flow.ts index 6aaef8b..163c38b 100644 --- a/src/domains/hose/flow.ts +++ b/src/domains/hose/flow.ts @@ -4,7 +4,6 @@ import { fetchHoseOpenCompositeFlow, type HoseOpenAllLogsItem, type HoseOpenCompositeData, - type HoseOpenFlowLog, type HoseOpenStaffItem, type HoseOpenVersionedItem } from "./open/index.js"; diff --git a/src/domains/hose/onboarding.ts b/src/domains/hose/onboarding.ts index 310cb27..3310410 100644 --- a/src/domains/hose/onboarding.ts +++ b/src/domains/hose/onboarding.ts @@ -287,5 +287,5 @@ export async function onboardHoseWebSession(input: HoseWebSessionInput) { auth: { refreshTtl: 300 } }; const saved = input.persist === false ? undefined : saveCorpConfig(config, { overwrite: input.overwrite }); - return { config, ...(saved ?? {}), session, identity, staffId }; + return { config, ...saved, session, identity, staffId }; } diff --git a/src/domains/hose/open/api.ts b/src/domains/hose/open/api.ts index 70e30d5..29844c0 100644 --- a/src/domains/hose/open/api.ts +++ b/src/domains/hose/open/api.ts @@ -103,7 +103,7 @@ export async function fetchHoseOpenStaffs( .json(); const parsed = HoseOpenStaffResponseSchema.parse(response); return parsed.items; - } catch (error) { + } catch { if (options.conditionIds.length > 1) { const items: HoseOpenStaffItem[] = []; for (const id of options.conditionIds) { diff --git a/src/domains/seal/api.test.ts b/src/domains/seal/api.test.ts index a8fcc1d..35149c8 100644 --- a/src/domains/seal/api.test.ts +++ b/src/domains/seal/api.test.ts @@ -387,7 +387,7 @@ describe("Seal Webhook API", () => { maxFileSizeBytes: 2000, allowedExtensions: [".pdf", ".xlsx"] }); - expect((posted?.integrations as Array>)[1]).toMatchObject({ type: "hosecloud" }); + expect((posted!.integrations as Array>)[1]).toMatchObject({ type: "hosecloud" }); const found = findWebhookIntegration([updated], "Renamed webhook"); expect(found.id).toBe("integration-1"); diff --git a/src/domains/seal/api.ts b/src/domains/seal/api.ts index 47fc8e9..adc5474 100644 --- a/src/domains/seal/api.ts +++ b/src/domains/seal/api.ts @@ -1,5 +1,5 @@ import { randomBytes } from "node:crypto"; -import ky, { HTTPError, KyInstance } from "ky"; +import { HTTPError, KyInstance } from "ky"; import { z } from "zod"; import { mergeMaterialPackFilePolicy, @@ -90,11 +90,7 @@ import { MaterialPackage, MaterialPackageSchema, SimulationSpecification, - SimulationSpecificationSchema, - ThinkingPolicy, - ThinkingDepthPreference, - HosecloudConfigInput, - ApprovalRunsStats + SimulationSpecificationSchema } from "./types.js"; const SuccessResponseSchema = z.object({ success: z.boolean().optional() }).passthrough(); diff --git a/src/domains/seal/approval-runs-export.test.ts b/src/domains/seal/approval-runs-export.test.ts index 184589e..6ea9495 100644 --- a/src/domains/seal/approval-runs-export.test.ts +++ b/src/domains/seal/approval-runs-export.test.ts @@ -8,7 +8,6 @@ import { formatExportDateTag, formatExportMinuteTag, getBeijingDate, - getBeijingDateFrom, getRuleBriefTitle, normalizeManualApprovalStatus, normalizeTimestamp, @@ -212,7 +211,7 @@ describe("exportApprovalRunsToExcel integration", () => { test("generates valid formatted excel workbook", async () => { const mockClient = { - get: (url: string, opts?: any) => { + get: (url: string) => { if (url.includes("api/v1/rules")) { return { json: async () => ({ diff --git a/src/domains/seal/approval-runs-export.ts b/src/domains/seal/approval-runs-export.ts index fbc5380..f292572 100644 --- a/src/domains/seal/approval-runs-export.ts +++ b/src/domains/seal/approval-runs-export.ts @@ -826,7 +826,6 @@ export async function exportApprovalRunsToExcel( // 6. 人工审核状态与驳回原因 const mar = (record as any).manualApprovalRecord || {}; - const marSourceStatus = String(mar.status?.sourceStatus || ""); let manualStatus = "-"; if (mar.status?.label) { manualStatus = String(mar.status.label); diff --git a/src/domains/seal/insight-export.ts b/src/domains/seal/insight-export.ts index 09c887d..831c4da 100644 --- a/src/domains/seal/insight-export.ts +++ b/src/domains/seal/insight-export.ts @@ -6,7 +6,7 @@ import type { KyInstance } from "ky"; import { formatBeijingIso } from "../../core/config/timestamps.js"; import type { CorpConfig } from "../../core/config/types.js"; import * as api from "./api.js"; -import { formatExportDateTag, getBeijingDate, resolveExportDateRange } from "./approval-runs-export.js"; +import { getBeijingDate, resolveExportDateRange } from "./approval-runs-export.js"; import type { InsightPerformance } from "./types.js"; export interface InsightExportOptions { diff --git a/src/domains/seal/linter/linter.test.ts b/src/domains/seal/linter/linter.test.ts index 1b8c793..3ca9c15 100644 --- a/src/domains/seal/linter/linter.test.ts +++ b/src/domains/seal/linter/linter.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; import { builtinRuleLinter } from "./builtin.js"; import { loadRuleLinter } from "./loader.js"; -import { lintRuleBatch, lintSingleRule } from "./service.js"; +import { lintRuleBatch } from "./service.js"; import { writeFileSync, unlinkSync, mkdirSync, existsSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; diff --git a/src/domains/seal/linter/service.ts b/src/domains/seal/linter/service.ts index 3d41cb6..9cf6056 100644 --- a/src/domains/seal/linter/service.ts +++ b/src/domains/seal/linter/service.ts @@ -3,7 +3,6 @@ import type { RuleLintBatchResult, RuleLintContext, RuleLintItemResult, - RuleLintResult, RuleLintTarget } from "./types.js"; diff --git a/src/domains/seal/material-pack/material-pack.test.ts b/src/domains/seal/material-pack/material-pack.test.ts index fc8e014..4f6e82b 100644 --- a/src/domains/seal/material-pack/material-pack.test.ts +++ b/src/domains/seal/material-pack/material-pack.test.ts @@ -6,8 +6,7 @@ import { isAttachmentColumn, attachmentLabel, attachmentKey, - parsePaths, - collectRowAttachments, + parsePaths } from "./parse.js" import { buildAttachmentPlans } from "./attachments.js" import { MaterialPackValidationError } from "./types.js" diff --git a/src/domains/seal/material-pack/service.ts b/src/domains/seal/material-pack/service.ts index b30b267..d5f1a94 100644 --- a/src/domains/seal/material-pack/service.ts +++ b/src/domains/seal/material-pack/service.ts @@ -3,7 +3,7 @@ import { webhookHeaders } from "./signature.js" import { buildAttachmentPlans, injectAttachmentPlan } from "./attachments.js" import { parseMaterialWorkbook, type Parsed } from "./parse.js" import { extractZipEntry, readZipEntries, validatePackEntries, type ZipEntry } from "./validate.js" -import { MaterialPackValidationError, type MaterialPackPreview, type MaterialPackPushResult, type ResourcePackPreview, type ResourcePackPushResult } from "./types.js" +import { MaterialPackValidationError, type MaterialPackPreview, type MaterialPackPushResult } from "./types.js" import type { MaterialPackFilePolicyPatch } from "./policy.js" function webhookInfo(url: string): { baseUrl: string; webhookId: string } { @@ -137,7 +137,7 @@ export async function pushMaterialPack( { method: "POST", headers: { - ...(config.customHeaders ?? {}), + ...config.customHeaders, ...webhookHeaders({}, config.secret) }, body @@ -157,7 +157,7 @@ export async function pushMaterialPack( { method: "POST", headers: { - ...(config.customHeaders ?? {}), + ...config.customHeaders, "Content-Type": "application/json", ...webhookHeaders({ webhookId, ...document }, config.secret) }, @@ -172,7 +172,7 @@ export async function pushMaterialPack( } export function readMaterialPackFile(filePath: string): { fileBuffer: Buffer; fileName: string } { - return { fileBuffer: readFileSync(filePath), fileName: filePath.split(/[\\\/]/).pop() ?? "material-pack.zip" } + return { fileBuffer: readFileSync(filePath), fileName: filePath.split(/[\\/]/).pop() ?? "material-pack.zip" } } export const previewResourcePack = previewMaterialPack diff --git a/src/domains/seal/regression/service.test.ts b/src/domains/seal/regression/service.test.ts index 8ce13c9..df63ada 100644 --- a/src/domains/seal/regression/service.test.ts +++ b/src/domains/seal/regression/service.test.ts @@ -262,7 +262,7 @@ describe("regression service", () => { } } as any; - const mockFetch = async (url: string) => { + const mockFetch = async () => { return { ok: true, status: 200, diff --git a/src/domains/seal/test-sync.ts b/src/domains/seal/test-sync.ts index 95a8a09..f0edaf1 100644 --- a/src/domains/seal/test-sync.ts +++ b/src/domains/seal/test-sync.ts @@ -119,7 +119,7 @@ export async function syncTestEnterprise( }); const changedRules = allSyncItems .filter((item) => !item.unchanged) - .map(({ unchanged, ...rest }) => rest); + .map(({ unchanged: _unchanged, ...rest }) => rest); const unchangedCount = allSyncItems.length - changedRules.length; return { diff --git a/src/domains/seal/tools/approval-runs.ts b/src/domains/seal/tools/approval-runs.ts index 0d65352..3ff0b0b 100644 --- a/src/domains/seal/tools/approval-runs.ts +++ b/src/domains/seal/tools/approval-runs.ts @@ -1,33 +1,8 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; +import { ensureHoseCloseApiToken } from "../../../core/auth/hose.js"; import { formatBeijingIso } from "../../../core/config/timestamps.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; -import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; import { extractApprovalRunAttachments } from "../attachments.js"; import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; import { @@ -35,103 +10,37 @@ import { createHoseOpenClient, getHoseOpenFlow } from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput + type ApprovalRun } from "../types.js"; import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch + ToolContext } from "./helpers.js"; import * as helpers from "./helpers.js"; const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, summarizeApprovalRun, summarizeApprovalRuns, parseFieldPaths, pickRunFields, - approvalRunMetadata, summarizeApprovalRunDetail, summarizeApprovalRunResult, summarizeApprovalRunDocument, extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, pickApprovalRunCandidate, resolveApprovalRunForUrl, resolveSealBaseUrl, normalizeUrl, stringFromUnknown, pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, withApprovalRunFilters, resolveManualApprovalStatus, prepareApprovalRuns, approvalRunAliases, extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts + localDateKey } = helpers; export const approvalRunsTools = [ diff --git a/src/domains/seal/tools/billing.ts b/src/domains/seal/tools/billing.ts index bf0bcb7..c268c15 100644 --- a/src/domains/seal/tools/billing.ts +++ b/src/domains/seal/tools/billing.ts @@ -1,137 +1,6 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; -import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput -} from "../types.js"; -import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch -} from "./helpers.js"; -import * as helpers from "./helpers.js"; - -const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts -} = helpers; export const billingTools = [ { diff --git a/src/domains/seal/tools/contacts.ts b/src/domains/seal/tools/contacts.ts index 2c99230..8060583 100644 --- a/src/domains/seal/tools/contacts.ts +++ b/src/domains/seal/tools/contacts.ts @@ -1,137 +1,6 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; -import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput -} from "../types.js"; -import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch -} from "./helpers.js"; -import * as helpers from "./helpers.js"; - -const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts -} = helpers; export const contactsTools = [ { diff --git a/src/domains/seal/tools/deploy.ts b/src/domains/seal/tools/deploy.ts index 3aa2725..b6e19af 100644 --- a/src/domains/seal/tools/deploy.ts +++ b/src/domains/seal/tools/deploy.ts @@ -1,136 +1,19 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; +import { probeHoseDomain } from "../../../core/auth/hose.js"; import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, type HosecloudConfigInput } from "../types.js"; import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch + ToolContext } from "./helpers.js"; import * as helpers from "./helpers.js"; const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts + mutationPreview } = helpers; export const deployTools = [ diff --git a/src/domains/seal/tools/helpers.ts b/src/domains/seal/tools/helpers.ts index acb1530..ed5f434 100644 --- a/src/domains/seal/tools/helpers.ts +++ b/src/domains/seal/tools/helpers.ts @@ -11,7 +11,6 @@ import type { WebhookIntegration } from "../types.js"; import { extractApprovalRunAttachments } from "../attachments.js"; -import { normalizeTimestamp } from "../approval-runs-export.js"; import type { LocalRuleItem } from "../rules-local.js"; export type ToolContext = { @@ -1541,4 +1540,3 @@ export function localParts(date: Date, timezone: string): Record ); } - diff --git a/src/domains/seal/tools/identity.ts b/src/domains/seal/tools/identity.ts index cea4997..151fe76 100644 --- a/src/domains/seal/tools/identity.ts +++ b/src/domains/seal/tools/identity.ts @@ -1,137 +1,10 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; -import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput -} from "../types.js"; +import { createSealClientForToken } from "../../../core/http/factory.js"; import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch + ToolContext } from "./helpers.js"; -import * as helpers from "./helpers.js"; - -const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts -} = helpers; export const identityTools = [ { diff --git a/src/domains/seal/tools/insight.ts b/src/domains/seal/tools/insight.ts index 91f5b95..1fe58a2 100644 --- a/src/domains/seal/tools/insight.ts +++ b/src/domains/seal/tools/insight.ts @@ -1,137 +1,10 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; -import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput -} from "../types.js"; import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch + ToolContext } from "./helpers.js"; -import * as helpers from "./helpers.js"; - -const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts -} = helpers; export const insightTools = [ { diff --git a/src/domains/seal/tools/preference.ts b/src/domains/seal/tools/preference.ts index 0ce5d87..6b945c4 100644 --- a/src/domains/seal/tools/preference.ts +++ b/src/domains/seal/tools/preference.ts @@ -1,136 +1,18 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; -import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; import { ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput + type DecisionPreferences } from "../types.js"; import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch + ToolContext } from "./helpers.js"; import * as helpers from "./helpers.js"; const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts + mutationPreview } = helpers; export const preferenceTools = [ diff --git a/src/domains/seal/tools/rules.ts b/src/domains/seal/tools/rules.ts index 9d33434..4c29f92 100644 --- a/src/domains/seal/tools/rules.ts +++ b/src/domains/seal/tools/rules.ts @@ -1,20 +1,12 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; import { formatBeijingIso } from "../../../core/config/timestamps.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; +import { loadGlobalConfig } from "../../../core/config/loader.js"; import { redactSensitiveText } from "../../../core/redact.js"; import { searchApprovalContent } from "../search.js"; import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; import { loadLocalRulesFile, @@ -23,118 +15,29 @@ import { type LocalRuleItem } from "../rules-local.js"; import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput + type RuleSetVersion } from "../types.js"; import type { ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch + RuleField } from "./helpers.js"; import * as helpers from "./helpers.js"; const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, projectApprovalRules, - pickRuleFields, buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, normalizeRuleStrictness, - parseDurationMs, - redactIntegrationSecrets, mutationPreview, - redactPreviewValue, - buildSimulationBatchParams, - summarizeSimulationBatch, - summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, - firstPath, - countPathCandidates, - getPath, - setPath, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, - summarizeRunBridge, summarizeRuleVersion, resolveRuleVersionForLookup, findRuleInDraft, findRuleInVersion, parseRuleCodeNumber, normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts + resolveRuleVersionSelector } = helpers; export const rulesTools = [ @@ -305,7 +208,7 @@ export const rulesTools = [ resolvedRuleId = matched.id; } } - const { ruleId, ...rest } = params; + const { ruleId: _ruleId, ...rest } = params; const result = await api.updateApprovalRule(client, resolvedRuleId, rest); if (params.description) { diff --git a/src/domains/seal/tools/simulation.ts b/src/domains/seal/tools/simulation.ts index 94432c1..3bcc5b3 100644 --- a/src/domains/seal/tools/simulation.ts +++ b/src/domains/seal/tools/simulation.ts @@ -1,138 +1,21 @@ import { z } from "zod"; import type { KyInstance } from "ky"; import { readFileSync } from "node:fs"; -import { randomBytes } from "node:crypto"; import * as api from "../api.js"; -import { defaultSealUrl, ensureHoseCloseApiToken, getHoseProvisionalAuthLink, probeHoseDomain } from "../../../core/auth/hose.js"; -import type { CorpConfig } from "../../../core/config/types.js"; -import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js"; -import { resolveCorpConfig } from "../../../core/config/manager.js"; -import { createSealClient, createSealClientForToken } from "../../../core/http/factory.js"; -import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js"; -import { searchApprovalContent } from "../search.js"; -import { diffRuleVersions, normalizedRuleCode, truncateRuleDiff } from "../rule-diff.js"; -import { hydrateRuleVersionStableIds, savePublishedRuleVersionSnapshot } from "../rule-version-snapshot.js"; -import { executeApprovalRunsReplay, resolveReplayCorpPair } from "../webhook-replay.js"; -import { loadRuleLinter, lintRuleBatch, lintSingleRule, type RuleLintTarget } from "../linter/index.js"; import { - loadLocalRulesFile, - saveLocalRulesFile, - localRulesToLintTargets, - type LocalRuleItem -} from "../rules-local.js"; -import { - checkWebhookReadiness, - previewMaterialPack, - pushMaterialPack, - readMaterialPackFile -} from "../material-pack/index.js"; -import { MaterialPackFilePolicyPatchSchema, MaterialPackFilePolicySchema } from "../material-pack/policy.js"; -import { extractApprovalRunAttachments } from "../attachments.js"; -import { exportApprovalRunsToExcel, normalizeTimestamp } from "../approval-runs-export.js"; -import { - alignApprovalRunsWithHoseFlow, - createHoseOpenClient, - getHoseOpenFlow -} from "../../hose/index.js"; -import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js"; -import { - ThinkingPolicySchema, - type ApprovalRule, - type ApprovalRun, - type RuleSetVersion, - type SimulationBatch, - type WebhookIntegration, - type WebhookMode, - type ThinkingPolicy, - type DecisionPreferences, - type HosecloudConfigInput + type SimulationBatch } from "../types.js"; -import type { - ToolContext, - SealToolDefinition, - ApprovalRunSummary, - ApprovalRunsSummaryOptions, - RuleField, - RulePushPlan, - SimulationBatchCreateInput, - HumanResultMatch -} from "./helpers.js"; import * as helpers from "./helpers.js"; const { - presentWebhookIntegration, - getConfiguredSealBaseUrl, - projectApprovalRules, - pickRuleFields, - buildRulePushPlan, - rulesHaveSameContent, - ruleChangedFields, - normalizeRuleStrictness, parseDurationMs, - redactIntegrationSecrets, - mutationPreview, - redactPreviewValue, buildSimulationBatchParams, summarizeSimulationBatch, summarizeApprovalRun, - summarizeApprovalRuns, - parseFieldPaths, - pickRunFields, - approvalRunMetadata, - summarizeApprovalRunDetail, - summarizeApprovalRunResult, - summarizeApprovalRunDocument, - extractCitedRules, findReusableSimulationBatch, - firstPath, - countPathCandidates, - getPath, - setPath, simulationBatchCreatedAtMs, - compactObject, - asRecord, - numberFromUnknown, - flattenDocumentFields, - collectDocumentFields, - firstByLabel, - collectInvoiceSummary, - collectInvoiceObjects, - findKeywordLines, summarizeRunBridge, - summarizeRuleVersion, - resolveRuleVersionForLookup, - findRuleInVersion, - normalizeRuleCode, - runtimeRuleIndex, - runtimeRuleIdToCode, - formatRuleCode, - pickApprovalRunCandidate, - resolveApprovalRunForUrl, - resolveSealBaseUrl, - normalizeUrl, - stringFromUnknown, - pickApprovalRuns, - timestampOf, - resolveRuleVersion, - resolveRuleVersionSelector, - filterRuns, - scalarIncludes, - objectContainsScalar, - filterRunsByHumanResult, - withApprovalRunFilters, - resolveManualApprovalStatus, - prepareApprovalRuns, - approvalRunAliases, - extractHumanResult, - findHumanResultValue, - isHumanResultKey, - stringifyHumanResultValue, - matchesRunLookup, - countBy, - localDateKey, - formatLocalDateTime, - toDate, - localParts + filterRuns } = helpers; export const simulationTools = [ diff --git a/src/http/routes.ts b/src/http/routes.ts index 99d54cb..d060c36 100644 --- a/src/http/routes.ts +++ b/src/http/routes.ts @@ -8,7 +8,7 @@ import type { CorpConfig } from "../core/config/types.js"; import { getOpenApiSchema } from "../core/embedded-openapi.js"; import { loadCorpConfigs, loadGlobalConfig } from "../core/config/loader.js"; import { createSealClient } from "../core/http/factory.js"; -import { findSealTool, sealTools, type SealTool } from "../domains/seal/tools.js"; +import { findSealTool, type SealTool } from "../domains/seal/tools.js"; import { tokenizeCommand } from "../cli/tokenize.js"; import { redactSensitiveText } from "../core/redact.js"; import { VERSION } from "../version.js";