@palettelab/cli 0.3.63 → 0.3.66

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 (43) hide show
  1. package/README.md +144 -9
  2. package/backend-sdk/palette_sdk/__init__.py +17 -1
  3. package/backend-sdk/palette_sdk/data_rooms.py +2 -2
  4. package/backend-sdk/palette_sdk/db/base.py +4 -1
  5. package/backend-sdk/palette_sdk/db/rls.py +7 -1
  6. package/backend-sdk/palette_sdk/manifest.py +9 -1
  7. package/backend-sdk/palette_sdk/platform_services.py +790 -36
  8. package/backend-sdk/palette_sdk/plugin_context.py +30 -2
  9. package/backend-sdk/palette_sdk/plugin_router.py +64 -8
  10. package/backend-sdk/palette_sdk/repository.py +12 -3
  11. package/backend-sdk/palette_sdk/tasks.py +117 -0
  12. package/backend-sdk/pyproject.toml +1 -1
  13. package/docs/python-backend-sdk.md +132 -8
  14. package/lib/cli.js +20 -2
  15. package/lib/commands/capabilities.js +1 -1
  16. package/lib/commands/doctor.js +15 -0
  17. package/lib/commands/models.js +65 -0
  18. package/lib/commands/platform.js +137 -0
  19. package/lib/commands/test.js +47 -4
  20. package/lib/dev-simulator.js +95 -0
  21. package/lib/manifest.js +123 -3
  22. package/package.json +1 -1
  23. package/template-fallback/README.md +9 -0
  24. package/template-fallback/frontend/src/translations.ts +2 -2
  25. package/template-fallback/package.json +1 -1
  26. package/template-fallback/palette-plugin.json +1 -0
  27. package/template-fallback/templates/agent-tool/palette-plugin.json +1 -0
  28. package/template-fallback/templates/consumer-app/package.json +1 -1
  29. package/template-fallback/templates/consumer-app/palette-plugin.json +1 -0
  30. package/template-fallback/templates/dashboard/package.json +1 -1
  31. package/template-fallback/templates/dashboard/palette-plugin.json +1 -0
  32. package/template-fallback/templates/database/package.json +1 -1
  33. package/template-fallback/templates/database/palette-plugin.json +1 -0
  34. package/template-fallback/templates/external-service/package.json +1 -1
  35. package/template-fallback/templates/external-service/palette-plugin.json +1 -0
  36. package/template-fallback/templates/frontend-only/package.json +1 -1
  37. package/template-fallback/templates/frontend-only/palette-plugin.json +1 -0
  38. package/template-fallback/templates/next/package.json +1 -1
  39. package/template-fallback/templates/next/palette-plugin.json +1 -0
  40. package/template-fallback/templates/palette-app/package.json +1 -1
  41. package/template-fallback/templates/palette-app/palette-plugin.json +1 -0
  42. package/template-fallback/templates/provider-app/package.json +1 -1
  43. package/template-fallback/templates/provider-app/palette-plugin.json +1 -0
