Kaynağa Gözat

fix(sdk): expose prompt input contract

Dax Raad 1 ay önce
ebeveyn
işleme
36d17c30a7

+ 6 - 6
packages/cli/src/mini/session.shared.ts

@@ -176,22 +176,22 @@ export async function resolveCurrentSession(
             parts: [
               ...(message.files ?? []).map((file) => ({
                 type: "file" as const,
-                url: file.uri,
+                url: file.source.type === "uri" ? file.source.uri : `data:${file.mime};base64,${file.data}`,
                 mime: file.mime,
                 filename: file.name,
-                source: file.source
+                source: file.mention
                   ? {
                       type: "file" as const,
-                      path: file.name ?? file.uri,
-                      text: { start: file.source.start, end: file.source.end, value: file.source.text },
+                      path: file.name ?? (file.source.type === "uri" ? file.source.uri : "inline attachment"),
+                      text: { start: file.mention.start, end: file.mention.end, value: file.mention.text },
                     }
                   : undefined,
               })),
               ...(message.agents ?? []).map((agent) => ({
                 type: "agent" as const,
                 name: agent.name,
-                source: agent.source
-                  ? { start: agent.source.start, end: agent.source.end, value: agent.source.text }
+                source: agent.mention
+                  ? { start: agent.mention.start, end: agent.mention.end, value: agent.mention.text }
                   : undefined,
               })),
             ],

+ 1 - 0
packages/client/src/effect/index.ts

@@ -42,5 +42,6 @@ export { SessionInput } from "@opencode-ai/schema/session-input"
 export { SessionMessage } from "@opencode-ai/schema/session-message"
 export { Skill } from "@opencode-ai/schema/skill"
 export { Prompt } from "@opencode-ai/schema/prompt"
+export { PromptInput } from "@opencode-ai/schema/prompt-input"
 export type { OpenCodeEvent } from "@opencode-ai/protocol/groups/event"
 export type OpenCodeClient = Effect.Success<ReturnType<typeof import("./generated/client").make>>

+ 1 - 0
packages/sdk-next/src/index.ts

@@ -8,6 +8,7 @@ export {
   Location,
   Model,
   Prompt,
+  PromptInput,
   Provider,
   RelativePath,
   Session,

+ 3 - 3
packages/sdk-next/test/embedded.test.ts

@@ -181,7 +181,7 @@ it.live(
         const active = yield* opencode.sessions.active()
         const admitted = yield* opencode.sessions.prompt({
           sessionID: id,
-          prompt: fixture.sdk.Prompt.make({ text: "Do not run" }),
+          prompt: fixture.sdk.PromptInput.Prompt.make({ text: "Do not run" }),
           resume: false,
         })
         const context = yield* opencode.sessions.context({ sessionID: id })
@@ -192,7 +192,7 @@ it.live(
         const remainingContextEntries = yield* opencode.sessions.instructions.entry.list({ sessionID: id })
         const wake = yield* opencode.sessions.prompt({
           sessionID: id,
-          prompt: fixture.sdk.Prompt.make({ text: "Promote this input" }),
+          prompt: fixture.sdk.PromptInput.Prompt.make({ text: "Promote this input" }),
         })
         const prompted = yield* opencode.sessions.log({ sessionID: id, follow: true }).pipe(
           Stream.filter((event) => event.type === "session.prompt.promoted" && event.data.inputID === wake.id),
@@ -282,7 +282,7 @@ it.live(
         yield* opencode.sessions.create({ id, location: location(fixture) })
         yield* opencode.sessions.prompt({
           sessionID: id,
-          prompt: fixture.sdk.Prompt.make({ text: "Observe this input" }),
+          prompt: fixture.sdk.PromptInput.Prompt.make({ text: "Observe this input" }),
         })
 
         const event = yield* Deferred.await(prompted).pipe(Effect.timeout("4 seconds"))