@openchamber/web 1.9.2 → 1.9.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.
- package/dist/assets/ToolOutputDialog-iiUOHO3c.js +16 -0
- package/dist/assets/index-BZ8pfXBh.css +1 -0
- package/dist/assets/index-DEj7Q-1y.js +2 -0
- package/dist/assets/{main-BFP0Fw2a.js → main-Ba2uuSTQ.js} +119 -119
- package/dist/assets/{vendor-.bun-CjZZibdK.js → vendor-.bun-B34wtB0D.js} +39 -39
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/server/TERMINAL_WS_PROTOCOL.md +48 -0
- package/server/lib/fs/routes.js +48 -0
- package/server/lib/opencode/proxy.js +106 -2
- package/server/lib/quota/DOCUMENTATION.md +1 -0
- package/server/lib/quota/index.js +2 -1
- package/server/lib/quota/providers/copilot.js +1 -1
- package/server/lib/quota/providers/index.js +8 -0
- package/server/lib/quota/providers/minimax-cn-coding-plan.js +141 -15
- package/server/lib/quota/providers/minimax-coding-plan.js +139 -15
- package/server/lib/quota/providers/zhipuai.js +114 -0
- package/server/lib/terminal/DOCUMENTATION.md +41 -80
- package/server/lib/terminal/index.js +27 -8
- package/server/lib/terminal/output-replay-buffer.js +66 -0
- package/server/lib/terminal/output-replay-buffer.test.js +66 -0
- package/server/lib/terminal/runtime.js +107 -20
- package/server/lib/terminal/{input-ws-protocol.js → terminal-ws-protocol.js} +13 -11
- package/server/lib/terminal/{input-ws-protocol.test.js → terminal-ws-protocol.test.js} +39 -32
- package/server/opencode-proxy.test.js +83 -0
- package/server/proxy-headers.js +61 -0
- package/server/proxy-headers.test.js +58 -0
- package/dist/assets/ToolOutputDialog-DwlX_M_n.js +0 -16
- package/dist/assets/index-BQqVuvn2.js +0 -2
- package/dist/assets/index-CH1IFYgs.css +0 -1
- package/server/TERMINAL_INPUT_WS_PROTOCOL.md +0 -44
- package/server/lib/quota/providers/minimax-shared.js +0 -136
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { readAuthFile } from '../../opencode/auth.js';
|
|
2
|
-
import {
|
|
3
|
-
getAuthEntry,
|
|
4
|
-
normalizeAuthEntry,
|
|
5
|
-
buildResult,
|
|
6
|
-
toUsageWindow,
|
|
7
|
-
toNumber,
|
|
8
|
-
toTimestamp,
|
|
9
|
-
} from '../utils/index.js';
|
|
10
|
-
|
|
11
|
-
export const createMiniMaxCodingPlanProvider = ({ providerId, providerName, aliases, endpoint }) => {
|
|
12
|
-
const isConfigured = () => {
|
|
13
|
-
const auth = readAuthFile();
|
|
14
|
-
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
15
|
-
return Boolean(entry?.key || entry?.token);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const fetchQuota = async () => {
|
|
19
|
-
const auth = readAuthFile();
|
|
20
|
-
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
21
|
-
const apiKey = entry?.key ?? entry?.token;
|
|
22
|
-
|
|
23
|
-
if (!apiKey) {
|
|
24
|
-
return buildResult({
|
|
25
|
-
providerId,
|
|
26
|
-
providerName,
|
|
27
|
-
ok: false,
|
|
28
|
-
configured: false,
|
|
29
|
-
error: 'Not configured',
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const response = await fetch(endpoint, {
|
|
35
|
-
method: 'GET',
|
|
36
|
-
headers: {
|
|
37
|
-
Authorization: `Bearer ${apiKey}`,
|
|
38
|
-
'Content-Type': 'application/json',
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
return buildResult({
|
|
44
|
-
providerId,
|
|
45
|
-
providerName,
|
|
46
|
-
ok: false,
|
|
47
|
-
configured: true,
|
|
48
|
-
error: `API error: ${response.status}`,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const payload = await response.json();
|
|
53
|
-
const baseResp = payload?.base_resp;
|
|
54
|
-
if (baseResp && baseResp.status_code !== 0) {
|
|
55
|
-
return buildResult({
|
|
56
|
-
providerId,
|
|
57
|
-
providerName,
|
|
58
|
-
ok: false,
|
|
59
|
-
configured: true,
|
|
60
|
-
error: baseResp.status_msg || `API error: ${baseResp.status_code}`,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const firstModel = payload?.model_remains?.[0];
|
|
65
|
-
if (!firstModel) {
|
|
66
|
-
return buildResult({
|
|
67
|
-
providerId,
|
|
68
|
-
providerName,
|
|
69
|
-
ok: false,
|
|
70
|
-
configured: true,
|
|
71
|
-
error: 'No model quota data available',
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const intervalTotal = toNumber(firstModel.current_interval_total_count);
|
|
76
|
-
const intervalUsage = toNumber(firstModel.current_interval_usage_count);
|
|
77
|
-
const intervalStartAt = toTimestamp(firstModel.start_time);
|
|
78
|
-
const intervalResetAt = toTimestamp(firstModel.end_time);
|
|
79
|
-
const weeklyTotal = toNumber(firstModel.current_weekly_total_count);
|
|
80
|
-
const weeklyUsage = toNumber(firstModel.current_weekly_usage_count);
|
|
81
|
-
const weeklyStartAt = toTimestamp(firstModel.weekly_start_time);
|
|
82
|
-
const weeklyResetAt = toTimestamp(firstModel.weekly_end_time);
|
|
83
|
-
const intervalUsed = intervalTotal - intervalUsage;
|
|
84
|
-
const weeklyUsed = weeklyTotal - weeklyUsage;
|
|
85
|
-
const intervalUsedPercent =
|
|
86
|
-
intervalTotal > 0 ? Math.max(0, Math.min(100, (intervalUsed / intervalTotal) * 100)) : null;
|
|
87
|
-
const intervalWindowSeconds =
|
|
88
|
-
intervalStartAt && intervalResetAt && intervalResetAt > intervalStartAt
|
|
89
|
-
? Math.floor((intervalResetAt - intervalStartAt) / 1000)
|
|
90
|
-
: null;
|
|
91
|
-
const weeklyUsedPercent =
|
|
92
|
-
weeklyTotal > 0 ? Math.max(0, Math.min(100, (weeklyUsed / weeklyTotal) * 100)) : null;
|
|
93
|
-
const weeklyWindowSeconds =
|
|
94
|
-
weeklyStartAt && weeklyResetAt && weeklyResetAt > weeklyStartAt
|
|
95
|
-
? Math.floor((weeklyResetAt - weeklyStartAt) / 1000)
|
|
96
|
-
: null;
|
|
97
|
-
|
|
98
|
-
const windows = {
|
|
99
|
-
'5h': toUsageWindow({
|
|
100
|
-
usedPercent: intervalUsedPercent,
|
|
101
|
-
windowSeconds: intervalWindowSeconds,
|
|
102
|
-
resetAt: intervalResetAt,
|
|
103
|
-
}),
|
|
104
|
-
weekly: toUsageWindow({
|
|
105
|
-
usedPercent: weeklyUsedPercent,
|
|
106
|
-
windowSeconds: weeklyWindowSeconds,
|
|
107
|
-
resetAt: weeklyResetAt,
|
|
108
|
-
}),
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
return buildResult({
|
|
112
|
-
providerId,
|
|
113
|
-
providerName,
|
|
114
|
-
ok: true,
|
|
115
|
-
configured: true,
|
|
116
|
-
usage: { windows },
|
|
117
|
-
});
|
|
118
|
-
} catch (error) {
|
|
119
|
-
return buildResult({
|
|
120
|
-
providerId,
|
|
121
|
-
providerName,
|
|
122
|
-
ok: false,
|
|
123
|
-
configured: true,
|
|
124
|
-
error: error instanceof Error ? error.message : 'Request failed',
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
providerId,
|
|
131
|
-
providerName,
|
|
132
|
-
aliases,
|
|
133
|
-
isConfigured,
|
|
134
|
-
fetchQuota,
|
|
135
|
-
};
|
|
136
|
-
};
|