@palettelab/cli 0.3.73 → 0.3.75
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 +50 -15
- package/backend-sdk/palette_sdk/__init__.py +1 -1
- package/backend-sdk/palette_sdk/connections_generated.py +26 -0
- package/backend-sdk/palette_sdk/platform_services.py +73 -1
- package/backend-sdk/palette_sdk/plugin_context.py +8 -2
- package/backend-sdk/pyproject.toml +1 -1
- package/docs/python-backend-sdk.md +35 -11
- package/lib/acp.js +227 -25
- package/lib/agent-client.js +56 -27
- package/lib/cli.js +1 -0
- package/lib/commands/agent.js +145 -50
- package/lib/commands/dev.js +19 -2
- package/lib/connection-catalog.json +132 -0
- package/lib/dev-simulator.js +29 -14
- package/package.json +1 -1
- package/template-fallback/backend/pytest.ini +3 -0
- package/template-fallback/backend/tests/test_import.py +4 -8
- package/template-fallback/package.json +1 -1
- package/template-fallback/pyproject.toml +5 -0
- 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/backend/api/main.py +7 -6
- package/template-fallback/templates/external-service/package.json +1 -1
- package/template-fallback/templates/external-service/palette-plugin.json +7 -0
- 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
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
from pathlib import Path
|
|
1
|
+
# pytest.ini puts backend/api on the import path, as the platform loader does.
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
def test_backend_entry_exports_router():
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
assert
|
|
9
|
-
module = importlib.util.module_from_spec(spec)
|
|
10
|
-
spec.loader.exec_module(module)
|
|
11
|
-
assert getattr(module, "router", None) is not None
|
|
5
|
+
from main import router
|
|
6
|
+
|
|
7
|
+
assert router is not None
|
|
@@ -17,3 +17,8 @@ dependencies = [
|
|
|
17
17
|
# `pltt test` ships the backend SDK on PYTHONPATH. Pin a released
|
|
18
18
|
# palette-sdk package here only if you run backend tests outside the CLI.
|
|
19
19
|
]
|
|
20
|
+
|
|
21
|
+
[tool.pytest.ini_options]
|
|
22
|
+
# The backend entry's folder is on the import path, as the platform loader puts it (backend/pytest.ini does the same
|
|
23
|
+
# for runs from backend/): backend/tests import `main` directly.
|
|
24
|
+
pythonpath = ["backend/api"]
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"""External-service plugin backend.
|
|
2
2
|
|
|
3
|
-
Reads a per-org
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
the
|
|
3
|
+
Reads a per-org API token (the install-scoped EXAMPLE_API_TOKEN secret the
|
|
4
|
+
manifest declares, set when the org installs the plugin) and forwards a
|
|
5
|
+
request to a declared external host. The host MUST be listed in
|
|
6
|
+
capabilities.external_network in the manifest — the platform enforces the
|
|
7
|
+
allowlist at runtime.
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
|
-
import os
|
|
10
10
|
from fastapi import Depends, HTTPException
|
|
11
11
|
|
|
12
12
|
from palette_sdk import PluginRouter, PluginContext, get_plugin_context, require_permission
|
|
@@ -21,7 +21,8 @@ async def proxy(ctx: PluginContext = Depends(get_plugin_context)) -> dict:
|
|
|
21
21
|
import httpx
|
|
22
22
|
|
|
23
23
|
connection = await ctx.connections.status("example_oauth")
|
|
24
|
-
|
|
24
|
+
# Declared secrets come from the install's config, never the server's environment.
|
|
25
|
+
token = ctx.secret("EXAMPLE_API_TOKEN")
|
|
25
26
|
if not token:
|
|
26
27
|
raise HTTPException(status_code=500, detail="EXAMPLE_API_TOKEN not configured")
|
|
27
28
|
async with httpx.AsyncClient() as client:
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
"frontend": { "entry": "./frontend/src/index.tsx", "sandbox": true },
|
|
25
25
|
"backend": { "entry": "./backend/api/main.py" },
|
|
26
26
|
"permissions": ["resources:read"],
|
|
27
|
+
"secrets": {
|
|
28
|
+
"EXAMPLE_API_TOKEN": {
|
|
29
|
+
"scope": "install",
|
|
30
|
+
"required": false,
|
|
31
|
+
"help": "API token for api.example.com, entered by the installing organization."
|
|
32
|
+
}
|
|
33
|
+
},
|
|
27
34
|
"connections": [
|
|
28
35
|
{
|
|
29
36
|
"id": "example_oauth",
|