slopcode 0.2.143 → 0.2.146

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.
Binary file
package/bin/slopcode CHANGED
@@ -154,7 +154,7 @@ function supportsAvx2() {
154
154
  function names(prefix) {
155
155
  const kind = libc()
156
156
  const base = kind === "bionic" ? `${prefix}-android-${arch}` : `${prefix}-${platform}-${arch}`
157
- if (kind === "bionic") return [`@slopcode-ai/slopcode-android-${arch}`, base]
157
+ if (kind === "bionic") return [base, `@slopcode-ai/slopcode-android-${arch}`, `slopcode-android-${arch}`]
158
158
  const avx2 = supportsAvx2()
159
159
  const baseline = arch === "x64" && !avx2
160
160
 
@@ -261,6 +261,50 @@ function androidBun(arch) {
261
261
  ].find((item) => item && fs.existsSync(item))
262
262
  }
263
263
 
264
+ function androidRuntimeArgs(args) {
265
+ const out = []
266
+ let project
267
+ let skip = false
268
+ const valueOptions = new Set(["--cwd", "--session", "--model", "--agent", "--prompt", "--view-id", "--log-level"])
269
+ for (let i = 0; i < args.length; i++) {
270
+ const arg = args[i]
271
+ if (skip) {
272
+ skip = false
273
+ continue
274
+ }
275
+ if (arg === "--print-logs" || arg === "--pure") continue
276
+ if (arg.startsWith("--log-level=")) continue
277
+ if (valueOptions.has(arg)) {
278
+ if (arg !== "--log-level") {
279
+ out.push(arg, args[i + 1])
280
+ }
281
+ skip = true
282
+ continue
283
+ }
284
+ if (!project && arg && !arg.startsWith("-")) {
285
+ project = arg
286
+ continue
287
+ }
288
+ out.push(arg)
289
+ }
290
+ if (project && !out.includes("--cwd")) {
291
+ out.unshift("--cwd", path.resolve(process.env.PWD || process.cwd(), project))
292
+ }
293
+ return out.filter((item) => item !== undefined)
294
+ }
295
+
296
+ function androidRuntimeEnv(runtimeRoot, extra = {}) {
297
+ return {
298
+ SLOPCODE_BIONIC: "1",
299
+ SLOPCODE_VERSION: pkg.version,
300
+ SLOPCODE_ANDROID_ROOT: runtimeRoot,
301
+ SLOPCODE_ANDROID_HOST_PATH: path.join(runtimeRoot, "bin", "slopcode-android-host"),
302
+ SLOPCODE_ANDROID_HOST: process.env.SLOPCODE_ANDROID_HOST || "sidecar",
303
+ NODE_PATH: [path.join(rootDir, "android-modules"), process.env.NODE_PATH].filter(Boolean).join(path.delimiter),
304
+ ...extra,
305
+ }
306
+ }
307
+
264
308
  const useCache = libc() !== "bionic"
265
309
 
266
310
  const packageNames = names("slopcode-bin")
@@ -289,6 +333,12 @@ function resolveBinary() {
289
333
  }
290
334
  }
291
335
 
336
+ function embeddedAndroidBinary() {
337
+ if (libc() !== "bionic") return
338
+ const candidate = path.join(rootDir, "android-runtime", arch, "bin", binary)
339
+ if (fs.existsSync(candidate)) return { path: candidate, package: `slopcode-embedded-android-${arch}` }
340
+ }
341
+
292
342
  function findBinary(startDir) {
293
343
  let current = startDir
294
344
  for (;;) {
@@ -307,7 +357,10 @@ function findBinary(startDir) {
307
357
  }
308
358
  }
309
359
 
310
- const resolved = resolveBinary() || findBinary(scriptDir)
360
+ const resolved =
361
+ libc() === "bionic"
362
+ ? embeddedAndroidBinary() || resolveBinary() || findBinary(scriptDir)
363
+ : resolveBinary() || findBinary(scriptDir)
311
364
  if (!resolved) {
312
365
  if (libc() === "bionic") {
313
366
  console.error(termuxMessage())
@@ -324,36 +377,40 @@ if (!resolved) {
324
377
  const args = process.argv.slice(2)
325
378
  if (libc() === "bionic" && androidInteractive(args)) {
326
379
  const bun = androidBun(arch)
380
+ const runtimeRoot = path.dirname(path.dirname(resolved.path))
381
+ const daemonURL = process.env.SLOPCODE_DAEMON_URL || process.env.SLOPCODE_SERVER_URL
382
+ const daemonToken = process.env.SLOPCODE_DAEMON_TOKEN || process.env.SLOPCODE_TOKEN
327
383
  startupLog("launcher.android.interactive", {
328
384
  runtime: path.basename(resolved.path),
329
385
  bun: bun ? path.basename(bun) : undefined,
330
- legacy: process.env.SLOPCODE_ANDROID_BOOTSTRAP === "legacy",
386
+ rustFirst: true,
331
387
  })
388
+ if (daemonURL && daemonToken) {
389
+ startupLog("launcher.android.rust_tui", { mode: "attached" })
390
+ run(resolved.path, {
391
+ args: androidRuntimeArgs(args),
392
+ env: androidRuntimeEnv(runtimeRoot),
393
+ })
394
+ }
332
395
  if (!fs.existsSync(androidBundle)) {
333
396
  console.error(
334
- "SlopCode Android CLI bootstrap bundle is missing. Reinstall from Termux with: npm install -g slopcode@latest --include=optional",
397
+ "SlopCode Android daemon bootstrap bundle is missing. Reinstall from Termux with: npm install -g slopcode@latest --include=optional",
335
398
  )
336
399
  process.exit(1)
337
400
  }
338
401
  if (bun && fs.existsSync(androidBundle)) {
339
- const runtimeRoot = path.dirname(path.dirname(resolved.path))
340
- startupLog("launcher.android.legacy_bundle", { bundle: androidBundle })
341
- run(bun, {
342
- args: [androidBundle, ...args],
343
- env: {
344
- SLOPCODE_BIONIC: "1",
345
- SLOPCODE_VERSION: pkg.version,
402
+ startupLog("launcher.android.rust_tui", { mode: "bootstrap", bundle: androidBundle })
403
+ run(resolved.path, {
404
+ args: androidRuntimeArgs(args),
405
+ env: androidRuntimeEnv(runtimeRoot, {
346
406
  SLOPCODE_ENTRYPOINT: androidBundle,
347
- SLOPCODE_ANDROID_ROOT: runtimeRoot,
348
- SLOPCODE_ANDROID_HOST_PATH: path.join(runtimeRoot, "bin", "slopcode-android-host"),
349
- SLOPCODE_ANDROID_HOST: process.env.SLOPCODE_ANDROID_HOST || "sidecar",
350
- NODE_PATH: [path.join(rootDir, "android-modules"), process.env.NODE_PATH].filter(Boolean).join(path.delimiter),
351
- },
407
+ SLOPCODE_ANDROID_BOOTSTRAP_RUNNER: bun,
408
+ }),
352
409
  })
353
410
  }
354
411
  if (!bun) {
355
412
  console.error(
356
- "SlopCode Android CLI bootstrap is missing. Run npm rebuild slopcode or reinstall from Termux with: npm install -g slopcode@latest --include=optional",
413
+ "SlopCode Android daemon bootstrap is missing. Run npm rebuild slopcode or reinstall from Termux with: npm install -g slopcode@latest --include=optional",
357
414
  )
358
415
  process.exit(1)
359
416
  }