@shuind/dsh-codex-harness 0.1.10 → 0.1.12
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/LICENSE +21 -21
- package/README.md +27 -6
- package/README.zh.md +3 -3
- package/cordis.patch.yml +5 -5
- package/lib/client.js +633 -0
- package/lib/index.js +445 -4
- package/lib/types/client/index.d.ts +40 -0
- package/lib/types/client/index.js +112 -0
- package/lib/types/context.d.ts +5 -0
- package/lib/types/context.js +5 -0
- package/lib/types/index.d.ts +32 -0
- package/lib/types/index.js +156 -1
- package/lib/types/patch.js +15 -15
- package/lib/types/remote.d.ts +21 -0
- package/lib/types/remote.js +324 -0
- package/package.json +99 -13
- package/presets/codex/agent.cordis.yml +13 -0
- package/presets/codex/preset.yml +3 -3
package/lib/client.js
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@shuind/dsh-codex-harness",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperties(exports, {
|
|
7
|
+
__esModule: { value: true },
|
|
8
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
9
|
+
});
|
|
10
|
+
//#region \0rolldown/runtime.js
|
|
11
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
14
|
+
/**
|
|
15
|
+
* @license React
|
|
16
|
+
* react.production.min.js
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/
|
|
23
|
+
var require_react_production_min = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
24
|
+
var l = Symbol.for("react.element");
|
|
25
|
+
var n = Symbol.for("react.portal");
|
|
26
|
+
var p = Symbol.for("react.fragment");
|
|
27
|
+
var q = Symbol.for("react.strict_mode");
|
|
28
|
+
var r = Symbol.for("react.profiler");
|
|
29
|
+
var t = Symbol.for("react.provider");
|
|
30
|
+
var u = Symbol.for("react.context");
|
|
31
|
+
var v = Symbol.for("react.forward_ref");
|
|
32
|
+
var w = Symbol.for("react.suspense");
|
|
33
|
+
var x = Symbol.for("react.memo");
|
|
34
|
+
var y = Symbol.for("react.lazy");
|
|
35
|
+
var z = Symbol.iterator;
|
|
36
|
+
function A(a) {
|
|
37
|
+
if (null === a || "object" !== typeof a) return null;
|
|
38
|
+
a = z && a[z] || a["@@iterator"];
|
|
39
|
+
return "function" === typeof a ? a : null;
|
|
40
|
+
}
|
|
41
|
+
var B = {
|
|
42
|
+
isMounted: function() {
|
|
43
|
+
return !1;
|
|
44
|
+
},
|
|
45
|
+
enqueueForceUpdate: function() {},
|
|
46
|
+
enqueueReplaceState: function() {},
|
|
47
|
+
enqueueSetState: function() {}
|
|
48
|
+
};
|
|
49
|
+
var C = Object.assign;
|
|
50
|
+
var D = {};
|
|
51
|
+
function E(a, b, e) {
|
|
52
|
+
this.props = a;
|
|
53
|
+
this.context = b;
|
|
54
|
+
this.refs = D;
|
|
55
|
+
this.updater = e || B;
|
|
56
|
+
}
|
|
57
|
+
E.prototype.isReactComponent = {};
|
|
58
|
+
E.prototype.setState = function(a, b) {
|
|
59
|
+
if ("object" !== typeof a && "function" !== typeof a && null != a) throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
60
|
+
this.updater.enqueueSetState(this, a, b, "setState");
|
|
61
|
+
};
|
|
62
|
+
E.prototype.forceUpdate = function(a) {
|
|
63
|
+
this.updater.enqueueForceUpdate(this, a, "forceUpdate");
|
|
64
|
+
};
|
|
65
|
+
function F() {}
|
|
66
|
+
F.prototype = E.prototype;
|
|
67
|
+
function G(a, b, e) {
|
|
68
|
+
this.props = a;
|
|
69
|
+
this.context = b;
|
|
70
|
+
this.refs = D;
|
|
71
|
+
this.updater = e || B;
|
|
72
|
+
}
|
|
73
|
+
var H = G.prototype = new F();
|
|
74
|
+
H.constructor = G;
|
|
75
|
+
C(H, E.prototype);
|
|
76
|
+
H.isPureReactComponent = !0;
|
|
77
|
+
var I = Array.isArray;
|
|
78
|
+
var J = Object.prototype.hasOwnProperty;
|
|
79
|
+
var K = { current: null };
|
|
80
|
+
var L = {
|
|
81
|
+
key: !0,
|
|
82
|
+
ref: !0,
|
|
83
|
+
__self: !0,
|
|
84
|
+
__source: !0
|
|
85
|
+
};
|
|
86
|
+
function M(a, b, e) {
|
|
87
|
+
var d, c = {}, k = null, h = null;
|
|
88
|
+
if (null != b) for (d in void 0 !== b.ref && (h = b.ref), void 0 !== b.key && (k = "" + b.key), b) J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]);
|
|
89
|
+
var g = arguments.length - 2;
|
|
90
|
+
if (1 === g) c.children = e;
|
|
91
|
+
else if (1 < g) {
|
|
92
|
+
for (var f = Array(g), m = 0; m < g; m++) f[m] = arguments[m + 2];
|
|
93
|
+
c.children = f;
|
|
94
|
+
}
|
|
95
|
+
if (a && a.defaultProps) for (d in g = a.defaultProps, g) void 0 === c[d] && (c[d] = g[d]);
|
|
96
|
+
return {
|
|
97
|
+
$$typeof: l,
|
|
98
|
+
type: a,
|
|
99
|
+
key: k,
|
|
100
|
+
ref: h,
|
|
101
|
+
props: c,
|
|
102
|
+
_owner: K.current
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function N(a, b) {
|
|
106
|
+
return {
|
|
107
|
+
$$typeof: l,
|
|
108
|
+
type: a.type,
|
|
109
|
+
key: b,
|
|
110
|
+
ref: a.ref,
|
|
111
|
+
props: a.props,
|
|
112
|
+
_owner: a._owner
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function O(a) {
|
|
116
|
+
return "object" === typeof a && null !== a && a.$$typeof === l;
|
|
117
|
+
}
|
|
118
|
+
function escape(a) {
|
|
119
|
+
var b = {
|
|
120
|
+
"=": "=0",
|
|
121
|
+
":": "=2"
|
|
122
|
+
};
|
|
123
|
+
return "$" + a.replace(/[=:]/g, function(a) {
|
|
124
|
+
return b[a];
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
var P = /\/+/g;
|
|
128
|
+
function Q(a, b) {
|
|
129
|
+
return "object" === typeof a && null !== a && null != a.key ? escape("" + a.key) : b.toString(36);
|
|
130
|
+
}
|
|
131
|
+
function R(a, b, e, d, c) {
|
|
132
|
+
var k = typeof a;
|
|
133
|
+
if ("undefined" === k || "boolean" === k) a = null;
|
|
134
|
+
var h = !1;
|
|
135
|
+
if (null === a) h = !0;
|
|
136
|
+
else switch (k) {
|
|
137
|
+
case "string":
|
|
138
|
+
case "number":
|
|
139
|
+
h = !0;
|
|
140
|
+
break;
|
|
141
|
+
case "object": switch (a.$$typeof) {
|
|
142
|
+
case l:
|
|
143
|
+
case n: h = !0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (h) return h = a, c = c(h), a = "" === d ? "." + Q(h, 0) : d, I(c) ? (e = "", null != a && (e = a.replace(P, "$&/") + "/"), R(c, b, e, "", function(a) {
|
|
147
|
+
return a;
|
|
148
|
+
})) : null != c && (O(c) && (c = N(c, e + (!c.key || h && h.key === c.key ? "" : ("" + c.key).replace(P, "$&/") + "/") + a)), b.push(c)), 1;
|
|
149
|
+
h = 0;
|
|
150
|
+
d = "" === d ? "." : d + ":";
|
|
151
|
+
if (I(a)) for (var g = 0; g < a.length; g++) {
|
|
152
|
+
k = a[g];
|
|
153
|
+
var f = d + Q(k, g);
|
|
154
|
+
h += R(k, b, e, f, c);
|
|
155
|
+
}
|
|
156
|
+
else if (f = A(a), "function" === typeof f) for (a = f.call(a), g = 0; !(k = a.next()).done;) k = k.value, f = d + Q(k, g++), h += R(k, b, e, f, c);
|
|
157
|
+
else if ("object" === k) throw b = String(a), Error("Objects are not valid as a React child (found: " + ("[object Object]" === b ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead.");
|
|
158
|
+
return h;
|
|
159
|
+
}
|
|
160
|
+
function S(a, b, e) {
|
|
161
|
+
if (null == a) return a;
|
|
162
|
+
var d = [], c = 0;
|
|
163
|
+
R(a, d, "", "", function(a) {
|
|
164
|
+
return b.call(e, a, c++);
|
|
165
|
+
});
|
|
166
|
+
return d;
|
|
167
|
+
}
|
|
168
|
+
function T(a) {
|
|
169
|
+
if (-1 === a._status) {
|
|
170
|
+
var b = a._result;
|
|
171
|
+
b = b();
|
|
172
|
+
b.then(function(b) {
|
|
173
|
+
if (0 === a._status || -1 === a._status) a._status = 1, a._result = b;
|
|
174
|
+
}, function(b) {
|
|
175
|
+
if (0 === a._status || -1 === a._status) a._status = 2, a._result = b;
|
|
176
|
+
});
|
|
177
|
+
-1 === a._status && (a._status = 0, a._result = b);
|
|
178
|
+
}
|
|
179
|
+
if (1 === a._status) return a._result.default;
|
|
180
|
+
throw a._result;
|
|
181
|
+
}
|
|
182
|
+
var U = { current: null };
|
|
183
|
+
var V = { transition: null };
|
|
184
|
+
var W = {
|
|
185
|
+
ReactCurrentDispatcher: U,
|
|
186
|
+
ReactCurrentBatchConfig: V,
|
|
187
|
+
ReactCurrentOwner: K
|
|
188
|
+
};
|
|
189
|
+
function X() {
|
|
190
|
+
throw Error("act(...) is not supported in production builds of React.");
|
|
191
|
+
}
|
|
192
|
+
exports.Children = {
|
|
193
|
+
map: S,
|
|
194
|
+
forEach: function(a, b, e) {
|
|
195
|
+
S(a, function() {
|
|
196
|
+
b.apply(this, arguments);
|
|
197
|
+
}, e);
|
|
198
|
+
},
|
|
199
|
+
count: function(a) {
|
|
200
|
+
var b = 0;
|
|
201
|
+
S(a, function() {
|
|
202
|
+
b++;
|
|
203
|
+
});
|
|
204
|
+
return b;
|
|
205
|
+
},
|
|
206
|
+
toArray: function(a) {
|
|
207
|
+
return S(a, function(a) {
|
|
208
|
+
return a;
|
|
209
|
+
}) || [];
|
|
210
|
+
},
|
|
211
|
+
only: function(a) {
|
|
212
|
+
if (!O(a)) throw Error("React.Children.only expected to receive a single React element child.");
|
|
213
|
+
return a;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
exports.Component = E;
|
|
217
|
+
exports.Fragment = p;
|
|
218
|
+
exports.Profiler = r;
|
|
219
|
+
exports.PureComponent = G;
|
|
220
|
+
exports.StrictMode = q;
|
|
221
|
+
exports.Suspense = w;
|
|
222
|
+
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = W;
|
|
223
|
+
exports.act = X;
|
|
224
|
+
exports.cloneElement = function(a, b, e) {
|
|
225
|
+
if (null === a || void 0 === a) throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + a + ".");
|
|
226
|
+
var d = C({}, a.props), c = a.key, k = a.ref, h = a._owner;
|
|
227
|
+
if (null != b) {
|
|
228
|
+
void 0 !== b.ref && (k = b.ref, h = K.current);
|
|
229
|
+
void 0 !== b.key && (c = "" + b.key);
|
|
230
|
+
if (a.type && a.type.defaultProps) var g = a.type.defaultProps;
|
|
231
|
+
for (f in b) J.call(b, f) && !L.hasOwnProperty(f) && (d[f] = void 0 === b[f] && void 0 !== g ? g[f] : b[f]);
|
|
232
|
+
}
|
|
233
|
+
var f = arguments.length - 2;
|
|
234
|
+
if (1 === f) d.children = e;
|
|
235
|
+
else if (1 < f) {
|
|
236
|
+
g = Array(f);
|
|
237
|
+
for (var m = 0; m < f; m++) g[m] = arguments[m + 2];
|
|
238
|
+
d.children = g;
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
$$typeof: l,
|
|
242
|
+
type: a.type,
|
|
243
|
+
key: c,
|
|
244
|
+
ref: k,
|
|
245
|
+
props: d,
|
|
246
|
+
_owner: h
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
exports.createContext = function(a) {
|
|
250
|
+
a = {
|
|
251
|
+
$$typeof: u,
|
|
252
|
+
_currentValue: a,
|
|
253
|
+
_currentValue2: a,
|
|
254
|
+
_threadCount: 0,
|
|
255
|
+
Provider: null,
|
|
256
|
+
Consumer: null,
|
|
257
|
+
_defaultValue: null,
|
|
258
|
+
_globalName: null
|
|
259
|
+
};
|
|
260
|
+
a.Provider = {
|
|
261
|
+
$$typeof: t,
|
|
262
|
+
_context: a
|
|
263
|
+
};
|
|
264
|
+
return a.Consumer = a;
|
|
265
|
+
};
|
|
266
|
+
exports.createElement = M;
|
|
267
|
+
exports.createFactory = function(a) {
|
|
268
|
+
var b = M.bind(null, a);
|
|
269
|
+
b.type = a;
|
|
270
|
+
return b;
|
|
271
|
+
};
|
|
272
|
+
exports.createRef = function() {
|
|
273
|
+
return { current: null };
|
|
274
|
+
};
|
|
275
|
+
exports.forwardRef = function(a) {
|
|
276
|
+
return {
|
|
277
|
+
$$typeof: v,
|
|
278
|
+
render: a
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
exports.isValidElement = O;
|
|
282
|
+
exports.lazy = function(a) {
|
|
283
|
+
return {
|
|
284
|
+
$$typeof: y,
|
|
285
|
+
_payload: {
|
|
286
|
+
_status: -1,
|
|
287
|
+
_result: a
|
|
288
|
+
},
|
|
289
|
+
_init: T
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
exports.memo = function(a, b) {
|
|
293
|
+
return {
|
|
294
|
+
$$typeof: x,
|
|
295
|
+
type: a,
|
|
296
|
+
compare: void 0 === b ? null : b
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
exports.startTransition = function(a) {
|
|
300
|
+
var b = V.transition;
|
|
301
|
+
V.transition = {};
|
|
302
|
+
try {
|
|
303
|
+
a();
|
|
304
|
+
} finally {
|
|
305
|
+
V.transition = b;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
exports.unstable_act = X;
|
|
309
|
+
exports.useCallback = function(a, b) {
|
|
310
|
+
return U.current.useCallback(a, b);
|
|
311
|
+
};
|
|
312
|
+
exports.useContext = function(a) {
|
|
313
|
+
return U.current.useContext(a);
|
|
314
|
+
};
|
|
315
|
+
exports.useDebugValue = function() {};
|
|
316
|
+
exports.useDeferredValue = function(a) {
|
|
317
|
+
return U.current.useDeferredValue(a);
|
|
318
|
+
};
|
|
319
|
+
exports.useEffect = function(a, b) {
|
|
320
|
+
return U.current.useEffect(a, b);
|
|
321
|
+
};
|
|
322
|
+
exports.useId = function() {
|
|
323
|
+
return U.current.useId();
|
|
324
|
+
};
|
|
325
|
+
exports.useImperativeHandle = function(a, b, e) {
|
|
326
|
+
return U.current.useImperativeHandle(a, b, e);
|
|
327
|
+
};
|
|
328
|
+
exports.useInsertionEffect = function(a, b) {
|
|
329
|
+
return U.current.useInsertionEffect(a, b);
|
|
330
|
+
};
|
|
331
|
+
exports.useLayoutEffect = function(a, b) {
|
|
332
|
+
return U.current.useLayoutEffect(a, b);
|
|
333
|
+
};
|
|
334
|
+
exports.useMemo = function(a, b) {
|
|
335
|
+
return U.current.useMemo(a, b);
|
|
336
|
+
};
|
|
337
|
+
exports.useReducer = function(a, b, e) {
|
|
338
|
+
return U.current.useReducer(a, b, e);
|
|
339
|
+
};
|
|
340
|
+
exports.useRef = function(a) {
|
|
341
|
+
return U.current.useRef(a);
|
|
342
|
+
};
|
|
343
|
+
exports.useState = function(a) {
|
|
344
|
+
return U.current.useState(a);
|
|
345
|
+
};
|
|
346
|
+
exports.useSyncExternalStore = function(a, b, e) {
|
|
347
|
+
return U.current.useSyncExternalStore(a, b, e);
|
|
348
|
+
};
|
|
349
|
+
exports.useTransition = function() {
|
|
350
|
+
return U.current.useTransition();
|
|
351
|
+
};
|
|
352
|
+
exports.version = "18.3.1";
|
|
353
|
+
}));
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
|
356
|
+
var require_react = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
357
|
+
module.exports = require_react_production_min();
|
|
358
|
+
}));
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js
|
|
361
|
+
/**
|
|
362
|
+
* @license React
|
|
363
|
+
* react-jsx-runtime.production.min.js
|
|
364
|
+
*
|
|
365
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
366
|
+
*
|
|
367
|
+
* This source code is licensed under the MIT license found in the
|
|
368
|
+
* LICENSE file in the root directory of this source tree.
|
|
369
|
+
*/
|
|
370
|
+
var require_react_jsx_runtime_production_min = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
371
|
+
var f = require_react();
|
|
372
|
+
var k = Symbol.for("react.element");
|
|
373
|
+
var m = Object.prototype.hasOwnProperty;
|
|
374
|
+
var n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
|
|
375
|
+
var p = {
|
|
376
|
+
key: !0,
|
|
377
|
+
ref: !0,
|
|
378
|
+
__self: !0,
|
|
379
|
+
__source: !0
|
|
380
|
+
};
|
|
381
|
+
function q(c, a, g) {
|
|
382
|
+
var b, d = {}, e = null, h = null;
|
|
383
|
+
void 0 !== g && (e = "" + g);
|
|
384
|
+
void 0 !== a.key && (e = "" + a.key);
|
|
385
|
+
void 0 !== a.ref && (h = a.ref);
|
|
386
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
387
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
|
|
388
|
+
return {
|
|
389
|
+
$$typeof: k,
|
|
390
|
+
type: c,
|
|
391
|
+
key: e,
|
|
392
|
+
ref: h,
|
|
393
|
+
props: d,
|
|
394
|
+
_owner: n.current
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
exports.jsx = q;
|
|
398
|
+
exports.jsxs = q;
|
|
399
|
+
}));
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region lib/types/context.js
|
|
402
|
+
var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
403
|
+
module.exports = require_react_jsx_runtime_production_min();
|
|
404
|
+
})))();
|
|
405
|
+
/** User-selectable Codex context controls use whole K-token units. */
|
|
406
|
+
const CODEX_CONTEXT_UNIT = 1e3;
|
|
407
|
+
const CODEX_CONTEXT_MAX = 1e6;
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region lib/types/client/index.js
|
|
410
|
+
const NS = "codex";
|
|
411
|
+
const SETTINGS_NAMESPACE = "codex";
|
|
412
|
+
const en = {
|
|
413
|
+
fast: "Fast mode",
|
|
414
|
+
fastOn: "Fast mode on (priority tier)",
|
|
415
|
+
fastOff: "Fast mode off",
|
|
416
|
+
fastStateOn: "On",
|
|
417
|
+
fastStateOff: "Off",
|
|
418
|
+
contextSize: "Context size",
|
|
419
|
+
contextSizeDescription: "Next request capacity in K tokens. The meter above is current.",
|
|
420
|
+
contextRestore: "Restore model default"
|
|
421
|
+
};
|
|
422
|
+
const zh = {
|
|
423
|
+
fast: "Fast",
|
|
424
|
+
fastOn: "Fast mode on (priority tier)",
|
|
425
|
+
fastOff: "Fast mode off",
|
|
426
|
+
fastStateOn: "开",
|
|
427
|
+
fastStateOff: "关",
|
|
428
|
+
contextSize: "上下文大小",
|
|
429
|
+
contextSizeDescription: "设置下次请求的上下文容量,单位为 K tokens;上方是当前请求。",
|
|
430
|
+
contextRestore: "恢复模型默认值"
|
|
431
|
+
};
|
|
432
|
+
function FastModeButton({ sessionId, useSessions, useSettings, setSetting, t }) {
|
|
433
|
+
const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
|
|
434
|
+
const snapshot = useSettings((state) => state);
|
|
435
|
+
const fast = snapshot.value?.fast ?? false;
|
|
436
|
+
if (agentPreset !== "codex") return null;
|
|
437
|
+
return (0, import_jsx_runtime.jsxs)("button", {
|
|
438
|
+
type: "button",
|
|
439
|
+
role: "menuitemcheckbox",
|
|
440
|
+
disabled: snapshot.writable === false,
|
|
441
|
+
"aria-pressed": fast,
|
|
442
|
+
"aria-label": fast ? t("fastOn") : t("fastOff"),
|
|
443
|
+
title: fast ? t("fastOn") : t("fastOff"),
|
|
444
|
+
onClick: () => {
|
|
445
|
+
setSetting("fast", !fast);
|
|
446
|
+
},
|
|
447
|
+
style: {
|
|
448
|
+
boxSizing: "border-box",
|
|
449
|
+
display: "flex",
|
|
450
|
+
alignItems: "center",
|
|
451
|
+
justifyContent: "space-between",
|
|
452
|
+
width: "100%",
|
|
453
|
+
height: 40,
|
|
454
|
+
border: 0,
|
|
455
|
+
borderRadius: 10,
|
|
456
|
+
padding: "0 10px",
|
|
457
|
+
color: fast ? "var(--dsw-static-blue-500)" : "var(--dsw-alias-label-secondary)",
|
|
458
|
+
background: fast ? "var(--dsw-alias-interactive-bg-selected)" : "transparent",
|
|
459
|
+
cursor: snapshot.writable === false ? "default" : "pointer",
|
|
460
|
+
font: "inherit",
|
|
461
|
+
fontSize: 14,
|
|
462
|
+
lineHeight: "22px",
|
|
463
|
+
fontWeight: fast ? 600 : 400,
|
|
464
|
+
textAlign: "left"
|
|
465
|
+
},
|
|
466
|
+
children: [(0, import_jsx_runtime.jsx)("span", { children: t("fast") }), (0, import_jsx_runtime.jsx)("span", {
|
|
467
|
+
style: {
|
|
468
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
469
|
+
fontSize: 12
|
|
470
|
+
},
|
|
471
|
+
children: fast ? t("fastStateOn") : t("fastStateOff")
|
|
472
|
+
})]
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function ContextSizeControl({ contextWindow, useSettings, setSetting, unsetSetting, t }) {
|
|
476
|
+
const snapshot = useSettings((state) => state);
|
|
477
|
+
const configured = snapshot.value?.contextWindow;
|
|
478
|
+
const maxK = CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT;
|
|
479
|
+
const valueK = Math.min(maxK, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
|
|
480
|
+
const setValueK = (nextK) => {
|
|
481
|
+
if (!Number.isFinite(nextK)) return;
|
|
482
|
+
const normalized = Math.min(maxK, Math.max(1, Math.trunc(nextK))) * CODEX_CONTEXT_UNIT;
|
|
483
|
+
if (normalized === contextWindow) unsetSetting("contextWindow");
|
|
484
|
+
else setSetting("contextWindow", normalized);
|
|
485
|
+
};
|
|
486
|
+
return (0, import_jsx_runtime.jsxs)("div", {
|
|
487
|
+
style: {
|
|
488
|
+
marginTop: 10,
|
|
489
|
+
display: "grid",
|
|
490
|
+
gap: 5
|
|
491
|
+
},
|
|
492
|
+
children: [
|
|
493
|
+
(0, import_jsx_runtime.jsxs)("div", {
|
|
494
|
+
style: {
|
|
495
|
+
display: "flex",
|
|
496
|
+
alignItems: "baseline",
|
|
497
|
+
justifyContent: "space-between",
|
|
498
|
+
gap: 12
|
|
499
|
+
},
|
|
500
|
+
children: [(0, import_jsx_runtime.jsx)("strong", {
|
|
501
|
+
style: {
|
|
502
|
+
color: "var(--dsw-alias-label-primary)",
|
|
503
|
+
fontSize: 12
|
|
504
|
+
},
|
|
505
|
+
children: t("contextSize")
|
|
506
|
+
}), (0, import_jsx_runtime.jsxs)("span", {
|
|
507
|
+
style: {
|
|
508
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
509
|
+
fontSize: 11
|
|
510
|
+
},
|
|
511
|
+
children: [valueK, "K"]
|
|
512
|
+
})]
|
|
513
|
+
}),
|
|
514
|
+
(0, import_jsx_runtime.jsx)("input", {
|
|
515
|
+
type: "range",
|
|
516
|
+
min: 1,
|
|
517
|
+
max: maxK,
|
|
518
|
+
step: 1,
|
|
519
|
+
value: valueK,
|
|
520
|
+
disabled: snapshot.writable === false,
|
|
521
|
+
"aria-label": t("contextSize"),
|
|
522
|
+
onChange: (event) => {
|
|
523
|
+
setValueK(Number(event.target.value));
|
|
524
|
+
}
|
|
525
|
+
}),
|
|
526
|
+
(0, import_jsx_runtime.jsxs)("div", {
|
|
527
|
+
style: {
|
|
528
|
+
display: "flex",
|
|
529
|
+
alignItems: "center",
|
|
530
|
+
gap: 7
|
|
531
|
+
},
|
|
532
|
+
children: [
|
|
533
|
+
(0, import_jsx_runtime.jsx)("input", {
|
|
534
|
+
type: "number",
|
|
535
|
+
min: 1,
|
|
536
|
+
max: maxK,
|
|
537
|
+
step: 1,
|
|
538
|
+
value: valueK,
|
|
539
|
+
disabled: snapshot.writable === false,
|
|
540
|
+
"aria-label": t("contextSize"),
|
|
541
|
+
onChange: (event) => {
|
|
542
|
+
setValueK(Number(event.target.value));
|
|
543
|
+
},
|
|
544
|
+
style: {
|
|
545
|
+
width: 76,
|
|
546
|
+
border: "1px solid var(--dsw-alias-border-primary)",
|
|
547
|
+
borderRadius: 5,
|
|
548
|
+
padding: "3px 5px",
|
|
549
|
+
color: "var(--dsw-alias-label-primary)",
|
|
550
|
+
background: "var(--dsw-alias-fill-primary)",
|
|
551
|
+
font: "inherit",
|
|
552
|
+
fontSize: 11
|
|
553
|
+
}
|
|
554
|
+
}),
|
|
555
|
+
(0, import_jsx_runtime.jsx)("span", {
|
|
556
|
+
style: {
|
|
557
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
558
|
+
fontSize: 11
|
|
559
|
+
},
|
|
560
|
+
children: "K"
|
|
561
|
+
}),
|
|
562
|
+
(0, import_jsx_runtime.jsx)("span", {
|
|
563
|
+
style: {
|
|
564
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
565
|
+
fontSize: 11
|
|
566
|
+
},
|
|
567
|
+
children: t("contextSizeDescription")
|
|
568
|
+
})
|
|
569
|
+
]
|
|
570
|
+
}),
|
|
571
|
+
configured !== void 0 && (0, import_jsx_runtime.jsx)("button", {
|
|
572
|
+
type: "button",
|
|
573
|
+
onClick: () => {
|
|
574
|
+
unsetSetting("contextWindow");
|
|
575
|
+
},
|
|
576
|
+
style: {
|
|
577
|
+
justifySelf: "start",
|
|
578
|
+
border: 0,
|
|
579
|
+
padding: 0,
|
|
580
|
+
color: "var(--dsw-static-blue-500)",
|
|
581
|
+
background: "transparent",
|
|
582
|
+
cursor: "pointer",
|
|
583
|
+
font: "inherit",
|
|
584
|
+
fontSize: 11
|
|
585
|
+
},
|
|
586
|
+
children: t("contextRestore")
|
|
587
|
+
})
|
|
588
|
+
]
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
const inject = [
|
|
592
|
+
"slots",
|
|
593
|
+
"locale",
|
|
594
|
+
"settingsScope"
|
|
595
|
+
];
|
|
596
|
+
/** Mount Fast inside the model selector and context size inside the meter panel. */
|
|
597
|
+
function apply(ctx) {
|
|
598
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
599
|
+
en,
|
|
600
|
+
zh
|
|
601
|
+
}), "codex client: dictionaries");
|
|
602
|
+
const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
|
|
603
|
+
const injected = () => ({
|
|
604
|
+
hooks: { settings },
|
|
605
|
+
setSetting: (field, value) => settings.set(field, value),
|
|
606
|
+
unsetSetting: (field) => settings.unset(field)
|
|
607
|
+
});
|
|
608
|
+
ctx.slots.inject("conversation.input.model.settings", () => ctx.slots.register({
|
|
609
|
+
name: "conversation.input.model.settings",
|
|
610
|
+
id: "codex-fast",
|
|
611
|
+
order: 0,
|
|
612
|
+
locale: NS,
|
|
613
|
+
inject: injected
|
|
614
|
+
}, FastModeButton));
|
|
615
|
+
ctx.slots.inject("conversation.input.context.settings", () => ctx.slots.register({
|
|
616
|
+
name: "conversation.input.context.settings",
|
|
617
|
+
id: "codex-context-size",
|
|
618
|
+
order: 0,
|
|
619
|
+
locale: NS,
|
|
620
|
+
inject: injected
|
|
621
|
+
}, ContextSizeControl));
|
|
622
|
+
}
|
|
623
|
+
var client_default = {
|
|
624
|
+
inject,
|
|
625
|
+
apply
|
|
626
|
+
};
|
|
627
|
+
//#endregion
|
|
628
|
+
exports.apply = apply;
|
|
629
|
+
exports.default = client_default;
|
|
630
|
+
exports.inject = inject;
|
|
631
|
+
return module.exports;
|
|
632
|
+
}
|
|
633
|
+
});
|