@palettelab/cli 0.3.75 → 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.
Files changed (53) hide show
  1. package/README.md +37 -5
  2. package/backend-sdk/palette_sdk/__init__.py +1 -1
  3. package/backend-sdk/palette_sdk/agent_routes.py +28 -2
  4. package/backend-sdk/palette_sdk/apps.py +16 -1
  5. package/backend-sdk/palette_sdk/connections_generated.py +27 -0
  6. package/backend-sdk/palette_sdk/data_rooms.py +59 -0
  7. package/backend-sdk/palette_sdk/manifest.py +10 -0
  8. package/backend-sdk/palette_sdk/mcp.py +11 -2
  9. package/backend-sdk/palette_sdk/platform_services.py +81 -15
  10. package/backend-sdk/palette_sdk/tool_definition.py +21 -1
  11. package/backend-sdk/pyproject.toml +1 -1
  12. package/docs/connectors.md +154 -0
  13. package/docs/python-backend-sdk.md +113 -4
  14. package/lib/bundler.js +5 -2
  15. package/lib/cli.js +2 -2
  16. package/lib/commands/capabilities.js +30 -9
  17. package/lib/commands/check.js +7 -0
  18. package/lib/commands/package.js +5 -1
  19. package/lib/commands/publish.js +17 -0
  20. package/lib/commands/test.js +15 -3
  21. package/lib/connection-catalog.json +167 -0
  22. package/lib/connector.js +148 -0
  23. package/lib/manifest.js +22 -1
  24. package/package.json +1 -1
  25. package/template-fallback/backend/api/main.py +4 -2
  26. package/template-fallback/backend/tools/example_tool.py +4 -0
  27. package/template-fallback/package.json +1 -1
  28. package/template-fallback/palette-plugin.json +4 -0
  29. package/template-fallback/templates/agent-tool/README.md +3 -0
  30. package/template-fallback/templates/agent-tool/palette-plugin.json +4 -0
  31. package/template-fallback/templates/agent-tool/skills/echo-check/SKILL.md +15 -0
  32. package/template-fallback/templates/consumer-app/backend/api/main.py +3 -2
  33. package/template-fallback/templates/consumer-app/package.json +1 -1
  34. package/template-fallback/templates/consumer-app/palette-plugin.json +4 -0
  35. package/template-fallback/templates/dashboard/backend/api/main.py +2 -2
  36. package/template-fallback/templates/dashboard/package.json +1 -1
  37. package/template-fallback/templates/dashboard/palette-plugin.json +4 -0
  38. package/template-fallback/templates/database/backend/api/main.py +3 -3
  39. package/template-fallback/templates/database/package.json +1 -1
  40. package/template-fallback/templates/database/palette-plugin.json +4 -0
  41. package/template-fallback/templates/external-service/backend/api/main.py +3 -2
  42. package/template-fallback/templates/external-service/package.json +1 -1
  43. package/template-fallback/templates/external-service/palette-plugin.json +4 -0
  44. package/template-fallback/templates/frontend-only/package.json +1 -1
  45. package/template-fallback/templates/frontend-only/palette-plugin.json +4 -0
  46. package/template-fallback/templates/next/package.json +1 -1
  47. package/template-fallback/templates/next/palette-plugin.json +4 -0
  48. package/template-fallback/templates/palette-app/backend/api/main.py +2 -2
  49. package/template-fallback/templates/palette-app/package.json +1 -1
  50. package/template-fallback/templates/palette-app/palette-plugin.json +4 -0
  51. package/template-fallback/templates/provider-app/backend/api/main.py +2 -2
  52. package/template-fallback/templates/provider-app/package.json +1 -1
  53. package/template-fallback/templates/provider-app/palette-plugin.json +5 -0
@@ -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.
@@ -159,13 +159,14 @@ These are the public Python helpers exported by `palette_sdk`.
159
159
  | `PluginContext`, `get_plugin_context` | Authenticated request context dependency |
160
160
  | `MissingSecretError` | Handling missing required declared secrets from `ctx.secret(...)` |
161
161
  | `require_permission(permission)` | Route-level permission gate required for protected routes |
162
+ | `agent_route(use, name=, description=, opens=)` | Say how assistants may use a route: `read`, `write` or `hidden` (see 5a) |
162
163
  | `KNOWN_PERMISSIONS`, `is_known_permission(...)` | Permission vocabulary checks for manifests/tools |
163
- | `DataRoomsClient`, `ctx.data_rooms` | Backend Data Room room/folder/file helpers |
164
+ | `DataRoomsClient`, `ctx.data_rooms` | Backend Data Room room/folder/file and share-link helpers |
164
165
  | `OrganizationMembersClient`, `ctx.members` | Current-organization member lookup, invite, and role helpers |
165
166
  | `NotificationsClient`, `ctx.notifications` | Push notifications into the OS notification center |
166
167
  | `TalkClient`, `ctx.talk` | Post into Talk channels the app's agent is seated in |
167
168
  | `PluginConnectionsClient`, `ConnectionStatus`, `MissingConnectionError`, `ctx.connections` | Third-party connection status and tool calls (there is no token accessor — the platform holds the credential) |
168
- | `AppInteropClient`, `AppServiceClient`, `MissingAppServiceError`, `ctx.apps` | Call required apps/services without direct database access |
169
+ | `AppInteropClient`, `AppServiceClient`, `MissingAppServiceError`, `ctx.apps` | Call required apps/services without direct database access. The path-style `ctx.apps.call(app_id, path)` is deprecated; use `services(ctx).call("namespace/version#method", payload)` |
169
170
  | `service(...)`, `services(ctx)`, `ServicesClient`, `BrokerCallError` | Provide and consume OS-broker service methods/events |
170
171
  | `OrgRepository`, `ctx.repo(Model)` | Org-safe convenience CRUD for app-owned models |
171
172
  | `PluginBase`, `OrgScopedTable` | SQLAlchemy declarative bases for plugin-owned tables |
@@ -175,14 +176,14 @@ These are the public Python helpers exported by `palette_sdk`.
175
176
  | `ctx.llm`, `ctx.media`, `ctx.web`, `ctx.email` | The platform's model, fal.ai, web-search and email-provider keys, declared in `platform_services` |
176
177
  | `MediaStillRunning` | `ctx.media.run` gave up waiting; carries `request_id` to collect the render later |
177
178
  | `LocalLLMService`, `LocalMediaService`, `LocalWebService`, `LocalEmailService`, `LocalRedisService`, `LocalVectorService`, `LocalStorageService` | Local `pltt dev` service emulators and test fakes |
178
- | `McpClient`, `mcp_tool(...)`, `mcp_resource(...)`, `mcp_prompt(...)` | Provide and consume MCP tools, resources and prompts |
179
+ | `McpClient`, `mcp_tool(...)`, `mcp_resource(...)`, `mcp_prompt(...)` | Provide and consume MCP tools. `mcp_resource` and `mcp_prompt` are inert: recorded, not served |
179
180
  | `PlatformServiceUnavailable`, `UnavailablePlatformService` | Clear errors when an undeclared platform service is used |
180
181
  | `LifecycleHooks` | Install/update/enable/disable/uninstall callbacks |
181
182
  | `Event`, `EventPublisher`, `subscribe_event(...)` | In-process event subscriptions and declared app event publishing |
182
183
  | `job(...)`, `JobExecution` | Register durable async job handlers and report progress, heartbeat, or cancellation |
183
184
  | `JobHandle`, `JobsClient`, `ctx.jobs` | Enqueue jobs and inspect or cancel runs without retaining request state |
184
185
  | `sign_webhook(...)`, `verify_webhook_signature(...)` | HMAC-SHA256 webhook signing and verification |
185
- | `ToolDefinition` | Base class for custom agent tools |
186
+ | `ToolDefinition` | Deprecated base class for custom agent tools; use `@capability(...)` with an `agent_exposable` `provides.services` method |
186
187
  | `PluginManifest`, `load_manifest(...)` | Typed manifest parsing from `palette-plugin.json` |
