{
  "schemaVersion": "1.0",
  "item": {
    "slug": "javascript-sdk",
    "name": "Javascript Sdk",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/okaris/javascript-sdk",
    "canonicalUrl": "https://clawhub.ai/okaris/javascript-sdk",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/javascript-sdk",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=javascript-sdk",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "references/agent-patterns.md",
      "references/files.md",
      "references/react-integration.md",
      "references/server-proxy.md",
      "references/sessions.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/javascript-sdk"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/javascript-sdk",
    "agentPageUrl": "https://openagent3.xyz/skills/javascript-sdk/agent",
    "manifestUrl": "https://openagent3.xyz/skills/javascript-sdk/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/javascript-sdk/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "JavaScript SDK",
        "body": "Build AI applications with the inference.sh JavaScript/TypeScript SDK."
      },
      {
        "title": "Quick Start",
        "body": "npm install @inferencesh/sdk\n\nimport { inference } from '@inferencesh/sdk';\n\nconst client = inference({ apiKey: 'inf_your_key' });\n\n// Run an AI app\nconst result = await client.run({\n  app: 'infsh/flux-schnell',\n  input: { prompt: 'A sunset over mountains' }\n});\nconsole.log(result.output);"
      },
      {
        "title": "Installation",
        "body": "npm install @inferencesh/sdk\n# or\nyarn add @inferencesh/sdk\n# or\npnpm add @inferencesh/sdk\n\nRequirements: Node.js 18.0.0+ (or modern browser with fetch)"
      },
      {
        "title": "Authentication",
        "body": "import { inference } from '@inferencesh/sdk';\n\n// Direct API key\nconst client = inference({ apiKey: 'inf_your_key' });\n\n// From environment variable (recommended)\nconst client = inference({ apiKey: process.env.INFERENCE_API_KEY });\n\n// For frontend apps (use proxy)\nconst client = inference({ proxyUrl: '/api/inference/proxy' });\n\nGet your API key: Settings → API Keys → Create API Key"
      },
      {
        "title": "Basic Execution",
        "body": "const result = await client.run({\n  app: 'infsh/flux-schnell',\n  input: { prompt: 'A cat astronaut' }\n});\n\nconsole.log(result.status);  // \"completed\"\nconsole.log(result.output);  // Output data"
      },
      {
        "title": "Fire and Forget",
        "body": "const task = await client.run({\n  app: 'google/veo-3-1-fast',\n  input: { prompt: 'Drone flying over mountains' }\n}, { wait: false });\n\nconsole.log(`Task ID: ${task.id}`);\n// Check later with client.getTask(task.id)"
      },
      {
        "title": "Streaming Progress",
        "body": "const stream = await client.run({\n  app: 'google/veo-3-1-fast',\n  input: { prompt: 'Ocean waves at sunset' }\n}, { stream: true });\n\nfor await (const update of stream) {\n  console.log(`Status: ${update.status}`);\n  if (update.logs?.length) {\n    console.log(update.logs.at(-1));\n  }\n}"
      },
      {
        "title": "Run Parameters",
        "body": "ParameterTypeDescriptionappstringApp ID (namespace/name@version)inputobjectInput matching app schemasetupobjectHidden setup configurationinfrastring'cloud' or 'private'sessionstringSession ID for stateful executionsession_timeoutnumberIdle timeout (1-3600 seconds)"
      },
      {
        "title": "Automatic Upload",
        "body": "const result = await client.run({\n  app: 'image-processor',\n  input: {\n    image: '/path/to/image.png'  // Auto-uploaded\n  }\n});"
      },
      {
        "title": "Manual Upload",
        "body": "// Basic upload\nconst file = await client.uploadFile('/path/to/image.png');\n\n// With options\nconst file = await client.uploadFile('/path/to/image.png', {\n  filename: 'custom_name.png',\n  contentType: 'image/png',\n  public: true\n});\n\nconst result = await client.run({\n  app: 'image-processor',\n  input: { image: file.uri }\n});"
      },
      {
        "title": "Browser File Upload",
        "body": "const input = document.querySelector('input[type=\"file\"]');\nconst file = await client.uploadFile(input.files[0]);"
      },
      {
        "title": "Sessions (Stateful Execution)",
        "body": "Keep workers warm across multiple calls:\n\n// Start new session\nconst result = await client.run({\n  app: 'my-app',\n  input: { action: 'init' },\n  session: 'new',\n  session_timeout: 300  // 5 minutes\n});\nconst sessionId = result.session_id;\n\n// Continue in same session\nconst result2 = await client.run({\n  app: 'my-app',\n  input: { action: 'process' },\n  session: sessionId\n});"
      },
      {
        "title": "Template Agents",
        "body": "Use pre-built agents from your workspace:\n\nconst agent = client.agent('my-team/support-agent@latest');\n\n// Send message\nconst response = await agent.sendMessage('Hello!');\nconsole.log(response.text);\n\n// Multi-turn conversation\nconst response2 = await agent.sendMessage('Tell me more');\n\n// Reset conversation\nagent.reset();\n\n// Get chat history\nconst chat = await agent.getChat();"
      },
      {
        "title": "Ad-hoc Agents",
        "body": "Create custom agents programmatically:\n\nimport { tool, string, number, appTool } from '@inferencesh/sdk';\n\n// Define tools\nconst calculator = tool('calculate')\n  .describe('Perform a calculation')\n  .param('expression', string('Math expression'))\n  .build();\n\nconst imageGen = appTool('generate_image', 'infsh/flux-schnell@latest')\n  .describe('Generate an image')\n  .param('prompt', string('Image description'))\n  .build();\n\n// Create agent\nconst agent = client.agent({\n  core_app: { ref: 'infsh/claude-sonnet-4@latest' },\n  system_prompt: 'You are a helpful assistant.',\n  tools: [calculator, imageGen],\n  temperature: 0.7,\n  max_tokens: 4096\n});\n\nconst response = await agent.sendMessage('What is 25 * 4?');"
      },
      {
        "title": "Available Core Apps",
        "body": "ModelApp ReferenceClaude Sonnet 4infsh/claude-sonnet-4@latestClaude 3.5 Haikuinfsh/claude-haiku-35@latestGPT-4oinfsh/gpt-4o@latestGPT-4o Miniinfsh/gpt-4o-mini@latest"
      },
      {
        "title": "Parameter Types",
        "body": "import {\n  string, number, integer, boolean,\n  enumOf, array, obj, optional\n} from '@inferencesh/sdk';\n\nconst name = string('User\\'s name');\nconst age = integer('Age in years');\nconst score = number('Score 0-1');\nconst active = boolean('Is active');\nconst priority = enumOf(['low', 'medium', 'high'], 'Priority');\nconst tags = array(string('Tag'), 'List of tags');\nconst address = obj({\n  street: string('Street'),\n  city: string('City'),\n  zip: optional(string('ZIP'))\n}, 'Address');"
      },
      {
        "title": "Client Tools (Run in Your Code)",
        "body": "const greet = tool('greet')\n  .display('Greet User')\n  .describe('Greets a user by name')\n  .param('name', string('Name to greet'))\n  .requireApproval()\n  .build();"
      },
      {
        "title": "App Tools (Call AI Apps)",
        "body": "const generate = appTool('generate_image', 'infsh/flux-schnell@latest')\n  .describe('Generate an image from text')\n  .param('prompt', string('Image description'))\n  .setup({ model: 'schnell' })\n  .input({ steps: 20 })\n  .requireApproval()\n  .build();"
      },
      {
        "title": "Agent Tools (Delegate to Sub-agents)",
        "body": "import { agentTool } from '@inferencesh/sdk';\n\nconst researcher = agentTool('research', 'my-org/researcher@v1')\n  .describe('Research a topic')\n  .param('topic', string('Topic to research'))\n  .build();"
      },
      {
        "title": "Webhook Tools (Call External APIs)",
        "body": "import { webhookTool } from '@inferencesh/sdk';\n\nconst notify = webhookTool('slack', 'https://hooks.slack.com/...')\n  .describe('Send Slack notification')\n  .secret('SLACK_SECRET')\n  .param('channel', string('Channel'))\n  .param('message', string('Message'))\n  .build();"
      },
      {
        "title": "Internal Tools (Built-in Capabilities)",
        "body": "import { internalTools } from '@inferencesh/sdk';\n\nconst config = internalTools()\n  .plan()\n  .memory()\n  .webSearch(true)\n  .codeExecution(true)\n  .imageGeneration({\n    enabled: true,\n    appRef: 'infsh/flux@latest'\n  })\n  .build();\n\nconst agent = client.agent({\n  core_app: { ref: 'infsh/claude-sonnet-4@latest' },\n  internal_tools: config\n});"
      },
      {
        "title": "Streaming Agent Responses",
        "body": "const response = await agent.sendMessage('Explain quantum computing', {\n  onMessage: (msg) => {\n    if (msg.content) {\n      process.stdout.write(msg.content);\n    }\n  },\n  onToolCall: async (call) => {\n    console.log(`\\n[Tool: ${call.name}]`);\n    const result = await executeTool(call.name, call.args);\n    agent.submitToolResult(call.id, result);\n  }\n});"
      },
      {
        "title": "File Attachments",
        "body": "// From file path (Node.js)\nimport { readFileSync } from 'fs';\nconst response = await agent.sendMessage('What\\'s in this image?', {\n  files: [readFileSync('image.png')]\n});\n\n// From base64\nconst response = await agent.sendMessage('Analyze this', {\n  files: ['data:image/png;base64,iVBORw0KGgo...']\n});\n\n// From browser File object\nconst input = document.querySelector('input[type=\"file\"]');\nconst response = await agent.sendMessage('Describe this', {\n  files: [input.files[0]]\n});"
      },
      {
        "title": "Skills (Reusable Context)",
        "body": "const agent = client.agent({\n  core_app: { ref: 'infsh/claude-sonnet-4@latest' },\n  skills: [\n    {\n      name: 'code-review',\n      description: 'Code review guidelines',\n      content: '# Code Review\\n\\n1. Check security\\n2. Check performance...'\n    },\n    {\n      name: 'api-docs',\n      description: 'API documentation',\n      url: 'https://example.com/skills/api-docs.md'\n    }\n  ]\n});"
      },
      {
        "title": "Server Proxy (Frontend Apps)",
        "body": "For browser apps, proxy through your backend to keep API keys secure:"
      },
      {
        "title": "Client Setup",
        "body": "const client = inference({\n  proxyUrl: '/api/inference/proxy'\n  // No apiKey needed on frontend\n});"
      },
      {
        "title": "Next.js Proxy (App Router)",
        "body": "// app/api/inference/proxy/route.ts\nimport { createRouteHandler } from '@inferencesh/sdk/proxy/nextjs';\n\nconst route = createRouteHandler({\n  apiKey: process.env.INFERENCE_API_KEY\n});\n\nexport const POST = route.POST;"
      },
      {
        "title": "Express Proxy",
        "body": "import express from 'express';\nimport { createProxyMiddleware } from '@inferencesh/sdk/proxy/express';\n\nconst app = express();\napp.use('/api/inference/proxy', createProxyMiddleware({\n  apiKey: process.env.INFERENCE_API_KEY\n}));"
      },
      {
        "title": "Supported Frameworks",
        "body": "Next.js (App Router & Pages Router)\nExpress\nHono\nRemix\nSvelteKit"
      },
      {
        "title": "TypeScript Support",
        "body": "Full type definitions included:\n\nimport type {\n  TaskDTO,\n  ChatDTO,\n  ChatMessageDTO,\n  AgentTool,\n  TaskStatusCompleted,\n  TaskStatusFailed\n} from '@inferencesh/sdk';\n\nif (result.status === TaskStatusCompleted) {\n  console.log('Done!');\n} else if (result.status === TaskStatusFailed) {\n  console.log('Failed:', result.error);\n}"
      },
      {
        "title": "Error Handling",
        "body": "import { RequirementsNotMetException, InferenceError } from '@inferencesh/sdk';\n\ntry {\n  const result = await client.run({ app: 'my-app', input: {...} });\n} catch (e) {\n  if (e instanceof RequirementsNotMetException) {\n    console.log('Missing requirements:');\n    for (const err of e.errors) {\n      console.log(`  - ${err.type}: ${err.key}`);\n    }\n  } else if (e instanceof InferenceError) {\n    console.log('API error:', e.message);\n  }\n}"
      },
      {
        "title": "Human Approval Workflows",
        "body": "const response = await agent.sendMessage('Delete all temp files', {\n  onToolCall: async (call) => {\n    if (call.requiresApproval) {\n      const approved = await promptUser(`Allow ${call.name}?`);\n      if (approved) {\n        const result = await executeTool(call.name, call.args);\n        agent.submitToolResult(call.id, result);\n      } else {\n        agent.submitToolResult(call.id, { error: 'Denied by user' });\n      }\n    }\n  }\n});"
      },
      {
        "title": "CommonJS Support",
        "body": "const { inference, tool, string } = require('@inferencesh/sdk');\n\nconst client = inference({ apiKey: 'inf_...' });\nconst result = await client.run({...});"
      },
      {
        "title": "Reference Files",
        "body": "Agent Patterns - Multi-agent, RAG, batch processing patterns\nTool Builder - Complete tool builder API reference\nServer Proxy - Next.js, Express, Hono, Remix, SvelteKit setup\nStreaming - Real-time progress updates and SSE handling\nFile Handling - Upload, download, and manage files\nSessions - Stateful execution with warm workers\nTypeScript - Type definitions and type-safe patterns\nReact Integration - Hooks, components, and patterns"
      },
      {
        "title": "Related Skills",
        "body": "# Python SDK\nnpx skills add inference-sh/skills@python-sdk\n\n# Full platform skill (all 150+ apps via CLI)\nnpx skills add inference-sh/skills@inference-sh\n\n# LLM models\nnpx skills add inference-sh/skills@llm-models\n\n# Image generation\nnpx skills add inference-sh/skills@ai-image-generation"
      },
      {
        "title": "Documentation",
        "body": "JavaScript SDK Reference - Full API documentation\nAgent SDK Overview - Building agents\nTool Builder Reference - Creating tools\nServer Proxy Setup - Frontend integration\nAuthentication - API key setup\nStreaming - Real-time updates\nFile Uploads - File handling"
      }
    ],
    "body": "JavaScript SDK\n\nBuild AI applications with the inference.sh JavaScript/TypeScript SDK.\n\nQuick Start\nnpm install @inferencesh/sdk\n\nimport { inference } from '@inferencesh/sdk';\n\nconst client = inference({ apiKey: 'inf_your_key' });\n\n// Run an AI app\nconst result = await client.run({\n  app: 'infsh/flux-schnell',\n  input: { prompt: 'A sunset over mountains' }\n});\nconsole.log(result.output);\n\nInstallation\nnpm install @inferencesh/sdk\n# or\nyarn add @inferencesh/sdk\n# or\npnpm add @inferencesh/sdk\n\n\nRequirements: Node.js 18.0.0+ (or modern browser with fetch)\n\nAuthentication\nimport { inference } from '@inferencesh/sdk';\n\n// Direct API key\nconst client = inference({ apiKey: 'inf_your_key' });\n\n// From environment variable (recommended)\nconst client = inference({ apiKey: process.env.INFERENCE_API_KEY });\n\n// For frontend apps (use proxy)\nconst client = inference({ proxyUrl: '/api/inference/proxy' });\n\n\nGet your API key: Settings → API Keys → Create API Key\n\nRunning Apps\nBasic Execution\nconst result = await client.run({\n  app: 'infsh/flux-schnell',\n  input: { prompt: 'A cat astronaut' }\n});\n\nconsole.log(result.status);  // \"completed\"\nconsole.log(result.output);  // Output data\n\nFire and Forget\nconst task = await client.run({\n  app: 'google/veo-3-1-fast',\n  input: { prompt: 'Drone flying over mountains' }\n}, { wait: false });\n\nconsole.log(`Task ID: ${task.id}`);\n// Check later with client.getTask(task.id)\n\nStreaming Progress\nconst stream = await client.run({\n  app: 'google/veo-3-1-fast',\n  input: { prompt: 'Ocean waves at sunset' }\n}, { stream: true });\n\nfor await (const update of stream) {\n  console.log(`Status: ${update.status}`);\n  if (update.logs?.length) {\n    console.log(update.logs.at(-1));\n  }\n}\n\nRun Parameters\nParameter\tType\tDescription\napp\tstring\tApp ID (namespace/name@version)\ninput\tobject\tInput matching app schema\nsetup\tobject\tHidden setup configuration\ninfra\tstring\t'cloud' or 'private'\nsession\tstring\tSession ID for stateful execution\nsession_timeout\tnumber\tIdle timeout (1-3600 seconds)\nFile Handling\nAutomatic Upload\nconst result = await client.run({\n  app: 'image-processor',\n  input: {\n    image: '/path/to/image.png'  // Auto-uploaded\n  }\n});\n\nManual Upload\n// Basic upload\nconst file = await client.uploadFile('/path/to/image.png');\n\n// With options\nconst file = await client.uploadFile('/path/to/image.png', {\n  filename: 'custom_name.png',\n  contentType: 'image/png',\n  public: true\n});\n\nconst result = await client.run({\n  app: 'image-processor',\n  input: { image: file.uri }\n});\n\nBrowser File Upload\nconst input = document.querySelector('input[type=\"file\"]');\nconst file = await client.uploadFile(input.files[0]);\n\nSessions (Stateful Execution)\n\nKeep workers warm across multiple calls:\n\n// Start new session\nconst result = await client.run({\n  app: 'my-app',\n  input: { action: 'init' },\n  session: 'new',\n  session_timeout: 300  // 5 minutes\n});\nconst sessionId = result.session_id;\n\n// Continue in same session\nconst result2 = await client.run({\n  app: 'my-app',\n  input: { action: 'process' },\n  session: sessionId\n});\n\nAgent SDK\nTemplate Agents\n\nUse pre-built agents from your workspace:\n\nconst agent = client.agent('my-team/support-agent@latest');\n\n// Send message\nconst response = await agent.sendMessage('Hello!');\nconsole.log(response.text);\n\n// Multi-turn conversation\nconst response2 = await agent.sendMessage('Tell me more');\n\n// Reset conversation\nagent.reset();\n\n// Get chat history\nconst chat = await agent.getChat();\n\nAd-hoc Agents\n\nCreate custom agents programmatically:\n\nimport { tool, string, number, appTool } from '@inferencesh/sdk';\n\n// Define tools\nconst calculator = tool('calculate')\n  .describe('Perform a calculation')\n  .param('expression', string('Math expression'))\n  .build();\n\nconst imageGen = appTool('generate_image', 'infsh/flux-schnell@latest')\n  .describe('Generate an image')\n  .param('prompt', string('Image description'))\n  .build();\n\n// Create agent\nconst agent = client.agent({\n  core_app: { ref: 'infsh/claude-sonnet-4@latest' },\n  system_prompt: 'You are a helpful assistant.',\n  tools: [calculator, imageGen],\n  temperature: 0.7,\n  max_tokens: 4096\n});\n\nconst response = await agent.sendMessage('What is 25 * 4?');\n\nAvailable Core Apps\nModel\tApp Reference\nClaude Sonnet 4\tinfsh/claude-sonnet-4@latest\nClaude 3.5 Haiku\tinfsh/claude-haiku-35@latest\nGPT-4o\tinfsh/gpt-4o@latest\nGPT-4o Mini\tinfsh/gpt-4o-mini@latest\nTool Builder API\nParameter Types\nimport {\n  string, number, integer, boolean,\n  enumOf, array, obj, optional\n} from '@inferencesh/sdk';\n\nconst name = string('User\\'s name');\nconst age = integer('Age in years');\nconst score = number('Score 0-1');\nconst active = boolean('Is active');\nconst priority = enumOf(['low', 'medium', 'high'], 'Priority');\nconst tags = array(string('Tag'), 'List of tags');\nconst address = obj({\n  street: string('Street'),\n  city: string('City'),\n  zip: optional(string('ZIP'))\n}, 'Address');\n\nClient Tools (Run in Your Code)\nconst greet = tool('greet')\n  .display('Greet User')\n  .describe('Greets a user by name')\n  .param('name', string('Name to greet'))\n  .requireApproval()\n  .build();\n\nApp Tools (Call AI Apps)\nconst generate = appTool('generate_image', 'infsh/flux-schnell@latest')\n  .describe('Generate an image from text')\n  .param('prompt', string('Image description'))\n  .setup({ model: 'schnell' })\n  .input({ steps: 20 })\n  .requireApproval()\n  .build();\n\nAgent Tools (Delegate to Sub-agents)\nimport { agentTool } from '@inferencesh/sdk';\n\nconst researcher = agentTool('research', 'my-org/researcher@v1')\n  .describe('Research a topic')\n  .param('topic', string('Topic to research'))\n  .build();\n\nWebhook Tools (Call External APIs)\nimport { webhookTool } from '@inferencesh/sdk';\n\nconst notify = webhookTool('slack', 'https://hooks.slack.com/...')\n  .describe('Send Slack notification')\n  .secret('SLACK_SECRET')\n  .param('channel', string('Channel'))\n  .param('message', string('Message'))\n  .build();\n\nInternal Tools (Built-in Capabilities)\nimport { internalTools } from '@inferencesh/sdk';\n\nconst config = internalTools()\n  .plan()\n  .memory()\n  .webSearch(true)\n  .codeExecution(true)\n  .imageGeneration({\n    enabled: true,\n    appRef: 'infsh/flux@latest'\n  })\n  .build();\n\nconst agent = client.agent({\n  core_app: { ref: 'infsh/claude-sonnet-4@latest' },\n  internal_tools: config\n});\n\nStreaming Agent Responses\nconst response = await agent.sendMessage('Explain quantum computing', {\n  onMessage: (msg) => {\n    if (msg.content) {\n      process.stdout.write(msg.content);\n    }\n  },\n  onToolCall: async (call) => {\n    console.log(`\\n[Tool: ${call.name}]`);\n    const result = await executeTool(call.name, call.args);\n    agent.submitToolResult(call.id, result);\n  }\n});\n\nFile Attachments\n// From file path (Node.js)\nimport { readFileSync } from 'fs';\nconst response = await agent.sendMessage('What\\'s in this image?', {\n  files: [readFileSync('image.png')]\n});\n\n// From base64\nconst response = await agent.sendMessage('Analyze this', {\n  files: ['data:image/png;base64,iVBORw0KGgo...']\n});\n\n// From browser File object\nconst input = document.querySelector('input[type=\"file\"]');\nconst response = await agent.sendMessage('Describe this', {\n  files: [input.files[0]]\n});\n\nSkills (Reusable Context)\nconst agent = client.agent({\n  core_app: { ref: 'infsh/claude-sonnet-4@latest' },\n  skills: [\n    {\n      name: 'code-review',\n      description: 'Code review guidelines',\n      content: '# Code Review\\n\\n1. Check security\\n2. Check performance...'\n    },\n    {\n      name: 'api-docs',\n      description: 'API documentation',\n      url: 'https://example.com/skills/api-docs.md'\n    }\n  ]\n});\n\nServer Proxy (Frontend Apps)\n\nFor browser apps, proxy through your backend to keep API keys secure:\n\nClient Setup\nconst client = inference({\n  proxyUrl: '/api/inference/proxy'\n  // No apiKey needed on frontend\n});\n\nNext.js Proxy (App Router)\n// app/api/inference/proxy/route.ts\nimport { createRouteHandler } from '@inferencesh/sdk/proxy/nextjs';\n\nconst route = createRouteHandler({\n  apiKey: process.env.INFERENCE_API_KEY\n});\n\nexport const POST = route.POST;\n\nExpress Proxy\nimport express from 'express';\nimport { createProxyMiddleware } from '@inferencesh/sdk/proxy/express';\n\nconst app = express();\napp.use('/api/inference/proxy', createProxyMiddleware({\n  apiKey: process.env.INFERENCE_API_KEY\n}));\n\nSupported Frameworks\nNext.js (App Router & Pages Router)\nExpress\nHono\nRemix\nSvelteKit\nTypeScript Support\n\nFull type definitions included:\n\nimport type {\n  TaskDTO,\n  ChatDTO,\n  ChatMessageDTO,\n  AgentTool,\n  TaskStatusCompleted,\n  TaskStatusFailed\n} from '@inferencesh/sdk';\n\nif (result.status === TaskStatusCompleted) {\n  console.log('Done!');\n} else if (result.status === TaskStatusFailed) {\n  console.log('Failed:', result.error);\n}\n\nError Handling\nimport { RequirementsNotMetException, InferenceError } from '@inferencesh/sdk';\n\ntry {\n  const result = await client.run({ app: 'my-app', input: {...} });\n} catch (e) {\n  if (e instanceof RequirementsNotMetException) {\n    console.log('Missing requirements:');\n    for (const err of e.errors) {\n      console.log(`  - ${err.type}: ${err.key}`);\n    }\n  } else if (e instanceof InferenceError) {\n    console.log('API error:', e.message);\n  }\n}\n\nHuman Approval Workflows\nconst response = await agent.sendMessage('Delete all temp files', {\n  onToolCall: async (call) => {\n    if (call.requiresApproval) {\n      const approved = await promptUser(`Allow ${call.name}?`);\n      if (approved) {\n        const result = await executeTool(call.name, call.args);\n        agent.submitToolResult(call.id, result);\n      } else {\n        agent.submitToolResult(call.id, { error: 'Denied by user' });\n      }\n    }\n  }\n});\n\nCommonJS Support\nconst { inference, tool, string } = require('@inferencesh/sdk');\n\nconst client = inference({ apiKey: 'inf_...' });\nconst result = await client.run({...});\n\nReference Files\nAgent Patterns - Multi-agent, RAG, batch processing patterns\nTool Builder - Complete tool builder API reference\nServer Proxy - Next.js, Express, Hono, Remix, SvelteKit setup\nStreaming - Real-time progress updates and SSE handling\nFile Handling - Upload, download, and manage files\nSessions - Stateful execution with warm workers\nTypeScript - Type definitions and type-safe patterns\nReact Integration - Hooks, components, and patterns\nRelated Skills\n# Python SDK\nnpx skills add inference-sh/skills@python-sdk\n\n# Full platform skill (all 150+ apps via CLI)\nnpx skills add inference-sh/skills@inference-sh\n\n# LLM models\nnpx skills add inference-sh/skills@llm-models\n\n# Image generation\nnpx skills add inference-sh/skills@ai-image-generation\n\nDocumentation\nJavaScript SDK Reference - Full API documentation\nAgent SDK Overview - Building agents\nTool Builder Reference - Creating tools\nServer Proxy Setup - Frontend integration\nAuthentication - API key setup\nStreaming - Real-time updates\nFile Uploads - File handling"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/okaris/javascript-sdk",
    "publisherUrl": "https://clawhub.ai/okaris/javascript-sdk",
    "owner": "okaris",
    "version": "0.1.5",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/javascript-sdk",
    "downloadUrl": "https://openagent3.xyz/downloads/javascript-sdk",
    "agentUrl": "https://openagent3.xyz/skills/javascript-sdk/agent",
    "manifestUrl": "https://openagent3.xyz/skills/javascript-sdk/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/javascript-sdk/agent.md"
  }
}