package/README.md CHANGED
@@ -308,13 +308,14 @@ async def create_invoice(body: InvoiceIn, ctx: PluginContext = Depends(get_plugi
308
308
 
309
309
  Backend SDK features for app-owned data:
310
310
 
311
- - `PluginRouter`, `PluginContext`, and `get_plugin_context` provide the FastAPI route and request-context surface.
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.web`, `ctx.config`, and `ctx.logger`.
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`.
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.
318
319
  - `ctx.has_permission("...")`, `ctx.has_any_permission([...])`, and `ctx.has_all_permissions([...])` check declared permissions.
319
320
  - `ctx.config_value("key")` and `ctx.require_config("key")` read app install/config values.
320
321
  - `ctx.secret("KEY")` reads app secrets from config or environment variables.
@@ -323,8 +324,11 @@ Backend SDK features for app-owned data:
323
324
  - `ctx.redis` gives a Redis-backed, plugin/org-scoped Redis API when `"redis"` is declared in `platform_services`.
324
325
  - `ctx.vector` gives a Qdrant-backed, plugin/org-scoped vector API when `"vector"` is declared in `platform_services`.
325
326
  - `ctx.storage` gives app/org-scoped file upload helpers when `"storage"` is declared in `platform_services`.
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. The platform picks the model (an app cannot select the premium tier or bypass the org's SECURE policy), meters spend per organisation and app, and raises once the monthly budget is spent.
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.
328
+ - `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`.
327
330
  - `ctx.web` gives web search and an SSRF-guarded page reader (HTML tables and PDFs handled) when `"web"` is declared.
331
+ - `pltt platform list` prints every service above with a snippet and its `pltt dev` mode; `pltt platform enable <name>` writes the manifest declaration.
328
332
  - `ctx.connections` gives the viewer's OS service connections — see `pltt connections`.
329
333
  - `@job(...)`, `JobExecution`, and `ctx.jobs` provide durable async work with retries, progress, status, and cancellation.
330
334
  - `LifecycleHooks` lets apps define install/update/enable/disable/uninstall hooks.
@@ -569,10 +573,15 @@ Templates:
569
573
  - `dashboard`
570
574
  - `palette-app`
571
575
  - `next`
572
- - `agent-tool`
576
+ - `agent-tool` (`agent-ready` is an alias)
573
577
  - `external-service`
574
578
  - `database`
575
579
  - `frontend-only`
580
+ - `provider-app` — publishes OS-broker services for other apps
581
+ - `consumer-app` — consumes another app's services/events
582
+
583
+ `pltt init` clones the official template repository and falls back to the
584
+ bundled copy under `template-fallback/` when git or the network is unavailable.
576
585
 
577
586
  ### Palette App Router
578
587
 
@@ -683,6 +692,13 @@ For developer sandboxes where manual approval should not block OS testing, run t
683
692
  `pltt preview --env staging` is also supported as a developer-friendly alias
684
693
  for the same hosted preview flow.
685
694
 
695
+ `pltt dev --sandbox --watch` keeps the preview alive after publishing: the CLI
696
+ rebuilds the frontend entry on every save and pushes the new bundle onto the
697
+ existing preview record, so the hosted OS shows the change without a second
698
+ publish or review. Only frontend changes are live-pushed; backend changes need
699
+ a re-run. `--ttl-hours <n>` overrides the 24-hour preview TTL and `--json`
700
+ emits the publish record instead of the human log.
701
+
686
702
  `pltt dev --platform` runs the full Docker `platform-dev` image for internal platform parity testing. App developers should not need it. It pulls `ghcr.io/palette-lab/platform-dev:latest` and mounts your plugin at `/plugins/<your-id>`.
687
703
 
688
704
  Environment variables:
@@ -733,7 +749,7 @@ install-scoped values or labels/help text:
733
749
  "STRIPE_SECRET": { "scope": "plugin", "required": true },
734
750
  "DEBUG_PROBE_URL": { "scope": "dev", "required": false }
735
751
  },
736
- "platform_services": ["llm", "redis", "storage", "vector", "web"]
752
+ "platform_services": ["llm", "media", "redis", "storage", "vector", "web"]
737
753
  }
738
754
  ```
739
755
 
@@ -827,9 +843,16 @@ Save a Palette sandbox or production environment URL plus token in `~/.palette/c
827
843
 
828
844
  ```bash
829
845
  pltt login --env staging --url https://sandbox.pltt.ai --token <publish-token>
846
+ pltt login --env production --url https://palette.example.com --token <token> --no-default
830
847
  pltt dev --sandbox --env staging
831
848
  ```
832
849
 
850
+ The saved environment becomes the default for `--env`-less commands unless
851
+ `--no-default` is passed. `--url` and `--token` fall back to
852
+ `PALETTE_PLATFORM_URL` / `PALETTE_<ENV>_URL` and `PALETTE_PUBLISH_TOKEN` /
853
+ `PALETTE_<ENV>_TOKEN` (`PALETTE_PROD_TOKEN` for `production`). `--json` prints
854
+ the saved record.
855
+
833
856
  ### `pltt version`
834
857
 
835
858
  Show the installed `pltt` CLI version.
@@ -866,7 +889,13 @@ Check local tooling and common setup problems.
866
889
  pltt doctor
867
890
  ```
868
891
 
869
- Checks include Node version, port availability, manifest validity, entry files, and frontend bundling.
892
+ Checks include Node version, port availability, manifest validity, entry files,
893
+ and frontend bundling. It also reports every declared platform service with the
894
+ mode `pltt dev` will run it in (live via your own key, or stubbed), names the
895
+ available set when an app declares none, and warns when a manifest declares a
896
+ permission that gates nothing today (`agents:*`, `routines:*`, `resources:*`) —
897
+ those stay valid so published manifests keep working, but a reviewer reading
898
+ "agents:write" on an app should not believe it can write agents.
870
899
 
871
900
  Docker is intentionally skipped by default:
872
901
 
@@ -920,9 +949,11 @@ pltt publish --env production
920
949
  pltt publish --env production -y
921
950
  pltt publish --env staging --json
922
951
  pltt publish --env staging --ttl-hours 24
952
+ pltt publish --env staging --preview
923
953
  ```
924
954
 
925
- Publishing first runs the same contract checks as `pltt test`. Preview publishes skip the release semver bump check, while release publishes still require a version newer than the last release. If preflight passes, it bundles frontend/backend artifacts, uploads them, creates a review record, and prints review/preview URLs when the platform returns them.
955
+ `--preview` (or `--publish-type preview`) publishes a reviewable preview
956
+ instead of a release; `--release` is the default. Publishing first runs the same contract checks as `pltt test`. Preview publishes skip the release semver bump check, while release publishes still require a version newer than the last release. If preflight passes, it bundles frontend/backend artifacts, uploads them, creates a review record, and prints review/preview URLs when the platform returns them.
926
957
 
927
958
  `--ttl-hours` sets an expiration on the preview URL. It is mainly used by `pltt dev --sandbox`, which defaults previews to 24 hours.
928
959
 
@@ -952,6 +983,88 @@ pltt logs --json
952
983
 
953
984
  If no plugin ID is provided, the CLI uses the current `palette-plugin.json` or `.palette/last-publish.json`.
954
985
 
986
+ ### `pltt open`
987
+
988
+ Open the preview URL from the last publish in your default browser.
989
+
990
+ ```bash
991
+ pltt dev --sandbox --env staging
992
+ pltt open
993
+ ```
994
+
995
+ Reads `.palette/last-publish.json`; fails with a hint when no publish has run
996
+ yet or the last publish returned no preview URL.
997
+
998
+ ### `pltt platform`
999
+
1000
+ The services the **platform** lends your app through `ctx.*`. Declaring one is
1001
+ what replaces shipping an API key: the platform's own credential is used,
1002
+ metered per organisation, and the installing org has nothing to paste in.
1003
+
1004
+ ```bash
1005
+ pltt platform list # every ctx.* service, a snippet, and its pltt dev mode
1006
+ pltt platform list --json
1007
+ pltt platform enable llm media # writes platform_services into palette-plugin.json
1008
+ pltt platform disable web
1009
+ ```
1010
+
1011
+ | Service | Replaces | `ctx.*` |
1012
+ |---|---|---|
1013
+ | `llm` | `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` | chat with tool calls, streaming, embeddings, image generation; receipts name the model that ran |
1014
+ | `media` | `FAL_KEY` | fal.ai — image, video, speech, transcription, any model fal publishes; `upload()` for private inputs |
1015
+ | `web` | `TAVILY_API_KEY` / `SERPAPI_KEY` | search + SSRF-guarded page reader |
1016
+ | `storage` | an S3/GCS bucket | per-app, per-org objects with resumable uploads |
1017
+ | `vector` | a Pinecone/Qdrant account | namespaced vector search |
1018
+ | `redis` | `REDIS_URL` | KV, lists, sets, sorted sets, counters, locks |
1019
+
1020
+ `list` also prints the **permission-gated** clients — `ctx.tasks`,
1021
+ `ctx.data_rooms`, `ctx.members`, `ctx.talk` — and whether your manifest has
1022
+ granted them, so "what can `ctx` do, and what do I declare to get it" is one
1023
+ answer.
1024
+
1025
+ Notes:
1026
+
1027
+ - `enable` preserves the object form, so per-service `billing` / `required`
1028
+ 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.
1031
+ - Under `pltt dev` there is no platform: `llm` and `media` use your own
1032
+ `OPENAI_API_KEY` / `FAL_KEY` when `.env.local` has them and return
1033
+ deterministic stubs when it does not. `pltt doctor` prints which mode each
1034
+ one is in.
1035
+
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.
1039
+
1040
+ `pltt platform` is about what the *platform* provides. For app-to-app contracts
1041
+ see `pltt services`; for third-party accounts the *user* connected see
1042
+ `pltt connections`.
1043
+
1044
+ ### `pltt models`
1045
+
1046
+ The chat, image, video and audio models your app can use **in your workspace
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).
1050
+
1051
+ ```bash
1052
+ pltt models # every model: provider, kind, limits, why not
1053
+ pltt models --kind image --available # only the image models you can run
1054
+ pltt models --json --env staging
1055
+ ```
1056
+
1057
+ ```text
1058
+ 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)
1060
+ ok fal-ai/nano-banana/edit fal image image-to-image
1061
+ ```
1062
+
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
1066
+ `fallback=False` call raises as `ModelUnavailable`.
1067
+
955
1068
  ### `pltt connections`
