codebind 0.4.0__tar.gz → 0.4.2__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.4.0 → codebind-0.4.2}/PKG-INFO +2 -2
- {codebind-0.4.0 → codebind-0.4.2}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json +2 -2
- codebind-0.4.2/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.6544266cd73a003b.js +1 -0
- codebind-0.4.0/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.a1fc3d70ac53ef43.js → codebind-0.4.2/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.6f017385dfc989f1.js +1 -1
- {codebind-0.4.0 → codebind-0.4.2}/jupyterlab/package.json +1 -1
- {codebind-0.4.0 → codebind-0.4.2}/jupyterlab/src/index.ts +91 -20
- {codebind-0.4.0 → codebind-0.4.2}/pyproject.toml +2 -2
- {codebind-0.4.0 → codebind-0.4.2}/pyproject.toml.orig +2 -2
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/execution.py +141 -10
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/jupyter.py +47 -6
- codebind-0.4.0/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.4acc74d60e21c02c.js +0 -1
- {codebind-0.4.0 → codebind-0.4.2}/LICENSE +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/README.md +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/data/share/jupyter/labextensions/codebind-jupyterlab/install.json +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/data/share/jupyter/labextensions/codebind-jupyterlab/static/style.js +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/data/share/jupyter/labextensions/codebind-jupyterlab/static/third-party-licenses.json +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/jupyterlab/.yarnrc.yml +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/jupyterlab/install.json +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/jupyterlab/tsconfig.json +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/jupyterlab/yarn.lock +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/__init__.py +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/cli.py +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/display.py +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/extension.py +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/py.typed +0 -0
- {codebind-0.4.0 → codebind-0.4.2}/src/codebind/session.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codebind
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
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
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
17
17
|
Classifier: Typing :: Typed
|
|
18
18
|
Requires-Dist: ipython>=9.0
|
|
19
19
|
Requires-Dist: langchain-core>=1.0
|
|
20
|
-
Requires-Dist: models-provider>=0.1.
|
|
20
|
+
Requires-Dist: models-provider>=0.1.1
|
|
21
21
|
Requires-Python: >=3.13
|
|
22
22
|
Project-URL: Repository, https://github.com/ghovax/codebind
|
|
23
23
|
Project-URL: Issues, https://github.com/ghovax/codebind/issues
|
{codebind-0.4.0 → codebind-0.4.2}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebind-jupyterlab",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Native JupyterLab cells for Codebind model executions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"extension": true,
|
|
31
31
|
"outputDir": "../data/share/jupyter/labextensions/codebind-jupyterlab",
|
|
32
32
|
"_build": {
|
|
33
|
-
"load": "static/remoteEntry.
|
|
33
|
+
"load": "static/remoteEntry.6f017385dfc989f1.js",
|
|
34
34
|
"extension": "./extension"
|
|
35
35
|
}
|
|
36
36
|
}
|
codebind-0.4.2/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.6544266cd73a003b.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(171);function l(e){let t=e.sessionContext.session?.kernel;if(!t)return;let n=null,l=new Map;t.registerCommTarget("codebind",(u,c)=>{u.onMsg=u=>{var c;let d,i,r=u.content.data;if(!("object"==typeof r&&null!==r&&("markdown_cell"===r.type?"string"==typeof r.source:"code_cell_started"===r.type?"string"==typeof r.cell_id&&"string"==typeof r.source:"code_cell_output"===r.type?"string"==typeof r.cell_id&&"object"==typeof r.output&&null!==r.output:"code_cell_clear"===r.type?"string"==typeof r.cell_id&&"boolean"==typeof r.wait:"code_cell_finished"===r.type&&"string"==typeof r.cell_id&&("number"==typeof r.execution_count||null===r.execution_count)&&Array.isArray(r.outputs))))return;if("code_cell_output"===r.type)return void l.get(r.cell_id)?.outputs.add(r.output);if("code_cell_clear"===r.type)return void l.get(r.cell_id)?.outputs.clear(r.wait);if("code_cell_finished"===r.type){let e=l.get(r.cell_id);if(!e)return;e.outputs.fromJSON(r.outputs),e.executionCount=r.execution_count,e.executionState="idle",n&&null===n.parentExecutionCount&&null!==r.execution_count&&(n.parentExecutionCount=r.execution_count-1);return}let s=(()=>{if(n)return n;let o=e.content,l=o.widgets.findIndex(e=>"code"===e.model.type&&"running"===e.model.executionState);n={parentModel:l>=0?o.widgets[l].model:null,parentExecutionCount:null,resumeModel:o.activeCell?.model??null,nextIndex:l>=0?l+1:o.activeCell?o.activeCellIndex+1:0};let u=(o,l)=>{"idle"===l&&(t.statusChanged.disconnect(u),(()=>{if(!n)return;let t=e.content,o=n;if(n=null,o.parentModel&&null!==o.parentExecutionCount&&(o.parentModel.executionCount=o.parentExecutionCount),o.resumeModel){let e=t.widgets.findIndex(e=>e.model===o.resumeModel);e>=0&&(t.activeCellIndex=e)}})())};return t.statusChanged.connect(u),n})(),a=(c=s.nextIndex,(i=(d=e.content).model)?("code_cell_started"===r.type?i.sharedModel.insertCell(c,{cell_type:"code",source:r.source,metadata:{trusted:!0},execution_count:null,outputs:[]}):i.sharedModel.insertCell(c,{cell_type:"markdown",source:r.source,metadata:{}}),d.activeCellIndex=c,d.deselectAll(),"markdown_cell"===r.type&&o.NotebookActions.run(d),d.scrollToItem(c),d.widgets[c]?.model??null):null);"code_cell_started"===r.type&&a?.type==="code"&&(a.executionState="running",l.set(r.cell_id,a)),s.nextIndex+=1},u.send({type:"ready"})})}function u(e){e.sessionContext.ready.then(()=>l(e)),e.sessionContext.kernelChanged.connect(()=>l(e))}let c={id:"codebind-jupyterlab:plugin",description:"Insert Codebind executions as native notebook cells.",autoStart:!0,requires:[o.INotebookTracker],activate:(e,t)=>{t.forEach(u),t.widgetAdded.connect((e,t)=>u(t))}};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,v,g,m,y,b,S,j,k,w,E,x,T,P,M,A,C,O,D,_,L,N,$,q={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})}},z={};function I(e){var n=z[e];if(void 0!==n)return n.exports;var r=z[e]={exports:{}};return q[e](r,r.exports,I),r.exports}I.m=q,I.c=z,I.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return I.d(n,{a:n}),n},I.d=(e,n,r)=>{var t=(n,r)=>{for(var t in n)I.o(n,t)&&!I.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:n[t]})};t(n,"get"),t(r,"value")},I.f={},I.e=e=>Promise.all(Object.keys(I.f).reduce((n,r)=>(I.f[r](e,n),n),[])),I.u=e=>""+e+".4acc74d60e21c02c.js?v=4acc74d60e21c02c",I.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),I.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),R={},I.l=function(e,n,r,t){if(R[e])return void R[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,I.nc&&o.setAttribute("nonce",I.nc),o.setAttribute("data-rspack","codebind-jupyterlab:"+r),o.src=e),R[e]=[n];var l=function(n,r){o.onerror=o.onload=null,clearTimeout(f);var t=R[e];if(delete R[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)},I.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},I.S={},I.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"codebind-jupyterlab",version:"0.4.0",factory:()=>I.e(590).then(()=>()=>I(509)),eager:0,treeShakingMode:null}]},uniqueName:"codebind-jupyterlab"},U={},B={},I.I=function(e,n){n||(n=[]);var r=B[e];if(r||(r=B[e]={}),!(n.indexOf(r)>=0)){if(n.push(r),U[e])return U[e];I.o(I.S,e)||(I.S[e]={});var t=I.S[e],o=function(e){"u">typeof console&&console.warn&&console.warn(e)},i=I.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=I(r);if(!i)return;var u=function(r){return r&&r.init&&r.init(I.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=I.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)?U[e]=Promise.all(c).then(function(){return U[e]=1}):U[e]=1}},I.g.importScripts&&(V=I.g.location+"");var R,U,B,V,J=I.g.document;if(!V&&J&&(J.currentScript&&"SCRIPT"===J.currentScript.tagName.toUpperCase()&&(V=J.currentScript.src),!V)){var Y=J.getElementsByTagName("script");if(Y.length)for(var K=Y.length-1;K>-1&&(!V||!/^http(s?):/.test(V));)V=Y[K--].src}if(!V)throw Error("Automatic publicPath is not supported in this browser");I.p=V=V.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),I.consumesLoadingData={chunkMapping:{590:["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}},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=I.S[e];if(!r||!I.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 y(e[r][o])},s=function(e,n,r,t){var o=c(e,r);return i(t,o)||g(l(e,r,o,t)),y(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 y(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(", ")},v=function(e,n,r,t){var o=d(e,r,t);if(o)return y(o);throw Error(h(e,n,r,t))},g=function(e){"u">typeof console&&console.warn&&console.warn(e)},m=function(e,n,r,t){g(h(e,n,r,t))},y=function(e){return e.loaded=1,e.get()},S=(b=function(e){return function(n,r,t,o){var i=I.I(n);return i&&i.then?i.then(e.bind(e,n,I.S[n],r,t,o)):e(n,I.S[n],r,t,o)}})(function(e,n,r){return u(e,r),y(a(n,r))}),j=b(function(e,n,r,t){return n&&I.o(n,r)?y(a(n,r)):t()}),k=b(function(e,n,r,t){return u(e,r),y(d(n,r,t)||m(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),v(n,e,r,t)}),T=b(function(e,n,r,t){return u(e,r),p(n,e,r,t)}),P=b(function(e,n,r,t,o){return n&&I.o(n,r)?y(d(n,r,t)||m(n,e,r,t)||a(n,r)):o()}),M=b(function(e,n,r,t){return n&&I.o(n,r)?f(n,e,r):t()}),A=b(function(e,n,r,t,o){return n&&I.o(n,r)?s(n,e,r,t):o()}),C=b(function(e,n,r,t,o){var i=n&&I.o(n,r)&&d(n,r,t);return i?y(i):o()}),O=b(function(e,n,r,t,o){return n&&I.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 M.apply(null,u)}:o&&i?function(){return P.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 k.apply(null,u)}:i?function(){return j.apply(null,u)}:function(){return S.apply(null,u)}},_={},I.f.consumes=function(e,n){var r=I.consumesLoadingData.moduleIdToConsumeDataMapping,t=I.consumesLoadingData.chunkMapping;I.o(t,e)&&t[e].forEach(function(e){if(I.o(_,e))return n.push(_[e]);var t=function(n){_[e]=0,I.m[e]=function(r){delete I.c[e],r.exports=n()}},o=function(n){delete _[e],I.m[e]=function(r){throw delete I.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)}})},L={871:0},I.f.j=function(e,n){var r=I.o(L,e)?L[e]:void 0;if(0!==r)if(r)n.push(r[2]);else{var t=new Promise((n,t)=>r=L[e]=[n,t]);n.push(r[2]=t);var o=I.p+I.u(e),i=Error();I.l(o,function(n){if(I.o(L,e)&&(0!==(r=L[e])&&(L[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)}},N=(e,n)=>{var r,t,[o,i,u]=n,a=0;if(o.some(e=>0!==L[e])){for(r in i)I.o(i,r)&&(I.m[r]=i[r]);u&&u(I)}for(e&&e(n);a<o.length;a++)t=o[a],I.o(L,t)&&L[t]&&L[t][0](),L[t]=0},($=self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).forEach(N.bind(null,0)),$.push=N.bind(null,$.push.bind($));var F=I(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,v,g,m,y,b,S,j,k,w,E,x,T,P,M,A,C,O,D,_,L,N,$,q={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})}},z={};function I(e){var n=z[e];if(void 0!==n)return n.exports;var r=z[e]={exports:{}};return q[e](r,r.exports,I),r.exports}I.m=q,I.c=z,I.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return I.d(n,{a:n}),n},I.d=(e,n,r)=>{var t=(n,r)=>{for(var t in n)I.o(n,t)&&!I.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:n[t]})};t(n,"get"),t(r,"value")},I.f={},I.e=e=>Promise.all(Object.keys(I.f).reduce((n,r)=>(I.f[r](e,n),n),[])),I.u=e=>""+e+".6544266cd73a003b.js?v=6544266cd73a003b",I.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),I.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),R={},I.l=function(e,n,r,t){if(R[e])return void R[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,I.nc&&o.setAttribute("nonce",I.nc),o.setAttribute("data-rspack","codebind-jupyterlab:"+r),o.src=e),R[e]=[n];var l=function(n,r){o.onerror=o.onload=null,clearTimeout(f);var t=R[e];if(delete R[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)},I.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},I.S={},I.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"codebind-jupyterlab",version:"0.4.1",factory:()=>I.e(590).then(()=>()=>I(509)),eager:0,treeShakingMode:null}]},uniqueName:"codebind-jupyterlab"},U={},B={},I.I=function(e,n){n||(n=[]);var r=B[e];if(r||(r=B[e]={}),!(n.indexOf(r)>=0)){if(n.push(r),U[e])return U[e];I.o(I.S,e)||(I.S[e]={});var t=I.S[e],o=function(e){"u">typeof console&&console.warn&&console.warn(e)},i=I.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=I(r);if(!i)return;var u=function(r){return r&&r.init&&r.init(I.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=I.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)?U[e]=Promise.all(c).then(function(){return U[e]=1}):U[e]=1}},I.g.importScripts&&(V=I.g.location+"");var R,U,B,V,J=I.g.document;if(!V&&J&&(J.currentScript&&"SCRIPT"===J.currentScript.tagName.toUpperCase()&&(V=J.currentScript.src),!V)){var Y=J.getElementsByTagName("script");if(Y.length)for(var K=Y.length-1;K>-1&&(!V||!/^http(s?):/.test(V));)V=Y[K--].src}if(!V)throw Error("Automatic publicPath is not supported in this browser");I.p=V=V.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),I.consumesLoadingData={chunkMapping:{590:["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}},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=I.S[e];if(!r||!I.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 y(e[r][o])},s=function(e,n,r,t){var o=c(e,r);return i(t,o)||g(l(e,r,o,t)),y(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 y(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(", ")},v=function(e,n,r,t){var o=d(e,r,t);if(o)return y(o);throw Error(h(e,n,r,t))},g=function(e){"u">typeof console&&console.warn&&console.warn(e)},m=function(e,n,r,t){g(h(e,n,r,t))},y=function(e){return e.loaded=1,e.get()},S=(b=function(e){return function(n,r,t,o){var i=I.I(n);return i&&i.then?i.then(e.bind(e,n,I.S[n],r,t,o)):e(n,I.S[n],r,t,o)}})(function(e,n,r){return u(e,r),y(a(n,r))}),j=b(function(e,n,r,t){return n&&I.o(n,r)?y(a(n,r)):t()}),k=b(function(e,n,r,t){return u(e,r),y(d(n,r,t)||m(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),v(n,e,r,t)}),T=b(function(e,n,r,t){return u(e,r),p(n,e,r,t)}),P=b(function(e,n,r,t,o){return n&&I.o(n,r)?y(d(n,r,t)||m(n,e,r,t)||a(n,r)):o()}),M=b(function(e,n,r,t){return n&&I.o(n,r)?f(n,e,r):t()}),A=b(function(e,n,r,t,o){return n&&I.o(n,r)?s(n,e,r,t):o()}),C=b(function(e,n,r,t,o){var i=n&&I.o(n,r)&&d(n,r,t);return i?y(i):o()}),O=b(function(e,n,r,t,o){return n&&I.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 M.apply(null,u)}:o&&i?function(){return P.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 k.apply(null,u)}:i?function(){return j.apply(null,u)}:function(){return S.apply(null,u)}},_={},I.f.consumes=function(e,n){var r=I.consumesLoadingData.moduleIdToConsumeDataMapping,t=I.consumesLoadingData.chunkMapping;I.o(t,e)&&t[e].forEach(function(e){if(I.o(_,e))return n.push(_[e]);var t=function(n){_[e]=0,I.m[e]=function(r){delete I.c[e],r.exports=n()}},o=function(n){delete _[e],I.m[e]=function(r){throw delete I.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)}})},L={871:0},I.f.j=function(e,n){var r=I.o(L,e)?L[e]:void 0;if(0!==r)if(r)n.push(r[2]);else{var t=new Promise((n,t)=>r=L[e]=[n,t]);n.push(r[2]=t);var o=I.p+I.u(e),i=Error();I.l(o,function(n){if(I.o(L,e)&&(0!==(r=L[e])&&(L[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)}},N=(e,n)=>{var r,t,[o,i,u]=n,a=0;if(o.some(e=>0!==L[e])){for(r in i)I.o(i,r)&&(I.m[r]=i[r]);u&&u(I)}for(e&&e(n);a<o.length;a++)t=o[a],I.o(L,t)&&L[t]&&L[t][0](),L[t]=0},($=self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).forEach(N.bind(null,0)),$.push=N.bind(null,$.push.bind($));var F=I(457);(_JUPYTERLAB=void 0===_JUPYTERLAB?{}:_JUPYTERLAB)["codebind-jupyterlab"]=F})();
|
|
@@ -13,19 +13,43 @@ import { Kernel, KernelMessage } from '@jupyterlab/services';
|
|
|
13
13
|
|
|
14
14
|
const TARGET_NAME = 'codebind';
|
|
15
15
|
|
|
16
|
-
interface
|
|
17
|
-
type: '
|
|
16
|
+
interface CodeCellStartedMessage {
|
|
17
|
+
type: 'code_cell_started';
|
|
18
|
+
cell_id: string;
|
|
18
19
|
source: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface CodeCellFinishedMessage {
|
|
23
|
+
type: 'code_cell_finished';
|
|
24
|
+
cell_id: string;
|
|
19
25
|
execution_count: number | null;
|
|
20
26
|
outputs: nbformat.IOutput[];
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
interface CodeCellOutputMessage {
|
|
30
|
+
type: 'code_cell_output';
|
|
31
|
+
cell_id: string;
|
|
32
|
+
output: nbformat.IOutput;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CodeCellClearMessage {
|
|
36
|
+
type: 'code_cell_clear';
|
|
37
|
+
cell_id: string;
|
|
38
|
+
wait: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
23
41
|
interface MarkdownCellMessage {
|
|
24
42
|
type: 'markdown_cell';
|
|
25
43
|
source: string;
|
|
26
44
|
}
|
|
27
45
|
|
|
28
|
-
type CodebindMessage =
|
|
46
|
+
type CodebindMessage =
|
|
47
|
+
| CodeCellStartedMessage
|
|
48
|
+
| CodeCellFinishedMessage
|
|
49
|
+
| CodeCellOutputMessage
|
|
50
|
+
| CodeCellClearMessage
|
|
51
|
+
| MarkdownCellMessage;
|
|
52
|
+
type InsertMessage = CodeCellStartedMessage | MarkdownCellMessage;
|
|
29
53
|
|
|
30
54
|
interface TurnState {
|
|
31
55
|
parentModel: ICodeCellModel | null;
|
|
@@ -42,9 +66,25 @@ function isCodebindMessage(value: unknown): value is CodebindMessage {
|
|
|
42
66
|
if (message.type === 'markdown_cell') {
|
|
43
67
|
return typeof message.source === 'string';
|
|
44
68
|
}
|
|
69
|
+
if (message.type === 'code_cell_started') {
|
|
70
|
+
return (
|
|
71
|
+
typeof message.cell_id === 'string' &&
|
|
72
|
+
typeof message.source === 'string'
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (message.type === 'code_cell_output') {
|
|
76
|
+
return (
|
|
77
|
+
typeof message.cell_id === 'string' &&
|
|
78
|
+
typeof message.output === 'object' &&
|
|
79
|
+
message.output !== null
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (message.type === 'code_cell_clear') {
|
|
83
|
+
return typeof message.cell_id === 'string' && typeof message.wait === 'boolean';
|
|
84
|
+
}
|
|
45
85
|
return (
|
|
46
|
-
message.type === '
|
|
47
|
-
typeof message.
|
|
86
|
+
message.type === 'code_cell_finished' &&
|
|
87
|
+
typeof message.cell_id === 'string' &&
|
|
48
88
|
(typeof message.execution_count === 'number' ||
|
|
49
89
|
message.execution_count === null) &&
|
|
50
90
|
Array.isArray(message.outputs)
|
|
@@ -53,22 +93,22 @@ function isCodebindMessage(value: unknown): value is CodebindMessage {
|
|
|
53
93
|
|
|
54
94
|
function insertCell(
|
|
55
95
|
panel: NotebookPanel,
|
|
56
|
-
message:
|
|
96
|
+
message: InsertMessage,
|
|
57
97
|
index: number
|
|
58
|
-
):
|
|
98
|
+
): ICellModel | null {
|
|
59
99
|
const notebook = panel.content;
|
|
60
100
|
const model = notebook.model;
|
|
61
101
|
if (!model) {
|
|
62
|
-
return;
|
|
102
|
+
return null;
|
|
63
103
|
}
|
|
64
104
|
|
|
65
|
-
if (message.type === '
|
|
105
|
+
if (message.type === 'code_cell_started') {
|
|
66
106
|
model.sharedModel.insertCell(index, {
|
|
67
107
|
cell_type: 'code',
|
|
68
108
|
source: message.source,
|
|
69
109
|
metadata: { trusted: true },
|
|
70
|
-
execution_count:
|
|
71
|
-
outputs:
|
|
110
|
+
execution_count: null,
|
|
111
|
+
outputs: []
|
|
72
112
|
});
|
|
73
113
|
} else {
|
|
74
114
|
model.sharedModel.insertCell(index, {
|
|
@@ -84,6 +124,7 @@ function insertCell(
|
|
|
84
124
|
void NotebookActions.run(notebook);
|
|
85
125
|
}
|
|
86
126
|
void notebook.scrollToItem(index);
|
|
127
|
+
return notebook.widgets[index]?.model ?? null;
|
|
87
128
|
}
|
|
88
129
|
|
|
89
130
|
function registerKernel(panel: NotebookPanel): void {
|
|
@@ -93,6 +134,7 @@ function registerKernel(panel: NotebookPanel): void {
|
|
|
93
134
|
}
|
|
94
135
|
|
|
95
136
|
let turn: TurnState | null = null;
|
|
137
|
+
const codeCells = new Map<string, ICodeCellModel>();
|
|
96
138
|
|
|
97
139
|
const finishTurn = (): void => {
|
|
98
140
|
if (!turn) {
|
|
@@ -117,7 +159,7 @@ function registerKernel(panel: NotebookPanel): void {
|
|
|
117
159
|
}
|
|
118
160
|
};
|
|
119
161
|
|
|
120
|
-
const beginTurn = (
|
|
162
|
+
const beginTurn = (): TurnState => {
|
|
121
163
|
if (turn) {
|
|
122
164
|
return turn;
|
|
123
165
|
}
|
|
@@ -133,10 +175,7 @@ function registerKernel(panel: NotebookPanel): void {
|
|
|
133
175
|
: null;
|
|
134
176
|
turn = {
|
|
135
177
|
parentModel,
|
|
136
|
-
parentExecutionCount:
|
|
137
|
-
message.type === 'code_cell' && message.execution_count !== null
|
|
138
|
-
? message.execution_count - 1
|
|
139
|
-
: null,
|
|
178
|
+
parentExecutionCount: null,
|
|
140
179
|
resumeModel: notebook.activeCell?.model ?? null,
|
|
141
180
|
nextIndex:
|
|
142
181
|
parentIndex >= 0
|
|
@@ -164,11 +203,43 @@ function registerKernel(panel: NotebookPanel): void {
|
|
|
164
203
|
(comm: Kernel.IComm, _message: KernelMessage.ICommOpenMsg) => {
|
|
165
204
|
comm.onMsg = (message: KernelMessage.ICommMsgMsg) => {
|
|
166
205
|
const data = message.content.data;
|
|
167
|
-
if (isCodebindMessage(data)) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
206
|
+
if (!isCodebindMessage(data)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (data.type === 'code_cell_output') {
|
|
210
|
+
codeCells.get(data.cell_id)?.outputs.add(data.output);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (data.type === 'code_cell_clear') {
|
|
214
|
+
codeCells.get(data.cell_id)?.outputs.clear(data.wait);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (data.type === 'code_cell_finished') {
|
|
218
|
+
const model = codeCells.get(data.cell_id);
|
|
219
|
+
if (!model) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
model.outputs.fromJSON(data.outputs);
|
|
223
|
+
model.executionCount = data.execution_count;
|
|
224
|
+
model.executionState = 'idle';
|
|
225
|
+
if (
|
|
226
|
+
turn &&
|
|
227
|
+
turn.parentExecutionCount === null &&
|
|
228
|
+
data.execution_count !== null
|
|
229
|
+
) {
|
|
230
|
+
turn.parentExecutionCount = data.execution_count - 1;
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const activeTurn = beginTurn();
|
|
236
|
+
const model = insertCell(panel, data, activeTurn.nextIndex);
|
|
237
|
+
if (data.type === 'code_cell_started' && model?.type === 'code') {
|
|
238
|
+
const code = model as ICodeCellModel;
|
|
239
|
+
code.executionState = 'running';
|
|
240
|
+
codeCells.set(data.cell_id, code);
|
|
171
241
|
}
|
|
242
|
+
activeTurn.nextIndex += 1;
|
|
172
243
|
};
|
|
173
244
|
comm.send({ type: 'ready' });
|
|
174
245
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codebind"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "A frontend-neutral model loop for persistent IPython sessions."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.13"
|
|
@@ -26,7 +26,7 @@ classifiers = [
|
|
|
26
26
|
dependencies = [
|
|
27
27
|
"ipython>=9.0",
|
|
28
28
|
"langchain-core>=1.0",
|
|
29
|
-
"models-provider>=0.1.
|
|
29
|
+
"models-provider>=0.1.1",
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
[[project.authors]]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codebind"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "A frontend-neutral model loop for persistent IPython sessions."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
dependencies = [
|
|
24
24
|
"ipython>=9.0",
|
|
25
25
|
"langchain-core>=1.0",
|
|
26
|
-
"models-provider>=0.1.
|
|
26
|
+
"models-provider>=0.1.1",
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
[project.urls]
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import sys
|
|
6
|
-
from collections.abc import Iterator
|
|
6
|
+
from collections.abc import Callable, Iterator
|
|
7
7
|
from contextlib import contextmanager
|
|
8
8
|
from dataclasses import asdict, dataclass
|
|
9
|
-
from typing import Any
|
|
9
|
+
from typing import Any, cast
|
|
10
10
|
|
|
11
|
+
from IPython.core.displaypub import DisplayPublisher
|
|
11
12
|
from IPython.core.interactiveshell import InteractiveShell
|
|
12
13
|
from IPython.utils.capture import capture_output
|
|
13
14
|
|
|
@@ -34,9 +35,15 @@ class ExecutionReport:
|
|
|
34
35
|
class _ExecutionDisplayHook:
|
|
35
36
|
"""Capture an expression result while preserving IPython output history."""
|
|
36
37
|
|
|
37
|
-
def __init__(
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
shell: InteractiveShell,
|
|
41
|
+
outputs: list[dict[str, Any]],
|
|
42
|
+
on_output: Callable[[dict[str, Any]], None] | None = None,
|
|
43
|
+
) -> None:
|
|
38
44
|
self.shell = shell
|
|
39
45
|
self.outputs = outputs
|
|
46
|
+
self.on_output = on_output
|
|
40
47
|
|
|
41
48
|
def __call__(self, value: Any = None) -> None:
|
|
42
49
|
if value is None:
|
|
@@ -51,6 +58,86 @@ class _ExecutionDisplayHook:
|
|
|
51
58
|
if data:
|
|
52
59
|
displayhook.log_output(data)
|
|
53
60
|
self.outputs.append({"data": data, "metadata": metadata})
|
|
61
|
+
if self.on_output is not None:
|
|
62
|
+
self.on_output(
|
|
63
|
+
{
|
|
64
|
+
"output_type": "execute_result",
|
|
65
|
+
"execution_count": displayhook.prompt_count,
|
|
66
|
+
"data": data,
|
|
67
|
+
"metadata": metadata,
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class _StreamingTextIO:
|
|
73
|
+
"""Write to IPython's capture buffer while forwarding live stream output."""
|
|
74
|
+
|
|
75
|
+
def __init__(
|
|
76
|
+
self,
|
|
77
|
+
stream: Any,
|
|
78
|
+
name: str,
|
|
79
|
+
on_output: Callable[[dict[str, Any]], None],
|
|
80
|
+
) -> None:
|
|
81
|
+
self.stream = stream
|
|
82
|
+
self.name = name
|
|
83
|
+
self.on_output = on_output
|
|
84
|
+
|
|
85
|
+
def write(self, text: str) -> int:
|
|
86
|
+
written = self.stream.write(text)
|
|
87
|
+
if text:
|
|
88
|
+
self.on_output({"output_type": "stream", "name": self.name, "text": text})
|
|
89
|
+
return written
|
|
90
|
+
|
|
91
|
+
def flush(self) -> None:
|
|
92
|
+
self.stream.flush()
|
|
93
|
+
|
|
94
|
+
def __getattr__(self, name: str) -> Any:
|
|
95
|
+
return getattr(self.stream, name)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class _StreamingDisplayPublisher:
|
|
99
|
+
"""Capture rich displays while forwarding them to the notebook cell."""
|
|
100
|
+
|
|
101
|
+
def __init__(
|
|
102
|
+
self,
|
|
103
|
+
publisher: Any,
|
|
104
|
+
on_output: Callable[[dict[str, Any]], None],
|
|
105
|
+
on_clear: Callable[[bool], None],
|
|
106
|
+
) -> None:
|
|
107
|
+
self.publisher = publisher
|
|
108
|
+
self.on_output = on_output
|
|
109
|
+
self.on_clear = on_clear
|
|
110
|
+
|
|
111
|
+
def publish(
|
|
112
|
+
self,
|
|
113
|
+
data: dict[str, Any],
|
|
114
|
+
metadata: dict[str, Any] | None = None,
|
|
115
|
+
source: str | None = None,
|
|
116
|
+
*,
|
|
117
|
+
transient: dict[str, Any] | None = None,
|
|
118
|
+
update: bool = False,
|
|
119
|
+
) -> None:
|
|
120
|
+
self.publisher.publish(
|
|
121
|
+
data,
|
|
122
|
+
metadata=metadata,
|
|
123
|
+
source=source,
|
|
124
|
+
transient=transient,
|
|
125
|
+
update=update,
|
|
126
|
+
)
|
|
127
|
+
self.on_output(
|
|
128
|
+
{
|
|
129
|
+
"output_type": "display_data",
|
|
130
|
+
"data": data,
|
|
131
|
+
"metadata": metadata or {},
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def clear_output(self, wait: bool = False) -> None:
|
|
136
|
+
self.publisher.clear_output(wait)
|
|
137
|
+
self.on_clear(wait)
|
|
138
|
+
|
|
139
|
+
def __getattr__(self, name: str) -> Any:
|
|
140
|
+
return getattr(self.publisher, name)
|
|
54
141
|
|
|
55
142
|
|
|
56
143
|
@contextmanager
|
|
@@ -59,6 +146,8 @@ def _captured_execution(
|
|
|
59
146
|
expression_outputs: list[dict[str, Any]],
|
|
60
147
|
*,
|
|
61
148
|
bridged: bool,
|
|
149
|
+
on_output: Callable[[dict[str, Any]], None] | None = None,
|
|
150
|
+
on_clear: Callable[[bool], None] | None = None,
|
|
62
151
|
) -> Iterator[Any]:
|
|
63
152
|
"""Capture one nested execution without leaking its output to the parent cell."""
|
|
64
153
|
with capture_output() as captured:
|
|
@@ -69,7 +158,18 @@ def _captured_execution(
|
|
|
69
158
|
previous_displayhook = sys.displayhook
|
|
70
159
|
previous_showtraceback = shell.showtraceback
|
|
71
160
|
previous_showsyntaxerror = shell.showsyntaxerror
|
|
72
|
-
|
|
161
|
+
if on_output is not None:
|
|
162
|
+
sys.stdout = _StreamingTextIO(sys.stdout, "stdout", on_output)
|
|
163
|
+
sys.stderr = _StreamingTextIO(sys.stderr, "stderr", on_output)
|
|
164
|
+
shell.display_pub = cast(
|
|
165
|
+
DisplayPublisher,
|
|
166
|
+
_StreamingDisplayPublisher(
|
|
167
|
+
shell.display_pub,
|
|
168
|
+
on_output,
|
|
169
|
+
on_clear or (lambda wait: None),
|
|
170
|
+
),
|
|
171
|
+
)
|
|
172
|
+
sys.displayhook = _ExecutionDisplayHook(shell, expression_outputs, on_output)
|
|
73
173
|
shell.showtraceback = lambda *args, **kwargs: None
|
|
74
174
|
shell.showsyntaxerror = lambda *args, **kwargs: None
|
|
75
175
|
try:
|
|
@@ -96,7 +196,10 @@ class IPythonExecutor:
|
|
|
96
196
|
if not isinstance(cell, str) or not cell.strip():
|
|
97
197
|
raise ValueError("cell must be a non-empty string")
|
|
98
198
|
|
|
99
|
-
|
|
199
|
+
bridge = self.bridge
|
|
200
|
+
cell_id = bridge.start_code_cell(cell) if bridge is not None else None
|
|
201
|
+
bridged = cell_id is not None
|
|
202
|
+
on_output, on_clear = self._stream_callbacks(cell_id)
|
|
100
203
|
if not bridged:
|
|
101
204
|
display_cell(cell)
|
|
102
205
|
expression_outputs: list[dict[str, Any]] = []
|
|
@@ -104,11 +207,14 @@ class IPythonExecutor:
|
|
|
104
207
|
self.shell,
|
|
105
208
|
expression_outputs,
|
|
106
209
|
bridged=bridged,
|
|
210
|
+
on_output=on_output,
|
|
211
|
+
on_clear=on_clear,
|
|
107
212
|
) as captured:
|
|
108
213
|
result = self.shell.run_cell(cell, store_history=True)
|
|
109
214
|
if bridged:
|
|
110
|
-
|
|
111
|
-
|
|
215
|
+
assert bridge is not None and cell_id is not None
|
|
216
|
+
bridge.finish_code_cell(
|
|
217
|
+
cell_id,
|
|
112
218
|
result.execution_count,
|
|
113
219
|
self._notebook_outputs(result, captured, expression_outputs),
|
|
114
220
|
)
|
|
@@ -122,7 +228,10 @@ class IPythonExecutor:
|
|
|
122
228
|
if not isinstance(cell, str) or not cell.strip():
|
|
123
229
|
raise ValueError("cell must be a non-empty string")
|
|
124
230
|
|
|
125
|
-
|
|
231
|
+
bridge = self.bridge
|
|
232
|
+
cell_id = bridge.start_code_cell(cell) if bridge is not None else None
|
|
233
|
+
bridged = cell_id is not None
|
|
234
|
+
on_output, on_clear = self._stream_callbacks(cell_id)
|
|
126
235
|
if not bridged:
|
|
127
236
|
display_cell(cell)
|
|
128
237
|
transformed = self.shell.transform_cell(cell)
|
|
@@ -131,6 +240,8 @@ class IPythonExecutor:
|
|
|
131
240
|
self.shell,
|
|
132
241
|
expression_outputs,
|
|
133
242
|
bridged=bridged,
|
|
243
|
+
on_output=on_output,
|
|
244
|
+
on_clear=on_clear,
|
|
134
245
|
) as captured:
|
|
135
246
|
result = await self.shell.run_cell_async(
|
|
136
247
|
cell,
|
|
@@ -138,8 +249,9 @@ class IPythonExecutor:
|
|
|
138
249
|
transformed_cell=transformed,
|
|
139
250
|
)
|
|
140
251
|
if bridged:
|
|
141
|
-
|
|
142
|
-
|
|
252
|
+
assert bridge is not None and cell_id is not None
|
|
253
|
+
bridge.finish_code_cell(
|
|
254
|
+
cell_id,
|
|
143
255
|
result.execution_count,
|
|
144
256
|
self._notebook_outputs(result, captured, expression_outputs),
|
|
145
257
|
)
|
|
@@ -148,6 +260,25 @@ class IPythonExecutor:
|
|
|
148
260
|
|
|
149
261
|
return self._report(result, captured)
|
|
150
262
|
|
|
263
|
+
def _stream_callbacks(
|
|
264
|
+
self,
|
|
265
|
+
cell_id: str | None,
|
|
266
|
+
) -> tuple[
|
|
267
|
+
Callable[[dict[str, Any]], None] | None,
|
|
268
|
+
Callable[[bool], None] | None,
|
|
269
|
+
]:
|
|
270
|
+
bridge = self.bridge
|
|
271
|
+
if bridge is None or cell_id is None:
|
|
272
|
+
return None, None
|
|
273
|
+
|
|
274
|
+
def on_output(output: dict[str, Any]) -> None:
|
|
275
|
+
bridge.append_code_output(cell_id, output)
|
|
276
|
+
|
|
277
|
+
def on_clear(wait: bool) -> None:
|
|
278
|
+
bridge.clear_code_output(cell_id, wait=wait)
|
|
279
|
+
|
|
280
|
+
return on_output, on_clear
|
|
281
|
+
|
|
151
282
|
@staticmethod
|
|
152
283
|
def _report(result: Any, captured: Any) -> ExecutionReport:
|
|
153
284
|
"""Build the model-facing text projection of an IPython execution."""
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from typing import Any
|
|
6
|
+
from uuid import uuid4
|
|
6
7
|
|
|
7
8
|
from IPython.core.interactiveshell import InteractiveShell
|
|
8
9
|
|
|
@@ -25,7 +26,7 @@ class JupyterLabBridge:
|
|
|
25
26
|
return None
|
|
26
27
|
|
|
27
28
|
try:
|
|
28
|
-
from comm import create_comm
|
|
29
|
+
from comm import create_comm # pyright: ignore[reportMissingImports]
|
|
29
30
|
|
|
30
31
|
return cls(create_comm(target_name=_TARGET_NAME))
|
|
31
32
|
except (ImportError, RuntimeError):
|
|
@@ -36,25 +37,65 @@ class JupyterLabBridge:
|
|
|
36
37
|
self._comm.close()
|
|
37
38
|
self.ready = False
|
|
38
39
|
|
|
39
|
-
def
|
|
40
|
+
def start_code_cell(self, source: str) -> str | None:
|
|
41
|
+
"""Insert a running code cell before its execution begins."""
|
|
42
|
+
if not self.ready:
|
|
43
|
+
return None
|
|
44
|
+
cell_id = str(uuid4())
|
|
45
|
+
self._comm.send(
|
|
46
|
+
{
|
|
47
|
+
"type": "code_cell_started",
|
|
48
|
+
"cell_id": cell_id,
|
|
49
|
+
"source": source,
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
return cell_id
|
|
53
|
+
|
|
54
|
+
def finish_code_cell(
|
|
40
55
|
self,
|
|
41
|
-
|
|
56
|
+
cell_id: str,
|
|
42
57
|
execution_count: int | None,
|
|
43
58
|
outputs: list[dict[str, Any]],
|
|
44
59
|
) -> bool:
|
|
45
|
-
"""
|
|
60
|
+
"""Finish a previously inserted code cell with its native outputs."""
|
|
46
61
|
if not self.ready:
|
|
47
62
|
return False
|
|
48
63
|
self._comm.send(
|
|
49
64
|
{
|
|
50
|
-
"type": "
|
|
51
|
-
"
|
|
65
|
+
"type": "code_cell_finished",
|
|
66
|
+
"cell_id": cell_id,
|
|
52
67
|
"execution_count": execution_count,
|
|
53
68
|
"outputs": outputs,
|
|
54
69
|
}
|
|
55
70
|
)
|
|
56
71
|
return True
|
|
57
72
|
|
|
73
|
+
def append_code_output(self, cell_id: str, output: dict[str, Any]) -> bool:
|
|
74
|
+
"""Append one live output to a running code cell."""
|
|
75
|
+
if not self.ready:
|
|
76
|
+
return False
|
|
77
|
+
self._comm.send(
|
|
78
|
+
{
|
|
79
|
+
"type": "code_cell_output",
|
|
80
|
+
"cell_id": cell_id,
|
|
81
|
+
"output": output,
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
return True
|
|
85
|
+
|
|
86
|
+
def clear_code_output(self, cell_id: str, *, wait: bool = False) -> bool:
|
|
87
|
+
"""Clear a running code cell's outputs."""
|
|
88
|
+
if not self.ready:
|
|
89
|
+
return False
|
|
90
|
+
self._comm.send(
|
|
91
|
+
{
|
|
92
|
+
"type": "code_cell_clear",
|
|
93
|
+
"cell_id": cell_id,
|
|
94
|
+
"wait": wait,
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
return True
|
|
98
|
+
|
|
58
99
|
def insert_markdown_cell(self, source: str) -> bool:
|
|
59
100
|
"""Insert one rendered Markdown cell through JupyterLab."""
|
|
60
101
|
if not self.ready:
|
codebind-0.4.0/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.4acc74d60e21c02c.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(171);function l(e){let t=e.sessionContext.session?.kernel;if(!t)return;let n=null;t.registerCommTarget("codebind",(l,c)=>{l.onMsg=l=>{var c;let u=l.content.data;if("object"==typeof u&&null!==u&&("markdown_cell"===u.type?"string"==typeof u.source:"code_cell"===u.type&&"string"==typeof u.source&&("number"==typeof u.execution_count||null===u.execution_count)&&Array.isArray(u.outputs))){let l,d,r=(o=>{if(n)return n;let l=e.content,c=l.widgets.findIndex(e=>"code"===e.model.type&&"running"===e.model.executionState);n={parentModel:c>=0?l.widgets[c].model:null,parentExecutionCount:"code_cell"===o.type&&null!==o.execution_count?o.execution_count-1:null,resumeModel:l.activeCell?.model??null,nextIndex:c>=0?c+1:l.activeCell?l.activeCellIndex+1:0};let u=(o,l)=>{"idle"===l&&(t.statusChanged.disconnect(u),(()=>{if(!n)return;let t=e.content,o=n;if(n=null,o.parentModel&&null!==o.parentExecutionCount&&(o.parentModel.executionCount=o.parentExecutionCount),o.resumeModel){let e=t.widgets.findIndex(e=>e.model===o.resumeModel);e>=0&&(t.activeCellIndex=e)}})())};return t.statusChanged.connect(u),n})(u);c=r.nextIndex,(d=(l=e.content).model)&&("code_cell"===u.type?d.sharedModel.insertCell(c,{cell_type:"code",source:u.source,metadata:{trusted:!0},execution_count:u.execution_count,outputs:u.outputs}):d.sharedModel.insertCell(c,{cell_type:"markdown",source:u.source,metadata:{}}),l.activeCellIndex=c,l.deselectAll(),"markdown_cell"===u.type&&o.NotebookActions.run(l),l.scrollToItem(c)),r.nextIndex+=1}},l.send({type:"ready"})})}function c(e){e.sessionContext.ready.then(()=>l(e)),e.sessionContext.kernelChanged.connect(()=>l(e))}let u={id:"codebind-jupyterlab:plugin",description:"Insert Codebind executions as native notebook cells.",autoStart:!0,requires:[o.INotebookTracker],activate:(e,t)=>{t.forEach(c),t.widgetAdded.connect((e,t)=>c(t))}};n.d(t,{},{default:u})}}]);
|
|
File without changes
|
|
File without changes
|
{codebind-0.4.0 → codebind-0.4.2}/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
|