1 | import * as nbformat from '@jupyterlab/nbformat';
|
2 | import { JSONObject } from '@lumino/coreutils';
|
3 | export interface IOptions<T extends Message> {
|
4 | session: string;
|
5 | channel: T['channel'];
|
6 | msgType: T['header']['msg_type'];
|
7 | content: T['content'];
|
8 | buffers?: (ArrayBuffer | ArrayBufferView)[];
|
9 | metadata?: JSONObject;
|
10 | msgId?: string;
|
11 | username?: string;
|
12 | parentHeader?: T['parent_header'];
|
13 | }
|
14 | export declare function createMessage<T extends IClearOutputMsg>(options: IOptions<T>): T;
|
15 | export declare function createMessage<T extends ICommCloseMsg<'iopub'>>(options: IOptions<T>): T;
|
16 | export declare function createMessage<T extends ICommCloseMsg<'shell'>>(options: IOptions<T>): T;
|
17 | export declare function createMessage<T extends ICommInfoReplyMsg>(options: IOptions<T>): T;
|
18 | export declare function createMessage<T extends ICommInfoRequestMsg>(options: IOptions<T>): T;
|
19 | export declare function createMessage<T extends ICommMsgMsg<'iopub'>>(options: IOptions<T>): T;
|
20 | export declare function createMessage<T extends ICommMsgMsg<'shell'>>(options: IOptions<T>): T;
|
21 | export declare function createMessage<T extends ICommOpenMsg<'iopub'>>(options: IOptions<T>): T;
|
22 | export declare function createMessage<T extends ICommOpenMsg<'shell'>>(options: IOptions<T>): T;
|
23 | export declare function createMessage<T extends ICompleteReplyMsg>(options: IOptions<T>): T;
|
24 | export declare function createMessage<T extends ICompleteRequestMsg>(options: IOptions<T>): T;
|
25 | export declare function createMessage<T extends IDisplayDataMsg>(options: IOptions<T>): T;
|
26 | export declare function createMessage<T extends IErrorMsg>(options: IOptions<T>): T;
|
27 | export declare function createMessage<T extends IExecuteInputMsg>(options: IOptions<T>): T;
|
28 | export declare function createMessage<T extends IExecuteReplyMsg>(options: IOptions<T>): T;
|
29 | export declare function createMessage<T extends IExecuteRequestMsg>(options: IOptions<T>): T;
|
30 | export declare function createMessage<T extends IExecuteResultMsg>(options: IOptions<T>): T;
|
31 | export declare function createMessage<T extends IHistoryReplyMsg>(options: IOptions<T>): T;
|
32 | export declare function createMessage<T extends IHistoryRequestMsg>(options: IOptions<T>): T;
|
33 | export declare function createMessage<T extends IInfoReplyMsg>(options: IOptions<T>): T;
|
34 | export declare function createMessage<T extends IInfoRequestMsg>(options: IOptions<T>): T;
|
35 | export declare function createMessage<T extends IInputReplyMsg>(options: IOptions<T>): T;
|
36 | export declare function createMessage<T extends IInputRequestMsg>(options: IOptions<T>): T;
|
37 | export declare function createMessage<T extends IInspectReplyMsg>(options: IOptions<T>): T;
|
38 | export declare function createMessage<T extends IInspectRequestMsg>(options: IOptions<T>): T;
|
39 | export declare function createMessage<T extends IIsCompleteReplyMsg>(options: IOptions<T>): T;
|
40 | export declare function createMessage<T extends IIsCompleteRequestMsg>(options: IOptions<T>): T;
|
41 | export declare function createMessage<T extends IStatusMsg>(options: IOptions<T>): T;
|
42 | export declare function createMessage<T extends IStreamMsg>(options: IOptions<T>): T;
|
43 | export declare function createMessage<T extends IUpdateDisplayDataMsg>(options: IOptions<T>): T;
|
44 | /**
|
45 | * @hidden
|
46 | * #### Notes
|
47 | * Debug messages are experimental messages that are not in the official
|
48 | * kernel message specification. As such, this function is *NOT* considered
|
49 | * part of the public API, and may change without notice.
|
50 | */
|
51 | export declare function createMessage<T extends IDebugRequestMsg>(options: IOptions<T>): T;
|
52 | /**
|
53 | * @hidden
|
54 | * #### Notes
|
55 | * Debug messages are experimental messages that are not in the official
|
56 | * kernel message specification. As such, this function is *NOT* considered
|
57 | * part of the public API, and may change without notice.
|
58 | */
|
59 | export declare function createMessage<T extends IDebugReplyMsg>(options: IOptions<T>): T;
|
60 | /**
|
61 | * @hidden
|
62 | * #### Notes
|
63 | * Debug messages are experimental messages that are not in the official
|
64 | * kernel message specification. As such, this function is *NOT* considered
|
65 | * part of the public API, and may change without notice.
|
66 | */
|
67 | export declare function createMessage<T extends IDebugEventMsg>(options: IOptions<T>): T;
|
68 | /**
|
69 | * Shell message types.
|
70 | */
|
71 | export type ShellMessageType = 'comm_close' | 'comm_info_reply' | 'comm_info_request' | 'comm_msg' | 'comm_open' | 'complete_reply' | 'complete_request' | 'execute_reply' | 'execute_request' | 'history_reply' | 'history_request' | 'inspect_reply' | 'inspect_request' | 'interrupt_reply' | 'interrupt_request' | 'is_complete_reply' | 'is_complete_request' | 'kernel_info_reply' | 'kernel_info_request' | 'shutdown_reply' | 'shutdown_request';
|
72 | /**
|
73 | * Control message types.
|
74 | *
|
75 | * #### Notes
|
76 | * Debug messages are experimental messages that are not in the official
|
77 | * kernel message specification. As such, debug message types are *NOT*
|
78 | * considered part of the public API, and may change without notice.
|
79 | */
|
80 | export type ControlMessageType = 'debug_request' | 'debug_reply';
|
81 | /**
|
82 | * IOPub message types.
|
83 | *
|
84 | * #### Notes
|
85 | * Debug messages are experimental messages that are not in the official
|
86 | * kernel message specification. As such, debug message types are *NOT*
|
87 | * considered part of the public API, and may change without notice.
|
88 | */
|
89 | export type IOPubMessageType = 'clear_output' | 'comm_close' | 'comm_msg' | 'comm_open' | 'display_data' | 'error' | 'execute_input' | 'execute_result' | 'shutdown_reply' | 'status' | 'stream' | 'update_display_data' | 'debug_event';
|
90 | /**
|
91 | * Stdin message types.
|
92 | */
|
93 | export type StdinMessageType = 'input_request' | 'input_reply';
|
94 | /**
|
95 | * Jupyter message types.
|
96 | */
|
97 | export type MessageType = IOPubMessageType | ShellMessageType | ControlMessageType | StdinMessageType;
|
98 | /**
|
99 | * The valid Jupyter channel names in a message to a frontend.
|
100 | */
|
101 | export type Channel = 'shell' | 'control' | 'iopub' | 'stdin';
|
102 | /**
|
103 | * Kernel message header content.
|
104 | *
|
105 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#general-message-format).
|
106 | *
|
107 | * **See also:** [[IMessage]]
|
108 | */
|
109 | export interface IHeader<T extends MessageType = MessageType> {
|
110 | /**
|
111 | * ISO 8601 timestamp for when the message is created
|
112 | */
|
113 | date: string;
|
114 | /**
|
115 | * Message id, typically UUID, must be unique per message
|
116 | */
|
117 | msg_id: string;
|
118 | /**
|
119 | * Message type
|
120 | */
|
121 | msg_type: T;
|
122 | /**
|
123 | * Session id, typically UUID, should be unique per session.
|
124 | */
|
125 | session: string;
|
126 | /**
|
127 | * The user sending the message
|
128 | */
|
129 | username: string;
|
130 | /**
|
131 | * The message protocol version, should be 5.1, 5.2, 5.3, etc.
|
132 | */
|
133 | version: string;
|
134 | }
|
135 | /**
|
136 | * Kernel message specification.
|
137 | *
|
138 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#general-message-format).
|
139 | */
|
140 | export interface IMessage<MSGTYPE extends MessageType = MessageType> {
|
141 | /**
|
142 | * An optional list of binary buffers.
|
143 | */
|
144 | buffers?: (ArrayBuffer | ArrayBufferView)[];
|
145 | /**
|
146 | * The channel on which the message is transmitted.
|
147 | */
|
148 | channel: Channel;
|
149 | /**
|
150 | * The content of the message.
|
151 | */
|
152 | content: Message['content'];
|
153 | /**
|
154 | * The message header.
|
155 | */
|
156 | header: IHeader<MSGTYPE>;
|
157 | /**
|
158 | * Metadata associated with the message.
|
159 | */
|
160 | metadata: JSONObject;
|
161 | /**
|
162 | * The parent message
|
163 | */
|
164 | parent_header: IHeader | Record<string, never>;
|
165 | }
|
166 | /**
|
167 | * A kernel message on the `'shell'` channel.
|
168 | */
|
169 | export interface IShellMessage<T extends ShellMessageType = ShellMessageType> extends IMessage<T> {
|
170 | channel: 'shell';
|
171 | }
|
172 | /**
|
173 | * A kernel message on the `'control'` channel.
|
174 | */
|
175 | export interface IControlMessage<T extends ControlMessageType = ControlMessageType> extends IMessage<T> {
|
176 | channel: 'control';
|
177 | }
|
178 | /**
|
179 | * A message type for shell or control messages.
|
180 | *
|
181 | * #### Notes
|
182 | * This convenience is so we can use it as a generic type constraint.
|
183 | */
|
184 | export type IShellControlMessage = IShellMessage | IControlMessage;
|
185 | /**
|
186 | * A kernel message on the `'iopub'` channel.
|
187 | */
|
188 | export interface IIOPubMessage<T extends IOPubMessageType = IOPubMessageType> extends IMessage<T> {
|
189 | channel: 'iopub';
|
190 | }
|
191 | /**
|
192 | * A kernel message on the `'stdin'` channel.
|
193 | */
|
194 | export interface IStdinMessage<T extends StdinMessageType = StdinMessageType> extends IMessage<T> {
|
195 | channel: 'stdin';
|
196 | }
|
197 | /**
|
198 | * Message types.
|
199 | *
|
200 | * #### Notes
|
201 | * Debug messages are experimental messages that are not in the official
|
202 | * kernel message specification. As such, debug message types are *NOT*
|
203 | * considered part of the public API, and may change without notice.
|
204 | */
|
205 | export type Message = IClearOutputMsg | ICommCloseMsg<'iopub'> | ICommCloseMsg<'shell'> | ICommInfoReplyMsg | ICommInfoRequestMsg | ICommMsgMsg<'iopub'> | ICommMsgMsg<'shell'> | ICommOpenMsg<'iopub'> | ICommOpenMsg<'shell'> | ICompleteReplyMsg | ICompleteRequestMsg | IDisplayDataMsg | IErrorMsg | IExecuteInputMsg | IExecuteReplyMsg | IExecuteRequestMsg | IExecuteResultMsg | IHistoryReplyMsg | IHistoryRequestMsg | IInfoReplyMsg | IInfoRequestMsg | IInputReplyMsg | IInputRequestMsg | IInspectReplyMsg | IInspectRequestMsg | IIsCompleteReplyMsg | IIsCompleteRequestMsg | IStatusMsg | IStreamMsg | IUpdateDisplayDataMsg | IDebugRequestMsg | IDebugReplyMsg | IDebugEventMsg;
|
206 | /**
|
207 | * A `'stream'` message on the `'iopub'` channel.
|
208 | *
|
209 | * See [Streams](https://jupyter-client.readthedocs.io/en/latest/messaging.html#streams-stdout-stderr-etc).
|
210 | */
|
211 | export interface IStreamMsg extends IIOPubMessage<'stream'> {
|
212 | content: {
|
213 | name: 'stdout' | 'stderr';
|
214 | text: string;
|
215 | };
|
216 | }
|
217 | /**
|
218 | * Test whether a kernel message is a `'stream'` message.
|
219 | */
|
220 | export declare function isStreamMsg(msg: IMessage): msg is IStreamMsg;
|
221 | /**
|
222 | * A `'display_data'` message on the `'iopub'` channel.
|
223 | *
|
224 | * See [Display data](https://jupyter-client.readthedocs.io/en/latest/messaging.html#display-data).
|
225 | */
|
226 | export interface IDisplayDataMsg extends IIOPubMessage<'display_data'> {
|
227 | content: {
|
228 | data: nbformat.IMimeBundle;
|
229 | metadata: nbformat.OutputMetadata;
|
230 | transient?: {
|
231 | display_id?: string;
|
232 | };
|
233 | };
|
234 | }
|
235 | /**
|
236 | * Test whether a kernel message is an `'display_data'` message.
|
237 | */
|
238 | export declare function isDisplayDataMsg(msg: IMessage): msg is IDisplayDataMsg;
|
239 | /**
|
240 | * An `'update_display_data'` message on the `'iopub'` channel.
|
241 | *
|
242 | * See [Update Display data](https://jupyter-client.readthedocs.io/en/latest/messaging.html#update-display-data).
|
243 | */
|
244 | export interface IUpdateDisplayDataMsg extends IIOPubMessage<'update_display_data'> {
|
245 | content: IDisplayDataMsg['content'] & {
|
246 | transient: {
|
247 | display_id: string;
|
248 | };
|
249 | };
|
250 | }
|
251 | /**
|
252 | * Test whether a kernel message is an `'update_display_data'` message.
|
253 | */
|
254 | export declare function isUpdateDisplayDataMsg(msg: IMessage): msg is IUpdateDisplayDataMsg;
|
255 | /**
|
256 | * An `'execute_input'` message on the `'iopub'` channel.
|
257 | *
|
258 | * See [Code inputs](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-inputs).
|
259 | */
|
260 | export interface IExecuteInputMsg extends IIOPubMessage<'execute_input'> {
|
261 | content: {
|
262 | code: string;
|
263 | execution_count: nbformat.ExecutionCount;
|
264 | };
|
265 | }
|
266 | /**
|
267 | * Test whether a kernel message is an `'execute_input'` message.
|
268 | */
|
269 | export declare function isExecuteInputMsg(msg: IMessage): msg is IExecuteInputMsg;
|
270 | /**
|
271 | * An `'execute_result'` message on the `'iopub'` channel.
|
272 | *
|
273 | * See [Execution results](https://jupyter-client.readthedocs.io/en/latest/messaging.html#id4).
|
274 | */
|
275 | export interface IExecuteResultMsg extends IIOPubMessage<'execute_result'> {
|
276 | content: {
|
277 | execution_count: nbformat.ExecutionCount;
|
278 | data: nbformat.IMimeBundle;
|
279 | metadata: nbformat.OutputMetadata;
|
280 | transient?: {
|
281 | display_id?: string;
|
282 | };
|
283 | };
|
284 | }
|
285 | /**
|
286 | * Test whether a kernel message is an `'execute_result'` message.
|
287 | */
|
288 | export declare function isExecuteResultMsg(msg: IMessage): msg is IExecuteResultMsg;
|
289 | /**
|
290 | * A `'error'` message on the `'iopub'` channel.
|
291 | *
|
292 | * See [Execution errors](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-errors).
|
293 | */
|
294 | export interface IErrorMsg extends IIOPubMessage<'error'> {
|
295 | content: {
|
296 | ename: string;
|
297 | evalue: string;
|
298 | traceback: string[];
|
299 | };
|
300 | }
|
301 | /**
|
302 | * Test whether a kernel message is an `'error'` message.
|
303 | */
|
304 | export declare function isErrorMsg(msg: IMessage): msg is IErrorMsg;
|
305 | /**
|
306 | * The valid Kernel status states.
|
307 | *
|
308 | * #### Notes
|
309 | * The status states are:
|
310 | * * `unknown`: The kernel status is unknown, often because the connection
|
311 | * is disconnected or connecting. This state is determined by the kernel
|
312 | * connection status.
|
313 | * * `autorestarting`: The kernel is restarting, initiated by the server.
|
314 | * This state is set by the services library, not explicitly sent from the
|
315 | * kernel.
|
316 | * * `starting`: The kernel is starting
|
317 | * * `idle`: The kernel has finished processing messages.
|
318 | * * `busy`: The kernel is currently processing messages.
|
319 | * * `restarting`: The kernel is restarting. This state is sent by the
|
320 | * Jupyter server.
|
321 | * * `dead`: The kernel is dead and will not be restarted. This state is set
|
322 | * by the Jupyter server and is a final state.
|
323 | */
|
324 | export type Status = 'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead';
|
325 | /**
|
326 | * A `'status'` message on the `'iopub'` channel.
|
327 | *
|
328 | * See [Kernel status](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-status).
|
329 | */
|
330 | export interface IStatusMsg extends IIOPubMessage<'status'> {
|
331 | content: {
|
332 | execution_state: Status;
|
333 | };
|
334 | }
|
335 | /**
|
336 | * Test whether a kernel message is a `'status'` message.
|
337 | */
|
338 | export declare function isStatusMsg(msg: IMessage): msg is IStatusMsg;
|
339 | /**
|
340 | * A `'clear_output'` message on the `'iopub'` channel.
|
341 | *
|
342 | * See [Clear output](https://jupyter-client.readthedocs.io/en/latest/messaging.html#clear-output).
|
343 | */
|
344 | export interface IClearOutputMsg extends IIOPubMessage<'clear_output'> {
|
345 | content: {
|
346 | wait: boolean;
|
347 | };
|
348 | }
|
349 | /**
|
350 | * Test whether a kernel message is a `'clear_output'` message.
|
351 | */
|
352 | export declare function isClearOutputMsg(msg: IMessage): msg is IClearOutputMsg;
|
353 | /**
|
354 | * An experimental `'debug_event'` message on the `'iopub'` channel
|
355 | *
|
356 | * @hidden
|
357 | *
|
358 | * #### Notes
|
359 | * Debug messages are experimental messages that are not in the official
|
360 | * kernel message specification. As such, this is *NOT* considered
|
361 | * part of the public API, and may change without notice.
|
362 | */
|
363 | export interface IDebugEventMsg extends IIOPubMessage<'debug_event'> {
|
364 | content: {
|
365 | seq: number;
|
366 | type: 'event';
|
367 | event: string;
|
368 | body?: any;
|
369 | };
|
370 | }
|
371 | /**
|
372 | * Test whether a kernel message is an experimental `'debug_event'` message.
|
373 | *
|
374 | * @hidden
|
375 | *
|
376 | * #### Notes
|
377 | * Debug messages are experimental messages that are not in the official
|
378 | * kernel message specification. As such, this is *NOT* considered
|
379 | * part of the public API, and may change without notice.
|
380 | */
|
381 | export declare function isDebugEventMsg(msg: IMessage): msg is IDebugEventMsg;
|
382 | /**
|
383 | * A `'comm_open'` message on the `'iopub'` channel.
|
384 | *
|
385 | * See [Comm open](https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm).
|
386 | */
|
387 | export interface ICommOpenMsg<T extends 'shell' | 'iopub' = 'iopub' | 'shell'> extends IMessage<'comm_open'> {
|
388 | channel: T;
|
389 | content: {
|
390 | comm_id: string;
|
391 | target_name: string;
|
392 | data: JSONObject;
|
393 | target_module?: string;
|
394 | };
|
395 | }
|
396 | /**
|
397 | * Test whether a kernel message is a `'comm_open'` message.
|
398 | */
|
399 | export declare function isCommOpenMsg(msg: IMessage): msg is ICommOpenMsg;
|
400 | /**
|
401 | * A `'comm_close'` message on the `'iopub'` channel.
|
402 | *
|
403 | * See [Comm close](https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm).
|
404 | */
|
405 | export interface ICommCloseMsg<T extends 'iopub' | 'shell' = 'iopub' | 'shell'> extends IMessage<'comm_close'> {
|
406 | channel: T;
|
407 | content: {
|
408 | comm_id: string;
|
409 | data: JSONObject;
|
410 | };
|
411 | }
|
412 | /**
|
413 | * Test whether a kernel message is a `'comm_close'` message.
|
414 | */
|
415 | export declare function isCommCloseMsg(msg: IMessage): msg is ICommCloseMsg<'iopub' | 'shell'>;
|
416 | /**
|
417 | * A `'comm_msg'` message on the `'iopub'` channel.
|
418 | *
|
419 | * See [Comm msg](https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm).
|
420 | */
|
421 | export interface ICommMsgMsg<T extends 'iopub' | 'shell' = 'iopub' | 'shell'> extends IMessage<'comm_msg'> {
|
422 | channel: T;
|
423 | content: {
|
424 | comm_id: string;
|
425 | data: JSONObject;
|
426 | };
|
427 | }
|
428 | /**
|
429 | * Test whether a kernel message is a `'comm_msg'` message.
|
430 | */
|
431 | export declare function isCommMsgMsg(msg: IMessage): msg is ICommMsgMsg;
|
432 | /**
|
433 | * Reply content indicating a successful request.
|
434 | */
|
435 | export interface IReplyOkContent {
|
436 | status: 'ok';
|
437 | }
|
438 | /**
|
439 | * Reply content indicating an error.
|
440 | *
|
441 | * See the [Message spec](https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply) for details.
|
442 | */
|
443 | export interface IReplyErrorContent {
|
444 | status: 'error';
|
445 | /**
|
446 | * Exception name
|
447 | */
|
448 | ename: string;
|
449 | /**
|
450 | * Exception value
|
451 | */
|
452 | evalue: string;
|
453 | /**
|
454 | * Traceback
|
455 | */
|
456 | traceback: string[];
|
457 | }
|
458 | /**
|
459 | * Reply content indicating an aborted request.
|
460 | *
|
461 | * This is [deprecated](https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply)
|
462 | * in message spec 5.1. Kernels should send an 'error' reply instead.
|
463 | */
|
464 | export interface IReplyAbortContent {
|
465 | status: 'abort';
|
466 | }
|
467 | /**
|
468 | * A convenience type for reply content.
|
469 | *
|
470 | * This automatically unions the necessary error and abort replies required in
|
471 | * the [message spec](https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply).
|
472 | */
|
473 | type ReplyContent<T> = T | IReplyErrorContent | IReplyAbortContent;
|
474 | /**
|
475 | * A `'kernel_info_request'` message on the `'shell'` channel.
|
476 | *
|
477 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
|
478 | */
|
479 | export interface IInfoRequestMsg extends IShellMessage<'kernel_info_request'> {
|
480 | content: Record<string, never>;
|
481 | }
|
482 | /**
|
483 | * Test whether a kernel message is a `'kernel_info_request'` message.
|
484 | */
|
485 | export declare function isInfoRequestMsg(msg: IMessage): msg is IInfoRequestMsg;
|
486 | /**
|
487 | * A `'kernel_info_reply'` message content.
|
488 | *
|
489 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
|
490 | */
|
491 | export interface IInfoReply extends IReplyOkContent {
|
492 | protocol_version: string;
|
493 | implementation: string;
|
494 | implementation_version: string;
|
495 | language_info: ILanguageInfo;
|
496 | banner: string;
|
497 | help_links: {
|
498 | text: string;
|
499 | url: string;
|
500 | }[];
|
501 | }
|
502 | /**
|
503 | * The kernel language information specification.
|
504 | *
|
505 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
|
506 | */
|
507 | export interface ILanguageInfo extends nbformat.ILanguageInfoMetadata {
|
508 | version: string;
|
509 | nbconverter_exporter?: string;
|
510 | }
|
511 | /**
|
512 | * A `'kernel_info_reply'` message on the `'shell'` channel.
|
513 | *
|
514 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
|
515 | */
|
516 | export interface IInfoReplyMsg extends IShellMessage<'kernel_info_reply'> {
|
517 | parent_header: IHeader<'kernel_info_request'>;
|
518 | content: ReplyContent<IInfoReply>;
|
519 | }
|
520 | /**
|
521 | * A `'complete_request'` message.
|
522 | *
|
523 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
|
524 | *
|
525 | * **See also:** [[ICompleteReplyMsg]], [[IKernel.complete]]
|
526 | */
|
527 | export interface ICompleteRequestMsg extends IShellMessage<'complete_request'> {
|
528 | content: {
|
529 | code: string;
|
530 | cursor_pos: number;
|
531 | };
|
532 | }
|
533 | /**
|
534 | * A `'complete_reply'` message content.
|
535 | *
|
536 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
|
537 | *
|
538 | * **See also:** [[ICompleteRequest]], [[IKernel.complete]]
|
539 | */
|
540 | interface ICompleteReply extends IReplyOkContent {
|
541 | matches: string[];
|
542 | cursor_start: number;
|
543 | cursor_end: number;
|
544 | metadata: JSONObject;
|
545 | }
|
546 | /**
|
547 | * A `'complete_reply'` message on the `'shell'` channel.
|
548 | *
|
549 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
|
550 | *
|
551 | * **See also:** [[ICompleteRequest]], [[IKernel.complete]]
|
552 | */
|
553 | export interface ICompleteReplyMsg extends IShellMessage<'complete_reply'> {
|
554 | parent_header: IHeader<'complete_request'>;
|
555 | content: ReplyContent<ICompleteReply>;
|
556 | }
|
557 | /**
|
558 | * An `'inspect_request'` message.
|
559 | *
|
560 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
|
561 | *
|
562 | * **See also:** [[IInspectReplyMsg]], [[[IKernel.inspect]]]
|
563 | */
|
564 | export interface IInspectRequestMsg extends IShellMessage<'inspect_request'> {
|
565 | content: {
|
566 | code: string;
|
567 | cursor_pos: number;
|
568 | detail_level: 0 | 1;
|
569 | };
|
570 | }
|
571 | /**
|
572 | * A `'inspect_reply'` message content.
|
573 | *
|
574 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
|
575 | *
|
576 | * **See also:** [[IInspectRequest]], [[IKernel.inspect]]
|
577 | */
|
578 | export interface IInspectReply extends IReplyOkContent {
|
579 | found: boolean;
|
580 | data: JSONObject;
|
581 | metadata: JSONObject;
|
582 | }
|
583 | /**
|
584 | * A `'inspect_reply'` message on the `'shell'` channel.
|
585 | *
|
586 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
|
587 | *
|
588 | * **See also:** [[IInspectRequest]], [[IKernel.inspect]]
|
589 | */
|
590 | export interface IInspectReplyMsg extends IShellMessage<'inspect_reply'> {
|
591 | parent_header: IHeader<'inspect_request'>;
|
592 | content: ReplyContent<IInspectReply>;
|
593 | }
|
594 | /**
|
595 | * A `'history_request'` message.
|
596 | *
|
597 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
|
598 | *
|
599 | * **See also:** [[IHistoryReplyMsg]], [[[IKernel.history]]]
|
600 | */
|
601 | export interface IHistoryRequestMsg extends IShellMessage<'history_request'> {
|
602 | content: IHistoryRequestRange | IHistoryRequestSearch | IHistoryRequestTail;
|
603 | }
|
604 | /**
|
605 | * The content of a `'history_request'` range message.
|
606 | *
|
607 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
|
608 | *
|
609 | * **See also:** [[IHistoryReply]], [[[IKernel.history]]]
|
610 | */
|
611 | export interface IHistoryRequestRange {
|
612 | output: boolean;
|
613 | raw: boolean;
|
614 | hist_access_type: 'range';
|
615 | session: number;
|
616 | start: number;
|
617 | stop: number;
|
618 | }
|
619 | /**
|
620 | * The content of a `'history_request'` search message.
|
621 | *
|
622 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
|
623 | *
|
624 | * **See also:** [[IHistoryReply]], [[[IKernel.history]]]
|
625 | */
|
626 | export interface IHistoryRequestSearch {
|
627 | output: boolean;
|
628 | raw: boolean;
|
629 | hist_access_type: 'search';
|
630 | n: number;
|
631 | pattern: string;
|
632 | unique: boolean;
|
633 | }
|
634 | /**
|
635 | * The content of a `'history_request'` tail message.
|
636 | *
|
637 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
|
638 | *
|
639 | * **See also:** [[IHistoryReply]], [[[IKernel.history]]]
|
640 | */
|
641 | export interface IHistoryRequestTail {
|
642 | output: boolean;
|
643 | raw: boolean;
|
644 | hist_access_type: 'tail';
|
645 | n: number;
|
646 | }
|
647 | /**
|
648 | * A `'history_reply'` message content.
|
649 | *
|
650 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
|
651 | *
|
652 | * **See also:** [[IHistoryRequest]], [[IKernel.history]]
|
653 | */
|
654 | export interface IHistoryReply extends IReplyOkContent {
|
655 | history: [number, number, string][] | [number, number, [string, string]][];
|
656 | }
|
657 | /**
|
658 | * A `'history_reply'` message on the `'shell'` channel.
|
659 | *
|
660 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
|
661 | *
|
662 | * **See also:** [[IHistoryRequest]], [[IKernel.history]]
|
663 | */
|
664 | export interface IHistoryReplyMsg extends IShellMessage<'history_reply'> {
|
665 | parent_header: IHeader<'history_request'>;
|
666 | content: ReplyContent<IHistoryReply>;
|
667 | }
|
668 | /**
|
669 | * An `'is_complete_request'` message.
|
670 | *
|
671 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
|
672 | *
|
673 | * **See also:** [[IIsCompleteReplyMsg]], [[IKernel.isComplete]]
|
674 | */
|
675 | export interface IIsCompleteRequestMsg extends IShellMessage<'is_complete_request'> {
|
676 | content: {
|
677 | code: string;
|
678 | };
|
679 | }
|
680 | /**
|
681 | * An `'is_complete_reply'` message on the `'stream'` channel.
|
682 | *
|
683 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
|
684 | *
|
685 | * **See also:** [[IIsCompleteRequest]], [[IKernel.isComplete]]
|
686 | */
|
687 | export interface IIsCompleteReplyMsg extends IShellMessage<'is_complete_reply'> {
|
688 | parent_header: IHeader<'is_complete_request'>;
|
689 | content: ReplyContent<IIsCompleteReplyIncomplete | IIsCompleteReplyOther>;
|
690 | }
|
691 | /**
|
692 | * An 'incomplete' completion reply
|
693 | */
|
694 | export interface IIsCompleteReplyIncomplete {
|
695 | status: 'incomplete';
|
696 | indent: string;
|
697 | }
|
698 | /**
|
699 | * A completion reply for completion or invalid states.
|
700 | */
|
701 | export interface IIsCompleteReplyOther {
|
702 | status: 'complete' | 'invalid' | 'unknown';
|
703 | }
|
704 | /**
|
705 | * An `execute_request` message on the `'shell'` channel.
|
706 | */
|
707 | export interface IExecuteRequestMsg extends IShellMessage<'execute_request'> {
|
708 | content: {
|
709 | /**
|
710 | * The code to execute.
|
711 | */
|
712 | code: string;
|
713 | /**
|
714 | * Whether to execute the code as quietly as possible.
|
715 | * The default is `false`.
|
716 | */
|
717 | silent?: boolean;
|
718 | /**
|
719 | * Whether to store history of the execution.
|
720 | * The default `true` if silent is False.
|
721 | * It is forced to `false ` if silent is `true`.
|
722 | */
|
723 | store_history?: boolean;
|
724 | /**
|
725 | * A mapping of names to expressions to be evaluated in the
|
726 | * kernel's interactive namespace.
|
727 | */
|
728 | user_expressions?: JSONObject;
|
729 | /**
|
730 | * Whether to allow stdin requests.
|
731 | * The default is `true`.
|
732 | */
|
733 | allow_stdin?: boolean;
|
734 | /**
|
735 | * Whether to the abort execution queue on an error.
|
736 | * The default is `false`.
|
737 | */
|
738 | stop_on_error?: boolean;
|
739 | };
|
740 | }
|
741 | /**
|
742 | * The content of an `execute-reply` message.
|
743 | *
|
744 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results).
|
745 | */
|
746 | export interface IExecuteCount {
|
747 | execution_count: nbformat.ExecutionCount;
|
748 | }
|
749 | /**
|
750 | * A convenience type for a base for an execute reply content.
|
751 | */
|
752 | type IExecuteReplyBase = IExecuteCount & IReplyOkContent;
|
753 | /**
|
754 | * The `'execute_reply'` contents for an `'ok'` status.
|
755 | *
|
756 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results).
|
757 | */
|
758 | export interface IExecuteReply extends IExecuteReplyBase {
|
759 | /**
|
760 | * A list of payload objects.
|
761 | * Payloads are considered deprecated.
|
762 | * The only requirement of each payload object is that it have a 'source'
|
763 | * key, which is a string classifying the payload (e.g. 'page').
|
764 | */
|
765 | payload?: JSONObject[];
|
766 | /**
|
767 | * Results for the user_expressions.
|
768 | */
|
769 | user_expressions: JSONObject;
|
770 | }
|
771 | /**
|
772 | * An `'execute_reply'` message on the `'stream'` channel.
|
773 | *
|
774 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results).
|
775 | *
|
776 | * **See also:** [[IExecuteRequest]], [[IKernel.execute]]
|
777 | */
|
778 | export interface IExecuteReplyMsg extends IShellMessage<'execute_reply'> {
|
779 | parent_header: IHeader<'execute_request'>;
|
780 | content: ReplyContent<IExecuteReply> & IExecuteCount;
|
781 | }
|
782 | /**
|
783 | * Test whether a kernel message is an `'execute_reply'` message.
|
784 | */
|
785 | export declare function isExecuteReplyMsg(msg: IMessage): msg is IExecuteReplyMsg;
|
786 | /**
|
787 | * A `'comm_info_request'` message on the `'shell'` channel.
|
788 | *
|
789 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info).
|
790 | *
|
791 | * **See also:** [[ICommInfoReplyMsg]], [[IKernel.commInfo]]
|
792 | */
|
793 | export interface ICommInfoRequestMsg extends IShellMessage<'comm_info_request'> {
|
794 | content: {
|
795 | /**
|
796 | * The comm target name to filter returned comms
|
797 | */
|
798 | target_name?: string;
|
799 | };
|
800 | }
|
801 | /**
|
802 | * A `'comm_info_reply'` message content.
|
803 | *
|
804 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info).
|
805 | *
|
806 | * **See also:** [[ICommInfoRequest]], [[IKernel.commInfo]]
|
807 | */
|
808 | export interface ICommInfoReply extends IReplyOkContent {
|
809 | /**
|
810 | * Mapping of comm ids to target names.
|
811 | */
|
812 | comms: {
|
813 | [commId: string]: {
|
814 | target_name: string;
|
815 | };
|
816 | };
|
817 | }
|
818 | /**
|
819 | * A `'comm_info_reply'` message on the `'shell'` channel.
|
820 | *
|
821 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info).
|
822 | *
|
823 | * **See also:** [[ICommInfoRequestMsg]], [[IKernel.commInfo]]
|
824 | */
|
825 | export interface ICommInfoReplyMsg extends IShellMessage<'comm_info_reply'> {
|
826 | parent_header: IHeader<'comm_info_request'>;
|
827 | content: ReplyContent<ICommInfoReply>;
|
828 | }
|
829 | /**
|
830 | * An experimental `'debug_request'` message on the `'control'` channel.
|
831 | *
|
832 | * @hidden
|
833 | *
|
834 | * #### Notes
|
835 | * Debug messages are experimental messages that are not in the official
|
836 | * kernel message specification. As such, this function is *NOT* considered
|
837 | * part of the public API, and may change without notice.
|
838 | */
|
839 | export interface IDebugRequestMsg extends IControlMessage<'debug_request'> {
|
840 | content: {
|
841 | seq: number;
|
842 | type: 'request';
|
843 | command: string;
|
844 | arguments?: any;
|
845 | };
|
846 | }
|
847 | /**
|
848 | * Test whether a kernel message is an experimental `'debug_request'` message.
|
849 | *
|
850 | * @hidden
|
851 | *
|
852 | * #### Notes
|
853 | * Debug messages are experimental messages that are not in the official
|
854 | * kernel message specification. As such, this is *NOT* considered
|
855 | * part of the public API, and may change without notice.
|
856 | */
|
857 | export declare function isDebugRequestMsg(msg: IMessage): msg is IDebugRequestMsg;
|
858 | /**
|
859 | * An experimental `'debug_reply'` message on the `'control'` channel.
|
860 | *
|
861 | * @hidden
|
862 | *
|
863 | * #### Notes
|
864 | * Debug messages are experimental messages that are not in the official
|
865 | * kernel message specification. As such, this is *NOT* considered
|
866 | * part of the public API, and may change without notice.
|
867 | */
|
868 | export interface IDebugReplyMsg extends IControlMessage<'debug_reply'> {
|
869 | content: {
|
870 | seq: number;
|
871 | type: 'response';
|
872 | request_seq: number;
|
873 | success: boolean;
|
874 | command: string;
|
875 | message?: string;
|
876 | body?: any;
|
877 | };
|
878 | }
|
879 | /**
|
880 | * Test whether a kernel message is an experimental `'debug_reply'` message.
|
881 | *
|
882 | * @hidden
|
883 | *
|
884 | * #### Notes
|
885 | * Debug messages are experimental messages that are not in the official
|
886 | * kernel message specification. As such, this is *NOT* considered
|
887 | * part of the public API, and may change without notice.
|
888 | */
|
889 | export declare function isDebugReplyMsg(msg: IMessage): msg is IDebugReplyMsg;
|
890 | /**
|
891 | * An `'input_request'` message on the `'stdin'` channel.
|
892 | *
|
893 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
|
894 | */
|
895 | export interface IInputRequestMsg extends IStdinMessage<'input_request'> {
|
896 | content: {
|
897 | /**
|
898 | * The text to show at the prompt.
|
899 | */
|
900 | prompt: string;
|
901 | /**
|
902 | * Whether the request is for a password.
|
903 | * If so, the frontend shouldn't echo input.
|
904 | */
|
905 | password: boolean;
|
906 | };
|
907 | }
|
908 | /**
|
909 | * Test whether a kernel message is an `'input_request'` message.
|
910 | */
|
911 | export declare function isInputRequestMsg(msg: IMessage): msg is IInputRequestMsg;
|
912 | /**
|
913 | * An `'input_reply'` message content.
|
914 | *
|
915 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
|
916 | */
|
917 | export interface IInputReply extends IReplyOkContent {
|
918 | value: string;
|
919 | }
|
920 | /**
|
921 | * An `'input_reply'` message on the `'stdin'` channel.
|
922 | *
|
923 | * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
|
924 | */
|
925 | export interface IInputReplyMsg extends IStdinMessage<'input_reply'> {
|
926 | parent_header: IHeader<'input_request'>;
|
927 | content: ReplyContent<IInputReply>;
|
928 | }
|
929 | /**
|
930 | * Test whether a kernel message is an `'input_reply'` message.
|
931 | */
|
932 | export declare function isInputReplyMsg(msg: IMessage): msg is IInputReplyMsg;
|
933 | /**
|
934 | * The list of supported kernel wire protocols over websocket.
|
935 | */
|
936 | export declare enum supportedKernelWebSocketProtocols {
|
937 | v1KernelWebsocketJupyterOrg = "v1.kernel.websocket.jupyter.org"
|
938 | }
|
939 | export {};
|