@dvina/sdk 5.0.86 → 5.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_generated_documents-TDBSJ6XM.js +1 -0
- package/dist/{_generated_sdk-CCR_Pi4C.d.ts → _generated_sdk-D8w-01tO.d.ts} +131 -58
- package/dist/adapters/react/index.d.ts +1 -1
- package/dist/ai/index.d.ts +6 -22
- package/dist/ai/index.js +1 -1
- package/dist/chunk-2L5VZY66.js +1 -0
- package/dist/chunk-SUEBE7BG.js +1 -0
- package/dist/{connection-BIc0EXAn.d.ts → connection-DsqFEUbC.d.ts} +15 -3
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/pagination/index.d.ts +3 -3
- package/dist/{types-DlNXHZQK.d.ts → types-qFfDxUXY.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/_generated_documents-X6QM3LR2.js +0 -1
- package/dist/chunk-32KGDH2Q.js +0 -1
- package/dist/chunk-TRD4NWTI.js +0 -1
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { UIMessage, DefaultChatTransport } from 'ai';
|
|
2
|
-
import { D as DvinaSdk, C as ChatMessage, a as ChatMessageConnection } from '../_generated_sdk-
|
|
3
|
-
|
|
2
|
+
import { D as DvinaSdk, C as ChatMessage, a as ChatMessageConnection } from '../_generated_sdk-D8w-01tO.js';
|
|
3
|
+
export { b as DvinaTaskState, t as taskStateOf } from '../_generated_sdk-D8w-01tO.js';
|
|
4
|
+
import '../types-qFfDxUXY.js';
|
|
4
5
|
import 'graphql';
|
|
5
|
-
import '../connection-
|
|
6
|
+
import '../connection-DsqFEUbC.js';
|
|
6
7
|
import 'dexie';
|
|
7
8
|
import '../error-CuX-RKTE.js';
|
|
8
9
|
import '../billing/index.js';
|
|
@@ -571,24 +572,7 @@ type DvinaHandOffPart = {
|
|
|
571
572
|
* input still streaming holds part of an id, so none is read from it. A task the call could not start is in none.
|
|
572
573
|
*/
|
|
573
574
|
declare function handedTasksOf(part: DvinaHandOffPart): DvinaHandedTask[];
|
|
574
|
-
|
|
575
|
-
type DvinaTaskState = 'starting' | 'working' | 'waiting' | 'ready' | 'done' | 'stopped';
|
|
576
|
-
/** The lifecycle columns of a task's Chat row its state is read from (dates as the API or the SDK hold them). */
|
|
577
|
-
type DvinaTaskRow = {
|
|
578
|
-
busyAt?: Date | string | null;
|
|
579
|
-
idleAt?: Date | string | null;
|
|
580
|
-
idleOutcome?: string | null;
|
|
581
|
-
queuedAt?: Date | string | null;
|
|
582
|
-
waitingOn?: unknown;
|
|
583
|
-
};
|
|
584
|
-
/**
|
|
585
|
-
* A task's state from its own rows only, the one rule the API and the app both read it by: its Chat's lifecycle and
|
|
586
|
-
* its TaskJob's status. `jobStatus` is `null` when the task is known to have no TaskJob, `undefined` while that is not
|
|
587
|
-
* known yet (the app before its jobs load). Every run of a task has its TaskJob, so with none running an old row's busy
|
|
588
|
-
* or queued mark (a run cut before task core v2, a turn parked after its last try) is not a run: the task reads as
|
|
589
|
-
* ended. A failure reads as done; its note says what happened.
|
|
590
|
-
*/
|
|
591
|
-
declare function taskStateOf(chat: DvinaTaskRow, jobStatus: string | null | undefined): DvinaTaskState;
|
|
575
|
+
|
|
592
576
|
/** A tool call the system answered with a hold (the API's held-call.ts `heldCall`): the model reads `note`. */
|
|
593
577
|
type HeldCallOutput = {
|
|
594
578
|
guarded: 'hold';
|
|
@@ -750,4 +734,4 @@ type DvinaLazyToolOutput = {
|
|
|
750
734
|
/** The held-back output a tool part carries instead of its output, or `null` for a whole output. */
|
|
751
735
|
declare function lazyToolOutputOf(output: unknown): DvinaLazyToolOutput | null;
|
|
752
736
|
|
|
753
|
-
export { type DvinaAnswerOutcome, type DvinaChatActionsSdk, type DvinaChatMessageNode, type DvinaChatTransportOptions, type DvinaDataParts, type DvinaGoal, type DvinaGoalCriterion, type DvinaGoalEvaluation, type DvinaGoalStatus, type DvinaHandOffPart, type DvinaHandedTask, type DvinaLazyToolOutput, type DvinaMessageLinks, type DvinaMessageMetadata, type DvinaMessagePage, type DvinaMessageRoute, type
|
|
737
|
+
export { type DvinaAnswerOutcome, type DvinaChatActionsSdk, type DvinaChatMessageNode, type DvinaChatTransportOptions, type DvinaDataParts, type DvinaGoal, type DvinaGoalCriterion, type DvinaGoalEvaluation, type DvinaGoalStatus, type DvinaHandOffPart, type DvinaHandedTask, type DvinaLazyToolOutput, type DvinaMessageLinks, type DvinaMessageMetadata, type DvinaMessagePage, type DvinaMessageRoute, type DvinaToolMetadata, type DvinaUIMessage, type HeldCallOutput, LIVE_FILE_FORMATS, MAX_MESSAGE_PAGE, STOPPED_BY_USER, answerDvinaQuestion, answerDvinaToolCall, answeredMessageOf, createDvinaChatTransport, createDvinaTemporaryChatTransport, dvinaMessagePageOf, dvinaUIMessageOf, endingHoldIndex, endingHoldOf, fetchAllDvinaChatMessages, fetchDvinaNextPrompt, handedTasksOf, isHeldOutput, lazyToolOutputOf, postDvinaChatMessage, replyTargetIn, respondDvinaApproval, sentAgain, startDvinaDay, stopDvinaChat, wasUpdated };
|
package/dist/ai/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'../chunk-
|
|
1
|
+
import {a}from'../chunk-2L5VZY66.js';export{j as taskStateOf}from'../chunk-2L5VZY66.js';import {b as b$1,c as c$1}from'../chunk-XBOJ7CCU.js';import'../chunk-EK7ODJWE.js';import {DefaultChatTransport}from'ai';var S="The user stopped this reply before this call was answered.",O={html:"html",htm:"html",md:"markdown",markdown:"markdown",csv:"csv",svg:"svg",mmd:"mermaid",mermaid:"mermaid"},B=2;function*Q(e,{named:t=true}={}){if(e?.role!=="user")return;if(t&&e.metadata?.inResponseToTaskChatId)return e.metadata.inResponseToTaskChatId;let a=e.metadata?.inResponseToId??void 0;for(let n=0;a&&n<B;n++){let s=yield a;if(s?.referencedChatId)return s.referencedChatId;a=s?.inResponseToId??void 0;}}function R(e,t){let a=Q(e),n=a.next();for(;!n.done;)n=a.next(t(n.value));return n.value}function P(e){let{callProviderMetadata:t,resultProviderMetadata:a}=e;return t?.dvina?.updated===true||a?.dvina?.updated===true}function E(e){let t=e.input??{},a=[t.title,...(Array.isArray(t.tasks)?t.tasks:[]).map(A)].map(u),n=o=>o===0?e.toolCallId:`${e.toolCallId}:${o}`;if(e.state==="output-available"){let o=e.output??{},r=(Array.isArray(o.tasks)?o.tasks:[]).flatMap(l=>{let g=u(l?.chatId);return g?[{chatId:g,title:u(A(l))}]:[]}),i=u(o.chatId)??u(t.chatId),d=r.length?r:i?[{chatId:i,title:a[0]??null}]:[],k=new Set;return d.map((l,g)=>{let M=a.findIndex((x,$)=>!k.has($)&&!!x&&x===l.title),C=M>=0?M:g;return k.add(C),{...l,key:n(C)}})}let s=e.state==="input-streaming"?null:u(t.chatId);return s?[{chatId:s,title:a[0]??null,key:n(0)}]:a.map((o,r)=>({chatId:null,title:o,key:n(r)}))}function A(e){return e?.title}function u(e){return typeof e=="string"&&e.trim()?e.trim():null}function v(e){let t=e;return typeof t=="object"&&t!==null&&t.guarded==="hold"&&typeof t.note=="string"&&typeof t.hold?.reason=="string"}function D(e){let t=n=>n.type.startsWith("tool-")||n.type==="dynamic-tool",a=e.parts.flatMap((n,s)=>n.type==="step-start"?[s]:[]);for(let n=a.length-1;n>=-1;n--){let s=n<0?0:a[n]??0,o=e.parts.slice(s,a[n+1]??e.parts.length);if(!o.some(t))continue;let r=o.findIndex(i=>t(i)&&i.state==="output-available"&&v(i.output));return r<0?-1:s+r}return -1}function _(e){if(!e)return;let t=D(e);return t<0?void 0:e.parts[t].output.hold}var V=["threadId","inResponseToId","inResponseToExcerpt","inResponseToTaskChatId","resourceFiles","voiceInput","surface","screenContext","hidden"],q=new Set(["text","file","data-context"]);function U(e,t,a){let n={};for(let r of V){let i=e.metadata?.[r];i!=null&&i!==false&&Object.assign(n,{[r]:i});}let{createdAt:s,afterReply:o}=a;return {id:t,role:"user",parts:e.parts.filter(r=>q.has(r.type)),metadata:{...n,...s?{createdAt:s}:{},...o?{afterReply:o}:{},retryOf:e.id}}}function N(e,t){let a=t.metadata?.inResponseToId;if(a)return e.find(s=>s.id===a&&s.role==="user");let n=e.indexOf(t);return (n<0?e:e.slice(0,n)).findLast(s=>s.role==="user")}function X(e){let t=`${e.apiUrl.replace(/\/+$/,"")}/api/chat`;return new DefaultChatTransport({api:t,fetch:G(H(e)),prepareSendMessagesRequest:({id:a,messages:n,trigger:s,messageId:o,body:r})=>({api:`${t}/${encodeURIComponent(a)}`,body:{...r,trigger:s,messageId:o,message:n[n.length-1]}}),prepareReconnectToStreamRequest:({id:a})=>({api:`${t}/${encodeURIComponent(a)}/stream`})})}function K(e){return new DefaultChatTransport({api:`${e.apiUrl.replace(/\/+$/,"")}/api/temporary-chat`,fetch:G(H(e))})}var y=[1e3,2e3,4e3,8e3,15e3,3e4],p=429,J=6e4;function G(e,t=y,a=[503]){return async(n,s)=>{for(let o of t){let r=await e(n,s).catch(d=>{if(s?.signal?.aborted||!(d instanceof TypeError))throw d;return null}),i=r?.status===p;if(r&&!i&&!a.includes(r.status))return r;await r?.body?.cancel().catch(()=>{}),await T(i?Z(r,o):o,s?.signal??void 0);}return e(n,s)}}function Z(e,t){let a=Number.NaN;return e.headers.forEach((n,s)=>{Number.isNaN(a)&&s.toLowerCase().startsWith("retry-after")&&(a=Number(n));}),Number.isFinite(a)&&a>0?Math.min(Math.max(a*1e3,t),J):t}function T(e,t){return new Promise((a,n)=>{if(t?.aborted)return n(t.reason);let s=setTimeout(()=>{t?.removeEventListener("abort",o),a();},e),o=()=>{clearTimeout(s),n(t?.reason);};t?.addEventListener("abort",o,{once:true});})}var ee=a();function H(e){let t=e.fetch??globalThis.fetch.bind(globalThis),a=async(n,s,o)=>{let r=new Headers(s?.headers);r.set("Authorization",`Bearer ${await e.getToken({forceRefresh:o})}`);let i=ee();i&&!r.has("x-user-timezone")&&r.set("x-user-timezone",i);let d=e.getLanguage?.();return d&&!r.has("x-preferred-language")&&r.set("x-preferred-language",d),t(n,{...s,headers:r})};return async(n,s)=>{let o=await a(n,s,false);return o.status===401?a(n,s,true):o}}async function te(e,t,a,n){await c(()=>e.sendChatMessageWhileRunning({chatId:t,message:a}),{statuses:ge,rateLimited:true,signal:n});}async function ne(e,t){let a=await c(()=>e.chatNextPrompt({chatId:t}),{delaysMs:[1e3,3e3]});return typeof a=="string"&&a.trim()?a:null}async function ae(e,t){await c(()=>e.stopChat({chatId:t}),{statuses:F});}function se(e,t,a,n){return b(()=>e.respondChatApproval({chatId:t,toolCallId:a,approved:n.approved}))}function re(e,t,a,n){return b(()=>e.answerChatQuestion({chatId:t,toolCallId:a,answers:n}))}function oe(e,t,a,n){return b(()=>e.answerChatToolCall({chatId:t,toolCallId:a,...n}))}async function ie(e){return {started:await e.startChatDay()}}async function b(e){try{return await c(e,{statuses:F,signal:AbortSignal.timeout(pe)}),"sent"}catch(t){if(de(t))return "answered-elsewhere";throw t}}function de(e){return e instanceof b$1&&e.errors.some(t=>t.message===z||t.extensions?.code===z)}var z="NOT_WAITING";function ue(e){return e instanceof c$1?e.status===p:e instanceof b$1&&e.errors.some(t=>/ThrottlerException|Too Many Requests/i.test(t.message)||t.extensions?.code==="TOO_MANY_REQUESTS"||t.extensions?.originalError?.statusCode===p)}var le=[503],ge=[500,502,503,504],F=[502,503,504],pe=9e4,j=0;async function c(e,{delaysMs:t=y,statuses:a=le,rateLimited:n=false,signal:s}={}){let o=r=>r instanceof c$1&&(r.status===j||a.includes(r.status??j))||n&&ue(r);for(let r of t){try{return await Y(e(),s)}catch(i){if(s?.aborted||!o(i))throw i}await T(r,s);}return Y(e(),s)}function Y(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((a,n)=>{let s=()=>n(t.reason);t.addEventListener("abort",s,{once:true}),e.then(a,n).finally(()=>t.removeEventListener("abort",s));}):e}function I(e){return {id:e.id,role:e.role,parts:e.parts??[],...e.metadata?{metadata:e.metadata}:{}}}function ce(e){let{pageInfo:t}=e;return {messages:e.nodes.map(I),hasOlder:t.hasPreviousPage,hasNewer:t.hasNextPage,...t.startCursor?{startCursor:t.startCursor}:{},...t.endCursor?{endCursor:t.endCursor}:{}}}var W=200;async function me(e,t,{pageSize:a=W}={}){let n=[],s;for(;;){let o=await e.chatMessages({...t,first:a,after:s}).fetch();n.push(...o.nodes.map(I));let r=o.pageInfo.endCursor??void 0;if(!o.pageInfo.hasNextPage||!r||r===s)return n;s=r;}}function fe(e){if(!e||typeof e!="object"||!("dvinaLazyOutput"in e))return null;let t=e.dvinaLazyOutput;if(!t||typeof t!="object")return null;let{bytes:a,preview:n,urls:s}=t;return {bytes:typeof a=="number"?a:0,preview:typeof n=="string"?n:"",urls:Array.isArray(s)?s.filter(o=>typeof o=="string"):[]}}export{O as LIVE_FILE_FORMATS,W as MAX_MESSAGE_PAGE,S as STOPPED_BY_USER,re as answerDvinaQuestion,oe as answerDvinaToolCall,N as answeredMessageOf,X as createDvinaChatTransport,K as createDvinaTemporaryChatTransport,ce as dvinaMessagePageOf,I as dvinaUIMessageOf,D as endingHoldIndex,_ as endingHoldOf,me as fetchAllDvinaChatMessages,ne as fetchDvinaNextPrompt,E as handedTasksOf,v as isHeldOutput,fe as lazyToolOutputOf,te as postDvinaChatMessage,R as replyTargetIn,se as respondDvinaApproval,U as sentAgain,ie as startDvinaDay,ae as stopDvinaChat,P as wasUpdated};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=["idle","queued","claimed","streaming","starting","waiting"],u=["approval","question","device","app","handover","quota"],r=["approval","question"],p=["device"];var d=200;function l(e){return e?.phase==="queued"||e?.phase==="claimed"||e?.phase==="streaming"}function c(e){return e?.phase==="starting"?true:e?.phase==="waiting"&&!!e.waitingOn&&!r.includes(e.waitingOn)}function g(e){return e?Object.values(e.asking??{}).some(t=>t.length>0)?true:e.phase==="waiting"&&!!e.waitingOn&&r.includes(e.waitingOn):false}function h(e,t){if(e?.phase==="waiting")return "waiting";let i=t===void 0||t==="running",n=e?.phase;return i&&(n==="claimed"||n==="streaming"||n==="starting")?"working":i&&n==="queued"?"starting":t&&t!=="running"?"ready":e?.outcome==="interrupted"?"stopped":e?.outcome==="failed"?"failed":"done"}function a(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||t.length>100))try{return Intl.DateTimeFormat(void 0,{timeZone:t}),t}catch{return}}function m(){return ()=>{if(!(!o()||typeof Intl>"u"||typeof Intl.DateTimeFormat!="function"))return a(Intl.DateTimeFormat().resolvedOptions().timeZone)}}function o(){return typeof window<"u"&&typeof document<"u"}export{m as a,s as b,u as c,r as d,p as e,d as f,l as g,c as h,g as i,h as j};
|