@palettelab/cli 0.3.72 → 0.3.74
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.
- package/README.md +65 -12
- package/backend-sdk/palette_sdk/__init__.py +3 -1
- package/backend-sdk/palette_sdk/manifest.py +2 -2
- package/backend-sdk/palette_sdk/platform_services.py +254 -1
- package/backend-sdk/palette_sdk/plugin_context.py +8 -0
- package/backend-sdk/pyproject.toml +1 -1
- package/docs/python-backend-sdk.md +53 -4
- package/lib/acp.js +227 -25
- package/lib/agent-client.js +56 -27
- package/lib/cli.js +7 -2
- package/lib/commands/agent.js +145 -50
- package/lib/commands/categories.js +25 -0
- package/lib/commands/doctor.js +2 -1
- package/lib/commands/platform.js +3 -2
- package/lib/commands/publish.js +7 -0
- package/lib/dev-simulator.js +8 -0
- package/lib/manifest.js +11 -1
- package/package.json +1 -1
- package/template-fallback/README.md +2 -2
- package/template-fallback/package.json +1 -1
- package/template-fallback/templates/agent-tool/palette-plugin.json +1 -1
- package/template-fallback/templates/consumer-app/package.json +1 -1
- package/template-fallback/templates/dashboard/package.json +1 -1
- package/template-fallback/templates/database/package.json +1 -1
- package/template-fallback/templates/external-service/package.json +1 -1
- package/template-fallback/templates/external-service/palette-plugin.json +1 -1
- package/template-fallback/templates/frontend-only/package.json +1 -1
- package/template-fallback/templates/next/package.json +1 -1
- package/template-fallback/templates/palette-app/package.json +1 -1
- package/template-fallback/templates/provider-app/package.json +1 -1
package/lib/commands/agent.js
CHANGED
|
@@ -10,15 +10,19 @@ const fs = require("fs")
|
|
|
10
10
|
const path = require("path")
|
|
11
11
|
const readline = require("readline")
|
|
12
12
|
const { once } = require("events")
|
|
13
|
-
const
|
|
13
|
+
const consumers = require("stream/consumers")
|
|
14
14
|
const { parseFlags } = require("../environments")
|
|
15
|
-
const { connect, locate, untilIdle } = require("../agent-client")
|
|
15
|
+
const { connect, locate, sessionOf, followLog, untilIdle } = require("../agent-client")
|
|
16
16
|
const { AcpServer } = require("../acp")
|
|
17
17
|
|
|
18
18
|
const USAGE = `usage:
|
|
19
|
-
pltt agent run --app <id> "<change>" [--format json|text] [--timeout <s>]
|
|
20
|
-
change a built app and follow it to the end
|
|
21
|
-
|
|
19
|
+
pltt agent run --app <id> ["<change>" | --file <path> | -] [--auto] [--format json|text] [--timeout <s>]
|
|
20
|
+
change a built app and follow it to the end; the change comes
|
|
21
|
+
as words, from a file, or on standard input (- or piped in).
|
|
22
|
+
--auto answers for nobody watching: each permission ask is
|
|
23
|
+
allowed once, each question goes on with the agent's assumption.
|
|
24
|
+
Exit 0 done, 2 stopped short, 1 error; Ctrl+C and SIGTERM
|
|
25
|
+
interrupt the session and exit 130 and 143
|
|
22
26
|
pltt agent edit --app <id> "<change>" [--follow] start a change (steers the agent when it is working)
|
|
23
27
|
pltt agent attach <session> follow live, answer permission asks and questions,
|
|
24
28
|
type to steer, /exit to leave
|
|
@@ -45,6 +49,8 @@ const USAGE = `usage:
|
|
|
45
49
|
pltt agent permit <session> <request> once|always|reject [message]
|
|
46
50
|
pltt agent questions <session> open questions
|
|
47
51
|
pltt agent answer <session> <question> "<answer>"
|
|
52
|
+
pltt agent ask <session> "<question>" a side question, answered from the session's transcript
|
|
53
|
+
(its history stays as it is; billed to the session)
|
|
48
54
|
pltt agent fork <session> [--seq <n>] [--title <t>]
|
|
49
55
|
pltt agent export <session> [--sanitize] [-o <file>]
|
|
50
56
|
pltt agent import --app <id> <file>
|
|
@@ -60,8 +66,6 @@ const USAGE = `usage:
|
|
|
60
66
|
pltt agent skills the skills a session can load (or invoke as /<skill>)
|
|
61
67
|
pltt agent models [query] the models a subagent can run on
|
|
62
68
|
pltt agent mcp the MCP servers the agent can use, with their tools
|
|
63
|
-
pltt agent config the Build Agent's effective settings
|
|
64
|
-
pltt agent plugins hook-bus plugins (changed plugin files reload)
|
|
65
69
|
pltt agent api <METHOD> <path> [json] a raw call under /api/v1/build-sessions
|
|
66
70
|
pltt agent agents the agents a session can run
|
|
67
71
|
pltt agent commands the slash commands a message can start with
|
|
@@ -186,19 +190,48 @@ function describe(event) {
|
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
192
|
|
|
193
|
+
// What `run`, `edit --follow`, `attach` and `log` print for each event. --json: every event as one line, live ones
|
|
194
|
+
// ("live": true) included. Text: describe()'s line, plus the agent's text as it streams in (text.delta), a line at a
|
|
195
|
+
// time, and a running command's newest output line (tool.progress) when it changes; a step whose text streamed in
|
|
196
|
+
// does not print it again when its text.ended arrives.
|
|
189
197
|
function printer(json, log) {
|
|
198
|
+
let partial = null // the streamed text after its last newline; null: nothing streamed in this step yet
|
|
199
|
+
let step = null // the step whose text streamed in
|
|
200
|
+
let progress = ""
|
|
190
201
|
return (event) => {
|
|
191
|
-
|
|
202
|
+
if (json) return log(JSON.stringify(event))
|
|
203
|
+
const d = event.data || {}
|
|
204
|
+
if (event.type === "text.delta") {
|
|
205
|
+
const lines = `${partial ?? "agent: "}${d.text || ""}`.split("\n")
|
|
206
|
+
partial = lines.pop()
|
|
207
|
+
lines.forEach((line) => log(line))
|
|
208
|
+
step = d.step
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
if (event.type === "tool.progress") {
|
|
212
|
+
const line = ` … ${d.name}: ${String(d.tail || "").trimEnd().split(/[\r\n]/).pop().slice(0, 160)}`
|
|
213
|
+
if (line !== progress) log((progress = line))
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
if (event.live) return // thinking (reasoning.delta), and live kinds newer than this CLI
|
|
217
|
+
if (partial !== null && (event.type === "tool.called" || event.type === "text.ended")) {
|
|
218
|
+
if (partial) log(partial)
|
|
219
|
+
const said = step === d.step
|
|
220
|
+
partial = step = null
|
|
221
|
+
if (said && event.type === "text.ended") return
|
|
222
|
+
}
|
|
223
|
+
const line = describe(event)
|
|
192
224
|
if (line) log(line)
|
|
193
225
|
}
|
|
194
226
|
}
|
|
195
227
|
|
|
196
228
|
// `log`: replay the durable log; live, stream it until the round running now ends (a round.ended in the replay is
|
|
197
|
-
// history, not the end).
|
|
229
|
+
// history, not the end), across dropped connections.
|
|
198
230
|
async function follow(client, sessionId, { after = 0, live = true, print, signal }) {
|
|
199
231
|
let last = after
|
|
200
232
|
let synced = false
|
|
201
|
-
|
|
233
|
+
const events = live ? followLog(client, sessionId, { after, signal }) : client.log(sessionId, { after, follow: false, signal })
|
|
234
|
+
for await (const event of events) {
|
|
202
235
|
if (event.type === "log.synced") {
|
|
203
236
|
if (!live) return { last: event.seq, stop: null }
|
|
204
237
|
synced = true
|
|
@@ -222,27 +255,89 @@ function promptLine(result) {
|
|
|
222
255
|
return result.running ? "[pltt] sent — the agent picks it up between two steps" : "[pltt] waiting — the session is not running now; its next round starts with it"
|
|
223
256
|
}
|
|
224
257
|
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
async function
|
|
228
|
-
const
|
|
258
|
+
// A change's text: the words given, a file (--file <path>), or standard input (`-`, `--file -`, or piped in with no
|
|
259
|
+
// words).
|
|
260
|
+
async function changeText(words, file, { cwd, stdin }) {
|
|
261
|
+
const piped = file === "-" || (!file && (words.join(" ") === "-" || (!words.length && !(stdin || process.stdin).isTTY)))
|
|
262
|
+
const text = piped ? await consumers.text(stdin || process.stdin) : file ? fs.readFileSync(path.resolve(cwd, file), "utf8") : words.join(" ")
|
|
263
|
+
if (!text.trim()) throw new Error(`no change given: pass it as words, with --file <path>, or on standard input\n${USAGE}`)
|
|
264
|
+
return text.trim()
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// --auto: nobody is there to answer, so the run does. A permission ask is allowed for that one call (never always);
|
|
268
|
+
// a question gets the agent's own assumption back at once, instead of waiting out its timer.
|
|
269
|
+
async function autoReply(client, session, event) {
|
|
270
|
+
const d = event.data || {}
|
|
271
|
+
try {
|
|
272
|
+
if (event.type === "permission.asked") await client.permit(session, d.id, "once")
|
|
273
|
+
if (event.type === "question.asked") {
|
|
274
|
+
await client.answer(session, d.id, `Unattended run: nobody can answer, so go with your assumption${d.assumption ? ` (${d.assumption})` : ""}.`)
|
|
275
|
+
}
|
|
276
|
+
} catch (err) {
|
|
277
|
+
console.error(`[pltt] could not answer ${d.id}: ${err.message}`)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// `run` (and `edit --follow`): send the change, follow its session until it is idle, exit by how it stopped. Without
|
|
282
|
+
// --auto it never attends, so the server decides each ask unattended: a permission ask is denied, a question goes on
|
|
283
|
+
// with the agent's assumption. With --auto it attends and answers them itself (autoReply). Ctrl+C (SIGINT) and
|
|
284
|
+
// SIGTERM interrupt the session and exit 130 and 143; a second one ends the process at once.
|
|
285
|
+
async function runChange(client, { app, text, json, log, timeout, auto }) {
|
|
286
|
+
const controller = new AbortController()
|
|
287
|
+
const { signal } = controller
|
|
288
|
+
const timer = setTimeout(() => controller.abort(), Math.min(timeout * 1000, 2 ** 31 - 1)) // a timer's longest delay
|
|
289
|
+
let stopped = null // the signal that stopped the run
|
|
290
|
+
const handlers = ["SIGINT", "SIGTERM"].map((name) => [name, () => {
|
|
291
|
+
stopped = stopped || name
|
|
292
|
+
controller.abort()
|
|
293
|
+
}])
|
|
294
|
+
for (const [name, handler] of handlers) process.once(name, handler)
|
|
295
|
+
const print = printer(json, log)
|
|
296
|
+
let before = []
|
|
297
|
+
let result = null
|
|
229
298
|
let session = null
|
|
299
|
+
let attending
|
|
230
300
|
let state
|
|
231
301
|
try {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
302
|
+
;({ sessions: before } = await client.sessions(app, { limit: 100 }))
|
|
303
|
+
signal.throwIfAborted() // stopped before the change was sent: nothing to interrupt
|
|
304
|
+
result = await client.edit(app, text)
|
|
305
|
+
log(json ? JSON.stringify({ type: "edit.sent", ...result }) : `[pltt] ${editLine(result)}`)
|
|
235
306
|
const found = await locate(client, app, result, before, signal)
|
|
236
307
|
session = found.session
|
|
237
|
-
|
|
238
|
-
|
|
308
|
+
log(json ? JSON.stringify({ type: "run.following", session, after: found.after }) : `[pltt] following ${session}`)
|
|
309
|
+
if (auto) {
|
|
310
|
+
const attend = () => client.attend(session).catch((err) => console.error(`[pltt] attend failed: ${err.message}`))
|
|
311
|
+
attend()
|
|
312
|
+
attending = setInterval(attend, 30_000)
|
|
313
|
+
}
|
|
314
|
+
state = await untilIdle(client, session, {
|
|
315
|
+
after: found.after,
|
|
316
|
+
signal,
|
|
317
|
+
onEvent: async (event) => {
|
|
318
|
+
print(event)
|
|
319
|
+
if (auto) await autoReply(client, session, event)
|
|
320
|
+
},
|
|
321
|
+
})
|
|
239
322
|
} catch (err) {
|
|
240
323
|
if (!signal.aborted) throw err
|
|
324
|
+
if (stopped) {
|
|
325
|
+
session = session || (await sessionOf(client, app, result, before))
|
|
326
|
+
if (session) await client.interrupt(session).catch((error) => console.error(`[pltt] interrupt failed: ${error.message}`))
|
|
327
|
+
}
|
|
241
328
|
state = session ? await client.wait(session, 1) : { status: null, done: false, last_stop: null }
|
|
329
|
+
} finally {
|
|
330
|
+
clearTimeout(timer)
|
|
331
|
+
clearInterval(attending)
|
|
332
|
+
for (const [name, handler] of handlers) process.removeListener(name, handler)
|
|
242
333
|
}
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
334
|
+
const code = stopped ? { SIGINT: 130, SIGTERM: 143 }[stopped] : exitCode(state)
|
|
335
|
+
const outcome = stopped ? `interrupted (${stopped})`
|
|
336
|
+
: !state.done ? `still running after ${timeout}s` : state.last_stop === "done" ? "done" : `stopped: ${state.last_stop}`
|
|
337
|
+
log(json
|
|
338
|
+
? JSON.stringify({ type: "run.ended", session, ...state, exit_code: code, ...(stopped ? { signal: stopped } : {}) })
|
|
339
|
+
: `[pltt] ${outcome}${state.summary ? ` — ${state.summary}` : ""}`)
|
|
340
|
+
process.exitCode = code
|
|
246
341
|
}
|
|
247
342
|
|
|
248
343
|
// What a line typed into `attach` does, given the oldest open ask (a permission ask or a question; null when none):
|
|
@@ -273,9 +368,10 @@ function askLine(ask) {
|
|
|
273
368
|
|
|
274
369
|
// `attach`: a line-mode follower. Attends (so asks wait for the owner), prompts for each open ask, and sends any other
|
|
275
370
|
// line as a steering message. Leaves on /exit or the end of input.
|
|
276
|
-
async function attach(client, sessionId, { log }) {
|
|
371
|
+
async function attach(client, sessionId, { log, json }) {
|
|
277
372
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
278
373
|
const controller = new AbortController()
|
|
374
|
+
const print = printer(json, log)
|
|
279
375
|
const asks = [] // open permission asks and questions, oldest first
|
|
280
376
|
let synced = false
|
|
281
377
|
const promptNext = () => {
|
|
@@ -305,27 +401,21 @@ async function attach(client, sessionId, { log }) {
|
|
|
305
401
|
promptNext()
|
|
306
402
|
})
|
|
307
403
|
rl.on("close", () => controller.abort())
|
|
308
|
-
let after = 0
|
|
309
404
|
try {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (
|
|
321
|
-
const at = asks.findIndex((ask) => ask.id === d.id)
|
|
322
|
-
if (at >= 0) asks.splice(at, 1)
|
|
323
|
-
}
|
|
324
|
-
const line = describe(event)
|
|
325
|
-
if (line) log(line)
|
|
326
|
-
if (synced && /^(permission|question)\.(asked|replied)$/.test(event.type)) promptNext()
|
|
405
|
+
for await (const event of followLog(client, sessionId, { signal: controller.signal })) {
|
|
406
|
+
if (event.type === "log.synced") {
|
|
407
|
+
synced = true
|
|
408
|
+
promptNext()
|
|
409
|
+
continue
|
|
410
|
+
}
|
|
411
|
+
const d = event.data || {}
|
|
412
|
+
if (event.type === "permission.asked" || event.type === "question.asked") asks.push({ kind: event.type.split(".")[0], ...d })
|
|
413
|
+
if (event.type === "permission.replied" || event.type === "question.replied") {
|
|
414
|
+
const at = asks.findIndex((ask) => ask.id === d.id)
|
|
415
|
+
if (at >= 0) asks.splice(at, 1)
|
|
327
416
|
}
|
|
328
|
-
|
|
417
|
+
print(event)
|
|
418
|
+
if (synced && /^(permission|question)\.(asked|replied)$/.test(event.type)) promptNext()
|
|
329
419
|
}
|
|
330
420
|
} catch (err) {
|
|
331
421
|
if (!controller.signal.aborted) throw err
|
|
@@ -371,7 +461,7 @@ function diffStat(data, log) {
|
|
|
371
461
|
log(` ${files.length} file${files.length === 1 ? "" : "s"} changed, +${data.additions} -${data.deletions}`)
|
|
372
462
|
}
|
|
373
463
|
|
|
374
|
-
async function run(argv, { cwd = process.cwd(), log = console.log } = {}) {
|
|
464
|
+
async function run(argv, { cwd = process.cwd(), log = console.log, stdin } = {}) {
|
|
375
465
|
const [sub, ...args] = argv
|
|
376
466
|
const { flags, rest } = parseFlags(args)
|
|
377
467
|
const json = flags.json
|
|
@@ -450,15 +540,19 @@ async function run(argv, { cwd = process.cwd(), log = console.log } = {}) {
|
|
|
450
540
|
const app = option(rest, "--app")
|
|
451
541
|
const format = option(rest, "--format")
|
|
452
542
|
const timeout = option(rest, "--timeout")
|
|
543
|
+
const file = option(rest, "--file")
|
|
544
|
+
const auto = flag(rest, "--auto")
|
|
453
545
|
const followIt = flag(rest, "--follow") || sub === "run"
|
|
454
|
-
need(app
|
|
455
|
-
const text = rest
|
|
456
|
-
if (followIt)
|
|
546
|
+
need(app)
|
|
547
|
+
const text = await changeText(rest, file, { cwd, stdin })
|
|
548
|
+
if (followIt) {
|
|
549
|
+
return runChange(client, { app, text, json: json || format === "json", log, timeout: timeout ? positiveInt(timeout, "--timeout") : 1800, auto })
|
|
550
|
+
}
|
|
457
551
|
return out(await client.edit(app, text), (result) => log(`[pltt] ${editLine(result)}`))
|
|
458
552
|
}
|
|
459
553
|
case "attach":
|
|
460
554
|
need(id)
|
|
461
|
-
return attach(client, id, { log })
|
|
555
|
+
return attach(client, id, { log, json })
|
|
462
556
|
case "acp": {
|
|
463
557
|
const app = option(rest, "--app")
|
|
464
558
|
need(app)
|
|
@@ -555,6 +649,9 @@ async function run(argv, { cwd = process.cwd(), log = console.log } = {}) {
|
|
|
555
649
|
case "answer":
|
|
556
650
|
need(id, words[0], words[1])
|
|
557
651
|
return out(await client.answer(id, words[0], words.slice(1).join(" ")), () => log(`[pltt] answered ${words[0]}`))
|
|
652
|
+
case "ask":
|
|
653
|
+
need(id, words[0])
|
|
654
|
+
return out(await client.ask(id, words.join(" ")), (r) => log(r.answer))
|
|
558
655
|
case "fork": {
|
|
559
656
|
const seq = option(rest, "--seq")
|
|
560
657
|
const title = option(rest, "--title")
|
|
@@ -637,10 +734,8 @@ async function run(argv, { cwd = process.cwd(), log = console.log } = {}) {
|
|
|
637
734
|
? data.servers.forEach((m) => log(`${m.name}: ${m.error ? `unavailable (${m.error})` : `${(m.tools || []).length} tools, ${(m.resources || []).length} resources, ${(m.prompts || []).length} prompts`}`))
|
|
638
735
|
: log("[pltt] no MCP servers are configured"))
|
|
639
736
|
case "config":
|
|
640
|
-
return out(await client.config(), (data) => Object.entries(data.config).forEach(([k, v]) => log(`${k.padEnd(20)} ${JSON.stringify(v)}`)))
|
|
641
737
|
case "plugins":
|
|
642
|
-
|
|
643
|
-
data.plugins.forEach((p) => log(`${p.name.padEnd(20)} ${(p.points || []).join(", ") || "-"}${p.error ? ` ERROR ${p.error}` : ""}`)))
|
|
738
|
+
throw new Error(`the Build Agent's ${sub === "config" ? "settings" : "plugins"} are for platform operators (the superadmin console's Build Agent tab)`)
|
|
644
739
|
case "api": {
|
|
645
740
|
const [method, route, body] = rest
|
|
646
741
|
need(method, route)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
const { parseFlags, resolveEnvironment } = require("../environments")
|
|
4
|
+
|
|
5
|
+
// Superadmins keep the store's categories on the platform, so the list is
|
|
6
|
+
// read from it, never shipped with the CLI. A manifest `category` that names
|
|
7
|
+
// none of them (or no category at all) is filed under Other at publish.
|
|
8
|
+
async function run(argv, { cwd, log = console.log } = {}) {
|
|
9
|
+
const { flags } = parseFlags(argv)
|
|
10
|
+
const env = resolveEnvironment({ cwd, flags })
|
|
11
|
+
const url = `${env.url}/api/v1/appstore/categories`
|
|
12
|
+
const res = await fetch(url)
|
|
13
|
+
if (!res.ok) throw new Error(`GET ${url} → ${res.status}: ${await res.text()}`)
|
|
14
|
+
const { categories } = await res.json()
|
|
15
|
+
if (flags.json) {
|
|
16
|
+
log(JSON.stringify({ categories }, null, 2))
|
|
17
|
+
return categories
|
|
18
|
+
}
|
|
19
|
+
log(`App Store categories on ${env.name} (set "category" in palette-plugin.json to one of them):`)
|
|
20
|
+
for (const name of categories) log(` ${name}`)
|
|
21
|
+
log('Any other value, or none, is filed under "Other". A superadmin can move the app at any time.')
|
|
22
|
+
return categories
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = run
|
package/lib/commands/doctor.js
CHANGED
|
@@ -63,7 +63,8 @@ function reportPlatformServices(manifest, cwd) {
|
|
|
63
63
|
ok(`manifest declares ${names.length} platform service(s): ${names.join(", ")}`)
|
|
64
64
|
for (const name of names) {
|
|
65
65
|
const note = PLATFORM_SERVICE_DEV_NOTES[name]
|
|
66
|
-
|
|
66
|
+
const dev = note ? note(cwd) : PLATFORM_SERVICES.find((service) => service.name === name)?.dev
|
|
67
|
+
if (dev) console.log(` ctx.${name} — ${dev}`)
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
package/lib/commands/platform.js
CHANGED
|
@@ -37,7 +37,7 @@ function list(manifest, cwd, json) {
|
|
|
37
37
|
const rows = PLATFORM_SERVICES.map((service) => ({
|
|
38
38
|
...service,
|
|
39
39
|
declared: on.has(service.name),
|
|
40
|
-
dev: devNote(service.name, cwd),
|
|
40
|
+
dev: service.dev || devNote(service.name, cwd),
|
|
41
41
|
}))
|
|
42
42
|
// The other half of what `ctx` can do: clients switched on by a manifest
|
|
43
43
|
// permission rather than by platform_services. Printing them together is the
|
|
@@ -106,7 +106,8 @@ function enable(cwd, names) {
|
|
|
106
106
|
console.log(`[pltt] ${service.accessor} enabled — ${service.summary}`)
|
|
107
107
|
if (service.python) console.log(` ${service.python}`)
|
|
108
108
|
const key = DEV_KEYS[name]
|
|
109
|
-
if (
|
|
109
|
+
if (service.dev) console.log(` ${service.dev}`)
|
|
110
|
+
else if (key) console.log(` pltt dev stubs this unless ${key} is in .env.local`)
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
|
package/lib/commands/publish.js
CHANGED
|
@@ -503,6 +503,13 @@ async function run(argv, { cwd }) {
|
|
|
503
503
|
if (record.review_url && record.status !== "active") {
|
|
504
504
|
console.log(`[pltt] review queue: ${record.review_url}`)
|
|
505
505
|
}
|
|
506
|
+
// Where the store filed the app: a manifest category that names no store
|
|
507
|
+
// category lands in Other (older platforms send neither field).
|
|
508
|
+
if (record.category_note) {
|
|
509
|
+
console.log(`[pltt] ${record.category_note}`)
|
|
510
|
+
} else if (record.category) {
|
|
511
|
+
console.log(`[pltt] store category: ${record.category}`)
|
|
512
|
+
}
|
|
506
513
|
if (record.preview_url) {
|
|
507
514
|
console.log(`[pltt] preview: ${record.preview_url}`)
|
|
508
515
|
}
|
package/lib/dev-simulator.js
CHANGED
|
@@ -222,6 +222,7 @@ DEV_STORAGE = None
|
|
|
222
222
|
DEV_LLM = None
|
|
223
223
|
DEV_WEB = None
|
|
224
224
|
DEV_MEDIA = None
|
|
225
|
+
DEV_EMAIL = None
|
|
225
226
|
if _service_enabled("llm"):
|
|
226
227
|
from palette_sdk.platform_services import LocalLLMService
|
|
227
228
|
DEV_LLM = LocalLLMService(DEV_SECRETS.get("OPENAI_API_KEY") or os.environ.get("OPENAI_API_KEY", ""))
|
|
@@ -229,6 +230,10 @@ if _service_enabled("llm"):
|
|
|
229
230
|
if _service_enabled("web"):
|
|
230
231
|
from palette_sdk.platform_services import LocalWebService
|
|
231
232
|
DEV_WEB = LocalWebService()
|
|
233
|
+
if _service_enabled("email"):
|
|
234
|
+
from palette_sdk.platform_services import LocalEmailService
|
|
235
|
+
DEV_EMAIL = LocalEmailService(ROOT / ".palette" / "dev-outbox", app_name=MANIFEST.get("name") or MANIFEST.get("id", ""))
|
|
236
|
+
print("[pltt] ctx.email: messages are saved to .palette/dev-outbox as .eml files, not sent")
|
|
232
237
|
if _service_enabled("redis"):
|
|
233
238
|
from palette_sdk.platform_services import LocalRedisService
|
|
234
239
|
DEV_REDIS = LocalRedisService()
|
|
@@ -542,6 +547,8 @@ def _local_job_context(session):
|
|
|
542
547
|
extra["talk"] = TalkClient(TALK, MANIFEST.get("permissions", []))
|
|
543
548
|
if "media" in getattr(PluginContext, "__dataclass_fields__", {}):
|
|
544
549
|
extra["media"] = DEV_MEDIA or UnavailablePlatformService("media")
|
|
550
|
+
if "email" in getattr(PluginContext, "__dataclass_fields__", {}):
|
|
551
|
+
extra["email"] = DEV_EMAIL or UnavailablePlatformService("email")
|
|
545
552
|
if "user_name" in getattr(PluginContext, "__dataclass_fields__", {}):
|
|
546
553
|
extra["user_name"] = "Palette Developer"
|
|
547
554
|
|
|
@@ -644,6 +651,7 @@ class DevPluginContextMiddleware(BaseHTTPMiddleware):
|
|
|
644
651
|
request.state.llm = DEV_LLM
|
|
645
652
|
request.state.web = DEV_WEB
|
|
646
653
|
request.state.media = DEV_MEDIA
|
|
654
|
+
request.state.email = DEV_EMAIL
|
|
647
655
|
request.state.plugin_local_connections = DEV_CONNECTIONS
|
|
648
656
|
request.state.plugin_apps = LocalAppInteropService()
|
|
649
657
|
request.state.plugin_events = LocalEventPublisher()
|
package/lib/manifest.js
CHANGED
|
@@ -291,10 +291,18 @@ const PLATFORM_SERVICES = [
|
|
|
291
291
|
{
|
|
292
292
|
name: "web",
|
|
293
293
|
accessor: "ctx.web",
|
|
294
|
-
summary: "Web search plus an SSRF-guarded page reader (HTML tables, PDFs)",
|
|
294
|
+
summary: "Web search plus an SSRF-guarded page reader (HTML tables, PDFs; render=True for pages built by scripts)",
|
|
295
295
|
python: 'hits = await ctx.web.search("fx rates", limit=5)',
|
|
296
296
|
instead_of: "TAVILY_API_KEY / SERPAPI_KEY",
|
|
297
297
|
},
|
|
298
|
+
{
|
|
299
|
+
name: "email",
|
|
300
|
+
accessor: "ctx.email",
|
|
301
|
+
summary: "Send email through the platform's provider — to/cc/bcc, html + text, reply_to, attachments and inline images, headers, tags",
|
|
302
|
+
python: 'await ctx.email.send("ann@acme.com", "Your invoice", html=body, attachments=[{"filename": "invoice.pdf", "content": pdf}])',
|
|
303
|
+
instead_of: "SENDGRID_API_KEY / SMTP credentials + a verified sender domain",
|
|
304
|
+
dev: "pltt dev: checked like hosted, saved to .palette/dev-outbox as .eml — nothing is sent",
|
|
305
|
+
},
|
|
298
306
|
]
|
|
299
307
|
|
|
300
308
|
function validatePlatformServices(value, errors) {
|
|
@@ -815,6 +823,8 @@ function validateManifest(m) {
|
|
|
815
823
|
errors.push("data_scope must be personal or organization")
|
|
816
824
|
}
|
|
817
825
|
requireString(m, "developer", "manifest", errors)
|
|
826
|
+
// Superadmins keep the store's categories on the platform (`pltt categories`), so
|
|
827
|
+
// the value is checked at publish: one that names none is filed under Other.
|
|
818
828
|
requireString(m, "category", "manifest", errors)
|
|
819
829
|
requireString(m, "tagline", "manifest", errors)
|
|
820
830
|
requireString(m, "description", "manifest", errors)
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@ pltt package --json
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
See what the platform already gives your app before adding an API key or a
|
|
12
|
-
dependency — models, fal.ai media, web search, storage, vector and redis
|
|
13
|
-
available through `ctx.*` on the platform's own credentials:
|
|
12
|
+
dependency — models, fal.ai media, web search, email, storage, vector and redis
|
|
13
|
+
are all available through `ctx.*` on the platform's own credentials:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
pltt platform list # every service + a snippet, and its pltt dev mode
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "My Agent Tool",
|
|
6
6
|
"version": "1.0.0",
|
|
7
7
|
"developer": "Your Team",
|
|
8
|
-
"category": "
|
|
8
|
+
"category": "Productivity",
|
|
9
9
|
"tagline": "A tool an agent can call",
|
|
10
10
|
"description": "Registers a callable tool that any agent in the org can invoke.",
|
|
11
11
|
"icon": "Toolbox",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "My External Service",
|
|
6
6
|
"version": "1.0.0",
|
|
7
7
|
"developer": "Your Team",
|
|
8
|
-
"category": "
|
|
8
|
+
"category": "Productivity",
|
|
9
9
|
"tagline": "Calls a third-party API",
|
|
10
10
|
"description": "Demonstrates declared external_network access and a scoped per-org config token.",
|
|
11
11
|
"icon": "CloudArrowUp",
|