Open-source, local-first social media research agent for Instagram, TikTok, and LinkedIn. Jev routes read-only steps; socai CLI captures cited browser evidence.
JavaScript agent-skillsai-agentsbrowser-agentbrowser-automationdecision-modeldeep-researchinstagramjevlinkedinlocal-firstopen-sourceosintresearch-agentsocaisocial-listeningsocial-mediasocial-media-researchsocmintsystem-onetiktok
fix: require explicit TikTok media intent
Asklv05581cac6b8c
diff --git a/README.md b/README.mdindex 15cbf77..d664a46 100644--- a/README.md+++ b/README.md@@ -9,7 +9,7 @@[](https://github.com/socai-io/jev-social/releases/latest)[](LICENSE)-Jev chooses each next operation: search, open a particular post or profile, read comments, download a TikTok video, or finish. [socai](https://github.com/socai-io/socai) executes the selected CLI command in your real Chrome. Each result goes back to Jev before the next decision.+Jev chooses each next operation: search, open a particular post or profile, read comments, explicitly requested TikTok media download, or finish. [socai](https://github.com/socai-io/socai) executes the selected CLI command in your real Chrome. Each result goes back to Jev before the next decision.<p><img src="https://raw.githubusercontent.com/socai-io/jev-social/main/docs/platforms/instagram.png" height="32" alt="Instagram">@@ -55,7 +55,7 @@ This video also predates the per-operation Jev loop.| Platform | Jev can select || --- | --- || Instagram | Search, open a profile and its post cards, open a specific post/reel and read comments, inspect page state |-| TikTok | Search, open an author, read a selected video and its comments, optionally download that video's media, inspect page state |+| TikTok | Search, open an author, read a selected video and its comments, download that video's media only when the goal explicitly requests it, inspect page state || LinkedIn | Search people/content/companies, read a selected profile/company/post, read experience or education, inspect page state |Only commands exposed by the installed socai CLI are offered. Targets come from captured results or explicit URLs in the user's request. Unsupported, malformed, and low-confidence decisions do not execute. Previously attempted operations are removed from the next choice set.diff --git a/SECURITY.md b/SECURITY.mdindex 30d3930..3956e80 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -38,6 +38,6 @@ Jev Social runs locally, but it is not an offline application.### External effects and recovery-- Supported platform operations are read-only, but they still make network requests and write local run files. A TikTok detail action may include `--download-media`; there is currently no separate confirmation immediately before that local download.+- Supported platform operations do not change remote social state, but they still make network requests and write local run files. Jev Social exposes a TikTok action containing `--download-media` only when the user's goal explicitly asks to download, save, archive, capture, record, or keep an offline copy of media. That authorization is recorded as `downloadMedia: true` on the selected action in run history; there is no second confirmation after the explicit request.- Jev and platform requests can incur provider or network costs. `--max-steps` bounds decision-loop work, and cancellation terminates the active socai process tree.- Access gates, low-confidence decisions, failed operations, and step exhaustion produce partial or failed runs instead of changing remote social state. Recovery consists of stopping the run, reviewing the saved evidence, and removing only the unwanted local artifacts described above.diff --git a/site/llms.txt b/site/llms.txtindex 9606411..3d59e31 100644--- a/site/llms.txt+++ b/site/llms.txt@@ -24,7 +24,7 @@ Recorded output example: https://github.com/socai-io/jev-social/blob/main/docs/e## Supported operations- Instagram: search, inspect a profile, inspect an observed post or reel, read comments, inspect page state-- TikTok: search, inspect an author, inspect an observed video and comments, download the selected video's media, inspect page state+- TikTok: search, inspect an author, inspect an observed video and comments, download selected media only when explicitly requested, inspect page state- LinkedIn: search people, content, or companies; inspect an observed profile, company, post, experience, or education; inspect page state## Interfacesdiff --git a/src/actions.js b/src/actions.jsindex d25da72..8749521 100644--- a/src/actions.js+++ b/src/actions.js@@ -44,6 +44,21 @@ export function targetKind(raw, platform) {return null;}+export function mediaDownloadRequested(goal) {+ const text = String(goal || "");+ const excludesMediaIntent = /\b(?:comments?|captions?|metadata|notes?|evidence|reports?|transcripts?|thumbnails?|details?|results?|links?|urls?|discussions?)\b/i;+ const excludesChineseMediaIntent = /(?:评论|字幕|元数据|笔记|证据|报告|文字|链接|封面|讨论)/;+ const hasUnblockedMatch = (pattern, excluded) => [...text.matchAll(pattern)]+ .some((match) => !excluded.test(match.groups?.between || ""));++ return hasUnblockedMatch(/\b(?:download|save|archive|grab)\b(?<between>[\s\S]{0,48}?)\b(?:videos?|media|clips?|files?)\b/gi, excludesMediaIntent)+ || hasUnblockedMatch(/\b(?:videos?|media|clips?|files?)\b(?<between>[\s\S]{0,48}?)\b(?:download|save|archive|grab)\b/gi, excludesMediaIntent)+ || /\b(?:capture|record)\s+(?:(?:the|a|an|this|that|selected|its|their|your)\s+){0,2}(?:videos?|media|clips?)\b/i.test(text)+ || /\b(?:local|offline)\s+copy\s+(?:(?:of|the|a|this|that|selected|chosen)\s+){0,4}(?:videos?|media|clips?|files?)\b/i.test(text)+ || hasUnblockedMatch(/(?:下载|保存|留存|归档|抓取)(?<between>.{0,16}?)(?:视频|媒体|文件)/g, excludesChineseMediaIntent)+ || hasUnblockedMatch(/(?:视频|媒体|文件)(?<between>.{0,16}?)(?:下载|保存|留存|归档|抓取)/g, excludesChineseMediaIntent);+}+export function buildActionArgs(action) {const { platform, kind, target, query, resultType, limit = 4, downloadMedia = false } = action;if (!DOMAINS[platform]) throw new AppError("Unsupported action platform.", { code: "INVALID_ACTION" });@@ -85,6 +100,7 @@ export function buildActionArgs(action) {export function availableActions({ platform, query, goal, items, history, commands, limit }) {const actions = [];+ const allowMediaDownload = platform === "tiktok" && mediaDownloadRequested(goal);const attempted = new Set(history.map((step) => step.action.id));const add = (kind, label, fields = {}) => {const action = { platform, kind, label, limit, ...fields };@@ -121,7 +137,7 @@ export function availableActions({ platform, query, goal, items, history, commanconst read = history.some((step) => step.action.kind === "read_post" && step.action.target === target);if (!read) {add("read_post", `Open this post and read its comments: ${target} ${detail}`, { target });- if (platform === "tiktok") add("read_post", `Open this video, read comments, and download its media: ${target} ${detail}`, { target, downloadMedia: true });+ if (allowMediaDownload) add("read_post", `Open this video, read comments, and download its media: ${target} ${detail}`, { target, downloadMedia: true });}}if (type === "profile") {@@ -164,7 +180,7 @@ export async function chooseAction({ goal, platform, actions, history, items, li"Start with the literal search or an explicit URL. On LinkedIn choose people, content, or companies to match the goal.","Read the most relevant posts and their comments before finishing; search cards alone are not detailed evidence.","Open a promising profile when search results are profiles instead of posts, or when the goal is creator discovery.",- "Download TikTok video when requested or useful to inspect the goal; do not download unrelated videos.",+ "Offer a TikTok media-download action only when the user's goal explicitly asks to download, save, archive, capture, record, or keep an offline copy of media.","Do not repeat failed operations or evade login, CAPTCHA, or access gates. Finish when blocked or when enough relevant evidence is collected.","An explicit count or stopping condition in the user's request takes priority over target_count. Otherwise aim for target_count useful records. Finish when the goal is met; do not exhaust the budget just to use every action.",],diff --git a/test/actions.test.js b/test/actions.test.jsindex 5277428..3ba7f7f 100644--- a/test/actions.test.js+++ b/test/actions.test.js@@ -17,6 +17,17 @@ test('actions accept only observed social targets and known CLI operations', ()assert.ok(!availableActions({...base,commands:['search']}).some(x=>x.kind==='page_state'));});+test('TikTok media downloads require explicit user intent', () => {+ const tiktok={platform:'tiktok',query:'handmade art',goal:'research handmade art on TikTok',items:[{url:'https://www.tiktok.com/@demo/video/222',title:'Handmade art'}],history:[],commands:['search','get-videos','author','page_state'],limit:4};+ assert.ok(!availableActions(tiktok).some(x=>x.downloadMedia));+ assert.ok(!availableActions({...tiktok,goal:'capture evidence from video'}).some(x=>x.downloadMedia));+ assert.ok(!availableActions({...tiktok,goal:'save notes about this video'}).some(x=>x.downloadMedia));+ assert.ok(!availableActions({...tiktok,goal:'download comments from this video'}).some(x=>x.downloadMedia));+ assert.ok(availableActions({...tiktok,goal:'find and download the selected TikTok video'}).some(x=>x.downloadMedia));+ assert.ok(availableActions({...tiktok,goal:'record the selected video for offline analysis'}).some(x=>x.downloadMedia));+ assert.ok(availableActions({...tiktok,goal:'下载并保存选中的 TikTok 视频'}).some(x=>x.downloadMedia));+});+test('Instagram aliases merge detail and comments into the existing card', () => {assert.equal(sourceUrl('https://www.instagram.com/reel/demo/?x=1','instagram'),'https://www.instagram.com/p/demo/');const action={platform:'instagram',kind:'read_post',target:'https://www.instagram.com/p/demo/'};diff --git a/test/app.test.js b/test/app.test.jsindex 50c2fd1..0a381aa 100644--- a/test/app.test.js+++ b/test/app.test.js@@ -97,14 +97,27 @@ test("Jev opens a profile then selects a newly observed post", async () => {} finally { await rm(directory,{recursive:true,force:true}); }});-test("runSearch downloads only the TikTok video selected by Jev", async () => {+test("generic TikTok research reads video details without downloading media", async () => {const { directory, env } = await fixture();- const client = choices('tiktok', (criteria, step) => step === 0 ? matching(criteria,/^Search tiktok/) : step === 1 ? matching(criteria,/download its media.*\/222/) : 'finish');+ const client = choices('tiktok', (criteria, step) => step === 0 ? matching(criteria,/^Search tiktok/) : step === 1 ? matching(criteria,/Open this post.*\/222/) : 'finish');try {const run = await runSearch({query:'find handmade art on TikTok'}, {env,client});assert.equal(run.socaiOutputs.length,2);+ assert.match(run.command,/get-videos --video 'https:\/\/www.tiktok.com\/@demo\/video\/222' --num-comments 8 --pretty/);+ assert.ok(!run.command.includes('--download-media'));+ assert.ok(!run.actions[1].action.downloadMedia);+ } finally { await rm(directory,{recursive:true,force:true}); }+});++test("runSearch downloads only the TikTok video selected by Jev after an explicit request", async () => {+ const { directory, env } = await fixture();+ const client = choices('tiktok', (criteria, step) => step === 0 ? matching(criteria,/^Search tiktok/) : step === 1 ? matching(criteria,/download its media.*\/222/) : 'finish');+ try {+ const run = await runSearch({query:'find and download a handmade art video on TikTok'}, {env,client});+ assert.equal(run.socaiOutputs.length,2);assert.match(run.command,/get-videos --video 'https:\/\/www.tiktok.com\/@demo\/video\/222' --num-comments 8 --download-media/);assert.ok(!run.command.includes('/111'));+ assert.equal(run.actions[1].action.downloadMedia,true);assert.equal(run.result.items.find((item)=>item.url.endsWith('/222')).video.local_path,'/tmp/video.mp4');} finally { await rm(directory,{recursive:true,force:true}); }});