aki-pro-max 2.3.3

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 (83) hide show
  1. package/.env.example +34 -0
  2. package/AICOWORKER-NATIVE-TOOLS.md +60 -0
  3. package/CLAUDE-LIVE-TOOLS-EVIDENCE.json +94 -0
  4. package/FULL-TRACE-EVIDENCE.json +109 -0
  5. package/ISSUE-1-REMOTE.json +1 -0
  6. package/ISSUE-2-POSTREVIEW.json +1 -0
  7. package/ISSUE-2-REMOTE.json +1 -0
  8. package/KEY-ROTATION-EVIDENCE.json +9 -0
  9. package/LICENSE +21 -0
  10. package/PMN-9ROUTER-FINAL.md +13 -0
  11. package/RAPID-BASIL-RECONCILIATION.json +10 -0
  12. package/README.md +232 -0
  13. package/RELEASE-ARCHIVE.json +15 -0
  14. package/SECURITY-RECONCILIATION.json +30 -0
  15. package/SECURITY.md +16 -0
  16. package/TEST-ISSUES12-FINAL.txt +0 -0
  17. package/TEST-ISSUES12-HARNESS.txt +0 -0
  18. package/VERIFICATION-REPORT.md +58 -0
  19. package/VERIFIER-ISSUES12-FINAL.txt +0 -0
  20. package/VERIFY-RELEASE-ISSUES12-FINAL.txt +0 -0
  21. package/VERIFY-RELEASE-ISSUES12-HARNESS.txt +0 -0
  22. package/bin/aki-pro-max.js +98 -0
  23. package/docs/ADMIN-GUI-CONTRACT.md +29 -0
  24. package/docs/ARCHITECTURE.md +109 -0
  25. package/docs/CAPABILITY-MATRIX.md +44 -0
  26. package/docs/CORRELATION-DESIGN.md +226 -0
  27. package/docs/FAIL-CLOSED-ISSUE-HARNESS.md +21 -0
  28. package/docs/WEB-SESSION-TRANSPORT-DESIGN.md +423 -0
  29. package/docs/assets/control-plane.jpg +0 -0
  30. package/gitleaks-report-all.json +1 -0
  31. package/gitleaks-report-latest.json +1 -0
  32. package/gitleaks-report.json +1 -0
  33. package/package.json +33 -0
  34. package/scripts/eventual-tool-loop.mjs +55 -0
  35. package/scripts/install-local.ps1 +35 -0
  36. package/scripts/live-eventual-multitool.mjs +18 -0
  37. package/scripts/upgrade-admin-v232.mjs +33 -0
  38. package/scripts/verify-issue-closure.mjs +81 -0
  39. package/scripts/verify-release.mjs +31 -0
  40. package/src/admin-auth.mjs +94 -0
  41. package/src/admin.mjs +133 -0
  42. package/src/canonical.mjs +23 -0
  43. package/src/config.mjs +88 -0
  44. package/src/correlation-store.mjs +120 -0
  45. package/src/errors.mjs +18 -0
  46. package/src/index.mjs +4 -0
  47. package/src/openai-response.mjs +72 -0
  48. package/src/openai.mjs +104 -0
  49. package/src/postman-events.mjs +43 -0
  50. package/src/postman-request.mjs +49 -0
  51. package/src/schema.mjs +35 -0
  52. package/src/server.mjs +73 -0
  53. package/src/session-store.mjs +48 -0
  54. package/src/sse.mjs +13 -0
  55. package/src/transport.mjs +90 -0
  56. package/src/web-session-events.mjs +358 -0
  57. package/src/web-session-request.mjs +280 -0
  58. package/test/9router-executor.integration.test.mjs +207 -0
  59. package/test/admin-auth.test.mjs +47 -0
  60. package/test/admin.test.mjs +68 -0
  61. package/test/config.test.mjs +14 -0
  62. package/test/contract.test.mjs +14 -0
  63. package/test/correlation-store.test.mjs +19 -0
  64. package/test/correlation.integration.test.mjs +48 -0
  65. package/test/eventual-tool-loop.test.mjs +42 -0
  66. package/test/fixtures/text.json +8 -0
  67. package/test/fixtures/tool.json +7 -0
  68. package/test/fixtures/web-session-observed-done.json +12 -0
  69. package/test/fixtures/web-session-tool-fragments.json +14 -0
  70. package/test/full-ingress/alias-loader.mjs +22 -0
  71. package/test/full-ingress/run-full-ingress.mjs +207 -0
  72. package/test/full-ingress/seed-9router.mjs +36 -0
  73. package/test/helpers.mjs +9 -0
  74. package/test/issue-closure-harness.test.mjs +49 -0
  75. package/test/model-thinking.test.mjs +20 -0
  76. package/test/protocol.test.mjs +16 -0
  77. package/test/request.test.mjs +10 -0
  78. package/test/session-store.test.mjs +20 -0
  79. package/test/web-session-builder.test.mjs +124 -0
  80. package/test/web-session-events.test.mjs +241 -0
  81. package/test/web-session-integration.test.mjs +103 -0
  82. package/test/web-session-tools.test.mjs +52 -0
  83. package/version.json +8 -0
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ <div align="center">
2
+
3
+ <img src="docs/assets/control-plane.jpg" alt="Aki Pro Max Local Control Plane" width="900" />
4
+
5
+ # ⚡ Aki Pro Max
6
+
7
+ ### High-Performance OpenAI-Compatible Local Facade & Gateway for Postman Agent Mode
8
+
9
+ [![Release](https://img.shields.io/badge/release-v2.3.2-f97316)](https://github.com/khangtudo/aki-pro-max/releases)
10
+ [![Tests](https://img.shields.io/badge/tests-109%2F109%20passing-22c55e)](#-verified-capabilities)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
12
+ [![Node](https://img.shields.io/badge/Node-%3E%3D22.15-339933?logo=node.js&logoColor=white)](package.json)
13
+ [![CLI](https://img.shields.io/badge/CLI-npx%20aki--pro--max-blue?logo=npm&logoColor=white)](#-1-line-quick-deploy-npx--npm)
14
+
15
+ **Unified Local Inference Gateway · Eight Public Model Aliases · Adaptive Context Ingress (>100KB) · Native Tool Calling & Session Continuity**
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## 🌟 Overview (Omniroute Style)
22
+
23
+ **Aki Pro Max** is a resilient, local-first gateway that bridges **closed web-session AI capabilities** (such as Postman Agent Mode) into a standardized **OpenAI Chat Completions API** (`/v1/chat/completions`). It enables autonomous AI agents (OpenClaw, AICoworker, Cursor, Cline, 9router, Continue) to tap into premier reasoning models (`GPT-5.6 Sol`, `Claude Opus 4.8`, `GPT-5.6 Terra`) seamlessly on local machines or remote VPS servers.
24
+
25
+ ### 📐 Motion & Data Flow Architecture
26
+
27
+ ```mermaid
28
+ flowchart TD
29
+ subgraph Clients ["Autonomous Clients & Agents"]
30
+ OC["AICoworker / OpenClaw"]
31
+ CR["Cursor / Cline / IDEs"]
32
+ NR["9router / LiteLLM Gateway"]
33
+ end
34
+
35
+ subgraph Facade ["Aki Pro Max Facade Engine (:8788)"]
36
+ IG["Ingress Guard & Body Reader\n(100MB Capacity)"]
37
+ ACI["Adaptive Context Ingress Engine\n(Head 100KB + Tail 200KB)"]
38
+ SCH["Recursive JSON Schema Validator\n(patternProperties enabled)"]
39
+ TRC["Tool Continuation & Role Normalizer\n(toolResult -> conversational turns)"]
40
+ SSM["Stateful Session Store\n(x-session-id -> conversationId)"]
41
+ end
42
+
43
+ subgraph Upstream ["Postman Agent Mode Cloud"]
44
+ GW["Postman Cloud Gateway\n(gateway.postman.com / _gw/chat)"]
45
+ BRK["AWS Bedrock / Azure / Anthropic Upstream"]
46
+ end
47
+
48
+ OC -->|Chat Request: System + Tools >90KB| NR
49
+ CR -->|OpenAI standard request| IG
50
+ NR -->|Forward to PMN endpoint| IG
51
+
52
+ IG -->|Payload bytes >6000| ACI
53
+ ACI -->|Virtual File: selectedContext >400KB| GW
54
+ ACI -->|Active Query turn <=4000 bytes| GW
55
+
56
+ IG -->|Validate Function Parameters| SCH
57
+ SCH --> TRC
58
+ TRC -->|Correlate toolResponses| SSM
59
+ SSM -->|HTTPS Streamable EventStream| GW
60
+
61
+ GW --> BRK
62
+ BRK -->|SSE Chunks: textChunk, toolCallChunk| Facade
63
+ Facade -->|OpenAI Stream Response / tool_calls| Clients
64
+
65
+ style Facade fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#f8fafc
66
+ style Clients fill:#1e293b,stroke:#94a3b8,stroke-width:1px,color:#f8fafc
67
+ style Upstream fill:#1e1b4b,stroke:#818cf8,stroke-width:1px,color:#f8fafc
68
+ ```
69
+
70
+ ---
71
+
72
+ ## ⚡ 1-Line Quick Deploy (NPX / NPM)
73
+
74
+ Deploy instantly on any personal computer or remote Linux VPS without manual Git cloning:
75
+
76
+ ### Option 1: Instant Launch with NPX
77
+ ```bash
78
+ # Set your authenticated Postman session cookie and start
79
+ export POSTMAN_SESSION_COOKIE="c936e68742abd76e..."
80
+ npx aki-pro-max start
81
+ ```
82
+
83
+ ### Option 2: Global Install via NPM
84
+ ```bash
85
+ npm install -g aki-pro-max
86
+ # Start the proxy (server + local Control Plane):
87
+ aki-pro-max start
88
+ # Or use the short alias:
89
+ akimcp start --port 8788
90
+ ```
91
+
92
+ ### Option 3: Windows Server + Tray Helper + Control Plane
93
+ ```powershell
94
+ # Installs the global server command, Start Menu helper shortcuts (tray-style launcher),
95
+ # and the local Aki Pro Max Control Plane link:
96
+ irm https://raw.githubusercontent.com/khangtudo/aki-pro-max/main/scripts/install-local.ps1 | iex
97
+ ```
98
+
99
+ The installer provides:
100
+ - **Server:** `aki-pro-max start`
101
+ - **Tray-style background launcher shortcut:** *Start Aki Pro Max Control*
102
+ - **Control Plane shortcut:** `http://127.0.0.1:8788/admin`
103
+
104
+ ### Safe Manual Update (Control Plane Flow)
105
+ When the Control Plane shows **Update Available**, follow this exact order:
106
+ 1. Stop the old proxy completely by PID (do not update while it is processing a request):
107
+ ```powershell
108
+ Get-NetTCPConnection -LocalPort 8788 -State Listen | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }
109
+ ```
110
+ 2. Run the update in a new PowerShell window:
111
+ ```powershell
112
+ npm install -g aki-pro-max@latest
113
+ ```
114
+ 3. Return to the Control Plane and click **Reload Control Plane**, then run `aki-pro-max start` to obtain a new proxy PID.
115
+
116
+ ### Option 4: Traditional Git Clone
117
+ ```bash
118
+ git clone https://github.com/khangtudo/aki-pro-max.git
119
+ cd aki-pro-max
120
+ cp .env.example .env
121
+ npm install
122
+ npm test
123
+ npm start
124
+ ```
125
+
126
+ - **Local Admin Control Plane:** `http://127.0.0.1:8788/admin`
127
+ - **OpenAI Compatible Endpoint:** `http://127.0.0.1:8788/v1/chat/completions`
128
+
129
+ ---
130
+
131
+ ## 🚀 Key Technical Breakthroughs (v2.3.2)
132
+
133
+ 1. **Adaptive Context Ingress (>100KB Payload Ceiling Breaker):**
134
+ - Postman's cloud gateway enforces a strict `~9.500 bytes` ceiling on `input.query`.
135
+ - Aki Pro Max transparently offloads extensive system prompts, tool definitions (~90KB), and past conversation turns into virtual file attachments (`selectedContext`) while keeping the active query concise (≤ 6.000 bytes UTF-8).
136
+ 2. **Recursive JSON Schema Validator (`patternProperties`):**
137
+ - Seamlessly validates all 34+ native OpenClaw/AICoworker tools (including `exec.env`).
138
+ 3. **Tool Continuation & Role Normalization:**
139
+ - Gracefully converts non-standard OpenClaw `role: "toolResult"` and complex thinking blocks into clean conversational feedback, eliminating `404 unknown_tool_call` and RPC timeouts.
140
+ 4. **Massive Multi-Agent Room Scale (100MB Body):**
141
+ - Ingress limit scaled to `100MB` (`MAX_BODY_BYTES=104857600`) with an intelligent Head (100KB) + Tail (200KB) truncation window to safely handle sprawling multi-agent collaborative sessions.
142
+ 5. **Universal Model Support:**
143
+ - Whitelisted `global.anthropic.claude-opus-4-7`, ensuring 100% 200 OK delivery across all 8 models.
144
+
145
+ ---
146
+
147
+ ## 🧠 Model Catalog
148
+
149
+ | Public Model ID | Upstream Model Engine | Thinking Mode | Max Context |
150
+ |---|---|:---:|:---:|
151
+ | `gpt-5.6-sol` | `GPT_56_SOL` | ❌ | 400.000 tokens |
152
+ | `gpt-5.6-sol-thinking` | `GPT_56_SOL` | ✅ | 400.000 tokens |
153
+ | `gpt-5.6-terra` | `GPT_56_TERRA` | ❌ | 400.000 tokens |
154
+ | `gpt-5.6-terra-thinking` | `GPT_56_TERRA` | ✅ | 400.000 tokens |
155
+ | `claude-opus-4-8` | `CLAUDE_OPUS_48_BEDROCK` | ❌ | 400.000 tokens |
156
+ | `claude-opus-4-8-thinking` | `CLAUDE_OPUS_48_BEDROCK` | ✅ | 400.000 tokens |
157
+ | `claude-opus-4-7` | `CLAUDE_OPUS_47_BEDROCK` | ❌ | 400.000 tokens |
158
+ | `claude-opus-4-7-thinking` | `CLAUDE_OPUS_47_BEDROCK` | ✅ | 400.000 tokens |
159
+
160
+ ---
161
+
162
+ ## ❓ FAQ — Deployment, Resources & Connection
163
+
164
+ ### What resources does Aki Pro Max need?
165
+ - **Runtime:** Node.js `>=22.15`, npm, and an active browser/web-session credential for the authorized upstream account.
166
+ - **Hardware:** It is a protocol facade — inference runs upstream — so 2 CPU cores, 2GB free RAM, and 1GB free disk is sufficient for a single-user VPS/PC deployment. Use more RAM if you expect many concurrent streaming clients.
167
+ - **Network:** The server binds to loopback (`127.0.0.1`) by default. Put a reverse proxy with TLS and separate authentication in front only if you intentionally expose it to a private network.
168
+
169
+ ### How does authentication work?
170
+ Aki Pro Max supports two explicit modes in `.env`:
171
+ 1. **`access_token`** — provide an authorized upstream access token.
172
+ 2. **`web_session`** — provide a current authenticated session cookie, workspace subdomain, workspace ID, and upstream selected model.
173
+
174
+ Copy `.env.example` to `.env`, choose **one** mode, and populate only the values for that mode. Never commit `.env`, session cookies, bearer tokens, or API keys. The Control Plane deliberately masks credentials and never stores them in browser storage.
175
+
176
+ ### Which models can I use?
177
+ The included catalog exposes eight aliases: `gpt-5.6-sol`, `gpt-5.6-sol-thinking`, `gpt-5.6-terra`, `gpt-5.6-terra-thinking`, `claude-opus-4-8`, `claude-opus-4-8-thinking`, `claude-opus-4-7`, and `claude-opus-4-7-thinking`. Availability still depends on the upstream account and the exact observed-model allowlist in `.env`.
178
+
179
+ ### What URL do I configure in my client?
180
+ Use the OpenAI-compatible base URL:
181
+ ```text
182
+ http://127.0.0.1:8788/v1
183
+ ```
184
+
185
+ Examples:
186
+ - **OpenAI SDK:** `baseURL: 'http://127.0.0.1:8788/v1'`
187
+ - **9router / LiteLLM:** provider base URL `http://127.0.0.1:8788/v1`
188
+ - **Control Plane:** `http://127.0.0.1:8788/admin`
189
+
190
+ ### How do I create an API key for local clients?
191
+ Set a strong opaque value in `.env`:
192
+ ```env
193
+ PROVIDER_API_KEY=replace-with-a-long-random-local-bearer
194
+ ```
195
+
196
+ Generate one locally:
197
+ ```powershell
198
+ node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"
199
+ ```
200
+
201
+ Then send it to clients as `Authorization: Bearer <PROVIDER_API_KEY>`. It is the local facade key, not the upstream web-session cookie.
202
+
203
+ ### What does the 1-line installer install?
204
+ On Windows, the installer creates the global **server command** (`aki-pro-max` / `akimcp`), a Start Menu **background/tray-style launcher shortcut**, and an **Aki Pro Max Control** shortcut. The actual proxy starts only when you run `aki-pro-max start` or select the launcher; no auto-start service is installed silently.
205
+
206
+ ### How do I update safely?
207
+ When **Aki Pro Max Control** shows an update banner, follow its three steps exactly: stop the active server PID, run `npm install -g aki-pro-max@latest` in PowerShell, then reload the Control Plane and start a new proxy PID. The banner checks version metadata with a short timeout and fails open — an offline machine keeps working normally. If npm reports an error, reinstall the last known version explicitly (for example `npm install -g aki-pro-max@2.3.3`) before restarting.
208
+
209
+ ---
210
+
211
+ ## 🧩 Verified Test Suite
212
+
213
+ ```text
214
+ # tests 109
215
+ # pass 109
216
+ # fail 0
217
+ All contracts, tools, event parsers, and multi-turn continuations verified 100% passing.
218
+ ```
219
+
220
+ ---
221
+
222
+ ## 🔒 Security & Privacy
223
+
224
+ - **Loopback Only:** Bound exclusively to `127.0.0.1`.
225
+ - **Zero Raw Secret Leaks:** Authenticated credentials, raw cookies, and session tokens are strictly redacted from logs, error payloads, and git commits.
226
+ - **Fail-Closed Safety:** Mismatched schemas or unauthorized models fail closed without silent fallback.
227
+
228
+ ---
229
+
230
+ ## 📄 License
231
+
232
+ MIT © 2026 Phan Manh Khang (khangtudo)
@@ -0,0 +1,15 @@
1
+ {
2
+ "Url": "https://github.com/khangtudo/aki-pro-max",
3
+ "Visibility": "PUBLIC",
4
+ "Branch": "main",
5
+ "DefaultBranch": "main",
6
+ "Tag": "v0.1.0-beta.1",
7
+ "SHA": "8b664aef05277b30a5655840c995ea7cacf993b5",
8
+ "RemoteMainSHA": "8b664aef05277b30a5655840c995ea7cacf993b5",
9
+ "RemoteTagSHA": {
10
+
11
+ },
12
+ "Remote": "https://github.com/khangtudo/aki-pro-max.git",
13
+ "Description": "Local-first OpenAI-compatible gateway and secure control plane for an authorized Postman web session.",
14
+ "Verified": false
15
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "Timestamp": "2026-09-12T18:23:20.3462359+07:00",
3
+ "FlaggedFixtureProvenance": [
4
+ {
5
+ "File": "test/admin-auth.test.mjs",
6
+ "History": [
7
+ "8b664aef05277b30a5655840c995ea7cacf993b5|2026-09-12T18:10:59+07:00|release: Aki Pro Max v0.1.0-beta.1 ΓÇö verified GPT gateway and local control plane"
8
+ ]
9
+ },
10
+ {
11
+ "File": "test/admin.test.mjs",
12
+ "History": [
13
+ "8b664aef05277b30a5655840c995ea7cacf993b5|2026-09-12T18:10:59+07:00|release: Aki Pro Max v0.1.0-beta.1 ΓÇö verified GPT gateway and local control plane"
14
+ ]
15
+ },
16
+ {
17
+ "File": "test/full-ingress/run-full-ingress.mjs",
18
+ "History": [
19
+ "8b664aef05277b30a5655840c995ea7cacf993b5|2026-09-12T18:10:59+07:00|release: Aki Pro Max v0.1.0-beta.1 ΓÇö verified GPT gateway and local control plane"
20
+ ]
21
+ }
22
+ ],
23
+ "GitleaksConfigOrIgnoreFiles": [
24
+
25
+ ],
26
+ "FullHistory": "--all",
27
+ "Commits": "3",
28
+ "Leaks": 0,
29
+ "Classification": "Synthetic test literals introduced in initial release commit; exact current credentials do not match; Gitleaks no findings."
30
+ }
package/SECURITY.md ADDED
@@ -0,0 +1,16 @@
1
+ # Security Policy
2
+
3
+ ## Reporting
4
+
5
+ Please report suspected credential exposure or authentication bypass privately to the repository owner through GitHub Security Advisories.
6
+
7
+ ## Test fixtures
8
+
9
+ Values used under `test/` are synthetic, intentionally invalid fixtures. They are never copied from live API keys, cookies or session exports. The release verification script scans the complete tree, and release preparation includes a full Git-history scan with Gitleaks.
10
+
11
+ ## Operator responsibilities
12
+
13
+ - Use only accounts and workspaces you are authorized to access.
14
+ - Keep `.env` and timestamped backups out of Git.
15
+ - Rotate a credential immediately if it is ever committed or shared.
16
+ - Keep the admin control plane bound to loopback.
Binary file
Binary file
@@ -0,0 +1,58 @@
1
+ # VERIFICATION REPORT — Local Proxy Builder (v2.3.0) & Aki Pro Max Runtime
2
+
3
+ - **Target / Evaluator:** `@wiha` (Verified via Independent QC Protocol / UHH)
4
+ - **Subject:** `skills/proxy-builder/SKILL.md` (v2.3.0) & Live Aki Pro Max Facade (:8788 / :20128)
5
+ - **Protocol:** Vibe Workflow Phase 4 (Staging Gate & Independent QC)
6
+ - **Date:** 2026-09-13
7
+ - **Final Verdict:** **VERIFIED_PASS (100% Meets Acceptance Criteria)**
8
+
9
+ ---
10
+
11
+ ## 📊 Summary Matrix
12
+
13
+ | Check Item | Acceptance Criteria | Measured Result | Verdict |
14
+ |---|---|---|---|
15
+ | **Check 1: Service Ports** | 8788 (Proxy) & 20128 (9router) listening on loopback | Port 8788 (PID 26436) & Port 20128 (PID 16260) active `Listen` | **PASS** |
16
+ | **Check 2: Model Invocations** | 8/8 PMN models respond HTTP 200 OK via 9router | All 8 models returned 200 OK (latency: 2.4s - 5.2s) | **PASS** |
17
+ | **Check 3: Payload Ceiling (>100KB)** | Context >100KB passes without 413/502 | 120KB payload returned HTTP 200 OK (body: 325B) | **PASS** |
18
+ | **Check 4: AgentSkills.io Spec** | Standard metadata, architecture, 5-phase plan, runnable code | Full compliance with AgentSkills.io v2.3.0 standard | **PASS** |
19
+
20
+ ---
21
+
22
+ ## 🔍 Detailed Verification Evidence
23
+
24
+ ### Check 1: Service Health & Listener Ports
25
+ ```text
26
+ LocalAddress LocalPort OwningProcess State
27
+ ------------ --------- ------------- -----
28
+ 127.0.0.1 8788 26436 Listen
29
+ 0.0.0.0 20128 16260 Listen
30
+ ```
31
+
32
+ ### Check 2: Smoke-test All 8 Models (PMN/*) via 9router
33
+ - `PMN/gpt-5.6-sol` -> status: **200 OK** (2851ms)
34
+ - `PMN/gpt-5.6-sol-thinking` -> status: **200 OK** (4708ms)
35
+ - `PMN/gpt-5.6-terra` -> status: **200 OK** (2430ms)
36
+ - `PMN/gpt-5.6-terra-thinking` -> status: **200 OK** (3226ms)
37
+ - `PMN/claude-opus-4-8` -> status: **200 OK** (4899ms)
38
+ - `PMN/claude-opus-4-8-thinking` -> status: **200 OK** (5292ms)
39
+ - `PMN/claude-opus-4-7` -> status: **200 OK** (4260ms)
40
+ - `PMN/claude-opus-4-7-thinking` -> status: **200 OK** (4532ms)
41
+
42
+ ### Check 3: Large Context Test (120KB Payload)
43
+ ```bash
44
+ # Request sent: 120,000 bytes padding + system directives
45
+ HTTP/1.1 200 OK
46
+ Content-Type: application/json
47
+ Response Time: 4.8s
48
+ Body length: 325 bytes (valid JSON response without 413 / 502 errors)
49
+ ```
50
+
51
+ ### Check 4: AgentSkills.io Spec Compliance
52
+ - **YAML Metadata:** Complete frontmatter including `name: proxy-builder`, `description`, `compatibility`, `version: 2.3.0`, `specification: agentskills.io`.
53
+ - **Structural Integrity:** Contains Core Objectives, High-Priority Directives, Optimization Ladder, Execution Flow, and Runnable Code Reference.
54
+
55
+ ---
56
+
57
+ ## 🏁 Conclusion
58
+ The `proxy-builder` skill (v2.3.0) and live runtime meet all functional, resilience, and security requirements under the Progressive Hyper Harness (UHH) and Vibe Workflow. Ready for production deployment and cross-agent delegation.
Binary file
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { dirname, join } from 'node:path';
5
+ import { existsSync, readFileSync } from 'node:fs';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ const rootDir = join(__dirname, '..');
10
+
11
+ const args = process.argv.slice(2);
12
+
13
+ function showHelp() {
14
+ console.log(`
15
+ Aki Pro Max CLI (v2.3.2)
16
+ OpenAI-Compatible Local Facade & Gateway for Postman Agent Mode
17
+
18
+ Usage:
19
+ npx aki-pro-max [command] [options]
20
+ akimcp [command] [options]
21
+
22
+ Commands:
23
+ start Start the local Aki Pro Max facade proxy (default port 8788)
24
+ status Check local running status and health probe
25
+ version, -v Display current installed version
26
+ help, -h Show this help reference
27
+
28
+ Options:
29
+ --port <number> Override listen port (default: 8788, or PORT env)
30
+ --host <ip> Override listen host (default: 127.0.0.1)
31
+ --env <path> Path to custom .env file
32
+
33
+ Quick Setup:
34
+ 1. Set your session cookie: export POSTMAN_SESSION_COOKIE="c936e687..."
35
+ 2. Start the proxy: npx aki-pro-max start
36
+ 3. Open Admin Control Plane: http://127.0.0.1:8788/admin
37
+ 4. Point your OpenAI client or 9router to: http://127.0.0.1:8788/v1
38
+ `);
39
+ }
40
+
41
+ if (args.includes('--help') || args.includes('-h') || args[0] === 'help') {
42
+ showHelp();
43
+ process.exit(0);
44
+ }
45
+
46
+ if (args.includes('--version') || args.includes('-v') || args[0] === 'version') {
47
+ try {
48
+ const pkg = JSON.parse(readFileSync(join(rootDir, 'package.json'), 'utf8'));
49
+ console.log(pkg.version);
50
+ } catch {
51
+ console.log('2.3.2');
52
+ }
53
+ process.exit(0);
54
+ }
55
+
56
+ if (args[0] === 'status') {
57
+ const http = await import('node:http');
58
+ const req = http.get('http://127.0.0.1:8788/health', (res) => {
59
+ let data = '';
60
+ res.on('data', chunk => data += chunk);
61
+ res.on('end', () => {
62
+ try {
63
+ const json = JSON.parse(data);
64
+ console.log('Aki Pro Max Status: ONLINE (HTTP 200)');
65
+ console.log(JSON.stringify(json, null, 2));
66
+ } catch {
67
+ console.log('Aki Pro Max Status: Responded but non-JSON:', data);
68
+ }
69
+ });
70
+ });
71
+ req.on('error', (err) => {
72
+ console.log('Aki Pro Max Status: OFFLINE or unreachable on http://127.0.0.1:8788');
73
+ console.log('Reason:', err.message);
74
+ process.exit(1);
75
+ });
76
+ } else {
77
+ // Start server
78
+ const serverPath = join(rootDir, 'src', 'index.mjs');
79
+ const envArgs = [];
80
+ const envFile = join(rootDir, '.env');
81
+ if (existsSync(envFile)) {
82
+ envArgs.push('--env-file-if-exists=' + envFile);
83
+ }
84
+
85
+ const child = spawn(process.execPath, [...envArgs, serverPath, ...args], {
86
+ cwd: rootDir,
87
+ stdio: 'inherit',
88
+ env: process.env,
89
+ });
90
+
91
+ child.on('exit', (code, signal) => {
92
+ if (signal) {
93
+ process.kill(process.pid, signal);
94
+ } else {
95
+ process.exit(code ?? 0);
96
+ }
97
+ });
98
+ }
@@ -0,0 +1,29 @@
1
+ # Aki Pro Max Local Control Plane Contract
2
+
3
+ ## Routes
4
+ - `GET /admin` — local administration UI.
5
+ - `GET /admin/app.css` — same-origin stylesheet.
6
+ - `GET /admin/app.js` — same-origin script.
7
+ - `GET /admin/config` — runtime metadata plus raw provider API key for explicit reveal/copy.
8
+
9
+ ## Security boundary
10
+ 1. Every `/admin*` request is checked using `req.socket.remoteAddress` only; proxy and forwarded headers are ignored.
11
+ 2. Accepted client addresses: IPv4 `127.0.0.0/8`, IPv6 `::1`, and IPv4-mapped loopback `::ffff:127.0.0.0/8`.
12
+ 3. Host header must be literal `localhost`, `127.0.0.1`, or `[::1]`, optionally with the actual listening port. DNS names and non-loopback IPs fail closed.
13
+ 4. No CORS headers are emitted. Config responses use `Cache-Control: no-store` and `X-Content-Type-Options: nosniff`.
14
+ 5. API key is never embedded in static HTML/JS/CSS, logged, persisted by the GUI, or returned from `/health`.
15
+ 6. CSP for `/admin` is `default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; frame-ancestors 'none'; form-action 'none'`.
16
+
17
+ ## GUI behavior
18
+ - Loads health and config from the same origin.
19
+ - Initially masks the API key.
20
+ - Reveal button only changes local DOM state after `/admin/config` succeeds.
21
+ - Copy buttons use Clipboard API for Base URL and API key.
22
+ - Shows model list, transport, workspace ID, health boundary, and OpenAI client configuration snippet.
23
+
24
+ ## Tests
25
+ - Pure loopback and Host validation matrix.
26
+ - `/admin` succeeds on localhost and contains no API key.
27
+ - `/admin/config` returns metadata/key on loopback with no-store and no CORS.
28
+ - Non-loopback remoteAddress or attacker Host is rejected.
29
+ - Static assets never contain configured key.
@@ -0,0 +1,109 @@
1
+ # Aki Pro Max — Technical Architecture & Vibe Workflow Package
2
+
3
+ **Phiên bản:** 1.0.0
4
+ **Tác giả:** Xilo AI / OpenClaw Team
5
+ **Chuẩn quy trình:** Vibe Workflow (Brief → Plan → Execute → Verify → Report → Archive)
6
+
7
+ ---
8
+
9
+ ## 1. Cơ Chế Xác Thực Cho Người Dùng Mới (First-Time Auth)
10
+
11
+ ### 1.1. Luồng Người Dùng Chưa Từng Đăng Nhập
12
+ Đối với người dùng mới hoàn toàn chưa đăng nhập Postman:
13
+ 1. **Desktop Auto-Sync (Ưu tiên số 1)**:
14
+ - Người dùng cài đặt Postman Desktop hoặc khởi chạy Postman Agent cục bộ.
15
+ - Khi đăng nhập trên ứng dụng Postman Desktop một lần, Postman lưu trữ phiên xác thực an toàn tại Local AppData (`%APPDATA%/Postman` hoặc `~/Library/Application Support/Postman`).
16
+ - Service `postman-openai-provider` tích hợp bridge tự động đọc token/session được mã hóa cục bộ thông qua Desktop Agent Bridge (mặc định mở tại port `5005` loopback) hoặc quét tệp session cấu hình, tự động trích xuất `postman.sid` và `workspaceId` mà người dùng không cần mở DevTools.
17
+ 2. **Web Guided Login (OAuth Popup)**:
18
+ - Trên Aki Pro Max Local Control Plane, người dùng mở phần **Postman Session**.
19
+ - Một cửa sổ popup mở ra chuyển hướng đến `https://identity.getpostman.com/login`.
20
+ - Tiện ích mở rộng hoặc Script Helper bắt callback sau khi đăng nhập thành công, trích xuất cookie session và lưu vào Local Keyring an toàn của hệ thống (AES-256-GCM).
21
+ 3. **Manual Direct Session Token**:
22
+ - Dành cho môi trường Server/Headless: Người dùng nhập trực tiếp cookie `postman.sid` vào Web GUI. Hệ thống chạy lệnh `handshake verification` kiểm tra quyền sở hữu Team/Workspace trước khi kích hoạt.
23
+
24
+ ---
25
+
26
+
27
+ ### 1.4. Cơ Chế Định Tuyến Team Subdomain & Workspace Linh Hoạt
28
+ - Không gán cứng subdomain hay workspace ID (kimax6).
29
+ - Người dùng khi xác thực qua Web GUI hoặc Client có thể chỉ định Team mục tiêu qua Header:
30
+ * x-postman-subdomain hoặc x-team-subdomain: Subdomain của team (ví dụ: myteam, kimax6).
31
+ * x-postman-workspace-id hoặc x-workspace-id: ID của workspace tương ứng.
32
+ - Proxy tự động xác thực URL hợp lệ https://.postman.co/_gw/chat và định tuyến token từ pool của đúng team đó.
33
+
34
+ ## 2. API Endpoint & API Key Chuẩn Tương Thích OpenAI
35
+
36
+ ### 2.1. Cấp Phát & Quản Lý API Key
37
+ Hệ thống đóng vai trò là một **OpenAI Compatible Facade Gateway**:
38
+ - **Format API Key phát hành**: `sk-pmn-live-[account_hash]-[random_uuid]`
39
+ - **Header xác thực từ Client**:
40
+ ```http
41
+ Authorization: Bearer YOUR_LOCAL_FACADE_KEY
42
+ x-session-id: ss-claude-agent-01 (Dùng để duy trì 1-1 session mapping)
43
+ ```
44
+ - **Base URL cấu hình trên các client**:
45
+ - URL cục bộ: `http://localhost:18789/v1` hoặc `http://127.0.0.1:50585/v1`
46
+ - URL LAN/Tailscale: `http://192.168.x.x:18789/v1`
47
+ - Hỗ trợ định tuyến chuẩn OpenAI:
48
+ * `GET /v1/models`: Trả về danh sách model khả dụng.
49
+ * `POST /v1/chat/completions`: Endpoint chính phục vụ cả Stream SSE và JSON, đầy đủ Function Calling / Tools.
50
+
51
+ ---
52
+
53
+ ## 3. Cơ Chế Xử Lý Đa Luồng & Concurrency Queue
54
+
55
+ ### 3.1. Thách Thức Kỹ Thuật
56
+ Postman Team Account có giới hạn số lượng request đồng thời (thường từ 1-2 request concurrent trên mỗi session cookie). Nếu nhiều subagent hoặc client gửi request đồng thời mà không kiểm soát, Postman sẽ trả về lỗi `HTTP 429 Too Many Requests` hoặc hủy stream `LLM_STREAM_ERROR`.
57
+
58
+ ### 3.2. Kiến Trúc Hàng Đợi (Concurrency Queue per Account)
59
+ 1. **Async Semaphore & FIFO Queue**:
60
+ - Mỗi tài khoản Postman trong Pool được gán một `AccountQueue` riêng biệt với `maxConcurrency` có thể cấu hình (mặc định = 2).
61
+ - Khi request đến:
62
+ * Nếu tài khoản còn slot trống: Request được thực thi ngay lập tức.
63
+ * Nếu tài khoản đã hết slot: Request được đẩy vào hàng đợi FIFO của tài khoản đó (có timeout chờ tối đa 60 giây).
64
+ 2. **Account Pool Load Balancing & Failover**:
65
+ - **Chiến lược định tuyến**:
66
+ * `Session Affinity (Sticky Session)`: Các request có cùng `x-session-id` luôn được định tuyến về đúng tài khoản và đúng Postman conversation đã tạo trước đó để tận dụng context cache.
67
+ * `Least-Busy Routing`: Với các session mới, proxy tự động chọn tài khoản có hàng đợi ngắn nhất và còn nhiều quota nhất.
68
+ - **Tự động Failover khi gặp 429**: Nếu một tài khoản bị lỗi rate limit, các request mới trong hàng đợi sẽ được chuyển tiếp sang tài khoản dự phòng khác trong Pool.
69
+
70
+ ---
71
+
72
+ ## 4. Kiến Trúc Web GUI Quản Trị (Tương tự Notion2API)
73
+
74
+ Giao diện Web GUI được xây dựng gọn nhẹ (Local Web UI tích hợp hoặc Dashboard nhúng trong Electron):
75
+ - **Tab Accounts**:
76
+ * Danh sách tài khoản Postman kết nối, hiển thị trạng thái (Live / Expired / Rate Limited).
77
+ * Nút "Add Account", "Re-sync Session", "Test Connection".
78
+ * Theo dõi hạn mức sử dụng (Usage millicredits theo tuần của từng tài khoản).
79
+ - **Tab API Keys**:
80
+ * Tạo, thu hồi và gán quyền API Key cho từng Client/Ứng dụng.
81
+ * Giới hạn model được phép truy cập theo từng Key.
82
+ - **Tab Live Logs & Chat Inspector**:
83
+ * Theo dõi luồng request thời gian thực, độ trễ upstream (TTFT, total latency).
84
+ * Xem trực quan các tool call và kết quả trả về, hiển thị y hệt lịch sử trên Postman.
85
+ - **Tab Models & Thinking**:
86
+ * Bật/tắt các model trong catalog (`gpt-5.6-sol`, `gpt-5.6-terra`, `claude-opus-4-8`, `claude-opus-4-7`).
87
+ * Cấu hình tham số thinking mặc định cho nhánh `-thinking`.
88
+
89
+ ---
90
+
91
+ ## 5. Quy Chuẩn Đóng Gói Vibe Workflow (Vibe Workflow Rule)
92
+
93
+ 1. **Phase 1: Brief & Core Goal** (`docs/vibe-workflow.md`):
94
+ - Đã xác định rõ mục tiêu: OpenAI Facade kết nối Postman Desktop / Web Team Account, bảo toàn native tools, session continuity 1-1.
95
+ 2. **Phase 2: Plan & Architecture**:
96
+ - Tài liệu kỹ thuật chi tiết đã hoàn tất tại `ARCHITECTURE.md`.
97
+ 3. **Phase 3: Execute**:
98
+ - Mã nguồn lõi `services/postman-openai-provider` đã hỗ trợ:
99
+ * 1-1 Stateful Session Mapping (`SessionMappingStore`).
100
+ * Bộ 4 Model Foodcode chuẩn (`GPT_56_SOL`, `GPT_56_TERRA`, `CLAUDE_OPUS_48_BEDROCK`, `CLAUDE_OPUS_47_BEDROCK`).
101
+ * Phân giải linh hoạt hậu tố `-thinking`.
102
+ * Xử lý lỗi 409 `continuation_tools_mismatch` và 502 `upstream_model_mismatch`.
103
+ 4. **Phase 4: Verify**:
104
+ - Toàn bộ 89 bài test offline regression đã pass 100%.
105
+ - Live probe thực tế đạt `completed_match` cho chu trình tool calling.
106
+ 5. **Phase 5: Report**:
107
+ - Báo cáo trực quan Dashboard, So sánh và Sơ đồ luồng đã được gửi cho Papa.
108
+ 6. **Phase 6: Archive**:
109
+ - Đóng gói artifact, ghi nhật ký phiên và sẵn sàng tạo branch/tag deliverable theo đúng quy tắc Vibe Workflow.
@@ -0,0 +1,44 @@
1
+ # Aki Pro Max — Capability Matrix
2
+
3
+ ## Current verified scope
4
+
5
+ | Requirement | Evidence | Verdict |
6
+ |---|---|---|
7
+ | OpenAI-compatible facade | `/v1/models`, `/v1/chat/completions`, authentication and model-contract tests | Met |
8
+ | Authorized Postman Web Team route | Fresh live probes used the configured team origin and workspace | Met for configured workspace |
9
+ | GPT-5.6 Sol native tool loop | Initial tool call, local result, same-session continuation, exact final marker | Met |
10
+ | Claude Opus 4.8 native tool loop | `CLAUDE-LIVE-TOOLS-EVIDENCE.json`: HTTP 200 initial and continuation, valid empty-object arguments, exact final marker | Met |
11
+ | 1:1 single-process session continuity | Correlation tests plus sticky `x-session-id` contract | Met |
12
+ | Eight public model aliases | Runtime catalog and deterministic checks | Met as catalog |
13
+ | AICoworker → 9router → Aki Pro Max attribution | `FULL-TRACE-EVIDENCE.json`: fresh `provider=pmn` subagent request correlated to usage row `86672` on `Aki Pro Max Local`; CPX remained active | Met |
14
+ | Local Control Plane | `/admin` UAT, masked status, API-key reveal and upstream-auth fields | Met |
15
+ | Automatic protected Desktop-session extraction | Not implemented; manual authorized session input remains required | Not supported |
16
+ | Multi-team live routing | Header validation exists; a live multi-team matrix has not been exercised | Partial |
17
+ | Restart/multi-worker correlation | Correlation store remains in-memory and single-process | Not supported |
18
+
19
+ ## Closure evidence for issues #1 and #2
20
+
21
+ ### Issue #1 — Claude live tool flow
22
+
23
+ The fresh acceptance run at `services/postman-openai-provider/reports/live-runs/goal-issue1-session-20260913-072211/LIVE-TWO-MODEL-TOOLS-EVIDENCE.json` recorded:
24
+
25
+ - `publicModel=claude-opus-4-8`
26
+ - `selectedModel=CLAUDE_OPUS_48_BEDROCK`
27
+ - initial HTTP `200`
28
+ - exactly one valid `get_probe_value` tool call
29
+ - `argumentsValid=true`
30
+ - continuation HTTP `200`
31
+ - `finalMatchesMarker=true`
32
+ - terminal state `completed_match`
33
+
34
+ ### Issue #2 — PMN attribution with CPX still active
35
+
36
+ A fresh AICoworker subagent explicitly requested `pmn/PMN/gpt-5.6-sol` and its persisted transcript recorded `provider=pmn`, `model=PMN/gpt-5.6-sol`. In the matching time window, 9router usage row `86672` was served by connection `6706879a-9897-4b2a-9142-728ca64276d4`, mapped to `Aki Pro Max Local`, with status `ok` and four completion tokens—the exact marker response. CPX remained active and served surrounding unrelated requests, so the result is not a CPX-disabled negative test.
37
+
38
+ ## Verification gate
39
+
40
+ Tier 1 syntax and focused integration tests passed. The Trio verifier scored closure evidence **17.43/20** with **StdDev 0.40**, above the required 14.0 threshold and below the 3.5 disagreement gate. See `VERIFIER-ISSUES12-FINAL.txt`.
41
+
42
+ ## Honest remaining boundaries
43
+
44
+ This remains a beta release because automatic protected-session extraction, multi-team live coverage and restart-safe distributed correlation are not claimed. Those boundaries do not invalidate closure of issues #1 and #2.