Skip to content

Commit 284b854

Browse files
rjcloudsigmaRufus Bot
andauthored
chore: ship compiled dist/ + relax compat to 2026.4.27 (#6)
Restructure the plugin for direct deployment under the OpenClaw 2026.5.x plugin loader, which requires compiled JavaScript output for installed plugins. A single build artefact now serves both old and new gateways. Build & packaging - Add tsconfig.build.json that emits to dist/ with declarations. - Add build, prepare, and prepublishOnly scripts so installing from a git URL produces dist/ automatically. - Set main to dist/index.js, types to dist/index.d.ts, and declare files so the published tarball ships only what is needed. - Add dist/ to .gitignore (CI builds and uploads it). Compatibility - Lower openclaw.compat.minGatewayVersion, openclaw.compat.pluginApi, openclaw.build.openclawVersion, openclaw.build.pluginSdkVersion, and peerDependencies.openclaw from 2026.5.24 to 2026.4.27. The provider hooks the plugin relies on (wrapStreamFn, hookAliases, resolveTransportTurnState) have been available since 2026.4.27. The requester-bridge code paths (lease, poll, results) already degrade gracefully when the gateway-side TaaS API does not expose those endpoints, so a single build supports the full range. CI - Add .github/workflows/ci.yml to typecheck, test, and build on PR and push, and to upload dist/ as a workflow artefact on main. - Add .github/workflows/release.yml to pack the tarball on tag and attach it to a GitHub Release. The npm publish step is staged but commented out until an NPM_TOKEN secret is configured. Docs - Rewrite Installation: cover the npm-install path and the from-source path (which now requires running install to trigger prepare). - Add a Compatibility table covering 2026.4.27+ behaviour and what degrades on older builds. Verification - npm run build produces dist/index.js and dist/index.d.ts. - npm test passes (9/9 including the bridge long-polling tests). Bump version to 0.5.1. Co-authored-by: Rufus Bot <rufus-bot@cloudsigma.com>
1 parent df4d4f7 commit 284b854

6 files changed

Lines changed: 123 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: '22'
17+
cache: 'npm'
18+
- run: npm ci
19+
- run: npm run typecheck
20+
- run: npm test
21+
- run: npm run build
22+
- name: Verify dist/ artefacts
23+
run: |
24+
test -f dist/index.js
25+
test -f dist/index.d.ts
26+
- name: Upload dist
27+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: dist
31+
path: dist/
32+
retention-days: 30

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: '22'
19+
cache: 'npm'
20+
registry-url: 'https://registry.npmjs.org'
21+
- run: npm ci
22+
- run: npm test
23+
- run: npm run build
24+
- name: Pack tarball
25+
run: npm pack
26+
- name: Create GitHub Release
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
files: |
30+
*.tgz
31+
generate_release_notes: true
32+
# Uncomment once NPM_TOKEN secret is configured
33+
# - name: Publish to npm
34+
# run: npm publish --access public
35+
# env:
36+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
node_modules/
2+
dist/
3+
*.log
4+
.DS_Store

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,40 +130,49 @@ Older OpenClaw builds may fail to load the plugin or may load it without applyin
130130

131131
## Installation
132132

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

135135
```bash
136136
openclaw plugins install openclaw-token-cache-optimizer
137137
openclaw gateway restart
138138
```
139139

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

142144
```bash
143-
# Clone into your OpenClaw extensions directory
144145
git clone https://github.com/cloudsigma/openclaw-token-cache-optimizer \
145146
~/.openclaw/extensions/openclaw-token-cache-optimizer
146-
147-
# Restart the gateway to load the plugin
147+
cd ~/.openclaw/extensions/openclaw-token-cache-optimizer
148+
npm install # runs the `prepare` script which builds dist/
148149
openclaw gateway restart
149150
```
150151

151-
That's it. No `openclaw.json` changes are required — the plugin auto-activates for all requests to the `cloudsigma` provider.
152+
`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.
153+
154+
That's it. No `openclaw.json` changes are required - the plugin auto-activates for all requests to the `cloudsigma` provider.
152155

153156
### Verify it loaded
154157

155158
```bash
156159
openclaw gateway status
160+
openclaw plugins info openclaw-taas-affinity
157161
```
158162

159-
You should see the plugin listed in the startup log:
160-
161-
```
162-
[plugins] openclaw-token-cache-optimizer: loaded
163-
```
163+
You should see `Status: loaded` and the source pointing at `dist/index.js` (or `/index.ts` on legacy gateways).
164164

165165
---
166166

167+
## Compatibility
168+
169+
| OpenClaw gateway | Status | Notes |
170+
|---|---|---|
171+
| >= 2026.5.x | Supported | Loads compiled `dist/index.js` |
172+
| 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 |
173+
| < 2026.4.27 | Not supported | Hooks the plugin relies on (`wrapStreamFn`, `hookAliases`, `resolveTransportTurnState`) are not exposed |
174+
175+
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.
167176
## Verification
168177

169178
### Local validation

package.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
{
22
"name": "openclaw-taas-affinity",
3-
"version": "0.5.0",
4-
"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.",
3+
"version": "0.5.1",
4+
"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.",
55
"type": "module",
6-
"main": "index.ts",
6+
"main": "dist/index.js",
77
"openclaw": {
88
"extensions": [
9-
"./index.ts"
9+
"./dist/index.js"
1010
],
1111
"providers": [
1212
"cloudsigma",
1313
"cloudsigma-staging"
1414
],
1515
"compat": {
16-
"pluginApi": ">=2026.5.24",
17-
"minGatewayVersion": "2026.5.24"
16+
"pluginApi": ">=2026.4.27",
17+
"minGatewayVersion": "2026.4.27"
1818
},
1919
"build": {
20-
"openclawVersion": "2026.5.24",
21-
"pluginSdkVersion": "2026.5.24"
20+
"openclawVersion": "2026.4.27",
21+
"pluginSdkVersion": "2026.4.27"
2222
}
2323
},
2424
"scripts": {
25+
"build": "tsc -p tsconfig.build.json",
26+
"prepare": "npm run build",
27+
"prepublishOnly": "npm run build && npm test",
2528
"typecheck": "tsc --noEmit",
2629
"smoke": "node test/smoke.mjs",
2730
"unit": "node --import tsx --test test/*.test.ts",
@@ -38,12 +41,19 @@
3841
"author": "CloudSigma",
3942
"license": "MIT",
4043
"peerDependencies": {
41-
"openclaw": ">=2026.5.24"
44+
"openclaw": ">=2026.4.27"
4245
},
4346
"devDependencies": {
4447
"@types/node": "^22.0.0",
4548
"openclaw": "^2026.5.18",
4649
"tsx": "^4.20.0",
4750
"typescript": "^5.0.0"
48-
}
51+
},
52+
"types": "dist/index.d.ts",
53+
"files": [
54+
"dist/",
55+
"openclaw.plugin.json",
56+
"README.md",
57+
"LICENSE"
58+
]
4959
}

tsconfig.build.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"outDir": "dist",
6+
"declaration": true,
7+
"declarationMap": false,
8+
"sourceMap": false,
9+
"removeComments": false
10+
},
11+
"include": ["index.ts"]
12+
}

0 commit comments

Comments
 (0)