{
  "schemaVersion": 1,
  "slug": "bla-agents-first-run",
  "tool": {
    "name": "bla-agents",
    "repo": "qybaihe/bla",
    "version": "3.2.0"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.4 LTS",
    "runtime": "Node.js 24.21.0",
    "installSeconds": 2.7,
    "installBytes": 6716884
  },
  "method": {
    "hypothesis": "README 사용법: npm으로 패키지를 설치한 뒤 디렉터리 단위 CLI 보호 명령이나 코딩 에이전트 연동 설정을 실행하고 번들러 플러그인을 등록해 자바스크립트 청크와 소스맵 및 웹어셈블리 산출물을 보호한다. 이 환경에서 확인: 네트워크와 외부 코딩 에이전트가 없는 오프라인 환경에서 번들러 플러그인 초기화와 샘플 에셋 보호 처리 및 디렉터리 보호 진입 함수 호출의 동작 여부와 소요 시간을 확인한다.",
    "conditions": [
      "외부 네트워크와 호스트 코딩 에이전트 및 자격증명이 없는 격리된 오프라인 샌드박스에서 샘플 파일 3개를 대상으로 실행한다",
      "고정된 자바스크립트 코드 20줄과 소스맵 항목 5개 및 웹어셈블리 24바이트를 임시 디렉터리에 생성해 동일하게 입력한다",
      "핵심 기능 지표인 pluginOk와 shieldOk가 모두 1이면 오프라인 보호 기능이 정상 동작한 것으로 읽고 하나라도 0이면 실패로 판정한다"
    ],
    "repeats": 5
  },
  "script": "import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { pathToFileURL } from \"node:url\";\n\nconst roundMs = (v) => Math.max(0, Math.round(v * 1000) / 1000);\nconst toErrKind = (e) => {\n  if (!e) return \"none\";\n  const raw = typeof e === \"object\" && e.constructor && e.constructor.name ? String(e.constructor.name) : \"Error\";\n  return /^[A-Za-z_][A-Za-z0-9_.]*$/.test(raw) ? raw : \"Error\";\n};\n\nconst origStdoutWrite = process.stdout.write.bind(process.stdout);\nconst origStderrWrite = process.stderr.write.bind(process.stderr);\nconst origExit = process.exit;\nconst origArgv = process.argv.slice();\nconst origCwd = process.cwd();\n\nlet importMs = 0;\nlet helpMs = 0;\nlet helpBytes = 0;\nlet helpOk = 0;\nlet pluginInitMs = 0;\nlet pluginOk = 0;\nlet shieldMs = 0;\nlet shieldOutBytes = 0;\nlet shieldOk = 0;\nlet hardenMs = 0;\nlet hardenOutBytes = 0;\nlet hardenOk = 0;\nlet hardenErr = \"none\";\n\nlet pkg = {};\nlet pkgDir = path.resolve(\"node_modules/bla-agents\");\nlet bundlerMod = null;\nlet mainMod = null;\n\nconst tImport0 = performance.now();\ntry {\n  const pkgJsonPath = path.join(pkgDir, \"package.json\");\n  pkg = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n  bundlerMod = await import(\"bla-agents/bundler\");\n  try {\n    mainMod = await import(\"bla-agents\");\n  } catch {\n    mainMod = null;\n  }\n} catch {\n  bundlerMod = null;\n}\nimportMs = roundMs(performance.now() - tImport0);\n\nconst captureOutput = async (fn) => {\n  const chunks = [];\n  let exitCode = 0;\n  process.stdout.write = (chunk, ... nop) => {\n    chunks.push(typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(\"utf8\"));\n    return true;\n  };\n  process.stderr.write = (chunk, ... nop) => {\n    chunks.push(typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(\"utf8\"));\n    return true;\n  };\n  process.exit = (code = 0) => {\n    exitCode = Number(code) || 0;\n    const err = new Error(\"CLI_EXIT\");\n    err.__cliExit = true;\n    err.code = exitCode;\n    throw err;\n  };\n  try {\n    await fn();\n  } catch (e) {\n    if (!e || !e.__cliExit) {\n      throw e;\n    }\n  } finally {\n    process.stdout.write = origStdoutWrite;\n    process.stderr.write = origStderrWrite;\n    process.exit = origExit;\n    process.argv = origArgv.slice();\n  }\n  return { text: chunks.join(\"\"), exitCode };\n};\n\nconst tHelp0 = performance.now();\ntry {\n  const infoParts = [];\n  if (pkg && pkg.version) infoParts.push(`version:${pkg.version}`);\n  if (bundlerMod) infoParts.push(`bundlerExports:${Object.keys(bundlerMod).sort().join(\",\")}`);\n  if (mainMod) infoParts.push(`mainExports:${Object.keys(mainMod).sort().join(\",\")}`);\n  const cliFn = (mainMod && (mainMod.cli || mainMod.main || mainMod.parse)) || null;\n  if (typeof cliFn === \"function\") {\n    const res = await captureOutput(async () => {\n      await cliFn([\"--help\"]);\n    });\n    if (res.text) infoParts.push(res.text);\n  }\n  const fullHelp = infoParts.join(\"\\n\");\n  helpBytes = Buffer.byteLength(fullHelp, \"utf8\");\n  helpOk = pkg && pkg.version && helpBytes > 0 ? 1 : 0;\n} catch {\n  helpOk = 0;\n}\nhelpMs = roundMs(performance.now() - tHelp0);\n\nlet plugins = [];\nconst tPlugin0 = performance.now();\ntry {\n  if (bundlerMod && typeof bundlerMod.blaVitePlugin === \"function\") {\n    const raw = await bundlerMod.blaVitePlugin({\n      intensity: \"bankrupt\",\n      enableHoneySourceMaps: true\n    });\n    plugins = (Array.isArray(raw) ? raw.flat(Infinity) : [raw]).filter((p) => p && typeof p === \"object\");\n    if (plugins.length > 0) {\n      pluginOk = 1;\n    }\n  }\n} catch {\n  pluginOk = 0;\n}\npluginInitMs = roundMs(performance.now() - tPlugin0);\n\nconst tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), \"bla-first-\"));\nconst distDir = path.join(tmpDir, \"dist\");\nfs.mkdirSync(path.join(distDir, \"assets\"), { recursive: true });\n\nconst sampleLines = [\n  \"export function verifyLicense(token, secret) {\",\n  \"  const prefix = 'BLA_SHIELD_2026';\",\n  \"  let hash = 2166136261;\",\n  \"  const input = String(token || '') + ':' + String(secret || '') + ':' + prefix;\",\n  \"  for (let i = 0; i < input.length; i++) {\",\n  \"    hash ^= input.charCodeAt(i);\",\n  \"    hash = Math.imul(hash, 16777619);\",\n  \"  }\",\n  \"  return (hash >>> 0).toString(16);\",\n  \"}\",\n  \"export function computeDigest(items) {\",\n  \"  const list = Array.isArray(items) ? items : [items];\",\n  \"  let acc = 0;\",\n  \"  for (let idx = 0; idx < list.length; idx++) {\",\n  \"    const str = JSON.stringify(list[idx]);\",\n  \"    acc = (acc + str.length * (idx + 17)) % 1000003;\",\n  \"  }\",\n  \"  return { count: list.length, checksum: acc };\",\n  \"}\",\n  \"export default { verifyLicense, computeDigest };\"\n];\nconst sampleCode = sampleLines.join(\"\\n\");\nconst sampleMap = {\n  version: 3,\n  file: \"index.js\",\n  sources: [\"../src/index.js\"],\n  names: [\"verifyLicense\", \"computeDigest\", \"token\", \"secret\", \"hash\"],\n  mappings: \"AAAA,OAAO,SAAS,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE;EAC3C,MAAM,MAAM,GAAG,iBAAiB,CAAC\"\n};\nconst sampleWasm = new Uint8Array([\n  0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00,\n  0x01, 0x04, 0x01, 0x60, 0x00, 0x00, 0x03, 0x02,\n  0x01, 0x00, 0x0a, 0x04, 0x01, 0x02, 0x00, 0x0b\n]);\n\nconst jsPath = path.join(distDir, \"assets\", \"index.js\");\nconst mapPath = path.join(distDir, \"assets\", \"index.js.map\");\nconst wasmPath = path.join(distDir, \"assets\", \"core.wasm\");\nfs.writeFileSync(jsPath, sampleCode, \"utf8\");\nfs.writeFileSync(mapPath, JSON.stringify(sampleMap), \"utf8\");\nfs.writeFileSync(wasmPath, sampleWasm);\n\nconst getHook = (p, name) => {\n  const h = p ? p[name] : null;\n  if (typeof h === \"function\") return h.bind(p);\n  if (h && typeof h.handler === \"function\") return h.handler.bind(p);\n  return null;\n};\n\nconst tShield0 = performance.now();\ntry {\n  let code = sampleCode;\n  let mapObj = sampleMap;\n  const emitted = [];\n  const ctx = {\n    emitFile(file) {\n      emitted.push(file);\n      return `asset_${emitted.length}`;\n    },\n    warn() {},\n    info() {},\n    error(err) {\n      throw new Error(String(err));\n    }\n  };\n\n  for (const p of plugins) {\n    const configResolved = getHook(p, \"configResolved\");\n    if (configResolved) {\n      try {\n        await configResolved.call(ctx, {\n          command: \"build\",\n          mode: \"production\",\n          root: tmpDir,\n          build: { outDir: distDir, sourcemap: true }\n        });\n      } catch {}\n    }\n    const transform = getHook(p, \"transform\");\n    if (transform) {\n      try {\n        const tr = await transform.call(ctx, code, jsPath);\n        if (typeof tr === \"string\" && tr.length > 0) code = tr;\n        else if (tr && typeof tr.code === \"string\" && tr.code.length > 0) {\n          code = tr.code;\n          if (tr.map) mapObj = typeof tr.map === \"string\" ? JSON.parse(tr.map) : tr.map;\n        }\n      } catch {}\n    }\n    const renderChunk = getHook(p, \"renderChunk\");\n    if (renderChunk) {\n      try {\n        const rc = await renderChunk.call(\n          ctx,\n          code,\n          {\n            fileName: \"assets/index.js\",\n            name: \"index\",\n            isEntry: true,\n            type: \"chunk\",\n            code,\n            modules: {}\n          },\n          { dir: distDir, format: \"es\", sourcemap: true }\n        );\n        if (typeof rc === \"string\" && rc.length > 0) code = rc;\n        else if (rc && typeof rc.code === \"string\" && rc.code.length > 0) {\n          code = rc.code;\n          if (rc.map) mapObj = typeof rc.map === \"string\" ? JSON.parse(rc.map) : rc.map;\n        }\n      } catch {}\n    }\n  }\n\n  const bundle = {\n    \"assets/index.js\": {\n      type: \"chunk\",\n      fileName: \"assets/index.js\",\n      name: \"index\",\n      isEntry: true,\n      code,\n      map: mapObj,\n      imports: [],\n      dynamicImports: [],\n      exports: [\"verifyLicense\", \"computeDigest\"],\n      modules: {}\n    },\n    \"assets/index.js.map\": {\n      type: \"asset\",\n      fileName: \"assets/index.js.map\",\n      name: \"index.js.map\",\n      source: JSON.stringify(mapObj)\n    },\n    \"assets/core.wasm\": {\n      type: \"asset\",\n      fileName: \"assets/core.wasm\",\n      name: \"core.wasm\",\n      source: new Uint8Array(sampleWasm)\n    }\n  };\n\n  for (const p of plugins) {\n    const generateBundle = getHook(p, \"generateBundle\");\n    if (generateBundle) {\n      try {\n        await generateBundle.call(ctx, { dir: distDir, format: \"es\", sourcemap: true }, bundle, false);\n      } catch {}\n    }\n    const writeBundle = getHook(p, \"writeBundle\");\n    if (writeBundle) {\n      try {\n        await writeBundle.call(ctx, { dir: distDir, format: \"es\", sourcemap: true }, bundle);\n      } catch {}\n    }\n  }\n\n  let totalBytes = 0;\n  for (const item of Object.values(bundle)) {\n    if (item.type === \"chunk\" && typeof item.code === \"string\") {\n      totalBytes += Buffer.byteLength(item.code, \"utf8\");\n    } else if (item.source != null) {\n      totalBytes += typeof item.source === \"string\"\n        ? Buffer.byteLength(item.source, \"utf8\")\n        : item.source.byteLength || 0;\n    }\n  }\n  for (const em of emitted) {\n    if (em && em.source != null) {\n      totalBytes += typeof em.source === \"string\"\n        ? Buffer.byteLength(em.source, \"utf8\")\n        : em.source.byteLength || 0;\n    }\n  }\n  shieldOutBytes = totalBytes;\n  shieldOk = pluginOk === 1 && shieldOutBytes > 0 ? 1 : 0;\n} catch {\n  shieldOk = 0;\n}\nshieldMs = roundMs(performance.now() - tShield0);\n\nconst tHarden0 = performance.now();\ntry {\n  let invoked = false;\n  const hardenFn =\n    (mainMod && (mainMod.harden || mainMod.blaHarden || mainMod.hardenDirectory)) ||\n    (bundlerMod && (bundlerMod.harden || bundlerMod.blaHarden)) ||\n    null;\n  if (typeof hardenFn === \"function\") {\n    invoked = true;\n    await hardenFn(tmpDir);\n  } else if (pkg && pkg.bin) {\n    const binRel = typeof pkg.bin === \"string\" ? pkg.bin : Object.values(pkg.bin)[0];\n    if (binRel) {\n      const binAbs = path.resolve(pkgDir, binRel);\n      if (fs.existsSync(binAbs)) {\n        invoked = true;\n        await captureOutput(async () => {\n          process.argv = [\"node\", binAbs, \"harden\", tmpDir];\n          const cliMod = await import(pathToFileURL(binAbs).href);\n          const entry = cliMod.default || cliMod.main || cliMod.cli || cliMod.run;\n          if (typeof entry === \"function\") {\n            await entry([\"harden\", tmpDir]);\n          }\n        });\n      }\n    }\n  }\n  const walkBytes = (dir) => {\n    let sum = 0;\n    for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {\n      const full = path.join(dir, ent.name);\n      if (ent.isDirectory()) sum += walkBytes(full);\n      else if (ent.isFile()) sum += fs.statSync(full).size;\n    }\n    return sum;\n  };\n  hardenOutBytes = walkBytes(tmpDir);\n  hardenOk = invoked && hardenOutBytes > 0 ? 1 : 0;\n  hardenErr = \"none\";\n} catch (e) {\n  hardenOk = 0;\n  hardenErr = toErrKind(e);\n} finally {\n  try {\n    process.chdir(origCwd);\n    fs.rmSync(tmpDir, { recursive: true, force: true });\n  } catch {}\n}\nhardenMs = roundMs(performance.now() - tHarden0);\n\nconst result = {\n  importMs,\n  helpMs,\n  helpBytes,\n  helpOk,\n  pluginInitMs,\n  pluginOk,\n  shieldMs,\n  shieldOutBytes,\n  shieldOk,\n  hardenMs,\n  hardenOutBytes,\n  hardenOk,\n  hardenErr\n};\norigStdoutWrite(JSON.stringify(result) + \"\\n\");\n",
  "scriptSha256": "9adff4e23be1d9b618fccd63ebaf473c44b1778268f2b5c7420ccf1c964d958e",
  "runs": [
    {
      "run": 1,
      "importMs": 186.264,
      "helpMs": 0.176,
      "helpBytes": 8258,
      "helpOk": 1,
      "pluginInitMs": 0.104,
      "pluginOk": 1,
      "shieldMs": 242.639,
      "shieldOutBytes": 131147,
      "shieldOk": 1,
      "hardenMs": 678.55,
      "hardenOutBytes": 4011027,
      "hardenOk": 1,
      "hardenErr": "none",
      "wallMs": 1272.139
    },
    {
      "run": 2,
      "importMs": 190.118,
      "helpMs": 0.177,
      "helpBytes": 8258,
      "helpOk": 1,
      "pluginInitMs": 0.159,
      "pluginOk": 1,
      "shieldMs": 233.282,
      "shieldOutBytes": 131147,
      "shieldOk": 1,
      "hardenMs": 630.892,
      "hardenOutBytes": 4010860,
      "hardenOk": 1,
      "hardenErr": "none",
      "wallMs": 1218.742
    },
    {
      "run": 3,
      "importMs": 186.57,
      "helpMs": 0.21,
      "helpBytes": 8258,
      "helpOk": 1,
      "pluginInitMs": 0.111,
      "pluginOk": 1,
      "shieldMs": 224.752,
      "shieldOutBytes": 131147,
      "shieldOk": 1,
      "hardenMs": 657.313,
      "hardenOutBytes": 4010952,
      "hardenOk": 1,
      "hardenErr": "none",
      "wallMs": 1218.259
    },
    {
      "run": 4,
      "importMs": 189.304,
      "helpMs": 0.176,
      "helpBytes": 8258,
      "helpOk": 1,
      "pluginInitMs": 0.11,
      "pluginOk": 1,
      "shieldMs": 229.119,
      "shieldOutBytes": 131147,
      "shieldOk": 1,
      "hardenMs": 643.731,
      "hardenOutBytes": 4011150,
      "hardenOk": 1,
      "hardenErr": "none",
      "wallMs": 1220.056
    },
    {
      "run": 5,
      "importMs": 189.863,
      "helpMs": 0.175,
      "helpBytes": 8258,
      "helpOk": 1,
      "pluginInitMs": 0.103,
      "pluginOk": 1,
      "shieldMs": 233.527,
      "shieldOutBytes": 131147,
      "shieldOk": 1,
      "hardenMs": 613.667,
      "hardenOutBytes": 4009906,
      "hardenOk": 1,
      "hardenErr": "none",
      "wallMs": 1220.265
    }
  ],
  "summary": {
    "importMs": {
      "median": 189.304,
      "min": 186.264,
      "max": 190.118,
      "unit": "ms"
    },
    "helpMs": {
      "median": 0.176,
      "min": 0.175,
      "max": 0.21,
      "unit": "ms"
    },
    "helpBytes": {
      "median": 8258,
      "min": 8258,
      "max": 8258,
      "unit": "bytes"
    },
    "helpOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    },
    "pluginInitMs": {
      "median": 0.11,
      "min": 0.103,
      "max": 0.159,
      "unit": "ms"
    },
    "pluginOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    },
    "shieldMs": {
      "median": 233.282,
      "min": 224.752,
      "max": 242.639,
      "unit": "ms"
    },
    "shieldOutBytes": {
      "median": 131147,
      "min": 131147,
      "max": 131147,
      "unit": "bytes"
    },
    "shieldOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    },
    "hardenMs": {
      "median": 643.731,
      "min": 613.667,
      "max": 678.55,
      "unit": "ms"
    },
    "hardenOutBytes": {
      "median": 4010952,
      "min": 4009906,
      "max": 4011150,
      "unit": "bytes"
    },
    "hardenOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    }
  },
  "createdAt": "2026-11-10T01:09:53Z"
}
