@palettelab/cli 0.3.76 → 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 +36 -4
- 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/tool_definition.py +21 -1
- package/backend-sdk/pyproject.toml +1 -1
- package/docs/connectors.md +154 -0
- package/docs/python-backend-sdk.md +106 -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
|
@@ -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(
|
|
@@ -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.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Your App As A Connector
|
|
2
|
+
|
|
3
|
+
Palette presents an installed app to assistants the way it presents a connected service: as a **connector**. A
|
|
4
|
+
connector is one description of your app, and every assistant reads the same one, in chat, in hired agents, in
|
|
5
|
+
workflows and in the desktop agent. Installing your app also gives each member an agent named after it, which they
|
|
6
|
+
DM in Messenger or mention in a room; it operates your app for them through the same connector.
|
|
7
|
+
|
|
8
|
+
| Part of the connector | Where it comes from |
|
|
9
|
+
|---|---|
|
|
10
|
+
| Summary and instructions | `agent` in `palette-plugin.json`; generated from your description when you write none |
|
|
11
|
+
| Tools | Agent-exposed `provides.services` methods, MCP tools, and your backend routes |
|
|
12
|
+
| Skills | `skills/<name>/SKILL.md` in your app folder |
|
|
13
|
+
| Events | `provides.events` entries that have a description and a payload schema |
|
|
14
|
+
|
|
15
|
+
An app that adds none of this still works: it is a plain connector with generated instructions. What you write
|
|
16
|
+
decides how well assistants use it. `pltt capabilities` prints the connector as an assistant will see it, and
|
|
17
|
+
`pltt check` reports what is missing.
|
|
18
|
+
|
|
19
|
+
## The `agent` block
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
"agent": {
|
|
23
|
+
"summary": "Keeps each member's meeting notes and action items.",
|
|
24
|
+
"instructions": "Search for an existing note before creating one. Never delete a note unless the member names it."
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`summary` (at most 160 characters) is the line an assistant sees wherever a member's apps are listed; without it the
|
|
29
|
+
platform uses the first sentence of the tagline or the description. `instructions` (at most 2,000 characters) say
|
|
30
|
+
when to reach for the app, what to check first and what never to do. Write them for a reader who has never seen your
|
|
31
|
+
app. They are your app's words, not the platform's: shown to the model as coming from your app, reviewed by the store
|
|
32
|
+
with each version, and unable to widen what your tools are allowed to do.
|
|
33
|
+
|
|
34
|
+
## Tools
|
|
35
|
+
|
|
36
|
+
The preferred form is a typed capability: an `@capability` handler with an `agent_exposable` method under
|
|
37
|
+
`provides.services`. It carries its own description, input schema and risk, it is the same method other apps call
|
|
38
|
+
through the broker, and stable capability ids let saved agents and workflows switch to another provider app without
|
|
39
|
+
changing.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from palette_sdk import CapabilityResult, PluginContext, capability
|
|
43
|
+
|
|
44
|
+
@capability(
|
|
45
|
+
"poster.generate",
|
|
46
|
+
capability_id="creative.poster.generate",
|
|
47
|
+
description="Create a social media poster and return its stored artifact.",
|
|
48
|
+
input_schema={
|
|
49
|
+
"type": "object",
|
|
50
|
+
"properties": {"brief": {"type": "string"}},
|
|
51
|
+
"required": ["brief"],
|
|
52
|
+
},
|
|
53
|
+
effects=["artifact.create"],
|
|
54
|
+
risk="write",
|
|
55
|
+
idempotent=True,
|
|
56
|
+
artifact_outputs=["image/png"],
|
|
57
|
+
)
|
|
58
|
+
async def generate_poster(ctx: PluginContext, payload: dict) -> CapabilityResult:
|
|
59
|
+
artifact = await create_and_store_poster(ctx, payload["brief"])
|
|
60
|
+
return CapabilityResult(data={"status": "ready"}, artifacts=[artifact])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pltt capabilities add creative.poster.generate --method poster.generate --risk write --effects artifact.create --idempotent
|
|
65
|
+
pltt services sync
|
|
66
|
+
pltt test
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Your backend routes are offered as tools too. The platform calls them in-process as the member, through your normal
|
|
70
|
+
`require_permission` checks and their data partition. Mark each one with `agent_route`:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from palette_sdk import agent_route
|
|
74
|
+
|
|
75
|
+
@router.get("/notes", dependencies=[require_permission("resources:read")],
|
|
76
|
+
openapi_extra=agent_route("read")) # runs at once
|
|
77
|
+
@router.post("/notes", dependencies=[require_permission("resources:write")],
|
|
78
|
+
openapi_extra=agent_route("write")) # a change: the member is asked
|
|
79
|
+
@router.post("/admin/reindex", dependencies=[require_permission("resources:write")],
|
|
80
|
+
openapi_extra=agent_route("hidden")) # never offered
|
|
81
|
+
@router.post("/notes/search", dependencies=[require_permission("resources:read")],
|
|
82
|
+
openapi_extra=agent_route("read", name="search_notes",
|
|
83
|
+
description="Search my notes by title and body."))
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A route with no mark is still offered, a `GET` as a read and anything else as a change. That is rarely what you want
|
|
87
|
+
for admin and internal routes, so hide those. `name` gives the tool a name of its own instead of one built from the
|
|
88
|
+
path, and `description` replaces the docstring as what the assistant reads. Keep tool names the same between
|
|
89
|
+
versions: a member's per-tool switches and permission rules are keyed by name. The full `agent_route` reference,
|
|
90
|
+
including `opens`, is in [Routes The Agent Can Use](./python-backend-sdk.md#5a-routes-the-agent-can-use).
|
|
91
|
+
|
|
92
|
+
## Skills
|
|
93
|
+
|
|
94
|
+
A skill is a recipe an assistant follows for one of your app's multi-step jobs. Put each in
|
|
95
|
+
`skills/<name>/SKILL.md`:
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
---
|
|
99
|
+
name: file-note
|
|
100
|
+
description: Turn a conversation into a note with its action items.
|
|
101
|
+
allowed-tools: search_notes note.create
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
1. Search for an existing note on the subject first.
|
|
105
|
+
2. ...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`name` is the folder's name, and `allowed-tools` lists tools your app has, separated by spaces. `pltt package` and
|
|
109
|
+
`pltt publish` put the folder in the bundle. Skills and the `agent` text are reviewed by the store with each version.
|
|
110
|
+
The `agent-tool` template has a working example in `skills/echo-check/`.
|
|
111
|
+
|
|
112
|
+
## Events as triggers
|
|
113
|
+
|
|
114
|
+
A member can start an assistant from an event your app raises ("when *Orders* raises *order.created*, check stock").
|
|
115
|
+
Only an event with a `description` and a `payload_schema` in `provides.events` is offered as a trigger. One without
|
|
116
|
+
them still reaches other apps as before. Delivery is best-effort today: `ctx.events.publish_durable(...)` has the
|
|
117
|
+
durable call's signature and currently delivers like `publish`.
|
|
118
|
+
|
|
119
|
+
## What `pltt check` reports
|
|
120
|
+
|
|
121
|
+
All are warnings except the first two, which the manifest validator already refuses.
|
|
122
|
+
|
|
123
|
+
| id | Meaning |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `connector.instructions_too_long` | `agent.instructions` is over 2,000 characters |
|
|
126
|
+
| `connector.action_incomplete` | An agent-exposed method, legacy tool or route has no description, input schema or risk |
|
|
127
|
+
| `connector.route_unmarked` | A route is offered to assistants with no `agent_route` mark |
|
|
128
|
+
| `connector.skill_unknown_tool` | A skill's `allowed-tools` names a tool the app does not have |
|
|
129
|
+
| `connector.skill_invalid` | A `SKILL.md` has no frontmatter, no description, or a `name` that is not its folder |
|
|
130
|
+
| `connector.event_not_triggerable` | An event has no description or no payload schema |
|
|
131
|
+
| `deprecated.apps_call` | The code uses the path-style `ctx.apps.call(app_id, path)` |
|
|
132
|
+
|
|
133
|
+
## Deprecated
|
|
134
|
+
|
|
135
|
+
Both keep working, with a `DeprecationWarning`, until the next major release.
|
|
136
|
+
|
|
137
|
+
| Deprecated | Use instead |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `ToolDefinition` and the manifest's `tools` list | `@capability` plus an `agent_exposable` `provides.services` method (`pltt capabilities add`) |
|
|
140
|
+
| `ctx.apps.call(app_id, path)` | `services(ctx).call("namespace/version#method", payload)`, declared under `consumes.services` |
|
|
141
|
+
|
|
142
|
+
Mutating legacy tools are not run by agents, because they do not take part in broker approvals. `@mcp_resource` and
|
|
143
|
+
`@mcp_prompt` are inert: the platform records them and serves neither. A connector carries tools, instructions and
|
|
144
|
+
skills.
|
|
145
|
+
|
|
146
|
+
## Order of release
|
|
147
|
+
|
|
148
|
+
The platform refuses a manifest key it does not know. A platform older than the release that accepts `agent`
|
|
149
|
+
therefore refuses your publish if the manifest has the block, and the templates of this CLI write one. Check that
|
|
150
|
+
your environment accepts it before you add it; the CLI does not check the platform's version for you.
|
|
151
|
+
|
|
152
|
+
The parts also arrive in steps. The platform reads `agent.summary`, the `read`, `write` and `hidden` marks, and
|
|
153
|
+
capabilities today. Instructions, skills from store apps, a route's `name` and `description`, and event triggers are
|
|
154
|
+
accepted and kept now, and reach assistants as the platform's connector release rolls out.
|