letify 2.12.2__tar.gz → 2.12.4__tar.gz
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.
- {letify-2.12.2 → letify-2.12.4}/PKG-INFO +1 -1
- {letify-2.12.2 → letify-2.12.4}/docs/SPEC.md +13 -3
- {letify-2.12.2 → letify-2.12.4}/letify/__init__.py +1 -1
- {letify-2.12.2 → letify-2.12.4}/letify/install.py +11 -4
- {letify-2.12.2 → letify-2.12.4}/letify/protocol/worker.py +50 -11
- {letify-2.12.2 → letify-2.12.4}/letify/providers/colab.py +6 -3
- {letify-2.12.2 → letify-2.12.4}/letify/providers/colab_files.py +2 -1
- {letify-2.12.2 → letify-2.12.4}/letify/providers/elice.py +2 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/kaggle.py +7 -2
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/bootstrap.py +1 -7
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/channel.py +6 -1
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/reattach.py +12 -3
- {letify-2.12.2 → letify-2.12.4}/letify/store/backends/drive.py +4 -3
- {letify-2.12.2 → letify-2.12.4}/letify/store/backends/google_auth.py +2 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/backends/objects.py +5 -1
- {letify-2.12.2 → letify-2.12.4}/letify/store/pathdata.py +2 -1
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linksignal.py +2 -11
- {letify-2.12.2 → letify-2.12.4}/letify/transport/portmap.py +7 -3
- letify-2.12.4/letify/useragent.py +23 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/Cargo.lock +3 -3
- {letify-2.12.2 → letify-2.12.4}/letify-core/Cargo.toml +1 -1
- {letify-2.12.2 → letify-2.12.4}/letify-ext/package-lock.json +2 -2
- {letify-2.12.2 → letify-2.12.4}/letify-ext/package.json +1 -1
- {letify-2.12.2 → letify-2.12.4}/pyproject.toml +1 -1
- {letify-2.12.2 → letify-2.12.4}/tests/test_drive_store.py +2 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_kaggle.py +18 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_agent.py +14 -3
- {letify-2.12.2 → letify-2.12.4}/tests/test_run_reattach.py +40 -1
- letify-2.12.4/tests/test_user_agent.py +170 -0
- {letify-2.12.2 → letify-2.12.4}/.github/workflows/ci.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/.github/workflows/docs.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/.github/workflows/letify-link.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/.github/workflows/publish-crates.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/.github/workflows/publish.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/.github/workflows/reserve-crates.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/.gitignore +0 -0
- {letify-2.12.2 → letify-2.12.4}/.researchtree +0 -0
- {letify-2.12.2 → letify-2.12.4}/CLAUDE.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/LICENSE +0 -0
- {letify-2.12.2 → letify-2.12.4}/PROJECT.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/COMPONENT.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/INTENT.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/NETWORK.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/ROADMAP-3.0.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/01-getting-started.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/02-providers.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/03-execution-modes.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/04-environments-and-data.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/05-concurrency.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/06-cost.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/07-troubleshooting.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/08-releasing.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/09-agent.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/01-/354/213/234/354/236/221/355/225/230/352/270/260.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/02-/355/224/204/353/241/234/353/260/224/354/235/264/353/215/224.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/03-/354/213/244/355/226/211-/353/260/251/354/213/235.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/04-/355/231/230/352/262/275/352/263/274-/353/215/260/354/235/264/355/204/260.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/05-/353/217/231/354/213/234-/354/213/244/355/226/211.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/06-/353/271/204/354/232/251.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/07-/353/254/270/354/240/234-/355/225/264/352/262/260.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/08-/353/246/264/353/246/254/354/212/244.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/09-/354/227/220/354/235/264/354/240/204/355/212/270.md" +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/guide/ko/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/locales/README_ko.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/docs/mkdocs.yml +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/.letify.example +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/00_smoke.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/01_sweep.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/02_resume.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/03_watch.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/README_ko.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/common.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/examples/nvfp4-lora/recipe.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/cli.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/config/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/config/inventory.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/config/login.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/config/schema.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/config/secrets.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/config/writer.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/cache.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/env.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/exit.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/function.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/instance.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/reduce.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/declare/replicas.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/errors.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/launcher.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/paths.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/protocol/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/protocol/codec.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/protocol/driver.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/protocol/handle.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/protocol/wire.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/base.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/colab_keepalive.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/kaggle_adapter.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/local.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/modal.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/modal_adapter.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/naming.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/shell.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/tunnel.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/providers/usage.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/client.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/cuda.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/executor.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/frames.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/guard.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/tensor.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/trace.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/remoting/device/value.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/render.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/broker.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/control.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/lease.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/pool.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/session.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/takeover.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/telemetry.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/runtime/workers.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/backends/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/backends/filesystem.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/backends/layout.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/cas.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/handoff.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/sendorder.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/store/volume.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/stubs.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/tools.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/__init__.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/agent.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/announce.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/link.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkagent.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkchannel.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkd.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkmailbox.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkpump.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkshim.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkupload.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/linkwebsocket.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/nat.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/pipeline.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/probe.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/quic.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/rendezvous.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/setup.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/sshopts.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify/transport/strategies.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/.gitignore +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/build.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify/Cargo.toml +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify/LICENSE +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify/src/lib.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/Cargo.toml +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/examples/bench.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/acceptor.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/bin/letify-link.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/config.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/error.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/frame.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/handshake.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/hysteresis.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/identity.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/keys.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/lib.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/observe.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/paths.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/plan.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/policing.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/punch.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/record.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/relay.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/rendezvous.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/replay.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/session.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/sidecar.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/stream.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/stun.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/tcp.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/trace.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/src/udp.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/acceptor.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/api.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/common/mod.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/diag_sim.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/fairness.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/gauge.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/handshake.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/hysteresis.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/keepalive.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/mobile.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/nat.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/paths.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/qad.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/rekey.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/relay.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/relay_pairing.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/rendezvous.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/reorder.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/replay.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/resume.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/revoke.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/session.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/sidecar.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/startup.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/subflows.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/trace.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/udp.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-link/tests/udp_bench.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-quic/Cargo.toml +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/letify-quic/src/main.rs +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-core/rust-toolchain.toml +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/.vscodeignore +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/LICENSE +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/media/icon.svg +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/src/cli.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/src/extension.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/src/history.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/src/model.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/src/poll.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/src/render.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/test/cli.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/test/manifest.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/test/model.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/test/regressions.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-ext/tsconfig.json +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/README.md +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/cloudflare.config.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/package-lock.json +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/package.json +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/auth.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/ed25519.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/handler.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/index.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/limiter.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/mailbox.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/objects.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/protocol.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/src/storage.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/auth.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/ed25519.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/helpers.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/interop.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/limiter.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/mailbox.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/objects.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/setup.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/test/worker.test.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/tsconfig.json +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify-signal/vitest.config.ts +0 -0
- {letify-2.12.2 → letify-2.12.4}/letify_providers.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/scripts/sync-main.sh +0 -0
- {letify-2.12.2 → letify-2.12.4}/scripts/version.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/conftest.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/fake_kaggle_adapter.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/fake_modal_adapter.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_cli.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_cli_output.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_colab_keepalive.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_config.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_core.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_data.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_data_in_place.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_data_streaming.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_declare.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_device.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_device_compile.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_distributed.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_drive_handoff.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_editor_sessions.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_elice.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_frames.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_install.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_kaggle_cookie.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_kaggle_link.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_channel.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_command_channel.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_exec.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_log.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_mailbox_close.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_opt_in.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_signal.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_ssh_stream.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_link_upload.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_linkd.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_notebook.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_parallel_placement.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_paths.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_portmap.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_protocol.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_providers.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_punch_sockets.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_quic.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_remoting.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_render.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_run_control.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_run_takeover.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_runtime.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_shell_workers.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_ship.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_store.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_strategies.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_stubs.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_transport.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_tunnel_agent_login.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_tunnel_setup.py +0 -0
- {letify-2.12.2 → letify-2.12.4}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: letify
|
|
3
|
-
Version: 2.12.
|
|
3
|
+
Version: 2.12.4
|
|
4
4
|
Summary: Declarations that become infrastructure.
|
|
5
5
|
Project-URL: Homepage, https://github.com/DarkPyonix/letify
|
|
6
6
|
Project-URL: Documentation, https://github.com/DarkPyonix/letify/tree/main/docs
|
|
@@ -258,6 +258,15 @@ A provider is built from one entry in the configuration file and reached by attr
|
|
|
258
258
|
| `Elice` | ephemeral | yes | persistent | `filesystem` |
|
|
259
259
|
| `Kaggle` | ephemeral | no | persistent, in one cell of the session the user registered | `filesystem` |
|
|
260
260
|
|
|
261
|
+
### User-Agent <!-- id: user-agent -->
|
|
262
|
+
|
|
263
|
+
> Every HTTP request letify sends carries `User-Agent: letify/<version>`, and nothing else is ever sent in its place.
|
|
264
|
+
|
|
265
|
+
- **One rule for every client.** The rule covers each request letify makes with `urllib` or `http.client`: the provider APIs (Kaggle, Colab, Elice), the blob backends (Drive, GCS), the signalling service, the release and installer downloads, and the UPnP requests of the port mapper. `<version>` is `letify.__version__`. `letify/useragent.py` builds the string, and no module writes its own copy.
|
|
266
|
+
- **The value is letify's own name.** letify does not send a browser User-Agent and does not imitate another client, whatever a service answers.
|
|
267
|
+
- **A runtime sends it too.** The worker takes the request headers from the machine that drives it and sends them unchanged, so the headers of every pull and push the driver builds already carry the User-Agent. The uv installer download in the bootstrap script carries it the same way.
|
|
268
|
+
- **Why.** Services refuse the Python default `Python-urllib/<version>`: Cloudflare's Browser Integrity Check answers it with error 1010 (the signalling service), astral.sh with 403 (the uv installer), and kaggle.com with 404 and an empty body since 2026-11-08.
|
|
269
|
+
|
|
261
270
|
### Kaggle <!-- id: kaggle-provider -->
|
|
262
271
|
|
|
263
272
|
> A Kaggle account is declared with two required credentials: the browser session cookie of a logged-in kaggle.com tab, and an API token. The cookie is kept to the interactive session alone; everything else goes through the official Kaggle CLI, authenticated by the token, with no cookie fallback. It opens no tunnel, port forward or Tailcat link, so the kernel channel is its only link to a session, and that channel cannot carry a device stream, so it cannot serve `host="local"`.
|
|
@@ -274,6 +283,7 @@ Creating the notebook stays on the cookie side rather than moving to `kernels in
|
|
|
274
283
|
Not opening a link is a decision of this project, not a rule of Kaggle's. Two sources bear on it, and they say different things. Kaggle staff answered a request for SSH access with "You can't run docker inside Kaggle. We also don't support port forwarding.", which is a statement that the feature does not exist, not that reaching it is forbidden. The Acceptable Use Policy of June 22, 2025 forbids using the Services "to disable, interfere with or circumvent any aspect of the Services" and lists "tools for circumvention/obfuscation" among abusive uses. Whether hole punching to a machine that offers no inbound port is circumvention is not written anywhere, so treating it as circumvention is this project's reading rather than Kaggle's rule. letify takes the cautious side because the cost of being wrong falls on the user's account. The session has outbound network, so a link dialled out from the session to the local process is possible in principle; letify does not open one, and `host="local"` is refused for the throughput reason in Placements a provider cannot serve, not because Kaggle forbids it.
|
|
275
284
|
|
|
276
285
|
- No keep-alive request is ever sent, and accounts are never rotated.
|
|
286
|
+
- **User-Agent.** Every request to Kaggle carries `User-Agent: letify/<version>`, as the section "User-Agent" requires. Since 2026-11-08 kaggle.com has answered the Python default `Python-urllib/<version>` with HTTP 404 and an empty body, which login checks and session starts reported as `could not be checked: HTTP 404`.
|
|
277
287
|
- The accelerators are `CPU`, `T4` and `TPU_V3_8`, a fixed list read without a network call. `T4` declares two GPU cards through `Instance.devices=2`, and requests `NVIDIA_TESLA_T4`. The name stays `T4` to preserve existing declarations: the card count belongs to the instance shape.
|
|
278
288
|
- `P100` is not offered. Kaggle retired the Tesla P100 on 2026-09-15 and switches a notebook that asks for it to T4x2, so a request for it is answered with a different card and a different card count. A declaration states where a function runs, so letify refuses the name rather than letting the substitution through: `kaggle_<alias>.P100` raises `UnknownInstance` naming the retirement date and `T4`. Two live accounts asking for `P100` both received two T4s, which is what the substitution looks like from here.
|
|
279
289
|
- The card the session got is checked, because a retirement is not the only way Kaggle answers with something else. Before the environment is built, the session reads `Model:` from each `/proc/driver/nvidia/gpus/*/information` and compares the names and the count against the instance: `T4` expects two cards whose model contains `T4`. A mismatch raises `InsufficientDevices` naming what was asked for and what arrived. `nvidia-smi` is not used because a Kaggle image does not have it on `PATH`. The check runs before the environment so a wrong card costs seconds rather than the minutes a sync takes. The check also asks whether the driver works, by loading `libcuda.so.1` with `ctypes` and calling `cuInit(0)`, and a non-zero result refuses the session the same way a wrong card does, naming the code. That is the call CUDA initialization makes, so it answers the question rather than a proxy for it: a live Kaggle session listed both T4s in `/proc` and had `/dev/nvidiactl`, and the first `.cuda()` still raised `Found no NVIDIA driver on your system` after 30 GB of shards had been sent. `torch.cuda.is_available()` would answer too and cannot be used, because the check runs before the environment is built and there is no torch in the session yet; `ctypes` is in the standard library and needs neither. An account that accepts whatever card it is given sets `any_accelerator = true`, and then the mismatch is one line on standard error instead.
|
|
@@ -1119,7 +1129,7 @@ The worker outlives a channel that closes without a shutdown frame, as [Taking o
|
|
|
1119
1129
|
|
|
1120
1130
|
`RuntimeLost` (including `SpotPreempted`), `RuntimeFailure` (including a call that exceeded its `timeout`), `RemoteError` and a provider that raises `UnsupportedMode` from `attach_channel` are never reattached. They take the path of [Failure and retry](#failure-and-retry).
|
|
1121
1131
|
2. **Attempts.** The owner stops renewing the lease on the dead channel, waits 5, 10, 20, then 40 s before each attempt (40 s for every attempt after the fourth, at most 8 attempts), and gives up when the next wait plus `MARGIN_S` would pass the lease deadline. Each attempt builds a channel with `Provider.attach_channel`, starts it and sends `adopt` for the run id, exactly as `letify takeover` does, and the body's `timeout` keeps counting from the first send.
|
|
1122
|
-
3. **On success.** The runtime's channel becomes the new one, which keeps the old channel's output setting. The lease is armed again over it, the
|
|
1132
|
+
3. **On success.** The runtime's channel becomes the new one, which keeps the old channel's output setting. The lease is armed again over it, and the call goes on waiting for its reply. The output the call made reaches this process in order and once, whatever the lost channel had carried: `adopt` names, per stream, how many bytes of the call's output this process has received (`have`), and the worker replays the rest from its history before anything newer. A byte the worker wrote into the broken link but this process never read is therefore replayed, and one it did read is not. The worker keeps the last 256 KiB (`_BACKLOG_BYTES`) of each stream for the call, and a `have` older than that replays the whole history. An `adopt` with no `have`, as `letify takeover` sends, replays only the output no channel could take. The call's value, its raised exception and its written-back outputs are those of the original call. The body is not run again. A channel lost again is reattached again under the same limits. As after a takeover, the session ends when the reattached call returns, even inside `keep_alive`.
|
|
1123
1133
|
4. **Messages.** Before each attempt the owner prints to standard error `letify: lost the channel to <runtime> during <run>; reattaching (attempt <n>)`, and on success `letify: reattached to <run> on <runtime>`.
|
|
1124
1134
|
5. **When it gives up.** The old channel is closed without a shutdown frame, and the original failure takes the path of [Failure and retry](#failure-and-retry): the runtime is discarded and the call is retried on a fresh one under `retries`. A failure of the user's code is never retried, as before.
|
|
1125
1135
|
|
|
@@ -1775,7 +1785,7 @@ Two declarations cannot diverge from the local process. Before any session start
|
|
|
1775
1785
|
|
|
1776
1786
|
> The runtime uses the uv it has, and installs uv under the workspace root when it has none.
|
|
1777
1787
|
|
|
1778
|
-
The worker looks for `uv` on `PATH`, then at `<workspace root>/uv-bin/uv`. When neither exists it downloads `https://astral.sh/uv/install.sh` over HTTPS with the bootstrap interpreter's `urllib`, sending `User-Agent: letify/<version>`
|
|
1788
|
+
The worker looks for `uv` on `PATH`, then at `<workspace root>/uv-bin/uv`. When neither exists it downloads `https://astral.sh/uv/install.sh` over HTTPS with the bootstrap interpreter's `urllib`, sending `User-Agent: letify/<version>` as the section "User-Agent" requires, and runs it with `sh`, with `UV_INSTALL_DIR=<workspace root>/uv-bin` and `UV_NO_MODIFY_PATH=1`. That is the same as `curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="<workspace root>/uv-bin" UV_NO_MODIFY_PATH=1 sh`, and letify fetches the script itself so it does not need `curl` to reach astral.sh. The installer script does need one, though: it downloads the uv binary with `curl` or `wget`. So before running it, the worker checks that one of the two is on `PATH`, and when neither is it raises `uv cannot be installed on <runtime>: its installer needs curl or wget on PATH, and neither is present` rather than letting the installer fail with an unclear message. It writes only under the workspace root, so it needs no root and nothing outside the one directory an account may be restricted to. A failed download or a non-zero exit raises `EnvironmentFailure` saying `uv could not be installed on <runtime>` with the reason.
|
|
1779
1789
|
|
|
1780
1790
|
### uv cache <!-- id: uv-cache -->
|
|
1781
1791
|
|
|
@@ -2252,7 +2262,7 @@ The service is the auxiliary rendezvous of [Rendezvous trait](#link-rendezvous).
|
|
|
2252
2262
|
|
|
2253
2263
|
`<to>` and `<node>` are 64 lowercase hex characters. Sequence numbers count from 1 per mailbox and are never reused. Messages of one mailbox are delivered in sequence order, at least once: a message is deleted by an acknowledgement or by its TTL, never by being read, so a receiver that reconnects with the last `after` it had sees the rest again.
|
|
2254
2264
|
|
|
2255
|
-
**User-Agent.** Every request, the WebSocket handshake included, carries `User-Agent: letify/<version>`,
|
|
2265
|
+
**User-Agent.** Every request, the WebSocket handshake included, carries `User-Agent: letify/<version>`, as the section "User-Agent" requires. Cloudflare's Browser Integrity Check answers the Python default with 403 and error code 1010 before the request reaches the Worker.
|
|
2256
2266
|
|
|
2257
2267
|
**Connections.** `SignalClient` keeps the HTTPS connections it opened and sends the next request on an idle one, so a connect pays the TCP and TLS set-up once and not once per request. A connection serves one request at a time: a long poll holds its connection until it returns, so a send made meanwhile takes another idle connection or opens one, and at most 4 idle connections are kept (`MAX_IDLE`). A connection is returned to the idle list only after its reply was read to the end and the service did not say `Connection: close`. A request that fails on a reused connection before any reply byte arrives (the service or a middlebox closed it while idle) is sent once more on a new connection, signed again with a new nonce, and a failure on a new connection is not retried. The client uses `http.client` from the standard library. When the environment names a proxy for the service's host, it sends through `urllib` with a new connection per request, because `http.client` does not use a proxy. The WebSocket of `/ws/<node>` is its own connection and is not part of this list. The error texts do not change.
|
|
2258
2268
|
|
|
@@ -34,6 +34,7 @@ from pathlib import Path
|
|
|
34
34
|
from . import render
|
|
35
35
|
from .errors import LetifyError
|
|
36
36
|
from .transport.setup import TAILCAT_VERSION
|
|
37
|
+
from .useragent import user_agent, with_agent
|
|
37
38
|
|
|
38
39
|
#: Seconds to wait for a release server.
|
|
39
40
|
DOWNLOAD_TIMEOUT = 60.0
|
|
@@ -390,7 +391,9 @@ def _download(url: str, *, label: str | None = None, stream=None) -> bytes:
|
|
|
390
391
|
"""Fetch ``url``; with ``label``, report progress on ``stream`` (standard error)."""
|
|
391
392
|
_reachable(url)
|
|
392
393
|
try:
|
|
393
|
-
with urllib.request.urlopen(
|
|
394
|
+
with urllib.request.urlopen(
|
|
395
|
+
urllib.request.Request(url, headers=with_agent()), timeout=DOWNLOAD_TIMEOUT
|
|
396
|
+
) as response:
|
|
394
397
|
if label is None:
|
|
395
398
|
return response.read()
|
|
396
399
|
length = response.headers.get("Content-Length")
|
|
@@ -656,7 +659,8 @@ def remote_tailcat_source() -> str:
|
|
|
656
659
|
return (
|
|
657
660
|
inspect.getsource(_remote_tailcat)
|
|
658
661
|
+ f"\nbinary = _remote_tailcat({TAILCAT_VERSION!r}, "
|
|
659
|
-
+ f"{TAILCAT_RELEASE.format(version=TAILCAT_VERSION)!r}, {TAILCAT_SHA256!r}
|
|
662
|
+
+ f"{TAILCAT_RELEASE.format(version=TAILCAT_VERSION)!r}, {TAILCAT_SHA256!r}, "
|
|
663
|
+
+ f"{user_agent()!r})\n"
|
|
660
664
|
+ "import json\nprint('LETIFY-TAILCAT ' + json.dumps(binary))\n"
|
|
661
665
|
)
|
|
662
666
|
|
|
@@ -730,7 +734,7 @@ def _remote_quic(version):
|
|
|
730
734
|
return str(target)
|
|
731
735
|
|
|
732
736
|
|
|
733
|
-
def _remote_tailcat(version, release, pins):
|
|
737
|
+
def _remote_tailcat(version, release, pins, agent):
|
|
734
738
|
"""Install a verified Linux tailcat using only the runtime's standard library."""
|
|
735
739
|
import hashlib
|
|
736
740
|
import io
|
|
@@ -757,7 +761,10 @@ def _remote_tailcat(version, release, pins):
|
|
|
757
761
|
if verified.get("archive") != pins[asset] or verified.get("binary") != actual:
|
|
758
762
|
raise RuntimeError("tailcat cached binary SHA-256 mismatch; refused")
|
|
759
763
|
return str(binary)
|
|
760
|
-
with urllib.request.urlopen(
|
|
764
|
+
with urllib.request.urlopen(
|
|
765
|
+
urllib.request.Request(f"{release}/{asset}", headers={"User-Agent": agent}),
|
|
766
|
+
timeout=60,
|
|
767
|
+
) as response:
|
|
761
768
|
data = response.read()
|
|
762
769
|
actual = hashlib.sha256(data).hexdigest()
|
|
763
770
|
if actual != pins[asset]:
|
|
@@ -98,14 +98,24 @@ _SENDER = (TextSender if _LETIFY_TEXT_FRAMES else Sender)(fd_writer(_FRAME_FD))
|
|
|
98
98
|
# owner the door connection that adopted the call, and owner_stream its request id
|
|
99
99
|
# finished/outcome the call's reply once the body has ended and before it is delivered
|
|
100
100
|
# backlog the tail of output made while no channel could take it
|
|
101
|
+
# history the tail of all output the call made, per stream, and total the number of
|
|
102
|
+
# bytes it made, so an owner that says how much it has received can be given
|
|
103
|
+
# the rest. Guarded by _HISTORY_LOCK, which also guards the choice of sender.
|
|
101
104
|
_TAKE = {
|
|
102
105
|
"run": None, "path": None, "listener": None, "stream": None, "live": True,
|
|
103
106
|
"ended_input": False, "moved": False, "owner": None, "owner_stream": None,
|
|
104
107
|
"finished": False, "outcome": None, "primary": None, "new_owner": None,
|
|
105
108
|
"backlog": {STDOUT: bytearray(), STDERR: bytearray()},
|
|
109
|
+
"history": {STDOUT: bytearray(), STDERR: bytearray()},
|
|
110
|
+
"total": {STDOUT: 0, STDERR: 0},
|
|
106
111
|
}
|
|
107
112
|
_TAKE_COND = threading.Condition()
|
|
108
113
|
|
|
114
|
+
#: Held by a pump while it records output and picks the sender it goes to, and by an adoption
|
|
115
|
+
#: while it replays the history and switches the sender, so each byte goes to exactly one side
|
|
116
|
+
#: of the switch. Taken after _TAKE_COND, never before.
|
|
117
|
+
_HISTORY_LOCK = threading.Lock()
|
|
118
|
+
|
|
109
119
|
#: The most output kept for a new owner while no channel could take it, per stream.
|
|
110
120
|
_BACKLOG_BYTES = 256 << 10
|
|
111
121
|
|
|
@@ -119,6 +129,17 @@ _DOOR_IDLE_S = 30.0
|
|
|
119
129
|
_DRAIN_TOKEN = b"\x1a\x1aLETIFY-DRAIN-7f3a9c4e\x1a\x1a"
|
|
120
130
|
|
|
121
131
|
|
|
132
|
+
def _remember_output(kind, data):
|
|
133
|
+
"""Add output to the history of the call being served. The caller holds _HISTORY_LOCK."""
|
|
134
|
+
if _TAKE["run"] is None:
|
|
135
|
+
return
|
|
136
|
+
kept = _TAKE["history"][kind]
|
|
137
|
+
kept += data
|
|
138
|
+
_TAKE["total"][kind] += len(data)
|
|
139
|
+
if len(kept) > _BACKLOG_BYTES:
|
|
140
|
+
del kept[: len(kept) - _BACKLOG_BYTES]
|
|
141
|
+
|
|
142
|
+
|
|
122
143
|
def _held_back(data):
|
|
123
144
|
"""How many bytes at the end of ``data`` could be the start of a split token."""
|
|
124
145
|
most = min(len(_DRAIN_TOKEN) - 1, len(data))
|
|
@@ -148,7 +169,10 @@ class _Pump(threading.Thread):
|
|
|
148
169
|
return
|
|
149
170
|
self.busy = True
|
|
150
171
|
try:
|
|
151
|
-
|
|
172
|
+
with _HISTORY_LOCK:
|
|
173
|
+
_remember_output(self.kind, data)
|
|
174
|
+
sender = _SENDER
|
|
175
|
+
sender.frame(self.kind, 0, data)
|
|
152
176
|
except OSError:
|
|
153
177
|
# While a call runs, a channel that closed must not take the pump with it: the body
|
|
154
178
|
# would die of a broken pipe on its next print. The output is kept for a new owner.
|
|
@@ -3759,8 +3783,9 @@ def _door_open(take):
|
|
|
3759
3783
|
run=take["run"], live=True, ended_input=False, finished=False, outcome=None,
|
|
3760
3784
|
path=take["door"],
|
|
3761
3785
|
)
|
|
3762
|
-
for kept in _TAKE["backlog"].values():
|
|
3786
|
+
for kept in list(_TAKE["backlog"].values()) + list(_TAKE["history"].values()):
|
|
3763
3787
|
del kept[:]
|
|
3788
|
+
_TAKE["total"] = {STDOUT: 0, STDERR: 0}
|
|
3764
3789
|
listener = None
|
|
3765
3790
|
try:
|
|
3766
3791
|
import socket
|
|
@@ -3838,20 +3863,34 @@ def _door_adopt(door, stream, request):
|
|
|
3838
3863
|
"state": "finished" if _TAKE["finished"] else "running",
|
|
3839
3864
|
"orphaned": not was_live,
|
|
3840
3865
|
}
|
|
3866
|
+
have = request.get("have")
|
|
3841
3867
|
try:
|
|
3842
3868
|
door.sender.message(REPLY, stream, {"ok": True, "value": state})
|
|
3843
|
-
for kind in (STDOUT, STDERR):
|
|
3844
|
-
kept = _TAKE["backlog"][kind]
|
|
3845
|
-
if kept:
|
|
3846
|
-
door.sender.frame(kind, 0, bytes(kept))
|
|
3847
|
-
del kept[:]
|
|
3848
3869
|
except OSError:
|
|
3849
3870
|
return
|
|
3850
3871
|
door.connection.settimeout(None)
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3872
|
+
with _HISTORY_LOCK:
|
|
3873
|
+
try:
|
|
3874
|
+
for kind in (STDOUT, STDERR):
|
|
3875
|
+
kept = _TAKE["backlog"][kind]
|
|
3876
|
+
if have is None:
|
|
3877
|
+
data = bytes(kept)
|
|
3878
|
+
else:
|
|
3879
|
+
# What the owner has not received: the history after its count. A
|
|
3880
|
+
# count older than the history replays all of it.
|
|
3881
|
+
key = "stdout" if kind == STDOUT else "stderr"
|
|
3882
|
+
history = _TAKE["history"][kind]
|
|
3883
|
+
first = _TAKE["total"][kind] - len(history)
|
|
3884
|
+
data = bytes(history[max(int(have.get(key, 0)) - first, 0):])
|
|
3885
|
+
if data:
|
|
3886
|
+
door.sender.frame(kind, 0, data)
|
|
3887
|
+
del kept[:]
|
|
3888
|
+
except OSError:
|
|
3889
|
+
return
|
|
3890
|
+
_TAKE.update(
|
|
3891
|
+
owner=door, owner_stream=stream, moved=True, live=True, ended_input=False
|
|
3892
|
+
)
|
|
3893
|
+
_SENDER = door.sender
|
|
3855
3894
|
_TAKE_COND.notify_all()
|
|
3856
3895
|
# Told last, after the output has been switched, so that nothing the body prints from
|
|
3857
3896
|
# the moment the former owner learns of the move is sent to a channel that has stopped
|
|
@@ -45,6 +45,7 @@ from .. import tools
|
|
|
45
45
|
from ..config.secrets import account_directory
|
|
46
46
|
from ..declare.instance import Instance
|
|
47
47
|
from ..errors import ProviderUnavailable, RuntimeFailure, RuntimeLost
|
|
48
|
+
from ..useragent import with_agent
|
|
48
49
|
from .shell import Shell
|
|
49
50
|
from .usage import Usage
|
|
50
51
|
|
|
@@ -116,7 +117,9 @@ def _access_token(stored: dict[str, Any]) -> str:
|
|
|
116
117
|
"grant_type": "refresh_token",
|
|
117
118
|
}
|
|
118
119
|
).encode()
|
|
119
|
-
request = urllib.request.Request(
|
|
120
|
+
request = urllib.request.Request(
|
|
121
|
+
str(stored["token_uri"]), data=form, method="POST", headers=with_agent()
|
|
122
|
+
)
|
|
120
123
|
with urllib.request.urlopen(request, timeout=USAGE_HTTP_TIMEOUT) as response:
|
|
121
124
|
return str(json.loads(response.read())["access_token"])
|
|
122
125
|
|
|
@@ -207,12 +210,12 @@ class Colab(Shell):
|
|
|
207
210
|
token = _access_token(stored)
|
|
208
211
|
request = urllib.request.Request(
|
|
209
212
|
CCU_INFO_URL,
|
|
210
|
-
headers={
|
|
213
|
+
headers=with_agent({
|
|
211
214
|
"Authorization": f"Bearer {token}",
|
|
212
215
|
"Accept": "application/json",
|
|
213
216
|
"X-Colab-Client-Agent": "colab-cli",
|
|
214
217
|
"X-Colab-Tunnel": "Google",
|
|
215
|
-
},
|
|
218
|
+
}),
|
|
216
219
|
)
|
|
217
220
|
with urllib.request.urlopen(request, timeout=USAGE_HTTP_TIMEOUT) as response:
|
|
218
221
|
text = response.read().decode(errors="replace")
|
|
@@ -24,6 +24,7 @@ from typing import Any
|
|
|
24
24
|
|
|
25
25
|
from ..config.secrets import account_directory
|
|
26
26
|
from ..errors import RuntimeFailure
|
|
27
|
+
from ..useragent import with_agent
|
|
27
28
|
|
|
28
29
|
#: Size of one upload part and one download range.
|
|
29
30
|
PART_BYTES = 32 * 1024 * 1024
|
|
@@ -89,7 +90,7 @@ class ContentsTransfer:
|
|
|
89
90
|
headers: dict[str, str] | None = None,
|
|
90
91
|
) -> bytes:
|
|
91
92
|
request = urllib.request.Request(address, data=body, method=method)
|
|
92
|
-
for key, value in {**self._auth_headers(), **(headers or {})}.items():
|
|
93
|
+
for key, value in with_agent({**self._auth_headers(), **(headers or {})}).items():
|
|
93
94
|
request.add_header(key, value)
|
|
94
95
|
try:
|
|
95
96
|
with urllib.request.urlopen(request, timeout=3600) as response:
|
|
@@ -44,6 +44,7 @@ from ..errors import (
|
|
|
44
44
|
UnsupportedMode,
|
|
45
45
|
)
|
|
46
46
|
from ..paths import accounts_label, tools_label
|
|
47
|
+
from ..useragent import user_agent
|
|
47
48
|
from .naming import normalize_gpu
|
|
48
49
|
from .shell import Shell
|
|
49
50
|
from .usage import Usage
|
|
@@ -152,6 +153,7 @@ def request(
|
|
|
152
153
|
url = f"{url}?{urllib.parse.urlencode(params)}"
|
|
153
154
|
data = None if json is None else _json.dumps(json).encode()
|
|
154
155
|
call = urllib.request.Request(url, data=data, method=method)
|
|
156
|
+
call.add_header("User-Agent", user_agent())
|
|
155
157
|
call.add_header("Authorization", f"Bearer {token}")
|
|
156
158
|
call.add_header("Accept", "application/json")
|
|
157
159
|
for name, value in (headers or {}).items():
|
|
@@ -52,6 +52,7 @@ from ..errors import (
|
|
|
52
52
|
from ..protocol import wire
|
|
53
53
|
from ..runtime.channel import Connection, FramedChannel, _drain, _Tail
|
|
54
54
|
from ..transport import sshopts
|
|
55
|
+
from ..useragent import user_agent, with_agent
|
|
55
56
|
from .base import Provider
|
|
56
57
|
from .usage import Usage
|
|
57
58
|
|
|
@@ -240,6 +241,7 @@ def cookie_headers(cookie: str) -> dict[str, str]:
|
|
|
240
241
|
jar = require_cookie_shape(cookie)
|
|
241
242
|
return {
|
|
242
243
|
"Content-Type": "application/json",
|
|
244
|
+
"User-Agent": user_agent(),
|
|
243
245
|
"cookie": cookie,
|
|
244
246
|
"x-xsrf-token": jar["XSRF-TOKEN"],
|
|
245
247
|
"x-kaggle-build-version": jar.get("build-hash", "1"),
|
|
@@ -365,7 +367,7 @@ def _call(cookie: str, path: str, body: dict[str, Any]) -> dict[str, Any]:
|
|
|
365
367
|
def _post(url: str, body: dict[str, Any], headers: dict[str, str]) -> dict[str, Any]:
|
|
366
368
|
request = urllib.request.Request(
|
|
367
369
|
url, data=json.dumps(body).encode(), method="POST",
|
|
368
|
-
headers={**headers, "Content-Type": "application/json"},
|
|
370
|
+
headers=with_agent({**headers, "Content-Type": "application/json"}),
|
|
369
371
|
)
|
|
370
372
|
with urlopen(request) as response:
|
|
371
373
|
return json.loads(response.read())
|
|
@@ -497,7 +499,9 @@ def jupyter_token(id_token: str, webtier: str, deadline: float) -> str:
|
|
|
497
499
|
url = FIRESTORE_BASE + urllib.parse.quote(
|
|
498
500
|
FIRESTORE_DOCUMENT.format(sid=webtier), safe="/()"
|
|
499
501
|
)
|
|
500
|
-
request = urllib.request.Request(
|
|
502
|
+
request = urllib.request.Request(
|
|
503
|
+
url, headers=with_agent({"Authorization": "Bearer " + id_token})
|
|
504
|
+
)
|
|
501
505
|
while True:
|
|
502
506
|
try:
|
|
503
507
|
with urlopen(request) as response:
|
|
@@ -947,6 +951,7 @@ class Session:
|
|
|
947
951
|
query = f"?{urllib.parse.urlencode({'token': self.token})}" if self.token else ""
|
|
948
952
|
data = json.dumps(body).encode() if body is not None else None
|
|
949
953
|
request = urllib.request.Request(f"{self.base}{path}{query}", data=data, method=method)
|
|
954
|
+
request.add_header("User-Agent", user_agent())
|
|
950
955
|
if self.token:
|
|
951
956
|
request.add_header("Authorization", f"token {self.token}")
|
|
952
957
|
if data is not None:
|
|
@@ -19,6 +19,7 @@ from pathlib import Path
|
|
|
19
19
|
from typing import TYPE_CHECKING
|
|
20
20
|
|
|
21
21
|
from ..errors import ConfigError, InterpreterMismatch
|
|
22
|
+
from ..useragent import user_agent
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
24
25
|
from ..declare.env import Env
|
|
@@ -76,13 +77,6 @@ TAIL_LINES = 40
|
|
|
76
77
|
VERSION_SOURCE = "import sys\n__letify_value__ = '%d.%d' % sys.version_info[:2]\n"
|
|
77
78
|
|
|
78
79
|
|
|
79
|
-
def user_agent() -> str:
|
|
80
|
-
"""The User-Agent a runtime sends when it downloads the uv installer."""
|
|
81
|
-
from .. import __version__
|
|
82
|
-
|
|
83
|
-
return f"letify/{__version__}"
|
|
84
|
-
|
|
85
|
-
|
|
86
80
|
def local_python() -> str:
|
|
87
81
|
"""The major.minor of the interpreter running letify, such as ``"3.12"``."""
|
|
88
82
|
return f"{sys.version_info[0]}.{sys.version_info[1]}"
|
|
@@ -313,6 +313,9 @@ class Connection:
|
|
|
313
313
|
self._slots_lock = threading.Lock()
|
|
314
314
|
self._next_stream = 1
|
|
315
315
|
self._tail = _Tail()
|
|
316
|
+
#: Bytes of worker output received on this channel, by stream. Spec "Reattaching after
|
|
317
|
+
#: a lost channel": a reattach tells the worker how much of a call's output arrived.
|
|
318
|
+
self.received: dict[str, int] = {"stdout": 0, "stderr": 0}
|
|
316
319
|
#: Device executor messages that arrived on ``wire.DEVICE_STREAM``, or None when closed.
|
|
317
320
|
self._device: collections.deque | None = None
|
|
318
321
|
#: ``data_want`` payloads that arrived on ``wire.DATA_STREAM``, for the data sender.
|
|
@@ -343,7 +346,9 @@ class Connection:
|
|
|
343
346
|
open_slots = list(self._slots.values())
|
|
344
347
|
for slot in open_slots:
|
|
345
348
|
slot.tail.add(value)
|
|
346
|
-
|
|
349
|
+
name = "stdout" if kind == wire.STDOUT else "stderr"
|
|
350
|
+
self.received[name] += len(value)
|
|
351
|
+
self._emit(name, value)
|
|
347
352
|
elif kind == wire.HELLO:
|
|
348
353
|
with self._turn:
|
|
349
354
|
self.hello = value
|
|
@@ -81,6 +81,7 @@ def request(
|
|
|
81
81
|
"""
|
|
82
82
|
started = time.monotonic()
|
|
83
83
|
assert runtime.channel is not None
|
|
84
|
+
seen = dict(getattr(runtime.channel, "received", {}))
|
|
84
85
|
try:
|
|
85
86
|
return runtime.channel.request(payload, timeout=timeout)
|
|
86
87
|
except ProtocolError as exc:
|
|
@@ -91,7 +92,7 @@ def request(
|
|
|
91
92
|
remaining = timeout - (time.monotonic() - started)
|
|
92
93
|
if remaining <= 0:
|
|
93
94
|
raise RuntimeFailure(f"{runtime.name}: the call exceeded {timeout}s") from failure
|
|
94
|
-
pieces = _reattach(runtime, run, failure, remaining, on_channel)
|
|
95
|
+
pieces = _reattach(runtime, run, failure, remaining, on_channel, seen)
|
|
95
96
|
try:
|
|
96
97
|
return next(pieces), ""
|
|
97
98
|
except ProtocolError as exc:
|
|
@@ -107,10 +108,14 @@ def _reattach(
|
|
|
107
108
|
failure: ProtocolError,
|
|
108
109
|
timeout: float | None,
|
|
109
110
|
on_channel: Callable[[Channel], None] | None,
|
|
111
|
+
seen: dict[str, int],
|
|
110
112
|
) -> Iterator[Any]:
|
|
111
113
|
"""Adopt the run again over a new channel and return the stream that carries its reply.
|
|
112
114
|
|
|
113
|
-
Raises ``failure`` when the conditions do not hold or no attempt succeeds.
|
|
115
|
+
Raises ``failure`` when the conditions do not hold or no attempt succeeds. ``seen`` is what
|
|
116
|
+
the channel had received when the call was sent, so the difference is what the call's own
|
|
117
|
+
output amounted to. It goes to the worker as ``have``, and the new channel goes on counting
|
|
118
|
+
from the old one's totals.
|
|
114
119
|
"""
|
|
115
120
|
if not eligible(runtime, run, failure):
|
|
116
121
|
raise failure
|
|
@@ -137,11 +142,15 @@ def _reattach(
|
|
|
137
142
|
flush=True,
|
|
138
143
|
)
|
|
139
144
|
channel.echo, channel.on_output = old.echo, old.on_output
|
|
145
|
+
total = dict(getattr(old, "received", {}))
|
|
146
|
+
have = {name: count - seen.get(name, 0) for name, count in total.items()}
|
|
147
|
+
if hasattr(channel, "received"):
|
|
148
|
+
channel.received = total
|
|
140
149
|
pieces = None
|
|
141
150
|
try:
|
|
142
151
|
channel.start()
|
|
143
152
|
pieces = channel.stream(
|
|
144
|
-
{"op": "adopt", "run": run.id, "owner": os.getpid()}, timeout=timeout
|
|
153
|
+
{"op": "adopt", "run": run.id, "owner": os.getpid(), "have": have}, timeout=timeout
|
|
145
154
|
)
|
|
146
155
|
next(pieces)
|
|
147
156
|
except RemoteError:
|
|
@@ -31,6 +31,7 @@ from collections.abc import Iterator
|
|
|
31
31
|
from typing import Any
|
|
32
32
|
|
|
33
33
|
from ...errors import ConfigError, ProviderUnavailable, RuntimeFailure
|
|
34
|
+
from ...useragent import with_agent
|
|
34
35
|
from ..cas import Backend
|
|
35
36
|
from .google_auth import TokenSource
|
|
36
37
|
|
|
@@ -265,10 +266,10 @@ class DriveBackend(Backend):
|
|
|
265
266
|
# -- HTTP ------------------------------------------------------------------
|
|
266
267
|
|
|
267
268
|
def _headers(self) -> dict[str, str]:
|
|
268
|
-
return {
|
|
269
|
+
return with_agent({
|
|
269
270
|
"Authorization": f"Bearer {self.tokens.token()}",
|
|
270
271
|
"x-goog-user-project": self.project,
|
|
271
|
-
}
|
|
272
|
+
})
|
|
272
273
|
|
|
273
274
|
def _call(
|
|
274
275
|
self,
|
|
@@ -416,7 +417,7 @@ class DriveBackend(Backend):
|
|
|
416
417
|
raise RuntimeFailure(f"Drive upload session for {digest} named no upload URL")
|
|
417
418
|
return {
|
|
418
419
|
"url": location,
|
|
419
|
-
"headers": {"x-goog-user-project": self.project},
|
|
420
|
+
"headers": with_agent({"x-goog-user-project": self.project}),
|
|
420
421
|
"piece": UPLOAD_PIECE,
|
|
421
422
|
}
|
|
422
423
|
|
|
@@ -24,6 +24,7 @@ import urllib.request
|
|
|
24
24
|
from pathlib import Path
|
|
25
25
|
|
|
26
26
|
from ...errors import ProviderUnavailable, RuntimeFailure
|
|
27
|
+
from ...useragent import user_agent
|
|
27
28
|
|
|
28
29
|
#: Where Google exchanges a refresh token when the credentials file names no other place.
|
|
29
30
|
DEFAULT_TOKEN_URI = "https://oauth2.googleapis.com/token"
|
|
@@ -109,6 +110,7 @@ class TokenSource:
|
|
|
109
110
|
).encode()
|
|
110
111
|
uri = str(info.get("token_uri") or DEFAULT_TOKEN_URI)
|
|
111
112
|
request = urllib.request.Request(uri, data=form, method="POST")
|
|
113
|
+
request.add_header("User-Agent", user_agent())
|
|
112
114
|
request.add_header("Content-Type", "application/x-www-form-urlencoded")
|
|
113
115
|
try:
|
|
114
116
|
with urllib.request.urlopen(request, timeout=60) as response:
|
|
@@ -21,6 +21,7 @@ from collections.abc import Iterator
|
|
|
21
21
|
from typing import Any
|
|
22
22
|
|
|
23
23
|
from ...errors import ConfigError, ProviderUnavailable, RuntimeFailure
|
|
24
|
+
from ...useragent import user_agent, with_agent
|
|
24
25
|
from ..cas import Backend
|
|
25
26
|
from .google_auth import TokenSource
|
|
26
27
|
from .layout import BLOB_PREFIX, blob_key, ref_key
|
|
@@ -93,6 +94,7 @@ class GCSBackend(Backend):
|
|
|
93
94
|
}
|
|
94
95
|
).encode()
|
|
95
96
|
request = urllib.request.Request(self.sts_endpoint, data=form, method="POST")
|
|
97
|
+
request.add_header("User-Agent", user_agent())
|
|
96
98
|
request.add_header("Content-Type", "application/x-www-form-urlencoded")
|
|
97
99
|
try:
|
|
98
100
|
with urllib.request.urlopen(request, timeout=60) as response:
|
|
@@ -111,7 +113,7 @@ class GCSBackend(Backend):
|
|
|
111
113
|
"""A Colab runtime is a Compute Engine VM, so it reads the bucket over Google's network."""
|
|
112
114
|
return {
|
|
113
115
|
"url": self.blob_url(digest),
|
|
114
|
-
"headers": {"Authorization": f"Bearer {self.read_token()}"},
|
|
116
|
+
"headers": with_agent({"Authorization": f"Bearer {self.read_token()}"}),
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
def _key(self, key: str) -> str:
|
|
@@ -133,6 +135,7 @@ class GCSBackend(Backend):
|
|
|
133
135
|
) -> bytes | None:
|
|
134
136
|
"""Send one request. A 404 answers None, any other failure raises."""
|
|
135
137
|
request = urllib.request.Request(url, data=data, method=method)
|
|
138
|
+
request.add_header("User-Agent", user_agent())
|
|
136
139
|
request.add_header("Authorization", f"Bearer {self.tokens.token()}")
|
|
137
140
|
if data is not None:
|
|
138
141
|
request.add_header("Content-Type", "application/octet-stream")
|
|
@@ -165,6 +168,7 @@ class GCSBackend(Backend):
|
|
|
165
168
|
with open(path, "rb") as handle:
|
|
166
169
|
body = _CountingReader(handle, progress)
|
|
167
170
|
request = urllib.request.Request(url, data=body, method="POST") # type: ignore[arg-type]
|
|
171
|
+
request.add_header("User-Agent", user_agent())
|
|
168
172
|
request.add_header("Authorization", f"Bearer {self.tokens.token()}")
|
|
169
173
|
request.add_header("Content-Type", "application/octet-stream")
|
|
170
174
|
request.add_header("Content-Length", str(size))
|
|
@@ -25,6 +25,7 @@ from pathlib import Path
|
|
|
25
25
|
from typing import TYPE_CHECKING, Any
|
|
26
26
|
|
|
27
27
|
from ..errors import ConfigError, ProtocolError, RemoteError, RuntimeFailure
|
|
28
|
+
from ..useragent import with_agent
|
|
28
29
|
|
|
29
30
|
if TYPE_CHECKING:
|
|
30
31
|
from ..providers.base import Provider
|
|
@@ -1026,7 +1027,7 @@ class Stream:
|
|
|
1026
1027
|
"op": "data_pull",
|
|
1027
1028
|
"dir": self.blobs,
|
|
1028
1029
|
"items": [[digest, bucket.blob_url(digest)]],
|
|
1029
|
-
"headers": {"Authorization": f"Bearer {self._token}"},
|
|
1030
|
+
"headers": with_agent({"Authorization": f"Bearer {self._token}"}),
|
|
1030
1031
|
},
|
|
1031
1032
|
)
|
|
1032
1033
|
if not uploaded:
|
|
@@ -29,6 +29,7 @@ from collections.abc import Callable, Iterable
|
|
|
29
29
|
from dataclasses import dataclass
|
|
30
30
|
from typing import Any, Protocol
|
|
31
31
|
|
|
32
|
+
from ..useragent import user_agent
|
|
32
33
|
from . import linkd, linkwebsocket
|
|
33
34
|
|
|
34
35
|
#: The service the owner operates.
|
|
@@ -95,16 +96,6 @@ class Incoming:
|
|
|
95
96
|
body: bytes
|
|
96
97
|
|
|
97
98
|
|
|
98
|
-
def _user_agent() -> str:
|
|
99
|
-
"""The User-Agent of every request. Spec "Signalling service" item 1, "User-Agent".
|
|
100
|
-
|
|
101
|
-
Cloudflare's Browser Integrity Check refuses the urllib default with error 1010.
|
|
102
|
-
"""
|
|
103
|
-
from .. import __version__
|
|
104
|
-
|
|
105
|
-
return f"letify/{__version__}"
|
|
106
|
-
|
|
107
|
-
|
|
108
99
|
def _proxied(url: str) -> bool:
|
|
109
100
|
"""Whether the environment sends a request for ``url`` through a proxy."""
|
|
110
101
|
parts = urllib.parse.urlsplit(url)
|
|
@@ -176,7 +167,7 @@ class SignalClient:
|
|
|
176
167
|
text = f"{method}\n{target}\n{stamp}\n{nonce}\n{hashlib.sha256(body).hexdigest()}"
|
|
177
168
|
signature = self.daemon.sign(REQUEST_DOMAIN, text.encode())
|
|
178
169
|
return {
|
|
179
|
-
"User-Agent":
|
|
170
|
+
"User-Agent": user_agent(),
|
|
180
171
|
"X-Letify-Node": signer_id or self.daemon.node_id,
|
|
181
172
|
"X-Letify-Time": stamp,
|
|
182
173
|
"X-Letify-Nonce": nonce,
|
|
@@ -18,6 +18,8 @@ import urllib.request
|
|
|
18
18
|
from dataclasses import dataclass
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
|
|
21
|
+
from ..useragent import with_agent
|
|
22
|
+
|
|
21
23
|
#: Seconds a mapping is asked to live. One hour outlasts a session's setup and is short
|
|
22
24
|
#: enough that a mapping letify fails to release expires on its own.
|
|
23
25
|
LIFETIME = 3600
|
|
@@ -239,7 +241,9 @@ def _ssdp_location(timeout: float) -> str | None:
|
|
|
239
241
|
|
|
240
242
|
def _fetch(url: str, timeout: float) -> str | None:
|
|
241
243
|
try:
|
|
242
|
-
with urllib.request.urlopen(
|
|
244
|
+
with urllib.request.urlopen(
|
|
245
|
+
urllib.request.Request(url, headers=with_agent()), timeout=timeout
|
|
246
|
+
) as answer:
|
|
243
247
|
return answer.read(1 << 18).decode("latin-1")
|
|
244
248
|
except Exception:
|
|
245
249
|
return None
|
|
@@ -266,10 +270,10 @@ def _soap(url: str, service: str, action: str, body: str, timeout: float) -> str
|
|
|
266
270
|
request = urllib.request.Request(
|
|
267
271
|
url,
|
|
268
272
|
data=envelope,
|
|
269
|
-
headers={
|
|
273
|
+
headers=with_agent({
|
|
270
274
|
"Content-Type": 'text/xml; charset="utf-8"',
|
|
271
275
|
"SOAPAction": f'"{service}#{action}"',
|
|
272
|
-
},
|
|
276
|
+
}),
|
|
273
277
|
)
|
|
274
278
|
try:
|
|
275
279
|
with urllib.request.urlopen(request, timeout=timeout) as answer:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""The User-Agent letify names itself with. Owns the string; it sends no request itself.
|
|
2
|
+
|
|
3
|
+
Spec "User-Agent": every HTTP request letify sends carries ``User-Agent: letify/<version>``.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from collections.abc import Mapping
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def user_agent() -> str:
|
|
12
|
+
"""The User-Agent of every request: ``letify/<version>``."""
|
|
13
|
+
from . import __version__
|
|
14
|
+
|
|
15
|
+
return f"letify/{__version__}"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def with_agent(headers: Mapping[str, str] | None = None) -> dict[str, str]:
|
|
19
|
+
"""A copy of ``headers`` that carries the letify User-Agent, keeping any one already set."""
|
|
20
|
+
named = dict(headers or {})
|
|
21
|
+
if not any(key.lower() == "user-agent" for key in named):
|
|
22
|
+
named["User-Agent"] = user_agent()
|
|
23
|
+
return named
|