Spaces:
Running
Running
File size: 2,283 Bytes
fb4d8fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import { Type } from "@sinclair/typebox";
import { NonEmptyString } from "./primitives.js";
export const LogsTailParamsSchema = Type.Object(
{
cursor: Type.Optional(Type.Integer({ minimum: 0 })),
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 5000 })),
maxBytes: Type.Optional(Type.Integer({ minimum: 1, maximum: 1_000_000 })),
},
{ additionalProperties: false },
);
export const LogsTailResultSchema = Type.Object(
{
file: NonEmptyString,
cursor: Type.Integer({ minimum: 0 }),
size: Type.Integer({ minimum: 0 }),
lines: Type.Array(Type.String()),
truncated: Type.Optional(Type.Boolean()),
reset: Type.Optional(Type.Boolean()),
},
{ additionalProperties: false },
);
// WebChat/WebSocket-native chat methods
export const ChatHistoryParamsSchema = Type.Object(
{
sessionKey: NonEmptyString,
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 1000 })),
},
{ additionalProperties: false },
);
export const ChatSendParamsSchema = Type.Object(
{
sessionKey: NonEmptyString,
message: Type.String(),
thinking: Type.Optional(Type.String()),
deliver: Type.Optional(Type.Boolean()),
attachments: Type.Optional(Type.Array(Type.Unknown())),
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 })),
idempotencyKey: NonEmptyString,
},
{ additionalProperties: false },
);
export const ChatAbortParamsSchema = Type.Object(
{
sessionKey: NonEmptyString,
runId: Type.Optional(NonEmptyString),
},
{ additionalProperties: false },
);
export const ChatInjectParamsSchema = Type.Object(
{
sessionKey: NonEmptyString,
message: NonEmptyString,
label: Type.Optional(Type.String({ maxLength: 100 })),
},
{ additionalProperties: false },
);
export const ChatEventSchema = Type.Object(
{
runId: NonEmptyString,
sessionKey: NonEmptyString,
seq: Type.Integer({ minimum: 0 }),
state: Type.Union([
Type.Literal("delta"),
Type.Literal("final"),
Type.Literal("aborted"),
Type.Literal("error"),
]),
message: Type.Optional(Type.Unknown()),
errorMessage: Type.Optional(Type.String()),
usage: Type.Optional(Type.Unknown()),
stopReason: Type.Optional(Type.String()),
},
{ additionalProperties: false },
);
|