mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
test: prune orphaned test-support fixtures and helpers (#23360)
Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com>
This commit is contained in:
1 parent
d5c22b8424
commit
9aaeae40bf
5 files changed
+2
-387
No files matched your search
@@ -1,8 +1,5 @@
|
||||
import { readFileSync, statSync } from "node:fs";
|
||||
|
||||
/** Private file contains only explicit disposable-resource allowlists and env
|
||||
* names. Credential values belong in the coordinator's child environment. */
|
||||
export const EXTERNAL_CONFIG_ENV = "PAPERCLIP_CHAT_CATALOG_EXTERNAL_CONFIG";
|
||||
export type ExternalProvider = "notion" | "slack" | "agentmail" | "vault" | "github";
|
||||
export interface ProviderBinding {
|
||||
disposable: true;
|
||||
@@ -50,14 +47,6 @@ export function validateExternalConfig(value: unknown): ExternalFixtureConfig {
|
||||
}
|
||||
return config;
|
||||
}
|
||||
export function readExternalConfig(env: NodeJS.ProcessEnv = process.env): ExternalFixtureConfig | undefined {
|
||||
const path = env[EXTERNAL_CONFIG_ENV]?.trim(); if (!path) return;
|
||||
try {
|
||||
const stat = statSync(path);
|
||||
if (!stat.isFile() || (stat.mode & 0o077) !== 0 || stat.size > 65_536) throw new Error("Not a private bounded file");
|
||||
return validateExternalConfig(JSON.parse(readFileSync(path, "utf8")));
|
||||
} catch { throw new Error("External fixture config is unavailable, invalid or not private (0600); contents withheld"); }
|
||||
}
|
||||
export function externalPrerequisiteReceipt(scenarioId: string, config: ExternalFixtureConfig | undefined, env: NodeJS.ProcessEnv = process.env): PrerequisiteReceipt {
|
||||
const requirement = externalRequirements[scenarioId]; if (!requirement) return { scenarioId, configured: true, missing: [] };
|
||||
const binding = config?.providers[requirement.provider];
|
||||
@@ -68,13 +57,6 @@ export function externalPrerequisiteReceipt(scenarioId: string, config: External
|
||||
];
|
||||
return { scenarioId, provider: requirement.provider, configured: missing.length === 0, missing };
|
||||
}
|
||||
export function requireExternalPrerequisites(scenarioId: string, config = readExternalConfig()): ProviderBinding {
|
||||
const receipt = externalPrerequisiteReceipt(scenarioId, config);
|
||||
if (!receipt.configured) throw new Error(`Setup blocker ${scenarioId}: ${receipt.provider} requires ${receipt.missing.join(", ")}; provide private ${EXTERNAL_CONFIG_ENV} reference`);
|
||||
const provider = externalRequirements[scenarioId]?.provider;
|
||||
if (!provider) throw new Error("This scenario has no external-account prerequisite");
|
||||
return config!.providers[provider]!;
|
||||
}
|
||||
|
||||
/** Runtime case consumers receive only the selected declaration's configuration
|
||||
* and references. Never fall back to ambient host/model/provider environment. */
|
||||
|
||||
Reference in new issue
Block a user