codebind 0.6.2__tar.gz → 0.6.3__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.6.2 → codebind-0.6.3}/PKG-INFO +7 -3
- {codebind-0.6.2 → codebind-0.6.3}/README.md +3 -1
- {codebind-0.6.2 → codebind-0.6.3}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json +2 -2
- codebind-0.6.3/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.dae4561c5427a855.js +1 -0
- codebind-0.6.3/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.76c22319f766843f.js +1 -0
- {codebind-0.6.2 → codebind-0.6.3}/jupyterlab/package.json +1 -1
- {codebind-0.6.2 → codebind-0.6.3}/jupyterlab/src/index.ts +315 -179
- {codebind-0.6.2 → codebind-0.6.3}/pyproject.toml +4 -2
- {codebind-0.6.2 → codebind-0.6.3}/pyproject.toml.orig +4 -2
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/conversation.py +166 -15
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/execution.py +56 -11
- codebind-0.6.3/src/codebind/extension.py +154 -0
- codebind-0.6.3/src/codebind/images.py +127 -0
- codebind-0.6.3/src/codebind/instructions.md +15 -0
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/jupyter.py +16 -45
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/session.py +142 -92
- codebind-0.6.2/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.5b773af7a27693b3.js +0 -1
- codebind-0.6.2/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.2cec6ffa067e0ab2.js +0 -1
- codebind-0.6.2/src/codebind/extension.py +0 -109
- codebind-0.6.2/src/codebind/instructions.md +0 -11
- {codebind-0.6.2 → codebind-0.6.3}/LICENSE +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/data/share/jupyter/labextensions/codebind-jupyterlab/install.json +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/data/share/jupyter/labextensions/codebind-jupyterlab/static/style.js +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/data/share/jupyter/labextensions/codebind-jupyterlab/static/third-party-licenses.json +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/jupyterlab/.yarnrc.yml +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/jupyterlab/install.json +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/jupyterlab/tsconfig.json +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/jupyterlab/yarn.lock +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/__init__.py +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/cli.py +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/configuration.py +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/display.py +0 -0
- {codebind-0.6.2 → codebind-0.6.3}/src/codebind/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codebind
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
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,9 @@ 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.2
|
|
21
|
+
Requires-Dist: pillow>=11
|
|
22
|
+
Requires-Dist: resvg-py>=0.5
|
|
21
23
|
Requires-Python: >=3.13
|
|
22
24
|
Project-URL: Repository, https://github.com/ghovax/codebind
|
|
23
25
|
Project-URL: Issues, https://github.com/ghovax/codebind/issues
|
|
@@ -95,10 +97,12 @@ That is the complete setup. **Question** is a native toolbar toggle. Turning it
|
|
|
95
97
|
|
|
96
98
|
Loading the extension adds a locked Markdown cell containing Codebind's packaged instructions. That exact text becomes the conversation's immutable system message and remains stable when the server or kernel restarts.
|
|
97
99
|
|
|
98
|
-
The whole notebook is model context. Before each Question, Codebind takes a canonical snapshot of ordinary Markdown, raw, and code cells, including
|
|
100
|
+
The whole notebook is model context. Before each Question, Codebind takes a canonical snapshot of ordinary Markdown, raw, and code cells, including visible text and image outputs but never the live Python namespace. Images displayed by the model's IPython tool are included in that tool's result as well. PNG, JPEG, WebP, GIF, and SVG renditions are prepared as model-visible images; unsupported or oversized images are reported as omissions rather than silently discarded. The first turn records the snapshot; later turns append only new, changed, removed, or reordered cells. Questions, tool calls, tool results, and answers already present in the conversation ledger are not duplicated. Image bytes are carried in the relevant message, while notebook snapshots contain only stable image descriptors. This append-only representation keeps the prior model prefix unchanged for provider caching.
|
|
99
101
|
|
|
100
102
|
Codebind stores the complete LangChain message, notebook-context, and turn ledger in notebook metadata. Reopening the notebook, restarting its kernel, and loading the extension restores the exact accumulated context automatically. Each assistant Markdown segment is buffered and inserted as one complete native cell as soon as that segment finishes, before a following tool call is complete. Tool executions and assistant answers are always appended to the notebook end without changing the user's current selection or scroll position. Tool outputs are collapsed by default and remain expandable through JupyterLab's native output control.
|
|
101
103
|
|
|
104
|
+
The conversation ledger validates its structure and every assistant tool call against its single matching result, without a version gate. Interrupted saves finish before a turn is cancelled, so a restart cannot turn a partial write into an orphan tool result. Temporary model transport failures retry the same Question with a fresh connection; repeated WebSocket failures use HTTP. Invalid requests and authentication failures remain visible errors.
|
|
105
|
+
|
|
102
106
|
An interrupted tool call is closed with an explicit interrupted result before the turn ends. If a provider stream is cancelled or fails, Codebind discards that provider session before the next Question while retaining the notebook conversation and its stable prompt-cache identity.
|
|
103
107
|
|
|
104
108
|
The instruction cell, sent Question cells, model-authored tool cells, and assistant Markdown cells are non-editable and non-deletable. Draft Question cells remain editable until they are sent. Jupyter's standard interrupt button cancels an active Codebind question.
|
|
@@ -70,10 +70,12 @@ That is the complete setup. **Question** is a native toolbar toggle. Turning it
|
|
|
70
70
|
|
|
71
71
|
Loading the extension adds a locked Markdown cell containing Codebind's packaged instructions. That exact text becomes the conversation's immutable system message and remains stable when the server or kernel restarts.
|
|
72
72
|
|
|
73
|
-
The whole notebook is model context. Before each Question, Codebind takes a canonical snapshot of ordinary Markdown, raw, and code cells, including
|
|
73
|
+
The whole notebook is model context. Before each Question, Codebind takes a canonical snapshot of ordinary Markdown, raw, and code cells, including visible text and image outputs but never the live Python namespace. Images displayed by the model's IPython tool are included in that tool's result as well. PNG, JPEG, WebP, GIF, and SVG renditions are prepared as model-visible images; unsupported or oversized images are reported as omissions rather than silently discarded. The first turn records the snapshot; later turns append only new, changed, removed, or reordered cells. Questions, tool calls, tool results, and answers already present in the conversation ledger are not duplicated. Image bytes are carried in the relevant message, while notebook snapshots contain only stable image descriptors. This append-only representation keeps the prior model prefix unchanged for provider caching.
|
|
74
74
|
|
|
75
75
|
Codebind stores the complete LangChain message, notebook-context, and turn ledger in notebook metadata. Reopening the notebook, restarting its kernel, and loading the extension restores the exact accumulated context automatically. Each assistant Markdown segment is buffered and inserted as one complete native cell as soon as that segment finishes, before a following tool call is complete. Tool executions and assistant answers are always appended to the notebook end without changing the user's current selection or scroll position. Tool outputs are collapsed by default and remain expandable through JupyterLab's native output control.
|
|
76
76
|
|
|
77
|
+
The conversation ledger validates its structure and every assistant tool call against its single matching result, without a version gate. Interrupted saves finish before a turn is cancelled, so a restart cannot turn a partial write into an orphan tool result. Temporary model transport failures retry the same Question with a fresh connection; repeated WebSocket failures use HTTP. Invalid requests and authentication failures remain visible errors.
|
|
78
|
+
|
|
77
79
|
An interrupted tool call is closed with an explicit interrupted result before the turn ends. If a provider stream is cancelled or fails, Codebind discards that provider session before the next Question while retaining the notebook conversation and its stable prompt-cache identity.
|
|
78
80
|
|
|
79
81
|
The instruction cell, sent Question cells, model-authored tool cells, and assistant Markdown cells are non-editable and non-deletable. Draft Question cells remain editable until they are sent. Jupyter's standard interrupt button cancels an active Codebind question.
|
{codebind-0.6.2 → codebind-0.6.3}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebind-jupyterlab",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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.76c22319f766843f.js",
|
|
35
35
|
"extension": "./extension"
|
|
36
36
|
}
|
|
37
37
|
}
|
codebind-0.6.3/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.dae4561c5427a855.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),d=n(99),i=n(171),r=n(241);let s="codebind:insert-question",a="codebind:toggle-question-mode",c="codebind:run-question",u="jp-CodebindQuestionCell",m=new WeakMap,p=new WeakMap;function f(e){return 0!==e.runningQuestions.size&&(e.comm?.send({type:"cancel"}),!0)}function g(e){let t=e.getMetadata("codebind");return"object"!=typeof t||null===t||"question"!==t.kind?null:{kind:"question",status:"draft"===t.status?"draft":"sent"}}function y(e){let t=e.getMetadata("codebind");if("object"!=typeof t||null===t)return null;let n=t.kind;return"string"==typeof n?n:null}function b(e){let t={},n=[];for(let[o,l]of Object.entries(e))o.startsWith("text/")||["image/png","image/jpeg","image/webp","image/gif","image/svg+xml"].includes(o)||"application/json"===o||"application/vnd.jupyter.stdout"===o||"application/vnd.jupyter.stderr"===o?void 0!==l&&(t[o]=l):n.push(o);return n.length>0&&(t.omitted_mime_types=n),t}function _(e){return d.isStream(e)?{type:"stream",name:e.name,text:e.text}:d.isError(e)?{type:"error",name:e.ename,message:e.evalue,traceback:e.traceback}:d.isExecuteResult(e)?{type:"result",execution_count:e.execution_count,data:b(e.data)}:d.isDisplayData(e)?{type:"display",data:b(e.data)}:{type:e.output_type}}function w(e){return e.replace(/(^|[^\\])\\([()[\]])/g,"$1\\\\$2")}function k(e){let t=m.get(e);for(let n of e.content.widgets){let e=g(n.model);n.node.classList.toggle(u,null!==e);let o=n.node.querySelector(".jp-InputPrompt");o&&(e?(n.readOnly="sent"===e.status,o.dataset.codebindQuestion="true",o.textContent=t?.runningQuestions.has(n.model.id)?"[*]:":"[ ]:"):o.dataset.codebindQuestion&&(delete o.dataset.codebindQuestion,o.textContent=""))}}function C(e){let t=e.sessionContext.session?.kernel;if(!t)return;let n=m.get(e)??{comm:null,kernel:null,registeredKernel:null,connectKernel:null,disconnectKernel:null,ready:null,resolveReady:null,rejectReady:null,connectOnIdle:!1,runningQuestions:new Map,questionTimers:new Map,sessionReady:!1,questionMode:!1,questionButton:null,knownCellIds:new Set(e.content.widgets.map(e=>e.model.id)),pendingQuestionCellIds:new Set};if(m.set(e,n),n.registeredKernel===t)return;n.disconnectKernel?.(),n.rejectReady?.(Error("The notebook kernel changed.")),n.comm?.close(),n.registeredKernel=t,n.connectKernel=null,n.disconnectKernel=null,n.ready=null,n.resolveReady=null,n.rejectReady=null,n.connectOnIdle=!1;n.kernel&&n.kernel!==t&&p.get(n.kernel)?.delete(n),n.kernel=t;let d=p.get(t);if(!d){d=new Set,p.set(t,d);let e=t.interrupt.bind(t);t.interrupt=async()=>{let t=[...d??[]].filter(e=>e.runningQuestions.size>0);for(let e of t)f(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()}}for(let e of(d.add(n),n.comm=null,n.runningQuestions.clear(),n.questionTimers.values()))window.clearTimeout(e);n.questionTimers.clear(),n.sessionReady=!1;let i=null,s=new Map,a=new Map,c=()=>{if(!i)return;let e=i;i=null,e.parentModel&&null!==e.parentExecutionCount&&(e.parentModel.executionCount=e.parentExecutionCount)},u=()=>{if(n.comm||"idle"!==t.status||!e.content.model)return;let d=t.createComm("codebind");d.commsOverSubshells=r.CommsOverSubshells.Disabled,n.comm=d,n.sessionReady=!1,n.ready=new Promise((e,t)=>{n.resolveReady=e,n.rejectReady=t}),n.ready.catch(()=>void 0),d.onMsg=r=>{let u,m=r.content.data;if(!function(e){if("object"!=typeof e||null===e)return!1;if("markdown_cell"===e.type||"instructions_cell"===e.type)return"string"==typeof e.source;if("markdown_cell_started"===e.type||"markdown_cell_updated"===e.type||"markdown_cell_finished"===e.type)return"string"==typeof e.cell_id&&"string"==typeof e.source;if("markdown_cell_cancelled"===e.type)return"string"==typeof e.cell_id;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)}if("question_started"===e.type)return"string"==typeof e.cell_id;if("session_ready"===e.type){let t=e.error;return null===t||"object"==typeof t&&"string"==typeof t.type&&"string"==typeof t.message}return"conversation_save"===e.type?"string"==typeof e.request_id&&"object"==typeof e.conversation&&null!==e.conversation:"code_cell_finished"===e.type&&"string"==typeof e.cell_id&&("number"==typeof e.execution_count||null===e.execution_count)&&Array.isArray(e.outputs)}(m))return;if("conversation_save"===m.type){let t=e.content.model;return t?(t.setMetadata("codebind",m.conversation),void e.context.save().then(()=>{d.send({type:"conversation_saved",request_id:m.request_id,error:null})},e=>{d.send({type:"conversation_saved",request_id:m.request_id,error:String(e)})})):void d.send({type:"conversation_saved",request_id:m.request_id,error:"Notebook model is unavailable."})}if("instructions_cell"===m.type)return void function(e,t){let n=e.content,o=n.model;if(!o)return;let d=n.widgets.findIndex(e=>"instructions"===y(e.model));if(d<0){let e=n.activeCell?.model.id??null;if(o.sharedModel.insertCell(0,{cell_type:"markdown",source:t,metadata:{editable:!1,deletable:!1,codebind:{kind:"instructions"}}}),d=0,null!==e){let t=n.widgets.findIndex(t=>t.model.id===e);t>=0&&(n.activeCellIndex=t)}}let i=n.widgets[d];i&&(i.model.sharedModel.getSource()!==t&&i.model.sharedModel.setSource(t),i.model.setMetadata("editable",!1),i.model.setMetadata("deletable",!1),i.model.setMetadata("codebind",{kind:"instructions"}),i.readOnly=!0,i instanceof l.MarkdownCell&&(i.rendered=!0))}(e,m.source);if("session_ready"===m.type){n.sessionReady=null===m.error,m.error?(n.rejectReady?.(Error(m.error.message)),(0,o.showErrorMessage)(`Codebind could not load: ${m.error.type}`,m.error.message)):n.resolveReady?.(),n.resolveReady=null,n.rejectReady=null;return}if("question_started"===m.type){let e=n.questionTimers.get(m.cell_id);void 0!==e&&(window.clearTimeout(e),n.questionTimers.delete(m.cell_id));return}if("question_finished"===m.type){let t=n.questionTimers.get(m.cell_id);void 0!==t&&(window.clearTimeout(t),n.questionTimers.delete(m.cell_id)),n.runningQuestions.delete(m.cell_id),k(e),c(),m.error&&!m.cancelled&&(0,o.showErrorMessage)(`Codebind question: ${m.error.type}`,m.error.message);return}if("markdown_cell_updated"===m.type||"markdown_cell_finished"===m.type){let t=a.get(m.cell_id);if(!t)return;t.sharedModel.setSource(w(m.source));let n=e.content.widgets.find(e=>e.model.id===t.id);n instanceof l.MarkdownCell&&(n.rendered=!0),"markdown_cell_finished"===m.type&&a.delete(m.cell_id);return}if("markdown_cell_cancelled"===m.type){let t=a.get(m.cell_id);if(a.delete(m.cell_id),!t)return;let n=e.content.widgets.findIndex(e=>e.model.id===t.id);n>=0&&e.content.model?.sharedModel.deleteCell(n);return}if("code_cell_output"===m.type)return void s.get(m.cell_id)?.outputs.add(m.output);if("code_cell_clear"===m.type)return void s.get(m.cell_id)?.outputs.clear(m.wait);if("code_cell_finished"===m.type){let e=s.get(m.cell_id);if(!e)return;e.outputs.fromJSON(m.outputs),e.executionCount=m.execution_count,e.executionState="idle",i&&null===i.parentExecutionCount&&null!==m.execution_count&&(i.parentExecutionCount=m.execution_count-1);return}if("markdown_cell_started"===m.type)u={type:"markdown_cell",source:m.source};else{if("markdown_cell"!==m.type&&"code_cell_started"!==m.type)return;u=m}(()=>{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),c())};return t.statusChanged.connect(l)})();let p=function(e,t){let n=e.content,o=n.model;if(!o)return null;let d=n.widgets.length;"code_cell_started"===t.type?o.sharedModel.insertCell(d,{cell_type:"code",source:t.source,metadata:{trusted:!0,collapsed:!0,editable:!1,deletable:!1,codebind:{kind:"tool"}},execution_count:null,outputs:[]}):o.sharedModel.insertCell(d,{cell_type:"markdown",source:w(t.source),metadata:{editable:!1,deletable:!1,codebind:{kind:"assistant"}}});let i=n.widgets[d]??null;return i&&(i.readOnly=!0),i instanceof l.MarkdownCell&&(i.rendered=!0),i?.model??null}(e,u);"code_cell_started"===m.type&&p?.type==="code"&&(p.executionState="running",s.set(m.cell_id,p)),"markdown_cell_started"===m.type&&p&&a.set(m.cell_id,p)},d.onClose=()=>{if(n.comm===d){let e=n.sessionReady;n.rejectReady?.(Error("Codebind is not loaded in this kernel. Run %load_ext codebind.")),n.comm=null,n.sessionReady=!1,n.ready=null,n.resolveReady=null,n.rejectReady=null,n.connectOnIdle=e}};let u=e.content.model?.getMetadata("codebind");d.open({conversation:"object"==typeof u&&null!==u?u:null})};n.connectKernel=u;let g=(e,t)=>{"idle"===t&&n.connectOnIdle&&(n.connectOnIdle=!1,u())},b=(e,t)=>{r.KernelMessage.isExecuteInputMsg(t)&&/(?:^|\n)\s*%(?:re)?load_ext\s+codebind(?:\s|$)/.test(t.content.code)&&(n.connectOnIdle=!0)};t.statusChanged.connect(g),t.iopubMessage.connect(b),n.disconnectKernel=()=>{t.statusChanged.disconnect(g),t.iopubMessage.disconnect(b)},e.context.ready.then(()=>{e.content.model?.getMetadata("codebind")&&(n.connectOnIdle=!0,u())})}function h(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&&null!==y(o.model)||(o?.model.setMetadata("codebind",{kind:"question",status:"draft"}),o instanceof l.MarkdownCell&&(o.rendered=!1),t.mode="edit",k(e),o?.editor?.focus())}function v(e){let t=m.get(e);if(!t)return;let n=e.content.widgets,o=new Set(n.map(e=>e.model.id)),l=n.filter(e=>!t.knownCellIds.has(e.model.id));for(let e of(t.knownCellIds=o,t.pendingQuestionCellIds))o.has(e)||t.pendingQuestionCellIds.delete(e);if(t.questionMode)for(let e of l)null===y(e.model)&&t.pendingQuestionCellIds.add(e.model.id);k(e),t.questionMode&&e.content.activeCell&&t.pendingQuestionCellIds.delete(e.content.activeCell.model.id)&&h(e)}function M(e,t){let n=m.get(e);n&&(n.questionMode=t,n.questionMode||n.pendingQuestionCellIds.clear(),n.questionButton&&(n.questionButton.pressed=n.questionMode),n.questionMode&&e.content.activeCell&&null===y(e.content.activeCell.model)&&h(e))}async function q(e){let t=e.content,n=t.activeCell;if(!n||!g(n.model))return;await e.sessionContext.ready,C(e);let d=m.get(e),i=d?.registeredKernel;if(!d||!i)return void await (0,o.showErrorMessage)("Codebind is not connected","Start the notebook kernel before sending a Question cell.");try{if("dead"===i.status)throw Error("The notebook kernel stopped.");if("idle"!==i.status&&await new Promise((e,t)=>{let n=(o,l)=>{("idle"===l||"dead"===l)&&(i.statusChanged.disconnect(n),"idle"===l?e():t(Error("The notebook kernel stopped.")))};i.statusChanged.connect(n)}),d.connectKernel?.(),!d.ready)throw Error("Run %load_ext codebind in this kernel.");await d.ready}catch(e){await (0,o.showErrorMessage)("Codebind could not load",String(e));return}if(!d.sessionReady||!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();if(!r)return void await (0,o.showErrorMessage)("Empty Codebind question","Write a question before sending it.");d.runningQuestions.set(n.model.id,n.model),n.model.sharedModel.setSource(w(r)),n.model.setMetadata("codebind",{kind:"question",status:"sent"}),n.model.setMetadata("editable",!1),n.model.setMetadata("deletable",!1),n.readOnly=!0,k(e),n instanceof l.MarkdownCell&&(n.rendered=!0),t.mode="command";let s=window.setTimeout(()=>{d.questionTimers.has(n.model.id)&&(d.questionTimers.delete(n.model.id),d.runningQuestions.delete(n.model.id),n.model.setMetadata("codebind",{kind:"question",status:"draft"}),n.model.setMetadata("editable",!0),n.model.setMetadata("deletable",!0),n.readOnly=!1,k(e),(0,o.showErrorMessage)("Codebind did not receive the Question","The kernel did not acknowledge it. Reload Codebind and send it again."))},1e4);d.questionTimers.set(n.model.id,s),d.comm.send({type:"question",cell_id:n.model.id,question:r,notebook:function(e){let t=[];for(let n of e.content.widgets){if(null!==y(n.model))continue;let e=n.model.type;if("code"!==e&&"markdown"!==e&&"raw"!==e)continue;let o={id:n.model.id,type:e,source:n.model.sharedModel.getSource(),execution_count:null,outputs:[],attachments:{}};if("code"===e){let e=n.model.toJSON();o.execution_count=e.execution_count,o.outputs=e.outputs.map(_)}else{let e=n.model.toJSON().attachments;if(e){let t={};for(let[n,o]of Object.entries(e))o&&(t[n]=b(o));o.attachments=t}}t.push(o)}return t}(e)})}function x(e,t){let n={comm:null,kernel:null,registeredKernel:null,connectKernel:null,disconnectKernel:null,ready:null,resolveReady:null,rejectReady:null,connectOnIdle:!1,runningQuestions:new Map,questionTimers:new Map,sessionReady:!1,questionMode:!1,questionButton:null,knownCellIds:new Set(e.content.widgets.map(e=>e.model.id)),pendingQuestionCellIds:new Set};m.set(e,n);let l=e=>{f(n)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),window.setTimeout(()=>{n.runningQuestions.size>0&&n.kernel?.interrupt()},500))},d=null,i=()=>{let t=e.toolbar.node.querySelector('[data-command="notebook:interrupt-kernel"]');t!==d&&(d?.removeEventListener("click",l,!0),d=t,d?.addEventListener("click",l,!0))},r=new MutationObserver(i);r.observe(e.toolbar.node,{childList:!0,subtree:!0});let s=new MutationObserver(()=>{window.setTimeout(()=>v(e),0)});s.observe(e.content.node,{childList:!0,subtree:!0}),i(),e.disposed.connect(()=>{for(let e of(r.disconnect(),s.disconnect(),d?.removeEventListener("click",l,!0),n.disconnectKernel?.(),n.rejectReady?.(Error("The notebook closed.")),n.comm?.close(),n.kernel&&p.get(n.kernel)?.delete(n),n.questionTimers.values()))window.clearTimeout(e);n.questionTimers.clear()});let c=new o.ToolbarButton({label:"Question",tooltip:"Toggle Question mode for the selected and newly created cells",onClick:()=>{M(e,c.pressed),t.commands.notifyCommandChanged(a)}});n.questionButton=c,e.toolbar.insertItem(10,"codebindQuestion",c),e.content.modelContentChanged.connect(()=>{v(e),window.setTimeout(()=>v(e),0)}),e.content.activeCellChanged.connect(()=>v(e)),e.context.ready.then(()=>{e.content.model?.cells.changed.connect(()=>{v(e),window.setTimeout(()=>v(e),0)}),v(e)}),e.sessionContext.ready.then(()=>C(e)),e.sessionContext.kernelChanged.connect(()=>C(e))}let j={id:"codebind-jupyterlab:plugin",description:"Insert Codebind executions as native notebook cells.",autoStart:!0,requires:[i.INotebookTracker],activate:(e,t)=>{e.commands.addCommand(s,{label:"Use Selected Cell as Codebind Question",execute:()=>{let e=t.currentWidget;e&&h(e)}}),e.commands.addCommand(a,{label:"Toggle Codebind Question Mode",isToggled:()=>{let e=t.currentWidget;return!!e&&(m.get(e)?.questionMode??!1)},execute:()=>{let n=t.currentWidget;if(n){let t;(t=m.get(n))&&M(n,!t.questionMode),e.commands.notifyCommandChanged(a)}}}),e.commands.addCommand(c,{label:"Send Codebind Question",isEnabled:()=>{let e=t.currentWidget?.content.activeCell;return!!e&&null!==g(e.model)},execute:async()=>{let e=t.currentWidget;e&&await q(e)}}),e.commands.addKeyBinding({command:c,keys:["Shift Enter"],selector:`.jp-Notebook.jp-mod-editMode .${u}`}),e.commands.addKeyBinding({command:c,keys:["Shift Enter"],selector:`.jp-Notebook.jp-mod-commandMode .${u}`}),e.contextMenu.addItem({command:s,selector:".jp-Notebook .jp-Cell",rank:8}),t.forEach(t=>x(t,e)),t.widgetAdded.connect((t,n)=>x(n,e))}};n.d(t,{},{default:j})}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _JUPYTERLAB;(()=>{"use strict";var e,n,r,t,o,i,u,a,l,c,s,f,p,d,h,g,v,y,b,m,S,k,j,w,E,x,T,M,P,V,q,A,C,O,D,_,L,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+".dae4561c5427a855.js?v=dae4561c5427a855",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 l=u[a];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="codebind-jupyterlab:"+r){o=l;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 c=function(n,r){o.onerror=o.onload=null,clearTimeout(s);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)},s=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.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.6.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 l.push(i.then(u,t));var a=u(i);if(a&&a.then)return l.push(a.catch(t))}catch(e){t(e)}},l=[],c=z.initializeSharingData.scopeToSharingDataMapping;return(c[e]&&c[e].forEach(function(e){"object"==typeof e?u(e.name,e.version,e.factory,e.eager):a(e)}),l.length)?R[e]=Promise.all(l).then(function(){return R[e]=1}):R[e]=1}},z.g.importScripts&&(B=z.g.location+"");var I,R,U,B,K=z.g.document;if(!B&&K&&(K.currentScript&&"SCRIPT"===K.currentScript.tagName.toUpperCase()&&(B=K.currentScript.src),!B)){var J=K.getElementsByTagName("script");if(J.length)for(var Y=J.length-1;Y>-1&&(!B||!/^http(s?):/.test(B));)B=J[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","99","171","241"]},moduleIdToConsumeDataMapping:{171:{shareScope:"default",shareKey:"@jupyterlab/notebook",import:null,requiredVersion:"^4.6.3",strictVersion:!1,singleton:!0,eager:!1,fallback:void 0,treeShakingMode:null},241:{shareScope:"default",shareKey:"@jupyterlab/services",import:null,requiredVersion:"^7.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},99:{shareScope:"default",shareKey:"@jupyterlab/nbformat",import:null,requiredVersion:"^4.6.3",strictVersion:!1,singleton:!1,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,l=0;a=r.exec(e);){let r=a.index+1;n.push(i(e.slice(l,r).trim())),l=r}return n.push(i(e.slice(l).trim())),u(n,2)}let c=r(n[0]),s=r(n[1]);return[,t(s),o(s),1,c,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 l=[],i=1;i<e.length;i++){var u=e[i];l.push(0===u?"not("+c()+")":1===u?"("+c()+" || "+c()+")":2===u?l.pop()+" "+l.pop():o(u))}return c();function c(){return l.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,l=!0;;a++,u++){var c,s,f=a<e.length?(typeof e[a])[0]:"";if(u>=n.length||"o"==(s=(typeof(c=n[u]))[0])){if(!l)return!0;if("u"==f)return a>t&&!o;return""==f!=o}if("u"==s){if(!l||"u"!=f)return!1}else if(l)if(f==s)if(a<=t){if(c!=e[a])return!1}else{if(o?c>e[a]:c<e[a])return!1;c!=e[a]&&(l=!1)}else if("s"!=f&&"n"!=f){if(o||a<=t)return!1;l=!1,a--}else{if(a<=t||s<f!=o)return!1;l=!1}else"s"!=f&&"n"!=f&&(l=!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]},l=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)},c=function(e,n,r,t){return"Unsatisfied version "+r+" from "+(r&&e[n][r].from)+" of shared singleton module "+n+" (required "+o(t)+")"},s=function(e,n,r,t){var o=l(e,r);return b(e[r][o])},f=function(e,n,r,t){var o=l(e,r);return i(t,o)||v(c(e,r,o,t)),b(e[r][o])},p=function(e,n,r,t){var o=l(e,r);if(!i(t,o))throw Error(c(e,r,o,t));return b(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 b(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))},b=function(e){return e.loaded=1,e.get()},S=(m=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),b(a(n,r))}),k=m(function(e,n,r,t){return n&&z.o(n,r)?b(a(n,r)):t()}),j=m(function(e,n,r,t){return u(e,r),b(d(n,r,t)||y(n,e,r,t)||a(n,r))}),w=m(function(e,n,r){return u(e,r),s(n,e,r)}),E=m(function(e,n,r,t){return u(e,r),f(n,e,r,t)}),x=m(function(e,n,r,t){return u(e,r),g(n,e,r,t)}),T=m(function(e,n,r,t){return u(e,r),p(n,e,r,t)}),M=m(function(e,n,r,t,o){return n&&z.o(n,r)?b(d(n,r,t)||y(n,e,r,t)||a(n,r)):o()}),P=m(function(e,n,r,t){return n&&z.o(n,r)?s(n,e,r):t()}),V=m(function(e,n,r,t,o){return n&&z.o(n,r)?f(n,e,r,t):o()}),q=m(function(e,n,r,t,o){var i=n&&z.o(n,r)&&d(n,r,t);return i?b(i):o()}),A=m(function(e,n,r,t,o){return n&&z.o(n,r)?p(n,e,r,t):o()}),C=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 A.apply(null,u)}:r&&o&&i?function(){return q.apply(null,u)}:t&&o&&i?function(){return V.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)}},O={},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(O,e))return n.push(O[e]);var t=function(n){O[e]=0,z.m[e]=function(r){delete z.c[e],r.exports=n()}},o=function(n){delete O[e],z.m[e]=function(r){throw delete z.c[e],n}};try{var i=C(r[e])();i.then?n.push(O[e]=i.then(t).catch(o)):t(i)}catch(e){o(e)}})},D={871:0},z.f.j=function(e,n){var r=z.o(D,e)?D[e]:void 0;if(0!==r)if(r)n.push(r[2]);else{var t=new Promise((n,t)=>r=D[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(D,e)&&(0!==(r=D[e])&&(D[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)}},_=(e,n)=>{var r,t,[o,i,u]=n,a=0;if(o.some(e=>0!==D[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(D,t)&&D[t]&&D[t][0](),D[t]=0},(L=self.rspackChunkcodebind_jupyterlab=self.rspackChunkcodebind_jupyterlab||[]).forEach(_.bind(null,0)),L.push=_.bind(null,L.push.bind(L));var F=z(457);(_JUPYTERLAB=void 0===_JUPYTERLAB?{}:_JUPYTERLAB)["codebind-jupyterlab"]=F})();
|