@runic-labs/sdk
askRunic और storeResult — एजेंट-उन्मुख पूरा अनुबंध।
@runic-labs/sdk एकमात्र पैकेज है जिसे अधिकांश इंटीग्रेशन को सीधे इंपोर्ट करने की आवश्यकता होती है। यह @runic-labs/cache और @runic-labs/ledger को दो फ़ंक्शनों के पीछे रैप करता है।
npm install @runic-labs/sdkpnpm add @runic-labs/sdkyarn add @runic-labs/sdkbun add @runic-labs/sdkमॉड्यूल-स्तरीय फ़ंक्शन
सामान्य स्थिति के लिए — एक एजेंट प्रक्रिया, डिफ़ॉल्ट फ़ाइल-समर्थित स्टोरेज — मुक्त फ़ंक्शनों का सीधे उपयोग करें:
import { askRunic, storeResult } from "@runic-labs/sdk";
askRunic(decision)
जांचता है कि क्या यह सटीक निर्णय पहले ही हल किया जा चुका है।
decisionDecision
{ intent: string; params: Record<string, unknown> }
DecisionPromise<CachedEntry | null> लौटाता है — मिस होने पर null, या हिट होने पर कैश की गई एंट्री (और लेजर में हिट लॉग करता है)।
signature?string
The normalized signature this entry is keyed on.
stringartifact?unknown
Whatever was passed to storeResult() originally.
unknowntokensSpent?number
What producing this artifact cost the first time.
numbercreatedAt?number
Epoch ms when this entry was first stored.
numberlastUsedAt?number
Epoch ms of the most recent hit.
numberhitCount?number
Number of times this entry has been reused.
numberstale?boolean
Advisory only — Runic never acts on this itself.
booleanstoreResult(decision, artifact, tokensSpent)
किसी निर्णय के लिए नए सिरे से जनरेट किया गया आर्टिफ़ैक्ट रिकॉर्ड करता है, और उसकी लागत लॉग करता है ताकि भविष्य की हिट को पता हो कि उससे कितनी बचत हुई।
decisionDecision
Same shape as askRunic's argument.
Decisionartifactunknown
Whatever you want returned on a future cache hit.
unknowntokensSpentnumber
Agent-reported cost of producing this artifact. Runic never measures this itself.
numberPromise<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);
cache?Cache
Defaults to a file-backed cache under .runic/ if omitted.
Cacheledger?Ledger
Defaults to a file-backed ledger under .runic/ if omitted.
Ledgerवही askRunic / storeResult संरचना वाला एक RunicClient लौटाता है जो आपके द्वारा पास किए गए cache/ledger इंस्टेंसों तक सीमित होता है।