saeeol 1.0.6 → 1.0.7

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.0.6",
3
+ "version": "1.0.7",
4
4
  "name": "saeeol",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/script/build.ts CHANGED
@@ -55,7 +55,99 @@ const baselineFlag = process.argv.includes("--baseline")
55
55
  const skipInstall = process.argv.includes("--skip-install")
56
56
  const sourcemapsFlag = process.argv.includes("--sourcemaps")
57
57
  const plugin = createSolidTransformPlugin()
58
- async function copyTreeSitterWasms(outputDir: string) {
58
+
59
+ // ══════════════════════════════════════════════════════════════════
60
+ // Tier-based tree-sitter WASM selection
61
+ //
62
+ // LIGHT = 5 langs (markdown, json, yaml, toml, tsx) ~8 MB
63
+ // CODE = 15 langs (+ python, rust, go, c, cpp...) ~18 MB
64
+ // MASTER = all 37 langs ~50 MB
65
+ // ══════════════════════════════════════════════════════════════════
66
+
67
+ // ══════════════════════════════════════════════════════════════════
68
+ // Tier-based external packages
69
+ // These packages are excluded from the bundle entirely
70
+ // ══════════════════════════════════════════════════════════════════
71
+
72
+ const allProviderPkgs = [
73
+ "@ai-sdk/amazon-bedrock",
74
+ "@ai-sdk/anthropic",
75
+ "@ai-sdk/azure",
76
+ "@ai-sdk/google",
77
+ "@ai-sdk/google-vertex",
78
+ "@ai-sdk/openai",
79
+ "@ai-sdk/openai-compatible",
80
+ "@openrouter/ai-sdk-provider",
81
+ "@ai-sdk/xai",
82
+ "@ai-sdk/mistral",
83
+ "@ai-sdk/groq",
84
+ "@ai-sdk/deepinfra",
85
+ "@ai-sdk/cerebras",
86
+ "@ai-sdk/cohere",
87
+ "@ai-sdk/gateway",
88
+ "@ai-sdk/togetherai",
89
+ "@ai-sdk/perplexity",
90
+ "@ai-sdk/vercel",
91
+ "@ai-sdk/alibaba",
92
+ "gitlab-ai-provider",
93
+ "venice-ai-sdk-provider",
94
+ ]
95
+
96
+ const lightRequired = new Set([
97
+ "@ai-sdk/anthropic",
98
+ "@ai-sdk/openai",
99
+ "@ai-sdk/openai-compatible",
100
+ "@ai-sdk/google",
101
+ "@saeeol/gateway",
102
+ ])
103
+
104
+ const codeRequired = new Set([
105
+ ...lightRequired,
106
+ "@ai-sdk/amazon-bedrock",
107
+ "@ai-sdk/azure",
108
+ "@ai-sdk/google-vertex",
109
+ "@openrouter/ai-sdk-provider",
110
+ "@ai-sdk/groq",
111
+ "@ai-sdk/deepinfra",
112
+ "@ai-sdk/gateway",
113
+ "@ai-sdk/alibaba",
114
+ "@ai-sdk/cerebras",
115
+ ])
116
+
117
+ function tierExternals(tier: string): string[] {
118
+ if (tier === "master") return []
119
+ const required = tier === "light" ? lightRequired : codeRequired
120
+ return allProviderPkgs.filter((p) => !required.has(p))
121
+ }
122
+
123
+ const tierArg = process.argv.find((a) => a.startsWith("--tier="))?.split("=")[1] ?? "master"
124
+
125
+ const treeSitterLanguages: Record<string, string[]> = {
126
+ light: [
127
+ "markdown", "markdown_inline",
128
+ "json",
129
+ "yaml",
130
+ "toml",
131
+ "tsx", "typescript",
132
+ ],
133
+ code: [
134
+ "markdown", "markdown_inline",
135
+ "json",
136
+ "yaml",
137
+ "toml",
138
+ "tsx", "typescript",
139
+ "python",
140
+ "rust",
141
+ "go",
142
+ "c", "cpp",
143
+ "java",
144
+ "javascript",
145
+ "bash",
146
+ ],
147
+ master: [], // empty = all
148
+ }
149
+
150
+ async function copyTreeSitterWasms(outputDir: string, tier: string) {
59
151
  const runtimeWasmPath = require.resolve("web-tree-sitter/tree-sitter.wasm")
60
152
  const languagePackagePath = require.resolve("tree-sitter-wasms/package.json")
61
153
  const languageWasmDir = path.join(path.dirname(languagePackagePath), "out")
@@ -64,13 +156,21 @@ async function copyTreeSitterWasms(outputDir: string) {
64
156
  await fs.promises.mkdir(targetDir, { recursive: true })
65
157
  await fs.promises.copyFile(runtimeWasmPath, path.join(targetDir, "tree-sitter.wasm"))
66
158
 
67
- const languageWasmFiles = (await fs.promises.readdir(languageWasmDir)).filter((file) => file.endsWith(".wasm"))
159
+ const allWasmFiles = (await fs.promises.readdir(languageWasmDir)).filter((file) => file.endsWith(".wasm"))
160
+ const allowed = treeSitterLanguages[tier]
161
+
162
+ const filesToCopy = allowed.length === 0
163
+ ? allWasmFiles
164
+ : allWasmFiles.filter((file) => {
165
+ const langName = file.replace("tree-sitter-", "").replace(".wasm", "")
166
+ return allowed.some((a) => langName === a || langName.startsWith(a + "-"))
167
+ })
68
168
 
69
169
  await Promise.all(
70
- languageWasmFiles.map((file) => fs.promises.copyFile(path.join(languageWasmDir, file), path.join(targetDir, file))),
170
+ filesToCopy.map((file) => fs.promises.copyFile(path.join(languageWasmDir, file), path.join(targetDir, file))),
71
171
  )
72
172
 
73
- console.log(`copied ${languageWasmFiles.length + 1} tree-sitter wasm files to ${targetDir}`)
173
+ console.log(`copied ${filesToCopy.length + 1} tree-sitter wasm files to ${targetDir} (tier=${tier})`)
74
174
  }
75
175
 
76
176
  const allTargets: {
@@ -192,7 +292,7 @@ for (const item of targets) {
192
292
  tsconfig: "./tsconfig.json",
193
293
  plugins: [plugin],
194
294
  sourcemap: Script.release ? "none" : "external",
195
- external: ["node-gyp", ...LanceDBRuntime.external],
295
+ external: ["node-gyp", ...LanceDBRuntime.external, ...tierExternals(tierArg)],
196
296
  format: "esm",
197
297
  minify: true,
198
298
  splitting: true,
@@ -216,10 +316,11 @@ for (const item of targets) {
216
316
  SAEEOL_CHANNEL: `'${Script.channel}'`,
217
317
  SAEEOL_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "",
218
318
  SAEEOL_BUILD_KIND: Script.release ? `'release'` : `'source'`,
319
+ SAEEOL_TIER: `'${tierArg}'`,
219
320
  },
220
321
  })
221
322
 
222
- await copyTreeSitterWasms(path.resolve(dir, `dist/${name}/bin`))
323
+ await copyTreeSitterWasms(path.resolve(dir, `dist/${name}/bin`), tierArg)
223
324
  if (item.os === "linux") {
224
325
  const interpreters: Record<string, string> = {
225
326
  x64: "/lib64/ld-linux-x86-64.so.2",
@@ -1,4 +1,3 @@
1
- import { SAEEOL_BUNDLED_PROVIDERS } from "@/saeeol/provider/provider"
2
1
  import type { BundledSDK } from "./provider-types"
3
2
 
4
3
  export function shouldUseCopilotResponsesApi(modelID: string): boolean {
@@ -11,30 +10,32 @@ export function useLanguageModel(sdk: any) {
11
10
  return sdk.responses === undefined && sdk.chat === undefined
12
11
  }
13
12
 
14
- export const BUNDLED_PROVIDERS: Record<string, () => Promise<(opts: any) => BundledSDK>> = {
15
- "@ai-sdk/amazon-bedrock": () => import("@ai-sdk/amazon-bedrock").then((m) => m.createAmazonBedrock),
16
- "@ai-sdk/anthropic": () => import("@ai-sdk/anthropic").then((m) => m.createAnthropic),
17
- "@ai-sdk/azure": () => import("@ai-sdk/azure").then((m) => m.createAzure),
18
- "@ai-sdk/google": () => import("@ai-sdk/google").then((m) => m.createGoogleGenerativeAI),
19
- "@ai-sdk/google-vertex": () => import("@ai-sdk/google-vertex").then((m) => m.createVertex),
20
- "@ai-sdk/google-vertex/anthropic": () =>
21
- import("@ai-sdk/google-vertex/anthropic").then((m) => m.createVertexAnthropic),
22
- "@ai-sdk/openai": () => import("@ai-sdk/openai").then((m) => m.createOpenAI),
23
- "@ai-sdk/openai-compatible": () => import("@ai-sdk/openai-compatible").then((m) => m.createOpenAICompatible),
24
- "@openrouter/ai-sdk-provider": () => import("@openrouter/ai-sdk-provider").then((m) => m.createOpenRouter),
25
- "@ai-sdk/xai": () => import("@ai-sdk/xai").then((m) => m.createXai),
26
- "@ai-sdk/mistral": () => import("@ai-sdk/mistral").then((m) => m.createMistral),
27
- "@ai-sdk/groq": () => import("@ai-sdk/groq").then((m) => m.createGroq),
28
- "@ai-sdk/deepinfra": () => import("@ai-sdk/deepinfra").then((m) => m.createDeepInfra),
29
- "@ai-sdk/cerebras": () => import("@ai-sdk/cerebras").then((m) => m.createCerebras),
30
- "@ai-sdk/cohere": () => import("@ai-sdk/cohere").then((m) => m.createCohere),
31
- "@ai-sdk/gateway": () => import("@ai-sdk/gateway").then((m) => m.createGateway),
32
- "@ai-sdk/togetherai": () => import("@ai-sdk/togetherai").then((m) => m.createTogetherAI),
33
- "@ai-sdk/perplexity": () => import("@ai-sdk/perplexity").then((m) => m.createPerplexity),
34
- "@ai-sdk/vercel": () => import("@ai-sdk/vercel").then((m) => m.createVercel),
35
- "@ai-sdk/alibaba": () => import("@ai-sdk/alibaba").then((m) => m.createAlibaba),
36
- "gitlab-ai-provider": () => import("gitlab-ai-provider").then((m) => m.createGitLab),
37
- "@ai-sdk/github-copilot": () => import("./sdk/copilot/copilot-provider").then((m) => m.createOpenaiCompatible),
38
- "venice-ai-sdk-provider": () => import("venice-ai-sdk-provider").then((m) => m.createVenice),
39
- ...SAEEOL_BUNDLED_PROVIDERS,
13
+ // ╔══════════════════════════════════════════════════════════════════╗
14
+ // ║ 티어별 provider 로딩 ║
15
+ // ║ ║
16
+ // ║ SAEEOL_TIER는 build.ts define으로 "light"|"code"|"master" 주입 ║
17
+ // ║ Bun은 dead branch를 제거하므로 다른 티어의 import() 제외됨 ║
18
+ // ╚══════════════════════════════════════════════════════════════════╝
19
+
20
+ declare const SAEEOL_TIER: string
21
+
22
+ type ProviderLoader = () => Promise<(opts: any) => BundledSDK>
23
+
24
+ // 티어별 파일에서 각각 서로 다른 provider 집합을 import
25
+ // Bun은 조건에 맞지 않는 branch의 import() dead code로 처리
26
+
27
+ function getProviders(): Record<string, ProviderLoader> {
28
+ if (SAEEOL_TIER === "light") {
29
+ // Bun replaces SAEEOL_TIER with literal, dead-eliminates else branches
30
+ const m = require("./tiers/light") as typeof import("./tiers/light")
31
+ return m.lightProviders
32
+ }
33
+ if (SAEEOL_TIER === "code") {
34
+ const m = require("./tiers/code") as typeof import("./tiers/code")
35
+ return m.codeProviders
36
+ }
37
+ const m = require("./tiers/master") as typeof import("./tiers/master")
38
+ return m.masterProviders
40
39
  }
40
+
41
+ export const BUNDLED_PROVIDERS: Record<string, ProviderLoader> = getProviders()
@@ -0,0 +1,21 @@
1
+ // CODE 티어 provider 맵 — LIGHT + 개발용 provider
2
+ import type { BundledSDK } from "../../provider/provider-types"
3
+ import { createSaeeol } from "@saeeol/gateway"
4
+ import { lightProviders } from "./light"
5
+
6
+ type L = () => Promise<(opts: any) => BundledSDK>
7
+
8
+ export const codeProviders: Record<string, L> = {
9
+ ...lightProviders,
10
+ "@ai-sdk/amazon-bedrock": () => import("@ai-sdk/amazon-bedrock").then((m) => m.createAmazonBedrock),
11
+ "@ai-sdk/azure": () => import("@ai-sdk/azure").then((m) => m.createAzure),
12
+ "@ai-sdk/google-vertex": () => import("@ai-sdk/google-vertex").then((m) => m.createVertex),
13
+ "@ai-sdk/google-vertex/anthropic": () =>
14
+ import("@ai-sdk/google-vertex/anthropic").then((m) => m.createVertexAnthropic),
15
+ "@openrouter/ai-sdk-provider": () => import("@openrouter/ai-sdk-provider").then((m) => m.createOpenRouter),
16
+ "@ai-sdk/groq": () => import("@ai-sdk/groq").then((m) => m.createGroq),
17
+ "@ai-sdk/deepinfra": () => import("@ai-sdk/deepinfra").then((m) => m.createDeepInfra),
18
+ "@ai-sdk/gateway": () => import("@ai-sdk/gateway").then((m) => m.createGateway),
19
+ "@ai-sdk/alibaba": () => import("@ai-sdk/alibaba").then((m) => m.createAlibaba),
20
+ "@ai-sdk/cerebras": () => import("@ai-sdk/cerebras").then((m) => m.createCerebras),
21
+ }
@@ -0,0 +1,14 @@
1
+ // LIGHT 티어 provider 맵 — 최소 provider만
2
+ import type { BundledSDK } from "../../provider/provider-types"
3
+ import { createSaeeol } from "@saeeol/gateway"
4
+
5
+ type L = () => Promise<(opts: any) => BundledSDK>
6
+
7
+ export const lightProviders: Record<string, L> = {
8
+ "@saeeol/gateway": async () => createSaeeol as any,
9
+ "@ai-sdk/anthropic": () => import("@ai-sdk/anthropic").then((m) => m.createAnthropic),
10
+ "@ai-sdk/openai": () => import("@ai-sdk/openai").then((m) => m.createOpenAI),
11
+ "@ai-sdk/openai-compatible": () => import("@ai-sdk/openai-compatible").then((m) => m.createOpenAICompatible),
12
+ "@ai-sdk/google": () => import("@ai-sdk/google").then((m) => m.createGoogleGenerativeAI),
13
+ "@ai-sdk/github-copilot": () => import("../sdk/copilot/copilot-provider").then((m) => m.createOpenaiCompatible),
14
+ }
@@ -0,0 +1,17 @@
1
+ // MASTER 티어 provider 맵 — 전체 provider
2
+ import type { BundledSDK } from "../../provider/provider-types"
3
+ import { codeProviders } from "./code"
4
+
5
+ type L = () => Promise<(opts: any) => BundledSDK>
6
+
7
+ export const masterProviders: Record<string, L> = {
8
+ ...codeProviders,
9
+ "@ai-sdk/xai": () => import("@ai-sdk/xai").then((m) => m.createXai),
10
+ "@ai-sdk/mistral": () => import("@ai-sdk/mistral").then((m) => m.createMistral),
11
+ "@ai-sdk/cohere": () => import("@ai-sdk/cohere").then((m) => m.createCohere),
12
+ "@ai-sdk/togetherai": () => import("@ai-sdk/togetherai").then((m) => m.createTogetherAI),
13
+ "@ai-sdk/perplexity": () => import("@ai-sdk/perplexity").then((m) => m.createPerplexity),
14
+ "@ai-sdk/vercel": () => import("@ai-sdk/vercel").then((m) => m.createVercel),
15
+ "gitlab-ai-provider": () => import("gitlab-ai-provider").then((m) => m.createGitLab),
16
+ "venice-ai-sdk-provider": () => import("venice-ai-sdk-provider").then((m) => m.createVenice),
17
+ }