Skip to content

gooseworks-ai/goose-skills / skills/video/media-proxy

media-proxy

Unverified

Shared helper that routes ALL paid media generation (FAL image/video, ElevenLabs music) through the GooseWorks proxies so every call is charged to your GooseWorks credits — never a provider SDK's default host. Host-swaps the FAL queue URLs, loads the agent token from the sandbox env (GW_MEDIA_PROXY_TOKEN) or ~/.gooseworks/credentials.json, and returns the result CDN URL. Every video-ad media capability imports this; templates never call a provider directly.

FileKindSize
SKILL.mdskill md15.2 KB
scripts/media_proxy.pyscript56.8 KB
scripts/resume.pyscript2.2 KB
skill.meta.jsonconfig126 B
tests/smoke-test.mdmarkdown655 B
tests/test_call_query.pyscript2.9 KB
tests/test_media_proxy_policy.pyscript25.3 KB

tests/test_call_query.py

View on GitHub
"""Custom-video quality tiers: a call's GooseWorks query (shot_scene and the upgrade fields) reaches
the proxy in both transports, and never overrides the proxy's own token or attribution. Free: the
HTTP call and the relay are stubbed, nothing is sent."""
import importlib.util
import json
import os
import pathlib
import tempfile
import unittest
from unittest import mock

SCRIPT = pathlib.Path(__file__).resolve().parents[1] / "scripts" / "media_proxy.py"
QUERY = {"shot_scene": 3, "upgrade_reason": "failed_attempt", "upgrade_attempt": "op-1",
         "upgrade_why": "label text garbled at medium", "token": "evil", "project_id": "other"}


def load():
    spec = importlib.util.spec_from_file_location("media_proxy_query", SCRIPT)
    mod = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(mod)
    return mod


class Stop(Exception):
    pass


class CallQueryTest(unittest.TestCase):
    def test_direct_proxy_sends_the_query_beside_its_own_params(self):
        mp = load()
        seen = {}

        def post(url, params=None, **kw):
            seen.update(params)
            raise Stop()

        with mock.patch.object(mp, "relay_mode", return_value=False), \
                mock.patch.object(mp, "_cfg", return_value=("https://api.example", "tok", "agent-1")), \
                mock.patch.dict(os.environ, {"GW_PROJECT_ID": "proj-1"}), \
                mock.patch.object(mp.requests, "post", side_effect=post):
            with self.assertRaises(Stop):
                mp._fal_run_once("openai/gpt-image-2/edit", {"prompt": "x", "quality": "high"}, 5, 1, False, None, QUERY)
        self.assertEqual(seen["shot_scene"], "3")
        self.assertEqual(seen["upgrade_reason"], "failed_attempt")
        self.assertEqual(seen["upgrade_attempt"], "op-1")
        self.assertEqual(seen["upgrade_why"], "label text garbled at medium")
        self.assertEqual((seen["token"], seen["agent_id"], seen["project_id"]), ("tok", "agent-1", "proj-1"))

    def test_relay_puts_the_query_in_the_data_post_args(self):
        mp = load()
        seen = {}

        def relay(kind, tool, args, then, extra=None, check=None):
            seen.update(args)
            raise Stop()

        with mock.patch.object(mp, "relay_mode", return_value=True), mock.patch.object(mp, "_relay", side_effect=relay):
            with self.assertRaises(Stop):
                mp._fal_run_once("minimax/h3-max/reference-to-video", {"prompt": "x"}, 5, 1, False, None,
                                 {"shot_scene": "2", "upgrade_reason": "customer_asked", "upgrade_quote": "sharper"})
        self.assertEqual(seen["query"], {"shot_scene": "2", "upgrade_reason": "customer_asked", "upgrade_quote": "sharper"})

    def test_no_query_sends_nothing_extra(self):
        mp = load()
        self.assertEqual(mp._call_query(None), {})
        self.assertEqual(mp._call_query({"shot_scene": None}), {})


if __name__ == "__main__":
    unittest.main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall