@eddyskywalker/dsh-chatgpt-subscription 0.48.1 → 0.48.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.
package/lib/index.js
CHANGED
|
@@ -145,7 +145,7 @@ const ROUTE_PREFIX$5 = "/api/dsh-chatgpt-subscription";
|
|
|
145
145
|
* `test/responses-client.test.ts` asserts the two agree, so a release that
|
|
146
146
|
* forgets this constant fails the suite instead of shipping quietly.
|
|
147
147
|
*/
|
|
148
|
-
const PLUGIN_VERSION = "0.48.
|
|
148
|
+
const PLUGIN_VERSION = "0.48.2";
|
|
149
149
|
const CODEX_CHATGPT_PROVIDER_ID = "codex-chatgpt";
|
|
150
150
|
const CODEX_API_BASE = "https://chatgpt.com/backend-api/codex";
|
|
151
151
|
const CODEX_RESPONSES_URL = `${CODEX_API_BASE}/responses`;
|
|
@@ -80832,10 +80832,11 @@ function installCompactionPrompt(ctx) {
|
|
|
80832
80832
|
* realm 的 `ctx.reflect.store` 里,宿主平面根本看不到它,也就没有地方把
|
|
80833
80833
|
* "这场会话的 provider 该不该修剪" 插进去。
|
|
80834
80834
|
*
|
|
80835
|
-
*
|
|
80835
|
+
* 这一层守卫因此待在**宿主平面**:它不替换任何行,只在下述时机把已经挂载
|
|
80836
80836
|
* 的 `toolResultPruner` 实例的 `pruneSession` 包一层 provider 短路 ——
|
|
80837
|
-
* 安装时先扫一遍,此后每个 agent 开始一步(`agent/pre-step
|
|
80838
|
-
* (`agent/request-error
|
|
80837
|
+
* 安装时先扫一遍,此后每个 agent 开始一步(`agent/pre-step`)、每次发起请求
|
|
80838
|
+
* (`agent/request`)或撞上上下文溢出(`agent/request-error`)时再扫一遍。
|
|
80839
|
+
* 三个事件都是 Cordis **瀑布**事件,监听器必须转交 `next()`(见下)。两个位置都要看:
|
|
80839
80840
|
*
|
|
80840
80841
|
* - `ctx.reflect.store`(宿主平面自己的服务记录,含安装后才挂上的实例);
|
|
80841
80842
|
* - `agent.ctx.get('toolResultPruner')` 与 `agent.ctx.reflect.store`
|
|
@@ -80844,6 +80845,17 @@ function installCompactionPrompt(ctx) {
|
|
|
80844
80845
|
* 包装按 `WeakSet` 幂等,重复事件不会叠第二层;`dispose()` 逐条还原原方法并
|
|
80845
80846
|
* 摘掉监听器。
|
|
80846
80847
|
*
|
|
80848
|
+
* ## 瀑布事件必须转交 `next()`
|
|
80849
|
+
*
|
|
80850
|
+
* `agent/pre-step` / `agent/request` / `agent/request-error` 是 Cordis **瀑布**事件
|
|
80851
|
+
* (`ctx.waterfall`),最后一个参数就是 `next`。瀑布的返回值是**最外层监听器的返回值**:不调用 `next()`
|
|
80852
|
+
* 等于替整条链做了决定——后续监听器(连同内置的默认行为)一个都不跑,瀑布的返回值
|
|
80853
|
+
* 也变成监听器自己的返回值。于是 `agent-loop` 读 `decision.kind` 时拿到
|
|
80854
|
+
* `undefined`,每一轮都炸成
|
|
80855
|
+
* `TypeError: Cannot read properties of undefined (reading 'kind')`。
|
|
80856
|
+
* 本守卫是旁路,扫描失败只吞掉扫描本身,但 `next()` 在所有分支上都要被调用并原样
|
|
80857
|
+
* 交回去。
|
|
80858
|
+
*
|
|
80847
80859
|
* ## 只做短路,不改语义
|
|
80848
80860
|
*
|
|
80849
80861
|
* 包装后的 `pruneSession` 只有一条分支:`shouldSkipPruningForSession` 命中就
|
|
@@ -80852,8 +80864,12 @@ function installCompactionPrompt(ctx) {
|
|
|
80852
80864
|
*
|
|
80853
80865
|
* @module @eddyskywalker/dsh-chatgpt-subscription/host/tool-result-pruner-guard
|
|
80854
80866
|
*/
|
|
80855
|
-
/**
|
|
80856
|
-
const GUARDED_EVENTS$1 = [
|
|
80867
|
+
/** 会先跑一遍扫描的宿主事件(全部是 Cordis 瀑布事件,监听器必须转交 `next()`)。 */
|
|
80868
|
+
const GUARDED_EVENTS$1 = [
|
|
80869
|
+
"agent/pre-step",
|
|
80870
|
+
"agent/request",
|
|
80871
|
+
"agent/request-error"
|
|
80872
|
+
];
|
|
80857
80873
|
/**
|
|
80858
80874
|
* 安装跨 preset 守卫。
|
|
80859
80875
|
*
|
|
@@ -80970,16 +80986,32 @@ function installToolResultPrunerGuard(ctx, options = {}) {
|
|
|
80970
80986
|
/**
|
|
80971
80987
|
* 事件回调:先扫宿主平面,再扫事件里那个 agent 自己的 realm。
|
|
80972
80988
|
*
|
|
80973
|
-
*
|
|
80989
|
+
* ## 瀑布必须转交
|
|
80990
|
+
*
|
|
80991
|
+
* `agent/pre-step` / `agent/request` / `agent/request-error` 在 DSH 里是 Cordis
|
|
80992
|
+
* **瀑布**事件(`ctx.waterfall`),最后一个参数就是 `next`。瀑布的返回值是**最外层监听器
|
|
80993
|
+
* 的返回值**:不调用 `next()` 等于替整条链做了决定——后续监听器(连同内置的
|
|
80994
|
+
* 默认行为)一个都不会跑,瀑布的返回值也变成监听器自己的返回值(这里是
|
|
80995
|
+
* `undefined`)。`agent-loop` 随后读 `decision.kind`,于是每一轮都炸成
|
|
80996
|
+
* `TypeError: Cannot read properties of undefined (reading 'kind')`。
|
|
80997
|
+
*
|
|
80998
|
+
* 所以扫描照旧做(扫描失败也只吞掉扫描本身),但 `next()` **必须**在所有分支上
|
|
80999
|
+
* 被调用,并把它的结果原样交回去。
|
|
81000
|
+
*
|
|
81001
|
+
* @param args - 事件参数(最后一个参数可能是 `next`)。
|
|
81002
|
+
* @returns `next()` 的结果;没有 `next` 时为 `undefined`。
|
|
80974
81003
|
*/
|
|
80975
81004
|
const handleAgentEvent = (...args) => {
|
|
81005
|
+
const next = args.length > 0 && typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
80976
81006
|
try {
|
|
80977
81007
|
scanAndWrap();
|
|
80978
81008
|
const agentCtx = findAgentContext$1(args);
|
|
80979
|
-
if (agentCtx
|
|
80980
|
-
|
|
80981
|
-
|
|
81009
|
+
if (agentCtx !== void 0) {
|
|
81010
|
+
scanStore(agentCtx);
|
|
81011
|
+
wrapServiceFrom(agentCtx, PRUNER_SERVICE_NAME);
|
|
81012
|
+
}
|
|
80982
81013
|
} catch {}
|
|
81014
|
+
return next === void 0 ? void 0 : next();
|
|
80983
81015
|
};
|
|
80984
81016
|
for (const event of GUARDED_EVENTS$1) {
|
|
80985
81017
|
const disposer = subscribe$3(host, event, handleAgentEvent);
|
|
@@ -81893,6 +81925,17 @@ function markPatched$1(patched, holder, name) {
|
|
|
81893
81925
|
* `agent.options`),把确切的 provider/model 登记进来——于是匹配用的是 100%
|
|
81894
81926
|
* 标准的普通对象,没有一行依赖 Proxy 的巧合。
|
|
81895
81927
|
*
|
|
81928
|
+
* ## 瀑布事件必须转交 `next()`
|
|
81929
|
+
*
|
|
81930
|
+
* `agent/pre-step` / `agent/request` / `agent/request-error` 是 Cordis **瀑布**事件
|
|
81931
|
+
* (`ctx.waterfall`),最后一个参数就是 `next`。瀑布的返回值是**最外层监听器的
|
|
81932
|
+
* 返回值**:不调用 `next()` 等于替整条链做了决定——后续监听器(连同内置的默认行为)
|
|
81933
|
+
* 一个都不跑,瀑布的返回值也变成监听器自己的返回值。于是 `agent-loop` 读
|
|
81934
|
+
* `decision.kind` / `proposedConfig.provider` 时拿到 `undefined`,每一轮都炸成
|
|
81935
|
+
* `TypeError: Cannot read properties of undefined (reading 'kind')`。
|
|
81936
|
+
* 本守卫是旁路,观测与扫描失败只吞掉它们自己,但 `next()` 在所有分支上都要被调用
|
|
81937
|
+
* 并原样交回去。
|
|
81938
|
+
*
|
|
81896
81939
|
* @module @eddyskywalker/dsh-chatgpt-subscription/host/compaction-policy-guard
|
|
81897
81940
|
*/
|
|
81898
81941
|
/** 压缩服务的名字(`ctx.reflect.store` 与 `ctx.get` 都用它)。 */
|
|
@@ -82235,9 +82278,24 @@ function installCompactionPolicyGuard(ctx, options = {}) {
|
|
|
82235
82278
|
/**
|
|
82236
82279
|
* 事件回调:先观测模型,再扫宿主平面与 agent 自己的 realm。
|
|
82237
82280
|
*
|
|
82238
|
-
*
|
|
82281
|
+
* ## 瀑布必须转交
|
|
82282
|
+
*
|
|
82283
|
+
* `agent/pre-step` / `agent/request` / `agent/request-error` 在 DSH 里是
|
|
82284
|
+
* Cordis **瀑布**事件(`ctx.waterfall`),最后一个参数就是 `next`。瀑布的返回值
|
|
82285
|
+
* 是**最外层监听器的返回值**:不调用 `next()` 等于替整条链做了决定——后续监听器
|
|
82286
|
+
* (连同内置的默认行为)一个都不会跑,瀑布的返回值也变成监听器自己的返回值
|
|
82287
|
+
* (这里是 `undefined`)。`agent-loop` 随后读 `decision.kind` 与
|
|
82288
|
+
* `proposedConfig.provider`,于是每一轮都炸成
|
|
82289
|
+
* `TypeError: Cannot read properties of undefined (reading 'kind')`。
|
|
82290
|
+
*
|
|
82291
|
+
* 所以观测与扫描照旧做(失败也只吞掉扫描本身),但 `next()` **必须**在所有分支上
|
|
82292
|
+
* 被调用,并把它的结果原样交回去。
|
|
82293
|
+
*
|
|
82294
|
+
* @param args - 事件参数(最后一个参数可能是 `next`)。
|
|
82295
|
+
* @returns `next()` 的结果;没有 `next` 时为 `undefined`。
|
|
82239
82296
|
*/
|
|
82240
82297
|
const handleAgentEvent = (...args) => {
|
|
82298
|
+
const next = args.length > 0 && typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
82241
82299
|
try {
|
|
82242
82300
|
for (const arg of args) {
|
|
82243
82301
|
observeFrom(arg);
|
|
@@ -82245,10 +82303,12 @@ function installCompactionPolicyGuard(ctx, options = {}) {
|
|
|
82245
82303
|
}
|
|
82246
82304
|
scanAndPatch();
|
|
82247
82305
|
const agentCtx = findAgentContext(args);
|
|
82248
|
-
if (agentCtx
|
|
82249
|
-
|
|
82250
|
-
|
|
82306
|
+
if (agentCtx !== void 0) {
|
|
82307
|
+
scanStore(agentCtx);
|
|
82308
|
+
patchServiceFrom(agentCtx, COMPACTION_SERVICE_NAME);
|
|
82309
|
+
}
|
|
82251
82310
|
} catch {}
|
|
82311
|
+
return next === void 0 ? void 0 : next();
|
|
82252
82312
|
};
|
|
82253
82313
|
for (const event of GUARDED_EVENTS) {
|
|
82254
82314
|
const disposer = subscribe(host, event, handleAgentEvent);
|
package/lib/types/compat.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export declare const ROUTE_PREFIX: "/api/dsh-chatgpt-subscription";
|
|
|
71
71
|
* `test/responses-client.test.ts` asserts the two agree, so a release that
|
|
72
72
|
* forgets this constant fails the suite instead of shipping quietly.
|
|
73
73
|
*/
|
|
74
|
-
export declare const PLUGIN_VERSION: "0.48.
|
|
74
|
+
export declare const PLUGIN_VERSION: "0.48.2";
|
|
75
75
|
export declare const CODEX_CHATGPT_PROVIDER_ID: "codex-chatgpt";
|
|
76
76
|
export { MINIMAX_CODE_PROVIDER_ID, MINIMAX_CODE_ROUTE_PREFIX } from './shared/minimax-code-contracts.ts';
|
|
77
77
|
export declare const CODEX_API_BASE: "https://chatgpt.com/backend-api/codex";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-policy-guard.d.ts","sourceRoot":"","sources":["../../../src/host/compaction-policy-guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compaction-policy-guard.d.ts","sourceRoot":"","sources":["../../../src/host/compaction-policy-guard.ts"],"names":[],"mappings":"AAuEA,oDAAoD;AACpD,eAAO,MAAM,uBAAuB,eAAe,CAAA;AAEnD,uBAAuB;AACvB,eAAO,MAAM,wBAAwB,cAAc,CAAA;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B;;;;;;;EAO1C,CAAA;AAEF,2BAA2B;AAC3B,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAO5C,CAAA;AAEF,YAAY;AACZ,MAAM,WAAW,4BAA4B;IAC3C,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,YAAY;AACZ,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,OAAO,IAAI,IAAI,CAAA;IACf;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;CACtC;AAiCD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAmavB;AAgOD,eAAe,4BAA4B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-result-pruner-guard.d.ts","sourceRoot":"","sources":["../../../src/host/tool-result-pruner-guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-result-pruner-guard.d.ts","sourceRoot":"","sources":["../../../src/host/tool-result-pruner-guard.ts"],"names":[],"mappings":"AAkDA,aAAa;AACb,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC;AAED,YAAY;AACZ,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,OAAO,IAAI,IAAI,CAAA;IACf;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;CACrC;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAoLvB;AAuOD,eAAe,4BAA4B,CAAA"}
|