Skip to main content

Scripts API

ที่เก็บ script แบบถาวร — บันทึก shell, Python หรือ Node script ที่ใช้ซ้ำ และดึงผ่าน curl | bash


Scripts API

Scripts API ให้บริการที่เก็บแบบถาวรสำหรับ script ที่ใช้ซ้ำ script ถูกตั้งชื่อและกำหนดเวอร์ชันภายใน mind และสามารถดึงเป็น plain text — เหมาะสำหรับรูปแบบ curl | bash

Endpoints

POST /script

จัดเก็บหรืออัปเดต script

curl -X POST https://synapse.schaefer.zone/script \
  -H "Authorization: Bearer YOUR_MIND_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "deploy-synapse",
    "content": "#!/bin/bash\nset -euo pipefail\ngit pull\nnpm ci\nnpm run build\ndocker compose up -d",
    "description": "Deploy Synapse to production",
    "language": "bash"
  }'

GET /script/:name

ดึงเนื้อหา script เป็น text/plain เหมาะสำหรับ pipe ไปยัง bash

curl -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/script/deploy-synapse | bash

GET /script/:name/info

ดึง metadata ของ script โดยไม่มีเนื้อหา

curl -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/script/deploy-synapse/info

Response:

{
  "name": "deploy-synapse",
  "description": "Deploy Synapse to production",
  "language": "bash",
  "size_bytes": 142,
  "created_at": "2026-06-27T...",
  "updated_at": "2026-06-27T..."
}

GET /scripts

รายการ script ทั้งหมดใน mind ปัจจุบัน

curl -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/scripts

DELETE /script/:name

ลบ script

curl -X DELETE -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/script/deploy-synapse

กรณีการใช้งานทั่วไป

Deployment script

จัดเก็บขั้นตอน deployment มาตรฐานเพื่อให้ LLM รันได้โดยไม่ต้อง derive ขั้นตอนใหม่ทุกครั้ง:

# LLM stores this once
curl -X POST .../script -d '{
  "name": "deploy-vps1",
  "content": "#!/bin/bash\nssh vps1 \"cd /opt/synapse && git pull && docker compose up -d --build\"",
  "language": "bash"
}'

# Later sessions just run it
curl -H "Authorization: ..." .../script/deploy-vps1 | bash

Troubleshooting snippet

จัดเก็บคำสั่ง diagnostic สำหรับปัญหาทั่วไป:

curl -X POST .../script -d '{
  "name": "check-docker",
  "content": "#!/bin/bash\ndocker ps\ndocker stats --no-stream\ndocker system df",
  "description": "Quick Docker health check",
  "language": "bash"
}'

ตัวสร้าง configuration

จัดเก็บ script ที่สร้าง config:

curl -X POST .../script -d '{
  "name": "gen-nginx-conf",
  "content": "#!/usr/bin/env python3\nimport sys\n# ... generate nginx config from template ...",
  "language": "python"
}'

ขั้นตอนถัดไป