187
188
  | `SuccessResponse`, `ErrorResponse`, `PaginatedResponse` | Common response schemas for plugin APIs |
188
189
  | `route_permission_issues(router, public_routes=None)` | Test helper that reports routes missing `require_permission(...)` |
@@ -390,6 +391,52 @@ async def invite_member(email: str, ctx: PluginContext = Depends(get_plugin_cont
390
391
  `invite(email, role="member")`, and `update_role(user_id, role)`. Member
391
392
  deletion/removal is intentionally not exposed through the app SDK.
392
393
 
394
+ ## 5a. Routes The Agent Can Use
395
+
396
+ Your routes are tools for assistants and for your app's own agent: the platform calls them in-process as the member,
397
+ through the same `require_permission` checks and data partition as your screens. What an assistant sees is each
398
+ route's path, query parameters, request model and the first line of its docstring, so write those for a reader. Say
399
+ how each route may be used with `agent_route(...)` in `openapi_extra`:
400
+
401
+ ```python
402
+ from palette_sdk import agent_route
403
+
404
+ @router.get("/notes", dependencies=[require_permission("resources:read")],
405
+ openapi_extra=agent_route("read"))
406
+ async def list_notes(q: str = "", ctx: PluginContext = Depends(get_plugin_context)):
407
+ """List my notes, newest first; q searches title and body."""
408
+
409
+ @router.post("/notes/search", dependencies=[require_permission("resources:read")],
410
+ openapi_extra=agent_route("read", name="search_notes",
411
+ description="Search my notes by title and body."))
412
+ async def search(...): ...
413
+
414
+ @router.get("/notes/{note_id}", dependencies=[require_permission("resources:read")],
415
+ openapi_extra=agent_route("read", opens="/notes/{note_id}"))
416
+ async def get_note(note_id: int, ctx: PluginContext = Depends(get_plugin_context)): ...
417
+
418
+ @router.post("/admin/reindex", dependencies=[require_permission("resources:write")],
419
+ openapi_extra=agent_route("hidden"))
420
+ async def reindex(...): ...
421
+ ```
422
+
423
+ | Argument | Meaning |
424
+ |---|---|
425
+ | `use` | `"read"` runs at once; `"write"` is a change, staged as an approval card before it runs; `"hidden"` is never offered |
426
+ | `name` | The tool's stable name instead of one built from the path: lowercase letters, digits and underscores, at most 64 characters |
427
+ | `description` | What an assistant reads to choose the tool, instead of the docstring: 1 to 500 characters |
428
+ | `opens` | On a route that reads one item, where the item lives in your screens: `"/notes/{note_id}"` or `"?note={note_id}"`, with the route's own path parameters |
429
+
430
+ A bad value raises `ValueError` when the module loads. A route with no mark is still offered, a `GET` as a read and
431
+ anything else as a change, and `pltt check` warns about it (`connector.route_unmarked`); `include_in_schema=False`
432
+ hides a route too. Keep `name` the same between versions: a member's per-tool switches and permission rules are keyed
433
+ by it. With `opens`, a card for the item opens your app at `/apps/<your app id>/notes/42` and your app receives
434
+ `/notes/42` as `platform.routePath`. A file response (`Content-Disposition: attachment`) is attached to the agent's
435
+ reply, and an upload route accepts a file the member attached in the conversation.
436
+
437
+ Routes are one part of your app as a connector; the `agent` block, typed capabilities, skills and event triggers are
438
+ in [Your App As A Connector](./connectors.md).
439
+
393
440
  ## 6. App-Owned Data
394
441
 
395
442
  Apps can ship their own tables and migrations. Use `OrgScopedTable` for data
@@ -717,6 +764,57 @@ async def room_contents(ctx: PluginContext = Depends(get_plugin_context)):
717
764
  return contents
718
765
  ```
719
766
 
767
+ ### Share A File Or Folder Outside The Workspace
768
+
769
+ Share a file, a folder or the whole room with people outside the workspace
770
+ through a link, `{frontend}/l/{token}`. The call acts as the member making the
771
+ request, who needs edit permission on the room (or to own it). With no gate
772
+ set, anyone holding the link opens it without signing in to Palette, so pick
773
+ the gates the content needs:
774
+
775
+ ```python
776
+ from datetime import datetime, timedelta, timezone
777
+
778
+ @router.post("/share-report", dependencies=[require_permission("data_rooms:write")])
779
+ async def share_report(ctx: PluginContext = Depends(get_plugin_context)):
780
+ room = await ctx.data_rooms.require_room_by_name("Finance")
781
+ f = await ctx.data_rooms.find_file_by_name(room["id"], "q3-report.pdf")
782
+ link = await ctx.data_rooms.create_link(
783
+ room["id"],
784
+ file_id=f["id"], # folder_id=... for a folder; neither for the whole room
785
+ verify_email=True, # a 6-digit code mailed to the viewer proves the address
786
+ allowed_viewers=["@acme.com"], # addresses or @domains
787
+ allow_download=False,
788
+ expires_at=datetime.now(timezone.utc) + timedelta(days=14),
789
+ )
790
+ return {"url": link["url"]}
791
+ ```
792
+
793
+ Settings, all optional:
794
+
795
+ - `name`: your label for the link (at most 120 characters), never shown to viewers.
796
+ - `require_login`: the viewer signs in to Palette OS; their account's email is their identity.
797
+ - `require_email`: the viewer enters their email.
798
+ - `verify_email`: the email is proven by a 6-digit code mailed to it (implies `require_email`).
799
+ - `allowed_viewers`: only these addresses (`"ann@acme.com"`) or domains (`"@acme.com"`), at most 100 (implies `require_email`).
800
+ - `password`: 4 to 128 characters, stored hashed and never returned (a link carries `has_password`).
801
+ - `allow_download`: default `True`; when `False`, downloads are refused and the viewer page shows no download button.
802
+ - `notify_on_view`: email the sharer when someone opens the link, at most once an hour per viewer.
803
+ - `watermark`: the viewer's email and the time over the content.
804
+ - `screenshot_protection`: the page blurs when its window loses focus and blocks printing and right-click (deterrence only).
805
+ - `agreement`: text, such as an NDA, the viewer must accept first (at most 10,000 characters).
806
+ - `expires_at`: a `datetime` or ISO string in the future; afterwards the link answers "expired".
807
+
808
+ A link is a dict with `id`, `url`, `token`, `target` (`"file"`, `"folder"` or
809
+ `"room"`), `target_name`, the settings above except `password`, `has_password`, `expired`,
810
+ `view_count`, `last_viewed_at`, `created_by`, `created_by_name` and
811
+ `created_at`. `list_links(room_id)` returns the room's links, newest first
812
+ (`file_id=` or `folder_id=` keeps one item's). `update_link(room_id, link_id,
813
+ **changes)` changes only the keys passed; `None` removes a password, an
814
+ agreement or an expiry. `delete_link(room_id, link_id)` stops the link at once.
815
+ Unknown keys are refused. On a platform without share links the helpers raise
816
+ `RuntimeError`.
817
+
720
818
  Available Data Room helpers:
721
819
 
722
820
  ```python
@@ -755,6 +853,10 @@ await ctx.data_rooms.upload_file(
755
853
  content_type=None,
756
854
  public=False, # True: every member of the organisation can read it
757
855
  )
856
+ await ctx.data_rooms.list_links(room_id, file_id=None, folder_id=None)
857
+ await ctx.data_rooms.create_link(room_id, file_id=None, folder_id=None, **settings)
858
+ await ctx.data_rooms.update_link(room_id, link_id, **changes)
859
+ await ctx.data_rooms.delete_link(room_id, link_id)
758
860
  ```
759
861
 
760
862
  Uploads are private to the room's members. With `public=True` every member of
@@ -975,6 +1077,13 @@ except MediaStillRunning as pending:
975
1077
  job = await ctx.media.submit("fal-ai/kling-video/v3/pro/text-to-video", {"prompt": "…"})
976
1078
  state = await ctx.media.status(job["request_id"], model=job["model"])
977
1079
 
1080
+ # A model that answers in a second or two (SAM on a click): one request to fal's
1081
+ # synchronous endpoint, no queue and no polls. timeout defaults to 60 s; no handle.
1082
+ mask = await ctx.media.run("fal-ai/sam-3/image", {"image_url": url, "prompt": "shoe"}, sync=True)
1083
+
1084
+ # fal refusing a call: ValueError (4xx, change the request) or PlatformServiceUnavailable
1085
+ # (5xx, try again later), both with .status_code; read it with getattr(exc, "status_code", None).
1086
+
978
1087
  # Web search + reader (HTML tables and PDFs already handled).
979
1088
  hits = await ctx.web.search("palette os changelog", limit=5)
980
1089
  text = await ctx.web.fetch("https://example.com/report.pdf")
package/lib/bundler.js CHANGED
@@ -690,8 +690,11 @@ async function bundleBackend(pluginDir, options = {}) {
690
690
 
691
691
  const backendDir = path.join(pluginDir, "backend")
692
692
  if (fs.existsSync(backendDir)) copy(backendDir, path.join(stage, "backend"))
693
- const schemasDir = path.join(pluginDir, "schemas")
694
- if (fs.existsSync(schemasDir)) copy(schemasDir, path.join(stage, "schemas"))
693
+ // schemas/ are the broker contracts; skills/ are the app's recipes for assistants, reviewed at publish.
694
+ for (const folder of ["schemas", "skills"]) {
695
+ const dir = path.join(pluginDir, folder)
696
+ if (fs.existsSync(dir)) copy(dir, path.join(stage, folder))
697
+ }
695
698
  for (const metadataFile of ["package.json", "pyproject.toml", "palette-plugin.json"]) {
696
699
  if (metadataFile === "palette-plugin.json" && options.manifest) continue
697
700
  const src = path.join(pluginDir, metadataFile)
package/lib/cli.js CHANGED
@@ -92,7 +92,7 @@ const COMMANDS = {
92
92
  },
93
93
  capabilities: {
94
94
  run: capabilities,
95
- help: "Add, list, or inspect agent-callable app capabilities",
95
+ help: "Show the app as a connector (tools, instructions, skills, events); add or inspect capabilities",
96
96
  },
97
97
  agent: {
98
98
  run: agent,
@@ -143,7 +143,7 @@ function printHelp() {
143
143
  console.log(" pltt services pull # generate typed TS+Python clients from consumes")
144
144
  console.log(" pltt services scaffold NAME # add a provider method (schemas + handler stub)")
145
145
  console.log("\nAgent capabilities:")
146
- console.log(" pltt capabilities list")
146
+ console.log(" pltt capabilities list # the connector as an assistant will see it")
147
147
  console.log(" pltt capabilities inspect CAPABILITY_ID")
148
148
  console.log(" pltt capabilities add creative.poster.generate --risk write --idempotent")
149
149
  console.log("\nSecrets:")
@@ -1,6 +1,7 @@
1
1
  "use strict"
2
2
 
3
3
  const { loadManifest } = require("../manifest")
4
+ const connector = require("../connector")
4
5
  const servicesCommand = require("./services")
5
6
 
6
7
  function valueAfter(args, flag) {
@@ -93,7 +94,7 @@ function collect(manifest) {
93
94
  return out
94
95
  }
95
96
 
96
- async function run(args, { cwd }) {
97
+ async function run(args, { cwd, log = console.log }) {
97
98
  const manifest = loadManifest(cwd)
98
99
  const json = args.includes("--json")
99
100
  const positional = args.filter((arg) => !arg.startsWith("-"))
@@ -130,20 +131,40 @@ async function run(args, { cwd }) {
130
131
  return
131
132
  }
132
133
  if (command !== "list") throw new Error("usage: pltt capabilities [list | inspect <id> | add <id>] [--json]")
134
+ // The connector as an agent will see it: what the app says about itself, its tools, skills and events.
135
+ const view = connector.view(cwd, manifest)
133
136
  if (json) {
134
- console.log(JSON.stringify({ app_id: manifest.id, capabilities }, null, 2))
137
+ log(JSON.stringify({ app_id: manifest.id, capabilities, ...view }, null, 2))
135
138
  return
136
139
  }
137
- if (!capabilities.length) {
138
- console.log("[pltt] no agent-exposable capabilities declared")
139
- console.log("[pltt] expose a provides.services method with agent_exposable=true and a stable capability_id")
140
- return
140
+ log("Connector for " + manifest.id + "@" + manifest.version)
141
+ log(" Summary: " + (view.summary || "none in the manifest; the platform uses the tagline or the description"))
142
+ if (view.instructions) {
143
+ log(" Instructions (" + view.instructions.length + " of 2000 characters):")
144
+ for (const line of view.instructions.split("\n")) log(" " + line)
145
+ } else {
146
+ log(" Instructions: none in the manifest; the platform generates them from the description")
141
147
  }
142
- console.log("Capabilities for " + manifest.id + "@" + manifest.version)
148
+ log("Tools (" + capabilities.length + "):")
143
149
  for (const item of capabilities) {
144
150
  const scheduling = item.supports_scheduling ? "scheduled" : "interactive-only"
145
- console.log(" " + item.capability_id + " " + item.risk + ", " + scheduling)
146
- console.log(" " + item.name + (item.description ? " - " + item.description : ""))
151
+ log(" " + item.capability_id + " " + item.risk + ", " + scheduling)
152
+ log(" " + item.name + (item.description ? " - " + item.description : ""))
153
+ }
154
+ if (!capabilities.length) {
155
+ log(" none declared; expose a provides.services method with agent_exposable=true and a stable capability_id")
156
+ }
157
+ if (manifest.backend) {
158
+ log(" plus every backend route a member can call, unless marked agent_route(\"hidden\"); pltt check lists unmarked ones")
159
+ }
160
+ log("Skills (" + view.skills.length + "):")
161
+ for (const skill of view.skills) {
162
+ log(" " + skill.name + " - " + skill.description + (skill.tools.length ? " [tools: " + skill.tools.join(", ") + "]" : ""))
163
+ }
164
+ log("Events (" + view.events.length + "):")
165
+ for (const event of view.events) {
166
+ log(" " + event.topic + " " + (event.trigger ? "can start an agent run" : "not a trigger (needs a description and a payload schema)")
167
+ + (event.description ? " - " + event.description : ""))
147
168
  }
148
169
  }
149
170
 
@@ -14,6 +14,13 @@ const USAGE = "usage: pltt check [--json] [--publish-type preview|release] [--fi
14
14
 
15
15
  const IDS = [
16
16
  [/^could not (create Python|install pyproject)/i, "toolchain.python"],
17
+ [/agent\.instructions must be at most/, "connector.instructions_too_long"],
18
+ [/is required when agent_exposable is true|^agent-exposed (action|route) .* has no /, "connector.action_incomplete"],
19
+ [/is offered to agents with no agent_route mark/, "connector.route_unmarked"],
20
+ [/^skill .* names a tool the app does not have/, "connector.skill_unknown_tool"],
21
+ [/^skill .* will not load/, "connector.skill_invalid"],
22
+ [/is not offered as an agent trigger/, "connector.event_not_triggerable"],
23
+ [/^path-style ctx\.apps\.call/, "deprecated.apps_call"],
17
24
  [/^manifest invalid/i, "manifest.invalid"],
18
25
  [/^frontend bundle failed/i, "bundle.syntax"],
19
26
  [/^backend import failed/i, "py.import"],
@@ -5,6 +5,7 @@ const path = require("path")
5
5
  const crypto = require("crypto")
6
6
  const { loadManifest, validateManifest } = require("../manifest")
7
7
  const { bundleFrontend, bundleBackend } = require("../bundler")
8
+ const connector = require("../connector")
8
9
  const buildCommand = require("./build")
9
10
 
10
11
  function sha256(buf) {
@@ -48,7 +49,8 @@ async function run(argv, { cwd }) {
48
49
  pluginId: manifest.id,
49
50
  })
50
51
  : null
51
- const backend = manifest.backend ? await bundleBackend(cwd) : null
52
+ // skills/ travel in the backend bundle, so an app with skills and no backend still gets one (as publish does).
53
+ const backend = manifest.backend || connector.skills(cwd).length ? await bundleBackend(cwd) : null
52
54
 
53
55
  const out = path.join(distDir, `${manifest.id}-${manifest.version}.tar.gz`)
54
56
  // Build a simple tar by piping through node-tar via spawn — avoid extra dep
@@ -80,6 +82,8 @@ async function run(argv, { cwd }) {
80
82
  } else {
81
83
  console.log(`[pltt] packaged ${manifest.id}@${manifest.version} → ${out} (${buf.length} bytes)`)
82
84
  console.log(`[pltt] sha256: ${result.sha256}`)
85
+ const review = connector.reviewNote(cwd, manifest)
86
+ if (review) console.log(`[pltt] ${review}`)
83
87
  }
84
88
  }
85
89
 
@@ -6,6 +6,7 @@ const path = require("path")
6
6
  const { spawnSync } = require("child_process")
7
7
  const { loadManifest, validateManifest } = require("../manifest")
8
8
  const { bundleFrontend, bundleBackend } = require("../bundler")
9
+ const connector = require("../connector")
9
10
  const {
10
11
  resolveEnvironment,
11
12
  parseFlags,
@@ -408,6 +409,8 @@ async function run(argv, { cwd }) {
408
409
  log("[pltt] bundling backend")
409
410
  const backend = await bundleBackend(cwd, { manifest: publishManifest })
410
411
  log(`[pltt] ${backend.length} bytes`)
412
+ const review = connector.reviewNote(cwd, publishManifest)
413
+ if (review) log(`[pltt] ${review}`)
411
414
 
412
415
  const backendSha = sha256(backend)
413
416
  const frontendSha = frontend ? sha256(frontend) : null
@@ -510,6 +513,8 @@ async function run(argv, { cwd }) {
510
513
  } else if (record.category) {
511
514
  console.log(`[pltt] store category: ${record.category}`)
512
515
  }
516
+ const lockedNote = lockedSecretsNote(record)
517
+ if (lockedNote) console.log(`[pltt] ${lockedNote}`)
513
518
  if (record.preview_url) {
514
519
  console.log(`[pltt] preview: ${record.preview_url}`)
515
520
  }
@@ -524,4 +529,16 @@ async function run(argv, { cwd }) {
524
529
  return record
525
530
  }
526
531
 
532
+ // Pushed plugin secrets the platform kept: a Palette admin locked their values
533
+ // (older platforms send no such field).
534
+ function lockedSecretsNote(record) {
535
+ const keys = record.locked_plugin_secrets || []
536
+ if (!keys.length) return null
537
+ return (
538
+ `kept the server's value for ${keys.join(", ")}: a Palette admin locked ${keys.length === 1 ? "it" : "them"}. ` +
539
+ "Ask an admin to unlock a key for your pushes to change it."
540
+ )
541
+ }
542
+
527
543
  module.exports = run
