Skip to content

Commit 2ce4c7e

Browse files
Templates: add invocation_id to browser creation; upgrade templates to Kernel SDK 0.35.0 (#116)
### Summary - Pass **invocation_id** into browser creation for Yutori, Gemini, OpenAGI, and Anthropic computer-use templates so the dashboard can link browser sessions to invocations. - **Upgrade templates to Kernel SDK 0.35.0** for those same templates. ### Changes **1. Invocation ID (4 commits)** - **Yutori** (TS + Python): `SessionOptions` / session options include `invocation_id`; `browsers.create()` and action handlers receive it from `ctx.invocation_id`. - **Gemini** (TS + Python): Same pattern. - **OpenAGI** (Python only): `kernel_session` and both actions pass `invocation_id` into browser creation. - **Anthropic** (TS + Python): Same pattern as Yutori/Gemini. **2. SDK upgrade (1 commit)** - **Upgrade templates to Kernel SDK 0.35.0**: TypeScript templates use `@onkernel/sdk@^0.35.0`, Python templates use `kernel>=0.35.0` (yutori, gemini, anthropic, openagi computer-use). ### Templates touched - `pkg/templates/typescript/{yutori,gemini,anthropic}-computer-use/` - `pkg/templates/python/{yutori,gemini,anthropic,openagi}-computer-use/` ### QA - Created, deployed, and invoked all 7 apps; all invokes succeeded. Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Template-only changes that mostly thread through an extra optional parameter and bump SDK versions; risk is limited to potential runtime incompatibilities if consumers rely on older SDK behavior. > > **Overview** > Updates the Python and TypeScript computer-use templates (Anthropic, Gemini, Yutori, and OpenAGI) to pass `ctx.invocation_id` through their session helpers into `browsers.create(...)`, enabling browser sessions/replays to be linked back to the originating invocation. > > Bumps template dependencies to Kernel SDK `0.35.0` (`kernel>=0.35.0` and `@onkernel/sdk@^0.35.0`) and adjusts TypeScript session typing/nullable assignments to accommodate the newer SDK response shapes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit edf1d67. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6c922e1 commit 2ce4c7e

File tree

21 files changed

+63
-20
lines changed

21 files changed

+63
-20
lines changed

pkg/templates/python/anthropic-computer-use/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async def cua_task(
4848
record_replay = payload.get("record_replay", False)
4949

5050
async with KernelBrowserSession(
51+
invocation_id=ctx.invocation_id,
5152
stealth=True,
5253
record_replay=record_replay,
5354
) as session:

pkg/templates/python/anthropic-computer-use/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ dependencies = [
88
"python-dateutil>=2.9.0",
99
"pydantic>=2.12.5",
1010
"typing-extensions>=4.15.0",
11-
"kernel>=0.24.0",
11+
"kernel>=0.35.0",
1212
"python-dotenv>=1.2.1",
1313
]

pkg/templates/python/anthropic-computer-use/session.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class KernelBrowserSession:
3939
record_replay: bool = False
4040
replay_grace_period: float = 5.0 # Seconds to wait before stopping replay
4141

42+
# Invocation ID to link browser session to the action invocation
43+
invocation_id: Optional[str] = None
44+
4245
# Set after browser creation
4346
session_id: Optional[str] = field(default=None, init=False)
4447
live_view_url: Optional[str] = field(default=None, init=False)
@@ -52,6 +55,7 @@ async def __aenter__(self) -> "KernelBrowserSession":
5255

5356
# Create browser with specified settings
5457
browser = self._kernel.browsers.create(
58+
invocation_id=self.invocation_id,
5559
stealth=self.stealth,
5660
timeout_seconds=self.timeout_seconds,
5761
viewport={

pkg/templates/python/gemini-computer-use/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async def cua_task(
5252
record_replay = payload.get("record_replay", False)
5353

5454
async with KernelBrowserSession(
55+
invocation_id=ctx.invocation_id,
5556
stealth=True,
5657
record_replay=record_replay,
5758
) as session:

pkg/templates/python/gemini-computer-use/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = "README.md"
66
requires-python = ">=3.11"
77
dependencies = [
88
"google-genai>=1.0.0",
9-
"kernel>=0.5.0",
9+
"kernel>=0.35.0",
1010
]
1111

1212
[tool.uv]

pkg/templates/python/gemini-computer-use/session.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class KernelBrowserSession:
2323
record_replay: bool = False
2424
replay_grace_period: float = 5.0 # Seconds to wait before stopping replay
2525

26+
# Invocation ID to link browser session to the action invocation
27+
invocation_id: Optional[str] = None
28+
2629
# Set after browser creation
2730
session_id: Optional[str] = field(default=None, init=False)
2831
live_view_url: Optional[str] = field(default=None, init=False)
@@ -35,6 +38,7 @@ async def __aenter__(self) -> "KernelBrowserSession":
3538

3639
# Create browser with specified settings
3740
browser = self._kernel.browsers.create(
41+
invocation_id=self.invocation_id,
3842
stealth=self.stealth,
3943
timeout_seconds=self.timeout_seconds,
4044
viewport={

pkg/templates/python/openagi-computer-use/kernel_session.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class KernelBrowserSession:
3535
replay_framerate: int = 30
3636
replay_grace_period: float = 5.0 # Seconds to wait before stopping replay
3737

38+
# Invocation ID to link browser session to the action invocation
39+
invocation_id: str | None = None
40+
3841
# Set after browser creation
3942
session_id: str | None = None
4043
live_view_url: str | None = None
@@ -48,6 +51,7 @@ async def __aenter__(self) -> "KernelBrowserSession":
4851

4952
# Create browser with specified settings
5053
browser = self._kernel.browsers.create(
54+
invocation_id=self.invocation_id,
5155
stealth=self.stealth,
5256
timeout_seconds=self.timeout_seconds,
5357
)

pkg/templates/python/openagi-computer-use/main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ async def oagi_default_task(
103103
model = payload.get("model", "lux-actor-1")
104104
record_replay = payload.get("record_replay", False)
105105

106-
async with KernelBrowserSession(record_replay=record_replay) as session:
106+
async with KernelBrowserSession(
107+
record_replay=record_replay,
108+
invocation_id=ctx.invocation_id,
109+
) as session:
107110
print("Kernel browser live view url:", session.live_view_url)
108111

109112
provider = KernelScreenshotProvider(session)
@@ -155,7 +158,10 @@ async def oagi_tasker_task(
155158
todos = payload["todos"]
156159
record_replay = payload.get("record_replay", False)
157160

158-
async with KernelBrowserSession(record_replay=record_replay) as session:
161+
async with KernelBrowserSession(
162+
record_replay=record_replay,
163+
invocation_id=ctx.invocation_id,
164+
) as session:
159165
print("Kernel browser live view url:", session.live_view_url)
160166

161167
provider = KernelScreenshotProvider(session)

pkg/templates/python/openagi-computer-use/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Kernel sample app for OpenAGI Lux computer-use models"
55
readme = "README.md"
66
requires-python = ">=3.11"
77
dependencies = [
8-
"kernel>=0.22.0",
8+
"kernel>=0.35.0",
99
"oagi>=0.1.0",
1010
"python-dotenv>=1.0.0",
1111
"Pillow>=10.0.0",

pkg/templates/python/yutori-computer-use/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async def cua_task(
5050
kiosk_mode = payload.get("kiosk", False)
5151

5252
async with KernelBrowserSession(
53+
invocation_id=ctx.invocation_id,
5354
stealth=True,
5455
record_replay=record_replay,
5556
kiosk_mode=kiosk_mode,

0 commit comments

Comments
 (0)