सामग्री पर जाएँ
Runic
हिन्दी
Esc
नेविगेटखोलें⌘Jप्रीव्यू
इस पेज पर

@runic-labs/sdk

askRunic और storeResult — एजेंट-उन्मुख पूरा अनुबंध।

@runic-labs/sdk एकमात्र पैकेज है जिसे अधिकांश इंटीग्रेशन को सीधे इंपोर्ट करने की आवश्यकता होती है। यह @runic-labs/cache और @runic-labs/ledger को दो फ़ंक्शनों के पीछे रैप करता है।

npm install @runic-labs/sdk
pnpm add @runic-labs/sdk
yarn add @runic-labs/sdk
bun add @runic-labs/sdk

मॉड्यूल-स्तरीय फ़ंक्शन

सामान्य स्थिति के लिए — एक एजेंट प्रक्रिया, डिफ़ॉल्ट फ़ाइल-समर्थित स्टोरेज — मुक्त फ़ंक्शनों का सीधे उपयोग करें:

import { askRunic, storeResult } from "@runic-labs/sdk";

askRunic(decision)

जांचता है कि क्या यह सटीक निर्णय पहले ही हल किया जा चुका है।

PropType
decisionDecision

{ intent: string; params: Record<string, unknown> }

TypeDecision

Promise<CachedEntry | null> लौटाता है — मिस होने पर null, या हिट होने पर कैश की गई एंट्री (और लेजर में हिट लॉग करता है)।

PropType
signature?string

The normalized signature this entry is keyed on.

Typestring
artifact?unknown

Whatever was passed to storeResult() originally.

Typeunknown
tokensSpent?number

What producing this artifact cost the first time.

Typenumber
createdAt?number

Epoch ms when this entry was first stored.

Typenumber
lastUsedAt?number

Epoch ms of the most recent hit.

Typenumber
hitCount?number

Number of times this entry has been reused.

Typenumber
stale?boolean

Advisory only — Runic never acts on this itself.

Typeboolean

storeResult(decision, artifact, tokensSpent)

किसी निर्णय के लिए नए सिरे से जनरेट किया गया आर्टिफ़ैक्ट रिकॉर्ड करता है, और उसकी लागत लॉग करता है ताकि भविष्य की हिट को पता हो कि उससे कितनी बचत हुई।

PropType
decisionDecision

Same shape as askRunic's argument.

TypeDecision
artifactunknown

Whatever you want returned on a future cache hit.

Typeunknown
tokensSpentnumber

Agent-reported cost of producing this artifact. Runic never measures this itself.

Typenumber

Promise<void> लौटाता है।

createRunicClient(options?)

जब आपको कई स्वतंत्र क्लाइंट चाहिए हों, तब मॉड्यूल-स्तरीय फ़ंक्शनों के बजाय इसका उपयोग करें — आमतौर पर परीक्षणों के लिए, या इन-मेमोरी स्टोरेज को स्पष्ट रूप से चुनते समय:

import { createRunicClient } from "@runic-labs/sdk";
import { createCache, MemoryCacheStore } from "@runic-labs/cache";
import { createLedger, MemoryLedgerStore } from "@runic-labs/ledger";

const runic = createRunicClient({
  cache: createCache(new MemoryCacheStore()),
  ledger: createLedger(new MemoryLedgerStore()),
});

await runic.askRunic({ intent: "summarize_pr", params: { repo, pr } });
await runic.storeResult({ intent: "summarize_pr", params: { repo, pr } }, artifact, tokensUsed);
PropType
cache?Cache

Defaults to a file-backed cache under .runic/ if omitted.

TypeCache
ledger?Ledger

Defaults to a file-backed ledger under .runic/ if omitted.

TypeLedger

वही askRunic / storeResult संरचना वाला एक RunicClient लौटाता है जो आपके द्वारा पास किए गए cache/ledger इंस्टेंसों तक सीमित होता है।

आगे

  • कैश — कस्टम CacheStore इंप्लीमेंटेशन बनाएँ
  • लेजर — लेजर सारांश सीधे पढ़ें
  • CLI — कमांड लाइन से स्थिति का निरीक्षण करें

क्या यह पेज सहायक था?