@kody/codex
Create and manage OpenAI Agents API (Codex harness) cloud agent sessions.
README.md
87 lines · 3.2 KB · Markdown@kody/codex
Thin, isolate-safe helpers for OpenAI's Agents API (managed Codex harness): create durable cloud agent sessions, continue turns, list items, and clean up.
Intent
Give agents and humans a pit-of-success way to create and manage Agents API
sessions (POST https://api.openai.com/v1/agents/sessions with
OpenAI-Beta: agents=v1) — Cursor/Devin-shaped cloud agents you create via
API — without pretending to remote existing chatgpt.com/codex web threads or
codex cloud CLI chats. Success means a working session create/list/get/input
path with secret-backed auth and clear docs.
What this is / is not
| This package | Not this package |
|---|---|
Official Agents API REST (/v1/agents/sessions) | Control of existing ChatGPT UI / Codex web conversations |
openai_hosted / self_hosted / none environments | Unofficial ChatGPT task scraping |
Fetch + {{secret:openaiApiKey}} | Heavy OpenAI Node SDK or native deps |
Prerequisites
- An OpenAI Platform API key with:
api.agents.readapi.agents.writeapi.responses.write
- Kody user secret
openaiApiKeyallowed for hostapi.openai.com: Create secret (prefilled)
Quick start
import openaiHosted from 'kody:@kody/codex/environments/openai-hosted'
const result = await openaiHosted({
input:
'Create tree.py, a Python script that prints a readable tree of the files in the current directory. Run it and show me the output.',
})
// result.sessionId — store with your conversation stateOr the generic create path:
import createSession from 'kody:@kody/codex/sessions/create'
const result = await createSession({
agent: {
model: 'gpt-6-astra', // docs placeholder — use a model your project allows
instructions: 'Write clean code, run it, and report the actual output.',
},
environment: { type: 'openai_hosted' },
input: 'Create tree.py, run it, and show the output.',
})Core exports
| Export | Use when |
|---|---|
. / ./overview | Discovery |
./sessions/create | Main create path |
./environments/openai-hosted | Quickstart sandbox wrapper |
./environments/self-hosted | Recipe metadata for self-hosted envs |
./sessions/get / list / delete | Inspect, browse, clean up |
./sessions/input | Follow-up or cancel |
./sessions/items | Saved work after disconnect |
./events/stream | Stream URL guidance (+ optional bounded collect) |
./smoke-test | Verify secret wiring without creating agents |
Docs
Visibility
Published private by default. Flip public via package visibility when you
want it on /community (same pattern as @kody/browser-run after review).
License
MIT