@okkishops/aireach-cli
v0.1.1
Published
AiReach protected-tool CLI wrapper.
Readme
@okkishops/aireach-cli
AiReach protected-tool CLI wrapper.
This package wraps the okki_ai_reach MCP scene behind a stable CLI boundary:
- validates inputs against packaged scene schemas
- resolves the target gateway environment (
dev/prod) - injects a Bearer token
- calls
tools/callon the JSON-RPC gateway endpoint - prints stable JSON to stdout
Command surface
aireach-cli
├─ background
│ ├─ company-background-check
│ ├─ contacts-fetch
│ └─ contact-validity-check
└─ trade
└─ searchBuild
From the monorepo root:
cd skill-platform
bunx tsc -b packages/aireach-cli/tsconfig.json --pretty falseBuild output:
packages/aireach-cli/dist/- packaged schemas under
packages/aireach-cli/scenes/
One-step distributable release
From the package directory:
cd skill-platform/packages/aireach-cli
npm run bundle:releaseRelease output directory:
dist/release/aireach-cli-<version>/
Included release artifacts:
- npm tarball for portable install
- single-file JS bundle
- current-host native binary
- native target matrix under
native-matrix/ manifest.jsonSHA256SUMSINSTALL.md
This is the recommended command when you need a distributable CLI drop rather than an intermediate build artifact.
Single-file JS bundle
From the package directory:
cd skill-platform/packages/aireach-cli
npm run bundle:single-fileBundle output:
dist/aireach-cli.single.js
Properties verified in this repository:
- preserves the CLI shebang
- runs directly after
chmod +x - resolves schema/help from embedded scenes (
embedded://scenes/...) - can execute a real live gateway request without a sibling
scenes/directory
Single-file native binary
From the package directory:
cd skill-platform/packages/aireach-cli
npm run bundle:nativeNative output:
dist/aireach-cli.native
Properties verified on the current host:
- Bun 1.3.4
--compileproduced a standalone executable - current host artifact is
Mach-O 64-bit executable arm64 - runs directly after copying to a temp directory with no sibling package files
- resolves schema/help from embedded scenes (
embedded://scenes/...) - can execute a real live gateway request as a standalone binary
Go native target matrix
From the package directory:
cd skill-platform/packages/aireach-cli
npm run build:go:matrixDefault verified compile targets on the current host:
darwin-arm64->dist/go/aireach-cli-darwin-arm64darwin-x64->dist/go/aireach-cli-darwin-x64linux-x64->dist/go/aireach-cli-linux-x64linux-arm64->dist/go/aireach-cli-linux-arm64windows-x64->dist/go/aireach-cli-windows-x64.exewindows-ia32->dist/go/aireach-cli-windows-ia32.exe
Manifest output:
dist/go/manifest.json
Override targets with a comma-separated env var:
AIREACH_GO_TARGETS='darwin-arm64,windows-x64,windows-ia32' npm run build:go:matrixNotes:
- Go matrix artifacts are copied into separate platform packages by
npm run build:platforms - the npm
binentry uses a Node launcher atdist/bin/aireach-cli.js, which picks a matching optional platform package when present and falls back todist/index.js - Go release binaries are much smaller than Bun
--compilebinaries and are the preferred npm platform package payload dist/aireach-cli.nativeremains the simplest current-host Bun output when you only need one binary
Platform packages
From the package directory:
cd skill-platform/packages/aireach-cli
npm run build:platformsThis creates platform package directories under:
dist/platform-packages/darwin-arm64/->@okkishops/aireach-cli-darwin-arm64dist/platform-packages/darwin-x64/->@okkishops/aireach-cli-darwin-x64dist/platform-packages/linux-x64/->@okkishops/aireach-cli-linux-x64dist/platform-packages/linux-arm64/->@okkishops/aireach-cli-linux-arm64dist/platform-packages/windows-x64/->@okkishops/aireach-cli-windows-x64dist/platform-packages/windows-ia32/->@okkishops/aireach-cli-windows-ia32
Windows 32-bit is named windows-ia32 because Node reports that architecture as process.arch === "ia32" and npm uses cpu: ["ia32"].
Each platform package declares os and cpu so npm installs only the package matching the user's environment when it is pulled as an optional dependency of @okkishops/aireach-cli.
Pack for distribution
From the package directory:
cd skill-platform/packages/aireach-cli
npm packThis produces a tarball such as:
okkishops-aireach-cli-0.1.0.tgz
The main tarball contains only:
dist/JS fallback and launcher filesscenes/package.jsonREADME.md
It does not contain dist/go/** or dist/native/**; native binaries are distributed through optional platform packages.
Install from tarball
mkdir /tmp/aireach-cli-smoke && cd /tmp/aireach-cli-smoke
npm init -y
npm install /path/to/okkishops-aireach-cli-0.1.0.tgzBinary path after install:
./node_modules/.bin/aireach-cli --helpAuthentication model
aireach-cli implements its own OAuth PAT login flow; social-cli is not required.
Login/status/logout:
aireach-cli auth login
aireach-cli auth status
aireach-cli auth logoutauth login opens the OAuth PAT page, listens on a localhost callback, exchanges the callback delivery code, and writes the PAT to:
~/.okki-agent/social-media/settings.json -> oauth.pat_tokenThe settings format is intentionally compatible with existing local PAT state, but aireach-cli does not execute or depend on social-cli.
Token resolution order for business calls:
--bearer-tokenAIREACH_BEARER_TOKENAIREACH_PAT_TOKENAIREACH_SOCIAL_CLI_PAT_TOKEN--bearer-token-fileAIREACH_BEARER_TOKEN_FILE~/.okki-agent/social-media/settings.json -> oauth.pat_token
Notes:
- PAT and access token are both sent as:
Authorization: Bearer <token>
AIREACH_PAT_TOKENandAIREACH_SOCIAL_CLI_PAT_TOKENcan be used when you want to inject a PAT directly from the environment instead of reading local settingsAIREACH_SETTINGS_PATHcan point auth commands and token loading at a custom settings file;AIREACH_SOCIAL_CLI_SETTINGS_PATHremains as a compatibility aliasAIREACH_GATEWAY_ENV=dev|prodcan force the environment- if
AIREACH_GATEWAY_ENVis not set, the CLI infers env fromAIREACH_JSONRPC_URL .dev.xiaoman.cnresolves todev; everything else defaults toprod
Examples
Help
aireach-cli --help
aireach-cli trade search --helpDry run with flags (trade search)
./node_modules/.bin/aireach-cli trade search \
--keyword chair \
--search-type PRODUCT \
--data-country-code US \
--data-type IMPDAT \
--page 1 \
--size 2 \
--sort-field DATE \
--sort-type DESC \
--dry-runReal trade search with default prod gateway
./node_modules/.bin/aireach-cli trade search \
--keyword chair \
--search-type PRODUCT \
--data-country-code US \
--data-type IMPDAT \
--page 1 \
--size 2 \
--sort-field DATE \
--sort-type DESCReal trade search with explicit dev gateway override
AIREACH_JSONRPC_URL='https://oauth-gateway.dev.xiaoman.cn/mcp/aireach/jsonrpc/accio_work_aireach' \
./node_modules/.bin/aireach-cli trade search \
--keyword chair \
--search-type PRODUCT \
--data-country-code US \
--data-type IMPDAT \
--page 1 \
--size 2 \
--sort-field DATE \
--sort-type DESCReal trade search with JSON input
AIREACH_JSONRPC_URL='https://oauth-gateway.dev.xiaoman.cn/mcp/aireach/jsonrpc/accio_work_aireach' \
./node_modules/.bin/aireach-cli trade search \
--input '{"keyword":"chair","search_type":"PRODUCT","data_country_codes":["US"],"data_type":"IMPDAT","page":1,"size":2,"sort_field":"DATE","sort_type":"DESC"}'Real call with explicit bearer token file
AIREACH_JSONRPC_URL='https://oauth-gateway.dev.xiaoman.cn/mcp/aireach/jsonrpc/accio_work_aireach' \
./node_modules/.bin/aireach-cli trade search \
--bearer-token-file /tmp/openclaw-device-token.json \
--input '{"keyword":"chair","search_type":"PRODUCT","data_country_codes":["US"],"data_type":"IMPDAT","page":1,"size":2,"sort_field":"DATE","sort_type":"DESC"}'Verified status
Verified against the live dev gateway:
trade search✅background contacts-fetch✅background contact-validity-check✅background company-background-check✅ on cache-hit fast pathbackground company-background-checknon-cache slow path reaches real upstream createTask, but current probe hit an upstream timeout inokki_leads_service
Exit semantics
- success: stdout JSON with
success: true - validation / auth / transport failure: stderr JSON with
success: false
Example failure shape:
{
"success": false,
"error": "input schema validation failed: $.operation is required"
}Distribution note
This package now supports three verified shapes:
- npm tarball distribution with a cross-platform Node
binlauncher atdist/bin/aireach-cli.js - self-contained single-file JS bundle at
dist/aireach-cli.single.js - standalone native binary at
dist/aireach-cli.nativeon the current host
Important boundary:
- npm tarballs remain the primary portable package distribution
- the main
@okkishops/aireach-clitarball excludesdist/go/**anddist/native/**and depends on platform native packages viaoptionalDependencies - if a platform package is unavailable or skipped, the launcher falls back to the JS CLI entrypoint at
dist/index.js dist/aireach-cli.single.jsanddist/aireach-cli.nativeare local build artifacts and are excluded from the tarball payloaddist/aireach-cli.nativeis host/architecture-specific, not a universal binary
