@palettelab/cli 0.3.68 → 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 +8 -5
  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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "palette-sdk"
3
- version = "0.1.17"
3
+ version = "0.1.18"
4
4
  description = "Palette Platform SDK for building backend plugins"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -130,13 +130,12 @@ Available context values:
130
130
  | `ctx.members` | Current organisation member client |
131
131
  | `ctx.notifications` | Push OS notification-center notifications |
132
132
  | `ctx.talk` | Post into Talk channels as the app's own agent (`chat:write`, seat required) |
133
- | `ctx.tasks` | The caller's task board, scoped to this app's own tasks (`tasks:read` / `tasks:write`) |
134
133
  | `ctx.apps` / `services(ctx)` | Governed app-to-app calls through declared `consumes` contracts |
135
134
  | `ctx.events` | Publish event topics declared in `provides.events` |
136
135
  | `ctx.jobs` | Enqueue, inspect, and cancel durable background jobs |
137
136
  | `ctx.redis` | Plugin/org-scoped Redis-style service when `platform_services` includes `redis` |
138
137
  | `ctx.vector` | Plugin/org-scoped vector service when `platform_services` includes `vector` |
139
- | `ctx.llm` | The platform's own model keys under an org spend cap when `platform_services` includes `llm` |
138
+ | `ctx.llm` | The platform's own model keys, billed to the workspace's credits, when `platform_services` includes `llm` |
140
139
  | `ctx.web` | Web search + SSRF-guarded page reader when `platform_services` includes `web` |
141
140
  | `ctx.media` | fal.ai on the platform's key — any model, any payload — when `platform_services` includes `media` |
142
141
  | `ctx.config` | App install/config values |
@@ -164,7 +163,6 @@ These are the public Python helpers exported by `palette_sdk`.
164
163
  | `OrganizationMembersClient`, `ctx.members` | Current-organization member lookup, invite, and role helpers |
165
164
  | `NotificationsClient`, `ctx.notifications` | Push notifications into the OS notification center |
166
165
  | `TalkClient`, `ctx.talk` | Post into Talk channels the app's agent is seated in |
167
- | `TasksClient`, `ctx.tasks` | The caller's task board, scoped to the tasks this app created |
168
166
  | `PluginConnectionsClient`, `ConnectionStatus`, `MissingConnectionError`, `ctx.connections` | Third-party connection status and tool calls (there is no token accessor — the platform holds the credential) |
169
167
  | `AppInteropClient`, `AppServiceClient`, `MissingAppServiceError`, `ctx.apps` | Call required apps/services without direct database access |
170
168
  | `service(...)`, `services(ctx)`, `ServicesClient`, `BrokerCallError` | Provide and consume OS-broker service methods/events |
@@ -367,7 +365,6 @@ async def dashboard(ctx: PluginContext = Depends(get_plugin_context)):
367
365
  Known permissions currently include:
368
366
 
