saeeol 1.2.7 → 1.2.8
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/bin/saeeol +187 -0
- package/package.json +4 -2
- package/src/session/core/session.ts +1 -39
- package/tsconfig.json +19 -0
package/bin/saeeol
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process")
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
const path = require("path")
|
|
6
|
+
const os = require("os")
|
|
7
|
+
|
|
8
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
})
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(result.error.message)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
+
process.exit(code)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const envPath = process.env.SAEEOL_BIN_PATH
|
|
21
|
+
if (envPath) {
|
|
22
|
+
run(envPath)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
+
const scriptDir = path.dirname(scriptPath)
|
|
27
|
+
|
|
28
|
+
// fall through to findBinary() if cached binary fails
|
|
29
|
+
const cached = path.join(scriptDir, ".saeeol")
|
|
30
|
+
if (fs.existsSync(cached)) {
|
|
31
|
+
const result = childProcess.spawnSync(cached, process.argv.slice(2), {
|
|
32
|
+
stdio: "inherit",
|
|
33
|
+
})
|
|
34
|
+
if (!result.error) {
|
|
35
|
+
const code = typeof result.status === "number" ? result.status : 0
|
|
36
|
+
process.exit(code)
|
|
37
|
+
}
|
|
38
|
+
// cached binary failed (e.g. wrong platform/arch, missing dynamic linker),
|
|
39
|
+
// fall through to findBinary() which has better variant detection
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const platformMap = {
|
|
43
|
+
darwin: "darwin",
|
|
44
|
+
linux: "linux",
|
|
45
|
+
win32: "windows",
|
|
46
|
+
}
|
|
47
|
+
const archMap = {
|
|
48
|
+
x64: "x64",
|
|
49
|
+
arm64: "arm64",
|
|
50
|
+
arm: "arm",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let platform = platformMap[os.platform()]
|
|
54
|
+
if (!platform) {
|
|
55
|
+
platform = os.platform()
|
|
56
|
+
}
|
|
57
|
+
let arch = archMap[os.arch()]
|
|
58
|
+
if (!arch) {
|
|
59
|
+
arch = os.arch()
|
|
60
|
+
}
|
|
61
|
+
const base = "saeeol-" + platform + "-" + arch
|
|
62
|
+
const binary = platform === "windows" ? "saeeol.exe" : "saeeol"
|
|
63
|
+
|
|
64
|
+
function supportsAvx2() {
|
|
65
|
+
if (arch !== "x64") return false
|
|
66
|
+
|
|
67
|
+
if (platform === "linux") {
|
|
68
|
+
try {
|
|
69
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
70
|
+
} catch {
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (platform === "darwin") {
|
|
76
|
+
try {
|
|
77
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
78
|
+
encoding: "utf8",
|
|
79
|
+
timeout: 1500,
|
|
80
|
+
})
|
|
81
|
+
if (result.status !== 0) return false
|
|
82
|
+
return (result.stdout || "").trim() === "1"
|
|
83
|
+
} catch {
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (platform === "windows") {
|
|
89
|
+
const cmd =
|
|
90
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
91
|
+
|
|
92
|
+
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
93
|
+
try {
|
|
94
|
+
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
95
|
+
encoding: "utf8",
|
|
96
|
+
timeout: 3000,
|
|
97
|
+
windowsHide: true,
|
|
98
|
+
})
|
|
99
|
+
if (result.status !== 0) continue
|
|
100
|
+
const out = (result.stdout || "").trim().toLowerCase()
|
|
101
|
+
if (out === "true" || out === "1") return true
|
|
102
|
+
if (out === "false" || out === "0") return false
|
|
103
|
+
} catch {
|
|
104
|
+
continue
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const names = (() => {
|
|
115
|
+
const avx2 = supportsAvx2()
|
|
116
|
+
const baseline = arch === "x64" && !avx2
|
|
117
|
+
|
|
118
|
+
if (platform === "linux") {
|
|
119
|
+
const musl = (() => {
|
|
120
|
+
try {
|
|
121
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
122
|
+
} catch {
|
|
123
|
+
// ignore
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
128
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
129
|
+
if (text.includes("musl")) return true
|
|
130
|
+
} catch {
|
|
131
|
+
// ignore
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return false
|
|
135
|
+
})()
|
|
136
|
+
|
|
137
|
+
if (musl) {
|
|
138
|
+
if (arch === "x64") {
|
|
139
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
140
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
141
|
+
}
|
|
142
|
+
return [`${base}-musl`, base]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (arch === "x64") {
|
|
146
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
147
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
148
|
+
}
|
|
149
|
+
return [base, `${base}-musl`]
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (arch === "x64") {
|
|
153
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
154
|
+
return [base, `${base}-baseline`]
|
|
155
|
+
}
|
|
156
|
+
return [base]
|
|
157
|
+
})()
|
|
158
|
+
|
|
159
|
+
function findBinary(startDir) {
|
|
160
|
+
let current = startDir
|
|
161
|
+
for (;;) {
|
|
162
|
+
const modules = path.join(current, "node_modules")
|
|
163
|
+
if (fs.existsSync(modules)) {
|
|
164
|
+
for (const name of names) {
|
|
165
|
+
const candidate = path.join(modules, name, "bin", binary)
|
|
166
|
+
if (fs.existsSync(candidate)) return candidate
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const parent = path.dirname(current)
|
|
170
|
+
if (parent === current) {
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
current = parent
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const resolved = findBinary(scriptDir)
|
|
178
|
+
if (!resolved) {
|
|
179
|
+
console.error(
|
|
180
|
+
"It seems that your package manager failed to install the right version of the SAEEOL CLI for your platform. You can try manually installing " +
|
|
181
|
+
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
182
|
+
" package",
|
|
183
|
+
)
|
|
184
|
+
process.exit(1)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
run(resolved)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"name": "saeeol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -204,6 +204,8 @@
|
|
|
204
204
|
},
|
|
205
205
|
"peerDependencies": {},
|
|
206
206
|
"files": [
|
|
207
|
-
"src"
|
|
207
|
+
"src",
|
|
208
|
+
"bin",
|
|
209
|
+
"tsconfig.json"
|
|
208
210
|
]
|
|
209
211
|
}
|
|
@@ -279,45 +279,7 @@ const UpdatedEventSchema = Schema.Struct({
|
|
|
279
279
|
info: UpdatedInfo,
|
|
280
280
|
})
|
|
281
281
|
|
|
282
|
-
export
|
|
283
|
-
Created: SyncEvent.define({
|
|
284
|
-
type: "session.created",
|
|
285
|
-
version: 1,
|
|
286
|
-
aggregate: "sessionID",
|
|
287
|
-
schema: CreatedEventSchema,
|
|
288
|
-
}),
|
|
289
|
-
Updated: SyncEvent.define({
|
|
290
|
-
type: "session.updated",
|
|
291
|
-
version: 1,
|
|
292
|
-
aggregate: "sessionID",
|
|
293
|
-
schema: UpdatedEventSchema,
|
|
294
|
-
busSchema: CreatedEventSchema,
|
|
295
|
-
}),
|
|
296
|
-
Deleted: SyncEvent.define({
|
|
297
|
-
type: "session.deleted",
|
|
298
|
-
version: 1,
|
|
299
|
-
aggregate: "sessionID",
|
|
300
|
-
schema: CreatedEventSchema,
|
|
301
|
-
}),
|
|
302
|
-
Diff: BusEvent.define(
|
|
303
|
-
"session.diff",
|
|
304
|
-
Schema.Struct({
|
|
305
|
-
sessionID: SessionID,
|
|
306
|
-
diff: Schema.Array(Snapshot.FileDiff),
|
|
307
|
-
}),
|
|
308
|
-
),
|
|
309
|
-
Error: BusEvent.define(
|
|
310
|
-
"session.error",
|
|
311
|
-
Schema.Struct({
|
|
312
|
-
sessionID: Schema.optional(SessionID),
|
|
313
|
-
// Reuses MessageV2.Assistant.fields.error (already Schema.optional) so
|
|
314
|
-
// the derived zod keeps the same discriminated-union shape on the bus.
|
|
315
|
-
error: MessageV2.Assistant.fields.error,
|
|
316
|
-
}),
|
|
317
|
-
),
|
|
318
|
-
TurnOpen: SaeeolSession.Event.TurnOpen,
|
|
319
|
-
TurnClose: SaeeolSession.Event.TurnClose,
|
|
320
|
-
}
|
|
282
|
+
export { Event } from "./session-types"
|
|
321
283
|
|
|
322
284
|
export function plan(input: { slug: string; time: { created: number } }, instance: InstanceContext) {
|
|
323
285
|
const base = instance.project.vcs
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "@tsconfig/bun/tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"jsx": "preserve",
|
|
6
|
+
"jsxImportSource": "@opentui/solid",
|
|
7
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
8
|
+
"types": [],
|
|
9
|
+
"noUncheckedIndexedAccess": false,
|
|
10
|
+
"customConditions": ["browser"],
|
|
11
|
+
"paths": {
|
|
12
|
+
"@/*": ["./src/*"],
|
|
13
|
+
"@/saeeol/*": ["./src/overlay/*"],
|
|
14
|
+
"@tui/*": ["./src/cli/cmd/tui/*"],
|
|
15
|
+
"@test/*": ["./test/*"]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"exclude": ["src/provider/models-snapshot.ts"]
|
|
19
|
+
}
|