Skip to content

teng-lin/notebooklm-py

notebooklm

Verified

Install, authenticate, troubleshoot, and operate Gemini Notebook through the notebooklm-py CLI or typed async Python API. Use for notebook and source management, grounded chat and research, and artifact generation or download when the user mentions Gemini Notebook, notebooklm-py, the notebooklm CLI, or its Python API. Do not use for the generic Gemini API or unrelated content creation.

FileKindSize
SKILL.mdskill md16.0 KB
examples/bulk-import.pyscript3.4 KB
examples/chat.pyscript6.9 KB
examples/notes.pyscript9.8 KB
examples/quickstart.pyscript2.3 KB
examples/refresh_browser_cookies.pyscript2.9 KB
examples/research-to-podcast.pyscript3.2 KB
examples/video.pyscript5.9 KB
scripts/__init__.pyscript73 B
scripts/_ci_e2e_notebooks.pyscript19.0 KB
scripts/_ci_progress.pyscript2.5 KB
scripts/_ci_rpc_progress.pyscript7.5 KB
scripts/_live_auth_scenarios/__init__.pyscript2.6 KB
scripts/_live_auth_scenarios/_contract.pyscript1.9 KB
scripts/_live_auth_scenarios/browser_refresh.pyscript3.1 KB
scripts/_live_auth_scenarios/crash_safe_writer.pyscript1.9 KB
scripts/_live_auth_scenarios/master_token_recovery.pyscript3.3 KB
scripts/_live_auth_scenarios/mcp_recovery.pyscript3.0 KB
scripts/_live_auth_scenarios/rest_recovery.pyscript5.9 KB
scripts/_live_auth_scenarios/sibling_concurrent_reload.pyscript3.9 KB
scripts/_live_auth_scenarios/storage_reload.pyscript2.9 KB
scripts/_onetime_rescrub_cookies.pyscript6.6 KB
scripts/_onetime_retarget_cassette_hosts.pyscript8.5 KB
scripts/_strip_audit_refs.pyscript15.9 KB
scripts/_tracked_files.pyscript872 B
scripts/aggregate_ci_e2e_outcomes.pyscript10.8 KB
scripts/android_grpc_canary.pyscript26.6 KB
scripts/api-compat-allowlist.jsonconfig163 B
scripts/audit_auth_import_graph.pyscript7.5 KB
scripts/audit_auth_patch_sites.pyscript83.6 KB
scripts/audit_auth_shared_mutations.pyscript41.7 KB
scripts/audit_backend_coupling.pyscript32.8 KB
scripts/audit_public_api_compat.pyscript47.4 KB
scripts/audit_test_suite.pyscript10.7 KB
scripts/capture_mobile_grpc.jsscript5.1 KB
scripts/capture_rpc_registry.pyscript44.5 KB
scripts/check_action_pinning.pyscript6.7 KB
scripts/check_auth_behavior_scenario_policy.pyscript37.1 KB
scripts/check_auth_coverage_delta.pyscript23.2 KB
scripts/check_auth_lifecycle_cleanup_policy.pyscript11.7 KB
scripts/check_base_wheel.pyscript6.3 KB
scripts/check_ci_install_parity.pyscript8.8 KB
scripts/check_claude_md_freshness.pyscript8.0 KB
scripts/check_coverage_thresholds.pyscript8.4 KB
scripts/check_deprecation_targets.pyscript33.1 KB
scripts/check_docs_module_refs.pyscript14.4 KB
scripts/check_rpc_health.pyscript112.0 KB
scripts/check_workflow_permissions.pyscript5.3 KB
scripts/check_workflow_secret_gates.pyscript40.4 KB
scripts/decode_mobile_grpc.pyscript7.2 KB
scripts/diagnose_get_notebook.pyscript9.1 KB
scripts/extract_blutter_grpc_signatures.pyscript7.6 KB
scripts/live_auth_matrix.pyscript40.2 KB
scripts/manage_ci_e2e_notebooks.pyscript67.4 KB
scripts/materialize_ci_auth.pyscript8.0 KB
scripts/mcp_live_smoke.pyexecutablescript224 B
scripts/parse_pbenums.pyscript8.6 KB
scripts/parse_pbschema.pyscript11.8 KB
scripts/regen_baselines.pyscript2.7 KB
scripts/regenerate_android_protos.pyscript16.3 KB
scripts/rescrub-cassettes.pyscript13.3 KB
scripts/scrub_rpc_har.pyscript9.4 KB
scripts/select_ci_account.pyscript4.8 KB
scripts/stress_fault_server.pyscript20.6 KB
scripts/test_taxonomy_inventory.pyscript16.1 KB
scripts/verify_ci_artifacts.pyscript35.3 KB

