@tibame201020/queqiao-http 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +181 -27
  2. package/README.zh-TW.md +202 -0
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -1,48 +1,202 @@
1
- # Queqiao HTTP
1
+ # @tibame201020/queqiao-http
2
2
 
3
- Bounded outbound HTTP extension for [Queqiao](https://github.com/tibame201020/Queqiao).
3
+ [English](https://github.com/tibame201020/queqiao-http/blob/main/README.md) | [繁體中文](https://github.com/tibame201020/queqiao-http/blob/main/README.zh-TW.md)
4
4
 
5
- It exposes one Worker-hosted capability, `http_request`, through Queqiao's stable `extension` proxy. It uses `context.runtime.http.request()`; it does not invoke `curl`, a shell, `child_process`, or unrestricted global `fetch`.
5
+ Official bounded HTTP extension for [Queqiao](https://github.com/tibame201020/Queqiao).
6
6
 
7
- ## MVP scope
7
+ `@tibame201020/queqiao-http` lets a Queqiao Worker call explicitly authorized HTTP/HTTPS origins through Queqiao's managed Extension runtime. It exposes one capability, `http_request`, through Queqiao's stable public `extension` proxy instead of adding a new public connector tool.
8
8
 
9
- Allowed origins are intentionally fixed in the extension manifest:
9
+ It uses `context.runtime.http.request()` directly. It does **not** invoke `curl`, a shell, `child_process`, or unrestricted global `fetch`.
10
10
 
11
- - `http://127.0.0.1:9889`
12
- - `http://localhost:9889`
11
+ ## Status
13
12
 
14
- Requests to other origins are rejected by Queqiao's Worker runtime with `extension_network_denied`. Redirects, request/response bounds, cancellation, and timeout behavior remain owned by Queqiao.
13
+ v0.1 baseline for Queqiao 0.9.7. The canonical npm package is `@tibame201020/queqiao-http`. Starting with v0.1.1, releases are published automatically from GitHub Releases through npm Trusted Publishing with provenance.
15
14
 
16
- ## Install locally
15
+ The current v0.1 runtime policy is intentionally narrow and has been validated end-to-end against the local Personal Asset Manager API on port `9889`.
17
16
 
18
- ```powershell
19
- npm install
20
- npm run check
21
- queqiao extension install . --worker <worker-name>
17
+ Verified acceptance chain:
18
+
19
+ ```text
20
+ MCP client / LLM
21
+ → Queqiao Gateway
22
+ → Queqiao Worker
23
+ → stable extension proxy
24
+ → queqiao-http
25
+ → Queqiao managed HTTP runtime
26
+ → authorized REST API
27
+ ```
28
+
29
+ Verified behavior includes:
30
+
31
+ - successful JSON GET requests;
32
+ - automatic JSON response parsing;
33
+ - backend HTTP 4xx responses preserved as normal HTTP responses;
34
+ - unauthorized origins rejected with `extension_network_denied`;
35
+ - no public Queqiao connector manifest expansion when the extension is installed or updated.
36
+
37
+ ## Install
38
+
39
+ Install from npm and attach to every Worker:
40
+
41
+ ```bash
42
+ queqiao extension install npm:@tibame201020/queqiao-http --attach-all
43
+ ```
44
+
45
+ Or install into the Extension Hub first and attach a selected Worker later:
46
+
47
+ ```bash
48
+ queqiao extension install npm:@tibame201020/queqiao-http
49
+ queqiao extension attach dev.queqiao.http --worker windows
22
50
  ```
23
51
 
52
+ `attach` is activation. There is no separate enable/disable state.
53
+
54
+ Because Queqiao exposes extensions through the stable public `extension` proxy, installing or updating `queqiao-http` does not require rebuilding the ChatGPT / MCP connector manifest.
55
+
56
+ ## Allowed origins
57
+
58
+ The v0.1 package deliberately grants only these exact origins:
59
+
60
+ ```text
61
+ http://127.0.0.1:9889
62
+ http://localhost:9889
63
+ ```
64
+
65
+ Requests to any other origin are rejected by the Queqiao Worker runtime.
66
+
67
+ This means v0.1 is a bounded HTTP extension for the current local service integration, **not** an unrestricted arbitrary-internet HTTP client. A future configurable-origin design should extend Queqiao's deployment/runtime grant model rather than bypassing it inside this extension.
68
+
24
69
  ## Capability
25
70
 
26
- `http_request` accepts:
71
+ `queqiao-http` registers one capability:
27
72
 
28
- - `workspaceId`
29
- - `url`
30
- - `method`: `GET | POST | PUT | PATCH | DELETE | HEAD` (default `GET`)
31
- - `headers` (optional)
32
- - `body` or `json` (mutually exclusive)
33
- - `timeoutMs` (100-120000, default 30000)
73
+ ```text
74
+ http_request
75
+ ```
34
76
 
35
- When `json` is supplied, it is serialized and `content-type: application/json` is added unless already present. JSON responses are returned with both the raw `body` and a parsed `json` field when parsing succeeds. Non-2xx HTTP responses are returned as responses rather than converted into transport errors.
77
+ Input fields:
78
+
79
+ - `workspaceId` — selected Queqiao Workspace;
80
+ - `url` — full HTTP/HTTPS URL under an allowed origin;
81
+ - `method` — `GET | POST | PUT | PATCH | DELETE | HEAD`, default `GET`;
82
+ - `headers` — optional string header map;
83
+ - `body` — optional raw string body;
84
+ - `json` — optional JSON value, mutually exclusive with `body`;
85
+ - `timeoutMs` — `100` to `120000`, default `30000`.
86
+
87
+ When `json` is supplied, the extension serializes it and adds `content-type: application/json` unless the caller already supplied a Content-Type header.
88
+
89
+ ### Call through Queqiao's extension proxy
90
+
91
+ A client using Queqiao's stable public `extension` tool can invoke the capability like this:
92
+
93
+ ```json
94
+ {
95
+ "workspaceId": "codes",
96
+ "operation": "call",
97
+ "extensionId": "dev.queqiao.http",
98
+ "capability": "http_request",
99
+ "arguments": {
100
+ "url": "http://127.0.0.1:9889/api/meal/types",
101
+ "method": "GET"
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### JSON POST
107
+
108
+ ```json
109
+ {
110
+ "workspaceId": "codes",
111
+ "operation": "call",
112
+ "extensionId": "dev.queqiao.http",
113
+ "capability": "http_request",
114
+ "arguments": {
115
+ "url": "http://127.0.0.1:9889/api/trans/save",
116
+ "method": "POST",
117
+ "json": {
118
+ "type": "支出",
119
+ "category": "食",
120
+ "name": "牛肉麵",
121
+ "value": 180,
122
+ "transDate": "2026-09-07T00:00:00"
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ ## Response contract
129
+
130
+ Successful transport execution returns the downstream HTTP response without converting non-2xx status codes into transport failures:
131
+
132
+ ```json
133
+ {
134
+ "status": 200,
135
+ "headers": {
136
+ "content-type": "application/json"
137
+ },
138
+ "body": "{\"ok\":true}",
139
+ "json": {
140
+ "ok": true
141
+ }
142
+ }
143
+ ```
144
+
145
+ `json` is included only when the response body can be parsed as JSON. `body` always preserves the raw response text.
146
+
147
+ For example, an application-level `HTTP 400` validation response remains a response with `status: 400`. Runtime policy failures such as a denied origin remain Queqiao runtime errors instead.
148
+
149
+ ## Trust boundary
150
+
151
+ Queqiao extensions are trusted plugin code. Installing and attaching `queqiao-http` grants this extension authority to issue requests only through the managed Worker HTTP surface declared by its manifest.
152
+
153
+ Queqiao remains authoritative for:
154
+
155
+ - explicit package install/attach intent;
156
+ - Extension contract validation;
157
+ - exact-origin authorization;
158
+ - HTTP/HTTPS scheme validation;
159
+ - redirect denial;
160
+ - request/response bounds;
161
+ - timeout and cancellation handling;
162
+ - Gateway → Worker routing and ExtensionHost lifecycle.
163
+
164
+ `queqiao-http` owns only the request-level adapter behavior: validating its input, serializing optional JSON, calling `context.runtime.http.request()`, and normalizing the returned response.
165
+
166
+ The extension intentionally has:
167
+
168
+ ```text
169
+ process allowlist: empty
170
+ shell access: none
171
+ curl execution: none
172
+ child_process: none
173
+ unrestricted global fetch: none
174
+ ```
36
175
 
37
176
  ## Development
38
177
 
39
- ```powershell
40
- npm test
41
- npm run typecheck
42
- npm run build
178
+ ```bash
179
+ npm ci
43
180
  npm run check
181
+ npm pack --ignore-scripts --dry-run
182
+ ```
183
+
184
+ The test suite covers request mapping, JSON serialization/parsing, body/JSON exclusivity, non-2xx preservation, runtime error propagation, manifest/schema parity, bilingual package documentation, and release workflow invariants.
185
+
186
+ ## Releasing
187
+
188
+ Releases are tag-driven after the initial npm bootstrap:
189
+
190
+ ```text
191
+ main CI passes
192
+ → tag v<package-version>
193
+ → publish matching GitHub Release
194
+ → Publish npm workflow
195
+ → npm Trusted Publishing + provenance
44
196
  ```
45
197
 
46
- ## Publishing
198
+ See [`docs/releasing.md`](docs/releasing.md).
199
+
200
+ ## License
47
201
 
48
- GitHub Releases publish matching `v<version>` tags to npm through OIDC trusted publishing. See [`docs/releasing.md`](docs/releasing.md) for the one-time bootstrap and trusted-publisher setup.
202
+ MIT
@@ -0,0 +1,202 @@
1
+ # @tibame201020/queqiao-http
2
+
3
+ [English](https://github.com/tibame201020/queqiao-http/blob/main/README.md) | [繁體中文](https://github.com/tibame201020/queqiao-http/blob/main/README.zh-TW.md)
4
+
5
+ [Queqiao](https://github.com/tibame201020/Queqiao) 的官方 bounded HTTP extension。
6
+
7
+ `@tibame201020/queqiao-http` 讓 Queqiao Worker 能透過 Queqiao 管理的 Extension runtime,呼叫 manifest 明確授權的 HTTP/HTTPS origin。它只註冊一個 `http_request` capability,並透過 Queqiao 穩定的公開 `extension` proxy 使用,而不是為 HTTP 能力新增一個固定的 public connector tool。
8
+
9
+ 底層直接使用 `context.runtime.http.request()`;**不會**執行 `curl`、shell、`child_process`,也不使用 unrestricted global `fetch`。
10
+
11
+ ## 狀態
12
+
13
+ v0.1 baseline 對應 Queqiao 0.9.7。Canonical npm package 為 `@tibame201020/queqiao-http`。自 v0.1.1 起,release 會在 GitHub Release 發布後,透過 npm Trusted Publishing + provenance 自動發布。
14
+
15
+ 目前 v0.1 runtime policy 刻意維持狹窄,並已對本機 `9889` port 的 Personal Asset Manager API 完成端到端驗證。
16
+
17
+ 已驗證的 acceptance chain:
18
+
19
+ ```text
20
+ MCP client / LLM
21
+ → Queqiao Gateway
22
+ → Queqiao Worker
23
+ → stable extension proxy
24
+ → queqiao-http
25
+ → Queqiao managed HTTP runtime
26
+ → authorized REST API
27
+ ```
28
+
29
+ 已驗證行為包括:
30
+
31
+ - JSON GET request 成功;
32
+ - JSON response 自動解析;
33
+ - backend HTTP 4xx 保留為正常 HTTP response;
34
+ - 未授權 origin 會被 `extension_network_denied` 拒絕;
35
+ - 安裝或更新 extension 不會擴張 Queqiao 公開 connector manifest。
36
+
37
+ ## 安裝
38
+
39
+ 從 npm 安裝並 attach 到所有 Worker:
40
+
41
+ ```bash
42
+ queqiao extension install npm:@tibame201020/queqiao-http --attach-all
43
+ ```
44
+
45
+ 或先安裝到 Extension Hub,再 attach 到指定 Worker:
46
+
47
+ ```bash
48
+ queqiao extension install npm:@tibame201020/queqiao-http
49
+ queqiao extension attach dev.queqiao.http --worker windows
50
+ ```
51
+
52
+ `attach` 即為 activation,沒有另外的 enable/disable 狀態。
53
+
54
+ 因為 Queqiao 使用固定的公開 `extension` proxy 暴露 extension,安裝或更新 `queqiao-http` 不需要重建 ChatGPT / MCP connector manifest。
55
+
56
+ ## 允許的 origins
57
+
58
+ v0.1 package 只明確授權以下 exact origins:
59
+
60
+ ```text
61
+ http://127.0.0.1:9889
62
+ http://localhost:9889
63
+ ```
64
+
65
+ 任何其他 origin 都會由 Queqiao Worker runtime 拒絕。
66
+
67
+ 因此 v0.1 是針對目前本機服務整合的 bounded HTTP extension,**不是** unrestricted arbitrary-internet HTTP client。未來若要支援可配置 origin,應擴充 Queqiao 的 deployment/runtime grant model,而不是在 extension 內繞過安全邊界。
68
+
69
+ ## Capability
70
+
71
+ `queqiao-http` 只註冊一個 capability:
72
+
73
+ ```text
74
+ http_request
75
+ ```
76
+
77
+ 輸入欄位:
78
+
79
+ - `workspaceId` — 選定的 Queqiao Workspace;
80
+ - `url` — 位於允許 origin 下的完整 HTTP/HTTPS URL;
81
+ - `method` — `GET | POST | PUT | PATCH | DELETE | HEAD`,預設 `GET`;
82
+ - `headers` — optional string header map;
83
+ - `body` — optional raw string body;
84
+ - `json` — optional JSON value,與 `body` 互斥;
85
+ - `timeoutMs` — `100` 到 `120000`,預設 `30000`。
86
+
87
+ 提供 `json` 時,extension 會自動 serialize,且在 caller 未提供 Content-Type 時補上 `content-type: application/json`。
88
+
89
+ ### 透過 Queqiao extension proxy 呼叫
90
+
91
+ 使用 Queqiao 穩定公開 `extension` tool 的 client,可以這樣呼叫:
92
+
93
+ ```json
94
+ {
95
+ "workspaceId": "codes",
96
+ "operation": "call",
97
+ "extensionId": "dev.queqiao.http",
98
+ "capability": "http_request",
99
+ "arguments": {
100
+ "url": "http://127.0.0.1:9889/api/meal/types",
101
+ "method": "GET"
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### JSON POST
107
+
108
+ ```json
109
+ {
110
+ "workspaceId": "codes",
111
+ "operation": "call",
112
+ "extensionId": "dev.queqiao.http",
113
+ "capability": "http_request",
114
+ "arguments": {
115
+ "url": "http://127.0.0.1:9889/api/trans/save",
116
+ "method": "POST",
117
+ "json": {
118
+ "type": "支出",
119
+ "category": "食",
120
+ "name": "牛肉麵",
121
+ "value": 180,
122
+ "transDate": "2026-09-07T00:00:00"
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ ## Response contract
129
+
130
+ Transport 成功執行後會回傳 downstream HTTP response;非 2xx status 不會被轉成 transport failure:
131
+
132
+ ```json
133
+ {
134
+ "status": 200,
135
+ "headers": {
136
+ "content-type": "application/json"
137
+ },
138
+ "body": "{\"ok\":true}",
139
+ "json": {
140
+ "ok": true
141
+ }
142
+ }
143
+ ```
144
+
145
+ 只有 response body 可成功 parse 為 JSON 時才會提供 `json`;`body` 永遠保留原始 response text。
146
+
147
+ 例如 application validation 的 `HTTP 400` 仍會以 `status: 400` response 回傳。相對地,origin 未授權這類 runtime policy failure,會維持 Queqiao runtime error。
148
+
149
+ ## 信任邊界
150
+
151
+ Queqiao extension 屬於 trusted plugin code。安裝並 attach `queqiao-http`,代表允許 extension 在自己的 manifest runtime policy 範圍內,透過 Worker managed HTTP surface 發出 request。
152
+
153
+ Queqiao 仍負責:
154
+
155
+ - 明確的 package install/attach intent;
156
+ - Extension contract validation;
157
+ - exact-origin authorization;
158
+ - HTTP/HTTPS scheme validation;
159
+ - redirect denial;
160
+ - request/response bounds;
161
+ - timeout 與 cancellation;
162
+ - Gateway → Worker routing 與 ExtensionHost lifecycle。
163
+
164
+ `queqiao-http` 只負責 request-level adapter:驗證 input、serialize optional JSON、呼叫 `context.runtime.http.request()`,以及 normalize response。
165
+
166
+ Extension 刻意不具備:
167
+
168
+ ```text
169
+ process allowlist: empty
170
+ shell access: none
171
+ curl execution: none
172
+ child_process: none
173
+ unrestricted global fetch: none
174
+ ```
175
+
176
+ ## 開發
177
+
178
+ ```bash
179
+ npm ci
180
+ npm run check
181
+ npm pack --ignore-scripts --dry-run
182
+ ```
183
+
184
+ Test suite 會驗證 request mapping、JSON serialization/parsing、body/JSON 互斥、non-2xx preservation、runtime error propagation、manifest/schema parity、中英文 package documentation,以及 release workflow invariants。
185
+
186
+ ## 發布
187
+
188
+ 首次 npm bootstrap 完成後,release 採 tag-driven:
189
+
190
+ ```text
191
+ main CI passes
192
+ → tag v<package-version>
193
+ → publish matching GitHub Release
194
+ → Publish npm workflow
195
+ → npm Trusted Publishing + provenance
196
+ ```
197
+
198
+ 另見 [`docs/releasing.md`](docs/releasing.md)。
199
+
200
+ ## 授權
201
+
202
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tibame201020/queqiao-http",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Bounded outbound HTTP extension for Queqiao",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,6 +15,7 @@
15
15
  "files": [
16
16
  "dist/",
17
17
  "README.md",
18
+ "README.zh-TW.md",
18
19
  "LICENSE"
19
20
  ],
20
21
  "scripts": {
@@ -42,7 +43,7 @@
42
43
  "module": "./dist/index.js",
43
44
  "manifest": {
44
45
  "id": "dev.queqiao.http",
45
- "version": "0.1.1",
46
+ "version": "0.1.2",
46
47
  "displayName": "Queqiao HTTP",
47
48
  "host": {
48
49
  "kind": "worker"