956
1069
 
957
1070
  Use the third-party services the OS already holds — Gmail, Drive, Calendar,
@@ -1016,7 +1129,7 @@ pltt services pull --env staging
1016
1129
  pltt services scaffold approvalChain.get
1017
1130
  pltt capabilities add creative.poster.generate --method poster.generate --risk write --effects artifact.create --idempotent
1018
1131
  pltt capabilities list
1019
- pltt test --agent
1132
+ pltt test
1020
1133
  ```
1021
1134
 
1022
1135
  Subcommands:
@@ -1065,9 +1178,31 @@ Provider methods can use inline JSON Schema objects or schema file paths in
1065
1178
  `schema` or `payload_schema`. The CLI scaffolds schema files by default because
1066
1179
  they are easier to review and reuse for generated clients.
1067
1180
 
1181
+ ### `pltt capabilities`
1182
+
1183
+ Manage agent-callable capabilities: provider methods that Palette agents may
1184
+ invoke or schedule on the user's behalf. `pltt capability` is an alias.
1185
+
1186
+ ```bash
1187
+ pltt capabilities list [--json]
1188
+ pltt capabilities inspect creative.poster.generate
1189
+ pltt capabilities add creative.poster.generate --method poster.generate --risk write --effects artifact.create --idempotent
1190
+ pltt capabilities add reports.export --risk read
1191
+ pltt capabilities add mail.send --risk write --no-scheduling
1192
+ ```
1193
+
1194
+ Subcommands:
1195
+
1196
+ - `list`: agent-exposable methods declared in `provides.services`, with their `capability_id`, risk, effects, and scheduling flags.
1197
+ - `inspect <capability_id>`: the full manifest entry for one capability.
1198
+ - `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.
1199
+
1200
+ `pltt test` verifies every agent capability has a stable `capability_id` and a
1201
+ matching `@capability(...)` / `service(..., agent_exposable=True)` handler.
1202
+
1068
1203
  ## Global Flags
