@runtypelabs/persona 4.27.0 → 4.28.0
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/approval-ui.d.cts +13 -0
- package/dist/approval-ui.d.ts +13 -0
- package/dist/artifacts-ui.d.cts +13 -0
- package/dist/artifacts-ui.d.ts +13 -0
- package/dist/chunk-AALCT54S.js +1 -0
- package/dist/{client-history-HTRKHBAF.js → client-history-LV3KHEFA.js} +1 -1
- package/dist/client-history.js +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions.d.cts +13 -0
- package/dist/context-mentions.d.ts +13 -0
- package/dist/event-stream-view.d.cts +13 -0
- package/dist/event-stream-view.d.ts +13 -0
- package/dist/forms-ui.d.cts +19 -0
- package/dist/forms-ui.d.ts +19 -0
- package/dist/index.cjs +33 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/dist/session-reconnect.d.cts +13 -0
- package/dist/session-reconnect.d.ts +13 -0
- package/dist/smart-dom-reader.d.cts +13 -0
- package/dist/smart-dom-reader.d.ts +13 -0
- package/dist/theme-editor-preview.cjs +63 -63
- package/dist/theme-editor-preview.d.cts +13 -0
- package/dist/theme-editor-preview.d.ts +13 -0
- package/dist/theme-editor-preview.js +5 -5
- package/dist/theme-editor.d.cts +13 -0
- package/dist/theme-editor.d.ts +13 -0
- package/dist/voice-runtime-LVUMPUDS.js +17 -0
- package/dist/voice-runtime.cjs +8 -8
- package/dist/voice-runtime.d.cts +24 -0
- package/dist/voice-runtime.d.ts +24 -0
- package/dist/voice-runtime.js +8 -8
- package/package.json +1 -1
- package/src/client.interrupt.test.ts +18 -0
- package/src/client.ts +7 -0
- package/src/session.ts +11 -3
- package/src/session.voice.test.ts +140 -0
- package/src/types.ts +19 -0
- package/src/voice/runtype-voice-provider.ts +93 -11
- package/src/voice/voice-clause-buffer.test.ts +143 -0
- package/src/voice/voice-clause-buffer.ts +187 -0
- package/src/voice/voice-delegation.ts +85 -3
- package/src/voice/voice.test.ts +257 -2
- package/dist/chunk-3255TNY7.js +0 -1
- package/dist/voice-runtime-RHRX4F3T.js +0 -17
package/dist/approval-ui.d.cts
CHANGED
|
@@ -7125,6 +7125,13 @@ type VoiceDelegationRequest = {
|
|
|
7125
7125
|
role: string;
|
|
7126
7126
|
content: unknown;
|
|
7127
7127
|
}>;
|
|
7128
|
+
/**
|
|
7129
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7130
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7131
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7132
|
+
* says how much of it with `streamedChars`.
|
|
7133
|
+
*/
|
|
7134
|
+
stream?: (text: string) => void;
|
|
7128
7135
|
};
|
|
7129
7136
|
/**
|
|
7130
7137
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7155,6 +7162,12 @@ type VoiceDelegationResult = {
|
|
|
7155
7162
|
* @default true
|
|
7156
7163
|
*/
|
|
7157
7164
|
inChat?: boolean;
|
|
7165
|
+
/**
|
|
7166
|
+
* How many leading characters of `text` already went out through
|
|
7167
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7168
|
+
* Omitted or 0: nothing was streamed.
|
|
7169
|
+
*/
|
|
7170
|
+
streamedChars?: number;
|
|
7158
7171
|
/**
|
|
7159
7172
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7160
7173
|
* Resolves with the terminal result once the visitor decides (or the
|
package/dist/approval-ui.d.ts
CHANGED
|
@@ -7125,6 +7125,13 @@ type VoiceDelegationRequest = {
|
|
|
7125
7125
|
role: string;
|
|
7126
7126
|
content: unknown;
|
|
7127
7127
|
}>;
|
|
7128
|
+
/**
|
|
7129
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7130
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7131
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7132
|
+
* says how much of it with `streamedChars`.
|
|
7133
|
+
*/
|
|
7134
|
+
stream?: (text: string) => void;
|
|
7128
7135
|
};
|
|
7129
7136
|
/**
|
|
7130
7137
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7155,6 +7162,12 @@ type VoiceDelegationResult = {
|
|
|
7155
7162
|
* @default true
|
|
7156
7163
|
*/
|
|
7157
7164
|
inChat?: boolean;
|
|
7165
|
+
/**
|
|
7166
|
+
* How many leading characters of `text` already went out through
|
|
7167
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7168
|
+
* Omitted or 0: nothing was streamed.
|
|
7169
|
+
*/
|
|
7170
|
+
streamedChars?: number;
|
|
7158
7171
|
/**
|
|
7159
7172
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7160
7173
|
* Resolves with the terminal result once the visitor decides (or the
|
package/dist/artifacts-ui.d.cts
CHANGED
|
@@ -7127,6 +7127,13 @@ type VoiceDelegationRequest = {
|
|
|
7127
7127
|
role: string;
|
|
7128
7128
|
content: unknown;
|
|
7129
7129
|
}>;
|
|
7130
|
+
/**
|
|
7131
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7132
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7133
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7134
|
+
* says how much of it with `streamedChars`.
|
|
7135
|
+
*/
|
|
7136
|
+
stream?: (text: string) => void;
|
|
7130
7137
|
};
|
|
7131
7138
|
/**
|
|
7132
7139
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7157,6 +7164,12 @@ type VoiceDelegationResult = {
|
|
|
7157
7164
|
* @default true
|
|
7158
7165
|
*/
|
|
7159
7166
|
inChat?: boolean;
|
|
7167
|
+
/**
|
|
7168
|
+
* How many leading characters of `text` already went out through
|
|
7169
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7170
|
+
* Omitted or 0: nothing was streamed.
|
|
7171
|
+
*/
|
|
7172
|
+
streamedChars?: number;
|
|
7160
7173
|
/**
|
|
7161
7174
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7162
7175
|
* Resolves with the terminal result once the visitor decides (or the
|
package/dist/artifacts-ui.d.ts
CHANGED
|
@@ -7127,6 +7127,13 @@ type VoiceDelegationRequest = {
|
|
|
7127
7127
|
role: string;
|
|
7128
7128
|
content: unknown;
|
|
7129
7129
|
}>;
|
|
7130
|
+
/**
|
|
7131
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7132
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7133
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7134
|
+
* says how much of it with `streamedChars`.
|
|
7135
|
+
*/
|
|
7136
|
+
stream?: (text: string) => void;
|
|
7130
7137
|
};
|
|
7131
7138
|
/**
|
|
7132
7139
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7157,6 +7164,12 @@ type VoiceDelegationResult = {
|
|
|
7157
7164
|
* @default true
|
|
7158
7165
|
*/
|
|
7159
7166
|
inChat?: boolean;
|
|
7167
|
+
/**
|
|
7168
|
+
* How many leading characters of `text` already went out through
|
|
7169
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7170
|
+
* Omitted or 0: nothing was streamed.
|
|
7171
|
+
*/
|
|
7172
|
+
streamedChars?: number;
|
|
7160
7173
|
/**
|
|
7161
7174
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7162
7175
|
* Resolves with the terminal result once the visitor decides (or the
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t="4.28.0";var n=t;export{n as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
1
|
+
import{a as g}from"./chunk-AALCT54S.js";var H=32768,c=49152,p=t=>{let e=t??{},i=typeof e.targetId=="string"?e.targetId:null;return{id:typeof e.id=="string"?e.id:"",title:typeof e.title=="string"?e.title:"",targetId:i,preview:typeof e.preview=="string"?e.preview:null,messageCount:typeof e.messageCount=="number"?e.messageCount:0,createdAt:typeof e.createdAt=="string"?e.createdAt:"",updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}},v="The identity proof was not admitted; account history is unavailable",m="The identity proof was rejected",C="The request carried no visitor credential",w="The stored visitor belongs to a different signed-in user";function E(t,e,i){let r=new URLSearchParams;for(let[n,s]of Object.entries(i))s===void 0||s===""||r.set(n,String(s));let o=r.toString();return`${t.clientApiBase()}/v1/client/${e}${o?`?${o}`:""}`}function b(t,e){if(e)return e;let i=t.config.features?.history?.scope;return i||(t.config.getIdentityProof?"verified-user":"browser")}async function T(t,e,i){let r=t.config.getIdentityProof;if(!r)return i&&t.setHistoryIdentityStatus(t.browserOnlyStatus()),null;i&&t.setHistoryIdentityStatus({state:"verifying"});let o;try{o=await r()??null}catch{throw i&&t.setHistoryIdentityStatus({state:"identity_provider_failed"}),new t.HistoryClientError("identity_provider_failed","The identity proof provider failed")}if(o)return o;if(e.visitor?.endUserId!=null)throw i&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"proof_unavailable_after_binding"}),new t.HistoryClientError("authentication_required","This browser is bound to a signed-in user and needs a fresh identity proof");return i&&t.setHistoryIdentityStatus({state:"browser_only",reason:"proof_unavailable_before_binding"}),null}async function P(t,e,i,r){if(e.visitor?.endUserId!=null)return e;let o=await t.reinitWithProof(i);if(!(o.visitor?.identityStatus==="admitted"&&o.visitor?.endUserId!=null))throw r&&t.setHistoryIdentityStatus({state:"configuration_error",reason:"proof_not_admitted"}),new t.HistoryClientError("proof_not_admitted",v);return o}async function _(t,e){let i=await e.json().catch(()=>({}));return typeof i.error=="string"?i.error:typeof i.message=="string"?i.message:""}async function A(t,e,i,r){let o=e.toLowerCase();if(o.includes("invalid_identity_proof"))throw r&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"invalid_identity_proof"}),new t.HistoryClientError("invalid_identity_proof",m);if(o.includes("visitor token required"))throw new t.HistoryClientError("visitor_token_missing",C);if(o.includes("visitor_identity_mismatch")){if(!i)throw r&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"proof_unavailable_after_binding"}),new t.HistoryClientError("visitor_identity_mismatch",w);return t.reinitWithProof(i)}if(o.includes("expired")||o.includes("not found"))return t.clearClientSession(),t.initSession();throw new t.HistoryClientError("unauthorized",e||"History request was not authorized")}async function h(t,e,i){let r=await _(t,e);if(e.status===404)return new t.HistoryClientError("not_found","Conversation not found");if(e.status===429){let o=Number.parseInt(e.headers.get("Retry-After")??"",10);return new t.HistoryClientError("rate_limited","Too many history requests",{...Number.isFinite(o)?{retryAfterSeconds:o}:{}})}if(e.status===503&&r.includes("identity_proof_not_admitted"))return i&&t.setHistoryIdentityStatus({state:"configuration_error",reason:"proof_not_admitted"}),new t.HistoryClientError("proof_not_admitted",v);if(e.status===401){let o=r.toLowerCase();return o.includes("invalid_identity_proof")?(i&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"invalid_identity_proof"}),new t.HistoryClientError("invalid_identity_proof",m)):o.includes("visitor token required")?new t.HistoryClientError("visitor_token_missing",C):o.includes("visitor_identity_mismatch")?new t.HistoryClientError("visitor_identity_mismatch",w):new t.HistoryClientError("unauthorized",r||"History request was not authorized")}return new t.HistoryClientError("request_failed",r||`History request failed (${e.status})`)}function R(t,e,i,r){let o=e?.toLowerCase()??null;if(i){if(o==="admitted"){r&&t.setHistoryIdentityStatus({state:"verified"});return}throw r&&t.setHistoryIdentityStatus({state:"configuration_error",reason:"proof_not_admitted"}),o==="ignored"?new t.HistoryClientError("identity_contract_violation","Server reported an ignored identity proof on a success response"):new t.HistoryClientError("proof_not_admitted","The response did not acknowledge the identity proof this request sent")}if(o==="admitted")throw new t.HistoryClientError("identity_contract_violation","Server admitted an identity proof that was never sent");r&&t.setHistoryIdentityStatus(t.browserOnlyStatus())}async function y(t,e,i){f(t);let r=i.trackIdentity!==!1,o=await t.initSession(),n=null;b(t,i.scope)==="verified-user"&&(n=await T(t,o,r),n&&(o=await P(t,o,n,r)));let s=t.historyInternals.visitorStore,a=!1;for(;;){let u=s?.revision()??0,d=await t.readVisitorToken();if(!d&&!i.visitorTokenOptional)throw new t.HistoryClientError("visitor_token_missing","No visitor credential is stored for this browser");let l=await fetch(E(t,e,{...i.query,sessionId:o.sessionId}),{method:i.method,headers:{"X-Persona-Version":g,...d?{"X-Visitor-Token":d}:{},...n?{"X-Identity-Proof":n}:{},...i.body!==void 0?{"Content-Type":"application/json"}:{}},...i.body!==void 0?{body:JSON.stringify(i.body)}:{},...i.keepalive?{keepalive:!0}:{}});if(l.status===401&&!a){a=!0,o=await A(t,await _(t,l),n,r);continue}if(!l.ok)throw await h(t,l,r);let S=l.headers.get("X-History-Identity-Status"),I=await l.json().catch(()=>{});if(s&&s.revision()!==u)throw new t.HistoryClientError("credential_changed","The visitor credential changed while the request was in flight");return R(t,S,n!==null,r),I}}function f(t){if(!t.isClientTokenMode())throw new Error("Conversation history is only available in client token mode");if(!t.isHistoryCapable())throw new t.HistoryClientError("history_disabled","Visitor history is disabled for this surface")}async function O(t,e){let i=await y(t,"conversations",{method:"GET",query:{...e?.cursor?{cursor:e.cursor}:{},...e?.limit!==void 0?{limit:e.limit}:{},...e?.targetId?{targetId:e.targetId}:{}},...e?.scope?{scope:e.scope}:{}});return{data:(Array.isArray(i?.data)?i.data:[]).map(p),nextCursor:typeof i?.nextCursor=="string"?i.nextCursor:null}}async function x(t,e,i){let r=await y(t,`conversations/${encodeURIComponent(e)}`,{method:"GET",query:{...i?.messageCursor?{messageCursor:i.messageCursor}:{}},...i?.scope?{scope:i.scope}:{}});return{summary:p(r),messages:Array.isArray(r?.messages)?r.messages:[],nextMessageCursor:typeof r?.nextMessageCursor=="string"?r.nextMessageCursor:null,conversationRevision:typeof r?.conversationRevision=="string"?r.conversationRevision:null}}async function q(t,e,i){f(t);let r=0;for(let u of i){let d=u.displayContent.length;if(d>H)throw new t.HistoryClientError("payload_too_large",`displayContent exceeds the ${H} character limit`);r+=d}if(r>c)throw new t.HistoryClientError("payload_too_large",`Display projection batch exceeds the ${c} character limit`);await t.initSession();let o=t.historyInternals.visitorStore,n=o?.revision()??0,s=await y(t,`conversations/${encodeURIComponent(e)}/display-projections`,{method:"PATCH",body:{messages:i},scope:"browser",keepalive:r<=c,trackIdentity:!1}),a=typeof s?.conversationRevision=="string"?s.conversationRevision:null;return a&&t.clientSession?.conversationId===e&&(o?.revision()??0)===n&&t.historyInternals.setStoredConversationRevision?.(a),{conversationRevision:a}}async function D(t,e,i){let r=await y(t,`conversations/${encodeURIComponent(e)}`,{method:"DELETE",...i?.scope?{scope:i.scope}:{}});return{deleted:typeof r?.deleted=="number"?r.deleted:0}}async function M(t,e){let i=await y(t,"conversations",{method:"DELETE",query:{...e?.targetId!==void 0?{targetId:e.targetId}:{}},...e?.scope?{scope:e.scope}:{}});return{deleted:typeof i?.deleted=="number"?i.deleted:0}}async function N(t){f(t),t.setHistoryIdentityStatus({state:"resetting"});try{await y(t,"visitor/reset",{method:"POST",scope:"browser",visitorTokenOptional:!0})}finally{await t.historyInternals.visitorStore?.clear(),t.setHistoryIdentityStatus(t.derivedBrowserOnly())}return{reset:!0}}export{M as deleteAllConversations,D as deleteConversation,q as finalizeDisplayProjections,x as getConversation,h as historyErrorFor,O as listConversations,_ as readErrorCode,A as recoverFromUnauthorized,N as resetVisitor};
|
package/dist/client-history.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var y="4.
|
|
1
|
+
var y="4.28.0";var f=y;var g=32768,p=49152,b=t=>{let e=t??{},i=typeof e.targetId=="string"?e.targetId:null;return{id:typeof e.id=="string"?e.id:"",title:typeof e.title=="string"?e.title:"",targetId:i,preview:typeof e.preview=="string"?e.preview:null,messageCount:typeof e.messageCount=="number"?e.messageCount:0,createdAt:typeof e.createdAt=="string"?e.createdAt:"",updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}},v="The identity proof was not admitted; account history is unavailable",w="The identity proof was rejected",H="The request carried no visitor credential",C="The stored visitor belongs to a different signed-in user";function j(t,e,i){let s=new URLSearchParams;for(let[r,o]of Object.entries(i))o===void 0||o===""||s.set(r,String(o));let n=s.toString();return`${t.clientApiBase()}/v1/client/${e}${n?`?${n}`:""}`}function I(t,e){if(e)return e;let i=t.config.features?.history?.scope;return i||(t.config.getIdentityProof?"verified-user":"browser")}async function E(t,e,i){let s=t.config.getIdentityProof;if(!s)return i&&t.setHistoryIdentityStatus(t.browserOnlyStatus()),null;i&&t.setHistoryIdentityStatus({state:"verifying"});let n;try{n=await s()??null}catch{throw i&&t.setHistoryIdentityStatus({state:"identity_provider_failed"}),new t.HistoryClientError("identity_provider_failed","The identity proof provider failed")}if(n)return n;if(e.visitor?.endUserId!=null)throw i&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"proof_unavailable_after_binding"}),new t.HistoryClientError("authentication_required","This browser is bound to a signed-in user and needs a fresh identity proof");return i&&t.setHistoryIdentityStatus({state:"browser_only",reason:"proof_unavailable_before_binding"}),null}async function k(t,e,i,s){if(e.visitor?.endUserId!=null)return e;let n=await t.reinitWithProof(i);if(!(n.visitor?.identityStatus==="admitted"&&n.visitor?.endUserId!=null))throw s&&t.setHistoryIdentityStatus({state:"configuration_error",reason:"proof_not_admitted"}),new t.HistoryClientError("proof_not_admitted",v);return n}async function h(t,e){let i=await e.json().catch(()=>({}));return typeof i.error=="string"?i.error:typeof i.message=="string"?i.message:""}async function T(t,e,i,s){let n=e.toLowerCase();if(n.includes("invalid_identity_proof"))throw s&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"invalid_identity_proof"}),new t.HistoryClientError("invalid_identity_proof",w);if(n.includes("visitor token required"))throw new t.HistoryClientError("visitor_token_missing",H);if(n.includes("visitor_identity_mismatch")){if(!i)throw s&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"proof_unavailable_after_binding"}),new t.HistoryClientError("visitor_identity_mismatch",C);return t.reinitWithProof(i)}if(n.includes("expired")||n.includes("not found"))return t.clearClientSession(),t.initSession();throw new t.HistoryClientError("unauthorized",e||"History request was not authorized")}async function q(t,e,i){let s=await h(t,e);if(e.status===404)return new t.HistoryClientError("not_found","Conversation not found");if(e.status===429){let n=Number.parseInt(e.headers.get("Retry-After")??"",10);return new t.HistoryClientError("rate_limited","Too many history requests",{...Number.isFinite(n)?{retryAfterSeconds:n}:{}})}if(e.status===503&&s.includes("identity_proof_not_admitted"))return i&&t.setHistoryIdentityStatus({state:"configuration_error",reason:"proof_not_admitted"}),new t.HistoryClientError("proof_not_admitted",v);if(e.status===401){let n=s.toLowerCase();return n.includes("invalid_identity_proof")?(i&&t.setHistoryIdentityStatus({state:"authentication_required",reason:"invalid_identity_proof"}),new t.HistoryClientError("invalid_identity_proof",w)):n.includes("visitor token required")?new t.HistoryClientError("visitor_token_missing",H):n.includes("visitor_identity_mismatch")?new t.HistoryClientError("visitor_identity_mismatch",C):new t.HistoryClientError("unauthorized",s||"History request was not authorized")}return new t.HistoryClientError("request_failed",s||`History request failed (${e.status})`)}function P(t,e,i,s){let n=e?.toLowerCase()??null;if(i){if(n==="admitted"){s&&t.setHistoryIdentityStatus({state:"verified"});return}throw s&&t.setHistoryIdentityStatus({state:"configuration_error",reason:"proof_not_admitted"}),n==="ignored"?new t.HistoryClientError("identity_contract_violation","Server reported an ignored identity proof on a success response"):new t.HistoryClientError("proof_not_admitted","The response did not acknowledge the identity proof this request sent")}if(n==="admitted")throw new t.HistoryClientError("identity_contract_violation","Server admitted an identity proof that was never sent");s&&t.setHistoryIdentityStatus(t.browserOnlyStatus())}async function l(t,e,i){m(t);let s=i.trackIdentity!==!1,n=await t.initSession(),r=null;I(t,i.scope)==="verified-user"&&(r=await E(t,n,s),r&&(n=await k(t,n,r,s)));let o=t.historyInternals.visitorStore,a=!1;for(;;){let c=o?.revision()??0,d=await t.readVisitorToken();if(!d&&!i.visitorTokenOptional)throw new t.HistoryClientError("visitor_token_missing","No visitor credential is stored for this browser");let u=await fetch(j(t,e,{...i.query,sessionId:n.sessionId}),{method:i.method,headers:{"X-Persona-Version":f,...d?{"X-Visitor-Token":d}:{},...r?{"X-Identity-Proof":r}:{},...i.body!==void 0?{"Content-Type":"application/json"}:{}},...i.body!==void 0?{body:JSON.stringify(i.body)}:{},...i.keepalive?{keepalive:!0}:{}});if(u.status===401&&!a){a=!0,n=await T(t,await h(t,u),r,s);continue}if(!u.ok)throw await q(t,u,s);let x=u.headers.get("X-History-Identity-Status"),_=await u.json().catch(()=>{});if(o&&o.revision()!==c)throw new t.HistoryClientError("credential_changed","The visitor credential changed while the request was in flight");return P(t,x,r!==null,s),_}}function m(t){if(!t.isClientTokenMode())throw new Error("Conversation history is only available in client token mode");if(!t.isHistoryCapable())throw new t.HistoryClientError("history_disabled","Visitor history is disabled for this surface")}async function z(t,e){let i=await l(t,"conversations",{method:"GET",query:{...e?.cursor?{cursor:e.cursor}:{},...e?.limit!==void 0?{limit:e.limit}:{},...e?.targetId?{targetId:e.targetId}:{}},...e?.scope?{scope:e.scope}:{}});return{data:(Array.isArray(i?.data)?i.data:[]).map(b),nextCursor:typeof i?.nextCursor=="string"?i.nextCursor:null}}async function M(t,e,i){let s=await l(t,`conversations/${encodeURIComponent(e)}`,{method:"GET",query:{...i?.messageCursor?{messageCursor:i.messageCursor}:{}},...i?.scope?{scope:i.scope}:{}});return{summary:b(s),messages:Array.isArray(s?.messages)?s.messages:[],nextMessageCursor:typeof s?.nextMessageCursor=="string"?s.nextMessageCursor:null,conversationRevision:typeof s?.conversationRevision=="string"?s.conversationRevision:null}}async function N(t,e,i){m(t);let s=0;for(let c of i){let d=c.displayContent.length;if(d>g)throw new t.HistoryClientError("payload_too_large",`displayContent exceeds the ${g} character limit`);s+=d}if(s>p)throw new t.HistoryClientError("payload_too_large",`Display projection batch exceeds the ${p} character limit`);await t.initSession();let n=t.historyInternals.visitorStore,r=n?.revision()??0,o=await l(t,`conversations/${encodeURIComponent(e)}/display-projections`,{method:"PATCH",body:{messages:i},scope:"browser",keepalive:s<=p,trackIdentity:!1}),a=typeof o?.conversationRevision=="string"?o.conversationRevision:null;return a&&t.clientSession?.conversationId===e&&(n?.revision()??0)===r&&t.historyInternals.setStoredConversationRevision?.(a),{conversationRevision:a}}async function L(t,e,i){let s=await l(t,`conversations/${encodeURIComponent(e)}`,{method:"DELETE",...i?.scope?{scope:i.scope}:{}});return{deleted:typeof s?.deleted=="number"?s.deleted:0}}async function U(t,e){let i=await l(t,"conversations",{method:"DELETE",query:{...e?.targetId!==void 0?{targetId:e.targetId}:{}},...e?.scope?{scope:e.scope}:{}});return{deleted:typeof i?.deleted=="number"?i.deleted:0}}async function $(t){m(t),t.setHistoryIdentityStatus({state:"resetting"});try{await l(t,"visitor/reset",{method:"POST",scope:"browser",visitorTokenOptional:!0})}finally{await t.historyInternals.visitorStore?.clear(),t.setHistoryIdentityStatus(t.derivedBrowserOnly())}return{reset:!0}}export{U as deleteAllConversations,L as deleteConversation,N as finalizeDisplayProjections,M as getConversation,q as historyErrorFor,z as listConversations,h as readErrorCode,T as recoverFromUnauthorized,$ as resetVisitor};
|
package/dist/codegen.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var $=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var W=(e,i)=>{for(var r in i)$(e,r,{get:i[r],enumerable:!0})},H=(e,i,r,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of M(i))!R.call(e,a)&&a!==r&&$(e,a,{get:()=>i[a],enumerable:!(s=T(i,a))||s.enumerable});return e};var N=e=>H($({},"__esModule",{value:!0}),e);var X={};W(X,{generateCodeSnippet:()=>I});module.exports=N(X);var j="4.
|
|
1
|
+
"use strict";var $=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var W=(e,i)=>{for(var r in i)$(e,r,{get:i[r],enumerable:!0})},H=(e,i,r,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of M(i))!R.call(e,a)&&a!==r&&$(e,a,{get:()=>i[a],enumerable:!(s=T(i,a))||s.enumerable});return e};var N=e=>H($({},"__esModule",{value:!0}),e);var X={};W(X,{generateCodeSnippet:()=>I});module.exports=N(X);var j="4.28.0";var A=j;function x(e){return e?.cdnBase?.trim().replace(/\/+$/,"").replace(/[\\'"<>`]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)||`https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${A}/dist`}function u(e){if(e!==void 0)return typeof e=="string"?e:Array.isArray(e)?`[${e.map(i=>i.toString()).join(", ")}]`:e.toString()}function q(e){if(e)return{getHeaders:u(e.getHeaders),onFeedback:u(e.onFeedback),onCopy:u(e.onCopy),requestMiddleware:u(e.requestMiddleware),actionHandlers:u(e.actionHandlers),actionParsers:u(e.actionParsers),postprocessMessage:u(e.postprocessMessage),contextProviders:u(e.contextProviders),streamParser:u(e.streamParser)}}var O=`({ text, message }: any) => {
|
|
2
2
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
3
3
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
4
4
|
let cleanJson = jsonSource
|
package/dist/codegen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var S="4.
|
|
1
|
+
var S="4.28.0";var j=S;function $(e){return e?.cdnBase?.trim().replace(/\/+$/,"").replace(/[\\'"<>`]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)||`https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${j}/dist`}function u(e){if(e!==void 0)return typeof e=="string"?e:Array.isArray(e)?`[${e.map(i=>i.toString()).join(", ")}]`:e.toString()}function _(e){if(e)return{getHeaders:u(e.getHeaders),onFeedback:u(e.onFeedback),onCopy:u(e.onCopy),requestMiddleware:u(e.requestMiddleware),actionHandlers:u(e.actionHandlers),actionParsers:u(e.actionParsers),postprocessMessage:u(e.postprocessMessage),contextProviders:u(e.contextProviders),streamParser:u(e.streamParser)}}var A=`({ text, message }: any) => {
|
|
2
2
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
3
3
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
4
4
|
let cleanJson = jsonSource
|
|
@@ -7125,6 +7125,13 @@ type VoiceDelegationRequest = {
|
|
|
7125
7125
|
role: string;
|
|
7126
7126
|
content: unknown;
|
|
7127
7127
|
}>;
|
|
7128
|
+
/**
|
|
7129
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7130
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7131
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7132
|
+
* says how much of it with `streamedChars`.
|
|
7133
|
+
*/
|
|
7134
|
+
stream?: (text: string) => void;
|
|
7128
7135
|
};
|
|
7129
7136
|
/**
|
|
7130
7137
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7155,6 +7162,12 @@ type VoiceDelegationResult = {
|
|
|
7155
7162
|
* @default true
|
|
7156
7163
|
*/
|
|
7157
7164
|
inChat?: boolean;
|
|
7165
|
+
/**
|
|
7166
|
+
* How many leading characters of `text` already went out through
|
|
7167
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7168
|
+
* Omitted or 0: nothing was streamed.
|
|
7169
|
+
*/
|
|
7170
|
+
streamedChars?: number;
|
|
7158
7171
|
/**
|
|
7159
7172
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7160
7173
|
* Resolves with the terminal result once the visitor decides (or the
|
|
@@ -7125,6 +7125,13 @@ type VoiceDelegationRequest = {
|
|
|
7125
7125
|
role: string;
|
|
7126
7126
|
content: unknown;
|
|
7127
7127
|
}>;
|
|
7128
|
+
/**
|
|
7129
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7130
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7131
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7132
|
+
* says how much of it with `streamedChars`.
|
|
7133
|
+
*/
|
|
7134
|
+
stream?: (text: string) => void;
|
|
7128
7135
|
};
|
|
7129
7136
|
/**
|
|
7130
7137
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7155,6 +7162,12 @@ type VoiceDelegationResult = {
|
|
|
7155
7162
|
* @default true
|
|
7156
7163
|
*/
|
|
7157
7164
|
inChat?: boolean;
|
|
7165
|
+
/**
|
|
7166
|
+
* How many leading characters of `text` already went out through
|
|
7167
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7168
|
+
* Omitted or 0: nothing was streamed.
|
|
7169
|
+
*/
|
|
7170
|
+
streamedChars?: number;
|
|
7158
7171
|
/**
|
|
7159
7172
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7160
7173
|
* Resolves with the terminal result once the visitor decides (or the
|
|
@@ -7125,6 +7125,13 @@ type VoiceDelegationRequest = {
|
|
|
7125
7125
|
role: string;
|
|
7126
7126
|
content: unknown;
|
|
7127
7127
|
}>;
|
|
7128
|
+
/**
|
|
7129
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7130
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7131
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7132
|
+
* says how much of it with `streamedChars`.
|
|
7133
|
+
*/
|
|
7134
|
+
stream?: (text: string) => void;
|
|
7128
7135
|
};
|
|
7129
7136
|
/**
|
|
7130
7137
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7155,6 +7162,12 @@ type VoiceDelegationResult = {
|
|
|
7155
7162
|
* @default true
|
|
7156
7163
|
*/
|
|
7157
7164
|
inChat?: boolean;
|
|
7165
|
+
/**
|
|
7166
|
+
* How many leading characters of `text` already went out through
|
|
7167
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7168
|
+
* Omitted or 0: nothing was streamed.
|
|
7169
|
+
*/
|
|
7170
|
+
streamedChars?: number;
|
|
7158
7171
|
/**
|
|
7159
7172
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7160
7173
|
* Resolves with the terminal result once the visitor decides (or the
|
|
@@ -7125,6 +7125,13 @@ type VoiceDelegationRequest = {
|
|
|
7125
7125
|
role: string;
|
|
7126
7126
|
content: unknown;
|
|
7127
7127
|
}>;
|
|
7128
|
+
/**
|
|
7129
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7130
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7131
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7132
|
+
* says how much of it with `streamedChars`.
|
|
7133
|
+
*/
|
|
7134
|
+
stream?: (text: string) => void;
|
|
7128
7135
|
};
|
|
7129
7136
|
/**
|
|
7130
7137
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7155,6 +7162,12 @@ type VoiceDelegationResult = {
|
|
|
7155
7162
|
* @default true
|
|
7156
7163
|
*/
|
|
7157
7164
|
inChat?: boolean;
|
|
7165
|
+
/**
|
|
7166
|
+
* How many leading characters of `text` already went out through
|
|
7167
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7168
|
+
* Omitted or 0: nothing was streamed.
|
|
7169
|
+
*/
|
|
7170
|
+
streamedChars?: number;
|
|
7158
7171
|
/**
|
|
7159
7172
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7160
7173
|
* Resolves with the terminal result once the visitor decides (or the
|
package/dist/forms-ui.d.cts
CHANGED
|
@@ -7294,6 +7294,13 @@ type VoiceDelegationRequest = {
|
|
|
7294
7294
|
role: string;
|
|
7295
7295
|
content: unknown;
|
|
7296
7296
|
}>;
|
|
7297
|
+
/**
|
|
7298
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7299
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7300
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7301
|
+
* says how much of it with `streamedChars`.
|
|
7302
|
+
*/
|
|
7303
|
+
stream?: (text: string) => void;
|
|
7297
7304
|
};
|
|
7298
7305
|
/**
|
|
7299
7306
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7324,6 +7331,12 @@ type VoiceDelegationResult = {
|
|
|
7324
7331
|
* @default true
|
|
7325
7332
|
*/
|
|
7326
7333
|
inChat?: boolean;
|
|
7334
|
+
/**
|
|
7335
|
+
* How many leading characters of `text` already went out through
|
|
7336
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7337
|
+
* Omitted or 0: nothing was streamed.
|
|
7338
|
+
*/
|
|
7339
|
+
streamedChars?: number;
|
|
7327
7340
|
/**
|
|
7328
7341
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7329
7342
|
* Resolves with the terminal result once the visitor decides (or the
|
|
@@ -10507,6 +10520,12 @@ type DispatchOptions = {
|
|
|
10507
10520
|
* `submitMode: "interrupt"` so the server cancels the prior run.
|
|
10508
10521
|
*/
|
|
10509
10522
|
interrupt?: boolean;
|
|
10523
|
+
/**
|
|
10524
|
+
* Client-token only: a voice model reads the reply aloud (a delegated voice
|
|
10525
|
+
* turn). Sends `voice: { spoken: true }` so the server asks for a speakable
|
|
10526
|
+
* answer.
|
|
10527
|
+
*/
|
|
10528
|
+
voiceSpoken?: boolean;
|
|
10510
10529
|
};
|
|
10511
10530
|
type SSEHandler = (event: AgentWidgetEvent) => void;
|
|
10512
10531
|
type SSEEventCallback = (eventType: string, payload: unknown) => void;
|
package/dist/forms-ui.d.ts
CHANGED
|
@@ -7294,6 +7294,13 @@ type VoiceDelegationRequest = {
|
|
|
7294
7294
|
role: string;
|
|
7295
7295
|
content: unknown;
|
|
7296
7296
|
}>;
|
|
7297
|
+
/**
|
|
7298
|
+
* Set when the server streams delegated answers (`delegation_stream`): called
|
|
7299
|
+
* with each speakable piece of the turn's answer, in order, while it renders.
|
|
7300
|
+
* The pieces, concatenated, are a prefix of the result's `text`; the result
|
|
7301
|
+
* says how much of it with `streamedChars`.
|
|
7302
|
+
*/
|
|
7303
|
+
stream?: (text: string) => void;
|
|
7297
7304
|
};
|
|
7298
7305
|
/**
|
|
7299
7306
|
* How a delegated turn ended, or that it waits on an approval (contract
|
|
@@ -7324,6 +7331,12 @@ type VoiceDelegationResult = {
|
|
|
7324
7331
|
* @default true
|
|
7325
7332
|
*/
|
|
7326
7333
|
inChat?: boolean;
|
|
7334
|
+
/**
|
|
7335
|
+
* How many leading characters of `text` already went out through
|
|
7336
|
+
* `request.stream` (the rest, such as an approval script, is unstreamed).
|
|
7337
|
+
* Omitted or 0: nothing was streamed.
|
|
7338
|
+
*/
|
|
7339
|
+
streamedChars?: number;
|
|
7327
7340
|
/**
|
|
7328
7341
|
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7329
7342
|
* Resolves with the terminal result once the visitor decides (or the
|
|
@@ -10507,6 +10520,12 @@ type DispatchOptions = {
|
|
|
10507
10520
|
* `submitMode: "interrupt"` so the server cancels the prior run.
|
|
10508
10521
|
*/
|
|
10509
10522
|
interrupt?: boolean;
|
|
10523
|
+
/**
|
|
10524
|
+
* Client-token only: a voice model reads the reply aloud (a delegated voice
|
|
10525
|
+
* turn). Sends `voice: { spoken: true }` so the server asks for a speakable
|
|
10526
|
+
* answer.
|
|
10527
|
+
*/
|
|
10528
|
+
voiceSpoken?: boolean;
|
|
10510
10529
|
};
|
|
10511
10530
|
type SSEHandler = (event: AgentWidgetEvent) => void;
|
|
10512
10531
|
type SSEEventCallback = (eventType: string, payload: unknown) => void;
|