orynacode-ai 1.16.9 → 1.16.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "1.16.9",
3
+ "version": "1.16.10",
4
4
  "name": "orynacode-ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -6,6 +6,7 @@ import { InstallationVersion } from "@opencode-ai/core/installation/version"
6
6
  import { GlobalBus } from "@/bus/global"
7
7
 
8
8
  export async function upgrade() {
9
+ if (InstallationVersion.startsWith("0.0.0-")) return
9
10
  const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
10
11
  if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
11
12
  const method = await Installation.method()
@@ -224,6 +224,22 @@ function mapOrynaModels(data: Record<string, any>): Record<string, any> {
224
224
  return result
225
225
  }
226
226
 
227
+ export async function reAuthOryna(): Promise<string> {
228
+ const port = await startOAuthServer()
229
+ const state = randomState()
230
+ const redirectUri = `http://127.0.0.1:${port}/callback`
231
+ const loginUrl = `${ORYNA_LOGIN_URL}?redirect_uri=${encodeURIComponent(redirectUri)}&state=${state}`
232
+
233
+ const tokenPromise = waitForToken(state)
234
+ await open(loginUrl)
235
+
236
+ try {
237
+ return await tokenPromise
238
+ } finally {
239
+ stopOAuthServer()
240
+ }
241
+ }
242
+
227
243
  export async function OrynaAuthPlugin(input: PluginInput): Promise<Hooks> {
228
244
  return {
229
245
  provider: {
@@ -251,15 +267,18 @@ export async function OrynaAuthPlugin(input: PluginInput): Promise<Hooks> {
251
267
 
252
268
  if (jwtExpired(jwt)) {
253
269
  if (!_refreshPromise) {
254
- _refreshPromise = refreshJwt(jwt).catch(() => {
270
+ _refreshPromise = refreshJwt(jwt).catch(async () => {
255
271
  _refreshPromise = undefined
256
- return jwt
272
+ log.info("oryna token refresh failed, removing stale auth")
273
+ await (input.client as any)._client.delete({ url: "/auth/{id}", path: { id: "oryna" } }).catch(() => {})
274
+ log.info("oryna stale auth removed")
275
+ return ""
257
276
  })
258
277
  }
259
278
  jwt = await _refreshPromise
260
279
  _refreshPromise = undefined
261
280
 
262
- if (jwt !== auth.key) {
281
+ if (jwt && jwt !== auth.key) {
263
282
  await input.client.auth
264
283
  .set({
265
284
  path: { id: "oryna" },
@@ -269,7 +288,7 @@ export async function OrynaAuthPlugin(input: PluginInput): Promise<Hooks> {
269
288
  }
270
289
  }
271
290
 
272
- return { apiKey: jwt }
291
+ return jwt ? { apiKey: jwt } : {}
273
292
  },
274
293
  methods: [
275
294
  {
@@ -277,36 +296,20 @@ export async function OrynaAuthPlugin(input: PluginInput): Promise<Hooks> {
277
296
  label: "Login with Oryna AI (Browser)",
278
297
  authorize: async () => {
279
298
  try {
280
- const port = await startOAuthServer()
281
- const state = randomState()
282
- const redirectUri = `http://127.0.0.1:${port}/callback`
283
- const loginUrl = `${ORYNA_LOGIN_URL}?redirect_uri=${encodeURIComponent(redirectUri)}&state=${state}`
284
-
285
- const tokenPromise = waitForToken(state)
286
-
287
- await open(loginUrl)
288
-
299
+ const tokenPromise = reAuthOryna()
289
300
  return {
290
- url: loginUrl,
301
+ url: ORYNA_LOGIN_URL,
291
302
  instructions: "Complete login in your browser. This window will close automatically when done.",
292
303
  method: "auto" as const,
293
304
  callback: async () => {
294
305
  try {
295
- const token = await tokenPromise
296
- return {
297
- type: "success" as const,
298
- key: token,
299
- }
300
- } catch (err) {
301
- log.error("oryna login callback failed", { error: err })
306
+ return { type: "success" as const, key: await tokenPromise }
307
+ } catch {
302
308
  return { type: "failed" as const }
303
- } finally {
304
- stopOAuthServer()
305
309
  }
306
310
  },
307
311
  }
308
- } catch (err) {
309
- log.error("oryna login authorize failed", { error: err })
312
+ } catch {
310
313
  return {
311
314
  url: ORYNA_LOGIN_URL,
312
315
  instructions: "Failed to start login server. Please use API key instead.",
@@ -952,7 +952,14 @@ export const layer = Layer.effect(
952
952
  sessionID: ctx.assistantMessage.sessionID,
953
953
  error: ctx.assistantMessage.error,
954
954
  })
955
- yield* status.set(ctx.sessionID, { type: "idle" })
955
+ if (
956
+ error.name === "ProviderAuthError" ||
957
+ (error.data as any)?.statusCode === 401
958
+ ) {
959
+ yield* status.set(ctx.sessionID, { type: "needs_auth", providerID: String(input.model.providerID) })
960
+ } else {
961
+ yield* status.set(ctx.sessionID, { type: "idle" })
962
+ }
956
963
  })
957
964
 
958
965
  const process = Effect.fn("SessionProcessor.process")(function* (streamInput: LLM.StreamInput) {
@@ -28,6 +28,10 @@ export const Info = Schema.Union([
28
28
  Schema.Struct({
29
29
  type: Schema.Literal("busy"),
30
30
  }),
31
+ Schema.Struct({
32
+ type: Schema.Literal("needs_auth"),
33
+ providerID: Schema.String,
34
+ }),
31
35
  ]).annotate({ identifier: "SessionStatus" })
32
36
  export type Info = Schema.Schema.Type<typeof Info>
33
37
 
@@ -76,6 +80,7 @@ export const layer = Layer.effect(
76
80
 
77
81
  const set = Effect.fn("SessionStatus.set")(function* (sessionID: SessionID, status: Info) {
78
82
  const data = yield* InstanceState.get(state)
83
+ if (status.type === "idle" && data.get(sessionID)?.type === "needs_auth") return
79
84
  yield* events.publish(Event.Status, { sessionID, status })
80
85
  if (status.type === "idle") {
81
86
  yield* events.publish(Event.Idle, { sessionID })
@@ -240,7 +240,7 @@ export const layer: Layer.Layer<
240
240
  question: Tool.init(question),
241
241
  lsp: Tool.init(lsptool),
242
242
  plan: Tool.init(plan),
243
- reply: Tool.init(replytool),
243
+ collab_reply: Tool.init(replytool),
244
244
  })
245
245
 
246
246
  return {
@@ -260,7 +260,7 @@ export const layer: Layer.Layer<
260
260
  tool.search,
261
261
  tool.skill,
262
262
  tool.patch,
263
- tool.reply,
263
+ tool.collab_reply,
264
264
  ...(flags.experimentalLspTool ? [tool.lsp] : []),
265
265
  ...(flags.experimentalPlanMode && flags.client === "cli" ? [tool.plan] : []),
266
266
  ],
package/src/tool/reply.ts CHANGED
@@ -12,7 +12,7 @@ export const Parameters = Schema.Struct({
12
12
  })
13
13
 
14
14
  export const ReplyTool = Tool.define(
15
- "reply",
15
+ "collab_reply",
16
16
  Effect.gen(function* () {
17
17
  return {
18
18
  description: