kweaver-caller
v0.1.4
Published
A TypeScript CLI tool to call KWeaver.
Readme
kweaver-caller
A TypeScript CLI tool to call KWeaver.
Install
Use Node from .nvmrc, then install globally or run with npx:
nvm use
npm install -g kweaver-callernpx kweaverc --helpAfter global install, the command is available directly:
kweaverc --helpDevelopment
Use nvm to keep the Node version consistent:
nvm use
npm installCommon commands:
npm run dev
npm run build
npm testRun the built CLI locally:
node dist/cli.js --helpAuth
Use nvm use first, then pass only the platform base URL:
npm run build
kweaverc auth https://platform.example.comThe CLI stores auth state per platform under ~/.kweaver/platforms/ and keeps one active platform pointer. If no client is stored for the target platform, it registers one through /oauth2/clients, generates the full /oauth2/auth?... URL, and opens the browser. You complete login and verification manually in the browser.
The CLI also starts a local callback listener on http://127.0.0.1:9010/callback, captures the returned code, exchanges it for tokens, and makes that platform the current one.
You can assign a short alias when saving a platform:
kweaverc auth https://platform.example.com --alias primary
kweaverc auth https://platform2.example.com --alias secondaryInspect or switch saved platforms:
kweaverc auth list
kweaverc auth status
kweaverc auth status dip
kweaverc auth use dipAPI Call
Use the saved token to call APIs with curl-style flags. The CLI auto-injects both Authorization: Bearer ... and token: ....
If the current platform's access_token has expired and a refresh_token is available, kweaverc call automatically requests a new token from /oauth2/token, updates that platform's token file, and then continues the original API call. If refresh fails, run kweaverc auth <platform-url> again.
Print the current access token directly:
kweaverc tokenExample aligned with ref/test_api.js:
kweaverc call 'https://platform.example.com/api/agent-factory/v3/personal-space/agent-list?name=&pagination_marker_str=&publish_status=&publish_to_be=&size=48' -H 'accept: application/json, text/plain, */*' -H 'x-language: zh-CN' -H 'x-requested-with: XMLHttpRequest' -bd bd_public --prettyAdd --verbose to print the final request method, URL, headers, and whether a body was sent. This is useful when checking whether headers such as x-business-domain, authorization, and token were actually attached.
Both call and agent chat accept -bd or --biz-domain. If omitted, the CLI sends x-business-domain: bd_public.
Agent Chat
After kweaverc auth <platform-url>, chat with an agent by passing its agent_id.
Before sending the chat request, the CLI resolves the agent detail through /api/agent-factory/v3/agent-market/agent/{agent_id}/version/{version}?is_visit=true, reads the returned key, and then calls /api/agent-factory/v1/app/{agent_id}/chat/completion.
If you do not pass --version, the CLI uses v0.
Interactive mode starts a REPL and reuses the returned conversation_id automatically:
kweaverc agent chat 01KFT0E68A1RES94ZV6DA131X4
kweaverc agent chat 01KFT0E68A1RES94ZV6DA131X4 --version v2Non-interactive mode sends a single message and exits:
kweaverc agent chat 01KFT0E68A1RES94ZV6DA131X4 -m "你好"Continue an existing conversation by passing --conversation-id or the compatibility aliases used in the reference docs:
kweaverc agent chat 01KFT0E68A1RES94ZV6DA131X4 -m "继续" --conversation-id conv_123
kweaverc agent chat 01KFT0E68A1RES94ZV6DA131X4 -m "继续" -conversation_id conv_123Streaming defaults to on in interactive mode and off in -m mode. Override it with --stream or --no-stream. Use --verbose to print the final request target and request body. Use -bd or --biz-domain to override x-business-domain when needed.
