@ljoukov/llm 4.0.4 → 4.0.6
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 +1 -1
- package/dist/index.cjs +68 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +68 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -556,7 +556,7 @@ console.log(result.text);
|
|
|
556
556
|
For read/search/write tasks in a workspace, enable `filesystemTool`. The library auto-selects a tool profile by model
|
|
557
557
|
when `profile: "auto"`:
|
|
558
558
|
|
|
559
|
-
- Codex-like models: Codex-compatible filesystem tool shape.
|
|
559
|
+
- Codex-like models (`gpt-5.4`, `chatgpt-gpt-5.4`, `chatgpt-gpt-5.4-fast`, and `*codex*` variants): Codex-compatible filesystem tool shape.
|
|
560
560
|
- Gemini models: Gemini-compatible filesystem tool shape.
|
|
561
561
|
- Other models: model-agnostic profile (currently Gemini-style).
|
|
562
562
|
|
package/dist/index.cjs
CHANGED
|
@@ -2794,6 +2794,7 @@ var import_node_async_hooks = require("async_hooks");
|
|
|
2794
2794
|
var import_node_buffer2 = require("buffer");
|
|
2795
2795
|
var import_promises = require("fs/promises");
|
|
2796
2796
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
2797
|
+
var DEFAULT_THOUGHT_DELTA_LOG_THROTTLE_MS = 4e3;
|
|
2797
2798
|
function toIsoNow() {
|
|
2798
2799
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
2799
2800
|
}
|
|
@@ -2957,6 +2958,63 @@ function appendAgentStreamEventLog(options) {
|
|
|
2957
2958
|
}
|
|
2958
2959
|
}
|
|
2959
2960
|
}
|
|
2961
|
+
function createAgentStreamEventLogger(options) {
|
|
2962
|
+
const thoughtDeltaThrottleMs = Math.max(
|
|
2963
|
+
0,
|
|
2964
|
+
options.thoughtDeltaThrottleMs ?? DEFAULT_THOUGHT_DELTA_LOG_THROTTLE_MS
|
|
2965
|
+
);
|
|
2966
|
+
let pendingThoughtDelta = "";
|
|
2967
|
+
let thoughtFlushTimer = null;
|
|
2968
|
+
const cancelThoughtFlushTimer = () => {
|
|
2969
|
+
if (thoughtFlushTimer === null) {
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
clearTimeout(thoughtFlushTimer);
|
|
2973
|
+
thoughtFlushTimer = null;
|
|
2974
|
+
};
|
|
2975
|
+
const flushThoughtDelta = () => {
|
|
2976
|
+
cancelThoughtFlushTimer();
|
|
2977
|
+
if (pendingThoughtDelta.length === 0) {
|
|
2978
|
+
return;
|
|
2979
|
+
}
|
|
2980
|
+
options.append(`thought_delta: ${pendingThoughtDelta}`);
|
|
2981
|
+
pendingThoughtDelta = "";
|
|
2982
|
+
};
|
|
2983
|
+
const scheduleThoughtFlush = () => {
|
|
2984
|
+
if (thoughtFlushTimer !== null || thoughtDeltaThrottleMs === 0) {
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
thoughtFlushTimer = setTimeout(() => {
|
|
2988
|
+
thoughtFlushTimer = null;
|
|
2989
|
+
flushThoughtDelta();
|
|
2990
|
+
}, thoughtDeltaThrottleMs);
|
|
2991
|
+
thoughtFlushTimer.unref?.();
|
|
2992
|
+
};
|
|
2993
|
+
return {
|
|
2994
|
+
appendEvent: (event) => {
|
|
2995
|
+
if (event.type === "delta" && event.channel === "thought") {
|
|
2996
|
+
if (event.text.length === 0) {
|
|
2997
|
+
return;
|
|
2998
|
+
}
|
|
2999
|
+
pendingThoughtDelta += event.text;
|
|
3000
|
+
if (thoughtDeltaThrottleMs === 0) {
|
|
3001
|
+
flushThoughtDelta();
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
scheduleThoughtFlush();
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
flushThoughtDelta();
|
|
3008
|
+
appendAgentStreamEventLog({
|
|
3009
|
+
event,
|
|
3010
|
+
append: options.append
|
|
3011
|
+
});
|
|
3012
|
+
},
|
|
3013
|
+
flush: () => {
|
|
3014
|
+
flushThoughtDelta();
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
2960
3018
|
var AgentLoggingSessionImpl = class {
|
|
2961
3019
|
workspaceDir;
|
|
2962
3020
|
logsRootDir;
|
|
@@ -9708,7 +9766,7 @@ async function runAccessHook2(runtime, context) {
|
|
|
9708
9766
|
}
|
|
9709
9767
|
function isCodexModel(model) {
|
|
9710
9768
|
const normalized = model.startsWith("chatgpt-") ? model.slice("chatgpt-".length) : model;
|
|
9711
|
-
return normalized.includes("codex");
|
|
9769
|
+
return normalized.includes("codex") || normalized === "gpt-5.4" || normalized === "gpt-5.4-fast";
|
|
9712
9770
|
}
|
|
9713
9771
|
function isGeminiModel(model) {
|
|
9714
9772
|
return model.startsWith("gemini-");
|
|
@@ -10136,19 +10194,17 @@ async function runAgentLoopInternal(request, context) {
|
|
|
10136
10194
|
);
|
|
10137
10195
|
const sourceOnEvent = toolLoopRequestWithSteering.onEvent;
|
|
10138
10196
|
const includeLlmStreamEvents = telemetrySession?.includeLlmStreamEvents === true;
|
|
10197
|
+
const streamEventLogger = loggingSession ? createAgentStreamEventLogger({
|
|
10198
|
+
append: (line) => {
|
|
10199
|
+
loggingSession.logLine(`[agent:${runId}] ${line}`);
|
|
10200
|
+
}
|
|
10201
|
+
}) : void 0;
|
|
10139
10202
|
const wrappedOnEvent = sourceOnEvent || includeLlmStreamEvents ? (event) => {
|
|
10140
10203
|
sourceOnEvent?.(event);
|
|
10141
10204
|
if (includeLlmStreamEvents) {
|
|
10142
10205
|
emitTelemetry({ type: "agent.run.stream", event });
|
|
10143
10206
|
}
|
|
10144
|
-
|
|
10145
|
-
appendAgentStreamEventLog({
|
|
10146
|
-
event,
|
|
10147
|
-
append: (line) => {
|
|
10148
|
-
loggingSession.logLine(`[agent:${runId}] ${line}`);
|
|
10149
|
-
}
|
|
10150
|
-
});
|
|
10151
|
-
}
|
|
10207
|
+
streamEventLogger?.appendEvent(event);
|
|
10152
10208
|
} : void 0;
|
|
10153
10209
|
try {
|
|
10154
10210
|
const result = await runToolLoop({
|
|
@@ -10157,6 +10213,7 @@ async function runAgentLoopInternal(request, context) {
|
|
|
10157
10213
|
...wrappedOnEvent ? { onEvent: wrappedOnEvent } : {},
|
|
10158
10214
|
tools: mergedTools
|
|
10159
10215
|
});
|
|
10216
|
+
streamEventLogger?.flush();
|
|
10160
10217
|
emitTelemetry({
|
|
10161
10218
|
type: "agent.run.completed",
|
|
10162
10219
|
success: true,
|
|
@@ -10189,6 +10246,7 @@ async function runAgentLoopInternal(request, context) {
|
|
|
10189
10246
|
}
|
|
10190
10247
|
return result;
|
|
10191
10248
|
} catch (error) {
|
|
10249
|
+
streamEventLogger?.flush();
|
|
10192
10250
|
emitTelemetry({
|
|
10193
10251
|
type: "agent.run.completed",
|
|
10194
10252
|
success: false,
|
|
@@ -10205,6 +10263,7 @@ async function runAgentLoopInternal(request, context) {
|
|
|
10205
10263
|
);
|
|
10206
10264
|
throw error;
|
|
10207
10265
|
} finally {
|
|
10266
|
+
streamEventLogger?.flush();
|
|
10208
10267
|
await subagentController?.closeAll();
|
|
10209
10268
|
}
|
|
10210
10269
|
}
|