[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B0NMY7NB2ENAS3MN0FJZBP":3,"skill-same:01M7B0NMY7NB2ENAS3MN0FJZBP":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":13,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":40,"install":41,"resources":54},"01M7B0NMY7NB2ENAS3MN0FJZBP","codespace-service-discovery",null,"Use when asked to find out HOW a service inside this Codespace reaches its backend — how an in-house LLM\u002Fcopilot provider is called, where a token\u002Fendpoint lives, or whether an endpoint can be reused\u002Fproxied — by inspecting processes, \u002Fproc env, ports, logs, and bundled code, then probing live.","gitricko\u002F.minions","gitricko","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F18060558?v=4","01M7B0KG9EHG0CZ0QT1EN5YPCR","01M7B0KGA0ZV14R7SKBF3B5SCT",2,"MIT","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fcodespace-service-discovery\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: codespace-service-discovery\ndescription: \"Use when asked to find out HOW a service inside this Codespace reaches its backend — how an in-house LLM\u002Fcopilot provider is called, where a token\u002Fendpoint lives, or whether an endpoint can be reused\u002Fproxied — by inspecting processes, \u002Fproc env, ports, logs, and bundled code, then probing live.\"\nversion: 0.1.0\ntags: [codespace, discovery, llm, copilot, processes, \u002Fproc, endpoints]\nrelated_skills:\n  - codespace-gh-auth\n  - minions-llm-proxy-ops\n---\n\n# Codespace Service Discovery\n\nGoal: given a question like *\"how does X here call its LLM\u002Fprovider backend, and can we reuse or proxy it\"*, produce an **evidence-backed** answer — not a guess. Apply this method whenever you must reverse-engineer *how* a runtime component reaches an external service (LLM, API, token issuance), or locate a credential\u002Fendpoint\u002FURL that isn't in the shell env.\n\nThe single rule that makes or breaks this: **separate what you verified by real output this session from what you inferred.** Report them in two buckets, always. Inference is fine and expected — but label it, and name the one experiment that would turn it into fact.\n\n## The 8-step method\n\nWork top-to-bottom. Each step's output feeds the next. Batch independent steps into one terminal call.\n\n### 1. Frame the question (10 seconds, do it before any cmd)\nWrite out: (a) the target behavior (which feature\u002Fprocess am I hunting), (b) what \"reusable\" concretely means (a portable key? a URL I can curl? a client I can point at?), (c) what success looks like. If (b) is ambiguous it usually has two answers — \"extractable token\" vs \"a live proxy I can attach to\" — and those need different evidence. Name both.\n\n### 2. Find the process family\nIdentify candidate processes and their roles. Never assume — read real output.\n\n```bash\n# Broad: anything LLM\u002Fprovider\u002Fvendor related\nps aux | grep -iE \"copilot|llm|anthropic|claude|codex|openai|extension-host|server-main|runtime\" | grep -v grep\n\n# Enumerate ALL pids and dump cmdline (survives truncated ps)\nfor pid in $(ls \u002Fproc\u002F*\u002Fcmdline 2>\u002Fdev\u002Fnull | cut -d\u002F -f3); do\n  cmd=$(tr '\\0' ' ' \u003C \u002Fproc\u002F$pid\u002Fcmdline 2>\u002Fdev\u002Fnull)\n  echo \"PID=$pid COMM=$(cat \u002Fproc\u002F$pid\u002Fcomm 2>\u002Fdev\u002Fnull) :: $cmd\"\ndone\n\n# Role hints from comm: copilot-runtime \u002F node \u002F MainThread \u002F extensionHost\n```\nBuild the **PID map** first: launcher (`sh ... code-server`), server (`server-main.js`), extension host (`node ...\u002Fextension.js`), agent host (`bootstrap-fork --type=agentHost`), native runtime (`copilot-runtime`). Knowing which PID hosts which job tells you whose env\u002Flogs\u002Fbinary to read.\n\n### 3. Read `\u002Fproc\u002FPID\u002Fenviron` for credentials & URLs\nThe shell does NOT inherit the process's env. This is where live tokens, base URLs, feature flags, provider names, and model names hide.\n\n```bash\nPID=\u003Cpid>\ngrep -iE \"token|key|secret|copilot|anthropic|claude|openai|model|provider|base_url|endpoint|proxy|auth|bearer|license|plan|tier\" \\\n  \u002Fproc\u002F$PID\u002Fenviron 2>\u002Fdev\u002Fnull | tr '\\0' '\\n' | sort\n\n# When grep is too aggressive, dump full env to a file and grep it interactively\ncat \u002Fproc\u002F$PID\u002Fenviron | tr '\\0' '\\n' > \u002Ftmp\u002Fenv_$PID.txt\ngrep -inE \"proxy|auth|key|base_url|header|anthropic|claude|model|api|127\\.0\\.0\\.1|port\" \u002Ftmp\u002Fenv_$PID.txt\n```\nRead the *negative* evidence too: `ANTHROPIC_ADVISOR=false`, no `ANTHROPIC_BASE_URL`, no `OPENAI_API_KEY` → the provider is **not** keyed by a classic API key. That's a real finding, not a gap.\n\n### 4. Map ports to PIDs\n```bash\nss -tlnp        # listening sockets -> owning PID; correlate to the PID map\nss -tnp         # established connections (which remote host each pid talks to)\n```\nA local `LISTEN` that a chat\u002Fagent feature depends on is usually the LLM proxy. Note the exact `127.0.0.1:PORT` — that's the thing to probe in step 7.\n\n### 5. Read the logs (fastest path to the *real* endpoint)\nBundled runtimes and VS Code write rich logs. Log content beats `strings` because it is the *actual* behavior.\n```bash\n# Find log roots\nfind \u002Fproc\u002F\u003Cpid>\u002Ffd -lname '*log*' 2>\u002Fdev\u002Fnull      # which files this pid has open\nfind ~ -maxdepth 4 \\( -name '*.log' -o -path '*\u002Flogs\u002F*' \\) 2>\u002Fdev\u002Fnull | xargs ls -lad | grep -vE '\\.git'\n\n# Pull endpoint\u002Fauth\u002Fmodel signal from them\nLOG=\u003Cpath>; grep -aoiE \"https?:\u002F\u002F[a-z0-9.\u002F_?=-]+|listening on http[^ ]*|\u002Fv[0-9]+\u002F[a-z_]+|model[\\\"':=][a-z0-9._-]*|nonce|token\" \"$LOG\" | sort | uniq -c | sort -rn | head -40\n```\n\"listening on http:\u002F\u002F127.0.0.1:PORT\" is a proxy. A provider\u002Fmodel name in the log tells you which model is active.\n\n### 6. Read the bundled code (definitive for *logic*: auth rules, upstream URL)\nNative binaries: `strings -a \u003Cbin> | grep -iE \"https?:\u002F\u002F|baseURL|endpoint|nonce|\u002Fv1\u002F\"`. Bundled JS (VS Code `out\u002F`, extension `*.js`): minified, so grep with context windows, not plain `grep -w`.\n```bash\nF=\u003Cbundle.js>\ngrep -aoE '.{0,160}\u003Cneedle>.{0,200}' \"$F\" | head        # context window around a word\ngrep -aoE 'https:\u002F\u002F[a-z0-9.-]+\u002F[a-zA-Z0-9\u002F_.-]*\u003Cns>[a-zA-Z0-9\u002F_.-]*' \"$F\" | sort -u   # real URLs\ngrep -aoE '\"\u002Fv[0-9]+\u002F[a-z_]+\"' \"$F\" | sort -u           # routes\n```\n`\u003Cneedle>` examples: the service name from step 5 (e.g. `ClaudeProxyService`, `nonce`, `Invalid authentication`), `Bearer`, `x-api-key`. The line that **validates** the request shows exactly what auth is required. The line that **forwards** it shows the upstream.\n\n> Pitfall: `strings -a` on a large JS bundle can be slow\u002Fempty for the URLs you want — JS constants live as string literals, so use `grep -aoF '\u003Curl-fragment>'` (count) to confirm presence, then the context-window form to extract.\n\n### 7. Probe live, and read what each status *means* (with the right path shape)\nTest the endpoint with whatever token you have. Interpret:\n- `200` + data → works, token valid.\n- `401 Invalid authentication` → the gate is a *different* credential (a nonce, an SSO token, a per-session key) than the one you passed. This is the most common finding and is itself the answer — it proves the endpoint is **gated, not open**.\n- `404` → the path exists in code but is not exposed over this auth surface (needs an internal SSO\u002FOAuth service), or the URL is wrong.\n- `400` + `model_not_supported` \u002F `no_available_model_endpoints` → **the endpoint is fine, the token is fine, the model is not for this tier.** Not a gate — the model list is what to test from.\n- `404 page not found` on the *obvious* path (e.g. `\u002Fv1\u002Fchat\u002Fcompletions`) → **try the path without the `\u002Fv1`** (`\u002Fchat\u002Fcompletions`). Vendor LLM endpoints often drop the OpenAI-style `\u002Fv1` prefix. A 404 on the obvious shape is *usually* a path mismatch, not an auth block. Probe 2–3 variants (`\u002Fv1\u002F…`, `\u002F…`, `\u002Fapi\u002F…`) before concluding \"not the public path.\"\n- `405 Method Not Allowed` → the *verb* is wrong; `GET \u002Fmodels` may need `POST`.\n- Vendor errors that name a feature flag (e.g. *\"To enable this API, set `COPILOT_ALLOW_GET_PROVIDER_ENDPOINT=true`\"*) are **flags, not walls** — set the env var on the spawned child, retry, and the method becomes callable.\n\n```bash\nB=https:\u002F\u002F… # or http:\u002F\u002F127.0.0.1:PORT\n# try path variants, not just one\nfor p in \u002Fv1\u002Fchat\u002Fcompletions \u002Fchat\u002Fcompletions \u002Fchat \u002Fcompletions \u002Fv1\u002Fcompletions; do\n  printf '%s ' \"$p\"\n  curl -s -m 5 -X POST \"$B$p\" -H \"Authorization: Bearer $TOK\" \\\n       -H 'content-type: application\u002Fjson' \\\n       -d '{\"model\":\"gpt-4o-mini\",\"max_tokens\":8,\"stream\":false,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}' \\\n       | head -c 100\n  echo\ndone\n```\nThe **error envelope shape** identifies the protocol: `{\"type\":\"error\",\"error\":{\"type\":\"authentication_error\"...}}` = Anthropic; `{\"message\":\"Not Found\",\"documentation_url\":\"…\"}` = GitHub REST. Knowing the wire protocol half-answers \"can OmniRoute\u002F9Router attach to it.\"\n\n### 8. (The step that ends most dead-ends) Reverse-engineer the SDK's wire protocol\n\nSteps 5–7 can leave you at \"gated local proxy + a client that obviously works (the panel\u002FCLI\u002Fagent)\". When that happens, **the working client is a better oracle than the proxy**: it already holds every credential, path, and header. Most vendor SDKs ship TypeScript `.d.ts` typings next to the minified bundle, and those typings are a map of the RPC surface.\n\n```bash\nSDK=node_modules\u002F@github\u002Fcopilot-sdk-linux-x64\u002Fcopilot-sdk\n# (a) experimental\u002Fhidden RPC methods\ngrep -rnoE \"@experimental|getEndpoint|get[A-Z][A-Za-z]+Request\" \"$SDK\"\u002F*.d.ts \"$SDK\"\u002Fgenerated\u002F*.d.ts | sort -u | head -40\n# (b) the WIRE method names — what the client actually sends over the transport\ngrep -oE 'sendRequest\\(\"[a-zA-Z\u002F_.]+\"' \"$SDK\u002Findex.js\" | sort -u\n# (c) response shapes (baseUrl\u002FapiKey\u002Fheaders\u002FsessionToken fields live here)\ngrep -n \"ProviderEndpoint\\b\" \"$SDK\"\u002Fgenerated\u002F*.d.ts | head\n```\n\nThen drive the SDK from Node. **The session's `.connection` object is the wire** — a JSON-RPC `MessageConnection` — so any wire method from (b) is callable:\n\n```js\nimport { CopilotClient } from '\u002Fabs\u002Fpath\u002Fcopilot-sdk\u002Findex.js';\nconst c = new CopilotClient(); await c.start();                    \u002F\u002F auth from GITHUB_TOKEN env\nconst s = await c.createSession({ name: 'probe' });\nconst ep = await s.connection.sendRequest('session.provider.getEndpoint',\n                                          { sessionId: s.sessionId });\n\u002F\u002F => { baseUrl, apiKey, headers, wireApi }  ← the FULL upstream contract, no packet capture\n```\n\nRules learned the hard way:\n1. **Feature-flag errors are flags, not walls.** \"To enable this API, set `X_ALLOW_Y=true`\" → put the var in the *client process* env (the one spawning the runtime), retry, done.\n2. **`wireApi: completions` does NOT mean `\u002Fv1\u002Fchat\u002Fcompletions`.** In the Copilot case the server 404s every `\u002Fv1\u002F...` path and serves `\u002Fchat\u002Fcompletions` (no `v1`). Always probe 2–3 path shapes after you get `baseUrl`.\n3. **`400 model_not_supported` is a tier constraint, not a gate.** The endpoint, token, and path are all correct — pull the model catalog and test the free-eligible entries (Copilot: `gpt-4o-mini`, `gpt-4o`, `gpt-4.1`, `text-embedding-3-small` work standalone; `gpt-*-luna`, claude models 400).\n4. **Minimality check is the last probe:** once you have one working call, strip headers until it breaks. Copilot needed *zero* extra headers — bare `Bearer \u003Cghu_>` + `\u002Fchat\u002Fcompletions` returns 200. That's the difference between \"needs the SDK\" and \"registerable in 6 lines of proxy config.\"\n5. Introspection shortcuts when typings hide the surface: `Object.getOwnPropertyNames(s)` on the session, `Object.getOwnPropertyNames(c._rpc)`, etc. Symbols and private fields show up there.\n\n## Decision rubric: \"can we reuse \u002F proxy this?\"\n| You find | Reuse verdict |\n|---|---|\n| A real API key\u002Ftoken in env that returns `200` + data | **Reusable** as a portable credential. |\n| A token that authenticates metadata (`\u002Fuser`) but **not** the LLM path | Metadata reusable; LLM path is **gated separately**. |\n| A local proxy that requires a per-session nonce \u002F SSO upstream | The **proxy** is not reusable standalone — but run step 8: the SDK often has a `getEndpoint`-style RPC that returns the real upstream `baseUrl`+`apiKey`. In the Copilot case that upstream was a plain OpenAI-style REST API callable with Bearer auth alone. Solve for the upstream before declaring \"not extractable\". |\n| `404` everywhere with the available token | Two different causes: (a) wrong path shape — probe `\u002Fv1\u002F...` vs `...` vs `\u002Fapi\u002F...` variants; (b) genuinely an internal OAuth\u002FSSO surface — only then is it **not extractable**. |\n\nFree\u002Flimited tier is a real constraint to surface: `access_type_sku: free_limited_copilot`, `copilot_plan: individual` mean bounded models + rate limits even in the happy path.\n\n## Close the loop (turn inference into fact)\nWhen the upstream domain \u002F real token is still \"inferred\", offer the user the one experiment that proves it: `strace -p \u003Cruntime>,\u003Chost> -e trace=network` or `tcpdump -i lo port \u003CPORT>` while a real request fires (e.g. user types one message in the panel). That reveals the true backend + auth flow.\n\n## Pitfalls (learned)\n- **Shell env ≠ process env.** Tokens for these services are almost always in the *server\u002Fruntime* process, not the interactive shell. Check `\u002Fproc\u002FPID\u002Fenviron`.\n- **Truncated output hides the answer.** `ps aux` and `cat \u002Fproc\u002FPID\u002Fenviron` truncate in tool output. Dump to a file, then grep the file.\n- **\"Nonce-gated local proxy\" is usually not the endpoint.** The proxy is an internal hop; the SDK's `getEndpoint`-style RPC (step 8) reveals the real upstream, which in the Copilot case was a plain public REST API taking Bearer auth. Solve for the upstream before declaring \"not extractable\".\n- **`404` and `400` are different news.** `404` = wrong path\u002Fmethod (try the other path shapes first); `400 model_not_supported` = path+token+auth all correct, model just not entitled for this tier. Never report `400 model_not_supported` as \"gated\u002F404\" — it's a model-tier finding.\n- **`wireApi: completions` ≠ OpenAI `\u002Fv1\u002F...`.** Copilot's `api.individual.githubcopilot.com` serves `\u002Fchat\u002Fcompletions` (no `v1`); every `\u002Fv1\u002F...` variant 404s. Probe 2–3 path shapes before concluding.\n- **Vendor feature-flag errors are flags, not walls.** \"set `X_ALLOW_Y=true`\" → set the env var on the client process and retry.\n- **Metadata vs LLM auth are different gates.** A token that reads `\u002Fuser` (plan\u002Faccess) needs separate testing against the completion endpoint — though here the *same* `ghu_` token opened the LLM path.\n- **GitHub App token (`ghu_`) is scope-limited** to Codespace-installed repos and returns \"Bad credentials\" on raw REST (`\u002Fuser`, push works) — but it *is* a valid Copilot LLM credential via the Copilot endpoint. Don't let the REST rejection make you skip the LLM surface. See `codespace-gh-auth`.\n- **Report buckets honestly.** \"Verified this session\" vs \"inferred (strong)\" vs \"the one experiment that would confirm it.\" Never present inference as tested.\n\n## Reference\n- `references\u002Fplaybook-copilot-llm.md` — the worked example (finding the GitHub Copilot LLM path in a 2026-10 Codespace + what each step returned), plus the concrete verdict.\n- `scripts\u002Fprobe-service.sh` — generic env+port+log+endpoint dumper for a given PID set.\n- `scripts\u002Fcopilot-bridge.sh` — drives the standalone Copilot CLI as a scriptable LLM\u002Fagent: `github` backend (free-tier token) or `byok` backend (local OpenAI-compatible provider URL).\n","# Codespace Service Discovery\n\nGoal: given a question like *\"how does X here call its LLM\u002Fprovider backend, and can we reuse or proxy it\"*, produce an **evidence-backed** answer — not a guess. Apply this method whenever you must reverse-engineer *how* a runtime component reaches an external service (LLM, API, token issuance), or locate a credential\u002Fendpoint\u002FURL that isn't in the shell env.\n\nThe single rule that makes or breaks this: **separate what you verified by real output this session from what you inferred.** Report them in two buckets, always. Inference is fine and expected — but label it, and name the one experiment that would turn it into fact.\n\n## The 8-step method\n\nWork top-to-bottom. Each step's output feeds the next. Batch independent steps into one terminal call.\n\n### 1. Frame the question (10 seconds, do it before any cmd)\nWrite out: (a) the target behavior (which feature\u002Fprocess am I hunting), (b) what \"reusable\" concretely means (a portable key? a URL I can curl? a client I can point at?), (c) what success looks like. If (b) is ambiguous it usually has two answers — \"extractable token\" vs \"a live proxy I can attach to\" — and those need different evidence. Name both.\n\n### 2. Find the process family\nIdentify candidate processes and their roles. Never assume — read real output.\n\n```bash\n# Broad: anything LLM\u002Fprovider\u002Fvendor related\nps aux | grep -iE \"copilot|llm|anthropic|claude|codex|openai|extension-host|server-main|runtime\" | grep -v grep\n\n# Enumerate ALL pids and dump cmdline (survives truncated ps)\nfor pid in $(ls \u002Fproc\u002F*\u002Fcmdline 2>\u002Fdev\u002Fnull | cut -d\u002F -f3); do\n  cmd=$(tr '\\0' ' ' \u003C \u002Fproc\u002F$pid\u002Fcmdline 2>\u002Fdev\u002Fnull)\n  echo \"PID=$pid COMM=$(cat \u002Fproc\u002F$pid\u002Fcomm 2>\u002Fdev\u002Fnull) :: $cmd\"\ndone\n\n# Role hints from comm: copilot-runtime \u002F node \u002F MainThread \u002F extensionHost\n```\nBuild the **PID map** first: launcher (`sh ... code-server`), server (`server-main.js`), extension host (`node ...\u002Fextension.js`), agent host (`bootstrap-fork --type=agentHost`), native runtime (`copilot-runtime`). Knowing which PID hosts which job tells you whose env\u002Flogs\u002Fbinary to read.\n\n### 3. Read `\u002Fproc\u002FPID\u002Fenviron` for credentials & URLs\nThe shell does NOT inherit the process's env. This is where live tokens, base URLs, feature flags, provider names, and model names hide.\n\n```bash\nPID=\u003Cpid>\ngrep -iE \"token|key|secret|copilot|anthropic|claude|openai|model|provider|base_url|endpoint|proxy|auth|bearer|license|plan|tier\" \\\n  \u002Fproc\u002F$PID\u002Fenviron 2>\u002Fdev\u002Fnull | tr '\\0' '\\n' | sort\n\n# When grep is too aggressive, dump full env to a file and grep it interactively\ncat \u002Fproc\u002F$PID\u002Fenviron | tr '\\0' '\\n' > \u002Ftmp\u002Fenv_$PID.txt\ngrep -inE \"proxy|auth|key|base_url|header|anthropic|claude|model|api|127\\.0\\.0\\.1|port\" \u002Ftmp\u002Fenv_$PID.txt\n```\nRead the *negative* evidence too: `ANTHROPIC_ADVISOR=false`, no `ANTHROPIC_BASE_URL`, no `OPENAI_API_KEY` → the provider is **not** keyed by a classic API key. That's a real finding, not a gap.\n\n### 4. Map ports to PIDs\n```bash\nss -tlnp        # listening sockets -> owning PID; correlate to the PID map\nss -tnp         # established connections (which remote host each pid talks to)\n```\nA local `LISTEN` that a chat\u002Fagent feature depends on is usually the LLM proxy. Note the exact `127.0.0.1:PORT` — that's the thing to probe in step 7.\n\n### 5. Read the logs (fastest path to the *real* endpoint)\nBundled runtimes and VS Code write rich logs. Log content beats `strings` because it is the *actual* behavior.\n```bash\n# Find log roots\nfind \u002Fproc\u002F\u003Cpid>\u002Ffd -lname '*log*' 2>\u002Fdev\u002Fnull      # which files this pid has open\nfind ~ -maxdepth 4 \\( -name '*.log' -o -path '*\u002Flogs\u002F*' \\) 2>\u002Fdev\u002Fnull | xargs ls -lad | grep -vE '\\.git'\n\n# Pull endpoint\u002Fauth\u002Fmodel signal from them\nLOG=\u003Cpath>; grep -aoiE \"https?:\u002F\u002F[a-z0-9.\u002F_?=-]+|listening on http[^ ]*|\u002Fv[0-9]+\u002F[a-z_]+|model[\\\"':=][a-z0-9._-]*|nonce|token\" \"$LOG\" | sort | uniq -c | sort -rn | head -40\n```\n\"listening on http:\u002F\u002F127.0.0.1:PORT\" is a proxy. A provider\u002Fmodel name in the log tells you which model is active.\n\n### 6. Read the bundled code (definitive for *logic*: auth rules, upstream URL)\nNative binaries: `strings -a \u003Cbin> | grep -iE \"https?:\u002F\u002F|baseURL|endpoint|nonce|\u002Fv1\u002F\"`. Bundled JS (VS Code `out\u002F`, extension `*.js`): minified, so grep with context windows, not plain `grep -w`.\n```bash\nF=\u003Cbundle.js>\ngrep -aoE '.{0,160}\u003Cneedle>.{0,200}' \"$F\" | head        # context window around a word\ngrep -aoE 'https:\u002F\u002F[a-z0-9.-]+\u002F[a-zA-Z0-9\u002F_.-]*\u003Cns>[a-zA-Z0-9\u002F_.-]*' \"$F\" | sort -u   # real URLs\ngrep -aoE '\"\u002Fv[0-9]+\u002F[a-z_]+\"' \"$F\" | sort -u           # routes\n```\n`\u003Cneedle>` examples: the service name from step 5 (e.g. `ClaudeProxyService`, `nonce`, `Invalid authentication`), `Bearer`, `x-api-key`. The line that **validates** the request shows exactly what auth is required. The line that **forwards** it shows the upstream.\n\n> Pitfall: `strings -a` on a large JS bundle can be slow\u002Fempty for the URLs you want — JS constants live as string literals, so use `grep -aoF '\u003Curl-fragment>'` (count) to confirm presence, then the context-window form to extract.\n\n### 7. Probe live, and read what each status *means* (with the right path shape)\nTest the endpoint with whatever token you have. Interpret:\n- `200` + data → works, token valid.\n- `401 Invalid authentication` → the gate is a *different* credential (a nonce, an SSO token, a per-session key) than the one you passed. This is the most common finding and is itself the answer — it proves the endpoint is **gated, not open**.\n- `404` → the path exists in code but is not exposed over this auth surface (needs an internal SSO\u002FOAuth service), or the URL is wrong.\n- `400` + `model_not_supported` \u002F `no_available_model_endpoints` → **the endpoint is fine, the token is fine, the model is not for this tier.** Not a gate — the model list is what to test from.\n- `404 page not found` on the *obvious* path (e.g. `\u002Fv1\u002Fchat\u002Fcompletions`) → **try the path without the `\u002Fv1`** (`\u002Fchat\u002Fcompletions`). Vendor LLM endpoints often drop the OpenAI-style `\u002Fv1` prefix. A 404 on the obvious shape is *usually* a path mismatch, not an auth block. Probe 2–3 variants (`\u002Fv1\u002F…`, `\u002F…`, `\u002Fapi\u002F…`) before concluding \"not the public path.\"\n- `405 Method Not Allowed` → the *verb* is wrong; `GET \u002Fmodels` may need `POST`.\n- Vendor errors that name a feature flag (e.g. *\"To enable this API, set `COPILOT_ALLOW_GET_PROVIDER_ENDPOINT=true`\"*) are **flags, not walls** — set the env var on the spawned child, retry, and the method becomes callable.\n\n```bash\nB=https:\u002F\u002F… # or http:\u002F\u002F127.0.0.1:PORT\n# try path variants, not just one\nfor p in \u002Fv1\u002Fchat\u002Fcompletions \u002Fchat\u002Fcompletions \u002Fchat \u002Fcompletions \u002Fv1\u002Fcompletions; do\n  printf '%s ' \"$p\"\n  curl -s -m 5 -X POST \"$B$p\" -H \"Authorization: Bearer $TOK\" \\\n       -H 'content-type: application\u002Fjson' \\\n       -d '{\"model\":\"gpt-4o-mini\",\"max_tokens\":8,\"stream\":false,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}' \\\n       | head -c 100\n  echo\ndone\n```\nThe **error envelope shape** identifies the protocol: `{\"type\":\"error\",\"error\":{\"type\":\"authentication_error\"...}}` = Anthropic; `{\"message\":\"Not Found\",\"documentation_url\":\"…\"}` = GitHub REST. Knowing the wire protocol half-answers \"can OmniRoute\u002F9Router attach to it.\"\n\n### 8. (The step that ends most dead-ends) Reverse-engineer the SDK's wire protocol\n\nSteps 5–7 can leave you at \"gated local proxy + a client that obviously works (the panel\u002FCLI\u002Fagent)\". When that happens, **the working client is a better oracle than the proxy**: it already holds every credential, path, and header. Most vendor SDKs ship TypeScript `.d.ts` typings next to the minified bundle, and those typings are a map of the RPC surface.\n\n```bash\nSDK=node_modules\u002F@github\u002Fcopilot-sdk-linux-x64\u002Fcopilot-sdk\n# (a) experimental\u002Fhidden RPC methods\ngrep -rnoE \"@experimental|getEndpoint|get[A-Z][A-Za-z]+Request\" \"$SDK\"\u002F*.d.ts \"$SDK\"\u002Fgenerated\u002F*.d.ts | sort -u | head -40\n# (b) the WIRE method names — what the client actually sends over the transport\ngrep -oE 'sendRequest\\(\"[a-zA-Z\u002F_.]+\"' \"$SDK\u002Findex.js\" | sort -u\n# (c) response shapes (baseUrl\u002FapiKey\u002Fheaders\u002FsessionToken fields live here)\ngrep -n \"ProviderEndpoint\\b\" \"$SDK\"\u002Fgenerated\u002F*.d.ts | head\n```\n\nThen drive the SDK from Node. **The session's `.connection` object is the wire** — a JSON-RPC `MessageConnection` — so any wire method from (b) is callable:\n\n```js\nimport { CopilotClient } from '\u002Fabs\u002Fpath\u002Fcopilot-sdk\u002Findex.js';\nconst c = new CopilotClient(); await c.start();                    \u002F\u002F auth from GITHUB_TOKEN env\nconst s = await c.createSession({ name: 'probe' });\nconst ep = await s.connection.sendRequest('session.provider.getEndpoint',\n                                          { sessionId: s.sessionId });\n\u002F\u002F => { baseUrl, apiKey, headers, wireApi }  ← the FULL upstream contract, no packet capture\n```\n\nRules learned the hard way:\n1. **Feature-flag errors are flags, not walls.** \"To enable this API, set `X_ALLOW_Y=true`\" → put the var in the *client process* env (the one spawning the runtime), retry, done.\n2. **`wireApi: completions` does NOT mean `\u002Fv1\u002Fchat\u002Fcompletions`.** In the Copilot case the server 404s every `\u002Fv1\u002F...` path and serves `\u002Fchat\u002Fcompletions` (no `v1`). Always probe 2–3 path shapes after you get `baseUrl`.\n3. **`400 model_not_supported` is a tier constraint, not a gate.** The endpoint, token, and path are all correct — pull the model catalog and test the free-eligible entries (Copilot: `gpt-4o-mini`, `gpt-4o`, `gpt-4.1`, `text-embedding-3-small` work standalone; `gpt-*-luna`, claude models 400).\n4. **Minimality check is the last probe:** once you have one working call, strip headers until it breaks. Copilot needed *zero* extra headers — bare `Bearer \u003Cghu_>` + `\u002Fchat\u002Fcompletions` returns 200. That's the difference between \"needs the SDK\" and \"registerable in 6 lines of proxy config.\"\n5. Introspection shortcuts when typings hide the surface: `Object.getOwnPropertyNames(s)` on the session, `Object.getOwnPropertyNames(c._rpc)`, etc. Symbols and private fields show up there.\n\n## Decision rubric: \"can we reuse \u002F proxy this?\"\n| You find | Reuse verdict |\n|---|---|\n| A real API key\u002Ftoken in env that returns `200` + data | **Reusable** as a portable credential. |\n| A token that authenticates metadata (`\u002Fuser`) but **not** the LLM path | Metadata reusable; LLM path is **gated separately**. |\n| A local proxy that requires a per-session nonce \u002F SSO upstream | The **proxy** is not reusable standalone — but run step 8: the SDK often has a `getEndpoint`-style RPC that returns the real upstream `baseUrl`+`apiKey`. In the Copilot case that upstream was a plain OpenAI-style REST API callable with Bearer auth alone. Solve for the upstream before declaring \"not extractable\". |\n| `404` everywhere with the available token | Two different causes: (a) wrong path shape — probe `\u002Fv1\u002F...` vs `...` vs `\u002Fapi\u002F...` variants; (b) genuinely an internal OAuth\u002FSSO surface — only then is it **not extractable**. |\n\nFree\u002Flimited tier is a real constraint to surface: `access_type_sku: free_limited_copilot`, `copilot_plan: individual` mean bounded models + rate limits even in the happy path.\n\n## Close the loop (turn inference into fact)\nWhen the upstream domain \u002F real token is still \"inferred\", offer the user the one experiment that proves it: `strace -p \u003Cruntime>,\u003Chost> -e trace=network` or `tcpdump -i lo port \u003CPORT>` while a real request fires (e.g. user types one message in the panel). That reveals the true backend + auth flow.\n\n## Pitfalls (learned)\n- **Shell env ≠ process env.** Tokens for these services are almost always in the *server\u002Fruntime* process, not the interactive shell. Check `\u002Fproc\u002FPID\u002Fenviron`.\n- **Truncated output hides the answer.** `ps aux` and `cat \u002Fproc\u002FPID\u002Fenviron` truncate in tool output. Dump to a file, then grep the file.\n- **\"Nonce-gated local proxy\" is usually not the endpoint.** The proxy is an internal hop; the SDK's `getEndpoint`-style RPC (step 8) reveals the real upstream, which in the Copilot case was a plain public REST API taking Bearer auth. Solve for the upstream before declaring \"not extractable\".\n- **`404` and `400` are different news.** `404` = wrong path\u002Fmethod (try the other path shapes first); `400 model_not_supported` = path+token+auth all correct, model just not entitled for this tier. Never report `400 model_not_supported` as \"gated\u002F404\" — it's a model-tier finding.\n- **`wireApi: completions` ≠ OpenAI `\u002Fv1\u002F...`.** Copilot's `api.individual.githubcopilot.com` serves `\u002Fchat\u002Fcompletions` (no `v1`); every `\u002Fv1\u002F...` variant 404s. Probe 2–3 path shapes before concluding.\n- **Vendor feature-flag errors are flags, not walls.** \"set `X_ALLOW_Y=true`\" → set the env var on the client process and retry.\n- **Metadata vs LLM auth are different gates.** A token that reads `\u002Fuser` (plan\u002Faccess) needs separate testing against the completion endpoint — though here the *same* `ghu_` token opened the LLM path.\n- **GitHub App token (`ghu_`) is scope-limited** to Codespace-installed repos and returns \"Bad credentials\" on raw REST (`\u002Fuser`, push works) — but it *is* a valid Copilot LLM credential via the Copilot endpoint. Don't let the REST rejection make you skip the LLM surface. See `codespace-gh-auth`.\n- **Report buckets honestly.** \"Verified this session\" vs \"inferred (strong)\" vs \"the one experiment that would confirm it.\" Never present inference as tested.\n\n## Reference\n- `references\u002Fplaybook-copilot-llm.md` — the worked example (finding the GitHub Copilot LLM path in a 2026-10 Codespace + what each step returned), plus the concrete verdict.\n- `scripts\u002Fprobe-service.sh` — generic env+port+log+endpoint dumper for a given PID set.\n- `scripts\u002Fcopilot-bridge.sh` — drives the standalone Copilot CLI as a scriptable LLM\u002Fagent: `github` backend (free-tier token) or `byok` backend (local OpenAI-compatible provider URL).\n",{"name":5,"tags":23,"version":31,"description":7,"related_skills":32},[24,25,26,27,28,29,30],"codespace","discovery","llm","copilot","processes","\u002Fproc","endpoints","0.1.0",[33,34],"codespace-gh-auth","minions-llm-proxy-ops","main","e95aec76487a22bbbc23b63234724bc7178d4692","skills\u002Fcodespace-service-discovery","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions","https:\u002F\u002Fgithub.com\u002Fgitricko","2026-11-13 16:00:00",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add gitricko\u002F.minions --skill codespace-service-discovery",{"tool":47,"command":48},"bunx","bunx skills add gitricko\u002F.minions --skill codespace-service-discovery",{"tool":50,"command":51},"pnpm","pnpm dlx skills add gitricko\u002F.minions --skill codespace-service-discovery","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fcodespace-service-discovery\u002FSKILL.md",true,[55,61,65,71],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"references\u002Fplaybook-copilot-llm-live-capture.md","REFERENCE","参考文档",6736,"https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fcodespace-service-discovery\u002Freferences\u002Fplaybook-copilot-llm-live-capture.md",{"path":62,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fplaybook-copilot-llm.md",6130,"https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fcodespace-service-discovery\u002Freferences\u002Fplaybook-copilot-llm.md",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"scripts\u002Fcopilot-bridge.sh","SCRIPT","脚本",4643,"https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fcodespace-service-discovery\u002Fscripts\u002Fcopilot-bridge.sh",{"path":72,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":73,"sourceHtmlUrl":74},"scripts\u002Fprobe-service.sh",3190,"https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fcodespace-service-discovery\u002Fscripts\u002Fprobe-service.sh",[76,83,90,97,104,111],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M7B0VJ3Q0YMCTJY69FEJ4100","version-single-source","Use when adding a new component dependency or versioning a binary in install\u002Fboot scripts.","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fversion-single-source\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M7B0V888DV8J3JY5W9Z6WCF3","tdd","Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions \"red-green-refactor\", or wants integration tests.","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Ftdd\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":18},"01M7B0TVFM38JH3PBA2K219Z2X","shell-path-login","Use when a binary or script works in one shell context but not another (interactive vs non-interactive login vs non-login shell).","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fshell-path-login\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":18},"01M7B0TKFCTVQBTSNF9WF1MXJ6","self-update-fix","Fix a failing dependency update PR. Use when a self-update PR's CI fails, or when invoked by scripts\u002Fself-update-fix.sh.","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fself-update-fix\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":18},"01M7B0TB57WEW0E6E9874K3C72","pr-change-log","Use when a multi-commit PR needs its description written\u002Fupdated, or when closing out a long branch with many fix commits.","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fpr-change-log\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":18},"01M7B0T2FGSV0ZFRZ46PG4BBY2","persistent-knowledge","Persistent skills\u002Fknowledge in Codespace via symlinks.","https:\u002F\u002Fgithub.com\u002Fgitricko\u002F.minions\u002Fblob\u002Fmain\u002Fskills\u002Fpersistent-knowledge\u002FSKILL.md",[],[]]