Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run typecheck
- run: npm test
- run: npm run build
- name: Verify dist/ artefacts
run: |
test -f dist/index.js
test -f dist/index.d.ts
- name: Upload dist
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 30
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm test
- run: npm run build
- name: Pack tarball
run: npm pack
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
*.tgz
generate_release_notes: true
# Uncomment once NPM_TOKEN secret is configured
# - name: Publish to npm
# run: npm publish --access public
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules/
dist/
*.log
.DS_Store
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,40 +130,49 @@ Older OpenClaw builds may fail to load the plugin or may load it without applyin

## Installation

### Option 1 — ClaWHub (coming soon)
### Option 1 - npm install (recommended)

```bash
openclaw plugins install openclaw-token-cache-optimizer
openclaw gateway restart
```

### Option 2 — Manual
The published npm package ships pre-built JavaScript in `dist/` and works on OpenClaw `2026.4.27` and later (see [Compatibility](#compatibility)).

### Option 2 - Manual install from source

```bash
# Clone into your OpenClaw extensions directory
git clone https://github.com/cloudsigma/openclaw-token-cache-optimizer \
~/.openclaw/extensions/openclaw-token-cache-optimizer

# Restart the gateway to load the plugin
cd ~/.openclaw/extensions/openclaw-token-cache-optimizer
npm install # runs the `prepare` script which builds dist/
openclaw gateway restart
```

That's it. No `openclaw.json` changes are required — the plugin auto-activates for all requests to the `cloudsigma` provider.
`npm install` triggers the `prepare` lifecycle script which compiles TypeScript to `dist/index.js`. OpenClaw `2026.5.x` and later require this compiled output for installed plugins; older gateways will still load it directly.

That's it. No `openclaw.json` changes are required - the plugin auto-activates for all requests to the `cloudsigma` provider.

### Verify it loaded

```bash
openclaw gateway status
openclaw plugins info openclaw-taas-affinity
```

You should see the plugin listed in the startup log:

```
[plugins] openclaw-token-cache-optimizer: loaded
```
You should see `Status: loaded` and the source pointing at `dist/index.js` (or `/index.ts` on legacy gateways).

---

## Compatibility

| OpenClaw gateway | Status | Notes |
|---|---|---|
| >= 2026.5.x | Supported | Loads compiled `dist/index.js` |
| 2026.4.27 - 2026.4.x | Supported | Loads compiled `dist/index.js`; bridge polling endpoints may not exist on the gateway-side TaaS API yet - plugin falls back to advisory-only metadata |
| < 2026.4.27 | Not supported | Hooks the plugin relies on (`wrapStreamFn`, `hookAliases`, `resolveTransportTurnState`) are not exposed |

The plugin is **forward and backward compatible** within this range from a single build artefact: bridge leasing, polling, and result submission all degrade gracefully when the corresponding TaaS endpoints are missing.
## Verification

### Local validation
Expand Down
30 changes: 20 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
{
"name": "openclaw-taas-affinity",
"version": "0.5.0",
"description": "OpenClaw provider plugin \u2014 CloudSigma TaaS session affinity. Injects a stable X-Session-Id header per conversation so TaaS can pin the session to the same OAuth token / Bedrock region / Claude Code node, maximising prompt-cache hit rates.",
"version": "0.5.1",
"description": "OpenClaw provider plugin CloudSigma TaaS session affinity. Injects a stable X-Session-Id header per conversation so TaaS can pin the session to the same OAuth token / Bedrock region / Claude Code node, maximising prompt-cache hit rates.",
"type": "module",
"main": "index.ts",
"main": "dist/index.js",
"openclaw": {
"extensions": [
"./index.ts"
"./dist/index.js"
],
"providers": [
"cloudsigma",
"cloudsigma-staging"
],
"compat": {
"pluginApi": ">=2026.5.24",
"minGatewayVersion": "2026.5.24"
"pluginApi": ">=2026.4.27",
"minGatewayVersion": "2026.4.27"
},
"build": {
"openclawVersion": "2026.5.24",
"pluginSdkVersion": "2026.5.24"
"openclawVersion": "2026.4.27",
"pluginSdkVersion": "2026.4.27"
}
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"prepare": "npm run build",
"prepublishOnly": "npm run build && npm test",
"typecheck": "tsc --noEmit",
"smoke": "node test/smoke.mjs",
"unit": "node --import tsx --test test/*.test.ts",
Expand All @@ -38,12 +41,19 @@
"author": "CloudSigma",
"license": "MIT",
"peerDependencies": {
"openclaw": ">=2026.5.24"
"openclaw": ">=2026.4.27"
},
"devDependencies": {
"@types/node": "^22.0.0",
"openclaw": "^2026.5.18",
"tsx": "^4.20.0",
"typescript": "^5.0.0"
}
},
"types": "dist/index.d.ts",
"files": [
"dist/",
"openclaw.plugin.json",
"README.md",
"LICENSE"
]
}
12 changes: 12 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "dist",
"declaration": true,
"declarationMap": false,
"sourceMap": false,
"removeComments": false
},
"include": ["index.ts"]
}
Loading