@palettelab/cli 0.3.62 → 0.3.65

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.
Files changed (50) hide show
  1. package/README.md +185 -9
  2. package/backend-sdk/palette_sdk/__init__.py +13 -1
  3. package/backend-sdk/palette_sdk/connections.py +49 -11
  4. package/backend-sdk/palette_sdk/connections_generated.py +246 -0
  5. package/backend-sdk/palette_sdk/data_rooms.py +2 -2
  6. package/backend-sdk/palette_sdk/db/base.py +4 -1
  7. package/backend-sdk/palette_sdk/db/rls.py +7 -1
  8. package/backend-sdk/palette_sdk/manifest.py +16 -2
  9. package/backend-sdk/palette_sdk/platform_services.py +400 -0
  10. package/backend-sdk/palette_sdk/plugin_context.py +41 -2
  11. package/backend-sdk/palette_sdk/plugin_router.py +64 -8
  12. package/backend-sdk/palette_sdk/repository.py +12 -3
  13. package/backend-sdk/palette_sdk/talk.py +65 -0
  14. package/backend-sdk/palette_sdk/tasks.py +117 -0
  15. package/backend-sdk/pyproject.toml +1 -1
  16. package/docs/python-backend-sdk.md +196 -9
  17. package/lib/bundler.js +64 -0
  18. package/lib/cli.js +25 -3
  19. package/lib/commands/capabilities.js +1 -1
  20. package/lib/commands/connections.js +234 -0
  21. package/lib/commands/dev.js +75 -1
  22. package/lib/commands/doctor.js +85 -0
  23. package/lib/commands/open.js +43 -0
  24. package/lib/commands/platform.js +137 -0
  25. package/lib/commands/test.js +47 -4
  26. package/lib/connection-catalog.json +1185 -0
  27. package/lib/dev-simulator.js +232 -3
  28. package/lib/manifest.js +115 -5
  29. package/package.json +1 -1
  30. package/template-fallback/README.md +9 -0
  31. package/template-fallback/frontend/src/translations.ts +2 -2
  32. package/template-fallback/package.json +1 -1
  33. package/template-fallback/palette-plugin.json +1 -0
  34. package/template-fallback/templates/agent-tool/palette-plugin.json +1 -0
  35. package/template-fallback/templates/consumer-app/package.json +1 -1
  36. package/template-fallback/templates/consumer-app/palette-plugin.json +1 -0
  37. package/template-fallback/templates/dashboard/package.json +1 -1
  38. package/template-fallback/templates/dashboard/palette-plugin.json +1 -0
  39. package/template-fallback/templates/database/package.json +1 -1
  40. package/template-fallback/templates/database/palette-plugin.json +1 -0
  41. package/template-fallback/templates/external-service/package.json +1 -1
  42. package/template-fallback/templates/external-service/palette-plugin.json +1 -0
  43. package/template-fallback/templates/frontend-only/package.json +1 -1
  44. package/template-fallback/templates/frontend-only/palette-plugin.json +1 -0
  45. package/template-fallback/templates/next/package.json +1 -1
  46. package/template-fallback/templates/next/palette-plugin.json +1 -0
  47. package/template-fallback/templates/palette-app/package.json +1 -1
  48. package/template-fallback/templates/palette-app/palette-plugin.json +1 -0
  49. package/template-fallback/templates/provider-app/package.json +1 -1
  50. package/template-fallback/templates/provider-app/palette-plugin.json +1 -0
