@absolutejs/voice 0.0.7 → 0.0.9
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/htmx.d.ts +2 -2
- package/dist/index.js +15 -12
- package/dist/plugin.d.ts +2 -10
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/htmx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { VoiceHTMXRenderConfig, VoiceHTMXRenderInput, VoiceHTMXTargets, VoiceSessionRecord } from './types';
|
|
1
|
+
import type { VoiceHTMXConfig, VoiceHTMXRenderConfig, VoiceHTMXRenderInput, VoiceHTMXTargets, VoiceSessionRecord } from './types';
|
|
2
2
|
type ResolvedVoiceHTMXRenderConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Required<VoiceHTMXRenderConfig<TSession, TResult>>;
|
|
3
3
|
export declare const resolveVoiceHTMXTargets: (custom?: Partial<VoiceHTMXTargets>) => VoiceHTMXTargets;
|
|
4
|
-
export declare const resolveVoiceHTMXRenderers: <TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(custom?:
|
|
4
|
+
export declare const resolveVoiceHTMXRenderers: <TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(custom?: VoiceHTMXConfig<TSession, TResult>) => ResolvedVoiceHTMXRenderConfig<TSession, TResult>;
|
|
5
5
|
export declare const buildVoiceHTMXResponse: <TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(input: VoiceHTMXRenderInput<TResult, TSession>, renderers: ResolvedVoiceHTMXRenderConfig<TSession, TResult>, targets: VoiceHTMXTargets) => string;
|
|
6
6
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -173,14 +173,17 @@ var resolveVoiceHTMXTargets = (custom) => ({
|
|
|
173
173
|
...DEFAULT_HTMX_TARGETS,
|
|
174
174
|
...custom
|
|
175
175
|
});
|
|
176
|
-
var resolveVoiceHTMXRenderers = (custom) =>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
var resolveVoiceHTMXRenderers = (custom) => {
|
|
177
|
+
const renderConfig = typeof custom === "function" ? { result: custom } : custom;
|
|
178
|
+
return {
|
|
179
|
+
assistant: renderConfig?.assistant ?? defaultAssistant,
|
|
180
|
+
emptyState: renderConfig?.emptyState ?? defaultEmptyState,
|
|
181
|
+
metrics: renderConfig?.metrics ?? defaultMetrics,
|
|
182
|
+
result: renderConfig?.result ?? defaultResult,
|
|
183
|
+
status: renderConfig?.status ?? defaultStatus,
|
|
184
|
+
turns: renderConfig?.turns ?? defaultTurns
|
|
185
|
+
};
|
|
186
|
+
};
|
|
184
187
|
var renderOob = (id, html) => `<div id="${escapeHtml(id)}" hx-swap-oob="innerHTML">${html}</div>`;
|
|
185
188
|
var buildVoiceHTMXResponse = (input, renderers, targets) => [
|
|
186
189
|
renderOob(targets.metrics, renderers.metrics(input)),
|
|
@@ -678,10 +681,10 @@ var voice = (config) => {
|
|
|
678
681
|
logger: resolveLogger(config.logger),
|
|
679
682
|
socketSessions: new WeakMap
|
|
680
683
|
};
|
|
681
|
-
const
|
|
682
|
-
const htmxRoute =
|
|
683
|
-
const htmxRenderers = resolveVoiceHTMXRenderers(
|
|
684
|
-
const htmxTargets = resolveVoiceHTMXTargets(
|
|
684
|
+
const htmxOptions = config.htmx && typeof config.htmx === "object" ? config.htmx : undefined;
|
|
685
|
+
const htmxRoute = htmxOptions?.route ?? `${config.path}/htmx/session`;
|
|
686
|
+
const htmxRenderers = resolveVoiceHTMXRenderers(config.htmx && config.htmx !== true ? config.htmx : undefined);
|
|
687
|
+
const htmxTargets = resolveVoiceHTMXTargets(htmxOptions?.targets);
|
|
685
688
|
const htmxRoutes = () => {
|
|
686
689
|
if (!config.htmx) {
|
|
687
690
|
return new Elysia;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
result?: infer TResult;
|
|
5
|
-
} ? TResult : unknown;
|
|
6
|
-
type VoiceOnTurnHandler<TContext, TSession extends VoiceSessionRecord> = VoiceRouteConfig<TContext, TSession, unknown>['onTurn'];
|
|
7
|
-
export declare const voice: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TOnTurn extends VoiceOnTurnHandler<TContext, TSession> = VoiceOnTurnHandler<TContext, TSession>>(config: Omit<VoicePluginConfig<TContext, TSession, InferVoiceResult<TOnTurn>>, "onTurn" | "htmx"> & {
|
|
8
|
-
onTurn: TOnTurn;
|
|
9
|
-
htmx?: boolean | VoiceHTMXConfig<TSession, NoInfer<InferVoiceResult<TOnTurn>>>;
|
|
10
|
-
}) => Elysia<"", {
|
|
2
|
+
import type { VoicePluginConfig, VoiceSessionRecord } from './types';
|
|
3
|
+
export declare const voice: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(config: VoicePluginConfig<TContext, TSession, TResult>) => Elysia<"", {
|
|
11
4
|
decorator: {};
|
|
12
5
|
store: {};
|
|
13
6
|
derive: {};
|
|
@@ -73,4 +66,3 @@ export declare const voice: <TContext = unknown, TSession extends VoiceSessionRe
|
|
|
73
66
|
standaloneSchema: {};
|
|
74
67
|
response: {};
|
|
75
68
|
}>;
|
|
76
|
-
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -299,6 +299,7 @@ export type VoiceHTMXRenderConfig<TSession extends VoiceSessionRecord = VoiceSes
|
|
|
299
299
|
result?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
300
300
|
emptyState?: (kind: keyof VoiceHTMXTargets, input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
301
301
|
};
|
|
302
|
+
export type VoiceHTMXRenderer<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
302
303
|
export type VoiceHTMXTargets = {
|
|
303
304
|
assistant: string;
|
|
304
305
|
metrics: string;
|
|
@@ -306,10 +307,11 @@ export type VoiceHTMXTargets = {
|
|
|
306
307
|
status: string;
|
|
307
308
|
turns: string;
|
|
308
309
|
};
|
|
309
|
-
export type
|
|
310
|
+
export type VoiceHTMXOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderConfig<TSession, TResult> & {
|
|
310
311
|
route?: string;
|
|
311
312
|
targets?: Partial<VoiceHTMXTargets>;
|
|
312
313
|
};
|
|
314
|
+
export type VoiceHTMXConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderer<TSession, TResult> | VoiceHTMXOptions<TSession, TResult>;
|
|
313
315
|
export type VoiceStreamState<TResult = unknown> = {
|
|
314
316
|
sessionId: string | null;
|
|
315
317
|
status: VoiceSessionStatus | 'idle';
|