Sign In

@knowmint/sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knowmint/sdk

TypeScript SDK for KnowMint API

latest
npmnpm
Version
0.2.0
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

@knowmint/sdk

TypeScript SDK for the KnowMint API.

人間の暗黙知・体験知をAIエージェントに販売するナレッジマーケットプレイスの TypeScript クライアントライブラリです。

特徴

  • 外部依存ゼロ: Node.js 18+ ネイティブの fetch を使用
  • 型安全: 完全な TypeScript 型定義
  • シンプルな API: 検索・詳細取得・購入記録・出品を数行で実装可能

インストール

# npm
npm install @knowmint/sdk

# pnpm
pnpm add @knowmint/sdk

# bun
bun add @knowmint/sdk

クイックスタート

import { KnowledgeMarketClient } from "@knowmint/sdk";

const client = new KnowledgeMarketClient({
  apiKey: process.env.KM_API_KEY!,
  baseUrl: "https://your-knowledge-market.example.com",
});

// ナレッジを検索
const results = await client.search({ query: "prompt engineering" });
console.log(`Found ${results.pagination.total} items`);

for (const item of results.data) {
  console.log(`- ${item.title} (${item.price_sol} SOL)`);
}

// 詳細を取得
const detail = await client.getItem(results.data[0].id);
console.log(detail.preview_content);

API リファレンス

new KnowledgeMarketClient(options)

クライアントを初期化します。

オプション必須デフォルト説明
apiKeystringはいKnowMint API キー (km_<64 hex>)
baseUrlstringいいえhttp://127.0.0.1:3000API ベース URL
timeoutMsnumberいいえ30000リクエストタイムアウト (ms)

client.search(params)

ナレッジを検索します。

const results = await client.search({
  query: "React performance",
  content_type: "prompt",
  sort_by: "trust_score",
  max_results: 10,
  metadata_domain: "web-development",
});
// => SearchResult { data: KnowledgeItem[], pagination: Pagination }
パラメータ説明
querystring?全文検索クエリ
content_typeContentType?prompt / tool_def / dataset / api / general
sort_bystring?newest / popular / price_low / price_high / rating / trust_score
max_resultsnumber?最大取得件数
metadata_domainstring?メタデータ: ドメインでフィルタ
metadata_experience_typestring?メタデータ: 体験タイプでフィルタ
metadata_source_typestring?メタデータ: ソースタイプでフィルタ

client.getItem(id)

ナレッジアイテムの詳細を取得します。

const item = await client.getItem("item-uuid");
// => KnowledgeItem (seller プロフィール付き)

client.getContent(id)

購入済みナレッジのフルコンテンツを取得します。未購入の場合は KmApiError (status: 403) が発生します。

const content = await client.getContent("item-uuid");
console.log(content.full_content);
console.log(content.file_url); // ファイルがある場合

client.recordPurchase(input)

オンチェーン購入のトランザクションを記録します。実際の SOL/トークン送金は事前にオンチェーンで行ってください。

const purchase = await client.recordPurchase({
  knowledgeId: "item-uuid",
  txHash: "5JkQ...", // オンチェーントランザクションハッシュ
  token: "SOL",      // SOL / USDC / ETH
  chain: "solana",   // solana / base / ethereum
});
// => PurchaseResult

client.getVersionHistory(id)

ナレッジのバージョン履歴を取得します。

const versions = await client.getVersionHistory("item-uuid");
for (const v of versions) {
  console.log(`v${v.version_number}: ${v.change_summary}`);
}
// => KnowledgeVersion[]

client.publish(input)

ナレッジを下書き作成して即時公開します。

const item = await client.publish({
  title: "React Hooks の最適化パターン",
  description: "実務で培った useCallback / useMemo の正しい使い方",
  content_type: "prompt",
  content: "フルコンテンツ...",
  price_sol: 0.1,
  tags: ["react", "hooks", "performance"],
});
// => KnowledgeItem (published)

エラーハンドリング

import { KnowledgeMarketClient, KmApiError } from "@knowmint/sdk";

try {
  const item = await client.getItem("nonexistent-id");
} catch (err) {
  if (err instanceof KmApiError) {
    console.error(`API Error [${err.status}]: ${err.message}`);
    // err.status: HTTPステータスコード (404, 403 など)
    // err.code:   APIエラーコード (文字列)
  }
}

OpenClaw 統合例

OpenClaw AI エージェントが KnowMint SDK を使ってナレッジを自律的に検索・購入するサンプルは examples/openclaw-integration.ts を参照してください。

import { KnowledgeMarketClient } from "@knowmint/sdk";

const client = new KnowledgeMarketClient({ apiKey: process.env.KM_API_KEY! });

// エージェントのナレッジ獲得フロー
async function acquireKnowledge(topic: string, maxBudgetSol: number) {
  // 1. 信頼スコア順で検索
  const results = await client.search({ query: topic, sort_by: "trust_score" });

  // 2. 予算内のアイテムを選定
  const candidate = results.data.find(
    (item) => item.price_sol !== null && item.price_sol <= maxBudgetSol
  );
  if (!candidate) return null;

  // 3. オンチェーン送金後に記録
  const purchase = await client.recordPurchase({
    knowledgeId: candidate.id,
    txHash: "on_chain_tx_hash",
  });

  // 4. フルコンテンツを取得
  return client.getContent(candidate.id);
}

ライセンス

MIT

FAQs

Package last updated on 16 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts