@palettelab/cli 0.3.61 → 0.3.63

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 (39) hide show
  1. package/README.md +80 -5
  2. package/backend-sdk/palette_sdk/__init__.py +21 -1
  3. package/backend-sdk/palette_sdk/capabilities.py +126 -0
  4. package/backend-sdk/palette_sdk/connections.py +49 -11
  5. package/backend-sdk/palette_sdk/connections_generated.py +246 -0
  6. package/backend-sdk/palette_sdk/manifest.py +78 -3
  7. package/backend-sdk/palette_sdk/platform_services.py +122 -0
  8. package/backend-sdk/palette_sdk/plugin_context.py +14 -0
  9. package/backend-sdk/palette_sdk/services.py +45 -6
  10. package/backend-sdk/palette_sdk/talk.py +65 -0
  11. package/backend-sdk/pyproject.toml +1 -1
  12. package/docs/python-backend-sdk.md +64 -1
  13. package/lib/bundler.js +64 -0
  14. package/lib/cli.js +27 -2
  15. package/lib/commands/capabilities.js +151 -0
  16. package/lib/commands/connections.js +234 -0
  17. package/lib/commands/dev.js +75 -1
  18. package/lib/commands/doctor.js +70 -0
  19. package/lib/commands/init.js +3 -2
  20. package/lib/commands/open.js +43 -0
  21. package/lib/commands/services.js +74 -8
  22. package/lib/commands/test.js +89 -1
  23. package/lib/connection-catalog.json +1185 -0
  24. package/lib/dev-simulator.js +137 -3
  25. package/lib/manifest.js +90 -6
  26. package/package.json +1 -1
  27. package/template-fallback/package.json +1 -1
  28. package/template-fallback/templates/agent-tool/README.md +6 -2
  29. package/template-fallback/templates/agent-tool/backend/api/main.py +27 -6
  30. package/template-fallback/templates/agent-tool/palette-plugin.json +35 -4
  31. package/template-fallback/templates/consumer-app/package.json +1 -1
  32. package/template-fallback/templates/dashboard/package.json +1 -1
  33. package/template-fallback/templates/database/package.json +1 -1
  34. package/template-fallback/templates/external-service/package.json +1 -1
  35. package/template-fallback/templates/frontend-only/package.json +1 -1
  36. package/template-fallback/templates/next/package.json +1 -1
  37. package/template-fallback/templates/palette-app/package.json +1 -1
  38. package/template-fallback/templates/provider-app/package.json +1 -1
  39. package/template-fallback/templates/agent-tool/backend/tools/echo.py +0 -15
@@ -1,5 +1,6 @@
1
1
  "use strict"
2
2
 
3
+ const crypto = require("crypto")
3
4
  const fs = require("fs")
4
5
  const http = require("http")
5
6
  const path = require("path")
@@ -215,6 +216,15 @@ sys.path.insert(0, str(ENTRY.parent))
215
216
  DEV_REDIS = None
216
217
  DEV_VECTOR = None
217
218
  DEV_STORAGE = None
219
+ DEV_LLM = None
220
+ DEV_WEB = None
221
+ if _service_enabled("llm"):
222
+ from palette_sdk.platform_services import LocalLLMService
223
+ DEV_LLM = LocalLLMService(DEV_SECRETS.get("OPENAI_API_KEY") or os.environ.get("OPENAI_API_KEY", ""))
224
+ print(f"[pltt] ctx.llm: {'live (your OPENAI_API_KEY)' if DEV_LLM.live else 'stubbed (no OPENAI_API_KEY)'}")
225
+ if _service_enabled("web"):
226
+ from palette_sdk.platform_services import LocalWebService
227
+ DEV_WEB = LocalWebService()
218
228
  if _service_enabled("redis"):
219
229
  from palette_sdk.platform_services import LocalRedisService
220
230
  DEV_REDIS = LocalRedisService()
@@ -360,7 +370,37 @@ class LocalNotificationsService:
360
370
  print("[palette-notification]", json.dumps(notification, sort_keys=True))
361
371
  return notification
362
372
 
373
+ class LocalTalkService:
374
+ """Local stand-in for Talk: logs the post instead of putting it in a room.
375
+
376
+ One fake seat is reported, so a loop over ctx.talk.channels() runs locally
377
+ the way it will once a member invites the app to a channel.
378
+ """
379
+
380
+ def __init__(self):
381
+ self._next_id = 1
382
+
383
+ async def channels(self):
384
+ return [{"id": "dev-channel", "name": "general", "type": "stream"}]
385
+
386
+ async def post(self, *, text, channel):
387
+ content = (text or "").strip()
388
+ if not content:
389
+ raise ValueError("text is required")
390
+ message = {
391
+ "id": f"dev-message-{self._next_id}",
392
+ "channel_id": str(channel),
393
+ "content": content,
394
+ "message_type": "text",
395
+ "sender": {"kind": "agent", "name": MANIFEST.get("name") or MANIFEST.get("id", "")},
396
+ "created_at": datetime.now(timezone.utc).isoformat(),
397
+ }
398
+ self._next_id += 1
399
+ print("[palette-talk]", json.dumps(message, sort_keys=True))
400
+ return message
401
+
363
402
  NOTIFICATIONS = LocalNotificationsService()
403
+ TALK = LocalTalkService()
364
404
 
365
405
  spec = importlib.util.spec_from_file_location("palette_local_backend", ENTRY)
366
406
  module = importlib.util.module_from_spec(spec)
@@ -484,6 +524,14 @@ def _local_job_context(session):
484
524
  from palette_sdk.organization import OrganizationInfo
485
525
  from palette_sdk.platform_services import UnavailablePlatformService
486
526
 
527
+ # ctx.talk arrived after this simulator shipped its first job context, so a
528
+ # backend pinned to an older palette_sdk keeps working without it.
529
+ extra = {}
530
+ if "talk" in getattr(PluginContext, "__dataclass_fields__", {}):
531
+ from palette_sdk.talk import TalkClient
532
+
533
+ extra["talk"] = TalkClient(TALK, MANIFEST.get("permissions", []))
534
+
487
535
  return PluginContext(
488
536
  db=session,
489
537
  user_id="dev-user",
@@ -498,6 +546,8 @@ def _local_job_context(session):
498
546
  notifications=NotificationsClient(NOTIFICATIONS),
499
547
  redis=DEV_REDIS or UnavailablePlatformService("redis"),
500
548
  vector=DEV_VECTOR or UnavailablePlatformService("vector"),
549
+ llm=DEV_LLM or UnavailablePlatformService("llm"),
550
+ web=DEV_WEB or UnavailablePlatformService("web"),
501
551
  events=EventPublisher(LocalEventPublisher()),
502
552
  jobs=JobsClient(LOCAL_JOB_SERVICE),
503
553
  config={
@@ -505,6 +555,7 @@ def _local_job_context(session):
505
555
  "secret_specs": MANIFEST.get("secrets") or {},
506
556
  "secret_scope": "dev",
507
557
  },
558
+ **extra,
508
559
  )
509
560
 
510
561
  async def _run_local_job(record, declaration):
@@ -577,11 +628,14 @@ class DevPluginContextMiddleware(BaseHTTPMiddleware):
577
628
  "secret_specs": MANIFEST.get("secrets") or {},
578
629
  "secret_scope": "dev",
579
630
  }
631
+ request.state.llm = DEV_LLM
632
+ request.state.web = DEV_WEB
580
633
  request.state.plugin_local_connections = DEV_CONNECTIONS
581
634
  request.state.plugin_apps = LocalAppInteropService()
582
635
  request.state.plugin_events = LocalEventPublisher()
583
636
  request.state.plugin_jobs = LOCAL_JOB_SERVICE
584
637
  request.state.notifications = NOTIFICATIONS
638
+ request.state.talk = TALK
585
639
  request.state.storage = DEV_STORAGE
586
640
  if DEV_REDIS is not None:
587
641
  request.state.redis = DEV_REDIS
@@ -945,7 +999,7 @@ createRoot(document.getElementById("root")).render(React.createElement(Shell))
945
999
  `
946
1000
  }
947
1001
 
948
- function indexHtml(manifest) {
1002
+ function indexHtml(manifest, buildState) {
949
1003
  return `<!doctype html>
950
1004
  <html lang="en">
951
1005
  <head>
@@ -964,6 +1018,46 @@ function indexHtml(manifest) {
964
1018
  <body>
965
1019
  <div id="root"></div>
966
1020
  <script type="module" src="/simulator.js"></script>
1021
+ <script type="module">
1022
+ const loaded = { js: ${JSON.stringify(buildState.jsHash)}, css: ${JSON.stringify(buildState.cssHash)} }
1023
+ const OVERLAY_ID = "__pltt-error-overlay"
1024
+ function showOverlay(errors) {
1025
+ let el = document.getElementById(OVERLAY_ID)
1026
+ if (!el) {
1027
+ el = document.createElement("div")
1028
+ el.id = OVERLAY_ID
1029
+ el.style.cssText = "position:fixed;inset:0;z-index:2147483647;background:rgba(20,18,16,.96);color:#ffb4a2;overflow:auto;padding:32px;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace"
1030
+ document.body.appendChild(el)
1031
+ }
1032
+ el.innerHTML = ""
1033
+ const title = document.createElement("div")
1034
+ title.textContent = "[pltt] build failed"
1035
+ title.style.cssText = "color:#fff;font-weight:600;margin-bottom:16px"
1036
+ el.appendChild(title)
1037
+ for (const err of errors) {
1038
+ const pre = document.createElement("pre")
1039
+ pre.style.cssText = "white-space:pre-wrap;margin:0 0 12px"
1040
+ pre.textContent = (err.file ? err.file + ":" + (err.line || "?") + " — " : "") + err.text
1041
+ el.appendChild(pre)
1042
+ }
1043
+ }
1044
+ function clearOverlay() {
1045
+ const el = document.getElementById(OVERLAY_ID)
1046
+ if (el) el.remove()
1047
+ }
1048
+ const events = new EventSource("/__pltt/events")
1049
+ events.addEventListener("build", (evt) => {
1050
+ const state = JSON.parse(evt.data)
1051
+ if (!state.ok) { showOverlay(state.errors || []); return }
1052
+ clearOverlay()
1053
+ if (state.jsHash && state.jsHash !== loaded.js) { location.reload(); return }
1054
+ if (state.cssHash !== loaded.css) {
1055
+ loaded.css = state.cssHash
1056
+ const link = document.querySelector('link[rel="stylesheet"][href^="/simulator.css"]')
1057
+ if (link) link.href = "/simulator.css?t=" + Date.now()
1058
+ }
1059
+ })
1060
+ </script>
967
1061
  </body>
968
1062
  </html>`
969
1063
  }
@@ -991,6 +1085,21 @@ async function startFrontend(cwd, devDir, manifest, frontendPort, backendPort) {
991
1085
  fs.writeFileSync(generatedEntry, simulatorEntrySource(cwd, absEntry, manifest, backendPort))
992
1086
  const buildConfig = frontendBuildConfig(cwd, { ...(manifest.frontend || {}), entry })
993
1087
 
1088
+ const sseClients = new Set()
1089
+ const fileHash = (file) =>
1090
+ fs.existsSync(file) ? crypto.createHash("sha1").update(fs.readFileSync(file)).digest("hex") : ""
1091
+ const buildState = { ok: true, errors: [], jsHash: "", cssHash: "" }
1092
+ const broadcastBuild = () => {
1093
+ const payload = `event: build\ndata: ${JSON.stringify(buildState)}\n\n`
1094
+ for (const client of sseClients) {
1095
+ try {
1096
+ client.write(payload)
1097
+ } catch (_err) {
1098
+ sseClients.delete(client)
1099
+ }
1100
+ }
1101
+ }
1102
+
994
1103
  const esbuild = loadEsbuild()
995
1104
  const ctx = await esbuild.context({
996
1105
  entryPoints: [generatedEntry],
@@ -1015,10 +1124,22 @@ async function startFrontend(cwd, devDir, manifest, frontendPort, backendPort) {
1015
1124
  if (result.errors.length) {
1016
1125
  console.error("[pltt] simulator bundle failed:")
1017
1126
  for (const err of result.errors) console.error(` - ${err.text}`)
1127
+ buildState.ok = false
1128
+ buildState.errors = result.errors.map((err) => ({
1129
+ text: err.text,
1130
+ file: err.location?.file,
1131
+ line: err.location?.line,
1132
+ }))
1133
+ broadcastBuild()
1018
1134
  return
1019
1135
  }
1020
1136
  const size = fs.existsSync(bundlePath) ? fs.statSync(bundlePath).size : 0
1021
1137
  console.log(`[pltt] simulator bundle ready (${size} bytes)`)
1138
+ buildState.ok = true
1139
+ buildState.errors = []
1140
+ buildState.jsHash = fileHash(bundlePath)
1141
+ buildState.cssHash = fileHash(cssPath)
1142
+ broadcastBuild()
1022
1143
  })
1023
1144
  },
1024
1145
  },
@@ -1029,6 +1150,18 @@ async function startFrontend(cwd, devDir, manifest, frontendPort, backendPort) {
1029
1150
 
1030
1151
  const server = http.createServer((req, res) => {
1031
1152
  const url = new URL(req.url || "/", `http://127.0.0.1:${frontendPort}`)
1153
+ if (url.pathname === "/__pltt/events") {
1154
+ res.writeHead(200, {
1155
+ "Content-Type": "text/event-stream",
1156
+ "Cache-Control": "no-store",
1157
+ Connection: "keep-alive",
1158
+ })
1159
+ res.write("retry: 1000\n\n")
1160
+ res.write(`event: build\ndata: ${JSON.stringify(buildState)}\n\n`)
1161
+ sseClients.add(res)
1162
+ req.on("close", () => sseClients.delete(res))
1163
+ return
1164
+ }
1032
1165
  if (url.pathname === "/simulator.js") {
1033
1166
  console.log(`[pltt] frontend GET ${url.pathname} -> 200`)
1034
1167
  res.writeHead(200, { "Content-Type": "text/javascript; charset=utf-8", "Cache-Control": "no-store" })
@@ -1048,11 +1181,11 @@ async function startFrontend(cwd, devDir, manifest, frontendPort, backendPort) {
1048
1181
  }
1049
1182
  console.log(`[pltt] frontend GET ${url.pathname} -> 200`)
1050
1183
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" })
1051
- res.end(indexHtml(manifest))
1184
+ res.end(indexHtml(manifest, buildState))
1052
1185
  })
