@palettelab/cli 0.3.67 → 0.3.69

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 (34) hide show
  1. package/README.md +22 -18
  2. package/backend-sdk/palette_sdk/__init__.py +3 -3
  3. package/backend-sdk/palette_sdk/agent_routes.py +43 -0
  4. package/backend-sdk/palette_sdk/connections_generated.py +302 -51
  5. package/backend-sdk/palette_sdk/manifest.py +2 -2
  6. package/backend-sdk/palette_sdk/permissions.py +1 -3
  7. package/backend-sdk/palette_sdk/platform_services.py +17 -11
  8. package/backend-sdk/palette_sdk/plugin_context.py +10 -12
  9. package/backend-sdk/pyproject.toml +1 -1
  10. package/docs/python-backend-sdk.md +12 -60
  11. package/lib/commands/models.js +12 -8
  12. package/lib/connection-catalog.json +2687 -622
  13. package/lib/dev-simulator.js +2 -83
  14. package/lib/manifest.js +3 -10
  15. package/package.json +1 -1
  16. package/template-fallback/backend/api/main.py +2 -2
  17. package/template-fallback/frontend/src/index.tsx +10 -21
  18. package/template-fallback/frontend/src/translations.ts +6 -12
  19. package/template-fallback/package.json +1 -1
  20. package/template-fallback/palette-plugin.json +1 -3
  21. package/template-fallback/templates/agent-tool/README.md +1 -1
  22. package/template-fallback/templates/consumer-app/package.json +1 -1
  23. package/template-fallback/templates/dashboard/package.json +1 -1
  24. package/template-fallback/templates/database/backend/api/main.py +2 -0
  25. package/template-fallback/templates/database/package.json +1 -1
  26. package/template-fallback/templates/external-service/package.json +1 -1
  27. package/template-fallback/templates/frontend-only/package.json +1 -1
  28. package/template-fallback/templates/frontend-only/palette-plugin.json +1 -1
  29. package/template-fallback/templates/next/package.json +1 -1
  30. package/template-fallback/templates/palette-app/backend/api/main.py +1 -1
  31. package/template-fallback/templates/palette-app/package.json +1 -1
  32. package/template-fallback/templates/palette-app/palette-plugin.json +1 -1
  33. package/template-fallback/templates/provider-app/package.json +1 -1
  34. package/backend-sdk/palette_sdk/tasks.py +0 -117