@@ -0,0 +1,246 @@
1
+ """GENERATED by backend/scripts/gen_connection_helpers.py — do not edit by hand.
2
+
3
+ Typed facades over `ctx.connections.call(provider, tool, args)`. Every call is
4
+ proxied by the platform, which owns the OAuth token, the approval gate and the
5
+ audit trail — an app never sees a provider credential.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any, Protocol
11
+
12
+
13
+ class _Caller(Protocol):
14
+ async def call(self, provider: str, tool: str, args: dict[str, Any]) -> Any: ...
15
+
16
+
17
+ class _Namespace:
18
+ def __init__(self, caller: _Caller):
19
+ self._caller = caller
20
+
21
+ async def _call(self, provider: str, tool: str, args: dict[str, Any]) -> Any:
22
+ # Drop unset optionals so provider defaults apply.
23
+ return await self._caller.call(provider, tool, {k: v for k, v in args.items() if v is not None})
24
+
25
+
26
+ class CalendarTools(_Namespace):
27
+ async def create_event(self, *, end: str, start: str, add_meet: bool | None = None, attendees: str | None = None, calendar_id: str | None = None, description: str | None = None, location: str | None = None, summary: str | None = None, time_zone: str | None = None) -> Any:
28
+ """Create a Google Calendar event. Set add_meet=true to attach a Google Meet video link. start/end are RFC3339 datetimes. Invites are emailed to attendees."""
29
+ return await self._call("google", "calendar.create_event", {"end": end, "start": start, "add_meet": add_meet, "attendees": attendees, "calendar_id": calendar_id, "description": description, "location": location, "summary": summary, "time_zone": time_zone})
30
+
31
+ async def list_calendars(self, *, max_results: int | None = None) -> Any:
32
+ """List the calendars the connected Google account can access (id, name, access role)."""
33
+ return await self._call("google", "calendar.list_calendars", {"max_results": max_results})
34
+
35
+ async def list_events(self, *, calendar_id: str | None = None, max_results: int | None = None, query: str | None = None, time_max: str | None = None, time_min: str | None = None) -> Any:
36
+ """List upcoming events on a Google Calendar. Optional time window (RFC3339) and text query. Returns summary, start/end, attendees and any Meet link."""
37
+ return await self._call("google", "calendar.list_events", {"calendar_id": calendar_id, "max_results": max_results, "query": query, "time_max": time_max, "time_min": time_min})
38
+
39
+
40
+ class ContactsTools(_Namespace):
41
+ async def list(self, *, max_results: int | None = None) -> Any:
42
+ """List the connected account's Google Contacts (most recently modified first)."""
43
+ return await self._call("google", "contacts.list", {"max_results": max_results})
44
+
45
+ async def search(self, *, query: str, max_results: int | None = None) -> Any:
46
+ """Search the connected account's Google Contacts by name, email or phone. Returns matching people."""
47
+ return await self._call("google", "contacts.search", {"query": query, "max_results": max_results})
48
+
49
+
50
+ class DocsTools(_Namespace):
51
+ async def create(self, *, title: str, body: str | None = None) -> Any:
52
+ """Create a new Google Doc with a title and optional plain-text body. Returns the doc id and edit URL."""
53
+ return await self._call("google", "docs.create", {"title": title, "body": body})
54
+
55
+ async def read(self, *, document_id: str) -> Any:
56
+ """Read a Google Doc's text content (plain text) by document id."""
57
+ return await self._call("google", "docs.read", {"document_id": document_id})
58
+
59
+
60
+ class DriveTools(_Namespace):
61
+ async def list(self, *, folder_id: str | None = None, max_results: int | None = None) -> Any:
62
+ """List recent files in the connected Google Drive (optionally inside one folder)."""
63
+ return await self._call("google", "drive.list", {"folder_id": folder_id, "max_results": max_results})
64
+
65
+ async def read(self, *, file_id: str) -> Any:
66
+ """Read a Google Drive file's content as text (Docs/Sheets/Slides exported; text files downloaded)."""
67
+ return await self._call("google", "drive.read", {"file_id": file_id})
68
+
69
+ async def search(self, *, query: str, max_results: int | None = None) -> Any:
70
+ """Search Google Drive by file name or full text."""
71
+ return await self._call("google", "drive.search", {"query": query, "max_results": max_results})
72
+
73
+
74
+ class FormsTools(_Namespace):
75
+ async def list_responses(self, *, form_id: str, max_results: int | None = None) -> Any:
76
+ """List submitted responses to a Google Form, with answers keyed by question id."""
77
+ return await self._call("google", "forms.list_responses", {"form_id": form_id, "max_results": max_results})
78
+
79
+ async def read(self, *, form_id: str) -> Any:
80
+ """Read a Google Form's title, description and questions by form id."""
81
+ return await self._call("google", "forms.read", {"form_id": form_id})
82
+
83
+
84
+ class GmailTools(_Namespace):
85
+ async def create_draft(self, *, body: str, subject: str, to: str, cc: str | None = None, thread_id: str | None = None) -> Any:
86
+ """Create a Gmail draft (not sent) — the safe holding pattern for emails the user should review."""
87
+ return await self._call("google", "gmail.create_draft", {"body": body, "subject": subject, "to": to, "cc": cc, "thread_id": thread_id})
88
+
89
+ async def get_draft(self, *, draft_id: str) -> Any:
90
+ """Read the full content (to, subject, body) of an existing Gmail draft by draft_id."""
91
+ return await self._call("google", "gmail.get_draft", {"draft_id": draft_id})
92
+
93
+ async def read(self, *, message_id: str) -> Any:
94
+ """Read one Gmail message's full body (plain text) by message id."""
95
+ return await self._call("google", "gmail.read", {"message_id": message_id})
96
+
97
+ async def search(self, *, query: str, max_results: int | None = None) -> Any:
98
+ """Search the connected Gmail account. Supports Gmail query syntax (from:, subject:, is:unread, newer_than:2d...). Returns message metadata + snippets."""
99
+ return await self._call("google", "gmail.search", {"query": query, "max_results": max_results})
100
+
101
+ async def send(self, *, body: str, subject: str, to: str, cc: str | None = None, thread_id: str | None = None) -> Any:
102
+ """Send an email from the connected Gmail account. Use gmail.create_draft instead when the user should review before sending."""
103
+ return await self._call("google", "gmail.send", {"body": body, "subject": subject, "to": to, "cc": cc, "thread_id": thread_id})
104
+
105
+ async def send_draft(self, *, draft_id: str) -> Any:
106
+ """Send an existing Gmail draft by draft_id after the user has approved it."""
107
+ return await self._call("google", "gmail.send_draft", {"draft_id": draft_id})
108
+
109
+ async def update_draft(self, *, body: str, draft_id: str, subject: str, to: str, cc: str | None = None, thread_id: str | None = None) -> Any:
110
+ """Replace the content of an existing Gmail draft (before it is sent)."""
111
+ return await self._call("google", "gmail.update_draft", {"body": body, "draft_id": draft_id, "subject": subject, "to": to, "cc": cc, "thread_id": thread_id})
112
+
113
+
114
+ class MetaTools(_Namespace):
115
+ async def create_page_post(self, *, message: str, page_id: str, link: str | None = None) -> Any:
116
+ """Publish a text post (optionally with a link) to a Facebook Page the account manages."""
117
+ return await self._call("meta", "meta.create_page_post", {"message": message, "page_id": page_id, "link": link})
118
+
119
+ async def list_pages(self, *, limit: int | None = None) -> Any:
120
+ """List the Facebook Pages this account manages (id, name, category)."""
121
+ return await self._call("meta", "meta.list_pages", {"limit": limit})
122
+
123
+ async def read_page_posts(self, *, page_id: str, limit: int | None = None) -> Any:
124
+ """Read recent posts from a Facebook Page the account manages."""
125
+ return await self._call("meta", "meta.read_page_posts", {"page_id": page_id, "limit": limit})
126
+
127
+
128
+ class NotionTools(_Namespace):
129
+ async def append_blocks(self, *, block_id: str, blocks: list[Any] | None = None, content: str | None = None) -> Any:
130
+ """Append paragraph blocks (from newline-separated text) or raw blocks to a Notion page/block."""
131
+ return await self._call("notion", "notion.append_blocks", {"block_id": block_id, "blocks": blocks, "content": content})
132
+
133
+ async def create_page(self, *, content: str | None = None, parent_database_id: str | None = None, parent_page_id: str | None = None, properties: dict[str, Any] | None = None, title: str | None = None) -> Any:
134
+ """Create a Notion page under a parent page or database (title + optional plain-text content, or a raw properties object for database parents)."""
135
+ return await self._call("notion", "notion.create_page", {"content": content, "parent_database_id": parent_database_id, "parent_page_id": parent_page_id, "properties": properties, "title": title})
136
+
137
+ async def get_page(self, *, page_id: str) -> Any:
138
+ """Read a Notion page's title and top-level text content by page id."""
139
+ return await self._call("notion", "notion.get_page", {"page_id": page_id})
140
+
141
+ async def query_database(self, *, database_id: str, filter: dict[str, Any] | None = None, limit: int | None = None, sorts: list[Any] | None = None) -> Any:
142
+ """Query rows of a Notion database by id (optional Notion filter/sorts objects)."""
143
+ return await self._call("notion", "notion.query_database", {"database_id": database_id, "filter": filter, "limit": limit, "sorts": sorts})
144
+
145
+ async def search(self, *, filter: str | None = None, limit: int | None = None, query: str | None = None) -> Any:
146
+ """Search pages and databases shared with the Notion integration (by text query)."""
147
+ return await self._call("notion", "notion.search", {"filter": filter, "limit": limit, "query": query})
148
+
149
+ async def update_page(self, *, page_id: str, archived: bool | None = None, properties: dict[str, Any] | None = None) -> Any:
150
+ """Update a Notion page's properties, or archive/unarchive it."""
151
+ return await self._call("notion", "notion.update_page", {"page_id": page_id, "archived": archived, "properties": properties})
152
+
153
+
154
+ class SheetsTools(_Namespace):
155
+ async def append_row(self, *, range: str, spreadsheet_id: str, values: list[Any]) -> Any:
156
+ """Append one row to a Google Sheet range. `values` is an array of cell values for the new row."""
157
+ return await self._call("google", "sheets.append_row", {"range": range, "spreadsheet_id": spreadsheet_id, "values": values})
158
+
159
+ async def read_range(self, *, range: str, spreadsheet_id: str) -> Any:
160
+ """Read a cell range from a Google Sheet in A1 notation (e.g. 'Sheet1!A1:D20'). Returns a 2D array of values."""
161
+ return await self._call("google", "sheets.read_range", {"range": range, "spreadsheet_id": spreadsheet_id})
162
+
163
+ async def update_range(self, *, range: str, spreadsheet_id: str, values: list[Any]) -> Any:
164
+ """Overwrite a cell range in a Google Sheet. `values` is a 2D array (array of row arrays) sized to the range."""
165
+ return await self._call("google", "sheets.update_range", {"range": range, "spreadsheet_id": spreadsheet_id, "values": values})
166
+
167
+
168
+ class SlackTools(_Namespace):
169
+ async def add_reaction(self, *, channel: str, emoji: str, ts: str) -> Any:
170
+ """Add an emoji reaction to a message (by channel + ts)."""
171
+ return await self._call("slack", "slack.add_reaction", {"channel": channel, "emoji": emoji, "ts": ts})
172
+
173
+ async def get_permalink(self, *, channel: str, ts: str) -> Any:
174
+ """Get a shareable permalink URL for a message (by channel + ts)."""
175
+ return await self._call("slack", "slack.get_permalink", {"channel": channel, "ts": ts})
176
+
177
+ async def list_channels(self, *, limit: int | None = None) -> Any:
178
+ """List public Slack channels in the connected workspace."""
179
+ return await self._call("slack", "slack.list_channels", {"limit": limit})
180
+
181
+ async def post_message(self, *, channel: str, text: str) -> Any:
182
+ """Post a message to a Slack channel (by #name or channel id) as the workspace bot."""
183
+ return await self._call("slack", "slack.post_message", {"channel": channel, "text": text})
184
+
185
+ async def read_channel(self, *, channel: str, limit: int | None = None) -> Any:
186
+ """Read recent messages from a public Slack channel."""
187
+ return await self._call("slack", "slack.read_channel", {"channel": channel, "limit": limit})
188
+
189
+ async def update_message(self, *, channel: str, text: str, ts: str) -> Any:
190
+ """Edit the text of a message the bot previously posted (by channel + ts)."""
191
+ return await self._call("slack", "slack.update_message", {"channel": channel, "text": text, "ts": ts})
192
+
193
+
194
+ class SlidesTools(_Namespace):
195
+ async def read(self, *, presentation_id: str) -> Any:
196
+ """Read the text of every slide in a Google Slides presentation by presentation id."""
197
+ return await self._call("google", "slides.read", {"presentation_id": presentation_id})
198
+
199
+
200
+ class TasksTools(_Namespace):
201
+ async def create(self, *, title: str, due: str | None = None, notes: str | None = None, tasklist_id: str | None = None) -> Any:
202
+ """Create a task in a Google Tasks list. Optional notes and RFC3339 due date."""
203
+ return await self._call("google", "tasks.create", {"title": title, "due": due, "notes": notes, "tasklist_id": tasklist_id})
204
+
205
+ async def list(self, *, max_results: int | None = None, show_completed: bool | None = None, tasklist_id: str | None = None) -> Any:
206
+ """List tasks from a Google Tasks list (defaults to the primary '@default' list)."""
207
+ return await self._call("google", "tasks.list", {"max_results": max_results, "show_completed": show_completed, "tasklist_id": tasklist_id})
208
+
209
+
210
+ class TelegramTools(_Namespace):
211
+ async def edit_message(self, *, chat_id: str, message_id: int, text: str) -> Any:
212
+ """Edit the text of a message the bot previously sent."""
213
+ return await self._call("telegram", "telegram.edit_message", {"chat_id": chat_id, "message_id": message_id, "text": text})
214
+
215
+ async def get_chat(self, *, chat_id: str) -> Any:
216
+ """Get metadata for a Telegram chat/group/channel the bot is a member of."""
217
+ return await self._call("telegram", "telegram.get_chat", {"chat_id": chat_id})
218
+
219
+ async def read_updates(self, *, limit: int | None = None, offset: int | None = None) -> Any:
220
+ """Read recent messages sent to the connected Telegram bot (private chats, groups it is in)."""
221
+ return await self._call("telegram", "telegram.read_updates", {"limit": limit, "offset": offset})
222
+
223
+ async def send_message(self, *, chat_id: str, text: str) -> Any:
224
+ """Send a message to a Telegram chat, group, or channel as the connected bot (chat_id = numeric id or @channelusername; the bot must be a member/admin of the chat)."""
225
+ return await self._call("telegram", "telegram.send_message", {"chat_id": chat_id, "text": text})
226
+
227
+ async def send_photo(self, *, chat_id: str, photo: str, caption: str | None = None) -> Any:
228
+ """Send a photo (by public URL or Telegram file_id) to a chat as the connected bot, with an optional caption."""
229
+ return await self._call("telegram", "telegram.send_photo", {"chat_id": chat_id, "photo": photo, "caption": caption})
230
+
231
+
232
+ NAMESPACES: dict[str, type[_Namespace]] = {
233
+ "calendar": CalendarTools,
234
+ "contacts": ContactsTools,
235
+ "docs": DocsTools,
236
+ "drive": DriveTools,
237
+ "forms": FormsTools,
238
+ "gmail": GmailTools,
239
+ "meta": MetaTools,
240
+ "notion": NotionTools,
241
+ "sheets": SheetsTools,
242
+ "slack": SlackTools,
243
+ "slides": SlidesTools,
244
+ "tasks": TasksTools,
245
+ "telegram": TelegramTools,
246
+ }
@@ -19,7 +19,7 @@ class DataRoomsClient:
19
19
  def _require_service(self) -> Any:
20
20
  if self._service is None:
21
21
  raise RuntimeError(
22
- "Data Room service is not available in this runtime. "
22
+ "Drive service is not available in this runtime. "
23
23
  "Run inside Palette OS/hosted sandbox or inject a fake service in tests."
24
24
  )
25
25
  return self._service
@@ -36,7 +36,7 @@ class DataRoomsClient:
36
36
  async def require_room_by_name(self, name: str, *, case_sensitive: bool = False) -> dict[str, Any]:
37
37
  room = await self.find_room_by_name(name, case_sensitive=case_sensitive)
38
38
  if room is None:
39
- raise LookupError(f"Data Room not found: {name}")
39
+ raise LookupError(f"Drive not found: {name}")
40
40
  return room
41
41
 
42
42
  async def ensure_room(self, name: str, description: str | None = None) -> dict[str, Any]:
@@ -39,7 +39,7 @@ class PluginBase(DeclarativeBase):
39
39
 
40
40
 
41
41
  class OrgScopedTable(PluginBase):
42
- """Base for all per-organization plugin tables.
42
+ """Base for all per-install plugin tables.
43
43
 
44
44
  Inheriting from this gives you:
45
45
  - An `organization_id BIGINT NOT NULL` column with an index.
@@ -49,6 +49,9 @@ class OrgScopedTable(PluginBase):
49
49
  Never write `WHERE organization_id = ?` in your queries — the database
