refactor: strengthen sdk control and settings types
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
export {
|
export class SDKControlRequest {}
|
||||||
SDKControlRequest,
|
|
||||||
SDKControlResponse,
|
export class SDKControlResponse {}
|
||||||
} from './controlTypes.ts'
|
|
||||||
|
|||||||
@@ -1,14 +1,103 @@
|
|||||||
export type SDKControlRequest = Record<string, unknown> & {
|
import type { SDKMessage } from './coreTypes.ts'
|
||||||
subtype?: string
|
|
||||||
|
export type SDKPermissionResponse =
|
||||||
|
| {
|
||||||
|
behavior: 'allow'
|
||||||
|
updatedInput?: Record<string, unknown>
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
behavior: 'deny' | 'ask'
|
||||||
|
message?: string
|
||||||
|
updatedInput?: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SDKControlResponse = Record<string, unknown> & {
|
export type SDKControlInterruptRequest = {
|
||||||
type?: string
|
subtype: 'interrupt'
|
||||||
subtype?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StdoutMessage = SDKControlResponse
|
export type SDKControlPermissionRequest = {
|
||||||
|
subtype: 'can_use_tool'
|
||||||
|
tool_name: string
|
||||||
|
input: Record<string, unknown>
|
||||||
|
permission_suggestions?: Array<Record<string, unknown>>
|
||||||
|
blocked_path?: string
|
||||||
|
decision_reason?: string
|
||||||
|
title?: string
|
||||||
|
display_name?: string
|
||||||
|
tool_use_id: string
|
||||||
|
agent_id?: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
export class SDKControlRequest {}
|
export type SDKControlRequestInner =
|
||||||
|
| SDKControlInterruptRequest
|
||||||
|
| SDKControlPermissionRequest
|
||||||
|
| ({
|
||||||
|
subtype: string
|
||||||
|
} & Record<string, unknown>)
|
||||||
|
|
||||||
export class SDKControlResponse {}
|
export type SDKControlRequest = {
|
||||||
|
type: 'control_request'
|
||||||
|
request_id: string
|
||||||
|
request: SDKControlRequestInner
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDKControlSuccessResponse = {
|
||||||
|
subtype: 'success'
|
||||||
|
request_id: string
|
||||||
|
response?: SDKPermissionResponse | Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDKControlErrorResponse = {
|
||||||
|
subtype: 'error'
|
||||||
|
request_id: string
|
||||||
|
error: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDKControlResponseInner =
|
||||||
|
| SDKControlSuccessResponse
|
||||||
|
| SDKControlErrorResponse
|
||||||
|
| ({
|
||||||
|
subtype: string
|
||||||
|
request_id: string
|
||||||
|
} & Record<string, unknown>)
|
||||||
|
|
||||||
|
export type SDKControlResponse = {
|
||||||
|
type: 'control_response'
|
||||||
|
response: SDKControlResponseInner
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDKControlCancelRequest = {
|
||||||
|
type: 'control_cancel_request'
|
||||||
|
request_id: string
|
||||||
|
tool_use_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type KeepAliveMessage = {
|
||||||
|
type: 'keep_alive'
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDKStreamlinedTextMessage = {
|
||||||
|
type: 'streamlined_text'
|
||||||
|
text: string
|
||||||
|
session_id?: string
|
||||||
|
uuid?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDKStreamlinedToolUseSummaryMessage = {
|
||||||
|
type: 'streamlined_tool_use_summary'
|
||||||
|
tool_summary: string
|
||||||
|
session_id?: string
|
||||||
|
uuid?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StdoutMessage =
|
||||||
|
| SDKMessage
|
||||||
|
| SDKControlRequest
|
||||||
|
| SDKControlResponse
|
||||||
|
| SDKControlCancelRequest
|
||||||
|
| KeepAliveMessage
|
||||||
|
| SDKStreamlinedTextMessage
|
||||||
|
| SDKStreamlinedToolUseSummaryMessage
|
||||||
|
|||||||
@@ -1 +1,13 @@
|
|||||||
export type Settings = Record<string, unknown>
|
export type SettingsValue =
|
||||||
|
| string
|
||||||
|
| number
|
||||||
|
| boolean
|
||||||
|
| null
|
||||||
|
| SettingsObject
|
||||||
|
| SettingsValue[]
|
||||||
|
|
||||||
|
export type SettingsObject = {
|
||||||
|
[key: string]: SettingsValue
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Settings = SettingsObject
|
||||||
|
|||||||
Reference in New Issue
Block a user