Skip to content

feat: add text processing with media payloads - #1

Open
gabewillen wants to merge 2 commits into
mainfrom
feat/process-text-with-media
Open

gabewillen wants to merge 2 commits into
mainfrom
feat/process-text-with-media

Conversation

@gabewillen

Copy link
Copy Markdown
Contributor

Summary

  • add CortextWasm.processTextWithMedia using the media-capable JSON C API
  • preserve arbitrary binary bytes and MIME metadata via the wasm cortext_media ABI struct
  • add TypeScript Media type, unit coverage, README and changelog documentation

Compatibility

  • existing processText path is unchanged
  • requires a WASM asset built from the media-capable core C API, including _cortext_process_text_with_media_json_with_options
  • null media passes a null descriptor and keeps no-payload behavior

Validation

  • npm run typecheck
  • npm run test:unit (18 passed)
  • npm test (19 passed; smoke context skipped because vendored 1.2.0 asset lacks model)
  • npm run pack:check
  • npm run check:wasm

Core C API/export update is tracked in the companion core PR.

Copilot AI lite review requested due to automatic review settings August 6, 2026 23:55
@gabewillen
gabewillen force-pushed the feat/process-text-with-media branch from 3e2c1f6 to faf7e59 Compare August 6, 2026 23:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new WASM binding entrypoint for processing canonical text while attaching an arbitrary binary “media” payload (bytes + MIME type), using the media-capable JSON C API to avoid string/base64 coercion.

Changes:

  • Add CortextWasm.processTextWithMedia(...) that marshals cortext_media + options structs into WASM memory and calls _cortext_process_text_with_media_json_with_options.
  • Introduce and export a new TypeScript Media type and update the Emscripten module typings for the new export.
  • Add unit coverage plus README/CHANGELOG documentation for the new API.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit.test.mjs Extends the fake Emscripten module and adds unit tests asserting correct ABI marshalling and retention validation.
src/types.ts Adds Media type and declares the new C export on CortextEmscriptenModule.
src/index.ts Re-exports the new Media type from the package entrypoint.
src/cortext-wasm.ts Implements processTextWithMedia and adds a helper to write uint32 fields into WASM memory.
README.md Documents the new API and provides a usage example.
CHANGELOG.md Notes the new API addition.
Suppressed comments (1)

src/cortext-wasm.ts:272

  • After introducing the processWithMedia runtime check, call the validated local function reference so this continues to typecheck if _cortext_process_text_with_media_json_with_options is made optional on the module interface.
        this.#readRawJson(
          this.module._cortext_process_text_with_media_json_with_options(
            handle,
            textPtr,
            sourcePtr,
            mediaPtr,
            optionsPtr
          )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types.ts Outdated
Comment thread src/cortext-wasm.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants