@fishaudio/agent-client 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fish Audio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @fishaudio/agent-client
2
+
3
+ Framework-agnostic JavaScript/TypeScript SDK for embedding [Fish Audio](https://fish.audio) voice agents into any website or web app: realtime voice over WebRTC, live transcripts, text input, and client tools — behind one small, event-driven API.
4
+
5
+ Using React? [`@fishaudio/agent-react`](https://github.com/fishaudio/fish-agent-sdk-web/tree/main/packages/react) wraps this SDK in hooks and components.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @fishaudio/agent-client
11
+ ```
12
+
13
+ ## Quickstart
14
+
15
+ ```js
16
+ import { AgentSession } from "@fishaudio/agent-client";
17
+
18
+ // Session token from your backend — or { agentId } for a public agent.
19
+ const sessionToken = await fetch("/api/voice-session", { method: "POST" }).then((r) => r.json());
20
+
21
+ const session = await AgentSession.start({
22
+ sessionToken,
23
+ callbacks: {
24
+ onModeChange: (mode) => setOrbState(mode), // "listening" | "thinking" | "speaking"
25
+ onMessage: ({ role, text }) => renderChatBubble(role, text),
26
+ onDisconnect: ({ reason }) => showCallEnded(reason),
27
+ },
28
+ });
29
+
30
+ // Later:
31
+ session.sendUserMessage("Can you summarize that?");
32
+ await session.end();
33
+ ```
34
+
35
+ Starting a session requests microphone access; call `start()` from a user gesture (button click) for the best permission and autoplay behavior.
36
+
37
+ ## Documentation
38
+
39
+ - [Quickstart](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/quickstart.md) — first call, with or without a backend.
40
+ - [Authentication](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/authentication.md) — server-created session tokens vs. public agents.
41
+ - [Sessions](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/sessions.md) — `start()` options, the session API, lifecycle and reconnection.
42
+ - [Events](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/events.md) — event reference and live transcripts.
43
+ - [Client tools](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/client-tools.md) — let the agent call functions in the browser.
44
+ - [Customization](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/customization.md) — per-session overrides and dynamic variables.
45
+ - [Errors](https://github.com/fishaudio/fish-agent-sdk-web/blob/main/docs/errors.md) — `FishAgentError` codes.
@@ -0,0 +1,36 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+ var __privateWrapper = (obj, member, setter, getter) => ({
10
+ set _(value) {
11
+ __privateSet(obj, member, value, setter);
12
+ },
13
+ get _() {
14
+ return __privateGet(obj, member, getter);
15
+ }
16
+ });
17
+
18
+ // src/errors.ts
19
+ var FishAgentError = class extends Error {
20
+ constructor(code, message, options) {
21
+ super(message, options?.cause !== void 0 ? { cause: options.cause } : void 0);
22
+ this.name = "FishAgentError";
23
+ this.code = code;
24
+ this.statusCode = options?.statusCode;
25
+ }
26
+ };
27
+
28
+ export {
29
+ __privateGet,
30
+ __privateAdd,
31
+ __privateSet,
32
+ __privateMethod,
33
+ __privateWrapper,
34
+ FishAgentError
35
+ };
36
+ //# sourceMappingURL=chunk-PEVOZB5Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export type FishAgentErrorCode =\n | \"session_request_failed\"\n | \"agent_not_public\"\n | \"origin_forbidden\"\n | \"unsupported_transport\"\n | \"mic_permission_denied\"\n /** A requested audio device could not be activated, or the browser does not support selecting it. */\n | \"device_change_failed\"\n | \"connection_failed\"\n | \"session_expired\"\n | \"tool_failed\"\n | \"tool_timeout\"\n /** An upstream model/speech provider failed during the session. */\n | \"provider_error\"\n /** The agent runtime hit an internal error. */\n | \"internal_error\";\n\nexport class FishAgentError extends Error {\n readonly code: FishAgentErrorCode;\n /** HTTP status of the failing session request, when the error originated there. */\n readonly statusCode?: number;\n\n constructor(\n code: FishAgentErrorCode,\n message: string,\n options?: { statusCode?: number; cause?: unknown },\n ) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = \"FishAgentError\";\n this.code = code;\n this.statusCode = options?.statusCode;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAKxC,YACE,MACA,SACA,SACA;AACA,UAAM,SAAS,SAAS,UAAU,SAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,MAAS;AAClF,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa,SAAS;AAAA,EAC7B;AACF;","names":[]}