@nteract/pi 0.1.8 → 0.2.0
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.
- package/extensions/repl.ts +45 -0
- package/package.json +5 -5
package/extensions/repl.ts
CHANGED
|
@@ -89,8 +89,29 @@ type QueuedExecution = {
|
|
|
89
89
|
executionId: string;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
+
type ExecutionViewSnapshot = {
|
|
93
|
+
execution_count: number | null;
|
|
94
|
+
status: string;
|
|
95
|
+
success: boolean | null;
|
|
96
|
+
output_ids: string[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type ExecutionViewChangeset = {
|
|
100
|
+
execution_upserts?: Array<[executionId: string, snapshot: ExecutionViewSnapshot]>;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
type SubscriptionLike = {
|
|
104
|
+
unsubscribe?: () => void;
|
|
105
|
+
dispose?: () => void;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type ObservableLike<T> = {
|
|
109
|
+
subscribe(next: (value: T) => void): SubscriptionLike;
|
|
110
|
+
};
|
|
111
|
+
|
|
92
112
|
type Session = {
|
|
93
113
|
readonly notebookId: string;
|
|
114
|
+
readonly executionViewChanges$?: ObservableLike<ExecutionViewChangeset>;
|
|
94
115
|
runCell(
|
|
95
116
|
source: string,
|
|
96
117
|
opts?: { timeoutMs?: number; cellType?: string; onUpdate?: (progress: CellResult) => void },
|
|
@@ -649,6 +670,27 @@ export default function nteractReplExtension(pi: ExtensionAPI) {
|
|
|
649
670
|
let session: Session | null = null;
|
|
650
671
|
let opening: Promise<Session> | null = null;
|
|
651
672
|
let nextExecCount: number | null = 1;
|
|
673
|
+
let executionViewSubscription: SubscriptionLike | null = null;
|
|
674
|
+
|
|
675
|
+
function disposeExecutionViewTracking(): void {
|
|
676
|
+
const sub = executionViewSubscription;
|
|
677
|
+
executionViewSubscription = null;
|
|
678
|
+
sub?.unsubscribe?.();
|
|
679
|
+
sub?.dispose?.();
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function trackExecutionView(sess: Session): void {
|
|
683
|
+
disposeExecutionViewTracking();
|
|
684
|
+
executionViewSubscription =
|
|
685
|
+
sess.executionViewChanges$?.subscribe((changeset) => {
|
|
686
|
+
for (const [, snapshot] of changeset.execution_upserts ?? []) {
|
|
687
|
+
const count = snapshot.execution_count;
|
|
688
|
+
if (typeof count === "number") {
|
|
689
|
+
nextExecCount = Math.max(nextExecCount ?? 1, count + 1);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}) ?? null;
|
|
693
|
+
}
|
|
652
694
|
|
|
653
695
|
async function addDependenciesAndSync(sess: Session, packages: string[]): Promise<void> {
|
|
654
696
|
const unique = Array.from(new Set(packages.map((pkg) => pkg.trim()).filter(Boolean)));
|
|
@@ -689,6 +731,7 @@ export default function nteractReplExtension(pi: ExtensionAPI) {
|
|
|
689
731
|
description: "pi Python REPL",
|
|
690
732
|
dependencies,
|
|
691
733
|
});
|
|
734
|
+
trackExecutionView(session);
|
|
692
735
|
return session;
|
|
693
736
|
})();
|
|
694
737
|
try {
|
|
@@ -951,6 +994,7 @@ export default function nteractReplExtension(pi: ExtensionAPI) {
|
|
|
951
994
|
const old = session;
|
|
952
995
|
session = null;
|
|
953
996
|
nextExecCount = 1;
|
|
997
|
+
disposeExecutionViewTracking();
|
|
954
998
|
if (old) {
|
|
955
999
|
try {
|
|
956
1000
|
if (old.shutdownNotebook) {
|
|
@@ -968,6 +1012,7 @@ export default function nteractReplExtension(pi: ExtensionAPI) {
|
|
|
968
1012
|
});
|
|
969
1013
|
|
|
970
1014
|
pi.on("session_shutdown", async () => {
|
|
1015
|
+
disposeExecutionViewTracking();
|
|
971
1016
|
if (session) {
|
|
972
1017
|
try {
|
|
973
1018
|
if (session.shutdownNotebook) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nteract/pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Persistent notebook-backed Python REPL for Pi coding agents. Stateful execution, hot dependency sync, zero cold starts.",
|
|
5
5
|
"author": "nteract contributors",
|
|
6
6
|
"icon": "icon.png",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"license": "BSD-3-Clause",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/nteract/
|
|
11
|
+
"url": "git+https://github.com/nteract/nteract.git",
|
|
12
12
|
"directory": "plugins/nteract/pi"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/nteract/
|
|
14
|
+
"homepage": "https://github.com/nteract/nteract/tree/main/plugins/nteract/pi#readme",
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/nteract/
|
|
16
|
+
"url": "https://github.com/nteract/nteract/issues"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"pi-package",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"extensions"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@runtimed/node": "0.
|
|
39
|
+
"@runtimed/node": "0.3.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@earendil-works/pi-ai": "*",
|