1053
1186
 
1054
1187
  await new Promise((resolve) => server.listen(frontendPort, "127.0.0.1", resolve))
1055
- return { server, ctx }
1188
+ return { server, ctx, sseClients }
1056
1189
  }
1057
1190
 
1058
1191
  async function startSimulator({ cwd, frontendPort, backendPort }) {
@@ -1070,6 +1203,7 @@ async function startSimulator({ cwd, frontendPort, backendPort }) {
1070
1203
  console.log("[pltt] use `pltt dev --platform` for full Docker platform parity")
1071
1204
 
1072
1205
  const stop = async () => {
1206
+ for (const client of frontend.sseClients) client.end()
1073
1207
  frontend.server.close()
1074
1208
  await frontend.ctx.dispose()
1075
1209
  if (backend && !backend.killed) backend.kill("SIGTERM")
package/lib/manifest.js CHANGED
@@ -125,6 +125,58 @@ function validateArray(value, label, errors) {
125
125
  if (value !== undefined && !Array.isArray(value)) errors.push(`${label} must be an array`)
126
126
  }
127
127
 
128
+ const CAPABILITY_METADATA_KEYS = [
129
+ "effects", "risk", "idempotent", "timeout_seconds", "tags", "artifact_inputs",
130
+ "artifact_outputs", "examples", "cost_class", "latency_class",
131
+ ]
132
+
133
+ function validateCapabilityMetadata(value, label, errors) {
134
+ for (const key of ["effects", "tags", "artifact_inputs", "artifact_outputs"]) {
135
+ if (value[key] !== undefined && (!Array.isArray(value[key]) || value[key].some((item) => typeof item !== "string"))) {
136
+ errors.push(`${label}.${key} must be an array of strings`)
137
+ }
138
+ }
139
+ requireBoolean(value, "idempotent", label, errors)
140
+ if (value.risk !== undefined && !["read", "write", "destructive", "controlled"].includes(value.risk)) {
141
+ errors.push(`${label}.risk must be read, write, destructive, or controlled`)
142
+ }
143
+ if (value.timeout_seconds !== undefined && (!Number.isInteger(value.timeout_seconds) || value.timeout_seconds < 1 || value.timeout_seconds > 7200)) {
144
+ errors.push(`${label}.timeout_seconds must be an integer between 1 and 7200`)
145
+ }
146
+ if (value.examples !== undefined && (!Array.isArray(value.examples) || value.examples.some((item) => !isObject(item)))) {
147
+ errors.push(`${label}.examples must be an array of objects`)
148
+ }
149
+ if (value.cost_class !== undefined && !["low", "medium", "high"].includes(value.cost_class)) {
150
+ errors.push(`${label}.cost_class must be low, medium, or high`)
151
+ }
152
+ if (value.latency_class !== undefined && !["interactive", "background", "long_running"].includes(value.latency_class)) {
153
+ errors.push(`${label}.latency_class must be interactive, background, or long_running`)
154
+ }
155
+ }
156
+
157
+ function validateAgentCapability(value, label, errors) {
158
+ if (value.agent_exposable !== true) return
159
+ if (typeof value.capability_id !== "string" || !/^[a-z][a-z0-9_-]*(\.[a-z0-9_-]+)+$/.test(value.capability_id)) {
160
+ errors.push(`${label}.capability_id must be a stable dotted lowercase id when agent_exposable is true`)
161
+ }
162
+ if (typeof value.description !== "string" || !value.description.trim()) {
163
+ errors.push(`${label}.description is required when agent_exposable is true`)
164
+ }
165
+ const input = value.input_schema ?? value.input
166
+ if (input === undefined) {
167
+ errors.push(`${label}.input_schema is required when agent_exposable is true`)
168
+ }
169
+ if (!Array.isArray(value.effects) || value.effects.length === 0) {
170
+ errors.push(`${label}.effects must declare at least one effect when agent_exposable is true`)
171
+ }
172
+ if (!value.risk) {
173
+ errors.push(`${label}.risk is required when agent_exposable is true`)
174
+ }
175
+ if (["write", "destructive"].includes(value.risk) && value.supports_scheduling !== false && value.idempotent !== true) {
176
+ errors.push(`${label} scheduled write capabilities must be idempotent or set supports_scheduling=false`)
177
+ }
178
+ }
179
+
128
180
  function validateSecrets(value, errors) {
129
181
  if (value === undefined) return
130
182
  if (!isObject(value)) {
@@ -164,7 +216,7 @@ function validateSecrets(value, errors) {
164
216
 
165
217
  function validatePlatformServices(value, errors) {
166
218
  if (value === undefined) return
167
- const known = new Set(["llm", "redis", "storage", "vector"])
219
+ const known = new Set(["llm", "redis", "storage", "vector", "web"])
168
220
  if (Array.isArray(value)) {
169
221
  for (const service of value) {
170
222
  if (!known.has(service)) errors.push(`platform_services contains unknown service: ${service}`)
@@ -190,10 +242,13 @@ function validatePlatformServices(value, errors) {
190
242
  }
191
243
  }
192
244
 
245
+ // Providers with a live OS service connection — declaring one lets the app call
246
+ // ctx.connections.* against the user's existing connection, no OAuth of its own.
247
+ const LIVE_CONNECTION_PROVIDERS = new Set(["google", "slack", "notion", "telegram", "meta"])
248
+ // Legacy slugs still validate so published manifests keep working, but dispatch nothing.
193
249
  const CONNECTION_PROVIDERS = new Set([
194
- "google",
250
+ ...LIVE_CONNECTION_PROVIDERS,
195
251
  "instagram",
196
- "slack",
197
252
  "linear",
198
253
  "hubspot",
199
254
  "stripe",
@@ -208,13 +263,14 @@ function validateConnections(value, errors) {
208
263
  return
209
264
  }
210
265
  const seen = new Set()
266
+ const seenProviders = new Set()
211
267
  value.forEach((conn, i) => {
212
268
  const label = `connections[${i}]`
213
269
  if (!isObject(conn)) {
214
270
  errors.push(`${label} must be an object`)
215
271
  return
216
272
  }
217
- unknownKeys(conn, new Set(["id", "provider", "label", "auth", "scopes", "required"]), label, errors)
273
+ unknownKeys(conn, new Set(["id", "provider", "label", "auth", "scopes", "required", "tools"]), label, errors)
218
274
  if (!conn.id || typeof conn.id !== "string" || !/^[a-z0-9][a-z0-9_-]*[a-z0-9]$/.test(conn.id)) {
219
275
  errors.push(`${label}.id must be lowercase snake/kebab case`)
220
276
  } else if (seen.has(conn.id)) {
@@ -223,6 +279,14 @@ function validateConnections(value, errors) {
223
279
  seen.add(conn.id)
224
280
  if (!conn.provider || typeof conn.provider !== "string" || !CONNECTION_PROVIDERS.has(conn.provider)) {
225
281
  errors.push(`${label}.provider must be one of ${Array.from(CONNECTION_PROVIDERS).join(", ")}`)
282
+ } else if (LIVE_CONNECTION_PROVIDERS.has(conn.provider)) {
283
+ // ctx.connections resolves a grant by provider, so two entries on the
284
+ // same provider would be ambiguous at call time.
285
+ if (seenProviders.has(conn.provider)) errors.push(`duplicate connection provider: ${conn.provider}`)
286
+ seenProviders.add(conn.provider)
287
+ }
288
+ if (conn.tools !== undefined && !Array.isArray(conn.tools)) {
289
+ errors.push(`${label}.tools must be an array`)
226
290
  }
227
291
  if (!conn.label || typeof conn.label !== "string") errors.push(`${label}.label is required`)
228
292
  if (conn.auth !== undefined && conn.auth !== "oauth2" && conn.auth !== "api_key") {
@@ -307,8 +371,13 @@ function validateServiceMethods(value, label, errors) {
307
371
  "output",
308
372
  "route_method",
309
373
  "route_path",
374
+ "annotations",
375
+ "capability_id",
376
+ "supports_scheduling",
377
+ "agent_exposable",
310
378
  "deprecated",
311
379
  "replacement",
380
+ ...CAPABILITY_METADATA_KEYS,
312
381
  ]),
313
382
  methodLabel,
314
383
  errors,
@@ -319,11 +388,15 @@ function validateServiceMethods(value, label, errors) {
319
388
  errors.push(`duplicate provided method name: ${method.name}`)
320
389
  }
321
390
  seen.add(method.name)
322
- for (const key of ["scope", "label", "description", "route_path"]) {
391
+ for (const key of ["scope", "label", "description", "route_path", "capability_id"]) {
323
392
  requireString(method, key, methodLabel, errors)
324
393
  }
394
+ requireBoolean(method, "agent_exposable", methodLabel, errors)
395
+ requireBoolean(method, "supports_scheduling", methodLabel, errors)
325
396
  requireBoolean(method, "deprecated", methodLabel, errors)
326
397
  requireString(method, "replacement", methodLabel, errors)
398
+ validateCapabilityMetadata(method, methodLabel, errors)
399
+ validateAgentCapability(method, methodLabel, errors)
327
400
  for (const key of ["input_schema", "input", "output_schema", "output"]) {
328
401
  requireSchema(method, key, methodLabel, errors)
329
402
  }
@@ -527,7 +600,7 @@ function validateMcp(value, errors) {
527
600
  } else {
528
601
  unknownKeys(value.provides, new Set(["tools", "resources", "prompts"]), "mcp.provides", errors)
529
602
  const allowedByBucket = {
530
- tools: new Set(["name", "label", "description", "input_schema", "output_schema", "annotations", "scope", "expose_external"]),
603
+ tools: new Set(["name", "label", "description", "input_schema", "output_schema", "annotations", "scope", "expose_external", "agent_exposable", "capability_id", "supports_scheduling", "deprecated", "replacement", ...CAPABILITY_METADATA_KEYS]),
531
604
  resources: new Set(["name", "uri_template", "description", "mime_type", "expose_external"]),
532
605
  prompts: new Set(["name", "description", "arguments", "expose_external"]),
533
606
  }
@@ -553,7 +626,18 @@ function validateMcp(value, errors) {
553
626
  if (seen.has(entry.name)) errors.push(`duplicate mcp.provides.${bucket} name: ${entry.name}`)
554
627
  seen.add(entry.name)
555
628
  requireBoolean(entry, "expose_external", label, errors)
629
+ requireBoolean(entry, "agent_exposable", label, errors)
630
+ requireBoolean(entry, "supports_scheduling", label, errors)
631
+ requireBoolean(entry, "deprecated", label, errors)
556
632
  requireString(entry, "description", label, errors)
633
+ if (bucket === "tools") {
634
+ requireString(entry, "capability_id", label, errors)
635
+ requireString(entry, "replacement", label, errors)
636
+ requireSchema(entry, "input_schema", label, errors)
637
+ requireSchema(entry, "output_schema", label, errors)
638
+ validateCapabilityMetadata(entry, label, errors)
639
+ validateAgentCapability(entry, label, errors)
640
+ }
557
641
  })
558
642
  }
559
643
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palettelab/cli",
3
- "version": "0.3.61",
3
+ "version": "0.3.63",
4
4
  "description": "Developer CLI for building Palette platform plugins — no platform source access required.",
5
5
  "bin": {
6
6
  "pltt": "bin/pltt.js"
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "description": "A Palette platform plugin",
6
6
  "dependencies": {
7
- "@palettelab/sdk": "^0.1.27"
7
+ "@palettelab/sdk": "^0.1.30"
8
8
  },
9
9
  "devDependencies": {
10
10
  "typescript": "^5.0.0",
@@ -1,4 +1,8 @@
1
1
  # Agent-tool plugin
2
2
 
3
- Defines a callable tool (`echo`) under `backend/tools/`. Any agent in the org
4
- can invoke it once installed.
3
+ Defines a typed `echo` capability with the `@capability` SDK decorator and a
4
+ matching reviewed manifest contract. Once installed, chat agents, workflows,
5
+ and scheduled loops discover the same capability automatically.
6
+
7
+ Run `pltt capabilities list` to inspect the agent surface and `pltt test --agent`
8
+ before publishing.
@@ -1,14 +1,35 @@
1
- """Agent-tool plugin backend.
1
+ """Agent-ready plugin backend with one typed, discoverable capability."""
2
2
 
3
- This plugin's primary surface is the tool defined in backend/tools/echo.py.
4
- The router exists so superadmin health checks have something to ping.
5
- """
6
-
7
- from palette_sdk import PluginRouter
3
+ from palette_sdk import PluginContext, PluginRouter, capability
8
4
 
9
5
  router = PluginRouter(tags=["my-agent-tool"])
10
6
 
11
7
 
8
+ @capability(
9
+ "echo",
10
+ capability_id="utility.text.echo",
11
+ version="v1",
12
+ description="Echo text back as a structured result.",
13
+ input_schema={
14
+ "type": "object",
15
+ "properties": {"message": {"type": "string"}},
16
+ "required": ["message"],
17
+ },
18
+ output_schema={
19
+ "type": "object",
20
+ "properties": {"echoed": {"type": "string"}},
21
+ "required": ["echoed"],
22
+ },
23
+ effects=["read"],
24
+ risk="read",
25
+ idempotent=True,
26
+ timeout_seconds=30,
27
+ tags=["utility", "text"],
28
+ )
29
+ async def echo(ctx: PluginContext, payload: dict) -> dict:
30
+ return {"echoed": str(payload["message"])}
31
+
32
+
12
33
  @router.get("/health")
13
34
  async def health() -> dict:
14
35
  return {"status": "ok"}
@@ -22,8 +22,39 @@
22
22
  },
23
23
  "backend": { "entry": "./backend/api/main.py" },
24
24
  "public_routes": ["/health"],
25
- "tools": [
26
- { "name": "echo", "description": "Echo a string back", "entry": "./backend/tools/echo.py" }
27
- ],
28
- "permissions": ["tasks:read", "tasks:write"]
25
+ "provides": {
26
+ "namespace": "my-agent-tool",
27
+ "services": [
28
+ {
29
+ "id": "agent-tools",
30
+ "version": "v1",
31
+ "label": "Agent tools",
32
+ "methods": [
33
+ {
34
+ "name": "echo",
35
+ "label": "Echo text",
36
+ "description": "Echo text back as a structured result.",
37
+ "input_schema": {
38
+ "type": "object",
39
+ "properties": { "message": { "type": "string" } },
40
+ "required": ["message"]
41
+ },
42
+ "output_schema": {
43
+ "type": "object",
44
+ "properties": { "echoed": { "type": "string" } },
45
+ "required": ["echoed"]
46
+ },
47
+ "capability_id": "utility.text.echo",
48
+ "agent_exposable": true,
49
+ "supports_scheduling": true,
50
+ "effects": ["read"],
51
+ "risk": "read",
52
+ "idempotent": true,
53
+ "timeout_seconds": 30,
54
+ "tags": ["utility", "text"]
55
+ }
56
+ ]
57
+ }
58
+ ]
59
+ }
29
60
  }
@@ -2,7 +2,7 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@palettelab/sdk": "^0.1.27",
5
+ "@palettelab/sdk": "^0.1.30",
6
6
  "react": "^19.0.0",
7
7
  "react-dom": "^19.0.0"
8
8
  }
@@ -3,7 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "dependencies": {
6
- "@palettelab/sdk": "^0.1.27",
6
+ "@palettelab/sdk": "^0.1.30",
7
7
  "react": "^19.0.0"
8
8
  }
9
9
  }
@@ -2,5 +2,5 @@
2
2
  "name": "my-db-plugin",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
- "dependencies": { "@palettelab/sdk": "^0.1.27", "react": "^19.0.0" }
5
+ "dependencies": { "@palettelab/sdk": "^0.1.30", "react": "^19.0.0" }
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "name": "my-external-svc",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
- "dependencies": { "@palettelab/sdk": "^0.1.27", "react": "^19.0.0" }
5
+ "dependencies": { "@palettelab/sdk": "^0.1.30", "react": "^19.0.0" }
6
6
  }
@@ -3,7 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "dependencies": {
6
- "@palettelab/sdk": "^0.1.27",
6
+ "@palettelab/sdk": "^0.1.30",
7
7
  "react": "^19.0.0"
8
8
  }
9
9
  }
@@ -3,7 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "dependencies": {
6
- "@palettelab/sdk": "^0.1.27",
6
+ "@palettelab/sdk": "^0.1.30",
7
7
  "react": "^19.0.0"
8
8
  },
9
9
  "devDependencies": {
@@ -3,7 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "dependencies": {
6
- "@palettelab/sdk": "^0.1.27",
6
+ "@palettelab/sdk": "^0.1.30",
7
7
  "react": "^19.0.0"
8
8
  },
9
9
  "devDependencies": {
@@ -2,7 +2,7 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@palettelab/sdk": "^0.1.27",
5
+ "@palettelab/sdk": "^0.1.30",
6
6
  "react": "^19.0.0"
7
7
  }
8
8
  }
@@ -1,15 +0,0 @@
1
- """Echo tool — agents can call this to echo a message back."""
2
-
3
- from pydantic import BaseModel
4
-
5
-
6
- class EchoInput(BaseModel):
7
- message: str
8
-
9
-
10
- class EchoOutput(BaseModel):
11
- echoed: str
12
-
13
-
14
- async def run(inp: EchoInput) -> EchoOutput:
15
- return EchoOutput(echoed=inp.message)