seclaw 0.1.7 → 0.1.9

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/dist/cli.js CHANGED
@@ -380,11 +380,12 @@ async function scaffoldProject(targetDir, answers) {
380
380
  for (const sub of wsSubdirs) {
381
381
  await mkdir(resolve3(targetDir, ws, sub), { recursive: true });
382
382
  }
383
- for (const dir of ["templates", "commander", "agent"]) {
383
+ for (const dir of ["templates", "commander", "agent", "cloudflared"]) {
384
384
  await mkdir(join2(targetDir, dir), { recursive: true });
385
385
  }
386
386
  await writeEnv(targetDir, answers);
387
387
  await writeDockerCompose(targetDir, ws);
388
+ await writeCloudflaredFiles(targetDir);
388
389
  await writePermissions(targetDir);
389
390
  await writeGitignore(targetDir);
390
391
  await writeDockerignore(targetDir);
@@ -481,9 +482,16 @@ async function writeDockerCompose(dir, workspacePath = "./shared") {
481
482
  retries: 5
482
483
 
483
484
  cloudflared:
484
- image: cloudflare/cloudflared:latest
485
+ build:
486
+ context: ./cloudflared
487
+ dockerfile: Dockerfile
488
+ image: seclaw/cloudflared:latest
485
489
  restart: unless-stopped
486
- command: ["tunnel", "--no-autoupdate", "--url", "http://agent:3000"]
490
+ entrypoint: ["/bin/sh", "/tunnel-start.sh"]
491
+ volumes:
492
+ - ./tunnel-start.sh:/tunnel-start.sh:ro
493
+ env_file:
494
+ - .env
487
495
  networks:
488
496
  - agent-net
489
497
  depends_on:
@@ -520,6 +528,51 @@ networks:
520
528
  `;
521
529
  await writeFile2(join2(dir, "docker-compose.yml"), content);
522
530
  }
531
+ async function writeCloudflaredFiles(dir) {
532
+ await mkdir(join2(dir, "cloudflared"), { recursive: true });
533
+ await writeFile2(
534
+ join2(dir, "cloudflared", "Dockerfile"),
535
+ `FROM cloudflare/cloudflared:latest AS upstream
536
+ FROM alpine:3.20
537
+ RUN apk add --no-cache curl
538
+ COPY --from=upstream /usr/local/bin/cloudflared /usr/local/bin/cloudflared
539
+ ENTRYPOINT ["/bin/sh"]
540
+ `
541
+ );
542
+ const script = `#!/bin/sh
543
+ # Auto-updates Telegram webhook when tunnel URL changes on restart.
544
+
545
+ set_webhook() {
546
+ URL="$1"
547
+ for i in 1 2 3; do
548
+ sleep 10
549
+ RESP=$(curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/setWebhook" \\
550
+ -H "Content-Type: application/json" \\
551
+ -d "{\\"url\\":\\"$URL/webhook\\",\\"allowed_updates\\":[\\"message\\",\\"callback_query\\"]}")
552
+ case "$RESP" in
553
+ *'"ok":true'*)
554
+ printf '[tunnel] Webhook set: %s (attempt %d)\\n' "$URL" "$i" >&2
555
+ return 0
556
+ ;;
557
+ esac
558
+ printf '[tunnel] Webhook attempt %d failed: %s\\n' "$i" "$RESP" >&2
559
+ done
560
+ return 1
561
+ }
562
+
563
+ cloudflared tunnel --no-autoupdate --url http://agent:3000 2>&1 | while IFS= read -r line; do
564
+ printf '%s\\n' "$line" >&2
565
+ case "$line" in
566
+ *https://*trycloudflare.com*)
567
+ URL=$(echo "$line" | sed -n 's|.*\\(https://[a-z0-9-]*\\.trycloudflare\\.com\\).*|\\1|p')
568
+ [ -z "$URL" ] && continue
569
+ [ -n "$TELEGRAM_BOT_TOKEN" ] && set_webhook "$URL" &
570
+ ;;
571
+ esac
572
+ done
573
+ `;
574
+ await writeFile2(join2(dir, "tunnel-start.sh"), script, { mode: 493 });
575
+ }
523
576
  async function copyAgentFiles(dir) {
524
577
  const agentTemplateSrc = resolve3(import.meta.dirname, "runtime");
525
578
  const agentDest = join2(dir, "agent");
@@ -241,7 +241,7 @@ ${memory}` : ""}
241
241
  - When the user asks to save/note/draft/track something, use the appropriate workspace tool. Always confirm what was saved.`;
242
242
  return prompt;
243
243
  }
244
- var MAX_TOOL_RESULT = 4e3;
244
+ var MAX_TOOL_RESULT = 1e4;
245
245
  function truncateToolResult(text) {
246
246
  let cleaned = text.replace(/<[^>]+>/g, " ");
247
247
  cleaned = cleaned.replace(/[A-Za-z0-9+/=]{100,}/g, "[base64-data]");
@@ -410,7 +410,7 @@ async function connectComposio(config2) {
410
410
  }
411
411
  const toolResults = await Promise.allSettled(
412
412
  activeApps.map(
413
- (app) => apiFetch(`/tools?toolkit_slug=${app}&important=true&limit=8`)
413
+ (app) => apiFetch(`/tools?toolkit_slug=${app}&limit=20`)
414
414
  )
415
415
  );
416
416
  const tools = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seclaw",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Secure autonomous AI agents in 60 seconds",
5
5
  "type": "module",
6
6
  "bin": {