Skip to content

Commit d0e47ff

Browse files
kiberguscopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 928823128 Change-Id: Ieb09fc821092b4d8a626a2a9f54534a1edebaf4c
1 parent 9f39c9f commit d0e47ff

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

google/antigravity/connections/local/local_connection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ def normalize_wire_path(path: str) -> str:
230230
# urlparse("file:///abs/path").path == "/abs/path"
231231
# url2pathname converts URL path to platform-native path
232232
return urllib.request.url2pathname(parsed.path)
233+
if parsed.scheme == "cns":
234+
# urlparse("cns://el-d/home/user/...").netloc == "el-d"
235+
# urlparse("cns://el-d/home/user/...").path == "/home/user/..."
236+
# Convert to the canonical /cns/<cell>/... absolute path format.
237+
return "/cns/" + parsed.netloc + parsed.path
233238
return path
234239

235240

google/antigravity/connections/local/local_connection_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,31 @@ def test_step_from_dict_normalizes_file_uri_arguments(self):
13771377
"/dev/shm/workspace/foo.py",
13781378
)
13791379

1380+
def test_step_from_dict_normalizes_cns_uri_arguments(self):
1381+
"""Verifies that LocalConnectionStep.from_dict normalizes cns:// URIs.
1382+
1383+
Why: The CNS-backed filesystem uses cns:// URIs as path representations.
1384+
The workspace_only policy compares canonical_path against /cns/... paths
1385+
provided by the user, so cns:// must be translated to /cns/... for
1386+
policy matching to work correctly.
1387+
"""
1388+
step = local_connection.LocalConnectionStep.from_dict({
1389+
"step_index": 1,
1390+
"trajectory_id": "traj_1",
1391+
"state": "STATE_WAITING_FOR_USER",
1392+
"create_file": {"path": "cns://el-d/home/user/workspace/kittens.md"},
1393+
})
1394+
self.assertEqual(len(step.tool_calls), 1)
1395+
self.assertEqual(
1396+
step.tool_calls[0].args.get("path"),
1397+
"/cns/el-d/home/user/workspace/kittens.md",
1398+
)
1399+
self.assertNotIn("canonical_path", step.tool_calls[0].args)
1400+
self.assertEqual(
1401+
step.tool_calls[0].canonical_path,
1402+
"/cns/el-d/home/user/workspace/kittens.md",
1403+
)
1404+
13801405

13811406
class LocalConnectionToolCallNoRunnerTest(unittest.IsolatedAsyncioTestCase):
13821407
"""Tests for tool call handling when no ToolRunner is configured."""

0 commit comments

Comments
 (0)