zidane 5.8.0 → 5.8.3

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.
Files changed (58) hide show
  1. package/dist/{agent-DYghZGC8.d.ts → agent-CL4nT5Ti.d.ts} +155 -10
  2. package/dist/agent-CL4nT5Ti.d.ts.map +1 -0
  3. package/dist/chat/pure.d.ts +3 -3
  4. package/dist/chat.d.ts +6 -6
  5. package/dist/chat.js +2 -2
  6. package/dist/{headless-DnjYDckH.js → headless-BfEQtRfX.js} +4 -4
  7. package/dist/{headless-DnjYDckH.js.map → headless-BfEQtRfX.js.map} +1 -1
  8. package/dist/headless.d.ts +1 -1
  9. package/dist/headless.js +1 -1
  10. package/dist/{index-B2cMuK6S.d.ts → index-DdjlsREW.d.ts} +2 -2
  11. package/dist/{index-B2cMuK6S.d.ts.map → index-DdjlsREW.d.ts.map} +1 -1
  12. package/dist/{index-CVzpMtdq.d.ts → index-DtLfTUXt.d.ts} +2 -2
  13. package/dist/{index-CVzpMtdq.d.ts.map → index-DtLfTUXt.d.ts.map} +1 -1
  14. package/dist/index.d.ts +4 -4
  15. package/dist/index.js +5 -296
  16. package/dist/index.js.map +1 -1
  17. package/dist/{login-D-3A5CK7.js → login-Ck6dmcMH.js} +301 -4
  18. package/dist/login-Ck6dmcMH.js.map +1 -0
  19. package/dist/{mcp-Kqzz-Rs_.js → mcp-Br3b1Xm3.js} +50 -8
  20. package/dist/mcp-Br3b1Xm3.js.map +1 -0
  21. package/dist/mcp.d.ts +2 -2
  22. package/dist/mcp.js +2 -2
  23. package/dist/{presets-B1gWui0v.js → presets-DIweYdlN.js} +2 -2
  24. package/dist/{presets-B1gWui0v.js.map → presets-DIweYdlN.js.map} +1 -1
  25. package/dist/presets.d.ts +2 -2
  26. package/dist/presets.js +1 -1
  27. package/dist/providers.d.ts +1 -1
  28. package/dist/restate.d.ts +1 -1
  29. package/dist/session/sqlite.d.ts +1 -1
  30. package/dist/session.d.ts +1 -1
  31. package/dist/skills.d.ts +2 -2
  32. package/dist/{tool-formatters-0FEGRd6w.d.ts → tool-formatters-D-aWpu2N.d.ts} +2 -2
  33. package/dist/{tool-formatters-0FEGRd6w.d.ts.map → tool-formatters-D-aWpu2N.d.ts.map} +1 -1
  34. package/dist/tools/fetch-url.d.ts +1 -1
  35. package/dist/tools/web-search.d.ts +1 -1
  36. package/dist/{tools-BmPeBGU1.js → tools-DLRIhCl1.js} +109 -36
  37. package/dist/tools-DLRIhCl1.js.map +1 -0
  38. package/dist/tools.d.ts +2 -2
  39. package/dist/tools.js +1 -1
  40. package/dist/{transcript-anchors-D2erm5iS.d.ts → transcript-anchors-BJpOyLPm.d.ts} +5 -5
  41. package/dist/{transcript-anchors-D2erm5iS.d.ts.map → transcript-anchors-BJpOyLPm.d.ts.map} +1 -1
  42. package/dist/{transcript-anchors-Bp5bV0Bv.js → transcript-anchors-Dc0WlxnA.js} +18 -5
  43. package/dist/transcript-anchors-Dc0WlxnA.js.map +1 -0
  44. package/dist/tui.d.ts +14 -4
  45. package/dist/tui.d.ts.map +1 -1
  46. package/dist/tui.js +282 -76
  47. package/dist/tui.js.map +1 -1
  48. package/dist/{turn-operations-CeUrtsaM.d.ts → turn-operations-D-fypW6K.d.ts} +3 -3
  49. package/dist/{turn-operations-CeUrtsaM.d.ts.map → turn-operations-D-fypW6K.d.ts.map} +1 -1
  50. package/dist/types-BPw_i5vb.js.map +1 -1
  51. package/dist/types.d.ts +3 -3
  52. package/docs/ARCHITECTURE.md +2 -1
  53. package/package.json +1 -1
  54. package/dist/agent-DYghZGC8.d.ts.map +0 -1
  55. package/dist/login-D-3A5CK7.js.map +0 -1
  56. package/dist/mcp-Kqzz-Rs_.js.map +0 -1
  57. package/dist/tools-BmPeBGU1.js.map +0 -1
  58. package/dist/transcript-anchors-Bp5bV0Bv.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { A as getReadState } from "./tools-BmPeBGU1.js";
1
+ import { j as getReadState } from "./tools-DLRIhCl1.js";
2
2
  import { h as utf8ByteLength, m as estimateTokens } from "./edit-utils-DnfNoj16.js";
3
3
  import { o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-CvRQTdbR.js";
4
4
  import { n as toolOutputByteLength } from "./types-BPw_i5vb.js";
5
- import { a as createTolerantClient, o as sseToJsonFetchIfNeeded, s as McpOAuthProvider } from "./mcp-Kqzz-Rs_.js";
5
+ import { c as McpOAuthProvider, o as createTolerantClient, s as sseToJsonFetchIfNeeded } from "./mcp-Br3b1Xm3.js";
6
6
  import { createServer } from "node:http";
7
7
  //#region src/compact/errors.ts
8
8
  /**
@@ -940,6 +940,303 @@ async function buildPostCompactAttachments(opts) {
940
940
  };
941
941
  }
942
942
  //#endregion
943
+ //#region src/logger.ts
944
+ /**
945
+ * Build a Logger from a sink. Stateless and cheap; create one per agent
946
+ * (or per app) and use `.with()` to attach correlation ids per-call.
947
+ */
948
+ function createLogger(sink, baseAttributes = {}) {
949
+ function emit(level, message, attrs) {
950
+ try {
951
+ sink.emit({
952
+ level,
953
+ timestamp: Date.now(),
954
+ message,
955
+ attrs: attrs ? {
956
+ ...baseAttributes,
957
+ ...attrs
958
+ } : { ...baseAttributes }
959
+ });
960
+ } catch {}
961
+ }
962
+ return {
963
+ debug: (m, a) => emit("debug", m, a),
964
+ info: (m, a) => emit("info", m, a),
965
+ warn: (m, a) => emit("warn", m, a),
966
+ error: (m, a) => emit("error", m, a),
967
+ with: (extra) => createLogger(sink, {
968
+ ...baseAttributes,
969
+ ...extra
970
+ }),
971
+ baseAttributes
972
+ };
973
+ }
974
+ const LEVEL_ORDER = {
975
+ debug: 0,
976
+ info: 1,
977
+ warn: 2,
978
+ error: 3
979
+ };
980
+ /**
981
+ * Human-readable terminal sink. Renders each record as
982
+ * `<ISO timestamp> <LEVEL> <message> <attrs as kv pairs>`.
983
+ *
984
+ * Honors `process.stderr` by default so log lines don't interleave with
985
+ * the agent's stdout-bound output (chat responses, JSON results).
986
+ */
987
+ function consoleSink(options = {}) {
988
+ const min = LEVEL_ORDER[options.minLevel ?? "info"];
989
+ const stream = options.stream ?? process.stderr;
990
+ return { emit(record) {
991
+ if (LEVEL_ORDER[record.level] < min) return;
992
+ const ts = new Date(record.timestamp).toISOString();
993
+ const kv = Object.entries(record.attrs).filter(([, v]) => v !== void 0).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
994
+ stream.write(`${ts} ${record.level.toUpperCase().padEnd(5)} ${record.message}${kv ? ` ${kv}` : ""}\n`);
995
+ } };
996
+ }
997
+ /**
998
+ * One-JSON-object-per-line sink. Suitable for piping into log aggregators
999
+ * (Datadog Agent, Fluent Bit, Loki, Vector) that expect JSONL.
1000
+ */
1001
+ function jsonSink(options = {}) {
1002
+ const min = LEVEL_ORDER[options.minLevel ?? "info"];
1003
+ const stream = options.stream ?? process.stderr;
1004
+ return { emit(record) {
1005
+ if (LEVEL_ORDER[record.level] < min) return;
1006
+ try {
1007
+ stream.write(`${JSON.stringify(record)}\n`);
1008
+ } catch {}
1009
+ } };
1010
+ }
1011
+ /**
1012
+ * Install a bundle of hook handlers that emit a structured line per
1013
+ * relevant lifecycle event, automatically attaching correlation ids
1014
+ * (`runId`, `turnId`, `callId`, `childId`, `depth`, `agentName`).
1015
+ *
1016
+ * @example
1017
+ * ```ts
1018
+ * const logger = createLogger(consoleSink({ minLevel: 'debug' }), { service: 'tui' })
1019
+ * const lh = createLoggingHooks({ logger })
1020
+ * const uninstall = lh.install(agent.hooks)
1021
+ * try { await agent.run({ prompt }) }
1022
+ * finally { uninstall() }
1023
+ * ```
1024
+ */
1025
+ function createLoggingHooks(options) {
1026
+ const root = options.logger;
1027
+ const includeLifecycle = options.includeLifecycle ?? true;
1028
+ const minLevel = LEVEL_ORDER[options.level ?? "info"];
1029
+ /**
1030
+ * Wrap a Logger so emissions below `minLevel` are dropped before they
1031
+ * hit the sink. Lets us gate harness chatter without forcing every
1032
+ * `LogSink` to re-implement level filtering. Preserves `.with()`
1033
+ * composition (children inherit the filter).
1034
+ */
1035
+ function gateLevel(logger) {
1036
+ const skip = (level) => LEVEL_ORDER[level] < minLevel;
1037
+ const wrap = (l) => ({
1038
+ debug: (m, a) => {
1039
+ if (!skip("debug")) l.debug(m, a);
1040
+ },
1041
+ info: (m, a) => {
1042
+ if (!skip("info")) l.info(m, a);
1043
+ },
1044
+ warn: (m, a) => {
1045
+ if (!skip("warn")) l.warn(m, a);
1046
+ },
1047
+ error: (m, a) => {
1048
+ if (!skip("error")) l.error(m, a);
1049
+ },
1050
+ with: (extra) => wrap(l.with(extra)),
1051
+ baseAttributes: l.baseAttributes
1052
+ });
1053
+ return wrap(logger);
1054
+ }
1055
+ return { install(hooks) {
1056
+ const unregisters = [];
1057
+ const gatedRoot = gateLevel(root);
1058
+ let runLogger = gatedRoot;
1059
+ let turnLogger = gatedRoot;
1060
+ unregisters.push(hooks.hook("agent:start", (ctx) => {
1061
+ runLogger = gatedRoot.with({
1062
+ runId: ctx.runId,
1063
+ ...ctx.parentRunId ? { parentRunId: ctx.parentRunId } : {},
1064
+ depth: ctx.depth,
1065
+ ...ctx.agentName ? { agentName: ctx.agentName } : {}
1066
+ });
1067
+ turnLogger = runLogger;
1068
+ if (includeLifecycle) runLogger.debug("agent run started");
1069
+ }));
1070
+ unregisters.push(hooks.hook("agent:done", (stats) => {
1071
+ runLogger.info("agent run completed", {
1072
+ turns: stats.turns,
1073
+ totalIn: stats.totalIn,
1074
+ totalOut: stats.totalOut,
1075
+ ...typeof stats.cost === "number" ? { cost: stats.cost } : {},
1076
+ elapsedMs: stats.elapsed,
1077
+ ...typeof stats.timeTillFirstTokenMs === "number" ? { ttftMs: stats.timeTillFirstTokenMs } : {}
1078
+ });
1079
+ }));
1080
+ unregisters.push(hooks.hook("agent:abort", () => {
1081
+ runLogger.warn("agent run aborted");
1082
+ }));
1083
+ unregisters.push(hooks.hook("turn:before", (ctx) => {
1084
+ turnLogger = runLogger.with({
1085
+ turnId: ctx.turnId,
1086
+ turn: ctx.turn
1087
+ });
1088
+ if (includeLifecycle) turnLogger.debug("turn started");
1089
+ }));
1090
+ unregisters.push(hooks.hook("turn:after", (ctx) => {
1091
+ turnLogger.debug("turn ended", {
1092
+ inputTokens: ctx.usage.input,
1093
+ outputTokens: ctx.usage.output,
1094
+ ...ctx.usage.finishReason ? { finishReason: ctx.usage.finishReason } : {},
1095
+ ...ctx.usage.modelId ? { modelId: ctx.usage.modelId } : {},
1096
+ ...typeof ctx.usage.timeToFirstTokenMs === "number" ? { ttftMs: ctx.usage.timeToFirstTokenMs } : {}
1097
+ });
1098
+ }));
1099
+ unregisters.push(hooks.hook("stream:error", (ctx) => {
1100
+ turnLogger.error("stream error", {
1101
+ message: ctx.err instanceof Error ? ctx.err.message : String(ctx.err),
1102
+ ...ctx.statusCode !== void 0 ? { statusCode: ctx.statusCode } : {},
1103
+ ...ctx.requestId !== void 0 ? { requestId: ctx.requestId } : {}
1104
+ });
1105
+ }));
1106
+ unregisters.push(hooks.hook("tool:before", (ctx) => {
1107
+ if (!includeLifecycle) return;
1108
+ turnLogger.debug("tool started", {
1109
+ toolName: ctx.name,
1110
+ displayName: ctx.displayName,
1111
+ callId: ctx.callId
1112
+ });
1113
+ }));
1114
+ unregisters.push(hooks.hook("tool:after", (ctx) => {
1115
+ if (!includeLifecycle) return;
1116
+ turnLogger.debug("tool ended", {
1117
+ toolName: ctx.name,
1118
+ callId: ctx.callId,
1119
+ outputBytes: ctx.outputBytes
1120
+ });
1121
+ }));
1122
+ unregisters.push(hooks.hook("tool:error", (ctx) => {
1123
+ turnLogger.error("tool error", {
1124
+ toolName: ctx.name,
1125
+ callId: ctx.callId,
1126
+ message: ctx.error.message
1127
+ });
1128
+ }));
1129
+ unregisters.push(hooks.hook("tool:dispatched", (ctx) => {
1130
+ const isAnomaly = ctx.outcome === "gate-block" || ctx.outcome === "unknown" || ctx.outcome === "invalid-input";
1131
+ if (!isAnomaly && !includeLifecycle) return;
1132
+ turnLogger[isAnomaly ? "warn" : "debug"]("tool dispatched", {
1133
+ toolName: ctx.name,
1134
+ callId: ctx.callId,
1135
+ outcome: ctx.outcome,
1136
+ ...ctx.reason ? { reason: ctx.reason } : {}
1137
+ });
1138
+ }));
1139
+ unregisters.push(hooks.hook("validation:reject", (ctx) => {
1140
+ turnLogger.warn("tool input rejected", {
1141
+ toolName: ctx.name,
1142
+ callId: ctx.callId,
1143
+ reason: ctx.reason
1144
+ });
1145
+ }));
1146
+ unregisters.push(hooks.hook("budget:exceeded", (ctx) => {
1147
+ turnLogger.warn("byte budget exceeded", {
1148
+ bytes: ctx.bytes,
1149
+ budget: ctx.budget
1150
+ });
1151
+ }));
1152
+ unregisters.push(hooks.hook("tool-budget:exceeded", (ctx) => {
1153
+ turnLogger.warn("tool budget exceeded", {
1154
+ toolName: ctx.tool,
1155
+ count: ctx.count,
1156
+ max: ctx.max,
1157
+ mode: ctx.mode
1158
+ });
1159
+ }));
1160
+ unregisters.push(hooks.hook("mcp:bootstrap:end", (ctx) => {
1161
+ if (ctx.ok) {
1162
+ if (includeLifecycle) runLogger.debug("mcp bootstrap ok", {
1163
+ server: ctx.name,
1164
+ transport: ctx.transport,
1165
+ durationMs: ctx.durationMs,
1166
+ toolCount: ctx.toolCount,
1167
+ ...ctx.lazy ? { lazy: true } : {},
1168
+ ...ctx.cached ? { cached: true } : {}
1169
+ });
1170
+ } else runLogger.warn("mcp bootstrap failed", {
1171
+ server: ctx.name,
1172
+ transport: ctx.transport,
1173
+ durationMs: ctx.durationMs,
1174
+ message: ctx.error.message
1175
+ });
1176
+ }));
1177
+ unregisters.push(hooks.hook("mcp:error", (ctx) => {
1178
+ runLogger.error("mcp error", {
1179
+ server: ctx.name,
1180
+ message: ctx.error.message
1181
+ });
1182
+ }));
1183
+ unregisters.push(hooks.hook("mcp:warn", (ctx) => {
1184
+ runLogger.warn("mcp warn", {
1185
+ server: ctx.name,
1186
+ message: ctx.message
1187
+ });
1188
+ }));
1189
+ unregisters.push(hooks.hook("mcp:auth:required", (ctx) => {
1190
+ runLogger.warn("mcp auth required", {
1191
+ server: ctx.name,
1192
+ transport: ctx.transport,
1193
+ reason: ctx.reason
1194
+ });
1195
+ }));
1196
+ unregisters.push(hooks.hook("mcp:tool:error", (ctx) => {
1197
+ turnLogger.error("mcp tool error", {
1198
+ server: ctx.server,
1199
+ tool: ctx.displayName,
1200
+ callId: ctx.callId,
1201
+ message: ctx.error.message
1202
+ });
1203
+ }));
1204
+ unregisters.push(hooks.hook("spawn:before", (ctx) => {
1205
+ if (!includeLifecycle) return;
1206
+ runLogger.debug("spawn started", {
1207
+ childId: ctx.id,
1208
+ depth: ctx.depth
1209
+ });
1210
+ }));
1211
+ unregisters.push(hooks.hook("spawn:complete", (ctx) => {
1212
+ runLogger.info("spawn completed", {
1213
+ childId: ctx.id,
1214
+ ...ctx.depth ? { depth: ctx.depth } : {},
1215
+ status: ctx.status ?? "completed",
1216
+ turns: ctx.stats.turns,
1217
+ totalIn: ctx.stats.totalIn,
1218
+ totalOut: ctx.stats.totalOut,
1219
+ ...typeof ctx.stats.cost === "number" ? { cost: ctx.stats.cost } : {}
1220
+ });
1221
+ }));
1222
+ unregisters.push(hooks.hook("spawn:error", (ctx) => {
1223
+ runLogger.error("spawn error", {
1224
+ childId: ctx.id,
1225
+ ...ctx.depth ? { depth: ctx.depth } : {},
1226
+ message: ctx.error.message
1227
+ });
1228
+ }));
1229
+ let disposed = false;
1230
+ return function uninstall() {
1231
+ if (disposed) return;
1232
+ disposed = true;
1233
+ for (const un of unregisters) try {
1234
+ un();
1235
+ } catch {}
1236
+ };
1237
+ } };
1238
+ }
1239
+ //#endregion
943
1240
  //#region src/mcp/oauth-callback.ts
944
1241
  const DEFAULT_PATH = "/callback";
945
1242
  const DEFAULT_HOST = "127.0.0.1";
@@ -1202,6 +1499,6 @@ async function raceLoginCallback(handle, timeoutMs, signal) {
1202
1499
  }
1203
1500
  }
1204
1501
  //#endregion
1205
- export { CompactPromptTooLongError as C, CompactInvalidInputError as S, anchorPreviewFor as _, selectFilesFromSession as a, summaryToTurn as b, BASE_INSTRUCTIONS as c, buildCompactPrompt as d, buildFromCompactPrompt as f, ANCHOR_PREVIEW_MAX_CHARS as g, buildUpToCompactPrompt as h, selectFilesFromReadState as i, NO_TOOLS_PREAMBLE as l, buildTailCompactPrompt as m, startOAuthCallback as n, selectRecentFiles as o, buildFullCompactPrompt as p, buildPostCompactAttachments as r, compactConversation as s, loginMcpServer as t, TRAILER as u, sliceForCompaction as v, truncateHeadForPtlRetry as x, stripImagesFromTurns as y };
1502
+ export { stripImagesFromTurns as C, CompactPromptTooLongError as D, CompactInvalidInputError as E, sliceForCompaction as S, truncateHeadForPtlRetry as T, buildFullCompactPrompt as _, createLoggingHooks as a, ANCHOR_PREVIEW_MAX_CHARS as b, selectFilesFromReadState as c, compactConversation as d, BASE_INSTRUCTIONS as f, buildFromCompactPrompt as g, buildCompactPrompt as h, createLogger as i, selectFilesFromSession as l, TRAILER as m, startOAuthCallback as n, jsonSink as o, NO_TOOLS_PREAMBLE as p, consoleSink as r, buildPostCompactAttachments as s, loginMcpServer as t, selectRecentFiles as u, buildTailCompactPrompt as v, summaryToTurn as w, anchorPreviewFor as x, buildUpToCompactPrompt as y };
1206
1503
 
1207
- //# sourceMappingURL=login-D-3A5CK7.js.map
1504
+ //# sourceMappingURL=login-Ck6dmcMH.js.map