50
50
  will filter rows for you based on the session variable set by the
51
51
  platform at request time.
52
+
53
+ The value is the app's effective data partition: a member tenant for
54
+ personal scope, or the real org id for organization scope.
52
55
  """
53
56
 
54
57
  __abstract__ = True
@@ -1,10 +1,16 @@
1
1
  """Row-level security helpers for plugin migrations.
2
2
 
3
- Every plugin table that holds org data must call `ensure_org_rls(op, table)`
3
+ Every plugin table that holds app data must call `ensure_org_rls(op, table)`
4
4
  in the migration that creates it. This enables RLS and installs the standard
5
5
  policy, which filters rows by the `app.current_org_id` session variable set
6
6
  by the platform at request time.
7
7
 
8
+ Every member installs an app individually. `manifest.data_scope` selects the
9
+ partition stored in `app.current_org_id`: `personal` uses that member's tenant
10
+ id; `organization` uses the real org id so installed members share one dataset.
11
+ `manifest.shared_tables` is only for global static lookup data shared across
12
+ all organisations, never for organisation business data.
13
+
8
14
  The `palette build` CLI lints migrations and will reject any that:
9
15
  - create an org table without a matching `ensure_org_rls` call,
10
16
  - contain `DROP POLICY` or `DISABLE ROW LEVEL SECURITY`,