544
+ module.exports.lockedSecretsNote = lockedSecretsNote
@@ -7,6 +7,8 @@ const { CTX_PERMISSIONS, loadManifest, validateManifest, KNOWN_PERMISSIONS } = r
7
7
  const { bundleFrontend, bundleBackend } = require("../bundler")
8
8
  const { declaredSecrets, loadLocalEnv, loadLocalEnvDetails } = require("../secrets")
9
9
  const buildCommand = require("./build")
10
+ const connector = require("../connector")
11
+ const { collect } = require("./capabilities")
10
12
 
11
13
  // Permissions consumed by a `ctx.*` client in a handler body rather than by a
12
14
  // route's require_permission() dependency. The route probe cannot see those —
@@ -192,7 +194,8 @@ function installPythonDependencies(cwd, out) {
192
194
  return { python: venvPython, env: pythonEnv(), failures: 0, dependencies: deps }
193
195
  }
194
196
 
195
- function checkBackendContract(cwd, manifest, out, pythonInfo) {
197
+ // `onRoutes` receives the routes the probe saw, for the connector checks that need them.
198
+ function checkBackendContract(cwd, manifest, out, pythonInfo, onRoutes = () => {}) {
196
199
  const entry = manifest.backend?.entry
197
200
  if (!entry) return 0
198
201
  const abs = path.resolve(cwd, entry)
@@ -234,7 +237,8 @@ function checkBackendContract(cwd, manifest, out, pythonInfo) {
234
237
  " perms.append(perm)",
235
238
  " used.add(perm)",
236
239
  " stack.extend(getattr(dep, 'dependencies', []) or [])",
237
- " routes.append({'path': path, 'methods': methods, 'permissions': sorted(set(perms)), 'public': path in public})",
240
+ " extra = getattr(route, 'openapi_extra', None) or {}",
241
+ " routes.append({'path': path, 'methods': methods, 'permissions': sorted(set(perms)), 'public': path in public, 'agent': extra.get('x-palette-agent'), 'name': extra.get('x-palette-name'), 'offered': bool(methods) and bool(getattr(route, 'include_in_schema', True)) and path not in public, 'described': bool(extra.get('x-palette-description') or getattr(route, 'summary', None) or getattr(route, 'description', None))})",
238
242
  " if path not in public and not perms:",
239
243
  " ungated.append({'path': path, 'methods': methods})",
240
244
  "capabilities = []",
@@ -257,6 +261,7 @@ function checkBackendContract(cwd, manifest, out, pythonInfo) {
257
261
 
258
262
  let failures = 0
259
263
  out.ok(`backend imports successfully: ${entry}`)
264
+ onRoutes(report.routes || [])
260
265
 
261
266
  if (report.ungated_routes?.length) {
262
267
  for (const route of report.ungated_routes) {
@@ -939,6 +944,8 @@ async function run(args, { cwd }) {
939
944
  }
940
945
  }
941
946
 
947
+ // null until the backend has been imported: its routes are tools too, so the tool list is not known before.
948
+ let routes = manifest.backend?.entry ? null : []
942
949
  if (manifest.backend?.entry) {
943
950
  const pythonInfo = installPythonDependencies(cwd, out)
944
951
  failures += pythonInfo.failures
@@ -947,7 +954,7 @@ async function run(args, { cwd }) {
947
954
  failures += out.fail(`backend entry not found: ${manifest.backend.entry}`)
948
955
  } else {
949
956
  out.ok(`backend entry exists: ${manifest.backend.entry}`)
950
- failures += checkBackendContract(cwd, manifest, out, pythonInfo)
957
+ failures += checkBackendContract(cwd, manifest, out, pythonInfo, (seen) => { routes = seen })
951
958
  }
952
959
 
953
960
  try {
@@ -965,6 +972,11 @@ async function run(args, { cwd }) {
965
972
  failures += lintMigrations(cwd, manifest, out)
966
973
  failures += lintDependencyPolicy(cwd, out)
967
974
 
975
+ // The app as a connector for assistants. Warnings only: an app that adds nothing still works.
976
+ const connectorFindings = connector.findings({ cwd, manifest, tools: collect(manifest), routes })
977
+ for (const finding of connectorFindings) out.warn(finding.message, finding.fix, finding)
978
+ if (!connectorFindings.length) out.ok("connector checks passed")
979
+
968
980
  if (failures > 0) {
969
981
  if (json) {
970
982
  console.log(JSON.stringify({ ok: false, failures, results }, null, 2))