@opencode/protocol 0.0.0-dev-21268 → 0.0.0-dev-21286

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ import { InstructionEntry } from "@opencode/schema/instruction-entry";
7
7
  import { Project } from "@opencode/schema/project";
8
8
  import { DateTimeUtcFromMillis, NonNegativeInt, PositiveInt } from "@opencode/schema/schema";
9
9
  import { Event } from "@opencode/schema/event";
10
+ import { SessionLegacy } from "@opencode/schema/session-legacy";
10
11
  import { Context, Schema, SchemaGetter, Struct } from "effect";
11
12
  import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api";
12
13
  import { ConflictError, LocationNotFoundError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
@@ -45,6 +46,15 @@ const PublicInboxInfo = Schema.Union([
45
46
  SessionInbox.Compaction,
46
47
  PublicMove,
47
48
  ]).annotate({ identifier: "Session.Inbox.Info" });
49
+ // Transcripts exported before v2.1 carry older names for native data. The wire stays plain JSON so any export file
50
+ // is accepted; decoding upgrades those names and then validates the current message shape.
51
+ const ImportedMessages = Schema.Array(Schema.Json).pipe(Schema.decodeTo(Schema.Array(Schema.Unknown), {
52
+ decode: SchemaGetter.transform(SessionLegacy.messages),
53
+ encode: SchemaGetter.passthrough({ strict: false }),
54
+ }), Schema.decodeTo(Schema.Array(PublicSessionMessage), {
55
+ decode: SchemaGetter.passthrough({ strict: false }),
56
+ encode: SchemaGetter.passthrough({ strict: false }),
57
+ }));
48
58
  const FormCreatePayload = Schema.Struct({
49
59
  id: Form.ID.pipe(Schema.optional),
50
60
  title: Form.Info.fields.title,
@@ -115,7 +125,8 @@ export const makeSessionGroup = (sessionLocationMiddleware, formLocationMiddlewa
115
125
  })))
116
126
  .add(HttpApiEndpoint.post("session.import", "/api/experimental/session/import", {
117
127
  payload: Schema.Struct({
118
- ...PublicSessionTransfer.fields,
128
+ info: PublicSessionTransfer.fields.info,
129
+ messages: ImportedMessages,
119
130
  location: Location.PublicRef.pipe(Schema.optional),
120
131
  }),
121
132
  success: Schema.Struct({ data: PublicSessionInfo }),
@@ -123,7 +134,7 @@ export const makeSessionGroup = (sessionLocationMiddleware, formLocationMiddlewa
123
134
  }).annotateMerge(OpenApi.annotations({
124
135
  identifier: "experimental.session.import",
125
136
  summary: "Import session",
126
- description: "Import a projected session transcript at the requested location. If parentID is supplied, the parent session must already exist; import parents before children.",
137
+ description: "Import a projected session transcript at the requested location. Accepts transcripts exported by earlier releases. If parentID is supplied, the parent session must already exist; import parents before children.",
127
138
  })))
128
139
  .add(HttpApiEndpoint.get("session.export", "/api/experimental/session/:sessionID/export", {
129
140
  params: { sessionID: Session.ID },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/protocol",
4
- "version": "0.0.0-dev-21268",
4
+ "version": "0.0.0-dev-21286",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "typecheck": "tsc --noEmit"
34
34
  },
35
35
  "dependencies": {
36
- "@opencode/schema": "0.0.0-dev-21268",
36
+ "@opencode/schema": "0.0.0-dev-21286",
37
37
  "effect": "4.0.1"
38
38
  },
39
39
  "devDependencies": {