Add native OpenAI adapter boundary
This commit is contained in:
parent
76f284f88e
commit
743f8bcc6c
7 changed files with 154 additions and 12 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,6 +2,8 @@ __pycache__/
|
|||
*.pyc
|
||||
epiphany-core/target/
|
||||
epiphany-core/Cargo.lock
|
||||
epiphany-openai-adapter/target/
|
||||
epiphany-openai-adapter/Cargo.lock
|
||||
apps/epiphany-gui/node_modules/
|
||||
apps/epiphany-gui/dist/
|
||||
apps/epiphany-gui/src-tauri/gen/
|
||||
|
|
|
|||
13
epiphany-openai-adapter/Cargo.toml
Normal file
13
epiphany-openai-adapter/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "epiphany-openai-adapter"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
license-file = "../LICENSE"
|
||||
|
||||
[lib]
|
||||
name = "epiphany_openai_adapter"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
112
epiphany-openai-adapter/src/lib.rs
Normal file
112
epiphany-openai-adapter/src/lib.rs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
pub const OPENAI_ADAPTER_REQUEST_SCHEMA_ID: &str = "epiphany.openai_model_request.v0";
|
||||
pub const OPENAI_ADAPTER_EVENT_SCHEMA_ID: &str = "epiphany.openai_model_stream_event.v0";
|
||||
pub const OPENAI_ADAPTER_RECEIPT_SCHEMA_ID: &str = "epiphany.openai_model_receipt.v0";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum EpiphanyOpenAiAuthMode {
|
||||
ChatGptSubscription,
|
||||
ApiKey,
|
||||
ExternalBearer,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct EpiphanyOpenAiAdapterStatus {
|
||||
pub adapter_id: String,
|
||||
pub auth_mode: EpiphanyOpenAiAuthMode,
|
||||
pub account_id: Option<String>,
|
||||
pub plan_type: Option<String>,
|
||||
pub default_model: Option<String>,
|
||||
pub supports_websockets: bool,
|
||||
pub codex_transport_attached: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EpiphanyOpenAiModelRequest {
|
||||
pub schema_id: String,
|
||||
pub request_id: String,
|
||||
pub conversation_id: String,
|
||||
pub model: String,
|
||||
pub instructions: String,
|
||||
pub input: Vec<EpiphanyOpenAiInputItem>,
|
||||
pub reasoning_effort: Option<String>,
|
||||
pub reasoning_summary: Option<String>,
|
||||
pub service_tier: Option<String>,
|
||||
pub output_contract_id: Option<String>,
|
||||
}
|
||||
|
||||
impl EpiphanyOpenAiModelRequest {
|
||||
pub fn new(
|
||||
request_id: impl Into<String>,
|
||||
conversation_id: impl Into<String>,
|
||||
model: impl Into<String>,
|
||||
instructions: impl Into<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
schema_id: OPENAI_ADAPTER_REQUEST_SCHEMA_ID.to_string(),
|
||||
request_id: request_id.into(),
|
||||
conversation_id: conversation_id.into(),
|
||||
model: model.into(),
|
||||
instructions: instructions.into(),
|
||||
input: Vec::new(),
|
||||
reasoning_effort: None,
|
||||
reasoning_summary: None,
|
||||
service_tier: None,
|
||||
output_contract_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum EpiphanyOpenAiInputItem {
|
||||
UserText { text: String },
|
||||
AssistantText { text: String },
|
||||
ToolResult { call_id: String, output: String },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EpiphanyOpenAiStreamEvent {
|
||||
pub schema_id: String,
|
||||
pub request_id: String,
|
||||
pub sequence: u64,
|
||||
pub payload: EpiphanyOpenAiStreamPayload,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum EpiphanyOpenAiStreamPayload {
|
||||
TextDelta { text: String },
|
||||
ReasoningDelta { text: String },
|
||||
ToolCall { call_id: String, name: String, arguments: String },
|
||||
Completed { receipt: EpiphanyOpenAiModelReceipt },
|
||||
Failed { message: String },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct EpiphanyOpenAiModelReceipt {
|
||||
pub schema_id: String,
|
||||
pub request_id: String,
|
||||
pub model: String,
|
||||
pub response_id: Option<String>,
|
||||
pub input_tokens: Option<u64>,
|
||||
pub output_tokens: Option<u64>,
|
||||
pub reasoning_output_tokens: Option<u64>,
|
||||
pub transport: Option<String>,
|
||||
}
|
||||
|
||||
impl EpiphanyOpenAiModelReceipt {
|
||||
pub fn new(request_id: impl Into<String>, model: impl Into<String>) -> Self {
|
||||
Self {
|
||||
schema_id: OPENAI_ADAPTER_RECEIPT_SCHEMA_ID.to_string(),
|
||||
request_id: request_id.into(),
|
||||
model: model.into(),
|
||||
response_id: None,
|
||||
input_tokens: None,
|
||||
output_tokens: None,
|
||||
reasoning_output_tokens: None,
|
||||
transport: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -104,14 +104,21 @@ state ownership.
|
|||
|
||||
## Next Cut
|
||||
|
||||
Define the first `epiphany-openai-adapter` crate boundary as a wrapper, not a
|
||||
rewrite:
|
||||
The first `epiphany-openai-adapter` crate boundary now exists as a native typed
|
||||
surface:
|
||||
|
||||
- input: typed model-turn request plus adapter config
|
||||
- output: typed stream events and terminal usage/error receipt
|
||||
- internal dependency: Codex auth/model transport only
|
||||
- current dependency: no Codex app-server and no Codex transport yet
|
||||
- planned internal dependency: Codex auth/model transport only
|
||||
- forbidden dependency: Codex app-server or Epiphany JSON-RPC routes
|
||||
|
||||
The first implementation can be a thin wrapper around existing Codex transport.
|
||||
The first attempt to wire `codex-core` directly as a standalone path dependency
|
||||
escaped the vendored workspace lock and hit transitive ICU/temporal dependency
|
||||
skew. Do not paper over that with random version pins. The next implementation
|
||||
slice should add a Codex-transport feature or workspace-verified wrapper that
|
||||
builds under the same dependency regime as vendored Codex, while preserving the
|
||||
typed request/event/receipt surface as the Epiphany-owned contract.
|
||||
|
||||
The point is ownership: Epiphany calls a model adapter; it does not live inside
|
||||
the Codex host brain.
|
||||
|
|
|
|||
|
|
@ -545,18 +545,26 @@ The auth-spine inventory now exists at
|
|||
the next real extraction target: create an outside-vendor
|
||||
`epiphany-openai-adapter` wrapper around auth/model transport with no
|
||||
dependency on Codex app-server or Epiphany JSON-RPC routes.
|
||||
The first `epiphany-openai-adapter` crate now exists outside `vendor/codex` and
|
||||
compiles as a native typed boundary: auth status, model request, stream event,
|
||||
and terminal receipt documents. It intentionally has no Codex app-server
|
||||
dependency and no generic JSON payload. A direct standalone `codex-core` path
|
||||
dependency attempt hit transitive dependency skew outside the vendored Codex
|
||||
workspace lock; do not "fix" that with random version pins. The next slice is a
|
||||
workspace-verified Codex transport feature/wrapper behind the typed adapter
|
||||
surface.
|
||||
|
||||
Also: MCP itself is allowed to be JSON. The target is not "replace MCP JSON";
|
||||
the target is an Epiphany-owned boundary that speaks typed Epiphany
|
||||
intent/result/receipt documents internally and normal MCP JSON-RPC externally.
|
||||
|
||||
Continue with the actual whale-carcass cut: create the first
|
||||
`epiphany-openai-adapter` boundary outside `vendor/codex`, wrapping only the
|
||||
keeper auth/model transport spine identified in
|
||||
`notes/codex-auth-spine-inventory.md`. Success is Epiphany calling a model
|
||||
adapter rather than living inside the Codex host brain. Do not resume Rider,
|
||||
Unity, Aquarium, Face, dogfood, planning, app, skill, marketplace, or bridge
|
||||
expansion until this organ is being cut cleanly.
|
||||
`epiphany-openai-adapter` Codex transport integration behind the native typed
|
||||
request/event/receipt surface, using the keeper auth/model transport spine
|
||||
identified in `notes/codex-auth-spine-inventory.md`. Success is Epiphany
|
||||
calling a model adapter rather than living inside the Codex host brain. Do not
|
||||
resume Rider, Unity, Aquarium, Face, dogfood, planning, app, skill,
|
||||
marketplace, or bridge expansion until this organ is being cut cleanly.
|
||||
|
||||
The Phase 6 freshness slice is landed. It exposes read-only
|
||||
`thread/epiphany/freshness` from live retrieval summaries plus graph
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -279,5 +279,5 @@ rejected_paths:
|
|||
reason: making Epiphany cleaner inside Codex still preserves the wrong organ; Codex must be starved down to OpenAI subscription auth/model transport, while Epiphany data and subsystem communication move to typed CultCache/CultNet.
|
||||
|
||||
current_status:
|
||||
summary: The Codex starvation pass has five typing receipts, seventeen processor cuts, and now a real physical extraction: `epiphany-codex-bridge` lives outside `vendor/codex` and owns the Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, and acceptance/evidence signal helpers. Vendored app-server now retains only `epiphany_invalidation.rs` as a root Epiphany module because watcher lifecycle is still app-server machinery; `codex_message_processor.rs` still contains route dispatch and mutation orchestration. The processor is about 10,339 lines, `epiphany_mutation_routes.rs` is about 1,071 lines, and `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader after moving typed mutation helpers, reviewability checks, completed runtime-result acceptance loading, live-state projection, launched/interrupted job fallback projection, role/reorient acceptance update bundle construction including its core state update, protocol patch-to-core state-update projection, and state-updated notification shaping out to the bridge. This is progress, not absolution: the bridge is still Codex-facing compatibility, not the final CultNet runtime, and route-level launch/update/promote/interrupt orchestration still lives inside the Codex processor. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON.
|
||||
next_action: Continue Codex starvation by creating the first outside-vendor `epiphany-openai-adapter` boundary as a wrapper around the keeper auth/model transport spine, with no dependency on Codex app-server or Epiphany JSON-RPC routes. Do not resume app/skill/marketplace expansion.
|
||||
summary: The Codex starvation pass has five typing receipts, seventeen processor cuts, a real physical extraction in `epiphany-codex-bridge`, a source-grounded Codex auth spine inventory, and now the first native `epiphany-openai-adapter` crate boundary. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, and acceptance/evidence signal helpers. Vendored app-server now retains only `epiphany_invalidation.rs` as a root Epiphany module because watcher lifecycle is still app-server machinery; `codex_message_processor.rs` still contains route dispatch and mutation orchestration. The processor is about 10,339 lines, `epiphany_mutation_routes.rs` is about 1,071 lines, and `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader. `epiphany-openai-adapter` currently defines typed request/event/receipt/auth-status documents with no Codex app-server or generic JSON dependency; a direct standalone `codex-core` wrapper attempt hit dependency skew outside the vendored workspace lock and is recorded as a constraint, not papered over. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON.
|
||||
next_action: Continue Codex starvation by wiring `epiphany-openai-adapter` to the keeper Codex auth/model transport under a workspace-verified dependency regime, without adding Codex app-server, apps, skills, marketplace, or Epiphany JSON-RPC dependencies. Do not resume app/skill/marketplace expansion.
|
||||
|
|
|
|||
Reference in a new issue