@palettelab/cli 0.3.75 → 0.3.77
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.
- package/README.md +37 -5
- package/backend-sdk/palette_sdk/__init__.py +1 -1
- package/backend-sdk/palette_sdk/agent_routes.py +28 -2
- package/backend-sdk/palette_sdk/apps.py +16 -1
- package/backend-sdk/palette_sdk/connections_generated.py +27 -0
- package/backend-sdk/palette_sdk/data_rooms.py +59 -0
- package/backend-sdk/palette_sdk/manifest.py +10 -0
- package/backend-sdk/palette_sdk/mcp.py +11 -2
- package/backend-sdk/palette_sdk/platform_services.py +81 -15
- package/backend-sdk/palette_sdk/tool_definition.py +21 -1
- package/backend-sdk/pyproject.toml +1 -1
- package/docs/connectors.md +154 -0
- package/docs/python-backend-sdk.md +113 -4
- package/lib/bundler.js +5 -2
- package/lib/cli.js +2 -2
- package/lib/commands/capabilities.js +30 -9
- package/lib/commands/check.js +7 -0
- package/lib/commands/package.js +5 -1
- package/lib/commands/publish.js +17 -0
- package/lib/commands/test.js +15 -3
- package/lib/connection-catalog.json +167 -0
- package/lib/connector.js +148 -0
- package/lib/manifest.js +22 -1
- package/package.json +1 -1
- package/template-fallback/backend/api/main.py +4 -2
- package/template-fallback/backend/tools/example_tool.py +4 -0
- package/template-fallback/package.json +1 -1
- package/template-fallback/palette-plugin.json +4 -0
- package/template-fallback/templates/agent-tool/README.md +3 -0
- package/template-fallback/templates/agent-tool/palette-plugin.json +4 -0
- package/template-fallback/templates/agent-tool/skills/echo-check/SKILL.md +15 -0
- package/template-fallback/templates/consumer-app/backend/api/main.py +3 -2
- package/template-fallback/templates/consumer-app/package.json +1 -1
- package/template-fallback/templates/consumer-app/palette-plugin.json +4 -0
- package/template-fallback/templates/dashboard/backend/api/main.py +2 -2
- package/template-fallback/templates/dashboard/package.json +1 -1
- package/template-fallback/templates/dashboard/palette-plugin.json +4 -0
- package/template-fallback/templates/database/backend/api/main.py +3 -3
- package/template-fallback/templates/database/package.json +1 -1
- package/template-fallback/templates/database/palette-plugin.json +4 -0
- package/template-fallback/templates/external-service/backend/api/main.py +3 -2
- package/template-fallback/templates/external-service/package.json +1 -1
- package/template-fallback/templates/external-service/palette-plugin.json +4 -0
- package/template-fallback/templates/frontend-only/package.json +1 -1
- package/template-fallback/templates/frontend-only/palette-plugin.json +4 -0
- package/template-fallback/templates/next/package.json +1 -1
- package/template-fallback/templates/next/palette-plugin.json +4 -0
- package/template-fallback/templates/palette-app/backend/api/main.py +2 -2
- package/template-fallback/templates/palette-app/package.json +1 -1
- package/template-fallback/templates/palette-app/palette-plugin.json +4 -0
- package/template-fallback/templates/provider-app/backend/api/main.py +2 -2
- package/template-fallback/templates/provider-app/package.json +1 -1
- package/template-fallback/templates/provider-app/palette-plugin.json +5 -0
package/README.md
CHANGED
|
@@ -325,7 +325,7 @@ Backend SDK features for app-owned data:
|
|
|
325
325
|
- `ctx.storage` gives app/org-scoped file upload helpers when `"storage"` is declared in `platform_services`.
|
|
326
326
|
- `ctx.llm` gives chat, streaming, embeddings and image generation on the PLATFORM's own provider keys when `"llm"` is declared — no `OPENAI_API_KEY` secret to ship or rotate. An app picks any model the workspace's own chat offers with `model=` — Palette's own models and the latest Claude, GPT and Gemini models, premium ones included, no declaration — and nothing bypasses the workspace's SECURE policy. `fallback=False` runs exactly the requested model or raises `ModelUnavailable`; every reply reports the model that actually ran. Tool calls (`tools=`, `tool_calls`, `reply["message"]` for the history) are supported. Calls spend the workspace's credits under its plan, seat and member limits, and are refused (the billing `CreditError`) when the workspace could not start a chat turn either.
|
|
327
327
|
- `ctx.llm` also takes generation keywords (`response_format`, `top_p`, `stop`, `seed`, `reasoning_effort`, `top_k`, `thinking`, …) as plain keywords, each sent to the providers that take it (endpoint, credential and transport keywords such as `base_url` or `api_key` raise `ValueError`; any other keyword is ignored with a warning), and reports `ctx.llm.catalog()` (models with limits and unavailable reasons), `ctx.llm.models()` and `ctx.llm.spend()` so an app can offer a real model picker and explain a refusal.
|
|
328
|
-
- `ctx.media` gives fal.ai on the PLATFORM's key when `"media"` is declared — no `FAL_KEY` secret to ship or rotate. `ctx.media.run(model, payload)` reaches ANY fal model with the payload passed through untouched (so a model fal shipped today needs no SDK release); `image`, `video`, `speech` and `transcribe` are the same call with a default model filled in, `submit`/`status`/`result`/`cancel` handle multi-minute renders through a durable handle (`MediaStillRunning.handle`), `upload` puts bytes, public URLs or the app's own `ctx.storage` files on fal's CDN, `catalog()` lists the fal models it can run, and `save` copies an output into the app's own storage — fal's URLs expire. It spends the workspace's credits like `ctx.llm`.
|
|
328
|
+
- `ctx.media` gives fal.ai on the PLATFORM's key when `"media"` is declared — no `FAL_KEY` secret to ship or rotate. `ctx.media.run(model, payload)` reaches ANY fal model with the payload passed through untouched (so a model fal shipped today needs no SDK release); `image`, `video`, `speech` and `transcribe` are the same call with a default model filled in, `submit`/`status`/`result`/`cancel` handle multi-minute renders through a durable handle (`MediaStillRunning.handle`), `run(model, payload, sync=True)` asks fal's synchronous endpoint for models that answer in a second or two (SAM on a click: no queue, no polls), fal's refusals carry `status_code` (`ValueError` for 4xx, `PlatformServiceUnavailable` for 5xx), `upload` puts bytes, public URLs or the app's own `ctx.storage` files on fal's CDN, `catalog()` lists the fal models it can run, and `save` copies an output into the app's own storage — fal's URLs expire. It spends the workspace's credits like `ctx.llm`.
|
|
329
329
|
- `ctx.web` gives web search and an SSRF-guarded page reader (HTML tables and PDFs handled) when `"web"` is declared. `ctx.web.fetch(url, render=True)` loads the page in a browser first, for content its scripts build after it loads (a shop page's size table); it takes tens of seconds and `pltt dev` ignores the flag.
|
|
330
330
|
- `ctx.email.send(to, subject, html=..., text=..., cc=..., bcc=..., reply_to=..., from_name=..., attachments=[...], headers=..., tags=...)` sends email through the PLATFORM's email provider when `"email"` is declared — from the platform's sender address under the app's name, so no SendGrid key, SMTP login or verified domain to ship. Attachments are bytes or text with an optional `content_type`, and a `content_id` makes one inline for `<img src="cid:...">`. Up to 50 recipients and 10 MB per message, within a daily recipient allowance per workspace. `pltt dev` sends nothing: each message is checked with the hosted rules and saved to `.palette/dev-outbox/` as an `.eml` file.
|
|
331
331
|
- `pltt platform list` prints every service above with a snippet and its `pltt dev` mode; `pltt platform enable <name>` writes the manifest declaration.
|
|
@@ -338,8 +338,8 @@ Backend SDK features for app-owned data:
|
|
|
338
338
|
- `sign_webhook(...)` and `verify_webhook_signature(...)` handle HMAC-SHA256 webhook signing checks.
|
|
339
339
|
- `@capability(...)`, `CapabilityResult`, and `ArtifactRef` define typed,
|
|
340
340
|
broker-governed tools shared by chat agents and visual workflows.
|
|
341
|
-
- `ToolDefinition` is
|
|
342
|
-
migrate
|
|
341
|
+
- `ToolDefinition` is deprecated (it raises a `DeprecationWarning`) and kept for existing read-only tools;
|
|
342
|
+
migrate tools to `@capability(...)`.
|
|
343
343
|
- `PluginManifest` and `load_manifest(...)` parse and validate `palette-plugin.json`.
|
|
344
344
|
- `SuccessResponse`, `ErrorResponse`, and `PaginatedResponse` are reusable response schemas.
|
|
345
345
|
- `route_permission_issues(router, public_routes=None)` is the test helper for detecting ungated backend routes.
|
|
@@ -404,6 +404,32 @@ async def sync_invoices(ctx: PluginContext = Depends(get_plugin_context)):
|
|
|
404
404
|
return {"room": room, "folder": folder, "bytes": len(content or b"")}
|
|
405
405
|
```
|
|
406
406
|
|
|
407
|
+
To share a Drive file, folder or whole room with people outside the workspace,
|
|
408
|
+
create a link; the member making the request needs edit permission on the room
|
|
409
|
+
(or to own it). With no gate set, anyone holding the link opens it without
|
|
410
|
+
signing in to Palette:
|
|
411
|
+
|
|
412
|
+
```python
|
|
413
|
+
link = await ctx.data_rooms.create_link(
|
|
414
|
+
room["id"],
|
|
415
|
+
file_id=f["id"], # folder_id=... for a folder; neither for the whole room
|
|
416
|
+
verify_email=True, # a 6-digit code mailed to the viewer
|
|
417
|
+
allowed_viewers=["@acme.com"], # addresses or @domains
|
|
418
|
+
allow_download=False,
|
|
419
|
+
expires_at=datetime.now(timezone.utc) + timedelta(days=14),
|
|
420
|
+
)
|
|
421
|
+
share_url = link["url"]
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
The other gates are `require_login`, `require_email`, `password` and `agreement`
|
|
425
|
+
(an NDA to accept first), plus `name`, `notify_on_view`, `watermark` and
|
|
426
|
+
`screenshot_protection`. `list_links`, `update_link` (only the keys passed
|
|
427
|
+
change; `None` removes a password, agreement or expiry) and `delete_link` manage
|
|
428
|
+
the links; the frontend has `palette.dataRooms.createLink(roomId, { fileId,
|
|
429
|
+
verifyEmail: true, ... })`, `listLinks`, `updateLink` and `deleteLink`. See
|
|
430
|
+
[Share A File Or Folder Outside The Workspace](./docs/python-backend-sdk.md#share-a-file-or-folder-outside-the-workspace)
|
|
431
|
+
for every setting.
|
|
432
|
+
|
|
407
433
|
Storage upload responses include both snake_case and camelCase aliases for object metadata (`object_path`/`objectPath`, `file_url`/`fileUrl`, `content_type`/`contentType`) so local simulator and hosted OS responses can be consumed with the same app code.
|
|
408
434
|
|
|
409
435
|
App storage is different from Data Room uploads. Backend Python code uses
|
|
@@ -948,6 +974,8 @@ pltt check --json --files frontend/src/index.tsx backend/api/main.py
|
|
|
948
974
|
|
|
949
975
|
Each diagnostic has a stable `id` (`bundle.syntax`, `py.import`, `route.ungated`, `permission.unknown`, `migration.<code>`, ...), a `severity`, the `file`, `line` and `column` where the check knows them, the `message` and the `fix`. Each esbuild error becomes its own diagnostic, and a backend import failure points at the innermost frame inside the project. `--files` keeps the diagnostics about those files plus the project-wide ones. The command exits 1 on any error.
|
|
950
976
|
|
|
977
|
+
Connector findings are warnings with ids of their own: `connector.action_incomplete` (a legacy tool or a route with no description, input schema or risk), `connector.route_unmarked` (a route offered to assistants with no `agent_route` mark), `connector.skill_unknown_tool`, `connector.skill_invalid`, `connector.event_not_triggerable` (an event with no description or payload schema) and `deprecated.apps_call` (the path-style `ctx.apps.call(app_id, path)`). `connector.instructions_too_long` and an incomplete agent-exposed method are errors from the manifest validator.
|
|
978
|
+
|
|
951
979
|
### `pltt agent`
|
|
952
980
|
|
|
953
981
|
Drive the Palette Build Agent (the App Builder's coding agent) on the selected environment, with the publish token: change an app from CI, follow and steer a session from a terminal, or work with it from an ACP editor. `pltt agent help` lists every subcommand.
|
|
@@ -1070,7 +1098,7 @@ pltt package
|
|
|
1070
1098
|
pltt package --json
|
|
1071
1099
|
```
|
|
1072
1100
|
|
|
1073
|
-
Use this to inspect the publishable artifact before sending it to a Palette environment.
|
|
1101
|
+
Use this to inspect the publishable artifact before sending it to a Palette environment. The backend bundle carries `backend/`, `schemas/` and `skills/`; when the app has an `agent` block or skills, the command says they are reviewed by the store with the version (`pltt publish` says the same).
|
|
1074
1102
|
|
|
1075
1103
|
### `pltt publish`
|
|
1076
1104
|
|
|
@@ -1353,13 +1381,16 @@ pltt capabilities add mail.send --risk write --no-scheduling
|
|
|
1353
1381
|
|
|
1354
1382
|
Subcommands:
|
|
1355
1383
|
|
|
1356
|
-
- `list`:
|
|
1384
|
+
- `list`: the app as a connector, as an assistant will see it: the `agent` summary and instructions (or a note that the platform generates them from the description), the agent-exposable tools with their `capability_id`, risk and scheduling flag, the skills under `skills/`, and the events with whether each can start an agent run. `--json` adds `summary`, `instructions`, `skills` and `events` beside `capabilities`.
|
|
1357
1385
|
- `inspect <capability_id>`: the full manifest entry for one capability.
|
|
1358
1386
|
- `add <domain.resource.action>`: scaffolds a provider method (schemas + Python handler stub, like `pltt services scaffold`) and marks it agent-exposable. `--method <name>` overrides the derived method name, `--risk read|write|destructive|controlled` (default `read`), `--effects a,b` lists side effects. `write`/`destructive` capabilities must pass `--idempotent` to be schedulable, or `--no-scheduling` for interactive-only actions.
|
|
1359
1387
|
|
|
1360
1388
|
`pltt test` verifies every agent capability has a stable `capability_id` and a
|
|
1361
1389
|
matching `@capability(...)` / `service(..., agent_exposable=True)` handler.
|
|
1362
1390
|
|
|
1391
|
+
How assistants see and use your app (the `agent` block, capabilities, `agent_route` marks, skills and event
|
|
1392
|
+
triggers) is in [Your App As A Connector](./docs/connectors.md).
|
|
1393
|
+
|
|
1363
1394
|
## App CSS Isolation
|
|
1364
1395
|
|
|
1365
1396
|
The bundler scopes every stylesheet your frontend imports to your app's root
|
|
@@ -1395,6 +1426,7 @@ or another app.
|
|
|
1395
1426
|
|
|
1396
1427
|
- `bin/pltt.js` — entry point
|
|
1397
1428
|
- `backend-sdk/` — backend SDK files used by local contract tests and simulator
|
|
1429
|
+
- `docs/` — [Python Backend SDK Developer Guide](./docs/python-backend-sdk.md) and [Your App As A Connector](./docs/connectors.md)
|
|
1398
1430
|
- `lib/` — pure-Node command implementations (no runtime dependencies)
|
|
1399
1431
|
- `platform-dev/docker-compose.yml` — compose file for internal `pltt dev --platform` parity checks
|
|
1400
1432
|
- `template-fallback/` — offline fallback for `pltt init` if git is unavailable
|
|
@@ -18,6 +18,14 @@ on the route that reads it, with that route's own path parameters; your app gets
|
|
|
18
18
|
``platform.routePath`` (a ``?query`` arrives in the window's URL instead)::
|
|
19
19
|
|
|
20
20
|
@router.get("/notes/{note_id}", openapi_extra=agent_route("read", opens="/notes/{note_id}"))
|
|
21
|
+
|
|
22
|
+
A route is one of the tools of your app's connector. By default the tool is named after the route's
|
|
23
|
+
method and path, so it changes when the path does, and members' per-tool switches and permission
|
|
24
|
+
rules are keyed by that name. Give it a ``name`` of its own to keep it stable, and a ``description``
|
|
25
|
+
when the docstring is written for developers rather than for an assistant::
|
|
26
|
+
|
|
27
|
+
@router.post("/notes/search", openapi_extra=agent_route(
|
|
28
|
+
"read", name="search_notes", description="Search my notes by title and body."))
|
|
21
29
|
"""
|
|
22
30
|
|
|
23
31
|
from __future__ import annotations
|
|
@@ -27,11 +35,21 @@ from typing import Literal
|
|
|
27
35
|
|
|
28
36
|
AGENT_EXTRA = "x-palette-agent"
|
|
29
37
|
AGENT_OPEN = "x-palette-open"
|
|
38
|
+
AGENT_NAME = "x-palette-name"
|
|
39
|
+
AGENT_DESCRIPTION = "x-palette-description"
|
|
30
40
|
|
|
31
41
|
|
|
32
|
-
def agent_route(
|
|
42
|
+
def agent_route(
|
|
43
|
+
use: Literal["read", "write", "hidden"],
|
|
44
|
+
*,
|
|
45
|
+
opens: str | None = None,
|
|
46
|
+
name: str | None = None,
|
|
47
|
+
description: str | None = None,
|
|
48
|
+
) -> dict[str, str]:
|
|
33
49
|
"""``openapi_extra`` saying how the app's agent may use a route, and — on a route that reads one
|
|
34
|
-
item — where that item ``opens`` inside the app ("/notes/{note_id}" or "?note={note_id}").
|
|
50
|
+
item — where that item ``opens`` inside the app ("/notes/{note_id}" or "?note={note_id}").
|
|
51
|
+
``name`` is the tool's stable name (it no longer follows the path) and ``description`` what an
|
|
52
|
+
assistant reads to choose it (instead of the docstring)."""
|
|
35
53
|
if use not in ("read", "write", "hidden"):
|
|
36
54
|
raise ValueError("agent_route takes 'read', 'write' or 'hidden'")
|
|
37
55
|
extra = {AGENT_EXTRA: use}
|
|
@@ -40,4 +58,12 @@ def agent_route(use: Literal["read", "write", "hidden"], *, opens: str | None =
|
|
|
40
58
|
or ":" in opens.split("?")[0] or re.search(r"\s", opens)):
|
|
41
59
|
raise ValueError("opens is a path inside your app, like '/notes/{note_id}' or '?note={note_id}'")
|
|
42
60
|
extra[AGENT_OPEN] = opens
|
|
61
|
+
if name is not None:
|
|
62
|
+
if not isinstance(name, str) or not re.fullmatch(r"[a-z][a-z0-9_]{0,63}", name):
|
|
63
|
+
raise ValueError("name is a stable tool name: lowercase letters, digits and underscores, at most 64 characters")
|
|
64
|
+
extra[AGENT_NAME] = name
|
|
65
|
+
if description is not None:
|
|
66
|
+
if not isinstance(description, str) or not description.strip() or len(description) > 500:
|
|
67
|
+
raise ValueError("description is what an assistant reads to choose the tool: 1 to 500 characters")
|
|
68
|
+
extra[AGENT_DESCRIPTION] = description.strip()
|
|
43
69
|
return extra
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
"""App-to-app communication helpers.
|
|
1
|
+
"""App-to-app communication helpers.
|
|
2
|
+
|
|
3
|
+
Call another app through its typed contract: ``await services(ctx).call("namespace/version#method", payload)``,
|
|
4
|
+
with the target declared under ``consumes.services``. The path-style ``ctx.apps.call(app_id, path)`` reaches
|
|
5
|
+
any route of the other app and skips that contract; it is deprecated under ``DEPRECATION_POLICY.md`` and keeps
|
|
6
|
+
working until the next major release.
|
|
7
|
+
"""
|
|
2
8
|
|
|
3
9
|
from __future__ import annotations
|
|
4
10
|
|
|
11
|
+
import warnings
|
|
5
12
|
from typing import Any
|
|
6
13
|
|
|
7
14
|
|
|
@@ -55,6 +62,14 @@ class AppInteropClient:
|
|
|
55
62
|
json: Any = None,
|
|
56
63
|
timeout: float = 30.0,
|
|
57
64
|
) -> Any:
|
|
65
|
+
"""Deprecated: call a typed method with ``services(ctx).call("namespace/version#method", payload)``."""
|
|
66
|
+
warnings.warn(
|
|
67
|
+
"ctx.apps.call(app_id, path) is deprecated: call a typed method with "
|
|
68
|
+
'services(ctx).call("namespace/version#method", payload) and declare it under consumes.services. '
|
|
69
|
+
"It is removed in the next major release.",
|
|
70
|
+
DeprecationWarning,
|
|
71
|
+
stacklevel=2,
|
|
72
|
+
)
|
|
58
73
|
if self._adapter is None:
|
|
59
74
|
raise MissingAppServiceError("Palette app service helpers are not available in this runtime")
|
|
60
75
|
return await self._adapter.call(
|
|
@@ -50,6 +50,10 @@ class ConfluenceTools(_Namespace):
|
|
|
50
50
|
"""List Confluence spaces (id, key, name), optionally one space by key."""
|
|
51
51
|
return await self._call("atlassian", "confluence.list_spaces", {"limit": limit, "site": site, "space_key": space_key})
|
|
52
52
|
|
|
53
|
+
async def list_trash(self, *, limit: int | None = None, site: str | None = None, space_id: str | None = None, space_key: str | None = None) -> Any:
|
|
54
|
+
"""List deleted Confluence pages and blog posts still in the trash (whole site, or one space by key or id). Search never returns trashed content; use this to find deleted pages."""
|
|
55
|
+
return await self._call("atlassian", "confluence.list_trash", {"limit": limit, "site": site, "space_id": space_id, "space_key": space_key})
|
|
56
|
+
|
|
53
57
|
async def search(self, *, cql: str | None = None, limit: int | None = None, query: str | None = None, site: str | None = None, space_key: str | None = None) -> Any:
|
|
54
58
|
"""Search Confluence pages by text (optionally within a space) or with a raw CQL query."""
|
|
55
59
|
return await self._call("atlassian", "confluence.search", {"cql": cql, "limit": limit, "query": query, "site": site, "space_key": space_key})
|
|
@@ -170,6 +174,10 @@ class JiraTools(_Namespace):
|
|
|
170
174
|
"""Create a Jira issue (Task by default) with optional description, assignee, due date, priority, labels and parent."""
|
|
171
175
|
return await self._call("atlassian", "jira.create_issue", {"project_key": project_key, "summary": summary, "assignee_account_id": assignee_account_id, "description": description, "due_date": due_date, "issue_type": issue_type, "labels": labels, "parent_key": parent_key, "priority": priority, "site": site})
|
|
172
176
|
|
|
177
|
+
async def create_project(self, *, key: str, name: str, description: str | None = None, lead_account_id: str | None = None, site: str | None = None, template: str | None = None) -> Any:
|
|
178
|
+
"""Create a Jira project (needs the Jira admin permission). template: kanban (default), scrum, kanban-company, scrum-company, project-management, task-tracking, recruitment, procurement, process-control, lead-tracking, content-management, document-approval, it-service-management, or a full Jira template key. The lead defaults to the connected user."""
|
|
179
|
+
return await self._call("atlassian", "jira.create_project", {"key": key, "name": name, "description": description, "lead_account_id": lead_account_id, "site": site, "template": template})
|
|
180
|
+
|
|
173
181
|
async def get_issue(self, *, issue_key: str, comment_limit: int | None = None, include_comments: bool | None = None, site: str | None = None) -> Any:
|
|
174
182
|
"""Read one Jira issue: fields, plain-text description, parent/subtasks and recent comments."""
|
|
175
183
|
return await self._call("atlassian", "jira.get_issue", {"issue_key": issue_key, "comment_limit": comment_limit, "include_comments": include_comments, "site": site})
|
|
@@ -287,6 +295,24 @@ class NotionTools(_Namespace):
|
|
|
287
295
|
return await self._call("notion", "notion.update_page", {"command": command, "page_id": page_id, "allow_deleting_content": allow_deleting_content, "content": content, "content_updates": content_updates, "cover": cover, "icon": icon, "new_str": new_str, "position": position, "properties": properties, "template_id": template_id, "verification_expiry_days": verification_expiry_days, "verification_status": verification_status})
|
|
288
296
|
|
|
289
297
|
|
|
298
|
+
class RovoTools(_Namespace):
|
|
299
|
+
async def describe_tool(self, *, name: str) -> Any:
|
|
300
|
+
"""Read one Atlassian tool's full instructions and argument schema before calling it."""
|
|
301
|
+
return await self._call("rovo", "rovo.describe_tool", {"name": name})
|
|
302
|
+
|
|
303
|
+
async def execute(self, *, name: str, arguments: dict[str, Any] | None = None) -> Any:
|
|
304
|
+
"""Call an Atlassian tool that changes something: createJiraIssue, editJiraIssue, transitionJiraIssue, addOrEditJiraIssueComment, createConfluenceContent, updateConfluenceContent, createJsmRequest, createBitbucketRepoPullRequest … Most tools need a cloudId: get it first with rovo.query name=getAccessibleAtlassianResources. Staged for approval; Atlassian applies the user's own permissions."""
|
|
305
|
+
return await self._call("rovo", "rovo.execute", {"name": name, "arguments": arguments})
|
|
306
|
+
|
|
307
|
+
async def list_tools(self, *, limit: int | None = None, query: str | None = None) -> Any:
|
|
308
|
+
"""List the Atlassian tools this account can use (Jira, Confluence, Jira Service Management, Bitbucket, Loom, Goals, Projects, Teams, Assets …), filtered by keyword; each row says read or write."""
|
|
309
|
+
return await self._call("rovo", "rovo.list_tools", {"limit": limit, "query": query})
|
|
310
|
+
|
|
311
|
+
async def query(self, *, name: str, arguments: dict[str, Any] | None = None) -> Any:
|
|
312
|
+
"""Call a read-only Atlassian tool (atlassianUserInfo, getAccessibleAtlassianResources, getJiraIssue, searchJiraIssuesUsingJql, searchConfluence, getConfluenceContent, listBitbucketRepositories …). Most tools need a cloudId: get it first with rovo.query name=getAccessibleAtlassianResources. Refuses tools that change anything."""
|
|
313
|
+
return await self._call("rovo", "rovo.query", {"name": name, "arguments": arguments})
|
|
314
|
+
|
|
315
|
+
|
|
290
316
|
class SheetsTools(_Namespace):
|
|
291
317
|
async def append_row(self, *, range: str, spreadsheet_id: str, values: list[Any]) -> Any:
|
|
292
318
|
"""Append one row to a Google Sheet range. `values` is an array of cell values for the new row."""
|
|
@@ -512,6 +538,7 @@ NAMESPACES: dict[str, type[_Namespace]] = {
|
|
|
512
538
|
"jira": JiraTools,
|
|
513
539
|
"meta": MetaTools,
|
|
514
540
|
"notion": NotionTools,
|
|
541
|
+
"rovo": RovoTools,
|
|
515
542
|
"sheets": SheetsTools,
|
|
516
543
|
"slack": SlackTools,
|
|
517
544
|
"slides": SlidesTools,
|
|
@@ -137,3 +137,62 @@ class DataRoomsClient:
|
|
|
137
137
|
content_type=content_type,
|
|
138
138
|
**extra,
|
|
139
139
|
)
|
|
140
|
+
|
|
141
|
+
# External share links. Settings go to the platform exactly as given: it
|
|
142
|
+
# owns the defaults and refuses unknown keys and invalid values.
|
|
143
|
+
|
|
144
|
+
def _link_method(self, name: str) -> Any:
|
|
145
|
+
method = getattr(self._require_service(), name, None)
|
|
146
|
+
if method is None:
|
|
147
|
+
raise RuntimeError(
|
|
148
|
+
f"Drive share links need a newer Palette platform: this one has no data_rooms.{name}."
|
|
149
|
+
)
|
|
150
|
+
return method
|
|
151
|
+
|
|
152
|
+
async def list_links(
|
|
153
|
+
self,
|
|
154
|
+
room_id: int,
|
|
155
|
+
*,
|
|
156
|
+
file_id: int | None = None,
|
|
157
|
+
folder_id: int | None = None,
|
|
158
|
+
) -> list[dict[str, Any]]:
|
|
159
|
+
"""List the drive's external share links, newest first.
|
|
160
|
+
|
|
161
|
+
With ``file_id`` or ``folder_id`` only the links to that file or
|
|
162
|
+
folder are returned; with neither, every link in the drive. Needs edit
|
|
163
|
+
permission on the drive.
|
|
164
|
+
"""
|
|
165
|
+
return await self._link_method("list_links")(room_id, file_id=file_id, folder_id=folder_id)
|
|
166
|
+
|
|
167
|
+
async def create_link(
|
|
168
|
+
self,
|
|
169
|
+
room_id: int,
|
|
170
|
+
*,
|
|
171
|
+
file_id: int | None = None,
|
|
172
|
+
folder_id: int | None = None,
|
|
173
|
+
**settings: Any,
|
|
174
|
+
) -> dict[str, Any]:
|
|
175
|
+
"""Share a file, a folder or the whole drive with people outside the workspace.
|
|
176
|
+
|
|
177
|
+
Give ``file_id`` or ``folder_id``, or neither to share the whole
|
|
178
|
+
drive. The returned link's ``url`` is what you hand out. With no gate
|
|
179
|
+
set, anyone holding the link opens it without signing in to Palette.
|
|
180
|
+
The settings are ``name``, ``require_login``, ``require_email``,
|
|
181
|
+
``verify_email``, ``allowed_viewers``, ``password``,
|
|
182
|
+
``allow_download``, ``notify_on_view``, ``watermark``,
|
|
183
|
+
``screenshot_protection``, ``agreement`` and ``expires_at``. Needs
|
|
184
|
+
edit permission on the drive.
|
|
185
|
+
"""
|
|
186
|
+
return await self._link_method("create_link")(room_id, file_id=file_id, folder_id=folder_id, **settings)
|
|
187
|
+
|
|
188
|
+
async def update_link(self, room_id: int, link_id: int, **changes: Any) -> dict[str, Any]:
|
|
189
|
+
"""Change a link's settings: only the keys passed change.
|
|
190
|
+
|
|
191
|
+
``password``, ``agreement`` or ``expires_at`` set to ``None`` removes
|
|
192
|
+
it. A link's target cannot change; delete it and create another.
|
|
193
|
+
"""
|
|
194
|
+
return await self._link_method("update_link")(room_id, link_id, **changes)
|
|
195
|
+
|
|
196
|
+
async def delete_link(self, room_id: int, link_id: int) -> None:
|
|
197
|
+
"""Delete a link: it stops opening at once."""
|
|
198
|
+
await self._link_method("delete_link")(room_id, link_id)
|
|
@@ -321,6 +321,15 @@ class McpSpec(BaseModel):
|
|
|
321
321
|
exposes_to_external_clients: bool = False
|
|
322
322
|
|
|
323
323
|
|
|
324
|
+
class AgentText(BaseModel):
|
|
325
|
+
"""What the app says to assistants in its own words; reviewed at publish."""
|
|
326
|
+
|
|
327
|
+
model_config = ConfigDict(extra="forbid")
|
|
328
|
+
|
|
329
|
+
summary: str = Field(default="", max_length=160)
|
|
330
|
+
instructions: str = Field(default="", max_length=2000)
|
|
331
|
+
|
|
332
|
+
|
|
324
333
|
class PluginManifest(BaseModel):
|
|
325
334
|
"""Validated plugin manifest from palette-plugin.json."""
|
|
326
335
|
|
|
@@ -333,6 +342,7 @@ class PluginManifest(BaseModel):
|
|
|
333
342
|
category: str = "Other" # the store files an app with no registered category under Other
|
|
334
343
|
tagline: str = ""
|
|
335
344
|
description: str = ""
|
|
345
|
+
agent: AgentText | None = None
|
|
336
346
|
icon: str = "Puzzle"
|
|
337
347
|
gradient: GradientConfig = GradientConfig(bg="linear-gradient(135deg, #6366F1, #8B5CF6)")
|
|
338
348
|
sdk: SdkCompat | None = None
|
|
@@ -25,6 +25,10 @@ Targets use the OS qualified-name grammar: `mcp.{connector_slug}/v1#{tool}`
|
|
|
25
25
|
for org-configured external servers, `{app_namespace}/v1#{tool}` for tools
|
|
26
26
|
provided by other installed apps. Both must be declared in the manifest
|
|
27
27
|
(`mcp.consumes.tools` or `consumes.services`).
|
|
28
|
+
|
|
29
|
+
`@mcp_resource` and `@mcp_prompt` are inert: the platform records the declaration and serves neither.
|
|
30
|
+
An app reaches assistants as a connector, which carries tools, instructions (`agent` in the manifest)
|
|
31
|
+
and skills (`skills/<name>/SKILL.md`).
|
|
28
32
|
"""
|
|
29
33
|
|
|
30
34
|
from __future__ import annotations
|
|
@@ -98,7 +102,9 @@ def mcp_resource(
|
|
|
98
102
|
description: str | None = None,
|
|
99
103
|
mime_type: str | None = None,
|
|
100
104
|
) -> Callable[[ToolHandler], ToolHandler]:
|
|
101
|
-
"""Mark an async function as an MCP resource provider (read-only).
|
|
105
|
+
"""Mark an async function as an MCP resource provider (read-only).
|
|
106
|
+
|
|
107
|
+
Currently inert: the declaration is recorded and nothing serves it. Use a read tool instead."""
|
|
102
108
|
|
|
103
109
|
def decorator(fn: ToolHandler) -> ToolHandler:
|
|
104
110
|
_pending_resources.append(
|
|
@@ -121,7 +127,10 @@ def mcp_prompt(
|
|
|
121
127
|
description: str | None = None,
|
|
122
128
|
arguments: list[dict[str, Any]] | None = None,
|
|
123
129
|
) -> Callable[[ToolHandler], ToolHandler]:
|
|
124
|
-
"""Mark an async function as an MCP prompt provider.
|
|
130
|
+
"""Mark an async function as an MCP prompt provider.
|
|
131
|
+
|
|
132
|
+
Currently inert: the declaration is recorded and nothing serves it. Ship a skill
|
|
133
|
+
(`skills/<name>/SKILL.md`) or `agent.instructions` in the manifest instead."""
|
|
125
134
|
|
|
126
135
|
def decorator(fn: ToolHandler) -> ToolHandler:
|
|
127
136
|
_pending_prompts.append(
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
+
import functools
|
|
6
7
|
import hashlib
|
|
7
8
|
import json
|
|
8
9
|
import logging
|
|
@@ -1216,6 +1217,45 @@ _STUB_PNG = (
|
|
|
1216
1217
|
)
|
|
1217
1218
|
|
|
1218
1219
|
|
|
1220
|
+
def _hosted_error(exc: Exception) -> Exception | None:
|
|
1221
|
+
"""What hosted ctx.media raises for `exc`, or None to let `exc` go as it is. fal answering an HTTP error status
|
|
1222
|
+
is ValueError (4xx, with up to 300 characters of fal's answer) or PlatformServiceUnavailable (5xx), and both carry
|
|
1223
|
+
`status_code`, which tells "change the request" from "try again later"; an unreachable fal is
|
|
1224
|
+
PlatformServiceUnavailable."""
|
|
1225
|
+
httpx = sys.modules.get("httpx") # only a live call imports it, and only a live call raises its errors
|
|
1226
|
+
if httpx is None:
|
|
1227
|
+
return None
|
|
1228
|
+
if isinstance(exc, httpx.HTTPStatusError):
|
|
1229
|
+
status = exc.response.status_code
|
|
1230
|
+
said = f"ctx.media: fal answered HTTP {status}"
|
|
1231
|
+
if status >= 500:
|
|
1232
|
+
return PlatformServiceUnavailable(said, status_code=status)
|
|
1233
|
+
answer = exc.response.text[:300]
|
|
1234
|
+
refused = ValueError(f"{said}: {answer}" if answer else said)
|
|
1235
|
+
refused.status_code = status
|
|
1236
|
+
return refused
|
|
1237
|
+
if isinstance(exc, (httpx.ConnectError, httpx.ConnectTimeout, httpx.PoolTimeout)):
|
|
1238
|
+
return PlatformServiceUnavailable("ctx.media: fal could not be reached")
|
|
1239
|
+
return None
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
def _like_hosted(fn: Any) -> Any:
|
|
1243
|
+
"""A LocalMediaService call that fails the way the hosted one does (_hosted_error), so the app's `except` and
|
|
1244
|
+
its `status_code` checks behave the same under pltt dev."""
|
|
1245
|
+
|
|
1246
|
+
@functools.wraps(fn)
|
|
1247
|
+
async def call(*args: Any, **kwargs: Any) -> Any:
|
|
1248
|
+
try:
|
|
1249
|
+
return await fn(*args, **kwargs)
|
|
1250
|
+
except Exception as exc: # noqa: BLE001 — only fal's HTTP errors are translated
|
|
1251
|
+
hosted = _hosted_error(exc)
|
|
1252
|
+
if hosted is None:
|
|
1253
|
+
raise
|
|
1254
|
+
raise hosted from exc
|
|
1255
|
+
|
|
1256
|
+
return call
|
|
1257
|
+
|
|
1258
|
+
|
|
1219
1259
|
class LocalMediaService:
|
|
1220
1260
|
"""`ctx.media` for pltt dev — the same fal.ai surface as hosted.
|
|
1221
1261
|
|
|
@@ -1226,6 +1266,9 @@ class LocalMediaService:
|
|
|
1226
1266
|
"""
|
|
1227
1267
|
|
|
1228
1268
|
QUEUE_BASE = "https://queue.fal.run"
|
|
1269
|
+
# fal's synchronous endpoint, for run(sync=True): the answer comes back on the request itself.
|
|
1270
|
+
SYNC_BASE = "https://fal.run"
|
|
1271
|
+
SYNC_TIMEOUT_S = 60.0
|
|
1229
1272
|
# fal's own upload flow (fal-client "fal_v3"): trade the key for a CDN
|
|
1230
1273
|
# token, then POST the bytes. storage.fal.ai no longer resolves.
|
|
1231
1274
|
CDN_TOKEN_URL = "https://rest.fal.ai/storage/auth/token?storage_type=fal-cdn-v3"
|
|
@@ -1302,6 +1345,7 @@ class LocalMediaService:
|
|
|
1302
1345
|
"text": f"[pltt dev: no FAL_KEY] {payload.get('prompt') or payload.get('text') or ''}",
|
|
1303
1346
|
}
|
|
1304
1347
|
|
|
1348
|
+
@_like_hosted
|
|
1305
1349
|
async def submit(self, model: str, payload: dict[str, Any] | None = None, **fields: Any) -> dict[str, Any]:
|
|
1306
1350
|
"""Queue a job; returns the durable handle {request_id, model,
|
|
1307
1351
|
status_url, response_url, cancel_url}. A 429 is retried with backoff,
|
|
@@ -1312,12 +1356,30 @@ class LocalMediaService:
|
|
|
1312
1356
|
"request_id": "pltt-dev-stub", "model": model, "status_url": "", "response_url": "",
|
|
1313
1357
|
"cancel_url": "", "request": body,
|
|
1314
1358
|
}
|
|
1359
|
+
task = await self._start(self.QUEUE_BASE, model, body, 60.0)
|
|
1360
|
+
request_id = str(task.get("request_id") or "")
|
|
1361
|
+
rebuilt_status, rebuilt_response, rebuilt_cancel = self._queue_urls(model, request_id)
|
|
1362
|
+
provider_status = str(task.get("status_url") or "")
|
|
1363
|
+
provider_response = str(task.get("response_url") or "")
|
|
1364
|
+
provider_cancel = str(task.get("cancel_url") or "")
|
|
1365
|
+
return {
|
|
1366
|
+
"request_id": request_id,
|
|
1367
|
+
"model": model,
|
|
1368
|
+
"status_url": provider_status if self._fal_host_ok(provider_status) else rebuilt_status,
|
|
1369
|
+
"response_url": provider_response if self._fal_host_ok(provider_response) else rebuilt_response,
|
|
1370
|
+
"cancel_url": provider_cancel if self._fal_host_ok(provider_cancel) else rebuilt_cancel,
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
async def _start(self, base: str, model: str, body: dict[str, Any], timeout: float) -> dict[str, Any]:
|
|
1374
|
+
"""POST work to fal's queue or its synchronous endpoint (`base`), as hosted does: a 429 or a failed connect
|
|
1375
|
+
is retried with backoff, then MediaRateLimited; an answer lost after fal got the request is
|
|
1376
|
+
MediaSubmitInterrupted, never sent again."""
|
|
1315
1377
|
import httpx
|
|
1316
1378
|
|
|
1317
|
-
async with httpx.AsyncClient(timeout=
|
|
1379
|
+
async with httpx.AsyncClient(timeout=timeout, headers=self._headers()) as client:
|
|
1318
1380
|
for attempt in range(1, self.SUBMIT_ATTEMPTS + 1):
|
|
1319
1381
|
try:
|
|
1320
|
-
response = await client.post(f"{
|
|
1382
|
+
response = await client.post(f"{base}/{str(model).strip('/')}", json=body)
|
|
1321
1383
|
except (httpx.ConnectError, httpx.ConnectTimeout):
|
|
1322
1384
|
if attempt == self.SUBMIT_ATTEMPTS:
|
|
1323
1385
|
raise
|
|
@@ -1336,21 +1398,10 @@ class LocalMediaService:
|
|
|
1336
1398
|
)
|
|
1337
1399
|
await asyncio.sleep(self.RETRY_BASE_S * attempt)
|
|
1338
1400
|
response.raise_for_status()
|
|
1339
|
-
|
|
1340
|
-
request_id = str(task.get("request_id") or "")
|
|
1341
|
-
rebuilt_status, rebuilt_response, rebuilt_cancel = self._queue_urls(model, request_id)
|
|
1342
|
-
provider_status = str(task.get("status_url") or "")
|
|
1343
|
-
provider_response = str(task.get("response_url") or "")
|
|
1344
|
-
provider_cancel = str(task.get("cancel_url") or "")
|
|
1345
|
-
return {
|
|
1346
|
-
"request_id": request_id,
|
|
1347
|
-
"model": model,
|
|
1348
|
-
"status_url": provider_status if self._fal_host_ok(provider_status) else rebuilt_status,
|
|
1349
|
-
"response_url": provider_response if self._fal_host_ok(provider_response) else rebuilt_response,
|
|
1350
|
-
"cancel_url": provider_cancel if self._fal_host_ok(provider_cancel) else rebuilt_cancel,
|
|
1351
|
-
}
|
|
1401
|
+
return response.json() or {}
|
|
1352
1402
|
|
|
1353
1403
|
# `request_id=` is the keyword these took before SDK 0.1.16; still accepted.
|
|
1404
|
+
@_like_hosted
|
|
1354
1405
|
async def status(
|
|
1355
1406
|
self, request: Any = None, *, model: str | None = None, request_id: str | None = None, **params: Any
|
|
1356
1407
|
) -> dict[str, Any]:
|
|
@@ -1365,6 +1416,7 @@ class LocalMediaService:
|
|
|
1365
1416
|
response.raise_for_status()
|
|
1366
1417
|
return response.json() or {}
|
|
1367
1418
|
|
|
1419
|
+
@_like_hosted
|
|
1368
1420
|
async def result(self, request: Any = None, *, model: str | None = None, request_id: str | None = None) -> dict[str, Any]:
|
|
1369
1421
|
"""The finished output; an unfinished job raises MediaStillRunning."""
|
|
1370
1422
|
request_id, model = self._ref(request or request_id, model)
|
|
@@ -1381,6 +1433,7 @@ class LocalMediaService:
|
|
|
1381
1433
|
response.raise_for_status()
|
|
1382
1434
|
return response.json() or {}
|
|
1383
1435
|
|
|
1436
|
+
@_like_hosted
|
|
1384
1437
|
async def cancel(self, request: Any = None, *, model: str | None = None, request_id: str | None = None) -> dict[str, Any]:
|
|
1385
1438
|
if not self.live:
|
|
1386
1439
|
return {"cancelled": True, "pltt_dev_stub": True}
|
|
@@ -1392,6 +1445,7 @@ class LocalMediaService:
|
|
|
1392
1445
|
response = await client.put(cancel_url)
|
|
1393
1446
|
return {"cancelled": response.status_code < 400, "status_code": response.status_code}
|
|
1394
1447
|
|
|
1448
|
+
@_like_hosted
|
|
1395
1449
|
async def run(
|
|
1396
1450
|
self,
|
|
1397
1451
|
model: str,
|
|
@@ -1400,11 +1454,19 @@ class LocalMediaService:
|
|
|
1400
1454
|
timeout: float | None = None,
|
|
1401
1455
|
poll_interval: float | None = None,
|
|
1402
1456
|
on_status: Any = None,
|
|
1457
|
+
sync: bool = False,
|
|
1403
1458
|
**fields: Any,
|
|
1404
1459
|
) -> dict[str, Any]:
|
|
1460
|
+
"""Submit, poll to completion, return fal's JSON. `sync=True` is one request to fal's synchronous endpoint
|
|
1461
|
+
instead, for models that answer in a second or two (SAM): `timeout` (default 60 s) bounds it, and there is no
|
|
1462
|
+
handle to resume."""
|
|
1405
1463
|
body = self._merge(payload, fields)
|
|
1406
1464
|
if not self.live:
|
|
1407
1465
|
return self._stub(model, body)
|
|
1466
|
+
if sync:
|
|
1467
|
+
return await self._start(
|
|
1468
|
+
self.SYNC_BASE, model, body, float(timeout if timeout is not None else self.SYNC_TIMEOUT_S)
|
|
1469
|
+
)
|
|
1408
1470
|
import httpx
|
|
1409
1471
|
|
|
1410
1472
|
job = await self.submit(model, body)
|
|
@@ -1436,6 +1498,8 @@ class LocalMediaService:
|
|
|
1436
1498
|
raise MediaStillRunning(job["request_id"], model, **handle)
|
|
1437
1499
|
await asyncio.sleep(interval)
|
|
1438
1500
|
final = await client.get(job["response_url"])
|
|
1501
|
+
if final.status_code >= 500: # done and paid for: collect it later, as hosted
|
|
1502
|
+
raise MediaStillRunning(job["request_id"], model, **handle)
|
|
1439
1503
|
final.raise_for_status()
|
|
1440
1504
|
return final.json() or {}
|
|
1441
1505
|
|
|
@@ -1481,6 +1545,7 @@ class LocalMediaService:
|
|
|
1481
1545
|
fetched.raise_for_status()
|
|
1482
1546
|
return fetched.content, (fetched.headers.get("content-type") or "").split(";")[0].strip() or None
|
|
1483
1547
|
|
|
1548
|
+
@_like_hosted
|
|
1484
1549
|
async def upload(
|
|
1485
1550
|
self,
|
|
1486
1551
|
source: bytes | str,
|
|
@@ -1522,6 +1587,7 @@ class LocalMediaService:
|
|
|
1522
1587
|
raise RuntimeError(f"ctx.media: fal upload returned no URL ({response.text[:200]})")
|
|
1523
1588
|
return url
|
|
1524
1589
|
|
|
1590
|
+
@_like_hosted
|
|
1525
1591
|
async def save(self, url: str, *, filename: str | None = None, key: str | None = None) -> dict[str, Any]:
|
|
1526
1592
|
if self._storage is None or isinstance(self._storage, UnavailablePlatformService):
|
|
1527
1593
|
raise PlatformServiceUnavailable(
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
"""Base class for defining custom agent tools.
|
|
1
|
+
"""Base class for defining custom agent tools. Deprecated: use the capability contract.
|
|
2
|
+
|
|
3
|
+
``ToolDefinition`` and the manifest's ``tools`` list are the legacy way to give agents a tool. A legacy
|
|
4
|
+
tool has no risk mark, so one that changes data is never offered to agents. The replacement is the
|
|
5
|
+
capability contract: an ``@capability`` handler plus a matching ``agent_exposable`` method under
|
|
6
|
+
``provides.services`` in ``palette-plugin.json`` (``pltt capabilities add`` scaffolds both). Under
|
|
7
|
+
``DEPRECATION_POLICY.md`` this class keeps working, with this note, until the next major release.
|
|
8
|
+
"""
|
|
2
9
|
|
|
3
10
|
from __future__ import annotations
|
|
4
11
|
|
|
12
|
+
import warnings
|
|
5
13
|
from abc import ABC, abstractmethod
|
|
6
14
|
from typing import Any
|
|
7
15
|
|
|
@@ -9,6 +17,9 @@ from typing import Any
|
|
|
9
17
|
class ToolDefinition(ABC):
|
|
10
18
|
"""Base class for custom agent tools provided by plugins.
|
|
11
19
|
|
|
20
|
+
Deprecated: write an ``@capability`` handler and declare it as an ``agent_exposable`` method under
|
|
21
|
+
``provides.services``. Existing subclasses keep working until the next major release.
|
|
22
|
+
|
|
12
23
|
Subclass this to create tools that agents can use in chat conversations.
|
|
13
24
|
|
|
14
25
|
Example:
|
|
@@ -34,6 +45,15 @@ class ToolDefinition(ABC):
|
|
|
34
45
|
description: str = ""
|
|
35
46
|
input_schema: dict[str, Any] = {}
|
|
36
47
|
|
|
48
|
+
def __init_subclass__(cls, **kwargs: Any) -> None:
|
|
49
|
+
super().__init_subclass__(**kwargs)
|
|
50
|
+
warnings.warn(
|
|
51
|
+
"ToolDefinition is deprecated: write an @capability handler and declare it as an agent_exposable "
|
|
52
|
+
"method under provides.services (pltt capabilities add). It is removed in the next major release.",
|
|
53
|
+
DeprecationWarning,
|
|
54
|
+
stacklevel=2,
|
|
55
|
+
)
|
|
56
|
+
|
|
37
57
|
@abstractmethod
|
|
38
58
|
async def run(self, input_data: dict[str, Any], context: dict[str, Any]) -> str:
|
|
39
59
|
"""Execute the tool with the given input.
|