[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-112751":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":15,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":9,"pushedAt":9,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":14,"starSnapshotCount":14,"syncStatus":15,"lastSyncTime":26,"discoverSource":27},112751,"Shape","BottingRocks\u002FShape","BottingRocks","Shape CLI and SDKs for decoding and encoding request headers",null,"Rust",66,11,51,0,2,7,44.94,"GNU General Public License v3.0",false,"main",true,[],"2026-11-24 04:01:32","\u003Ch1 align=\"center\">Shape\u003C\u002Fh1>\n\nShape decodes captured request headers into named signal fields. You can\ninspect those fields, change supported values, and encode the full decoded\npayload back into headers while retaining its other signals and report channels.\n\nFor a new capture, trace its VM seed into readable JavaScript and use that\nprogram with the matching session to compile a decode artifact. Save the\nartifact to decode later requests from that build and session without repeating\nthe source analysis. You can also deobfuscate the kernel and name recovered\nfunctions to investigate how signals are collected.\n\nUse the CLI for one-off work with files, or load an artifact once in the SDK\nfor repeated calls from your application. Both use the same engine:\n\n| | Use it to | Start here |\n| --- | --- | --- |\n| **[Shape CLI](#shape-cli)** | Investigate a capture from the terminal: deobfuscate, trace, name functions, extract signal layouts, decode and encode | `cargo build --release --locked --bin shape` |\n| **[SDK](#sdk)** | Do the same from your application in Node.js\u002FTypeScript, Python, Go, Rust or C | `scripts\u002Fbuild-sdk.sh` |\n\nBefore running any `shape` command, follow the [CLI build and PATH setup](#build-once)\nfrom the repository root.\n\nThe table below shows where each operation is available. A decode artifact\nsaved by the CLI loads in every SDK, so you can prepare a capture in the\nterminal and reuse the result in your application.\n\n| Task | CLI | SDK command |\n| --- | --- | --- |\n| Deobfuscate a kernel | `shape deob` | `deob` |\n| Compile a kernel artifact | `shape report` | `report` |\n| Inspect VM properties and operations | `shape kernel show`, `shape ops list`, `shape ops show` | `kernel.show`, `ops.list`, `ops.show` |\n| Recover the linked program | `shape trace program` | `trace.program` |\n| Walk or clean one thread | `shape trace thread`, `shape trace cleanup-thread` | `trace.thread`, `cleanup.thread` |\n| Name functions and collectors | `shape naming threads`, `collectors`, `plan`, `inventory` | `naming.*` |\n| Compare captures | `shape trace corpus`, `shape naming corpus` | |\n| Extract the signal schema | `shape signals` | `signals.schema` |\n| Pin a session layout | `shape pin` | `pin` |\n| Compile a decode artifact | `shape decode --save-artifact` | `artifact.compile` |\n| Decode headers into named fields | `shape decode --artifact` | Generator `decode`, `explain` |\n| Encode edited fields back into headers | — (use the SDK; the CLI encodes framed payloads, not named fields) | Generator `encode` |\n| Look up what a signal means | `shape show signals` | |\n| Report and payload framing | `shape payload`, `shape headers`, `shape pack`, `shape unpack` | |\n\n**Contents:** [Scope and limitations](#scope-and-limitations) ·\n[Choose a path](#choose-a-path) · [How it fits together](#how-it-fits-together) ·\n[Inputs](#inputs) · [Shape CLI](#shape-cli) · [SDK](#sdk) ·\n[Decoded signals and editing](sdk\u002Fsignals.md) ·\n[SDK performance](#performance-in-the-sdk) · [Troubleshooting](#troubleshooting) ·\n[Documentation](#documentation)\n\n## Scope and limitations\n\nShape analyses captured Shape-style VM kernels and the request headers they\nproduce. Behavior that depends on runtime values may stop a trace.\n\nCheck the trace's `complete` or `stopped` status before using its output. The\nsignal schema lists `unidentified`, `ambiguous` and `refused` slots under\n`diagnostics`, so you can see where analysis could not establish a result.\nDecoding a field does not guarantee that every edit can be encoded: the\ncompiled wire recipes must support the requested value.\n\nCoordinates, handler keys, salts and layouts belong to a particular build.\nKeep the decode artifact with its matching site, build and session; re-run\nanalysis for a different build. Unsupported edits are refused, including edits\nwhose encoding context cannot be reconstructed.\n\nUse `shape seeds fetch` to download launchers and kernels; capturing browser\ntraffic is a separate step. Tracing large captures can be expensive, so use\nrelease builds, step limits and kernel-artifact caches for repeat work.\n\n## Choose a path\n\n| If you want to… | Start with |\n| --- | --- |\n| Understand the project from one capture | [Deobfuscate and inspect a kernel](#deobfuscate-and-inspect-a-kernel) |\n| Recover readable code from a seed | [Trace the program](#trace-a-whole-program) |\n| Decode captured request headers | [Decode headers into named fields](#decode-headers-into-named-fields) |\n| Build a decode artifact from your own capture | [Your own capture](#recover-code-and-save-a-decode-artifact) |\n| Integrate decoding into an application | [SDK](#sdk), then your [language guide](#documentation) |\n| Edit signal values and re-encode headers | [Decoded signals and editing](sdk\u002Fsignals.md) |\n| Investigate a stopped or slow trace | [Tracing](docs\u002Ftracing\u002Ftrace-cli.md) and [Troubleshooting](#troubleshooting) |\n| Work on the engine or the CLI | [Architecture](docs\u002Farchitecture.md) and [cli\u002FREADME.md](cli\u002FREADME.md) |\n\n## How it fits together\n\nShape parses captured JavaScript and WebAssembly, then traces a Rust intermediate representation to recover readable code.\n\nStart with the raw VM seed, the initializer that started the session, and the\nrequest headers from the same capture. The seed supplies the program, the\ninitializer supplies session settings, and the headers carry the values to\ndecode:\n\n```text\nseed.raw.js ── deob ────────────────► readable kernel JavaScript\n            └─ trace program ───────► traced program (linked JavaScript)\ninit.js ───── session.from_initializer ─► session (token, alphabet, keys)\n                                          │\ntraced program + session + site ID ─ artifact.compile ─► decode artifact\n                                                          │\nheaders.json ──────────────────────────── decode ◄─────────┘\n                                           │\n                              named fields in positionalSignals\n                                           │\n                              explain one signal, edit fields\n                                           │\nheaders.json ◄─────────────────────────── encode\n```\n\nStages are independent. You can read a kernel, trace one thread, or extract a\nsignal schema without ever decoding headers, and you can decode headers\nrepeatedly from one saved artifact without tracing again.\n\n| Document | Produced by | Contains | Reused by |\n| --- | --- | --- | --- |\n| Kernel artifact | `report`, `deob --report` | Source-free kernel facts (entry, tables, bytecode, module bytes) | `trace thread --report` |\n| Traced program | `trace program` | Linked JavaScript for every reachable thread | `signals`, `naming`, `pin`, `artifact.compile` |\n| Session | `session.from_initializer`, `pin` | Transaction token, alphabet, shuffle key, cipher keys, optional nonce | `pin`, `artifact.compile`, every decode |\n| Decode artifact | `artifact.compile`, `decode --save-artifact` | Layout, cipher settings, session defaults, compiled signal recipes | Every SDK generator, `shape decode --artifact` |\n| Compact schema | `artifact.compact_schema`, generator `schema` | Public descriptive view of a decode artifact | Inspection only; it cannot decode |\n\nSave the decode artifact when you want to use the analysis in another process\nor language. The CLI and all five SDKs load the same bytes without needing the\nsource files.\n\nEach document is versioned (`shape-kernel-artifact\u002Fv1`,\n`shape-decode-artifact\u002F1`, `shape-seed-schema\u002F1`). A document from a different\nversion is rejected rather than guessed at.\n\n## Inputs\n\nThe workflow below uses four files from one build and session. Save the\nlauncher and kernel, capture the browser's headers, and parse the session from\nthe launcher.\n\n| Input | File | Comes from |\n| --- | --- | --- |\n| Launcher | `seeds\u002F\u003Ctoken>.async.js` | Browser Network panel, or `shape seeds fetch` |\n| Kernel | `seeds\u002F\u003Ctoken>.raw.js` | The kernel URL in that launcher; `fetch` stores it |\n| Headers | `headers.json` | The captured request headers, reduced to suffix keys |\n| Session | `session.json` | The launcher's `detail.init(...)` call |\n\n### Launcher and kernel\n\n`\u003Ctoken>` is the capture token in the launcher's kernel URL. A fetch writes\nexactly two sibling files:\n\n```text\nseeds\u002F\n  \u003Ctoken>.async.js   launcher: kernel URL, detail.init(...), boot code\n  \u003Ctoken>.raw.js     kernel: the VM source analysed by shape\n```\n\nUse the registry instead of reconstructing URLs:\n\n```sh\nshape seeds sites\nshape seeds fetch --site NAME --out seeds\n```\n\nSDK integrations can fetch bytes with their own HTTP client and pass them to parsing or import operations.\n\nUse `fetch` to download launchers and kernels. `parse` classifies an already\nsaved file and prints its seed and resolved kernel URL, and `import` stores a\ndownloaded kernel without a request:\n\n```sh\nshape seeds parse saved.async.js \\\n  --base-url 'https:\u002F\u002Fassets.example.test\u002Flauncher.js?async'\nshape seeds import saved.raw.js \\\n  --launcher saved.async.js --out seeds\n```\n\nAn abbreviated launcher (values replaced with placeholders):\n\n```js\n(function () {\n  var kernel = \"https:\u002F\u002Fassets.example.test\u002Fkernel.js?seed=\u003Ctoken>&X-…--z=q\";\n  addEventListener(\"\u003Cevent-name>\", function (event) {\n    event.stopImmediatePropagation();\n    event.detail.init(\"\u003Ctransaction-token>\", \"\u003Calphabet>\", [],\n      [ \u002F* eight keys *\u002F ], \"\u003Cnonce>\", \u002F* … *\u002F);\n  });\n})();\n```\n\nThe kernel is minified JavaScript; `shape deob` reads it and\n`shape trace program` turns it into the traced program.\n\n```js\n(function () {\n  var document = window.document; \u002F* … VM tables, handlers, dispatch … *\u002F\n  \u002F* … *\u002F\n})();\n```\n\n`shape seeds parse` reports the same identity the launcher carries:\n\n```text\nsaved.async.js: async launcher\n  seed        \u003Ccapture-token>\n  kernel url  https:\u002F\u002Fassets.example.test\u002Fkernel.js?seed=\u003Ccapture-token>\n```\n\nThe launcher is also the initializer. Save it as `init.js`, or pass it directly\nto `session.from_initializer`; `shape pin --init` accepts the whole launcher.\nNo separate init extraction is required.\n\n### Headers\n\nThe browser sends one response header per field, prefixed with the capture's\nheader prefix (often `x-…-`). The normalised file keeps only the suffix and a\nsite label:\n\n```json\n{\n  \"siteId\": \"example-site\",\n  \"headers\": {\n    \"a\": \"ZCcDA5M-Wp6u…\",\n    \"a0\": \"_kDqP0McfRa…\",\n    \"b\": \"-upu45s\",\n    \"c\": \"AIAS-MKh…\",\n    \"d\": \"ADYAhICB…\",\n    \"f\": \"A71QDMOh…\",\n    \"z\": \"q\"\n  }\n}\n```\n\n- The real names are the capture's prefix plus the suffix, commonly\n  `x-…-a`, `x-…-a0`, and so on. The decode artifact supplies the prefix; `a0`,\n  `a1`, … are numeric chunks when a value is split across headers.\n- `siteId` is a label for this capture, not an HTTP header. It must match the\n  artifact.\n- Values are strings, including empty ones; optional fields may be absent.\n- `shape seeds` does not produce headers. Copy them from the same browser\n  request (Network panel response headers), or use an existing capture.\n- `shape decode --artifact … --headers …` reads exactly this shape.\n\n### Session\n\nThe launcher's `detail.init(...)` call carries the session: transaction token,\nalphabet, shuffle key, eight cipher keys and an optional nonce. The SDK parses\nthe saved launcher:\n\n```python\nimport shape\nsession = shape.session_from_initializer(open(\"seeds\u002F\u003Ctoken>.async.js\").read())\n```\n\nThe CLI's `shape pin --init seeds\u002F\u003Ctoken>.async.js` parses the same file and\nwrites a `shape-seed-layout\u002F1` document; its `session` member is the session\ndocument:\n\n```sh\nshape pin --input reports\u002Fprogram.js \\\n  --init seeds\u002F\u003Ctoken>.async.js --out reports\u002Fseed.json\npython3 -c 'import json; json.dump(json.load(open(\"reports\u002Fseed.json\"))[\"session\"], open(\"reports\u002Fsession.json\", \"w\"))'\n```\n\nThe values below are illustrative placeholders; use the parsed session\nunchanged:\n\n```json\n{\n  \"transactionToken\": \"\u003Ctoken>\",\n  \"alphabet\": \"\u003Cat least 64 symbols>\",\n  \"shuffleKey\": [],\n  \"keys\": [111111111, 222222222, 333333333, 444444444,\n           555555555, 666666666, 777777777, 888888888],\n  \"nonce\": \"\u003Coptional>\"\n}\n```\n\nThe session must belong to the same launcher, kernel and headers. When supplying\na replacement session, pass its complete token and cipher material; individual\nfields are not merged with the previous session.\n\n### From inputs to the generator\n\nThis sequence prepares an artifact and uses it to decode another request.\nDeobfuscation and function naming help with investigation; artifact preparation\nneeds the complete traced program with mechanical cleanup. You can go straight\nto tracing the raw seed when decoding is your goal.\n\n```sh\n# 1. Read the kernel (and optionally inspect the VM).\nshape deob seeds\u002F\u003Ctoken>.raw.js --output reports\u002Fkernel.js\n\n# 2. Trace it. Check reports\u002Ftrace.json for \"status\": \"complete\".\nshape trace program seeds\u002F\u003Ctoken>.raw.js --thread-cleanup \\\n  --json --out reports\u002Fprogram.js --report-dir reports\u002Fcache \\\n  > reports\u002Ftrace.json\n\n# 3. Parse the launcher and compile the decode artifact (the generator).\nshape pin --input reports\u002Fprogram.js \\\n  --init seeds\u002F\u003Ctoken>.async.js --out reports\u002Fseed.json\npython3 -c 'import json; json.dump(json.load(open(\"reports\u002Fseed.json\"))[\"session\"], open(\"reports\u002Fsession.json\", \"w\"))'\nshape decode --seed reports\u002Fprogram.js --input-kind program \\\n  --headers headers.json --session reports\u002Fsession.json \\\n  --float-byte-order little --save-artifact reports\u002Fartifact.json \\\n  --out reports\u002Fdecoded.json\n\n# 4. Inspect the signal schema and, optionally, rename functions.\nshape signals reports\u002Fprogram.js --json > reports\u002Fschema.json\nshape naming threads reports\u002Fprogram.js \\\n  --rename --out reports\u002Fnamed.js\n\n# 5. Reuse the generator without the seed, session or source files.\nshape decode --artifact reports\u002Fartifact.json \\\n  --headers next-headers.json --out reports\u002Fdecoded-next.json\n```\n\n- `reports\u002Fschema.json` is the **field schema**: names, routing and layouts for\n  this build. It describes signals; it does not decode by itself.\n- The **decode artifact** holds the layout, cipher settings, session defaults\n  and executable wire recipes. `--save-artifact` and\n  `artifact.compile` produce it; `decode --artifact` and every SDK\n  `Generator.load` consume it.\n- Renaming (`naming threads --rename`) is optional and cosmetic. It does not\n  change recipes, artifacts or header bytes.\n- In the SDK, `Generator.decode` returns named fields, `explain` shows one\n  signal, and `encode` turns edited fields back into headers. The CLI's\n  `shape encode` handles framed payloads, not named fields.\n- To inspect instead of decode: `kernel show`, `signals`, `signals show` and\n  `show signals` print the VM, the schema and the catalogue.\n\n## Shape CLI\n\nOne binary, `shape`, covers the whole path from a raw capture to named signal\nvalues. The walkthroughs use files committed to this repository, so most of\nthem can be tried without a capture of your own; the steps that need a real\ncapture say so.\n\n\u003Ca id=\"build-once\">\u003C\u002Fa>\n\n### Build\n\nRequires **Rust 1.92+** and a C toolchain for linking. Run from the repository\nroot:\n\n```sh\ncargo build --release --locked --bin shape\nexport PATH=\"$PWD\u002Ftarget\u002Frelease:$PATH\"\nmkdir -p reports\nshape --help\n```\n\nThis builds `target\u002Frelease\u002Fshape` and adds it to PATH for the current shell and\nits child processes; repeat the export in each new shell.\n`shape --help` lists every command, and\n`shape \u003Ccommand> --help` shows its options.\n\n- **Use a release build.** Debug builds are far slower on real captures.\n- **`--locked` builds the exact dependency versions in `Cargo.lock`.** The first\n  build resolves and downloads crates; later builds reuse Cargo's cache.\n- **Outputs go to `reports\u002F`.** That directory is Git-ignored; committed\n  fixtures and examples live under `tests\u002Ffixtures\u002F`.\n- **File outputs use atomic writes.** Existing outputs are refused unless the\n  command supports and receives `--force`; input\u002Foutput path aliasing is rejected.\n  Choose a fresh output path to keep earlier results.\n\n### Deobfuscate and inspect a kernel\n\n```sh\nshape deob tests\u002Ffixtures\u002Fkernels\u002Fjavascript\u002Fkernel.raw.js \\\n  --output reports\u002Fkernel.js\n```\n\nOpen `reports\u002Fkernel.js` to read the dispatcher and VM handlers. To look at the\nVM's operation table instead of the whole file:\n\n```sh\nshape ops list tests\u002Ffixtures\u002Fkernels\u002Fjavascript\u002Fkernel.raw.js\nshape ops show tests\u002Ffixtures\u002Fkernels\u002Fjavascript\u002Fkernel.raw.js --op 12\nshape kernel show tests\u002Ffixtures\u002Fkernels\u002Fjavascript\u002Fkernel.raw.js\n```\n\n- `ops list` prints the catalogue of operation handlers (241 in this kernel).\n- `ops show --op KEY` prints one handler with its source and analyses.\n- `kernel show` prints the tracer's input: the entry point, operation table,\n  string table and bytecode.\n\n`shape report \u003Csource> -o reports\u002Fkernel-artifact.json` saves the same facts as\na source-free kernel artifact that `trace thread --report` can reuse. This\ndocument describes the VM for tracing; decoding named signals requires the\nseparate decode artifact built from the recovered program and session.\n\nTo compare handlers across several captures instead of reading one:\n\n```sh\nshape ops classify reports\u002Fa.raw.js reports\u002Fb.raw.js\n```\n\nIt labels each handler as a JavaScript operation, VM machinery, fused, or\nunrecognized across the supplied seeds.\n\n\u003Ca id=\"trace-a-whole-program\">\u003C\u002Fa>\n\n### Trace the program\n\n`trace program` walks every reachable VM thread and links the result into one\nJavaScript file:\n\n```sh\nshape trace program tests\u002Ffixtures\u002Fkernels\u002Fjavascript\u002Fkernel.raw.js \\\n  --thread-cleanup --json --out reports\u002Fprogram.js --report-dir reports\u002Fcache \\\n  > reports\u002Ftrace.json\n```\n\nThis takes a few seconds and recovers 602 functions from the fixture.\n\n- **Check `reports\u002Ftrace.json` for `\"status\": \"complete\"`** before continuing.\n  A complete result has an empty `result.functions.stopped` list and\n  `result.javascript.incomplete` set to `false`.\n- A partial trace exits with code `3` and can contain throwing stubs. Inspect\n  `result.functions.stopped` to see what needs resolving.\n- `--report-dir` is a cache directory for compiled kernel artifacts. Reusing a\n  cache makes repeated traces of the same seed faster; it does not change the\n  result.\n- `--thread-cleanup` removes cleanup-safe helper scaffolding from each thread\n  before linking; omit it to retain that per-thread scaffolding. Independently,\n  `--no-cleanup` skips whole-program finishing after linking.\n\nTo recover a single function, or to clean one up on its own:\n\n```sh\nshape trace thread tests\u002Ffixtures\u002Fkernels\u002Fjavascript\u002Fkernel.raw.js \\\n  --pc 0 --state 0 --initialslots 2,0,3,1 --out reports\u002Fthread.js\nshape trace cleanup-thread reports\u002Fthread.js --out reports\u002Fthread-clean.js\n```\n\nThe entry `pc`, `state` and initial slots come from `kernel show`. A saved\nkernel artifact can replace the raw source: `--report reports\u002Fkernel-artifact.json`.\n\nTo compare which functions are reachable across captures:\n\n```sh\nshape trace corpus reports\u002Fa.raw.js reports\u002Fb.raw.js --json\n```\n\n### Name functions and read the signal schema\n\nBoth commands read the traced program:\n\n```sh\nshape signals reports\u002Fprogram.js --json > reports\u002Fschema.json\nshape naming threads reports\u002Fprogram.js \\\n  --rename --out reports\u002Fnamed.js > reports\u002Fnaming.json\n```\n\n- `reports\u002Fschema.json` holds every recognized signal by canonical name, with\n  its position, routing and typed fields. The fixture yields 64 signals.\n  `--layouts-only` adds projected layouts for unidentified slots.\n- `reports\u002Fnamed.js` is the program with recovered functions renamed.\n  `naming collectors`, `naming plan` and `naming inventory` report collector\n  routing, proposed names and the function index without editing the program.\n- `signals show`, `signals inputs` and `signals contracts` read generator-side\n  details: descriptor routing, composed inputs, and the typed wire contract per\n  emission.\n\nTo compare naming across seeds or against a reviewed baseline:\n\n```sh\nshape naming corpus reports\u002Fa.raw.js reports\u002Fb.raw.js --out reports\u002Fnaming-corpus\n```\n\nTo see what signals mean, with no program or capture at all, try these four\ncatalogue cards. Run `shape show signals` without a name to list every card.\nThe catalogue is source-independent and describes what a signal can collect.\nThe JSON blocks below show the cards' committed public example data, not values\nobserved by running these commands against your browser. All four cards report\n`size.kind: \"unavailable\"`: exact encoded sizes require a matching capture;\nexample data is not a byte measurement.\n\n**DeviceMemory — scalar.** Reads the browser-reported `navigator.deviceMemory`\nnumber, or `null` when the property is missing. This is the catalogue's example\n`data` object:\n\n```sh\nshape show signals DeviceMemory --json\n```\n\n```json\n{\n  \"deviceMemory\": 32\n}\n```\n\n**NavigatorPlugins — array of records.** Summarises up to five readable plugins;\neach entry has a name prefix (up to 12 characters) and a hash of its details.\n`pluginsLength` is the full plugin count, which may exceed the number of\nsummarised entries. The complete example `data` object preserves the array:\n\n```sh\nshape show signals NavigatorPlugins --json\n```\n\n```json\n{\n  \"plugin\": [\n    {\n      \"detailsHash\": -1716625998,\n      \"namePrefix\": \"WebKit built\"\n    },\n    {\n      \"detailsHash\": 1387368353,\n      \"namePrefix\": \"Microsoft Ed\"\n    },\n    {\n      \"detailsHash\": 2126051627,\n      \"namePrefix\": \"Chromium PDF\"\n    },\n    {\n      \"detailsHash\": 1061675194,\n      \"namePrefix\": \"Chrome PDF V\"\n    },\n    {\n      \"detailsHash\": 975495497,\n      \"namePrefix\": \"PDF Viewer\"\n    }\n  ],\n  \"pluginsLength\": 5\n}\n```\n\n**UserAgentData — nested objects.** Requests User-Agent Client Hints, including\nbrand\u002Fversion records and a nested `flags` object for `mobile` and `wow64`.\nMissing or rejected hints become `null`; browsers without the API emit no\npayload. This focused excerpt of example `data` keeps `architecture`,\n`brands`, `flags` and `platform`; other hints are omitted:\n\n```sh\nshape show signals UserAgentData --json\n```\n\n```json\n{\n  \"architecture\": \"arm\",\n  \"brands\": [\n    {\n      \"brand\": \"Google Chrome\",\n      \"version\": \"156\"\n    },\n    {\n      \"brand\": \"Chromium\",\n      \"version\": \"156\"\n    },\n    {\n      \"brand\": \"Not:A-Brand\",\n      \"version\": \"8\"\n    }\n  ],\n  \"flags\": {\n    \"mobile\": false,\n    \"wow64\": false\n  },\n  \"platform\": \"macOS\"\n}\n```\n\n**BrowserApiOwnPropertyFlags — named booleans.** Checks for `clipboard` on\n`Navigator.prototype`, `ServiceWorker` and `ApplePaySession` on the global\nobject, and `WebkitOverflowScrolling` on `CSSStyleDeclaration.prototype`.\nOnly own properties count. The complete example `data` object exposes each\nresult as a boolean:\n\n```sh\nshape show signals BrowserApiOwnPropertyFlags --json\n```\n\n```json\n{\n  \"ApplePaySession\": false,\n  \"ServiceWorker\": true,\n  \"WebkitOverflowScrolling\": false,\n  \"clipboard\": true\n}\n```\n\n### Decode headers into named fields\n\nA decode artifact holds the recipes and session settings for matching captured\nheaders. Try decoding with the committed synthetic artifact and capture:\n\n```sh\nshape decode \\\n  --artifact sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fartifact.json \\\n  --headers sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fcapture.json\n```\n\n```json\n{\n  \"siteId\": \"example\",\n  \"positionalSignals\": {\n    \"ConstantEmptyString\": { \"constant\": \"\" },\n    \"DeviceMemory\": { \"deviceMemory\": 32 },\n    \"StorageAccessApiPresence\": {\n      \"hasStorageAccess\": true,\n      \"requestStorageAccess\": false\n    }\n  }\n}\n```\n\nThe output above is trimmed to the named fields; the full document also carries\nthe report channels, seeds and metadata. Add `--out FILE` to save the full\ndocument for later edits and `--verify` to require byte-identical re-encoding.\n\n- **`shape decode` has two modes.** `--seed` traces and compiles recipes from a\n  raw or traced program; `--artifact` loads saved recipes and does no source\n  analysis. Only the second mode is cheap enough to run per request.\n- **`--float-byte-order` records how the collecting browser wrote native\n  floats.** It is required when the seed emits them, and is saved in the\n  artifact. `little` and `big` are the only values; guessing produces decode\n  failures rather than wrong values.\n\n\u003Ca id=\"recover-code-and-save-a-decode-artifact\">\u003C\u002Fa>\n\n### Your own capture: from seed to artifact\n\nSupply matching files from the same build and session. [Inputs](#inputs) shows\nwhat each file contains and how to obtain it.\n\n| File | Contents |\n| --- | --- |\n| `seeds\u002F\u003Ctoken>.async.js` | Launcher: kernel URL and the `detail.init(...)` session call |\n| `seeds\u002F\u003Ctoken>.raw.js` | Kernel: the captured VM source |\n| `session.json` | The session parsed from the launcher, or an existing parsed session |\n| `headers.json` | The capture document `{\"siteId\":\"example\",\"headers\":{\"a\":\"…\",\"b\":\"…\"}}` |\n\nThe [SDK workflow](sdk\u002FREADME.md#workflow) shows the same path in code, and\n[`shape seeds`](docs\u002Fdeob\u002Fseeds.md) covers acquisition and import.\n\n```sh\n# 1. Trace the seed. Check reports\u002Ftrace.json for \"status\": \"complete\".\nshape trace program seed.raw.js --thread-cleanup \\\n  --json --out reports\u002Fprogram.js --report-dir reports\u002Fcache > reports\u002Ftrace.json\n\n# 2. Compile recipes, decode named fields, and save the reusable artifact.\nshape decode --seed reports\u002Fprogram.js --input-kind program \\\n  --headers headers.json --session session.json --float-byte-order little \\\n  --save-artifact reports\u002Fartifact.json --out reports\u002Fdecoded.json\n\n# 3. Decode another request without tracing or loading source again.\nshape decode --artifact reports\u002Fartifact.json \\\n  --headers next-headers.json --out reports\u002Fdecoded-next.json\n```\n\n- `reports\u002Fdecoded.json` contains named `positionalSignals` like the output\n  above, along with the full report context needed to preserve the capture\n  during edits.\n- **The saved artifact works in every SDK.**\n- Choose `little` or `big` to match the capturing browser's float byte order.\n- `--save-artifact` verifies signal and header re-encoding. An ordinary decode\n  verifies only when `--verify` is given.\n- For `next-headers.json`, keep the same seed and session pairing, or pass the\n  matching replacement with `--session next-session.json`.\n- The session and the artifact are matched as a whole. Do not mix a token from\n  one capture with keys from another.\n\nFor explicit source-format analysis without lifecycle certification, opt into\n`--direct`. The same matching program, session and capture headers are required:\n\n```sh\nshape decode --direct --seed reports\u002Fprogram.js \\\n  --session session.json --headers headers.json --float-byte-order little \\\n  --verify --save-artifact reports\u002Fdirect-artifact.json --out reports\u002Fdecoded.json\n```\n\nWith `--direct`, `--seed` defaults to a traced program; use `--input-kind raw`\nto trace a raw seed first. Without `--direct`, the existing raw-seed default\nand strict refusal behavior remain. Direct mode bypasses lifecycle and strict\nalgorithm certification; it does not certify strict consumer support. Unsupported\nsource constructs can still fail. `--verify` requires exact signal and header\nre-encoding, and saving an artifact always performs that verification.\n\nDirect provenance persists in the artifact, so later `--artifact` loads use the\nrecorded mode automatically. `--direct` requires `--seed` and conflicts with\n`--artifact` and `--schema-only`; it cannot reinterpret a saved strict artifact.\nSee the [decode checkpoint](docs\u002Fsignals\u002Fdecode-checkpoint.md) and\n[SDK options](sdk\u002FREADME.md#workflow) for the same opt-in in library callers.\n\n### Report and payload framing\n\nUse this workflow to inspect and rebuild a captured report container. Start with\nthe recovered program and the initializer from the same capture\u002Fsession:\n\n```sh\nshape pin --input reports\u002Fprogram.js --init init.js --out reports\u002Fseed.json\nshape headers decode --seed reports\u002Fseed.json --input headers.http.json --out reports\u002Freport.json\nshape headers encode --seed reports\u002Fseed.json --input reports\u002Freport.json --out reports\u002Frebuilt-headers.json\n```\n\nHere `headers.http.json` is a raw captured HTTP header object containing all six\nfull header names and their values, without the SDK's `{siteId, headers}` wrapper.\nDecoding writes the framed report to `reports\u002Freport.json`; encoding rebuilds\nthe headers from that report. For named signal fields, use the earlier\n[`shape decode` workflow](#decode-headers-into-named-fields) or the SDK.\n\nThe pinned seed layout saves framing and session settings for reuse with this\ncapture; the compiled decode artifact additionally supports named signal decoding.\n\n| Command | Converts |\n| --- | --- |\n| `shape payload encode` \u002F `decode` | Report JSON to and from a bare finalized payload |\n| `shape headers encode` \u002F `decode` | Report framing to and from a header bundle |\n| `shape encode` \u002F `decode --profile` | Opaque payload bytes to and from session headers |\n| `shape pack` \u002F `unpack` | Typed values without encryption |\n\nFor advanced bare-payload work, run `shape payload encode --help` and\n`shape payload decode --help`; the pinned seed also supplies their framing settings.\n\nCommands refuse to overwrite existing output. Choose new output paths, or use\n`--force` where it is supported.\n\n### Command reference\n\nRun `shape \u003Ccommand> --help` for the complete option list. The binary exit\nstatus is `0` on success, `2` for usage errors, `3` for an incomplete trace,\nand `1` for an operational failure.\n\n**Recovery and inspection**\n\n| Command | Purpose |\n| --- | --- |\n| `deob \u003Csource>` | Deobfuscate one JavaScript source; `--output`, `--report`, `--verbose` |\n| `report \u003Csource>` | Compile a source-free kernel artifact; `--input-kind`, `--output` |\n| `kernel show \u003Csource>` | Print the tracer-input properties bundle; `--format json\\|markdown` |\n| `ops list \u003Csource>` | List proven operation handlers |\n| `ops show \u003Csource> --op KEY` | Show one operation handler; `--format` |\n| `ops classify \u003Csource>...` | Label handlers across captures |\n| `signals \u003Cprogram.js>` | Per-seed signal schema; `--json`, `--layouts-only`, `--no-finder-roles` |\n| `signals show\\|inputs\\|contracts \u003Cprogram.js>` | Generator inputs, composed inputs, typed contracts |\n| `show signals [SignalName]` | Source-independent catalogue card; `--json` |\n\n**Tracing**\n\n| Command | Purpose |\n| --- | --- |\n| `trace program \u003Csource>` | Recover and link the reachable program; `--out`, `--json`, `--thread-cleanup`, `--no-cleanup`, `--report-dir`, `--steps` |\n| `trace thread \u003Csource>` | Walk one thread; `--pc`, `--state`, `--initialslots`, `--report`, `--json`, `--out` |\n| `trace cleanup-thread \u003Cthread.js>` | Clean one emitted function; `--out`, `--json` |\n| `trace corpus \u003Csource>...` | Compare reachable-function fingerprints; `--json` |\n\n**Naming**\n\n| Command | Purpose |\n| --- | --- |\n| `naming threads \u003Cprogram.js>` | Name thread functions; `--rename`, `--out`, `--map-out`, `--labels` |\n| `naming collectors \u003Cprogram.js>` | Identify collector routing; `--rename`, `--out`, `--map-out` |\n| `naming inventory \u003Cprogram.js>` | Function index and role graph; `--json` |\n| `naming plan \u003Cprogram.js>` | Proposed names, ambiguities and refusals (JSON) |\n| `naming corpus \u003Csource>...` | Run the naming chain per seed and compare baselines |\n\n**Sessions, artifacts and framing**\n\n| Command | Purpose |\n| --- | --- |\n| `seeds fetch\\|parse\\|import\\|sites` | Acquire launchers and kernels, classify saved files, import local seeds, list the registry |\n| `pin --input \u003Cprogram.js> --init\\|--session` | Pin a traced program into a `shape-seed-layout\u002F1` document |\n| `decode --seed\\|--artifact ... --headers ...` | Decode captured headers into named fields |\n| `decode --schema-only --seed \u003Cprogram.js> --input-kind program --schema-out \u003Cschema.json>` | Export the static schema without a session or capture |\n| `headers encode\\|decode` | Report framing to and from a header bundle |\n| `payload encode\\|decode` | Report framing to and from a bare finalized payload |\n| `encode --profile` \u002F `decode --profile` | Opaque bytes to and from session headers |\n| `pack` \u002F `unpack` | Generic superpack serialization |\n| `gen \u003Ccommand>` | Legacy alias for the framing commands above |\n\n`shape seeds fetch` is the only command that uses the network. It downloads\nlaunchers and the kernels they load; `seeds import` stores an already\ndownloaded kernel without network access, and `seeds sites` lists the registry.\n\n### Performance and limits\n\nRaw-seed recovery does several jobs: compile the kernel facts, trace reachable\nthreads, mechanically clean the recovered program, then extract layouts and\ncompile signal recipes. Capture complexity and the number of reachable threads\nmake this a seconds-to-minutes operation. Use release builds for this stage.\n\nFor the shortest preparation path, trace the raw seed with thread cleanup and\nwhole-program mechanical finishing enabled. The SDK's automatic job selection\nuses available cores for tracing. Deobfuscating a separate kernel file and naming\nfunctions are optional investigation steps; neither is needed to compile the\ndecode artifact. See the [SDK workflow](sdk\u002FREADME.md#workflow) for the defaults.\n\nSave a decode artifact to reuse the finished analysis. Each invocation of\n`shape decode --artifact` still starts a process, reads the artifact and\nvalidates it before decoding headers. For repeated requests, the SDK can keep\nthat validated artifact in memory and avoid those repeated setup costs.\n\nA kernel cache such as `--report-dir` skips kernel compilation on a later\ntrace; it does **not** skip tracing. Saving a decode artifact skips the source\nanalysis stages on reuse. Keeping an SDK artifact loaded also skips repeated\nartifact parsing and validation. The SDK's named source operations leave disk\ncaching disabled unless requested; see the [cache policy](sdk\u002FREADME.md#explicit-cache-policy).\n\nUse `--steps` to limit each function walk, and the SDK's tracing `jobs` option\nto limit concurrent walks. These bound tracing work, not the cost of decoding a\nloaded capture. Decode and encode cost instead depends on the captured payload\nand signal layouts, requested metadata and verification, and concurrent request\nload. Default decode retains round-trip context without building every signal's\ndetails; `explain` can build one later. Verification adds re-encoding work.\n\n## SDK\n\nThe SDK puts the same engine inside your application. Decode headers into\nfields such as `DeviceMemory.deviceMemory`, inspect how a signal was encoded,\nchange its values, and encode the full payload back into headers. It also\nexposes tracing, cleanup, naming and schema extraction.\n\nThe engine is one Rust crate. The C ABI (`libshape`) wraps it, and the Python,\nNode.js and Go bindings wrap the C ABI. The Rust SDK is the crate itself, with a\nJSON dispatch that matches the C ABI plus typed APIs. All five paths share the\nsame requests, results and error codes.\n\n| Language | Guide | Interface | Best when |\n| --- | --- | --- | --- |\n| Node.js 18+ \u002F TypeScript | [sdk\u002Fnode](sdk\u002Fnode\u002FREADME.md) | CommonJS\u002FESM, Promises for commands, hand-written types | A Node service or tool should keep the event loop free while tracing |\n| Python 3.9+ | [sdk\u002Fpython](sdk\u002Fpython\u002FREADME.md) | Standard-library `ctypes`, synchronous | Scripting and data work; no compiler or package dependencies |\n| Go 1.22+ with cgo | [sdk\u002Fgo](sdk\u002Fgo\u002FREADME.md) | Synchronous functions returning values and errors | A static Go service or CLI that wants no shared-library deployment |\n| Rust | [sdk\u002Frust](sdk\u002Frust\u002FREADME.md) | Native crate, typed APIs and JSON dispatch | Maximum control, zero FFI, and access to internal modules |\n| C | [sdk\u002Fc](sdk\u002Fc\u002FREADME.md) | JSON ABI with explicit ownership | Any other language, or a minimal deployment surface |\n\nThe [shared SDK guide](sdk\u002FREADME.md) has the complete workflow, documents and\noperation matrix. The [decoded output and editing guide](sdk\u002Fsignals.md)\nexplains the named fields, per-signal details and full-payload round trips.\n\nStart with your language guide to load an artifact and decode a capture. It\nalso covers preparing an artifact from a raw seed, inspecting and editing\nfields, and handling errors. Check its precision and lifetime guidance when\npassing decoded payloads between processes or sharing loaded artifacts across\ncalls.\n\n### Set up once\n\nFor Node.js, Python, Go and C, run the shared native build from the repository\nroot on macOS or Linux:\n\n```sh\nscripts\u002Fbuild-sdk.sh\nmkdir -p reports\n```\n\nThe script needs Rust 1.92+ with Cargo, a C toolchain, and Node.js with Node-API\nheaders to build the addon. It also uses Rust's `llvm-tools` component\n(`rustup component add llvm-tools`) to prepare Go's static library. It builds\nthe release C ABI library, installs the libraries for the bindings and builds\nthe Node addon. Rerun it after native source changes; its outputs are Git-ignored.\n`scripts\u002Fbuild-sdk.sh --help` lists environment options, and the\n[C guide](sdk\u002Fc\u002FREADME.md#install-and-build) covers manual builds.\n\nRust applications depend directly on the repository's root crate and do not\nneed the C ABI build. For package setup and runtime minimums, follow the\n[Node.js 18+](sdk\u002Fnode\u002FREADME.md), [Python 3.9+](sdk\u002Fpython\u002FREADME.md),\n[Go 1.22+ with cgo](sdk\u002Fgo\u002FREADME.md), or [Rust](sdk\u002Frust\u002FREADME.md) guide.\nThe build supports macOS and Linux.\n\nThe examples below use the committed synthetic artifact and capture in\n`sdk\u002Fc\u002Ftests\u002Ffixtures\u002F`, the same pair as the CLI decode above. Each one\ndecodes the capture, changes `DeviceMemory.deviceMemory` from 32 to 16, and\nencodes the full payload back into headers.\n\nKeep the loaded artifact for as many requests as you need, then release it\nusing your language's lifetime rules. Each decode returns a separate payload\nto inspect or edit. The Node examples use explicit async methods; named Node\n`decode` and `encode` calls are synchronous.\n\nFor your own data, create an artifact with the\n[CLI](#recover-code-and-save-a-decode-artifact) or the\n[SDK workflow](sdk\u002FREADME.md#workflow), then substitute its path and your\ncaptured headers. The artifact, headers and session must match. Other captures\nmay carry different signals.\n\n### Node.js \u002F TypeScript\n\n#### JavaScript (ES modules)\n\nFrom the repository root, run `node --input-type=module` and paste this code on\nstandard input (finish with Ctrl-D). Installed applications import from\n`'shape'` instead of the checkout's `index.mjs`.\n\n```js\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { Generator, stringifyJSON } from '.\u002Fsdk\u002Fnode\u002Findex.mjs';\n\nconst generator = await Generator.loadAsync(readFileSync('sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fartifact.json'));\ntry {\n  const decoded = await generator.decodeAsync(readFileSync('sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fcapture.json'));\n  console.log(decoded.positionalSignals);\n  const memory = decoded.positionalSignals.DeviceMemory;\n  if (!memory || typeof memory.deviceMemory !== 'number') {\n    throw new Error('Capture has no numeric DeviceMemory field');\n  }\n  memory.deviceMemory = 16;\n  const encoded = await generator.encodeAsync({ decoded });\n  const json = stringifyJSON(encoded);\n  if (json === undefined) throw new Error('Capture could not be serialized');\n  writeFileSync('reports\u002Fnode-headers.json', json);\n} finally {\n  generator.close();\n}\n```\n\n#### TypeScript (ES modules)\n\nInstall the local package and compiler in an ignored demo workspace:\n\n```sh\nnpm install --prefix reports\u002Fsdk-demo --install-links \"$PWD\u002Fsdk\u002Fnode\"\nnpm install --prefix reports\u002Fsdk-demo --save-dev typescript@~5.7.3 @types\u002Fnode@^22\n```\n\nSave this as `reports\u002Fsdk-demo\u002Fdemo.mts`. The `.mts` extension selects ESM, and\n`NodeNext` resolves the installed package's exports and declarations.\n`--install-links` installs a package copy so its types resolve in the demo\nworkspace.\n\n```ts\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { Generator, stringifyJSON } from 'shape';\nimport type { CaptureHeaders, DecodedPayload } from 'shape';\n\nconst generator = await Generator.loadAsync(readFileSync('sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fartifact.json'));\ntry {\n  const decoded: DecodedPayload = await generator.decodeAsync(\n    readFileSync('sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fcapture.json'),\n  );\n  console.log(decoded.positionalSignals);\n  const memory = decoded.positionalSignals.DeviceMemory;\n  if (!memory || typeof memory.deviceMemory !== 'number') {\n    throw new Error('Capture has no numeric DeviceMemory field');\n  }\n  memory.deviceMemory = 16;\n  const encoded: CaptureHeaders = await generator.encodeAsync({ decoded });\n  const json = stringifyJSON(encoded);\n  if (json === undefined) throw new Error('Capture could not be serialized');\n  writeFileSync('reports\u002Ftypescript-headers.json', json);\n} finally {\n  generator.close();\n}\n```\n\nCompile and run from the repository root:\n\n```sh\nreports\u002Fsdk-demo\u002Fnode_modules\u002F.bin\u002Ftsc reports\u002Fsdk-demo\u002Fdemo.mts \\\n  --strict --noUncheckedIndexedAccess --target ES2022 \\\n  --module NodeNext --moduleResolution NodeNext --outDir reports\u002Fsdk-demo\u002Fdist\nnode reports\u002Fsdk-demo\u002Fdist\u002Fdemo.mjs\n```\n\nPass artifact and capture bytes directly. For saved decoded objects, use\n`shape.parseJSON` and `shape.stringifyJSON`: they preserve large integers as\n`bigint` across Node 18+, including runtimes without native lossless JSON\nsupport. Ordinary `JSON.parse` can round integers needed for exact encoding.\n\n### Python\n\nFrom the repository root, run `PYTHONPATH=sdk\u002Fpython python3` and supply this\ncode on standard input:\n\n```python\nimport json\nfrom pathlib import Path\nimport shape\n\nartifact = Path(\"sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fartifact.json\")\nheaders = Path(\"sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fcapture.json\").read_bytes()\nwith shape.Generator.load(artifact) as generator:\n    decoded = generator.decode(headers)\n    print(decoded[\"positionalSignals\"])\n    decoded[\"positionalSignals\"][\"DeviceMemory\"][\"deviceMemory\"] = 16\n    encoded = generator.encode(decoded=decoded)\n    Path(\"reports\u002Fpython-headers.json\").write_text(\n        json.dumps(encoded), encoding=\"utf-8\"\n    )\n```\n\n### Go\n\nIn a Go module configured with `require shape v0.0.0` and\n`replace shape => \u002Fabsolute\u002Fpath\u002Fto\u002Frepo\u002Fsdk\u002Fgo`, use this function. Pass the\nartifact and capture JSON bytes read from the two fixture files. It returns the\ncomplete edited capture, ready to marshal with `encoding\u002Fjson`.\n\n```go\npackage demo\n\nimport (\n\t\"encoding\u002Fjson\"\n\t\"fmt\"\n\n\t\"shape\"\n)\n\nfunc EditCapture(artifact, headers []byte) (*shape.Capture, error) {\n\tgenerator, err := shape.Load(artifact)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer generator.Close()\n\n\tdecoded, err := generator.Decode(headers, shape.DecodeOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfmt.Println(decoded.PositionalSignals)\n\tmemory, ok := decoded.PositionalSignals[\"DeviceMemory\"]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"capture has no DeviceMemory signal\")\n\t}\n\tmemory[\"deviceMemory\"] = json.Number(\"16\")\n\treturn generator.Encode(shape.EncodeRequest{Decoded: decoded})\n}\n```\n\nEdits to Go's exported `Decoded` fields are encoded. Keep numbers as\n`json.Number`, integers or `json.RawMessage` to preserve precision.\n\n### Rust and C\n\nRust callers depend on this repository's root crate by path and use\n`shape::Generator` or the typed APIs directly. C callers link `libshape` and\nexchange JSON text. See the [Rust guide](sdk\u002Frust\u002FREADME.md) and the\n[C guide](sdk\u002Fc\u002FREADME.md) for complete examples.\n\n```rust\nuse shape::Generator;\n\nfn main() -> Result\u003C(), Box\u003Cdyn std::error::Error>> {\n    let generator = Generator::load(&std::fs::read(\"artifact.json\")?)?;\n    let capture: shape::signals::decode::CaptureHeaders =\n        serde_json::from_slice(&std::fs::read(\"headers.json\")?)?;\n    let mut decoded = generator.decode(&capture, None, Default::default())?;\n    let memory = decoded.positional_signals.get_mut(\"DeviceMemory\")\n        .ok_or(\"capture has no DeviceMemory signal\")?;\n    memory[\"deviceMemory\"] = serde_json::json!(16);\n    let headers = generator.encode(&serde_json::to_value(&decoded)?, None)?;\n    println!(\"{} {}\", headers.site_id, headers.headers.iter().count());\n    Ok(())\n}\n```\n\n### Preserve the full payload\n\nDecode returns both readable `positionalSignals` and the context needed to\nrebuild the capture. Keep the **whole decoded object**, edit the specific named\nfields, and pass that whole object to encode. Persist the entire document when\npassing it to another pipeline stage, including `metadata.originalReport`;\nsaving only the named map loses the original encoding context.\n\nThat retained report carries raw signal bytes, other report channels, seeds,\nkeysets, header context and per-signal prefixes. For supported encodings with a\n*matching artifact and session*, encoding the unchanged full object reproduces\n**all six captured header values exactly**. Editing fields retains the logical\nunedited signals and other channels, and reuses original bytes and context\nwhere the codec supports it. A changed or reordered repeated row can require\ncanonical encoding of the entire row. Shared framing and encryption can also\nchange header bytes beyond the edited field; an edit is not a promise of\nunchanged ciphertext elsewhere.\n\n`metadata=false` still retains this context. It only avoids eagerly building\ndetails for every signal; use `explain` when you need one signal's fields,\nencoding details or verification. Explain reads the retained bytes, so **encode\nand decode an edit** before explaining its new value. The loaded artifact is\nimmutable and reusable; each decoded object is mutable request data. **Copy that\nobject** if you need to keep both the original and edited versions.\n\nEncoding the **named map alone** deliberately constructs a new payload with\n**fresh signal prefixes** and layout defaults for other channels. Choose it when\nyou want new construction from field values; use full-payload encoding when\nyou want to retain a capture. Both paths require supported wire recipes and\ncheck that the result decodes to exactly the requested fields. Literal and\ncount constraints still apply, and unsupported edits refuse. Some encodings\ndepend on the retained report and will refuse an edit if that context cannot\nbe reconstructed.\n\nA session override replaces the **whole** artifact session. Use the **same\nconsistent replacement** for decode, explain and encode, paired with headers\nfrom that session and the matching site\u002Fbuild layout. Replacing a session does\nnot make a different capture's layout compatible. See the complete\n[editing walkthrough](sdk\u002Fsignals.md) for retained fields and supported edits.\n\nTo check the distinction yourself, run this complete Python program from the\nrepository root with the binding installed. It uses the same public sample32\npair as the examples above and creates no output files:\n\n```python\nimport copy\nimport json\nfrom pathlib import Path\nimport shape\n\nfixtures = Path(\"sdk\u002Fc\u002Ftests\u002Ffixtures\")\ncapture = json.loads((fixtures \u002F \"capture.json\").read_text())\nwith shape.artifact.load((fixtures \u002F \"artifact.json\").read_bytes()) as loaded:\n    decoded = shape.decode(loaded, capture)  # metadata=False retains context\n    assert shape.encode(loaded, decoded) == capture\n    assert decoded[\"positionalSignals\"][\"DeviceMemory\"][\"deviceMemory\"] == 32\n\n    edited = copy.deepcopy(decoded)\n    edited[\"positionalSignals\"][\"DeviceMemory\"][\"deviceMemory\"] = 16\n    encoded = shape.encode(loaded, edited)\n    again = shape.decode(loaded, encoded, verify=True)\n    assert again[\"positionalSignals\"] == edited[\"positionalSignals\"]\n    for key in (\"errors\", \"signals\", \"keyedSignals\", \"seeds\", \"keysets\"):\n        assert again[key] == decoded[key]\n    for name, fields in decoded[\"positionalSignals\"].items():\n        if name != \"DeviceMemory\":\n            assert again[\"positionalSignals\"][name] == fields\n    assert decoded[\"positionalSignals\"][\"DeviceMemory\"][\"deviceMemory\"] == 32\n    print(\"Unchanged capture exact; edited value and untouched channels verified.\")\n```\n\n### Performance in the SDK\n\nCompile from source once, then keep one loaded artifact outside request loops.\nLoading parses and validates the saved document; repeated decode, explain and\nencode calls reuse that immutable native state. This removes source tracing,\nrecipe compilation and repeated artifact parsing\u002Fvalidation from the request\npath. Each call still processes its own capture and returns its own result.\n\nDefault `metadata=false` leaves per-signal detail work until `explain` is\nneeded. `verify=true` on decode additionally rebuilds signals and headers to\ncheck exact equality; enable it when that check is useful. Encode independently\nchecks the requested fields' round trip. Neither option replaces the need for\na matching artifact\u002Fsession. For host concurrency and handle lifetime, follow\nyour [language guide](#documentation); Node services can use async operations.\n\nMeasure source preparation, artifact loading, repeated decode and repeated\nencode separately. Record the capture's signal count, options and request\nconcurrency, warm up the loaded handle, then report iteration count, median and\np95 for each operation. Raw-seed walkthrough timings include the preparation\npipeline and do not measure loaded decode throughput. Capture complexity,\nmetadata, verification and competing work on the host all affect the result;\nthere is no single latency figure that describes every artifact.\n\nA local example using the public [sample32 capture](sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fcapture.json) and matching [artifact](sdk\u002Fc\u002Ftests\u002Ffixtures\u002Fartifact.json): three signals, six headers, on macOS arm64 \u002F Apple M5 Pro, Node 22.22.2.\nNamed Node calls in a warmed process, concurrency 1, one reused loaded artifact; default decode `metadata=false` \u002F `verify=false` (encode includes its own verification).\n\n| Operation | Median | p95 |\n| --- | ---: | ---: |\n| Artifact load + validation | 0.313 ms | 0.415 ms |\n| Loaded decode | 0.053 ms | 0.063 ms |\n| Full-payload encode | 0.062 ms | 0.075 ms |\n\nHot calls: 20 warmups then 200 samples each; fresh loads: 10 warmups then 50 samples, excluding file I\u002FO. These timings represent this small fixture; capture complexity and options change timing. Follow the measurement procedure above and the [Node guide](sdk\u002Fnode\u002FREADME.md) for your inputs.\n\n### Cross-language interoperability\n\nCompile a decode artifact once with the CLI or Rust, save it, and load the\n**same bytes** in Node.js\u002FTypeScript, Python, Go or C. The languages expose the\nsame operations, signal names and supported encodings. Save the artifact\ndocument to share it; each process loads its own instance. Kernel artifacts,\ntraced programs and decode artifacts are different inputs, and their\nformat versions and source identity matter. Keep the artifact with its matching\nsite\u002Fbuild and session\u002Fcapture pair rather than swapping documents from another\ncapture.\n\nFor example, the CLI can prepare an artifact, a Python script can inspect a\ncapture and save its **full decoded payload**, and a Node service can load that\nartifact, read the saved payload, edit a named field and encode it. Saving the\nartifact carries the compiled analysis between stages; saving the entire\ndecoded object separately carries that request's original channels and encoding\ncontext. Saving just `positionalSignals` selects new construction instead.\n\nExchange JSON text or bytes through a lossless path. Node provides\n`parseJSON` \u002F `stringifyJSON` for exact integers; Python's standard JSON\nintegers are exact. Go uses `json.Number` \u002F `json.RawMessage`, Rust uses the\nSDK's configured `serde_json`, and C can pass the raw JSON text through.\nOrdinary JavaScript numbers or Go `float64` can round large integers in\nartifacts and metadata. A JSON handoff needs those language-specific readers\nand writers; it does not automatically convert arbitrary BigInt objects between\nlanguages.\n\nThe [contract harness](sdk\u002Ftests\u002FREADME.md) compares artifact loading, decoding,\nedits, exact numeric data and errors across the SDKs. Use compatible SDK\nversions and artifact formats when passing documents between deployments.\n\n## Troubleshooting\n\nStart with the command's `--help` and the error message. Check which CLI binary\nor installed native SDK library is actually running: source changes do not\nupdate an older installed build. Then check that the seed, whole session,\nheaders and artifact describe the same site\u002Fbuild\u002Fcapture. Use the\n[CLI build and PATH setup](#build-once) when checking a checkout's binary.\n\n| Symptom | Likely cause | Fix |\n| --- | --- | --- |\n| `shape: command not found` | The repository binary is not on `PATH` | From the repository root, run `export PATH=\"$PWD\u002Ftarget\u002Frelease:$PATH\"` after the [CLI build](#build-once) |\n| Exit status `3`, empty `result.javascript` | Tracing stopped before producing a partial program | Inspect `result.functions.stopped`; raise `--steps`, retry without `--thread-cleanup`, or use branch overrides |\n| `capture\u002Fartifact siteId mismatch` | Headers and artifact come from different sites | Use the artifact compiled for that site, or recompile with the capture's `siteId` |\n| `native float byte order must be explicitly configured` | The seed emits native floats and the artifact has no byte order | Re-run `decode --seed` or `artifact.compile` with `--float-byte-order little\\|big` |\n| `reconstructed report differs` under `--verify` | Artifact, session and headers do not describe one capture | Re-extract the matching session and recompile the artifact |\n| `unsupported decode artifact format` | A compact schema or a kernel artifact was passed where a decode artifact was expected | Pass the `--save-artifact`\u002F`artifact.compile` output, not `--schema-out` or `report` |\n| `an existing output file` | Commands refuse to overwrite by default | Choose a new output path, or add `--force` where supported |\n| `too many open files` during a large trace | Many concurrent walks | Raise the shell's file limit; SDK callers can also lower the tracing `jobs` option |\n| Python `library_not_found` | `libshape` is not installed or not discoverable | Run `scripts\u002Fbuild-sdk.sh`, or set `SHAPE_LIBRARY` to the absolute library path |\n| Node cannot load `shape.node` | Addon not built, wrong architecture, or missing library beside it | Re-run `sdk\u002Fnode\u002Fbuild.sh`; confirm `libshape` is in `sdk\u002Fnode\u002Fbuild\u002F`; check `process.arch` |\n| Go `disallowed LTO section __LLVM,__bitcode` | The static library still contains LLVM bitcode | Run `scripts\u002Fbuild-sdk.sh`, or strip it (see the [Go guide](sdk\u002Fgo\u002FREADME.md#installing-the-library-by-hand)) |\n| C link error `mis-aligned LINKEDIT string pool` | A stripped Rust dylib was linked | Rebuild with `scripts\u002Fbuild-sdk.sh`; see the [C guide](sdk\u002Fc\u002FREADME.md#install-and-build) |\n| `artifact.json` decodes but edits fail | The requested edit has no supported encoding | Check `describe`\u002F`explain` for the signal; unsupported leaves cannot be synthesized |\n| Large integers change value | A JSON layer parsed them as doubles | Keep documents as text, or use the language's exact-integer path (see each guide's precision section) |\n\nSuccessful decoding does not mean every edit can be encoded. Inspect the\nsignal with `explain`, check its supported shape and literal\u002Fcount constraints,\nand retain the full decoded object. If values changed while moving through\nJSON, check integer precision before diagnosing a codec failure.\n\nIf a failure looks like an internal panic, the SDK returns a `panic` error\ncode rather than crashing your process. Include the operation or command,\nCLI\u002Fnative version, options, error `code` and a minimal reproduction in a report.\n\n## Repository layout\n\n| Path | Contents |\n| --- | --- |\n| `src\u002F` | The engine: deobfuscation, tracing, naming, signals, wire codec, SDK dispatch |\n| `shape.rs`, `cli\u002F` | The `shape` binary and its command implementations |\n| `sdk\u002Fc\u002F` | The C ABI crate (`shape-c`), header, samples and consumer tests |\n| `sdk\u002Fpython\u002F`, `sdk\u002Fnode\u002F`, `sdk\u002Fgo\u002F` | Language bindings and their guides |\n| `sdk\u002Frust\u002F` | Guide to the root crate's Rust SDK (no separate binding) |\n| `sdk\u002Ftests\u002F` | The five-language contract harness |\n| `tests\u002F` | Rust integration tests and committed fixtures |\n| `docs\u002F` | Contracts, workflows and source references by area |\n| `scripts\u002F` | `build-sdk.sh` and the documentation link check |\n| `reports\u002F` | Git-ignored output for local runs |\n\n## Documentation\n\n| Topic | Where |\n| --- | --- |\n| SDK workflow, documents, operation matrix and contract | [sdk\u002FREADME.md](sdk\u002FREADME.md) |\n| Decoded signals and editing | [sdk\u002Fsignals.md](sdk\u002Fsignals.md) |\n| Node.js \u002F TypeScript SDK | [sdk\u002Fnode\u002FREADME.md](sdk\u002Fnode\u002FREADME.md) |\n| Python SDK | [sdk\u002Fpython\u002FREADME.md](sdk\u002Fpython\u002FREADME.md) |\n| Go SDK | [sdk\u002Fgo\u002FREADME.md](sdk\u002Fgo\u002FREADME.md) |\n| Rust SDK | [sdk\u002Frust\u002FREADME.md](sdk\u002Frust\u002FREADME.md) |\n| C ABI and request reference | [sdk\u002Fc\u002FREADME.md](sdk\u002Fc\u002FREADME.md) |\n| Five-language contract harness | [sdk\u002Ftests\u002FREADME.md](sdk\u002Ftests\u002FREADME.md) |\n| Tracing | [docs\u002Ftracing\u002Ftrace-cli.md](docs\u002Ftracing\u002Ftrace-cli.md) |\n| Signal schema | [docs\u002Fsignals\u002Fschema.md](docs\u002Fsignals\u002Fschema.md) |\n| What each signal means | [shape show signals](#name-functions-and-read-the-signal-schema) or [docs\u002Fsignals\u002F](docs\u002Fsignals\u002FREADME.md) |\n| Payloads and headers | [docs\u002Fgenerator\u002FREADME.md](docs\u002Fgenerator\u002FREADME.md) |\n| Capture acquisition | [docs\u002Fdeob\u002Fseeds.md](docs\u002Fdeob\u002Fseeds.md) |\n| WebAssembly boundaries | [docs\u002Freference\u002Fwasm-boundary.md](docs\u002Freference\u002Fwasm-boundary.md) |\n| Architecture | [docs\u002Farchitecture.md](docs\u002Farchitecture.md) |\n| CLI module ownership | [cli\u002FREADME.md](cli\u002FREADME.md) |\n| Everything else | [docs\u002FREADME.md](docs\u002FREADME.md) |\n","Shape 是一个用于解析和重构网络请求头中信号字段的命令行工具与多语言 SDK。它支持对混淆的 JavaScript 内核进行反混淆、追踪虚拟机执行路径、恢复函数名与采集逻辑，并将原始请求头解码为结构化、可编辑的命名信号字段，再编码回标准 HTTP 头格式。核心能力包括内核分析、会话布局固化、信号 Schema 提取及跨语言解码\u002F编码复用，底层基于 Rust 实现高性能解析引擎。适用于 Web 安全研究、前端反爬机制逆向、自动化风控信号分析及浏览器环境行为建模等需要深度理解请求头语义的场景。","2026-11-19 04:45:22","CREATED_QUERY"]