369
367
  ```text
370
- tasks:read, tasks:write
371
368
  data_rooms:read, data_rooms:write
372
369
  agents:read, agents:write
373
370
  chat:read, chat:write
@@ -844,55 +841,6 @@ Available in request handlers, `@capability` methods, and background jobs.
844
841
  During `pltt dev` nothing reaches a real channel: the simulator reports one
845
842
  fake seat, logs each post as `[palette-talk] {...}`, and returns a stub message.
846
843
 
847
- ## 8c. The Task Board From Python
848
-
849
- `ctx.tasks` puts work on the caller's board and reads it back. Declare
850
- `tasks:read` / `tasks:write` in `permissions`:
851
-
852
- ```python
853
- @router.post("/queue-review", dependencies=[require_permission("tasks:write")])
854
- async def queue_review(ctx: PluginContext = Depends(get_plugin_context)):
855
- task = await ctx.tasks.create(
856
- "Review the Q3 supplier list",
857
- description="Flag anything over 50k.",
858
- priority="high",
859
- tags=["procurement"],
860
- due_date="2026-10-01T09:00:00Z",
861
- )
862
- return {"task_id": task["id"]}
863
-
864
-
865
- @router.post("/finish/{task_id}", dependencies=[require_permission("tasks:write")])
866
- async def finish(task_id: int, ctx: PluginContext = Depends(get_plugin_context)):
867
- # complete() also sets progress to 100 — a "completed" task still at 40% is
868
- # what makes a board stop being trusted.
869
- return await ctx.tasks.complete(task_id, output="12 suppliers checked, 2 flagged.")
870
- ```
871
-
872
- | Helper | Notes |
873
- |---|---|
874
- | `ctx.tasks.create(title, **fields)` | `description`, `status`, `priority`, `progress`, `tags`, `due_date`, `agent_id`, `parent_task_id`, `team_id` |
875
- | `ctx.tasks.list(status=None, limit=50)` | Newest first, capped at 200 |
876
- | `ctx.tasks.get(task_id)` | `None` when it is not this app's task |
877
- | `ctx.tasks.update(task_id, **fields)` | Same fields as `create`, plus `output` |
878
- | `ctx.tasks.complete(task_id, output=None)` | Sets `status="completed"` and `progress=100` |
879
- | `ctx.tasks.fail(task_id, output=None)` | Sets `status="failed"` |
880
- | `ctx.tasks.delete(task_id)` | Removes one of this app's tasks |
881
-
882
- **An app sees only its own tasks.** Every row is stamped with the app's id on
883
- create, and every other path re-checks that stamp. A task belonging to another
884
- app or to a person reads as *missing*, not as a permission error, so an app
885
- cannot probe the board for ids. Declaring `tasks:read` buys an app its own rows
886
- back, not the user's whole board, and the platform's own visibility rules still
887
- run underneath (a member sees their own tasks, an org admin the organisation's).
888
-
889
- Provenance fields — `app_id`, `source`, `source_channel`, `source_client`,
890
- `external_ref`, `routine_id` — are refused with a 422 rather than silently
891
- overwritten, so a caller cannot forge where a task came from.
892
-
893
- During `pltt dev` the board is an in-memory list for the life of the process,
894
- and each create is logged as `[palette-tasks] created {...}`.
895
-
896
844
  ## 9. Config And Secrets
897
845
 
898
846
  Use config for app install settings and secrets for sensitive values.
@@ -981,7 +929,7 @@ image_bytes, mime = await ctx.llm.image("a fox in the snow")
981
929
  # model, the budget and the token cap.
982
930
  strict = await ctx.llm.chat(messages, response_format={"type": "json_object"}, top_p=0.1)
983
931
  available = await ctx.llm.models() # what `model=` will honour ([] under SECURE)
984
- wallet = await ctx.llm.spend() # {"spent_usd", "cap_usd", "remaining_usd"}
932
+ wallet = await ctx.llm.spend() # wallet["workspace"]: the member's credits in the workspace
985
933
 
986
934
  # fal.ai on the platform's key — no FAL_KEY secret to ship or rotate.
987
935
  # `run` reaches ANY fal model and the payload is passed through untouched, so a
@@ -1032,12 +980,15 @@ Palette scopes every Redis key and vector operation by `plugin_id` and
1032
980
  `organization_id`; hosted previews also include the publish id. Plugin code
1033
981
  cannot read, list, update, or delete records owned by another app or org.
1034
982
 
1035
- `ctx.llm` and `ctx.media` draw on **one** monthly wallet per (app, organisation)
1036
- — separate ledgers would just let an app route around the cap it had already
1037
- exhausted. Both fail closed: past the cap the call raises
1038
- `PlatformServiceUnavailable` rather than spending. Call `ctx.llm.spend()` (or
1039
- `ctx.media.spend()` — the same wallet) to show the user why, instead of
1040
- surfacing a bare 503.
983
+ `ctx.llm` and `ctx.media` spend the **workspace's credits**, under its plan, seat
984
+ and member limits — the same gate a chat run passes, so an app can do what its
985
+ member could do in chat. When the workspace is out of credits the call raises
986
+ the billing `CreditError` (HTTP 402, `detail["code"]` such as `usage_exhausted`)
987
+ before anything runs. `ctx.llm.spend()["workspace"]` (or `ctx.media.spend()`)
988
+ shows the member's credits — `available`, `monthly_used`, `monthly_limit`,
989
+ `usage_state`, `execution_allowed` — so the app can say why instead of
990
+ surfacing a bare error. There is no per-app allowance unless the platform sets
991
+ one (`cap_usd`); past it the call raises `PlatformServiceUnavailable`.
1041
992
 
1042
993
  Under `pltt dev` there is no platform, so these run against your own
1043
994
  `OPENAI_API_KEY` / `FAL_KEY` when your `.env.local` has them and return
@@ -1277,6 +1228,7 @@ Advanced provider features are still available through scoped helpers:
1277
1228
  while blocking server/admin commands. `ctx.vector.client()` returns the Qdrant
1278
1229
  client for custom calls; combine it with `collection_name()`, `scoped_filter()`,
1279
1230
  `merge_filter()`, `scoped_payload()`, and `scoped_point()` to preserve isolation.
1231
+ 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.
1280
1232
 
1281
1233
  Common `ctx.redis` commands:
1282
1234
 
@@ -6,8 +6,9 @@ const { parseFlags, resolveEnvironment } = require("../environments")
6
6
  const KINDS = ["chat", "image", "video", "audio"]
7
7
  const USAGE = "usage: pltt models [--kind chat|image|video|audio] [--available] [--json] [--env <name>]"
8
8
 
9
- // The platform answers with THIS app's view: the manifest goes along so
10
- // declared premium models and capacity (platform_services.llm) are reflected.
9
+ // The platform answers with THIS app's view in the developer's workspace: the
10
+ // models its chat offers, and the workspace credits every call spends. The
11
+ // manifest goes along so declared capacity (platform_services.llm) is reflected.
11
12
  async function fetchModels(env, manifest) {
12
13
  const url = `${env.url}/api/v1/appstore/platform-models`
13
14
  const res = await fetch(url, {
@@ -47,15 +48,18 @@ async function run(argv, { cwd, log = console.log } = {}) {
47
48
  const data = await fetchModels(env, manifest)
48
49
  const rows = selectRows(data, { kind, available: argv.includes("--available") })
49
50
  if (argv.includes("--json")) {
50
- log(JSON.stringify({ app_id: data.app_id, organization_id: data.organization_id, models: rows }, null, 2))
51
+ log(JSON.stringify({ app_id: data.app_id, organization_id: data.organization_id, workspace: data.workspace ?? null, models: rows }, null, 2))
51
52
  return
52
53
  }
53
- log(`Models ${data.app_id} can use in workspace ${data.organization_id} (${env.name}):\n`)
54
- for (const row of rows) log(formatRow(row))
55
- const blocked = rows.filter((row) => row.reason === "not_approved").map((row) => row.id)
56
- if (blocked.length) {
57
- log(`\n Premium models need a declaration, e.g. platform_services.llm.models: ["${blocked[0]}"]`)
54
+ log(`Models ${data.app_id} can use in workspace ${data.organization_id} (${env.name}):`)
55
+ const credits = data.workspace
56
+ if (credits) {
57
+ const available = credits.available == null ? "unlimited" : credits.available.toFixed(2)
58
+ const refused = credits.execution_allowed === false ? " — calls are refused until the workspace has credits" : ""
59
+ log(` Workspace credits: ${available} available (${credits.usage_state})${refused}`)
58
60
  }
61
+ log("")
62
+ for (const row of rows) log(formatRow(row))
59
63
  log("\n Pass an id as ctx.llm.chat(..., model=...) or ctx.media.run(<id>, ...); fallback=False refuses substitutes.")
60
64
  }
61
65