@oh-my-pi/pi-catalog 15.10.11

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 (90) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/types/build.d.ts +3 -0
  3. package/dist/types/compat/anthropic.d.ts +11 -0
  4. package/dist/types/compat/apply.d.ts +7 -0
  5. package/dist/types/compat/openai.d.ts +21 -0
  6. package/dist/types/discovery/antigravity.d.ts +61 -0
  7. package/dist/types/discovery/codex.d.ts +38 -0
  8. package/dist/types/discovery/cursor-gen/agent_pb.d.ts +13022 -0
  9. package/dist/types/discovery/cursor.d.ts +23 -0
  10. package/dist/types/discovery/gemini.d.ts +25 -0
  11. package/dist/types/discovery/index.d.ts +4 -0
  12. package/dist/types/discovery/openai-compatible.d.ts +72 -0
  13. package/dist/types/effort.d.ts +9 -0
  14. package/dist/types/fireworks-model-id.d.ts +10 -0
  15. package/dist/types/hosts.d.ts +128 -0
  16. package/dist/types/identity/bundled.d.ts +6 -0
  17. package/dist/types/identity/classify.d.ts +45 -0
  18. package/dist/types/identity/equivalence.d.ts +46 -0
  19. package/dist/types/identity/family.d.ts +45 -0
  20. package/dist/types/identity/id.d.ts +12 -0
  21. package/dist/types/identity/index.d.ts +9 -0
  22. package/dist/types/identity/markers.d.ts +4 -0
  23. package/dist/types/identity/priority.d.ts +1 -0
  24. package/dist/types/identity/reference.d.ts +22 -0
  25. package/dist/types/identity/selection.d.ts +20 -0
  26. package/dist/types/index.d.ts +15 -0
  27. package/dist/types/model-cache.d.ts +17 -0
  28. package/dist/types/model-manager.d.ts +64 -0
  29. package/dist/types/model-thinking.d.ts +67 -0
  30. package/dist/types/models.d.ts +12 -0
  31. package/dist/types/provider-models/bundled-references.d.ts +11 -0
  32. package/dist/types/provider-models/descriptor-types.d.ts +74 -0
  33. package/dist/types/provider-models/descriptors.d.ts +384 -0
  34. package/dist/types/provider-models/discovery-constants.d.ts +11 -0
  35. package/dist/types/provider-models/google.d.ts +27 -0
  36. package/dist/types/provider-models/index.d.ts +6 -0
  37. package/dist/types/provider-models/ollama.d.ts +9 -0
  38. package/dist/types/provider-models/openai-compat.d.ts +385 -0
  39. package/dist/types/provider-models/special.d.ts +16 -0
  40. package/dist/types/types.d.ts +405 -0
  41. package/dist/types/utils.d.ts +5 -0
  42. package/dist/types/wire/codex.d.ts +26 -0
  43. package/dist/types/wire/gemini-headers.d.ts +18 -0
  44. package/dist/types/wire/github-copilot.d.ts +18 -0
  45. package/package.json +100 -0
  46. package/src/build.ts +40 -0
  47. package/src/compat/anthropic.ts +67 -0
  48. package/src/compat/apply.ts +15 -0
  49. package/src/compat/openai.ts +365 -0
  50. package/src/discovery/antigravity.ts +261 -0
  51. package/src/discovery/codex.ts +371 -0
  52. package/src/discovery/cursor-gen/agent_pb.ts +15274 -0
  53. package/src/discovery/cursor.ts +307 -0
  54. package/src/discovery/gemini.ts +249 -0
  55. package/src/discovery/index.ts +4 -0
  56. package/src/discovery/openai-compatible.ts +224 -0
  57. package/src/effort.ts +16 -0
  58. package/src/fireworks-model-id.ts +30 -0
  59. package/src/hosts.ts +114 -0
  60. package/src/identity/bundled.ts +38 -0
  61. package/src/identity/classify.ts +141 -0
  62. package/src/identity/equivalence.ts +870 -0
  63. package/src/identity/family.ts +88 -0
  64. package/src/identity/id.ts +81 -0
  65. package/src/identity/index.ts +9 -0
  66. package/src/identity/markers.ts +49 -0
  67. package/src/identity/priority.ts +56 -0
  68. package/src/identity/reference.ts +134 -0
  69. package/src/identity/selection.ts +65 -0
  70. package/src/index.ts +15 -0
  71. package/src/model-cache.ts +132 -0
  72. package/src/model-manager.ts +472 -0
  73. package/src/model-thinking.ts +407 -0
  74. package/src/models.json +75308 -0
  75. package/src/models.json.d.ts +9 -0
  76. package/src/models.ts +64 -0
  77. package/src/provider-models/bundled-references.ts +54 -0
  78. package/src/provider-models/descriptor-types.ts +79 -0
  79. package/src/provider-models/descriptors.ts +456 -0
  80. package/src/provider-models/discovery-constants.ts +11 -0
  81. package/src/provider-models/google.ts +105 -0
  82. package/src/provider-models/index.ts +6 -0
  83. package/src/provider-models/ollama.ts +154 -0
  84. package/src/provider-models/openai-compat.ts +3106 -0
  85. package/src/provider-models/special.ts +67 -0
  86. package/src/types.ts +470 -0
  87. package/src/utils.ts +27 -0
  88. package/src/wire/codex.ts +43 -0
  89. package/src/wire/gemini-headers.ts +41 -0
  90. package/src/wire/github-copilot.ts +72 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * GitHub Copilot wire metadata: API-key envelope parsing and endpoint
