@peers-app/peers-sdk 0.11.2 → 0.12.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/dist/data/index.d.ts +1 -0
- package/dist/data/index.js +1 -0
- package/dist/data/messages.js +9 -4
- package/dist/data/voice-messages.d.ts +33 -0
- package/dist/data/voice-messages.js +33 -0
- package/dist/rpc-types.d.ts +4 -0
- package/dist/rpc-types.js +3 -0
- package/package.json +1 -1
package/dist/data/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from "./tools";
|
|
|
30
30
|
export * from "./users";
|
|
31
31
|
export * from "./user-permissions";
|
|
32
32
|
export * from "./user-trust-levels";
|
|
33
|
+
export * from "./voice-messages";
|
|
33
34
|
export * from "./welcome-modal.pvar";
|
|
34
35
|
export * from "./workflow-logs";
|
|
35
36
|
export * from "./workflow-runs";
|
package/dist/data/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __exportStar(require("./tools"), exports);
|
|
|
46
46
|
__exportStar(require("./users"), exports);
|
|
47
47
|
__exportStar(require("./user-permissions"), exports);
|
|
48
48
|
__exportStar(require("./user-trust-levels"), exports);
|
|
49
|
+
__exportStar(require("./voice-messages"), exports);
|
|
49
50
|
__exportStar(require("./welcome-modal.pvar"), exports);
|
|
50
51
|
__exportStar(require("./workflow-logs"), exports);
|
|
51
52
|
__exportStar(require("./workflow-runs"), exports);
|
package/dist/data/messages.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.sendMessage = sendMessage;
|
|
|
6
6
|
exports.getThreadVars = getThreadVars;
|
|
7
7
|
const types_1 = require("./orm/types");
|
|
8
8
|
const users_1 = require("./users");
|
|
9
|
+
const groups_1 = require("./groups");
|
|
9
10
|
const channels_1 = require("./channels");
|
|
10
11
|
const workflow_runs_1 = require("./workflow-runs");
|
|
11
12
|
const utils_1 = require("../utils");
|
|
@@ -59,10 +60,14 @@ async function sendMessage(args) {
|
|
|
59
60
|
else {
|
|
60
61
|
const channel = await (0, channels_1.Channels)().get(channelOrThreadIdOrWorkflowRunId);
|
|
61
62
|
if (!channel) {
|
|
62
|
-
// check if
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
65
|
-
|
|
63
|
+
// check if it's a group id (group id doubles as its default channel id)
|
|
64
|
+
const group = await (0, groups_1.Groups)().get(channelOrThreadIdOrWorkflowRunId);
|
|
65
|
+
if (!group) {
|
|
66
|
+
// check if channel is a user id
|
|
67
|
+
const user = await (0, users_1.Users)().get(channelOrThreadIdOrWorkflowRunId);
|
|
68
|
+
if (!user) {
|
|
69
|
+
throw new Error(`Channel ${channelOrThreadIdOrWorkflowRunId} not found. A channel must be a valid channelId or userId or groupId.`);
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DataContext } from '../context/data-context';
|
|
3
|
+
export declare const voiceMessageSchema: z.ZodObject<{
|
|
4
|
+
voiceMessageId: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
5
|
+
sessionId: z.ZodString;
|
|
6
|
+
role: z.ZodEnum<["user", "assistant"]>;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
content: string;
|
|
12
|
+
role: "user" | "assistant";
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
voiceMessageId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
threadId?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
content: string;
|
|
19
|
+
role: "user" | "assistant";
|
|
20
|
+
sessionId: string;
|
|
21
|
+
createdAt?: Date | undefined;
|
|
22
|
+
voiceMessageId?: string | undefined;
|
|
23
|
+
threadId?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type IVoiceMessage = z.infer<typeof voiceMessageSchema>;
|
|
26
|
+
export declare function VoiceMessages(dataContext?: DataContext): import("./orm").Table<{
|
|
27
|
+
content: string;
|
|
28
|
+
role: "user" | "assistant";
|
|
29
|
+
createdAt: Date;
|
|
30
|
+
voiceMessageId: string;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
threadId?: string | undefined;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.voiceMessageSchema = void 0;
|
|
4
|
+
exports.VoiceMessages = VoiceMessages;
|
|
5
|
+
const types_1 = require("./orm/types");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const zod_types_1 = require("../types/zod-types");
|
|
9
|
+
const user_context_singleton_1 = require("../context/user-context-singleton");
|
|
10
|
+
const table_definitions_system_1 = require("./orm/table-definitions.system");
|
|
11
|
+
exports.voiceMessageSchema = zod_1.z.object({
|
|
12
|
+
voiceMessageId: zod_types_1.zodPeerId.default(() => (0, utils_1.newid)()),
|
|
13
|
+
sessionId: zod_1.z.string().describe('Groups messages belonging to one voice session'),
|
|
14
|
+
role: zod_1.z.enum(['user', 'assistant']),
|
|
15
|
+
content: zod_1.z.string(),
|
|
16
|
+
threadId: zod_1.z.string().optional().describe('messageId of the channel thread created when an action was dispatched to the background agent'),
|
|
17
|
+
createdAt: zod_1.z.date().default(() => new Date()),
|
|
18
|
+
});
|
|
19
|
+
const metaData = {
|
|
20
|
+
name: 'VoiceMessages',
|
|
21
|
+
description: 'Voice conversation history for the self-contained voice assistant',
|
|
22
|
+
primaryKeyName: 'voiceMessageId',
|
|
23
|
+
fields: (0, types_1.schemaToFields)(exports.voiceMessageSchema),
|
|
24
|
+
localOnly: true,
|
|
25
|
+
indexes: [
|
|
26
|
+
{ fields: ['sessionId'] },
|
|
27
|
+
{ fields: ['sessionId', 'createdAt'] },
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
(0, table_definitions_system_1.registerSystemTableDefinition)(metaData, exports.voiceMessageSchema);
|
|
31
|
+
function VoiceMessages(dataContext) {
|
|
32
|
+
return (0, user_context_singleton_1.getTableContainer)(dataContext).getTable(metaData, exports.voiceMessageSchema);
|
|
33
|
+
}
|
package/dist/rpc-types.d.ts
CHANGED
|
@@ -96,9 +96,11 @@ export declare const rpcServerCalls: {
|
|
|
96
96
|
}>);
|
|
97
97
|
voiceGetState: (() => Promise<{
|
|
98
98
|
state: "disabled" | "idle" | "listening" | "recording" | "processing" | "speaking";
|
|
99
|
+
keyError?: "refused" | "invalid" | "limit" | "throttled";
|
|
99
100
|
}>);
|
|
100
101
|
voiceStartRecording: (() => Promise<void>);
|
|
101
102
|
voiceStopRecording: (() => Promise<void>);
|
|
103
|
+
voiceCancelRecording: (() => Promise<void>);
|
|
102
104
|
voiceSetTargetChannel: ((channelId: string) => Promise<void>);
|
|
103
105
|
voiceGetAudioDevices: (() => Promise<string[]>);
|
|
104
106
|
voiceTestTTS: ((text: string) => Promise<void>);
|
|
@@ -107,6 +109,8 @@ export declare const rpcServerCalls: {
|
|
|
107
109
|
voiceGetThreadId: (() => Promise<string | null>);
|
|
108
110
|
voiceSetThreadId: ((threadId: string | null) => Promise<void>);
|
|
109
111
|
voiceNotifyTextActivity: (() => Promise<void>);
|
|
112
|
+
voiceDisable: (() => Promise<void>);
|
|
113
|
+
voiceEnable: (() => Promise<void>);
|
|
110
114
|
};
|
|
111
115
|
export declare const rpcClientCalls: {
|
|
112
116
|
ping: (msg: string) => Promise<string>;
|
package/dist/rpc-types.js
CHANGED
|
@@ -45,6 +45,7 @@ exports.rpcServerCalls = {
|
|
|
45
45
|
voiceGetState: rpcStub('voiceGetState'),
|
|
46
46
|
voiceStartRecording: rpcStub('voiceStartRecording'),
|
|
47
47
|
voiceStopRecording: rpcStub('voiceStopRecording'),
|
|
48
|
+
voiceCancelRecording: rpcStub('voiceCancelRecording'),
|
|
48
49
|
voiceSetTargetChannel: rpcStub('voiceSetTargetChannel'),
|
|
49
50
|
voiceGetAudioDevices: rpcStub('voiceGetAudioDevices'),
|
|
50
51
|
voiceTestTTS: rpcStub('voiceTestTTS'),
|
|
@@ -53,6 +54,8 @@ exports.rpcServerCalls = {
|
|
|
53
54
|
voiceGetThreadId: rpcStub('voiceGetThreadId'),
|
|
54
55
|
voiceSetThreadId: rpcStub('voiceSetThreadId'),
|
|
55
56
|
voiceNotifyTextActivity: rpcStub('voiceNotifyTextActivity'),
|
|
57
|
+
voiceDisable: rpcStub('voiceDisable'),
|
|
58
|
+
voiceEnable: rpcStub('voiceEnable'),
|
|
56
59
|
// TODO try to get rid of this and rely on the client-side table and server-side table individually emitting events
|
|
57
60
|
// TODO TODO before deleting this, check if we can stop client-side tables from emitting events and rely solely on server-side tables
|
|
58
61
|
// propagating events with rpcClientCalls.emitEvent. It's very likely we're currently seeing two events for every one write originating from the UI
|