Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

fix(prompt): embed pictures in a page, do not hand over a URL

booboosuiaf6d6ee83c15
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 450a20a..a44e35a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -144,6 +144,23 @@ because a release this size is the norm.
took the whole process down, which is the opposite of what the callback is for. Now qualified
`[email protected](msg)`. The listener's three other callbacks are unaffected: none of them
shares a name with an outer member.
+- **A picture, a video or a sound now goes into a page rather than being named as a URL.** The prompt
+ said the opposite, and said it wrongly: *"this device cannot turn an image into a URL, so an `img`
+ tag will not open"*. That is false for anything on the network — the page is served against a fake
+ `https://` origin, the app holds `INTERNET`, and WebView loads an absolute `https://` subresource
+ without complaint. What is true is narrower, and the old sentence flattened it into a blanket ban:
+ a *local* file has no address a page can point at, and `http://` is refused. So the model, obeying
+ its instructions, could not put a picture on screen — and what it did instead was hand the user a
+ URL to go and open, on the device they were already holding. §7 now asks for the embedding directly
+ (`<img>`, `<video controls>`, `<audio controls>`, absolute `https://` only), separates a media file
+ from a *site* — the latter belongs in Chrome through `open_url`, not in an `iframe`, which most
+ sites refuse — and says outright that passing over a bare URL is not an answer. The wrong half of
+ the same sentence sat in the `show_html` description too ("a page that fetches a font, a framework
+ or *an image* over the network renders broken"), which is the text the model reads while composing;
+ media is carved out there as well, because what that rule protects is a self-contained shell.
+ Verified by compiling and by reading both strings back out of the compiled classes — the new text is
+ present, all three old phrasings gone. **Not verified on a device**: none was attached, so a real
+ `https` image and a real `.mp4` rendering in the page are still unconfirmed.
### Changed
diff --git a/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt b/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt
index 79b9579..c202f1e 100644
--- a/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt
+++ b/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt
@@ -249,7 +249,29 @@ When **not** to put up a page:
- **Mid-way through operating the device.** `show_html` covers the current app — and then the user cannot see what you are tapping. Do not put one up half-way through the job; wait until it is done. (The page no longer blocks you: the call returns at once, and you are told when they close it. Only one page at a time; calling `show_html` again replaces it in place, which is how you revise a page — never ask the user to close it first.)
- When the user has said they only want to listen.
-**Images cannot go in a page**: this device cannot turn an image into a URL, so an `img` tag will not open. To show them a picture, use some other route; if there is none, describe it honestly in words.
+**To show them a picture, a clip or a sound, embed it in a page — never just
+hand over the URL.** The tablet is what they are holding, and "go and open
+this link" walks them off your screen to do your job for them. When what you
+have is a direct media address — a URL ending in an image, video or audio
+extension (`.jpg` `.png` `.webp`, `.mp4` `.webm`, `.mp3` `.m4a`) — it goes
+into a page you compose for it: `<img src="…">`, `<video src="…" controls>`,
+`<audio src="…" controls>`. Keep `controls` on a player — without it a clip is
+a still frame with nothing to press.
+
+The address must be **absolute and `https://`**. The page runs as a secure
+origin and this device blocks mixed content, so an `http://` picture or clip
+will not load; saying that plainly is better than handing over a link that
+opens nothing.
+
+**A file on this device has no address to embed.** A screenshot you took, a
+photo in the gallery, the frame the camera just showed you — there is no URL
+to point a page at, so open the gallery for them, or describe what you saw.
+Your looking is not their looking.
+
+And when it is not a media file but a *site* — a shop page, a video that
+plays only on its own site, anything behind a login — use `open_url` into
+Chrome, not an `iframe`: most sites refuse to be framed and the page comes up
+empty.
The rules for making a page (colour, type size, layout) are written in the `show_html` tool description — follow them. That style is what you look like; swap in another and the result stops looking like your work.
diff --git a/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt b/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt
index f7bf36d..09881ae 100644
--- a/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt
+++ b/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt
@@ -850,8 +850,13 @@ object ToolSchemas {
close the page first.
Inline CSS and JS ONLY. The device may have no usable internet, so a
- page that fetches a font, a framework or an image over the network
- renders broken.
+ page that fetches a font, a framework or a script over the network
+ renders broken. Media is the exception: an image, video or audio
+ file at an absolute https:// address embeds directly — `<img
+ src="…">`, `<video src="…" controls>`, `<audio src="…" controls>` —
+ and is how you show the user a picture or a clip instead of naming
+ a URL they would have to go and open themselves. Keep `controls` on
+ a player. A plain http:// address will not load.
HOUSE STYLE — follow it unless the user asked for something else.
This is what the rest of the device looks like; a page that ignores
diff --git a/app/src/main/java/net/kuafuai/andee/ui/HtmlActivity.kt b/app/src/main/java/net/kuafuai/andee/ui/HtmlActivity.kt
index a402e44..27ff58e 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/HtmlActivity.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/HtmlActivity.kt
@@ -89,8 +89,17 @@ class HtmlActivity : StageActivity() {
* near the top of a script — a high score, a saved setting, exactly what
* a model writes without thinking about it — and the whole script dies
* and the page renders blank. A stable fake https origin gives DOM
- * storage somewhere to live, and never resolves, which is fine because
- * the page is required to be self-contained anyway.
+ * storage somewhere to live, and never resolves.
+ *
+ * The page's own CSS and JS stay inline — there is no relative path to
+ * a host that never resolves. Media is the exception, and this origin
+ * is what decides it: a page served from https is a secure origin, so
+ * WebView (default `MIXED_CONTENT_NEVER_ALLOW`; this app targets 34)
+ * refuses an `http://` image or clip and loads an absolute `https://`
+ * one. §7 of `LocalPrompt` draws the model's side of that line, and
+ * relaxing it here would mean `MIXED_CONTENT_COMPATIBILITY_MODE` —
+ * with cleartext anyway refused to every host but the one named in
+ * `network_security_config.xml`.
*/
private const val BASE_URL = "https://brain.local/"