ck-pi-zen-session 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -15,7 +15,7 @@ OpenCode Zen 免费模型同步、请求头伪装与 Session 会话自动维护
15
15
  - `x-session-affinity`: 与 session 严格同步
16
16
  - `X-Session-Id`: 与 session 严格同步
17
17
  - `x-opencode-request`: `msg_<12位升序时间戳十六进制><14位Base62>`(每次 HTTP 请求唯一)
18
- - ⏱️ **45 分钟无感前置平滑轮换**:官方后端限制免费会话时长约为 1 小时(超时直接 403 `FreeTierError`)。本插件在底层请求拦截器(`before_provider_headers`)和 Agent 循环守卫(`before_agent_start`)中设置 45 分钟主动换新阈值,确保永不触碰 1 小时硬限制。
18
+ - ⏱️ **30 分钟无感前置平滑轮换**:官方后端限制免费会话时长约为 1 小时(超时直接 403 `FreeTierError`)。本插件在底层请求拦截器(`before_provider_headers`)和 Agent 循环守卫(`before_agent_start`)中设置 30 分钟主动换新阈值,兼顾会话上下文平滑与长期高频调用稳定性,确保永不触碰 1 小时硬限制。
19
19
  - 🧰 **Agent 工具链兼容性守卫**:OpenCode Zen 免费端点对工具集有硬性要求(无工具直接拒绝)。插件在 `before_provider_request` 钩子中实时监控请求体,若用户处于无工具或纯文本问答模式,自动补齐兼容性工具定义,彻底根除 403 拦截。
20
20
  - 🌐 **独立供应商隔离命名空间**:注册为独立供应商 `opencode-zen-free`,彻底避开并兼容用户自带的官方登录 `opencode` / `opencode-zen` 套餐,互不干扰、平稳共存。
21
21
  - 🧠 **精准上下文与思维链适配**:严格对齐 9 款免费模型的 `contextWindow`、`maxTokens` 与 `thinkingLevelMap`(涵盖小米 MiMo、英伟达 Nemotron、Meta Muse Spark、Ling、Jev 等)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ck-pi-zen-session",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "OpenCode Zen session auto-refresh and free-tier model catalog synchronization for the Pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package",
package/src/index.ts CHANGED
@@ -78,7 +78,7 @@ export default function piZenSession(pi: ExtensionAPI): void {
78
78
  model?.id === "big-pickle";
79
79
 
80
80
  if (isZenModel) {
81
- // 检查 x-opencode-session 是否过期 (>45分钟) 或缺失
81
+ // 检查 x-opencode-session 是否过期 (>30分钟) 或缺失
82
82
  let currentSession = event.headers["x-opencode-session"];
83
83
  if (
84
84
  typeof currentSession !== "string" ||
@@ -155,7 +155,7 @@ export default function piZenSession(pi: ExtensionAPI): void {
155
155
  pi.on("before_agent_start", async () => {
156
156
  try {
157
157
  const currentSession = getStoredZenSessionId();
158
- // 若当前会话不存在或已使用超过 45 分钟,后台自动续期
158
+ // 若当前会话不存在或已使用超过 30 分钟,后台自动续期
159
159
  if (!currentSession || isZenSessionExpired(currentSession, DEFAULT_SESSION_MAX_AGE_MS)) {
160
160
  const apiKey = getStoredZenApiKey();
161
161
  if (apiKey) {
package/src/session.ts CHANGED
@@ -139,14 +139,14 @@ export function extractZenSessionTimestamp(
139
139
 
140
140
  /**
141
141
  * 官方 OpenCode Zen 后端对会话生命周期严格限制(超 1 小时即报 403 FreeTierError)
142
- * 默认设定为 45 分钟,确保在达到 1 小时硬限制前无感平滑轮换
142
+ * 设定为 30 分钟无感前置轮换,兼顾会话上下文平滑与长期高频调用稳定性
143
143
  */
144
- export const DEFAULT_SESSION_MAX_AGE_MS = 45 * 60 * 1000;
144
+ export const DEFAULT_SESSION_MAX_AGE_MS = 30 * 60 * 1000;
145
145
 
146
146
  /**
147
147
  * 判断指定 Session ID 是否已过期
148
148
  * @param sessionId 会话 ID
149
- * @param maxAgeMs 最大允许有效时长(默认 45 分钟)
149
+ * @param maxAgeMs 最大允许有效时长(默认 30 分钟)
150
150
  * @param nowMs 当前时间戳
151
151
  */
152
152
  export function isZenSessionExpired(