scripts/extract_blutter_grpc_signatures.py

View on GitHub
#!/usr/bin/env python3
"""Extract exact unary gRPC signatures from a blutter dump.

``pp.txt`` preserves generated-client constants as adjacent entries: a
``TypeArguments: <Request, Response>`` entry followed eight bytes later by the full
``/service/method`` path.  ``ida_script/addNames.py`` supplies the protobuf-bearing Dart library
for each generated message's ``BuilderInfo._i`` symbol.  This script joins those two independent
pieces of binary evidence and writes deterministic CSV to stdout.

No package is inferred from a short type name alone.  A type must resolve uniquely either in the
service's protobuf namespace or across all recovered generated-message symbols; otherwise the
extraction fails.
"""

import argparse
import csv
import dataclasses
import re
import sys
from collections import defaultdict

TYPE_ARGUMENTS_RE = re.compile(
    r"^\[pp\+0x(?P<offset>[0-9A-Fa-f]+)\] TypeArguments: "
    r"<(?P<request>[A-Za-z_$][A-Za-z0-9_$]*), "
    r"(?P<response>[A-Za-z_$][A-Za-z0-9_$]*)>$"
)
METHOD_PATH_RE = re.compile(
    r'^\[pp\+0x(?P<offset>[0-9A-Fa-f]+)\] String: "'
    r'(?P<path>/[A-Za-z_][A-Za-z0-9_.]*/[A-Za-z_][A-Za-z0-9_]*)"$'
)
IDA_MESSAGE_RE = re.compile(
    r'idaapi\.set_name\(0x[0-9A-Fa-f]+, "'
    r'(?P<namespace>[^"$]+)\$(?P<library>[^"$]+?\.pb)_'
    r'(?P<type>[A-Za-z_$][A-Za-z0-9_$]*)::_i_[0-9A-Fa-f]+"\)'
)
CSV_FIELDS = ("path", "service", "method", "request_fqn", "response_fqn", "pp_offset")


class ExtractionError(ValueError):
    """Raised when binary evidence cannot support one deterministic exact signature."""


@dataclasses.dataclass(frozen=True, order=True)
class MessageSymbol:
    """A generated-message BuilderInfo symbol recovered by blutter."""

    namespace: str
    library: str
    dart_type: str

    @property
    def fqn(self) -> str:
        return f".{self.namespace}.{self.dart_type}"


@dataclasses.dataclass(frozen=True, order=True)
class RawMethod:
    """A method path adjacent to its generated-client type arguments in ``pp.txt``."""

    path: str
    request_type: str
    response_type: str
    pp_offset: int

    @property
    def service(self) -> str:
        return self.path[1:].rsplit("/", 1)[0]

    @property
    def method(self) -> str:
        return self.path.rsplit("/", 1)[1]


@dataclasses.dataclass(frozen=True, order=True)
class GrpcSignature:
    """One gRPC method whose request and response FQNs are fully resolved."""

    path: str
    service: str
    method: str
    request_fqn: str
    response_fqn: str
    pp_offset: int


