chore: import upstream snapshot with attribution
Integ / changes (push) Has been skipped
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
Test (Python) / changes (push) Has been skipped
Test (TypeScript) / changes (push) Has been skipped
CLI exit codes / cli-gate (push) Has been cancelled
Test (Install) / test-install-gate (push) Has been cancelled
Integ / integ-gate (push) Has been cancelled
Test (Python) / test-python-gate (push) Has been cancelled
Test (TypeScript) / test-typescript-gate (push) Has been cancelled
Test (Install) / python-minimal (3.12) (push) Has been cancelled
Test (Install) / python-minimal (3.11) (push) Has been cancelled
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Has been cancelled
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Has been cancelled
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Has been cancelled
Integ / integ (push) Has been cancelled
Integ / integ-database (push) Has been cancelled
Integ / integ-database-ts (push) Has been cancelled
Integ / integ-data (push) Has been cancelled
Integ / integ-ssh (push) Has been cancelled
Integ / integ-ssh-ts (push) Has been cancelled
Test (Python) / audit (push) Has been cancelled
Test (TypeScript) / test (push) Has been cancelled
Test (TypeScript) / python-fs-shim (push) Has been cancelled
CLI exit codes / Python CLI (push) Has been cancelled
CLI exit codes / TypeScript CLI (push) Has been cancelled
CLI exit codes / Cross-language snapshot interop (push) Has been cancelled
Test (Python) / test (push) Has been cancelled
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Integ / integ-ts (push) Has been cancelled
Integ / integ-fuse (push) Has been cancelled
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Has been cancelled
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Has been cancelled
Test (Install) / python-extra (email, mirage.resource.email) (push) Has been cancelled
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Has been cancelled
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Has been cancelled
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Has been cancelled
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Has been cancelled
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Has been cancelled
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Has been cancelled
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Has been cancelled
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Has been cancelled
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Has been cancelled
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Has been cancelled
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Has been cancelled
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Has been cancelled
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Has been cancelled
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Has been cancelled
Test (Install) / ts-minimal (push) Has been cancelled
Integ / changes (push) Has been skipped
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
Test (Python) / changes (push) Has been skipped
Test (TypeScript) / changes (push) Has been skipped
CLI exit codes / cli-gate (push) Has been cancelled
Test (Install) / test-install-gate (push) Has been cancelled
Integ / integ-gate (push) Has been cancelled
Test (Python) / test-python-gate (push) Has been cancelled
Test (TypeScript) / test-typescript-gate (push) Has been cancelled
Test (Install) / python-minimal (3.12) (push) Has been cancelled
Test (Install) / python-minimal (3.11) (push) Has been cancelled
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Has been cancelled
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Has been cancelled
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Has been cancelled
Integ / integ (push) Has been cancelled
Integ / integ-database (push) Has been cancelled
Integ / integ-database-ts (push) Has been cancelled
Integ / integ-data (push) Has been cancelled
Integ / integ-ssh (push) Has been cancelled
Integ / integ-ssh-ts (push) Has been cancelled
Test (Python) / audit (push) Has been cancelled
Test (TypeScript) / test (push) Has been cancelled
Test (TypeScript) / python-fs-shim (push) Has been cancelled
CLI exit codes / Python CLI (push) Has been cancelled
CLI exit codes / TypeScript CLI (push) Has been cancelled
CLI exit codes / Cross-language snapshot interop (push) Has been cancelled
Test (Python) / test (push) Has been cancelled
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Integ / integ-ts (push) Has been cancelled
Integ / integ-fuse (push) Has been cancelled
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Has been cancelled
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Has been cancelled
Test (Install) / python-extra (email, mirage.resource.email) (push) Has been cancelled
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Has been cancelled
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Has been cancelled
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Has been cancelled
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Has been cancelled
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Has been cancelled
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Has been cancelled
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Has been cancelled
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Has been cancelled
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Has been cancelled
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Has been cancelled
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Has been cancelled
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Has been cancelled
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Has been cancelled
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Has been cancelled
Test (Install) / ts-minimal (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,351 @@
|
||||
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
|
||||
|
||||
from mirage.accessor.trello import TrelloAccessor
|
||||
from mirage.cache.index import IndexCacheStore, IndexEntry
|
||||
from mirage.core.trello._client import (list_board_labels, list_board_lists,
|
||||
list_board_members, list_list_cards,
|
||||
list_workspace_boards, list_workspaces)
|
||||
from mirage.core.trello.pathing import (board_dirname, card_dirname,
|
||||
label_filename, list_dirname,
|
||||
member_filename, workspace_dirname)
|
||||
from mirage.types import PathSpec
|
||||
from mirage.utils.errors import enoent
|
||||
from mirage.utils.key_prefix import mount_key, mount_prefix_of
|
||||
|
||||
VIRTUAL_ROOTS = ("workspaces", )
|
||||
|
||||
|
||||
async def readdir(
|
||||
accessor: TrelloAccessor,
|
||||
path: PathSpec,
|
||||
index: IndexCacheStore = None,
|
||||
) -> list[str]:
|
||||
if isinstance(path, str):
|
||||
path = PathSpec(virtual=path,
|
||||
directory=path,
|
||||
resource_path=path.strip("/"))
|
||||
virtual = path.virtual
|
||||
prefix = mount_prefix_of(path.virtual, path.resource_path)
|
||||
path = (path.dir if path.pattern else path).mount_path
|
||||
key = path.strip("/")
|
||||
idx_key = "/" + key if key else "/"
|
||||
|
||||
if not key:
|
||||
return [f"{prefix}/workspaces"]
|
||||
|
||||
if key == "workspaces":
|
||||
if index is not None:
|
||||
listing = await index.list_dir(idx_key)
|
||||
if listing.entries is not None:
|
||||
return [f"{prefix}{entry}" for entry in listing.entries]
|
||||
workspaces = await list_workspaces(accessor.config)
|
||||
if accessor.config.workspace_id:
|
||||
workspaces = [
|
||||
w for w in workspaces
|
||||
if w.get("id") == accessor.config.workspace_id
|
||||
]
|
||||
entries = []
|
||||
for ws in workspaces:
|
||||
dirname = workspace_dirname(ws)
|
||||
entry = IndexEntry(
|
||||
id=ws["id"],
|
||||
name=ws.get("displayName") or ws.get("name") or ws["id"],
|
||||
resource_type="trello/workspace",
|
||||
remote_time="",
|
||||
vfs_name=dirname,
|
||||
)
|
||||
entries.append((dirname, entry))
|
||||
if index is not None:
|
||||
await index.set_dir(idx_key, entries)
|
||||
return [f"{prefix}/workspaces/{name}" for name, _ in entries]
|
||||
|
||||
parts = key.split("/")
|
||||
|
||||
if len(parts) == 2 and parts[0] == "workspaces":
|
||||
if index is not None:
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/workspaces",
|
||||
directory=prefix + "/workspaces",
|
||||
resource_path=mount_key(prefix + "/workspaces", prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
return [
|
||||
f"{prefix}/{key}/workspace.json",
|
||||
f"{prefix}/{key}/boards",
|
||||
]
|
||||
|
||||
if len(parts) == 3 and parts[0] == "workspaces" and parts[2] == "boards":
|
||||
ws_vkey = "/" + "/".join(parts[:2])
|
||||
if index is not None:
|
||||
result = await index.get(ws_vkey)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/workspaces",
|
||||
directory=prefix + "/workspaces",
|
||||
resource_path=mount_key(prefix + "/workspaces", prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(ws_vkey)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
ws_id = result.entry.id
|
||||
listing = await index.list_dir(idx_key)
|
||||
if listing.entries is not None:
|
||||
return [f"{prefix}{entry}" for entry in listing.entries]
|
||||
else:
|
||||
raise enoent(virtual)
|
||||
boards = await list_workspace_boards(accessor.config, ws_id)
|
||||
if accessor.config.board_ids:
|
||||
boards = [
|
||||
b for b in boards if b.get("id") in accessor.config.board_ids
|
||||
]
|
||||
entries = []
|
||||
for board in boards:
|
||||
dirname = board_dirname(board)
|
||||
entries.append((
|
||||
dirname,
|
||||
IndexEntry(
|
||||
id=board["id"],
|
||||
name=board.get("name") or board["id"],
|
||||
resource_type="trello/board",
|
||||
remote_time=board.get("dateLastActivity") or "",
|
||||
vfs_name=dirname,
|
||||
),
|
||||
))
|
||||
await index.set_dir(idx_key, entries)
|
||||
return [f"{prefix}/{key}/{name}" for name, _ in entries]
|
||||
|
||||
if len(parts) == 4 and parts[0] == "workspaces" and parts[2] == "boards":
|
||||
if index is not None:
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:3]),
|
||||
directory=prefix + "/" + "/".join(parts[:3]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:3]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
return [
|
||||
f"{prefix}/{key}/board.json",
|
||||
f"{prefix}/{key}/members",
|
||||
f"{prefix}/{key}/labels",
|
||||
f"{prefix}/{key}/lists",
|
||||
]
|
||||
|
||||
if (len(parts) == 5 and parts[0] == "workspaces" and parts[2] == "boards"
|
||||
and parts[4] == "members"):
|
||||
board_vkey = "/" + "/".join(parts[:4])
|
||||
if index is not None:
|
||||
result = await index.get(board_vkey)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:3]),
|
||||
directory=prefix + "/" + "/".join(parts[:3]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:3]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(board_vkey)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
board_id = result.entry.id
|
||||
listing = await index.list_dir(idx_key)
|
||||
if listing.entries is not None:
|
||||
return [f"{prefix}{entry}" for entry in listing.entries]
|
||||
else:
|
||||
raise enoent(virtual)
|
||||
members = await list_board_members(accessor.config, board_id)
|
||||
entries = []
|
||||
for member in members:
|
||||
filename = member_filename(member)
|
||||
entries.append((
|
||||
filename,
|
||||
IndexEntry(
|
||||
id=member["id"],
|
||||
name=member.get("fullName") or member.get("username")
|
||||
or member["id"],
|
||||
resource_type="trello/member",
|
||||
remote_time="",
|
||||
vfs_name=filename,
|
||||
),
|
||||
))
|
||||
await index.set_dir(idx_key, entries)
|
||||
return [f"{prefix}/{key}/{name}" for name, _ in entries]
|
||||
|
||||
if (len(parts) == 5 and parts[0] == "workspaces" and parts[2] == "boards"
|
||||
and parts[4] == "labels"):
|
||||
board_vkey = "/" + "/".join(parts[:4])
|
||||
if index is not None:
|
||||
result = await index.get(board_vkey)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:3]),
|
||||
directory=prefix + "/" + "/".join(parts[:3]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:3]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(board_vkey)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
board_id = result.entry.id
|
||||
listing = await index.list_dir(idx_key)
|
||||
if listing.entries is not None:
|
||||
return [f"{prefix}{entry}" for entry in listing.entries]
|
||||
else:
|
||||
raise enoent(virtual)
|
||||
labels = await list_board_labels(accessor.config, board_id)
|
||||
entries = []
|
||||
for label in labels:
|
||||
filename = label_filename(label)
|
||||
entries.append((
|
||||
filename,
|
||||
IndexEntry(
|
||||
id=label["id"],
|
||||
name=label.get("name") or label.get("color")
|
||||
or label["id"],
|
||||
resource_type="trello/label",
|
||||
remote_time="",
|
||||
vfs_name=filename,
|
||||
),
|
||||
))
|
||||
await index.set_dir(idx_key, entries)
|
||||
return [f"{prefix}/{key}/{name}" for name, _ in entries]
|
||||
|
||||
if (len(parts) == 5 and parts[0] == "workspaces" and parts[2] == "boards"
|
||||
and parts[4] == "lists"):
|
||||
board_vkey = "/" + "/".join(parts[:4])
|
||||
if index is not None:
|
||||
result = await index.get(board_vkey)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:3]),
|
||||
directory=prefix + "/" + "/".join(parts[:3]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:3]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(board_vkey)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
board_id = result.entry.id
|
||||
listing = await index.list_dir(idx_key)
|
||||
if listing.entries is not None:
|
||||
return [f"{prefix}{entry}" for entry in listing.entries]
|
||||
else:
|
||||
raise enoent(virtual)
|
||||
lists = await list_board_lists(accessor.config, board_id)
|
||||
entries = []
|
||||
for lst in lists:
|
||||
dirname = list_dirname(lst)
|
||||
entries.append((
|
||||
dirname,
|
||||
IndexEntry(
|
||||
id=lst["id"],
|
||||
name=lst.get("name") or lst["id"],
|
||||
resource_type="trello/list",
|
||||
remote_time="",
|
||||
vfs_name=dirname,
|
||||
),
|
||||
))
|
||||
await index.set_dir(idx_key, entries)
|
||||
return [f"{prefix}/{key}/{name}" for name, _ in entries]
|
||||
|
||||
if (len(parts) == 6 and parts[0] == "workspaces" and parts[2] == "boards"
|
||||
and parts[4] == "lists"):
|
||||
if index is not None:
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:5]),
|
||||
directory=prefix + "/" + "/".join(parts[:5]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:5]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
return [
|
||||
f"{prefix}/{key}/list.json",
|
||||
f"{prefix}/{key}/cards",
|
||||
]
|
||||
|
||||
if (len(parts) == 7 and parts[0] == "workspaces" and parts[2] == "boards"
|
||||
and parts[4] == "lists" and parts[6] == "cards"):
|
||||
list_vkey = "/" + "/".join(parts[:6])
|
||||
if index is not None:
|
||||
result = await index.get(list_vkey)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:5]),
|
||||
directory=prefix + "/" + "/".join(parts[:5]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:5]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(list_vkey)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
list_id = result.entry.id
|
||||
listing = await index.list_dir(idx_key)
|
||||
if listing.entries is not None:
|
||||
return [f"{prefix}{entry}" for entry in listing.entries]
|
||||
else:
|
||||
raise enoent(virtual)
|
||||
cards = await list_list_cards(accessor.config, list_id)
|
||||
entries = []
|
||||
for card in cards:
|
||||
dirname = card_dirname(card)
|
||||
entries.append((
|
||||
dirname,
|
||||
IndexEntry(
|
||||
id=card["id"],
|
||||
name=card.get("name") or card["id"],
|
||||
resource_type="trello/card",
|
||||
remote_time=card.get("dateLastActivity") or "",
|
||||
vfs_name=dirname,
|
||||
),
|
||||
))
|
||||
await index.set_dir(idx_key, entries)
|
||||
return [f"{prefix}/{key}/{name}" for name, _ in entries]
|
||||
|
||||
if (len(parts) == 8 and parts[0] == "workspaces" and parts[2] == "boards"
|
||||
and parts[4] == "lists" and parts[6] == "cards"):
|
||||
if index is not None:
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
parent = PathSpec(
|
||||
virtual=prefix + "/" + "/".join(parts[:7]),
|
||||
directory=prefix + "/" + "/".join(parts[:7]),
|
||||
resource_path=mount_key(prefix + "/" + "/".join(parts[:7]),
|
||||
prefix),
|
||||
)
|
||||
await readdir(accessor, parent, index)
|
||||
result = await index.get(idx_key)
|
||||
if result.entry is None:
|
||||
raise enoent(virtual)
|
||||
return [f"{prefix}/{key}/card.json", f"{prefix}/{key}/comments.jsonl"]
|
||||
|
||||
return []
|
||||
Reference in New Issue
Block a user