3
+ * derivation shared by catalog discovery and the pi-ai OAuth flow. The device
4
+ * login / token refresh flow lives in `@oh-my-pi/pi-ai`'s registry.
5
+ */
6
+
7
+ export const COPILOT_USER_AGENT = "opencode/1.3.15" as const;
8
+
9
+ export const OPENCODE_HEADERS = {
10
+ "User-Agent": COPILOT_USER_AGENT,
11
+ } as const;
12
+
13
+ type GitHubCopilotApiKeyPayload = {
14
+ token?: unknown;
15
+ enterpriseUrl?: unknown;
16
+ };
17
+
18
+ export type ParsedGitHubCopilotApiKey = {
19
+ accessToken: string;
20
+ enterpriseUrl?: string;
21
+ };
22
+
23
+ const PUBLIC_GITHUB_HOSTS = new Set(["api.github.com", "github.com", "www.github.com"]);
24
+
25
+ export function isPublicGitHubHost(host: string): boolean {
26
+ return PUBLIC_GITHUB_HOSTS.has(host.trim().toLowerCase());
27
+ }
28
+
29
+ export function normalizeGitHubCopilotEnterpriseDomain(input: string | undefined): string | undefined {
30
+ const trimmed = input?.trim();
31
+ if (!trimmed) return undefined;
32
+ const normalized = normalizeDomain(trimmed) ?? trimmed.toLowerCase();
33
+ if (!normalized || isPublicGitHubHost(normalized)) return undefined;
34
+ return normalized;
35
+ }
36
+
37
+ export function parseGitHubCopilotApiKey(apiKeyRaw: string): ParsedGitHubCopilotApiKey {
38
+ try {
39
+ const parsed = JSON.parse(apiKeyRaw) as GitHubCopilotApiKeyPayload;
40
+ if (typeof parsed.token === "string") {
41
+ return {
42
+ accessToken: parsed.token,
43
+ enterpriseUrl:
44
+ typeof parsed.enterpriseUrl === "string"
45
+ ? normalizeGitHubCopilotEnterpriseDomain(parsed.enterpriseUrl)
46
+ : undefined,
47
+ };
48
+ }
49
+ } catch {}
50
+
51
+ return { accessToken: apiKeyRaw };
52
+ }
53
+
54
+ export function normalizeDomain(input: string): string | null {
55
+ const trimmed = input.trim();
56
+ if (!trimmed) return null;
57
+ try {
58
+ const url = trimmed.includes("://") ? new URL(trimmed) : new URL(`https://${trimmed}`);
59
+ return url.hostname;
60
+ } catch {
61
+ return null;
62
+ }
63
+ }
64
+
65
+ export function getGitHubCopilotBaseUrl(enterpriseDomain?: string): string {
66
+ const normalizedEnterpriseDomain = normalizeGitHubCopilotEnterpriseDomain(enterpriseDomain);
67
+ if (!normalizedEnterpriseDomain) return "https://api.githubcopilot.com";
68
+ const host = normalizedEnterpriseDomain.startsWith("copilot-api.")
69
+ ? normalizedEnterpriseDomain
70
+ : `copilot-api.${normalizedEnterpriseDomain}`;
71
+ return `https://${host}`;
72
+ }