@ziggy-ai/client-sdk 1.12.0 → 1.13.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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +252 -15
- package/dist/screenshot-uploader.d.ts +35 -4
- package/dist/screenshot.d.ts +17 -0
- package/dist/session.d.ts +3 -1
- package/dist/storage.d.ts +10 -1
- package/dist/types.d.ts +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ziggy-ai/client-sdk changelog
|
|
2
2
|
|
|
3
|
+
## 1.13.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `grounding` on the `metadata` stream event (`MetadataEvent.grounding`), plus `GuideGroundingFlag` and `GuideGroundingNotice` types (ZIG-213 slice 3d, #528): present on replies from the owner's guide that Jev's post-reply grounding check flagged on complete evidence (`{ outcome: 'flagged', flags }`). Optional; absent on older servers, non-guide turns, and supported or unknown verdicts.
|
|
7
|
+
- Fixed visitor AI disclosure config on sessions (ZIG-383, #519): `SessionAiDisclosure` type, optional `SessionConfig.aiDisclosure`, and `SessionManager.aiDisclosure` getter (`client.sessions.aiDisclosure`) reflecting the app's Settings switch.
|
|
8
|
+
- Direct image upload and pending-upload cleanup on `StorageClient` (ZIG-383, #516): `client.storage.uploadDirectImage()` (`POST /v1/storage/upload/direct`), `client.storage.deletePending()` (`DELETE /v1/storage/pending/:id`), and types `DirectImageMimeType`, `DirectImageUploadRequest`, and `DirectImageUploadResponse`.
|
|
9
|
+
- Image upload and screenshot helpers exported from the package root (ZIG-383, #516): `uploadImageBlob`, `ALLOWED_CHAT_IMAGE_TYPES`, `MAX_CHAT_IMAGE_BYTES`, `ImageUploadOptions`, `ImageUploadResult`, `sanitizeCssForHtml2Canvas`, and `sanitizeClonedDocumentForHtml2Canvas`.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- `captureAndUpload` and `uploadImageBlob` now prefer the server-mediated direct upload endpoint (`/storage/upload/direct`) to avoid browser-to-R2 CORS failures, falling back to the presigned PUT flow on older servers that return 404 (ZIG-383, #516).
|
|
13
|
+
- `ScreenshotCapture` sanitizes modern CSS color functions (`color-mix`, `oklch`, `oklab`, `lch`, `lab`) in the cloned document before rendering with `html2canvas` (ZIG-383, #516).
|
|
14
|
+
|
|
3
15
|
## 1.12.0
|
|
4
16
|
|
|
5
17
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export declare class ZiggyClient {
|
|
|
134
134
|
*/
|
|
135
135
|
disconnect(): Promise<void>;
|
|
136
136
|
}
|
|
137
|
-
export type { GuideOpening, RecommendationDiscussionReference, BrowserReviewDiscussionReference, ZiggyClientConfig, CreateSessionRequest, SessionResponse, SessionExperiences, ExperienceKey, ExperienceWalkthroughStep, SessionConfig, AgentSummary, CatalogAgent, AgentListResponse, CatalogTool, AgentDetailResponse, PageContext, ProcessContext, ContentContext, UserContext, ErrorEntry, SupportContext, ContextPushRequest, ContextPushResponse, ContextEvent, ChatRequest, ChatResponse, ChatAttachment, ActionRequest, ActionResponse, Confidence, Source, ToolUsage, StreamEvent, StreamStartEvent, AgentStartEvent, AgentSwitchEvent, ToolStartEvent, ToolProgressEvent, ToolResultEvent, ContentDeltaEvent, ContentDoneEvent, MetadataEvent, ReplyFeeling, StreamEndEvent, StreamErrorEvent, ToolErrorEvent, ReturnHandoffEvent, ActivityEvent, QuestStatusEvent, QuestStepUpdateEvent, QuestCompleteEvent, WalkthroughStep, UIHighlightEvent, UIScrollEvent, UIClickEvent, UITypeEvent, UIWalkthroughEvent, UINavigateEvent, UIScreenshotAnalysisEvent, UISurfaceEvent, HostActionEvent, UICardEvent, GuideCard, GuideRecordCard, GuideStepCard, ChatSurfaceMode, HostActionDefinition, RegisterHostActionsRequest, RegisterHostActionsResponse, ListHostActionsResponse, ScreenshotAnnotation, WalkthroughResult, BrandConfig, SpokenVoiceConfig, SpokenVoiceRecommendation, SpokenVoiceRecommendationsResponse, ProactiveTrigger, QuickAction, ToolInvokeRequest, ToolInvokeResponse, ReactionRequest, FeedbackRequest, Quest, QuestStep, TriggerCondition, TriggerRegistration, RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, QuickActionSetConditions, QuickActionSet, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterBrandRequest, OwnerProfileFields, SetProfileResponse, AddDomainConceptRequest, AddDomainConceptResponse, GetBrandResponse, PublicBrandResponse, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, AppCallbackResponse, Ticket, CreateTicketRequest, CreateTicketResponse, UpdateTicketRequest, TicketFilters, TicketResponse, CreateTicketResponseRequest, TicketAnalysis, TimelineEvent, TicketTimeline, TicketConversation, TriageTicket, TicketPattern, MediaAttachment, RequestUploadRequest, RequestUploadResponse, ConfirmUploadResponse, UploadMediaRequest, UploadMediaResponse, VoiceTokenResponse, VoiceTtsResult, VoiceTtsAudio, VoiceTtsFallback, LiveConversationState, LiveSessionCreateRequest, LiveSessionCreateResponse, LiveSessionCloseResponse, LiveInterruptResponse, LiveSessionStatus, LiveStateEvent, LiveTranscriptEvent, LiveTurnEvent, LiveCommentaryEvent, LiveUsageEvent, LiveClosedEvent, DiscoveryJobStatus, PageType, DiscoveryJob, DiscoveredPage, AnalysisType, AnalysisIssue, AnalysisResult, SpecialistAnalysis, AppPersona, TestScenario, TestStrategy, ChangeEvent, ScreenshotConfig, ScreencastConfig, ScreencastFrame, TestRunStatus, TestResultStatus, TestRun, TestResult, StepResult, TestInsight, TriggerDiscoveryRequest, TriggerAnalysisRequest, GeneratePersonasRequest, GenerateTestScenariosRequest, GenerateTestStrategyRequest, DetectChangesRequest, CaptureScreenshotsRequest, StartTestRunRequest, AnalyzeTestRunRequest, ConversationPartnerState, ConversationPartnerCommand, ConversationMessage, ConversationSummary, ConversationDetail, ConversationMessagesPage, AppStatus, VerifyResponse, AppAvailabilityResponse, AppPlanState, ChatAvailability, ChatFallback, YoloConfig, SetYoloConfigRequest, DeploymentSettings, UpdateDeploymentSettingsRequest, TriageConfig, SetTriageConfigRequest, ToolConfig, SetToolConfigRequest, ObservationCycle, ObservationCycleDetail, Observation, HealthScore, HealthScoreResponse, HealthPart, HealthPartView, AppHealthView, ScoresResponse, SignalsResponse, SelfTestCycle, SelfTestCycleDetail, SuiteResult, SelfTestResult, TestingBrainReport, SelfTestTrend, TriggerResponse, EngineeringJob, EngineeringProposal, ProposalDeployment, TriggerEngineeringRequest, UpdateProposalRequest, TriggerDeploymentRequest, UpdateDeploymentRequest, AuditTriggerResponse, ObserverConfigResponse, DesignTokens, ComponentSpec, DesignSystemResponse, DesignTokensResponse, ComponentSpecResponse, Notification, NotificationType, NotificationSeverity, NotificationStatus, NotificationsResponse, NotificationCountResponse, CodeChangeEvent, SignificanceLevel, StreamCollectingEvent, StreamQueuedEvent, StreamSteeringEvent, StreamInterruptedEvent, CoalesceResponse, TurnMetrics, TurnStartedEvent, TurnMetricsEvent, TurnCompletedEvent, SpanStartedEvent, SpanCompletedEvent, SpanErrorEvent, UICaptureScreenshotEvent, CrewPlanEvent, AgentDispatchedEvent, AgentProgressEvent, AgentFindingEvent, AgentCompleteEvent, CrewSynthesisEvent, CrewCompleteEvent, CrewAwaitingApprovalEvent, CrewApprovedEvent, CrewCancelledEvent, CrewStoppedEvent, AgentHandoffEvent, HookName, HookStyle, WebhookHook, CreateHookRequest, UpdateHookRequest, ListHooksResponse, InboundSignalStatus, InboundSignalOutcome, InboundSignalEnvironment, InboundSignalPriority, InboundSignalRelease, InboundSignal, CreateInboundSignalRequest, CreateInboundSignalResponse, InboundSignalFilters, InboundSignalDetailResponse, SignalAutomationMode, AutomationPolicy, SetAutomationPolicyRequest, SignalWebhookEventType, SignalWebhookSubscription, CreateSignalWebhookSubscriptionRequest, UpdateSignalWebhookSubscriptionRequest, CreateSignalWebhookSubscriptionResponse, SignalWebhookDeliveryStatus, SignalWebhookDelivery, RoomParticipantKind, RoomParticipantRole, RoomParticipantMode, RoomPresenceState, Participant, RoomEventType, RoomEvent, RoutingSignal, ReclaimSignal, RoutingEvent, RoomParticipantsResponse, InviteHumanRequest, InviteHumanResponse, } from './types.js';
|
|
137
|
+
export type { GuideOpening, RecommendationDiscussionReference, BrowserReviewDiscussionReference, ZiggyClientConfig, CreateSessionRequest, SessionResponse, SessionExperiences, ExperienceKey, ExperienceWalkthroughStep, SessionAiDisclosure, SessionConfig, AgentSummary, CatalogAgent, AgentListResponse, CatalogTool, AgentDetailResponse, PageContext, ProcessContext, ContentContext, UserContext, ErrorEntry, SupportContext, ContextPushRequest, ContextPushResponse, ContextEvent, ChatRequest, ChatResponse, ChatAttachment, ActionRequest, ActionResponse, Confidence, Source, ToolUsage, StreamEvent, StreamStartEvent, AgentStartEvent, AgentSwitchEvent, ToolStartEvent, ToolProgressEvent, ToolResultEvent, ContentDeltaEvent, ContentDoneEvent, MetadataEvent, ReplyFeeling, GuideGroundingFlag, GuideGroundingNotice, StreamEndEvent, StreamErrorEvent, ToolErrorEvent, ReturnHandoffEvent, ActivityEvent, QuestStatusEvent, QuestStepUpdateEvent, QuestCompleteEvent, WalkthroughStep, UIHighlightEvent, UIScrollEvent, UIClickEvent, UITypeEvent, UIWalkthroughEvent, UINavigateEvent, UIScreenshotAnalysisEvent, UISurfaceEvent, HostActionEvent, UICardEvent, GuideCard, GuideRecordCard, GuideStepCard, ChatSurfaceMode, HostActionDefinition, RegisterHostActionsRequest, RegisterHostActionsResponse, ListHostActionsResponse, ScreenshotAnnotation, WalkthroughResult, BrandConfig, SpokenVoiceConfig, SpokenVoiceRecommendation, SpokenVoiceRecommendationsResponse, ProactiveTrigger, QuickAction, ToolInvokeRequest, ToolInvokeResponse, ReactionRequest, FeedbackRequest, Quest, QuestStep, TriggerCondition, TriggerRegistration, RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, QuickActionSetConditions, QuickActionSet, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterBrandRequest, OwnerProfileFields, SetProfileResponse, AddDomainConceptRequest, AddDomainConceptResponse, GetBrandResponse, PublicBrandResponse, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, AppCallbackResponse, Ticket, CreateTicketRequest, CreateTicketResponse, UpdateTicketRequest, TicketFilters, TicketResponse, CreateTicketResponseRequest, TicketAnalysis, TimelineEvent, TicketTimeline, TicketConversation, TriageTicket, TicketPattern, MediaAttachment, RequestUploadRequest, RequestUploadResponse, DirectImageMimeType, DirectImageUploadRequest, DirectImageUploadResponse, ConfirmUploadResponse, UploadMediaRequest, UploadMediaResponse, VoiceTokenResponse, VoiceTtsResult, VoiceTtsAudio, VoiceTtsFallback, LiveConversationState, LiveSessionCreateRequest, LiveSessionCreateResponse, LiveSessionCloseResponse, LiveInterruptResponse, LiveSessionStatus, LiveStateEvent, LiveTranscriptEvent, LiveTurnEvent, LiveCommentaryEvent, LiveUsageEvent, LiveClosedEvent, DiscoveryJobStatus, PageType, DiscoveryJob, DiscoveredPage, AnalysisType, AnalysisIssue, AnalysisResult, SpecialistAnalysis, AppPersona, TestScenario, TestStrategy, ChangeEvent, ScreenshotConfig, ScreencastConfig, ScreencastFrame, TestRunStatus, TestResultStatus, TestRun, TestResult, StepResult, TestInsight, TriggerDiscoveryRequest, TriggerAnalysisRequest, GeneratePersonasRequest, GenerateTestScenariosRequest, GenerateTestStrategyRequest, DetectChangesRequest, CaptureScreenshotsRequest, StartTestRunRequest, AnalyzeTestRunRequest, ConversationPartnerState, ConversationPartnerCommand, ConversationMessage, ConversationSummary, ConversationDetail, ConversationMessagesPage, AppStatus, VerifyResponse, AppAvailabilityResponse, AppPlanState, ChatAvailability, ChatFallback, YoloConfig, SetYoloConfigRequest, DeploymentSettings, UpdateDeploymentSettingsRequest, TriageConfig, SetTriageConfigRequest, ToolConfig, SetToolConfigRequest, ObservationCycle, ObservationCycleDetail, Observation, HealthScore, HealthScoreResponse, HealthPart, HealthPartView, AppHealthView, ScoresResponse, SignalsResponse, SelfTestCycle, SelfTestCycleDetail, SuiteResult, SelfTestResult, TestingBrainReport, SelfTestTrend, TriggerResponse, EngineeringJob, EngineeringProposal, ProposalDeployment, TriggerEngineeringRequest, UpdateProposalRequest, TriggerDeploymentRequest, UpdateDeploymentRequest, AuditTriggerResponse, ObserverConfigResponse, DesignTokens, ComponentSpec, DesignSystemResponse, DesignTokensResponse, ComponentSpecResponse, Notification, NotificationType, NotificationSeverity, NotificationStatus, NotificationsResponse, NotificationCountResponse, CodeChangeEvent, SignificanceLevel, StreamCollectingEvent, StreamQueuedEvent, StreamSteeringEvent, StreamInterruptedEvent, CoalesceResponse, TurnMetrics, TurnStartedEvent, TurnMetricsEvent, TurnCompletedEvent, SpanStartedEvent, SpanCompletedEvent, SpanErrorEvent, UICaptureScreenshotEvent, CrewPlanEvent, AgentDispatchedEvent, AgentProgressEvent, AgentFindingEvent, AgentCompleteEvent, CrewSynthesisEvent, CrewCompleteEvent, CrewAwaitingApprovalEvent, CrewApprovedEvent, CrewCancelledEvent, CrewStoppedEvent, AgentHandoffEvent, HookName, HookStyle, WebhookHook, CreateHookRequest, UpdateHookRequest, ListHooksResponse, InboundSignalStatus, InboundSignalOutcome, InboundSignalEnvironment, InboundSignalPriority, InboundSignalRelease, InboundSignal, CreateInboundSignalRequest, CreateInboundSignalResponse, InboundSignalFilters, InboundSignalDetailResponse, SignalAutomationMode, AutomationPolicy, SetAutomationPolicyRequest, SignalWebhookEventType, SignalWebhookSubscription, CreateSignalWebhookSubscriptionRequest, UpdateSignalWebhookSubscriptionRequest, CreateSignalWebhookSubscriptionResponse, SignalWebhookDeliveryStatus, SignalWebhookDelivery, RoomParticipantKind, RoomParticipantRole, RoomParticipantMode, RoomPresenceState, Participant, RoomEventType, RoomEvent, RoutingSignal, ReclaimSignal, RoutingEvent, RoomParticipantsResponse, InviteHumanRequest, InviteHumanResponse, } from './types.js';
|
|
138
138
|
export { ZiggyError, ZiggyConnectionError } from './errors.js';
|
|
139
139
|
export { LocalStoragePersistence } from './persistence.js';
|
|
140
140
|
export type { PersistenceAdapter } from './persistence.js';
|
|
@@ -155,9 +155,9 @@ export { UIActionExecutor } from './ui-actions.js';
|
|
|
155
155
|
export type { UIActionExecutorConfig } from './ui-actions.js';
|
|
156
156
|
export { ElementRegistry } from './element-registry.js';
|
|
157
157
|
export type { ElementRegistryEntry } from './element-registry.js';
|
|
158
|
-
export { ScreenshotCapture } from './screenshot.js';
|
|
158
|
+
export { ScreenshotCapture, sanitizeCssForHtml2Canvas, sanitizeClonedDocumentForHtml2Canvas, } from './screenshot.js';
|
|
159
159
|
export type { ScreenshotOptions, ScreenshotResult } from './screenshot.js';
|
|
160
|
-
export { captureAndUpload } from './screenshot-uploader.js';
|
|
161
|
-
export type { ScreenshotUploadResult } from './screenshot-uploader.js';
|
|
160
|
+
export { captureAndUpload, uploadImageBlob, ALLOWED_CHAT_IMAGE_TYPES, MAX_CHAT_IMAGE_BYTES, } from './screenshot-uploader.js';
|
|
161
|
+
export type { ScreenshotUploadResult, ImageUploadOptions, ImageUploadResult, } from './screenshot-uploader.js';
|
|
162
162
|
export { PRODUCT_MEMORY_EVENT_TYPES, PRODUCT_FRICTION_KINDS, PRODUCT_SIGNAL_PREF_KEYS, isProductMemoryEventType, } from './product-memory.js';
|
|
163
163
|
export type { ProductMemoryEventType, ProductFrictionKind, ProductOutcomePayload, ProductSignalPrefKey, ProductMemoryPreferences, } from './product-memory.js';
|
package/dist/index.js
CHANGED
|
@@ -282,6 +282,7 @@ var SessionManager = class {
|
|
|
282
282
|
_sessionId = null;
|
|
283
283
|
_conversationId = null;
|
|
284
284
|
_userId = null;
|
|
285
|
+
_aiDisclosure = null;
|
|
285
286
|
constructor(connection, config) {
|
|
286
287
|
this.connection = connection;
|
|
287
288
|
this.appId = config.appId;
|
|
@@ -293,6 +294,9 @@ var SessionManager = class {
|
|
|
293
294
|
get conversationId() {
|
|
294
295
|
return this._conversationId;
|
|
295
296
|
}
|
|
297
|
+
get aiDisclosure() {
|
|
298
|
+
return this._aiDisclosure;
|
|
299
|
+
}
|
|
296
300
|
/**
|
|
297
301
|
* Create or resume a session.
|
|
298
302
|
* Replaces 4 separate calls (brand + context + triggers + actions).
|
|
@@ -337,6 +341,7 @@ var SessionManager = class {
|
|
|
337
341
|
this._sessionId = response.sessionId;
|
|
338
342
|
this._conversationId = response.conversationId;
|
|
339
343
|
this._userId = request.userId;
|
|
344
|
+
this._aiDisclosure = response.config?.aiDisclosure ?? null;
|
|
340
345
|
if (this.persistence) {
|
|
341
346
|
this.persistence.set(persistenceKey(this.appId, request.userId, "conversationId"), response.conversationId);
|
|
342
347
|
this.persistence.set(persistenceKey(this.appId, request.userId, "sessionId"), response.sessionId);
|
|
@@ -394,6 +399,7 @@ var SessionManager = class {
|
|
|
394
399
|
await this.connection.request("DELETE", `/sessions/${this._sessionId}`);
|
|
395
400
|
this._sessionId = null;
|
|
396
401
|
this._conversationId = null;
|
|
402
|
+
this._aiDisclosure = null;
|
|
397
403
|
}
|
|
398
404
|
};
|
|
399
405
|
|
|
@@ -1611,6 +1617,13 @@ var StorageClient = class {
|
|
|
1611
1617
|
constructor(connection) {
|
|
1612
1618
|
this.connection = connection;
|
|
1613
1619
|
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Direct image upload through the Ziggy API into storage.
|
|
1622
|
+
* Avoids browser-to-R2 presigned PUT CORS issues for chat screenshots and pasted images.
|
|
1623
|
+
*/
|
|
1624
|
+
async uploadDirectImage(body) {
|
|
1625
|
+
return this.connection.request("POST", "/storage/upload/direct", body);
|
|
1626
|
+
}
|
|
1614
1627
|
/**
|
|
1615
1628
|
* Step 1 of presigned upload flow: request a presigned PUT URL.
|
|
1616
1629
|
* Returns the URL the client should PUT the file to.
|
|
@@ -1643,6 +1656,12 @@ var StorageClient = class {
|
|
|
1643
1656
|
async get(id) {
|
|
1644
1657
|
return this.connection.request("GET", `/storage/${id}`);
|
|
1645
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Delete an unsent media attachment uploaded by the current user before it is sent.
|
|
1661
|
+
*/
|
|
1662
|
+
async deletePending(id) {
|
|
1663
|
+
return this.connection.request("DELETE", `/storage/pending/${id}`);
|
|
1664
|
+
}
|
|
1646
1665
|
/**
|
|
1647
1666
|
* Delete a media attachment (removes from storage and graph).
|
|
1648
1667
|
*/
|
|
@@ -2491,6 +2510,92 @@ var UIActionExecutor = class {
|
|
|
2491
2510
|
};
|
|
2492
2511
|
|
|
2493
2512
|
// src/screenshot.ts
|
|
2513
|
+
var UNSUPPORTED_COLOR_FN_RE = /(^|[^a-zA-Z0-9_-])(color-mix|oklch|oklab|lch|lab)\(/gi;
|
|
2514
|
+
function sanitizeCssForHtml2Canvas(css) {
|
|
2515
|
+
UNSUPPORTED_COLOR_FN_RE.lastIndex = 0;
|
|
2516
|
+
if (!UNSUPPORTED_COLOR_FN_RE.test(css)) return css;
|
|
2517
|
+
UNSUPPORTED_COLOR_FN_RE.lastIndex = 0;
|
|
2518
|
+
let result = "";
|
|
2519
|
+
let cursor = 0;
|
|
2520
|
+
let match;
|
|
2521
|
+
while ((match = UNSUPPORTED_COLOR_FN_RE.exec(css)) !== null) {
|
|
2522
|
+
const prefix = match[1];
|
|
2523
|
+
const fnStart = match.index + prefix.length;
|
|
2524
|
+
if (fnStart < cursor) continue;
|
|
2525
|
+
let depth = 1;
|
|
2526
|
+
let i = match.index + match[0].length;
|
|
2527
|
+
while (i < css.length && depth > 0) {
|
|
2528
|
+
const ch = css[i];
|
|
2529
|
+
if (ch === "(") depth += 1;
|
|
2530
|
+
else if (ch === ")") depth -= 1;
|
|
2531
|
+
i += 1;
|
|
2532
|
+
}
|
|
2533
|
+
result += css.slice(cursor, fnStart) + "transparent";
|
|
2534
|
+
cursor = i;
|
|
2535
|
+
UNSUPPORTED_COLOR_FN_RE.lastIndex = cursor;
|
|
2536
|
+
}
|
|
2537
|
+
return result + css.slice(cursor);
|
|
2538
|
+
}
|
|
2539
|
+
function sanitizeClonedDocumentForHtml2Canvas(clonedDoc, options) {
|
|
2540
|
+
if (options?.ignoreSelector) {
|
|
2541
|
+
try {
|
|
2542
|
+
for (const el of Array.from(clonedDoc.querySelectorAll(options.ignoreSelector))) {
|
|
2543
|
+
el.remove();
|
|
2544
|
+
}
|
|
2545
|
+
} catch {
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
const sourceDoc = options?.sourceDoc;
|
|
2549
|
+
if (sourceDoc?.styleSheets) {
|
|
2550
|
+
const sheetCssByHref = /* @__PURE__ */ new Map();
|
|
2551
|
+
for (const sheet of Array.from(sourceDoc.styleSheets)) {
|
|
2552
|
+
if (!sheet.href) continue;
|
|
2553
|
+
try {
|
|
2554
|
+
const rules = sheet.cssRules;
|
|
2555
|
+
if (!rules) continue;
|
|
2556
|
+
let combined = "";
|
|
2557
|
+
for (let i = 0; i < rules.length; i += 1) {
|
|
2558
|
+
combined += rules[i].cssText + "\n";
|
|
2559
|
+
}
|
|
2560
|
+
sheetCssByHref.set(sheet.href, combined);
|
|
2561
|
+
} catch {
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
for (const link of Array.from(clonedDoc.querySelectorAll('link[rel="stylesheet"]'))) {
|
|
2565
|
+
const rawHref = link.getAttribute("href");
|
|
2566
|
+
if (!rawHref) continue;
|
|
2567
|
+
let resolvedHref = link.href || rawHref;
|
|
2568
|
+
try {
|
|
2569
|
+
resolvedHref = new URL(rawHref, sourceDoc.baseURI || "http://localhost").href;
|
|
2570
|
+
} catch {
|
|
2571
|
+
}
|
|
2572
|
+
const cssText = sheetCssByHref.get(resolvedHref) ?? sheetCssByHref.get(rawHref);
|
|
2573
|
+
if (!cssText) continue;
|
|
2574
|
+
const sanitized = sanitizeCssForHtml2Canvas(cssText);
|
|
2575
|
+
if (sanitized !== cssText) {
|
|
2576
|
+
const styleEl = clonedDoc.createElement("style");
|
|
2577
|
+
styleEl.textContent = sanitized;
|
|
2578
|
+
link.replaceWith(styleEl);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
for (const styleEl of Array.from(clonedDoc.querySelectorAll("style"))) {
|
|
2583
|
+
const raw = styleEl.textContent;
|
|
2584
|
+
if (!raw) continue;
|
|
2585
|
+
const sanitized = sanitizeCssForHtml2Canvas(raw);
|
|
2586
|
+
if (sanitized !== raw) {
|
|
2587
|
+
styleEl.textContent = sanitized;
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
for (const el of Array.from(clonedDoc.querySelectorAll("[style]"))) {
|
|
2591
|
+
const raw = el.getAttribute("style");
|
|
2592
|
+
if (!raw) continue;
|
|
2593
|
+
const sanitized = sanitizeCssForHtml2Canvas(raw);
|
|
2594
|
+
if (sanitized !== raw) {
|
|
2595
|
+
el.setAttribute("style", sanitized);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2494
2599
|
var ScreenshotCapture = class {
|
|
2495
2600
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2496
2601
|
html2canvas = null;
|
|
@@ -2515,7 +2620,13 @@ var ScreenshotCapture = class {
|
|
|
2515
2620
|
logging: false,
|
|
2516
2621
|
scale: 1,
|
|
2517
2622
|
backgroundColor: null,
|
|
2518
|
-
ignoreElements: options?.ignoreSelector ? (el) => el.matches(options.ignoreSelector) : void 0
|
|
2623
|
+
ignoreElements: options?.ignoreSelector ? (el) => el.matches(options.ignoreSelector) : void 0,
|
|
2624
|
+
onclone: (clonedDoc) => {
|
|
2625
|
+
sanitizeClonedDocumentForHtml2Canvas(clonedDoc, {
|
|
2626
|
+
ignoreSelector: options?.ignoreSelector,
|
|
2627
|
+
sourceDoc: document
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2519
2630
|
});
|
|
2520
2631
|
let finalCanvas = canvas;
|
|
2521
2632
|
if (canvas.width > maxWidth) {
|
|
@@ -2546,31 +2657,152 @@ var ScreenshotCapture = class {
|
|
|
2546
2657
|
};
|
|
2547
2658
|
|
|
2548
2659
|
// src/screenshot-uploader.ts
|
|
2549
|
-
|
|
2550
|
-
|
|
2660
|
+
var ALLOWED_CHAT_IMAGE_TYPES = [
|
|
2661
|
+
"image/png",
|
|
2662
|
+
"image/jpeg",
|
|
2663
|
+
"image/webp"
|
|
2664
|
+
];
|
|
2665
|
+
var MAX_CHAT_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
2666
|
+
var EXT_BY_MIME = {
|
|
2667
|
+
"image/png": "png",
|
|
2668
|
+
"image/jpeg": "jpg",
|
|
2669
|
+
"image/webp": "webp"
|
|
2670
|
+
};
|
|
2671
|
+
function normalizeImageMimeType(rawType) {
|
|
2672
|
+
const lowered = (rawType || "").trim().toLowerCase();
|
|
2673
|
+
if (lowered === "image/jpg") return "image/jpeg";
|
|
2674
|
+
if (ALLOWED_CHAT_IMAGE_TYPES.includes(lowered)) {
|
|
2675
|
+
return lowered;
|
|
2676
|
+
}
|
|
2677
|
+
return null;
|
|
2678
|
+
}
|
|
2679
|
+
async function blobToBase64(blob) {
|
|
2680
|
+
if (typeof blob.arrayBuffer === "function") {
|
|
2681
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
2682
|
+
if (typeof btoa === "function") {
|
|
2683
|
+
const chunkSize = 32768;
|
|
2684
|
+
let binary = "";
|
|
2685
|
+
for (let offset = 0; offset < bytes.length; offset += chunkSize) {
|
|
2686
|
+
const slice = bytes.subarray(offset, offset + chunkSize);
|
|
2687
|
+
binary += String.fromCharCode(...slice);
|
|
2688
|
+
}
|
|
2689
|
+
return btoa(binary);
|
|
2690
|
+
}
|
|
2691
|
+
const BufferCtor = globalThis.Buffer;
|
|
2692
|
+
if (BufferCtor) {
|
|
2693
|
+
return BufferCtor.from(bytes).toString("base64");
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
if (typeof FileReader === "function") {
|
|
2697
|
+
return await new Promise((resolve, reject) => {
|
|
2698
|
+
const reader = new FileReader();
|
|
2699
|
+
reader.onload = () => {
|
|
2700
|
+
const result = typeof reader.result === "string" ? reader.result : "";
|
|
2701
|
+
const commaIdx = result.indexOf(",");
|
|
2702
|
+
if (commaIdx === -1) {
|
|
2703
|
+
reject(new Error("Could not read image data."));
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
resolve(result.slice(commaIdx + 1));
|
|
2707
|
+
};
|
|
2708
|
+
reader.onerror = () => reject(reader.error ?? new Error("Could not read image data."));
|
|
2709
|
+
reader.readAsDataURL(blob);
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
throw new Error("Base64 encoding is not available in this environment.");
|
|
2713
|
+
}
|
|
2714
|
+
async function uploadImageBlob(storage, blob, userId, options) {
|
|
2715
|
+
const mimeType = normalizeImageMimeType(blob.type);
|
|
2716
|
+
if (!mimeType) {
|
|
2717
|
+
throw new Error("Only PNG, JPEG, and WebP images are supported.");
|
|
2718
|
+
}
|
|
2719
|
+
if (blob.size <= 0) {
|
|
2720
|
+
throw new Error("The selected image is empty.");
|
|
2721
|
+
}
|
|
2722
|
+
if (blob.size > MAX_CHAT_IMAGE_BYTES) {
|
|
2723
|
+
throw new Error("Images must be 10 MB or smaller.");
|
|
2724
|
+
}
|
|
2725
|
+
const ext = EXT_BY_MIME[mimeType];
|
|
2726
|
+
const prefix = options?.source === "screenshot" ? "page-screenshot" : "chat-image";
|
|
2727
|
+
const filename = options?.filename?.trim() || `${prefix}-${Date.now()}.${ext}`;
|
|
2728
|
+
const width = options?.width ?? 0;
|
|
2729
|
+
const height = options?.height ?? 0;
|
|
2730
|
+
const pageUrl = typeof window !== "undefined" && window.location ? `${window.location.origin}${window.location.pathname}` : void 0;
|
|
2731
|
+
const metadata = {
|
|
2732
|
+
...width > 0 ? { width } : {},
|
|
2733
|
+
...height > 0 ? { height } : {},
|
|
2734
|
+
uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2735
|
+
source: options?.source ?? "upload",
|
|
2736
|
+
...pageUrl ? { url: pageUrl } : {},
|
|
2737
|
+
...options?.metadata
|
|
2738
|
+
};
|
|
2739
|
+
if (typeof storage.uploadDirectImage === "function") {
|
|
2740
|
+
try {
|
|
2741
|
+
const dataBase64 = await blobToBase64(blob);
|
|
2742
|
+
const uploaded = await storage.uploadDirectImage({
|
|
2743
|
+
type: "screenshot",
|
|
2744
|
+
filename,
|
|
2745
|
+
mimeType,
|
|
2746
|
+
dataBase64,
|
|
2747
|
+
caption: options?.caption,
|
|
2748
|
+
metadata,
|
|
2749
|
+
uploadedBy: userId
|
|
2750
|
+
});
|
|
2751
|
+
return {
|
|
2752
|
+
attachmentId: uploaded.id,
|
|
2753
|
+
width,
|
|
2754
|
+
height,
|
|
2755
|
+
mimeType,
|
|
2756
|
+
size: uploaded.size ?? blob.size,
|
|
2757
|
+
filename
|
|
2758
|
+
};
|
|
2759
|
+
} catch (err) {
|
|
2760
|
+
const isNotFound = err instanceof ZiggyError && err.status === 404;
|
|
2761
|
+
if (!isNotFound) throw err;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2551
2764
|
const upload = await storage.requestUpload({
|
|
2552
2765
|
type: "screenshot",
|
|
2553
|
-
filename
|
|
2554
|
-
mimeType
|
|
2555
|
-
size:
|
|
2766
|
+
filename,
|
|
2767
|
+
mimeType,
|
|
2768
|
+
size: blob.size,
|
|
2769
|
+
caption: options?.caption,
|
|
2556
2770
|
uploadedBy: userId,
|
|
2557
|
-
metadata
|
|
2558
|
-
width: screenshot.width,
|
|
2559
|
-
height: screenshot.height,
|
|
2560
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2561
|
-
url: window.location.href
|
|
2562
|
-
}
|
|
2771
|
+
metadata
|
|
2563
2772
|
});
|
|
2564
|
-
await fetch(upload.uploadUrl, {
|
|
2773
|
+
const putResponse = await fetch(upload.uploadUrl, {
|
|
2565
2774
|
method: upload.method,
|
|
2566
2775
|
headers: upload.headers,
|
|
2567
|
-
body:
|
|
2776
|
+
body: blob
|
|
2568
2777
|
});
|
|
2778
|
+
if (!putResponse.ok) {
|
|
2779
|
+
throw new Error(`Image upload failed with status ${putResponse.status}.`);
|
|
2780
|
+
}
|
|
2569
2781
|
await storage.confirmUpload(upload.id, upload.storageKey);
|
|
2570
2782
|
return {
|
|
2571
2783
|
attachmentId: upload.id,
|
|
2784
|
+
width,
|
|
2785
|
+
height,
|
|
2786
|
+
mimeType,
|
|
2787
|
+
size: blob.size,
|
|
2788
|
+
filename
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
async function captureAndUpload(storage, capture, userId, options) {
|
|
2792
|
+
const screenshot = await capture.capture(options);
|
|
2793
|
+
const uploaded = await uploadImageBlob(storage, screenshot.blob, userId, {
|
|
2794
|
+
filename: `page-screenshot-${Date.now()}.jpg`,
|
|
2572
2795
|
width: screenshot.width,
|
|
2573
|
-
height: screenshot.height
|
|
2796
|
+
height: screenshot.height,
|
|
2797
|
+
source: "screenshot",
|
|
2798
|
+
metadata: {
|
|
2799
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2800
|
+
}
|
|
2801
|
+
});
|
|
2802
|
+
return {
|
|
2803
|
+
attachmentId: uploaded.attachmentId,
|
|
2804
|
+
width: uploaded.width,
|
|
2805
|
+
height: uploaded.height
|
|
2574
2806
|
};
|
|
2575
2807
|
}
|
|
2576
2808
|
|
|
@@ -2740,12 +2972,14 @@ var ZiggyClient = class {
|
|
|
2740
2972
|
}
|
|
2741
2973
|
};
|
|
2742
2974
|
export {
|
|
2975
|
+
ALLOWED_CHAT_IMAGE_TYPES,
|
|
2743
2976
|
CallbackHandler,
|
|
2744
2977
|
ConversationsClient,
|
|
2745
2978
|
DEFAULT_CALLBACK_TOLERANCE_MS,
|
|
2746
2979
|
ElementRegistry,
|
|
2747
2980
|
HookClient,
|
|
2748
2981
|
LocalStoragePersistence,
|
|
2982
|
+
MAX_CHAT_IMAGE_BYTES,
|
|
2749
2983
|
NotificationClient,
|
|
2750
2984
|
ObserverClient,
|
|
2751
2985
|
PRODUCT_FRICTION_KINDS,
|
|
@@ -2764,5 +2998,8 @@ export {
|
|
|
2764
2998
|
createVisitorToken,
|
|
2765
2999
|
isProductMemoryEventType,
|
|
2766
3000
|
parseNdjsonStream,
|
|
3001
|
+
sanitizeClonedDocumentForHtml2Canvas,
|
|
3002
|
+
sanitizeCssForHtml2Canvas,
|
|
3003
|
+
uploadImageBlob,
|
|
2767
3004
|
verifyCallbackSignature
|
|
2768
3005
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Screenshot
|
|
3
|
-
*
|
|
2
|
+
* Screenshot and chat image uploader.
|
|
3
|
+
*
|
|
4
|
+
* Uploads page screenshots and user-selected or pasted images to Ziggy's
|
|
5
|
+
* storage. Prefers the server-mediated direct upload endpoint so browser-to-R2
|
|
6
|
+
* CORS never blocks uploads, and falls back to the presigned PUT flow when
|
|
7
|
+
* talking to an older server that returns 404 on `/storage/upload/direct`.
|
|
4
8
|
*
|
|
5
9
|
* @example
|
|
6
10
|
* ```typescript
|
|
@@ -11,16 +15,43 @@
|
|
|
11
15
|
*/
|
|
12
16
|
import type { StorageClient } from './storage.js';
|
|
13
17
|
import type { ScreenshotCapture, ScreenshotOptions } from './screenshot.js';
|
|
18
|
+
import type { DirectImageMimeType } from './types.js';
|
|
19
|
+
export declare const ALLOWED_CHAT_IMAGE_TYPES: readonly ["image/png", "image/jpeg", "image/webp"];
|
|
20
|
+
export declare const MAX_CHAT_IMAGE_BYTES: number;
|
|
14
21
|
export interface ScreenshotUploadResult {
|
|
15
|
-
/** MediaAttachment ID
|
|
22
|
+
/** MediaAttachment ID for use in ChatAttachment */
|
|
16
23
|
attachmentId: string;
|
|
17
24
|
/** Image width in pixels */
|
|
18
25
|
width: number;
|
|
19
26
|
/** Image height in pixels */
|
|
20
27
|
height: number;
|
|
21
28
|
}
|
|
29
|
+
export interface ImageUploadOptions {
|
|
30
|
+
/** Optional display filename (defaults to a generated name for the MIME type) */
|
|
31
|
+
filename?: string;
|
|
32
|
+
/** Image width in pixels if known */
|
|
33
|
+
width?: number;
|
|
34
|
+
/** Image height in pixels if known */
|
|
35
|
+
height?: number;
|
|
36
|
+
/** Optional caption */
|
|
37
|
+
caption?: string;
|
|
38
|
+
/** How the image entered chat */
|
|
39
|
+
source?: 'screenshot' | 'paste' | 'upload';
|
|
40
|
+
/** Additional metadata stored with the MediaAttachment */
|
|
41
|
+
metadata?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export interface ImageUploadResult extends ScreenshotUploadResult {
|
|
44
|
+
mimeType: DirectImageMimeType;
|
|
45
|
+
size: number;
|
|
46
|
+
filename: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate and upload an image Blob (pasted, selected from disk, or captured
|
|
50
|
+
* as a screenshot) and return an attachment ID ready for ChatAttachment.
|
|
51
|
+
*/
|
|
52
|
+
export declare function uploadImageBlob(storage: StorageClient, blob: Blob, userId: string, options?: ImageUploadOptions): Promise<ImageUploadResult>;
|
|
22
53
|
/**
|
|
23
|
-
* Capture a screenshot and upload it
|
|
54
|
+
* Capture a screenshot and upload it to storage.
|
|
24
55
|
* Returns an attachment ID ready to include in a chat message.
|
|
25
56
|
*/
|
|
26
57
|
export declare function captureAndUpload(storage: StorageClient, capture: ScreenshotCapture, userId: string, options?: ScreenshotOptions): Promise<ScreenshotUploadResult>;
|
package/dist/screenshot.d.ts
CHANGED
|
@@ -26,6 +26,23 @@ export interface ScreenshotResult {
|
|
|
26
26
|
height: number;
|
|
27
27
|
mimeType: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Replace modern CSS color functions (color-mix, oklch, oklab, lch, lab) with
|
|
31
|
+
* `transparent` using balanced parenthesis matching so nested var(...) calls
|
|
32
|
+
* never leave broken syntax behind. html2canvas v1.4.1 throws when parsing
|
|
33
|
+
* these functions in stylesheets.
|
|
34
|
+
*/
|
|
35
|
+
export declare function sanitizeCssForHtml2Canvas(css: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Clean up the cloned document that html2canvas renders: remove excluded
|
|
38
|
+
* elements and rewrite unsupported color functions in both inline styles and
|
|
39
|
+
* stylesheets (including same-origin linked stylesheets from Vite builds).
|
|
40
|
+
* Never mutates the live document.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sanitizeClonedDocumentForHtml2Canvas(clonedDoc: Document, options?: {
|
|
43
|
+
ignoreSelector?: string;
|
|
44
|
+
sourceDoc?: Document;
|
|
45
|
+
}): void;
|
|
29
46
|
export declare class ScreenshotCapture {
|
|
30
47
|
private html2canvas;
|
|
31
48
|
/**
|
package/dist/session.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Session management module.
|
|
3
3
|
*/
|
|
4
4
|
import type { Connection } from './connection.js';
|
|
5
|
-
import type { ZiggyClientConfig, CreateSessionRequest, SessionResponse, ContextPushRequest, ContextPushResponse } from './types.js';
|
|
5
|
+
import type { ZiggyClientConfig, CreateSessionRequest, SessionAiDisclosure, SessionResponse, ContextPushRequest, ContextPushResponse } from './types.js';
|
|
6
6
|
export declare class SessionManager {
|
|
7
7
|
private connection;
|
|
8
8
|
private appId;
|
|
@@ -10,9 +10,11 @@ export declare class SessionManager {
|
|
|
10
10
|
private _sessionId;
|
|
11
11
|
private _conversationId;
|
|
12
12
|
private _userId;
|
|
13
|
+
private _aiDisclosure;
|
|
13
14
|
constructor(connection: Connection, config: ZiggyClientConfig);
|
|
14
15
|
get sessionId(): string | null;
|
|
15
16
|
get conversationId(): string | null;
|
|
17
|
+
get aiDisclosure(): SessionAiDisclosure | null;
|
|
16
18
|
/**
|
|
17
19
|
* Create or resume a session.
|
|
18
20
|
* Replaces 4 separate calls (brand + context + triggers + actions).
|
package/dist/storage.d.ts
CHANGED
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
* 2. URL registration (fallback) — upload() registers a pre-hosted URL
|
|
8
8
|
*/
|
|
9
9
|
import type { Connection } from './connection.js';
|
|
10
|
-
import type { MediaAttachment, RequestUploadRequest, RequestUploadResponse, ConfirmUploadResponse, UploadMediaRequest, UploadMediaResponse, DeleteResponse } from './types.js';
|
|
10
|
+
import type { MediaAttachment, RequestUploadRequest, RequestUploadResponse, DirectImageUploadRequest, DirectImageUploadResponse, ConfirmUploadResponse, UploadMediaRequest, UploadMediaResponse, DeleteResponse } from './types.js';
|
|
11
11
|
export declare class StorageClient {
|
|
12
12
|
private connection;
|
|
13
13
|
constructor(connection: Connection);
|
|
14
|
+
/**
|
|
15
|
+
* Direct image upload through the Ziggy API into storage.
|
|
16
|
+
* Avoids browser-to-R2 presigned PUT CORS issues for chat screenshots and pasted images.
|
|
17
|
+
*/
|
|
18
|
+
uploadDirectImage(body: DirectImageUploadRequest): Promise<DirectImageUploadResponse>;
|
|
14
19
|
/**
|
|
15
20
|
* Step 1 of presigned upload flow: request a presigned PUT URL.
|
|
16
21
|
* Returns the URL the client should PUT the file to.
|
|
@@ -31,6 +36,10 @@ export declare class StorageClient {
|
|
|
31
36
|
* If R2 is configured server-side, returns a fresh signed download URL.
|
|
32
37
|
*/
|
|
33
38
|
get(id: string): Promise<MediaAttachment>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete an unsent media attachment uploaded by the current user before it is sent.
|
|
41
|
+
*/
|
|
42
|
+
deletePending(id: string): Promise<DeleteResponse>;
|
|
34
43
|
/**
|
|
35
44
|
* Delete a media attachment (removes from storage and graph).
|
|
36
45
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -85,10 +85,16 @@ export interface SessionResponse {
|
|
|
85
85
|
/** Per-user Experience pack gates (ZIG-118). Absent on older servers → treat as open. */
|
|
86
86
|
experiences?: SessionExperiences;
|
|
87
87
|
}
|
|
88
|
+
export interface SessionAiDisclosure {
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
text: string;
|
|
91
|
+
}
|
|
88
92
|
export interface SessionConfig {
|
|
89
93
|
heartbeatIntervalMs: number;
|
|
90
94
|
maxMessageLength: number;
|
|
91
95
|
streamingSupported: boolean;
|
|
96
|
+
/** Fixed AI disclosure footer for visitor chat. Absent on older servers. */
|
|
97
|
+
aiDisclosure?: SessionAiDisclosure;
|
|
92
98
|
}
|
|
93
99
|
export interface AgentSummary {
|
|
94
100
|
id: string;
|
|
@@ -606,6 +612,13 @@ export interface ContentDoneEvent {
|
|
|
606
612
|
}
|
|
607
613
|
/** What the assistant's reply felt like, for a host that shows it (the chat character). Unknown values are ignored. */
|
|
608
614
|
export type ReplyFeeling = 'plain' | 'glad' | 'curious' | 'unsure' | 'caring' | 'handoff';
|
|
615
|
+
/** Reasons Jev's post-reply grounding check may flag a reply from the owner's guide (ZIG-213, slice 3d). */
|
|
616
|
+
export type GuideGroundingFlag = 'unsupported_fact' | 'unsupported_money' | 'unsupported_time' | 'unsupported_work';
|
|
617
|
+
/** Present on a guide reply that Jev flagged on complete evidence; nothing is held. */
|
|
618
|
+
export interface GuideGroundingNotice {
|
|
619
|
+
outcome: 'flagged';
|
|
620
|
+
flags: GuideGroundingFlag[];
|
|
621
|
+
}
|
|
609
622
|
export interface MetadataEvent {
|
|
610
623
|
type: 'metadata';
|
|
611
624
|
confidence: Confidence;
|
|
@@ -613,6 +626,8 @@ export interface MetadataEvent {
|
|
|
613
626
|
quickActions?: QuickAction[];
|
|
614
627
|
/** Present on replies from a server that judges them; absent on older servers and short paths. */
|
|
615
628
|
feeling?: ReplyFeeling;
|
|
629
|
+
/** Present on owner-guide replies flagged by Jev's post-reply grounding judge (SDK 1.13.0+). */
|
|
630
|
+
grounding?: GuideGroundingNotice;
|
|
616
631
|
seq: number;
|
|
617
632
|
}
|
|
618
633
|
export interface StreamEndEvent {
|
|
@@ -1779,6 +1794,24 @@ export interface RequestUploadResponse {
|
|
|
1779
1794
|
method: string;
|
|
1780
1795
|
headers: Record<string, string>;
|
|
1781
1796
|
}
|
|
1797
|
+
export type DirectImageMimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
1798
|
+
export interface DirectImageUploadRequest {
|
|
1799
|
+
type?: 'screenshot' | 'file';
|
|
1800
|
+
filename: string;
|
|
1801
|
+
mimeType: DirectImageMimeType;
|
|
1802
|
+
dataBase64: string;
|
|
1803
|
+
caption?: string;
|
|
1804
|
+
metadata?: Record<string, unknown>;
|
|
1805
|
+
uploadedBy: string;
|
|
1806
|
+
}
|
|
1807
|
+
export interface DirectImageUploadResponse {
|
|
1808
|
+
id: string;
|
|
1809
|
+
storageKey: string;
|
|
1810
|
+
url: string;
|
|
1811
|
+
size: number;
|
|
1812
|
+
mimeType: DirectImageMimeType;
|
|
1813
|
+
confirmed: boolean;
|
|
1814
|
+
}
|
|
1782
1815
|
/** Response from POST /v1/voice/token */
|
|
1783
1816
|
export interface VoiceTokenResponse {
|
|
1784
1817
|
/** Single-use ElevenLabs Scribe token when mint succeeded */
|