Assistant Pencarian Dengan Tenaga Ai
No comments yet. Be the first to comment!
1/**
2 * AI DeepSearch
3 * Author : Gienetic
4 * Base : https://play.google.com/store/apps/details?id=in.dealempire.deepsearch
5 * Jenis Apk : Flutter
6 * Note : Kuki dah bikin ambil otomatis, ada fitur model lain, tapi untuk skrepan gratisan ini sudah cukup lah wkwkw,
7 */
8
9
10const axios = require('axios');
11
12const InfoTarget = {
13 host: "getliner.com",
14 user_agent: "Gienetic_sniff/4.11.0"
15};
16
17const buatHeader = (kue = null) => {
18 const headers = {
19 "user-agent": InfoTarget.user_agent,
20 "x-liner-platform-type": "app",
21 "accept": "application/json, text/plain, */*",
22 "accept-encoding": "gzip",
23 "content-type": "application/json; charset=utf-8",
24 "host": InfoTarget.host,
25 "connection": "Keep-Alive"
26 };
27 if (kue) headers["cookie"] = kue;
28 return headers;
29};
30
31async function cetakIdentitas() {
32 try {
33 const resp = await axios.post(`https://${InfoTarget.host}/auth/guest`, {}, {
34 headers: buatHeader()
35 });
36
37 const rawCookie = resp.headers['set-cookie'];
38 const kueMatang = rawCookie ? rawCookie.map(c => c.split(';')[0]).join('; ') : "";
39
40 return {
41 sukses: true,
42 uid: resp.data.id,
43 kue: kueMatang
44 };
45 } catch (e) {
46 return { sukses: false };
47 }
48}
49
50async function bangunBrankas(identitas) {
51 try {
52 const material = {
53 "name": "General",
54 "color": "#50555C",
55 "icon": "folder"
56 };
57 const resp = await axios.post(`https://${InfoTarget.host}/v1/space`, material, {
58 headers: buatHeader(identitas.kue)
59 });
60 return resp.data.id;
61 } catch (e) {
62 return null;
63 }
64}
65
66async function cariRuangBrankas(identitas) {
67 try {
68 const resp = await axios.get(`https://${InfoTarget.host}/v1/spaces?page=1&limit=5`, {
69 headers: buatHeader(identitas.kue)
70 });
71
72 if (resp.data.items && resp.data.items.length > 0) {
73 return resp.data.items[0].id;
74 } else {
75 return await bangunBrankas(identitas);
76 }
77 } catch (e) {
78 return await bangunBrankas(identitas);
79 }
80}
81
82async function retasPintu(identitas, vaultId, misi) {
83 const payload = {
84 "userId": identitas.uid,
85 "metadata": null,
86 "messagePieces": [{ "type": "text", "content": { "text": misi } }],
87 "attachments": [],
88 "mode": "general",
89 "deviceType": "android"
90 };
91
92 try {
93 const resp = await axios.post(`https://${InfoTarget.host}/v1/space/${vaultId}/thread`, payload, {
94 headers: buatHeader(identitas.kue)
95 });
96 return {
97 id: resp.data.id,
98 msgId: resp.data.messageId
99 };
100 } catch (e) {
101 return null;
102 }
103}
104
105async function sikatData(identitas, vaultId, akses, misi) {
106 const payload = {
107 "spaceId": vaultId,
108 "threadId": akses.id,
109 "userMessageId": akses.msgId,
110 "userId": identitas.uid,
111 "query": misi,
112 "agentId": "researcher",
113 "platform": "app",
114 "regenerate": false,
115 "modelType": "liner-pro",
116 "showReferenceChunks": true,
117 "mode": "general"
118 };
119
120 try {
121 const stream = await axios.post(`https://${InfoTarget.host}/platform/copilot/v3/answer`, payload, {
122 headers: buatHeader(identitas.kue),
123 responseType: 'stream'
124 });
125
126 return new Promise((resolve) => {
127 let hasil = "";
128 let buffer = "";
129
130 stream.data.on('data', (chunk) => {
131 buffer += chunk.toString();
132 const lines = buffer.split('\n');
133 buffer = lines.pop();
134
135 for (const line of lines) {
136 if (line.trim()) {
137 try {
138 const json = JSON.parse(line);
139 if (json.answer) hasil += json.answer;
140 } catch (e) {}
141 }
142 }
143 });
144
145 stream.data.on('end', () => {
146 resolve({
147 author: "gienetic",
148 status: "success",
149 code: 200,
150 target: misi,
151 data: hasil
152 });
153 });
154
155 stream.data.on('error', (err) => {
156 resolve({ status: "failed", code: 500, error: err.message });
157 });
158 });
159
160 } catch (e) {
161 return { status: "error", code: 503, error: e.message };
162 }
163}
164
165// RUN
166(async () => {
167 const misi = "Siapakah Ayogi Akbar Afrenggo Itu ?";
168
169 const agen = await cetakIdentitas();
170
171 if (agen.sukses) {
172 const vaultId = await cariRuangBrankas(agen);
173
174 if (vaultId) {
175 const akses = await retasPintu(agen, vaultId, misi);
176
177 if (akses) {
178 const hasil = await sikatData(agen, vaultId, akses, misi);
179 console.log(JSON.stringify(hasil, null, 4));
180 } else {
181 console.log(JSON.stringify({ status: "failed", msg: "Thread creation failed" }, null, 4));
182 }
183 } else {
184 console.log(JSON.stringify({ status: "failed", msg: "Failed to create/find Vault" }, null, 4));
185 }
186 } else {
187 console.log(JSON.stringify({ status: "failed", msg: "Guest auth failed" }, null, 4));
188 }
189})();