Skip to content
Open
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
33 changes: 33 additions & 0 deletions sdk/typescript/scripts/fixtures/package-consumer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
CodexSecurity,
DiffTarget,
estimateScanCost,
type ScanCost,
type ScanOptions,
type ScanResult,
} from "@openai/codex-security";

const options: ScanOptions = {
target: DiffTarget.refs({ base: "HEAD~1" }),
onProgress(progress) {
const completed: number = progress.filesCompleted;
void completed;
},
};

export async function scan(repository: string): Promise<ScanResult> {
const client = new CodexSecurity();
try {
return await client.run(repository, options);
} finally {
await client.close();
}
}

export const cost: ScanCost | null = estimateScanCost("gpt-5.6-sol", {
input_tokens: 10,
output_tokens: 2,
});

// @ts-expect-error Dependency injection is internal, not a public constructor overload.
new CodexSecurity({}, undefined as never, { surface: "sdk" });
32 changes: 31 additions & 1 deletion sdk/typescript/scripts/smoke-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,36 @@ try {
{ cwd: consumer },
);

await cp(
join(packageRoot, "scripts", "fixtures", "package-consumer.ts"),
join(consumer, "consumer.ts"),
);
await writeFile(
join(consumer, "tsconfig.json"),
JSON.stringify({
files: ["consumer.ts"],
compilerOptions: {
target: "ES2022",
lib: ["ESNext"],
module: "NodeNext",
moduleResolution: "NodeNext",
strict: true,
noEmit: true,
types: ["node"],
typeRoots: [join(packageRoot, "node_modules", "@types")],
},
}),
);
run(
process.execPath,
[
join(packageRoot, "node_modules", "typescript", "bin", "tsc"),
"--project",
join(consumer, "tsconfig.json"),
],
{ cwd: consumer },
);

assert.equal(
typeof installedManifest.bin?.["codex-security"],
"string",
Expand Down Expand Up @@ -496,7 +526,7 @@ try {
await smokeNestedDeepScanWorker(installedRoot, consumer);

console.log(
`Validated installed ${packageManifest.name}@${packageManifest.version}: public import, CLI, ${expectedPluginFiles.length} bundled plugin files, bundled Codex version, and a nested worker without global codex.`,
`Validated installed ${packageManifest.name}@${packageManifest.version}: public import, NodeNext types, CLI, ${expectedPluginFiles.length} bundled plugin files, bundled Codex version, and a nested worker without global codex.`,
);
} finally {
await rm(consumer, {
Expand Down
Loading