@polyweave/tool-adapter (1.0.1)
Published 2026-07-10 19:55:44 +00:00 by Dvorak
Installation
@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/npm install @polyweave/tool-adapter@1.0.1"@polyweave/tool-adapter": "1.0.1"About this package
@polyweave/tool-adapter
Bridges duplex adapter-based tools to the @polyweave/tools callback interface. Wraps tool adapters (source/sink duplexes) as async callbacks consumable by tool routers.
Synopsis
import { wrapToolAdapter, createToolAdapterWrapper } from '@polyweave/tool-adapter';
import { SomeToolDuplex } from '@polyweave/some-tool';
const wrapped = wrapToolAdapter(SomeToolDuplex, { name: 'myTool', timeoutMs: 15000 });
wrapped({ query: 'hello' }, (err, result) => {
console.log(result);
});
Install
npm install @polyweave/tool-adapter
API
wrapToolAdapter(toolAdapter, options)
Wraps a tool adapter duplex as an (args, callback) function. Pipes frames through the duplex, collects results, and calls back on END or ERROR frames.
| Option | Type | Default | Description |
|---|---|---|---|
name |
string | 'unknown' |
Tool name for error messages |
timeoutMs |
number | 30000 |
Timeout before failing |
createToolAdapterWrapper(innerDuplex, options)
Wraps an inner duplex and intercepts TOOL_CALL frames, routing them to registered tool callbacks. Supports both synchronous functions and adapter-based tools.
| Option | Type | Default | Description |
|---|---|---|---|
tools |
object | {} |
Map of tool name to callback or adapter |
toolTimeoutMs |
number | 30000 |
Per-tool timeout |
onToolCall |
function | null | Hook fired on each tool call |
onToolResult |
function | null | Hook fired on each tool result |
mirrorContinue |
boolean | true |
Mirror continue text to wrapper output |
Tests
npm test
Requirements
- Node.js >= 18.0.0
@polyweave/core(peer)
License
MIT
Dependencies
Dependencies
| ID | Version |
|---|---|
| @polyweave/tools | * |
Development Dependencies
| ID | Version |
|---|---|
| @rigor/core | * |
Peer Dependencies
| ID | Version |
|---|---|
| @polyweave/core | * |
Keywords
polyweave
tool-adapter
tool-bridge
push-stream