@prestyj/voice 4.5.17 → 4.5.18
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 +6 -6
- package/dist/bridges/ezcoder-rpc.cjs +13 -13
- package/dist/bridges/ezcoder-rpc.cjs.map +1 -1
- package/dist/bridges/ezcoder-rpc.d.cts +8 -8
- package/dist/bridges/ezcoder-rpc.d.ts +8 -8
- package/dist/bridges/ezcoder-rpc.js +10 -10
- package/dist/bridges/ezcoder-rpc.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @prestyj/voice
|
|
2
2
|
|
|
3
|
-
Provider-agnostic realtime voice orchestration for
|
|
3
|
+
Provider-agnostic realtime voice orchestration for EZ tools, agents, and remote coding sessions.
|
|
4
4
|
|
|
5
5
|
## Architecture
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`@prestyj/voice` keeps the package root mobile-safe: it exports normalized voice session types, tool conversion helpers, in-memory tests, and platform interfaces without importing Node-only `@prestyj/cli` internals. Provider and bridge integrations live behind subpath exports so Expo, web, desktop, and Node relays can choose only the pieces they need.
|
|
8
8
|
|
|
9
9
|
Core concepts:
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ Core concepts:
|
|
|
12
12
|
- `VoiceTransport`: injectable WebRTC, WebSocket, or custom transport.
|
|
13
13
|
- `VoiceEvent`: normalized session, transcript, text, audio, tool, error, and close events.
|
|
14
14
|
- `VoiceTool`: realtime-safe tool contract with optional confirmation policies.
|
|
15
|
-
- `VoiceBridgeCommand` / `VoiceBridgeEvent`: small control surface for
|
|
15
|
+
- `VoiceBridgeCommand` / `VoiceBridgeEvent`: small control surface for EZ remotes.
|
|
16
16
|
|
|
17
17
|
## Provider support
|
|
18
18
|
|
|
@@ -34,7 +34,7 @@ This route is intentionally marked experimental because Codex backend request sh
|
|
|
34
34
|
|
|
35
35
|
## Tools
|
|
36
36
|
|
|
37
|
-
Convert existing
|
|
37
|
+
Convert existing EZ tools into realtime function tools:
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
40
|
import { agentToolToVoiceTool, voiceToolToRealtimeFunctionTool } from "@prestyj/voice";
|
|
@@ -56,7 +56,7 @@ await session.sendToolResult(result);
|
|
|
56
56
|
|
|
57
57
|
Use confirmation policies such as `"always"` or `"destructive"` for high-risk voice actions.
|
|
58
58
|
|
|
59
|
-
##
|
|
59
|
+
## EZ bridges
|
|
60
60
|
|
|
61
61
|
`@prestyj/voice/bridges/ezcoder-rpc` maps the voice bridge command surface to existing `ezcoder rpc` NDJSON commands such as `prompt`, `get_state`, `abort`, `new_session`, and `switch_model`.
|
|
62
62
|
|
|
@@ -74,6 +74,6 @@ Recommended first path:
|
|
|
74
74
|
|
|
75
75
|
1. A trusted backend uses an OpenAI API key to create a Realtime client secret or call session.
|
|
76
76
|
2. The mobile/web app uses the ephemeral credential or backend SDP exchange.
|
|
77
|
-
3. The app sends local device tools and remote
|
|
77
|
+
3. The app sends local device tools and remote EZ bridge tools through `@prestyj/voice`.
|
|
78
78
|
|
|
79
79
|
Experimental Codex auth should remain behind explicit user opt-in and separate imports.
|
|
@@ -20,25 +20,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/bridges/ezcoder-rpc.ts
|
|
21
21
|
var ezcoder_rpc_exports = {};
|
|
22
22
|
__export(ezcoder_rpc_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
createEZCoderRpcBridge: () => createEZCoderRpcBridge,
|
|
24
|
+
normalizeEZCoderRpcEvent: () => normalizeEZCoderRpcEvent,
|
|
25
|
+
toEZCoderRpcCommand: () => toEZCoderRpcCommand
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(ezcoder_rpc_exports);
|
|
28
|
-
function
|
|
28
|
+
function createEZCoderRpcBridge(options) {
|
|
29
29
|
const idFactory = options.idFactory ?? (() => `ezcoder_${Date.now()}`);
|
|
30
30
|
return {
|
|
31
31
|
async send(command, signal) {
|
|
32
32
|
const id = idFactory();
|
|
33
|
-
await options.sink.send(
|
|
33
|
+
await options.sink.send(toEZCoderRpcCommand(id, command), signal);
|
|
34
34
|
return id;
|
|
35
35
|
},
|
|
36
36
|
toTool() {
|
|
37
|
-
return
|
|
37
|
+
return createSendToEZCoderTool(this);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function toEZCoderRpcCommand(id, command) {
|
|
42
42
|
switch (command.type) {
|
|
43
43
|
case "prompt":
|
|
44
44
|
return { id, command: "prompt", text: command.text };
|
|
@@ -53,10 +53,10 @@ function toGGCoderRpcCommand(id, command) {
|
|
|
53
53
|
case "switch_project":
|
|
54
54
|
return { id, command: "prompt", text: `Switch project to ${command.project}` };
|
|
55
55
|
case "list_projects":
|
|
56
|
-
return { id, command: "prompt", text: "List available
|
|
56
|
+
return { id, command: "prompt", text: "List available EZ Coder projects." };
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function normalizeEZCoderRpcEvent(message) {
|
|
60
60
|
if (!isJsonObject(message)) {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
@@ -89,7 +89,7 @@ function normalizeGGCoderRpcEvent(message) {
|
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function createSendToEZCoderTool(bridge) {
|
|
93
93
|
return {
|
|
94
94
|
name: "send_to_ezcoder",
|
|
95
95
|
description: "Send a prompt or control command to a running ezcoder RPC session.",
|
|
@@ -121,8 +121,8 @@ function isJsonObject(value) {
|
|
|
121
121
|
}
|
|
122
122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
123
123
|
0 && (module.exports = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
createEZCoderRpcBridge,
|
|
125
|
+
normalizeEZCoderRpcEvent,
|
|
126
|
+
toEZCoderRpcCommand
|
|
127
127
|
});
|
|
128
128
|
//# sourceMappingURL=ezcoder-rpc.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bridges/ezcoder-rpc.ts"],"sourcesContent":["import type { JsonObject, VoiceBridgeCommand, VoiceBridgeEvent, VoiceTool } from \"../types.js\";\n\nexport interface
|
|
1
|
+
{"version":3,"sources":["../../src/bridges/ezcoder-rpc.ts"],"sourcesContent":["import type { JsonObject, VoiceBridgeCommand, VoiceBridgeEvent, VoiceTool } from \"../types.js\";\n\nexport interface EZCoderRpcMessageSink {\n send(message: JsonObject, signal?: AbortSignal): Promise<void>;\n}\n\nexport interface EZCoderRpcBridgeOptions {\n readonly sink: EZCoderRpcMessageSink;\n readonly idFactory?: () => string;\n}\n\nexport interface EZCoderRpcBridge {\n send(command: VoiceBridgeCommand, signal?: AbortSignal): Promise<string>;\n toTool(): VoiceTool;\n}\n\nexport function createEZCoderRpcBridge(options: EZCoderRpcBridgeOptions): EZCoderRpcBridge {\n const idFactory = options.idFactory ?? (() => `ezcoder_${Date.now()}`);\n return {\n async send(command, signal): Promise<string> {\n const id = idFactory();\n await options.sink.send(toEZCoderRpcCommand(id, command), signal);\n return id;\n },\n toTool(): VoiceTool {\n return createSendToEZCoderTool(this);\n },\n };\n}\n\nexport function toEZCoderRpcCommand(id: string, command: VoiceBridgeCommand): JsonObject {\n switch (command.type) {\n case \"prompt\":\n return { id, command: \"prompt\", text: command.text };\n case \"cancel\":\n return { id, command: \"abort\" };\n case \"status\":\n return { id, command: \"get_state\" };\n case \"new_session\":\n return { id, command: \"new_session\" };\n case \"switch_model\":\n return { id, command: \"switch_model\", provider: command.provider, model: command.model };\n case \"switch_project\":\n return { id, command: \"prompt\", text: `Switch project to ${command.project}` };\n case \"list_projects\":\n return { id, command: \"prompt\", text: \"List available EZ Coder projects.\" };\n }\n}\n\nexport function normalizeEZCoderRpcEvent(message: unknown): VoiceBridgeEvent | null {\n if (!isJsonObject(message)) {\n return null;\n }\n const type = typeof message.type === \"string\" ? message.type : \"\";\n switch (type) {\n case \"text_delta\":\n return { type: \"text_delta\", text: stringValue(message.text) };\n case \"tool_call_start\":\n return {\n type: \"tool_start\",\n id: stringOrUndefined(message.toolCallId),\n name: stringValue(message.name),\n };\n case \"tool_call_end\":\n return {\n type: \"tool_end\",\n id: stringOrUndefined(message.toolCallId),\n name: stringValue(message.name),\n isError: message.isError === true,\n };\n case \"agent_done\":\n return { type: \"completion\" };\n case \"ready\":\n case \"session_start\":\n case \"model_change\":\n return { type: \"status\", status: message };\n case \"error\":\n return { type: \"error\", error: stringValue(message.message ?? message.error) };\n default:\n return null;\n }\n}\n\nfunction createSendToEZCoderTool(bridge: EZCoderRpcBridge): VoiceTool {\n return {\n name: \"send_to_ezcoder\",\n description: \"Send a prompt or control command to a running ezcoder RPC session.\",\n parameters: {\n type: \"object\",\n properties: {\n text: { type: \"string\", description: \"Prompt text to send to ezcoder.\" },\n },\n required: [\"text\"],\n },\n async execute(args, context) {\n const text = typeof args.text === \"string\" ? args.text : \"\";\n if (!text) {\n return { error: \"text is required\" };\n }\n const id = await bridge.send({ type: \"prompt\", text }, context.signal);\n return { status: \"sent\", id };\n },\n };\n}\n\nfunction stringValue(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,uBAAuB,SAAoD;AACzF,QAAM,YAAY,QAAQ,cAAc,MAAM,WAAW,KAAK,IAAI,CAAC;AACnE,SAAO;AAAA,IACL,MAAM,KAAK,SAAS,QAAyB;AAC3C,YAAM,KAAK,UAAU;AACrB,YAAM,QAAQ,KAAK,KAAK,oBAAoB,I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
4
4
|
send(message: JsonObject, signal?: AbortSignal): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
7
|
-
readonly sink:
|
|
6
|
+
interface EZCoderRpcBridgeOptions {
|
|
7
|
+
readonly sink: EZCoderRpcMessageSink;
|
|
8
8
|
readonly idFactory?: () => string;
|
|
9
9
|
}
|
|
10
|
-
interface
|
|
10
|
+
interface EZCoderRpcBridge {
|
|
11
11
|
send(command: VoiceBridgeCommand, signal?: AbortSignal): Promise<string>;
|
|
12
12
|
toTool(): VoiceTool;
|
|
13
13
|
}
|
|
14
|
-
declare function
|
|
15
|
-
declare function
|
|
16
|
-
declare function
|
|
14
|
+
declare function createEZCoderRpcBridge(options: EZCoderRpcBridgeOptions): EZCoderRpcBridge;
|
|
15
|
+
declare function toEZCoderRpcCommand(id: string, command: VoiceBridgeCommand): JsonObject;
|
|
16
|
+
declare function normalizeEZCoderRpcEvent(message: unknown): VoiceBridgeEvent | null;
|
|
17
17
|
|
|
18
|
-
export { type
|
|
18
|
+
export { type EZCoderRpcBridge, type EZCoderRpcBridgeOptions, type EZCoderRpcMessageSink, createEZCoderRpcBridge, normalizeEZCoderRpcEvent, toEZCoderRpcCommand };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { p as VoiceBridgeCommand, e as VoiceTool, J as JsonObject, q as VoiceBridgeEvent } from '../types-Dc4Q3Z6X.js';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface EZCoderRpcMessageSink {
|
|
4
4
|
send(message: JsonObject, signal?: AbortSignal): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
7
|
-
readonly sink:
|
|
6
|
+
interface EZCoderRpcBridgeOptions {
|
|
7
|
+
readonly sink: EZCoderRpcMessageSink;
|
|
8
8
|
readonly idFactory?: () => string;
|
|
9
9
|
}
|
|
10
|
-
interface
|
|
10
|
+
interface EZCoderRpcBridge {
|
|
11
11
|
send(command: VoiceBridgeCommand, signal?: AbortSignal): Promise<string>;
|
|
12
12
|
toTool(): VoiceTool;
|
|
13
13
|
}
|
|
14
|
-
declare function
|
|
15
|
-
declare function
|
|
16
|
-
declare function
|
|
14
|
+
declare function createEZCoderRpcBridge(options: EZCoderRpcBridgeOptions): EZCoderRpcBridge;
|
|
15
|
+
declare function toEZCoderRpcCommand(id: string, command: VoiceBridgeCommand): JsonObject;
|
|
16
|
+
declare function normalizeEZCoderRpcEvent(message: unknown): VoiceBridgeEvent | null;
|
|
17
17
|
|
|
18
|
-
export { type
|
|
18
|
+
export { type EZCoderRpcBridge, type EZCoderRpcBridgeOptions, type EZCoderRpcMessageSink, createEZCoderRpcBridge, normalizeEZCoderRpcEvent, toEZCoderRpcCommand };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// src/bridges/ezcoder-rpc.ts
|
|
2
|
-
function
|
|
2
|
+
function createEZCoderRpcBridge(options) {
|
|
3
3
|
const idFactory = options.idFactory ?? (() => `ezcoder_${Date.now()}`);
|
|
4
4
|
return {
|
|
5
5
|
async send(command, signal) {
|
|
6
6
|
const id = idFactory();
|
|
7
|
-
await options.sink.send(
|
|
7
|
+
await options.sink.send(toEZCoderRpcCommand(id, command), signal);
|
|
8
8
|
return id;
|
|
9
9
|
},
|
|
10
10
|
toTool() {
|
|
11
|
-
return
|
|
11
|
+
return createSendToEZCoderTool(this);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function toEZCoderRpcCommand(id, command) {
|
|
16
16
|
switch (command.type) {
|
|
17
17
|
case "prompt":
|
|
18
18
|
return { id, command: "prompt", text: command.text };
|
|
@@ -27,10 +27,10 @@ function toGGCoderRpcCommand(id, command) {
|
|
|
27
27
|
case "switch_project":
|
|
28
28
|
return { id, command: "prompt", text: `Switch project to ${command.project}` };
|
|
29
29
|
case "list_projects":
|
|
30
|
-
return { id, command: "prompt", text: "List available
|
|
30
|
+
return { id, command: "prompt", text: "List available EZ Coder projects." };
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function normalizeEZCoderRpcEvent(message) {
|
|
34
34
|
if (!isJsonObject(message)) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
@@ -63,7 +63,7 @@ function normalizeGGCoderRpcEvent(message) {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function createSendToEZCoderTool(bridge) {
|
|
67
67
|
return {
|
|
68
68
|
name: "send_to_ezcoder",
|
|
69
69
|
description: "Send a prompt or control command to a running ezcoder RPC session.",
|
|
@@ -94,8 +94,8 @@ function isJsonObject(value) {
|
|
|
94
94
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95
95
|
}
|
|
96
96
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
createEZCoderRpcBridge,
|
|
98
|
+
normalizeEZCoderRpcEvent,
|
|
99
|
+
toEZCoderRpcCommand
|
|
100
100
|
};
|
|
101
101
|
//# sourceMappingURL=ezcoder-rpc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bridges/ezcoder-rpc.ts"],"sourcesContent":["import type { JsonObject, VoiceBridgeCommand, VoiceBridgeEvent, VoiceTool } from \"../types.js\";\n\nexport interface
|
|
1
|
+
{"version":3,"sources":["../../src/bridges/ezcoder-rpc.ts"],"sourcesContent":["import type { JsonObject, VoiceBridgeCommand, VoiceBridgeEvent, VoiceTool } from \"../types.js\";\n\nexport interface EZCoderRpcMessageSink {\n send(message: JsonObject, signal?: AbortSignal): Promise<void>;\n}\n\nexport interface EZCoderRpcBridgeOptions {\n readonly sink: EZCoderRpcMessageSink;\n readonly idFactory?: () => string;\n}\n\nexport interface EZCoderRpcBridge {\n send(command: VoiceBridgeCommand, signal?: AbortSignal): Promise<string>;\n toTool(): VoiceTool;\n}\n\nexport function createEZCoderRpcBridge(options: EZCoderRpcBridgeOptions): EZCoderRpcBridge {\n const idFactory = options.idFactory ?? (() => `ezcoder_${Date.now()}`);\n return {\n async send(command, signal): Promise<string> {\n const id = idFactory();\n await options.sink.send(toEZCoderRpcCommand(id, command), signal);\n return id;\n },\n toTool(): VoiceTool {\n return createSendToEZCoderTool(this);\n },\n };\n}\n\nexport function toEZCoderRpcCommand(id: string, command: VoiceBridgeCommand): JsonObject {\n switch (command.type) {\n case \"prompt\":\n return { id, command: \"prompt\", text: command.text };\n case \"cancel\":\n return { id, command: \"abort\" };\n case \"status\":\n return { id, command: \"get_state\" };\n case \"new_session\":\n return { id, command: \"new_session\" };\n case \"switch_model\":\n return { id, command: \"switch_model\", provider: command.provider, model: command.model };\n case \"switch_project\":\n return { id, command: \"prompt\", text: `Switch project to ${command.project}` };\n case \"list_projects\":\n return { id, command: \"prompt\", text: \"List available EZ Coder projects.\" };\n }\n}\n\nexport function normalizeEZCoderRpcEvent(message: unknown): VoiceBridgeEvent | null {\n if (!isJsonObject(message)) {\n return null;\n }\n const type = typeof message.type === \"string\" ? message.type : \"\";\n switch (type) {\n case \"text_delta\":\n return { type: \"text_delta\", text: stringValue(message.text) };\n case \"tool_call_start\":\n return {\n type: \"tool_start\",\n id: stringOrUndefined(message.toolCallId),\n name: stringValue(message.name),\n };\n case \"tool_call_end\":\n return {\n type: \"tool_end\",\n id: stringOrUndefined(message.toolCallId),\n name: stringValue(message.name),\n isError: message.isError === true,\n };\n case \"agent_done\":\n return { type: \"completion\" };\n case \"ready\":\n case \"session_start\":\n case \"model_change\":\n return { type: \"status\", status: message };\n case \"error\":\n return { type: \"error\", error: stringValue(message.message ?? message.error) };\n default:\n return null;\n }\n}\n\nfunction createSendToEZCoderTool(bridge: EZCoderRpcBridge): VoiceTool {\n return {\n name: \"send_to_ezcoder\",\n description: \"Send a prompt or control command to a running ezcoder RPC session.\",\n parameters: {\n type: \"object\",\n properties: {\n text: { type: \"string\", description: \"Prompt text to send to ezcoder.\" },\n },\n required: [\"text\"],\n },\n async execute(args, context) {\n const text = typeof args.text === \"string\" ? args.text : \"\";\n if (!text) {\n return { error: \"text is required\" };\n }\n const id = await bridge.send({ type: \"prompt\", text }, context.signal);\n return { status: \"sent\", id };\n },\n };\n}\n\nfunction stringValue(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"],"mappings":";AAgBO,SAAS,uBAAuB,SAAoD;AACzF,QAAM,YAAY,QAAQ,cAAc,MAAM,WAAW,KAAK,IAAI,CAAC;AACnE,SAAO;AAAA,IACL,MAAM,KAAK,SAAS,QAAyB;AAC3C,YAAM,KAAK,UAAU;AACrB,YAAM,QAAQ,KAAK,KAAK,oBAAoB,IAAI,OAAO,GAAG,MAAM;AAChE,aAAO;AAAA,IACT;AAAA,IACA,SAAoB;AAClB,aAAO,wBAAwB,IAAI;AAAA,IACrC;AAAA,EACF;AACF;AAEO,SAAS,oBAAoB,IAAY,SAAyC;AACvF,UAAQ,QAAQ,MAAM;AAAA,IACpB,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,UAAU,MAAM,QAAQ,KAAK;AAAA,IACrD,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,QAAQ;AAAA,IAChC,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,YAAY;AAAA,IACpC,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,cAAc;AAAA,IACtC,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,gBAAgB,UAAU,QAAQ,UAAU,OAAO,QAAQ,MAAM;AAAA,IACzF,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,UAAU,MAAM,qBAAqB,QAAQ,OAAO,GAAG;AAAA,IAC/E,KAAK;AACH,aAAO,EAAE,IAAI,SAAS,UAAU,MAAM,oCAAoC;AAAA,EAC9E;AACF;AAEO,SAAS,yBAAyB,SAA2C;AAClF,MAAI,CA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MAAM;AACrE,aAAO,EAAE,QAAQ,QAAQ,GAAG;AAAA,IAC9B;AAAA,EACF;AACF;AAEA,SAAS,YAAY,OAAwB;AAC3C,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AAEA,SAAS,kBAAkB,OAAoC;AAC7D,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AAEA,SAAS,aAAa,OAAqC;AACzD,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prestyj/voice",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provider-agnostic realtime voice orchestration for EZ tools and agents",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"zod": "^4.4.3",
|
|
48
|
-
"@prestyj/agent": "5.
|
|
49
|
-
"@prestyj/ai": "5.
|
|
48
|
+
"@prestyj/agent": "5.12.0",
|
|
49
|
+
"@prestyj/ai": "5.12.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "^6.0.3",
|