@shogo-ai/voice 1.4.1

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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/dist/chunk-D2EVSUZX.js +27 -0
  4. package/dist/chunk-Q3TJAJ54.js +165 -0
  5. package/dist/chunk-QHDIEE7O.js +453 -0
  6. package/dist/chunk-S3S2RNO6.js +671 -0
  7. package/dist/chunk-ZGYHDC5G.js +423 -0
  8. package/dist/index.cjs +1316 -0
  9. package/dist/index.d.cts +432 -0
  10. package/dist/index.d.ts +432 -0
  11. package/dist/index.js +735 -0
  12. package/dist/native/index.cjs +1667 -0
  13. package/dist/native/index.d.cts +285 -0
  14. package/dist/native/index.d.ts +285 -0
  15. package/dist/native/index.js +949 -0
  16. package/dist/organicParticlesShaders-DIva0vBO.d.cts +693 -0
  17. package/dist/organicParticlesShaders-DIva0vBO.d.ts +693 -0
  18. package/dist/react/index.cjs +1670 -0
  19. package/dist/react/index.d.cts +423 -0
  20. package/dist/react/index.d.ts +423 -0
  21. package/dist/react/index.js +952 -0
  22. package/dist/route/agent.cjs +981 -0
  23. package/dist/route/agent.d.cts +20 -0
  24. package/dist/route/agent.d.ts +20 -0
  25. package/dist/route/agent.js +17 -0
  26. package/dist/route/audio-tags.cjs +975 -0
  27. package/dist/route/audio-tags.d.cts +16 -0
  28. package/dist/route/audio-tags.d.ts +16 -0
  29. package/dist/route/audio-tags.js +13 -0
  30. package/dist/route/index.cjs +987 -0
  31. package/dist/route/index.d.cts +115 -0
  32. package/dist/route/index.d.ts +115 -0
  33. package/dist/route/index.js +12 -0
  34. package/dist/route/signed-url.cjs +975 -0
  35. package/dist/route/signed-url.d.cts +12 -0
  36. package/dist/route/signed-url.d.ts +12 -0
  37. package/dist/route/signed-url.js +13 -0
  38. package/dist/route/tts-preview.cjs +975 -0
  39. package/dist/route/tts-preview.d.cts +17 -0
  40. package/dist/route/tts-preview.d.ts +17 -0
  41. package/dist/route/tts-preview.js +13 -0
  42. package/dist/server.cjs +999 -0
  43. package/dist/server.d.cts +88 -0
  44. package/dist/server.d.ts +88 -0
  45. package/dist/server.js +11 -0
  46. package/dist/types-BKJtOUbE.d.cts +352 -0
  47. package/dist/types-BKJtOUbE.d.ts +352 -0
  48. package/package.json +148 -0
