import type { WorkerTaskState, WorkerTaskKind, WorkerTaskStatus } from '@optima-chat/gateway-protocol'; /** * Task status as actually seen on the wire (review Important-2). * * gateway 的 per-user 端点(`/api/users/me/tasks`)对超过 staleFloor(>70min)的 * 幽灵 `running` 行返回 `timed_out` —— gateway-protocol 的 `WorkerTaskStatus` * 尚未发布该值,先本地扩宽;protocol 发布后交集兼容。 */ export type NormalizedTaskStatus = WorkerTaskStatus | 'timed_out'; /** * Authenticated fetch — structural alias matching the workspace-provider pattern. * NOT `typeof fetch`; the consumer-supplied function must attach Bearer tokens. */ export type AuthFetch = (url: string, init?: RequestInit) => Promise; /** * Consumer-supplied abstraction for session task operations. The default * implementation (`createDefaultTasksProvider`) targets the gateway's * `/api/sessions/{sessionId}/tasks` endpoint. */ export interface TasksProvider { listTasks(sessionId: string, opts?: { kind?: WorkerTaskKind; }): Promise; /** * #1591 止血 B:user-wide task list — `GET /api/users/me/tasks`。 * 服务端从 auth token 自解 userId,无参数;响应形状与 per-session 端点相同, * 每项多一个 `sessionId`(归属 session)。 * * 可选(BC):第三方注入的 provider 可能没实现——useTasks 缺失时回退旧的 * per-session `listTasks(sessionId)` hydrate 行为。 * * `opts` 预留(review NIT):与 `listTasks` 能力对称;将来加分页等不动契约。 */ listAllTasks?(opts?: { kind?: WorkerTaskKind; }): Promise; } /** * UserTaskState — per-user 端点(`/api/users/me/tasks`)返回的行: * WorkerTaskState + 归属 `sessionId`。Local type-extend until * @optima-chat/gateway-protocol publishes `WorkerTaskState.sessionId`; * the intersection stays compatible once it does. */ export type UserTaskState = Omit & { status: NormalizedTaskStatus; sessionId?: string; }; /** * NormalizedTask — REST WorkerTaskState + optional `stale` flag. * The `stale` flag is set by B4 (useTasks) when the REST snapshot may be * out-of-date relative to live WS events. * * `conversationId` — COO task-conversation binding (COO_TASK_CONV_ENABLED * MVP). Local type-extend until @optima-chat/gateway-protocol publishes * `WorkerTaskState.conversationId`; the intersection stays compatible once * it does. Absent whenever the gateway flag is off. */ export type NormalizedTask = Omit & { /** Wire status incl. `timed_out`(per-user 端点对幽灵行返回,见 NormalizedTaskStatus)。 */ status: NormalizedTaskStatus; stale?: boolean; conversationId?: string; /** 归属 session(per-user hydrate #1591 带回;per-session hydrate / WS 事件行缺省)。 */ sessionId?: string; }; //# sourceMappingURL=types.d.ts.map