Polyweave

@polyweave/tool-adapter (1.0.2)

Published 2026-07-10 22:39:53 +00:00 by Dvorak

Installation

@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/
npm install @polyweave/tool-adapter@1.0.2
"@polyweave/tool-adapter": "1.0.2"

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
Details
npm
2026-07-10 22:39:53 +00:00
332
John Dvorak
SEE LICENSE IN LICENSE
3.8 KiB
Assets (1)
Versions (5) View all
1.0.5 2026-07-17
1.0.6 2026-07-11
1.0.3 2026-07-11
1.0.2 2026-07-10
1.0.1 2026-07-10