@dubeyvishal/orbital-cli 1.0.2 → 1.0.4
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 +13 -0
- package/package.json +10 -7
- package/server/{src/cli/ai → ai}/googleService.js +1 -1
- package/server/{src/cli/chat → chat}/chat-with-ai-agent.js +21 -22
- package/server/{src/cli/chat → chat}/chat-with-ai-tools.js +22 -21
- package/server/{src/cli/chat → chat}/chat-with-ai.js +21 -18
- package/server/commands/General/openApp.js +71 -0
- package/server/commands/General/playSong.js +17 -0
- package/server/commands/General/searchYoutube.js +21 -0
- package/server/{src/cli/commands → commands}/ai/wakeUp.js +19 -28
- package/server/{src/cli/commands → commands}/auth/aboutMe.js +1 -1
- package/server/{src/cli/commands → commands}/auth/login.js +1 -1
- package/server/{src/cli/commands → commands}/auth/logout.js +1 -1
- package/server/{src/cli/commands → commands}/config/setkey.js +1 -1
- package/server/config/env.js +20 -0
- package/server/generalApp/Apps.js +21 -0
- package/server/{src/cli/main.js → main.js} +11 -3
- package/server/utils/apiClient.js +40 -0
- package/server/utils/chatServiceClient.js +73 -0
- package/server/prisma/migrations/20260105143219_test_migration/migration.sql +0 -7
- package/server/prisma/migrations/20260105151026_authentication/migration.sql +0 -78
- package/server/prisma/migrations/20260114105919_add_devicecode_conversation_message/migration.sql +0 -50
- package/server/prisma/migrations/migration_lock.toml +0 -3
- package/server/prisma/schema.prisma +0 -117
- package/server/src/config/env.js +0 -100
- package/server/src/index.js +0 -102
- package/server/src/lib/auth.js +0 -37
- package/server/src/lib/db.js +0 -18
- package/server/src/lib/dbHealth.js +0 -106
- package/server/src/prisma/migrations/20260107093841_device_flow/migration.sql +0 -94
- package/server/src/prisma/migrations/migration_lock.toml +0 -3
- package/server/src/prisma/schema.prisma +0 -115
- package/server/src/service/chatService.js +0 -156
- /package/server/{src/config → config}/agentConfig.js +0 -0
- /package/server/{src/config → config}/googleConfig.js +0 -0
- /package/server/{src/config → config}/toolConfig.js +0 -0
- /package/server/{src/lib → utils}/orbitalConfig.js +0 -0
- /package/server/{src/lib → utils}/token.js +0 -0
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
-- CreateTable
|
|
2
|
-
CREATE TABLE "user" (
|
|
3
|
-
"id" TEXT NOT NULL,
|
|
4
|
-
"name" TEXT NOT NULL,
|
|
5
|
-
"email" TEXT NOT NULL,
|
|
6
|
-
"emailVerified" BOOLEAN NOT NULL DEFAULT false,
|
|
7
|
-
"image" TEXT,
|
|
8
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
10
|
-
|
|
11
|
-
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
-- CreateTable
|
|
15
|
-
CREATE TABLE "session" (
|
|
16
|
-
"id" TEXT NOT NULL,
|
|
17
|
-
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
18
|
-
"token" TEXT NOT NULL,
|
|
19
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
20
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
21
|
-
"ipAddress" TEXT,
|
|
22
|
-
"userAgent" TEXT,
|
|
23
|
-
"userId" TEXT NOT NULL,
|
|
24
|
-
|
|
25
|
-
CONSTRAINT "session_pkey" PRIMARY KEY ("id")
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
-- CreateTable
|
|
29
|
-
CREATE TABLE "account" (
|
|
30
|
-
"id" TEXT NOT NULL,
|
|
31
|
-
"accountId" TEXT NOT NULL,
|
|
32
|
-
"providerId" TEXT NOT NULL,
|
|
33
|
-
"userId" TEXT NOT NULL,
|
|
34
|
-
"accessToken" TEXT,
|
|
35
|
-
"refreshToken" TEXT,
|
|
36
|
-
"idToken" TEXT,
|
|
37
|
-
"accessTokenExpiresAt" TIMESTAMP(3),
|
|
38
|
-
"refreshTokenExpiresAt" TIMESTAMP(3),
|
|
39
|
-
"scope" TEXT,
|
|
40
|
-
"password" TEXT,
|
|
41
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
43
|
-
|
|
44
|
-
CONSTRAINT "account_pkey" PRIMARY KEY ("id")
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
-- CreateTable
|
|
48
|
-
CREATE TABLE "verification" (
|
|
49
|
-
"id" TEXT NOT NULL,
|
|
50
|
-
"identifier" TEXT NOT NULL,
|
|
51
|
-
"value" TEXT NOT NULL,
|
|
52
|
-
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
53
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
54
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
55
|
-
|
|
56
|
-
CONSTRAINT "verification_pkey" PRIMARY KEY ("id")
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
-- CreateTable
|
|
60
|
-
CREATE TABLE "deviceCode" (
|
|
61
|
-
"id" TEXT NOT NULL,
|
|
62
|
-
"deviceCode" TEXT NOT NULL,
|
|
63
|
-
"userCode" TEXT NOT NULL,
|
|
64
|
-
"userId" TEXT,
|
|
65
|
-
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
66
|
-
"status" TEXT NOT NULL,
|
|
67
|
-
"lastPolledAt" TIMESTAMP(3),
|
|
68
|
-
"pollingInterval" INTEGER,
|
|
69
|
-
"clientId" TEXT,
|
|
70
|
-
"scope" TEXT,
|
|
71
|
-
|
|
72
|
-
CONSTRAINT "deviceCode_pkey" PRIMARY KEY ("id")
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
-- CreateIndex
|
|
76
|
-
CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
|
|
77
|
-
|
|
78
|
-
-- CreateIndex
|
|
79
|
-
CREATE INDEX "session_userId_idx" ON "session"("userId");
|
|
80
|
-
|
|
81
|
-
-- CreateIndex
|
|
82
|
-
CREATE UNIQUE INDEX "session_token_key" ON "session"("token");
|
|
83
|
-
|
|
84
|
-
-- CreateIndex
|
|
85
|
-
CREATE INDEX "account_userId_idx" ON "account"("userId");
|
|
86
|
-
|
|
87
|
-
-- CreateIndex
|
|
88
|
-
CREATE INDEX "verification_identifier_idx" ON "verification"("identifier");
|
|
89
|
-
|
|
90
|
-
-- AddForeignKey
|
|
91
|
-
ALTER TABLE "session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
92
|
-
|
|
93
|
-
-- AddForeignKey
|
|
94
|
-
ALTER TABLE "account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
generator client {
|
|
3
|
-
provider = "prisma-client-js"
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
datasource db {
|
|
7
|
-
provider = "postgresql"
|
|
8
|
-
url = env("DATABASE_URL")
|
|
9
|
-
directUrl = env("DIRECT_DATABASE_URL")
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
model User {
|
|
13
|
-
id String @id
|
|
14
|
-
name String
|
|
15
|
-
email String
|
|
16
|
-
emailVerified Boolean @default(false)
|
|
17
|
-
image String?
|
|
18
|
-
createdAt DateTime @default(now())
|
|
19
|
-
updatedAt DateTime @updatedAt
|
|
20
|
-
sessions Session[]
|
|
21
|
-
accounts Account[]
|
|
22
|
-
|
|
23
|
-
conversation Conversation
|
|
24
|
-
|
|
25
|
-
@@unique([email])
|
|
26
|
-
@@map("user")
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
model Session {
|
|
30
|
-
id String @id
|
|
31
|
-
expiresAt DateTime
|
|
32
|
-
token String
|
|
33
|
-
createdAt DateTime @default(now())
|
|
34
|
-
updatedAt DateTime @updatedAt
|
|
35
|
-
ipAddress String?
|
|
36
|
-
userAgent String?
|
|
37
|
-
userId String
|
|
38
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
39
|
-
|
|
40
|
-
@@unique([token])
|
|
41
|
-
@@index([userId])
|
|
42
|
-
@@map("session")
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
model Account {
|
|
46
|
-
id String @id
|
|
47
|
-
accountId String
|
|
48
|
-
providerId String
|
|
49
|
-
userId String
|
|
50
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
51
|
-
accessToken String?
|
|
52
|
-
refreshToken String?
|
|
53
|
-
idToken String?
|
|
54
|
-
accessTokenExpiresAt DateTime?
|
|
55
|
-
refreshTokenExpiresAt DateTime?
|
|
56
|
-
scope String?
|
|
57
|
-
password String?
|
|
58
|
-
createdAt DateTime @default(now())
|
|
59
|
-
updatedAt DateTime @updatedAt
|
|
60
|
-
|
|
61
|
-
@@index([userId])
|
|
62
|
-
@@map("account")
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
model Verification {
|
|
66
|
-
id String @id
|
|
67
|
-
identifier String
|
|
68
|
-
value String
|
|
69
|
-
expiresAt DateTime
|
|
70
|
-
createdAt DateTime @default(now())
|
|
71
|
-
updatedAt DateTime @updatedAt
|
|
72
|
-
|
|
73
|
-
@@index([identifier])
|
|
74
|
-
@@map("verification")
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
model DeviceCode {
|
|
78
|
-
id String @id
|
|
79
|
-
deviceCode String
|
|
80
|
-
userCode String
|
|
81
|
-
userId String?
|
|
82
|
-
expiresAt DateTime
|
|
83
|
-
status String
|
|
84
|
-
lastPolledAt DateTime?
|
|
85
|
-
pollingInterval Int?
|
|
86
|
-
clientId String?
|
|
87
|
-
scope String?
|
|
88
|
-
|
|
89
|
-
@@map("deviceCode")
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
model Conversation {
|
|
93
|
-
id String @id @default(cuid())
|
|
94
|
-
userId String
|
|
95
|
-
title String
|
|
96
|
-
mode String @default("chat")
|
|
97
|
-
createdAt DateTime @default(now())
|
|
98
|
-
updatedAt DateTime @default(now()) @updatedAt
|
|
99
|
-
|
|
100
|
-
user User @relation(fields: [userId] , references : [id] , onDelete : Cascade)
|
|
101
|
-
messages Message[]
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
model Message{
|
|
105
|
-
id String @id @default(cuid())
|
|
106
|
-
conversationId String
|
|
107
|
-
role String
|
|
108
|
-
content String
|
|
109
|
-
createdAt DateTime() @default(now())
|
|
110
|
-
|
|
111
|
-
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
@@index([conversationId])
|
|
115
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import prisma from "../lib/db.js";
|
|
2
|
-
|
|
3
|
-
export class ChatService{
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create a new conversation
|
|
7
|
-
* @param {string} userId - user id
|
|
8
|
-
* @param {string} mode - chat tool , or agent
|
|
9
|
-
* @param {string} title - Optional conversation title
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
async createConversation(userId , mode ="chat" , title=null){
|
|
13
|
-
return prisma.conversation.create({
|
|
14
|
-
data : {
|
|
15
|
-
userId ,
|
|
16
|
-
mode ,
|
|
17
|
-
title : title || `New ${mode} conversation`
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* get or create a new conversation for user
|
|
24
|
-
* @param {string} userId - user id
|
|
25
|
-
* @param {string} conversationalId - Optional conversation id
|
|
26
|
-
* @param {string} mode - chat , tool or agent
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
async getOrCreateConversation(userId , conversationId =null , mode="chat"){
|
|
30
|
-
if(conversationId){
|
|
31
|
-
const conversation = await prisma.conversation.findFirst({
|
|
32
|
-
where : {
|
|
33
|
-
id: conversationId ,
|
|
34
|
-
userId
|
|
35
|
-
},
|
|
36
|
-
include : {
|
|
37
|
-
messages : {
|
|
38
|
-
orderBy :{
|
|
39
|
-
createdAt : "asc"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if(conversation){
|
|
46
|
-
return conversation ;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return await this.createConversation(userId , mode)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Add a new message to conversation
|
|
54
|
-
* @param {string} conversationalId - conversation id
|
|
55
|
-
* @param {string} role - user , assistant , system ,tool
|
|
56
|
-
* @param {string | object} content - message content
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
async addMessage(conversationId , role , content){
|
|
60
|
-
|
|
61
|
-
const contentStr = typeof content === "string" ? content :
|
|
62
|
-
JSON.stringify(content);
|
|
63
|
-
|
|
64
|
-
return await prisma.message.create({
|
|
65
|
-
data :{
|
|
66
|
-
conversationId ,
|
|
67
|
-
role ,
|
|
68
|
-
content : contentStr
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get conversion messages
|
|
75
|
-
* @param {string} conversationId - conversational -id
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
async getMessages(conversationId){
|
|
79
|
-
const messages = await prisma.message.findMany({
|
|
80
|
-
where : {conversationId},
|
|
81
|
-
orderBy : {createdAt : "asc"}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
return messages.map((msg) => ({
|
|
85
|
-
...msg,
|
|
86
|
-
content: this.parseContent(msg.content),
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @param {string} userI - user id
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
async getUserConversation(userId){
|
|
95
|
-
return await prisma.conversation.findMany({
|
|
96
|
-
where : {userId} ,
|
|
97
|
-
orderBy :{updatedAt : "desc"},
|
|
98
|
-
include :{
|
|
99
|
-
messages : {
|
|
100
|
-
take : 1,
|
|
101
|
-
orderBy : {createdAt : "desc"}
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @param {string} conversationId - Conversation ID
|
|
109
|
-
* @param {string} userId - User ID
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
async deleteConversation(conversationId , userId){
|
|
113
|
-
return await prisma.conversation.deleteMany({
|
|
114
|
-
where : {
|
|
115
|
-
id : conversationId ,
|
|
116
|
-
userId
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} conversationId - Conversation ID
|
|
123
|
-
* @param {string} title - User ID
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
async updateTitle(conversationId , title){
|
|
127
|
-
return await prisma.conversation.update({
|
|
128
|
-
where : {id : conversationId},
|
|
129
|
-
data : {title}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Helper to parse content ( json to string)
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
parseContent(content){
|
|
138
|
-
try{
|
|
139
|
-
return JSON.parse(content);
|
|
140
|
-
}
|
|
141
|
-
catch{
|
|
142
|
-
return content
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @param {Array} messages - database messages
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
formatMessageForAI(messages){
|
|
151
|
-
return messages.map((msg)=>({
|
|
152
|
-
role : msg.role ,
|
|
153
|
-
content : typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content),
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|