1069
1204
 
1070
- - `--json` emits machine-readable output for `package`, `publish`, `status`, `logs`, `test`, `update`, and `version`.
1205
+ - `--json` emits machine-readable output for `package`, `publish`, `status`, `logs`, `test`, `update`, `version`, `login`, `dev --sandbox`, `platform list`, `services list`, and `capabilities`.
1071
1206
  - `-v, --version` prints the installed `pltt` CLI version.
1072
1207
  - `--env <name>` selects a configured publish/status/logs environment.
1073
1208
  - `-y, --yes` skips production publish confirmation.
@@ -9,9 +9,17 @@ from palette_sdk.members import OrganizationMembersClient
9
9
  from palette_sdk.notifications import NotificationRecipient, NotificationsClient
10
10
  from palette_sdk.organization import OrganizationInfo
11
11
  from palette_sdk.talk import TalkClient
12
+ from palette_sdk.tasks import TasksClient
12
13
  from palette_sdk.platform_services import (
14
+ LocalLLMService,
15
+ LocalMediaService,
13
16
  LocalRedisService,
14
17
  LocalVectorService,
18
+ LocalWebService,
19
+ MediaRateLimited,
20
+ MediaStillRunning,
21
+ MediaSubmitInterrupted,
22
+ ModelUnavailable,
15
23
  PlatformServiceUnavailable,
16
24
  UnavailablePlatformService,
17
25
  )
