codekingpro/portable-devtools
115k
1# compiled with https://www.npmjs.com/package/cddl2py v0.2.22 3from __future__ import annotations4 5from typing import Annotated, Any, Literal, Union6from typing_extensions import NotRequired, TypedDict7 8JsInt = int9 10JsUint = int11 12Namespace = list[str]13 14Extensible = dict[str, Any]15 16Timestamp = int17 18MetadataScalar = Union[None, bool, int, float, str]19 20MessageRole = Union[Literal["ai"], Literal["human"], Literal["system"]]21 22class MessageMetadata(TypedDict, extra_items=MetadataScalar):23 provider: NotRequired[str]24 model: NotRequired[str]25 model_type: NotRequired[str]26 run_id: NotRequired[str]27 thread_id: NotRequired[str]28 system_fingerprint: NotRequired[str]29 service_tier: NotRequired[str]30 31class TextContentBlock(TypedDict):32 type: Literal["text"]33 text: str34 id: NotRequired[str]35 index: NotRequired[BlockIndex]36 annotations: NotRequired[list[Annotation]]37 38class InvalidToolCall(TypedDict):39 type: Literal["invalid_tool_call"]40 id: Union[str, None]41 name: Union[str, None]42 args: Union[str, None]43 error: Union[str, None]44 index: NotRequired[BlockIndex]45 46class ReasoningContentBlock(TypedDict):47 type: Literal["reasoning"]48 reasoning: NotRequired[str]49 id: NotRequired[str]50 index: NotRequired[BlockIndex]51 52class NonStandardContentBlock(TypedDict):53 type: Literal["non_standard"]54 value: dict[str, Any]55 id: NotRequired[str]56 index: NotRequired[BlockIndex]57 58class ImageContentBlock(TypedDict):59 type: Literal["image"]60 id: NotRequired[str]61 file_id: NotRequired[str]62 url: NotRequired[str]63 base64: NotRequired[str] # Base64-encoded image data64 mime_type: NotRequired[str]65 index: NotRequired[BlockIndex]66 67class VideoContentBlock(TypedDict):68 type: Literal["video"]69 id: NotRequired[str]70 file_id: NotRequired[str]71 url: NotRequired[str]72 base64: NotRequired[str] # Base64-encoded video data73 mime_type: NotRequired[str]74 index: NotRequired[BlockIndex]75 76class AudioContentBlock(TypedDict):77 type: Literal["audio"]78 id: NotRequired[str]79 file_id: NotRequired[str]80 url: NotRequired[str]81 base64: NotRequired[str] # Base64-encoded audio data82 mime_type: NotRequired[str]83 index: NotRequired[BlockIndex]84 85class FileContentBlock(TypedDict):86 type: Literal["file"]87 id: NotRequired[str]88 file_id: NotRequired[str]89 url: NotRequired[str]90 base64: NotRequired[str] # Base64-encoded file data91 mime_type: NotRequired[str]92 index: NotRequired[BlockIndex]93 94DataContentBlock = Union[ImageContentBlock, VideoContentBlock, AudioContentBlock, FileContentBlock]95 96class ToolCall(TypedDict):97 type: Literal["tool_call"]98 id: Union[str, None]99 name: str100 args: dict[str, Any]101 index: NotRequired[BlockIndex]102 103class ToolCallChunk(TypedDict):104 type: Literal["tool_call_chunk"]105 id: Union[str, None]106 name: Union[str, None]107 args: Union[str, None] # Partial JSON string108 index: NotRequired[BlockIndex]109 110class ServerToolCall(TypedDict):111 type: Literal["server_tool_call"]112 id: str113 name: str114 args: dict[str, Any]115 index: NotRequired[BlockIndex]116 117class ServerToolCallChunk(TypedDict):118 type: Literal["server_tool_call_chunk"]119 id: NotRequired[str]120 name: NotRequired[str]121 args: NotRequired[str]122 index: NotRequired[BlockIndex]123 124class ServerToolResult(TypedDict):125 type: Literal["server_tool_result"]126 tool_call_id: str127 status: Union[Literal["success"], Literal["error"]]128 id: NotRequired[str]129 output: NotRequired[Any]130 index: NotRequired[BlockIndex]131 132ToolContentBlock = Union[ToolCall, ToolCallChunk, ServerToolCall, ServerToolCallChunk, ServerToolResult]133 134ContentBlock = Union[TextContentBlock, InvalidToolCall, ReasoningContentBlock, NonStandardContentBlock, DataContentBlock, ToolContentBlock]135 136FinalizedContentBlock = Union[TextContentBlock, ReasoningContentBlock, ToolCall, InvalidToolCall, ServerToolCall, ServerToolResult, DataContentBlock, NonStandardContentBlock]137 138BlockIndex = Union[JsInt, str]139 140class Citation(TypedDict):141 type: Literal["citation"]142 id: NotRequired[str]143 url: NotRequired[str]144 title: NotRequired[str]145 start_index: NotRequired[int]146 end_index: NotRequired[int]147 cited_text: NotRequired[str]148 149class NonStandardAnnotation(TypedDict):150 type: Literal["non_standard_annotation"]151 id: NotRequired[str]152 value: dict[str, Any]153 154Annotation = Union[Citation, NonStandardAnnotation]155 156class TextDelta(TypedDict):157 type: Literal["text-delta"]158 text: str159 160class ReasoningDelta(TypedDict):161 type: Literal["reasoning-delta"]162 reasoning: str163 164class DataDelta(TypedDict):165 type: Literal["data-delta"]166 data: str # Encoded data chunk to append167 encoding: NotRequired[Literal["base64"]] # Defaults to base64 when absent168 169class BlockDeltaFields(TypedDict, extra_items=Any):170 type: str171 172class BlockDelta(TypedDict):173 type: Literal["block-delta"]174 fields: BlockDeltaFields175 176ContentBlockDelta = Union[TextDelta, ReasoningDelta, DataDelta, BlockDelta]177 178class RunStart(TypedDict):179 method: Literal["run.start"]180 params: RunStartParams181 182class SubscriptionSubscribe(TypedDict):183 method: Literal["subscription.subscribe"]184 params: SubscribeParams185 186class SubscriptionUnsubscribe(TypedDict):187 method: Literal["subscription.unsubscribe"]188 params: UnsubscribeParams189 190class SubscriptionReconnect(TypedDict):191 method: Literal["subscription.reconnect"]192 params: ReconnectParams193 194SubscriptionCommand = Union[SubscriptionSubscribe, SubscriptionUnsubscribe, SubscriptionReconnect]195 196class AgentGetTree(TypedDict):197 method: Literal["agent.getTree"]198 params: AgentGetTreeParams199 200class InputRespond(TypedDict):201 method: Literal["input.respond"]202 params: InputRespondParams203 204class InputInject(TypedDict):205 method: Literal["input.inject"]206 params: InputInjectParams207 208InputCommand = Union[InputRespond, InputInject]209 210class StateGet(TypedDict):211 method: Literal["state.get"]212 params: StateGetParams213 214class StateListCheckpoints(TypedDict):215 method: Literal["state.listCheckpoints"]216 params: ListCheckpointsParams217 218class StateFork(TypedDict):219 method: Literal["state.fork"]220 params: StateForkParams221 222StateCommand = Union[StateGet, StateListCheckpoints, StateFork]223 224class _CommandFields(TypedDict):225 id: JsUint226 227class _CommandVariant1(_CommandFields, SubscriptionSubscribe):228 pass229 230class _CommandVariant2(_CommandFields, SubscriptionUnsubscribe):231 pass232 233class _CommandVariant3(_CommandFields, SubscriptionReconnect):234 pass235 236class _CommandVariant5(_CommandFields, InputRespond):237 pass238 239class _CommandVariant6(_CommandFields, InputInject):240 pass241 242class _CommandVariant7(_CommandFields, StateGet):243 pass244 245class _CommandVariant8(_CommandFields, StateListCheckpoints):246 pass247 248class _CommandVariant9(_CommandFields, StateFork):249 pass250 251class CommandResponse(TypedDict):252 type: Literal["success"]253 id: JsUint254 result: ResultData255 meta: NotRequired[ResponseMeta]256 257class ErrorResponse(TypedDict):258 type: Literal["error"]259 id: Union[JsUint, None]260 error: ErrorCode261 message: str262 stacktrace: NotRequired[str]263 meta: NotRequired[ResponseMeta]264 265class LifecycleEvent(TypedDict):266 method: Literal["lifecycle"]267 params: dict[str, Any]268 269class MessagesEvent(TypedDict):270 method: Literal["messages"]271 params: dict[str, Any]272 273class ToolsEvent(TypedDict):274 method: Literal["tools"]275 params: dict[str, Any]276 277class InputEvent(TypedDict):278 method: Literal["input.requested"]279 params: dict[str, Any]280 281class ValuesEvent(TypedDict):282 method: Literal["values"]283 params: dict[str, Any]284 285class UpdatesEvent(TypedDict):286 method: Literal["updates"]287 params: dict[str, Any]288 289class CheckpointsEvent(TypedDict):290 method: Literal["checkpoints"]291 params: dict[str, Any]292 293class CustomEvent(TypedDict):294 method: Literal["custom"]295 params: dict[str, Any]296 297class TasksEvent(TypedDict):298 method: Literal["tasks"]299 params: dict[str, Any]300 301EventData = Union[LifecycleEvent, MessagesEvent, ToolsEvent, InputEvent, ValuesEvent, UpdatesEvent, CheckpointsEvent, CustomEvent, TasksEvent]302 303class _EventFields(TypedDict):304 type: Literal["event"]305 event_id: NotRequired[str] # Unique ID for reconnection (maps to SSE id:)306 seq: NotRequired[JsUint] # Monotonic sequence number for ordering307 308class _EventVariant0(_EventFields, LifecycleEvent):309 pass310 311class _EventVariant1(_EventFields, MessagesEvent):312 pass313 314class _EventVariant2(_EventFields, ToolsEvent):315 pass316 317class _EventVariant3(_EventFields, InputEvent):318 pass319 320class _EventVariant4(_EventFields, ValuesEvent):321 pass322 323class _EventVariant5(_EventFields, UpdatesEvent):324 pass325 326class _EventVariant6(_EventFields, CheckpointsEvent):327 pass328 329class _EventVariant7(_EventFields, CustomEvent):330 pass331 332class _EventVariant8(_EventFields, TasksEvent):333 pass334 335Event = Union[_EventVariant0, _EventVariant1, _EventVariant2, _EventVariant3, _EventVariant4, _EventVariant5, _EventVariant6, _EventVariant7, _EventVariant8]336 337Message = Union[CommandResponse, ErrorResponse, Event]338 339class RunResult(TypedDict):340 run_id: NotRequired[str] # ID of the started or resumed run341 342class SubscribeResult(TypedDict):343 subscription_id: str344 replayed_events: NotRequired[int] # Events replayed from buffer345 346class ReconnectResult(TypedDict):347 restored: bool348 missed_events: NotRequired[int]349 current_namespaces: NotRequired[list[AgentStatusEntry]]350 351class EmptyResult(TypedDict):352 pass353 354class AgentResult(TypedDict):355 tree: AgentTreeNode356 357class StateGetResult(TypedDict):358 values: dict[str, Any]359 checkpoint: NotRequired[CheckpointRef]360 361class ListCheckpointsResult(TypedDict):362 checkpoints: list[CheckpointSummary]363 364class StateForkResult(TypedDict):365 run_id: str366 thread_id: str367 368ErrorCode = Union[Literal["invalid_argument"], Literal["unknown_command"], Literal["unknown_error"], Literal["no_such_run"], Literal["no_such_subscription"], Literal["no_such_namespace"], Literal["no_such_interrupt"], Literal["no_such_checkpoint"], Literal["permission_denied"], Literal["not_supported"]]369 370class ResponseMeta(TypedDict):371 applied_through_seq: NotRequired[JsUint]372 373RunCommand = RunStart374 375class _CommandVariant0(_CommandFields, RunCommand):376 pass377 378class RunStartParams(TypedDict):379 assistant_id: str # Deployed graph/agent to run380 input: Any # Graph input, resume value, or injected message381 config: NotRequired[dict[str, Any]] # Per-run config overrides382 metadata: NotRequired[dict[str, Any]] # Per-run metadata383 384Channel = Union[Literal["values"], Literal["updates"], Literal["messages"], Literal["tools"], Literal["lifecycle"], Literal["input"], Literal["checkpoints"], Literal["tasks"], Literal["custom"], Annotated[str, "custom:.+"]]385 386class EventStreamRequest(TypedDict):387 channels: list[Channel]388 namespaces: NotRequired[list[Namespace]] # Prefix-match these namespace paths389 depth: NotRequired[int] # Max depth below namespace prefix390 since: NotRequired[JsUint] # Replay events after this seq number391 392class SubscribeParams(TypedDict):393 channels: list[Channel]394 namespaces: NotRequired[list[Namespace]] # Prefix-match these namespace paths395 depth: NotRequired[int] # Max depth below namespace prefix396 397class UnsubscribeParams(TypedDict):398 subscription_id: str399 400class ReconnectParams(TypedDict):401 run_id: str402 last_event_id: NotRequired[str] # Last event the client processed403 subscriptions: NotRequired[list[str]] # Subscription IDs to restore404 405class AgentStatusEntry(TypedDict):406 namespace: Namespace407 status: AgentStatus408 409SubscriptionResult = Union[SubscribeResult, ReconnectResult, EmptyResult]410 411AgentCommand = AgentGetTree412 413CommandData = Union[RunCommand, SubscriptionCommand, AgentCommand, InputCommand, StateCommand]414 415class _CommandVariant4(_CommandFields, AgentCommand):416 pass417 418Command = Union[_CommandVariant0, _CommandVariant1, _CommandVariant2, _CommandVariant3, _CommandVariant4, _CommandVariant5, _CommandVariant6, _CommandVariant7, _CommandVariant8, _CommandVariant9]419 420class AgentGetTreeParams(TypedDict):421 run_id: NotRequired[str]422 423class AgentTreeNode(TypedDict):424 namespace: Namespace425 status: AgentStatus426 graph_name: str427 children: NotRequired[list[AgentTreeNode]]428 metadata: NotRequired[dict[str, Any]]429 430AgentStatus = Union[Literal["started"], Literal["running"], Literal["completed"], Literal["failed"], Literal["interrupted"]]431 432class LifecycleCauseToolCall(TypedDict):433 type: Literal["toolCall"] # The `tool_call_id` from the originating `tool-started` event434 tool_call_id: str435 436class LifecycleCauseSend(TypedDict):437 type: Literal["send"] # Name of the parent node that issued the `Send`. Multiple Sends438 from_node: str439 440class LifecycleCauseEdge(TypedDict):441 type: Literal["edge"] # Name of the parent node the edge originated from.442 from_node: str443 444LifecycleCause = Union[LifecycleCauseToolCall, LifecycleCauseSend, LifecycleCauseEdge]445 446class LifecycleData(TypedDict):447 event: AgentStatus448 graph_name: NotRequired[str]449 cause: NotRequired[LifecycleCause] # Causation edge (see LifecycleCause)450 error: NotRequired[str]451 checkpoint: NotRequired[CheckpointRef] # Checkpoint reference for time-travel452 453class MessageStartData(TypedDict):454 event: Literal["message-start"]455 role: MessageRole # Author role for this message456 id: str # Unique ID for this message457 metadata: NotRequired[MessageMetadata] # Concise provider/model metadata for AI messages458 459class ContentBlockStartData(TypedDict):460 event: Literal["content-block-start"]461 index: int # Positional index within the message462 content: ContentBlock463 464class ContentBlockDeltaData(TypedDict):465 event: Literal["content-block-delta"]466 index: int467 delta: ContentBlockDelta468 469class ContentBlockFinishData(TypedDict):470 event: Literal["content-block-finish"]471 index: int472 content: FinalizedContentBlock473 474class MessageFinishData(TypedDict):475 event: Literal["message-finish"]476 usage: NotRequired[UsageInfo] # Token usage for AI-authored messages477 478class MessageErrorData(TypedDict):479 event: Literal["error"]480 message: str481 code: NotRequired[str]482 483MessagesData = Union[MessageStartData, ContentBlockStartData, ContentBlockDeltaData, ContentBlockFinishData, MessageFinishData, MessageErrorData]484 485class UsageInfo(TypedDict):486 input_tokens: NotRequired[int]487 output_tokens: NotRequired[int]488 total_tokens: NotRequired[int]489 490class ToolStartedData(TypedDict):491 event: Literal["tool-started"]492 tool_call_id: str493 tool_name: str494 input: NotRequired[Any] # Tool input arguments495 496class ToolOutputDeltaData(TypedDict):497 event: Literal["tool-output-delta"]498 tool_call_id: str499 delta: str500 501class ToolFinishedData(TypedDict):502 event: Literal["tool-finished"]503 tool_call_id: str504 output: Any505 506class ToolErrorData(TypedDict):507 event: Literal["tool-error"]508 tool_call_id: str509 message: str510 code: NotRequired[str]511 512ToolsData = Union[ToolStartedData, ToolOutputDeltaData, ToolFinishedData, ToolErrorData]513 514class InputRespondParams(TypedDict):515 namespace: Namespace516 interrupt_id: str517 response: Any518 519class InputInjectParams(TypedDict):520 namespace: Namespace521 message: InputMessage522 523class InputMessage(TypedDict):524 role: Union[Literal["user"], Literal["system"]]525 content: str526 name: NotRequired[str]527 528InputResult = EmptyResult529 530class InputRequestedData(TypedDict):531 interrupt_id: str # Correlates this request with input.respond532 payload: Any # Opaque interrupt value from runtime; application-defined shape533 534class StateGetParams(TypedDict):535 namespace: Namespace536 keys: NotRequired[list[str]] # Specific state keys, or omit for all537 538class ListCheckpointsParams(TypedDict):539 namespace: NotRequired[Namespace]540 limit: NotRequired[int]541 before: NotRequired[str] # Cursor for pagination542 543class CheckpointSummary(TypedDict):544 id: str545 timestamp: str # ISO 8601546 step: int547 node_name: NotRequired[str] # Node that produced this checkpoint548 metadata: NotRequired[dict[str, Any]]549 550class CheckpointRef(TypedDict):551 id: str552 ns: NotRequired[str]553 554class StateForkParams(TypedDict):555 checkpoint_id: str556 input: NotRequired[Any] # Input for the forked run557 config: NotRequired[dict[str, Any]] # Config overrides558 559StateResult = Union[StateGetResult, ListCheckpointsResult, StateForkResult, EmptyResult]560 561ResultData = Union[RunResult, SubscriptionResult, AgentResult, InputResult, StateResult, EmptyResult]562 563class Checkpoint(TypedDict):564 id: str # Fork target: pass to state.fork / configurable.checkpoint_id565 parent_id: NotRequired[str] # Parent checkpoint id for tree linkage566 step: int # Superstep number (-1 for first input, 0 for first loop step, ...)567 source: CheckpointSource # Origin of the checkpoint568 569CheckpointSource = Union[Literal["input"], Literal["loop"], Literal["update"], Literal["fork"]]570 571class UpdatesData(TypedDict):572 node: NotRequired[str] # Graph node that produced this update573 values: dict[str, Any] # State delta574 575class CustomData(TypedDict):576 name: NotRequired[str] # Custom event name for dispatch577 payload: Any # User-defined payload578 579 