package/README.md CHANGED
@@ -309,13 +309,12 @@ async def create_invoice(body: InvoiceIn, ctx: PluginContext = Depends(get_plugi
309
309
  Backend SDK features for app-owned data:
310
310
 
311
311
  - `PluginRouter`, `PluginContext`, and `get_plugin_context` provide the FastAPI route and request-context surface. A parameter annotated `ctx: PluginContext` is wired automatically — `Depends(get_plugin_context)` is still accepted and behaves identically.
312
- - `PluginContext` exposes `user_id`, `organization_id`, `org_role`, `plugin_id`, `permissions`, `storage`, `ctx.db`, `ctx.jobs`, `ctx.data_rooms`, `ctx.connections`, `ctx.members`, `ctx.tasks`, `ctx.redis`, `ctx.vector`, `ctx.llm`, `ctx.media`, `ctx.web`, `ctx.config`, and `ctx.logger`.
312
+ - `PluginContext` exposes `user_id`, `organization_id`, `org_role`, `plugin_id`, `permissions`, `storage`, `ctx.db`, `ctx.jobs`, `ctx.data_rooms`, `ctx.connections`, `ctx.members`, `ctx.redis`, `ctx.vector`, `ctx.llm`, `ctx.media`, `ctx.web`, `ctx.config`, and `ctx.logger`.
313
313
  - `ctx.db` is the full scoped SQLAlchemy `AsyncSession` for app-owned database data.
314
314
  - `ctx.repo(Model)` gives org-safe CRUD helpers for app tables.
315
315
  - `ctx.data_rooms` gives backend access to Palette Data Rooms without importing platform internals.
316
316
  - `ctx.members` gives backend access to current organisation members; it exposes list/get/invite/update-role helpers, but no delete/remove helper.
317
317
  - `ctx.connections.<namespace>.<tool>(...)` calls the third-party services the viewer connected in Palette Connect — `ctx.connections.gmail.search(query=...)`, `ctx.connections.slack.post_message(...)`, and so on for drive, calendar, sheets, docs, slides, contacts, tasks, forms, notion, telegram and meta. `ctx.connections.list()/status(id)/require(id)` report what is connected and granted. There is no `access_token(...)`: the platform holds the credential so scope checks, write approval and audit cannot be bypassed.
318
- - `ctx.tasks` puts work on the caller's task board and reads it back — `create(title, **fields)`, `list(status=..., limit=...)`, `get`, `update`, `complete(id, output=...)`, `fail`, `delete`. Needs `tasks:read` / `tasks:write`. An app sees **only the tasks it created**: every row is stamped with the app id, another app's task reads as missing, and provenance fields (`app_id`, `source`, `external_ref`, …) are refused rather than silently overwritten.
319
318
  - `ctx.has_permission("...")`, `ctx.has_any_permission([...])`, and `ctx.has_all_permissions([...])` check declared permissions.
320
319
  - `ctx.config_value("key")` and `ctx.require_config("key")` read app install/config values.
321
320
  - `ctx.secret("KEY")` reads app secrets from config or environment variables.
@@ -324,9 +323,9 @@ Backend SDK features for app-owned data:
324
323
  - `ctx.redis` gives a Redis-backed, plugin/org-scoped Redis API when `"redis"` is declared in `platform_services`.
325
324
  - `ctx.vector` gives a Qdrant-backed, plugin/org-scoped vector API when `"vector"` is declared in `platform_services`.
326
325
  - `ctx.storage` gives app/org-scoped file upload helpers when `"storage"` is declared in `platform_services`.
327
- - `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 standard-tier model with `model=`; premium models need `platform_services.llm.models` (declared in the manifest the publish review approves), and nothing bypasses the org'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. Spend is metered per organisation and app and refused once the monthly budget is spent.
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=` — 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.
328
327
  - `ctx.llm` also takes provider passthrough (`response_format`, `top_p`, `stop`, `seed`, …) as plain keywords, 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.
329
- - `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 shares one monthly wallet with `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`), `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`.
330
329
  - `ctx.web` gives web search and an SSRF-guarded page reader (HTML tables and PDFs handled) when `"web"` is declared.
331
330
  - `pltt platform list` prints every service above with a snippet and its `pltt dev` mode; `pltt platform enable <name>` writes the manifest declaration.
332
331
  - `ctx.connections` gives the viewer's OS service connections — see `pltt connections`.
@@ -790,7 +789,7 @@ Redis after rewriting key arguments into the plugin/org namespace, and blocks
790
789
  server/admin commands such as `FLUSHDB`, `CONFIG`, `KEYS`, and cluster
791
790
  management. For advanced Qdrant features, use `ctx.vector.client()` with
792
791
  `collection_name()`, `scoped_filter()`, `merge_filter()`, `scoped_payload()`,
793
- and `scoped_point()` so custom calls remain scoped.
792
+ and `scoped_point()` so custom calls remain scoped. The client is confined to your app's partition: it offers `query_points`, `scroll`, `count`, `retrieve`, `upsert` (of `scoped_point(...)` points only) and `delete`, always filtered to this app and organization; other operations are refused.
794
793
 
795
794
  Common managed-service commands:
796
795
 
@@ -1017,8 +1016,8 @@ pltt platform disable web
1017
1016
  | `vector` | a Pinecone/Qdrant account | namespaced vector search |
1018
1017
  | `redis` | `REDIS_URL` | KV, lists, sets, sorted sets, counters, locks |
1019
1018
 
1020
- `list` also prints the **permission-gated** clients — `ctx.tasks`,
1021
- `ctx.data_rooms`, `ctx.members`, `ctx.talk` — and whether your manifest has
1019
+ `list` also prints the **permission-gated** clients — `ctx.data_rooms`,
1020
+ `ctx.members`, `ctx.talk` — and whether your manifest has
1022
1021
  granted them, so "what can `ctx` do, and what do I declare to get it" is one
1023
1022
  answer.
1024
1023
 
@@ -1026,16 +1025,17 @@ Notes:
1026
1025
 
1027
1026
  - `enable` preserves the object form, so per-service `billing` / `required`
1028
1027
  settings you already wrote are kept.
1029
- - `llm` and `media` share **one** monthly wallet per (app, organisation) and
1030
- both fail closed. `ctx.llm.spend()` reports what is left.
1028
+ - `llm` and `media` spend the workspace's credits under its plan, seat and
1029
+ member limits. `ctx.llm.spend()["workspace"]` reports what is left.
1031
1030
  - Under `pltt dev` there is no platform: `llm` and `media` use your own
1032
1031
  `OPENAI_API_KEY` / `FAL_KEY` when `.env.local` has them and return
1033
1032
  deterministic stubs when it does not. `pltt doctor` prints which mode each
1034
1033
  one is in.
1035
1034
 
1036
- - Premium models and bigger calls are declared on `llm`'s object form —
1037
- `{"llm": {"models": ["gpt-6-astra"], "max_output_tokens": 12000, "max_images": 16}}` —
1038
- in the manifest the publish review approves. `pltt build` / `pltt test` validate it.
1035
+ - Bigger calls are declared on `llm`'s object form —
1036
+ `{"llm": {"max_output_tokens": 12000, "max_images": 16}}` — in the manifest
1037
+ the publish review approves. `pltt build` / `pltt test` validate it. Models
1038
+ need no declaration: an app gets every model the workspace can run.
1039
1039
 
1040
1040
  `pltt platform` is about what the *platform* provides. For app-to-app contracts
1041
1041
  see `pltt services`; for third-party accounts the *user* connected see
@@ -1045,8 +1045,9 @@ see `pltt services`; for third-party accounts the *user* connected see
1045
1045
 
1046
1046
  The chat, image, video and audio models your app can use **in your workspace
1047
1047
  right now**, as `ctx.llm.catalog()` / `ctx.media.catalog()` would report them
1048
- at runtime. Your `palette-plugin.json` is sent along, so declared premium
1049
- models and capacity are reflected. Needs `pltt login` (a publish token).
1048
+ at runtime, and the workspace credits its calls spend. Your
1049
+ `palette-plugin.json` is sent along, so declared capacity is reflected. Needs
1050
+ `pltt login` (a publish token).
1050
1051
 
1051
1052
  ```bash
1052
1053
  pltt models # every model: provider, kind, limits, why not
@@ -1055,14 +1056,17 @@ pltt models --json --env staging
1055
1056
  ```
1056
1057
 
1057
1058
  ```text
1059
+ Workspace credits: 812.50 available (normal)
1060
+
1058
1061
  ok gpt-6-astra openai chat 12000 out tok, 16 img
1059
- -- claude-fable-5-1 anthropic chat 4096 out tok, 4 img (not_approved)
1062
+ ok claude-haiku-5-5 anthropic chat 4096 out tok, 4 img
1063
+ -- gemini-4-argon google chat 4096 out tok, 4 img (billing_disabled)
1060
1064
  ok fal-ai/nano-banana/edit fal image image-to-image
1061
1065
  ```
1062
1066
 
1063
- `reason` values: `unknown_model`, `provider_unconfigured`, `not_approved`
1064
- (declare it in `platform_services.llm.models`), `billing_disabled`,
1065
- `org_policy` (SECURE workspace), `budget_exhausted`. The same reason is what a
1067
+ `reason` values: `unknown_model`, `provider_unconfigured`, `billing_disabled`
1068
+ (the platform has not priced it yet), `org_policy` (SECURE workspace),
1069
+ `budget_exhausted` (the workspace is out of credits). The same reason is what a
1066
1070
  `fallback=False` call raises as `ModelUnavailable`.
1067
1071
 
1068
1072
  ### `pltt connections`
@@ -1,6 +1,7 @@
1
1
  """Palette Platform SDK for building backend plugins."""
2
2
 
3
3
  from palette_sdk.plugin_router import PluginRouter
4
+ from palette_sdk.agent_routes import agent_route
4
5
  from palette_sdk.plugin_context import MissingSecretError, PluginContext, get_plugin_context
5
6
  from palette_sdk.data_rooms import DataRoomsClient
6
7
  from palette_sdk.connections import ConnectionStatus, MissingConnectionError, PluginConnectionsClient
@@ -9,7 +10,6 @@ from palette_sdk.members import OrganizationMembersClient
9
10
  from palette_sdk.notifications import NotificationRecipient, NotificationsClient
10
11
  from palette_sdk.organization import OrganizationInfo
11
12
  from palette_sdk.talk import TalkClient
12
- from palette_sdk.tasks import TasksClient
13
13
  from palette_sdk.platform_services import (
14
14
  LocalLLMService,
15
15
  LocalMediaService,
@@ -74,6 +74,7 @@ from palette_sdk.storage import LocalStorageService
74
74
 
75
75
  __all__ = [
76
76
  "PluginRouter",
77
+ "agent_route",
77
78
  "PluginContext",
78
79
  "MissingSecretError",
79
80
  "get_plugin_context",
@@ -89,7 +90,6 @@ __all__ = [
89
90
  "NotificationsClient",
90
91
  "NotificationRecipient",
91
92
  "TalkClient",
92
- "TasksClient",
93
93
  "LocalLLMService",
94
94
  "LocalMediaService",
95
95
  "LocalRedisService",
@@ -154,4 +154,4 @@ __all__ = [
154
154
  "LocalStorageService",
155
155
  ]
156
156
 
157
- __version__ = "0.1.16"
157
+ __version__ = "0.1.18"
@@ -0,0 +1,43 @@
1
+ """How the app's own agent may use a route — its bot in Messenger and in chat.
2
+
3
+ The platform operates an installed app through the app's own routes: the very requests its
4
+ screens make, sent as the member the agent is answering (their install, data partition and the
5
+ app's permissions). Every route a member can call is offered to the agent with no extra work; the
6
+ route's docstring and request model are what the agent reads to use it. Reads (GET) run at once;
7
+ anything else is a change, which waits for the member's approval where the platform asks for one.
8
+
9
+ Mark the exceptions with FastAPI's own ``openapi_extra``::
10
+
11
+ @router.post("/search", openapi_extra=agent_route("read")) # a POST that only reads
12
+ @router.post("/admin/reindex", openapi_extra=agent_route("hidden")) # never offered to the agent
13
+
14
+ ``include_in_schema=False`` hides a route as well.
15
+
16
+ When the agent shows a member one of your items, its card opens your app. Say where the item opens
17
+ on the route that reads it, with that route's own path parameters; your app gets the path as
18
+ ``platform.routePath`` (a ``?query`` arrives in the window's URL instead)::
19
+
20
+ @router.get("/notes/{note_id}", openapi_extra=agent_route("read", opens="/notes/{note_id}"))
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import re
26
+ from typing import Literal
27
+
28
+ AGENT_EXTRA = "x-palette-agent"
29
+ AGENT_OPEN = "x-palette-open"
30
+
31
+
32
+ def agent_route(use: Literal["read", "write", "hidden"], *, opens: str | None = None) -> dict[str, str]:
33
+ """``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}")."""
35
+ if use not in ("read", "write", "hidden"):
36
+ raise ValueError("agent_route takes 'read', 'write' or 'hidden'")
37
+ extra = {AGENT_EXTRA: use}
38
+ if opens is not None:
39
+ if (not isinstance(opens, str) or not opens.startswith(("/", "?")) or len(opens) > 200 or "//" in opens
40
+ or ":" in opens.split("?")[0] or re.search(r"\s", opens)):
41
+ raise ValueError("opens is a path inside your app, like '/notes/{note_id}' or '?note={note_id}'")
42
+ extra[AGENT_OPEN] = opens
43
+ return extra