@@ -0,0 +1,115 @@
1
+ import { VoiceHandlersConfig, VoiceHandlers } from '../server.cjs';
2
+ import 'node:http';
3
+ import '../types-BKJtOUbE.cjs';
4
+
5
+ /**
6
+ * @shogo-ai/sdk/voice/route
7
+ *
8
+ * Drop-in route handlers for any Web-Standard router that dispatches
9
+ * by HTTP method export (Expo Router `+api.ts`, Next.js App Router
10
+ * `route.ts`, Cloudflare Workers, Bun.serve, Deno, Hono, etc.).
11
+ *
12
+ * The per-resource sub-modules (`./signed-url`, `./tts-preview`,
13
+ * `./agent`, `./audio-tags`) re-export pre-instantiated `GET`/`POST`/
14
+ * `PATCH`/`DELETE` handlers that delegate to {@link createVoiceHandlers}
15
+ * with zero configuration — pod apps just point a route file at them:
16
+ *
17
+ * @example Expo Router (zero-config, runtime-token proxy mode)
18
+ * ```ts
19
+ * // app/api/voice/signed-url+api.ts
20
+ * export { GET } from '@shogo-ai/sdk/voice/route/signed-url'
21
+ *
22
+ * // app/api/voice/audio-tags+api.ts
23
+ * export { GET } from '@shogo-ai/sdk/voice/route/audio-tags'
24
+ *
25
+ * // app/api/voice/tts-preview+api.ts
26
+ * export { POST } from '@shogo-ai/sdk/voice/route/tts-preview'
27
+ *
28
+ * // app/api/voice/agent+api.ts
29
+ * export { POST, PATCH, DELETE } from '@shogo-ai/sdk/voice/route/agent'
30
+ * ```
31
+ *
32
+ * In a Shogo-managed pod, `RUNTIME_AUTH_SECRET` and `PROJECT_ID` are
33
+ * injected automatically; `createVoiceHandlers({})` detects them and
34
+ * proxies to the Shogo API. No keys, no `getUser`, no companion store
35
+ * are required for the proxy path.
36
+ *
37
+ * @example Next.js App Router (BYO ElevenLabs)
38
+ * ```ts
39
+ * // app/api/voice/route.ts — when you own the EL key + user/companion stores
40
+ * import { createVoiceRoute } from '@shogo-ai/sdk/voice/route'
41
+ *
42
+ * const voice = createVoiceRoute({
43
+ * apiKey: process.env.ELEVENLABS_API_KEY!,
44
+ * getUser: async (req) => authenticate(req),
45
+ * companionStore: new PrismaCompanionStore(prisma),
46
+ * })
47
+ *
48
+ * export const { GET } = voice.signedUrl
49
+ * ```
50
+ */
51
+
52
+ /**
53
+ * Lazily build a {@link VoiceHandlers} instance per request using
54
+ * environment-driven config. Used by the per-resource modules so that
55
+ * `process.env` reads happen at request time (some runtimes populate
56
+ * env after module evaluation) and so tests can mutate env between
57
+ * cases without poisoning a cached handler.
58
+ *
59
+ * Instantiation cost is negligible — proxy mode just snapshots a few
60
+ * env vars; BYO mode constructs a single `ElevenLabsClient`.
61
+ *
62
+ * @internal Public for tests; not part of the stable surface.
63
+ */
64
+ declare function defaultHandlers(): VoiceHandlers;
65
+ /**
66
+ * Per-resource route exports keyed by HTTP method.
67
+ *
68
+ * Maps directly onto the file convention used by Expo Router /
69
+ * Next.js App Router / etc.: each property is an object whose keys
70
+ * are method names and whose values are `(req: Request) =>
71
+ * Promise<Response>` handlers.
72
+ */
73
+ interface VoiceRoute {
74
+ /** `GET /voice/signed-url` */
75
+ signedUrl: {
76
+ GET: (req: Request) => Promise<Response>;
77
+ };
78
+ /** `POST /voice/tts-preview` */
79
+ ttsPreview: {
80
+ POST: (req: Request) => Promise<Response>;
81
+ };
82
+ /** `POST | PATCH | DELETE /voice/agent` */
83
+ agent: {
84
+ POST: (req: Request) => Promise<Response>;
85
+ PATCH: (req: Request) => Promise<Response>;
86
+ DELETE: (req: Request) => Promise<Response>;
87
+ };
88
+ /** `GET /voice/audio-tags` */
89
+ audioTags: {
90
+ GET: (req: Request) => Promise<Response>;
91
+ };
92
+ }
93
+ /**
94
+ * Build per-resource route handlers from an explicit
95
+ * {@link VoiceHandlersConfig}. Use this when you need to pass
96
+ * `apiKey` / `getUser` / `companionStore` (BYO ElevenLabs mode) or
97
+ * an explicit `proxy` override — the zero-config per-resource
98
+ * modules cover the pod auto-detect case.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const voice = createVoiceRoute({
103
+ * apiKey: process.env.ELEVENLABS_API_KEY!,
104
+ * getUser: async (req) => authenticate(req),
105
+ * companionStore: new PrismaCompanionStore(prisma),
106
+ * })
107
+ *
108
+ * // Re-export under whatever route file the framework expects:
109
+ * export const { GET } = voice.signedUrl
110
+ * export const { POST, PATCH, DELETE } = voice.agent
111
+ * ```
112
+ */
113
+ declare function createVoiceRoute(config: VoiceHandlersConfig): VoiceRoute;
114
+
115
+ export { type VoiceRoute, createVoiceRoute, defaultHandlers };
@@ -0,0 +1,115 @@
1
+ import { VoiceHandlersConfig, VoiceHandlers } from '../server.js';
2
+ import 'node:http';
3
+ import '../types-BKJtOUbE.js';
4
+
5
+ /**
6
+ * @shogo-ai/sdk/voice/route
7
+ *
8
+ * Drop-in route handlers for any Web-Standard router that dispatches
9
+ * by HTTP method export (Expo Router `+api.ts`, Next.js App Router
10
+ * `route.ts`, Cloudflare Workers, Bun.serve, Deno, Hono, etc.).
11
+ *
12
+ * The per-resource sub-modules (`./signed-url`, `./tts-preview`,
13
+ * `./agent`, `./audio-tags`) re-export pre-instantiated `GET`/`POST`/
14
+ * `PATCH`/`DELETE` handlers that delegate to {@link createVoiceHandlers}
15
+ * with zero configuration — pod apps just point a route file at them:
16
+ *
17
+ * @example Expo Router (zero-config, runtime-token proxy mode)
18
+ * ```ts
19
+ * // app/api/voice/signed-url+api.ts
20
+ * export { GET } from '@shogo-ai/sdk/voice/route/signed-url'
21
+ *
22
+ * // app/api/voice/audio-tags+api.ts
23
+ * export { GET } from '@shogo-ai/sdk/voice/route/audio-tags'
24
+ *
25
+ * // app/api/voice/tts-preview+api.ts
26
+ * export { POST } from '@shogo-ai/sdk/voice/route/tts-preview'
27
+ *
28
+ * // app/api/voice/agent+api.ts
29
+ * export { POST, PATCH, DELETE } from '@shogo-ai/sdk/voice/route/agent'
30
+ * ```
31
+ *
32
+ * In a Shogo-managed pod, `RUNTIME_AUTH_SECRET` and `PROJECT_ID` are
33
+ * injected automatically; `createVoiceHandlers({})` detects them and
34
+ * proxies to the Shogo API. No keys, no `getUser`, no companion store
35
+ * are required for the proxy path.
36
+ *
37
+ * @example Next.js App Router (BYO ElevenLabs)
38
+ * ```ts
39
+ * // app/api/voice/route.ts — when you own the EL key + user/companion stores
40
+ * import { createVoiceRoute } from '@shogo-ai/sdk/voice/route'
41
+ *
42
+ * const voice = createVoiceRoute({
43
+ * apiKey: process.env.ELEVENLABS_API_KEY!,
44
+ * getUser: async (req) => authenticate(req),
45
+ * companionStore: new PrismaCompanionStore(prisma),
46
+ * })
47
+ *
48
+ * export const { GET } = voice.signedUrl
49
+ * ```
50
+ */
51
+
52
+ /**
53
+ * Lazily build a {@link VoiceHandlers} instance per request using
54
+ * environment-driven config. Used by the per-resource modules so that
55
+ * `process.env` reads happen at request time (some runtimes populate
56
+ * env after module evaluation) and so tests can mutate env between
57
+ * cases without poisoning a cached handler.
58
+ *
59
+ * Instantiation cost is negligible — proxy mode just snapshots a few
60
+ * env vars; BYO mode constructs a single `ElevenLabsClient`.
61
+ *
62
+ * @internal Public for tests; not part of the stable surface.
63
+ */
64
+ declare function defaultHandlers(): VoiceHandlers;
65
+ /**
66
+ * Per-resource route exports keyed by HTTP method.
67
+ *
68
+ * Maps directly onto the file convention used by Expo Router /
69
+ * Next.js App Router / etc.: each property is an object whose keys
70
+ * are method names and whose values are `(req: Request) =>
71
+ * Promise<Response>` handlers.
72
+ */
73
+ interface VoiceRoute {
74
+ /** `GET /voice/signed-url` */
75
+ signedUrl: {
76
+ GET: (req: Request) => Promise<Response>;
77
+ };
78
+ /** `POST /voice/tts-preview` */
79
+ ttsPreview: {
80
+ POST: (req: Request) => Promise<Response>;
81
+ };
82
+ /** `POST | PATCH | DELETE /voice/agent` */
83
+ agent: {
84
+ POST: (req: Request) => Promise<Response>;
85
+ PATCH: (req: Request) => Promise<Response>;
86
+ DELETE: (req: Request) => Promise<Response>;
87
+ };
88
+ /** `GET /voice/audio-tags` */
89
+ audioTags: {
90
+ GET: (req: Request) => Promise<Response>;
91
+ };
92
+ }
93
+ /**
94
+ * Build per-resource route handlers from an explicit
95
+ * {@link VoiceHandlersConfig}. Use this when you need to pass
96
+ * `apiKey` / `getUser` / `companionStore` (BYO ElevenLabs mode) or
97
+ * an explicit `proxy` override — the zero-config per-resource
98
+ * modules cover the pod auto-detect case.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const voice = createVoiceRoute({
103
+ * apiKey: process.env.ELEVENLABS_API_KEY!,
104
+ * getUser: async (req) => authenticate(req),
105
+ * companionStore: new PrismaCompanionStore(prisma),
106
+ * })
107
+ *
108
+ * // Re-export under whatever route file the framework expects:
109
+ * export const { GET } = voice.signedUrl
110
+ * export const { POST, PATCH, DELETE } = voice.agent
111
+ * ```
112
+ */
113
+ declare function createVoiceRoute(config: VoiceHandlersConfig): VoiceRoute;
114
+
115
+ export { type VoiceRoute, createVoiceRoute, defaultHandlers };
@@ -0,0 +1,12 @@
1
+ import {
2
+ createVoiceRoute,
3
+ defaultHandlers
4
+ } from "../chunk-D2EVSUZX.js";
5
+ import "../chunk-QHDIEE7O.js";
6
+ import "../chunk-ZGYHDC5G.js";
7
+ import "../chunk-Q3TJAJ54.js";
8
+ export {
9
+ createVoiceRoute,
10
+ defaultHandlers
11
+ };
12
+ //# sourceMappingURL=index.js.map