@ai-accounts/vue-headless 0.3.0-alpha.2 → 0.3.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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { Ref, App, InjectionKey } from 'vue';
2
- import { AiAccountsClient, WizardState, DetectResultDTO, BackendDTO, OnboardingMachineState, OAuthDeviceLoginDTO, AiAccountsEventHandler, AiAccountsEvent, BackendMetadata, UrlPrompt, TextPrompt, LoginFlowKind } from '@ai-accounts/ts-core';
1
+ import { Ref, App, InjectionKey, ShallowRef } from 'vue';
2
+ import { AiAccountsClient, WizardState, DetectResultDTO, BackendDTO, OnboardingMachineState, OAuthDeviceLoginDTO, AiAccountsEventHandler, AiAccountsEvent, BackendMetadata, UrlPrompt, TextPrompt, MenuPrompt, LoginFlowKind, ProcessGroupType, ToolCallDelta, ChatMessageDTO as ChatMessageDTO$1, ChatMode } from '@ai-accounts/ts-core';
3
3
 
4
4
  interface UseAccountWizardOptions {
5
5
  client: AiAccountsClient;
@@ -74,6 +74,7 @@ type UseLoginSession = {
74
74
  accountId: Ref<string | null>;
75
75
  urlPrompt: Ref<UrlPrompt | null>;
76
76
  textPrompt: Ref<TextPrompt | null>;
77
+ menuPrompt: Ref<MenuPrompt | null>;
77
78
  stdoutLines: Ref<string[]>;
78
79
  errorCode: Ref<string | null>;
79
80
  errorMessage: Ref<string | null>;
@@ -83,6 +84,123 @@ type UseLoginSession = {
83
84
  };
84
85
  declare function useLoginSession(): UseLoginSession;
85
86
 
87
+ interface ChatMessageDTO {
88
+ id: string;
89
+ role: 'system' | 'user' | 'assistant' | 'tool';
90
+ content: string;
91
+ created_at: string;
92
+ model: string | null;
93
+ tokens_in: number | null;
94
+ tokens_out: number | null;
95
+ }
96
+ interface UseConversationReturn {
97
+ sessionId: Ref<string | null>;
98
+ messages: ShallowRef<ChatMessageDTO[]>;
99
+ isStreaming: Ref<boolean>;
100
+ streamingText: Ref<string>;
101
+ error: Ref<string | null>;
102
+ create: (backendId: string, model: string) => Promise<void>;
103
+ send: (content: string) => Promise<void>;
104
+ load: (id: string) => Promise<void>;
105
+ }
106
+ declare function useConversation(client: AiAccountsClient): UseConversationReturn;
107
+
108
+ interface ProcessGroup {
109
+ id: string;
110
+ type: ProcessGroupType;
111
+ label: string;
112
+ content: string;
113
+ timestamp: string;
114
+ isExpanded: boolean;
115
+ autoCollapseMs: number;
116
+ }
117
+ interface UseProcessGroupsReturn {
118
+ groups: Ref<Map<string, ProcessGroup>>;
119
+ addGroup: (group: Omit<ProcessGroup, 'isExpanded'>) => void;
120
+ removeGroup: (id: string) => void;
121
+ toggleGroup: (id: string) => void;
122
+ collapseGroup: (id: string) => void;
123
+ expandGroup: (id: string) => void;
124
+ updateGroupContent: (id: string, content: string) => void;
125
+ clearGroups: () => void;
126
+ processToolCallDelta: (delta: ToolCallDelta) => void;
127
+ }
128
+ declare function useProcessGroups(): UseProcessGroupsReturn;
129
+
130
+ interface BackendResponseState {
131
+ backend: string;
132
+ content: string;
133
+ status: 'streaming' | 'complete' | 'error' | 'timeout';
134
+ error?: string;
135
+ }
136
+ interface SynthesisStateRef {
137
+ status: 'waiting' | 'streaming' | 'complete' | 'error';
138
+ content: string;
139
+ primaryBackend: string;
140
+ backendsCollected: string[];
141
+ error?: string;
142
+ }
143
+ interface UseSmartChatReturn {
144
+ sessionId: Ref<string | null>;
145
+ messages: ShallowRef<ChatMessageDTO$1[]>;
146
+ isStreaming: Ref<boolean>;
147
+ streamingContent: Ref<string>;
148
+ error: Ref<string | null>;
149
+ chatMode: Ref<ChatMode>;
150
+ backendResponses: Ref<Map<string, BackendResponseState>>;
151
+ synthesisState: Ref<SynthesisStateRef | null>;
152
+ selectedBackend: Ref<string | null>;
153
+ selectedAccount: Ref<string | null>;
154
+ selectedModel: Ref<string | null>;
155
+ createSession: (backendId: string, model: string) => Promise<void>;
156
+ loadSession: (id: string) => Promise<void>;
157
+ send: (content: string) => Promise<void>;
158
+ setMode: (mode: ChatMode) => void;
159
+ selectBackend: (kind: string | null) => void;
160
+ processGroups: UseProcessGroupsReturn;
161
+ canFinalize: Ref<boolean>;
162
+ isFinalizing: Ref<boolean>;
163
+ detectedConfig: Ref<Record<string, unknown> | null>;
164
+ finalize: () => Promise<Record<string, unknown> | null>;
165
+ setConfigParser: (parser: ((content: string) => Record<string, unknown> | null) | null) => void;
166
+ }
167
+ declare function useSmartChat(): UseSmartChatReturn;
168
+
169
+ interface UseSmartScrollReturn {
170
+ containerRef: Ref<HTMLElement | null>;
171
+ isNearBottom: Ref<boolean>;
172
+ showScrollButton: Ref<boolean>;
173
+ scrollToBottom: () => void;
174
+ }
175
+ declare function useSmartScroll(): UseSmartScrollReturn;
176
+
177
+ interface UseStreamingParserOptions {
178
+ onFlush?: () => void;
179
+ /** Max buffered chars before pre-init writes are dropped (prevents leak when smd fails to resolve). */
180
+ maxPendingChars?: number;
181
+ }
182
+ interface UseStreamingParserReturn {
183
+ init: (container: HTMLElement) => void;
184
+ write: (text: string) => void;
185
+ finalize: () => void;
186
+ destroy: () => void;
187
+ }
188
+ /**
189
+ * Reusable smd.js streaming markdown parser with rAF-batched writes.
190
+ *
191
+ * Lifecycle: init(container) → write(text)* → finalize()
192
+ *
193
+ * smd is resolved lazily — via globalThis.__smd (consumer-injected) or a
194
+ * dynamic import of the optional `streaming-markdown` peer dependency.
195
+ * If the peer dep cannot be resolved, the composable logs a one-time warning
196
+ * and discards writes; the internal `smd`/`SmdModule` identifiers are the
197
+ * historical module alias for the streaming-markdown package.
198
+ *
199
+ * @param options.onFlush - called after each rAF batch is flushed (e.g. scroll-to-bottom)
200
+ * @param options.maxPendingChars - cap for the pre-init buffer (default 1M chars)
201
+ */
202
+ declare function useStreamingParser(options?: UseStreamingParserOptions): UseStreamingParserReturn;
203
+
86
204
  declare const version = "0.3.0-alpha.1";
87
205
 
88
- export { type AiAccountsContext, type AiAccountsPluginOptions, type LoginStatus, type UseAccountWizardOptions, type UseAccountWizardReturn, type UseLoginSession, type UseOnboardingOptions, type UseOnboardingReturn, aiAccountsKey, aiAccountsPlugin, useAccountWizard, useAiAccounts, useBackendRegistry, useLoginSession, useOnboarding, version };
206
+ export { type AiAccountsContext, type AiAccountsPluginOptions, type BackendResponseState, type LoginStatus, type ProcessGroup, type SynthesisStateRef, type UseAccountWizardOptions, type UseAccountWizardReturn, type UseConversationReturn, type UseLoginSession, type UseOnboardingOptions, type UseOnboardingReturn, type UseProcessGroupsReturn, type UseSmartChatReturn, type UseSmartScrollReturn, type UseStreamingParserOptions, type UseStreamingParserReturn, aiAccountsKey, aiAccountsPlugin, useAccountWizard, useAiAccounts, useBackendRegistry, useConversation, useLoginSession, useOnboarding, useProcessGroups, useSmartChat, useSmartScroll, useStreamingParser, version };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Ref, App, InjectionKey } from 'vue';
2
- import { AiAccountsClient, WizardState, DetectResultDTO, BackendDTO, OnboardingMachineState, OAuthDeviceLoginDTO, AiAccountsEventHandler, AiAccountsEvent, BackendMetadata, UrlPrompt, TextPrompt, LoginFlowKind } from '@ai-accounts/ts-core';
1
+ import { Ref, App, InjectionKey, ShallowRef } from 'vue';
2
+ import { AiAccountsClient, WizardState, DetectResultDTO, BackendDTO, OnboardingMachineState, OAuthDeviceLoginDTO, AiAccountsEventHandler, AiAccountsEvent, BackendMetadata, UrlPrompt, TextPrompt, MenuPrompt, LoginFlowKind, ProcessGroupType, ToolCallDelta, ChatMessageDTO as ChatMessageDTO$1, ChatMode } from '@ai-accounts/ts-core';
3
3
 
4
4
  interface UseAccountWizardOptions {
5
5
  client: AiAccountsClient;
@@ -74,6 +74,7 @@ type UseLoginSession = {
74
74
  accountId: Ref<string | null>;
75
75
  urlPrompt: Ref<UrlPrompt | null>;
76
76
  textPrompt: Ref<TextPrompt | null>;
77
+ menuPrompt: Ref<MenuPrompt | null>;
77
78
  stdoutLines: Ref<string[]>;
78
79
  errorCode: Ref<string | null>;
79
80
  errorMessage: Ref<string | null>;
@@ -83,6 +84,123 @@ type UseLoginSession = {
83
84
  };
84
85
  declare function useLoginSession(): UseLoginSession;
85
86
 
87
+ interface ChatMessageDTO {
88
+ id: string;
89
+ role: 'system' | 'user' | 'assistant' | 'tool';
90
+ content: string;
91
+ created_at: string;
92
+ model: string | null;
93
+ tokens_in: number | null;
94
+ tokens_out: number | null;
95
+ }
96
+ interface UseConversationReturn {
97
+ sessionId: Ref<string | null>;
98
+ messages: ShallowRef<ChatMessageDTO[]>;
99
+ isStreaming: Ref<boolean>;
100
+ streamingText: Ref<string>;
101
+ error: Ref<string | null>;
102
+ create: (backendId: string, model: string) => Promise<void>;
103
+ send: (content: string) => Promise<void>;
104
+ load: (id: string) => Promise<void>;
105
+ }
106
+ declare function useConversation(client: AiAccountsClient): UseConversationReturn;
107
+
108
+ interface ProcessGroup {
109
+ id: string;
110
+ type: ProcessGroupType;
111
+ label: string;
112
+ content: string;
113
+ timestamp: string;
114
+ isExpanded: boolean;
115
+ autoCollapseMs: number;
116
+ }
117
+ interface UseProcessGroupsReturn {
118
+ groups: Ref<Map<string, ProcessGroup>>;
119
+ addGroup: (group: Omit<ProcessGroup, 'isExpanded'>) => void;
120
+ removeGroup: (id: string) => void;
121
+ toggleGroup: (id: string) => void;
122
+ collapseGroup: (id: string) => void;
123
+ expandGroup: (id: string) => void;
124
+ updateGroupContent: (id: string, content: string) => void;
125
+ clearGroups: () => void;
126
+ processToolCallDelta: (delta: ToolCallDelta) => void;
127
+ }
128
+ declare function useProcessGroups(): UseProcessGroupsReturn;
129
+
130
+ interface BackendResponseState {
131
+ backend: string;
132
+ content: string;
133
+ status: 'streaming' | 'complete' | 'error' | 'timeout';
134
+ error?: string;
135
+ }
136
+ interface SynthesisStateRef {
137
+ status: 'waiting' | 'streaming' | 'complete' | 'error';
138
+ content: string;
139
+ primaryBackend: string;
140
+ backendsCollected: string[];
141
+ error?: string;
142
+ }
143
+ interface UseSmartChatReturn {
144
+ sessionId: Ref<string | null>;
145
+ messages: ShallowRef<ChatMessageDTO$1[]>;
146
+ isStreaming: Ref<boolean>;
147
+ streamingContent: Ref<string>;
148
+ error: Ref<string | null>;
149
+ chatMode: Ref<ChatMode>;
150
+ backendResponses: Ref<Map<string, BackendResponseState>>;
151
+ synthesisState: Ref<SynthesisStateRef | null>;
152
+ selectedBackend: Ref<string | null>;
153
+ selectedAccount: Ref<string | null>;
154
+ selectedModel: Ref<string | null>;
155
+ createSession: (backendId: string, model: string) => Promise<void>;
156
+ loadSession: (id: string) => Promise<void>;
157
+ send: (content: string) => Promise<void>;
158
+ setMode: (mode: ChatMode) => void;
159
+ selectBackend: (kind: string | null) => void;
160
+ processGroups: UseProcessGroupsReturn;
161
+ canFinalize: Ref<boolean>;
162
+ isFinalizing: Ref<boolean>;
163
+ detectedConfig: Ref<Record<string, unknown> | null>;
164
+ finalize: () => Promise<Record<string, unknown> | null>;
165
+ setConfigParser: (parser: ((content: string) => Record<string, unknown> | null) | null) => void;
166
+ }
167
+ declare function useSmartChat(): UseSmartChatReturn;
168
+
169
+ interface UseSmartScrollReturn {
170
+ containerRef: Ref<HTMLElement | null>;
171
+ isNearBottom: Ref<boolean>;
172
+ showScrollButton: Ref<boolean>;
173
+ scrollToBottom: () => void;
174
+ }
175
+ declare function useSmartScroll(): UseSmartScrollReturn;
176
+
177
+ interface UseStreamingParserOptions {
178
+ onFlush?: () => void;
179
+ /** Max buffered chars before pre-init writes are dropped (prevents leak when smd fails to resolve). */
180
+ maxPendingChars?: number;
181
+ }
182
+ interface UseStreamingParserReturn {
183
+ init: (container: HTMLElement) => void;
184
+ write: (text: string) => void;
185
+ finalize: () => void;
186
+ destroy: () => void;
187
+ }
188
+ /**
189
+ * Reusable smd.js streaming markdown parser with rAF-batched writes.
190
+ *
191
+ * Lifecycle: init(container) → write(text)* → finalize()
192
+ *
193
+ * smd is resolved lazily — via globalThis.__smd (consumer-injected) or a
194
+ * dynamic import of the optional `streaming-markdown` peer dependency.
195
+ * If the peer dep cannot be resolved, the composable logs a one-time warning
196
+ * and discards writes; the internal `smd`/`SmdModule` identifiers are the
197
+ * historical module alias for the streaming-markdown package.
198
+ *
199
+ * @param options.onFlush - called after each rAF batch is flushed (e.g. scroll-to-bottom)
200
+ * @param options.maxPendingChars - cap for the pre-init buffer (default 1M chars)
201
+ */
202
+ declare function useStreamingParser(options?: UseStreamingParserOptions): UseStreamingParserReturn;
203
+
86
204
  declare const version = "0.3.0-alpha.1";
87
205
 
88
- export { type AiAccountsContext, type AiAccountsPluginOptions, type LoginStatus, type UseAccountWizardOptions, type UseAccountWizardReturn, type UseLoginSession, type UseOnboardingOptions, type UseOnboardingReturn, aiAccountsKey, aiAccountsPlugin, useAccountWizard, useAiAccounts, useBackendRegistry, useLoginSession, useOnboarding, version };
206
+ export { type AiAccountsContext, type AiAccountsPluginOptions, type BackendResponseState, type LoginStatus, type ProcessGroup, type SynthesisStateRef, type UseAccountWizardOptions, type UseAccountWizardReturn, type UseConversationReturn, type UseLoginSession, type UseOnboardingOptions, type UseOnboardingReturn, type UseProcessGroupsReturn, type UseSmartChatReturn, type UseSmartScrollReturn, type UseStreamingParserOptions, type UseStreamingParserReturn, aiAccountsKey, aiAccountsPlugin, useAccountWizard, useAiAccounts, useBackendRegistry, useConversation, useLoginSession, useOnboarding, useProcessGroups, useSmartChat, useSmartScroll, useStreamingParser, version };