mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
* fix(native-chat): name the request a chat start ran out of time on, and log the original start error A start that failed because a provider request hit Orca's deadline (e.g. Codex thread/start after 30s) now says so instead of the generic couldn't-start banner. The deadline marks its error with the method and timeout; the start failure fact carries them as an optional requestTimeout field, and the host logs the original error, method and elapsed open time. * fix(native-chat): neutral start-timeout wording; log only the current child's failure, without timing in the repeat key
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// A provider request Orca stopped waiting for, carried on a start failure so a reader can say
|
|
// which step stalled and for how long instead of a bare "couldn't start".
|
|
|
|
export type AgentSessionRequestTimeout = {
|
|
/** The provider's protocol method, e.g. `thread/start`; never its params. */
|
|
method: string
|
|
timeoutMs: number
|
|
}
|
|
|
|
// A protocol method name, not free text: the words show it as it is.
|
|
const METHOD_NAME = /^[A-Za-z][\w./-]{0,63}$/
|
|
|
|
/** A timeout as a reader meets it; undefined unless both fields are ones this build can show. */
|
|
export function readAgentSessionRequestTimeout(
|
|
value: unknown
|
|
): AgentSessionRequestTimeout | undefined {
|
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
return undefined
|
|
}
|
|
const record: Record<string, unknown> = { ...value }
|
|
const { method, timeoutMs } = record
|
|
return typeof method === 'string' &&
|
|
METHOD_NAME.test(method) &&
|
|
typeof timeoutMs === 'number' &&
|
|
Number.isInteger(timeoutMs) &&
|
|
timeoutMs > 0
|
|
? { method, timeoutMs }
|
|
: undefined
|
|
}
|
|
|
|
/** Whole seconds, at least one, as the words say a deadline. */
|
|
export function requestTimeoutSeconds({ timeoutMs }: AgentSessionRequestTimeout): string {
|
|
return String(Math.max(1, Math.round(timeoutMs / 1000)))
|
|
}
|