diff --git a/changes/studio-sample-wall.md b/changes/studio-sample-wall.md new file mode 100644 index 00000000..6f117ac9 --- /dev/null +++ b/changes/studio-sample-wall.md @@ -0,0 +1,5 @@ +**Studio 的空间有了样片墙:照着工作台自己的片子开一支;对话列的下拉框不再截字,没登录的提示只说一次** +- Why: 刚装好打开 Studio,空间是空的,除了右边一列没东西可看,也不知道第一句该说什么。 +- 样片墙:官网放的那四支片子(竖屏科普、数学讲解、手绘短片、发布短片),每张卡写类型、时长、竖屏还是横屏、风格(库里有的带上风格的 id)。按钮"照这个做一支"只把一句话写进开新片子的框里,不发送、不开始任何事:这句话和官网那张卡复制的一样,点名库里的风格(`styles/dark-math`、`watercolor-pastoral`、`product-keynote`)和取自发布短片的三张配方;有要填的空就选中它,框里原来写的 ⌘Z 拿得回来。框写不进去时不写:还没装 agent,就先留着这一句、在"装上"那里说一声,装好以后点一下"写进框里";空间里那段对话还在做或在等你批准,不把它换走,等它停下再写。还没有片子时样片墙展开着;有了自己的片子,或在窄屏上,它先收着,点开再看。画面是官网的封面图;用 `tools/fetch_media.sh` 下载过片子的,鼠标停在卡上放 4 秒。 +- 官网那三句(数学讲解、手绘短片、发布短片)也带上了同样的风格和配方,两处一字不差;`tools/desk/test_wording.py` 对着官网查,句子里点名的风格和配方都要在仓库里。 +- 对话列:选 agent 的下拉框把名字写全(以前在 1440×900 下是"Claude Code(没装");没登录时发一句,怎么登录在屏幕上正好说一次,不管 agent 先报"没登录"、先用自己的话说,还是先说这一句没做成,停下的那一句也算。 diff --git a/docs/site/index.html b/docs/site/index.html index a1e8a00f..2a48a11e 100644 --- a/docs/site/index.html +++ b/docs/site/index.html @@ -1140,7 +1140,7 @@

