mighty-colab 0.1.12__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.
- mighty_colab-0.1.12/.githooks/pre-commit +9 -0
- mighty_colab-0.1.12/.gitignore +89 -0
- mighty_colab-0.1.12/.gitmodules +0 -0
- mighty_colab-0.1.12/.pre-commit-config.yaml +36 -0
- mighty_colab-0.1.12/.python-version +1 -0
- mighty_colab-0.1.12/AGENTS.md +97 -0
- mighty_colab-0.1.12/CHANGELOG.md +81 -0
- mighty_colab-0.1.12/CONTRIBUTING.md +5 -0
- mighty_colab-0.1.12/LICENSE +202 -0
- mighty_colab-0.1.12/PKG-INFO +277 -0
- mighty_colab-0.1.12/README.md +239 -0
- mighty_colab-0.1.12/cloudbuild.yaml +91 -0
- mighty_colab-0.1.12/docs/01_session_management.md +120 -0
- mighty_colab-0.1.12/docs/02_execution_and_interactive.md +57 -0
- mighty_colab-0.1.12/docs/03_file_management.md +62 -0
- mighty_colab-0.1.12/docs/04_automation_and_utility.md +334 -0
- mighty_colab-0.1.12/docs/05_run_command.md +92 -0
- mighty_colab-0.1.12/docs/06_ssh_access.md +135 -0
- mighty_colab-0.1.12/docs/07_mcp_server.md +143 -0
- mighty_colab-0.1.12/docs/3042ab12-2026-05-07.png +0 -0
- mighty_colab-0.1.12/docs/demo.webm +0 -0
- mighty_colab-0.1.12/docs/demos.md +625 -0
- mighty_colab-0.1.12/examples/finetune_run.py +153 -0
- mighty_colab-0.1.12/integration/README.md +34 -0
- mighty_colab-0.1.12/integration/repro_bundled_oauth/test.sh +93 -0
- mighty_colab-0.1.12/integration/repro_keep_alive/test.sh +135 -0
- mighty_colab-0.1.12/integration/repro_keep_alive_scope/test.sh +164 -0
- mighty_colab-0.1.12/integration/repro_mcp_server/test.sh +200 -0
- mighty_colab-0.1.12/integration/repro_piped_console/test.sh +92 -0
- mighty_colab-0.1.12/integration/repro_plot_redirection/test.sh +60 -0
- mighty_colab-0.1.12/integration/repro_run_command/test.sh +132 -0
- mighty_colab-0.1.12/integration/repro_ssh/test.sh +189 -0
- mighty_colab-0.1.12/integration/repro_variable_persistence/test.sh +51 -0
- mighty_colab-0.1.12/pyproject.toml +87 -0
- mighty_colab-0.1.12/skills/colab-operator/SKILL.md +98 -0
- mighty_colab-0.1.12/src/colab_cli/auth.py +247 -0
- mighty_colab-0.1.12/src/colab_cli/auto_update.py +254 -0
- mighty_colab-0.1.12/src/colab_cli/cli.py +159 -0
- mighty_colab-0.1.12/src/colab_cli/client.py +305 -0
- mighty_colab-0.1.12/src/colab_cli/commands/__init__.py +14 -0
- mighty_colab-0.1.12/src/colab_cli/commands/adopt.py +141 -0
- mighty_colab-0.1.12/src/colab_cli/commands/automation.py +270 -0
- mighty_colab-0.1.12/src/colab_cli/commands/execution.py +412 -0
- mighty_colab-0.1.12/src/colab_cli/commands/files.py +204 -0
- mighty_colab-0.1.12/src/colab_cli/commands/mcp.py +32 -0
- mighty_colab-0.1.12/src/colab_cli/commands/run.py +525 -0
- mighty_colab-0.1.12/src/colab_cli/commands/session.py +514 -0
- mighty_colab-0.1.12/src/colab_cli/commands/ssh.py +682 -0
- mighty_colab-0.1.12/src/colab_cli/commands/utility.py +436 -0
- mighty_colab-0.1.12/src/colab_cli/common.py +185 -0
- mighty_colab-0.1.12/src/colab_cli/console.py +172 -0
- mighty_colab-0.1.12/src/colab_cli/contents.py +93 -0
- mighty_colab-0.1.12/src/colab_cli/converter.py +184 -0
- mighty_colab-0.1.12/src/colab_cli/history.py +65 -0
- mighty_colab-0.1.12/src/colab_cli/mcp_server.py +228 -0
- mighty_colab-0.1.12/src/colab_cli/oauth_config.json +11 -0
- mighty_colab-0.1.12/src/colab_cli/repl.py +174 -0
- mighty_colab-0.1.12/src/colab_cli/runtime.py +274 -0
- mighty_colab-0.1.12/src/colab_cli/state.py +156 -0
- mighty_colab-0.1.12/src/colab_cli/utils.py +104 -0
- mighty_colab-0.1.12/tests/conftest.py +39 -0
- mighty_colab-0.1.12/tests/test_adopt.py +262 -0
- mighty_colab-0.1.12/tests/test_auth.py +158 -0
- mighty_colab-0.1.12/tests/test_auth_adc.py +203 -0
- mighty_colab-0.1.12/tests/test_automation.py +125 -0
- mighty_colab-0.1.12/tests/test_cli.py +565 -0
- mighty_colab-0.1.12/tests/test_cli_log.py +95 -0
- mighty_colab-0.1.12/tests/test_client.py +236 -0
- mighty_colab-0.1.12/tests/test_console.py +222 -0
- mighty_colab-0.1.12/tests/test_contents.py +152 -0
- mighty_colab-0.1.12/tests/test_exec.py +301 -0
- mighty_colab-0.1.12/tests/test_history.py +52 -0
- mighty_colab-0.1.12/tests/test_ipynb_exec.py +216 -0
- mighty_colab-0.1.12/tests/test_keep_alive.py +423 -0
- mighty_colab-0.1.12/tests/test_log_export.py +109 -0
- mighty_colab-0.1.12/tests/test_mcp_server.py +228 -0
- mighty_colab-0.1.12/tests/test_pay.py +30 -0
- mighty_colab-0.1.12/tests/test_readme.py +92 -0
- mighty_colab-0.1.12/tests/test_repl.py +268 -0
- mighty_colab-0.1.12/tests/test_resolution_logic.py +119 -0
- mighty_colab-0.1.12/tests/test_run.py +639 -0
- mighty_colab-0.1.12/tests/test_runtime.py +165 -0
- mighty_colab-0.1.12/tests/test_ssh.py +444 -0
- mighty_colab-0.1.12/tests/test_ssh_autocreate.py +313 -0
- mighty_colab-0.1.12/tests/test_ssh_lifecycle.py +284 -0
- mighty_colab-0.1.12/tests/test_ssh_wire_contract.py +391 -0
- mighty_colab-0.1.12/tests/test_ssh_workdir.py +75 -0
- mighty_colab-0.1.12/tests/test_state.py +327 -0
- mighty_colab-0.1.12/tests/test_streaming.py +98 -0
- mighty_colab-0.1.12/tests/test_update.py +583 -0
- mighty_colab-0.1.12/tests/test_url.py +332 -0
- mighty_colab-0.1.12/tests/test_utils.py +87 -0
- mighty_colab-0.1.12/tests/test_version.py +55 -0
- mighty_colab-0.1.12/tests/test_whoami.py +172 -0
- mighty_colab-0.1.12/uv.lock +1197 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
|
|
4
|
+
# end templated
|
|
5
|
+
|
|
6
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
+
ARGS+=(--hook-dir "$HERE" -- "$@")
|
|
8
|
+
|
|
9
|
+
exec uv run --active --index https://pypi.org/simple --with pre-commit,pre-commit-uv pre-commit "${ARGS[@]}"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Environments
|
|
55
|
+
.env
|
|
56
|
+
.venv
|
|
57
|
+
env/
|
|
58
|
+
venv/
|
|
59
|
+
ENV/
|
|
60
|
+
env.bak/
|
|
61
|
+
venv.bak/
|
|
62
|
+
|
|
63
|
+
# IDEs / Editors
|
|
64
|
+
.vscode/
|
|
65
|
+
.idea/
|
|
66
|
+
*.swp
|
|
67
|
+
*.swo
|
|
68
|
+
*~
|
|
69
|
+
.DS_Store
|
|
70
|
+
|
|
71
|
+
# Tool caches
|
|
72
|
+
.ruff_cache/
|
|
73
|
+
.mypy_cache/
|
|
74
|
+
.pyre/
|
|
75
|
+
|
|
76
|
+
# Logs
|
|
77
|
+
colab.log
|
|
78
|
+
*.log
|
|
79
|
+
|
|
80
|
+
# Jupyter
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# Design Docs & Research Scripts (Untracked)
|
|
84
|
+
DRIVEFS_BACKEND_PROPOSAL.md
|
|
85
|
+
docs/AUTH_DESIGN_PROPOSAL.md
|
|
86
|
+
docs/credential propagation - flow details.md
|
|
87
|
+
docs/credential propagation analysis.md
|
|
88
|
+
docs/creds.md
|
|
89
|
+
get_drive_source.py
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
repos:
|
|
16
|
+
- repo: local
|
|
17
|
+
hooks:
|
|
18
|
+
- id: pytest
|
|
19
|
+
name: pytest
|
|
20
|
+
entry: uv run pytest
|
|
21
|
+
language: system
|
|
22
|
+
types: [python]
|
|
23
|
+
pass_filenames: false
|
|
24
|
+
always_run: true
|
|
25
|
+
- id: ruff-check
|
|
26
|
+
name: ruff check
|
|
27
|
+
entry: uv run ruff check --force-exclude
|
|
28
|
+
language: system
|
|
29
|
+
types: [python]
|
|
30
|
+
require_serial: true
|
|
31
|
+
- id: ruff-format
|
|
32
|
+
name: ruff format
|
|
33
|
+
entry: uv run ruff format --force-exclude
|
|
34
|
+
language: system
|
|
35
|
+
types: [python]
|
|
36
|
+
require_serial: true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Colab CLI: Agent Guidelines
|
|
2
|
+
|
|
3
|
+
## Architecture Overview
|
|
4
|
+
- **CLI**: Modular `Typer` based entry point in `cli.py` with subcommands in `commands/`.
|
|
5
|
+
- **Common**: `common.py` centralizes shared `State` (lazy-loading) and session resolution.
|
|
6
|
+
- **Client**: `ColabClient` handles API interactions (assignment, unassignment).
|
|
7
|
+
- **Auth**: `auth.py` exposes a single `get_credentials(config_path, provider)` facade that dispatches on the `AuthProvider` enum. Two providers are supported, selected via the global `--auth=oauth2|adc` flag (default `oauth2`):
|
|
8
|
+
- `oauth2`: public `google-auth-oauthlib` `InstalledAppFlow`, token cached at `~/.config/colab-cli/token.json`. Reads the client OAuth config from `-c/--client-oauth-config` (default `~/.colab-cli-oauth-config.json`), falling back to the **bundled** `src/colab_cli/oauth_config.json` resource (re-added in PR #41 / `9f44fe2`, 2026-05-29 — the earlier "removed in `20eb88e`" note was stale/incorrect; the file exists and `auth.py:_get_google_auth_credentials` loads it via `importlib.resources`). As of 2026-06-11 the flow is a **remote copy-paste flow**, not a localhost server: `_run_remote_flow` sets `redirect_uri=https://sdk.cloud.google.com/applicationdefaultauthcode.html` + `token_usage=remote`, prints the URL, and reads the pasted code via `input()`. NEVER revert to OOB (`urn:ietf:wg:oauth:2.0:oob`) — Google blocked it in 2022 ("OOB flow has been blocked"); the `sdk.cloud.google.com` redirect is registered only to the bundled cloud-SDK client (`764086051850-...`), so any other client id gets `redirect_uri_mismatch`. Server-side acceptance/rejection of these variants is verifiable GET-only by building the authorization URL and inspecting whether Google reaches sign-in vs. an OAuth error page (no resources allocated).
|
|
9
|
+
- `adc`: Google Application Default Credentials via `google.auth.default()`. The CLI passes `scopes=PUBLIC_SCOPES` (which includes `colaboratory`) and re-applies via `creds.with_scopes()` for credential types that support it. **User credentials minted by `gcloud auth application-default login` ignore the `scopes=` kwarg AND raise `NotImplementedError` on `with_scopes`**: ADC users must explicitly re-authenticate with `gcloud auth application-default login --scopes=openid,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/colaboratory`. `userinfo.email` is required by the session backend at `colab.research.google.com` (assign/unassign/sessions/keep-alive return 401 without it); `colaboratory` is retained for forward compatibility and other Colab features (keep-alive no longer uses `colab.pa.googleapis.com` — see the Keep-alive note below); `openid` and `cloud-platform` are mandated by `gcloud` itself, which rejects scope lists that omit `cloud-platform` with `Invalid value for [--scopes]`. Service-account / GCE / GKE / impersonated creds get the right scopes transparently via `with_scopes`.
|
|
10
|
+
- **Backend Hosts**: Two distinct backends with different requirements:
|
|
11
|
+
- `colab.research.google.com` (session backend / `tun/m/...`): accepts the `userinfo.email` scope. Handles assign, unassign, the contents API, **and keep-alive** (see below).
|
|
12
|
+
- **Keep-alive (2026-06-15, issue #14)**: keep-alive is a **Tunnel Frontend (TFE) HTTP ping** — `GET https://colab.research.google.com/tun/m/<endpoint>/keep-alive/` with header `X-Colab-Tunnel: Google`, authenticated by the user's own Gaia bearer token (same host/credential as `assign`). TFE records `LastActiveTime` before forwarding, refreshing the idle timer. The VM usually doesn't answer on this path, so the request commonly **read-times-out even on success** — `client.keep_alive_assignment` therefore catches `requests.exceptions.ReadTimeout` and treats it as success, while genuine HTTP errors (e.g. 404 for a deleted assignment) propagate. This mirrors the official `colab-vscode` extension's `sendKeepAlive` (`src/colab/client.ts`). **DO NOT revert to the `colab.pa.googleapis.com` `RuntimeService/KeepAliveAssignment` RPC**: that RPC requires the caller to be a `serviceusage` consumer of Colab's internal project `1014160490159`, which no ordinary user account is, so it returned HTTP 403 `USER_PROJECT_DENIED` for every external user (issue #14) and silently idle-pruned their sessions within minutes. The browser only made that RPC work by riding the user's `google.com` cookie through an internal cookie-proxy (`colab.clients6.google.com`), which a headless bearer-token CLI cannot use. Verified live 2026-06-15 with a third-party account (the RPC 403'd; the tunnel ping succeeded and kept the VM alive).
|
|
13
|
+
- **Runtime**: `ColabRuntime` wraps `jupyter-kernel-client` for execution.
|
|
14
|
+
- **State**:
|
|
15
|
+
- `StateStore` persists session metadata in `~/.config/colab-cli/sessions.json`.
|
|
16
|
+
- Persistent settings are in `~/.config/colab-cli/settings.json`.
|
|
17
|
+
- **History**: `HistoryLogger` records structured events in `~/.config/colab-cli/history/*.jsonl`.
|
|
18
|
+
|
|
19
|
+
## Core Mandates
|
|
20
|
+
- **Minimalism**: Favor standard library where possible (e.g., `urllib`) while utilizing `Typer` for CLI ergonomics.
|
|
21
|
+
- **Piping**: Always consider piped input (`stdin`) vs. interactive TTY.
|
|
22
|
+
- **Trace Alignment**: When implementing new endpoints, validate against captured browser traces (HAR files).
|
|
23
|
+
- **TDD (Test-Driven Development)**: Always implement tests first. Verify they fail before implementing the solution to make them pass. Every design must include a testing strategy and specific test cases.
|
|
24
|
+
|
|
25
|
+
- **Jupyter Protocol Deviations**: Google Colab uses custom extensions to the Jupyter protocol. Examples include `colab_request` messages over the `iopub` channel and `input_reply` wrapping `colab_reply` payloads on the `stdin` channel. These require monkey-patching or specialized handlers within `jupyter-kernel-client` (e.g., `wsclient.kernel_socket.on_message` interceptors).
|
|
26
|
+
|
|
27
|
+
- **Integration Testing**: Unit tests and mocks are not enough. Before declaring any feature complete, you MUST perform a real-world, end-to-end integration test against a live Colab environment using the CLI. Never rely solely on mocked unit tests to verify a feature's correctness.
|
|
28
|
+
- Integration tests are located in `integration/` (e.g., `integration/repro_plot_redirection/test.sh`).
|
|
29
|
+
- To run an integration test, use: `uv run bash integration/repro_<name>/test.sh`.
|
|
30
|
+
- `uv run` ensures the `colab` command (entry point) is available in the shell environment.
|
|
31
|
+
- **Continuous Improvement**: Whenever the user provides feedback, workflow advice, or corrections, immediately encode that advice into this `AGENTS.md` file. The goal is to learn from review and never repeat the same errors.
|
|
32
|
+
|
|
33
|
+
## Tools & Workflow
|
|
34
|
+
- **Workflow**:
|
|
35
|
+
1. **Draft**: Plan and start the task. Create a new git branch before working on new features or changes.
|
|
36
|
+
2. **Refine**: Implement changes and verify with tests and linting. Run tests using `uv run pytest tests/` and resolve any lint errors using `uv run ruff check . --fix`.
|
|
37
|
+
3. **Finalize**: Ensure everything is complete and correct. **Whenever features are added or behaviors change, you MUST re-review the corresponding design document in `docs/` and update it to reflect the new state. You should also add a brief log entry to the frontmatter of the updated design document with the current date summarizing the change.** Finally, commit the finished changes to the git branch for review.
|
|
38
|
+
|
|
39
|
+
## Subcommand Workflows
|
|
40
|
+
- **Session Management**: `new`, `sessions`, `status`, `stop`.
|
|
41
|
+
- **Execution**: `repl`, `exec`, `console`.
|
|
42
|
+
- **Files**: `ls`, `rm`, `upload`, `download`, `edit`.
|
|
43
|
+
- **Automation**: `auth`, `drivemount`, `install`, `log`, `pay`, `version`, `update`.
|
|
44
|
+
|
|
45
|
+
## Release Tagging Workflow
|
|
46
|
+
The package version is derived from the git tag via `hatch-vcs` (see `pyproject.toml`), so a release is just (1) a `CHANGELOG.md` entry and (2) a `vX.Y.Z` tag on the merged commit. Follow this workflow ONLY when the user explicitly requests a release (e.g. "cut a release", "tag v0.7.0", "release the keep-alive fix"). NEVER propose or perform a release proactively.
|
|
47
|
+
|
|
48
|
+
1. **Verify a clean, current `main`**: `git fetch origin && git checkout main && git pull --ff-only origin main`. Confirm `git status` is clean. If `main` has diverged or there are unmerged feature branches the user expects in the release, stop and ask.
|
|
49
|
+
2. **Identify unreleased commits**: Find the last release tag with `git describe --tags --abbrev=0`, then list commits since then with `git log <last-tag>..HEAD --oneline`. These are what the new changelog section must cover. Cross-reference each commit's PR number (the `(#NN)` suffix in the merge commit subject) — every entry in the changelog should cite at least one PR.
|
|
50
|
+
3. **Infer the next version (semver)**: Categorize each commit using the Keep-a-Changelog buckets already present in `CHANGELOG.md` (`Added`, `Changed`, `Fixed`, `Removed`, `Deprecated`, `Security`). Pick the bump:
|
|
51
|
+
- **Major** (`X.0.0`): any breaking change to the CLI surface, flag semantics, on-disk state schema (`sessions.json` / `settings.json`), or persisted token format.
|
|
52
|
+
- **Minor** (`0.X.0`): at least one `Added` entry (new subcommand, new flag, new capability) with no breaking changes.
|
|
53
|
+
- **Patch** (`0.0.X`): only `Fixed`, `Changed`, `Removed` (non-breaking cleanup), `Deprecated`, or `Security` entries.
|
|
54
|
+
Confirm the inferred version with the user before proceeding — never tag without that confirmation, even when the bump seems obvious.
|
|
55
|
+
4. **Draft and commit the CHANGELOG entry on a branch**: Create a release branch (e.g. `release-v0.7.0`), then prepend a new `## [X.Y.Z] - YYYY-MM-DD` section above the previous release. Group entries by category in the order already established in `CHANGELOG.md` (`Changed`, `Added`, `Fixed`, `Removed`). Each bullet should be one short paragraph naming the user-visible behavior change (not the implementation detail) and ending with the PR reference `(#NN)`. Append a new link reference at the bottom: `[X.Y.Z]: https://github.com/danbarua/mighty-colab/compare/v<PREV>...vX.Y.Z`. Commit with message `docs: add CHANGELOG.md for vX.Y.Z release`, push the branch, and open a PR with `gh pr create`.
|
|
56
|
+
5. **Wait for the changelog PR to merge**: Do NOT tag the pre-merge commit on your branch. The tag must land on the squash-merge commit that appears on `main` (this is what `hatch-vcs` will see and what users will `git checkout`). After the user reports the PR is merged (or you observe it via `gh pr view <num> --json state,mergeCommit`), `git fetch origin && git checkout main && git pull --ff-only origin main`.
|
|
57
|
+
6. **Tag the merged changelog commit and push the tag**: Verify `git log -1 --oneline` is the merged changelog commit (subject matches `docs: add CHANGELOG.md for vX.Y.Z release (#NN)`). Create an annotated tag whose message is the changelog section body: `git tag -a vX.Y.Z -m "vX.Y.Z" -m "<changelog section body>"`. Push with `git push origin vX.Y.Z`. Do NOT create a GitHub Release entry via `gh release create` — the tag alone is sufficient because `hatch-vcs` reads it directly, and the canonical release notes already live in `CHANGELOG.md`.
|
|
58
|
+
7. **Verify**: Run `git describe --tags --exact-match HEAD` (should print `vX.Y.Z`) and `uv run mighty-colab version` (the version string should match). Confirm with `gh api repos/danbarua/mighty-colab/tags --jq '.[0].name'` that the tag is visible on the remote.
|
|
59
|
+
|
|
60
|
+
## Implementation Principles
|
|
61
|
+
1. **Direct Execution**: Code for `auth`, `drivemount`, etc., should be injected and executed on the VM kernel.
|
|
62
|
+
2. **Contents API**: Use the Jupyter Contents API for file management as seen in the browser traces.
|
|
63
|
+
3. **Transparent Storage**: Local state must be overridable via flags.
|
|
64
|
+
4. **No netrc**: Avoid `netrc` for token persistence in this project.
|
|
65
|
+
5. **Mocking Interactivity**: When testing commands that branch on `stdin.isatty()`, use the `is_stdin_tty` helper in `execution.py` and mock it via `mocker.patch("colab_cli.commands.execution.is_stdin_tty", return_value=...)`. This ensures tests don't hang in CI/agent environments.
|
|
66
|
+
6. **State Isolation**: Always patch the `colab_cli.common.state` singleton in tests to control session persistence and client behavior. Refer to `tests/conftest.py` for the standard global fixture.
|
|
67
|
+
7. **Fire-and-Forget Architecture**: The Colab CLI is a "fire-and-forget" tool. Avoid using background threads for long-running tasks within the main command flows. For persistent needs such as keep-alive, utilize detached background daemon processes (with PID tracking in the session state).
|
|
68
|
+
8. **Verify the Local Install**: A globally-installed `colab` may exist on `PATH` (e.g. at `~/.local/bin/colab`) and can shadow the project's editable install when `uv run` is invoked from outside the repo. ALWAYS run shell commands with the repo as the working directory (e.g. via the `workdir` parameter, never `cd && cmd`) so `uv run mighty-colab ...` resolves to `.venv/bin/colab`. Confirm with `which colab` and `uv run which colab` if a CLI test produces unexpected results (e.g. flag-not-recognized errors for flags you just added). **Shebang invocations always resolve via `$PATH`**, so a script like `#!/usr/bin/env -S mighty-colab run ...` will pick up the stale global tool even when the editable install is current — when testing shebang-based behavior after a code change, always run `uv tool install --reinstall --force --from . colab` first, then verify with `colab version` (the version string includes the git short SHA). Encoded 2026-05-12 after the SystemExit-suppression fix appeared not to work in `examples/hello_colab.py` because the shebang resolved to a uv-tool install pinned to the prior commit.
|
|
69
|
+
9. **Isolate the Regression First**: When a user reports an error in code you just touched, do NOT assume your change caused it. First, reproduce the failure on `main` (or the branch point) to determine whether the bug is pre-existing. Only after confirming the regression is yours should you start debugging the new code. Encoded after spending a turn debugging "ADC broke `colab new`" only to discover `colab new --gpu A100` was already failing on `main` due to an A100-quota-vs-default issue unrelated to ADC.
|
|
70
|
+
10. **Live Probes Allocate Real Resources**: Probing the Colab API to debug an issue creates real, billable assignments — every successful POST `/tun/m/assign` reserves a VM. Prefer GET-only (read) probes whenever possible. For any state-mutating call, (a) record every endpoint you create as you go, and (b) clean up via `client.unassign(endpoint)` (or `colab stop`) before declaring the investigation done. Then verify with `colab sessions` that nothing was orphaned.
|
|
71
|
+
11. **Push Freshness**: The remote may have advanced during a session (other contributors land commits while you work). ALWAYS `git fetch <remote>` immediately before pushing or merging. If `git log main..<remote>/main` is non-empty, reset local `main` to the remote, rebase feature branches onto it, retest, then push. NEVER force-push `main` to recover from divergence.
|
|
72
|
+
12. **Amend Safety**: Before `git commit --amend`, explicitly verify all three preconditions: (a) the user requested amend OR a pre-commit hook auto-modified files for an otherwise-successful commit, (b) HEAD was created by you in this conversation (`git log -1 --format='%an %ae'`), (c) the commit has not been pushed to a remote. If any precondition fails, create a new commit instead. NEVER amend a failed/rejected commit — fix the issue and create a new one.
|
|
73
|
+
13. **Run Integration Tests Yourself**: Re-read AGENTS.md "Agent Execution Limitations" before claiming you can't run a test. The CANNOT-run list is exclusively interactive commands (`colab auth`, `colab drivemount`, `colab repl`, `colab console`). Tests built on `colab new` / `colab stop` / `colab log` are non-interactive and you MUST run them yourself before declaring a fix complete. Encoded after running through a full implement-and-document cycle for a fix that the integration test would have falsified in 30 seconds — the cure was `uv run bash integration/repro_keep_alive/test.sh`.
|
|
74
|
+
14. **Heed Research Caveats**: When a research subagent surfaces a caveat ("the proto allows it but the policy may reject"), treat it as a TODO to verify, not as a footnote. The validation pattern: shell out to the actual service with the proposed inputs and confirm the response matches expectations BEFORE writing the code that depends on it. For policy-gated paths, run a one-shot probe before committing to a design.
|
|
75
|
+
15. **Two distinct auths — never confuse them**: This codebase has two unrelated authentication concerns: (a) **CLI-to-Colab-control-plane**: how `Client` authenticates HTTP requests to `colab.research.google.com` and `colab.pa.googleapis.com`. Driven by the global `--auth={oauth2,adc}` flag and `auth.py:get_credentials`. The OAuth2 path is bootstrapped automatically by `google_auth_oauthlib`'s `InstalledAppFlow` on first invocation when `~/.config/colab-cli/token.json` doesn't exist; **no separate command is needed** — any `--auth=oauth2` invocation (e.g. `colab --auth=oauth2 sessions`) triggers the browser consent flow. (b) **VM-side credentials**: how the `colab auth` subcommand injects user GCP credentials *into* the running Colab kernel so notebook code (e.g. `gcloud`, BigQuery client) can make authenticated calls from inside the VM. This uses the `USE_AUTH_EPHEM='0'` gcloud-fallback path executed on the kernel via `ColabRuntime`. **NEVER tell a user to "run `colab auth`" as a prerequisite for fixing CLI-side auth issues** — they're orthogonal layers and the suggestion misleads.
|
|
76
|
+
16. **Detached daemons inherit nothing useful**: When spawning a detached child process via `subprocess.Popen` (e.g. `spawn_keep_alive`), the child does NOT inherit the parent's parsed Typer flags. It re-parses argv from scratch, so any global flag the parent saw via `--auth=adc` or `--config /tmp/foo.json` MUST be re-emitted as part of the child's command line. Forgetting this causes silent fallback to Typer defaults: in 2026-04-30 this manifested as the keep-alive daemon (a) using OAUTH2 instead of the parent's ADC, and (b) reading from `~/.config/colab-cli/sessions.json` instead of the parent's `--config` path. Always propagate every relevant global flag in `cmd = [sys.executable, "-m", ...]` BEFORE the subcommand name (Typer requires global flags before the subcommand).
|
|
77
|
+
17. **Persist-before-spawn for daemons that read shared state**: When a detached child reads from a state file the parent owns (e.g. `state.store.get(session_name)`), the parent MUST persist BEFORE spawning. Otherwise the child can race ahead of the parent's `add()` call and observe an empty store. Symptom in 2026-04-30: keep-alive daemon exits immediately with `keep_alive_stopped reason=session_not_found iters=1 duration=0.0s`. Fix: call `state.store.add(s)` once before `spawn_keep_alive`, and again after (to capture the PID).
|
|
78
|
+
18. **[SUPERSEDED 2026-06-15 — keep-alive no longer calls `colab.pa.googleapis.com`; see issue #14 / the Keep-alive note above] `colab.pa.googleapis.com` rejects ADC user creds without `X-Goog-User-Project`**: When calling `colab.pa.googleapis.com` from ADC user credentials minted by `gcloud auth application-default login`, the bearer token carries the user's gcloud quota project. The mighty-colab API key sent alongside it belongs to a different project (Colab, `1014160490159`). The backend enforces project-match between the two and returns HTTP 400 `CONSUMER_INVALID` ("The API Key and the authentication credential are from different projects."). The old fix was to send `X-Goog-User-Project: 1014160490159` to pin the consumer project — but that in turn required `serviceusage.serviceUsageConsumer` on project `1014160490159`, which ordinary users lack, yielding HTTP 403 `USER_PROJECT_DENIED` (the issue #14 root cause). Both failure modes are now moot because keep-alive uses the TFE tunnel ping on `colab.research.google.com` instead. Retained here as institutional knowledge: if any future code path must call `colab.pa.googleapis.com` with a bearer token, it will face this same project-entitlement wall for non-internal accounts.
|
|
79
|
+
19. **Pydantic validation requires a schema**: `_issue_request` accepts an optional `schema=` and historically called `TypeAdapter(schema).validate_python(...)` unconditionally. When `schema=None` (a caller that doesn't care about the response body — e.g. fire-and-forget RPCs like `KeepAliveAssignment` that return `[]`), this raises `pydantic.ValidationError: Input should be None`. Always guard with `if schema is None: return` after the empty-body short-circuit.
|
|
80
|
+
20. **Suggest the branch-diff review command after committing**: The user reviews changes with `git diff main..<branch-name>` (full cumulative diff against `main`, not just the latest commit). After landing one or more commits on a feature branch, ALWAYS suggest the exact command — e.g. "Review with `git diff main..sort-help-commands`" — instead of `git show <sha>` (which only shows a single commit and misses context when a branch has multiple commits). Encoded 2026-05-05 after suggesting `git show 9d9c7da` for a branch the user wanted to review holistically.
|
|
81
|
+
21. **Verify research-tool claims with primary sources**: Research tools and AI assistants can be confidently wrong, especially about edge cases or features outside their training corpus. When such a tool says "X is not used / not parsed / doesn't exist", treat it as a hypothesis to verify, not a fact. Always cross-check against the primary source (the actual code or config) — and when a tool names files, check whether the indirection chain it describes actually exists. The cost of believing the tool when it's wrong is shipping a non-functional feature; the cost of double-checking is small. Encoded 2026-05-05 after a `colab url` first-cut shipped the wrong URL format because of unverified output.
|
|
82
|
+
22. **Clean up orphaned assignments before finishing live tests**: After running a live integration test, `colab sessions` may show server-side assignments that the local `colab stop` couldn't see (e.g. assignments leaked from earlier in the session, or from crashed prior runs). Always run `colab sessions` as the final cleanup step, and for any `[?]`-marked orphan, run `python -c "from colab_cli.common import state; state.client.unassign('<endpoint>')"` (the CLI doesn't expose a direct unassign-by-endpoint command). Re-verify with `colab sessions` returning "No active sessions". Encoded 2026-05-05 after the first `colab url` live test left an orphan from a prior conversation turn that would have idled-out and billed compute units.
|
|
83
|
+
23. **Forward unknown args through Typer with `context_settings`**: Typer/Click consumes any token starting with `-`/`--` as a flag of the parent command unless told otherwise. For a subcommand like `colab run script.py --some-script-flag` (where `--some-script-flag` belongs to the user's script, not to `colab`), declare it with `app.command(name="run", context_settings={"allow_extra_args": True, "ignore_unknown_options": True})` and accept the positional with `Annotated[Optional[List[str]], typer.Argument(...)] = None`. Also use `repr()` (not f-string interpolation) when embedding those forwarded strings into kernel-side Python source — `repr()` produces a safe round-trippable literal regardless of the user's shell-passed quotes, backslashes, or non-ASCII bytes. Encoded 2026-05-12 while implementing `colab run`.
|
|
84
|
+
|
|
85
|
+
## Agent Execution Limitations (What I Can vs Cannot Run)
|
|
86
|
+
As an AI agent operating via non-interactive shell tools (`run_shell_command`), there are strict limits on what I can test autonomously without human intervention:
|
|
87
|
+
- **I CAN Run:**
|
|
88
|
+
- Automated tests (`pytest`), linting (`ruff`), and headless execution scripts.
|
|
89
|
+
- Subcommands that don't pause for user input (e.g., `colab new`, `colab status`, `colab stop`, `colab ls`, `colab install`, `colab exec <file.py>`).
|
|
90
|
+
- **Piped `colab repl` and `colab console`**: as of 2026-05-07 both commands support piped stdin and exit cleanly on EOF (`echo 'cmd' | mighty-colab console -s s` returns in ~1.2s). The unpiped, interactive variants still cannot be run autonomously.
|
|
91
|
+
- Specially crafted mock scripts that simulate timeouts or API calls.
|
|
92
|
+
- **I CANNOT Run (Requires User Assistance):**
|
|
93
|
+
- **`colab auth`**: This command relies on the traditional Gcloud fallback `input_request` (via `USE_AUTH_EPHEM='0'`), which prompts the user via Python's `input()` to click a URL, sign in, and paste back an authorization code. My shell tool will hang indefinitely on this `input()`.
|
|
94
|
+
- **`colab drivemount`**: This command prompts the user via `sys.stdin.readline()` (specifically querying `/dev/tty` to ensure input is captured) to press `Enter` after granting OAuth consent in the browser. My shell tool will timeout/hang waiting for `Enter`.
|
|
95
|
+
- **Interactive (TTY) `colab repl` / `colab console`**: When stdin is a real terminal these commands drop into interactive raw-TTY modes that require real-time keystroke streaming. My shell tools cannot support this. (Piped stdin is fine — see above.)
|
|
96
|
+
|
|
97
|
+
Whenever working on interactive commands, I must build the core logic, write mock tests, and explicitly ask the user to run the live test in their terminal to verify success.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
The package version is derived from the git tag via `hatch-vcs`; each release
|
|
9
|
+
below corresponds to a tag of the same name.
|
|
10
|
+
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **adopt:** `colab adopt ENDPOINT` brings a Colab runtime that was started
|
|
16
|
+
outside the CLI (e.g. from the Colab web UI, or a process that exited
|
|
17
|
+
before persisting local state) under local session tracking, so
|
|
18
|
+
`status`/`stop`/`exec`/etc. can manage it going forward. `colab adopt
|
|
19
|
+
--orphanage` adopts every such orphaned assignment in one pass. Idempotent
|
|
20
|
+
— re-adopting an endpoint already tracked locally is a no-op — and never
|
|
21
|
+
overwrites a session created normally via `colab new`.
|
|
22
|
+
- **mcp:** `colab mcp` starts a stdio MCP (Model Context Protocol) server
|
|
23
|
+
exposing the CLI's own commands as tools, scanned directly from the Click
|
|
24
|
+
command registry so the exposed toolset stays in sync automatically as
|
|
25
|
+
commands are added. Interactive commands (`ssh`, `repl`, `console`, `edit`,
|
|
26
|
+
`drivemount`) and internal/hidden commands are excluded. See
|
|
27
|
+
[`docs/07_mcp_server.md`](docs/07_mcp_server.md).
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Renamed the project, PyPI package, and installed executable from
|
|
32
|
+
`google-colab-cli` to **`mighty-colab`**. Install with `pip install
|
|
33
|
+
mighty-colab` or `uv tool install mighty-colab`.
|
|
34
|
+
|
|
35
|
+
### Removed
|
|
36
|
+
|
|
37
|
+
- The experimental `colab-mcp` git submodule, superseded by the hand-rolled
|
|
38
|
+
MCP server above.
|
|
39
|
+
|
|
40
|
+
[Unreleased]: https://github.com/danbarua/mighty-colab/compare/v0.6.0...HEAD
|
|
41
|
+
|
|
42
|
+
## [0.6.0] - 2026-06-16
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **auth:** OAuth2 login now uses a remote copy-paste flow instead of a
|
|
47
|
+
localhost callback server. The CLI prints an authorization URL with
|
|
48
|
+
`redirect_uri=https://sdk.cloud.google.com/applicationdefaultauthcode.html`
|
|
49
|
+
and `token_usage=remote`, then reads the pasted code from stdin. This works
|
|
50
|
+
in headless/remote environments where a browser cannot reach a local
|
|
51
|
+
callback port. (#54)
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **display output:** Rich rendering for `display_data` output via a shared
|
|
56
|
+
`render_display_data()` helper. HTML is converted with `html2text` and
|
|
57
|
+
rendered as Markdown, following a `text/markdown > text/html > text/plain`
|
|
58
|
+
priority; `text/plain` is wrapped with `Text.from_ansi` to preserve embedded
|
|
59
|
+
ANSI escapes. Applied consistently across `exec`, `console`/`repl`, and
|
|
60
|
+
automation call sites. (#58)
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
|
|
64
|
+
- **keep-alive:** Replace the `RuntimeService/KeepAliveAssignment` RPC on
|
|
65
|
+
`colab.pa.googleapis.com` with a Tunnel Frontend (TFE) HTTP ping
|
|
66
|
+
(`GET /tun/m/<endpoint>/keep-alive/` with `X-Colab-Tunnel: Google`) on
|
|
67
|
+
`colab.research.google.com`, authenticated by the user's own bearer token.
|
|
68
|
+
The old RPC required `serviceusage` consumer access to Colab's internal
|
|
69
|
+
project and returned HTTP 403 `USER_PROJECT_DENIED` for every external user,
|
|
70
|
+
causing their sessions to be idle-pruned within minutes. The TFE ping needs
|
|
71
|
+
no project entitlement; because the VM often does not answer on this path, a
|
|
72
|
+
`ReadTimeout` is treated as success while genuine HTTP errors propagate.
|
|
73
|
+
(#14, #61)
|
|
74
|
+
|
|
75
|
+
### Removed
|
|
76
|
+
|
|
77
|
+
- Dead grpc-web client-registry / API-key code path and the now-irrelevant
|
|
78
|
+
`colaboratory`-scope / `pa.googleapis.com` pre-flight remediation messaging,
|
|
79
|
+
superseded by the TFE keep-alive ping. (#61)
|
|
80
|
+
|
|
81
|
+
[0.6.0]: https://github.com/danbarua/mighty-colab/compare/v0.5.11...v0.6.0
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Contributions
|
|
2
|
+
|
|
3
|
+
We don't have the bandwidth to review external pull requests right now, and we don't want PRs to languish, so we aren't accepting external contributions at this time.
|
|
4
|
+
|
|
5
|
+
If you have an idea or hit a pain point, please share it on our [discussions](https://github.com/danbarua/mighty-colab/discussions) page — the preferred place for issues and feature requests.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|