specific-ai-cli 0.0.0-stage → 0.1.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 +21 -0
- package/README.en.md +177 -0
- package/README.ja.md +177 -0
- package/README.ko.md +177 -0
- package/README.md +174 -2
- package/README.zh-TW.md +177 -0
- package/assets/banner.txt +3 -0
- package/dist/cli/argv.js +98 -0
- package/dist/cli/commands/auth.js +11 -0
- package/dist/cli/commands/config.js +23 -0
- package/dist/cli/commands/doctor.js +134 -0
- package/dist/cli/commands/platforms.js +24 -0
- package/dist/cli/commands/version.js +4 -0
- package/dist/cli/confirm.js +22 -0
- package/dist/cli/dispatch.js +440 -0
- package/dist/cli/help.js +223 -0
- package/dist/cli/hints.js +60 -0
- package/dist/cli/main.js +18 -0
- package/dist/cli/output.js +66 -0
- package/dist/core/auth-handlers.js +41 -0
- package/dist/core/auth-store.js +119 -0
- package/dist/core/capabilities.js +163 -0
- package/dist/core/config.js +121 -0
- package/dist/core/cookies.js +164 -0
- package/dist/core/errors.js +37 -0
- package/dist/core/files.js +89 -0
- package/dist/core/fsutil.js +52 -0
- package/dist/core/hash.js +4 -0
- package/dist/core/http.js +331 -0
- package/dist/core/image.js +280 -0
- package/dist/core/log.js +40 -0
- package/dist/core/login.js +191 -0
- package/dist/core/mp4.js +130 -0
- package/dist/core/normalize.js +207 -0
- package/dist/core/options.js +110 -0
- package/dist/core/paths.js +38 -0
- package/dist/core/pb.js +59 -0
- package/dist/core/py.js +181 -0
- package/dist/core/rand.js +131 -0
- package/dist/core/registry.js +129 -0
- package/dist/core/schemas.js +41 -0
- package/dist/core/stream.js +104 -0
- package/dist/core/toolkit.js +35 -0
- package/dist/core/vm.js +73 -0
- package/dist/core/vocab.js +157 -0
- package/dist/platforms/_shared/impaas.js +410 -0
- package/dist/platforms/bilibili/index.js +216 -0
- package/dist/platforms/bilibili/web/api.js +806 -0
- package/dist/platforms/bilibili/web/client.js +311 -0
- package/dist/platforms/bilibili/web/commands.js +783 -0
- package/dist/platforms/bilibili/web/ddddocr.js +342 -0
- package/dist/platforms/bilibili/web/gaia.js +130 -0
- package/dist/platforms/bilibili/web/geetest-manual.js +154 -0
- package/dist/platforms/bilibili/web/geetest-vision.js +232 -0
- package/dist/platforms/bilibili/web/geetest.js +450 -0
- package/dist/platforms/bilibili/web/normalize.js +234 -0
- package/dist/platforms/bilibili/web/profile.js +135 -0
- package/dist/platforms/bilibili/web/resolve.js +112 -0
- package/dist/platforms/bilibili/web/sign.js +223 -0
- package/dist/platforms/bilibili/web/upos.js +102 -0
- package/dist/platforms/douyin/index.js +142 -0
- package/dist/platforms/douyin/web/api.js +863 -0
- package/dist/platforms/douyin/web/client.js +413 -0
- package/dist/platforms/douyin/web/commands.js +712 -0
- package/dist/platforms/douyin/web/creator.js +601 -0
- package/dist/platforms/douyin/web/crypto.js +247 -0
- package/dist/platforms/douyin/web/dtrait.js +190 -0
- package/dist/platforms/douyin/web/im.js +502 -0
- package/dist/platforms/douyin/web/image.js +5 -0
- package/dist/platforms/douyin/web/live.js +225 -0
- package/dist/platforms/douyin/web/mssdk.js +148 -0
- package/dist/platforms/douyin/web/normalize.js +326 -0
- package/dist/platforms/douyin/web/passport.js +1247 -0
- package/dist/platforms/douyin/web/profile.js +221 -0
- package/dist/platforms/douyin/web/proto.js +26 -0
- package/dist/platforms/douyin/web/resolve.js +88 -0
- package/dist/platforms/douyin/web/sign.js +436 -0
- package/dist/platforms/douyin/web/tos.js +78 -0
- package/dist/platforms/index.js +17 -0
- package/dist/platforms/jd/index.js +67 -0
- package/dist/platforms/jd/web/aks.js +115 -0
- package/dist/platforms/jd/web/api.js +549 -0
- package/dist/platforms/jd/web/chat.js +132 -0
- package/dist/platforms/jd/web/client.js +470 -0
- package/dist/platforms/jd/web/commands.js +557 -0
- package/dist/platforms/jd/web/jcap/helper.js +90 -0
- package/dist/platforms/jd/web/jcap/host.js +107 -0
- package/dist/platforms/jd/web/jcap/lsd.js +300 -0
- package/dist/platforms/jd/web/jcap/solver.js +995 -0
- package/dist/platforms/jd/web/jcap.js +150 -0
- package/dist/platforms/jd/web/js.js +420 -0
- package/dist/platforms/jd/web/login.js +775 -0
- package/dist/platforms/jd/web/normalize.js +297 -0
- package/dist/platforms/jd/web/profile.js +256 -0
- package/dist/platforms/jd/web/util.js +175 -0
- package/dist/platforms/jd/web/webm.js +133 -0
- package/dist/platforms/kuaishou/index.js +98 -0
- package/dist/platforms/kuaishou/web/api.js +694 -0
- package/dist/platforms/kuaishou/web/captcha-crypto.js +134 -0
- package/dist/platforms/kuaishou/web/captcha-fp.js +180 -0
- package/dist/platforms/kuaishou/web/captcha.js +273 -0
- package/dist/platforms/kuaishou/web/client.js +487 -0
- package/dist/platforms/kuaishou/web/commands.js +863 -0
- package/dist/platforms/kuaishou/web/gap.js +144 -0
- package/dist/platforms/kuaishou/web/gdfp.js +376 -0
- package/dist/platforms/kuaishou/web/gql.js +11 -0
- package/dist/platforms/kuaishou/web/live.js +125 -0
- package/dist/platforms/kuaishou/web/normalize.js +241 -0
- package/dist/platforms/kuaishou/web/oracle.js +329 -0
- package/dist/platforms/kuaishou/web/profile.js +259 -0
- package/dist/platforms/kuaishou/web/resolve.js +84 -0
- package/dist/platforms/kuaishou/web/session.js +592 -0
- package/dist/platforms/kuaishou/web/sign.js +568 -0
- package/dist/platforms/taobao/index.js +56 -0
- package/dist/platforms/taobao/web/api.js +96 -0
- package/dist/platforms/taobao/web/client.js +102 -0
- package/dist/platforms/taobao/web/commands.js +172 -0
- package/dist/platforms/taobao/web/im.js +68 -0
- package/dist/platforms/taobao/web/normalize.js +103 -0
- package/dist/platforms/taobao/web/profile.js +85 -0
- package/dist/platforms/taobao/web/resolve.js +51 -0
- package/dist/platforms/taobao/web/sign.js +35 -0
- package/dist/platforms/tiktok/index.js +120 -0
- package/dist/platforms/tiktok/web/api.js +1234 -0
- package/dist/platforms/tiktok/web/client.js +362 -0
- package/dist/platforms/tiktok/web/commands.js +821 -0
- package/dist/platforms/tiktok/web/im.js +133 -0
- package/dist/platforms/tiktok/web/jsrun.js +126 -0
- package/dist/platforms/tiktok/web/normalize.js +286 -0
- package/dist/platforms/tiktok/web/profile.js +169 -0
- package/dist/platforms/tiktok/web/resolve.js +156 -0
- package/dist/platforms/tiktok/web/sign.js +585 -0
- package/dist/platforms/tiktok/web/upload.js +805 -0
- package/dist/platforms/tiktok/web/wire.js +490 -0
- package/dist/platforms/weibo/index.js +91 -0
- package/dist/platforms/weibo/web/api.js +206 -0
- package/dist/platforms/weibo/web/client.js +155 -0
- package/dist/platforms/weibo/web/commands.js +202 -0
- package/dist/platforms/weibo/web/normalize.js +137 -0
- package/dist/platforms/weibo/web/profile.js +246 -0
- package/dist/platforms/weibo/web/resolve.js +60 -0
- package/dist/platforms/weibo/web/sign.js +85 -0
- package/dist/platforms/x/index.js +107 -0
- package/dist/platforms/x/web/api.js +443 -0
- package/dist/platforms/x/web/article.js +212 -0
- package/dist/platforms/x/web/client.js +202 -0
- package/dist/platforms/x/web/commands.js +363 -0
- package/dist/platforms/x/web/graphql.js +108 -0
- package/dist/platforms/x/web/normalize.js +235 -0
- package/dist/platforms/x/web/profile.js +99 -0
- package/dist/platforms/x/web/resolve.js +44 -0
- package/dist/platforms/x/web/transaction.js +171 -0
- package/dist/platforms/xhs/index.js +101 -0
- package/dist/platforms/xhs/web/api.js +278 -0
- package/dist/platforms/xhs/web/client.js +540 -0
- package/dist/platforms/xhs/web/commands.js +1046 -0
- package/dist/platforms/xhs/web/creator-api.js +609 -0
- package/dist/platforms/xhs/web/creator.js +203 -0
- package/dist/platforms/xhs/web/js.js +194 -0
- package/dist/platforms/xhs/web/login.js +230 -0
- package/dist/platforms/xhs/web/normalize.js +166 -0
- package/dist/platforms/xhs/web/profile.js +127 -0
- package/dist/platforms/xhs/web/push.js +361 -0
- package/dist/platforms/xhs/web/resolve.js +69 -0
- package/dist/platforms/xhs/web/state.js +368 -0
- package/dist/platforms/xianyu/index.js +59 -0
- package/dist/platforms/xianyu/web/api.js +312 -0
- package/dist/platforms/xianyu/web/client.js +134 -0
- package/dist/platforms/xianyu/web/commands.js +305 -0
- package/dist/platforms/xianyu/web/im.js +73 -0
- package/dist/platforms/xianyu/web/normalize.js +123 -0
- package/dist/platforms/xianyu/web/profile.js +146 -0
- package/dist/platforms/xianyu/web/resolve.js +48 -0
- package/dist/platforms/xianyu/web/sign.js +79 -0
- package/package.json +77 -4
- package/static/douyin/Live.proto +194 -0
- package/static/douyin/Request.proto +89 -0
- package/static/douyin/Response.proto +46 -0
- package/static/douyin/acrawler_runtime/ac_vm.js +2 -0
- package/static/douyin/acrawler_runtime/browser_window_shape.json +1 -0
- package/static/douyin/acrawler_runtime/canvas_actual_exact.json +1 -0
- package/static/douyin/acrawler_runtime/run_ac_node.js +1005 -0
- package/static/douyin/acrawler_runtime/runner_window_keys_baseline.txt +240 -0
- package/static/douyin/challenge_profile.json +801 -0
- package/static/douyin/challenge_template_runner.js +217 -0
- package/static/douyin/dtrait_profile.json +66 -0
- package/static/douyin/mstoken_common_profile.json +1 -0
- package/static/douyin/mstoken_profile.json +214 -0
- package/static/jd/h5st5_env.js +750 -0
- package/static/jd/h5st5_lib.js +5 -0
- package/static/jd/h5st5_server.js +49 -0
- package/static/jd/jcap/env/env_core.js +512 -0
- package/static/jd/jcap/env/run.js +1307 -0
- package/static/jd/jcap/run/jcap_ujb96b.js +39 -0
- package/static/jd/package.json +4 -0
- package/static/jd/pc_tk_lib.js +1 -0
- package/static/jd/pc_tk_server.js +63 -0
- package/static/jd/summer_cryptico_runner.js +50 -0
- package/static/jd/webm/env/run.js +453 -0
- package/static/jd/webm/run/jdwebm-riskhandle.js +49 -0
- package/static/kuaishou/bundles/weapon/kwf-0.0.2.2cee19b4b7dec496.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-0-0.0.1-obfuscated.4b7f3de1ab0ddcc2.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-1-0.0.1-obfuscated.346ebdb1c78df316.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-10-0.0.1-obfuscated.a33db41897b983af.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-11-0.0.1-obfuscated.5e0a90af726d8a7e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-12-0.0.1-obfuscated.20ea29345706ec8c.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-13-0.0.1-obfuscated.6b74e9640ff18648.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-14-0.0.1-obfuscated.551e4429d156bf66.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-15-0.0.1-obfuscated.8625b087aaba4a60.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-16-0.0.1-obfuscated.d5ffa4020f3be99a.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-17-0.0.1-obfuscated.6d13e19b22f50a80.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-18-0.0.1-obfuscated.6d31405044166289.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-19-0.0.1-obfuscated.a9a8d925942f19e4.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-2-0.0.1-obfuscated.b849a136ae4a6b3e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-3-0.0.1-obfuscated.f9e77ebf6186e2ac.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-4-0.0.1-obfuscated.2c3c155aa52ceb0e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-5-0.0.1-obfuscated.4e553d17691b3c5a.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-6-0.0.1-obfuscated.f73ddd3ff13e1217.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-7-0.0.1-obfuscated.1628b8729beaab7e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-8-0.0.1-obfuscated.6da6baef7aa81fff.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-9-0.0.1-obfuscated.8645d55e5323b743.js +1 -0
- package/static/kuaishou/fixtures/current_follow_script_813.network-response +2 -0
- package/static/kuaishou/fixtures/live_ws_maps.json +61 -0
- package/static/kuaishou/fixtures/live_ws_proto.json +1342 -0
- package/static/kuaishou/js/cp-kwf.js +1 -0
- package/static/kuaishou/tools/kwf_oracle.js +799 -0
- package/static/kuaishou/tools/kws_oracle.js +885 -0
- package/static/kuaishou/tools/like_token_oracle.js +70 -0
- package/static/taobao/taobao_js_20260407.js +570 -0
- package/static/tiktok/Tiktok_Request.json +597 -0
- package/static/tiktok/package.json +3 -0
- package/static/tiktok/shop_bsid/core.js +1 -0
- package/static/tiktok/shop_bsid/env_core.js +512 -0
- package/static/tiktok/shop_bsid/loader.js +1 -0
- package/static/tiktok/shop_bsid/run.js +753 -0
- package/static/tiktok/shop_bsid/sign.js +100 -0
- package/static/tiktok/shop_bsid/webmssdk.js +1 -0
- package/static/tiktok/shop_bsid/webmssdk_ex.js +1 -0
- package/static/tiktok/signing/env/env_core.js +512 -0
- package/static/tiktok/signing/env/sign.js +455 -0
- package/static/tiktok/signing/sdk_config.json +230 -0
- package/static/tiktok/signing/source/webmssdk.js +1 -0
- package/static/tiktok/signing/source/webmssdk_ex.js +1 -0
- package/static/tiktok/signing/source/webmssdk_legacy.js +1 -0
- package/static/x/graphql.json +7777 -0
- package/static/x/transaction_l1.json +12 -0
- package/static/xhs/package.json +3 -0
- package/static/xhs/xhs_core/js/b1.js +210 -0
- package/static/xhs/xhs_core/js/mns.js +340 -0
- package/static/xhs/xhs_core/js/mns_0101_keystream.json +5 -0
- package/static/xhs/xhs_core/js/mns_keystreams.json +1 -0
- package/static/xhs/xhs_core/js/sign.js +225 -0
- package/static/xhs/xhs_core/js/websectiga_cli.js +220 -0
- package/static/xhs/xhs_core/js/websectiga_env.js +512 -0
- package/static/xhs/xhs_core/js/xs_common.js +79 -0
- package/static/xhs/xhs_creator/js/profile.js +115 -0
- package/static/xhs/xhs_creator/js/rap_fingerprint_creator.json +6 -0
- package/static/xhs/xhs_creator/js/reference_profile.json +282 -0
- package/static/xhs/xhs_creator/js/xhs_creator_sign.js +29 -0
- package/static/xhs/xhs_creator/js/xhs_creator_signature.js +23 -0
- package/static/xhs/xhs_pc/js/aes_decrypt.js +22 -0
- package/static/xhs/xhs_pc/js/aes_encrypt.js +30 -0
- package/static/xhs/xhs_pc/js/b1.js +9 -0
- package/static/xhs/xhs_pc/js/deflate.js +320 -0
- package/static/xhs/xhs_pc/js/mns.js +4 -0
- package/static/xhs/xhs_pc/js/profile.js +141 -0
- package/static/xhs/xhs_pc/js/rap.js +173 -0
- package/static/xhs/xhs_pc/js/rap_cli.js +30 -0
- package/static/xhs/xhs_pc/js/rap_crypto.js +73 -0
- package/static/xhs/xhs_pc/js/rap_fingerprint_template.json +8 -0
- package/static/xhs/xhs_pc/js/reference_profile.json +262 -0
- package/static/xhs/xhs_pc/js/sign.js +6 -0
- package/static/xhs/xhs_pc/js/web_ssk.js +82 -0
- package/static/xhs/xhs_pc/js/xs_common.js +4 -0
- package/static/xianyu/et_f.js +2 -0
- package/static/xianyu/gen_tfstk.js +410 -0
- package/static/xianyu/goofish_js_version_2.js +568 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SpecificAIError } from '../../../core/errors.js';
|
|
2
|
+
/** 参数归一化(AGENTS 4.8):商品 ID、商品链接、分享短链、分享口令文本;用户 ID、主页链接;会话 ID。 */
|
|
3
|
+
const URL_RE = /https?:\/\/[^\s"'<>,。「」【】]+/;
|
|
4
|
+
const ID_PARAM_RE = /[?&#](?:id|itemId|item_id)=(\d+)/;
|
|
5
|
+
const USER_PARAM_RE = /[?&#](?:userId|userid|user_id)=(\d+)/;
|
|
6
|
+
const itemFrom = (s) => ID_PARAM_RE.exec(s)?.[1];
|
|
7
|
+
const userFrom = (s) => USER_PARAM_RE.exec(s)?.[1];
|
|
8
|
+
/** 分享短链(m.tb.cn 等):跟一次跳转取 Location;没有跳转时从页面里找。 */
|
|
9
|
+
async function expand(x, url, pick, fromPage = pick) {
|
|
10
|
+
const res = await x.http.request({ url, redirect: 'manual', cookies: false, headers: [['user-agent', 'Mozilla/5.0']] });
|
|
11
|
+
const location = res.headers.get('location');
|
|
12
|
+
if (location)
|
|
13
|
+
return pick(location) ?? (location !== url && /^https?:/.test(location) ? expand(x, location, pick, fromPage) : undefined);
|
|
14
|
+
return fromPage((await res.text()).replaceAll('&', '&'));
|
|
15
|
+
}
|
|
16
|
+
/** 闲置商品:纯数字 ID、商品页 URL(`?id=`)、分享短链,或整段分享文本。 */
|
|
17
|
+
export async function resolveItem(x, input) {
|
|
18
|
+
const s = input.trim();
|
|
19
|
+
if (/^\d+$/.test(s))
|
|
20
|
+
return s;
|
|
21
|
+
const url = URL_RE.exec(s)?.[0];
|
|
22
|
+
const fromPage = (body) => itemFrom(body) ?? /["']itemId["']\s*[:=]\s*["']?(\d+)/.exec(body)?.[1];
|
|
23
|
+
const id = url ? (itemFrom(url) ?? (await expand(x, url, itemFrom, fromPage))) : undefined;
|
|
24
|
+
if (id)
|
|
25
|
+
return id;
|
|
26
|
+
throw new SpecificAIError('USAGE', `无法识别的闲鱼商品:${input}`, { hint: '传商品 ID、商品链接 https://www.goofish.com/item?id=<id>,或分享链接' });
|
|
27
|
+
}
|
|
28
|
+
/** 用户:`me`、纯数字 ID(可带 `@goofish`)、主页链接(`personal?userId=`)、分享短链,或整段分享文本。 */
|
|
29
|
+
export async function resolveUser(x, input) {
|
|
30
|
+
const s = input.trim();
|
|
31
|
+
if (s === 'me')
|
|
32
|
+
return x.myId;
|
|
33
|
+
const m = /^(\d+)(?:@goofish)?$/.exec(s);
|
|
34
|
+
if (m)
|
|
35
|
+
return m[1];
|
|
36
|
+
const url = URL_RE.exec(s)?.[0];
|
|
37
|
+
const id = url ? (userFrom(url) ?? (await expand(x, url, userFrom))) : undefined;
|
|
38
|
+
if (id)
|
|
39
|
+
return id;
|
|
40
|
+
throw new SpecificAIError('USAGE', `无法识别的闲鱼用户:${input}`, { hint: '传用户 ID,或主页链接 https://www.goofish.com/personal?userId=<id>' });
|
|
41
|
+
}
|
|
42
|
+
/** 会话 ID:纯数字,或带 `@goofish` 后缀。 */
|
|
43
|
+
export function resolveConversation(input) {
|
|
44
|
+
const m = /^(\d+)(?:@goofish)?$/.exec(input.trim());
|
|
45
|
+
if (m)
|
|
46
|
+
return m[1];
|
|
47
|
+
throw new SpecificAIError('USAGE', `无法识别的会话 ID:${input}`, { hint: '会话 ID 是数字,来自 msg listen / msg send 输出的 conversation_id' });
|
|
48
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { Console } from 'node:console';
|
|
4
|
+
import { Writable } from 'node:stream';
|
|
5
|
+
import vm from 'node:vm';
|
|
6
|
+
import { staticFile } from '../../../core/paths.js';
|
|
7
|
+
import { createContext, loadScript } from '../../../core/vm.js';
|
|
8
|
+
/**
|
|
9
|
+
* 上游 JS(static/xianyu/,原样复制):
|
|
10
|
+
* - goofish_js_version_2.js:mtop 签名、mid / uuid / 设备 ID、推送解码(上游 utils/goofish_utils.py 经 PyExecJS 调用);
|
|
11
|
+
* - gen_tfstk.js + et_f.js:补环境跑阿里的 et_f,生成 cookie `tfstk`(上游 `node utils/gen_tfstk.js` 子进程)。
|
|
12
|
+
*/
|
|
13
|
+
const GOOFISH_JS = staticFile('xianyu', 'goofish_js_version_2.js');
|
|
14
|
+
const TFSTK_JS = staticFile('xianyu', 'gen_tfstk.js');
|
|
15
|
+
/** 脚本里的函数是顶层 `const`,不挂在 context 上(core 的 callScript 取不到),按名字在 context 里求值。 */
|
|
16
|
+
function call(fn, ...args) {
|
|
17
|
+
const f = vm.runInContext(fn, loadScript(GOOFISH_JS));
|
|
18
|
+
return f(...args);
|
|
19
|
+
}
|
|
20
|
+
/** md5(token&t&34839810&data)。 */
|
|
21
|
+
export const generateSign = (t, token, data) => call('generate_sign', t, token, data);
|
|
22
|
+
export const generateMid = () => call('generate_mid');
|
|
23
|
+
export const generateUuid = () => call('generate_uuid');
|
|
24
|
+
export const generateDeviceId = (userId) => call('generate_device_id', userId);
|
|
25
|
+
/** 推送里 base64 + MessagePack 的数据 → JSON 字符串。 */
|
|
26
|
+
export const decrypt = (data) => call('decrypt', data);
|
|
27
|
+
/**
|
|
28
|
+
* 跑 gen_tfstk.js,拿到 `tfstk`;失败返回空串(与上游 `_gen_tfstk` 一致)。
|
|
29
|
+
*
|
|
30
|
+
* 脚本是命令行写法:读 `__dirname` 下的 et_f.js、结果写到 stdout、失败时 `process.exit`,这里喂一个假的 process 收结果。
|
|
31
|
+
* 它自己再开一层 vm 补浏览器环境,把 ArrayBuffer、Error、console 等宿主对象透传给 et_f;
|
|
32
|
+
* 所以这些要用宿主 realm 的(console 还要是完整的 Console),否则 et_f 的环境检测不过,算出来是 undefined。
|
|
33
|
+
*/
|
|
34
|
+
export async function genTfstk(debug = () => { }) {
|
|
35
|
+
const sink = new Writable({
|
|
36
|
+
write(chunk, _enc, done) {
|
|
37
|
+
for (const line of String(chunk).split('\n'))
|
|
38
|
+
if (line.trim())
|
|
39
|
+
debug(`[gen_tfstk] ${line}`);
|
|
40
|
+
done();
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
const proc = Object.create(process, {
|
|
45
|
+
argv: { value: ['node', TFSTK_JS] },
|
|
46
|
+
stdout: { value: { write: (s) => (resolve(String(s).trim()), true) } },
|
|
47
|
+
exit: { value: () => resolve('') },
|
|
48
|
+
});
|
|
49
|
+
const context = createContext({
|
|
50
|
+
process: proc,
|
|
51
|
+
__dirname: dirname(TFSTK_JS),
|
|
52
|
+
__filename: TFSTK_JS,
|
|
53
|
+
console: new Console({ stdout: sink, stderr: sink }),
|
|
54
|
+
Error,
|
|
55
|
+
queueMicrotask,
|
|
56
|
+
ArrayBuffer,
|
|
57
|
+
SharedArrayBuffer,
|
|
58
|
+
DataView,
|
|
59
|
+
Uint8Array,
|
|
60
|
+
Uint8ClampedArray,
|
|
61
|
+
Uint16Array,
|
|
62
|
+
Uint32Array,
|
|
63
|
+
Int8Array,
|
|
64
|
+
Int16Array,
|
|
65
|
+
Int32Array,
|
|
66
|
+
Float32Array,
|
|
67
|
+
Float64Array,
|
|
68
|
+
BigInt64Array,
|
|
69
|
+
BigUint64Array,
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
vm.runInContext(readFileSync(TFSTK_JS, 'utf8'), context, { filename: TFSTK_JS });
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
debug(`[gen_tfstk] ${err.message}`);
|
|
76
|
+
resolve('');
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specific-ai-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Specific AI:一个命令操作小红书、抖音、TikTok、B 站、快手、微博、闲鱼、淘宝、京东、X;统一命令与 JSON 输出,面向用户和 AI Agent。",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"xiaohongshu",
|
|
8
|
+
"douyin",
|
|
9
|
+
"tiktok",
|
|
10
|
+
"bilibili",
|
|
11
|
+
"kuaishou",
|
|
12
|
+
"weibo",
|
|
13
|
+
"xianyu",
|
|
14
|
+
"taobao",
|
|
15
|
+
"jd",
|
|
16
|
+
"twitter"
|
|
17
|
+
],
|
|
18
|
+
"author": "Dearli666",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Dearli666/specific-ai.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/Dearli666/specific-ai#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/Dearli666/specific-ai/issues"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"bin": {
|
|
30
|
+
"specific-ai": "dist/cli/main.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"static",
|
|
35
|
+
"assets/banner.txt"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
39
|
+
},
|
|
40
|
+
"workspaces": [
|
|
41
|
+
"packages/assets-jd",
|
|
42
|
+
"packages/assets-ocr"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "node scripts/clean.mjs && tsc -p tsconfig.build.json",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:e2e": "vitest run -c tests/e2e/vitest.config.ts",
|
|
49
|
+
"gen:capabilities": "npm run build && node scripts/gen-capabilities.mjs",
|
|
50
|
+
"prepack": "npm run build",
|
|
51
|
+
"assets:jd": "node scripts/fetch-jd-models.mjs",
|
|
52
|
+
"assets:ocr": "node scripts/fetch-ocr-models.mjs"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"specific-ai-assets-jd": "0.1.0",
|
|
56
|
+
"specific-ai-assets-ocr": "0.1.0",
|
|
57
|
+
"@napi-rs/canvas": "^1.0.9",
|
|
58
|
+
"@techstark/opencv-js": "^5.0.0-release.1",
|
|
59
|
+
"crypto-js": "^4.2.0",
|
|
60
|
+
"jsdom": "^30.1.1",
|
|
61
|
+
"onnxruntime-web": "^1.30.0",
|
|
62
|
+
"protobufjs": "^8.8.0",
|
|
63
|
+
"qrcode": "^1.5.4",
|
|
64
|
+
"smol-toml": "^1.9.0",
|
|
65
|
+
"wreq-js": "^3.2.0",
|
|
66
|
+
"zod": "^4.6.5"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/crypto-js": "^4.2.2",
|
|
70
|
+
"@types/jsdom": "^30.0.0",
|
|
71
|
+
"@types/node": "^22.20.4",
|
|
72
|
+
"@types/qrcode": "^1.5.6",
|
|
73
|
+
"typescript": "^7.0.2",
|
|
74
|
+
"vitest": "^5.0.2"
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
message HeadersList {
|
|
4
|
+
string key = 1;
|
|
5
|
+
string value = 2;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
message PushFrame {
|
|
9
|
+
uint64 seqId = 1;
|
|
10
|
+
uint64 logId = 2;
|
|
11
|
+
uint64 service = 3;
|
|
12
|
+
uint64 method = 4;
|
|
13
|
+
repeated HeadersList headersList = 5;
|
|
14
|
+
string payloadEncoding = 6;
|
|
15
|
+
string payloadType = 7;
|
|
16
|
+
bytes payload = 8;
|
|
17
|
+
string logIdNew = 9;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
message Message {
|
|
21
|
+
string method = 1;
|
|
22
|
+
bytes payload = 2;
|
|
23
|
+
int64 msgId = 3;
|
|
24
|
+
int32 msgType = 4;
|
|
25
|
+
int64 offset = 5;
|
|
26
|
+
bool needWrdsStore = 6;
|
|
27
|
+
int64 wrdsVersion = 7;
|
|
28
|
+
string wrdsSubKey = 8;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message LiveResponse {
|
|
32
|
+
repeated Message messagesList = 1;
|
|
33
|
+
string cursor = 2;
|
|
34
|
+
uint64 fetchInterval = 3;
|
|
35
|
+
uint64 now = 4;
|
|
36
|
+
string internalExt = 5;
|
|
37
|
+
uint32 fetchType = 6;
|
|
38
|
+
map<string, string> routeParams = 7;
|
|
39
|
+
uint64 heartbeatDuration = 8;
|
|
40
|
+
bool needAck = 9;
|
|
41
|
+
string pushServer = 10;
|
|
42
|
+
string liveCursor = 11;
|
|
43
|
+
bool historyNoMore = 12;
|
|
44
|
+
string proxyServer = 13;
|
|
45
|
+
}
|
|
46
|
+
message Image {
|
|
47
|
+
Content content = 8;
|
|
48
|
+
}
|
|
49
|
+
message Content {
|
|
50
|
+
string name = 1;
|
|
51
|
+
string font_color = 2;
|
|
52
|
+
int64 level = 3;
|
|
53
|
+
string alternative_text = 4;
|
|
54
|
+
}
|
|
55
|
+
message User {
|
|
56
|
+
int64 id = 1;
|
|
57
|
+
int64 short_id = 2;
|
|
58
|
+
string nickname = 3;
|
|
59
|
+
int32 gender = 4;
|
|
60
|
+
string signature = 5;
|
|
61
|
+
int32 level = 6;
|
|
62
|
+
int64 birthday = 7;
|
|
63
|
+
string telephone = 8;
|
|
64
|
+
bool verified = 12;
|
|
65
|
+
int32 experience = 13;
|
|
66
|
+
string city = 14;
|
|
67
|
+
int32 status = 15;
|
|
68
|
+
int64 create_time = 16;
|
|
69
|
+
int64 modify_time = 17;
|
|
70
|
+
int32 secret = 18;
|
|
71
|
+
string share_qrcode_uri = 19;
|
|
72
|
+
int32 income_share_percent = 20;
|
|
73
|
+
repeated Image badge_image_list = 21;
|
|
74
|
+
string special_id = 26;
|
|
75
|
+
int64 top_vip_no = 31;
|
|
76
|
+
int64 pay_score = 34;
|
|
77
|
+
int64 ticket_count = 35;
|
|
78
|
+
int32 link_mic_stats = 37;
|
|
79
|
+
string display_id = 38;
|
|
80
|
+
bool with_commerce_permission = 39;
|
|
81
|
+
bool with_fusion_shop_entry = 40;
|
|
82
|
+
int64 total_recharge_diamond_count = 41;
|
|
83
|
+
string verified_content = 43;
|
|
84
|
+
repeated User top_fans = 45;
|
|
85
|
+
string sec_uid = 46;
|
|
86
|
+
int32 user_role = 47;
|
|
87
|
+
int32 authorization_info = 54;
|
|
88
|
+
int32 adversary_authorization_info = 55;
|
|
89
|
+
int32 adversary_user_status = 58;
|
|
90
|
+
repeated int64 commerce_webcast_config_ids = 60;
|
|
91
|
+
string location_city = 63;
|
|
92
|
+
string remark_name = 65;
|
|
93
|
+
int32 mystery_man = 66;
|
|
94
|
+
string web_rid = 67;
|
|
95
|
+
string desensitized_nickname = 68;
|
|
96
|
+
bool is_anonymous = 71;
|
|
97
|
+
int32 consume_diamond_level = 72;
|
|
98
|
+
string webcast_uid = 73;
|
|
99
|
+
bool allow_be_located = 1001;
|
|
100
|
+
bool allow_find_by_contacts = 1002;
|
|
101
|
+
bool allow_others_download_video = 1003;
|
|
102
|
+
bool allow_others_download_when_sharing_video = 1004;
|
|
103
|
+
bool allow_share_show_profile = 1005;
|
|
104
|
+
bool allow_show_in_gossip = 1006;
|
|
105
|
+
bool allow_show_my_action = 1007;
|
|
106
|
+
bool allow_strange_comment = 1008;
|
|
107
|
+
bool allow_unfollower_comment = 1009;
|
|
108
|
+
bool allow_use_linkmic = 1010;
|
|
109
|
+
string bg_img_url = 1013;
|
|
110
|
+
string birthday_description = 1014;
|
|
111
|
+
bool birthday_valid = 1015;
|
|
112
|
+
int32 block_status = 1016;
|
|
113
|
+
int32 comment_restrict = 1017;
|
|
114
|
+
string constellation = 1018;
|
|
115
|
+
int32 disable_ichat = 1019;
|
|
116
|
+
int64 enable_ichat_img = 1020;
|
|
117
|
+
int32 exp = 1021;
|
|
118
|
+
int64 fan_ticket_count = 1022;
|
|
119
|
+
bool fold_stranger_chat = 1023;
|
|
120
|
+
int64 follow_status = 1024;
|
|
121
|
+
bool hotsoon_verified = 1025;
|
|
122
|
+
string hotsoon_verified_reason = 1026;
|
|
123
|
+
int32 ichat_restrict_type = 1027;
|
|
124
|
+
string id_str = 1028;
|
|
125
|
+
bool is_follower = 1029;
|
|
126
|
+
bool is_following = 1030;
|
|
127
|
+
bool need_profile_guide = 1031;
|
|
128
|
+
int64 pay_scores = 1032;
|
|
129
|
+
bool push_comment_status = 1033;
|
|
130
|
+
bool push_digg = 1034;
|
|
131
|
+
bool push_follow = 1035;
|
|
132
|
+
bool push_friend_action = 1036;
|
|
133
|
+
bool push_ichat = 1037;
|
|
134
|
+
bool push_status = 1038;
|
|
135
|
+
bool push_video_post = 1039;
|
|
136
|
+
bool push_video_recommend = 1040;
|
|
137
|
+
bool verified_mobile = 1042;
|
|
138
|
+
string verified_reason = 1043;
|
|
139
|
+
bool with_car_management_permission = 1044;
|
|
140
|
+
int32 age_range = 1045;
|
|
141
|
+
int64 watch_duration_month = 1046;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
message ChatMessage {
|
|
145
|
+
User user = 2;
|
|
146
|
+
string content = 3;
|
|
147
|
+
bool visibleToSender = 4;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
message GiftStruct {
|
|
151
|
+
int64 id = 5;
|
|
152
|
+
string name = 16;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
message GiftMessage {
|
|
156
|
+
string giftId = 2;
|
|
157
|
+
int64 comboCount = 6;
|
|
158
|
+
User user = 7;
|
|
159
|
+
User toUser = 8;
|
|
160
|
+
GiftStruct gift = 15;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
message MemberMessage {
|
|
164
|
+
User user = 2;
|
|
165
|
+
int64 memberCount = 3;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
message LikeMessage {
|
|
169
|
+
int64 count = 2;
|
|
170
|
+
int64 total = 3;
|
|
171
|
+
int64 color = 4;
|
|
172
|
+
User user = 5;
|
|
173
|
+
string icon = 6;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
message RoomStatsMessage {
|
|
177
|
+
string displayShort = 2;
|
|
178
|
+
string displayMiddle = 3;
|
|
179
|
+
string displayLong = 4;
|
|
180
|
+
int64 displayValue = 5;
|
|
181
|
+
int64 displayVersion = 6;
|
|
182
|
+
bool incremental = 7;
|
|
183
|
+
bool isHidden = 8;
|
|
184
|
+
int64 total = 9;
|
|
185
|
+
int64 displayType = 10;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
message SocialMessage {
|
|
189
|
+
User user = 2;
|
|
190
|
+
int64 shareType = 3;
|
|
191
|
+
int64 action = 4;
|
|
192
|
+
string shareTarget = 5;
|
|
193
|
+
uint64 followCount = 6;
|
|
194
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
message ExtValue {
|
|
4
|
+
string key = 1;
|
|
5
|
+
string value = 2;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
message Request {
|
|
9
|
+
int32 cmd = 1;
|
|
10
|
+
int64 sequence_id = 2;
|
|
11
|
+
string sdk_version = 3;
|
|
12
|
+
string token = 4;
|
|
13
|
+
int32 refer = 5;
|
|
14
|
+
int64 inbox_type = 6;
|
|
15
|
+
string build_number = 7;
|
|
16
|
+
RequestBody body = 8;
|
|
17
|
+
string device_id = 9;
|
|
18
|
+
string channel = 10;
|
|
19
|
+
string device_platform = 11;
|
|
20
|
+
string device_type = 12;
|
|
21
|
+
string os_version = 13;
|
|
22
|
+
string version_code = 14;
|
|
23
|
+
map<string, string> headers = 15;
|
|
24
|
+
int32 config_id = 16;
|
|
25
|
+
TokenInfo token_info = 17;
|
|
26
|
+
int32 auth_type = 18;
|
|
27
|
+
string biz = 21;
|
|
28
|
+
string access = 22;
|
|
29
|
+
string ts_sign = 23;
|
|
30
|
+
string sdk_cert = 24;
|
|
31
|
+
string reuqest_sign = 25;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
message RequestBody {
|
|
35
|
+
oneof body {
|
|
36
|
+
SendMessageRequestBody send_message_body = 100;
|
|
37
|
+
CreateConversationV2RequestBody create_conversation_v2_body = 609;
|
|
38
|
+
GetConversationInfoListV2RequestBody get_conversation_info_list_v2_body = 610;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message SendMessageRequestBody {
|
|
43
|
+
string conversation_id = 1;
|
|
44
|
+
int32 conversation_type = 2;
|
|
45
|
+
int64 conversation_short_id = 3;
|
|
46
|
+
string content = 4;
|
|
47
|
+
repeated ExtValue ext = 5;
|
|
48
|
+
int32 message_type = 6;
|
|
49
|
+
string ticket = 7;
|
|
50
|
+
string client_message_id = 8;
|
|
51
|
+
repeated int64 mentioned_users = 9;
|
|
52
|
+
bool ignore_badge_count = 10;
|
|
53
|
+
ReferencedMessageInfo ref_msg_info = 11;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message ReferencedMessageInfo {
|
|
57
|
+
int64 original_message_id = 1;
|
|
58
|
+
string original_message_sender = 2;
|
|
59
|
+
int64 original_message_timestamp = 3;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message TokenInfo {
|
|
63
|
+
int32 mark_id = 1;
|
|
64
|
+
int32 type = 2;
|
|
65
|
+
int32 app_id = 3;
|
|
66
|
+
int64 user_id = 4;
|
|
67
|
+
int64 timestamp = 5;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message CreateConversationV2RequestBody {
|
|
71
|
+
int32 conversation_type = 1;
|
|
72
|
+
repeated int64 participants = 2;
|
|
73
|
+
bool persistent = 3;
|
|
74
|
+
string idempotent_id = 4;
|
|
75
|
+
string name = 5;
|
|
76
|
+
string avatar_url = 6;
|
|
77
|
+
string description = 7;
|
|
78
|
+
map<string, string> biz_ext = 8;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
message GetConversationInfoListV2RequestBody {
|
|
82
|
+
GetConversationInfoListV2ResponseBodyData data = 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
message GetConversationInfoListV2ResponseBodyData {
|
|
86
|
+
string conversation_id = 1;
|
|
87
|
+
int64 conversation_short_id = 2;
|
|
88
|
+
int32 conversation_type = 3;
|
|
89
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
message Response {
|
|
3
|
+
int32 cmd = 1;
|
|
4
|
+
int64 sequence_id = 2;
|
|
5
|
+
string error_desc = 3;
|
|
6
|
+
string message = 4;
|
|
7
|
+
int64 inbox_type = 5;
|
|
8
|
+
ResponseBody body = 6;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message ResponseBody {
|
|
12
|
+
oneof body {
|
|
13
|
+
NewMessageNotify new_message_notify = 500;
|
|
14
|
+
GetConversationInfoListV2ResponseBody create_conversation_v2_body = 609;
|
|
15
|
+
GetConversationInfoListV2ResponseBody get_conversation_info_list_v2_response_body = 610;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message NewMessageNotify {
|
|
20
|
+
string conversation_id = 2;
|
|
21
|
+
int32 conversation_type = 3;
|
|
22
|
+
int32 notify_type = 4;
|
|
23
|
+
MessageBody message = 5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
message MessageBody {
|
|
27
|
+
string conversation_id = 1;
|
|
28
|
+
int32 conversation_type = 2;
|
|
29
|
+
int64 server_message_id = 3;
|
|
30
|
+
int64 index_in_conversation = 4;
|
|
31
|
+
int64 conversation_short_id = 5;
|
|
32
|
+
int32 message_type = 6;
|
|
33
|
+
int64 sender = 7;
|
|
34
|
+
string content = 8;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
message GetConversationInfoListV2ResponseBody {
|
|
38
|
+
repeated GetConversationInfoV2Response conversation_info_list = 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
message GetConversationInfoV2Response {
|
|
42
|
+
string conversation_id = 1;
|
|
43
|
+
int64 conversation_short_id = 2;
|
|
44
|
+
int32 conversation_type = 3;
|
|
45
|
+
string ticket = 4;
|
|
46
|
+
}
|