04Check & deliver查与交 Contact sheet of the math explainer contact sheet联系表 -
Math explainer, 3Blue1Brown style数学讲解,3Blue1Brown 风格Building a square wave from sine waves用正弦波搭出方波Manim · 25 s · English narrationManim · 25 秒 · 英文旁白
Quick draft: a 25-second math explainer in the 3Blue1Brown style, on why the odd numbers from 1 always add up to a square.快速出一版 25 秒的数学讲解,3Blue1Brown 的风格:为什么从 1 开始的连续奇数加起来总是平方数。
+
Math explainer, 3Blue1Brown style数学讲解,3Blue1Brown 风格Building a square wave from sine waves用正弦波搭出方波Manim · 25 s · English narrationManim · 25 秒 · 英文旁白
Quick draft: a 25-second math explainer in the Dark Math style (styles/dark-math), on why the odd numbers from 1 always add up to a square.快速出一版 25 秒的数学讲解,用「暗底数学」风格(styles/dark-math):为什么从 1 开始的连续奇数加起来总是平方数。
Every film ships with its paper trail每支片子都附带完整的制作记录 diff --git a/tools/ci-paths.txt b/tools/ci-paths.txt index 37b2a6e1..1000fe80 100644 --- a/tools/ci-paths.txt +++ b/tools/ci-paths.txt @@ -28,15 +28,15 @@ tools/ci-paths.txt plumbing_checks .github/** # pages people read (a tool that names one of them puts its groups here) -README.zh-CN.md +README.zh-CN.md desk_checks ACKNOWLEDGMENTS.md -CONTRIBUTING.md plumbing_checks studio_checks hdri_checks +CONTRIBUTING.md plumbing_checks desk_checks studio_checks hdri_checks CODE_OF_CONDUCT.md SECURITY.md -CITATION.cff plumbing_checks studio_checks +CITATION.cff plumbing_checks desk_checks studio_checks LICENSE hf_checks +showcase/** smoke_checks timeline_checks decision_checks desk_checks console_checks web_checks model3d_checks cases/** gate_checks desk_checks console_checks status_checks contract_checks cancel_checks history_checks know_checks artifacts_checks studio_checks -showcase/** smoke_checks timeline_checks decision_checks web_checks model3d_checks install.sh plumbing_checks smoke_checks desk_checks studio_checks cancel_checks assets_checks scout_checks web_checks model3d_checks settings_page_checks LOCAL.example.md plumbing_checks smoke_checks desk_checks studio_checks cancel_checks assets_checks scout_checks web_checks model3d_checks settings_page_checks skills/** smoke_checks cancel_checks assets_checks scout_checks web_checks model3d_checks settings_page_checks studio_checks diff --git a/tools/ci.sh b/tools/ci.sh index 7375a044..2683bb4c 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -4123,6 +4123,25 @@ want(s == 200 and h.get("Content-Security-Policy", "").startswith("sandbox"), "a for p in (f"/f/{K}/..%2fzh/BRIEF.md", f"/f/{K}/../zh/BRIEF.md", "/f/nope-x/BRIEF.md", "/api/p/nope-x/data", f"/api/p/{K}/gate/9", "/api/data", "/p/BRIEF.md"): want(req("GET", p)[0] == 404, f"{p} answered") want(req("GET", "/api/projects", host="evil.test")[0] == 403, "another Host answered") +# the space's sample wall: the four showcase posters always, each film only when it is in the clone, and nothing else of the clone +smp = json.loads(req("GET", "/api/projects")[2]).get("samples") +s, h, img = req("GET", "/samples/short.jpg") +want(isinstance(smp, list) and set(smp) <= {"short", "math", "handdrawn", "launch"} and s == 200 and h.get("Content-Type") == "image/jpeg" and img[:2] == b"\xff\xd8" + and all(req("GET", f"/samples/{x}.jpg")[0] == 200 for x in ("math", "handdrawn", "launch")) + and all(req("GET", f"/samples/{x}.mp4")[0] == (200 if x in smp else 404) for x in ("short", "math", "handdrawn", "launch")), + f"the sample wall's posters and films: {smp} {s} {h.get('Content-Type')}") +for p in ("/samples/nope.jpg", "/samples/short.png", "/samples/..%2fserver.py", "/samples/", "/samples/short.jpg/x"): + want(req("GET", p)[0] == 404, f"{p} answered") +film = "showcase/02-short-leo-doppler/media/final.mp4" # a film linked in from outside the clone: neither listed nor served +if not os.path.lexists(film) and os.path.isdir(os.path.dirname(film)): + outside = os.path.join(os.path.dirname(root), "outside.mp4") + open(outside, "wb").write(b"\x00" * 64) + os.symlink(outside, film) + try: + want("short" not in json.loads(req("GET", "/api/projects")[2]).get("samples", []) and req("GET", "/samples/short.mp4")[0] == 404, + "a film linked in from outside the clone is listed or served") + finally: + os.remove(film) fb = lambda **k: json.dumps(dict({"round": "3", "lang": "zh", "decisions": {"draft": "OK"}, "defaulted": ["voice"], "general": "", "items": [{"target": "least:S04", "status": "change", "label": "没把握:S04", "text": "再大一点"}], "pid": pid(root + "/demo")}, **k)).encode() H = {"Content-Type": "application/json", "X-Desk-Token": token} @@ -4391,7 +4410,7 @@ for f, text in (("ui.css", ui), ("studio.css", css), ("modules.css", mcss)): for sel, rule in re.findall(r"([^{}]+)\{([^{}]*)\}", re.sub(r"/\*.*?\*/", "", text, flags=re.S)): if re.search(r"text-transform:\s*(uppercase|var\(--label-case\))", rule): caps += [f"{f}: {s.strip()}" for s in sel.split(",")] -allowed = {"modules.css: .mh2 .kick", "modules.css: .pn-h", "modules.css: .mat-h", "ui.css: .g-eyebrow", "ui.css: .g-h", "studio.css: .mh .kick", "studio.css: .sect>h2", +allowed = {"modules.css: .mh2 .kick", "modules.css: .pn-h", "modules.css: .mat-h", "ui.css: .g-eyebrow", "ui.css: .g-h", "studio.css: .mh .kick", "studio.css: .sect>h2", "studio.css: .smp-wall>summary>h2", "studio.css: :root[data-theme=bridge] .col-head b", "studio.css: .col-body .blk-h", "studio.css: .lgroup", "studio.css: .tl .grp"} want(set(caps) <= allowed and "code,kbd,samp,pre,.kbd,.cmd,.hint{text-transform:none" in ui.replace(" ", ""), f"capitals beyond the short labels, or no reset for code: {sorted(set(caps) - allowed)}") want("flex-wrap:nowrap" in re.search(r"\.tl-bar\{[^}]*\}", css).group(0) and '' in st and ".tl-bar .zoom{" in css, "the timeline's bar wraps, or − and + can part") diff --git a/tools/desk/README.md b/tools/desk/README.md index f364d038..b9d6d0af 100644 --- a/tools/desk/README.md +++ b/tools/desk/README.md @@ -66,6 +66,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 - **外壳**:左边一列模块(空间、立意、大纲、分镜、声音、成片、交付、素材、账本;有一站在等人时,它的模块亮一个琥珀点)。顶上一条流程:立意 ① · 大纲 ① · 分镜 ② · 声音 · 成片 ③ · 交付,每一站的灯取这支片子自己的停(`bin/vh status` 的 stations):过了是绿,等你是琥珀,agent 在做是紫(只在它真的在做时:这支片子里有 `bin/vh` 命令在跑,或者右栏这一轮正在进行;轮到它、但这会儿没人在做的一站是灰的"还没定"),还没到是灰,这支片子不在这一站停是一个空心的点。右边一整列见下面。 - **空间**(`#/`):一张卡一支片,等人的在前,卡上写等人定什么;鼠标停在卡上,卡上的片子静音播 4 秒。卡上的画面按这个顺序取:等人时取这一轮要人看的(第一张立意卡的帧,没有就是它的片子、第一张图、第一个关键帧);不等人时取封面(`out/final/covers/`、`out/final/cover*`、`out/review/cover*`),没有就是当前成片的中间一帧(浏览器自己从视频里取,服务不跑 ffmpeg),再没有是分镜关键帧,最后是 `out/review/`、`out/check/`、`out/frames/` 里最新的一张图。 + - **样片墙**:片子下面是"照着样片开始":工作台自己做的四支片子(`showcase/` 里官网也放的那四支,同样的顺序:竖屏科普、数学讲解、手绘短片、发布短片),每张卡写类型、时长、竖屏还是横屏和尺寸、风格(库里有这个风格的,带上它的 id),一个按钮"照这个做一支"。按钮只把一句话写进对话那一列开新片子的框里,不发送、不开始任何事:和官网那张卡复制的一字不差(`tools/desk/test_wording.py` 对着官网查),点名库里的风格(`styles/`)和取自这支片子的配方;有要你填的空([在这里贴上它的链接])就选中它;框里原来写的,⌘Z 拿得回来;窄屏上那一列在下面,框会滚到眼前。框写不进去时不写:这一页只能看,就说这一页只能看;还没装 agent,就把这一句先留着,在那一列的"装上"那里说一声并滚到眼前,装好以后框上面有一个"写进框里",点了才写;空间里那段对话还在做、或在等你批准,不换走它,框上面说一句,等它停下再点"写进框里"。那段对话闲着时,换成开新片子的框,并说一声它在"历史"里。画面是官网的封面图(`docs/site/img/`);这份克隆里有这支片子(`tools/fetch_media.sh` 下载到 `tools/media.txt` 写的那个位置)时,鼠标停在卡上静音放 4 秒。空间里还没有片子时样片墙展开着,就是这一页;有了自己的片子,它收在片子下面成一行,点开再看;窄屏(900 px 以下,那一列在页面下面)也先收着,免得四张卡把框推到几屏以外。人自己点开、收起的,这个浏览器记住。 - **交出去以后**:这一站的意见交给 agent 以后(这一站在等 agent),"这一站"那一页不再摆着没选过似的卡片,而是"交给 agent 的":每件决定选了哪个、每条意见、什么时候交的,下面一个"改了再交",点了才把卡片摆回来;底下那一条写"已经交给 agent 了",按钮歇着,标签页上也不再写"等你定"。没交成功时,服务回一个 `reason`(`token`、`origin`、`page_changed`、`invalid`、`too_big`、`slow`、`moved`),页面照它用人的语言说发生了什么、该做什么,不把服务的英文原样放上去。 - **现在到哪了**:进了一支片子,右栏两页(对话、这一站)的上面是一句短话,说这支片子现在怎么样、轮到谁,下面一行小一点的字说细节(停在哪、留了什么、做好的文件,文件点得开),都是 `bin/vh status` 的 `now:` 那几行(中文或英文;英文和终端里一字不差),再下面至多一个按钮:要人看的一站是"去看初版"这种,转到那一站的模块(已经在那一页就不放);要 agent 接着做的(意见交了没人取、agent 停下了、引擎没装、暂停了)是"让 agent 来看意见""让 agent 接着做":点一下,在这支片子最近的对话里(没有就开一个)发一句写好的话:只用 `standing.py` 词表里的字、数字和时间拼成(命令名不在词表里时只认 `bin/vh` 命令名的样子),不放项目文件里的别的文字;输入框里人自己的草稿不动,这句话照样在对话记录里,记的是人说的。下面一行小字是这支片子的打算(`plan`:多长、竖屏横屏、有没有旁白、在哪几处停给人看),从 BRIEF 和停的计划读,模板里没填的不写。空间的卡片上写这一句的短的那一半("停下了""正在渲染,340 / 900 帧""意见还没人取"),轮到人的(等人看、意见没人取、停下了、暂停了)亮琥珀色。每种情况说什么,见下面"一个项目到哪了"的 `now`。 - **一支片子**(`#/p/<键>[/<模块>]`):打开在等人的那一站的模块(关卡 ① 立意,② 分镜,③ 成片);没人等时打开正在做的那一站,再没有就是成片。关卡不再是另一页:等人那一站的模块就是这一轮的关卡页,要你定的事在右栏。照原型排的模块自己画关卡页的画面(立意卡、镜头),关卡页里其余的东西(替你定的、附录、别的图)接在模块下面;成片模块把关卡页的画面放在它的时间线上。`#/p/<键>/gate/<页>` 打开那一页所在的模块,之前的页只看不交。 @@ -98,7 +99,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 - **起进程用干净的环境**之外,代理和证书照带:`HTTPS_PROXY`、`HTTP_PROXY`、`ALL_PROXY`、`NO_PROXY`(大小写都认)、`NODE_EXTRA_CA_CERTS`、`SSL_CERT_FILE`、`SSL_CERT_DIR`、`REQUESTS_CA_BUNDLE`,靠它们上网的人照样连得上。 - **模式和个人设置照终端里的,模型和推理档是 Studio 的**:会话开出来用的是你自己的设置(Claude 的模式、放行规则、skills、插件;Codex 的模式;DeepSeek Harness 桌面版的模型)。模型和推理档:新开的对话先用你上次在 Studio 里给这一家挑的(这台电脑上记一份,在适配器所在的文件夹里,`$OVH_AGENTS_DIR/picks.json`,不进项目),没挑过就用 Studio 的默认:Claude Code 是 Opus 5.5、推理档 xhigh(照 agent 报上来的选项认:名字是 Opus 5.5 或者值是 `claude-opus-5-5` 的模型,值是 `xhigh` 的推理档;它不报这两样就用它自己的默认),Codex 用它自己的,DeepSeek Harness 的推理档取桌面版的设置。只设 agent 自己报上来的值、它接受了才记下;正在说话的对话不会在背后被改(接回的对话什么都不设;接不回、只好重开的,和新对话一样)。挑的只给这一次对话用,不改你在终端里的默认(读过钉住的适配器源码,2026-11-17):Claude Code 的模型走 `set_model`,是这个会话里的覆盖,推理档进的是内存里的 flag 设置层,适配器不发写设置文件的 `update_settings`;Codex 只改适配器内存里这个会话的状态,下一轮带过去;DeepSeek Harness 记在这个对话自己的记录里,而且它用的是控制台自己的 `DSH_HOME`,不是你的 `~/.dsh`。顶上一行的“模型”“思考深度”是两个菜单,改了就是这个对话用的,也记成下一次新对话的起点;模式和其余设置收在旁边一个按钮里。开新对话的框里(还没开过对话时,在“和它说话”那一页上)写着会用什么开始,这次运行里见过它的选项时就是两个菜单,在那里挑的只给这个新对话用、也记下来。推理档越高,想得越久,用掉你订阅的额度也越多:在顶上的“思考深度”里调低就行,下一次新对话也从这一档开始。Claude 开新对话时可以关掉“带上我的个人设置”:只读项目自己的设置(`settingSources: project, local`),实测你的 42 个个人 skill、插件带的子 agent 都不带了;模式仍是 Claude Code 自己的默认(没有设置时它从"自己判断"开始),可以在顶上改。 - **一个会话的记录**:每一件事是一个事件,追加写进 `<项目>/.ovh/agents/.jsonl`(`.json` 是它的头:哪家 agent、它自己的会话号、带没带个人设置):你说的话、agent 的每一条更新(边写边出的文字、想法、工具调用和它的改动、计划、上下文用量和花费)、每一次请你批准和怎么答的、每一轮的开始和结束。项目里的路径写成相对路径,家目录写成 `~`,太长的输出截短(agent 自己的话和请你批准的内容不截;请你批准的那一条原样记,路径也不改写:`cd /tmp && rm -rf <项目>/x` 改写成相对路径就成了另一条命令);agent 列出的个人 skill 只记个数,Claude 的"子 agent"设置只记在用的那一个和一共几个(名字来自你的插件);边写边出的文字隔 0.12 秒并成一条记(一轮几万个碎片不会变成几万行)。这个文件夹里有一个内容是 `*` 的 `.gitignore`:放在自己 git 仓库里的项目,`git add -A` 也不会把对话加进去。页面用 SSE(`EventSource`,带 Last-Event-ID)读它:关了重开、断了重连,补上错过的,没答的批准卡重新出现。服务重启后,会话从这份记录读回来;接着说话时,能接回原会话的(Claude、Codex 的 `session/load`,DeepSeek Harness 的 `session/resume`)就接回,接不回的开新的并写一句"它记不得前面的话"。 -- **画什么**:你说的话(带着"对着"什么);agent 的文字边到边显示(DeepSeek Harness 是整段一起到,中间显示"在做,回复会整段一起到"和它正在用的工具);每个工具调用一张卡:读了哪个文件、跑了什么命令、改了哪里(有改动对比的画对比),输出折起来;请你批准时一张琥珀色的卡,把请求里的东西一样不少摆出来:它给这一步起的标题,输入里的每一个字段(键和值原样、转义过;认识的配一句人话,比如 `dangerouslyDisableSandbox` 是"不用沙箱跑"、`run_in_background` 是"在后台跑",`description` 标明是"它自己的说明",不认识的原样列出),涉及的位置,它附的话,改动对比(不截)。这些放在一个限高、能滚动的框里,不做首尾拼接;框装不下时,"允许"那几个按钮要等你滚到底、或点"全部展开"才能点,旁边写着为什么,"不行"随时能点。一条请求长到这里显示不全(一个字段超过 20 万字),就只能拒绝,服务端也这样拦。按钮用这一页的话(允许这一次、这个对话里同类的都允许、不允许……),下面并排写着它给的选项原文(它可能写明一个选项管到哪儿);问题就放在那个工具的卡里;它在等时输入框上面多一条"在等你批准",点一下回到那张卡;它的计划;想法折起来;不认识的消息按通用样子显示(名字和原样内容),不报错。顶上写着它现在在干什么(在想、在跑某条命令、在写回复、等你批准)和几秒了;下面一行是“模型”“推理”两个菜单和一个写着模式的按钮(点开是模式和其余设置),右边是上下文用量和这个对话的花费(agent 报了才有);额度警告(比如 Claude 订阅 7 天额度用到多少、哪天恢复)只在 agent 报了警告时单独一行;没登录或登录过期时,写清怎么登录。被你拒绝的命令写成"你没允许,所以没做",请求照样完整显示。 +- **画什么**:你说的话(带着"对着"什么);agent 的文字边到边显示(DeepSeek Harness 是整段一起到,中间显示"在做,回复会整段一起到"和它正在用的工具);每个工具调用一张卡:读了哪个文件、跑了什么命令、改了哪里(有改动对比的画对比),输出折起来;请你批准时一张琥珀色的卡,把请求里的东西一样不少摆出来:它给这一步起的标题,输入里的每一个字段(键和值原样、转义过;认识的配一句人话,比如 `dangerouslyDisableSandbox` 是"不用沙箱跑"、`run_in_background` 是"在后台跑",`description` 标明是"它自己的说明",不认识的原样列出),涉及的位置,它附的话,改动对比(不截)。这些放在一个限高、能滚动的框里,不做首尾拼接;框装不下时,"允许"那几个按钮要等你滚到底、或点"全部展开"才能点,旁边写着为什么,"不行"随时能点。一条请求长到这里显示不全(一个字段超过 20 万字),就只能拒绝,服务端也这样拦。按钮用这一页的话(允许这一次、这个对话里同类的都允许、不允许……),下面并排写着它给的选项原文(它可能写明一个选项管到哪儿);问题就放在那个工具的卡里;它在等时输入框上面多一条"在等你批准",点一下回到那张卡;它的计划;想法折起来;不认识的消息按通用样子显示(名字和原样内容),不报错。顶上写着它现在在干什么(在想、在跑某条命令、在写回复、等你批准)和几秒了;下面一行是“模型”“推理”两个菜单和一个写着模式的按钮(点开是模式和其余设置),右边是上下文用量和这个对话的花费(agent 报了才有);额度警告(比如 Claude 订阅 7 天额度用到多少、哪天恢复)只在 agent 报了警告时单独一行;没登录或登录过期时,写清怎么登录,每一段只在屏幕上说一次:先来的那一条(它报的"没登录"、它自己说的没登录的话、没做成的这一句,停下了的也算)说怎么登录,它自己的原话折起来;后面的只说这一句没做,直到有一句好好做完了(又登录上了;停下的不算)。被你拒绝的命令写成"你没允许,所以没做",请求照样完整显示。 - **停止**:先把没答的批准都回成取消,再让这一轮停下。适配器收到停止以后 `OVH_AGENT_STOP_GRACE` 秒(默认 8)还没结束这一轮,就在这里结束它、放掉项目锁、重启这个适配器(接着说话时接回原对话),这一列写清发生了什么;不会因为一个不理停止的适配器把项目锁上几个小时。 - **输入框**:回车发送,Shift+回车换行(输入法选字时的回车不算);"对着"跟着你在模块里选中的东西,发出去时附一句控制台自己写的说明(哪一镜、哪一段时间、哪个模块),不带项目文件里的文字。 - **项目锁**:一轮开始前查四样,有就不发,写清是谁占着:控制台里别的对话(`<项目>/.ovh/agent.lock`,一轮进行时拿着,O_EXCL 建,进程不在了就当没锁);终端里正在跑的 `bin/vh` 命令(活动记录,控制台自己的 agent 起的不算);终端里一个 agent 在等这一轮的提交(`bin/vh desk wait` 或 `bin/vh gate --wait` 的 `.listening`;等着的那条 `bin/vh gate` 不另算成在跑的命令);文件夹里开着的 agent 程序(`lsof` 找得到时:在这个文件夹起的 claude、codex,以及用 node、python 跑的 dsh 这类命令行)。后两种不一定在改东西,你可以点"仍然发这一句"(话里写明两边可能改到同一处);前两种直接不发。锁是建议性的,和 `bin/vh` 其他命令各自的锁(混音的、素材台账的、反馈的)不共用文件,互不等待。 @@ -124,6 +125,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 | `GET /api/hello` | 页面手里的令牌是不是这一次运行的(`X-Desk-Token`):200 是;403 `{ok: false, reopen: true}` 不是(控制台重启过,或者这个页面不是从窗口打开的):Studio 自己的窗口这时自己换一个新窗口,别的页面给一个"在 Studio 窗口里打开"的按钮 | | `GET /static/<文件>` | `ui.css`、`ui.js`(关卡视图的,静态页内嵌的是同两份)、`studio.css`、`studio.js`(控制台的外壳和成片模块)、`modules.css`、`modules.js`(其余模块)、`core.js`(控制台和静态页共用的文字和小函数) | | `GET /api/projects` | `{version, home, roots, count, waiting, projects}`:`bin/vh projects` 的每一行,等人的在前,其余按最后一次动静从新到旧,交付了的在最后;加 `key`(地址里的项目键,见下面)、`picture`(`{path, kind: image \| video, from, href}`:封面,`bin/vh thumbs` 的镜头图,片子本身,联系表,关卡页里的图,分镜关键帧,最新的一张图,只取在的文件)、`ask`(等人时:`{gate, title, title_en, question, questions, summary, decisions}`:`questions` 是这一页的问题,最多四个,`summary` 是这一页的那一句);`title` 在 BRIEF 没写片名时取最新一页关卡页的标题里关卡名之前的那一段 | +| `GET /samples/.jpg`、`.mp4` | 空间的样片墙(`server.py` 的 `SAMPLES`,四支,`short`、`math`、`handdrawn`、`launch`):官网那张封面图;片子本身,在 `tools/media.txt` 写的位置、这份克隆里真有时(没有、或是链到克隆外面的,都 404;`GET /api/projects` 的 `samples` 用同一个判断列出给得出的那几支)。只给这几个文件,克隆里别的一概不给 | | `GET /api/p/<键>/data` | `bin/vh desk data` 的内容,加 `status`(`bin/vh status --json`)、`key`、`home`、`pid`(这个项目文件夹的身份:真实路径的 SHA-1,提交要带上)、`only`、`current`(这一轮的页名)、`round_open`(这一轮那一站还没定:不是 done、skipped;这时提交带上它还没交过、或交过以后改了的决定),和 `studio`(`film` 是成片模块播的那一支,只取在的文件;这一站没点名片子、`bin/vh status` 的那支又没有声音、BRIEF 也没说要无声片时,换成有声音、而且不比它旧的一支(分镜的 animatic、关卡页的 film 或 animatic,新的页在前;`bin/vh status` 本身不变);换了时 `film_instead` 是没放的那支,缩略图、波形和检查的问题都是那支的,不给(读数写明放的是哪个文件,不写第几版);`film_sound` 是它有没有声音(true、false,ffprobe 看不了是 null;一个文件只看一次,大小和时间不变就记着);要的那支不在时,`film_missing` 是它的路径;`sheet` 是最新的联系表;成片模块用的:`timeline` 是 `bin/vh timeline --resolved` 的内容;`thumbs`、`peaks` 是 `bin/vh thumbs`、`peaks` 做过才有的记录;`check` 和 `findings` 是最近一次检查的结论和带时间的问题,没过和要注意的;读不出来的那一样是 `null`,原因记在 `warnings`),和 `mods`(其余模块读的,都是已有命令写下的文件:`loudness` `{integrated, true_peak, lra, target, severity}` 和 `silences`、`checks`(最近一次检查的每条 finding:`kind, severity, message, t, t1`);`pace`(旁白时间轴里 `bin/vh pace` 写的 `reference, unit, speech, with_pauses` 和逐句的 `lines`)、`voice`(旁白用的音色)、`audition`(最新的 `audition.json`:`{file, provider, unit, text, voices: [{voice, file, duration, pitch_hz, speech_rate, misread, error}]}`)、`lifts`(最新的 `*.beats.json` 的候选落点);`covers` `[{path, ratio, id, text}]`、`subs`(字幕文件);`assets`(台账里没删的每一件:`{id, kind, path, there, system, license, license_name, source, url, aigc, used_by, note}`;`system` 是系统自带的字体(`/System/Library/…`、`/Library/Fonts/`、Windows 的 Fonts 这些),算在,不算在项目外;没有台账是 `null`)、`refs`(`research/refs.json`)、`digests` `[{id, path, bytes}]`;没有台账时 `assets_notes` `{file, rows: [{file, source, license, there}]}` 是 NOTES.md 里旧的素材台账表(`there` 对链接是 `null`);每一部分各读各的:读不出的那部分是空的,`errors` 写着它的文件和原因,别的照样有;只读项目里面的文件,指到项目外的链接不跟,和 `/f/` 一样) | | `GET /api/p/<键>/gate/<页>[?lang=zh\|en]` | 那一页的关卡视图:`{version, gate, current, this_round, title, lang, takeall, html, errors, warnings, decisions: [{id, question, recommend, options}], summary, cards, marks, not_reviewed}`;`html` 和静态页同一份标记,文件地址换成 `/f/<键>/…`;`cards` 是所有决定的选项卡(右栏用,同一份标记),`marks` 是没把握和请你听的地方 `[{kind: least \| listen, t, t1, id, note, target}]` | | `GET /api/p/<键>/stage` | 不等人时的画面:`{kind: "video", path, html}`(同一个播放器和标尺),或 `{kind: "image", path, href}`,或 `{kind: null}` | diff --git a/tools/desk/fixtures/agents/fake_acp.py b/tools/desk/fixtures/agents/fake_acp.py index 39f0346f..01894b91 100644 --- a/tools/desk/fixtures/agents/fake_acp.py +++ b/tools/desk/fixtures/agents/fake_acp.py @@ -9,7 +9,8 @@ turn to stop, 计划/plan → a plan and an update kind no client knows, 想/think → codex's thoughts; anything else → reading BRIEF.md. A request to approve waits for the client's answer; a cancel ends the turn at once, as the real ones did. Like DeepSeek Harness, the dsh stand-in does not end when its stdin closes: only a signal stops it. --signed-out: as an agent -whose login expired (auth/status_update unauthenticated; a prompt answers with the adapter's words and fails). 卡住/"hang": +whose login expired (auth/status_update unauthenticated; a prompt answers with the adapter's words and fails); with +--late-auth it says so only after the failed prompt, as Claude Code's own login check can. 卡住/"hang": never answers the prompt and ignores the cancel, as a broken adapter would. Requests a hostile agent might make: 长命令/long-ask (the dangerous part at the end), 超长/huge-ask (too long to show), 藏命令/hidden-ask (a second command on a line of its own in the middle of a long one), 绕沙箱/no-sandbox (a short command with dangerouslyDisableSandbox and other fields). --stubborn-child: @@ -36,6 +37,7 @@ SPEED = float(sys.argv[sys.argv.index("--speed") + 1]) if "--speed" in sys.argv else float(os.environ.get("FAKE_ACP_SPEED") or 1.0) LOGIN_MARKER = Path(sys.argv[sys.argv.index("--login-marker") + 1]) if "--login-marker" in sys.argv else None SIGNED_OUT = "--signed-out" in sys.argv or (LOGIN_MARKER is not None and not LOGIN_MARKER.exists()) +LATE_AUTH = "--late-auth" in sys.argv # with --signed-out: says it is signed out only after the failed prompt (Claude Code's login check can) NO_OPUS = "--no-opus" in sys.argv FX = json.loads((HERE / f"{KIND}.json").read_text(encoding="utf-8")) CLAUDE = json.loads((HERE / "claude.json").read_text(encoding="utf-8")) @@ -329,7 +331,7 @@ def handle(msg): if m == "session/load": # a load replays the conversation as updates first send({"jsonrpc": "2.0", "method": "session/update", "params": {"sessionId": sid, "update": { "sessionUpdate": "user_message_chunk", "content": {"type": "text", "text": "(replayed)"}}}}) - if SIGNED_OUT: # the real adapter says so before it answers session/new + if SIGNED_OUT and not LATE_AUTH: # the real adapter says so before it answers session/new send({"jsonrpc": "2.0", "method": "auth/status_update", "params": {"state": "unauthenticated"}}) return send({"jsonrpc": "2.0", "id": rid, "result": dict(cfg, **({"sessionId": sid} if m == "session/new" else {}))}) if m == "session/set_mode": @@ -354,7 +356,11 @@ def handle(msg): if SIGNED_OUT: send({"jsonrpc": "2.0", "method": "session/update", "params": {"sessionId": sid, "update": {"sessionUpdate": "agent_message_chunk", "messageId": "m-auth", "content": {"type": "text", "text": "Failed to authenticate: OAuth session expired and could not be refreshed"}}}}) - return send({"jsonrpc": "2.0", "id": rid, "error": {"code": -32000, "message": "Authentication required"}}) + send({"jsonrpc": "2.0", "id": rid, "error": {"code": -32000, "message": "Authentication required"}}) + if LATE_AUTH: + time.sleep(0.3) + send({"jsonrpc": "2.0", "method": "auth/status_update", "params": {"state": "unauthenticated"}}) + return Path(os.environ.get("FAKE_ACP_LOG") or os.devnull).open("a").write(json.dumps({"prompt": p.get("prompt")}, ensure_ascii=False) + "\n") threading.Thread(target=run_turn, args=(rid, sid, text), daemon=True).start() return diff --git a/tools/desk/server.py b/tools/desk/server.py index cc72ec94..acae507d 100644 --- a/tools/desk/server.py +++ b/tools/desk/server.py @@ -21,6 +21,9 @@ studio.css and studio.js (the console's shell and the cut), modules.css and modules.js (the other modules), core.js (the words and helpers a static page shares) GET /api/projects every project: bin/vh projects' rows, each with its key, a picture, and what it waits for + (samples: which of the sample wall's films are in this clone) + GET /samples/.jpg|.mp4 the space's sample wall: a showcase film's poster (the homepage's), and the film itself once + tools/fetch_media.sh has put it in the clone; these and nothing else of the clone (SAMPLES) GET /api/p//data one project, read fresh: reader.read_project, plus bin/vh status (status), its key and what the cut module lays out (studio: the resolved timeline, thumbnails, peaks, findings), and what the other modules read besides (mods: loudness, voices, lifts, covers, the asset @@ -95,6 +98,28 @@ "agent.css": "text/css; charset=utf-8", "agent.js": "text/javascript; charset=utf-8", "reader.css": "text/css; charset=utf-8", "reader.js": "text/javascript; charset=utf-8", "settings.css": "text/css; charset=utf-8", "settings.js": "text/javascript; charset=utf-8"} +# GET /samples/.jpg|.mp4: the space's sample wall (studio.js SAMPLES): the repo's own showcase films, the same four the +# homepage shows, each with the homepage's poster, and the film itself once tools/fetch_media.sh has put it in this clone +# (found where tools/media.txt says that release file goes). These files and nothing else of the clone: the films are in no +# root, so /f/ cannot give them. +SAMPLES = {"short": ("docs/site/img/02-doppler.jpg", "02-vertical-science-short.mp4"), # the homepage's order + "math": ("docs/site/img/03-fourier.jpg", "03-math-explainer.mp4"), + "handdrawn": ("docs/site/img/01-clawd.jpg", "01-handdrawn-short.mp4"), + "launch": ("docs/site/img/00-launch.jpg", "00-launch-short.mp4")} + + +def sample_file(sid, kind): + """The clone's path of a sample's poster ("jpg") or film ("mp4", from tools/media.txt), or None.""" + if sid not in SAMPLES: + return None + poster, asset = SAMPLES[sid] + if kind == "jpg": + return poster + try: + rows = (WORKSPACE / "tools" / "media.txt").read_text(encoding="utf-8").splitlines() + except OSError: + return None + return next((r.split()[0] for r in rows if len(r.split()) == 3 and r.split()[1] == asset), None) # GET /v//: a project file on a page of its own (Studio's app opens the console's new-page links there) VIEW = {"image": {".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".avif", ".bmp"}, "video": {".mp4", ".mov", ".m4v", ".webm"}, "audio": {".mp3", ".wav", ".m4a", ".aac", ".ogg", ".oga", ".flac", ".opus"}, "page": {".html", ".htm"}, "markdown": {".md", ".markdown"}, @@ -1063,6 +1088,10 @@ def do_GET(self): return self._send(200, (HERE / "static" / path[8:]).read_bytes(), STATIC[path[8:]]) if path == "/api/projects": return self._projects() + m = re.fullmatch(r"/samples/([a-z]+)\.(jpg|mp4)", path) + if m and m.group(1) in SAMPLES: + f = sample_file(m.group(1), m.group(2)) + return self._file(WORKSPACE, f) if f else self._error(404, "no such sample") if path == "/api/hello": # does the page hold this run's token? (one from an earlier run does not count); if not, why, and the way out given = self.headers.get("X-Desk-Token", "").encode("utf-8", "replace") ok = secrets.compare_digest(given, srv.token.encode("ascii")) @@ -1277,7 +1306,8 @@ def _projects(self): -float((r.get("last_activity") or {}).get("t") or 0), r.get("name") or "") rows.sort(key=rank) self._json({"version": 1, "home": self.server.own_key, "roots": rec["roots"], "count": len(rows), - "waiting": sum(1 for r in rows if r.get("state") == "waiting_person"), "projects": rows}) + "waiting": sum(1 for r in rows if r.get("state") == "waiting_person"), "projects": rows, + "samples": [k for k in SAMPLES if (f := sample_file(k, "mp4")) and self._resolve(WORKSPACE, f)]}) # what /samples/ serves def _data(self, project, key): try: diff --git a/tools/desk/static/agent.css b/tools/desk/static/agent.css index c6d64c94..8637d69c 100644 --- a/tools/desk/static/agent.css +++ b/tools/desk/static/agent.css @@ -25,7 +25,7 @@ .ag-orb{width:9px;height:9px;border-radius:50%;background:var(--rule-2);flex:none} .ag-orb.agent{background:var(--agent);box-shadow:0 0 8px var(--agent)} .ag-orb.wait{background:var(--wait)}.ag-orb.live{background:var(--live)} -.ag-top select{max-width:150px;min-width:0;flex:0 1 auto;border:1px solid var(--rule-2);background:var(--panel-2);color:var(--ink-hi);font:500 var(--fs-small) var(--sans);padding:3px 6px;border-radius:var(--r-ctl)} +.ag-top select{flex:none;field-sizing:content;border:1px solid var(--rule-2);background:var(--panel-2);color:var(--ink-hi);font:500 var(--fs-small) var(--sans);padding:3px 6px;border-radius:var(--r-ctl)} .ag-state{flex:1 1 auto;font-size:var(--fs-small);color:var(--ink-2);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .ag-state.agent{color:var(--agent)}.ag-state.wait{color:var(--wait)}.ag-state.live{color:var(--live)} .ag-state .mono{font-size:11px;color:var(--ink-3);margin-left:4px} @@ -160,3 +160,8 @@ .ag-ask[hidden]{display:none} .ag-busy .ag-opts{margin-left:auto} @media (max-width:900px){.col.chat .agent{min-height:70vh}.ag-thread{max-height:60vh}} +/* the space's sample wall: the sentence the person picked, kept until the box can take it (an agent set up, the chat stopped) */ +.ag-offer{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:8px;padding:8px 10px;border:1px solid var(--you-line);background:var(--panel-2);color:var(--ink);font-size:var(--fs-label);line-height:1.55;border-radius:var(--r-card)} +.ag-offer[hidden]{display:none} +.ag-offer .ag-opts{margin-left:auto} +.ag-offer-keep{margin:10px 0 0;padding:8px 10px;border-left:2px solid var(--you-line);color:var(--ink);font-size:var(--fs-small);line-height:1.5} diff --git a/tools/desk/static/agent.js b/tools/desk/static/agent.js index a26da025..fff33186 100644 --- a/tools/desk/static/agent.js +++ b/tools/desk/static/agent.js @@ -56,6 +56,8 @@ const ASTR = { sp_own: "在开的新片子", sp_wait: "等你", sp_doing: "在做", stray: "从空间开的对话「{x}」可能就是做这支片子的,它还没跟过来。", stray_go: "把它带到这里", stray_fail: "没带过来:这支片子不像是那段对话建的", sp_h: "想做一支什么样的片子?", sp_b: "写一句发给 {a}:它照这个工作台的做法定类型、建好片子、先想立意。片子一建好,窗口就转过去,这段对话跟着过去。", sp_c: "它要停下来问你的,问题会出现在这里;它停在哪一站,那一站等你定的事也会摆出来。", sp_ph: "比如:做一支一分钟的科普,讲海水为什么一天涨两次", sp_copy: "复制给别处的 agent", sp_copied: "复制好了,贴给你的 agent", sp_empty: "先写一句", + of_keep: "你选的「{x}」那一句先留着:装上以后,在下面点一下就写进框里。", of_ready: "你选的「{x}」那一句:", of_go: "写进框里", of_no: "不用了", + of_busy: "空间里这段对话还在做,或在等你批准;它停下以后,再把「{x}」那一句写进新片子的框里。", of_moved: "开了新片子的框,之前那段对话在「历史」里", n_gone: "agent 的进程停了。再说一句会重新启动它。", n_signed_out: "{a} 还没登录,或者登录过期了:{l},再回来说一句就行。", n_unsupported: "agent 问了一件这一页还答不了的事,回了“不支持”。", n_restarted: "{a} 收到停止以后没有停下来:这一句在这里结束了,它也重新启动了(再说一句会接着这个对话)。", unknown: "{a} 发来一条这里还显示不了的更新(点开看原样)", working_dsh: "{a} 在做,回复会整段一起到", sec: "{n} 秒", min: "{m} 分 {s} 秒", m_default: "改动前都问", m_acceptEdits: "改文件不问", m_plan: "只出计划", m_auto: "危险的才问", m_bypassPermissions: "什么都不问", @@ -109,6 +111,8 @@ const ASTR = { sp_own: "New films under way", sp_wait: "waiting for you", sp_doing: "working", stray: "The chat begun on the space, “{x}”, may be the one that made this film; it hasn't followed it here.", stray_go: "Bring it here", stray_fail: "Not brought: this film doesn't look like that chat's", sp_h: "What film do you want to make?", sp_b: "Write a sentence to {a}: it works the way this workbench does, picks the kind of film, makes it and starts on the idea. Once the film is made, the window goes there and this chat goes with it.", sp_c: "When it stops to ask you something, the questions show here; when it stops at a step, what that step needs from you is laid out too.", sp_ph: "e.g. a one-minute explainer on why the tide comes in twice a day", sp_copy: "Copy for an agent elsewhere", sp_copied: "Copied: paste it to your agent", sp_empty: "Write a sentence first", + of_keep: "The “{x}” sentence you picked is kept: once it is set up, one click below puts it in the box.", of_ready: "The “{x}” sentence you picked:", of_go: "Put it in the box", of_no: "Not now", + of_busy: "The space's chat is still working, or waiting for your approval; once it stops, put the “{x}” sentence in a new film's box.", of_moved: "A new film's box is open; the earlier chat is in History", n_gone: "The agent's process stopped. Say something and it starts again.", n_signed_out: "{a} isn't signed in, or its login expired: {l}, then say something again.", n_unsupported: "The agent asked for something this page can't do yet; it was told no.", n_restarted: "{a} did not stop when asked: the turn was ended here and the agent restarted (say something to carry on in this chat).", unknown: "{a} sent an update this page can't show yet (open it to see it as sent)", working_dsh: "{a} is working; its reply comes in one piece", sec: "{n} s", min: "{m} min {s} s", m_default: "Ask before changes", m_acceptEdits: "Edit without asking", m_plan: "Plan only", m_auto: "Ask only if risky", m_bypassPermissions: "Never ask", @@ -290,6 +294,11 @@ const AGENT = (() => { } /* ---------- what the person does ---------- */ + let OFFER = null; // the sample the person picked on the space's wall while the box could not take it (no agent set up, the + // space's chat working or waiting for approval): kept here and offered again with one click, never put in the box by itself + const busyNow = () => !!(S && (S.running || Object.values(S.perms).some((p) => !p.answered))); + const offerName = () => (OFFER ? t(`smp_${OFFER}_type`) : ""); + function offerKept() { return OFFER && KEYP === SPACE ? `

${esc(at("of_keep", { x: offerName() }))}

` : ""; } let TELLING = ""; // the carry-on words a refused click was for: the busy line's "anyway" sends them, never the box's draft async function sayWords(text, despite) { const r = await post(`${S.id}/say`, { text, despite: !!despite }); @@ -523,12 +532,12 @@ const AGENT = (() => { const cmd = m.install || `bin/vh desk agents install ${KIND}`, j = m.installing || null, about = String(m.size || "").replace(/^≈\s*/, ""), h = `

${esc(at("not_inst_h", { a: m.label }))}

`; if (j && j.state === "running") { const s = Math.max(0, Math.round(Date.now() / 1000 - j.since)), took = s < 60 ? at("sec", { n: s }) : at("min", { m: Math.floor(s / 60), s: s % 60 }); - return `
${h}
${esc(at("inst_run", { a: m.label, s: about, t: took, m: Math.round((j.limit || 1800) / 60) }))}
${KEYOK ? `
` : ""}
`; + return `
${offerKept()}${h}
${esc(at("inst_run", { a: m.label, s: about, t: took, m: Math.round((j.limit || 1800) / 60) }))}
${KEYOK ? `
` : ""}
`; } const SAY = { failed: "inst_fail", no_npm: "inst_no_npm", timeout: "inst_timeout", cancelled: "inst_cancelled", busy: "inst_busy" }; // a sentence each, never what it printed const failed = !!(j && SAY[j.state]); const fall = j && j.state === "failed" ? `
${esc(cmd)}
` : ""; - return `
${h}${failed ? esc(at(SAY[j.state], { a: m.label, m: Math.round((j.limit || 1800) / 60) })) : at("not_inst_b", { s: esc(about), l })}

${fall}${KEYOK ? `
` : ""}
`; + return `
${h}${failed ? esc(at(SAY[j.state], { a: m.label, m: Math.round((j.limit || 1800) / 60) })) : at("not_inst_b", { s: esc(about), l })}

${fall}${KEYOK ? `
` : ""}${offerKept()}
`; } if (!KEYOK) return ""; // the note above the column says it once, with what to do const signedOut = KIND === "codex" && (ERR ? ERR.code === "signed_out" : !S && m.signed_in === false); @@ -546,7 +555,7 @@ const AGENT = (() => { function itemHtml(it) { const a = esc(label()); if (it.kind === "user") return `
${it.scope && it.scope.label ? `${esc(at("t_on", { x: cut(it.scope.label, 40) }))}` : ""}

${esc(it.text)}

`; - if (it.kind === "msg" && /^\s*(Failed to authenticate|Authentication required|Not logged in)/i.test(it.text)) return `
${esc(at("raw_said"))}
${md(it.text)}
`; + if (it.kind === "msg" && AUTH_MSG.test(it.text)) return `${HINTS.has(it.key) ? signInHint("warn") : ""}
${esc(at("raw_said"))}
${md(it.text)}
`; if (it.kind === "msg") return `
${a}
${md(it.text)}
`; if (it.kind === "thought") return it.text.trim() ? `
${esc(at("thought"))}
${md(it.text)}
` : ""; if (it.kind === "tool") { @@ -564,14 +573,13 @@ const AGENT = (() => { } if (it.kind === "plan") return `
${esc(at("plan_h"))}
    ${it.entries.map((p) => `
  1. ${esc(p.content || "")}
  2. `).join("")}
`; if (it.kind === "end") { + if (it.error && /auth/i.test(it.error)) return HINTS.has(it.key) ? signInHint("bad") : `

${esc(at("turn_signed_out"))}

`; // "Authentication required", a stopped turn too if (it.stop === "cancelled") return `

${esc(at(it.asked ? "turn_cancelled" : "turn_halted"))}${it.took ? " · " + esc(secs(it.took)) : ""}

`; // Codex ends a turn so after a refusal - if (it.error && /auth/i.test(it.error)) return S.items.some((x) => x.kind === "notice" && x.code === "signed_out") ? `

${esc(at("turn_signed_out"))}

` - : `

${esc(at("n_signed_out", { a: label(), l: at("login_" + KIND) }))}

`; // "Authentication required" if (it.error === "agent_stuck") return ""; // the notice after it says what happened if (it.error) return `

${esc(it.error === "agent_gone" ? at("turn_gone") : it.error === "desk_restart" ? at("turn_restart") : at("turn_error", { e: cut(it.error, 160) }))}

`; return it.took ? `

${esc(at("turn_took", { s: secs(it.took) }))}

` : ""; } - if (it.kind === "notice" && it.code === "signed_out") return `

${esc(at("n_signed_out", { a: label(), l: at("login_" + KIND) }))}

`; + if (it.kind === "notice" && it.code === "signed_out") return HINTS.has(it.key) ? signInHint("warn") : ""; if (it.kind === "notice" && it.code === "place_busy") return `

${esc(at("n_place_busy", { x: it.name || "", w: it.who || "?" }))}

`; if (it.kind === "notice" && it.code === "placed") return `

${esc(at("n_placed", { x: it.name || "" }))}

`; if (it.kind === "notice" && /^own/.test(it.code || "")) return `

${esc(at("n_" + it.code, { a: label() }))}

`; @@ -580,6 +588,21 @@ const AGENT = (() => { if (it.kind === "unknown") return `
${esc(at("unknown", { a: label() }))}
${esc(cut(JSON.stringify(it.u, null, 1), 2000))}
`; return ""; } + const AUTH_MSG = /^\s*(Failed to authenticate|Authentication required|Not logged in|Invalid API key)/i; // the agent's own words for it + let HINTS = new Set(); // the lines that say how to sign in (loginHints): the others say it no more + const signInHint = (cls) => `

${esc(at("n_signed_out", { a: label(), l: at("login_" + KIND) }))}

`; + function loginHints(items) { // how to sign in, said once a stretch, and always once: the first sign of it (the agent's "not + // signed in" notice, its own words for it, a turn that failed for it, a stopped one too) says how; the ones after it only that the + // sentence wasn't done (a turn), or nothing (a notice; its words stay folded), until a turn ends well (signed in again; a stopped + // turn is not that). Decided in order, so a notice that comes after the failed turn (Claude Code's login check can) doesn't say it twice + const out = new Set(); let said = false; + for (const x of items || []) { + const auth = (x.kind === "notice" && x.code === "signed_out") || (x.kind === "end" && x.error && /auth/i.test(x.error)) || (x.kind === "msg" && AUTH_MSG.test(x.text || "")); + if (auth) { if (!said) out.add(x.key); said = true; } + else if (x.kind === "end" && !x.error && x.stop !== "cancelled") said = false; + } + return out; + } function permOf(toolId) { let out = null; for (const p of Object.values(S.perms)) if (p.tool && p.tool.toolCallId === toolId) out = p; return out; } function askHead(pm) { return `
${esc(at("perm_h", { a: label(), v: verbWords(pm.tool || {}) }))}${pm.answered ? "" : `${esc(at("perm_wait"))}`}
`; } const FIELD = { command: "f_command", description: "f_description", timeout: "f_timeout", file_path: "f_file", path: "f_file", notebook_path: "f_file", @@ -649,7 +672,7 @@ const AGENT = (() => { : at({ stop: "perm_by_stop", timeout: "perm_by_timeout", agent_gone: "perm_by_gone", desk_restart: "perm_by_restart", turn_end: "perm_by_turn", desk_stop: "perm_by_desk" }[ans.by] || "perm_by_turn", { m: Math.round(((INFO && INFO.approval_timeout) || 600) / 60) }); return `

${esc(by)}

`; } - const DOM = new Map(); // an item's key → [its version, its element]: only what changed is drawn again + const DOM = new Map(); // an item's key → [its version, its element, whether it says how to sign in]: only what changed is drawn again function renderThread() { const th = $("#agThread"); if (!th) return; if (!S || !S.items.length || NEWBOX) { @@ -662,15 +685,16 @@ const AGENT = (() => { const stick = th.scrollHeight - th.scrollTop - th.clientHeight < 40; if (th.querySelector(".ag-empty, .ag-new")) th.innerHTML = ""; const wk = th.querySelector(".ag-working"); if (wk) wk.remove(); + HINTS = loginHints(S.items); for (const it of S.items) { - const was = DOM.get(it.key); - if (was && was[0] === it.v && was[1].isConnected) continue; + const was = DOM.get(it.key), hint = HINTS.has(it.key); + if (was && was[0] === it.v && was[2] === hint && was[1].isConnected) continue; const box = document.createElement("div"); box.className = "ag-item"; box.dataset.k = it.key; const open = was ? [...was[1].querySelectorAll("details")].map((x) => x.open) : []; box.innerHTML = itemHtml(it); [...box.querySelectorAll("details")].forEach((x, i) => { if (open[i]) x.open = true; }); if (was && was[1].isConnected) was[1].replaceWith(box); else th.appendChild(box); - DOM.set(it.key, [it.v, box]); + DOM.set(it.key, [it.v, box, hint]); } if (S.running) th.insertAdjacentHTML("beforeend", workingHtml()); wireThread(th); @@ -738,7 +762,7 @@ const AGENT = (() => { const ready = !!(f.dataset.ready); if (!ready) { f.dataset.ready = "1"; - f.innerHTML = `
${esc(t("at"))}
+ f.innerHTML = `
${esc(t("at"))}
`; const ta = $("#agSay"); ta.value = store_.get(`desk:agent:say:${KEYP}`) || ""; @@ -752,6 +776,8 @@ const AGENT = (() => { f.addEventListener("click", (e) => { if (e.target.closest("#agAnyway")) again(e); else if (e.target.closest("#agNotNow")) { BUSY = null; TELLING = ""; renderFoot(); } + else if (e.target.closest("#agOfferGo")) offer(e, OFFER); + else if (e.target.closest("#agOfferNo")) { OFFER = null; render(); } else if (e.target.closest("#agAsk")) { const c = $("#agThread .ag-perm:not(.done)"); if (c) c.scrollIntoView({ block: "center", behavior: reduced() ? "auto" : "smooth" }); } }); } @@ -765,6 +791,10 @@ const AGENT = (() => { const waitp = S ? Object.values(S.perms).filter((p) => !p.answered) : []; const ask = $("#agAsk"); ask.hidden = !waitp.length; ask.textContent = waitp.length ? at("ask_bar", { a: label(), x: cut(toolTitle(Object.assign({}, (S.tools[(waitp[0].tool || {}).toolCallId] || {}).d || {}, waitp[0].tool || {})) || verbWords(waitp[0].tool || {}), 48) }) + " ↑" : ""; + const of = $("#agOffer"), ofOn = !!(OFFER && sp && KEYOK && meta(KIND).installed); // not set up: the install panel says it + of.hidden = !ofOn; + const ofHtml = ofOn ? `${esc(at(busyNow() ? "of_busy" : "of_ready", { x: offerName() }))}${busyNow() ? "" : ``}` : ""; + if (of.dataset.html !== ofHtml) { of.innerHTML = ofHtml; of.dataset.html = ofHtml; } const bz = $("#agBusy"); bz.hidden = !busy; bz.innerHTML = busy ? `${esc(busy)}${anyway ? `` : ""}` : ""; } @@ -782,9 +812,10 @@ const AGENT = (() => { clearInterval(SPACETICK); SPACETICK = setInterval(async () => { if (KEYP !== SPACE) return clearInterval(SPACETICK); - const sig = () => JSON.stringify(((INFO && INFO.sessions) || []).map((x) => [x.id, x.running, x.pending])); + const sig = () => JSON.stringify([((INFO && INFO.sessions) || []).map((x) => [x.id, x.running, x.pending]), kinds().map((k) => k.installed)]); const before = sig(); if (!(await load()) || KEYP !== SPACE || sig() === before) return; + if (meta(KIND).installed && ERR && ERR.code === "not_installed") { ERR = null; renderFoot(); } // set up from a terminal meanwhile renderHead(); if (!S || !S.items.length) renderThread(); }, 4000); } @@ -796,6 +827,35 @@ const AGENT = (() => { const ta = $("#agSay"); if (ta) ta.focus(); } + async function offer(e, id) { // the space's sample wall (studio.js): the person's click puts that sample's sentence (Studio's own + // words, core.js smp__say, never a page's or a file's) in the box for a new film, and sends nothing. A box that can't be typed in + // is not filled: a page that can only look says so; with no agent set up the sample is kept, the install panel says it and comes + // into view; while the space's chat works or waits for approval, it stays (a line under the box offers the sentence once it stops). + // An idle chat open on the space gives way to a new film's box (it stays in the history: said so); what the person had written is + // replaced as typing would (⌘Z brings it back); a […] to fill in is selected + const sample = /^[a-z]+$/.test(String(id || "")) ? word(`smp_${id}_say`) : null; + if (!e || !e.isTrusted || KEYP !== SPACE || typeof sample !== "string") return false; + if (!KEYOK) { toast(t("nokey")); return false; } + const keep = (where) => { OFFER = id; render(); const el = $(where); if (el) el.scrollIntoView({ block: "nearest", behavior: reduced() ? "auto" : "smooth" }); return false; }; + if (!meta(KIND).installed) return keep("#agThread .ag-empty"); + if (busyNow()) return keep("#agOffer"); + const moved = !!(S && S.items.length); + if (moved) await fresh(); + const ta = $("#agSay"); + if (!ta || ta.disabled) return keep("#agOffer"); + OFFER = null; renderFoot(); + ta.focus(); ta.select(); + let typed = false; + try { typed = document.execCommand("insertText", false, sample) && String(ta.value) === sample; } catch (x) { typed = false; } + if (!typed) ta.value = sample; + store_.set(`desk:agent:say:${KEYP}`, ta.value); + const m = /[[^]]*]|\[[^\]]*\]/.exec(sample); + if (m) ta.setSelectionRange(m.index, m.index + m[0].length); else ta.setSelectionRange(sample.length, sample.length); + ta.scrollIntoView({ block: "nearest" }); + toast(moved ? at("of_moved") : t("smp_filled")); + return true; + } + /* ---------- the column's two tabs: this conversation, this round ---------- */ function tabs() { const bar = $("#colTabs"); if (!bar) return; @@ -842,6 +902,7 @@ const AGENT = (() => { token(t) { TOKEN_ = t; }, // the token the page got after it loaded: its code traded, or another tab's of this run (studio.js) lang() { if (KEYP) { const f = $("#agFoot"); if (f) f.dataset.ready = ""; const h = $("#agHead"); if (h) h.dataset.ready = ""; const b = $("#colTabs"); if (b) b.dataset.html = ""; DOM.clear(); render(); } }, tabs, setTab, fresh, + offer, listening(on) { if (LISTEN !== !!on) { LISTEN = !!on; if (KEYP && KEYP !== SPACE) renderHead(); } }, async tell(e, text) { // Studio's own button (the column's one action): its own words (bin/vh status's, Studio's word table and numbers), sent in this // film's conversation, the newest one, else a new one; the box keeps the person's draft (it is filled only by them) @@ -853,6 +914,7 @@ const AGENT = (() => { }, _again: (e) => again(e), // for tools/desk/test_agents.py (node): the busy line's "anyway" after a refused carry-on busy: () => !!(S && S.running && KEYP !== SPACE), // a turn in this film's column now (the flow strip's agent lamp) - _md: md, _diff: diffLines, _ask: (pm, d) => askHtml(pm, d), _defaultKind: defaultKind, _state: () => (S ? { id: S.id, items: S.items.length, seq: S.seq, es: ES ? ES.readyState : null, url: ES ? ES.url.replace(/token=[^&]*/, "token=…") : null } : null), // for tools/desk/test_agents.py (node): the escaping and the diff, without a page + _md: md, _diff: diffLines, _hints: (items) => [...loginHints(items)], + _draw: (items) => { const keep = [S, KIND]; S = blank({ id: "t", kind: "claude" }); KIND = "claude"; items.forEach((x) => { x.v = 1; S.items.push(x); S.index[x.key] = x; }); HINTS = loginHints(S.items); const out = S.items.map(itemHtml); [S, KIND] = keep; return out; }, _ask: (pm, d) => askHtml(pm, d), _defaultKind: defaultKind, _state: () => (S ? { id: S.id, items: S.items.length, seq: S.seq, es: ES ? ES.readyState : null, url: ES ? ES.url.replace(/token=[^&]*/, "token=…") : null } : null), // for tools/desk/test_agents.py (node): the escaping and the diff, without a page }; })(); diff --git a/tools/desk/static/core.js b/tools/desk/static/core.js index ba946715..f24fdd93 100644 --- a/tools/desk/static/core.js +++ b/tools/desk/static/core.js @@ -21,7 +21,19 @@ const STR = { th_darkfield: "暗场", th_prism: "棱镜", th_bridge: "舰桥", skip: "跳到内容", rail: "模块", flow: "这支片子的几站", ask_prefix: "用 OpenVideoHarness 做一支片子:", films: "片子", home_meta: "{n} 支 · {w} 支等你", home_meta0: "{n} 支", g_wait: "等你看", - no_projects: "这里还没有片子。在右边写一句想做什么,agent 就开一支。", + no_projects: "这里还没有片子。写一句想做什么,agent 就开一支。", + smp_h: "照着样片开始", + smp_b: "工作台自己做的几支片子。点「照这个做一支」,开新片子的框里就写好一句话:换成你的题目再发送。点它不会开始做。", + smp_go: "照这个做一支", smp_filled: "写进开新片子的框里了:换成你的题目,再发送", + smp_secs: "{s} 秒", smp_tall: "竖屏", smp_wide: "横屏", smp_style: "风格", + smp_short_type: "竖屏科普", smp_short_style: "深墨蓝底、扁平图形、一种橙色强调", + smp_short_say: "快速出一版 25 秒的竖屏科普,讲为什么天空是蓝的。", + smp_math_type: "数学讲解", smp_math_style: "暗底数学", + smp_math_say: "快速出一版 25 秒的数学讲解,用「暗底数学」风格(styles/dark-math):为什么从 1 开始的连续奇数加起来总是平方数。", + smp_handdrawn_type: "手绘短片", smp_handdrawn_style: "水彩田园", + smp_handdrawn_say: "快速出一版 12 秒的手绘小短片,用「水彩田园」风格(styles/watercolor-pastoral):一只猫追着一架被风吹走的纸飞机。", + smp_launch_type: "发布短片", smp_launch_style: "产品发布片", + smp_launch_say: "快速出一版 20 秒的发布短片,用「产品发布片」风格(styles/product-keynote),镜头参考配方 zoom-through、cut-the-curve、oversized-cursor,介绍我的开源项目:[在这里贴上它的链接]。", st_waiting_person: "等你看", st_waiting_agent: "agent 在做", st_in_progress: "在做", st_delivered: "已交付", st_paused: "暂停", st_no_record: "没有审阅记录", st_not_started: "没开始", st_skipped: "跳过", st_done: "已定", agent_list: "agent 在做", @@ -166,7 +178,19 @@ const STR = { search: "Find a film", search_ph: "Title, folder or type; Enter opens it", no_match: "No film matches", lang: "中", lang_tip: "切换到中文", themes: "Theme", th_darkfield: "Darkfield", th_prism: "Prism", th_bridge: "Bridge", skip: "Skip to content", rail: "Modules", flow: "This film's stops", ask_prefix: "Make a film with OpenVideoHarness: ", films: "Films", home_meta: "{n} · {w} waiting for you", home_meta0: "{n}", g_wait: "Waiting for you", - no_projects: "No films here yet. Write what you want to make on the right, and an agent starts one.", + no_projects: "No films here yet. Write what you want to make, and an agent starts one.", + smp_h: "Start from a sample", + smp_b: "Films this harness made. Press “Make one like this” and the new film's box gets a sentence: put your own subject in, then send it. Pressing it starts nothing.", + smp_go: "Make one like this", smp_filled: "It's in the new film's box: put your own subject in, then send it", + smp_secs: "{s} s", smp_tall: "vertical", smp_wide: "landscape", smp_style: "Style", + smp_short_type: "Vertical science short", smp_short_style: "deep ink-blue ground, flat shapes, one orange accent", + smp_short_say: "Quick draft: a 25-second vertical science short on why the sky is blue.", + smp_math_type: "Math explainer", smp_math_style: "Dark Math", + smp_math_say: "Quick draft: a 25-second math explainer in the Dark Math style (styles/dark-math), on why the odd numbers from 1 always add up to a square.", + smp_handdrawn_type: "Hand-drawn short", smp_handdrawn_style: "Watercolor Pastoral", + smp_handdrawn_say: "Quick draft: a 12-second hand-drawn short in the Watercolor Pastoral style (styles/watercolor-pastoral) of a cat chasing a paper plane the wind carries off.", + smp_launch_type: "Launch short", smp_launch_style: "Product Keynote", + smp_launch_say: "Quick draft: a 20-second launch short in the Product Keynote style (styles/product-keynote), with the recipes zoom-through, cut-the-curve and oversized-cursor, for my open-source project, [paste its link here].", st_waiting_person: "waiting for you", st_waiting_agent: "agent working", st_in_progress: "in progress", st_delivered: "delivered", st_paused: "paused", st_no_record: "no review record", st_not_started: "not started", st_skipped: "skipped", st_done: "decided", agent_list: "The agent is on", diff --git a/tools/desk/static/studio.css b/tools/desk/static/studio.css index 0d0b4e79..4b0d1260 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -143,6 +143,26 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .pcard-meta .mono{font-size:11px} .pcard-ask{font-size:var(--fs-small);color:var(--ink-2);line-height:1.45;padding-left:9px;border-left:2px solid var(--wait)} .pcard .err{font-size:var(--fs-label);color:var(--live)} +/* the sample wall (studio.js wallHtml): the showcase films under your own, folded once you have some; the button puts a sentence in the box */ +.smp-wall{margin-top:34px} +.smp-wall>summary{list-style:none;cursor:pointer}.smp-wall>summary::-webkit-details-marker{display:none} +.smp-wall>summary>h2{display:flex;align-items:baseline;gap:10px;margin:0 0 12px;font:500 var(--fs-small)/1.4 var(--sans);color:var(--ink-2);letter-spacing:var(--label-track);text-transform:var(--label-case)} +.smp-wall>summary>h2::before{content:"▸";color:var(--ink-2);font-size:14px;transition:transform .16s var(--ease)} +.smp-wall[open]>summary>h2::before{transform:rotate(90deg)} +.smp-wall>summary:hover>h2{color:var(--ink)} +.smp-wall>summary>h2::after{content:"";flex:1;border-top:1px solid var(--rule);transform:translateY(-4px)} +.smp-wall h2 .n{font-family:var(--mono);color:var(--ink-3)} +.smp-cards{grid-template-columns:repeat(auto-fill,minmax(190px,1fr))} /* the four side by side on a laptop */ +.smp-b{margin:0 0 16px;max-width:46em;font-size:var(--fs-small);color:var(--ink-2);line-height:1.55} +.smp .well img{position:relative} +.smp .well.tall img,.smp .well.tall video{object-fit:contain} +.smp .well video{position:absolute;inset:0;opacity:0;transition:opacity .2s var(--ease)} +.smp:hover .well video{opacity:1} +.smp-style{font-size:var(--fs-label);color:var(--ink-2);line-height:1.45} +.smp-style code{font-size:11px;color:var(--ink-3);white-space:nowrap} +.pcard.smp{display:flex;flex-direction:column} /* the buttons on one line, whatever the lines above them */ +.smp-act{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:2px} +@media (prefers-reduced-motion:reduce){.smp .well video{transition:none}} .roots{margin-top:26px;font-size:var(--fs-label);color:var(--ink-3)} .lacks{margin:-4px 0 22px;padding:10px 14px;border:1px solid var(--rule);border-radius:var(--r-card);background:var(--panel);font-size:var(--fs-small);color:var(--ink-2);max-width:62em} .lacks h2{margin:0 0 4px;font:500 var(--fs-label)/1.4 var(--sans);color:var(--ink-3)} diff --git a/tools/desk/static/studio.js b/tools/desk/static/studio.js index f9691893..a4acfe8a 100644 --- a/tools/desk/static/studio.js +++ b/tools/desk/static/studio.js @@ -198,14 +198,51 @@ async function showHome(quiet) { ${sect("g_wait", wait, `
${wait.map(heroCard).join("")}
`)} ${sect("g_doing", doing, `
${doing.map(card).join("")}
`)} ${sect("g_done", done, `
${done.map(card).join("")}
`)} + ${wallHtml(rows.length)} ${roots.length ? `

${esc(t("roots_n", { n: roots.length }))}

` : ""}`; const area = $("#stage"), y = area.scrollTop; area.innerHTML = html; if (quiet) area.scrollTop = y; - midFrames(area); hoverClips(area); spaceRunning(); + midFrames(area); hoverClips(area); spaceRunning(); wallWire(area); machine(); clearTimeout(homeTimer); homeTimer = setTimeout(() => { if (parse().view === "home") showHome(true); }, 15000); } +/* the sample wall: the repo's own showcase films, the four the homepage shows (docs/site/index.html), each with the homepage's + poster and "make one like this" sentence (core.js smp_*; tools/desk/test_wording.py holds the two to each other). Its one + button puts the sentence in the space's box for a new film and starts nothing. An empty space shows it open, as the page; + with films of your own it is folded under them, one click away; so is it where the column drops under the page (≤ 900 px: + four full-width cards would push the box a few screens down). This viewer's own open or close is kept */ +const SAMPLES = [ // the server gives each poster and film at /samples/.jpg|.mp4 (server.py SAMPLES); the numbers are the films' own + { id: "short", secs: 24.8, w: 1080, h: 1920 }, + { id: "math", secs: 25, w: 1920, h: 1080, style: "dark-math" }, + { id: "handdrawn", secs: 12, w: 1920, h: 1080, style: "watercolor-pastoral" }, + { id: "launch", secs: 20, w: 1920, h: 1080, style: "product-keynote" }, +]; +let wallPick = (() => { try { return localStorage.getItem("desk:samples") || ""; } catch (e) { return ""; } })(); // "open", "closed", or not chosen +function wallHtml(films) { + const here = new Set((LIST && LIST.samples) || []); + const cards = SAMPLES.map((x) => { + const tall = x.h > x.w, kind = t(`smp_${x.id}_type`); + return `
+ ${esc(kind.slice(0, 1))}${here.has(x.id) ? `` : ""} + ${esc(kind)} + ${esc(t("smp_secs", { s: x.secs }))}${esc(t(tall ? "smp_tall" : "smp_wide"))} ${x.w}×${x.h} + ${esc(t("smp_style"))}${esc(COLON())}${esc(t(`smp_${x.id}_style`))}${x.style ? ` ${esc(x.style)}` : ""} +
`; + }).join(""); + const body = `

${esc(t("smp_b"))}

${cards}
`; + const open = wallPick ? wallPick === "open" : !films && !matchMedia("(max-width: 900px)").matches; + return `

${esc(t("smp_h"))}${SAMPLES.length}

${body}
`; +} +function wallWire(root) { + const d = $("#smpWall", root); + if (d) $("summary", d).addEventListener("click", () => setTimeout(() => { // the person's own open or close (not the page drawing it) + wallPick = d.open ? "open" : "closed"; try { localStorage.setItem("desk:samples", wallPick); } catch (e) { /* private window */ } + }, 0)); + $$("[data-smp-go]", root).forEach((b) => b.addEventListener("click", async (e) => { + AGENT.offer(e, b.dataset.smpGo); // it says what happened (filled, kept until an agent is set up or the chat stops, look-only) + })); +} /* what this machine still lacks (bin/vh doctor, asked once a run by the console): a quiet panel on the space, nothing when all is there */ let MACHINE = null, machineAt = 0; async function machine() { // asked once a page; again (a minute later at most) while something is missing: the person may have fixed it diff --git a/tools/desk/test_agents.py b/tools/desk/test_agents.py index 47024a7c..e12fff7e 100644 --- a/tools/desk/test_agents.py +++ b/tools/desk/test_agents.py @@ -138,6 +138,48 @@ def claim(port, code): return r.status, d.get("token", "") +SAMPLE_LINE = re.compile(r'const sample = /\^\[a-z\]\+\$/\.test\(String\(id \|\| ""\)\) \? word\(`smp_\$\{id\}_say`\) : null;\s*' + r'if \(!e \|\| !e\.isTrusted \|\| KEYP !== SPACE \|\| typeof sample !== "string"\) return false;') +BOX_WRITE = re.compile(r"""\.value\s*=(?!=)\s*([^;]+);|execCommand\(\s*['"`]insertText['"`]\s*,[^,]*,\s*([^)]+?)\s*\)|\.setRangeText\s*\(|\.defaultValue\s*=(?!=)""") + + +def box_fills(js): + """What puts words in the box (agent.js's one textarea; every value written in the file counts, whatever names the box), + if anything but the person's own draft, or the sample wall's sentence inside offer(): None when it holds.""" + m = re.search(r"\basync function offer\(e, id\) \{", js) + if not m: + return "no offer(e, id) for the sample wall" + i = depth = js.index("{", m.start()) + depth, j = 0, i + while j < len(js): # its body, brace by brace (its strings and its one regular expression hold no braces of their own) + depth += {"{": 1, "}": -1}.get(js[j], 0) + if depth == 0: + break + j += 1 + body, rest = js[i:j + 1], js[:m.start()] + js[j + 1:] + outside = [(w.group(0), (w.group(1) or w.group(2) or "").strip()) for w in BOX_WRITE.finditer(rest)] + if sorted(set(x for _, x in outside)) != ['""', 'store_.get(`desk:agent:say:${KEYP}`) || ""'] or any(not w.startswith(".value") for w, _ in outside): + return f"the box is filled from something else: {[w for w, _ in outside]}" + inside = [(w.group(1) or w.group(2) or "").strip() for w in BOX_WRITE.finditer(body)] + one = SAMPLE_LINE.search(body) + if not one or set(inside) != {"sample"} or len(inside) != 2: + return f"the sample wall fills the box from something other than Studio's own sentence, or without a real click: {inside}" + others = body[:one.start()] + body[one.end():] + if re.search(r"[{\[,]\s*(?:\w+\s*:\s*)?sample\s*[,}\]=]|\bsample\s*=(?!=)|\b(?:const|let|var)\s+sample\b", others): # destructured, assigned, declared + return "the sample wall's sentence is bound a second time inside offer()" + + +BOX_TRIES = [ # (what, the change): ways round the rule that box_fills must catch + ("another function's parameter named sample", lambda js: js + '\nfunction elsewhere(sample) { const ta = $("#agSay"); ta.value = sample; }\n'), + ("a second sample bound inside offer()", lambda js: js.replace(" const ta = $(\"#agSay\");\n if (!ta || ta.disabled)", " const { text: sample2 } = {}; const ta = $(\"#agSay\");\n if (!ta || ta.disabled)", 1).replace("const { text: sample2 }", "const { text: sample }")), + ("insertText in single quotes", lambda js: js + "\ndocument.execCommand('insertText', false, page);\n"), + ("insertText with no spaces", lambda js: js + '\ndocument.execCommand("insertText",false,page);\n'), + ("setRangeText", lambda js: js + "\n$(\"#agSay\").setRangeText(page);\n"), + ("the box by another name", lambda js: js + '\nconst box = document.getElementById("agSay"); box.value = page;\n'), + ("the sentence from elsewhere inside offer()", lambda js: js.replace("if (!typed) ta.value = sample;", "if (!typed) ta.value = sample || page;", 1)), +] + + def page_check(): """agent.js in node: the agent's words escaped, no links made; the diff; send, answer, stop and the settings act only on a real event; the box is never filled from anything but the person's own draft.""" @@ -145,9 +187,12 @@ def page_check(): for fn in ("send", "answer", "stop", "setting"): if not re.search(r"async function " + fn + r"\(e\b[^)]*\) \{\s*if \(!e \|\| !e\.isTrusted\b", js): return f"{fn}() does not start by checking event.isTrusted" - sets = re.findall(r"(?:ta|\$\(\"#agSay\"\))\.value\s*=\s*([^;]+);", js) - if sorted(set(x.strip() for x in sets)) != ['""', 'store_.get(`desk:agent:say:${KEYP}`) || ""']: - return f"the box is filled from something else: {sets}" + bad = box_fills(js) + if bad: + return bad + for what, cut in BOX_TRIES: # the check's own tries: each of these ways round it is caught + if not box_fills(cut(js)): + return f"the box check lets this through: {what}" if "