Skip to content

Commit 75f0462

Browse files
committed
refactor(protocol): mark transient session controls
1 parent 6bc60ca commit 75f0462

8 files changed

Lines changed: 25 additions & 21 deletions

File tree

‎V2_HTTP_API_AUDIT.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ Review endpoints in document order. For each endpoint, select one disposition an
166166
| [x] 065 | `POST` | `/api/experimental/session/{sessionID}/wait` | `experimental.session.wait` | Experimental-only | Race-free idle barrier retained outside the stable API. |
167167
| [x] 066 | `POST` | `/api/session/{sessionID}/generate` | `session.generate` | Keep | Transient generation from session context retained. |
168168
| [x] 067 | `POST` | `/api/session/{sessionID}/interrupt` | `session.interrupt` | Change | Renamed `continue` to `resume` across public and internal interruption APIs. |
169-
| [ ] 068 | `PUT` | `/api/session/{sessionID}/environment` | `session.environment` | | |
170-
| [ ] 069 | `POST` | `/api/session/{sessionID}/view` | `session.view` | | |
169+
| [x] 068 | `PUT` | `/api/experimental/session/{sessionID}/environment` | `experimental.session.environment` | Experimental-only | Process-local environment replacement retained outside the stable API. |
170+
| [x] 069 | `POST` | `/api/session/{sessionID}/view` | `session.view` | Change | Idle watermark now uses the standard epoch-millisecond timestamp schema. |
171171

172172
## Group 6: Session history and recovery
173173

‎packages/client/src/effect/api/api.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ export type SessionEnvironmentOperation<E = never> = (
13321332
input: SessionEnvironmentInput,
13331333
) => Effect.Effect<SessionEnvironmentOutput, E>
13341334

1335-
export type SessionViewInput = { readonly sessionID: Session.ID; readonly idle: number }
1335+
export type SessionViewInput = { readonly sessionID: Session.ID; readonly idle: DateTime.Utc }
13361336
export type SessionViewOutput = void
13371337
export type SessionViewOperation<E = never> = (input: SessionViewInput) => Effect.Effect<SessionViewOutput, E>
13381338

‎packages/client/src/promise/generated/client.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ export function make(options: ClientOptions) {
979979
request<SessionEnvironmentOutput>(
980980
{
981981
method: "PUT",
982-
path: `/api/session/${encodeURIComponent(input.sessionID)}/environment`,
982+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/environment`,
983983
body: { variables: input["variables"] },
984984
successStatus: 204,
985985
declaredStatuses: [400, 401, 404],

‎packages/protocol/openapi.json‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,10 +4222,10 @@
42224222
"summary": "Get session message"
42234223
}
42244224
},
4225-
"/api/session/{sessionID}/environment": {
4225+
"/api/experimental/session/{sessionID}/environment": {
42264226
"put": {
42274227
"tags": ["session"],
4228-
"operationId": "session.environment",
4228+
"operationId": "experimental.session.environment",
42294229
"parameters": [
42304230
{
42314231
"name": "sessionID",
@@ -4357,8 +4357,7 @@
43574357
"type": "object",
43584358
"properties": {
43594359
"idle": {
4360-
"type": "integer",
4361-
"minimum": 0
4360+
"type": "number"
43624361
}
43634362
},
43644363
"required": ["idle"],

‎packages/protocol/src/groups/session.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import { Session } from "@opencode/schema/session"
55
import { SessionStats } from "@opencode/schema/session-stats"
66
import { InstructionEntry } from "@opencode/schema/instruction-entry"
77
import { Project } from "@opencode/schema/project"
8-
import { AbsolutePath, NonNegativeInt, PositiveInt, RelativePath, statics } from "@opencode/schema/schema"
8+
import {
9+
AbsolutePath,
10+
DateTimeUtcFromMillis,
11+
NonNegativeInt,
12+
PositiveInt,
13+
RelativePath,
14+
statics,
15+
} from "@opencode/schema/schema"
916
import { Event } from "@opencode/schema/event"
1017
import { Context, Effect, Encoding, Result, Schema, SchemaGetter, Struct } from "effect"
1118
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
@@ -764,14 +771,14 @@ export const makeSessionGroup = <I extends HttpApiMiddleware.AnyId, S>(sessionLo
764771
),
765772
)
766773
.add(
767-
HttpApiEndpoint.put("session.environment", "/api/session/:sessionID/environment", {
774+
HttpApiEndpoint.put("session.environment", "/api/experimental/session/:sessionID/environment", {
768775
params: { sessionID: Session.ID },
769776
payload: Schema.Struct({ variables: Schema.Record(Schema.String, Schema.String) }),
770777
success: HttpApiSchema.NoContent,
771778
error: SessionNotFoundError,
772779
}).annotateMerge(
773780
OpenApi.annotations({
774-
identifier: "session.environment",
781+
identifier: "experimental.session.environment",
775782
summary: "Set session environment",
776783
description: "Replace the process environment used by local shell commands for this session.",
777784
}),
@@ -780,7 +787,7 @@ export const makeSessionGroup = <I extends HttpApiMiddleware.AnyId, S>(sessionLo
780787
.add(
781788
HttpApiEndpoint.post("session.view", "/api/session/:sessionID/view", {
782789
params: { sessionID: Session.ID },
783-
payload: Schema.Struct({ idle: NonNegativeInt }),
790+
payload: Schema.Struct({ idle: DateTimeUtcFromMillis }),
784791
success: HttpApiSchema.NoContent,
785792
error: SessionNotFoundError,
786793
}).annotateMerge(

‎packages/server/src/handlers/session.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handl
184184
"session.view",
185185
Effect.fn(function* (ctx) {
186186
yield* session
187-
.view({ sessionID: ctx.params.sessionID, idle: ctx.payload.idle })
187+
.view({ sessionID: ctx.params.sessionID, idle: DateTime.toEpochMillis(ctx.payload.idle) })
188188
.pipe(Effect.catchTag("Session.NotFoundError", missingSession))
189189
return HttpApiSchema.NoContent.make()
190190
}),

‎services/www/openapi.json‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,10 +4222,10 @@
42224222
"summary": "Get session message"
42234223
}
42244224
},
4225-
"/api/session/{sessionID}/environment": {
4225+
"/api/experimental/session/{sessionID}/environment": {
42264226
"put": {
42274227
"tags": ["session"],
4228-
"operationId": "session.environment",
4228+
"operationId": "experimental.session.environment",
42294229
"parameters": [
42304230
{
42314231
"name": "sessionID",
@@ -4357,8 +4357,7 @@
43574357
"type": "object",
43584358
"properties": {
43594359
"idle": {
4360-
"type": "integer",
4361-
"minimum": 0
4360+
"type": "number"
43624361
}
43634362
},
43644363
"required": ["idle"],

‎services/www/public/openapi.json‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,10 +4222,10 @@
42224222
"summary": "Get session message"
42234223
}
42244224
},
4225-
"/api/session/{sessionID}/environment": {
4225+
"/api/experimental/session/{sessionID}/environment": {
42264226
"put": {
42274227
"tags": ["session"],
4228-
"operationId": "session.environment",
4228+
"operationId": "experimental.session.environment",
42294229
"parameters": [
42304230
{
42314231
"name": "sessionID",
@@ -4357,8 +4357,7 @@
43574357
"type": "object",
43584358
"properties": {
43594359
"idle": {
4360-
"type": "integer",
4361-
"minimum": 0
4360+
"type": "number"
43624361
}
43634362
},
43644363
"required": ["idle"],

0 commit comments

Comments
 (0)