acontext 0.0.12__tar.gz → 0.0.14__tar.gz
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.
- {acontext-0.0.12 → acontext-0.0.14}/PKG-INFO +1 -1
- {acontext-0.0.12 → acontext-0.0.14}/pyproject.toml +1 -1
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/_constants.py +1 -1
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/agent/disk.py +71 -8
- {acontext-0.0.12 → acontext-0.0.14}/README.md +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/__init__.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/_utils.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/agent/__init__.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/agent/base.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/async_client.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/client.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/client_types.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/errors.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/messages.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/py.typed +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/__init__.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/async_blocks.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/async_disks.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/async_sessions.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/async_spaces.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/async_tools.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/blocks.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/disks.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/sessions.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/spaces.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/resources/tools.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/types/__init__.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/types/block.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/types/disk.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/types/session.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/types/space.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/types/tool.py +0 -0
- {acontext-0.0.12 → acontext-0.0.14}/src/acontext/uploads.py +0 -0
|
@@ -261,15 +261,71 @@ class ListTool(BaseTool):
|
|
|
261
261
|
if not artifacts_list and not result.directories:
|
|
262
262
|
return f"No files or directories found in '{normalized_path}'"
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
output_parts.append(f"Directories: {', '.join(result.directories)}")
|
|
269
|
-
|
|
270
|
-
ls_sect = "\n".join(output_parts)
|
|
264
|
+
file_sect = "\n".join(artifacts_list) or "[NO FILE]"
|
|
265
|
+
dir_sect = (
|
|
266
|
+
"\n".join([d.rstrip("/") + "/" for d in result.directories]) or "[NO DIR]"
|
|
267
|
+
)
|
|
271
268
|
return f"""[Listing in {normalized_path}]
|
|
272
|
-
|
|
269
|
+
Directories:
|
|
270
|
+
{dir_sect}
|
|
271
|
+
Files:
|
|
272
|
+
{file_sect}"""
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class DownloadFileTool(BaseTool):
|
|
276
|
+
"""Tool for getting a public download URL for a file on the Acontext disk."""
|
|
277
|
+
|
|
278
|
+
@property
|
|
279
|
+
def name(self) -> str:
|
|
280
|
+
return "download_file"
|
|
281
|
+
|
|
282
|
+
@property
|
|
283
|
+
def description(self) -> str:
|
|
284
|
+
return "Get a public URL to download a file. Returns a presigned URL that can be shared or used to access the file."
|
|
285
|
+
|
|
286
|
+
@property
|
|
287
|
+
def arguments(self) -> dict:
|
|
288
|
+
return {
|
|
289
|
+
"file_path": {
|
|
290
|
+
"type": "string",
|
|
291
|
+
"description": "Optional directory path where the file is located, e.g. '/notes/'. Defaults to root '/' if not specified.",
|
|
292
|
+
},
|
|
293
|
+
"filename": {
|
|
294
|
+
"type": "string",
|
|
295
|
+
"description": "Filename to get the download URL for.",
|
|
296
|
+
},
|
|
297
|
+
"expire": {
|
|
298
|
+
"type": "integer",
|
|
299
|
+
"description": "URL expiration time in seconds. Defaults to 3600 (1 hour).",
|
|
300
|
+
},
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@property
|
|
304
|
+
def required_arguments(self) -> list[str]:
|
|
305
|
+
return ["filename"]
|
|
306
|
+
|
|
307
|
+
def execute(self, ctx: DiskContext, llm_arguments: dict) -> str:
|
|
308
|
+
"""Get a public download URL for a file."""
|
|
309
|
+
filename = llm_arguments.get("filename")
|
|
310
|
+
file_path = llm_arguments.get("file_path")
|
|
311
|
+
expire = llm_arguments.get("expire", 3600)
|
|
312
|
+
|
|
313
|
+
if not filename:
|
|
314
|
+
raise ValueError("filename is required")
|
|
315
|
+
|
|
316
|
+
normalized_path = _normalize_path(file_path)
|
|
317
|
+
result = ctx.client.disks.artifacts.get(
|
|
318
|
+
ctx.disk_id,
|
|
319
|
+
file_path=normalized_path,
|
|
320
|
+
filename=filename,
|
|
321
|
+
with_public_url=True,
|
|
322
|
+
expire=expire,
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
if not result.public_url:
|
|
326
|
+
raise RuntimeError("Failed to get public URL: server did not return a URL.")
|
|
327
|
+
|
|
328
|
+
return f"Public download URL for '{normalized_path}{filename}' (expires in {expire}s):\n{result.public_url}"
|
|
273
329
|
|
|
274
330
|
|
|
275
331
|
class DiskToolPool(BaseToolPool):
|
|
@@ -284,6 +340,7 @@ DISK_TOOLS.add_tool(WriteFileTool())
|
|
|
284
340
|
DISK_TOOLS.add_tool(ReadFileTool())
|
|
285
341
|
DISK_TOOLS.add_tool(ReplaceStringTool())
|
|
286
342
|
DISK_TOOLS.add_tool(ListTool())
|
|
343
|
+
DISK_TOOLS.add_tool(DownloadFileTool())
|
|
287
344
|
|
|
288
345
|
|
|
289
346
|
if __name__ == "__main__":
|
|
@@ -323,3 +380,9 @@ if __name__ == "__main__":
|
|
|
323
380
|
ctx, "read_file", {"filename": "test.txt", "file_path": "/try/"}
|
|
324
381
|
)
|
|
325
382
|
print(r)
|
|
383
|
+
r = DISK_TOOLS.execute_tool(
|
|
384
|
+
ctx,
|
|
385
|
+
"download_file",
|
|
386
|
+
{"filename": "test.txt", "file_path": "/try/", "expire": 300},
|
|
387
|
+
)
|
|
388
|
+
print(r)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|