@dudko.dev/agent-web-react 0.0.40 → 0.0.41
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/README.md +4 -2
- package/dist/{elicitation-IpjGRDD-.d.cts → elicitation-Dp6Fi6ZA.d.cts} +8 -0
- package/dist/{elicitation-IpjGRDD-.d.ts → elicitation-Dp6Fi6ZA.d.ts} +8 -0
- package/dist/index.cjs +80 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -4
- package/dist/index.d.ts +24 -4
- package/dist/index.js +80 -25
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
|
|
3
3
|
import { AskUserRequest, AskUserContext, AskUserAnswer, AskUserConfig, AskUserHandler, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, AppToolCallRequest, AppSamplingRequest, AppSamplingView, AppSamplingResult, CompactResult, IUsage, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions, ModelTier, TierReason, EscalationReason, DecisionFallbackReason, Skill, IPlan, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
|
|
4
4
|
export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AskUserAnswer, AskUserConfig, AskUserContext, AskUserHandler, AskUserOption, AskUserRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, SessionBusyError, SessionHolder, SessionLockMode, SessionRunState, SessionWatch, Skill, SkillStore, StorageChange, StorageChangeKind, StorageChangeOp, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, WatchSessionOptions, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, onStorageChange, parseSkillMarkdown, postStorageChange, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel, watchSession } from '@dudko.dev/agent-web';
|
|
5
|
-
import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, Q as QuestionView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-
|
|
6
|
-
export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, V as ElicitationOption, X as FetchView, Y as MCP_APP_DISPLAY_MODES, Z as MCP_APP_MAX_ARGS_CHARS, _ as MCP_APP_MAX_DOWNLOAD_BYTES, $ as MCP_APP_MAX_FILE_NAME_CHARS, a0 as MCP_APP_MAX_IN_FLIGHT, a1 as MCP_APP_MAX_MESSAGE_CHARS, a2 as MCP_APP_MAX_URL_CHARS, a3 as MCP_APP_NOTIFICATIONS, a4 as MCP_APP_OPTIONAL_REQUESTS, a5 as MCP_APP_PROTOCOL_VERSION, a6 as MCP_APP_REFUSED, a7 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a8 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a9 as MCP_APP_RELAY, aa as MCP_APP_REQUESTS, ab as MCP_APP_SANDBOX_FRAME_TOKENS, ac as MCP_APP_SANDBOX_GRACE_MS, ad as MCP_APP_SANDBOX_SERVER, ae as MCP_APP_SANDBOX_TIMEOUT_MS, af as McpAppBridge, ag as McpAppBridgeHandlers, ah as McpAppBridgeOptions, ai as McpAppDisplayMode, aj as McpAppRpcError, ak as McpAppRpcMessage, al as McpAppSandboxInput, am as McpAppSandboxLink, an as McpAppSandboxLinkOptions, ao as McpAppSandboxTarget, ap as McpElicitationFieldSchema, aq as McpElicitationRequest, ar as McpElicitationSchema, as as QueuedMessageView, at as ReplanState, au as SkillConsentView, av as StepEscalationView, aw as UseMcpAppHostOptions, ax as appDisplayModeAllowed, ay as appDownloadOf, az as appDownloadRefusal, aA as appFileExtensionOf, aB as appFileNameOf, aC as appGestureOf, aD as appLinkOf, aE as appMessageTextOf, aF as appMimeTypeOf, aG as appSamplingErrorOf, aH as buildMcpAppDocument, aI as buildMcpAppSandboxShell, aJ as clampAppHeight, aK as elicitationFields, aL as elicitationFormAnswer, aM as elicitationInitialDraft, aN as elicitationLink, aO as formatCountdown, aP as grantedAppCsp, aQ as mcpAppCsp, aR as mcpAppHostCapabilities, aS as mcpAppSandboxProxyUrl, aT as mcpAppSandboxShellCsp, aU as mcpAppSandboxTarget, aV as resolveAppDownload, aW as saveAppFile, aX as useMcpAppHost } from './elicitation-
|
|
5
|
+
import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, Q as QuestionView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-Dp6Fi6ZA.cjs';
|
|
6
|
+
export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, V as ElicitationOption, X as FetchView, Y as MCP_APP_DISPLAY_MODES, Z as MCP_APP_MAX_ARGS_CHARS, _ as MCP_APP_MAX_DOWNLOAD_BYTES, $ as MCP_APP_MAX_FILE_NAME_CHARS, a0 as MCP_APP_MAX_IN_FLIGHT, a1 as MCP_APP_MAX_MESSAGE_CHARS, a2 as MCP_APP_MAX_URL_CHARS, a3 as MCP_APP_NOTIFICATIONS, a4 as MCP_APP_OPTIONAL_REQUESTS, a5 as MCP_APP_PROTOCOL_VERSION, a6 as MCP_APP_REFUSED, a7 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a8 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a9 as MCP_APP_RELAY, aa as MCP_APP_REQUESTS, ab as MCP_APP_SANDBOX_FRAME_TOKENS, ac as MCP_APP_SANDBOX_GRACE_MS, ad as MCP_APP_SANDBOX_SERVER, ae as MCP_APP_SANDBOX_TIMEOUT_MS, af as McpAppBridge, ag as McpAppBridgeHandlers, ah as McpAppBridgeOptions, ai as McpAppDisplayMode, aj as McpAppRpcError, ak as McpAppRpcMessage, al as McpAppSandboxInput, am as McpAppSandboxLink, an as McpAppSandboxLinkOptions, ao as McpAppSandboxTarget, ap as McpElicitationFieldSchema, aq as McpElicitationRequest, ar as McpElicitationSchema, as as QueuedMessageView, at as ReplanState, au as SkillConsentView, av as StepEscalationView, aw as UseMcpAppHostOptions, ax as appDisplayModeAllowed, ay as appDownloadOf, az as appDownloadRefusal, aA as appFileExtensionOf, aB as appFileNameOf, aC as appGestureOf, aD as appLinkOf, aE as appMessageTextOf, aF as appMimeTypeOf, aG as appSamplingErrorOf, aH as buildMcpAppDocument, aI as buildMcpAppSandboxShell, aJ as clampAppHeight, aK as elicitationFields, aL as elicitationFormAnswer, aM as elicitationInitialDraft, aN as elicitationLink, aO as formatCountdown, aP as grantedAppCsp, aQ as mcpAppCsp, aR as mcpAppHostCapabilities, aS as mcpAppSandboxProxyUrl, aT as mcpAppSandboxShellCsp, aU as mcpAppSandboxTarget, aV as resolveAppDownload, aW as saveAppFile, aX as useMcpAppHost } from './elicitation-Dp6Fi6ZA.cjs';
|
|
7
7
|
export { M as MCP_APP_POLICY_TOKEN_MAX_CHARS, a as MCP_APP_SANDBOX_PROXY_READY, b as MCP_APP_SANDBOX_RESOURCE_READY, i as isMcpAppSandboxMessage, m as mcpAppPolicyToken } from './mcp-app-policy-DIUmGPJP.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -418,7 +418,9 @@ declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefin
|
|
|
418
418
|
* from here - that tab saves its own, unclipped copy. When another tab saved the chat after this
|
|
419
419
|
* tab last read or wrote it (or saved a chat this tab never read), THAT record is the truth for
|
|
420
420
|
* everything that is not this tab's own: this tab's own new messages - by identity, not by count,
|
|
421
|
-
* so a reset or a trim here drops nothing there - go after it
|
|
421
|
+
* so a reset or a trim here drops nothing there - go after it, each before a stored turn that
|
|
422
|
+
* began after its own (`ChatMessage.startedAt`: this tab saved its turn late, after another tab
|
|
423
|
+
* ran the next one and saved first). Without times, after it all.
|
|
422
424
|
*/
|
|
423
425
|
declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined,
|
|
424
426
|
/** The words of a title of attachments only (`chatTitle`). */
|
|
@@ -444,6 +446,8 @@ declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBa
|
|
|
444
446
|
* Several tabs: the list follows what other tabs of the site save (the store's `chats`
|
|
445
447
|
* notices), the open chat is read again when another tab saved it and nothing runs here, and a
|
|
446
448
|
* run followed from another tab (`agent.remote`) is never saved from here - its own tab saves it.
|
|
449
|
+
* A turn of this tab's is saved even when such a run reached it before the save began (a tab the
|
|
450
|
+
* browser froze, waking), and keeps its place among the other tab's turns (`mergeChatRecord`).
|
|
447
451
|
*/
|
|
448
452
|
declare const useChatHistory: (agent: UseAgentReturn, options?: UseChatHistoryOptions) => UseChatHistoryReturn;
|
|
449
453
|
|
|
@@ -2063,6 +2067,22 @@ interface ConvertedFile {
|
|
|
2063
2067
|
text: string;
|
|
2064
2068
|
/** Name of the text attachment (default: the file's name + ".md"). */
|
|
2065
2069
|
name?: string;
|
|
2070
|
+
/** The attachment's note (default: `convertedFrom` - "converted from report.pdf"). */
|
|
2071
|
+
note?: string;
|
|
2072
|
+
/**
|
|
2073
|
+
* Pictures that go with the text (e.g. the pages of a scanned PDF): each is attached as an
|
|
2074
|
+
* image the composer took itself - downscaled, counted against `maxImages` / `maxTotalBytes`,
|
|
2075
|
+
* saved under `/attachments/` - and only when the model reads images (otherwise the refusal is
|
|
2076
|
+
* said and the text goes alone).
|
|
2077
|
+
*/
|
|
2078
|
+
images?: ConvertedImage[];
|
|
2079
|
+
}
|
|
2080
|
+
/** A picture a `convertFile` made (`ConvertedFile.images`). */
|
|
2081
|
+
interface ConvertedImage {
|
|
2082
|
+
/** Its attachment's name, e.g. "scan-page-1.jpg". */
|
|
2083
|
+
name: string;
|
|
2084
|
+
/** The encoded picture; its `type` is the media type (an `image/*`). */
|
|
2085
|
+
blob: Blob;
|
|
2066
2086
|
}
|
|
2067
2087
|
interface AgentComposerProps {
|
|
2068
2088
|
/** The agent from `useAgent()` (or `useAgentContext()`). */
|
|
@@ -3532,4 +3552,4 @@ interface AppRequestPromptProps {
|
|
|
3532
3552
|
declare const AppRequestPrompt: ({ requests, onAnswer, renderRequest, labels, className, }: AppRequestPromptProps) => react.JSX.Element | null;
|
|
3533
3553
|
|
|
3534
3554
|
export { ASK_USER_TOOL_NAME, ATTACHMENT_BOUNDS, AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, ImageThumb, ImageViewer, ImageViewerProvider, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MemoryCard, MessageList, MicError, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, QUESTION_TIMEOUT_MS, QuestionPrompt, QuestionView, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SandboxedFrame, SourceView, SpeechOutputError, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, agentStatusOf, askUserOutputKept, askUserWith, attachmentKindOf, attachmentOverLimit, attachmentRefusal, attachmentTransformOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createQuestionQueue, createRecordingRecognizer, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, followsAfterResize, followsAfterScroll, formatClock, formatElapsed, imageExtensionOf, imageSizeOf, languageOfText, lessonsOf, linkedFilesOf, mediaFamilyOf, menuKeyTarget, menuSections, mergeChatRecord, mergeLabels, messageOverLimit, micProblemOf, micProblemText, newChatId, noticesOf, parseSlash, pendingApprovalsOf, pickRecordingType, questionChoiceOf, questionOtherOf, questionTimeoutOf, recordingSupported, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, settleAudioDuration, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, steerIntent, stopTracks, subagentTree, tokenizeHtml, unchangedSince, usageLine, useAgent, useAgentContext, useAudioRecorder, useChatHistory, useCredentials, useFollowScroll, useLabels, useLocalModel, useOptionalAgentContext, useReadAloud, useSpeechToText, useSpeechVoices, useVirtualFiles, useWebLLMModel, voiceFor, voiceMessageName, voicesOf, webSearchOf, withAttachments, withCspFirst, withPolicyFirst, withoutOwnWords };
|
|
3535
|
-
export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, AttachmentBounds, AttachmentOverLimit, AttachmentTexts, AttachmentTransform, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, ImageSize, ImageThumbProps, ImageViewerProps, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MediaRecorderConstructorLike, MediaRecorderLike, MemoryCardProps, MenuSection, MessageListProps, MicProblem, ModelLoadBarProps, NoticeTexts, PendingQuestion, PlanViewProps, QuestionOutcomeReason, QuestionPromptProps, QuestionQueue, QuestionQueueOptions, ReadAloudOptions, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, RenderImageViewer, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, ScrollMeasure, SlashCommand, SourceToken, SourceViewProps, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, SynthesizeSpeech, ToolApprovalPromptProps, ToolCallRowProps, TranscribeAudio, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseAudioRecorderOptions, UseAudioRecorderReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseReadAloudReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, ViewerImage, WebLLMModelFactory, WebSearchResultView, WebSearchView };
|
|
3555
|
+
export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, AttachmentBounds, AttachmentOverLimit, AttachmentTexts, AttachmentTransform, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, ConvertedImage, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, ImageSize, ImageThumbProps, ImageViewerProps, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MediaRecorderConstructorLike, MediaRecorderLike, MemoryCardProps, MenuSection, MessageListProps, MicProblem, ModelLoadBarProps, NoticeTexts, PendingQuestion, PlanViewProps, QuestionOutcomeReason, QuestionPromptProps, QuestionQueue, QuestionQueueOptions, ReadAloudOptions, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, RenderImageViewer, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, ScrollMeasure, SlashCommand, SourceToken, SourceViewProps, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, SynthesizeSpeech, ToolApprovalPromptProps, ToolCallRowProps, TranscribeAudio, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseAudioRecorderOptions, UseAudioRecorderReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseReadAloudReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, ViewerImage, WebLLMModelFactory, WebSearchResultView, WebSearchView };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
|
|
3
3
|
import { AskUserRequest, AskUserContext, AskUserAnswer, AskUserConfig, AskUserHandler, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, AppToolCallRequest, AppSamplingRequest, AppSamplingView, AppSamplingResult, CompactResult, IUsage, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions, ModelTier, TierReason, EscalationReason, DecisionFallbackReason, Skill, IPlan, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
|
|
4
4
|
export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AskUserAnswer, AskUserConfig, AskUserContext, AskUserHandler, AskUserOption, AskUserRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, SessionBusyError, SessionHolder, SessionLockMode, SessionRunState, SessionWatch, Skill, SkillStore, StorageChange, StorageChangeKind, StorageChangeOp, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, WatchSessionOptions, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, onStorageChange, parseSkillMarkdown, postStorageChange, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel, watchSession } from '@dudko.dev/agent-web';
|
|
5
|
-
import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, Q as QuestionView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-
|
|
6
|
-
export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, V as ElicitationOption, X as FetchView, Y as MCP_APP_DISPLAY_MODES, Z as MCP_APP_MAX_ARGS_CHARS, _ as MCP_APP_MAX_DOWNLOAD_BYTES, $ as MCP_APP_MAX_FILE_NAME_CHARS, a0 as MCP_APP_MAX_IN_FLIGHT, a1 as MCP_APP_MAX_MESSAGE_CHARS, a2 as MCP_APP_MAX_URL_CHARS, a3 as MCP_APP_NOTIFICATIONS, a4 as MCP_APP_OPTIONAL_REQUESTS, a5 as MCP_APP_PROTOCOL_VERSION, a6 as MCP_APP_REFUSED, a7 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a8 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a9 as MCP_APP_RELAY, aa as MCP_APP_REQUESTS, ab as MCP_APP_SANDBOX_FRAME_TOKENS, ac as MCP_APP_SANDBOX_GRACE_MS, ad as MCP_APP_SANDBOX_SERVER, ae as MCP_APP_SANDBOX_TIMEOUT_MS, af as McpAppBridge, ag as McpAppBridgeHandlers, ah as McpAppBridgeOptions, ai as McpAppDisplayMode, aj as McpAppRpcError, ak as McpAppRpcMessage, al as McpAppSandboxInput, am as McpAppSandboxLink, an as McpAppSandboxLinkOptions, ao as McpAppSandboxTarget, ap as McpElicitationFieldSchema, aq as McpElicitationRequest, ar as McpElicitationSchema, as as QueuedMessageView, at as ReplanState, au as SkillConsentView, av as StepEscalationView, aw as UseMcpAppHostOptions, ax as appDisplayModeAllowed, ay as appDownloadOf, az as appDownloadRefusal, aA as appFileExtensionOf, aB as appFileNameOf, aC as appGestureOf, aD as appLinkOf, aE as appMessageTextOf, aF as appMimeTypeOf, aG as appSamplingErrorOf, aH as buildMcpAppDocument, aI as buildMcpAppSandboxShell, aJ as clampAppHeight, aK as elicitationFields, aL as elicitationFormAnswer, aM as elicitationInitialDraft, aN as elicitationLink, aO as formatCountdown, aP as grantedAppCsp, aQ as mcpAppCsp, aR as mcpAppHostCapabilities, aS as mcpAppSandboxProxyUrl, aT as mcpAppSandboxShellCsp, aU as mcpAppSandboxTarget, aV as resolveAppDownload, aW as saveAppFile, aX as useMcpAppHost } from './elicitation-
|
|
5
|
+
import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, Q as QuestionView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-Dp6Fi6ZA.js';
|
|
6
|
+
export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, V as ElicitationOption, X as FetchView, Y as MCP_APP_DISPLAY_MODES, Z as MCP_APP_MAX_ARGS_CHARS, _ as MCP_APP_MAX_DOWNLOAD_BYTES, $ as MCP_APP_MAX_FILE_NAME_CHARS, a0 as MCP_APP_MAX_IN_FLIGHT, a1 as MCP_APP_MAX_MESSAGE_CHARS, a2 as MCP_APP_MAX_URL_CHARS, a3 as MCP_APP_NOTIFICATIONS, a4 as MCP_APP_OPTIONAL_REQUESTS, a5 as MCP_APP_PROTOCOL_VERSION, a6 as MCP_APP_REFUSED, a7 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a8 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a9 as MCP_APP_RELAY, aa as MCP_APP_REQUESTS, ab as MCP_APP_SANDBOX_FRAME_TOKENS, ac as MCP_APP_SANDBOX_GRACE_MS, ad as MCP_APP_SANDBOX_SERVER, ae as MCP_APP_SANDBOX_TIMEOUT_MS, af as McpAppBridge, ag as McpAppBridgeHandlers, ah as McpAppBridgeOptions, ai as McpAppDisplayMode, aj as McpAppRpcError, ak as McpAppRpcMessage, al as McpAppSandboxInput, am as McpAppSandboxLink, an as McpAppSandboxLinkOptions, ao as McpAppSandboxTarget, ap as McpElicitationFieldSchema, aq as McpElicitationRequest, ar as McpElicitationSchema, as as QueuedMessageView, at as ReplanState, au as SkillConsentView, av as StepEscalationView, aw as UseMcpAppHostOptions, ax as appDisplayModeAllowed, ay as appDownloadOf, az as appDownloadRefusal, aA as appFileExtensionOf, aB as appFileNameOf, aC as appGestureOf, aD as appLinkOf, aE as appMessageTextOf, aF as appMimeTypeOf, aG as appSamplingErrorOf, aH as buildMcpAppDocument, aI as buildMcpAppSandboxShell, aJ as clampAppHeight, aK as elicitationFields, aL as elicitationFormAnswer, aM as elicitationInitialDraft, aN as elicitationLink, aO as formatCountdown, aP as grantedAppCsp, aQ as mcpAppCsp, aR as mcpAppHostCapabilities, aS as mcpAppSandboxProxyUrl, aT as mcpAppSandboxShellCsp, aU as mcpAppSandboxTarget, aV as resolveAppDownload, aW as saveAppFile, aX as useMcpAppHost } from './elicitation-Dp6Fi6ZA.js';
|
|
7
7
|
export { M as MCP_APP_POLICY_TOKEN_MAX_CHARS, a as MCP_APP_SANDBOX_PROXY_READY, b as MCP_APP_SANDBOX_RESOURCE_READY, i as isMcpAppSandboxMessage, m as mcpAppPolicyToken } from './mcp-app-policy-DIUmGPJP.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -418,7 +418,9 @@ declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefin
|
|
|
418
418
|
* from here - that tab saves its own, unclipped copy. When another tab saved the chat after this
|
|
419
419
|
* tab last read or wrote it (or saved a chat this tab never read), THAT record is the truth for
|
|
420
420
|
* everything that is not this tab's own: this tab's own new messages - by identity, not by count,
|
|
421
|
-
* so a reset or a trim here drops nothing there - go after it
|
|
421
|
+
* so a reset or a trim here drops nothing there - go after it, each before a stored turn that
|
|
422
|
+
* began after its own (`ChatMessage.startedAt`: this tab saved its turn late, after another tab
|
|
423
|
+
* ran the next one and saved first). Without times, after it all.
|
|
422
424
|
*/
|
|
423
425
|
declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined,
|
|
424
426
|
/** The words of a title of attachments only (`chatTitle`). */
|
|
@@ -444,6 +446,8 @@ declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBa
|
|
|
444
446
|
* Several tabs: the list follows what other tabs of the site save (the store's `chats`
|
|
445
447
|
* notices), the open chat is read again when another tab saved it and nothing runs here, and a
|
|
446
448
|
* run followed from another tab (`agent.remote`) is never saved from here - its own tab saves it.
|
|
449
|
+
* A turn of this tab's is saved even when such a run reached it before the save began (a tab the
|
|
450
|
+
* browser froze, waking), and keeps its place among the other tab's turns (`mergeChatRecord`).
|
|
447
451
|
*/
|
|
448
452
|
declare const useChatHistory: (agent: UseAgentReturn, options?: UseChatHistoryOptions) => UseChatHistoryReturn;
|
|
449
453
|
|
|
@@ -2063,6 +2067,22 @@ interface ConvertedFile {
|
|
|
2063
2067
|
text: string;
|
|
2064
2068
|
/** Name of the text attachment (default: the file's name + ".md"). */
|
|
2065
2069
|
name?: string;
|
|
2070
|
+
/** The attachment's note (default: `convertedFrom` - "converted from report.pdf"). */
|
|
2071
|
+
note?: string;
|
|
2072
|
+
/**
|
|
2073
|
+
* Pictures that go with the text (e.g. the pages of a scanned PDF): each is attached as an
|
|
2074
|
+
* image the composer took itself - downscaled, counted against `maxImages` / `maxTotalBytes`,
|
|
2075
|
+
* saved under `/attachments/` - and only when the model reads images (otherwise the refusal is
|
|
2076
|
+
* said and the text goes alone).
|
|
2077
|
+
*/
|
|
2078
|
+
images?: ConvertedImage[];
|
|
2079
|
+
}
|
|
2080
|
+
/** A picture a `convertFile` made (`ConvertedFile.images`). */
|
|
2081
|
+
interface ConvertedImage {
|
|
2082
|
+
/** Its attachment's name, e.g. "scan-page-1.jpg". */
|
|
2083
|
+
name: string;
|
|
2084
|
+
/** The encoded picture; its `type` is the media type (an `image/*`). */
|
|
2085
|
+
blob: Blob;
|
|
2066
2086
|
}
|
|
2067
2087
|
interface AgentComposerProps {
|
|
2068
2088
|
/** The agent from `useAgent()` (or `useAgentContext()`). */
|
|
@@ -3532,4 +3552,4 @@ interface AppRequestPromptProps {
|
|
|
3532
3552
|
declare const AppRequestPrompt: ({ requests, onAnswer, renderRequest, labels, className, }: AppRequestPromptProps) => react.JSX.Element | null;
|
|
3533
3553
|
|
|
3534
3554
|
export { ASK_USER_TOOL_NAME, ATTACHMENT_BOUNDS, AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, ImageThumb, ImageViewer, ImageViewerProvider, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MemoryCard, MessageList, MicError, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, QUESTION_TIMEOUT_MS, QuestionPrompt, QuestionView, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SandboxedFrame, SourceView, SpeechOutputError, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, agentStatusOf, askUserOutputKept, askUserWith, attachmentKindOf, attachmentOverLimit, attachmentRefusal, attachmentTransformOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createQuestionQueue, createRecordingRecognizer, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, followsAfterResize, followsAfterScroll, formatClock, formatElapsed, imageExtensionOf, imageSizeOf, languageOfText, lessonsOf, linkedFilesOf, mediaFamilyOf, menuKeyTarget, menuSections, mergeChatRecord, mergeLabels, messageOverLimit, micProblemOf, micProblemText, newChatId, noticesOf, parseSlash, pendingApprovalsOf, pickRecordingType, questionChoiceOf, questionOtherOf, questionTimeoutOf, recordingSupported, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, settleAudioDuration, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, steerIntent, stopTracks, subagentTree, tokenizeHtml, unchangedSince, usageLine, useAgent, useAgentContext, useAudioRecorder, useChatHistory, useCredentials, useFollowScroll, useLabels, useLocalModel, useOptionalAgentContext, useReadAloud, useSpeechToText, useSpeechVoices, useVirtualFiles, useWebLLMModel, voiceFor, voiceMessageName, voicesOf, webSearchOf, withAttachments, withCspFirst, withPolicyFirst, withoutOwnWords };
|
|
3535
|
-
export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, AttachmentBounds, AttachmentOverLimit, AttachmentTexts, AttachmentTransform, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, ImageSize, ImageThumbProps, ImageViewerProps, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MediaRecorderConstructorLike, MediaRecorderLike, MemoryCardProps, MenuSection, MessageListProps, MicProblem, ModelLoadBarProps, NoticeTexts, PendingQuestion, PlanViewProps, QuestionOutcomeReason, QuestionPromptProps, QuestionQueue, QuestionQueueOptions, ReadAloudOptions, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, RenderImageViewer, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, ScrollMeasure, SlashCommand, SourceToken, SourceViewProps, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, SynthesizeSpeech, ToolApprovalPromptProps, ToolCallRowProps, TranscribeAudio, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseAudioRecorderOptions, UseAudioRecorderReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseReadAloudReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, ViewerImage, WebLLMModelFactory, WebSearchResultView, WebSearchView };
|
|
3555
|
+
export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, AttachmentBounds, AttachmentOverLimit, AttachmentTexts, AttachmentTransform, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, ConvertedImage, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, ImageSize, ImageThumbProps, ImageViewerProps, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MediaRecorderConstructorLike, MediaRecorderLike, MemoryCardProps, MenuSection, MessageListProps, MicProblem, ModelLoadBarProps, NoticeTexts, PendingQuestion, PlanViewProps, QuestionOutcomeReason, QuestionPromptProps, QuestionQueue, QuestionQueueOptions, ReadAloudOptions, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, RenderImageViewer, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, ScrollMeasure, SlashCommand, SourceToken, SourceViewProps, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, SynthesizeSpeech, ToolApprovalPromptProps, ToolCallRowProps, TranscribeAudio, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseAudioRecorderOptions, UseAudioRecorderReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseReadAloudReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, ViewerImage, WebLLMModelFactory, WebSearchResultView, WebSearchView };
|
package/dist/index.js
CHANGED
|
@@ -816,6 +816,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
816
816
|
const base = resetRun(ctx.remote ? state : withoutSubmitted(state));
|
|
817
817
|
const userId = `msg-${base.seq}`;
|
|
818
818
|
const assistantId = `msg-${base.seq + 1}`;
|
|
819
|
+
const began = ctx.at !== void 0 ? { startedAt: ctx.at } : {};
|
|
819
820
|
return {
|
|
820
821
|
...base,
|
|
821
822
|
// Another tab's run keeps the view of it; a run of this tab's ends it (and any wait).
|
|
@@ -833,6 +834,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
833
834
|
content: event.goal,
|
|
834
835
|
pending: false,
|
|
835
836
|
...ctx.remote ? { remote: true } : {},
|
|
837
|
+
...began,
|
|
836
838
|
...ctx.attachments?.length ? { attachments: ctx.attachments } : {}
|
|
837
839
|
},
|
|
838
840
|
{
|
|
@@ -840,7 +842,8 @@ var applyEvent = (state, event, ctx) => {
|
|
|
840
842
|
role: "assistant",
|
|
841
843
|
content: "",
|
|
842
844
|
pending: true,
|
|
843
|
-
...ctx.remote ? { remote: true } : {}
|
|
845
|
+
...ctx.remote ? { remote: true } : {},
|
|
846
|
+
...began
|
|
844
847
|
}
|
|
845
848
|
],
|
|
846
849
|
seq: base.seq + 2
|
|
@@ -2053,6 +2056,22 @@ var renumber = (own, after) => {
|
|
|
2053
2056
|
);
|
|
2054
2057
|
return own.map((m) => ({ ...m, id: `msg-${next += 1}` }));
|
|
2055
2058
|
};
|
|
2059
|
+
var turnAt = (m) => typeof m.startedAt === "number" && Number.isFinite(m.startedAt) ? m.startedAt : void 0;
|
|
2060
|
+
var placeByTurn = (stored, own) => {
|
|
2061
|
+
let i = stored.length;
|
|
2062
|
+
while (i > 0 && turnAt(stored[i - 1]) !== void 0) i -= 1;
|
|
2063
|
+
const out = stored.slice(0, i);
|
|
2064
|
+
for (const m of own) {
|
|
2065
|
+
const at = turnAt(m);
|
|
2066
|
+
while (i < stored.length && (at === void 0 || turnAt(stored[i]) <= at)) {
|
|
2067
|
+
out.push(stored[i]);
|
|
2068
|
+
i += 1;
|
|
2069
|
+
}
|
|
2070
|
+
out.push(m);
|
|
2071
|
+
}
|
|
2072
|
+
return [...out, ...stored.slice(i)];
|
|
2073
|
+
};
|
|
2074
|
+
var ownUnsaved = (messages, base) => messages.some((m) => !m.remote && !base?.known.has(m));
|
|
2056
2075
|
var unchangedSince = (messages, base) => base !== void 0 && messages.length === base.known.size && messages.every((m) => base.known.has(m));
|
|
2057
2076
|
var mergeChatRecord = (view, stored, base, texts) => {
|
|
2058
2077
|
const local = view.messages.filter((m) => !m.remote);
|
|
@@ -2060,7 +2079,7 @@ var mergeChatRecord = (view, stored, base, texts) => {
|
|
|
2060
2079
|
return { record: { ...view, messages: local }, merged: false };
|
|
2061
2080
|
}
|
|
2062
2081
|
const own = local.filter((m) => !base?.known.has(m));
|
|
2063
|
-
const messages =
|
|
2082
|
+
const messages = placeByTurn(stored.messages, renumber(own, stored.messages));
|
|
2064
2083
|
return {
|
|
2065
2084
|
record: {
|
|
2066
2085
|
...view,
|
|
@@ -2173,9 +2192,10 @@ var useChatHistory = (agent, options = {}) => {
|
|
|
2173
2192
|
void select(sessionId);
|
|
2174
2193
|
return;
|
|
2175
2194
|
}
|
|
2176
|
-
if (
|
|
2195
|
+
if (messages.length === 0) return;
|
|
2177
2196
|
const base = baseRef.current?.id === sessionId ? baseRef.current : void 0;
|
|
2178
2197
|
if (unchangedSince(messages, base)) return;
|
|
2198
|
+
if (remote && !ownUnsaved(messages, base)) return;
|
|
2179
2199
|
const now = Date.now();
|
|
2180
2200
|
const createdAt = createdRef.current.get(sessionId) ?? now;
|
|
2181
2201
|
createdRef.current.set(sessionId, createdAt);
|
|
@@ -6375,6 +6395,47 @@ ${draftText}` : draftText);
|
|
|
6375
6395
|
if (full) noRoom[full].push(name);
|
|
6376
6396
|
else setPending((cur) => [...cur, a]);
|
|
6377
6397
|
};
|
|
6398
|
+
const sendAs = async (name, f, kind, mediaType, transform, id) => {
|
|
6399
|
+
const blob = transform === "downscale" ? await downscaleImage(f, {
|
|
6400
|
+
maxDimension: imageMax,
|
|
6401
|
+
maxPixels: attachCfg.imageMaxPixels
|
|
6402
|
+
}) : f;
|
|
6403
|
+
const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
|
|
6404
|
+
if (sentOver) return overLimitText(name, sentOver);
|
|
6405
|
+
add(name, {
|
|
6406
|
+
id,
|
|
6407
|
+
name,
|
|
6408
|
+
kind,
|
|
6409
|
+
mediaType: blob.type || mediaType,
|
|
6410
|
+
dataUrl: await readDataUrl2(blob),
|
|
6411
|
+
bytes: blob.size,
|
|
6412
|
+
...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
|
|
6413
|
+
});
|
|
6414
|
+
return void 0;
|
|
6415
|
+
};
|
|
6416
|
+
const addImage = async (name, blob, id) => {
|
|
6417
|
+
const mediaType = blob.type || "image/jpeg";
|
|
6418
|
+
if (attachmentKindOf(mediaType, name) !== "image") return L.binaryText(name);
|
|
6419
|
+
const transform = attachmentTransformOf({
|
|
6420
|
+
kind: "image",
|
|
6421
|
+
mediaType,
|
|
6422
|
+
imageMaxDimension: imageMax,
|
|
6423
|
+
converts: false
|
|
6424
|
+
});
|
|
6425
|
+
const size = transform === "downscale" ? await imageSizeOf(blob) : void 0;
|
|
6426
|
+
const over = attachmentOverLimit(
|
|
6427
|
+
{ bytes: blob.size, pixels: size && size.width * size.height },
|
|
6428
|
+
"original",
|
|
6429
|
+
transform,
|
|
6430
|
+
bounds
|
|
6431
|
+
);
|
|
6432
|
+
if (over) return overLimitText(name, over);
|
|
6433
|
+
if (messageOverLimit(pendingRef.current, { kind: "image", bytes: 0 }, bounds) === "images") {
|
|
6434
|
+
noRoom.images.push(name);
|
|
6435
|
+
return void 0;
|
|
6436
|
+
}
|
|
6437
|
+
return sendAs(name, blob, "image", mediaType, transform, id);
|
|
6438
|
+
};
|
|
6378
6439
|
for (const f of list) {
|
|
6379
6440
|
const mediaType = f.type || "application/octet-stream";
|
|
6380
6441
|
const name = f.name || `pasted-${Date.now()}.${mediaType.split("/")[1] ?? "bin"}`;
|
|
@@ -6413,9 +6474,9 @@ ${draftText}` : draftText);
|
|
|
6413
6474
|
const converted = await convertFile(f);
|
|
6414
6475
|
if (converted) {
|
|
6415
6476
|
const bytes = new Blob([converted.text]).size;
|
|
6416
|
-
const
|
|
6417
|
-
if (
|
|
6418
|
-
problem = overLimitText(name,
|
|
6477
|
+
const sentOver = attachmentOverLimit({ bytes }, "sent", transform, bounds);
|
|
6478
|
+
if (sentOver) {
|
|
6479
|
+
problem = overLimitText(name, sentOver);
|
|
6419
6480
|
continue;
|
|
6420
6481
|
}
|
|
6421
6482
|
add(name, {
|
|
@@ -6425,8 +6486,18 @@ ${draftText}` : draftText);
|
|
|
6425
6486
|
mediaType: "text/markdown",
|
|
6426
6487
|
text: converted.text,
|
|
6427
6488
|
bytes,
|
|
6428
|
-
note: L.convertedFrom(name)
|
|
6489
|
+
note: converted.note ?? L.convertedFrom(name)
|
|
6429
6490
|
});
|
|
6491
|
+
const images = converted.images ?? [];
|
|
6492
|
+
if (images.length > 0) {
|
|
6493
|
+
const imageRefusal = attachmentRefusal("image", caps);
|
|
6494
|
+
if (imageRefusal) problem = imageRefusal;
|
|
6495
|
+
else
|
|
6496
|
+
for (const image of images) {
|
|
6497
|
+
const said3 = await addImage(image.name, image.blob, `att-${attachSeq += 1}`);
|
|
6498
|
+
if (said3) problem = said3;
|
|
6499
|
+
}
|
|
6500
|
+
}
|
|
6430
6501
|
continue;
|
|
6431
6502
|
}
|
|
6432
6503
|
}
|
|
@@ -6434,24 +6505,8 @@ ${draftText}` : draftText);
|
|
|
6434
6505
|
problem = refusal;
|
|
6435
6506
|
continue;
|
|
6436
6507
|
}
|
|
6437
|
-
const
|
|
6438
|
-
|
|
6439
|
-
maxPixels: attachCfg.imageMaxPixels
|
|
6440
|
-
}) : f;
|
|
6441
|
-
const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
|
|
6442
|
-
if (sentOver) {
|
|
6443
|
-
problem = overLimitText(name, sentOver);
|
|
6444
|
-
continue;
|
|
6445
|
-
}
|
|
6446
|
-
add(name, {
|
|
6447
|
-
id,
|
|
6448
|
-
name,
|
|
6449
|
-
kind,
|
|
6450
|
-
mediaType: blob.type || mediaType,
|
|
6451
|
-
dataUrl: await readDataUrl2(blob),
|
|
6452
|
-
bytes: blob.size,
|
|
6453
|
-
...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
|
|
6454
|
-
});
|
|
6508
|
+
const said2 = await sendAs(name, f, kind, mediaType, transform, id);
|
|
6509
|
+
if (said2) problem = said2;
|
|
6455
6510
|
} catch (err) {
|
|
6456
6511
|
problem = `${name}: ${err instanceof Error ? err.message : String(err)}`;
|
|
6457
6512
|
}
|