singularity-forge/tests/live/test-openai-roundtrip.ts
TÂCHES 6f410a0041 feat(ci): implement three-stage promotion pipeline (Dev → Test → Prod) (#1098)
* feat(ci): add version stamp script for dev publishes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add CLI smoke tests for pipeline test stage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add FixtureProvider for LLM conversation recording and replay

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add fixture test runner and sample recordings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add live test stubs and pipeline npm scripts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add three-stage promotion pipeline workflow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add weekly cleanup workflow for stale dev versions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(ci): add fixture recording helper stub

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 00:40:06 -06:00

32 lines
889 B
TypeScript

const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) {
console.log("SKIPPED: OPENAI_API_KEY not set");
process.exit(1);
}
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({
model: "gpt-4o-mini",
max_tokens: 32,
messages: [{ role: "user", content: "Reply with exactly: LIVE_TEST_OK" }],
}),
});
if (!response.ok) {
const body = await response.text();
console.error(`OpenAI API error ${response.status}: ${body}`);
process.exit(1);
}
const data = (await response.json()) as { choices: Array<{ message: { content: string } }> };
const text = data.choices?.[0]?.message?.content || "";
if (!text.includes("LIVE_TEST_OK")) {
console.error(`Unexpected response: "${text}"`);
process.exit(1);
}