slopcode 0.2.142 → 0.2.145

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,7 @@ function findBinary(startDir) {
307
357
  }
308
358
  }
309
359
 
310
- const resolved = resolveBinary() || findBinary(scriptDir)
360
+ const resolved = resolveBinary() || embeddedAndroidBinary() || findBinary(scriptDir)
311
361
  if (!resolved) {
312
362
  if (libc() === "bionic") {
313
363
  console.error(termuxMessage())
@@ -324,36 +374,40 @@ if (!resolved) {
324
374
  const args = process.argv.slice(2)
325
375
  if (libc() === "bionic" && androidInteractive(args)) {
326
376
  const bun = androidBun(arch)
377
+ const runtimeRoot = path.dirname(path.dirname(resolved.path))
378
+ const daemonURL = process.env.SLOPCODE_DAEMON_URL || process.env.SLOPCODE_SERVER_URL
379
+ const daemonToken = process.env.SLOPCODE_DAEMON_TOKEN || process.env.SLOPCODE_TOKEN
327
380
  startupLog("launcher.android.interactive", {
328
381
  runtime: path.basename(resolved.path),
329
382
  bun: bun ? path.basename(bun) : undefined,
330
- legacy: process.env.SLOPCODE_ANDROID_BOOTSTRAP === "legacy",
383
+ rustFirst: true,
331
384
  })
385
+ if (daemonURL && daemonToken) {
386
+ startupLog("launcher.android.rust_tui", { mode: "attached" })
387
+ run(resolved.path, {
388
+ args: androidRuntimeArgs(args),
389
+ env: androidRuntimeEnv(runtimeRoot),
390
+ })
391
+ }
332
392
  if (!fs.existsSync(androidBundle)) {
333
393
  console.error(
334
- "SlopCode Android CLI bootstrap bundle is missing. Reinstall from Termux with: npm install -g slopcode@latest --include=optional",
394
+ "SlopCode Android daemon bootstrap bundle is missing. Reinstall from Termux with: npm install -g slopcode@latest --include=optional",
335
395
  )
336
396
  process.exit(1)
337
397
  }
338
398
  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,
399
+ startupLog("launcher.android.rust_tui", { mode: "bootstrap", bundle: androidBundle })
400
+ run(resolved.path, {
401
+ args: androidRuntimeArgs(args),
402
+ env: androidRuntimeEnv(runtimeRoot, {
346
403
  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
- },
404
+ SLOPCODE_ANDROID_BOOTSTRAP_RUNNER: bun,
405
+ }),
352
406
  })
353
407
  }
354
408
  if (!bun) {
355
409
  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",
410
+ "SlopCode Android daemon bootstrap is missing. Run npm rebuild slopcode or reinstall from Termux with: npm install -g slopcode@latest --include=optional",
357
411
  )
358
412
  process.exit(1)
359
413
  }