Skip to content

Commit 4227aa2

Browse files
Add stub python runtime agent package
1 parent 95edfc2 commit 4227aa2

File tree

7 files changed

+147
-3
lines changed

7 files changed

+147
-3
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020

2121
env:
2222
DENO_VERSION: v2.x
23-
BUILD_ORDER: '["schema","lib", "ai", "pyodide-runtime-agent"]'
23+
BUILD_ORDER: '["schema","lib", "ai", "pyodide-runtime-agent", "python-runtime-agent"]'
2424

2525
jobs:
2626
generate-build-order:

deno.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"./packages/ai",
44
"./packages/schema",
55
"./packages/lib",
6-
"./packages/pyodide-runtime-agent"
6+
"./packages/pyodide-runtime-agent",
7+
"./packages/python-runtime-agent"
78
],
89
"imports": {
910
"@runt/ai": "./packages/ai/mod.ts",
1011
"@runt/schema": "./packages/schema/mod.ts",
1112
"@runt/lib": "./packages/lib/mod.ts",
12-
"@runt/pyodide-runtime-agent": "./packages/pyodide-runtime-agent/src/mod.ts"
13+
"@runt/pyodide-runtime-agent": "./packages/pyodide-runtime-agent/src/mod.ts",
14+
"@runt/python-runtime-agent": "./packages/python-runtime-agent/mod.ts"
1315
},
1416
"lint": {
1517
"rules": {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# @runt/python-runtime-agent
2+
3+
Stub Python runtime agent for the Runt platform.
4+
5+
This package provides a placeholder `PythonRuntimeAgent` class that subclasses
6+
`RuntimeAgent` from `@runt/lib`.
7+
8+
## Usage
9+
10+
This package is a stub and does not implement any Python execution logic yet.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@runt/python-runtime-agent",
3+
"version": "0.0.1",
4+
"description": "Stub Python runtime agent for Runt platform.",
5+
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/runtimed/anode.git"
9+
},
10+
"exports": {
11+
".": "./mod.ts"
12+
},
13+
"imports": {
14+
"@runt/lib": "jsr:@runt/lib@^0.6.2",
15+
"@runt/schema": "jsr:@runt/schema@^0.6.2"
16+
},
17+
"tasks": {
18+
"test": "deno test --allow-all",
19+
"check": "deno check src/**/*.ts",
20+
"fmt": "deno fmt",
21+
"lint": "deno lint"
22+
},
23+
"compilerOptions": {
24+
"strict": true,
25+
"exactOptionalPropertyTypes": true,
26+
"noImplicitReturns": true,
27+
"noUncheckedIndexedAccess": true
28+
},
29+
"fmt": {
30+
"useTabs": false,
31+
"lineWidth": 80,
32+
"indentWidth": 2,
33+
"semiColons": true,
34+
"singleQuote": false,
35+
"proseWrap": "preserve"
36+
},
37+
"lint": {
38+
"rules": {
39+
"tags": ["recommended"]
40+
}
41+
},
42+
"publish": {
43+
"include": ["mod.ts", "src/", "README.md"],
44+
"exclude": ["**/*.test.ts", "**/test_*.ts"]
45+
}
46+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { PythonRuntimeAgent } from "./src/python-runtime-agent.ts";
2+
import { runner } from "@runt/lib";
3+
export { PythonRuntimeAgent };
4+
5+
if (import.meta.main) {
6+
const agent = new PythonRuntimeAgent();
7+
await runner(agent);
8+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
createRuntimeConfig,
3+
RuntimeAgent,
4+
type RuntimeConfig,
5+
} from "@runt/lib";
6+
7+
export class PythonRuntimeAgent extends RuntimeAgent {
8+
constructor(args: string[] = Deno.args) {
9+
let config: RuntimeConfig;
10+
try {
11+
config = createRuntimeConfig(args, {
12+
runtimeType: "python3",
13+
capabilities: {
14+
canExecuteCode: true,
15+
canExecuteSql: false,
16+
canExecuteAi: false,
17+
availableAiModels: [],
18+
},
19+
});
20+
} catch (error) {
21+
// Configuration errors should still go to console for CLI usability
22+
console.error("❌ Configuration Error:");
23+
console.error(error instanceof Error ? error.message : String(error));
24+
console.error("\nExample usage:");
25+
console.error(
26+
' deno run --allow-all "jsr:@runt/python-runtime-agent" --notebook my-notebook --auth-token your-token',
27+
);
28+
console.error("\nOr set environment variables in .env:");
29+
console.error(" NOTEBOOK_ID=my-notebook");
30+
console.error(" AUTH_TOKEN=your-token");
31+
console.error("\nOr install globally:");
32+
console.error(
33+
" deno install -gf --allow-all jsr:@runt/python-runtime-agent",
34+
);
35+
console.error(" pyrunt --notebook my-notebook --auth-token your-token");
36+
Deno.exit(1);
37+
}
38+
39+
super(config, config.capabilities, {});
40+
}
41+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Simple Integration Test for PythonRuntimeAgent
2+
3+
import { assertEquals, assertExists } from "jsr:@std/assert";
4+
import { PythonRuntimeAgent } from "../src/python-runtime-agent.ts";
5+
6+
Deno.test("PythonRuntimeAgent - Basic Functionality (Stub)", async (t) => {
7+
const env = {
8+
RUNTIME_ID: "test-runtime",
9+
NOTEBOOK_ID: "test-notebook",
10+
AUTH_TOKEN: "test-token",
11+
};
12+
for (const [k, v] of Object.entries(env)) {
13+
Deno.env.set(k, v);
14+
}
15+
try {
16+
await t.step("can be constructed with minimal args", () => {
17+
const agent = new PythonRuntimeAgent([]);
18+
assertExists(agent);
19+
});
20+
21+
await t.step("exposes required methods (stub)", () => {
22+
const agent = new PythonRuntimeAgent([]);
23+
assertEquals(typeof agent.start, "function");
24+
assertEquals(typeof agent.shutdown, "function");
25+
assertEquals(typeof agent.keepAlive, "function");
26+
});
27+
28+
await t.step("has a config property (stub)", () => {
29+
const agent = new PythonRuntimeAgent([]);
30+
assertExists(agent.config);
31+
});
32+
} finally {
33+
for (const k of Object.keys(env)) {
34+
Deno.env.delete(k);
35+
}
36+
}
37+
});

0 commit comments

Comments
 (0)