@@ -81,8 +89,16 @@ __all__ = [
81
89
  "NotificationsClient",
82
90
  "NotificationRecipient",
83
91
  "TalkClient",
92
+ "TasksClient",
93
+ "LocalLLMService",
94
+ "LocalMediaService",
84
95
  "LocalRedisService",
85
96
  "LocalVectorService",
97
+ "LocalWebService",
98
+ "MediaRateLimited",
99
+ "MediaStillRunning",
100
+ "MediaSubmitInterrupted",
101
+ "ModelUnavailable",
86
102
  "PlatformServiceUnavailable",
87
103
  "UnavailablePlatformService",
88
104
  "OrgRepository",
@@ -138,4 +154,4 @@ __all__ = [
138
154
  "LocalStorageService",
139
155
  ]
140
156
 
141
- __version__ = "0.1.12"
157
+ __version__ = "0.1.16"
@@ -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`,
@@ -227,6 +227,13 @@ class ConsumesSpec(BaseModel):
227
227
  class PlatformServiceSpec(BaseModel):
228
228
  required: bool = False
229
229
  billing: Literal["org_wallet", "plugin_owner", "platform"] | None = None
230
+ # llm only — premium models (gpt-6-astra, claude-opus-*, claude-fable-*)
231
+ # and the capacity the app needs, declared where the publish review sees
232
+ # them and bounded by the platform. Without them: standard models, 4096
233
+ # output tokens and 4 images per call.
234
+ models: list[str] | None = Field(default=None, max_length=50)
235
+ max_output_tokens: int | None = Field(default=None, ge=0, le=200_000)
236
+ max_images: int | None = Field(default=None, ge=0, le=100)
230
237
 
231
238
 
232
239
  class McpToolSpec(BaseModel):
@@ -321,6 +328,7 @@ class PluginManifest(BaseModel):
321
328
  id: str
322
329
  name: str
323
330
  version: str = "1.0.0"
331
+ data_scope: Literal["personal", "organization"] = "personal"
324
332
  developer: str = ""
325
333
  category: str = "Productivity"
326
334
  tagline: str = ""
@@ -344,7 +352,7 @@ class PluginManifest(BaseModel):
344
352
  requires: RequiresSpec | None = None
345
353
  consumes: ConsumesSpec | None = None
346
354
  mcp: McpSpec | None = None
347
- platform_services: list[Literal["llm", "redis", "storage", "vector", "web"]] | dict[str, PlatformServiceSpec] = Field(default_factory=list)
355
+ platform_services: list[Literal["llm", "media", "redis", "storage", "vector", "web"]] | dict[str, PlatformServiceSpec] = Field(default_factory=list)
348
356
  rating: float = 0.0
349
357
  reviews: int = 0
350
358
  featured: bool = False