From a881a98db5cfacf088dc1b0519eba7d9ec3a6328 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Sat, 23 May 2026 18:05:09 -0300 Subject: [PATCH] feat(review-story): add reusable review story api --- CONTEXT.md | 109 + .../schema/json/ClientRequest.json | 127 ++ .../schema/json/ServerNotification.json | 308 +++ .../codex_app_server_protocol.schemas.json | 465 ++++ .../codex_app_server_protocol.v2.schemas.json | 465 ++++ .../schema/json/v2/ReviewStoryListParams.json | 27 + .../json/v2/ReviewStoryListResponse.json | 177 ++ .../schema/json/v2/ReviewStoryReadParams.json | 17 + .../json/v2/ReviewStoryReadResponse.json | 292 +++ ...eviewStorySnapshotUpdatedNotification.json | 292 +++ .../json/v2/ReviewStoryStartParams.json | 110 + .../json/v2/ReviewStoryStartResponse.json | 1971 +++++++++++++++++ .../schema/typescript/ClientRequest.ts | 5 +- .../schema/typescript/ServerNotification.ts | 3 +- .../schema/typescript/v2/ReviewStoryAnchor.ts | 6 + .../typescript/v2/ReviewStoryAnchorKind.ts | 5 + .../typescript/v2/ReviewStoryListParams.ts | 5 + .../typescript/v2/ReviewStoryListResponse.ts | 6 + .../typescript/v2/ReviewStoryReadParams.ts | 5 + .../typescript/v2/ReviewStoryReadResponse.ts | 6 + .../typescript/v2/ReviewStorySnapshot.ts | 9 + .../v2/ReviewStorySnapshotStatus.ts | 5 + .../v2/ReviewStorySnapshotSummary.ts | 7 + .../ReviewStorySnapshotUpdatedNotification.ts | 6 + .../typescript/v2/ReviewStoryStartParams.ts | 6 + .../typescript/v2/ReviewStoryStartResponse.ts | 7 + .../schema/typescript/v2/ReviewStoryStep.ts | 6 + .../typescript/v2/ReviewStoryStepReadiness.ts | 5 + .../schema/typescript/v2/index.ts | 14 + .../src/protocol/common.rs | 16 + .../src/protocol/v2/mod.rs | 2 + .../src/protocol/v2/review_story.rs | 161 ++ codex-rs/app-server/Cargo.toml | 1 + codex-rs/app-server/README.md | 1 + codex-rs/app-server/src/message_processor.rs | 17 + codex-rs/app-server/src/request_processors.rs | 2 + .../review_story_processor.rs | 1023 +++++++++ codex-rs/core/src/codex_thread.rs | 69 + codex-rs/state/BUILD.bazel | 2 +- .../0001_review_stories.sql | 19 + codex-rs/state/src/lib.rs | 6 + codex-rs/state/src/migrations.rs | 5 + codex-rs/state/src/runtime.rs | 58 +- codex-rs/state/src/runtime/review_stories.rs | 220 ++ codex-rs/state/src/telemetry.rs | 2 + .../tui/src/app/app_server_event_targets.rs | 3 + codex-rs/tui/src/chatwidget/protocol.rs | 1 + docs/adr/0001-review-story-v1.md | 33 + 48 files changed, 6103 insertions(+), 4 deletions(-) create mode 100644 CONTEXT.md create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListParams.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListResponse.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadParams.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadResponse.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStorySnapshotUpdatedNotification.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartParams.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartResponse.json create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchor.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchorKind.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListParams.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListResponse.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadParams.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadResponse.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshot.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotStatus.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotSummary.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotUpdatedNotification.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartParams.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartResponse.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStep.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStepReadiness.ts create mode 100644 codex-rs/app-server-protocol/src/protocol/v2/review_story.rs create mode 100644 codex-rs/app-server/src/request_processors/review_story_processor.rs create mode 100644 codex-rs/state/review_story_migrations/0001_review_stories.sql create mode 100644 codex-rs/state/src/runtime/review_stories.rs create mode 100644 docs/adr/0001-review-story-v1.md diff --git a/CONTEXT.md b/CONTEXT.md new file mode 100644 index 0000000000..458cbf5224 --- /dev/null +++ b/CONTEXT.md @@ -0,0 +1,109 @@ +# Codex Review Experience + +Language for features that help people understand and navigate code changes in Codex. + +## Implemented Language + +**Review Story**: +A structured explanation of a change that organizes the diff into a small number of ordered, cohesive steps for reviewer understanding. A **Review Story** is a navigation and explanation artifact, not a finding engine or correctness verdict. +_Avoid_: Review module, PR story, change story + +**Story Source**: +The change set that a **Review Story** explains. A **Story Source** may be a branch comparison, uncommitted changes, or a single commit; it is not limited to a hosted pull request. +_Avoid_: Pull request, GitHub PR + +**Concrete Story Source**: +A **Story Source** that resolves to a deterministic diff and **Source Fingerprint**, such as a branch comparison, uncommitted changes, or a single commit. Review Story creation requires a **Concrete Story Source**. +_Avoid_: Custom instructions + +**Source Fingerprint**: +A deterministic hash of the selected source and its collected diff. It is stored with the snapshot so future refresh or staleness behavior can compare source identity without depending on model output. +_Avoid_: Model context hash + +**Story Step**: +One ordered unit inside a **Review Story**. A **Story Step** has a title, goal, summary, dependency rationale, review focus, and references to the changed evidence that supports it. +_Avoid_: Cohort, layer, phase + +**Step Goal**: +The reason a **Story Step** belongs in the story. A goal explains the role of that step; its summary explains what changed. + +**Review Focus**: +Non-verdict guidance on what a reviewer should pay attention to while reading a **Story Step**. It may highlight assumptions or dependencies, but it is not a finding. +_Avoid_: Finding, issue, warning + +**Change Anchor**: +A system-created piece of changed evidence referenced by a **Story Step**. The current implementation creates one anchor for each file diff and stores its raw patch, path, and detected change kind. +_Avoid_: Model-invented location + +**Anchor Id**: +A stable identifier assigned by Codex to a **Change Anchor** before model story generation begins. The model may group only provided anchor ids; unknown references are discarded and missing anchors are appended for complete coverage. + +**Story Snapshot**: +A persisted version of a **Review Story** associated with one thread and source fingerprint. The current generator writes a completed snapshot after model grouping and validation or fallback construction. +_Avoid_: Transcript output + +**Snapshot Status**: +The stored lifecycle result of a snapshot. Current creation produces `ready` for fully validated output or an empty diff, and `partial` when generation falls back or the model omits or invents anchors. `building` and `failed` remain protocol values reserved for future asynchronous generation. + +**Step Readiness**: +The per-step readiness value included in the shared API shape. Current story creation emits `ready` steps; `outline`, `enriching`, and `failed` are reserved for future progressive work. + +**Snapshot Update**: +A full snapshot notification emitted when the app-server writes a story snapshot. Current generation emits one update for the completed snapshot; a future progressive workflow may emit additional replacements. +_Avoid_: Delta event + +**Story Store**: +The structured persistence location for **Story Snapshots**, keyed for lookup by thread and snapshot id and listable by thread. It stores canonical snapshot JSON plus indexed summary columns. + +**Story Database**: +The SQLite database managed by the shared state layer that backs the **Story Store**. It is separate from thread metadata storage so story-specific persistence can evolve independently. + +**Story Schema**: +The strict structured-output contract used by the model call that creates a **Review Story**. It ensures the server can validate step fields and anchor assignments before persisting a snapshot. + +**Partial Story**: +A complete stored snapshot that remains usable but required fallback or coverage correction. In the current implementation, a **Partial Story** is not a streaming or unfinished state. + +**Story Surface**: +A product surface that presents a **Story Snapshot** to a reviewer. The reusable app-server API exists so TUI and App UI surfaces can share the same artifact without generating their own story shape. + +**Story API**: +The app-server v2 contract used to create and retrieve **Story Snapshots**. It exposes `reviewStory/start`, `reviewStory/read`, `reviewStory/list`, and `reviewStory/snapshot/updated`. +_Avoid_: TUI API, local story service + +**reviewStory**: +The app-server v2 API namespace for **Story API** methods. It is separate from the findings-oriented `review` namespace because its artifact explains rather than judges a change. + +## Deferred Concepts + +These terms describe intended follow-up work, not behavior delivered by the current API/backend implementation. + +**Stale Story** and **Snapshot Lineage**: +Future refresh behavior may compare stored source fingerprints and link newly generated snapshots to earlier versions. Current snapshots set `stale` to false and do not link a previous snapshot. + +**Evidence Graph**: +A possible future evidence model that adds hunk anchors, commit relationships, or dependency signals. Current evidence is the set of deterministic file-level anchors from a git diff. + +**Progressive Story Snapshot** and **Step Enrichment**: +A future asynchronous generation workflow in which an ordered outline is usable before every step has complete explanatory prose. Current generation uses one blocking model grouping call and stores one completed snapshot. + +**Story Overlay** and **/story**: +A future TUI surface and entry point over the shared API. They are intentionally implemented in a stacked UI change rather than in the reusable backend base layer. + +## Example Dialogue + +Dev: "Does Review Story find bugs?" + +Domain expert: "No. It explains and orders changed evidence for reviewer understanding; findings remain part of the review workflow." + +Dev: "Can a model invent file locations for a story step?" + +Domain expert: "No. Codex creates file-diff anchors first, and the model may only group those anchor ids." + +Dev: "Does story generation stream step updates today?" + +Domain expert: "No. It persists a completed ready or partial snapshot. The notification and readiness fields leave room for future progressive generation." + +Dev: "Can the TUI and App UI render different story models?" + +Domain expert: "No. Both surfaces should consume the shared `reviewStory` snapshot contract." diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json index 7595527c21..ab9f624d57 100644 --- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json +++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json @@ -2671,6 +2671,61 @@ ], "type": "object" }, + "ReviewStoryListParams": { + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "threadId" + ], + "type": "object" + }, + "ReviewStoryReadParams": { + "properties": { + "storySnapshotId": { + "type": "string" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "storySnapshotId", + "threadId" + ], + "type": "object" + }, + "ReviewStoryStartParams": { + "properties": { + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "target", + "threadId" + ], + "type": "object" + }, "ReviewTarget": { "oneOf": [ { @@ -5425,6 +5480,78 @@ "title": "Review/startRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "reviewStory/start" + ], + "title": "ReviewStory/startRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStoryStartParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/startRequest", + "type": "object" + }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "reviewStory/read" + ], + "title": "ReviewStory/readRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStoryReadParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/readRequest", + "type": "object" + }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "reviewStory/list" + ], + "title": "ReviewStory/listRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStoryListParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/listRequest", + "type": "object" + }, { "properties": { "id": { diff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.json index 90899cb152..4a57728dcd 100644 --- a/codex-rs/app-server-protocol/schema/json/ServerNotification.json +++ b/codex-rs/app-server-protocol/schema/json/ServerNotification.json @@ -2946,6 +2946,294 @@ }, "type": "object" }, + "ReviewStoryAnchor": { + "properties": { + "anchorId": { + "type": "string" + }, + "changeKind": { + "$ref": "#/definitions/ReviewStoryAnchorKind" + }, + "diff": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "summary": { + "type": "string" + } + }, + "required": [ + "anchorId", + "changeKind", + "diff", + "filePath", + "summary" + ], + "type": "object" + }, + "ReviewStoryAnchorKind": { + "enum": [ + "added", + "modified", + "deleted", + "renamed", + "copied", + "unknown" + ], + "type": "string" + }, + "ReviewStorySnapshot": { + "properties": { + "anchors": { + "items": { + "$ref": "#/definitions/ReviewStoryAnchor" + }, + "type": "array" + }, + "createdAt": { + "format": "int64", + "type": "integer" + }, + "overview": { + "type": "string" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "stale": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "steps": { + "items": { + "$ref": "#/definitions/ReviewStoryStep" + }, + "type": "array" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "anchors", + "createdAt", + "overview", + "sourceFingerprint", + "stale", + "status", + "steps", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStorySnapshotUpdatedNotification": { + "properties": { + "snapshot": { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "snapshot", + "threadId" + ], + "type": "object" + }, + "ReviewStoryStep": { + "properties": { + "anchorIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "dependencyRationale": { + "type": "string" + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "goal": { + "type": "string" + }, + "index": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "readiness": { + "$ref": "#/definitions/ReviewStoryStepReadiness" + }, + "reviewFocus": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stepId": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "anchorIds", + "dependencyRationale", + "goal", + "index", + "readiness", + "reviewFocus", + "stepId", + "summary", + "title" + ], + "type": "object" + }, + "ReviewStoryStepReadiness": { + "enum": [ + "outline", + "enriching", + "ready", + "failed" + ], + "type": "string" + }, + "ReviewTarget": { + "oneOf": [ + { + "description": "Review the working tree: staged, unstaged, and untracked files.", + "properties": { + "type": { + "enum": [ + "uncommittedChanges" + ], + "title": "UncommittedChangesReviewTargetType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UncommittedChangesReviewTarget", + "type": "object" + }, + { + "description": "Review changes between the current branch and the given base branch.", + "properties": { + "branch": { + "type": "string" + }, + "type": { + "enum": [ + "baseBranch" + ], + "title": "BaseBranchReviewTargetType", + "type": "string" + } + }, + "required": [ + "branch", + "type" + ], + "title": "BaseBranchReviewTarget", + "type": "object" + }, + { + "description": "Review the changes introduced by a specific commit.", + "properties": { + "sha": { + "type": "string" + }, + "title": { + "description": "Optional human-readable label (e.g., commit subject) for UIs.", + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "commit" + ], + "title": "CommitReviewTargetType", + "type": "string" + } + }, + "required": [ + "sha", + "type" + ], + "title": "CommitReviewTarget", + "type": "object" + }, + { + "description": "Arbitrary instructions, equivalent to the old free-form prompt.", + "properties": { + "instructions": { + "type": "string" + }, + "type": { + "enum": [ + "custom" + ], + "title": "CustomReviewTargetType", + "type": "string" + } + }, + "required": [ + "instructions", + "type" + ], + "title": "CustomReviewTarget", + "type": "object" + } + ] + }, "SandboxPolicy": { "oneOf": [ { @@ -5557,6 +5845,26 @@ "title": "Turn/completedNotification", "type": "object" }, + { + "properties": { + "method": { + "enum": [ + "reviewStory/snapshot/updated" + ], + "title": "ReviewStory/snapshot/updatedNotificationMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStorySnapshotUpdatedNotification" + } + }, + "required": [ + "method", + "params" + ], + "title": "ReviewStory/snapshot/updatedNotification", + "type": "object" + }, { "properties": { "method": { diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json index a738405036..66bc64f10f 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json @@ -1429,6 +1429,78 @@ "title": "Review/startRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/v2/RequestId" + }, + "method": { + "enum": [ + "reviewStory/start" + ], + "title": "ReviewStory/startRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/v2/ReviewStoryStartParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/startRequest", + "type": "object" + }, + { + "properties": { + "id": { + "$ref": "#/definitions/v2/RequestId" + }, + "method": { + "enum": [ + "reviewStory/read" + ], + "title": "ReviewStory/readRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/v2/ReviewStoryReadParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/readRequest", + "type": "object" + }, + { + "properties": { + "id": { + "$ref": "#/definitions/v2/RequestId" + }, + "method": { + "enum": [ + "reviewStory/list" + ], + "title": "ReviewStory/listRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/v2/ReviewStoryListParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/listRequest", + "type": "object" + }, { "properties": { "id": { @@ -4227,6 +4299,26 @@ "title": "Turn/completedNotification", "type": "object" }, + { + "properties": { + "method": { + "enum": [ + "reviewStory/snapshot/updated" + ], + "title": "ReviewStory/snapshot/updatedNotificationMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/v2/ReviewStorySnapshotUpdatedNotification" + } + }, + "required": [ + "method", + "params" + ], + "title": "ReviewStory/snapshot/updatedNotification", + "type": "object" + }, { "properties": { "method": { @@ -14411,6 +14503,379 @@ "title": "ReviewStartResponse", "type": "object" }, + "ReviewStoryAnchor": { + "properties": { + "anchorId": { + "type": "string" + }, + "changeKind": { + "$ref": "#/definitions/v2/ReviewStoryAnchorKind" + }, + "diff": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "summary": { + "type": "string" + } + }, + "required": [ + "anchorId", + "changeKind", + "diff", + "filePath", + "summary" + ], + "type": "object" + }, + "ReviewStoryAnchorKind": { + "enum": [ + "added", + "modified", + "deleted", + "renamed", + "copied", + "unknown" + ], + "type": "string" + }, + "ReviewStoryListParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "threadId" + ], + "title": "ReviewStoryListParams", + "type": "object" + }, + "ReviewStoryListResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "data": { + "items": { + "$ref": "#/definitions/v2/ReviewStorySnapshotSummary" + }, + "type": "array" + }, + "nextCursor": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data" + ], + "title": "ReviewStoryListResponse", + "type": "object" + }, + "ReviewStoryReadParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "storySnapshotId": { + "type": "string" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "storySnapshotId", + "threadId" + ], + "title": "ReviewStoryReadParams", + "type": "object" + }, + "ReviewStoryReadResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "snapshot": { + "anyOf": [ + { + "$ref": "#/definitions/v2/ReviewStorySnapshot" + }, + { + "type": "null" + } + ] + } + }, + "title": "ReviewStoryReadResponse", + "type": "object" + }, + "ReviewStorySnapshot": { + "properties": { + "anchors": { + "items": { + "$ref": "#/definitions/v2/ReviewStoryAnchor" + }, + "type": "array" + }, + "createdAt": { + "format": "int64", + "type": "integer" + }, + "overview": { + "type": "string" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "stale": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/v2/ReviewStorySnapshotStatus" + }, + "steps": { + "items": { + "$ref": "#/definitions/v2/ReviewStoryStep" + }, + "type": "array" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/v2/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "anchors", + "createdAt", + "overview", + "sourceFingerprint", + "stale", + "status", + "steps", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStorySnapshotSummary": { + "properties": { + "createdAt": { + "format": "int64", + "type": "integer" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/v2/ReviewStorySnapshotStatus" + }, + "stepCount": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/v2/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "createdAt", + "sourceFingerprint", + "status", + "stepCount", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotUpdatedNotification": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "snapshot": { + "$ref": "#/definitions/v2/ReviewStorySnapshot" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "snapshot", + "threadId" + ], + "title": "ReviewStorySnapshotUpdatedNotification", + "type": "object" + }, + "ReviewStoryStartParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "target": { + "$ref": "#/definitions/v2/ReviewTarget" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "target", + "threadId" + ], + "title": "ReviewStoryStartParams", + "type": "object" + }, + "ReviewStoryStartResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "snapshot": { + "$ref": "#/definitions/v2/ReviewStorySnapshot" + }, + "storySnapshotId": { + "type": "string" + }, + "turn": { + "$ref": "#/definitions/v2/Turn" + } + }, + "required": [ + "snapshot", + "storySnapshotId", + "turn" + ], + "title": "ReviewStoryStartResponse", + "type": "object" + }, + "ReviewStoryStep": { + "properties": { + "anchorIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "dependencyRationale": { + "type": "string" + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "goal": { + "type": "string" + }, + "index": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "readiness": { + "$ref": "#/definitions/v2/ReviewStoryStepReadiness" + }, + "reviewFocus": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stepId": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "anchorIds", + "dependencyRationale", + "goal", + "index", + "readiness", + "reviewFocus", + "stepId", + "summary", + "title" + ], + "type": "object" + }, + "ReviewStoryStepReadiness": { + "enum": [ + "outline", + "enriching", + "ready", + "failed" + ], + "type": "string" + }, "ReviewTarget": { "oneOf": [ { diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json index ac565328f9..5e318dcabe 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json @@ -2155,6 +2155,78 @@ "title": "Review/startRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "reviewStory/start" + ], + "title": "ReviewStory/startRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStoryStartParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/startRequest", + "type": "object" + }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "reviewStory/read" + ], + "title": "ReviewStory/readRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStoryReadParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/readRequest", + "type": "object" + }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "reviewStory/list" + ], + "title": "ReviewStory/listRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStoryListParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "ReviewStory/listRequest", + "type": "object" + }, { "properties": { "id": { @@ -10940,6 +11012,379 @@ "title": "ReviewStartResponse", "type": "object" }, + "ReviewStoryAnchor": { + "properties": { + "anchorId": { + "type": "string" + }, + "changeKind": { + "$ref": "#/definitions/ReviewStoryAnchorKind" + }, + "diff": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "summary": { + "type": "string" + } + }, + "required": [ + "anchorId", + "changeKind", + "diff", + "filePath", + "summary" + ], + "type": "object" + }, + "ReviewStoryAnchorKind": { + "enum": [ + "added", + "modified", + "deleted", + "renamed", + "copied", + "unknown" + ], + "type": "string" + }, + "ReviewStoryListParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "threadId" + ], + "title": "ReviewStoryListParams", + "type": "object" + }, + "ReviewStoryListResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "data": { + "items": { + "$ref": "#/definitions/ReviewStorySnapshotSummary" + }, + "type": "array" + }, + "nextCursor": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data" + ], + "title": "ReviewStoryListResponse", + "type": "object" + }, + "ReviewStoryReadParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "storySnapshotId": { + "type": "string" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "storySnapshotId", + "threadId" + ], + "title": "ReviewStoryReadParams", + "type": "object" + }, + "ReviewStoryReadResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "snapshot": { + "anyOf": [ + { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + { + "type": "null" + } + ] + } + }, + "title": "ReviewStoryReadResponse", + "type": "object" + }, + "ReviewStorySnapshot": { + "properties": { + "anchors": { + "items": { + "$ref": "#/definitions/ReviewStoryAnchor" + }, + "type": "array" + }, + "createdAt": { + "format": "int64", + "type": "integer" + }, + "overview": { + "type": "string" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "stale": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "steps": { + "items": { + "$ref": "#/definitions/ReviewStoryStep" + }, + "type": "array" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "anchors", + "createdAt", + "overview", + "sourceFingerprint", + "stale", + "status", + "steps", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStorySnapshotSummary": { + "properties": { + "createdAt": { + "format": "int64", + "type": "integer" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "stepCount": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "createdAt", + "sourceFingerprint", + "status", + "stepCount", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotUpdatedNotification": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "snapshot": { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "snapshot", + "threadId" + ], + "title": "ReviewStorySnapshotUpdatedNotification", + "type": "object" + }, + "ReviewStoryStartParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "target", + "threadId" + ], + "title": "ReviewStoryStartParams", + "type": "object" + }, + "ReviewStoryStartResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "snapshot": { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + "storySnapshotId": { + "type": "string" + }, + "turn": { + "$ref": "#/definitions/Turn" + } + }, + "required": [ + "snapshot", + "storySnapshotId", + "turn" + ], + "title": "ReviewStoryStartResponse", + "type": "object" + }, + "ReviewStoryStep": { + "properties": { + "anchorIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "dependencyRationale": { + "type": "string" + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "goal": { + "type": "string" + }, + "index": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "readiness": { + "$ref": "#/definitions/ReviewStoryStepReadiness" + }, + "reviewFocus": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stepId": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "anchorIds", + "dependencyRationale", + "goal", + "index", + "readiness", + "reviewFocus", + "stepId", + "summary", + "title" + ], + "type": "object" + }, + "ReviewStoryStepReadiness": { + "enum": [ + "outline", + "enriching", + "ready", + "failed" + ], + "type": "string" + }, "ReviewTarget": { "oneOf": [ { @@ -11493,6 +11938,26 @@ "title": "Turn/completedNotification", "type": "object" }, + { + "properties": { + "method": { + "enum": [ + "reviewStory/snapshot/updated" + ], + "title": "ReviewStory/snapshot/updatedNotificationMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/ReviewStorySnapshotUpdatedNotification" + } + }, + "required": [ + "method", + "params" + ], + "title": "ReviewStory/snapshot/updatedNotification", + "type": "object" + }, { "properties": { "method": { diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListParams.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListParams.json new file mode 100644 index 0000000000..4101a6aa55 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListParams.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "threadId" + ], + "title": "ReviewStoryListParams", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListResponse.json new file mode 100644 index 0000000000..5626807079 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryListResponse.json @@ -0,0 +1,177 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStorySnapshotSummary": { + "properties": { + "createdAt": { + "format": "int64", + "type": "integer" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "stepCount": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "createdAt", + "sourceFingerprint", + "status", + "stepCount", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewTarget": { + "oneOf": [ + { + "description": "Review the working tree: staged, unstaged, and untracked files.", + "properties": { + "type": { + "enum": [ + "uncommittedChanges" + ], + "title": "UncommittedChangesReviewTargetType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UncommittedChangesReviewTarget", + "type": "object" + }, + { + "description": "Review changes between the current branch and the given base branch.", + "properties": { + "branch": { + "type": "string" + }, + "type": { + "enum": [ + "baseBranch" + ], + "title": "BaseBranchReviewTargetType", + "type": "string" + } + }, + "required": [ + "branch", + "type" + ], + "title": "BaseBranchReviewTarget", + "type": "object" + }, + { + "description": "Review the changes introduced by a specific commit.", + "properties": { + "sha": { + "type": "string" + }, + "title": { + "description": "Optional human-readable label (e.g., commit subject) for UIs.", + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "commit" + ], + "title": "CommitReviewTargetType", + "type": "string" + } + }, + "required": [ + "sha", + "type" + ], + "title": "CommitReviewTarget", + "type": "object" + }, + { + "description": "Arbitrary instructions, equivalent to the old free-form prompt.", + "properties": { + "instructions": { + "type": "string" + }, + "type": { + "enum": [ + "custom" + ], + "title": "CustomReviewTargetType", + "type": "string" + } + }, + "required": [ + "instructions", + "type" + ], + "title": "CustomReviewTarget", + "type": "object" + } + ] + } + }, + "properties": { + "data": { + "items": { + "$ref": "#/definitions/ReviewStorySnapshotSummary" + }, + "type": "array" + }, + "nextCursor": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data" + ], + "title": "ReviewStoryListResponse", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadParams.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadParams.json new file mode 100644 index 0000000000..32ed641596 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadParams.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "storySnapshotId": { + "type": "string" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "storySnapshotId", + "threadId" + ], + "title": "ReviewStoryReadParams", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadResponse.json new file mode 100644 index 0000000000..9d62de2c7b --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryReadResponse.json @@ -0,0 +1,292 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ReviewStoryAnchor": { + "properties": { + "anchorId": { + "type": "string" + }, + "changeKind": { + "$ref": "#/definitions/ReviewStoryAnchorKind" + }, + "diff": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "summary": { + "type": "string" + } + }, + "required": [ + "anchorId", + "changeKind", + "diff", + "filePath", + "summary" + ], + "type": "object" + }, + "ReviewStoryAnchorKind": { + "enum": [ + "added", + "modified", + "deleted", + "renamed", + "copied", + "unknown" + ], + "type": "string" + }, + "ReviewStorySnapshot": { + "properties": { + "anchors": { + "items": { + "$ref": "#/definitions/ReviewStoryAnchor" + }, + "type": "array" + }, + "createdAt": { + "format": "int64", + "type": "integer" + }, + "overview": { + "type": "string" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "stale": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "steps": { + "items": { + "$ref": "#/definitions/ReviewStoryStep" + }, + "type": "array" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "anchors", + "createdAt", + "overview", + "sourceFingerprint", + "stale", + "status", + "steps", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStoryStep": { + "properties": { + "anchorIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "dependencyRationale": { + "type": "string" + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "goal": { + "type": "string" + }, + "index": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "readiness": { + "$ref": "#/definitions/ReviewStoryStepReadiness" + }, + "reviewFocus": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stepId": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "anchorIds", + "dependencyRationale", + "goal", + "index", + "readiness", + "reviewFocus", + "stepId", + "summary", + "title" + ], + "type": "object" + }, + "ReviewStoryStepReadiness": { + "enum": [ + "outline", + "enriching", + "ready", + "failed" + ], + "type": "string" + }, + "ReviewTarget": { + "oneOf": [ + { + "description": "Review the working tree: staged, unstaged, and untracked files.", + "properties": { + "type": { + "enum": [ + "uncommittedChanges" + ], + "title": "UncommittedChangesReviewTargetType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UncommittedChangesReviewTarget", + "type": "object" + }, + { + "description": "Review changes between the current branch and the given base branch.", + "properties": { + "branch": { + "type": "string" + }, + "type": { + "enum": [ + "baseBranch" + ], + "title": "BaseBranchReviewTargetType", + "type": "string" + } + }, + "required": [ + "branch", + "type" + ], + "title": "BaseBranchReviewTarget", + "type": "object" + }, + { + "description": "Review the changes introduced by a specific commit.", + "properties": { + "sha": { + "type": "string" + }, + "title": { + "description": "Optional human-readable label (e.g., commit subject) for UIs.", + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "commit" + ], + "title": "CommitReviewTargetType", + "type": "string" + } + }, + "required": [ + "sha", + "type" + ], + "title": "CommitReviewTarget", + "type": "object" + }, + { + "description": "Arbitrary instructions, equivalent to the old free-form prompt.", + "properties": { + "instructions": { + "type": "string" + }, + "type": { + "enum": [ + "custom" + ], + "title": "CustomReviewTargetType", + "type": "string" + } + }, + "required": [ + "instructions", + "type" + ], + "title": "CustomReviewTarget", + "type": "object" + } + ] + } + }, + "properties": { + "snapshot": { + "anyOf": [ + { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + { + "type": "null" + } + ] + } + }, + "title": "ReviewStoryReadResponse", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStorySnapshotUpdatedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStorySnapshotUpdatedNotification.json new file mode 100644 index 0000000000..1bc24665aa --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStorySnapshotUpdatedNotification.json @@ -0,0 +1,292 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ReviewStoryAnchor": { + "properties": { + "anchorId": { + "type": "string" + }, + "changeKind": { + "$ref": "#/definitions/ReviewStoryAnchorKind" + }, + "diff": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "summary": { + "type": "string" + } + }, + "required": [ + "anchorId", + "changeKind", + "diff", + "filePath", + "summary" + ], + "type": "object" + }, + "ReviewStoryAnchorKind": { + "enum": [ + "added", + "modified", + "deleted", + "renamed", + "copied", + "unknown" + ], + "type": "string" + }, + "ReviewStorySnapshot": { + "properties": { + "anchors": { + "items": { + "$ref": "#/definitions/ReviewStoryAnchor" + }, + "type": "array" + }, + "createdAt": { + "format": "int64", + "type": "integer" + }, + "overview": { + "type": "string" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "stale": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "steps": { + "items": { + "$ref": "#/definitions/ReviewStoryStep" + }, + "type": "array" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "anchors", + "createdAt", + "overview", + "sourceFingerprint", + "stale", + "status", + "steps", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStoryStep": { + "properties": { + "anchorIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "dependencyRationale": { + "type": "string" + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "goal": { + "type": "string" + }, + "index": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "readiness": { + "$ref": "#/definitions/ReviewStoryStepReadiness" + }, + "reviewFocus": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stepId": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "anchorIds", + "dependencyRationale", + "goal", + "index", + "readiness", + "reviewFocus", + "stepId", + "summary", + "title" + ], + "type": "object" + }, + "ReviewStoryStepReadiness": { + "enum": [ + "outline", + "enriching", + "ready", + "failed" + ], + "type": "string" + }, + "ReviewTarget": { + "oneOf": [ + { + "description": "Review the working tree: staged, unstaged, and untracked files.", + "properties": { + "type": { + "enum": [ + "uncommittedChanges" + ], + "title": "UncommittedChangesReviewTargetType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UncommittedChangesReviewTarget", + "type": "object" + }, + { + "description": "Review changes between the current branch and the given base branch.", + "properties": { + "branch": { + "type": "string" + }, + "type": { + "enum": [ + "baseBranch" + ], + "title": "BaseBranchReviewTargetType", + "type": "string" + } + }, + "required": [ + "branch", + "type" + ], + "title": "BaseBranchReviewTarget", + "type": "object" + }, + { + "description": "Review the changes introduced by a specific commit.", + "properties": { + "sha": { + "type": "string" + }, + "title": { + "description": "Optional human-readable label (e.g., commit subject) for UIs.", + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "commit" + ], + "title": "CommitReviewTargetType", + "type": "string" + } + }, + "required": [ + "sha", + "type" + ], + "title": "CommitReviewTarget", + "type": "object" + }, + { + "description": "Arbitrary instructions, equivalent to the old free-form prompt.", + "properties": { + "instructions": { + "type": "string" + }, + "type": { + "enum": [ + "custom" + ], + "title": "CustomReviewTargetType", + "type": "string" + } + }, + "required": [ + "instructions", + "type" + ], + "title": "CustomReviewTarget", + "type": "object" + } + ] + } + }, + "properties": { + "snapshot": { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "snapshot", + "threadId" + ], + "title": "ReviewStorySnapshotUpdatedNotification", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartParams.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartParams.json new file mode 100644 index 0000000000..5ae8b4fd56 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartParams.json @@ -0,0 +1,110 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ReviewTarget": { + "oneOf": [ + { + "description": "Review the working tree: staged, unstaged, and untracked files.", + "properties": { + "type": { + "enum": [ + "uncommittedChanges" + ], + "title": "UncommittedChangesReviewTargetType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UncommittedChangesReviewTarget", + "type": "object" + }, + { + "description": "Review changes between the current branch and the given base branch.", + "properties": { + "branch": { + "type": "string" + }, + "type": { + "enum": [ + "baseBranch" + ], + "title": "BaseBranchReviewTargetType", + "type": "string" + } + }, + "required": [ + "branch", + "type" + ], + "title": "BaseBranchReviewTarget", + "type": "object" + }, + { + "description": "Review the changes introduced by a specific commit.", + "properties": { + "sha": { + "type": "string" + }, + "title": { + "description": "Optional human-readable label (e.g., commit subject) for UIs.", + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "commit" + ], + "title": "CommitReviewTargetType", + "type": "string" + } + }, + "required": [ + "sha", + "type" + ], + "title": "CommitReviewTarget", + "type": "object" + }, + { + "description": "Arbitrary instructions, equivalent to the old free-form prompt.", + "properties": { + "instructions": { + "type": "string" + }, + "type": { + "enum": [ + "custom" + ], + "title": "CustomReviewTargetType", + "type": "string" + } + }, + "required": [ + "instructions", + "type" + ], + "title": "CustomReviewTarget", + "type": "object" + } + ] + } + }, + "properties": { + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + } + }, + "required": [ + "target", + "threadId" + ], + "title": "ReviewStoryStartParams", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartResponse.json new file mode 100644 index 0000000000..db65c6961c --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStoryStartResponse.json @@ -0,0 +1,1971 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AbsolutePathBuf": { + "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.", + "type": "string" + }, + "ByteRange": { + "properties": { + "end": { + "format": "uint", + "minimum": 0.0, + "type": "integer" + }, + "start": { + "format": "uint", + "minimum": 0.0, + "type": "integer" + } + }, + "required": [ + "end", + "start" + ], + "type": "object" + }, + "CodexErrorInfo": { + "description": "This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant.", + "oneOf": [ + { + "enum": [ + "contextWindowExceeded", + "usageLimitExceeded", + "serverOverloaded", + "cyberPolicy", + "internalServerError", + "unauthorized", + "badRequest", + "threadRollbackFailed", + "sandboxError", + "other" + ], + "type": "string" + }, + { + "additionalProperties": false, + "properties": { + "httpConnectionFailed": { + "properties": { + "httpStatusCode": { + "format": "uint16", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "type": "object" + } + }, + "required": [ + "httpConnectionFailed" + ], + "title": "HttpConnectionFailedCodexErrorInfo", + "type": "object" + }, + { + "additionalProperties": false, + "description": "Failed to connect to the response SSE stream.", + "properties": { + "responseStreamConnectionFailed": { + "properties": { + "httpStatusCode": { + "format": "uint16", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "type": "object" + } + }, + "required": [ + "responseStreamConnectionFailed" + ], + "title": "ResponseStreamConnectionFailedCodexErrorInfo", + "type": "object" + }, + { + "additionalProperties": false, + "description": "The response SSE stream disconnected in the middle of a turn before completion.", + "properties": { + "responseStreamDisconnected": { + "properties": { + "httpStatusCode": { + "format": "uint16", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "type": "object" + } + }, + "required": [ + "responseStreamDisconnected" + ], + "title": "ResponseStreamDisconnectedCodexErrorInfo", + "type": "object" + }, + { + "additionalProperties": false, + "description": "Reached the retry limit for responses.", + "properties": { + "responseTooManyFailedAttempts": { + "properties": { + "httpStatusCode": { + "format": "uint16", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "type": "object" + } + }, + "required": [ + "responseTooManyFailedAttempts" + ], + "title": "ResponseTooManyFailedAttemptsCodexErrorInfo", + "type": "object" + }, + { + "additionalProperties": false, + "description": "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.", + "properties": { + "activeTurnNotSteerable": { + "properties": { + "turnKind": { + "$ref": "#/definitions/NonSteerableTurnKind" + } + }, + "required": [ + "turnKind" + ], + "type": "object" + } + }, + "required": [ + "activeTurnNotSteerable" + ], + "title": "ActiveTurnNotSteerableCodexErrorInfo", + "type": "object" + } + ] + }, + "CollabAgentState": { + "properties": { + "message": { + "type": [ + "string", + "null" + ] + }, + "status": { + "$ref": "#/definitions/CollabAgentStatus" + } + }, + "required": [ + "status" + ], + "type": "object" + }, + "CollabAgentStatus": { + "enum": [ + "pendingInit", + "running", + "interrupted", + "completed", + "errored", + "shutdown", + "notFound" + ], + "type": "string" + }, + "CollabAgentTool": { + "enum": [ + "spawnAgent", + "sendInput", + "resumeAgent", + "wait", + "closeAgent" + ], + "type": "string" + }, + "CollabAgentToolCallStatus": { + "enum": [ + "inProgress", + "completed", + "failed" + ], + "type": "string" + }, + "CommandAction": { + "oneOf": [ + { + "properties": { + "command": { + "type": "string" + }, + "name": { + "type": "string" + }, + "path": { + "$ref": "#/definitions/AbsolutePathBuf" + }, + "type": { + "enum": [ + "read" + ], + "title": "ReadCommandActionType", + "type": "string" + } + }, + "required": [ + "command", + "name", + "path", + "type" + ], + "title": "ReadCommandAction", + "type": "object" + }, + { + "properties": { + "command": { + "type": "string" + }, + "path": { + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "listFiles" + ], + "title": "ListFilesCommandActionType", + "type": "string" + } + }, + "required": [ + "command", + "type" + ], + "title": "ListFilesCommandAction", + "type": "object" + }, + { + "properties": { + "command": { + "type": "string" + }, + "path": { + "type": [ + "string", + "null" + ] + }, + "query": { + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "search" + ], + "title": "SearchCommandActionType", + "type": "string" + } + }, + "required": [ + "command", + "type" + ], + "title": "SearchCommandAction", + "type": "object" + }, + { + "properties": { + "command": { + "type": "string" + }, + "type": { + "enum": [ + "unknown" + ], + "title": "UnknownCommandActionType", + "type": "string" + } + }, + "required": [ + "command", + "type" + ], + "title": "UnknownCommandAction", + "type": "object" + } + ] + }, + "CommandExecutionSource": { + "enum": [ + "agent", + "userShell", + "unifiedExecStartup", + "unifiedExecInteraction" + ], + "type": "string" + }, + "CommandExecutionStatus": { + "enum": [ + "inProgress", + "completed", + "failed", + "declined" + ], + "type": "string" + }, + "DynamicToolCallOutputContentItem": { + "oneOf": [ + { + "properties": { + "text": { + "type": "string" + }, + "type": { + "enum": [ + "inputText" + ], + "title": "InputTextDynamicToolCallOutputContentItemType", + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "title": "InputTextDynamicToolCallOutputContentItem", + "type": "object" + }, + { + "properties": { + "imageUrl": { + "type": "string" + }, + "type": { + "enum": [ + "inputImage" + ], + "title": "InputImageDynamicToolCallOutputContentItemType", + "type": "string" + } + }, + "required": [ + "imageUrl", + "type" + ], + "title": "InputImageDynamicToolCallOutputContentItem", + "type": "object" + } + ] + }, + "DynamicToolCallStatus": { + "enum": [ + "inProgress", + "completed", + "failed" + ], + "type": "string" + }, + "FileUpdateChange": { + "properties": { + "diff": { + "type": "string" + }, + "kind": { + "$ref": "#/definitions/PatchChangeKind" + }, + "path": { + "type": "string" + } + }, + "required": [ + "diff", + "kind", + "path" + ], + "type": "object" + }, + "HookPromptFragment": { + "properties": { + "hookRunId": { + "type": "string" + }, + "text": { + "type": "string" + } + }, + "required": [ + "hookRunId", + "text" + ], + "type": "object" + }, + "ImageDetail": { + "enum": [ + "high", + "original" + ], + "type": "string" + }, + "McpToolCallError": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "McpToolCallResult": { + "properties": { + "_meta": true, + "content": { + "items": true, + "type": "array" + }, + "structuredContent": true + }, + "required": [ + "content" + ], + "type": "object" + }, + "McpToolCallStatus": { + "enum": [ + "inProgress", + "completed", + "failed" + ], + "type": "string" + }, + "MemoryCitation": { + "properties": { + "entries": { + "items": { + "$ref": "#/definitions/MemoryCitationEntry" + }, + "type": "array" + }, + "threadIds": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "entries", + "threadIds" + ], + "type": "object" + }, + "MemoryCitationEntry": { + "properties": { + "lineEnd": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "lineStart": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "note": { + "type": "string" + }, + "path": { + "type": "string" + } + }, + "required": [ + "lineEnd", + "lineStart", + "note", + "path" + ], + "type": "object" + }, + "MessagePhase": { + "description": "Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as \"phase unknown\" and keep compatibility behavior for legacy models.", + "oneOf": [ + { + "description": "Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.", + "enum": [ + "commentary" + ], + "type": "string" + }, + { + "description": "The assistant's terminal answer text for the current turn.", + "enum": [ + "final_answer" + ], + "type": "string" + } + ] + }, + "NonSteerableTurnKind": { + "enum": [ + "review", + "compact" + ], + "type": "string" + }, + "PatchApplyStatus": { + "enum": [ + "inProgress", + "completed", + "failed", + "declined" + ], + "type": "string" + }, + "PatchChangeKind": { + "oneOf": [ + { + "properties": { + "type": { + "enum": [ + "add" + ], + "title": "AddPatchChangeKindType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "AddPatchChangeKind", + "type": "object" + }, + { + "properties": { + "type": { + "enum": [ + "delete" + ], + "title": "DeletePatchChangeKindType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "DeletePatchChangeKind", + "type": "object" + }, + { + "properties": { + "move_path": { + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "update" + ], + "title": "UpdatePatchChangeKindType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UpdatePatchChangeKind", + "type": "object" + } + ] + }, + "ReasoningEffort": { + "description": "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning", + "enum": [ + "none", + "minimal", + "low", + "medium", + "high", + "xhigh" + ], + "type": "string" + }, + "ReviewStoryAnchor": { + "properties": { + "anchorId": { + "type": "string" + }, + "changeKind": { + "$ref": "#/definitions/ReviewStoryAnchorKind" + }, + "diff": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "summary": { + "type": "string" + } + }, + "required": [ + "anchorId", + "changeKind", + "diff", + "filePath", + "summary" + ], + "type": "object" + }, + "ReviewStoryAnchorKind": { + "enum": [ + "added", + "modified", + "deleted", + "renamed", + "copied", + "unknown" + ], + "type": "string" + }, + "ReviewStorySnapshot": { + "properties": { + "anchors": { + "items": { + "$ref": "#/definitions/ReviewStoryAnchor" + }, + "type": "array" + }, + "createdAt": { + "format": "int64", + "type": "integer" + }, + "overview": { + "type": "string" + }, + "previousStorySnapshotId": { + "type": [ + "string", + "null" + ] + }, + "sourceFingerprint": { + "type": "string" + }, + "stale": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/ReviewStorySnapshotStatus" + }, + "steps": { + "items": { + "$ref": "#/definitions/ReviewStoryStep" + }, + "type": "array" + }, + "storySnapshotId": { + "type": "string" + }, + "target": { + "$ref": "#/definitions/ReviewTarget" + }, + "threadId": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updatedAt": { + "format": "int64", + "type": "integer" + } + }, + "required": [ + "anchors", + "createdAt", + "overview", + "sourceFingerprint", + "stale", + "status", + "steps", + "storySnapshotId", + "target", + "threadId", + "title", + "updatedAt" + ], + "type": "object" + }, + "ReviewStorySnapshotStatus": { + "enum": [ + "building", + "ready", + "partial", + "failed" + ], + "type": "string" + }, + "ReviewStoryStep": { + "properties": { + "anchorIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "dependencyRationale": { + "type": "string" + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "goal": { + "type": "string" + }, + "index": { + "format": "uint32", + "minimum": 0.0, + "type": "integer" + }, + "readiness": { + "$ref": "#/definitions/ReviewStoryStepReadiness" + }, + "reviewFocus": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stepId": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "required": [ + "anchorIds", + "dependencyRationale", + "goal", + "index", + "readiness", + "reviewFocus", + "stepId", + "summary", + "title" + ], + "type": "object" + }, + "ReviewStoryStepReadiness": { + "enum": [ + "outline", + "enriching", + "ready", + "failed" + ], + "type": "string" + }, + "ReviewTarget": { + "oneOf": [ + { + "description": "Review the working tree: staged, unstaged, and untracked files.", + "properties": { + "type": { + "enum": [ + "uncommittedChanges" + ], + "title": "UncommittedChangesReviewTargetType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "UncommittedChangesReviewTarget", + "type": "object" + }, + { + "description": "Review changes between the current branch and the given base branch.", + "properties": { + "branch": { + "type": "string" + }, + "type": { + "enum": [ + "baseBranch" + ], + "title": "BaseBranchReviewTargetType", + "type": "string" + } + }, + "required": [ + "branch", + "type" + ], + "title": "BaseBranchReviewTarget", + "type": "object" + }, + { + "description": "Review the changes introduced by a specific commit.", + "properties": { + "sha": { + "type": "string" + }, + "title": { + "description": "Optional human-readable label (e.g., commit subject) for UIs.", + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "commit" + ], + "title": "CommitReviewTargetType", + "type": "string" + } + }, + "required": [ + "sha", + "type" + ], + "title": "CommitReviewTarget", + "type": "object" + }, + { + "description": "Arbitrary instructions, equivalent to the old free-form prompt.", + "properties": { + "instructions": { + "type": "string" + }, + "type": { + "enum": [ + "custom" + ], + "title": "CustomReviewTargetType", + "type": "string" + } + }, + "required": [ + "instructions", + "type" + ], + "title": "CustomReviewTarget", + "type": "object" + } + ] + }, + "TextElement": { + "properties": { + "byteRange": { + "allOf": [ + { + "$ref": "#/definitions/ByteRange" + } + ], + "description": "Byte range in the parent `text` buffer that this element occupies." + }, + "placeholder": { + "description": "Optional human-readable placeholder for the element, displayed in the UI.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "byteRange" + ], + "type": "object" + }, + "ThreadItem": { + "oneOf": [ + { + "properties": { + "content": { + "items": { + "$ref": "#/definitions/UserInput" + }, + "type": "array" + }, + "id": { + "type": "string" + }, + "type": { + "enum": [ + "userMessage" + ], + "title": "UserMessageThreadItemType", + "type": "string" + } + }, + "required": [ + "content", + "id", + "type" + ], + "title": "UserMessageThreadItem", + "type": "object" + }, + { + "properties": { + "fragments": { + "items": { + "$ref": "#/definitions/HookPromptFragment" + }, + "type": "array" + }, + "id": { + "type": "string" + }, + "type": { + "enum": [ + "hookPrompt" + ], + "title": "HookPromptThreadItemType", + "type": "string" + } + }, + "required": [ + "fragments", + "id", + "type" + ], + "title": "HookPromptThreadItem", + "type": "object" + }, + { + "properties": { + "id": { + "type": "string" + }, + "memoryCitation": { + "anyOf": [ + { + "$ref": "#/definitions/MemoryCitation" + }, + { + "type": "null" + } + ], + "default": null + }, + "phase": { + "anyOf": [ + { + "$ref": "#/definitions/MessagePhase" + }, + { + "type": "null" + } + ], + "default": null + }, + "text": { + "type": "string" + }, + "type": { + "enum": [ + "agentMessage" + ], + "title": "AgentMessageThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "text", + "type" + ], + "title": "AgentMessageThreadItem", + "type": "object" + }, + { + "description": "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.", + "properties": { + "id": { + "type": "string" + }, + "text": { + "type": "string" + }, + "type": { + "enum": [ + "plan" + ], + "title": "PlanThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "text", + "type" + ], + "title": "PlanThreadItem", + "type": "object" + }, + { + "properties": { + "content": { + "default": [], + "items": { + "type": "string" + }, + "type": "array" + }, + "id": { + "type": "string" + }, + "summary": { + "default": [], + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "enum": [ + "reasoning" + ], + "title": "ReasoningThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "type" + ], + "title": "ReasoningThreadItem", + "type": "object" + }, + { + "properties": { + "aggregatedOutput": { + "description": "The command's output, aggregated from stdout and stderr.", + "type": [ + "string", + "null" + ] + }, + "command": { + "description": "The command to be executed.", + "type": "string" + }, + "commandActions": { + "description": "A best-effort parsing of the command to understand the action(s) it will perform. This returns a list of CommandAction objects because a single shell command may be composed of many commands piped together.", + "items": { + "$ref": "#/definitions/CommandAction" + }, + "type": "array" + }, + "cwd": { + "allOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + } + ], + "description": "The command's working directory." + }, + "durationMs": { + "description": "The duration of the command execution in milliseconds.", + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "exitCode": { + "description": "The command's exit code.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "id": { + "type": "string" + }, + "processId": { + "description": "Identifier for the underlying PTY process (when available).", + "type": [ + "string", + "null" + ] + }, + "source": { + "allOf": [ + { + "$ref": "#/definitions/CommandExecutionSource" + } + ], + "default": "agent" + }, + "status": { + "$ref": "#/definitions/CommandExecutionStatus" + }, + "type": { + "enum": [ + "commandExecution" + ], + "title": "CommandExecutionThreadItemType", + "type": "string" + } + }, + "required": [ + "command", + "commandActions", + "cwd", + "id", + "status", + "type" + ], + "title": "CommandExecutionThreadItem", + "type": "object" + }, + { + "properties": { + "changes": { + "items": { + "$ref": "#/definitions/FileUpdateChange" + }, + "type": "array" + }, + "id": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/PatchApplyStatus" + }, + "type": { + "enum": [ + "fileChange" + ], + "title": "FileChangeThreadItemType", + "type": "string" + } + }, + "required": [ + "changes", + "id", + "status", + "type" + ], + "title": "FileChangeThreadItem", + "type": "object" + }, + { + "properties": { + "arguments": true, + "durationMs": { + "description": "The duration of the MCP tool call in milliseconds.", + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "error": { + "anyOf": [ + { + "$ref": "#/definitions/McpToolCallError" + }, + { + "type": "null" + } + ] + }, + "id": { + "type": "string" + }, + "mcpAppResourceUri": { + "type": [ + "string", + "null" + ] + }, + "pluginId": { + "type": [ + "string", + "null" + ] + }, + "result": { + "anyOf": [ + { + "$ref": "#/definitions/McpToolCallResult" + }, + { + "type": "null" + } + ] + }, + "server": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/McpToolCallStatus" + }, + "tool": { + "type": "string" + }, + "type": { + "enum": [ + "mcpToolCall" + ], + "title": "McpToolCallThreadItemType", + "type": "string" + } + }, + "required": [ + "arguments", + "id", + "server", + "status", + "tool", + "type" + ], + "title": "McpToolCallThreadItem", + "type": "object" + }, + { + "properties": { + "arguments": true, + "contentItems": { + "items": { + "$ref": "#/definitions/DynamicToolCallOutputContentItem" + }, + "type": [ + "array", + "null" + ] + }, + "durationMs": { + "description": "The duration of the dynamic tool call in milliseconds.", + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "id": { + "type": "string" + }, + "namespace": { + "type": [ + "string", + "null" + ] + }, + "status": { + "$ref": "#/definitions/DynamicToolCallStatus" + }, + "success": { + "type": [ + "boolean", + "null" + ] + }, + "tool": { + "type": "string" + }, + "type": { + "enum": [ + "dynamicToolCall" + ], + "title": "DynamicToolCallThreadItemType", + "type": "string" + } + }, + "required": [ + "arguments", + "id", + "status", + "tool", + "type" + ], + "title": "DynamicToolCallThreadItem", + "type": "object" + }, + { + "properties": { + "agentsStates": { + "additionalProperties": { + "$ref": "#/definitions/CollabAgentState" + }, + "description": "Last known status of the target agents, when available.", + "type": "object" + }, + "id": { + "description": "Unique identifier for this collab tool call.", + "type": "string" + }, + "model": { + "description": "Model requested for the spawned agent, when applicable.", + "type": [ + "string", + "null" + ] + }, + "prompt": { + "description": "Prompt text sent as part of the collab tool call, when available.", + "type": [ + "string", + "null" + ] + }, + "reasoningEffort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ], + "description": "Reasoning effort requested for the spawned agent, when applicable." + }, + "receiverThreadIds": { + "description": "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.", + "items": { + "type": "string" + }, + "type": "array" + }, + "senderThreadId": { + "description": "Thread ID of the agent issuing the collab request.", + "type": "string" + }, + "status": { + "allOf": [ + { + "$ref": "#/definitions/CollabAgentToolCallStatus" + } + ], + "description": "Current status of the collab tool call." + }, + "tool": { + "allOf": [ + { + "$ref": "#/definitions/CollabAgentTool" + } + ], + "description": "Name of the collab tool that was invoked." + }, + "type": { + "enum": [ + "collabAgentToolCall" + ], + "title": "CollabAgentToolCallThreadItemType", + "type": "string" + } + }, + "required": [ + "agentsStates", + "id", + "receiverThreadIds", + "senderThreadId", + "status", + "tool", + "type" + ], + "title": "CollabAgentToolCallThreadItem", + "type": "object" + }, + { + "properties": { + "action": { + "anyOf": [ + { + "$ref": "#/definitions/WebSearchAction" + }, + { + "type": "null" + } + ] + }, + "id": { + "type": "string" + }, + "query": { + "type": "string" + }, + "type": { + "enum": [ + "webSearch" + ], + "title": "WebSearchThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "query", + "type" + ], + "title": "WebSearchThreadItem", + "type": "object" + }, + { + "properties": { + "id": { + "type": "string" + }, + "path": { + "$ref": "#/definitions/AbsolutePathBuf" + }, + "type": { + "enum": [ + "imageView" + ], + "title": "ImageViewThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "path", + "type" + ], + "title": "ImageViewThreadItem", + "type": "object" + }, + { + "properties": { + "id": { + "type": "string" + }, + "result": { + "type": "string" + }, + "revisedPrompt": { + "type": [ + "string", + "null" + ] + }, + "savedPath": { + "anyOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + }, + { + "type": "null" + } + ] + }, + "status": { + "type": "string" + }, + "type": { + "enum": [ + "imageGeneration" + ], + "title": "ImageGenerationThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "result", + "status", + "type" + ], + "title": "ImageGenerationThreadItem", + "type": "object" + }, + { + "properties": { + "id": { + "type": "string" + }, + "review": { + "type": "string" + }, + "type": { + "enum": [ + "enteredReviewMode" + ], + "title": "EnteredReviewModeThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "review", + "type" + ], + "title": "EnteredReviewModeThreadItem", + "type": "object" + }, + { + "properties": { + "id": { + "type": "string" + }, + "review": { + "type": "string" + }, + "type": { + "enum": [ + "exitedReviewMode" + ], + "title": "ExitedReviewModeThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "review", + "type" + ], + "title": "ExitedReviewModeThreadItem", + "type": "object" + }, + { + "properties": { + "id": { + "type": "string" + }, + "type": { + "enum": [ + "contextCompaction" + ], + "title": "ContextCompactionThreadItemType", + "type": "string" + } + }, + "required": [ + "id", + "type" + ], + "title": "ContextCompactionThreadItem", + "type": "object" + } + ] + }, + "Turn": { + "properties": { + "completedAt": { + "description": "Unix timestamp (in seconds) when the turn completed.", + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "durationMs": { + "description": "Duration between turn start and completion in milliseconds, if known.", + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "error": { + "anyOf": [ + { + "$ref": "#/definitions/TurnError" + }, + { + "type": "null" + } + ], + "description": "Only populated when the Turn's status is failed." + }, + "id": { + "type": "string" + }, + "items": { + "description": "Thread items currently included in this turn payload.", + "items": { + "$ref": "#/definitions/ThreadItem" + }, + "type": "array" + }, + "itemsView": { + "allOf": [ + { + "$ref": "#/definitions/TurnItemsView" + } + ], + "default": "full", + "description": "Describes how much of `items` has been loaded for this turn." + }, + "startedAt": { + "description": "Unix timestamp (in seconds) when the turn started.", + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "status": { + "$ref": "#/definitions/TurnStatus" + } + }, + "required": [ + "id", + "items", + "status" + ], + "type": "object" + }, + "TurnError": { + "properties": { + "additionalDetails": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "codexErrorInfo": { + "anyOf": [ + { + "$ref": "#/definitions/CodexErrorInfo" + }, + { + "type": "null" + } + ] + }, + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "TurnItemsView": { + "oneOf": [ + { + "description": "`items` was not loaded for this turn. The field is intentionally empty.", + "enum": [ + "notLoaded" + ], + "type": "string" + }, + { + "description": "`items` contains only a display summary for this turn.", + "enum": [ + "summary" + ], + "type": "string" + }, + { + "description": "`items` contains every ThreadItem available from persisted app-server history for this turn.", + "enum": [ + "full" + ], + "type": "string" + } + ] + }, + "TurnStatus": { + "enum": [ + "completed", + "interrupted", + "failed", + "inProgress" + ], + "type": "string" + }, + "UserInput": { + "oneOf": [ + { + "properties": { + "text": { + "type": "string" + }, + "text_elements": { + "default": [], + "description": "UI-defined spans within `text` used to render or persist special elements.", + "items": { + "$ref": "#/definitions/TextElement" + }, + "type": "array" + }, + "type": { + "enum": [ + "text" + ], + "title": "TextUserInputType", + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "title": "TextUserInput", + "type": "object" + }, + { + "properties": { + "detail": { + "anyOf": [ + { + "$ref": "#/definitions/ImageDetail" + }, + { + "type": "null" + } + ], + "default": null + }, + "type": { + "enum": [ + "image" + ], + "title": "ImageUserInputType", + "type": "string" + }, + "url": { + "type": "string" + } + }, + "required": [ + "type", + "url" + ], + "title": "ImageUserInput", + "type": "object" + }, + { + "properties": { + "detail": { + "anyOf": [ + { + "$ref": "#/definitions/ImageDetail" + }, + { + "type": "null" + } + ], + "default": null + }, + "path": { + "type": "string" + }, + "type": { + "enum": [ + "localImage" + ], + "title": "LocalImageUserInputType", + "type": "string" + } + }, + "required": [ + "path", + "type" + ], + "title": "LocalImageUserInput", + "type": "object" + }, + { + "properties": { + "name": { + "type": "string" + }, + "path": { + "type": "string" + }, + "type": { + "enum": [ + "skill" + ], + "title": "SkillUserInputType", + "type": "string" + } + }, + "required": [ + "name", + "path", + "type" + ], + "title": "SkillUserInput", + "type": "object" + }, + { + "properties": { + "name": { + "type": "string" + }, + "path": { + "type": "string" + }, + "type": { + "enum": [ + "mention" + ], + "title": "MentionUserInputType", + "type": "string" + } + }, + "required": [ + "name", + "path", + "type" + ], + "title": "MentionUserInput", + "type": "object" + } + ] + }, + "WebSearchAction": { + "oneOf": [ + { + "properties": { + "queries": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "query": { + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "search" + ], + "title": "SearchWebSearchActionType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "SearchWebSearchAction", + "type": "object" + }, + { + "properties": { + "type": { + "enum": [ + "openPage" + ], + "title": "OpenPageWebSearchActionType", + "type": "string" + }, + "url": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "type" + ], + "title": "OpenPageWebSearchAction", + "type": "object" + }, + { + "properties": { + "pattern": { + "type": [ + "string", + "null" + ] + }, + "type": { + "enum": [ + "findInPage" + ], + "title": "FindInPageWebSearchActionType", + "type": "string" + }, + "url": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "type" + ], + "title": "FindInPageWebSearchAction", + "type": "object" + }, + { + "properties": { + "type": { + "enum": [ + "other" + ], + "title": "OtherWebSearchActionType", + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "OtherWebSearchAction", + "type": "object" + } + ] + } + }, + "properties": { + "snapshot": { + "$ref": "#/definitions/ReviewStorySnapshot" + }, + "storySnapshotId": { + "type": "string" + }, + "turn": { + "$ref": "#/definitions/Turn" + } + }, + "required": [ + "snapshot", + "storySnapshotId", + "turn" + ], + "title": "ReviewStoryStartResponse", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts index 86ba2cd171..f8eed8949c 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts @@ -55,6 +55,9 @@ import type { PluginShareUpdateTargetsParams } from "./v2/PluginShareUpdateTarge import type { PluginSkillReadParams } from "./v2/PluginSkillReadParams"; import type { PluginUninstallParams } from "./v2/PluginUninstallParams"; import type { ReviewStartParams } from "./v2/ReviewStartParams"; +import type { ReviewStoryListParams } from "./v2/ReviewStoryListParams"; +import type { ReviewStoryReadParams } from "./v2/ReviewStoryReadParams"; +import type { ReviewStoryStartParams } from "./v2/ReviewStoryStartParams"; import type { SendAddCreditsNudgeEmailParams } from "./v2/SendAddCreditsNudgeEmailParams"; import type { SkillsConfigWriteParams } from "./v2/SkillsConfigWriteParams"; import type { SkillsListParams } from "./v2/SkillsListParams"; @@ -85,4 +88,4 @@ import type { WindowsSandboxSetupStartParams } from "./v2/WindowsSandboxSetupSta /** * Request from the client to the server. */ -export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/goal/set", id: RequestId, params: ThreadGoalSetParams, } | { "method": "thread/goal/get", id: RequestId, params: ThreadGoalGetParams, } | { "method": "thread/goal/clear", id: RequestId, params: ThreadGoalClearParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/approveGuardianDeniedAction", id: RequestId, params: ThreadApproveGuardianDeniedActionParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "thread/inject_items", id: RequestId, params: ThreadInjectItemsParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "hooks/list", id: RequestId, params: HooksListParams, } | { "method": "marketplace/add", id: RequestId, params: MarketplaceAddParams, } | { "method": "marketplace/remove", id: RequestId, params: MarketplaceRemoveParams, } | { "method": "marketplace/upgrade", id: RequestId, params: MarketplaceUpgradeParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/installed", id: RequestId, params: PluginInstalledParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "plugin/skill/read", id: RequestId, params: PluginSkillReadParams, } | { "method": "plugin/share/save", id: RequestId, params: PluginShareSaveParams, } | { "method": "plugin/share/updateTargets", id: RequestId, params: PluginShareUpdateTargetsParams, } | { "method": "plugin/share/list", id: RequestId, params: PluginShareListParams, } | { "method": "plugin/share/checkout", id: RequestId, params: PluginShareCheckoutParams, } | { "method": "plugin/share/delete", id: RequestId, params: PluginShareDeleteParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "modelProvider/capabilities/read", id: RequestId, params: ModelProviderCapabilitiesReadParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "permissionProfile/list", id: RequestId, params: PermissionProfileListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "windowsSandbox/readiness", id: RequestId, params: undefined, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "account/sendAddCreditsNudgeEmail", id: RequestId, params: SendAddCreditsNudgeEmailParams, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, }; +export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/goal/set", id: RequestId, params: ThreadGoalSetParams, } | { "method": "thread/goal/get", id: RequestId, params: ThreadGoalGetParams, } | { "method": "thread/goal/clear", id: RequestId, params: ThreadGoalClearParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/approveGuardianDeniedAction", id: RequestId, params: ThreadApproveGuardianDeniedActionParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "thread/inject_items", id: RequestId, params: ThreadInjectItemsParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "hooks/list", id: RequestId, params: HooksListParams, } | { "method": "marketplace/add", id: RequestId, params: MarketplaceAddParams, } | { "method": "marketplace/remove", id: RequestId, params: MarketplaceRemoveParams, } | { "method": "marketplace/upgrade", id: RequestId, params: MarketplaceUpgradeParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/installed", id: RequestId, params: PluginInstalledParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "plugin/skill/read", id: RequestId, params: PluginSkillReadParams, } | { "method": "plugin/share/save", id: RequestId, params: PluginShareSaveParams, } | { "method": "plugin/share/updateTargets", id: RequestId, params: PluginShareUpdateTargetsParams, } | { "method": "plugin/share/list", id: RequestId, params: PluginShareListParams, } | { "method": "plugin/share/checkout", id: RequestId, params: PluginShareCheckoutParams, } | { "method": "plugin/share/delete", id: RequestId, params: PluginShareDeleteParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "reviewStory/start", id: RequestId, params: ReviewStoryStartParams, } | { "method": "reviewStory/read", id: RequestId, params: ReviewStoryReadParams, } | { "method": "reviewStory/list", id: RequestId, params: ReviewStoryListParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "modelProvider/capabilities/read", id: RequestId, params: ModelProviderCapabilitiesReadParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "permissionProfile/list", id: RequestId, params: PermissionProfileListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "windowsSandbox/readiness", id: RequestId, params: undefined, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "account/sendAddCreditsNudgeEmail", id: RequestId, params: SendAddCreditsNudgeEmailParams, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts b/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts index 3ed710efc0..f934287252 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts @@ -38,6 +38,7 @@ import type { ReasoningSummaryPartAddedNotification } from "./v2/ReasoningSummar import type { ReasoningSummaryTextDeltaNotification } from "./v2/ReasoningSummaryTextDeltaNotification"; import type { ReasoningTextDeltaNotification } from "./v2/ReasoningTextDeltaNotification"; import type { RemoteControlStatusChangedNotification } from "./v2/RemoteControlStatusChangedNotification"; +import type { ReviewStorySnapshotUpdatedNotification } from "./v2/ReviewStorySnapshotUpdatedNotification"; import type { ServerRequestResolvedNotification } from "./v2/ServerRequestResolvedNotification"; import type { SkillsChangedNotification } from "./v2/SkillsChangedNotification"; import type { TerminalInteractionNotification } from "./v2/TerminalInteractionNotification"; @@ -70,4 +71,4 @@ import type { WindowsWorldWritableWarningNotification } from "./v2/WindowsWorldW /** * Notification sent from the server to the client. */ -export type ServerNotification = { "method": "error", "params": ErrorNotification } | { "method": "thread/started", "params": ThreadStartedNotification } | { "method": "thread/status/changed", "params": ThreadStatusChangedNotification } | { "method": "thread/archived", "params": ThreadArchivedNotification } | { "method": "thread/unarchived", "params": ThreadUnarchivedNotification } | { "method": "thread/closed", "params": ThreadClosedNotification } | { "method": "skills/changed", "params": SkillsChangedNotification } | { "method": "thread/name/updated", "params": ThreadNameUpdatedNotification } | { "method": "thread/goal/updated", "params": ThreadGoalUpdatedNotification } | { "method": "thread/goal/cleared", "params": ThreadGoalClearedNotification } | { "method": "thread/settings/updated", "params": ThreadSettingsUpdatedNotification } | { "method": "thread/tokenUsage/updated", "params": ThreadTokenUsageUpdatedNotification } | { "method": "turn/started", "params": TurnStartedNotification } | { "method": "hook/started", "params": HookStartedNotification } | { "method": "turn/completed", "params": TurnCompletedNotification } | { "method": "hook/completed", "params": HookCompletedNotification } | { "method": "turn/diff/updated", "params": TurnDiffUpdatedNotification } | { "method": "turn/plan/updated", "params": TurnPlanUpdatedNotification } | { "method": "item/started", "params": ItemStartedNotification } | { "method": "item/autoApprovalReview/started", "params": ItemGuardianApprovalReviewStartedNotification } | { "method": "item/autoApprovalReview/completed", "params": ItemGuardianApprovalReviewCompletedNotification } | { "method": "item/completed", "params": ItemCompletedNotification } | { "method": "rawResponseItem/completed", "params": RawResponseItemCompletedNotification } | { "method": "item/agentMessage/delta", "params": AgentMessageDeltaNotification } | { "method": "item/plan/delta", "params": PlanDeltaNotification } | { "method": "command/exec/outputDelta", "params": CommandExecOutputDeltaNotification } | { "method": "process/outputDelta", "params": ProcessOutputDeltaNotification } | { "method": "process/exited", "params": ProcessExitedNotification } | { "method": "item/commandExecution/outputDelta", "params": CommandExecutionOutputDeltaNotification } | { "method": "item/commandExecution/terminalInteraction", "params": TerminalInteractionNotification } | { "method": "item/fileChange/outputDelta", "params": FileChangeOutputDeltaNotification } | { "method": "item/fileChange/patchUpdated", "params": FileChangePatchUpdatedNotification } | { "method": "serverRequest/resolved", "params": ServerRequestResolvedNotification } | { "method": "item/mcpToolCall/progress", "params": McpToolCallProgressNotification } | { "method": "mcpServer/oauthLogin/completed", "params": McpServerOauthLoginCompletedNotification } | { "method": "mcpServer/startupStatus/updated", "params": McpServerStatusUpdatedNotification } | { "method": "account/updated", "params": AccountUpdatedNotification } | { "method": "account/rateLimits/updated", "params": AccountRateLimitsUpdatedNotification } | { "method": "app/list/updated", "params": AppListUpdatedNotification } | { "method": "remoteControl/status/changed", "params": RemoteControlStatusChangedNotification } | { "method": "externalAgentConfig/import/completed", "params": ExternalAgentConfigImportCompletedNotification } | { "method": "fs/changed", "params": FsChangedNotification } | { "method": "item/reasoning/summaryTextDelta", "params": ReasoningSummaryTextDeltaNotification } | { "method": "item/reasoning/summaryPartAdded", "params": ReasoningSummaryPartAddedNotification } | { "method": "item/reasoning/textDelta", "params": ReasoningTextDeltaNotification } | { "method": "thread/compacted", "params": ContextCompactedNotification } | { "method": "model/rerouted", "params": ModelReroutedNotification } | { "method": "model/verification", "params": ModelVerificationNotification } | { "method": "warning", "params": WarningNotification } | { "method": "guardianWarning", "params": GuardianWarningNotification } | { "method": "deprecationNotice", "params": DeprecationNoticeNotification } | { "method": "configWarning", "params": ConfigWarningNotification } | { "method": "fuzzyFileSearch/sessionUpdated", "params": FuzzyFileSearchSessionUpdatedNotification } | { "method": "fuzzyFileSearch/sessionCompleted", "params": FuzzyFileSearchSessionCompletedNotification } | { "method": "thread/realtime/started", "params": ThreadRealtimeStartedNotification } | { "method": "thread/realtime/itemAdded", "params": ThreadRealtimeItemAddedNotification } | { "method": "thread/realtime/transcript/delta", "params": ThreadRealtimeTranscriptDeltaNotification } | { "method": "thread/realtime/transcript/done", "params": ThreadRealtimeTranscriptDoneNotification } | { "method": "thread/realtime/outputAudio/delta", "params": ThreadRealtimeOutputAudioDeltaNotification } | { "method": "thread/realtime/sdp", "params": ThreadRealtimeSdpNotification } | { "method": "thread/realtime/error", "params": ThreadRealtimeErrorNotification } | { "method": "thread/realtime/closed", "params": ThreadRealtimeClosedNotification } | { "method": "windows/worldWritableWarning", "params": WindowsWorldWritableWarningNotification } | { "method": "windowsSandbox/setupCompleted", "params": WindowsSandboxSetupCompletedNotification } | { "method": "account/login/completed", "params": AccountLoginCompletedNotification }; +export type ServerNotification = { "method": "error", "params": ErrorNotification } | { "method": "thread/started", "params": ThreadStartedNotification } | { "method": "thread/status/changed", "params": ThreadStatusChangedNotification } | { "method": "thread/archived", "params": ThreadArchivedNotification } | { "method": "thread/unarchived", "params": ThreadUnarchivedNotification } | { "method": "thread/closed", "params": ThreadClosedNotification } | { "method": "skills/changed", "params": SkillsChangedNotification } | { "method": "thread/name/updated", "params": ThreadNameUpdatedNotification } | { "method": "thread/goal/updated", "params": ThreadGoalUpdatedNotification } | { "method": "thread/goal/cleared", "params": ThreadGoalClearedNotification } | { "method": "thread/settings/updated", "params": ThreadSettingsUpdatedNotification } | { "method": "thread/tokenUsage/updated", "params": ThreadTokenUsageUpdatedNotification } | { "method": "turn/started", "params": TurnStartedNotification } | { "method": "hook/started", "params": HookStartedNotification } | { "method": "turn/completed", "params": TurnCompletedNotification } | { "method": "reviewStory/snapshot/updated", "params": ReviewStorySnapshotUpdatedNotification } | { "method": "hook/completed", "params": HookCompletedNotification } | { "method": "turn/diff/updated", "params": TurnDiffUpdatedNotification } | { "method": "turn/plan/updated", "params": TurnPlanUpdatedNotification } | { "method": "item/started", "params": ItemStartedNotification } | { "method": "item/autoApprovalReview/started", "params": ItemGuardianApprovalReviewStartedNotification } | { "method": "item/autoApprovalReview/completed", "params": ItemGuardianApprovalReviewCompletedNotification } | { "method": "item/completed", "params": ItemCompletedNotification } | { "method": "rawResponseItem/completed", "params": RawResponseItemCompletedNotification } | { "method": "item/agentMessage/delta", "params": AgentMessageDeltaNotification } | { "method": "item/plan/delta", "params": PlanDeltaNotification } | { "method": "command/exec/outputDelta", "params": CommandExecOutputDeltaNotification } | { "method": "process/outputDelta", "params": ProcessOutputDeltaNotification } | { "method": "process/exited", "params": ProcessExitedNotification } | { "method": "item/commandExecution/outputDelta", "params": CommandExecutionOutputDeltaNotification } | { "method": "item/commandExecution/terminalInteraction", "params": TerminalInteractionNotification } | { "method": "item/fileChange/outputDelta", "params": FileChangeOutputDeltaNotification } | { "method": "item/fileChange/patchUpdated", "params": FileChangePatchUpdatedNotification } | { "method": "serverRequest/resolved", "params": ServerRequestResolvedNotification } | { "method": "item/mcpToolCall/progress", "params": McpToolCallProgressNotification } | { "method": "mcpServer/oauthLogin/completed", "params": McpServerOauthLoginCompletedNotification } | { "method": "mcpServer/startupStatus/updated", "params": McpServerStatusUpdatedNotification } | { "method": "account/updated", "params": AccountUpdatedNotification } | { "method": "account/rateLimits/updated", "params": AccountRateLimitsUpdatedNotification } | { "method": "app/list/updated", "params": AppListUpdatedNotification } | { "method": "remoteControl/status/changed", "params": RemoteControlStatusChangedNotification } | { "method": "externalAgentConfig/import/completed", "params": ExternalAgentConfigImportCompletedNotification } | { "method": "fs/changed", "params": FsChangedNotification } | { "method": "item/reasoning/summaryTextDelta", "params": ReasoningSummaryTextDeltaNotification } | { "method": "item/reasoning/summaryPartAdded", "params": ReasoningSummaryPartAddedNotification } | { "method": "item/reasoning/textDelta", "params": ReasoningTextDeltaNotification } | { "method": "thread/compacted", "params": ContextCompactedNotification } | { "method": "model/rerouted", "params": ModelReroutedNotification } | { "method": "model/verification", "params": ModelVerificationNotification } | { "method": "warning", "params": WarningNotification } | { "method": "guardianWarning", "params": GuardianWarningNotification } | { "method": "deprecationNotice", "params": DeprecationNoticeNotification } | { "method": "configWarning", "params": ConfigWarningNotification } | { "method": "fuzzyFileSearch/sessionUpdated", "params": FuzzyFileSearchSessionUpdatedNotification } | { "method": "fuzzyFileSearch/sessionCompleted", "params": FuzzyFileSearchSessionCompletedNotification } | { "method": "thread/realtime/started", "params": ThreadRealtimeStartedNotification } | { "method": "thread/realtime/itemAdded", "params": ThreadRealtimeItemAddedNotification } | { "method": "thread/realtime/transcript/delta", "params": ThreadRealtimeTranscriptDeltaNotification } | { "method": "thread/realtime/transcript/done", "params": ThreadRealtimeTranscriptDoneNotification } | { "method": "thread/realtime/outputAudio/delta", "params": ThreadRealtimeOutputAudioDeltaNotification } | { "method": "thread/realtime/sdp", "params": ThreadRealtimeSdpNotification } | { "method": "thread/realtime/error", "params": ThreadRealtimeErrorNotification } | { "method": "thread/realtime/closed", "params": ThreadRealtimeClosedNotification } | { "method": "windows/worldWritableWarning", "params": WindowsWorldWritableWarningNotification } | { "method": "windowsSandbox/setupCompleted", "params": WindowsSandboxSetupCompletedNotification } | { "method": "account/login/completed", "params": AccountLoginCompletedNotification }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchor.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchor.ts new file mode 100644 index 0000000000..47bcd42223 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchor.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStoryAnchorKind } from "./ReviewStoryAnchorKind"; + +export type ReviewStoryAnchor = { anchorId: string, filePath: string, changeKind: ReviewStoryAnchorKind, summary: string, diff: string, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchorKind.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchorKind.ts new file mode 100644 index 0000000000..a969c090ec --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryAnchorKind.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ReviewStoryAnchorKind = "added" | "modified" | "deleted" | "renamed" | "copied" | "unknown"; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListParams.ts new file mode 100644 index 0000000000..115e6c6bb0 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListParams.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ReviewStoryListParams = { threadId: string, cursor?: string | null, limit?: number | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListResponse.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListResponse.ts new file mode 100644 index 0000000000..c1e0dc935f --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryListResponse.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStorySnapshotSummary } from "./ReviewStorySnapshotSummary"; + +export type ReviewStoryListResponse = { data: Array, nextCursor: string | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadParams.ts new file mode 100644 index 0000000000..75b545e144 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadParams.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ReviewStoryReadParams = { threadId: string, storySnapshotId: string, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadResponse.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadResponse.ts new file mode 100644 index 0000000000..f704306610 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryReadResponse.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStorySnapshot } from "./ReviewStorySnapshot"; + +export type ReviewStoryReadResponse = { snapshot: ReviewStorySnapshot | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshot.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshot.ts new file mode 100644 index 0000000000..9f5b5d2a6e --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshot.ts @@ -0,0 +1,9 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStoryAnchor } from "./ReviewStoryAnchor"; +import type { ReviewStorySnapshotStatus } from "./ReviewStorySnapshotStatus"; +import type { ReviewStoryStep } from "./ReviewStoryStep"; +import type { ReviewTarget } from "./ReviewTarget"; + +export type ReviewStorySnapshot = { storySnapshotId: string, threadId: string, title: string, overview: string, target: ReviewTarget, sourceFingerprint: string, status: ReviewStorySnapshotStatus, createdAt: bigint, updatedAt: bigint, previousStorySnapshotId: string | null, stale: boolean, steps: Array, anchors: Array, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotStatus.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotStatus.ts new file mode 100644 index 0000000000..8aa4ae7d38 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotStatus.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ReviewStorySnapshotStatus = "building" | "ready" | "partial" | "failed"; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotSummary.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotSummary.ts new file mode 100644 index 0000000000..7770dd0ea8 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotSummary.ts @@ -0,0 +1,7 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStorySnapshotStatus } from "./ReviewStorySnapshotStatus"; +import type { ReviewTarget } from "./ReviewTarget"; + +export type ReviewStorySnapshotSummary = { storySnapshotId: string, threadId: string, title: string, target: ReviewTarget, sourceFingerprint: string, status: ReviewStorySnapshotStatus, createdAt: bigint, updatedAt: bigint, previousStorySnapshotId: string | null, stepCount: number, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotUpdatedNotification.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotUpdatedNotification.ts new file mode 100644 index 0000000000..1da349b76f --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStorySnapshotUpdatedNotification.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStorySnapshot } from "./ReviewStorySnapshot"; + +export type ReviewStorySnapshotUpdatedNotification = { threadId: string, snapshot: ReviewStorySnapshot, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartParams.ts new file mode 100644 index 0000000000..9b4aa47799 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartParams.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewTarget } from "./ReviewTarget"; + +export type ReviewStoryStartParams = { threadId: string, target: ReviewTarget, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartResponse.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartResponse.ts new file mode 100644 index 0000000000..7056f23a42 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStartResponse.ts @@ -0,0 +1,7 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStorySnapshot } from "./ReviewStorySnapshot"; +import type { Turn } from "./Turn"; + +export type ReviewStoryStartResponse = { turn: Turn, storySnapshotId: string, snapshot: ReviewStorySnapshot, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStep.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStep.ts new file mode 100644 index 0000000000..be7ab0658c --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStep.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReviewStoryStepReadiness } from "./ReviewStoryStepReadiness"; + +export type ReviewStoryStep = { stepId: string, index: number, title: string, goal: string, summary: string, dependencyRationale: string, anchorIds: Array, reviewFocus: Array, readiness: ReviewStoryStepReadiness, error: string | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStepReadiness.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStepReadiness.ts new file mode 100644 index 0000000000..3fc54f6312 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ReviewStoryStepReadiness.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ReviewStoryStepReadiness = "outline" | "enriching" | "ready" | "failed"; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts index 5b4f2ed283..8d9053a259 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -323,6 +323,20 @@ export type { ResidencyRequirement } from "./ResidencyRequirement"; export type { ReviewDelivery } from "./ReviewDelivery"; export type { ReviewStartParams } from "./ReviewStartParams"; export type { ReviewStartResponse } from "./ReviewStartResponse"; +export type { ReviewStoryAnchor } from "./ReviewStoryAnchor"; +export type { ReviewStoryAnchorKind } from "./ReviewStoryAnchorKind"; +export type { ReviewStoryListParams } from "./ReviewStoryListParams"; +export type { ReviewStoryListResponse } from "./ReviewStoryListResponse"; +export type { ReviewStoryReadParams } from "./ReviewStoryReadParams"; +export type { ReviewStoryReadResponse } from "./ReviewStoryReadResponse"; +export type { ReviewStorySnapshot } from "./ReviewStorySnapshot"; +export type { ReviewStorySnapshotStatus } from "./ReviewStorySnapshotStatus"; +export type { ReviewStorySnapshotSummary } from "./ReviewStorySnapshotSummary"; +export type { ReviewStorySnapshotUpdatedNotification } from "./ReviewStorySnapshotUpdatedNotification"; +export type { ReviewStoryStartParams } from "./ReviewStoryStartParams"; +export type { ReviewStoryStartResponse } from "./ReviewStoryStartResponse"; +export type { ReviewStoryStep } from "./ReviewStoryStep"; +export type { ReviewStoryStepReadiness } from "./ReviewStoryStepReadiness"; export type { ReviewTarget } from "./ReviewTarget"; export type { SandboxMode } from "./SandboxMode"; export type { SandboxPolicy } from "./SandboxPolicy"; diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs index a8bec6b402..d1f04a3dae 100644 --- a/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/codex-rs/app-server-protocol/src/protocol/common.rs @@ -794,6 +794,21 @@ client_request_definitions! { serialization: thread_id(params.thread_id), response: v2::ReviewStartResponse, }, + ReviewStoryStart => "reviewStory/start" { + params: v2::ReviewStoryStartParams, + serialization: thread_id(params.thread_id), + response: v2::ReviewStoryStartResponse, + }, + ReviewStoryRead => "reviewStory/read" { + params: v2::ReviewStoryReadParams, + serialization: thread_id(params.thread_id), + response: v2::ReviewStoryReadResponse, + }, + ReviewStoryList => "reviewStory/list" { + params: v2::ReviewStoryListParams, + serialization: thread_id(params.thread_id), + response: v2::ReviewStoryListResponse, + }, ModelList => "model/list" { params: v2::ModelListParams, @@ -1484,6 +1499,7 @@ server_notification_definitions! { TurnStarted => "turn/started" (v2::TurnStartedNotification), HookStarted => "hook/started" (v2::HookStartedNotification), TurnCompleted => "turn/completed" (v2::TurnCompletedNotification), + ReviewStorySnapshotUpdated => "reviewStory/snapshot/updated" (v2::ReviewStorySnapshotUpdatedNotification), HookCompleted => "hook/completed" (v2::HookCompletedNotification), TurnDiffUpdated => "turn/diff/updated" (v2::TurnDiffUpdatedNotification), TurnPlanUpdated => "turn/plan/updated" (v2::TurnPlanUpdatedNotification), diff --git a/codex-rs/app-server-protocol/src/protocol/v2/mod.rs b/codex-rs/app-server-protocol/src/protocol/v2/mod.rs index b5fa9fdc65..3fbfb9e446 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2/mod.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2/mod.rs @@ -21,6 +21,7 @@ mod process; mod realtime; mod remote_control; mod review; +mod review_story; mod thread; mod thread_data; mod turn; @@ -47,6 +48,7 @@ pub use process::*; pub use realtime::*; pub use remote_control::*; pub use review::*; +pub use review_story::*; pub use shared::*; pub use thread::*; pub use thread_data::*; diff --git a/codex-rs/app-server-protocol/src/protocol/v2/review_story.rs b/codex-rs/app-server-protocol/src/protocol/v2/review_story.rs new file mode 100644 index 0000000000..f263ef4c42 --- /dev/null +++ b/codex-rs/app-server-protocol/src/protocol/v2/review_story.rs @@ -0,0 +1,161 @@ +use super::ReviewTarget; +use super::Turn; +use schemars::JsonSchema; +use serde::Deserialize; +use serde::Serialize; +use ts_rs::TS; + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryStartParams { + pub thread_id: String, + pub target: ReviewTarget, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryStartResponse { + pub turn: Turn, + pub story_snapshot_id: String, + pub snapshot: ReviewStorySnapshot, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryReadParams { + pub thread_id: String, + pub story_snapshot_id: String, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryReadResponse { + pub snapshot: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryListParams { + pub thread_id: String, + + #[ts(optional = nullable)] + pub cursor: Option, + + #[ts(optional = nullable)] + pub limit: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryListResponse { + pub data: Vec, + pub next_cursor: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStorySnapshotUpdatedNotification { + pub thread_id: String, + pub snapshot: ReviewStorySnapshot, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStorySnapshotSummary { + pub story_snapshot_id: String, + pub thread_id: String, + pub title: String, + pub target: ReviewTarget, + pub source_fingerprint: String, + pub status: ReviewStorySnapshotStatus, + pub created_at: i64, + pub updated_at: i64, + pub previous_story_snapshot_id: Option, + pub step_count: u32, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStorySnapshot { + pub story_snapshot_id: String, + pub thread_id: String, + pub title: String, + pub overview: String, + pub target: ReviewTarget, + pub source_fingerprint: String, + pub status: ReviewStorySnapshotStatus, + pub created_at: i64, + pub updated_at: i64, + pub previous_story_snapshot_id: Option, + pub stale: bool, + pub steps: Vec, + pub anchors: Vec, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum ReviewStorySnapshotStatus { + Building, + Ready, + Partial, + Failed, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryStep { + pub step_id: String, + pub index: u32, + pub title: String, + pub goal: String, + pub summary: String, + pub dependency_rationale: String, + pub anchor_ids: Vec, + pub review_focus: Vec, + pub readiness: ReviewStoryStepReadiness, + pub error: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum ReviewStoryStepReadiness { + Outline, + Enriching, + Ready, + Failed, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ReviewStoryAnchor { + pub anchor_id: String, + pub file_path: String, + pub change_kind: ReviewStoryAnchorKind, + pub summary: String, + pub diff: String, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum ReviewStoryAnchorKind { + Added, + Modified, + Deleted, + Renamed, + Copied, + Unknown, +} diff --git a/codex-rs/app-server/Cargo.toml b/codex-rs/app-server/Cargo.toml index 95baac4e9e..fdba32aa06 100644 --- a/codex-rs/app-server/Cargo.toml +++ b/codex-rs/app-server/Cargo.toml @@ -76,6 +76,7 @@ clap = { workspace = true, features = ["derive"] } futures = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } +sha2 = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } time = { workspace = true } diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md index dcc2953073..9e711193d8 100644 --- a/codex-rs/app-server/README.md +++ b/codex-rs/app-server/README.md @@ -167,6 +167,7 @@ Example with notification opt-out: - `thread/realtime/appendText` — append text input to the active realtime session (experimental); returns `{}`. - `thread/realtime/stop` — stop the active realtime session for the thread (experimental); returns `{}`. - `review/start` — kick off Codex’s automated reviewer for a thread; responds like `turn/start` and emits `item/started`/`item/completed` notifications with `enteredReviewMode` and `exitedReviewMode` items, plus a final assistant `agentMessage` containing the review. +- `reviewStory/start` — build a persisted, read-only review story for a concrete source (`uncommittedChanges`, `baseBranch`, or `commit`). Codex collects stable change anchors from the diff, asks a constrained model task to group those anchors into cohesive story steps, validates that every model-referenced anchor exists, and falls back to file-level steps if model generation is unavailable. The response includes the initial `storySnapshot`, and the server emits `reviewStory/snapshot/updated` whenever a snapshot is written. Use `reviewStory/read` to fetch a snapshot by id and `reviewStory/list` to page saved stories for a thread. - `command/exec` — run a single command under the server sandbox without starting a thread/turn (handy for utilities and validation). - `command/exec/write` — write base64-decoded stdin bytes to a running `command/exec` session or close stdin; returns `{}`. - `command/exec/resize` — resize a running PTY-backed `command/exec` session by `processId`; returns `{}`. diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rs index 0e1f019de9..c5dc70e4c0 100644 --- a/codex-rs/app-server/src/message_processor.rs +++ b/codex-rs/app-server/src/message_processor.rs @@ -31,6 +31,7 @@ use crate::request_processors::McpRequestProcessor; use crate::request_processors::PluginRequestProcessor; use crate::request_processors::ProcessExecRequestProcessor; use crate::request_processors::RemoteControlRequestProcessor; +use crate::request_processors::ReviewStoryRequestProcessor; use crate::request_processors::SearchRequestProcessor; use crate::request_processors::ThreadGoalRequestProcessor; use crate::request_processors::ThreadRequestProcessor; @@ -177,6 +178,7 @@ pub(crate) struct MessageProcessor { mcp_processor: McpRequestProcessor, plugin_processor: PluginRequestProcessor, remote_control_processor: RemoteControlRequestProcessor, + review_story_processor: ReviewStoryRequestProcessor, search_processor: SearchRequestProcessor, thread_goal_processor: ThreadGoalRequestProcessor, thread_processor: ThreadRequestProcessor, @@ -402,6 +404,11 @@ impl MessageProcessor { workspace_settings_cache, ); let remote_control_processor = RemoteControlRequestProcessor::new(remote_control_handle); + let review_story_processor = ReviewStoryRequestProcessor::new( + Arc::clone(&thread_manager), + outgoing.clone(), + state_db.clone(), + ); let search_processor = SearchRequestProcessor::new(outgoing.clone()); let thread_goal_processor = ThreadGoalRequestProcessor::new( Arc::clone(&thread_manager), @@ -498,6 +505,7 @@ impl MessageProcessor { mcp_processor, plugin_processor, remote_control_processor, + review_story_processor, search_processor, thread_goal_processor, thread_processor, @@ -1222,6 +1230,15 @@ impl MessageProcessor { ClientRequest::ReviewStart { params, .. } => { self.turn_processor.review_start(&request_id, params).await } + ClientRequest::ReviewStoryStart { params, .. } => { + self.review_story_processor.start(&request_id, params).await + } + ClientRequest::ReviewStoryRead { params, .. } => { + self.review_story_processor.read(params).await + } + ClientRequest::ReviewStoryList { params, .. } => { + self.review_story_processor.list(params).await + } ClientRequest::McpServerOauthLogin { params, .. } => { self.mcp_processor.mcp_server_oauth_login(params).await } diff --git a/codex-rs/app-server/src/request_processors.rs b/codex-rs/app-server/src/request_processors.rs index d0958e80ab..777d677e57 100644 --- a/codex-rs/app-server/src/request_processors.rs +++ b/codex-rs/app-server/src/request_processors.rs @@ -466,6 +466,7 @@ mod mcp_processor; mod plugins; mod process_exec_processor; mod remote_control_processor; +mod review_story_processor; mod search; mod thread_processor; mod token_usage_replay; @@ -488,6 +489,7 @@ pub(crate) use mcp_processor::McpRequestProcessor; pub(crate) use plugins::PluginRequestProcessor; pub(crate) use process_exec_processor::ProcessExecRequestProcessor; pub(crate) use remote_control_processor::RemoteControlRequestProcessor; +pub(crate) use review_story_processor::ReviewStoryRequestProcessor; pub(crate) use search::SearchRequestProcessor; pub(crate) use thread_goal_processor::ThreadGoalRequestProcessor; pub(crate) use thread_processor::ThreadRequestProcessor; diff --git a/codex-rs/app-server/src/request_processors/review_story_processor.rs b/codex-rs/app-server/src/request_processors/review_story_processor.rs new file mode 100644 index 0000000000..d77fb0dc14 --- /dev/null +++ b/codex-rs/app-server/src/request_processors/review_story_processor.rs @@ -0,0 +1,1023 @@ +use std::path::Path; +use std::sync::Arc; + +use codex_app_server_protocol::ClientResponsePayload; +use codex_app_server_protocol::ReviewStoryAnchor; +use codex_app_server_protocol::ReviewStoryAnchorKind; +use codex_app_server_protocol::ReviewStoryListParams; +use codex_app_server_protocol::ReviewStoryListResponse; +use codex_app_server_protocol::ReviewStoryReadParams; +use codex_app_server_protocol::ReviewStoryReadResponse; +use codex_app_server_protocol::ReviewStorySnapshot; +use codex_app_server_protocol::ReviewStorySnapshotStatus; +use codex_app_server_protocol::ReviewStorySnapshotSummary; +use codex_app_server_protocol::ReviewStorySnapshotUpdatedNotification; +use codex_app_server_protocol::ReviewStoryStartParams; +use codex_app_server_protocol::ReviewStoryStartResponse; +use codex_app_server_protocol::ReviewStoryStep; +use codex_app_server_protocol::ReviewStoryStepReadiness; +use codex_app_server_protocol::ReviewTarget; +use codex_app_server_protocol::ServerNotification; +use codex_app_server_protocol::ThreadItem; +use codex_app_server_protocol::Turn; +use codex_app_server_protocol::TurnItemsView; +use codex_app_server_protocol::TurnStatus; +use codex_app_server_protocol::UserInput as V2UserInput; +use codex_core::ThreadManager; +use codex_protocol::ThreadId; +use codex_protocol::protocol::SubAgentSource; +use codex_rollout::state_db::StateDbHandle; +use codex_state::ReviewStoryRecord; +use codex_state::ReviewStorySummaryRecord; +use serde::Deserialize; +use serde_json::json; +use sha2::Digest; +use sha2::Sha256; +use std::collections::HashMap; +use std::collections::HashSet; +use tokio::process::Command; +use uuid::Uuid; + +use crate::error_code::internal_error; +use crate::error_code::invalid_request; +use crate::outgoing_message::ConnectionRequestId; +use crate::outgoing_message::OutgoingMessageSender; + +#[derive(Clone)] +pub(crate) struct ReviewStoryRequestProcessor { + thread_manager: Arc, + outgoing: Arc, + state_db: Option, +} + +impl ReviewStoryRequestProcessor { + pub(crate) fn new( + thread_manager: Arc, + outgoing: Arc, + state_db: Option, + ) -> Self { + Self { + thread_manager, + outgoing, + state_db, + } + } + + pub(crate) async fn start( + &self, + _request_id: &ConnectionRequestId, + params: ReviewStoryStartParams, + ) -> Result, codex_app_server_protocol::JSONRPCErrorError> { + let ReviewStoryStartParams { thread_id, target } = params; + let (thread_uuid, thread) = self.load_thread(&thread_id).await?; + let state_db = self.require_state_db()?; + let cwd = thread.config_snapshot().await.cwd; + let evidence = collect_evidence(cwd.as_path(), &target).await?; + let model_story = generate_model_story(&thread, &target, &evidence).await; + let story_snapshot_id = Uuid::now_v7().to_string(); + let now = chrono::Utc::now().timestamp(); + let snapshot = build_snapshot( + story_snapshot_id.clone(), + thread_id.clone(), + target, + evidence, + model_story, + now, + /*previous_story_snapshot_id*/ None, + ); + let record = snapshot_record(&snapshot)?; + state_db + .review_stories() + .upsert_snapshot(record) + .await + .map_err(|err| internal_error(format!("failed to store review story: {err}")))?; + + self.outgoing + .send_server_notification(ServerNotification::ReviewStorySnapshotUpdated( + ReviewStorySnapshotUpdatedNotification { + thread_id: thread_uuid.to_string(), + snapshot: snapshot.clone(), + }, + )) + .await; + + let turn = build_story_turn( + format!("review-story-{}", snapshot.story_snapshot_id), + "Create a review story for the selected changes.", + ); + Ok(Some( + ReviewStoryStartResponse { + turn, + story_snapshot_id, + snapshot, + } + .into(), + )) + } + + pub(crate) async fn read( + &self, + params: ReviewStoryReadParams, + ) -> Result, codex_app_server_protocol::JSONRPCErrorError> { + let ReviewStoryReadParams { + thread_id, + story_snapshot_id, + } = params; + let thread_id = parse_thread_id(&thread_id)?; + let state_db = self.require_state_db()?; + let record = state_db + .review_stories() + .get_snapshot(thread_id, &story_snapshot_id) + .await + .map_err(|err| internal_error(format!("failed to read review story: {err}")))?; + let snapshot = record + .map(|record| serde_json::from_value(record.snapshot_json)) + .transpose() + .map_err(|err| internal_error(format!("failed to decode review story: {err}")))?; + Ok(Some(ReviewStoryReadResponse { snapshot }.into())) + } + + pub(crate) async fn list( + &self, + params: ReviewStoryListParams, + ) -> Result, codex_app_server_protocol::JSONRPCErrorError> { + let ReviewStoryListParams { + thread_id, + cursor, + limit, + } = params; + let thread_id = parse_thread_id(&thread_id)?; + let state_db = self.require_state_db()?; + let (records, next_cursor) = state_db + .review_stories() + .list_snapshots(thread_id, cursor, limit) + .await + .map_err(|err| internal_error(format!("failed to list review stories: {err}")))?; + let data = records + .into_iter() + .map(summary_from_record) + .collect::, _>>()?; + Ok(Some(ReviewStoryListResponse { data, next_cursor }.into())) + } + + async fn load_thread( + &self, + thread_id: &str, + ) -> Result< + (ThreadId, Arc), + codex_app_server_protocol::JSONRPCErrorError, + > { + let thread_id = parse_thread_id(thread_id)?; + let thread = self + .thread_manager + .get_thread(thread_id) + .await + .map_err(|_| invalid_request(format!("thread not found: {thread_id}")))?; + Ok((thread_id, thread)) + } + + fn require_state_db( + &self, + ) -> Result<&StateDbHandle, codex_app_server_protocol::JSONRPCErrorError> { + self.state_db + .as_ref() + .ok_or_else(|| internal_error("review story storage is unavailable")) + } +} + +struct StoryEvidence { + source_fingerprint: String, + anchors: Vec, +} + +struct ModelStoryResult { + output: Option, + error: Option, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +struct ModelReviewStoryOutput { + title: String, + overview: String, + steps: Vec, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +struct ModelReviewStoryStep { + title: String, + goal: String, + summary: String, + dependency_rationale: String, + anchor_ids: Vec, + review_focus: Vec, +} + +async fn collect_evidence( + cwd: &Path, + target: &ReviewTarget, +) -> Result { + let diff = match target { + ReviewTarget::UncommittedChanges => { + git_output( + cwd, + &["diff", "--no-ext-diff", "--find-renames", "HEAD", "--"], + ) + .await? + } + ReviewTarget::BaseBranch { branch } => { + let range = format!("{branch}...HEAD"); + git_output( + cwd, + &[ + "diff", + "--no-ext-diff", + "--find-renames", + range.as_str(), + "--", + ], + ) + .await? + } + ReviewTarget::Commit { sha, .. } => { + git_output( + cwd, + &[ + "show", + "--format=", + "--no-ext-diff", + "--find-renames", + sha, + "--", + ], + ) + .await? + } + ReviewTarget::Custom { .. } => { + return Err(invalid_request( + "reviewStory/start requires a concrete source: uncommitted changes, base branch, or commit", + )); + } + }; + let source_fingerprint = source_fingerprint(target, &diff)?; + let anchors = anchors_from_diff(&diff); + Ok(StoryEvidence { + source_fingerprint, + anchors, + }) +} + +async fn generate_model_story( + thread: &codex_core::CodexThread, + target: &ReviewTarget, + evidence: &StoryEvidence, +) -> ModelStoryResult { + if evidence.anchors.is_empty() { + return ModelStoryResult { + output: None, + error: None, + }; + } + let prompt = review_story_prompt(target, evidence); + let schema = review_story_output_schema(); + match thread + .run_structured_model_task( + prompt, + REVIEW_STORY_MODEL_INSTRUCTIONS.to_string(), + schema, + SubAgentSource::Other("review_story".to_string()), + ) + .await + { + Ok(Some(output_text)) => match parse_model_review_story_output(&output_text) { + Ok(output) => ModelStoryResult { + output: Some(output), + error: None, + }, + Err(err) => ModelStoryResult { + output: None, + error: Some(format!("model returned an invalid review story: {err}")), + }, + }, + Ok(None) => ModelStoryResult { + output: None, + error: Some("model did not return a review story".to_string()), + }, + Err(err) => ModelStoryResult { + output: None, + error: Some(format!("failed to generate review story: {err}")), + }, + } +} + +const REVIEW_STORY_MODEL_INSTRUCTIONS: &str = r#"You create review stories for code changes. + +Group the supplied change anchors into a small sequence of cohesive logic steps. Each step should help a reviewer understand why the change exists, what changed, and how that step depends on earlier steps. Use only the provided anchor ids. Do not invent files, commits, or anchor ids. Prefer semantic dependency order over file order when the evidence supports it."#; + +fn review_story_prompt(target: &ReviewTarget, evidence: &StoryEvidence) -> String { + let mut prompt = String::new(); + prompt.push_str("Create a dependency-aware review story for these changes.\n\n"); + prompt.push_str("Target:\n"); + prompt.push_str(&target_description(target)); + prompt.push_str("\n\nSource fingerprint:\n"); + prompt.push_str(&evidence.source_fingerprint); + prompt.push_str("\n\nAnchors:\n"); + for anchor in &evidence.anchors { + prompt.push_str("\n---\n"); + prompt.push_str("anchorId: "); + prompt.push_str(&anchor.anchor_id); + prompt.push_str("\nfilePath: "); + prompt.push_str(&anchor.file_path); + prompt.push_str("\nchangeKind: "); + prompt.push_str(anchor_kind_as_str(anchor.change_kind)); + prompt.push_str("\nsummary: "); + prompt.push_str(&anchor.summary); + prompt.push_str("\ndiff:\n"); + prompt.push_str(&truncate_for_prompt( + &anchor.diff, + /*max_chars*/ 12_000, + )); + prompt.push('\n'); + } + prompt.push_str( + "\nReturn JSON only. Every anchor id above should appear in exactly one step unless the diff is empty. Keep steps reviewer-sized and cohesive.", + ); + truncate_for_prompt(&prompt, /*max_chars*/ 120_000) +} + +fn target_description(target: &ReviewTarget) -> String { + match target { + ReviewTarget::UncommittedChanges => "uncommitted changes".to_string(), + ReviewTarget::BaseBranch { branch } => format!("diff from base branch {branch}"), + ReviewTarget::Commit { sha, title } => { + let title = title.as_deref().unwrap_or("untitled commit"); + format!("commit {sha}: {title}") + } + ReviewTarget::Custom { instructions } => { + format!("custom review target: {instructions}") + } + } +} + +fn anchor_kind_as_str(kind: ReviewStoryAnchorKind) -> &'static str { + match kind { + ReviewStoryAnchorKind::Added => "added", + ReviewStoryAnchorKind::Modified => "modified", + ReviewStoryAnchorKind::Deleted => "deleted", + ReviewStoryAnchorKind::Renamed => "renamed", + ReviewStoryAnchorKind::Copied => "copied", + ReviewStoryAnchorKind::Unknown => "unknown", + } +} + +fn truncate_for_prompt(text: &str, max_chars: usize) -> String { + if text.chars().count() <= max_chars { + return text.to_string(); + } + let mut truncated = text.chars().take(max_chars).collect::(); + truncated.push_str("\n[truncated]"); + truncated +} + +fn review_story_output_schema() -> serde_json::Value { + json!({ + "type": "object", + "additionalProperties": false, + "properties": { + "title": { + "type": "string" + }, + "overview": { + "type": "string" + }, + "steps": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "title": { + "type": "string" + }, + "goal": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "dependencyRationale": { + "type": "string" + }, + "anchorIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "reviewFocus": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "title", + "goal", + "summary", + "dependencyRationale", + "anchorIds", + "reviewFocus" + ] + } + } + }, + "required": [ + "title", + "overview", + "steps" + ] + }) +} + +fn parse_model_review_story_output( + text: &str, +) -> Result { + if let Ok(output) = serde_json::from_str::(text) { + return Ok(output); + } + if let (Some(start), Some(end)) = (text.find('{'), text.rfind('}')) + && start < end + && let Some(slice) = text.get(start..=end) + { + return serde_json::from_str::(slice); + } + serde_json::from_str::(text) +} + +async fn git_output( + cwd: &Path, + args: &[&str], +) -> Result { + let output = Command::new("git") + .args(args) + .current_dir(cwd) + .output() + .await + .map_err(|err| internal_error(format!("failed to run git: {err}")))?; + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string(); + return Err(invalid_request(format!("failed to read changes: {stderr}"))); + } + Ok(String::from_utf8_lossy(&output.stdout).into_owned()) +} + +fn source_fingerprint( + target: &ReviewTarget, + diff: &str, +) -> Result { + let mut hasher = Sha256::new(); + let target_json = serde_json::to_vec(target) + .map_err(|err| internal_error(format!("failed to encode review story target: {err}")))?; + hasher.update(target_json); + const FINGERPRINT_SEPARATOR: [u8; 1] = [0]; + hasher.update(FINGERPRINT_SEPARATOR); + hasher.update(diff.as_bytes()); + Ok(format!("sha256:{:x}", hasher.finalize())) +} + +fn anchors_from_diff(diff: &str) -> Vec { + let mut anchors = Vec::new(); + let mut current_header: Option = None; + let mut current_diff = String::new(); + for line in diff.lines() { + if line.starts_with("diff --git ") { + if let Some(header) = current_header.take() { + anchors.push(anchor_from_file_diff(anchors.len(), &header, ¤t_diff)); + current_diff.clear(); + } + current_header = Some(line.to_string()); + } + if current_header.is_some() { + current_diff.push_str(line); + current_diff.push('\n'); + } + } + if let Some(header) = current_header { + anchors.push(anchor_from_file_diff(anchors.len(), &header, ¤t_diff)); + } + anchors +} + +fn anchor_from_file_diff(index: usize, header: &str, diff: &str) -> ReviewStoryAnchor { + let file_path = file_path_from_diff_header(header).unwrap_or_else(|| "unknown".to_string()); + let change_kind = change_kind_from_file_diff(diff); + let summary = match change_kind { + ReviewStoryAnchorKind::Added => format!("Added {file_path}"), + ReviewStoryAnchorKind::Deleted => format!("Deleted {file_path}"), + ReviewStoryAnchorKind::Renamed => format!("Renamed {file_path}"), + ReviewStoryAnchorKind::Copied => format!("Copied {file_path}"), + ReviewStoryAnchorKind::Modified => format!("Modified {file_path}"), + ReviewStoryAnchorKind::Unknown => format!("Changed {file_path}"), + }; + ReviewStoryAnchor { + anchor_id: format!("anchor-{}", index + 1), + file_path, + change_kind, + summary, + diff: diff.to_string(), + } +} + +fn file_path_from_diff_header(header: &str) -> Option { + let mut parts = header.split_whitespace(); + let _diff = parts.next()?; + let _git = parts.next()?; + let _old = parts.next()?; + let new = parts.next()?; + Some(new.strip_prefix("b/").unwrap_or(new).to_string()) +} + +fn change_kind_from_file_diff(diff: &str) -> ReviewStoryAnchorKind { + if diff.contains("\nnew file mode ") { + ReviewStoryAnchorKind::Added + } else if diff.contains("\ndeleted file mode ") { + ReviewStoryAnchorKind::Deleted + } else if diff.contains("\nrename from ") { + ReviewStoryAnchorKind::Renamed + } else if diff.contains("\ncopy from ") { + ReviewStoryAnchorKind::Copied + } else if diff.is_empty() { + ReviewStoryAnchorKind::Unknown + } else { + ReviewStoryAnchorKind::Modified + } +} + +fn build_snapshot( + story_snapshot_id: String, + thread_id: String, + target: ReviewTarget, + evidence: StoryEvidence, + model_story: ModelStoryResult, + created_at: i64, + previous_story_snapshot_id: Option, +) -> ReviewStorySnapshot { + let fallback_title = title_for_target(&target); + let (title, overview, steps, status) = if evidence.anchors.is_empty() { + ( + fallback_title, + "No changes were detected for this review story source.".to_string(), + steps_from_anchors(&evidence.anchors), + ReviewStorySnapshotStatus::Ready, + ) + } else if let Some(output) = model_story.output { + let (steps, validation_error) = steps_from_model_output(output.steps, &evidence.anchors); + let status = if validation_error.is_some() { + ReviewStorySnapshotStatus::Partial + } else { + ReviewStorySnapshotStatus::Ready + }; + let overview = if let Some(error) = validation_error { + format!("{}\n\n{error}", output.overview) + } else { + output.overview + }; + (output.title, overview, steps, status) + } else { + let overview = model_story.error.map_or_else( + || { + format!( + "This story groups {} changed file(s) into review steps based on the local change map.", + evidence.anchors.len() + ) + }, + |error| format!("Model story generation did not complete. Falling back to file-level steps. {error}"), + ); + ( + fallback_title, + overview, + steps_from_anchors(&evidence.anchors), + ReviewStorySnapshotStatus::Partial, + ) + }; + ReviewStorySnapshot { + story_snapshot_id, + thread_id, + title, + overview, + target, + source_fingerprint: evidence.source_fingerprint, + status, + created_at, + updated_at: created_at, + previous_story_snapshot_id, + stale: false, + steps, + anchors: evidence.anchors, + } +} + +fn title_for_target(target: &ReviewTarget) -> String { + match target { + ReviewTarget::UncommittedChanges => "Review story for uncommitted changes".to_string(), + ReviewTarget::BaseBranch { branch } => format!("Review story against {branch}"), + ReviewTarget::Commit { title, sha } => title + .clone() + .unwrap_or_else(|| format!("Review story for commit {sha}")), + ReviewTarget::Custom { .. } => "Review story".to_string(), + } +} + +fn steps_from_anchors(anchors: &[ReviewStoryAnchor]) -> Vec { + if anchors.is_empty() { + return vec![ReviewStoryStep { + step_id: "step-1".to_string(), + index: 1, + title: "No changes".to_string(), + goal: "Confirm that the selected source has no diff to review.".to_string(), + summary: "The source currently produces an empty diff.".to_string(), + dependency_rationale: "There are no file-level dependencies to order.".to_string(), + anchor_ids: Vec::new(), + review_focus: Vec::new(), + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }]; + } + + anchors + .iter() + .enumerate() + .map(|(index, anchor)| ReviewStoryStep { + step_id: format!("step-{}", index + 1), + index: (index + 1) as u32, + title: anchor.summary.clone(), + goal: format!("Understand the purpose of changes in {}.", anchor.file_path), + summary: summarize_anchor(anchor), + dependency_rationale: "Placed according to the file-level evidence order from the diff; enrichment can refine this with semantic dependencies.".to_string(), + anchor_ids: vec![anchor.anchor_id.clone()], + review_focus: vec![format!("Check how {} fits the overall change story.", anchor.file_path)], + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }) + .collect() +} + +fn steps_from_model_output( + model_steps: Vec, + anchors: &[ReviewStoryAnchor], +) -> (Vec, Option) { + let anchors_by_id = anchors + .iter() + .map(|anchor| (anchor.anchor_id.as_str(), anchor)) + .collect::>(); + let mut seen_anchor_ids = HashSet::new(); + let mut invalid_anchor_ids = Vec::new(); + let mut steps = Vec::new(); + for model_step in model_steps { + let mut anchor_ids = Vec::new(); + for anchor_id in model_step.anchor_ids { + if anchors_by_id.contains_key(anchor_id.as_str()) + && seen_anchor_ids.insert(anchor_id.clone()) + { + anchor_ids.push(anchor_id); + } else if !anchors_by_id.contains_key(anchor_id.as_str()) { + invalid_anchor_ids.push(anchor_id); + } + } + if anchor_ids.is_empty() { + continue; + } + let index = steps.len() + 1; + steps.push(ReviewStoryStep { + step_id: format!("step-{index}"), + index: index as u32, + title: model_step.title, + goal: model_step.goal, + summary: model_step.summary, + dependency_rationale: model_step.dependency_rationale, + anchor_ids, + review_focus: model_step.review_focus, + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }); + } + + let missing_anchors = anchors + .iter() + .filter(|anchor| !seen_anchor_ids.contains(&anchor.anchor_id)) + .cloned() + .collect::>(); + if !missing_anchors.is_empty() { + let index = steps.len() + 1; + steps.push(ReviewStoryStep { + step_id: format!("step-{index}"), + index: index as u32, + title: "Remaining changes".to_string(), + goal: "Review changes the model did not place into a story step.".to_string(), + summary: format!( + "Covers {} anchor(s) that were omitted from the model-authored story.", + missing_anchors.len() + ), + dependency_rationale: + "Appended after model-authored steps to preserve full diff coverage.".to_string(), + anchor_ids: missing_anchors + .iter() + .map(|anchor| anchor.anchor_id.clone()) + .collect(), + review_focus: missing_anchors + .iter() + .map(|anchor| format!("Check {} independently.", anchor.file_path)) + .collect(), + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }); + } + + if steps.is_empty() { + return ( + steps_from_anchors(anchors), + Some("The model did not return any usable review story steps.".to_string()), + ); + } + + let mut validation_notes = Vec::new(); + if !missing_anchors.is_empty() { + validation_notes.push(format!( + "The model omitted {} anchor(s); Codex appended a coverage step.", + missing_anchors.len() + )); + } + if !invalid_anchor_ids.is_empty() { + validation_notes.push(format!( + "The model referenced unknown anchor id(s): {}.", + invalid_anchor_ids.join(", ") + )); + } + if validation_notes.is_empty() { + (steps, None) + } else { + (steps, Some(validation_notes.join(" "))) + } +} + +fn summarize_anchor(anchor: &ReviewStoryAnchor) -> String { + let additions = anchor + .diff + .lines() + .filter(|line| line.starts_with('+') && !line.starts_with("+++")) + .count(); + let deletions = anchor + .diff + .lines() + .filter(|line| line.starts_with('-') && !line.starts_with("---")) + .count(); + format!( + "{} with {additions} added line(s) and {deletions} removed line(s).", + anchor.summary + ) +} + +fn build_story_turn(turn_id: String, display_text: &str) -> Turn { + Turn { + id: turn_id.clone(), + items: vec![ThreadItem::UserMessage { + id: turn_id, + content: vec![V2UserInput::Text { + text: display_text.to_string(), + text_elements: Vec::new(), + }], + }], + items_view: TurnItemsView::NotLoaded, + error: None, + status: TurnStatus::Completed, + started_at: None, + completed_at: None, + duration_ms: None, + } +} + +fn snapshot_record( + snapshot: &ReviewStorySnapshot, +) -> Result { + let target_json = serde_json::to_value(&snapshot.target) + .map_err(|err| internal_error(format!("failed to encode review story target: {err}")))?; + let snapshot_json = serde_json::to_value(snapshot) + .map_err(|err| internal_error(format!("failed to encode review story snapshot: {err}")))?; + Ok(ReviewStoryRecord { + story_snapshot_id: snapshot.story_snapshot_id.clone(), + thread_id: snapshot.thread_id.clone(), + source_fingerprint: snapshot.source_fingerprint.clone(), + status: status_as_str(snapshot.status).to_string(), + title: snapshot.title.clone(), + step_count: snapshot.steps.len() as i64, + target_json, + snapshot_json, + previous_story_snapshot_id: snapshot.previous_story_snapshot_id.clone(), + created_at_ms: snapshot.created_at * 1000, + updated_at_ms: snapshot.updated_at * 1000, + }) +} + +fn summary_from_record( + record: ReviewStorySummaryRecord, +) -> Result { + let target = serde_json::from_value(record.target_json) + .map_err(|err| internal_error(format!("failed to decode review story target: {err}")))?; + Ok(ReviewStorySnapshotSummary { + story_snapshot_id: record.story_snapshot_id, + thread_id: record.thread_id, + title: record.title, + target, + source_fingerprint: record.source_fingerprint, + status: status_from_str(record.status.as_str()), + created_at: record.created_at_ms / 1000, + updated_at: record.updated_at_ms / 1000, + previous_story_snapshot_id: record.previous_story_snapshot_id, + step_count: record.step_count.max(/*other*/ 0) as u32, + }) +} + +fn status_as_str(status: ReviewStorySnapshotStatus) -> &'static str { + match status { + ReviewStorySnapshotStatus::Building => "building", + ReviewStorySnapshotStatus::Ready => "ready", + ReviewStorySnapshotStatus::Partial => "partial", + ReviewStorySnapshotStatus::Failed => "failed", + } +} + +fn status_from_str(status: &str) -> ReviewStorySnapshotStatus { + match status { + "building" => ReviewStorySnapshotStatus::Building, + "partial" => ReviewStorySnapshotStatus::Partial, + "failed" => ReviewStorySnapshotStatus::Failed, + "ready" => ReviewStorySnapshotStatus::Ready, + _ => ReviewStorySnapshotStatus::Failed, + } +} + +fn parse_thread_id( + thread_id: &str, +) -> Result { + ThreadId::from_string(thread_id) + .map_err(|err| invalid_request(format!("invalid thread id: {err}"))) +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn anchors_split_diff_by_file() { + let diff = "\ +diff --git a/src/lib.rs b/src/lib.rs +index 111..222 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -1 +1 @@ +-old ++new +diff --git a/src/main.rs b/src/main.rs +new file mode 100644 +--- /dev/null ++++ b/src/main.rs +@@ -0,0 +1 @@ ++fn main() {} +"; + + let anchors = anchors_from_diff(diff); + + assert_eq!( + anchors, + vec![ + ReviewStoryAnchor { + anchor_id: "anchor-1".to_string(), + file_path: "src/lib.rs".to_string(), + change_kind: ReviewStoryAnchorKind::Modified, + summary: "Modified src/lib.rs".to_string(), + diff: "diff --git a/src/lib.rs b/src/lib.rs\nindex 111..222 100644\n--- a/src/lib.rs\n+++ b/src/lib.rs\n@@ -1 +1 @@\n-old\n+new\n".to_string(), + }, + ReviewStoryAnchor { + anchor_id: "anchor-2".to_string(), + file_path: "src/main.rs".to_string(), + change_kind: ReviewStoryAnchorKind::Added, + summary: "Added src/main.rs".to_string(), + diff: "diff --git a/src/main.rs b/src/main.rs\nnew file mode 100644\n--- /dev/null\n+++ b/src/main.rs\n@@ -0,0 +1 @@\n+fn main() {}\n".to_string(), + }, + ] + ); + } + + #[test] + fn model_output_groups_anchors_into_cohesive_steps() { + let anchors = sample_anchors(); + let model_steps = vec![ModelReviewStoryStep { + title: "Introduce review story state".to_string(), + goal: "Create the storage and protocol foundation.".to_string(), + summary: "Adds reusable state and API shapes for review stories.".to_string(), + dependency_rationale: "The UI depends on the state and protocol contract.".to_string(), + anchor_ids: vec!["anchor-1".to_string(), "anchor-2".to_string()], + review_focus: vec!["Confirm the persisted snapshot is reusable.".to_string()], + }]; + + let (steps, validation_error) = steps_from_model_output(model_steps, &anchors); + + assert_eq!(validation_error, None); + assert_eq!( + steps, + vec![ReviewStoryStep { + step_id: "step-1".to_string(), + index: 1, + title: "Introduce review story state".to_string(), + goal: "Create the storage and protocol foundation.".to_string(), + summary: "Adds reusable state and API shapes for review stories.".to_string(), + dependency_rationale: "The UI depends on the state and protocol contract." + .to_string(), + anchor_ids: vec!["anchor-1".to_string(), "anchor-2".to_string()], + review_focus: vec!["Confirm the persisted snapshot is reusable.".to_string()], + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }] + ); + } + + #[test] + fn model_output_appends_missing_anchors_for_full_coverage() { + let anchors = sample_anchors(); + let model_steps = vec![ModelReviewStoryStep { + title: "Add protocol".to_string(), + goal: "Define the API contract.".to_string(), + summary: "Adds the protocol file.".to_string(), + dependency_rationale: "Protocol comes first.".to_string(), + anchor_ids: vec!["anchor-1".to_string(), "missing-anchor".to_string()], + review_focus: vec!["Check wire shape.".to_string()], + }]; + + let (steps, validation_error) = steps_from_model_output(model_steps, &anchors); + + assert_eq!( + validation_error, + Some( + "The model omitted 1 anchor(s); Codex appended a coverage step. The model referenced unknown anchor id(s): missing-anchor." + .to_string() + ) + ); + assert_eq!( + steps, + vec![ + ReviewStoryStep { + step_id: "step-1".to_string(), + index: 1, + title: "Add protocol".to_string(), + goal: "Define the API contract.".to_string(), + summary: "Adds the protocol file.".to_string(), + dependency_rationale: "Protocol comes first.".to_string(), + anchor_ids: vec!["anchor-1".to_string()], + review_focus: vec!["Check wire shape.".to_string()], + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }, + ReviewStoryStep { + step_id: "step-2".to_string(), + index: 2, + title: "Remaining changes".to_string(), + goal: "Review changes the model did not place into a story step.".to_string(), + summary: "Covers 1 anchor(s) that were omitted from the model-authored story." + .to_string(), + dependency_rationale: + "Appended after model-authored steps to preserve full diff coverage." + .to_string(), + anchor_ids: vec!["anchor-2".to_string()], + review_focus: vec![ + "Check codex-rs/tui/src/story.rs independently.".to_string() + ], + readiness: ReviewStoryStepReadiness::Ready, + error: None, + }, + ] + ); + } + + fn sample_anchors() -> Vec { + vec![ + ReviewStoryAnchor { + anchor_id: "anchor-1".to_string(), + file_path: "codex-rs/app-server-protocol/src/protocol/v2/review_story.rs" + .to_string(), + change_kind: ReviewStoryAnchorKind::Added, + summary: "Added protocol".to_string(), + diff: "+protocol".to_string(), + }, + ReviewStoryAnchor { + anchor_id: "anchor-2".to_string(), + file_path: "codex-rs/tui/src/story.rs".to_string(), + change_kind: ReviewStoryAnchorKind::Added, + summary: "Added TUI".to_string(), + diff: "+tui".to_string(), + }, + ] + } +} diff --git a/codex-rs/core/src/codex_thread.rs b/codex-rs/core/src/codex_thread.rs index 1b40387c3f..a7269d30e2 100644 --- a/codex-rs/core/src/codex_thread.rs +++ b/codex-rs/core/src/codex_thread.rs @@ -1,4 +1,6 @@ use crate::agent::AgentStatus; +use crate::codex_delegate::run_codex_thread_one_shot; +use crate::config::Constrained; use crate::config::ConstraintResult; use crate::goals::ExternalGoalSet; use crate::goals::GoalRuntimeEvent; @@ -11,6 +13,7 @@ use codex_protocol::config_types::ApprovalsReviewer; use codex_protocol::config_types::CollaborationMode; use codex_protocol::config_types::Personality; use codex_protocol::config_types::ReasoningSummary; +use codex_protocol::config_types::WebSearchMode; use codex_protocol::config_types::WindowsSandboxLevel; use codex_protocol::error::CodexErr; use codex_protocol::error::Result as CodexResult; @@ -23,10 +26,12 @@ use codex_protocol::models::ResponseItem; use codex_protocol::openai_models::ReasoningEffort; use codex_protocol::protocol::AskForApproval; use codex_protocol::protocol::Event; +use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::Op; use codex_protocol::protocol::SandboxPolicy; use codex_protocol::protocol::SessionConfiguredEvent; use codex_protocol::protocol::SessionSource; +use codex_protocol::protocol::SubAgentSource; use codex_protocol::protocol::Submission; use codex_protocol::protocol::ThreadMemoryMode; use codex_protocol::protocol::ThreadSource; @@ -41,11 +46,13 @@ use codex_thread_store::ThreadStoreError; use codex_thread_store::ThreadStoreResult; use codex_utils_absolute_path::AbsolutePathBuf; use rmcp::model::ReadResourceRequestParams; +use serde_json::Value; use std::collections::HashMap; use std::path::PathBuf; use std::sync::Arc; use tokio::sync::Mutex; use tokio::sync::watch; +use tokio_util::sync::CancellationToken; use codex_rollout::state_db::StateDbHandle; @@ -502,6 +509,68 @@ impl CodexThread { self.codex.session.get_config().await } + /// Run a short-lived model task that produces structured JSON for a caller-owned workflow. + /// + /// This keeps app-server features from needing to know how to spawn sub-agents while still + /// reusing the same constrained delegate machinery as review mode. + pub async fn run_structured_model_task( + &self, + prompt: String, + base_instructions: String, + final_output_json_schema: Value, + subagent_source: SubAgentSource, + ) -> CodexResult> { + let ctx = self + .codex + .session + .new_default_turn_with_sub_id(format!("structured-task-{}", uuid::Uuid::now_v7())) + .await; + let mut sub_agent_config = ctx.config.as_ref().clone(); + if let Err(err) = sub_agent_config + .web_search_mode + .set(WebSearchMode::Disabled) + { + panic!( + "by construction Constrained must always support Disabled: {err}" + ); + } + let _ = sub_agent_config.features.disable(Feature::SpawnCsv); + let _ = sub_agent_config.features.disable(Feature::Collab); + let _ = sub_agent_config.features.disable(Feature::MultiAgentV2); + sub_agent_config.permissions.approval_policy = + Constrained::allow_only(AskForApproval::Never); + sub_agent_config.base_instructions = Some(base_instructions); + let input = vec![UserInput::Text { + text: prompt, + text_elements: Vec::new(), + }]; + let io = run_codex_thread_one_shot( + sub_agent_config, + Arc::clone(&self.codex.session.services.auth_manager), + Arc::clone(&self.codex.session.services.models_manager), + input, + Arc::clone(&self.codex.session), + ctx, + CancellationToken::new(), + subagent_source, + Some(final_output_json_schema), + /*initial_history*/ None, + ) + .await?; + while let Ok(event) = io.next_event().await { + match event.msg { + EventMsg::TurnComplete(turn_complete) => { + return Ok(turn_complete.last_agent_message); + } + EventMsg::TurnAborted(_) => { + return Ok(None); + } + _ => {} + } + } + Ok(None) + } + /// Refresh the thread's layer-backed user config state from a caller-supplied /// config snapshot. Thread-scoped layers and session-static settings remain /// unchanged. diff --git a/codex-rs/state/BUILD.bazel b/codex-rs/state/BUILD.bazel index b3f0fecab7..dca74541f5 100644 --- a/codex-rs/state/BUILD.bazel +++ b/codex-rs/state/BUILD.bazel @@ -3,5 +3,5 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "state", crate_name = "codex_state", - compile_data = glob(["goals_migrations/**", "logs_migrations/**", "migrations/**"]), + compile_data = glob(["goals_migrations/**", "logs_migrations/**", "migrations/**", "review_story_migrations/**"]), ) diff --git a/codex-rs/state/review_story_migrations/0001_review_stories.sql b/codex-rs/state/review_story_migrations/0001_review_stories.sql new file mode 100644 index 0000000000..62f09234b9 --- /dev/null +++ b/codex-rs/state/review_story_migrations/0001_review_stories.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS review_story_snapshots ( + story_snapshot_id TEXT PRIMARY KEY NOT NULL, + thread_id TEXT NOT NULL, + source_fingerprint TEXT NOT NULL, + status TEXT NOT NULL, + title TEXT NOT NULL, + step_count INTEGER NOT NULL, + target_json TEXT NOT NULL, + snapshot_json TEXT NOT NULL, + previous_story_snapshot_id TEXT, + created_at_ms INTEGER NOT NULL, + updated_at_ms INTEGER NOT NULL +); + +CREATE INDEX IF NOT EXISTS review_story_snapshots_thread_updated_idx + ON review_story_snapshots(thread_id, updated_at_ms DESC, story_snapshot_id DESC); + +CREATE INDEX IF NOT EXISTS review_story_snapshots_thread_fingerprint_idx + ON review_story_snapshots(thread_id, source_fingerprint, updated_at_ms DESC); diff --git a/codex-rs/state/src/lib.rs b/codex-rs/state/src/lib.rs index f35b3420f6..0e8341a4d2 100644 --- a/codex-rs/state/src/lib.rs +++ b/codex-rs/state/src/lib.rs @@ -53,12 +53,17 @@ pub use runtime::GoalAccountingOutcome; pub use runtime::GoalStore; pub use runtime::GoalUpdate; pub use runtime::RemoteControlEnrollmentRecord; +pub use runtime::ReviewStoryRecord; +pub use runtime::ReviewStoryStore; +pub use runtime::ReviewStorySummaryRecord; pub use runtime::RuntimeDbPath; pub use runtime::ThreadFilterOptions; pub use runtime::goals_db_filename; pub use runtime::goals_db_path; pub use runtime::logs_db_filename; pub use runtime::logs_db_path; +pub use runtime::review_story_db_filename; +pub use runtime::review_story_db_path; pub use runtime::runtime_db_paths; pub use runtime::sqlite_integrity_check; pub use runtime::state_db_filename; @@ -74,6 +79,7 @@ pub const SQLITE_HOME_ENV: &str = "CODEX_SQLITE_HOME"; pub const LOGS_DB_FILENAME: &str = "logs_2.sqlite"; pub const GOALS_DB_FILENAME: &str = "goals_1.sqlite"; +pub const REVIEW_STORY_DB_FILENAME: &str = "review_stories_1.sqlite"; pub const STATE_DB_FILENAME: &str = "state_5.sqlite"; /// Errors encountered during DB operations. Tags: [stage] diff --git a/codex-rs/state/src/migrations.rs b/codex-rs/state/src/migrations.rs index 526e958b5a..e6d34898f6 100644 --- a/codex-rs/state/src/migrations.rs +++ b/codex-rs/state/src/migrations.rs @@ -5,6 +5,7 @@ use sqlx::migrate::Migrator; pub(crate) static STATE_MIGRATOR: Migrator = sqlx::migrate!("./migrations"); pub(crate) static LOGS_MIGRATOR: Migrator = sqlx::migrate!("./logs_migrations"); pub(crate) static GOALS_MIGRATOR: Migrator = sqlx::migrate!("./goals_migrations"); +pub(crate) static REVIEW_STORY_MIGRATOR: Migrator = sqlx::migrate!("./review_story_migrations"); /// Allow an older Codex binary to open a database that has already been /// migrated by a newer binary running in parallel. @@ -32,3 +33,7 @@ pub(crate) fn runtime_logs_migrator() -> Migrator { pub(crate) fn runtime_goals_migrator() -> Migrator { runtime_migrator(&GOALS_MIGRATOR) } + +pub(crate) fn runtime_review_story_migrator() -> Migrator { + runtime_migrator(&REVIEW_STORY_MIGRATOR) +} diff --git a/codex-rs/state/src/runtime.rs b/codex-rs/state/src/runtime.rs index 8c9c6d0267..4bb30a935c 100644 --- a/codex-rs/state/src/runtime.rs +++ b/codex-rs/state/src/runtime.rs @@ -10,6 +10,7 @@ use crate::LOGS_DB_FILENAME; use crate::LogEntry; use crate::LogQuery; use crate::LogRow; +use crate::REVIEW_STORY_DB_FILENAME; use crate::STATE_DB_FILENAME; use crate::SortKey; use crate::ThreadMetadata; @@ -18,6 +19,7 @@ use crate::ThreadsPage; use crate::apply_rollout_item; use crate::migrations::runtime_goals_migrator; use crate::migrations::runtime_logs_migrator; +use crate::migrations::runtime_review_story_migrator; use crate::migrations::runtime_state_migrator; use crate::model::AgentJobRow; use crate::model::ThreadRow; @@ -62,6 +64,7 @@ mod goals; mod logs; mod memories; mod remote_control; +mod review_stories; #[cfg(test)] mod test_support; mod threads; @@ -71,6 +74,9 @@ pub use goals::GoalAccountingOutcome; pub use goals::GoalStore; pub use goals::GoalUpdate; pub use remote_control::RemoteControlEnrollmentRecord; +pub use review_stories::ReviewStoryRecord; +pub use review_stories::ReviewStoryStore; +pub use review_stories::ReviewStorySummaryRecord; pub use threads::ThreadFilterOptions; // "Partition" is the retained-log-content bucket we cap at 10 MiB: @@ -121,7 +127,15 @@ const GOALS_DB: RuntimeDbSpec = RuntimeDbSpec { migrate_phase: "migrate_goals", }; -const RUNTIME_DBS: [RuntimeDbSpec; 3] = [STATE_DB, LOGS_DB, GOALS_DB]; +const REVIEW_STORY_DB: RuntimeDbSpec = RuntimeDbSpec { + label: "review story DB", + filename: REVIEW_STORY_DB_FILENAME, + kind: DbKind::ReviewStories, + open_phase: "open_review_stories", + migrate_phase: "migrate_review_stories", +}; + +const RUNTIME_DBS: [RuntimeDbSpec; 4] = [STATE_DB, LOGS_DB, GOALS_DB, REVIEW_STORY_DB]; #[derive(Clone, Debug, Eq, PartialEq)] pub struct RuntimeDbPath { @@ -136,6 +150,7 @@ pub struct StateRuntime { pool: Arc, logs_pool: Arc, thread_goals: GoalStore, + review_stories: ReviewStoryStore, thread_updated_at_millis: Arc, } @@ -172,9 +187,11 @@ impl StateRuntime { let state_migrator = runtime_state_migrator(); let logs_migrator = runtime_logs_migrator(); let goals_migrator = runtime_goals_migrator(); + let review_story_migrator = runtime_review_story_migrator(); let state_path = STATE_DB.path(codex_home.as_path()); let logs_path = LOGS_DB.path(codex_home.as_path()); let goals_path = GOALS_DB.path(codex_home.as_path()); + let review_story_path = REVIEW_STORY_DB.path(codex_home.as_path()); let pool = match open_state_sqlite(&state_path, &state_migrator, telemetry_override).await { Ok(db) => Arc::new(db), Err(err) => { @@ -198,6 +215,22 @@ impl StateRuntime { return Err(err); } }; + let review_story_pool = match open_review_story_sqlite( + &review_story_path, + &review_story_migrator, + telemetry_override, + ) + .await + { + Ok(db) => Arc::new(db), + Err(err) => { + warn!( + "failed to open review story db at {}: {err}", + review_story_path.display() + ); + return Err(err); + } + }; let started = Instant::now(); let backfill_state_result = ensure_backfill_state_row_in_pool(pool.as_ref()).await; crate::telemetry::record_init_result( @@ -225,6 +258,7 @@ impl StateRuntime { let thread_updated_at_millis = thread_updated_at_millis.unwrap_or(0); let runtime = Arc::new(Self { thread_goals: GoalStore::new(Arc::clone(&goals_pool)), + review_stories: ReviewStoryStore::new(review_story_pool), pool, logs_pool, codex_home, @@ -248,6 +282,10 @@ impl StateRuntime { pub fn thread_goals(&self) -> &GoalStore { &self.thread_goals } + + pub fn review_stories(&self) -> &ReviewStoryStore { + &self.review_stories + } } fn base_sqlite_options(path: &Path) -> SqliteConnectOptions { @@ -287,6 +325,14 @@ async fn open_goals_sqlite( open_sqlite(path, migrator, GOALS_DB, telemetry_override).await } +async fn open_review_story_sqlite( + path: &Path, + migrator: &Migrator, + telemetry_override: Option<&dyn DbTelemetry>, +) -> anyhow::Result { + open_sqlite(path, migrator, REVIEW_STORY_DB, telemetry_override).await +} + async fn open_sqlite( path: &Path, migrator: &Migrator, @@ -363,6 +409,14 @@ pub fn goals_db_path(codex_home: &Path) -> PathBuf { GOALS_DB.path(codex_home) } +pub fn review_story_db_filename() -> String { + REVIEW_STORY_DB.filename.to_string() +} + +pub fn review_story_db_path(codex_home: &Path) -> PathBuf { + REVIEW_STORY_DB.path(codex_home) +} + pub fn runtime_db_paths(codex_home: &Path) -> Vec { RUNTIME_DBS .iter() @@ -579,6 +633,8 @@ mod tests { "migrate_logs", "open_goals", "migrate_goals", + "open_review_stories", + "migrate_review_stories", "ensure_backfill_state", "post_init_query", ] diff --git a/codex-rs/state/src/runtime/review_stories.rs b/codex-rs/state/src/runtime/review_stories.rs new file mode 100644 index 0000000000..8d34ac70a2 --- /dev/null +++ b/codex-rs/state/src/runtime/review_stories.rs @@ -0,0 +1,220 @@ +use super::*; + +#[derive(Clone)] +pub struct ReviewStoryStore { + pool: Arc, +} + +impl ReviewStoryStore { + pub(crate) fn new(pool: Arc) -> Self { + Self { pool } + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ReviewStoryRecord { + pub story_snapshot_id: String, + pub thread_id: String, + pub source_fingerprint: String, + pub status: String, + pub title: String, + pub step_count: i64, + pub target_json: Value, + pub snapshot_json: Value, + pub previous_story_snapshot_id: Option, + pub created_at_ms: i64, + pub updated_at_ms: i64, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ReviewStorySummaryRecord { + pub story_snapshot_id: String, + pub thread_id: String, + pub source_fingerprint: String, + pub status: String, + pub title: String, + pub step_count: i64, + pub target_json: Value, + pub previous_story_snapshot_id: Option, + pub created_at_ms: i64, + pub updated_at_ms: i64, +} + +impl ReviewStoryStore { + pub async fn upsert_snapshot(&self, record: ReviewStoryRecord) -> anyhow::Result<()> { + let ReviewStoryRecord { + story_snapshot_id, + thread_id, + source_fingerprint, + status, + title, + step_count, + target_json, + snapshot_json, + previous_story_snapshot_id, + created_at_ms, + updated_at_ms, + } = record; + let target_json = serde_json::to_string(&target_json)?; + let snapshot_json = serde_json::to_string(&snapshot_json)?; + sqlx::query( + r#" +INSERT INTO review_story_snapshots ( + story_snapshot_id, + thread_id, + source_fingerprint, + status, + title, + step_count, + target_json, + snapshot_json, + previous_story_snapshot_id, + created_at_ms, + updated_at_ms +) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +ON CONFLICT(story_snapshot_id) DO UPDATE SET + thread_id = excluded.thread_id, + source_fingerprint = excluded.source_fingerprint, + status = excluded.status, + title = excluded.title, + step_count = excluded.step_count, + target_json = excluded.target_json, + snapshot_json = excluded.snapshot_json, + previous_story_snapshot_id = excluded.previous_story_snapshot_id, + created_at_ms = excluded.created_at_ms, + updated_at_ms = excluded.updated_at_ms + "#, + ) + .bind(story_snapshot_id) + .bind(thread_id) + .bind(source_fingerprint) + .bind(status) + .bind(title) + .bind(step_count) + .bind(target_json) + .bind(snapshot_json) + .bind(previous_story_snapshot_id) + .bind(created_at_ms) + .bind(updated_at_ms) + .execute(self.pool.as_ref()) + .await?; + Ok(()) + } + + pub async fn get_snapshot( + &self, + thread_id: ThreadId, + story_snapshot_id: &str, + ) -> anyhow::Result> { + let row = sqlx::query( + r#" +SELECT + story_snapshot_id, + thread_id, + source_fingerprint, + status, + title, + step_count, + target_json, + snapshot_json, + previous_story_snapshot_id, + created_at_ms, + updated_at_ms +FROM review_story_snapshots +WHERE thread_id = ? AND story_snapshot_id = ? + "#, + ) + .bind(thread_id.to_string()) + .bind(story_snapshot_id) + .fetch_optional(self.pool.as_ref()) + .await?; + + row.map(|row| review_story_record_from_row(&row)) + .transpose() + } + + pub async fn list_snapshots( + &self, + thread_id: ThreadId, + cursor: Option, + limit: Option, + ) -> anyhow::Result<(Vec, Option)> { + let limit = limit + .unwrap_or(/*default*/ 50) + .clamp(/*min*/ 1, /*max*/ 100); + let offset = cursor + .as_deref() + .and_then(|cursor| cursor.parse::().ok()) + .unwrap_or(/*default*/ 0); + let rows = sqlx::query( + r#" +SELECT + story_snapshot_id, + thread_id, + source_fingerprint, + status, + title, + step_count, + target_json, + previous_story_snapshot_id, + created_at_ms, + updated_at_ms +FROM review_story_snapshots +WHERE thread_id = ? +ORDER BY updated_at_ms DESC, story_snapshot_id DESC +LIMIT ? OFFSET ? + "#, + ) + .bind(thread_id.to_string()) + .bind(i64::from(limit) + 1) + .bind(i64::from(offset)) + .fetch_all(self.pool.as_ref()) + .await?; + + let has_next = rows.len() > limit as usize; + let rows = rows.into_iter().take(limit as usize); + let records = rows + .map(|row| review_story_summary_record_from_row(&row)) + .collect::>>()?; + let next_cursor = has_next.then(|| (offset + limit).to_string()); + Ok((records, next_cursor)) + } +} + +fn review_story_record_from_row( + row: &sqlx::sqlite::SqliteRow, +) -> anyhow::Result { + let target_json: String = row.try_get("target_json")?; + let snapshot_json: String = row.try_get("snapshot_json")?; + Ok(ReviewStoryRecord { + story_snapshot_id: row.try_get("story_snapshot_id")?, + thread_id: row.try_get("thread_id")?, + source_fingerprint: row.try_get("source_fingerprint")?, + status: row.try_get("status")?, + title: row.try_get("title")?, + step_count: row.try_get("step_count")?, + target_json: serde_json::from_str(&target_json)?, + snapshot_json: serde_json::from_str(&snapshot_json)?, + previous_story_snapshot_id: row.try_get("previous_story_snapshot_id")?, + created_at_ms: row.try_get("created_at_ms")?, + updated_at_ms: row.try_get("updated_at_ms")?, + }) +} + +fn review_story_summary_record_from_row( + row: &sqlx::sqlite::SqliteRow, +) -> anyhow::Result { + let target_json: String = row.try_get("target_json")?; + Ok(ReviewStorySummaryRecord { + story_snapshot_id: row.try_get("story_snapshot_id")?, + thread_id: row.try_get("thread_id")?, + source_fingerprint: row.try_get("source_fingerprint")?, + status: row.try_get("status")?, + title: row.try_get("title")?, + step_count: row.try_get("step_count")?, + target_json: serde_json::from_str(&target_json)?, + previous_story_snapshot_id: row.try_get("previous_story_snapshot_id")?, + created_at_ms: row.try_get("created_at_ms")?, + updated_at_ms: row.try_get("updated_at_ms")?, + }) +} diff --git a/codex-rs/state/src/telemetry.rs b/codex-rs/state/src/telemetry.rs index da2b7de7a8..19a8b3e1d3 100644 --- a/codex-rs/state/src/telemetry.rs +++ b/codex-rs/state/src/telemetry.rs @@ -40,6 +40,7 @@ pub(crate) enum DbKind { State, Logs, Goals, + ReviewStories, } impl DbKind { @@ -48,6 +49,7 @@ impl DbKind { Self::State => "state", Self::Logs => "logs", Self::Goals => "goals", + Self::ReviewStories => "review_stories", } } } diff --git a/codex-rs/tui/src/app/app_server_event_targets.rs b/codex-rs/tui/src/app/app_server_event_targets.rs index 0b2143b429..27465af71e 100644 --- a/codex-rs/tui/src/app/app_server_event_targets.rs +++ b/codex-rs/tui/src/app/app_server_event_targets.rs @@ -68,6 +68,9 @@ pub(super) fn server_notification_thread_target( ServerNotification::TurnStarted(notification) => Some(notification.thread_id.as_str()), ServerNotification::HookStarted(notification) => Some(notification.thread_id.as_str()), ServerNotification::TurnCompleted(notification) => Some(notification.thread_id.as_str()), + ServerNotification::ReviewStorySnapshotUpdated(notification) => { + Some(notification.thread_id.as_str()) + } ServerNotification::HookCompleted(notification) => Some(notification.thread_id.as_str()), ServerNotification::TurnDiffUpdated(notification) => Some(notification.thread_id.as_str()), ServerNotification::TurnPlanUpdated(notification) => Some(notification.thread_id.as_str()), diff --git a/codex-rs/tui/src/chatwidget/protocol.rs b/codex-rs/tui/src/chatwidget/protocol.rs index b3b58cbc82..20984dece9 100644 --- a/codex-rs/tui/src/chatwidget/protocol.rs +++ b/codex-rs/tui/src/chatwidget/protocol.rs @@ -219,6 +219,7 @@ impl ChatWidget { | ServerNotification::AccountUpdated(_) | ServerNotification::AccountRateLimitsUpdated(_) | ServerNotification::ThreadStarted(_) + | ServerNotification::ReviewStorySnapshotUpdated(_) | ServerNotification::ThreadStatusChanged(_) | ServerNotification::ThreadArchived(_) | ServerNotification::ThreadUnarchived(_) diff --git a/docs/adr/0001-review-story-v1.md b/docs/adr/0001-review-story-v1.md new file mode 100644 index 0000000000..33f17c49df --- /dev/null +++ b/docs/adr/0001-review-story-v1.md @@ -0,0 +1,33 @@ +# Review Story API Foundation + +Status: accepted + +## Context + +Large code changes are difficult to review as a flat file list. Codex already has `/review`, but that workflow is findings-oriented; a review story is a separate, read-only artifact intended to explain a change in a useful reading order. + +The first reusable layer must support both the future TUI surface and an App UI surface without coupling story generation to either client. + +## Decision + +Introduce an app-server v2 API namespace, `reviewStory/*`, backed by shared Rust generation logic and a separate SQLite story database managed by the state layer. + +`reviewStory/start` accepts a concrete source: branch comparison, uncommitted changes, or one commit. The server collects the source diff, creates deterministic file-level anchors and a source fingerprint, invokes one constrained structured model task to group anchors into ordered steps, validates anchor coverage, and persists the completed snapshot. If generation is unavailable or invalid, it persists a usable file-level fallback snapshot instead. + +The API also provides `reviewStory/read` and `reviewStory/list` for stored snapshots and emits `reviewStory/snapshot/updated` when a snapshot is written. Snapshot and step status fields include values that allow a future progressive generator, but this foundation produces completed `ready` or `partial` snapshots with `ready` steps. + +Story snapshots live in the story store rather than in thread transcript history. The API is the product boundary: a stacked TUI feature and a later App UI can present the same stored story artifact. + +## Deliberately Deferred + +- Interactive TUI or App UI presentation. +- Progressive outline-first generation and asynchronous step enrichment. +- Hunk-level anchors, dependency graph signals, or semantic indexing. +- Staleness detection, refresh, and snapshot lineage behavior. +- Review comments, findings, or hosted review submission from a story surface. + +## Consequences + +This layer provides a stable, validated, reusable story artifact without requiring a UI or an asynchronous job lifecycle in the same change. Clients receive a complete snapshot, and failures degrade to full file-level coverage rather than hiding changed evidence. + +Progressive loading remains compatible with the API shape but will require a separate implementation: early `building` snapshots, background enrichment, repeated snapshot writes, and client consumption of replacement notifications.