codebind 0.5.3__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codebind-0.5.3 → codebind-0.5.4}/PKG-INFO +2 -2
- {codebind-0.5.3 → codebind-0.5.4}/README.md +1 -1
- {codebind-0.5.3 → codebind-0.5.4}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json +2 -2
- codebind-0.5.4/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.23e40a479779d2ac.js +1 -0
- codebind-0.5.3/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.b6b50e099d2c670a.js → codebind-0.5.4/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.1939b78df7ae17ab.js +1 -1
- {codebind-0.5.3 → codebind-0.5.4}/jupyterlab/package.json +1 -1
- {codebind-0.5.3 → codebind-0.5.4}/jupyterlab/src/index.ts +85 -2
- {codebind-0.5.3 → codebind-0.5.4}/pyproject.toml +1 -1
- {codebind-0.5.3 → codebind-0.5.4}/pyproject.toml.orig +1 -1
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/jupyter.py +8 -0
- codebind-0.5.3/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.65031998ea066c13.js +0 -1
- {codebind-0.5.3 → codebind-0.5.4}/LICENSE +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/data/share/jupyter/labextensions/codebind-jupyterlab/install.json +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/data/share/jupyter/labextensions/codebind-jupyterlab/static/style.js +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/data/share/jupyter/labextensions/codebind-jupyterlab/static/third-party-licenses.json +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/jupyterlab/.yarnrc.yml +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/jupyterlab/install.json +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/jupyterlab/tsconfig.json +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/jupyterlab/yarn.lock +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/__init__.py +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/cli.py +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/display.py +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/execution.py +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/extension.py +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/py.typed +0 -0
- {codebind-0.5.3 → codebind-0.5.4}/src/codebind/session.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codebind
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: A frontend-neutral model loop for persistent IPython sessions.
|
|
5
5
|
Keywords: ai,ipython,llm,repl,agents
|
|
6
6
|
Author: Giovanni Gravili
|
|
@@ -86,7 +86,7 @@ model = models.chat("openai/gpt-5")
|
|
|
86
86
|
await chat.asend("Inspect the current notebook state.", model)
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
After assigning `model`, select a cell and click **Question** in the notebook toolbar to configure that cell as a Question cell. Write ordinary Markdown and press `Shift+Enter`; Codebind sends the cell through `chat` using the `model` variable, renders the question as Markdown, and appends tool executions and the assistant response to the end of the notebook. Question cells are stored as standard Markdown cells with Codebind metadata, so other notebook frontends can still read them.
|
|
89
|
+
After assigning `model`, select a cell and click **Question** in the notebook toolbar to configure that cell as a Question cell. Write ordinary Markdown and press `Shift+Enter`; Codebind sends the cell through `chat` using the `model` variable, renders the question as Markdown, and appends tool executions and the assistant response to the end of the notebook. Jupyter's standard interrupt button cancels an active Codebind question. Question cells are stored as standard Markdown cells with Codebind metadata, so other notebook frontends can still read them.
|
|
90
90
|
|
|
91
91
|
The Codebind package includes a prebuilt JupyterLab extension. In JupyterLab, each model-authored IPython execution becomes a genuine code cell with its native execution count and outputs, and the assistant response becomes a rendered Markdown cell. The cells are ordinary notebook content and are saved with the notebook.
|
|
92
92
|
|
|
@@ -61,7 +61,7 @@ model = models.chat("openai/gpt-5")
|
|
|
61
61
|
await chat.asend("Inspect the current notebook state.", model)
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
After assigning `model`, select a cell and click **Question** in the notebook toolbar to configure that cell as a Question cell. Write ordinary Markdown and press `Shift+Enter`; Codebind sends the cell through `chat` using the `model` variable, renders the question as Markdown, and appends tool executions and the assistant response to the end of the notebook. Question cells are stored as standard Markdown cells with Codebind metadata, so other notebook frontends can still read them.
|
|
64
|
+
After assigning `model`, select a cell and click **Question** in the notebook toolbar to configure that cell as a Question cell. Write ordinary Markdown and press `Shift+Enter`; Codebind sends the cell through `chat` using the `model` variable, renders the question as Markdown, and appends tool executions and the assistant response to the end of the notebook. Jupyter's standard interrupt button cancels an active Codebind question. Question cells are stored as standard Markdown cells with Codebind metadata, so other notebook frontends can still read them.
|
|
65
65
|
|
|
66
66
|
The Codebind package includes a prebuilt JupyterLab extension. In JupyterLab, each model-authored IPython execution becomes a genuine code cell with its native execution count and outputs, and the assistant response becomes a rendered Markdown cell. The cells are ordinary notebook content and are saved with the notebook.
|
|
67
67
|
|
{codebind-0.5.3 → codebind-0.5.4}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebind-jupyterlab",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Native JupyterLab cells and Question cells for Codebind.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"extension": true,
|
|
32
32
|
"outputDir": "../data/share/jupyter/labextensions/codebind-jupyterlab",
|
|
33
33
|
"_build": {
|
|
34
|
-
"load": "static/remoteEntry.
|
|
34
|
+
"load": "static/remoteEntry.1939b78df7ae17ab.js",
|
|
35
35
|
"extension": "./extension"
|
|
36
36
|
}
|
|
37
37
|
}
|
codebind-0.5.4/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.23e40a479779d2ac.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).push([[590],{509(e,t,n){n.r(t);var o=n(511),l=n(343),i=n(171);let r="codebind:insert-question",d="codebind:run-question",u="jp-CodebindQuestionCell",s=new WeakMap,c=new WeakMap;function a(e){return 0!==e.runningQuestions.size&&(e.comm?.send({type:"cancel"}),!0)}function p(e){let t=e.getMetadata("codebind");return"object"!=typeof t||null===t||"question"!==t.kind?null:{kind:"question",model:"string"==typeof t.model?t.model:"model"}}function m(e){return e.replace(/(^|[^\\])\\([()[\]])/g,"$1\\\\$2")}function f(e){let t=s.get(e);for(let n of e.content.widgets){let e=p(n.model);n.node.classList.toggle(u,null!==e);let o=n.node.querySelector(".jp-InputPrompt");o&&(e?(o.dataset.codebindQuestion="true",o.textContent=t?.runningQuestions.has(n.model.id)?"Question [*]:":"Question:"):o.dataset.codebindQuestion&&(delete o.dataset.codebindQuestion,o.textContent=""))}}function g(e){let t=e.sessionContext.session?.kernel;if(!t)return;let n=s.get(e)??{comm:null,kernel:null,runningQuestions:new Map};s.set(e,n);n.kernel&&n.kernel!==t&&c.get(n.kernel)?.delete(n),n.kernel=t;let i=c.get(t);if(!i){i=new Set,c.set(t,i);let e=t.interrupt.bind(t);t.interrupt=async()=>{let t=[...i??[]].filter(e=>e.runningQuestions.size>0);for(let e of t)a(e);for(let e=0;t.length>0&&e<50;e+=1){if(t.every(e=>0===e.runningQuestions.size))return;await new Promise(e=>setTimeout(e,10))}return e()}}i.add(n),n.comm=null,n.runningQuestions.clear();let r=null,d=new Map,u=()=>{if(!r)return;let e=r;r=null,e.parentModel&&null!==e.parentExecutionCount&&(e.parentModel.executionCount=e.parentExecutionCount)};t.registerCommTarget("codebind",(i,s)=>{i.onMsg=i=>{let s=i.content.data;if(!function(e){if("object"!=typeof e||null===e)return!1;if("markdown_cell"===e.type)return"string"==typeof e.source;if("code_cell_started"===e.type)return"string"==typeof e.cell_id&&"string"==typeof e.source;if("code_cell_output"===e.type)return"string"==typeof e.cell_id&&"object"==typeof e.output&&null!==e.output;if("code_cell_clear"===e.type)return"string"==typeof e.cell_id&&"boolean"==typeof e.wait;if("question_finished"===e.type){let t=e.error;return"string"==typeof e.cell_id&&"boolean"==typeof e.cancelled&&(null===t||"object"==typeof t&&"string"==typeof t.type&&"string"==typeof t.message)}return"code_cell_finished"===e.type&&"string"==typeof e.cell_id&&("number"==typeof e.execution_count||null===e.execution_count)&&Array.isArray(e.outputs)}(s))return;if("question_finished"===s.type){n.runningQuestions.delete(s.cell_id),f(e),u(),s.error&&!s.cancelled&&(0,o.showErrorMessage)(`Codebind question: ${s.error.type}`,s.error.message);return}if("code_cell_output"===s.type)return void d.get(s.cell_id)?.outputs.add(s.output);if("code_cell_clear"===s.type)return void d.get(s.cell_id)?.outputs.clear(s.wait);if("code_cell_finished"===s.type){let e=d.get(s.cell_id);if(!e)return;e.outputs.fromJSON(s.outputs),e.executionCount=s.execution_count,e.executionState="idle",r&&null===r.parentExecutionCount&&null!==s.execution_count&&(r.parentExecutionCount=s.execution_count-1);return}(()=>{if(r)return;let n=e.content,o=n.widgets.findIndex(e=>"code"===e.model.type&&"running"===e.model.executionState);r={parentModel:o>=0?n.widgets[o].model:null,parentExecutionCount:null};let l=(e,n)=>{"idle"===n&&(t.statusChanged.disconnect(l),u())};return t.statusChanged.connect(l)})();let c=function(e,t){let n=e.content,o=n.model;if(!o)return null;let i=n.widgets.length;"code_cell_started"===t.type?o.sharedModel.insertCell(i,{cell_type:"code",source:t.source,metadata:{trusted:!0},execution_count:null,outputs:[]}):o.sharedModel.insertCell(i,{cell_type:"markdown",source:m(t.source),metadata:{}});let r=n.widgets[i]??null;return r instanceof l.MarkdownCell&&(r.rendered=!0),r?.model??null}(e,s);"code_cell_started"===s.type&&c?.type==="code"&&(c.executionState="running",d.set(s.cell_id,c))},n.comm=i,i.onClose=()=>{n.comm===i&&(n.comm=null)},i.send({type:"ready"})})}async function y(e){let t=e.content,n=t.activeCell;if(!n)return;let i=p(n.model);if(!i)return;let r=s.get(e);if(!r?.comm)return void await (0,o.showErrorMessage)("Codebind is not connected","Run %load_ext codebind in this kernel before sending a Question cell.");if(r.runningQuestions.size>0)return void await (0,o.showErrorMessage)("Codebind is busy","Wait for the current question to finish before sending another.");let d=n.model.sharedModel.getSource().trim();d?(r.runningQuestions.set(n.model.id,n.model),n.model.sharedModel.setSource(m(d)),f(e),n instanceof l.MarkdownCell&&(n.rendered=!0),t.mode="command",r.comm.send({type:"question",cell_id:n.model.id,question:d,model:i.model})):await (0,o.showErrorMessage)("Empty Codebind question","Write a question before sending it.")}function b(e,t){let n={comm:null,kernel:null,runningQuestions:new Map};s.set(e,n);let l=e=>{a(n)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),window.setTimeout(()=>{n.runningQuestions.size>0&&n.kernel?.interrupt()},500))},i=null,d=()=>{let t=e.toolbar.node.querySelector('[data-command="notebook:interrupt-kernel"]');t!==i&&(i?.removeEventListener("click",l,!0),i=t,i?.addEventListener("click",l,!0))},u=new MutationObserver(d);u.observe(e.toolbar.node,{childList:!0,subtree:!0}),d(),e.disposed.connect(()=>{u.disconnect(),i?.removeEventListener("click",l,!0)}),e.toolbar.insertItem(10,"codebindQuestion",new o.ToolbarButton({label:"Question",tooltip:"Use the selected cell as a Codebind Question",onClick:()=>{t.commands.execute(r)}})),e.content.modelContentChanged.connect(()=>f(e)),e.context.ready.then(()=>f(e)),e.sessionContext.ready.then(()=>g(e)),e.sessionContext.kernelChanged.connect(()=>g(e))}let C={id:"codebind-jupyterlab:plugin",description:"Insert Codebind executions as native notebook cells.",autoStart:!0,requires:[i.INotebookTracker],activate:(e,t)=>{e.commands.addCommand(r,{label:"Use Selected Cell as Codebind Question",execute:()=>{let e=t.currentWidget;e&&function(e){let t=e.content,n=t.model;if(!n)return;t.activeCell?"markdown"!==t.activeCell.model.type&&i.NotebookActions.changeCellType(t,"markdown"):(n.sharedModel.insertCell(0,{cell_type:"markdown",source:"",metadata:{}}),t.activeCellIndex=0);let o=t.activeCell;o?.model.setMetadata("codebind",{kind:"question",model:"model"}),o instanceof l.MarkdownCell&&(o.rendered=!1),t.mode="edit",f(e),o?.editor?.focus()}(e)}}),e.commands.addCommand(d,{label:"Send Codebind Question",isEnabled:()=>{let e=t.currentWidget?.content.activeCell;return!!e&&null!==p(e.model)},execute:async()=>{let e=t.currentWidget;e&&await y(e)}}),e.commands.addKeyBinding({command:d,keys:["Shift Enter"],selector:`.jp-Notebook .${u}`}),e.contextMenu.addItem({command:r,selector:".jp-Notebook .jp-Cell",rank:8}),t.forEach(t=>b(t,e)),t.widgetAdded.connect((t,n)=>b(n,e))}};n.d(t,{},{default:C})}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _JUPYTERLAB;(()=>{"use strict";var e,n,r,t,o,i,u,a,c,l,f,s,p,d,h,g,v,y,m,b,S,k,j,w,E,x,T,M,P,A,C,O,D,_,q,L,V,N={457(e,n,r){var t={"./index":()=>r.e(590).then(()=>()=>r(509)),"./extension":()=>r.e(590).then(()=>()=>r(509))},o=function(e,n){return r.R=n,n=r.o(t,e)?t[e]():Promise.resolve().then(()=>{throw Error('Module "'+e+'" does not exist in container.')}),r.R=void 0,n},i=function(e,n){if(r.S){var t="default",o=r.S[t];if(o&&o!==e)throw Error("Container initialization failed as it has already been initialized with a different share scope");return r.S[t]=e,r.I(t,n)}};r.d(n,{get:()=>o,init:()=>i})}},$={};function z(e){var n=$[e];if(void 0!==n)return n.exports;var r=$[e]={exports:{}};return N[e](r,r.exports,z),r.exports}z.m=N,z.c=$,z.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return z.d(n,{a:n}),n},z.d=(e,n,r)=>{var t=(n,r)=>{for(var t in n)z.o(n,t)&&!z.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:n[t]})};t(n,"get"),t(r,"value")},z.f={},z.e=e=>Promise.all(Object.keys(z.f).reduce((n,r)=>(z.f[r](e,n),n),[])),z.u=e=>""+e+".65031998ea066c13.js?v=65031998ea066c13",z.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),z.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),I={},z.l=function(e,n,r,t){if(I[e])return void I[e].push(n);if(void 0!==r)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="codebind-jupyterlab:"+r){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,z.nc&&o.setAttribute("nonce",z.nc),o.setAttribute("data-rspack","codebind-jupyterlab:"+r),o.src=e),I[e]=[n];var l=function(n,r){o.onerror=o.onload=null,clearTimeout(f);var t=I[e];if(delete I[e],o.parentNode&&o.parentNode.removeChild(o),t&&t.forEach(function(e){return e(r)}),n)return n(r)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},z.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},z.S={},z.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"codebind-jupyterlab",version:"0.5.3",factory:()=>z.e(590).then(()=>()=>z(509)),eager:0,treeShakingMode:null}]},uniqueName:"codebind-jupyterlab"},R={},U={},z.I=function(e,n){n||(n=[]);var r=U[e];if(r||(r=U[e]={}),!(n.indexOf(r)>=0)){if(n.push(r),R[e])return R[e];z.o(z.S,e)||(z.S[e]={});var t=z.S[e],o=function(e){"u">typeof console&&console.warn&&console.warn(e)},i=z.initializeSharingData.uniqueName,u=function(e,n,r,o){var u=t[e]=t[e]||{},a=u[n];(!a||!a.loaded&&(!o!=!a.eager?o:i>a.from))&&(u[n]={get:r,from:i,eager:!!o})},a=function(r){var t=function(e){o("Initialization of sharing external failed: "+e)};try{var i=z(r);if(!i)return;var u=function(r){return r&&r.init&&r.init(z.S[e],n)};if(i.then)return c.push(i.then(u,t));var a=u(i);if(a&&a.then)return c.push(a.catch(t))}catch(e){t(e)}},c=[],l=z.initializeSharingData.scopeToSharingDataMapping;return(l[e]&&l[e].forEach(function(e){"object"==typeof e?u(e.name,e.version,e.factory,e.eager):a(e)}),c.length)?R[e]=Promise.all(c).then(function(){return R[e]=1}):R[e]=1}},z.g.importScripts&&(B=z.g.location+"");var I,R,U,B,J=z.g.document;if(!B&&J&&(J.currentScript&&"SCRIPT"===J.currentScript.tagName.toUpperCase()&&(B=J.currentScript.src),!B)){var K=J.getElementsByTagName("script");if(K.length)for(var Y=K.length-1;Y>-1&&(!B||!/^http(s?):/.test(B));)B=K[Y--].src}if(!B)throw Error("Automatic publicPath is not supported in this browser");z.p=B=B.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),z.consumesLoadingData={chunkMapping:{590:["511","343","171"]},moduleIdToConsumeDataMapping:{171:{shareScope:"default",shareKey:"@jupyterlab/notebook",import:null,requiredVersion:"^4.6.3",strictVersion:!1,singleton:!0,eager:!1,fallback:void 0,treeShakingMode:null},343:{shareScope:"default",shareKey:"@jupyterlab/cells",import:null,requiredVersion:"^4.6.3",strictVersion:!1,singleton:!1,eager:!1,fallback:void 0,treeShakingMode:null},511:{shareScope:"default",shareKey:"@jupyterlab/apputils",import:null,requiredVersion:"^4.7.3",strictVersion:!1,singleton:!0,eager:!1,fallback:void 0,treeShakingMode:null}},initialConsumes:[]},e=function(e){return e.split(".").map(function(e){return+e==e?+e:e})},n=function(n){var r=function(n){var r=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(n),t=r[1]?[0].concat(e(r[1])):[0];r[2]&&(t.length++,t.push.apply(t,e(r[2])));let o=t[t.length-1];for(;t.length&&(void 0===o||/^[*xX]$/.test(o));)t.pop(),o=t[t.length-1];return t},t=function(e){return 1===e.length?[0]:2===e.length?[1].concat(e.slice(1)):3===e.length?[2].concat(e.slice(1)):[e.length].concat(e.slice(1))},o=function(e){return[-e[0]-1].concat(e.slice(1))},i=function(e){let n=/^(\^|~|<=|<|>=|>|=|v|!)/.exec(e),i=n?n[0]:"",u=r(i.length?e.slice(i.length).trim():e.trim());switch(i){case"^":if(u.length>1&&0===u[1]){if(u.length>2&&0===u[2])return[3].concat(u.slice(1));return[2].concat(u.slice(1))}return[1].concat(u.slice(1));case"~":return[2].concat(u.slice(1));case">=":return u;case"=":case"v":case"":return t(u);case"<":return o(u);case">":return[,t(u),0,u,2];case"<=":return[,t(u),o(u),1];case"!":return[,t(u),0];default:throw Error("Unexpected start value")}},u=function(e,n){if(1===e.length)return e[0];let r=[];for(let n of e.slice().reverse())0 in n?r.push(n):r.push.apply(r,n.slice(1));return[,].concat(r,e.slice(1).map(()=>n))};return u(n.split(/\s*\|\|\s*/).map(function(e){let n=e.split(/\s+-\s+/);if(1===n.length){e=e.trim();let n=[],r=/[-0-9A-Za-z]\s+/g;for(var a,c=0;a=r.exec(e);){let r=a.index+1;n.push(i(e.slice(c,r).trim())),c=r}return n.push(i(e.slice(c).trim())),u(n,2)}let l=r(n[0]),f=r(n[1]);return[,t(f),o(f),1,l,2]}),1)},r=function(n){var r=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(n),t=r[1]?e(r[1]):[];return r[2]&&(t.length++,t.push.apply(t,e(r[2]))),r[3]&&(t.push([]),t.push.apply(t,e(r[3]))),t},t=function(e,n){e=r(e),n=r(n);for(var t=0;;){if(t>=e.length)return t<n.length&&"u"!=(typeof n[t])[0];var o=e[t],i=(typeof o)[0];if(t>=n.length)return"u"==i;var u=n[t],a=(typeof u)[0];if(i==a){if("o"!=i&&"u"!=i&&o!=u)return o<u;t++}else{if("o"==i&&"n"==a)return!0;return"s"==a||"u"==i}}},o=function(e){var n=e[0],r="";if(1===e.length)return"*";if(n+.5){r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var t=1,i=1;i<e.length;i++){var u=e[i],a=(typeof u)[0];t--,r+="u"==a?"-":(t>0?".":"")+(t=2,u)}return r}for(var c=[],i=1;i<e.length;i++){var u=e[i];c.push(0===u?"not("+l()+")":1===u?"("+l()+" || "+l()+")":2===u?c.pop()+" "+c.pop():o(u))}return l();function l(){return c.pop().replace(/^\((.+)\)$/,"$1")}},i=function(e,n){if(0 in e){n=r(n);var t=e[0],o=t<0;o&&(t=-t-1);for(var u=0,a=1,c=!0;;a++,u++){var l,f,s=a<e.length?(typeof e[a])[0]:"";if(u>=n.length||"o"==(f=(typeof(l=n[u]))[0])){if(!c)return!0;if("u"==s)return a>t&&!o;return""==s!=o}if("u"==f){if(!c||"u"!=s)return!1}else if(c)if(s==f)if(a<=t){if(l!=e[a])return!1}else{if(o?l>e[a]:l<e[a])return!1;l!=e[a]&&(c=!1)}else if("s"!=s&&"n"!=s){if(o||a<=t)return!1;c=!1,a--}else{if(a<=t||f<s!=o)return!1;c=!1}else"s"!=s&&"n"!=s&&(c=!1,a--)}}for(var p=[],d=p.pop.bind(p),u=1;u<e.length;u++){var h=e[u];p.push(1==h?d()|d():2==h?d()&d():h?i(h,n):!d())}return!!d()},u=function(e,n){var r=z.S[e];if(!r||!z.o(r,n))throw Error("Shared module "+n+" doesn't exist in shared scope "+e);return r},a=function(e,n){var r=e[n],n=Object.keys(r).reduce(function(e,n){return!e||t(e,n)?n:e},0);return n&&r[n]},c=function(e,n){var r=e[n];return Object.keys(r).reduce(function(e,n){return!e||!r[e].loaded&&t(e,n)?n:e},0)},l=function(e,n,r,t){return"Unsatisfied version "+r+" from "+(r&&e[n][r].from)+" of shared singleton module "+n+" (required "+o(t)+")"},f=function(e,n,r,t){var o=c(e,r);return m(e[r][o])},s=function(e,n,r,t){var o=c(e,r);return i(t,o)||v(l(e,r,o,t)),m(e[r][o])},p=function(e,n,r,t){var o=c(e,r);if(!i(t,o))throw Error(l(e,r,o,t));return m(e[r][o])},d=function(e,n,r){var o=e[n],n=Object.keys(o).reduce(function(e,n){return i(r,n)&&(!e||t(e,n))?n:e},0);return n&&o[n]},h=function(e,n,r,t){var i=e[r];return"No satisfying version ("+o(t)+") of shared module "+r+" found in shared scope "+n+".\nAvailable versions: "+Object.keys(i).map(function(e){return e+" from "+i[e].from}).join(", ")},g=function(e,n,r,t){var o=d(e,r,t);if(o)return m(o);throw Error(h(e,n,r,t))},v=function(e){"u">typeof console&&console.warn&&console.warn(e)},y=function(e,n,r,t){v(h(e,n,r,t))},m=function(e){return e.loaded=1,e.get()},S=(b=function(e){return function(n,r,t,o){var i=z.I(n);return i&&i.then?i.then(e.bind(e,n,z.S[n],r,t,o)):e(n,z.S[n],r,t,o)}})(function(e,n,r){return u(e,r),m(a(n,r))}),k=b(function(e,n,r,t){return n&&z.o(n,r)?m(a(n,r)):t()}),j=b(function(e,n,r,t){return u(e,r),m(d(n,r,t)||y(n,e,r,t)||a(n,r))}),w=b(function(e,n,r){return u(e,r),f(n,e,r)}),E=b(function(e,n,r,t){return u(e,r),s(n,e,r,t)}),x=b(function(e,n,r,t){return u(e,r),g(n,e,r,t)}),T=b(function(e,n,r,t){return u(e,r),p(n,e,r,t)}),M=b(function(e,n,r,t,o){return n&&z.o(n,r)?m(d(n,r,t)||y(n,e,r,t)||a(n,r)):o()}),P=b(function(e,n,r,t){return n&&z.o(n,r)?f(n,e,r):t()}),A=b(function(e,n,r,t,o){return n&&z.o(n,r)?s(n,e,r,t):o()}),C=b(function(e,n,r,t,o){var i=n&&z.o(n,r)&&d(n,r,t);return i?m(i):o()}),O=b(function(e,n,r,t,o){return n&&z.o(n,r)?p(n,e,r,t):o()}),D=function(e){var r=!1,t=!1,o=!1,i=!1,u=[e.shareScope,e.shareKey];return(e.requiredVersion?(e.strictVersion&&(r=!0),e.singleton&&(t=!0),u.push(n(e.requiredVersion)),o=!0):e.singleton&&(t=!0),e.fallback&&(i=!0,u.push(e.fallback)),r&&t&&o&&i)?function(){return O.apply(null,u)}:r&&o&&i?function(){return C.apply(null,u)}:t&&o&&i?function(){return A.apply(null,u)}:r&&t&&o?function(){return T.apply(null,u)}:t&&i?function(){return P.apply(null,u)}:o&&i?function(){return M.apply(null,u)}:r&&o?function(){return x.apply(null,u)}:t&&o?function(){return E.apply(null,u)}:t?function(){return w.apply(null,u)}:o?function(){return j.apply(null,u)}:i?function(){return k.apply(null,u)}:function(){return S.apply(null,u)}},_={},z.f.consumes=function(e,n){var r=z.consumesLoadingData.moduleIdToConsumeDataMapping,t=z.consumesLoadingData.chunkMapping;z.o(t,e)&&t[e].forEach(function(e){if(z.o(_,e))return n.push(_[e]);var t=function(n){_[e]=0,z.m[e]=function(r){delete z.c[e],r.exports=n()}},o=function(n){delete _[e],z.m[e]=function(r){throw delete z.c[e],n}};try{var i=D(r[e])();i.then?n.push(_[e]=i.then(t).catch(o)):t(i)}catch(e){o(e)}})},q={871:0},z.f.j=function(e,n){var r=z.o(q,e)?q[e]:void 0;if(0!==r)if(r)n.push(r[2]);else{var t=new Promise((n,t)=>r=q[e]=[n,t]);n.push(r[2]=t);var o=z.p+z.u(e),i=Error();z.l(o,function(n){if(z.o(q,e)&&(0!==(r=q[e])&&(q[e]=void 0),r)){var t=n&&("load"===n.type?"missing":n.type),o=n&&n.target&&n.target.src;i.message="Loading chunk "+e+" failed.\n("+t+": "+o+")",i.name="ChunkLoadError",i.type=t,i.request=o,r[1](i)}},"chunk-"+e,e)}},L=(e,n)=>{var r,t,[o,i,u]=n,a=0;if(o.some(e=>0!==q[e])){for(r in i)z.o(i,r)&&(z.m[r]=i[r]);u&&u(z)}for(e&&e(n);a<o.length;a++)t=o[a],z.o(q,t)&&q[t]&&q[t][0](),q[t]=0},(V=self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).forEach(L.bind(null,0)),V.push=L.bind(null,V.push.bind(V));var F=z(457);(_JUPYTERLAB=void 0===_JUPYTERLAB?{}:_JUPYTERLAB)["codebind-jupyterlab"]=F})();
|
|
1
|
+
var _JUPYTERLAB;(()=>{"use strict";var e,n,r,t,o,i,u,a,c,l,f,s,p,d,h,g,v,y,m,b,S,k,j,w,E,x,T,M,P,A,C,O,D,_,q,L,V,N={457(e,n,r){var t={"./index":()=>r.e(590).then(()=>()=>r(509)),"./extension":()=>r.e(590).then(()=>()=>r(509))},o=function(e,n){return r.R=n,n=r.o(t,e)?t[e]():Promise.resolve().then(()=>{throw Error('Module "'+e+'" does not exist in container.')}),r.R=void 0,n},i=function(e,n){if(r.S){var t="default",o=r.S[t];if(o&&o!==e)throw Error("Container initialization failed as it has already been initialized with a different share scope");return r.S[t]=e,r.I(t,n)}};r.d(n,{get:()=>o,init:()=>i})}},$={};function z(e){var n=$[e];if(void 0!==n)return n.exports;var r=$[e]={exports:{}};return N[e](r,r.exports,z),r.exports}z.m=N,z.c=$,z.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return z.d(n,{a:n}),n},z.d=(e,n,r)=>{var t=(n,r)=>{for(var t in n)z.o(n,t)&&!z.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:n[t]})};t(n,"get"),t(r,"value")},z.f={},z.e=e=>Promise.all(Object.keys(z.f).reduce((n,r)=>(z.f[r](e,n),n),[])),z.u=e=>""+e+".23e40a479779d2ac.js?v=23e40a479779d2ac",z.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),z.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),I={},z.l=function(e,n,r,t){if(I[e])return void I[e].push(n);if(void 0!==r)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="codebind-jupyterlab:"+r){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,z.nc&&o.setAttribute("nonce",z.nc),o.setAttribute("data-rspack","codebind-jupyterlab:"+r),o.src=e),I[e]=[n];var l=function(n,r){o.onerror=o.onload=null,clearTimeout(f);var t=I[e];if(delete I[e],o.parentNode&&o.parentNode.removeChild(o),t&&t.forEach(function(e){return e(r)}),n)return n(r)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},z.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},z.S={},z.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"codebind-jupyterlab",version:"0.5.4",factory:()=>z.e(590).then(()=>()=>z(509)),eager:0,treeShakingMode:null}]},uniqueName:"codebind-jupyterlab"},R={},U={},z.I=function(e,n){n||(n=[]);var r=U[e];if(r||(r=U[e]={}),!(n.indexOf(r)>=0)){if(n.push(r),R[e])return R[e];z.o(z.S,e)||(z.S[e]={});var t=z.S[e],o=function(e){"u">typeof console&&console.warn&&console.warn(e)},i=z.initializeSharingData.uniqueName,u=function(e,n,r,o){var u=t[e]=t[e]||{},a=u[n];(!a||!a.loaded&&(!o!=!a.eager?o:i>a.from))&&(u[n]={get:r,from:i,eager:!!o})},a=function(r){var t=function(e){o("Initialization of sharing external failed: "+e)};try{var i=z(r);if(!i)return;var u=function(r){return r&&r.init&&r.init(z.S[e],n)};if(i.then)return c.push(i.then(u,t));var a=u(i);if(a&&a.then)return c.push(a.catch(t))}catch(e){t(e)}},c=[],l=z.initializeSharingData.scopeToSharingDataMapping;return(l[e]&&l[e].forEach(function(e){"object"==typeof e?u(e.name,e.version,e.factory,e.eager):a(e)}),c.length)?R[e]=Promise.all(c).then(function(){return R[e]=1}):R[e]=1}},z.g.importScripts&&(B=z.g.location+"");var I,R,U,B,J=z.g.document;if(!B&&J&&(J.currentScript&&"SCRIPT"===J.currentScript.tagName.toUpperCase()&&(B=J.currentScript.src),!B)){var K=J.getElementsByTagName("script");if(K.length)for(var Y=K.length-1;Y>-1&&(!B||!/^http(s?):/.test(B));)B=K[Y--].src}if(!B)throw Error("Automatic publicPath is not supported in this browser");z.p=B=B.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),z.consumesLoadingData={chunkMapping:{590:["511","343","171"]},moduleIdToConsumeDataMapping:{171:{shareScope:"default",shareKey:"@jupyterlab/notebook",import:null,requiredVersion:"^4.6.3",strictVersion:!1,singleton:!0,eager:!1,fallback:void 0,treeShakingMode:null},343:{shareScope:"default",shareKey:"@jupyterlab/cells",import:null,requiredVersion:"^4.6.3",strictVersion:!1,singleton:!1,eager:!1,fallback:void 0,treeShakingMode:null},511:{shareScope:"default",shareKey:"@jupyterlab/apputils",import:null,requiredVersion:"^4.7.3",strictVersion:!1,singleton:!0,eager:!1,fallback:void 0,treeShakingMode:null}},initialConsumes:[]},e=function(e){return e.split(".").map(function(e){return+e==e?+e:e})},n=function(n){var r=function(n){var r=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(n),t=r[1]?[0].concat(e(r[1])):[0];r[2]&&(t.length++,t.push.apply(t,e(r[2])));let o=t[t.length-1];for(;t.length&&(void 0===o||/^[*xX]$/.test(o));)t.pop(),o=t[t.length-1];return t},t=function(e){return 1===e.length?[0]:2===e.length?[1].concat(e.slice(1)):3===e.length?[2].concat(e.slice(1)):[e.length].concat(e.slice(1))},o=function(e){return[-e[0]-1].concat(e.slice(1))},i=function(e){let n=/^(\^|~|<=|<|>=|>|=|v|!)/.exec(e),i=n?n[0]:"",u=r(i.length?e.slice(i.length).trim():e.trim());switch(i){case"^":if(u.length>1&&0===u[1]){if(u.length>2&&0===u[2])return[3].concat(u.slice(1));return[2].concat(u.slice(1))}return[1].concat(u.slice(1));case"~":return[2].concat(u.slice(1));case">=":return u;case"=":case"v":case"":return t(u);case"<":return o(u);case">":return[,t(u),0,u,2];case"<=":return[,t(u),o(u),1];case"!":return[,t(u),0];default:throw Error("Unexpected start value")}},u=function(e,n){if(1===e.length)return e[0];let r=[];for(let n of e.slice().reverse())0 in n?r.push(n):r.push.apply(r,n.slice(1));return[,].concat(r,e.slice(1).map(()=>n))};return u(n.split(/\s*\|\|\s*/).map(function(e){let n=e.split(/\s+-\s+/);if(1===n.length){e=e.trim();let n=[],r=/[-0-9A-Za-z]\s+/g;for(var a,c=0;a=r.exec(e);){let r=a.index+1;n.push(i(e.slice(c,r).trim())),c=r}return n.push(i(e.slice(c).trim())),u(n,2)}let l=r(n[0]),f=r(n[1]);return[,t(f),o(f),1,l,2]}),1)},r=function(n){var r=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(n),t=r[1]?e(r[1]):[];return r[2]&&(t.length++,t.push.apply(t,e(r[2]))),r[3]&&(t.push([]),t.push.apply(t,e(r[3]))),t},t=function(e,n){e=r(e),n=r(n);for(var t=0;;){if(t>=e.length)return t<n.length&&"u"!=(typeof n[t])[0];var o=e[t],i=(typeof o)[0];if(t>=n.length)return"u"==i;var u=n[t],a=(typeof u)[0];if(i==a){if("o"!=i&&"u"!=i&&o!=u)return o<u;t++}else{if("o"==i&&"n"==a)return!0;return"s"==a||"u"==i}}},o=function(e){var n=e[0],r="";if(1===e.length)return"*";if(n+.5){r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var t=1,i=1;i<e.length;i++){var u=e[i],a=(typeof u)[0];t--,r+="u"==a?"-":(t>0?".":"")+(t=2,u)}return r}for(var c=[],i=1;i<e.length;i++){var u=e[i];c.push(0===u?"not("+l()+")":1===u?"("+l()+" || "+l()+")":2===u?c.pop()+" "+c.pop():o(u))}return l();function l(){return c.pop().replace(/^\((.+)\)$/,"$1")}},i=function(e,n){if(0 in e){n=r(n);var t=e[0],o=t<0;o&&(t=-t-1);for(var u=0,a=1,c=!0;;a++,u++){var l,f,s=a<e.length?(typeof e[a])[0]:"";if(u>=n.length||"o"==(f=(typeof(l=n[u]))[0])){if(!c)return!0;if("u"==s)return a>t&&!o;return""==s!=o}if("u"==f){if(!c||"u"!=s)return!1}else if(c)if(s==f)if(a<=t){if(l!=e[a])return!1}else{if(o?l>e[a]:l<e[a])return!1;l!=e[a]&&(c=!1)}else if("s"!=s&&"n"!=s){if(o||a<=t)return!1;c=!1,a--}else{if(a<=t||f<s!=o)return!1;c=!1}else"s"!=s&&"n"!=s&&(c=!1,a--)}}for(var p=[],d=p.pop.bind(p),u=1;u<e.length;u++){var h=e[u];p.push(1==h?d()|d():2==h?d()&d():h?i(h,n):!d())}return!!d()},u=function(e,n){var r=z.S[e];if(!r||!z.o(r,n))throw Error("Shared module "+n+" doesn't exist in shared scope "+e);return r},a=function(e,n){var r=e[n],n=Object.keys(r).reduce(function(e,n){return!e||t(e,n)?n:e},0);return n&&r[n]},c=function(e,n){var r=e[n];return Object.keys(r).reduce(function(e,n){return!e||!r[e].loaded&&t(e,n)?n:e},0)},l=function(e,n,r,t){return"Unsatisfied version "+r+" from "+(r&&e[n][r].from)+" of shared singleton module "+n+" (required "+o(t)+")"},f=function(e,n,r,t){var o=c(e,r);return m(e[r][o])},s=function(e,n,r,t){var o=c(e,r);return i(t,o)||v(l(e,r,o,t)),m(e[r][o])},p=function(e,n,r,t){var o=c(e,r);if(!i(t,o))throw Error(l(e,r,o,t));return m(e[r][o])},d=function(e,n,r){var o=e[n],n=Object.keys(o).reduce(function(e,n){return i(r,n)&&(!e||t(e,n))?n:e},0);return n&&o[n]},h=function(e,n,r,t){var i=e[r];return"No satisfying version ("+o(t)+") of shared module "+r+" found in shared scope "+n+".\nAvailable versions: "+Object.keys(i).map(function(e){return e+" from "+i[e].from}).join(", ")},g=function(e,n,r,t){var o=d(e,r,t);if(o)return m(o);throw Error(h(e,n,r,t))},v=function(e){"u">typeof console&&console.warn&&console.warn(e)},y=function(e,n,r,t){v(h(e,n,r,t))},m=function(e){return e.loaded=1,e.get()},S=(b=function(e){return function(n,r,t,o){var i=z.I(n);return i&&i.then?i.then(e.bind(e,n,z.S[n],r,t,o)):e(n,z.S[n],r,t,o)}})(function(e,n,r){return u(e,r),m(a(n,r))}),k=b(function(e,n,r,t){return n&&z.o(n,r)?m(a(n,r)):t()}),j=b(function(e,n,r,t){return u(e,r),m(d(n,r,t)||y(n,e,r,t)||a(n,r))}),w=b(function(e,n,r){return u(e,r),f(n,e,r)}),E=b(function(e,n,r,t){return u(e,r),s(n,e,r,t)}),x=b(function(e,n,r,t){return u(e,r),g(n,e,r,t)}),T=b(function(e,n,r,t){return u(e,r),p(n,e,r,t)}),M=b(function(e,n,r,t,o){return n&&z.o(n,r)?m(d(n,r,t)||y(n,e,r,t)||a(n,r)):o()}),P=b(function(e,n,r,t){return n&&z.o(n,r)?f(n,e,r):t()}),A=b(function(e,n,r,t,o){return n&&z.o(n,r)?s(n,e,r,t):o()}),C=b(function(e,n,r,t,o){var i=n&&z.o(n,r)&&d(n,r,t);return i?m(i):o()}),O=b(function(e,n,r,t,o){return n&&z.o(n,r)?p(n,e,r,t):o()}),D=function(e){var r=!1,t=!1,o=!1,i=!1,u=[e.shareScope,e.shareKey];return(e.requiredVersion?(e.strictVersion&&(r=!0),e.singleton&&(t=!0),u.push(n(e.requiredVersion)),o=!0):e.singleton&&(t=!0),e.fallback&&(i=!0,u.push(e.fallback)),r&&t&&o&&i)?function(){return O.apply(null,u)}:r&&o&&i?function(){return C.apply(null,u)}:t&&o&&i?function(){return A.apply(null,u)}:r&&t&&o?function(){return T.apply(null,u)}:t&&i?function(){return P.apply(null,u)}:o&&i?function(){return M.apply(null,u)}:r&&o?function(){return x.apply(null,u)}:t&&o?function(){return E.apply(null,u)}:t?function(){return w.apply(null,u)}:o?function(){return j.apply(null,u)}:i?function(){return k.apply(null,u)}:function(){return S.apply(null,u)}},_={},z.f.consumes=function(e,n){var r=z.consumesLoadingData.moduleIdToConsumeDataMapping,t=z.consumesLoadingData.chunkMapping;z.o(t,e)&&t[e].forEach(function(e){if(z.o(_,e))return n.push(_[e]);var t=function(n){_[e]=0,z.m[e]=function(r){delete z.c[e],r.exports=n()}},o=function(n){delete _[e],z.m[e]=function(r){throw delete z.c[e],n}};try{var i=D(r[e])();i.then?n.push(_[e]=i.then(t).catch(o)):t(i)}catch(e){o(e)}})},q={871:0},z.f.j=function(e,n){var r=z.o(q,e)?q[e]:void 0;if(0!==r)if(r)n.push(r[2]);else{var t=new Promise((n,t)=>r=q[e]=[n,t]);n.push(r[2]=t);var o=z.p+z.u(e),i=Error();z.l(o,function(n){if(z.o(q,e)&&(0!==(r=q[e])&&(q[e]=void 0),r)){var t=n&&("load"===n.type?"missing":n.type),o=n&&n.target&&n.target.src;i.message="Loading chunk "+e+" failed.\n("+t+": "+o+")",i.name="ChunkLoadError",i.type=t,i.request=o,r[1](i)}},"chunk-"+e,e)}},L=(e,n)=>{var r,t,[o,i,u]=n,a=0;if(o.some(e=>0!==q[e])){for(r in i)z.o(i,r)&&(z.m[r]=i[r]);u&&u(z)}for(e&&e(n);a<o.length;a++)t=o[a],z.o(q,t)&&q[t]&&q[t][0](),q[t]=0},(V=self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).forEach(L.bind(null,0)),V.push=L.bind(null,V.push.bind(V));var F=z(457);(_JUPYTERLAB=void 0===_JUPYTERLAB?{}:_JUPYTERLAB)["codebind-jupyterlab"]=F})();
|
|
@@ -51,6 +51,7 @@ interface QuestionFinishedMessage {
|
|
|
51
51
|
type: 'question_finished';
|
|
52
52
|
cell_id: string;
|
|
53
53
|
error: { type: string; message: string } | null;
|
|
54
|
+
cancelled: boolean;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
type CodebindMessage =
|
|
@@ -69,6 +70,7 @@ interface TurnState {
|
|
|
69
70
|
|
|
70
71
|
interface PanelState {
|
|
71
72
|
comm: Kernel.IComm | null;
|
|
73
|
+
kernel: Kernel.IKernelConnection | null;
|
|
72
74
|
runningQuestions: Map<string, ICellModel>;
|
|
73
75
|
}
|
|
74
76
|
|
|
@@ -78,6 +80,18 @@ interface QuestionMetadata {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
const panelStates = new WeakMap<NotebookPanel, PanelState>();
|
|
83
|
+
const kernelStates = new WeakMap<
|
|
84
|
+
Kernel.IKernelConnection,
|
|
85
|
+
Set<PanelState>
|
|
86
|
+
>();
|
|
87
|
+
|
|
88
|
+
function cancelQuestions(state: PanelState): boolean {
|
|
89
|
+
if (state.runningQuestions.size === 0) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
state.comm?.send({ type: 'cancel' });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
81
95
|
|
|
82
96
|
function isCodebindMessage(value: unknown): value is CodebindMessage {
|
|
83
97
|
if (typeof value !== 'object' || value === null) {
|
|
@@ -107,6 +121,7 @@ function isCodebindMessage(value: unknown): value is CodebindMessage {
|
|
|
107
121
|
const error = message.error;
|
|
108
122
|
return (
|
|
109
123
|
typeof message.cell_id === 'string' &&
|
|
124
|
+
typeof message.cancelled === 'boolean' &&
|
|
110
125
|
(error === null ||
|
|
111
126
|
(typeof error === 'object' &&
|
|
112
127
|
typeof (error as Record<string, unknown>).type === 'string' &&
|
|
@@ -122,6 +137,38 @@ function isCodebindMessage(value: unknown): value is CodebindMessage {
|
|
|
122
137
|
);
|
|
123
138
|
}
|
|
124
139
|
|
|
140
|
+
function connectInterrupt(
|
|
141
|
+
kernel: Kernel.IKernelConnection,
|
|
142
|
+
state: PanelState
|
|
143
|
+
): void {
|
|
144
|
+
if (state.kernel && state.kernel !== kernel) {
|
|
145
|
+
kernelStates.get(state.kernel)?.delete(state);
|
|
146
|
+
}
|
|
147
|
+
state.kernel = kernel;
|
|
148
|
+
let states = kernelStates.get(kernel);
|
|
149
|
+
if (!states) {
|
|
150
|
+
states = new Set<PanelState>();
|
|
151
|
+
kernelStates.set(kernel, states);
|
|
152
|
+
const interrupt = kernel.interrupt.bind(kernel);
|
|
153
|
+
kernel.interrupt = async (): Promise<void> => {
|
|
154
|
+
const active = [...(states ?? [])].filter(
|
|
155
|
+
connected => connected.runningQuestions.size > 0
|
|
156
|
+
);
|
|
157
|
+
for (const connected of active) {
|
|
158
|
+
cancelQuestions(connected);
|
|
159
|
+
}
|
|
160
|
+
for (let attempt = 0; active.length > 0 && attempt < 50; attempt += 1) {
|
|
161
|
+
if (active.every(connected => connected.runningQuestions.size === 0)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
await new Promise<void>(resolve => setTimeout(resolve, 10));
|
|
165
|
+
}
|
|
166
|
+
return interrupt();
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
states.add(state);
|
|
170
|
+
}
|
|
171
|
+
|
|
125
172
|
function questionMetadata(model: ICellModel): QuestionMetadata | null {
|
|
126
173
|
const value = model.getMetadata('codebind');
|
|
127
174
|
if (typeof value !== 'object' || value === null) {
|
|
@@ -204,9 +251,11 @@ function registerKernel(panel: NotebookPanel): void {
|
|
|
204
251
|
|
|
205
252
|
const panelState = panelStates.get(panel) ?? {
|
|
206
253
|
comm: null,
|
|
254
|
+
kernel: null,
|
|
207
255
|
runningQuestions: new Map<string, ICellModel>()
|
|
208
256
|
};
|
|
209
257
|
panelStates.set(panel, panelState);
|
|
258
|
+
connectInterrupt(kernel, panelState);
|
|
210
259
|
panelState.comm = null;
|
|
211
260
|
panelState.runningQuestions.clear();
|
|
212
261
|
|
|
@@ -271,7 +320,7 @@ function registerKernel(panel: NotebookPanel): void {
|
|
|
271
320
|
panelState.runningQuestions.delete(data.cell_id);
|
|
272
321
|
refreshQuestionCells(panel);
|
|
273
322
|
finishTurn();
|
|
274
|
-
if (data.error) {
|
|
323
|
+
if (data.error && !data.cancelled) {
|
|
275
324
|
void showErrorMessage(
|
|
276
325
|
`Codebind question: ${data.error.type}`,
|
|
277
326
|
data.error.message
|
|
@@ -396,9 +445,43 @@ async function runQuestion(panel: NotebookPanel): Promise<void> {
|
|
|
396
445
|
}
|
|
397
446
|
|
|
398
447
|
function connectPanel(panel: NotebookPanel, app: JupyterFrontEnd): void {
|
|
399
|
-
|
|
448
|
+
const state: PanelState = {
|
|
400
449
|
comm: null,
|
|
450
|
+
kernel: null,
|
|
401
451
|
runningQuestions: new Map<string, ICellModel>()
|
|
452
|
+
};
|
|
453
|
+
panelStates.set(panel, state);
|
|
454
|
+
const onInterrupt = (event: Event): void => {
|
|
455
|
+
if (!cancelQuestions(state)) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
event.preventDefault();
|
|
459
|
+
event.stopPropagation();
|
|
460
|
+
event.stopImmediatePropagation();
|
|
461
|
+
window.setTimeout(() => {
|
|
462
|
+
if (state.runningQuestions.size > 0) {
|
|
463
|
+
void state.kernel?.interrupt();
|
|
464
|
+
}
|
|
465
|
+
}, 500);
|
|
466
|
+
};
|
|
467
|
+
let interruptButton: HTMLElement | null = null;
|
|
468
|
+
const connectInterruptButton = (): void => {
|
|
469
|
+
const button = panel.toolbar.node.querySelector<HTMLElement>(
|
|
470
|
+
'[data-command="notebook:interrupt-kernel"]'
|
|
471
|
+
);
|
|
472
|
+
if (button === interruptButton) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
interruptButton?.removeEventListener('click', onInterrupt, true);
|
|
476
|
+
interruptButton = button;
|
|
477
|
+
interruptButton?.addEventListener('click', onInterrupt, true);
|
|
478
|
+
};
|
|
479
|
+
const toolbarObserver = new MutationObserver(connectInterruptButton);
|
|
480
|
+
toolbarObserver.observe(panel.toolbar.node, { childList: true, subtree: true });
|
|
481
|
+
connectInterruptButton();
|
|
482
|
+
panel.disposed.connect(() => {
|
|
483
|
+
toolbarObserver.disconnect();
|
|
484
|
+
interruptButton?.removeEventListener('click', onInterrupt, true);
|
|
402
485
|
});
|
|
403
486
|
panel.toolbar.insertItem(
|
|
404
487
|
10,
|
|
@@ -122,6 +122,10 @@ class JupyterLabBridge:
|
|
|
122
122
|
if data.get("type") == "ready":
|
|
123
123
|
self.ready = True
|
|
124
124
|
return
|
|
125
|
+
if data.get("type") == "cancel":
|
|
126
|
+
for task in tuple(self._tasks):
|
|
127
|
+
task.cancel()
|
|
128
|
+
return
|
|
125
129
|
if data.get("type") != "question":
|
|
126
130
|
return
|
|
127
131
|
cell_id = data.get("cell_id")
|
|
@@ -135,10 +139,13 @@ class JupyterLabBridge:
|
|
|
135
139
|
|
|
136
140
|
async def _answer_question(self, cell_id: str, question: str, model: str) -> None:
|
|
137
141
|
error: dict[str, str] | None = None
|
|
142
|
+
cancelled = False
|
|
138
143
|
try:
|
|
139
144
|
if self._question_handler is None:
|
|
140
145
|
raise RuntimeError("Codebind is not ready to receive questions.")
|
|
141
146
|
await self._question_handler(question, model)
|
|
147
|
+
except asyncio.CancelledError:
|
|
148
|
+
cancelled = True
|
|
142
149
|
except Exception as exception:
|
|
143
150
|
error = {"type": type(exception).__name__, "message": str(exception)}
|
|
144
151
|
self._comm.send(
|
|
@@ -146,5 +153,6 @@ class JupyterLabBridge:
|
|
|
146
153
|
"type": "question_finished",
|
|
147
154
|
"cell_id": cell_id,
|
|
148
155
|
"error": error,
|
|
156
|
+
"cancelled": cancelled,
|
|
149
157
|
}
|
|
150
158
|
)
|
codebind-0.5.3/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.65031998ea066c13.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).push([[590],{509(e,t,n){n.r(t);var o=n(511),l=n(343),i=n(171);let d="codebind:insert-question",r="codebind:run-question",u="jp-CodebindQuestionCell",s=new WeakMap;function c(e){let t=e.getMetadata("codebind");return"object"!=typeof t||null===t||"question"!==t.kind?null:{kind:"question",model:"string"==typeof t.model?t.model:"model"}}function a(e){return e.replace(/(^|[^\\])\\([()[\]])/g,"$1\\\\$2")}function m(e){let t=s.get(e);for(let n of e.content.widgets){let e=c(n.model);n.node.classList.toggle(u,null!==e);let o=n.node.querySelector(".jp-InputPrompt");o&&(e?(o.dataset.codebindQuestion="true",o.textContent=t?.runningQuestions.has(n.model.id)?"Question [*]:":"Question:"):o.dataset.codebindQuestion&&(delete o.dataset.codebindQuestion,o.textContent=""))}}function p(e){let t=e.sessionContext.session?.kernel;if(!t)return;let n=s.get(e)??{comm:null,runningQuestions:new Map};s.set(e,n),n.comm=null,n.runningQuestions.clear();let i=null,d=new Map,r=()=>{if(!i)return;let e=i;i=null,e.parentModel&&null!==e.parentExecutionCount&&(e.parentModel.executionCount=e.parentExecutionCount)};t.registerCommTarget("codebind",(u,s)=>{u.onMsg=u=>{let s=u.content.data;if(!function(e){if("object"!=typeof e||null===e)return!1;if("markdown_cell"===e.type)return"string"==typeof e.source;if("code_cell_started"===e.type)return"string"==typeof e.cell_id&&"string"==typeof e.source;if("code_cell_output"===e.type)return"string"==typeof e.cell_id&&"object"==typeof e.output&&null!==e.output;if("code_cell_clear"===e.type)return"string"==typeof e.cell_id&&"boolean"==typeof e.wait;if("question_finished"===e.type){let t=e.error;return"string"==typeof e.cell_id&&(null===t||"object"==typeof t&&"string"==typeof t.type&&"string"==typeof t.message)}return"code_cell_finished"===e.type&&"string"==typeof e.cell_id&&("number"==typeof e.execution_count||null===e.execution_count)&&Array.isArray(e.outputs)}(s))return;if("question_finished"===s.type){n.runningQuestions.delete(s.cell_id),m(e),r(),s.error&&(0,o.showErrorMessage)(`Codebind question: ${s.error.type}`,s.error.message);return}if("code_cell_output"===s.type)return void d.get(s.cell_id)?.outputs.add(s.output);if("code_cell_clear"===s.type)return void d.get(s.cell_id)?.outputs.clear(s.wait);if("code_cell_finished"===s.type){let e=d.get(s.cell_id);if(!e)return;e.outputs.fromJSON(s.outputs),e.executionCount=s.execution_count,e.executionState="idle",i&&null===i.parentExecutionCount&&null!==s.execution_count&&(i.parentExecutionCount=s.execution_count-1);return}(()=>{if(i)return;let n=e.content,o=n.widgets.findIndex(e=>"code"===e.model.type&&"running"===e.model.executionState);i={parentModel:o>=0?n.widgets[o].model:null,parentExecutionCount:null};let l=(e,n)=>{"idle"===n&&(t.statusChanged.disconnect(l),r())};return t.statusChanged.connect(l)})();let c=function(e,t){let n=e.content,o=n.model;if(!o)return null;let i=n.widgets.length;"code_cell_started"===t.type?o.sharedModel.insertCell(i,{cell_type:"code",source:t.source,metadata:{trusted:!0},execution_count:null,outputs:[]}):o.sharedModel.insertCell(i,{cell_type:"markdown",source:a(t.source),metadata:{}});let d=n.widgets[i]??null;return d instanceof l.MarkdownCell&&(d.rendered=!0),d?.model??null}(e,s);"code_cell_started"===s.type&&c?.type==="code"&&(c.executionState="running",d.set(s.cell_id,c))},n.comm=u,u.onClose=()=>{n.comm===u&&(n.comm=null)},u.send({type:"ready"})})}async function f(e){let t=e.content,n=t.activeCell;if(!n)return;let i=c(n.model);if(!i)return;let d=s.get(e);if(!d?.comm)return void await (0,o.showErrorMessage)("Codebind is not connected","Run %load_ext codebind in this kernel before sending a Question cell.");if(d.runningQuestions.size>0)return void await (0,o.showErrorMessage)("Codebind is busy","Wait for the current question to finish before sending another.");let r=n.model.sharedModel.getSource().trim();r?(d.runningQuestions.set(n.model.id,n.model),n.model.sharedModel.setSource(a(r)),m(e),n instanceof l.MarkdownCell&&(n.rendered=!0),t.mode="command",d.comm.send({type:"question",cell_id:n.model.id,question:r,model:i.model})):await (0,o.showErrorMessage)("Empty Codebind question","Write a question before sending it.")}function g(e,t){s.set(e,{comm:null,runningQuestions:new Map}),e.toolbar.insertItem(10,"codebindQuestion",new o.ToolbarButton({label:"Question",tooltip:"Use the selected cell as a Codebind Question",onClick:()=>{t.commands.execute(d)}})),e.content.modelContentChanged.connect(()=>m(e)),e.context.ready.then(()=>m(e)),e.sessionContext.ready.then(()=>p(e)),e.sessionContext.kernelChanged.connect(()=>p(e))}let y={id:"codebind-jupyterlab:plugin",description:"Insert Codebind executions as native notebook cells.",autoStart:!0,requires:[i.INotebookTracker],activate:(e,t)=>{e.commands.addCommand(d,{label:"Use Selected Cell as Codebind Question",execute:()=>{let e=t.currentWidget;e&&function(e){let t=e.content,n=t.model;if(!n)return;t.activeCell?"markdown"!==t.activeCell.model.type&&i.NotebookActions.changeCellType(t,"markdown"):(n.sharedModel.insertCell(0,{cell_type:"markdown",source:"",metadata:{}}),t.activeCellIndex=0);let o=t.activeCell;o?.model.setMetadata("codebind",{kind:"question",model:"model"}),o instanceof l.MarkdownCell&&(o.rendered=!1),t.mode="edit",m(e),o?.editor?.focus()}(e)}}),e.commands.addCommand(r,{label:"Send Codebind Question",isEnabled:()=>{let e=t.currentWidget?.content.activeCell;return!!e&&null!==c(e.model)},execute:async()=>{let e=t.currentWidget;e&&await f(e)}}),e.commands.addKeyBinding({command:r,keys:["Shift Enter"],selector:`.jp-Notebook .${u}`}),e.contextMenu.addItem({command:d,selector:".jp-Notebook .jp-Cell",rank:8}),t.forEach(t=>g(t,e)),t.widgetAdded.connect((t,n)=>g(n,e))}};n.d(t,{},{default:y})}}]);
|
|
File without changes
|
{codebind-0.5.3 → codebind-0.5.4}/data/share/jupyter/labextensions/codebind-jupyterlab/install.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|