@palettelab/cli 0.3.68 → 0.3.70
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 +23 -18
- package/backend-sdk/palette_sdk/__init__.py +3 -3
- package/backend-sdk/palette_sdk/agent_routes.py +43 -0
- package/backend-sdk/palette_sdk/connections_generated.py +302 -51
- package/backend-sdk/palette_sdk/data_rooms.py +12 -0
- package/backend-sdk/palette_sdk/manifest.py +2 -2
- package/backend-sdk/palette_sdk/permissions.py +1 -3
- package/backend-sdk/palette_sdk/platform_services.py +8 -5
- package/backend-sdk/palette_sdk/plugin_context.py +10 -12
- package/backend-sdk/pyproject.toml +1 -1
- package/docs/python-backend-sdk.md +17 -60
- package/lib/commands/models.js +12 -8
- package/lib/connection-catalog.json +2687 -622
- package/lib/dev-simulator.js +2 -83
- package/lib/manifest.js +3 -10
- package/package.json +1 -1
- package/template-fallback/backend/api/main.py +2 -2
- package/template-fallback/frontend/src/index.tsx +10 -21
- package/template-fallback/frontend/src/translations.ts +6 -12
- package/template-fallback/package.json +1 -1
- package/template-fallback/palette-plugin.json +1 -3
- package/template-fallback/templates/agent-tool/README.md +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/backend/api/main.py +2 -0
- package/template-fallback/templates/database/package.json +1 -1
- package/template-fallback/templates/external-service/package.json +1 -1
- package/template-fallback/templates/frontend-only/package.json +1 -1
- package/template-fallback/templates/frontend-only/palette-plugin.json +1 -1
- package/template-fallback/templates/next/package.json +1 -1
- package/template-fallback/templates/palette-app/backend/api/main.py +1 -1
- package/template-fallback/templates/palette-app/package.json +1 -1
- package/template-fallback/templates/palette-app/palette-plugin.json +1 -1
- package/template-fallback/templates/provider-app/package.json +1 -1
- package/backend-sdk/palette_sdk/tasks.py +0 -117
package/lib/dev-simulator.js
CHANGED
|
@@ -408,86 +408,8 @@ class LocalTalkService:
|
|
|
408
408
|
print("[palette-talk]", json.dumps(message, sort_keys=True))
|
|
409
409
|
return message
|
|
410
410
|
|
|
411
|
-
class LocalTasksService:
|
|
412
|
-
"""Local stand-in for the task board: an in-memory list that behaves like
|
|
413
|
-
the hosted one, including the app scoping (an app sees only its own rows).
|
|
414
|
-
|
|
415
|
-
Rows live for the life of the pltt dev process — enough to exercise
|
|
416
|
-
create -> list -> complete without a platform.
|
|
417
|
-
"""
|
|
418
|
-
|
|
419
|
-
def __init__(self):
|
|
420
|
-
self._rows = {}
|
|
421
|
-
self._next_id = 1
|
|
422
|
-
|
|
423
|
-
RESERVED = {"app_id", "source", "source_channel", "source_client", "external_ref", "routine_id"}
|
|
424
|
-
|
|
425
|
-
def _clean(self, fields):
|
|
426
|
-
rejected = sorted(self.RESERVED & set(fields))
|
|
427
|
-
if rejected:
|
|
428
|
-
raise HTTPException(
|
|
429
|
-
status_code=422,
|
|
430
|
-
detail="ctx.tasks sets " + ", ".join(rejected) + " itself — remove it from the call",
|
|
431
|
-
)
|
|
432
|
-
return fields
|
|
433
|
-
|
|
434
|
-
async def create(self, *, title, **fields):
|
|
435
|
-
if not str(title or "").strip():
|
|
436
|
-
raise HTTPException(status_code=422, detail="title is required")
|
|
437
|
-
now = datetime.now(timezone.utc).isoformat()
|
|
438
|
-
row = {
|
|
439
|
-
"id": self._next_id,
|
|
440
|
-
"title": str(title),
|
|
441
|
-
"description": "",
|
|
442
|
-
"output": None,
|
|
443
|
-
"status": "pending",
|
|
444
|
-
"priority": "medium",
|
|
445
|
-
"task_type": "manual",
|
|
446
|
-
"progress": 0,
|
|
447
|
-
"tags": [],
|
|
448
|
-
"due_date": None,
|
|
449
|
-
"agent_id": None,
|
|
450
|
-
"parent_task_id": None,
|
|
451
|
-
"team_id": None,
|
|
452
|
-
"app_id": MANIFEST.get("id", ""),
|
|
453
|
-
"source": "app",
|
|
454
|
-
"created_at": now,
|
|
455
|
-
"updated_at": now,
|
|
456
|
-
"completed_at": None,
|
|
457
|
-
"started_at": None,
|
|
458
|
-
}
|
|
459
|
-
row.update(self._clean(fields))
|
|
460
|
-
self._rows[self._next_id] = row
|
|
461
|
-
self._next_id += 1
|
|
462
|
-
print("[palette-tasks] created", json.dumps(row, sort_keys=True, default=str))
|
|
463
|
-
return dict(row)
|
|
464
|
-
|
|
465
|
-
async def list(self, *, status=None, limit=50):
|
|
466
|
-
rows = [r for r in self._rows.values() if status is None or r["status"] == status]
|
|
467
|
-
rows.sort(key=lambda r: r["id"], reverse=True)
|
|
468
|
-
return [dict(r) for r in rows[: max(1, int(limit))]]
|
|
469
|
-
|
|
470
|
-
async def get(self, task_id):
|
|
471
|
-
row = self._rows.get(int(task_id))
|
|
472
|
-
return dict(row) if row else None
|
|
473
|
-
|
|
474
|
-
async def update(self, task_id, **fields):
|
|
475
|
-
row = self._rows.get(int(task_id))
|
|
476
|
-
if row is None:
|
|
477
|
-
raise HTTPException(status_code=404, detail="Task not found")
|
|
478
|
-
row.update(self._clean(fields))
|
|
479
|
-
row["updated_at"] = datetime.now(timezone.utc).isoformat()
|
|
480
|
-
if row["status"] == "completed":
|
|
481
|
-
row["completed_at"] = row["completed_at"] or row["updated_at"]
|
|
482
|
-
row["progress"] = max(int(row.get("progress") or 0), 100)
|
|
483
|
-
return dict(row)
|
|
484
|
-
|
|
485
|
-
async def delete(self, task_id):
|
|
486
|
-
self._rows.pop(int(task_id), None)
|
|
487
|
-
|
|
488
411
|
NOTIFICATIONS = LocalNotificationsService()
|
|
489
412
|
TALK = LocalTalkService()
|
|
490
|
-
TASKS = LocalTasksService()
|
|
491
413
|
|
|
492
414
|
spec = importlib.util.spec_from_file_location("palette_local_backend", ENTRY)
|
|
493
415
|
module = importlib.util.module_from_spec(spec)
|
|
@@ -620,10 +542,8 @@ def _local_job_context(session):
|
|
|
620
542
|
extra["talk"] = TalkClient(TALK, MANIFEST.get("permissions", []))
|
|
621
543
|
if "media" in getattr(PluginContext, "__dataclass_fields__", {}):
|
|
622
544
|
extra["media"] = DEV_MEDIA or UnavailablePlatformService("media")
|
|
623
|
-
if "
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
extra["tasks"] = TasksClient(TASKS, MANIFEST.get("permissions", []))
|
|
545
|
+
if "user_name" in getattr(PluginContext, "__dataclass_fields__", {}):
|
|
546
|
+
extra["user_name"] = "Palette Developer"
|
|
627
547
|
|
|
628
548
|
return PluginContext(
|
|
629
549
|
db=session,
|
|
@@ -730,7 +650,6 @@ class DevPluginContextMiddleware(BaseHTTPMiddleware):
|
|
|
730
650
|
request.state.plugin_jobs = LOCAL_JOB_SERVICE
|
|
731
651
|
request.state.notifications = NOTIFICATIONS
|
|
732
652
|
request.state.talk = TALK
|
|
733
|
-
request.state.tasks = TASKS
|
|
734
653
|
request.state.storage = DEV_STORAGE
|
|
735
654
|
if DEV_REDIS is not None:
|
|
736
655
|
request.state.redis = DEV_REDIS
|
package/lib/manifest.js
CHANGED
|
@@ -7,8 +7,6 @@ const { ENV_KEY_PATTERN, SECRET_SCOPES } = require("./secrets")
|
|
|
7
7
|
const MANIFEST_FILE = "palette-plugin.json"
|
|
8
8
|
const SUPPORTED_MANIFEST_VERSIONS = ["1"]
|
|
9
9
|
const KNOWN_PERMISSIONS = new Set([
|
|
10
|
-
"tasks:read",
|
|
11
|
-
"tasks:write",
|
|
12
10
|
"data_rooms:read",
|
|
13
11
|
"data_rooms:write",
|
|
14
12
|
"agents:read",
|
|
@@ -218,12 +216,6 @@ function validateSecrets(value, errors) {
|
|
|
218
216
|
// Permission-gated `ctx.*` clients. Declaring the permission in the manifest is
|
|
219
217
|
// what turns the client on; the platform re-checks it on every call.
|
|
220
218
|
const CTX_PERMISSIONS = [
|
|
221
|
-
{
|
|
222
|
-
accessor: "ctx.tasks",
|
|
223
|
-
permissions: ["tasks:read", "tasks:write"],
|
|
224
|
-
summary: "The caller's task board — create, list, update, complete. An app sees only the tasks it created",
|
|
225
|
-
python: 'task = await ctx.tasks.create("Review suppliers", priority="high")',
|
|
226
|
-
},
|
|
227
219
|
{
|
|
228
220
|
accessor: "ctx.data_rooms",
|
|
229
221
|
permissions: ["data_rooms:read", "data_rooms:write"],
|
|
@@ -326,8 +318,9 @@ function validatePlatformServices(value, errors) {
|
|
|
326
318
|
}
|
|
327
319
|
const allowed = new Set(["required", "billing"])
|
|
328
320
|
if (name === "llm") {
|
|
329
|
-
//
|
|
330
|
-
//
|
|
321
|
+
// Capacity the app asks ctx.llm for — granted by the publish review,
|
|
322
|
+
// bounded again by the platform at call time. `models` is accepted for
|
|
323
|
+
// older manifests and gates nothing: apps get the workspace's models.
|
|
331
324
|
for (const key of ["models", "max_output_tokens", "max_images"]) allowed.add(key)
|
|
332
325
|
const models = spec.models
|
|
333
326
|
if (
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ from palette_sdk import (
|
|
|
29
29
|
router = PluginRouter(tags=["my-plugin"])
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@router.get("/status", dependencies=[require_permission("
|
|
32
|
+
@router.get("/status", dependencies=[require_permission("data_rooms:read")])
|
|
33
33
|
async def get_status(ctx: PluginContext = Depends(get_plugin_context)):
|
|
34
34
|
"""Example endpoint — returns plugin status."""
|
|
35
35
|
return SuccessResponse(
|
|
@@ -42,7 +42,7 @@ async def get_status(ctx: PluginContext = Depends(get_plugin_context)):
|
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
@router.get("/hello", dependencies=[require_permission("
|
|
45
|
+
@router.get("/hello", dependencies=[require_permission("data_rooms:read")])
|
|
46
46
|
async def hello(ctx: PluginContext = Depends(get_plugin_context)):
|
|
47
47
|
"""Example endpoint — simple hello."""
|
|
48
48
|
return {"message": f"Hello from plugin! User: {ctx.user_id}"}
|
|
@@ -10,18 +10,17 @@
|
|
|
10
10
|
* Available hooks from @palettelab/sdk:
|
|
11
11
|
* - usePlatform() - access user, org, API, language, navigate, showToast
|
|
12
12
|
* - usePluginTranslations() - translate app-owned resource files using OS language
|
|
13
|
-
* - usePluginTasks() - CRUD tasks
|
|
14
13
|
* - usePluginDataRooms() - browse data rooms and files
|
|
15
14
|
* - usePluginChat() - chat with agents
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
|
-
import { usePlatform,
|
|
17
|
+
import { usePlatform, usePluginDataRooms, usePluginTranslations } from "@palettelab/sdk"
|
|
19
18
|
import type { PluginComponentProps } from "@palettelab/sdk"
|
|
20
19
|
import { translations } from "./translations"
|
|
21
20
|
|
|
22
21
|
export default function MyPlugin(_props: PluginComponentProps) {
|
|
23
|
-
const { user
|
|
24
|
-
const {
|
|
22
|
+
const { user } = usePlatform()
|
|
23
|
+
const { rooms, loading } = usePluginDataRooms()
|
|
25
24
|
const { t, language, setLanguage } = usePluginTranslations(translations)
|
|
26
25
|
|
|
27
26
|
return (
|
|
@@ -48,31 +47,21 @@ export default function MyPlugin(_props: PluginComponentProps) {
|
|
|
48
47
|
<li>{t("editUi")}</li>
|
|
49
48
|
<li>{t("editApi")}</li>
|
|
50
49
|
<li>{t("usePlatform")}</li>
|
|
51
|
-
<li>{t("useTasks")}</li>
|
|
52
50
|
<li>{t("useDataRooms")}</li>
|
|
53
51
|
</ul>
|
|
54
52
|
</div>
|
|
55
53
|
|
|
56
54
|
<div className="rounded-lg border p-4">
|
|
57
|
-
<h2 className="font-semibold mb-2">{t("
|
|
58
|
-
{!loading &&
|
|
59
|
-
<p className="text-sm text-muted-foreground">{t("
|
|
55
|
+
<h2 className="font-semibold mb-2">{t("drives")} ({loading ? "..." : rooms.length})</h2>
|
|
56
|
+
{!loading && rooms.length === 0 && (
|
|
57
|
+
<p className="text-sm text-muted-foreground">{t("noDrives")}</p>
|
|
60
58
|
)}
|
|
61
|
-
{
|
|
62
|
-
<div key={
|
|
63
|
-
<span>{
|
|
64
|
-
<span className="text-xs text-muted-foreground">{
|
|
59
|
+
{rooms.slice(0, 5).map(room => (
|
|
60
|
+
<div key={room.id} className="flex items-center justify-between py-1 text-sm">
|
|
61
|
+
<span>{room.name}</span>
|
|
62
|
+
<span className="text-xs text-muted-foreground">{t("fileCount", { count: room.files_count })}</span>
|
|
65
63
|
</div>
|
|
66
64
|
))}
|
|
67
|
-
<button
|
|
68
|
-
className="mt-3 px-3 py-1.5 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90"
|
|
69
|
-
onClick={async () => {
|
|
70
|
-
await createTask({ title: t("sampleTaskTitle"), priority: "medium" })
|
|
71
|
-
showToast(t("taskCreated"), "success")
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
{t("createSampleTask")}
|
|
75
|
-
</button>
|
|
76
65
|
</div>
|
|
77
66
|
</div>
|
|
78
67
|
)
|
|
@@ -8,13 +8,10 @@ export const translations = {
|
|
|
8
8
|
editUi: "Edit frontend/src/index.tsx to build your UI",
|
|
9
9
|
editApi: "Edit backend/api/main.py to add API endpoints",
|
|
10
10
|
usePlatform: "Use usePlatform() to access the authenticated user and API",
|
|
11
|
-
useTasks: "Use usePluginTasks() to manage tasks",
|
|
12
11
|
useDataRooms: "Use usePluginDataRooms() to browse Drive files",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
sampleTaskTitle: "Sample task from plugin",
|
|
17
|
-
taskCreated: "Task created!",
|
|
12
|
+
drives: "Drives",
|
|
13
|
+
noDrives: "No drives yet.",
|
|
14
|
+
fileCount: "{{count}} files",
|
|
18
15
|
language: "Language",
|
|
19
16
|
},
|
|
20
17
|
ko: {
|
|
@@ -24,13 +21,10 @@ export const translations = {
|
|
|
24
21
|
editUi: "frontend/src/index.tsx를 수정해 UI를 만드세요",
|
|
25
22
|
editApi: "backend/api/main.py를 수정해 API 엔드포인트를 추가하세요",
|
|
26
23
|
usePlatform: "usePlatform()으로 인증 사용자와 API에 접근하세요",
|
|
27
|
-
useTasks: "usePluginTasks()로 작업을 관리하세요",
|
|
28
24
|
useDataRooms: "usePluginDataRooms()로 드라이브 파일을 둘러보세요",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
sampleTaskTitle: "플러그인에서 만든 샘플 작업",
|
|
33
|
-
taskCreated: "작업이 생성되었습니다!",
|
|
25
|
+
drives: "드라이브",
|
|
26
|
+
noDrives: "아직 드라이브가 없습니다.",
|
|
27
|
+
fileCount: "파일 {{count}}개",
|
|
34
28
|
language: "언어",
|
|
35
29
|
},
|
|
36
30
|
} satisfies TranslationResources
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Defines a typed `echo` capability with the `@capability` SDK decorator and a
|
|
4
4
|
matching reviewed manifest contract. Once installed, chat agents, workflows,
|
|
5
|
-
and scheduled
|
|
5
|
+
and scheduled tasks discover the same capability automatically.
|
|
6
6
|
|
|
7
7
|
Run `pltt capabilities list` to inspect the agent surface and `pltt test --agent`
|
|
8
8
|
before publishing.
|
|
@@ -18,6 +18,7 @@ async def list_notes(
|
|
|
18
18
|
offset: int = Query(0, ge=0),
|
|
19
19
|
ctx: PluginContext = Depends(get_plugin_context),
|
|
20
20
|
) -> list[dict]:
|
|
21
|
+
"""List my notes, newest first (limit/offset page through them)."""
|
|
21
22
|
# One page per request: list() returns 100 rows unless told otherwise.
|
|
22
23
|
rows = await ctx.repo(Note).list(order_by="-id", limit=limit, offset=offset)
|
|
23
24
|
return [{"id": r.id, "body": r.body} for r in rows]
|
|
@@ -28,6 +29,7 @@ async def create_note(
|
|
|
28
29
|
body: NoteIn,
|
|
29
30
|
ctx: PluginContext = Depends(get_plugin_context),
|
|
30
31
|
) -> dict:
|
|
32
|
+
"""Create a note."""
|
|
31
33
|
if not body.body.strip():
|
|
32
34
|
raise HTTPException(status_code=400, detail="body required")
|
|
33
35
|
note = await ctx.repo(Note).create(body=body.body)
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"""Backend task-board helpers for plugin Python code.
|
|
2
|
-
|
|
3
|
-
Put work on the user's task board from an app, and read back what happened:
|
|
4
|
-
|
|
5
|
-
from palette_sdk import PluginContext, PluginRouter
|
|
6
|
-
|
|
7
|
-
router = PluginRouter()
|
|
8
|
-
|
|
9
|
-
@router.post("/queue-review")
|
|
10
|
-
async def queue_review(ctx: PluginContext):
|
|
11
|
-
task = await ctx.tasks.create(
|
|
12
|
-
"Review the Q3 supplier list",
|
|
13
|
-
description="Flag anything over £50k.",
|
|
14
|
-
priority="high",
|
|
15
|
-
tags=["procurement"],
|
|
16
|
-
)
|
|
17
|
-
return {"task_id": task["id"]}
|
|
18
|
-
|
|
19
|
-
Requires `tasks:read` / `tasks:write` in the manifest's `permissions`.
|
|
20
|
-
|
|
21
|
-
**An app sees only its own tasks.** Every task created here is stamped with the
|
|
22
|
-
app's id, and `list`/`get`/`update`/`delete` refuse anything another app or a
|
|
23
|
-
person created — declaring `tasks:read` buys an app its own rows back, not the
|
|
24
|
-
user's whole board. The platform's own visibility rules still apply on top of
|
|
25
|
-
that, so a member never sees a colleague's task through an app either.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
from __future__ import annotations
|
|
29
|
-
|
|
30
|
-
from typing import Any
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class TasksClient:
|
|
34
|
-
"""Thin wrapper around the platform-injected task service.
|
|
35
|
-
|
|
36
|
-
In production/hosted sandbox the platform injects the service into
|
|
37
|
-
`PluginContext`. In local unit tests, pass a fake service exposing the same
|
|
38
|
-
async `create`/`list`/`get`/`update`/`delete` methods.
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
def __init__(self, service: Any = None, permissions: list[str] | None = None):
|
|
42
|
-
self._service = service
|
|
43
|
-
self._permissions = permissions or []
|
|
44
|
-
|
|
45
|
-
def _require_service(self) -> Any:
|
|
46
|
-
if self._service is None:
|
|
47
|
-
raise RuntimeError(
|
|
48
|
-
"Task service is not available in this runtime. "
|
|
49
|
-
"Run inside Palette OS/hosted sandbox or inject a fake service in tests."
|
|
50
|
-
)
|
|
51
|
-
return self._service
|
|
52
|
-
|
|
53
|
-
def _require_permission(self, permission: str) -> None:
|
|
54
|
-
if permission not in self._permissions:
|
|
55
|
-
raise PermissionError(f"App does not declare required permission: {permission}")
|
|
56
|
-
|
|
57
|
-
async def create(self, title: str, **fields: Any) -> dict[str, Any]:
|
|
58
|
-
"""Create a task on the caller's board, owned by this app.
|
|
59
|
-
|
|
60
|
-
`title` is the only required field. Everything the board understands is
|
|
61
|
-
accepted as a keyword — `description`, `status`, `priority`
|
|
62
|
-
(`low`/`medium`/`high`/`urgent`), `progress`, `tags`, `due_date`,
|
|
63
|
-
`agent_id`, `parent_task_id`, `team_id` — and is validated by the
|
|
64
|
-
platform, so an unknown or malformed field is a 422 rather than a silent
|
|
65
|
-
drop. `app_id` and `source` are set by the platform and cannot be
|
|
66
|
-
spoofed from here.
|
|
67
|
-
"""
|
|
68
|
-
self._require_permission("tasks:write")
|
|
69
|
-
return await self._require_service().create(title=title, **fields)
|
|
70
|
-
|
|
71
|
-
async def list(self, *, status: str | None = None, limit: int = 50) -> list[dict[str, Any]]:
|
|
72
|
-
"""This app's tasks, newest first. `status` filters to one state
|
|
73
|
-
(`pending`, `in_progress`, `completed`, `failed`, `cancelled`)."""
|
|
74
|
-
self._require_permission("tasks:read")
|
|
75
|
-
return await self._require_service().list(status=status, limit=limit)
|
|
76
|
-
|
|
77
|
-
async def get(self, task_id: int) -> dict[str, Any] | None:
|
|
78
|
-
"""One of this app's tasks, or None — a task belonging to anything else
|
|
79
|
-
reads as missing rather than as a permission error, so an app cannot
|
|
80
|
-
probe the board for ids."""
|
|
81
|
-
self._require_permission("tasks:read")
|
|
82
|
-
return await self._require_service().get(task_id)
|
|
83
|
-
|
|
84
|
-
async def update(self, task_id: int, **fields: Any) -> dict[str, Any]:
|
|
85
|
-
"""Patch one of this app's tasks. Same field names as `create`, plus
|
|
86
|
-
`output` for the result text the board shows when it finishes."""
|
|
87
|
-
self._require_permission("tasks:write")
|
|
88
|
-
return await self._require_service().update(task_id, **fields)
|
|
89
|
-
|
|
90
|
-
async def complete(self, task_id: int, *, output: str | None = None) -> dict[str, Any]:
|
|
91
|
-
"""Mark a task done at 100%, with optional result text.
|
|
92
|
-
|
|
93
|
-
Sugar for the three-field update every caller was writing by hand, and
|
|
94
|
-
it keeps `progress` honest — a "completed" task still sitting at 40% is
|
|
95
|
-
what makes a board stop being trusted.
|
|
96
|
-
"""
|
|
97
|
-
self._require_permission("tasks:write")
|
|
98
|
-
fields: dict[str, Any] = {"status": "completed", "progress": 100}
|
|
99
|
-
if output is not None:
|
|
100
|
-
fields["output"] = output
|
|
101
|
-
return await self._require_service().update(task_id, **fields)
|
|
102
|
-
|
|
103
|
-
async def fail(self, task_id: int, *, output: str | None = None) -> dict[str, Any]:
|
|
104
|
-
"""Mark a task failed, with optional reason text."""
|
|
105
|
-
self._require_permission("tasks:write")
|
|
106
|
-
fields: dict[str, Any] = {"status": "failed"}
|
|
107
|
-
if output is not None:
|
|
108
|
-
fields["output"] = output
|
|
109
|
-
return await self._require_service().update(task_id, **fields)
|
|
110
|
-
|
|
111
|
-
async def delete(self, task_id: int) -> None:
|
|
112
|
-
"""Remove one of this app's tasks."""
|
|
113
|
-
self._require_permission("tasks:write")
|
|
114
|
-
await self._require_service().delete(task_id)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
__all__ = ["TasksClient"]
|