opencode-translate 0.1.2 → 0.2.0

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.
Files changed (41) hide show
  1. package/README.md +11 -11
  2. package/package.json +7 -4
  3. package/src/activation/chat-message.ts +164 -0
  4. package/src/activation/index.ts +38 -0
  5. package/src/activation/logging.ts +11 -0
  6. package/src/activation/messages-transform.ts +38 -0
  7. package/src/activation/metadata.ts +41 -0
  8. package/src/activation/parts.ts +53 -0
  9. package/src/activation/question-hooks.ts +95 -0
  10. package/src/activation/state.ts +97 -0
  11. package/src/activation/text-complete.ts +51 -0
  12. package/src/activation/trigger.ts +57 -0
  13. package/src/activation/types.ts +41 -0
  14. package/src/activation.ts +1 -633
  15. package/src/anthropic-oauth.ts +3 -3
  16. package/src/auth/codex-request.ts +108 -0
  17. package/src/auth/codex-response.ts +78 -0
  18. package/src/auth/codex-shared.ts +3 -0
  19. package/src/auth/headers.ts +18 -0
  20. package/src/auth/index.ts +153 -0
  21. package/src/auth/oauth-fetch.ts +100 -0
  22. package/src/auth/refresh.ts +102 -0
  23. package/src/auth/retry.ts +70 -0
  24. package/src/auth/store.ts +45 -0
  25. package/src/auth/types.ts +27 -0
  26. package/src/auth.ts +1 -725
  27. package/src/constants/errors.ts +24 -0
  28. package/src/constants/guards.ts +33 -0
  29. package/src/constants/options.ts +41 -0
  30. package/src/constants/plugin.ts +10 -0
  31. package/src/constants/types.ts +144 -0
  32. package/src/constants.ts +5 -261
  33. package/src/labels.ts +2 -16
  34. package/src/prompts.ts +2 -17
  35. package/src/question-tool.ts +1 -1
  36. package/src/translator/index.ts +125 -0
  37. package/src/translator/part-id.ts +43 -0
  38. package/src/translator/provider.ts +81 -0
  39. package/src/translator/retry.ts +62 -0
  40. package/src/translator/types.ts +17 -0
  41. package/src/translator.ts +1 -326
@@ -0,0 +1,27 @@
1
+ import type { FetchLike, OAuthInfo, ProviderInfo } from "../constants"
2
+
3
+ export interface ResolvedCredential {
4
+ providerID: string
5
+ provider?: ProviderInfo
6
+ apiKey?: string
7
+ fetch?: FetchLike
8
+ mode: "apiKey" | "oauth" | "default"
9
+ }
10
+
11
+ export interface AuthDependencies {
12
+ fetchImpl?: FetchLike
13
+ now?: () => number
14
+ sleep?: (ms: number) => Promise<void>
15
+ readFile?: (filePath: string, encoding: BufferEncoding) => Promise<string>
16
+ stat?: (filePath: string) => Promise<{ mode: number }>
17
+ packageVersion?: string
18
+ }
19
+
20
+ export type AuthRuntime = Required<Pick<AuthDependencies, "fetchImpl" | "sleep">>
21
+
22
+ export type OAuthResolver = (providerID: string) => Promise<OAuthInfo | undefined>
23
+
24
+ export interface CodexBodyRewrite {
25
+ body: BodyInit | null | undefined
26
+ originalStream: boolean
27
+ }