@@ -85,12 +85,25 @@ class SecretSpec(BaseModel):
85
85
 
86
86
 
87
87
  class ConnectionSpec(BaseModel):
88
+ """A third-party service this app reaches through the user's OS connection.
89
+
90
+ `google`/`slack`/`notion`/`telegram`/`meta` are live: the user connects once
91
+ in Connect and the app calls `ctx.connections.<tool>` with no OAuth of its
92
+ own. The remaining slugs are legacy and validate but dispatch nothing.
93
+ """
94
+
88
95
  id: str
89
- provider: Literal["google", "instagram", "slack", "linear", "hubspot", "stripe", "zendesk", "custom"]
96
+ provider: Literal[
97
+ "google", "slack", "notion", "telegram", "meta",
98
+ "instagram", "linear", "hubspot", "stripe", "zendesk", "custom",
99
+ ]
90
100
  label: str
91
101
  auth: Literal["oauth2", "api_key"] = "oauth2"
92
102
  scopes: list[str] = Field(default_factory=list)
93
103
  required: bool = False
104
+ # Tool names the app may call, e.g. ["gmail.search", "gmail.send"]. Empty
105
+ # grants every read-only tool the provider offers.
106
+ tools: list[str] = Field(default_factory=list)
94
107
 
95
108
 
96
109
  class AppServiceRouteSpec(BaseModel):
@@ -308,6 +321,7 @@ class PluginManifest(BaseModel):
308
321
  id: str
309
322
  name: str
310
323
  version: str = "1.0.0"
324
+ data_scope: Literal["personal", "organization"] = "personal"
311
325
  developer: str = ""
312
326
  category: str = "Productivity"
313
327
  tagline: str = ""
@@ -331,7 +345,7 @@ class PluginManifest(BaseModel):
331
345
  requires: RequiresSpec | None = None
332
346
  consumes: ConsumesSpec | None = None
333
347
  mcp: McpSpec | None = None
334
- platform_services: list[Literal["llm", "redis", "storage", "vector"]] | dict[str, PlatformServiceSpec] = Field(default_factory=list)
348
+ platform_services: list[Literal["llm", "media", "redis", "storage", "vector", "web"]] | dict[str, PlatformServiceSpec] = Field(default_factory=list)
335
349
  rating: float = 0.0
336
350
  reviews: int = 0
337
351
  featured: bool = False