dsh-lcx-codex 0.6.0-pre.1 → 0.6.0
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 +45 -26
- package/THIRD_PARTY_NOTICES.md +3 -2
- package/lib/abort-error.js +12 -1
- package/lib/client.js +73 -39
- package/lib/compact-v2.js +16 -56
- package/lib/defaults.js +15 -0
- package/lib/dsh-compat.js +15 -76
- package/lib/dsh-responses.js +178 -120
- package/lib/grok-native-search.js +1 -3
- package/lib/index.js +219 -149
- package/lib/model-catalog.js +46 -0
- package/lib/native-checkpoint.js +23 -185
- package/lib/pi-responses-runtime.js +749 -165
- package/lib/provider-headers.js +31 -0
- package/lib/responses-request.js +30 -15
- package/lib/responses-stream.js +120 -215
- package/lib/route.js +206 -88
- package/lib/search-accounting.js +1 -16
- package/lib/search-usage.js +8 -2
- package/lib/token-budget.js +6 -41
- package/lib/tool-surface.js +14 -18
- package/lib/transport.js +89 -107
- package/lib/types/client/search-media.d.ts +0 -2
- package/lib/util.js +21 -0
- package/lib/web-run-output.js +0 -3
- package/lib/web-search-alpha.js +22 -27
- package/lib/web-search-capability.js +1 -3
- package/lib/web-search-hosted.js +2 -2
- package/lib/web-search-ref-store.js +1 -3
- package/package.json +36 -32
- package/lib/pi086-responses-allowlist.js +0 -131
package/lib/dsh-compat.js
CHANGED
|
@@ -56,8 +56,8 @@ export function readSelectedAgentRouteState(agent) {
|
|
|
56
56
|
return route;
|
|
57
57
|
// Cold/resumed Agents recover pending selection from DSH's public projection.
|
|
58
58
|
const projections = resolveScopedService(agent, "sessionProjections");
|
|
59
|
-
if (
|
|
60
|
-
const selection =
|
|
59
|
+
if (typeof projections?.stateOf === "function") {
|
|
60
|
+
const selection = projections.stateOf(session, "modelSelection");
|
|
61
61
|
if (mutableService(selection))
|
|
62
62
|
return { ...route, requestConfig: selection.pending ?? route.requestConfig };
|
|
63
63
|
}
|
|
@@ -66,13 +66,11 @@ export function readSelectedAgentRouteState(agent) {
|
|
|
66
66
|
}
|
|
67
67
|
export function scopedToolRuntime(agent) {
|
|
68
68
|
const tools = resolveScopedService(agent, "tools");
|
|
69
|
-
if (
|
|
69
|
+
if (typeof tools?.register !== "function")
|
|
70
70
|
return undefined;
|
|
71
71
|
return {
|
|
72
72
|
register: tools.register.bind(tools),
|
|
73
|
-
...(typeof tools.get === "function"
|
|
74
|
-
? { get: tools.get.bind(tools) }
|
|
75
|
-
: {}),
|
|
73
|
+
...(typeof tools.get === "function" ? { get: tools.get.bind(tools) } : {}),
|
|
76
74
|
};
|
|
77
75
|
}
|
|
78
76
|
/**
|
|
@@ -82,31 +80,32 @@ export function scopedToolRuntime(agent) {
|
|
|
82
80
|
*/
|
|
83
81
|
export function onScopedToolExecute(agent, listener) {
|
|
84
82
|
const ctx = agentLike(agent)?.ctx;
|
|
85
|
-
if (
|
|
83
|
+
if (typeof ctx?.on !== "function")
|
|
86
84
|
return undefined;
|
|
87
85
|
try {
|
|
88
|
-
const dispose =
|
|
89
|
-
return typeof dispose === "function" ? () => void
|
|
86
|
+
const dispose = ctx.on("tools/execute", listener);
|
|
87
|
+
return typeof dispose === "function" ? () => void dispose() : undefined;
|
|
90
88
|
}
|
|
91
89
|
catch {
|
|
92
90
|
return undefined;
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
export function tokenMeterTotal(value, session) {
|
|
96
|
-
|
|
94
|
+
const meter = value;
|
|
95
|
+
if (typeof meter?.measure !== "function")
|
|
97
96
|
return undefined;
|
|
98
|
-
const measurement =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
const measurement = meter.measure(session);
|
|
98
|
+
return typeof measurement?.totalTokens === "number" && Number.isFinite(measurement.totalTokens)
|
|
99
|
+
? measurement.totalTokens
|
|
100
|
+
: undefined;
|
|
102
101
|
}
|
|
103
102
|
export function sessionsService(ctx) {
|
|
104
103
|
const service = resolveContextService(ctx, "sessions");
|
|
105
|
-
if (
|
|
104
|
+
if (typeof service?.get !== "function")
|
|
106
105
|
return undefined;
|
|
107
106
|
return {
|
|
108
107
|
get(id) {
|
|
109
|
-
const value =
|
|
108
|
+
const value = service.get?.(id);
|
|
110
109
|
return value instanceof Session ? value : undefined;
|
|
111
110
|
},
|
|
112
111
|
};
|
|
@@ -116,30 +115,6 @@ export function sessionFor(ctx, sessionId) {
|
|
|
116
115
|
? sessionsService(ctx)?.get(SessionId(sessionId))
|
|
117
116
|
: undefined;
|
|
118
117
|
}
|
|
119
|
-
export function readWebSearchProvider(ctx) {
|
|
120
|
-
const web = resolveContextService(ctx, "web");
|
|
121
|
-
if (!mutableService(web))
|
|
122
|
-
return undefined;
|
|
123
|
-
try {
|
|
124
|
-
return Reflect.get(web, "searchProviderId");
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export function writeWebSearchProvider(ctx, providerId) {
|
|
131
|
-
const web = resolveContextService(ctx, "web");
|
|
132
|
-
if (!mutableService(web))
|
|
133
|
-
return false;
|
|
134
|
-
try {
|
|
135
|
-
if (!Reflect.set(web, "searchProviderId", providerId))
|
|
136
|
-
return false;
|
|
137
|
-
return Reflect.get(web, "searchProviderId") === providerId;
|
|
138
|
-
}
|
|
139
|
-
catch {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
118
|
export function contextService(ctx, name) {
|
|
144
119
|
if (!mutableService(ctx))
|
|
145
120
|
return undefined;
|
|
@@ -334,39 +309,3 @@ export function restoreCompactionConfig(record) {
|
|
|
334
309
|
catch { }
|
|
335
310
|
}
|
|
336
311
|
}
|
|
337
|
-
export function patchVisibleWebSearchTimeout(agent, getTimeoutMs, patchedDefinitions) {
|
|
338
|
-
const tools = resolveScopedService(agent, "tools");
|
|
339
|
-
if (!mutableService(tools) || typeof tools.get !== "function")
|
|
340
|
-
return;
|
|
341
|
-
const definition = Reflect.apply(tools.get, tools, ["web_search", agent]);
|
|
342
|
-
if (!mutableService(definition))
|
|
343
|
-
return;
|
|
344
|
-
if (!patchedDefinitions.has(definition))
|
|
345
|
-
patchedDefinitions.set(definition, definition.timeoutMs);
|
|
346
|
-
const timeoutMs = getTimeoutMs();
|
|
347
|
-
const target = timeoutMs === undefined ? patchedDefinitions.get(definition) : timeoutMs;
|
|
348
|
-
try {
|
|
349
|
-
definition.timeoutMs = target;
|
|
350
|
-
}
|
|
351
|
-
catch { }
|
|
352
|
-
}
|
|
353
|
-
export function refreshVisibleWebSearchTimeouts(patchedDefinitions, timeoutMs) {
|
|
354
|
-
for (const [definition, original] of patchedDefinitions) {
|
|
355
|
-
try {
|
|
356
|
-
definition.timeoutMs = timeoutMs === undefined ? original : timeoutMs;
|
|
357
|
-
}
|
|
358
|
-
catch { }
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
export function restoreVisibleWebSearchTimeouts(patchedDefinitions) {
|
|
362
|
-
for (const [definition, original] of patchedDefinitions) {
|
|
363
|
-
try {
|
|
364
|
-
if (original === undefined)
|
|
365
|
-
delete definition.timeoutMs;
|
|
366
|
-
else
|
|
367
|
-
definition.timeoutMs = original;
|
|
368
|
-
}
|
|
369
|
-
catch { }
|
|
370
|
-
}
|
|
371
|
-
patchedDefinitions.clear();
|
|
372
|
-
}
|