feat: sync universal schema and sdk updates

This commit is contained in:
Nathan Flurry 2026-01-27 02:52:25 -08:00
parent 79bb441287
commit f5d1a6383d
56 changed files with 6800 additions and 3974 deletions

View file

@ -1,31 +1,23 @@
import type { components } from "./generated/openapi.js";
import type {
SandboxDaemonSpawnHandle,
SandboxDaemonSpawnOptions,
} from "./spawn.js";
export type AgentInstallRequest = components["schemas"]["AgentInstallRequest"];
export type AgentModeInfo = components["schemas"]["AgentModeInfo"];
export type AgentModesResponse = components["schemas"]["AgentModesResponse"];
export type AgentInfo = components["schemas"]["AgentInfo"];
export type AgentListResponse = components["schemas"]["AgentListResponse"];
export type CreateSessionRequest = components["schemas"]["CreateSessionRequest"];
export type CreateSessionResponse = components["schemas"]["CreateSessionResponse"];
export type HealthResponse = components["schemas"]["HealthResponse"];
export type MessageRequest = components["schemas"]["MessageRequest"];
export type EventsQuery = components["schemas"]["EventsQuery"];
export type EventsResponse = components["schemas"]["EventsResponse"];
export type PermissionRequest = components["schemas"]["PermissionRequest"];
export type QuestionReplyRequest = components["schemas"]["QuestionReplyRequest"];
export type QuestionRequest = components["schemas"]["QuestionRequest"];
export type PermissionReplyRequest = components["schemas"]["PermissionReplyRequest"];
export type PermissionReply = components["schemas"]["PermissionReply"];
export type ProblemDetails = components["schemas"]["ProblemDetails"];
export type SessionInfo = components["schemas"]["SessionInfo"];
export type SessionListResponse = components["schemas"]["SessionListResponse"];
export type UniversalEvent = components["schemas"]["UniversalEvent"];
export type UniversalMessage = components["schemas"]["UniversalMessage"];
export type UniversalMessagePart = components["schemas"]["UniversalMessagePart"];
} from "./spawn.ts";
import type {
AgentInstallRequest,
AgentListResponse,
AgentModesResponse,
CreateSessionRequest,
CreateSessionResponse,
EventsQuery,
EventsResponse,
HealthResponse,
MessageRequest,
PermissionReplyRequest,
ProblemDetails,
QuestionReplyRequest,
SessionListResponse,
UniversalEvent,
} from "./types.ts";
const API_PREFIX = "/v1";
@ -179,13 +171,14 @@ export class SandboxDaemonClient {
if (done) {
break;
}
buffer += decoder.decode(value, { stream: true });
// Normalize CRLF to LF for consistent parsing
buffer += decoder.decode(value, { stream: true }).replace(/\r\n/g, "\n");
let index = buffer.indexOf("\n\n");
while (index !== -1) {
const chunk = buffer.slice(0, index);
buffer = buffer.slice(index + 2);
const dataLines = chunk
.split(/\r?\n/)
.split("\n")
.filter((line) => line.startsWith("data:"));
if (dataLines.length > 0) {
const payload = dataLines

View file

@ -4,11 +4,6 @@
*/
/** OneOf type helpers */
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
type OneOf<T extends any[]> = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] ? OneOf<[XOR<A, B>, ...Rest]> : never;
export interface paths {
"/v1/agents": {
get: operations["list_agents"];
@ -46,12 +41,21 @@ export interface paths {
"/v1/sessions/{session_id}/questions/{question_id}/reply": {
post: operations["reply_question"];
};
"/v1/sessions/{session_id}/terminate": {
post: operations["terminate_session"];
};
}
export type webhooks = Record<string, never>;
export interface components {
schemas: {
AgentCapabilities: {
permissions: boolean;
planMode: boolean;
questions: boolean;
toolCalls: boolean;
};
AgentError: {
agent?: string | null;
details?: unknown;
@ -60,6 +64,7 @@ export interface components {
type: components["schemas"]["ErrorType"];
};
AgentInfo: {
capabilities: components["schemas"]["AgentCapabilities"];
id: string;
installed: boolean;
path?: string | null;
@ -79,25 +84,52 @@ export interface components {
AgentModesResponse: {
modes: components["schemas"]["AgentModeInfo"][];
};
AttachmentSource: {
AgentUnparsedData: {
error: string;
location: string;
raw_hash?: string | null;
};
ContentPart: {
text: string;
/** @enum {string} */
type: "text";
} | {
json: unknown;
/** @enum {string} */
type: "json";
} | {
arguments: string;
call_id: string;
name: string;
/** @enum {string} */
type: "tool_call";
} | {
call_id: string;
output: string;
/** @enum {string} */
type: "tool_result";
} | ({
action: components["schemas"]["FileAction"];
diff?: string | null;
path: string;
/** @enum {string} */
type: "path";
} | {
type: "file_ref";
}) | {
text: string;
/** @enum {string} */
type: "url";
url: string;
type: "reasoning";
visibility: components["schemas"]["ReasoningVisibility"];
} | ({
data: string;
encoding?: string | null;
mime?: string | null;
path: string;
/** @enum {string} */
type: "data";
type: "image";
}) | ({
detail?: string | null;
label: string;
/** @enum {string} */
type: "status";
});
CrashInfo: {
details?: unknown;
kind?: string | null;
message: string;
};
CreateSessionRequest: {
agent: string;
agentMode?: string | null;
@ -107,13 +139,21 @@ export interface components {
variant?: string | null;
};
CreateSessionResponse: {
agentSessionId?: string | null;
error?: components["schemas"]["AgentError"] | null;
healthy: boolean;
nativeSessionId?: string | null;
};
ErrorData: {
code?: string | null;
details?: unknown;
message: string;
};
/** @enum {string} */
ErrorType: "invalid_request" | "unsupported_agent" | "agent_not_installed" | "install_failed" | "agent_process_exited" | "token_invalid" | "permission_denied" | "session_not_found" | "session_already_exists" | "mode_not_supported" | "stream_error" | "timeout";
/** @enum {string} */
EventSource: "agent" | "daemon";
EventsQuery: {
includeRaw?: boolean | null;
/** Format: int64 */
limit?: number | null;
/** Format: int64 */
@ -123,32 +163,41 @@ export interface components {
events: components["schemas"]["UniversalEvent"][];
hasMore: boolean;
};
/** @enum {string} */
FileAction: "read" | "write" | "patch";
HealthResponse: {
status: string;
};
ItemDeltaData: {
delta: string;
item_id: string;
native_item_id?: string | null;
};
ItemEventData: {
item: components["schemas"]["UniversalItem"];
};
/** @enum {string} */
ItemKind: "message" | "tool_call" | "tool_result" | "system" | "status" | "unknown";
/** @enum {string} */
ItemRole: "user" | "assistant" | "system" | "tool";
/** @enum {string} */
ItemStatus: "in_progress" | "completed" | "failed";
MessageRequest: {
message: string;
};
PermissionEventData: {
action: string;
metadata?: unknown;
permission_id: string;
status: components["schemas"]["PermissionStatus"];
};
/** @enum {string} */
PermissionReply: "once" | "always" | "reject";
PermissionReplyRequest: {
reply: components["schemas"]["PermissionReply"];
};
PermissionRequest: {
always: string[];
id: string;
metadata?: {
[key: string]: unknown;
};
patterns: string[];
permission: string;
sessionId: string;
tool?: components["schemas"]["PermissionToolRef"] | null;
};
PermissionToolRef: {
callId: string;
messageId: string;
};
/** @enum {string} */
PermissionStatus: "requested" | "approved" | "denied";
ProblemDetails: {
detail?: string | null;
instance?: string | null;
@ -158,38 +207,34 @@ export interface components {
type: string;
[key: string]: unknown;
};
QuestionInfo: {
custom?: boolean | null;
header?: string | null;
multiSelect?: boolean | null;
options: components["schemas"]["QuestionOption"][];
question: string;
};
QuestionOption: {
description?: string | null;
label: string;
QuestionEventData: {
options: string[];
prompt: string;
question_id: string;
response?: string | null;
status: components["schemas"]["QuestionStatus"];
};
QuestionReplyRequest: {
answers: string[][];
};
QuestionRequest: {
id: string;
questions: components["schemas"]["QuestionInfo"][];
sessionId: string;
tool?: components["schemas"]["QuestionToolRef"] | null;
};
QuestionToolRef: {
callId: string;
messageId: string;
/** @enum {string} */
QuestionStatus: "requested" | "answered" | "rejected";
/** @enum {string} */
ReasoningVisibility: "public" | "private";
/** @enum {string} */
SessionEndReason: "completed" | "error" | "terminated";
SessionEndedData: {
reason: components["schemas"]["SessionEndReason"];
terminated_by: components["schemas"]["TerminatedBy"];
};
SessionInfo: {
agent: string;
agentMode: string;
agentSessionId?: string | null;
ended: boolean;
/** Format: int64 */
eventCount: number;
model?: string | null;
nativeSessionId?: string | null;
permissionMode: string;
sessionId: string;
variant?: string | null;
@ -197,98 +242,35 @@ export interface components {
SessionListResponse: {
sessions: components["schemas"]["SessionInfo"][];
};
Started: {
details?: unknown;
message?: string | null;
SessionStartedData: {
metadata?: unknown;
};
/** @enum {string} */
TerminatedBy: "agent" | "daemon";
UniversalEvent: {
agent: string;
agentSessionId?: string | null;
data: components["schemas"]["UniversalEventData"];
event_id: string;
native_session_id?: string | null;
raw?: unknown;
/** Format: int64 */
id: number;
sessionId: string;
timestamp: string;
sequence: number;
session_id: string;
source: components["schemas"]["EventSource"];
synthetic: boolean;
time: string;
type: components["schemas"]["UniversalEventType"];
};
UniversalEventData: {
message: components["schemas"]["UniversalMessage"];
} | {
started: components["schemas"]["Started"];
} | {
error: components["schemas"]["CrashInfo"];
} | {
questionAsked: components["schemas"]["QuestionRequest"];
} | {
permissionAsked: components["schemas"]["PermissionRequest"];
} | {
raw: unknown;
};
UniversalMessage: OneOf<[components["schemas"]["UniversalMessageParsed"], {
error?: string | null;
raw: unknown;
}]>;
UniversalMessageParsed: {
id?: string | null;
metadata?: {
[key: string]: unknown;
};
parts: components["schemas"]["UniversalMessagePart"][];
role: string;
};
UniversalMessagePart: {
text: string;
/** @enum {string} */
type: "text";
} | ({
id?: string | null;
input: unknown;
name: string;
/** @enum {string} */
type: "tool_call";
}) | ({
id?: string | null;
is_error?: boolean | null;
name?: string | null;
output: unknown;
/** @enum {string} */
type: "tool_result";
}) | ({
arguments: unknown;
id?: string | null;
name?: string | null;
raw?: unknown;
/** @enum {string} */
type: "function_call";
}) | ({
id?: string | null;
is_error?: boolean | null;
name?: string | null;
raw?: unknown;
result: unknown;
/** @enum {string} */
type: "function_result";
}) | ({
filename?: string | null;
mime_type?: string | null;
raw?: unknown;
source: components["schemas"]["AttachmentSource"];
/** @enum {string} */
type: "file";
}) | ({
alt?: string | null;
mime_type?: string | null;
raw?: unknown;
source: components["schemas"]["AttachmentSource"];
/** @enum {string} */
type: "image";
}) | {
message: string;
/** @enum {string} */
type: "error";
} | {
raw: unknown;
/** @enum {string} */
type: "unknown";
UniversalEventData: components["schemas"]["SessionStartedData"] | components["schemas"]["SessionEndedData"] | components["schemas"]["ItemEventData"] | components["schemas"]["ItemDeltaData"] | components["schemas"]["ErrorData"] | components["schemas"]["PermissionEventData"] | components["schemas"]["QuestionEventData"] | components["schemas"]["AgentUnparsedData"];
/** @enum {string} */
UniversalEventType: "session.started" | "session.ended" | "item.started" | "item.delta" | "item.completed" | "error" | "permission.requested" | "permission.resolved" | "question.requested" | "question.resolved" | "agent.unparsed";
UniversalItem: {
content: components["schemas"]["ContentPart"][];
item_id: string;
kind: components["schemas"]["ItemKind"];
native_item_id?: string | null;
parent_id?: string | null;
role?: components["schemas"]["ItemRole"] | null;
status: components["schemas"]["ItemStatus"];
};
};
responses: never;
@ -418,10 +400,12 @@ export interface operations {
get_events: {
parameters: {
query?: {
/** @description Last seen event id (exclusive) */
/** @description Last seen event sequence (exclusive) */
offset?: number | null;
/** @description Max events to return */
limit?: number | null;
/** @description Include raw provider payloads */
include_raw?: boolean | null;
};
path: {
/** @description Session id */
@ -444,8 +428,10 @@ export interface operations {
get_events_sse: {
parameters: {
query?: {
/** @description Last seen event id (exclusive) */
/** @description Last seen event sequence (exclusive) */
offset?: number | null;
/** @description Include raw provider payloads */
include_raw?: boolean | null;
};
path: {
/** @description Session id */
@ -556,4 +542,23 @@ export interface operations {
};
};
};
terminate_session: {
parameters: {
path: {
/** @description Session id */
session_id: string;
};
};
responses: {
/** @description Session terminated */
204: {
content: never;
};
404: {
content: {
"application/json": components["schemas"]["ProblemDetails"];
};
};
};
};
}

View file

@ -3,32 +3,53 @@ export {
SandboxDaemonError,
connectSandboxDaemonClient,
createSandboxDaemonClient,
} from "./client.js";
} from "./client.ts";
export type {
SandboxDaemonClientOptions,
SandboxDaemonConnectOptions,
} from "./client.ts";
export type {
AgentCapabilities,
AgentInfo,
AgentInstallRequest,
AgentListResponse,
AgentModeInfo,
AgentModesResponse,
AgentUnparsedData,
ContentPart,
CreateSessionRequest,
CreateSessionResponse,
ErrorData,
EventSource,
EventsQuery,
EventsResponse,
FileAction,
HealthResponse,
ItemDeltaData,
ItemEventData,
ItemKind,
ItemRole,
ItemStatus,
MessageRequest,
PermissionRequest,
PermissionEventData,
PermissionReply,
PermissionReplyRequest,
PermissionStatus,
ProblemDetails,
QuestionRequest,
QuestionEventData,
QuestionReplyRequest,
QuestionStatus,
ReasoningVisibility,
SessionEndReason,
SessionEndedData,
SessionInfo,
SessionListResponse,
SessionStartedData,
TerminatedBy,
UniversalEvent,
UniversalMessage,
UniversalMessagePart,
SandboxDaemonClientOptions,
SandboxDaemonConnectOptions,
} from "./client.js";
export type { components, paths } from "./generated/openapi.js";
export type { SandboxDaemonSpawnOptions, SandboxDaemonSpawnLogMode } from "./spawn.js";
UniversalEventData,
UniversalEventType,
UniversalItem,
} from "./types.ts";
export type { components, paths } from "./generated/openapi.ts";
export type { SandboxDaemonSpawnOptions, SandboxDaemonSpawnLogMode } from "./spawn.ts";

View file

@ -0,0 +1,45 @@
import type { components } from "./generated/openapi.ts";
type S = components["schemas"];
export type AgentCapabilities = S["AgentCapabilities"];
export type AgentInfo = S["AgentInfo"];
export type AgentInstallRequest = S["AgentInstallRequest"];
export type AgentListResponse = S["AgentListResponse"];
export type AgentModeInfo = S["AgentModeInfo"];
export type AgentModesResponse = S["AgentModesResponse"];
export type AgentUnparsedData = S["AgentUnparsedData"];
export type ContentPart = S["ContentPart"];
export type CreateSessionRequest = S["CreateSessionRequest"];
export type CreateSessionResponse = S["CreateSessionResponse"];
export type ErrorData = S["ErrorData"];
export type EventSource = S["EventSource"];
export type EventsQuery = S["EventsQuery"];
export type EventsResponse = S["EventsResponse"];
export type FileAction = S["FileAction"];
export type HealthResponse = S["HealthResponse"];
export type ItemDeltaData = S["ItemDeltaData"];
export type ItemEventData = S["ItemEventData"];
export type ItemKind = S["ItemKind"];
export type ItemRole = S["ItemRole"];
export type ItemStatus = S["ItemStatus"];
export type MessageRequest = S["MessageRequest"];
export type PermissionEventData = S["PermissionEventData"];
export type PermissionReply = S["PermissionReply"];
export type PermissionReplyRequest = S["PermissionReplyRequest"];
export type PermissionStatus = S["PermissionStatus"];
export type ProblemDetails = S["ProblemDetails"];
export type QuestionEventData = S["QuestionEventData"];
export type QuestionReplyRequest = S["QuestionReplyRequest"];
export type QuestionStatus = S["QuestionStatus"];
export type ReasoningVisibility = S["ReasoningVisibility"];
export type SessionEndReason = S["SessionEndReason"];
export type SessionEndedData = S["SessionEndedData"];
export type SessionInfo = S["SessionInfo"];
export type SessionListResponse = S["SessionListResponse"];
export type SessionStartedData = S["SessionStartedData"];
export type TerminatedBy = S["TerminatedBy"];
export type UniversalEvent = S["UniversalEvent"];
export type UniversalEventData = S["UniversalEventData"];
export type UniversalEventType = S["UniversalEventType"];
export type UniversalItem = S["UniversalItem"];