← 返回 Skills 市场
urbantech

Ainative Svelte Sdk

作者 Toby Morning · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
118
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install ainative-svelte-sdk
功能描述
Use @ainative/svelte-sdk to add AI chat to Svelte/SvelteKit apps. Use when (1) Installing @ainative/svelte-sdk, (2) Using Svelte stores for chat state, (3) C...
使用说明 (SKILL.md)

@ainative/svelte-sdk

Svelte stores and utilities for AINative chat completions.

Install

npm install @ainative/svelte-sdk

Configure

// src/lib/ainative.ts
import { setAINativeConfig } from '@ainative/svelte-sdk';

setAINativeConfig({
  apiKey: import.meta.env.VITE_AINATIVE_API_KEY,
  baseUrl: 'https://api.ainative.studio',
});

Call this once in your app root (+layout.svelte or App.svelte).

createChatStore

\x3C!-- src/lib/Chat.svelte -->
\x3Cscript lang="ts">
  import { createChatStore } from '@ainative/svelte-sdk';

  const chat = createChatStore({
    model: 'claude-3-5-sonnet-20241022',
  });

  let input = '';

  async function send() {
    if (!input.trim()) return;
    const userMsg = { role: 'user' as const, content: input };
    input = '';
    await chat.sendMessage([...$chat.messages, userMsg]);
  }
\x3C/script>

{#each $chat.messages as msg}
  \x3Cdiv class="message {msg.role}">
    \x3Cstrong>{msg.role}:\x3C/strong> {msg.content}
  \x3C/div>
{/each}

{#if $chat.isLoading}
  \x3Cp>Thinking...\x3C/p>
{/if}

{#if $chat.error}
  \x3Cp class="error">Error: {$chat.error.message}\x3C/p>
{/if}

\x3Cinput bind:value={input} on:keydown={(e) => e.key === 'Enter' && send()} />
\x3Cbutton on:click={send} disabled={$chat.isLoading}>Send\x3C/button>

Store Shape

$chat is a reactive store with this shape:

Field Type Description
messages Message[] Full conversation history
isLoading boolean True while request in flight
error AINativeError | null Last error

createChatStore Options

Option Type Default Description
model string Model ID
initialMessages Message[] [] Seed conversation

SvelteKit — Server Route

For server-side calls, use the raw API directly (no browser auth exposure):

// src/routes/api/chat/+server.ts
import { AINATIVE_API_KEY } from '$env/static/private';
import type { RequestHandler } from './$types';

export const POST: RequestHandler = async ({ request }) => {
  const { messages } = await request.json();

  const resp = await fetch('https://api.ainative.studio/v1/public/chat/completions', {
    method: 'POST',
    headers: {
      'X-API-Key': AINATIVE_API_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'claude-3-5-sonnet-20241022',
      messages,
    }),
  });

  return new Response(resp.body, {
    headers: { 'Content-Type': 'application/json' },
  });
};

Environment Variables

# .env
VITE_AINATIVE_API_KEY=ak_your_key         # Client-safe (public key only)
AINATIVE_API_KEY=ak_your_key              # Server-side (SvelteKit $env/static/private)

Use server routes for production — never expose API keys in client bundles.

Exports

import {
  createChatStore,
  setAINativeConfig,
  ainativeConfig,
  type Message,
  type ChatState,
  type AINativeError,
} from '@ainative/svelte-sdk';

References

  • packages/sdks/svelte/src/stores/chat.ts — Chat store implementation
  • packages/sdks/svelte/src/stores/config.ts — Config store
  • packages/sdks/svelte/src/index.ts — Package exports
安全使用建议
This skill's docs look like a normal Svelte SDK, but the metadata omitted the environment variables that the docs require. Before installing or wiring this into production: (1) verify the npm package and publisher (is @ainative/svelte-sdk actually published under the expected owner?), (2) inspect the package source/repository and package contents to confirm there is no unexpected behavior, (3) ensure you only store the real API key server-side (AINATIVE_API_KEY in SvelteKit $env/static/private) and never embed private keys in client bundles (VITE_ keys are public-facing), (4) confirm the API host (https://api.ainative.studio) is correct and trusted, and (5) ask the skill publisher to update the skill metadata to declare the required environment variables (at minimum AINATIVE_API_KEY) so automated tooling and reviewers have accurate information. If you cannot inspect the package source or confirm the publisher, treat the package as higher risk and avoid exposing sensitive keys.
能力评估
Purpose & Capability
The name/description (Svelte SDK for adding AI chat) match the instructions: creating Svelte stores, calling an AINative chat endpoint, and recommending server routes. The functionality described plausibly requires an AINative API key and outbound network access to api.ainative.studio.
Instruction Scope
SKILL.md stays within the stated purpose: it shows installing the npm package, setting configuration with import.meta.env, and a recommended server route that posts to https://api.ainative.studio/v1/public/chat/completions. It also explicitly warns not to expose API keys client-side, which is appropriate. No instructions request unrelated files, credentials, or system state.
Install Mechanism
This is an instruction-only skill with no install spec and no bundled code—lowest-risk delivery. It instructs using npm to install @ainative/svelte-sdk (expected for a JS SDK) but does not perform any downloads itself.
Credentials
SKILL.md references two environment variables (VITE_AINATIVE_API_KEY for client builds and AINATIVE_API_KEY for server-side use) but the skill metadata lists no required env vars or primary credential. The SDK legitimately needs at least a server API key; the metadata omission is an incoherence that reduces transparency and should be corrected. Otherwise the credentials requested in the docs are proportional to the purpose.
Persistence & Privilege
The skill is not always-enabled, does not request elevated persistence, and contains no instructions to modify other skills or agent settings. Autonomous invocation is allowed (platform default) but there is no extra privilege requested.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ainative-svelte-sdk
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ainative-svelte-sdk 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
ainative-svelte-sdk v1.0.0 initial release - Adds Svelte store utilities for integrating AINative chat into Svelte/SvelteKit apps. - Provides createChatStore for reactive chat state, handling messages, loading, and errors. - Includes setAINativeConfig for global API setup. - Documents recommended setup for both client and secure server-side usage. - Type exports for Message, ChatState, and AINativeError.
元数据
Slug ainative-svelte-sdk
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Ainative Svelte Sdk 是什么?

Use @ainative/svelte-sdk to add AI chat to Svelte/SvelteKit apps. Use when (1) Installing @ainative/svelte-sdk, (2) Using Svelte stores for chat state, (3) C... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 118 次。

如何安装 Ainative Svelte Sdk?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install ainative-svelte-sdk」即可一键安装,无需额外配置。

Ainative Svelte Sdk 是免费的吗?

是的,Ainative Svelte Sdk 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Ainative Svelte Sdk 支持哪些平台?

Ainative Svelte Sdk 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Ainative Svelte Sdk?

由 Toby Morning(@urbantech)开发并维护,当前版本 v1.0.0。

💬 留言讨论