SDKta cargay
<script src="/sdk/nebo.global.js"></script>
<script>
const { nebo, identity, storage, agents, janus, decide, chat, surfaces } = NeboAppSDK;
</script> Globalqa NeboAppSDKmi; mana nebo global kanchu. NeboAppSDK.neboqa SDK instanciam, sapa módulotaq hanaq nivelpipas exportasqa, chhaynapi NeboAppSDK.storage, NeboAppSDK.nebo.storagepas kikin objetom. Navegadorta mana llanthunanpaq, nebo.fetchqa neboFetch hina exportasqa, nebo.WebSockettaq NeboWebSocket hina.
identity
| Waqyay | Kutichin |
|---|---|
identity.get() | {id, name, displayName, description, persona, model, skills, inputValues} appq llamk'aqninpaq. Cachesqa. |
identity.invalidate() | Cacheta pichan. |
storage
Apppaq llave-chanin waqaychana. storage:readwriteta necesitan. Appq llamk'aqnin ñawinchasqan, tikrasqan kikin waqaychanam: dueño llamk'aqwan rimaspa yapasqan registroqa paginapim rikhurin, paginapi qillqasqataq llamk'aq tariyta atisqanmi.
const deals = (await NeboAppSDK.storage.getItem('deals')) ?? [];
deals.push({ name: 'Example renewal', closes: '2026-10-31' });
await NeboAppSDK.storage.setItem('deals', deals); | Waqyay | Ruway |
|---|---|
storage.getItem(key) | setItem waqaychasqanta chiqallanta (objeto, lista, yupay utaq string), utaq null. |
storage.setItem(key, value) | Mayqin JSON chanintapas waqaychan. |
storage.removeItem(key) | Huk llaveta hurqun; manañam keys()pi rikhurinchu. |
storage.keys() | Llapan llavekuna. |
storage.clear() | Sapa llaveta hurqun. |
storage.onChange(handler) | Sapa qillqay qhipam handler({appId, keys, action, source})ta waqyan, llamk'aqpa (source: "employee") utaq appq mayqin kichasqa ventananpa, kaypas (source: "page"). Uyariyta sayachiq funciónta kutichin. |
Willakuykuna tikrakuptin hukmanta siq'iy, pipas tikrachun:
async function load() {
render((await NeboAppSDK.storage.getItem('deals')) ?? []);
}
load();
const stop = NeboAppSDK.storage.onChange((change) => {
// { appId, keys: ['deals'], action: 'set' | 'delete', source: 'employee' | 'page' }
if (change.keys.includes('deals')) load();
}); Appq kikin llamk'aqninllam kay waqaychanaman chayan, kikinpa appninpaqlla; huk llamk'aqqa appq llamk'aqnintam tapun. Iskaynin ladokuna tarinanku llavekunata akllay (listata hap'iq huk llave, utaq deal:42 hina prefijo ukhupi sapa registropaq huk llave) llamk'aqpa kamachikuyninkunapitaq willay. Kikin allin JSON kaq string, "42" hina, parseasqam kutimun, chayrayku laya chaniyuq kaptinqa objetopi p'istuy. Sapa chaninta 2 MBmanta aswan pisilla hap'iy; setItemqa manam pantayta ch'utinchu qillqay mana chaskisqa kaptin.
agents
Appq llamk'aqninta utaq huk llamk'aqta tapuy, kutichiynintataq hap'iy. Huk llamk'aqta tapunapaqqa subagent:<employee-id>tam necesitan.
const { text } = await NeboAppSDK.agents.invoke('Which open deals close this month?');
for await (const part of NeboAppSDK.agents.stream('Summarize the pipeline.')) {
output.textContent += part.text;
} | Waqyay | Kutichin |
|---|---|
agents.invoke(message, {agent, data}) | {text, tools} llamk'aq tukuptin. |
agents.stream(message, {agent, data}) | {text, done}manta async iterador. |
janus
Persona, yuyay, herramientakuna mana kaq modelota chiqallanta waqyay.
| Waqyay | Kutichin |
|---|---|
janus.complete({messages, model, temperature, max_tokens, system}) | Kutichiy qillqa string hina. |
janus.stream(same) | Qillqa partechakunamanta async iterador. |
decide
Layasqa decisionkuna: wakin willakuykunamanta sutiyuq tapuykunata tapuy, sapa kutichiytataq probabilidadkunawan, confianzawanpas hap'iy, huk usqhay waqyaypi. Manam imapas qillqa hina qillqasqachu, chayrayku juiciokunapaq llamk'achiy (kay cliente q'uñichu, kay ticket mayqin categoríamantaq, hayk'a urgentetaq) yupaykunatataq, p'unchawkunatataq, saywakunatataq kikiykiq códigoykipi hap'iy. Appq llamk'aqninqa kikin tapuykunata decide herramientanwan tapuyta atinmi, qhawarinapaq appq waqaychasqa registronkunapi.
const { answers } = await NeboAppSDK.decide({
state: { company: 'Example Co', status: 'asked for a quote today' },
questions: {
tier: {
type: 'choice',
instructions: 'How warm is this lead, judging by `status`?',
criteria: { hot: 'ready to buy', warm: 'interested', cold: 'not now', other: "can't tell" }
},
fit: {
type: 'score',
instructions: 'How well does `company` fit our customers?',
criteria: ['poor', 'fair', 'good', 'great']
},
reply: { type: 'noul', instructions: '`status` asks us for a reply.' }
}
});
if (answers.tier.choice === 'hot' && answers.tier.confidence > 0.8) flag(lead);
// answers.fit.score is fractional: 0 is "poor", 1.5 is between "fair" and "good".
// answers.reply.noul is the probability the statement holds, from 0 to 1. | Tapuy laya | criteria | Kutichiy |
|---|---|---|
choice | 2manta 255kama sutiyuq akllanakuna objeto, {option: description}. Lista mana hunt'asqa kaptinqa other hina lluqsina akllanata yapay. | choice (akllasqa), confidence (0manta 1kama), sapa akllanapaq probabilitiespas. |
score | 2manta 10kama ordenasqa nivelkuna lista, aswan urapi kaq ñawpaqta. | score (partesqa, 0 ñawpaq nivel), confidence, sapa nivelpaq probabilitiespas. |
noul | Mana: tapuyqa chaninchanapaq huk willakuylla. | noul, willakuy chiqap kanan probabilidad. Mana sapaq confianza. |
decide({state, questions})nisqaqa{model, answers, usage}nisqamanmi tukun, sapa kutichiytaq tapukuyninman qusqayki sutipa uranpi.stateqa qillqa utaq mayqin JSONpas. Tapuykuna necesitasqan camponkunallata hap'iy, chay camponkunatataqinstructionsukhupi backtickkunapi sutichay. Llapan tapuyqainstructionspim tiyan; tapuypa sutinqa kutichiytallam sutichan. Ancha hatun stateqa chawpinpim pisiyachisqa manaraq kachachkaspa.- Huk errortam wikch'un, willakuyninqa imarayku kasqanmi. Errorqa manam status códigoyuqchu, chayrayku casokunata t'aqanaykipaq willakuyta tupachiy:
- Mana allin ruwasqa tapuy, qhawarinapaq huk akllanallayuq choice (botqa 400wan kutichin, ima mana allin kasqanwan).
- Dueñopa cuentanpi manaña llamk'ay kanchu: "Cuentaykipi kapuq llapan llamk'aytam llamk'achirqankiña. Planta akllay utaq créditokunata yapay qatinaykipaq." (429). Yapamanta pruebayqa manam yanapanchu dueño planta utaq créditokunata yapanankama.
- Ancha achka decisionkuna kuska: "Ancha achka decisionkuna kuska. Huk ratumanta yapamanta pruebay." (429).
- Botqa manam yaykusqachu: "Decisionkunaqa NeboAI t'inkisqatam necesitanku. NeboAIman yaykuy, yapamanta pruebaytaq." (503).
- Decisión servicioqa pantarqanmi (502).
- Decisionkunaqa bot dueñopa NeboAI cuentanmanmi cobrakun mayqin modelo waqyay hina. Precioskuna qhaway.
neboFetch
// Relative path: the app's own sidecar.
const res = await NeboAppSDK.neboFetch('/deals?stage=open');
// Absolute URL: through Nebo's proxy. Needs network:api.example.com.
const rates = await NeboAppSDK.neboFetch('https://api.example.com/rates'); Relativo ñanqa appq sidecarninmanmi rin /apps/<id>/api/<path>pi. Absoluto http utaq https URLqa Neboq proxyninmi pasan, network:<host>ta utaq network:*ta necesitan.
NeboWebSocket
new NeboAppSDK.NeboWebSocket()qa appq llamk'aqninman kawsaq sockettam kichan, backoffwantaq hukmanta t'inkikun. Mana argumentokunata hap'inchu, send(data), close(), onopen, onmessage, onerror, oncloseniyuqmi.
surfaces, a2uipas
surfaces.connect()qa appq kawsaq canalnintam kichan. Kunanqa appq llamk'aqninmanta interactivo tarjetakunatam apan: a2ui.init(processor)ta waqyay @a2ui/web_coremanta MessageProcessorwan, paginayki huñusqan (SDKqa manam kikinpa renderernin kanchu). Tarjetaqa ruwasqa kasqan appmanllam chayan, chaypi clicqa chay appq llamk'aqninmanmi rin, tarjeta kachasqa qhipa kichasqa paginataq manam chaskinchu, chayrayku pagina sapa kuti rikuchinan kaqta storagepi hap'iy.
SDKqa layasqa eventokunatapas riqsichinmi, text_content, state_delta, surface_update hina, surfaces.on(type, handler), surfaces.send(name, payload), surfaces.statewanpas. Neboqa manaraqmi chay eventokunata app paginakunaman kachanchu, sendtaqa manam imapas kutichinchu. Kawsaq willakuykunapaqqa, storage.onChangeta llamk'achiy.
chat
Neboq chatninta appq llamk'aqninwan paginapi churay.
NeboAppSDK.chat.mount(document.getElementById('chat'), {
placeholder: 'Ask about a deal',
contextId: 'deal-42'
});
NeboAppSDK.chat.setContext({ deal: 'Example renewal' }); | Waqyay | Ruway |
|---|---|
chat.mount(element, options) | Akllanakuna: placeholder, theme, height, borderless, contextId, scope. |
chat.send(text) | Mensajeta kachan. |
chat.setContext(context) | Llamk'aq rikusqan contextota churan; null pichan. |
chat.onMessage(handler) | Mensajekunata chaskin. |
chat.newThread() | Musuq hilota qallarin. |
chat.unmount() | Chatta hurqun. |
Configuración
Nebopa ukhunpiqa SDKqa app id, base URL nisqakunatapas kikillanmanta tarin. Huk cheqaspi qusqa paginapaqqa, nebo.configure({appId, baseUrl}) nisqata qayay, utaq NeboAppSDK.setAppId(id) hinaspa NeboAppSDK.setBaseUrl(url) nisqakunata. getAppId() hinaspa getBaseUrl() nisqakunam paykunata kutichispa ñawirinku.