@dvina/sdk 5.0.65 → 5.0.67

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.
@@ -1,10 +1,10 @@
1
1
  import { UIMessage, DefaultChatTransport } from 'ai';
2
- import { D as DvinaSdk, C as ChatMessage, a as ChatMessageConnection } from '../_generated_sdk-CMF68az0.js';
3
- import '../types-0oS5PBdX.js';
2
+ import { D as DvinaSdk, C as ChatMessage, a as ChatMessageConnection } from '../_generated_sdk-CEEffwAc.js';
3
+ import '../types-DlNXHZQK.js';
4
4
  import 'graphql';
5
- import '../connection-DkvWhViN.js';
5
+ import '../connection-CcX51iG3.js';
6
6
  import 'dexie';
7
- import '../error-aFALORBM.js';
7
+ import '../error-B-z8CPkV.js';
8
8
  import '../billing/index.js';
9
9
 
10
10
  /** Where the supervisor sent a user message: answered itself, relayed it to a task, or started a new task. */
@@ -39,6 +39,11 @@ type DvinaMessageMetadata = {
39
39
  inResponseToId?: string | null;
40
40
  /** The user inputs this reply consumes together; durable wake-ups use this to avoid answering a batch twice. */
41
41
  answeredUserMessageIds?: string[];
42
+ /**
43
+ * On a user message whose reply the reader deleted while keeping it: when a turn had handled it. It is answered for
44
+ * good: deleting a reply tidies the chat, never asks again (a new answer is a new message).
45
+ */
46
+ handledAt?: string;
42
47
  /** The part of the replied-to message the user answered, as the reply's quote shows it. */
43
48
  inResponseToExcerpt?: string;
44
49
  /** Task chat a supervisor message refers to. */
@@ -161,6 +166,11 @@ type DvinaDataParts = {
161
166
  privacy: {
162
167
  maskedValueCount: number;
163
168
  matchedTypes: string[];
169
+ /** What the model did not see, by kind: the value, or its masked form when masked for good. Older notes have none. */
170
+ maskedValues?: {
171
+ type: string;
172
+ text: string;
173
+ }[];
164
174
  };
165
175
  /** Context the model reads with the user's message but the UI does not show; persisted with the message. */
166
176
  context: {
@@ -279,12 +289,6 @@ type DvinaDataParts = {
279
289
  agentId?: string;
280
290
  agentName?: string;
281
291
  };
282
- /**
283
- * A task's one-line badge on a supervisor message: the message that started it (`delegate`), relayed a user
284
- * message to it (`relay`) or presents its result (`result`); `candidate` is an older "which one?" offer's task,
285
- * drawn as nothing since that question is asked by its card above the composer (2026-11-02). In a chat, a task's latest delegate/relay badge is live and follows the task. An earlier one
286
- * is frozen: it shows the `previous` state of the task's next badge, or its own `state` at `at`.
287
- */
288
292
  /**
289
293
  * A long conversation's checkpoint (agents `Checkpoint`), kept on the reply whose turn wrote it: the summary the
290
294
  * chat's model wrote of the turns before it, and the newest of them as text. The model reads the chat from it on;
@@ -305,12 +309,6 @@ type DvinaDataParts = {
305
309
  'dlp-blocked': {
306
310
  rules: string[];
307
311
  };
308
- /** Older replies: a user reply the supervisor passed to a task chat (now `task-badge`). */
309
- 'task-follow-up': {
310
- chatId: string;
311
- /** The task chat message the reply was passed as; the task's reply answers it (`metadata.inResponseToId`). */
312
- messageId?: string;
313
- };
314
312
  /** A task chat's live progress line in the user's language, updated in place after each step. */
315
313
  narration: {
316
314
  text: string;
@@ -511,8 +509,35 @@ type DvinaMessageLinks = {
511
509
  inResponseToId?: string | null;
512
510
  referencedChatId?: string | null;
513
511
  };
514
- /** replyTargetSteps over the messages in hand: `links` reads one by id (undefined when it is not there). */
512
+ /**
513
+ * replyTargetSteps over the messages in hand: `links` reads one by id (undefined when it is not there).
514
+ * @deprecated Kept for SDK consumers; the app no longer reads a reply's task itself. Send the reply with
515
+ * `metadata.inResponseToId` (and `inResponseToTaskChatId` when it names a task): the API routes it (TaskChats.replyTarget).
516
+ */
515
517
  declare function replyTargetIn(message: DvinaUIMessage | undefined, links: (messageId: string) => DvinaMessageLinks | null | undefined): string | undefined;
518
+ /**
519
+ * Whether a tool part's output was replaced by a later version of it (`callProviderMetadata.dvina.updated`, written
520
+ * by the task's One Chat writes): the app marks it "Updated". Only tool parts carry call metadata.
521
+ */
522
+ declare function wasUpdated(part: object): boolean;
523
+ /** A task's state, in Claude's few words (task core v2 plan §3a). */
524
+ type DvinaTaskState = 'starting' | 'working' | 'waiting' | 'ready' | 'done' | 'stopped';
525
+ /** The lifecycle columns of a task's Chat row its state is read from (dates as the API or the SDK hold them). */
526
+ type DvinaTaskRow = {
527
+ busyAt?: Date | string | null;
528
+ idleAt?: Date | string | null;
529
+ idleOutcome?: string | null;
530
+ queuedAt?: Date | string | null;
531
+ waitingOn?: unknown;
532
+ };
533
+ /**
534
+ * 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
535
+ * its TaskJob's status. `jobStatus` is `null` when the task is known to have no TaskJob, `undefined` while that is not
536
+ * 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
537
+ * 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
538
+ * ended. A failure reads as done; its note says what happened.
539
+ */
540
+ declare function taskStateOf(chat: DvinaTaskRow, jobStatus: string | null | undefined): DvinaTaskState;
516
541
 
517
542
  type DvinaChatTransportOptions = {
518
543
  /** API origin including protocol, e.g. `https://api.dvina.ai`. */
@@ -545,7 +570,7 @@ declare function createDvinaChatTransport(options: DvinaChatTransportOptions): D
545
570
  declare function createDvinaTemporaryChatTransport(options: DvinaChatTransportOptions): DefaultChatTransport<DvinaUIMessage>;
546
571
 
547
572
  /** The chat actions of the SDK, as the functions below call them. */
548
- type DvinaChatActionsSdk = Pick<DvinaSdk, 'sendChatMessageWhileRunning' | 'chatNextPrompt' | 'stopChat' | 'grantChatApproval' | 'respondChatApproval' | 'answerChatQuestion' | 'startChatDay'>;
573
+ type DvinaChatActionsSdk = Pick<DvinaSdk, 'sendChatMessageWhileRunning' | 'chatNextPrompt' | 'stopChat' | 'respondChatApproval' | 'answerChatQuestion' | 'startChatDay'>;
549
574
  /**
550
575
  * Sends a user message while the chat's turn runs: the server stores it at once (every device shows it) and answers it
551
576
  * with the chat's next turn, without cutting the running reply off. Sending it again under the same id changes nothing,
@@ -560,20 +585,14 @@ declare function postDvinaChatMessage(sdk: DvinaChatActionsSdk, chatId: string,
560
585
  declare function fetchDvinaNextPrompt(sdk: DvinaChatActionsSdk, chatId: string): Promise<string | null>;
561
586
  /** Stops the chat's running turn on the server; streaming clients then finish normally. */
562
587
  declare function stopDvinaChat(sdk: DvinaChatActionsSdk, chatId: string): Promise<void>;
563
- /**
564
- * Lets a task do this tool from now on without asking (its later approvals for the tool pass on the server); the
565
- * approval waiting now is still answered as usual. Only the caller's own task chats, only tools that ask.
566
- */
567
- declare function grantDvinaTaskApproval(sdk: DvinaChatActionsSdk, taskChatId: string, toolName: string): Promise<void>;
568
588
  /** What became of an answer given outside the chat: sent, or the chat no longer waited for it (answered elsewhere). */
569
589
  type DvinaAnswerOutcome = 'sent' | 'answered-elsewhere';
570
590
  /**
571
- * Answers a chat's waiting approval from outside the chat (a notification), as the chat's own card does; `always`
572
- * also allows the tool for the chat from now on. The turn continues on the server.
591
+ * Answers a chat's waiting approval from outside the chat (a notification), as the chat's own card does. The turn
592
+ * continues on the server.
573
593
  */
574
594
  declare function respondDvinaApproval(sdk: DvinaChatActionsSdk, chatId: string, toolCallId: string, answer: {
575
595
  approved: boolean;
576
- always?: boolean;
577
596
  }): Promise<DvinaAnswerOutcome>;
578
597
  /** Answers a chat's waiting question from outside the chat (a notification's reply): one answer list per question. */
579
598
  declare function answerDvinaQuestion(sdk: DvinaChatActionsSdk, chatId: string, toolCallId: string, answers: string[][]): Promise<DvinaAnswerOutcome>;
@@ -607,12 +626,17 @@ type DvinaMessagePage = {
607
626
  };
608
627
  /** A `chatMessages` or `chatMessagesAround` connection, oldest first, as a page of AI SDK messages. */
609
628
  declare function dvinaMessagePageOf(connection: Pick<ChatMessageConnection, 'nodes' | 'pageInfo'>): DvinaMessagePage;
610
- /** The most the API gives in one page (`first` and `last` are capped there). */
629
+ /**
630
+ * The most the API gives in one page (`first` and `last` are capped there).
631
+ * @deprecated Only fetchAllDvinaChatMessages reads it; page with `chatMessages` and dvinaMessagePageOf.
632
+ */
611
633
  declare const MAX_MESSAGE_PAGE = 200;
612
634
  /**
613
635
  * A whole chat, or one thread of it with the message it started from, oldest first: `chatMessages` read forward
614
636
  * (`first` + `after`) page by page to the end. For short reads such as a thread or a task chat; long chats load by
615
637
  * page. Each page is a one-off fetch, never a watch. A chat the caller may not read, or one not created yet, has none.
638
+ * @deprecated A one-off read of every page goes stale at once. Watch the chat's pages instead: `sdk.chatMessages(...)`
639
+ * with `.watch()` (or the React `useLiveQuery`), each page through dvinaMessagePageOf.
616
640
  */
617
641
  declare function fetchAllDvinaChatMessages(sdk: Pick<DvinaSdk, 'chatMessages'>, scope: {
618
642
  chatId: string;
@@ -633,4 +657,4 @@ type DvinaLazyToolOutput = {
633
657
  /** The held-back output a tool part carries instead of its output, or `null` for a whole output. */
634
658
  declare function lazyToolOutputOf(output: unknown): DvinaLazyToolOutput | null;
635
659
 
636
- export { type DvinaAnswerOutcome, type DvinaChatActionsSdk, type DvinaChatMessageNode, type DvinaChatTransportOptions, type DvinaDataParts, type DvinaGoal, type DvinaGoalCriterion, type DvinaGoalEvaluation, type DvinaGoalStatus, type DvinaLazyToolOutput, type DvinaMessageLinks, type DvinaMessageMetadata, type DvinaMessagePage, type DvinaMessageRoute, type DvinaToolMetadata, type DvinaUIMessage, LIVE_FILE_FORMATS, MAX_MESSAGE_PAGE, answerDvinaQuestion, createDvinaChatTransport, createDvinaTemporaryChatTransport, dvinaMessagePageOf, dvinaUIMessageOf, fetchAllDvinaChatMessages, fetchDvinaNextPrompt, grantDvinaTaskApproval, lazyToolOutputOf, postDvinaChatMessage, replyTargetIn, respondDvinaApproval, startDvinaDay, stopDvinaChat };
660
+ export { type DvinaAnswerOutcome, type DvinaChatActionsSdk, type DvinaChatMessageNode, type DvinaChatTransportOptions, type DvinaDataParts, type DvinaGoal, type DvinaGoalCriterion, type DvinaGoalEvaluation, type DvinaGoalStatus, type DvinaLazyToolOutput, type DvinaMessageLinks, type DvinaMessageMetadata, type DvinaMessagePage, type DvinaMessageRoute, type DvinaTaskRow, type DvinaTaskState, type DvinaToolMetadata, type DvinaUIMessage, LIVE_FILE_FORMATS, MAX_MESSAGE_PAGE, answerDvinaQuestion, createDvinaChatTransport, createDvinaTemporaryChatTransport, dvinaMessagePageOf, dvinaUIMessageOf, fetchAllDvinaChatMessages, fetchDvinaNextPrompt, lazyToolOutputOf, postDvinaChatMessage, replyTargetIn, respondDvinaApproval, startDvinaDay, stopDvinaChat, taskStateOf, wasUpdated };
package/dist/ai/index.js CHANGED
@@ -1 +1 @@
1
- import {a}from'../chunk-32KGDH2Q.js';import {b as b$1,c as c$1}from'../chunk-37LLNIGO.js';import'../chunk-EK7ODJWE.js';import {DefaultChatTransport}from'ai';var v={html:"html",htm:"html",md:"markdown",markdown:"markdown",csv:"csv",svg:"svg",mmd:"mermaid",mermaid:"mermaid"},k=2;function*w(e,{named:t=true}={}){if(e?.role!=="user")return;if(t&&e.metadata?.inResponseToTaskChatId)return e.metadata.inResponseToTaskChatId;let n=e.metadata?.inResponseToId??void 0;for(let a=0;n&&a<k;a++){let r=yield n;if(r?.referencedChatId)return r.referencedChatId;n=r?.inResponseToId??void 0;}}function f(e,t){let n=w(e),a=n.next();for(;!a.done;)a=n.next(t(a.value));return a.value}function S(e){let t=`${e.apiUrl.replace(/\/+$/,"")}/api/chat`;return new DefaultChatTransport({api:t,fetch:D(b(e)),prepareSendMessagesRequest:({id:n,messages:a,trigger:r,messageId:o,body:s})=>({api:`${t}/${encodeURIComponent(n)}`,body:{...s,trigger:r,messageId:o,message:a[a.length-1]}}),prepareReconnectToStreamRequest:({id:n})=>({api:`${t}/${encodeURIComponent(n)}/stream`})})}function R(e){return new DefaultChatTransport({api:`${e.apiUrl.replace(/\/+$/,"")}/api/temporary-chat`,fetch:D(b(e))})}var _=[1e3,2e3,4e3,8e3,15e3,3e4],E=429,P=6e4;function D(e,t=_,n=[503]){return async(a,r)=>{for(let o of t){let s=await e(a,r).catch(u=>{if(r?.signal?.aborted||!(u instanceof TypeError))throw u;return null}),i=s?.status===E;if(s&&!i&&!n.includes(s.status))return s;await s?.body?.cancel().catch(()=>{}),await U(i?O(s,o):o,r?.signal??void 0);}return e(a,r)}}function O(e,t){let n=Number.NaN;return e.headers.forEach((a,r)=>{Number.isNaN(n)&&r.toLowerCase().startsWith("retry-after")&&(n=Number(a));}),Number.isFinite(n)&&n>0?Math.min(Math.max(n*1e3,t),P):t}function U(e,t){return new Promise((n,a)=>{if(t?.aborted)return a(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",o),n();},e),o=()=>{clearTimeout(r),a(t?.reason);};t?.addEventListener("abort",o,{once:true});})}var N=a();function b(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=async(a,r,o)=>{let s=new Headers(r?.headers);s.set("Authorization",`Bearer ${await e.getToken({forceRefresh:o})}`);let i=N();i&&!s.has("x-user-timezone")&&s.set("x-user-timezone",i);let u=e.getLanguage?.();return u&&!s.has("x-preferred-language")&&s.set("x-preferred-language",u),t(a,{...r,headers:s})};return async(a,r)=>{let o=await n(a,r,false);return o.status===401?n(a,r,true):o}}async function L(e,t,n,a){await d(()=>e.sendChatMessageWhileRunning({chatId:t,message:n}),{statuses:V,rateLimited:true,signal:a});}async function G(e,t){let n=await d(()=>e.chatNextPrompt({chatId:t}),{delaysMs:[1e3,3e3]});return typeof n=="string"&&n.trim()?n:null}async function z(e,t){await d(()=>e.stopChat({chatId:t}),{statuses:l});}async function j(e,t,n){await d(()=>e.grantChatApproval({chatId:t,toolName:n}),{statuses:l,signal:AbortSignal.timeout(x)});}function F(e,t,n,a){return M(()=>e.respondChatApproval({chatId:t,toolCallId:n,approved:a.approved,always:a.always}))}function Y(e,t,n,a){return M(()=>e.answerChatQuestion({chatId:t,toolCallId:n,answers:a}))}async function W(e){return {started:await e.startChatDay()}}async function M(e){try{return await d(e,{statuses:l,signal:AbortSignal.timeout(x)}),"sent"}catch(t){if($(t))return "answered-elsewhere";throw t}}function $(e){return e instanceof b$1&&e.errors.some(t=>t.message===y||t.extensions?.code===y)}var y="NOT_WAITING";function Q(e){return e instanceof c$1?e.status===T: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===T)}var q=[1e3,2e3,4e3,8e3,15e3,3e4],B=[503],V=[500,502,503,504],T=429,l=[502,503,504],x=9e4,C=0;async function d(e,{delaysMs:t=q,statuses:n=B,rateLimited:a=false,signal:r}={}){let o=s=>s instanceof c$1&&(s.status===C||n.includes(s.status??C))||a&&Q(s);for(let s of t){try{return await I(e(),r)}catch(i){if(r?.aborted||!o(i))throw i}await H(s,r);}return I(e(),r)}function I(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((n,a)=>{let r=()=>a(t.reason);t.addEventListener("abort",r,{once:true}),e.then(n,a).finally(()=>t.removeEventListener("abort",r));}):e}function H(e,t){return new Promise((n,a)=>{if(t?.aborted)return a(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",o),n();},e),o=()=>{clearTimeout(r),a(t?.reason);};t?.addEventListener("abort",o,{once:true});})}function c(e){return {id:e.id,role:e.role,parts:e.parts??[],...e.metadata?{metadata:e.metadata}:{}}}function X(e){let{pageInfo:t}=e;return {messages:e.nodes.map(c),hasOlder:t.hasPreviousPage,hasNewer:t.hasNextPage,...t.startCursor?{startCursor:t.startCursor}:{},...t.endCursor?{endCursor:t.endCursor}:{}}}var A=200;async function K(e,t,{pageSize:n=A}={}){let a=[],r;for(;;){let o=await e.chatMessages({...t,first:n,after:r}).fetch();a.push(...o.nodes.map(c));let s=o.pageInfo.endCursor??void 0;if(!o.pageInfo.hasNextPage||!s||s===r)return a;r=s;}}function J(e){if(!e||typeof e!="object"||!("dvinaLazyOutput"in e))return null;let t=e.dvinaLazyOutput;if(!t||typeof t!="object")return null;let{bytes:n,preview:a,urls:r}=t;return {bytes:typeof n=="number"?n:0,preview:typeof a=="string"?a:"",urls:Array.isArray(r)?r.filter(o=>typeof o=="string"):[]}}export{v as LIVE_FILE_FORMATS,A as MAX_MESSAGE_PAGE,Y as answerDvinaQuestion,S as createDvinaChatTransport,R as createDvinaTemporaryChatTransport,X as dvinaMessagePageOf,c as dvinaUIMessageOf,K as fetchAllDvinaChatMessages,G as fetchDvinaNextPrompt,j as grantDvinaTaskApproval,J as lazyToolOutputOf,L as postDvinaChatMessage,f as replyTargetIn,F as respondDvinaApproval,W as startDvinaDay,z as stopDvinaChat};
1
+ import {a}from'../chunk-32KGDH2Q.js';import {b as b$1,c as c$1}from'../chunk-YQD7354H.js';import'../chunk-EK7ODJWE.js';import {DefaultChatTransport}from'ai';var h={html:"html",htm:"html",md:"markdown",markdown:"markdown",csv:"csv",svg:"svg",mmd:"mermaid",mermaid:"mermaid"},S=2;function*E(e,{named:t=true}={}){if(e?.role!=="user")return;if(t&&e.metadata?.inResponseToTaskChatId)return e.metadata.inResponseToTaskChatId;let n=e.metadata?.inResponseToId??void 0;for(let a=0;n&&a<S;a++){let r=yield n;if(r?.referencedChatId)return r.referencedChatId;n=r?.inResponseToId??void 0;}}function D(e,t){let n=E(e),a=n.next();for(;!a.done;)a=n.next(t(a.value));return a.value}function y(e){return e.callProviderMetadata?.dvina?.updated===true}function b(e,t){if(e.waitingOn)return "waiting";let n=t===void 0||t==="running",a=r=>r?new Date(r).getTime():0;return n&&e.busyAt&&(!e.idleAt||a(e.busyAt)>a(e.idleAt))?"working":n&&e.queuedAt?"starting":t&&t!=="running"?"ready":e.idleOutcome==="interrupted"?"stopped":"done"}function _(e){let t=`${e.apiUrl.replace(/\/+$/,"")}/api/chat`;return new DefaultChatTransport({api:t,fetch:M(C(e)),prepareSendMessagesRequest:({id:n,messages:a,trigger:r,messageId:i,body:s})=>({api:`${t}/${encodeURIComponent(n)}`,body:{...s,trigger:r,messageId:i,message:a[a.length-1]}}),prepareReconnectToStreamRequest:({id:n})=>({api:`${t}/${encodeURIComponent(n)}/stream`})})}function O(e){return new DefaultChatTransport({api:`${e.apiUrl.replace(/\/+$/,"")}/api/temporary-chat`,fetch:M(C(e))})}var m=[1e3,2e3,4e3,8e3,15e3,3e4],u=429,P=6e4;function M(e,t=m,n=[503]){return async(a,r)=>{for(let i of t){let s=await e(a,r).catch(d=>{if(r?.signal?.aborted||!(d instanceof TypeError))throw d;return null}),o=s?.status===u;if(s&&!o&&!n.includes(s.status))return s;await s?.body?.cancel().catch(()=>{}),await c(o?U(s,i):i,r?.signal??void 0);}return e(a,r)}}function U(e,t){let n=Number.NaN;return e.headers.forEach((a,r)=>{Number.isNaN(n)&&r.toLowerCase().startsWith("retry-after")&&(n=Number(a));}),Number.isFinite(n)&&n>0?Math.min(Math.max(n*1e3,t),P):t}function c(e,t){return new Promise((n,a)=>{if(t?.aborted)return a(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",i),n();},e),i=()=>{clearTimeout(r),a(t?.reason);};t?.addEventListener("abort",i,{once:true});})}var N=a();function C(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=async(a,r,i)=>{let s=new Headers(r?.headers);s.set("Authorization",`Bearer ${await e.getToken({forceRefresh:i})}`);let o=N();o&&!s.has("x-user-timezone")&&s.set("x-user-timezone",o);let d=e.getLanguage?.();return d&&!s.has("x-preferred-language")&&s.set("x-preferred-language",d),t(a,{...r,headers:s})};return async(a,r)=>{let i=await n(a,r,false);return i.status===401?n(a,r,true):i}}async function L(e,t,n,a){await g(()=>e.sendChatMessageWhileRunning({chatId:t,message:n}),{statuses:q,rateLimited:true,signal:a});}async function G(e,t){let n=await g(()=>e.chatNextPrompt({chatId:t}),{delaysMs:[1e3,3e3]});return typeof n=="string"&&n.trim()?n:null}async function z(e,t){await g(()=>e.stopChat({chatId:t}),{statuses:A});}function j(e,t,n,a){return w(()=>e.respondChatApproval({chatId:t,toolCallId:n,approved:a.approved}))}function F(e,t,n,a){return w(()=>e.answerChatQuestion({chatId:t,toolCallId:n,answers:a}))}async function Y(e){return {started:await e.startChatDay()}}async function w(e){try{return await g(e,{statuses:A,signal:AbortSignal.timeout(V)}),"sent"}catch(t){if(W(t))return "answered-elsewhere";throw t}}function W(e){return e instanceof b$1&&e.errors.some(t=>t.message===I||t.extensions?.code===I)}var I="NOT_WAITING";function $(e){return e instanceof c$1?e.status===u: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===u)}var Q=[503],q=[500,502,503,504],A=[502,503,504],V=9e4,x=0;async function g(e,{delaysMs:t=m,statuses:n=Q,rateLimited:a=false,signal:r}={}){let i=s=>s instanceof c$1&&(s.status===x||n.includes(s.status??x))||a&&$(s);for(let s of t){try{return await k(e(),r)}catch(o){if(r?.aborted||!i(o))throw o}await c(s,r);}return k(e(),r)}function k(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((n,a)=>{let r=()=>a(t.reason);t.addEventListener("abort",r,{once:true}),e.then(n,a).finally(()=>t.removeEventListener("abort",r));}):e}function f(e){return {id:e.id,role:e.role,parts:e.parts??[],...e.metadata?{metadata:e.metadata}:{}}}function B(e){let{pageInfo:t}=e;return {messages:e.nodes.map(f),hasOlder:t.hasPreviousPage,hasNewer:t.hasNextPage,...t.startCursor?{startCursor:t.startCursor}:{},...t.endCursor?{endCursor:t.endCursor}:{}}}var R=200;async function H(e,t,{pageSize:n=R}={}){let a=[],r;for(;;){let i=await e.chatMessages({...t,first:n,after:r}).fetch();a.push(...i.nodes.map(f));let s=i.pageInfo.endCursor??void 0;if(!i.pageInfo.hasNextPage||!s||s===r)return a;r=s;}}function X(e){if(!e||typeof e!="object"||!("dvinaLazyOutput"in e))return null;let t=e.dvinaLazyOutput;if(!t||typeof t!="object")return null;let{bytes:n,preview:a,urls:r}=t;return {bytes:typeof n=="number"?n:0,preview:typeof a=="string"?a:"",urls:Array.isArray(r)?r.filter(i=>typeof i=="string"):[]}}export{h as LIVE_FILE_FORMATS,R as MAX_MESSAGE_PAGE,F as answerDvinaQuestion,_ as createDvinaChatTransport,O as createDvinaTemporaryChatTransport,B as dvinaMessagePageOf,f as dvinaUIMessageOf,H as fetchAllDvinaChatMessages,G as fetchDvinaNextPrompt,X as lazyToolOutputOf,L as postDvinaChatMessage,D as replyTargetIn,j as respondDvinaApproval,Y as startDvinaDay,z as stopDvinaChat,b as taskStateOf,y as wasUpdated};
@@ -1,4 +1,4 @@
1
- import { D as DvinaError } from '../error-aFALORBM.js';
1
+ import { D as DvinaError } from '../error-B-z8CPkV.js';
2
2
 
3
3
  type Maybe<T> = T | null;
4
4
  type InputMaybe<T> = Maybe<T>;
@@ -1 +1 @@
1
- export{j as BillingClient,f as CancelReason,g as EntitlementTier,h as SubscriptionCycle,i as SubscriptionProvider}from'../chunk-3DLZQFCQ.js';import'../chunk-37LLNIGO.js';import'../chunk-EK7ODJWE.js';
1
+ export{j as BillingClient,f as CancelReason,g as EntitlementTier,h as SubscriptionCycle,i as SubscriptionProvider}from'../chunk-XTZRMWVM.js';import'../chunk-YQD7354H.js';import'../chunk-EK7ODJWE.js';