This document defines the canonical extension-facing SDK contract implemented by @codex-manager/agent-runtime-sdk.
Primary question:
- What stable types and helper semantics do runtime and extension code share?
- package:
@codex-manager/agent-runtime-sdk - core API constant:
AGENT_RUNTIME_CORE_API_VERSION = 1
This SDK is provider-neutral. Provider-specific behavior is implemented by runtime profile adapters in API core.
AgentRuntimeProfileruntimeProfileIdruntimeProfileVersioncoreApiVersion
AgentRuntimeCompatibilitycoreApiVersionorcoreApiVersionRangeprofiles[](name,version,versionRange)
AgentRuntimeEventtype,payload, optionalemittedAt,correlationId
AgentRuntimeToolsenqueueJob(input)logger- optional
getSessionSettings(sessionId)for extension-side per-session settings lookup - optional
getSessionSetting(sessionId, key)for extension-side top-level key lookup
AgentEventRegistryon(eventType, handler, { priority, timeoutMs })
emit() output is normalized to AgentEventEmitResult[] with discriminants:
enqueue_resultaction_resulthandler_resulthandler_error
Represents queue enqueue outcomes:
status: enqueued | already_queued- includes normalized job identity and state
Represents state-changing action attempts:
actionType(for exampleapproval.decide,turn.steer.create,transcript.upsert,queue.enqueue)status: performed | already_resolved | not_eligible | conflict | forbidden | invalid | failed
Handlers do not execute actions directly. Handlers return kind: "action_request" and runtime executes intents through the internal API-core action executor.
Represents non-side-effect or diagnostic outputs.
Represents normalized execution failures (thrown handler errors and timeout errors).
SDK helper functions:
toAgentEventEmitResult(moduleName, eventType, raw)toAgentEventHandlerError(moduleName, eventType, error)
These ensure active runtime paths avoid unknown-shape scanning.
selectEnqueueWinner(results, strategy)selectFirstSuccessfulAction(results)classifyReconciledActionStatus(status)selectActionExecutionPlan(results)
Semantics:
- first successful state-changing action (
performed) is winner already_resolved,not_eligible,conflictclassify as reconciledfailed,forbidden, andinvalidclassify as failed
The runtime order key is:
priorityascending- module name ascending
- registration index ascending
Default priority is 100.
Current runtime-emitted event names:
file_change.approval_requestedturn.completedsuggest_request.requestedapp_server.<normalized_method>for app-server notificationsapp_server.request.<normalized_method>for app-server server-initiated requests
Normalization:
- split app-server method on
/ - camelCase/PascalCase segments convert to
snake_case - segments join with
.
Shared app-server signal payload envelope fields:
source: "app_server"signalType: "notification" | "request"eventTypemethodreceivedAtcontext.threadId/context.turnIdparamssession({ id, title, projectId } | null)requestId(request signals only)
- Dispatch and reconciliation semantics:
agent-dispatch-and-reconciliation.md - Extension packaging and compatibility fields:
agent-extension-packaging.md - Runtime event families and envelopes:
harness-runtime-events.md