def parse_pp_methods(path) -> list[RawMethod]:
    """Parse exactly adjacent type-argument/path pairs and reject conflicting duplicates."""
    with open(path, errors="replace") as stream:
        lines = stream.read().splitlines()

    by_path: dict[str, RawMethod] = {}
    for type_line, path_line in zip(lines, lines[1:], strict=False):
        type_match = TYPE_ARGUMENTS_RE.match(type_line)
        path_match = METHOD_PATH_RE.match(path_line)
        if not type_match or not path_match:
            continue
        type_offset = int(type_match.group("offset"), 16)
        path_offset = int(path_match.group("offset"), 16)
        if path_offset != type_offset + 8:
            continue
        method = RawMethod(
            path=path_match.group("path"),
            request_type=type_match.group("request"),
            response_type=type_match.group("response"),
            pp_offset=type_offset,
        )
        previous = by_path.get(method.path)
        if previous and (
            previous.request_type != method.request_type
            or previous.response_type != method.response_type
        ):
            raise ExtractionError(
                f"conflicting type arguments for {method.path}: "
                f"<{previous.request_type}, {previous.response_type}> and "
                f"<{method.request_type}, {method.response_type}>"
            )
        if previous is None or method.pp_offset < previous.pp_offset:
            by_path[method.path] = method
    return sorted(by_path.values(), key=lambda item: item.path)


def parse_message_symbols(path) -> dict[str, tuple[MessageSymbol, ...]]:
    """Index generated-message ``_i`` symbols from blutter's IDA naming script."""
    symbols: defaultdict[str, set[MessageSymbol]] = defaultdict(set)
    with open(path, errors="replace") as stream:
        for line in stream:
            match = IDA_MESSAGE_RE.search(line)
            if not match:
                continue
            symbol = MessageSymbol(
                namespace=match.group("namespace"),
                library=match.group("library"),
                dart_type=match.group("type"),
            )
            symbols[symbol.dart_type].add(symbol)
    return {name: tuple(sorted(entries)) for name, entries in symbols.items()}


def resolve_type(
    short_name: str,
    service: str,
    symbols: dict[str, tuple[MessageSymbol, ...]],
) -> str:
    """Resolve a Dart type to one protobuf FQN, preferring the service namespace."""
    candidates = symbols.get(short_name, ())
    if not candidates:
        raise ExtractionError(f"unresolved generated-message type {short_name!r} for {service}")

    service_namespace = service.rsplit(".", 1)[0]
    local_fqns = {
        candidate.fqn for candidate in candidates if candidate.namespace == service_namespace
    }
    if len(local_fqns) == 1:
        return local_fqns.pop()
    if len(local_fqns) > 1:
        raise ExtractionError(
            f"ambiguous service-local type {short_name!r} for {service}: "
            f"{', '.join(sorted(local_fqns))}"
        )

    fqns = {candidate.fqn for candidate in candidates}
    if len(fqns) == 1:
        return fqns.pop()
    raise ExtractionError(
        f"ambiguous generated-message type {short_name!r} for {service}: {', '.join(sorted(fqns))}"
    )


def extract_signatures(pp_path, add_names_path) -> list[GrpcSignature]:
    """Join pp-table method evidence to exact generated-message FQNs."""
    methods = parse_pp_methods(pp_path)
    symbols = parse_message_symbols(add_names_path)
    signatures = []
    for method in methods:
        signatures.append(
            GrpcSignature(
                path=method.path,
                service=method.service,
                method=method.method,
                request_fqn=resolve_type(method.request_type, method.service, symbols),
                response_fqn=resolve_type(method.response_type, method.service, symbols),
                pp_offset=method.pp_offset,
            )
        )
    return signatures


def write_csv(signatures: list[GrpcSignature], stream) -> None:
    """Write stable, path-sorted CSV without mutating the input evidence."""
    writer = csv.DictWriter(stream, fieldnames=CSV_FIELDS, lineterminator="\n")
    writer.writeheader()
    for signature in sorted(signatures, key=lambda item: item.path):
        writer.writerow(
            {
                "path": signature.path,
                "service": signature.service,
                "method": signature.method,
                "request_fqn": signature.request_fqn,
                "response_fqn": signature.response_fqn,
                "pp_offset": f"0x{signature.pp_offset:x}",
            }
        )


def main(argv=None) -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("pp", help="path to the blutter dump's pp.txt")
    parser.add_argument("add_names", help="path to ida_script/addNames.py from the same dump")
    args = parser.parse_args(argv)
    try:
        signatures = extract_signatures(args.pp, args.add_names)
    except ExtractionError as exc:
        parser.error(str(exc))
    write_csv(signatures, sys.stdout)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall