fix(ci): sync logs tail protocol artifacts
This commit is contained in:
@@ -1417,6 +1417,60 @@ public struct CronRunLogEntry: Codable, Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct LogsTailParams: Codable, Sendable {
|
||||||
|
public let cursor: Int?
|
||||||
|
public let limit: Int?
|
||||||
|
public let maxbytes: Int?
|
||||||
|
|
||||||
|
public init(
|
||||||
|
cursor: Int?,
|
||||||
|
limit: Int?,
|
||||||
|
maxbytes: Int?
|
||||||
|
) {
|
||||||
|
self.cursor = cursor
|
||||||
|
self.limit = limit
|
||||||
|
self.maxbytes = maxbytes
|
||||||
|
}
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case cursor
|
||||||
|
case limit
|
||||||
|
case maxbytes = "maxBytes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct LogsTailResult: Codable, Sendable {
|
||||||
|
public let file: String
|
||||||
|
public let cursor: Int
|
||||||
|
public let size: Int
|
||||||
|
public let lines: [String]
|
||||||
|
public let truncated: Bool?
|
||||||
|
public let reset: Bool?
|
||||||
|
|
||||||
|
public init(
|
||||||
|
file: String,
|
||||||
|
cursor: Int,
|
||||||
|
size: Int,
|
||||||
|
lines: [String],
|
||||||
|
truncated: Bool?,
|
||||||
|
reset: Bool?
|
||||||
|
) {
|
||||||
|
self.file = file
|
||||||
|
self.cursor = cursor
|
||||||
|
self.size = size
|
||||||
|
self.lines = lines
|
||||||
|
self.truncated = truncated
|
||||||
|
self.reset = reset
|
||||||
|
}
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case file
|
||||||
|
case cursor
|
||||||
|
case size
|
||||||
|
case lines
|
||||||
|
case truncated
|
||||||
|
case reset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct ChatHistoryParams: Codable, Sendable {
|
public struct ChatHistoryParams: Codable, Sendable {
|
||||||
public let sessionkey: String
|
public let sessionkey: String
|
||||||
public let limit: Int?
|
public let limit: Int?
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
|
import { getResolvedLoggerSettings } from "../../logging.js";
|
||||||
import {
|
import {
|
||||||
ErrorCodes,
|
ErrorCodes,
|
||||||
errorShape,
|
errorShape,
|
||||||
formatValidationErrors,
|
formatValidationErrors,
|
||||||
validateLogsTailParams,
|
validateLogsTailParams,
|
||||||
} from "../protocol/index.js";
|
} from "../protocol/index.js";
|
||||||
import { getResolvedLoggerSettings } from "../../logging.js";
|
|
||||||
import type { GatewayRequestHandlers } from "./types.js";
|
import type { GatewayRequestHandlers } from "./types.js";
|
||||||
|
|
||||||
const DEFAULT_LIMIT = 500;
|
const DEFAULT_LIMIT = 500;
|
||||||
@@ -86,7 +85,7 @@ async function readLogSlice(params: {
|
|||||||
const length = Math.max(0, size - start);
|
const length = Math.max(0, size - start);
|
||||||
const buffer = Buffer.alloc(length);
|
const buffer = Buffer.alloc(length);
|
||||||
const readResult = await handle.read(buffer, 0, length, start);
|
const readResult = await handle.read(buffer, 0, length, start);
|
||||||
let text = buffer.toString("utf8", 0, readResult.bytesRead);
|
const text = buffer.toString("utf8", 0, readResult.bytesRead);
|
||||||
let lines = text.split("\n");
|
let lines = text.split("\n");
|
||||||
if (start > 0 && prefix !== "\n") {
|
if (start > 0 && prefix !== "\n") {
|
||||||
lines = lines.slice(1);
|
lines = lines.slice(1);
|
||||||
@@ -140,10 +139,7 @@ export const logsHandlers: GatewayRequestHandlers = {
|
|||||||
respond(
|
respond(
|
||||||
false,
|
false,
|
||||||
undefined,
|
undefined,
|
||||||
errorShape(
|
errorShape(ErrorCodes.UNAVAILABLE, `log read failed: ${String(err)}`),
|
||||||
ErrorCodes.UNAVAILABLE,
|
|
||||||
`log read failed: ${String(err)}`,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user