Skip to content

feat: patchwork-worker library for connecting to generic workers - #69

Merged
chee merged 7 commits into
mainfrom
grjte/iso-llm-1
Oct 5, 2026
Merged

chee merged 7 commits into
mainfrom
grjte/iso-llm-1

Conversation

@grjte

@grjte grjte commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

This creates a library for creating and connecting to workers by passing a transferable stream pair (readable, writable) to consumers that want to connect to the worker.

The motivation for this library is to enable packages inside of an iframe or isolated zone to connect to a worker that is initiated from the host. For example, when using chat from inside isolation, running the llm requires a worker which isn't powerful enough if initiated with an iframe context (e.g. for local llm it can't download the model or run it). Instead, it can request a worker running in the host and then get a stream pair to use for communication.

The rest of the architecture for the example llm case is separate from this library

@patchcrow

patchcrow commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Patchwork glance ready

https://patchwork-preview-69--patchwork-base.netlify.app

Patchwork from inkandswitch/patchwork.inkandswitch.com, packages from this PR at 3e02807.

build-info.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Connection lifecycle races, leaked request state, and swallowed transport failures can reject new requests or leave them hanging.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 3 Medium severity · 2 Low severity

Open (5)
What changed in this PR

Introduces a standalone worker transport library for host-realm workers accessed through transferable streams.

Changes:

  • Adds worker discovery, sessions, typed clients, and serving.
  • Adds lifecycle, multiplexing, abort, and failure tests.
  • Adds package configuration, declarations, and documentation.
File Description
.gitignore Excludes generated artifacts.
README.md Documents architecture and APIs.
client.js Resolves typed worker clients.
client.test.js Tests client resolution.
connect.js Implements provider discovery.
connect.test.js Tests connections and sessions.
index.js Exposes public API.
package.json Defines package metadata and exports.
pnpm-lock.yaml Locks dependencies.
pnpm-workspace.yaml Configures pnpm.
serve.js Implements host worker transport.
serve.test.js Tests serving and teardown.
session.js Implements multiplexed sessions.
tsconfig.json Configures declaration generation.
types/​client.d.ts Declares client API.
types/​connect.d.ts Declares connection API.
types/​index.d.ts Declares package exports.
types/​serve.d.ts Declares serving API.
types/​session.d.ts Declares session API.
vitest.config.ts Configures tests.
Files not reviewed (1)
  • libraries/patchwork-worker/pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libraries/patchwork-worker/README.md
Comment thread libraries/patchwork-worker/serve.js Outdated
Comment thread libraries/patchwork-worker/session.js Outdated
Comment thread libraries/patchwork-worker/README.md Outdated
Comment thread libraries/patchwork-worker/connect.js Outdated
Comment thread libraries/patchwork-worker/client.js Outdated
Comment thread libraries/patchwork-worker/package.json Outdated
Copilot AI requested a review from chee October 1, 2026 23:40
@chee
chee force-pushed the grjte/iso-llm-1 branch 2 times, most recently from d34e20e to f5df967 Compare October 1, 2026 23:45
grjte and others added 7 commits October 5, 2026 11:56
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: chee <178266+chee@users.noreply.github.com>
Clarified documentation regarding service integrations and removed specific example.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@chee
chee force-pushed the grjte/iso-llm-1 branch from 08bfceb to 3e02807 Compare October 5, 2026 10:56
@chee
chee merged commit d0551e6 into main Oct 5, 2026
3 checks passed
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.

5 participants