pi-opencode-go-provider 1.0.15 → 1.0.17
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.
- package/.pi/fabric/mcp-cache.json +1475 -0
- package/.pi/fabric/mesh/state.json +117 -0
- package/README.md +3 -1
- package/index.ts +39 -1
- package/models.json +29 -1
- package/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"entries": {
|
|
4
|
+
"topology/peer-seq": {
|
|
5
|
+
"key": "topology/peer-seq",
|
|
6
|
+
"value": {
|
|
7
|
+
"format": 1,
|
|
8
|
+
"next": 1
|
|
9
|
+
},
|
|
10
|
+
"version": 1,
|
|
11
|
+
"updatedAt": 1788421061231,
|
|
12
|
+
"updatedBy": {
|
|
13
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
14
|
+
"name": "main",
|
|
15
|
+
"kind": "main",
|
|
16
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"topology/hosts/ae5878888fad007023c5ff775ac6356930ec9eaacf6e5b09ceebb18d9d4e54c8": {
|
|
20
|
+
"key": "topology/hosts/ae5878888fad007023c5ff775ac6356930ec9eaacf6e5b09ceebb18d9d4e54c8",
|
|
21
|
+
"value": {
|
|
22
|
+
"format": 1,
|
|
23
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
24
|
+
"rootId": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
25
|
+
"identity": {
|
|
26
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
27
|
+
"name": "main",
|
|
28
|
+
"kind": "main",
|
|
29
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277"
|
|
30
|
+
},
|
|
31
|
+
"startedAt": 1788421061220,
|
|
32
|
+
"updatedAt": 1788422266448,
|
|
33
|
+
"expiresAt": 1788422281448
|
|
34
|
+
},
|
|
35
|
+
"version": 367,
|
|
36
|
+
"updatedAt": 1788422266450,
|
|
37
|
+
"updatedBy": {
|
|
38
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
39
|
+
"name": "main",
|
|
40
|
+
"kind": "main",
|
|
41
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"sessions/01a06632-9590-73a7-8e4c-bf4f4d6d8277": {
|
|
45
|
+
"key": "sessions/01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
46
|
+
"value": {
|
|
47
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
48
|
+
"name": "POGP-1",
|
|
49
|
+
"label": "POGP-1",
|
|
50
|
+
"kind": "peer",
|
|
51
|
+
"status": "running",
|
|
52
|
+
"runner": "pi",
|
|
53
|
+
"transport": "host",
|
|
54
|
+
"cwd": "/Users/monotykamary/VCS/working-remote/open-source/pi-opencode-go-provider",
|
|
55
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
56
|
+
"model": "xai/grok-4.6",
|
|
57
|
+
"thinking": "medium",
|
|
58
|
+
"startedAt": 1788421061220,
|
|
59
|
+
"updatedAt": 1788422266448,
|
|
60
|
+
"pendingMessages": false,
|
|
61
|
+
"local": false
|
|
62
|
+
},
|
|
63
|
+
"version": 367,
|
|
64
|
+
"updatedAt": 1788422266451,
|
|
65
|
+
"updatedBy": {
|
|
66
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
67
|
+
"name": "main",
|
|
68
|
+
"kind": "main",
|
|
69
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"topology/participants/ae5878888fad007023c5ff775ac6356930ec9eaacf6e5b09ceebb18d9d4e54c8": {
|
|
73
|
+
"key": "topology/participants/ae5878888fad007023c5ff775ac6356930ec9eaacf6e5b09ceebb18d9d4e54c8",
|
|
74
|
+
"value": {
|
|
75
|
+
"format": 1,
|
|
76
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
77
|
+
"kind": "root",
|
|
78
|
+
"rootId": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
79
|
+
"ownerHostId": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
80
|
+
"ownerIdentityId": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
81
|
+
"name": "main",
|
|
82
|
+
"status": "running",
|
|
83
|
+
"runner": "pi",
|
|
84
|
+
"transport": "host",
|
|
85
|
+
"capabilities": [
|
|
86
|
+
"steer",
|
|
87
|
+
"followUp",
|
|
88
|
+
"fabric"
|
|
89
|
+
],
|
|
90
|
+
"cwd": "/Users/monotykamary/VCS/working-remote/open-source/pi-opencode-go-provider",
|
|
91
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
92
|
+
"model": "xai/grok-4.6",
|
|
93
|
+
"thinking": "medium",
|
|
94
|
+
"startedAt": 1788421061220,
|
|
95
|
+
"updatedAt": 1788422266448,
|
|
96
|
+
"pendingMessages": false,
|
|
97
|
+
"controlProtocol": "v1",
|
|
98
|
+
"label": "POGP-1"
|
|
99
|
+
},
|
|
100
|
+
"version": 367,
|
|
101
|
+
"updatedAt": 1788422266453,
|
|
102
|
+
"updatedBy": {
|
|
103
|
+
"id": "session:01a06632-9590-73a7-8e4c-bf4f4d6d8277",
|
|
104
|
+
"name": "main",
|
|
105
|
+
"kind": "main",
|
|
106
|
+
"sessionId": "01a06632-9590-73a7-8e4c-bf4f4d6d8277"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"versions": {
|
|
111
|
+
"topology/peer-seq": 1,
|
|
112
|
+
"topology/hosts/ae5878888fad007023c5ff775ac6356930ec9eaacf6e5b09ceebb18d9d4e54c8": 367,
|
|
113
|
+
"sessions/01a06632-9590-73a7-8e4c-bf4f4d6d8277": 367,
|
|
114
|
+
"topology/participants/ae5878888fad007023c5ff775ac6356930ec9eaacf6e5b09ceebb18d9d4e54c8": 367
|
|
115
|
+
},
|
|
116
|
+
"tombstoneOrder": []
|
|
117
|
+
}
|
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ _Go-optimized endpoints for lower latency — 14+ models for [pi](https://github
|
|
|
20
20
|
- **Fast & Efficient** - Go-optimized endpoints for lower latency
|
|
21
21
|
- **Cost Tracking** with per-model pricing for budget management
|
|
22
22
|
- **Reasoning Models** with thinking level maps for proper effort control
|
|
23
|
+
- **Prompt-cache session affinity** — sends `x-opencode-session` and `x-opencode-client` so OpenCode Go can pin a session to the same cache node
|
|
23
24
|
|
|
24
25
|
## Installation
|
|
25
26
|
|
|
@@ -77,7 +78,7 @@ pi
|
|
|
77
78
|
| GLM-5.3-Flash (2x usage) | Completions | Text + Image | 1.0M | 131K | $0.07 | $0.25 |
|
|
78
79
|
| GPT-5.6 Luna | Responses | Text + Image | 1.1M | 128K | $0.20 | $1.20 |
|
|
79
80
|
| Grok 4.6 | Completions | Text + Image | 500K | 500K | $2.00 | $6.00 |
|
|
80
|
-
| Hy3 | Completions | Text | 256K |
|
|
81
|
+
| Hy3 | Completions | Text | 256K | 128K | $0.14 | $0.58 |
|
|
81
82
|
| Hy4 preview | Completions | Text | 1.0M | 64K | $0.83 | $2.50 |
|
|
82
83
|
| Kimi K2.6 | Completions | Text + Image | 262K | 66K | $0.95 | $4.00 |
|
|
83
84
|
| Kimi K2.7 Code | Completions | Text + Image | 262K | 262K | $0.95 | $4.00 |
|
|
@@ -88,6 +89,7 @@ pi
|
|
|
88
89
|
| MiniMax-M2.7 | Completions | Text | 205K | 131K | $0.30 | $1.20 |
|
|
89
90
|
| MiniMax-M3 | Anthropic | Text + Image | 1.0M | 131K | $0.30 | $1.20 |
|
|
90
91
|
| Muse Spark 1.2 Contributor | Completions | Text + Image | 1.0M | 131K | $0.10 | $0.20 |
|
|
92
|
+
| Muse Spark 1.3 Contributor | Completions | Text + Image | 1.0M | 131K | $0.10 | $0.20 |
|
|
91
93
|
| Qwen3.6 Plus | Completions | Text + Image | 1.0M | 66K | $0.50 | $3.00 |
|
|
92
94
|
| Qwen3.7 Max | Completions | Text | 1.0M | 66K | $2.50 | $7.50 |
|
|
93
95
|
| Qwen3.7 Plus | Completions | Text + Image | 1.0M | 66K | $0.40 | $1.60 |
|
package/index.ts
CHANGED
|
@@ -339,7 +339,40 @@ async function resolveApiKey(modelRegistry: ModelRegistry): Promise<void> {
|
|
|
339
339
|
cachedApiKey = await modelRegistry.getApiKeyForProvider("opencode-go") ?? undefined;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
//
|
|
342
|
+
// OpenCode Go prompt-cache routing headers.
|
|
343
|
+
// Pi core already injects these in mergeProviderAttributionHeaders for
|
|
344
|
+
// provider "opencode-go" / host opencode.ai (see #4847). This hook is a
|
|
345
|
+
// backstop: it fills them only when missing, so older pi builds and any
|
|
346
|
+
// request path that skipped transformHeaders still pin the session.
|
|
347
|
+
// Per-request via before_provider_headers — not registerProvider.headers —
|
|
348
|
+
// because provider-wide headers leak to raw helper streams
|
|
349
|
+
// (getApiKeyAndHeaders) that must not inherit the main session's cache
|
|
350
|
+
// lineage. No custom streamSimple is needed; headers are applied before
|
|
351
|
+
// provider dispatch.
|
|
352
|
+
const OPENCODE_SESSION_HEADER = "x-opencode-session";
|
|
353
|
+
const OPENCODE_CLIENT_HEADER = "x-opencode-client";
|
|
354
|
+
const OPENCODE_CLIENT = "pi";
|
|
355
|
+
|
|
356
|
+
function headerLookup(headers: Record<string, string | null | undefined>, name: string): string | undefined {
|
|
357
|
+
const lower = name.toLowerCase();
|
|
358
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
359
|
+
if (key.toLowerCase() === lower) return value ?? undefined;
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export function applyOpenCodeSessionHeaders(
|
|
365
|
+
headers: Record<string, string | null>,
|
|
366
|
+
sessionId: string | undefined,
|
|
367
|
+
): Record<string, string | null> {
|
|
368
|
+
if (sessionId && !headerLookup(headers, OPENCODE_SESSION_HEADER)) {
|
|
369
|
+
headers[OPENCODE_SESSION_HEADER] = sessionId;
|
|
370
|
+
}
|
|
371
|
+
if (!headerLookup(headers, OPENCODE_CLIENT_HEADER)) {
|
|
372
|
+
headers[OPENCODE_CLIENT_HEADER] = OPENCODE_CLIENT;
|
|
373
|
+
}
|
|
374
|
+
return headers;
|
|
375
|
+
}
|
|
343
376
|
|
|
344
377
|
export default function (pi: ExtensionAPI) {
|
|
345
378
|
const embeddedModels = modelsData as JsonModel[];
|
|
@@ -369,6 +402,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
369
402
|
})),
|
|
370
403
|
});
|
|
371
404
|
|
|
405
|
+
pi.on("before_provider_headers", (event, ctx) => {
|
|
406
|
+
if (ctx.model?.provider !== PROVIDER_ID) return;
|
|
407
|
+
applyOpenCodeSessionHeaders(event.headers, ctx.sessionManager.getSessionId());
|
|
408
|
+
});
|
|
409
|
+
|
|
372
410
|
pi.on("session_start", async (_event, ctx) => {
|
|
373
411
|
revalidateAbort?.abort();
|
|
374
412
|
revalidateAbort = new AbortController();
|
package/models.json
CHANGED
|
@@ -64,6 +64,34 @@
|
|
|
64
64
|
"contextWindow": 1048576,
|
|
65
65
|
"maxTokens": 131072
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
"id": "muse-spark-1.3-contributor",
|
|
69
|
+
"name": "Muse Spark 1.3 Contributor",
|
|
70
|
+
"api": "openai-completions",
|
|
71
|
+
"baseUrl": "https://opencode.ai/zen/go/v1",
|
|
72
|
+
"reasoning": true,
|
|
73
|
+
"thinkingLevelMap": {
|
|
74
|
+
"off": null,
|
|
75
|
+
"minimal": "minimal",
|
|
76
|
+
"low": "low",
|
|
77
|
+
"medium": "medium",
|
|
78
|
+
"high": "high",
|
|
79
|
+
"xhigh": "xhigh",
|
|
80
|
+
"max": null
|
|
81
|
+
},
|
|
82
|
+
"input": [
|
|
83
|
+
"text",
|
|
84
|
+
"image"
|
|
85
|
+
],
|
|
86
|
+
"cost": {
|
|
87
|
+
"input": 0.1,
|
|
88
|
+
"output": 0.2,
|
|
89
|
+
"cacheRead": 0.002,
|
|
90
|
+
"cacheWrite": 0
|
|
91
|
+
},
|
|
92
|
+
"contextWindow": 1048576,
|
|
93
|
+
"maxTokens": 131072
|
|
94
|
+
},
|
|
67
95
|
{
|
|
68
96
|
"id": "deepseek-v4-flash",
|
|
69
97
|
"name": "DeepSeek V4 Flash",
|
|
@@ -484,7 +512,7 @@
|
|
|
484
512
|
"cacheWrite": 0
|
|
485
513
|
},
|
|
486
514
|
"contextWindow": 256000,
|
|
487
|
-
"maxTokens":
|
|
515
|
+
"maxTokens": 128000
|
|
488
516
|
},
|
|
489
517
|
{
|
|
490
518
|
"id": "muse-spark-1.2-contributor",
|
package/package.json
CHANGED