interloper-api 0.132.0__tar.gz → 0.133.0__tar.gz
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.
- {interloper_api-0.132.0 → interloper_api-0.133.0}/PKG-INFO +2 -2
- {interloper_api-0.132.0 → interloper_api-0.133.0}/pyproject.toml +5 -6
- {interloper_api-0.132.0 → interloper_api-0.133.0}/pyproject.toml.orig +5 -6
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/app.py +51 -60
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/authorization.py +282 -3
- interloper_api-0.133.0/src/interloper_api/cli.py +204 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/dependencies/__init__.py +4 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/dependencies/state.py +30 -30
- interloper_api-0.133.0/src/interloper_api/extension.yaml +10 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/login.py +5 -3
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/notifications/base.py +4 -5
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/notifications/invitations.py +0 -3
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/notifications/super_admins.py +0 -3
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/admin.py +87 -290
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/agent.py +5 -6
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/apps.py +9 -3
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/auth.py +7 -7
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/authorization.py +12 -4
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/components.py +4 -3
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/oauth.py +2 -2
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/overview.py +2 -2
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/tokens.py +2 -2
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/websocket.py +106 -30
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/server.py +4 -3
- interloper_api-0.133.0/src/interloper_api/settings.py +162 -0
- interloper_api-0.132.0/src/interloper_api/cli.py +0 -161
- {interloper_api-0.132.0 → interloper_api-0.133.0}/README.md +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/__init__.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/dependencies/auth.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/dependencies/rbac.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/notifications/__init__.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/__init__.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/backfills.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/catalog.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/executions.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/health.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/organisations.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/relations.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/routes/runs.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/utils/__init__.py +0 -0
- {interloper_api-0.132.0 → interloper_api-0.133.0}/src/interloper_api/utils/time.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: interloper-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.133.0
|
|
4
4
|
Summary: Interloper FastAPI routes
|
|
5
5
|
Author: Guillaume Onfroy
|
|
6
6
|
Author-email: Guillaume Onfroy <guillaume@digitlcloud.com>
|
|
@@ -19,7 +19,7 @@ Requires-Dist: joserfc>=1.7
|
|
|
19
19
|
Requires-Dist: interloper-agent ; extra == 'agent'
|
|
20
20
|
Requires-Dist: interloper-core[otel] ; extra == 'otel'
|
|
21
21
|
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.65b0 ; extra == 'otel'
|
|
22
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
23
|
Provides-Extra: agent
|
|
24
24
|
Provides-Extra: otel
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "interloper-api"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.133.0"
|
|
4
4
|
description = "Interloper FastAPI routes"
|
|
5
5
|
readme = "README.md"
|
|
6
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"interloper-core",
|
|
9
9
|
"interloper-db",
|
|
@@ -30,12 +30,11 @@ otel = [
|
|
|
30
30
|
"opentelemetry-instrumentation-fastapi>=0.65b0",
|
|
31
31
|
]
|
|
32
32
|
|
|
33
|
-
[project.entry-points."interloper.
|
|
34
|
-
api = "interloper_api
|
|
35
|
-
oauth = "interloper_api.cli:register_oauth"
|
|
33
|
+
[project.entry-points."interloper.extensions"]
|
|
34
|
+
api = "interloper_api"
|
|
36
35
|
|
|
37
36
|
[build-system]
|
|
38
|
-
requires = ["uv_build>=0.
|
|
37
|
+
requires = ["uv_build>=0.13.7,<0.14"]
|
|
39
38
|
build-backend = "uv_build"
|
|
40
39
|
|
|
41
40
|
[tool.uv.sources.interloper-core]
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
# ###############
|
|
4
4
|
[project]
|
|
5
5
|
name = "interloper-api"
|
|
6
|
-
version = "0.
|
|
6
|
+
version = "0.133.0"
|
|
7
7
|
description = "Interloper FastAPI routes"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
authors = [{ name = "Guillaume Onfroy", email = "guillaume@digitlcloud.com" }]
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
11
|
dependencies = [
|
|
12
12
|
"interloper-core",
|
|
13
13
|
"interloper-db",
|
|
@@ -30,12 +30,11 @@ otel = [
|
|
|
30
30
|
"opentelemetry-instrumentation-fastapi>=0.65b0",
|
|
31
31
|
]
|
|
32
32
|
|
|
33
|
-
[project.entry-points."interloper.
|
|
34
|
-
api = "interloper_api
|
|
35
|
-
oauth = "interloper_api.cli:register_oauth"
|
|
33
|
+
[project.entry-points."interloper.extensions"]
|
|
34
|
+
api = "interloper_api"
|
|
36
35
|
|
|
37
36
|
[build-system]
|
|
38
|
-
requires = ["uv_build>=0.
|
|
37
|
+
requires = ["uv_build>=0.13.7,<0.14"]
|
|
39
38
|
build-backend = "uv_build"
|
|
40
39
|
|
|
41
40
|
[tool.uv.sources]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
-
from collections.abc import
|
|
6
|
+
from collections.abc import AsyncGenerator
|
|
7
7
|
from contextlib import asynccontextmanager
|
|
8
8
|
from typing import Any
|
|
9
9
|
|
|
@@ -44,6 +44,7 @@ from interloper_api.routes import (
|
|
|
44
44
|
websocket,
|
|
45
45
|
)
|
|
46
46
|
from interloper_api.routes import catalog as catalog_routes
|
|
47
|
+
from interloper_api.settings import ApiSettings
|
|
47
48
|
|
|
48
49
|
logger = logging.getLogger(__name__)
|
|
49
50
|
|
|
@@ -176,9 +177,9 @@ def install_error_handlers(app: FastAPI) -> None:
|
|
|
176
177
|
|
|
177
178
|
|
|
178
179
|
def create_app(
|
|
179
|
-
store: Store
|
|
180
|
-
catalog: Catalog
|
|
181
|
-
settings:
|
|
180
|
+
store: Store,
|
|
181
|
+
catalog: Catalog,
|
|
182
|
+
settings: ApiSettings,
|
|
182
183
|
cors_origins: list[str] | None = None,
|
|
183
184
|
**kwargs: Any,
|
|
184
185
|
) -> FastAPI:
|
|
@@ -190,10 +191,10 @@ def create_app(
|
|
|
190
191
|
Args:
|
|
191
192
|
store: The ``Store`` instance for persistence.
|
|
192
193
|
catalog: Catalog instance.
|
|
193
|
-
settings:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
only when
|
|
194
|
+
settings: Every section the API reads; the factory also builds the
|
|
195
|
+
secrets-redacted snapshot of every declared section for the
|
|
196
|
+
super-admin ``/admin/config`` view. The agent routes
|
|
197
|
+
mount only when they enable the agent and the ``agent`` extra
|
|
197
198
|
is installed.
|
|
198
199
|
cors_origins: Allowed CORS origins. Only needed in dev mode for direct
|
|
199
200
|
WebSocket connections that bypass the Vite proxy.
|
|
@@ -225,11 +226,11 @@ def create_app(
|
|
|
225
226
|
api.include_router(router)
|
|
226
227
|
for org_router in _ORG_ROUTERS:
|
|
227
228
|
api.include_router(org_router, prefix=ORG_PREFIX)
|
|
228
|
-
|
|
229
|
+
agent_model = _mount_agent(api, settings)
|
|
229
230
|
app.include_router(api)
|
|
230
231
|
app.include_router(authorization.well_known_router)
|
|
231
232
|
|
|
232
|
-
app.state.interloper = _state(store, catalog, settings,
|
|
233
|
+
app.state.interloper = _state(store, catalog, settings, agent_model=agent_model, google_login=google_login)
|
|
233
234
|
|
|
234
235
|
oauth.log_provider_status()
|
|
235
236
|
|
|
@@ -240,7 +241,7 @@ def create_app(
|
|
|
240
241
|
|
|
241
242
|
|
|
242
243
|
@asynccontextmanager
|
|
243
|
-
async def _lifespan(app: FastAPI) ->
|
|
244
|
+
async def _lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
|
244
245
|
"""Promote the configured super-admins, then serve with the realtime listener running.
|
|
245
246
|
|
|
246
247
|
``auth.super_admin_emails`` is applied here as well as at login, so a
|
|
@@ -249,38 +250,35 @@ async def _lifespan(app: FastAPI) -> AsyncIterator[None]:
|
|
|
249
250
|
|
|
250
251
|
Args:
|
|
251
252
|
app: The application being started; its state carries the store and
|
|
252
|
-
the settings
|
|
253
|
+
the settings.
|
|
253
254
|
|
|
254
255
|
Yields:
|
|
255
256
|
None, while the application serves.
|
|
256
257
|
"""
|
|
257
258
|
state: State = app.state.interloper
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
)
|
|
262
|
-
for profile in promoted:
|
|
263
|
-
logger.info("Promoted profile %s to super-admin.", profile.id)
|
|
259
|
+
emails = state.settings.auth.super_admin_emails
|
|
260
|
+
promoted = await run_in_threadpool(state.store.profiles.promote_super_admins, emails)
|
|
261
|
+
for profile in promoted:
|
|
262
|
+
logger.info("Promoted profile %s to super-admin.", profile.id)
|
|
264
263
|
async with websocket.realtime_lifespan(app):
|
|
265
264
|
yield
|
|
266
265
|
|
|
267
266
|
|
|
268
|
-
def _mount_agent(api: APIRouter, settings:
|
|
269
|
-
"""Mount the optional agent routes
|
|
267
|
+
def _mount_agent(api: APIRouter, settings: ApiSettings) -> str | None:
|
|
268
|
+
"""Mount the optional agent routes when the settings enable the agent.
|
|
270
269
|
|
|
271
270
|
The conversation routes go under the organisation prefix, the tool list outside it.
|
|
272
271
|
|
|
273
272
|
Args:
|
|
274
273
|
api: The ``/api`` router to mount onto.
|
|
275
|
-
settings:
|
|
276
|
-
extra is installed.
|
|
274
|
+
settings: The API's settings; ``agent`` is ``None`` without the agent package.
|
|
277
275
|
|
|
278
276
|
Returns:
|
|
279
|
-
|
|
277
|
+
The model the mounted agent runs on, or ``None`` when the routes are not mounted.
|
|
280
278
|
"""
|
|
281
|
-
if settings is
|
|
282
|
-
logger.info("Agent routes not mounted:
|
|
283
|
-
return
|
|
279
|
+
if settings.agent is None or not settings.agent.enabled:
|
|
280
|
+
logger.info("Agent routes not mounted: the agent is not enabled (agent.enabled).")
|
|
281
|
+
return None
|
|
284
282
|
|
|
285
283
|
try:
|
|
286
284
|
from interloper_api.routes import agent as agent_routes
|
|
@@ -289,90 +287,83 @@ def _mount_agent(api: APIRouter, settings: Any | None) -> bool:
|
|
|
289
287
|
"Agent routes not mounted: the 'agent' extra is not installed "
|
|
290
288
|
"(install interloper-api[agent]); /agent endpoints will return 404."
|
|
291
289
|
)
|
|
292
|
-
return
|
|
290
|
+
return None
|
|
293
291
|
|
|
294
292
|
api.include_router(agent_routes.router)
|
|
295
293
|
api.include_router(agent_routes.org_router, prefix=ORG_PREFIX)
|
|
296
|
-
return
|
|
294
|
+
return settings.agent.model
|
|
297
295
|
|
|
298
296
|
|
|
299
297
|
def _state(
|
|
300
|
-
store: Store
|
|
301
|
-
catalog: Catalog
|
|
302
|
-
settings:
|
|
298
|
+
store: Store,
|
|
299
|
+
catalog: Catalog,
|
|
300
|
+
settings: ApiSettings,
|
|
303
301
|
*,
|
|
304
|
-
|
|
302
|
+
agent_model: str | None,
|
|
305
303
|
google_login: GoogleLogin | None,
|
|
306
304
|
) -> State:
|
|
307
305
|
"""Build the state the request dependencies read back.
|
|
308
306
|
|
|
309
307
|
Args:
|
|
310
|
-
store: The ``Store`` instance
|
|
311
|
-
catalog: Catalog instance
|
|
312
|
-
settings:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
308
|
+
store: The ``Store`` instance.
|
|
309
|
+
catalog: Catalog instance.
|
|
310
|
+
settings: The API's settings.
|
|
311
|
+
agent_model: The model the mounted agent runs on, or ``None`` when
|
|
312
|
+
the agent routes are not mounted; recorded as a feature flag and
|
|
313
|
+
in the admin config snapshot.
|
|
316
314
|
google_login: The Google login, already installed on the app, or
|
|
317
315
|
``None``.
|
|
318
316
|
|
|
319
317
|
Returns:
|
|
320
318
|
The state.
|
|
321
319
|
"""
|
|
322
|
-
features = {"agent":
|
|
320
|
+
features = {"agent": agent_model is not None}
|
|
323
321
|
agent = None
|
|
324
|
-
if
|
|
325
|
-
from interloper.settings import AgentSettings
|
|
322
|
+
if agent_model is not None:
|
|
326
323
|
from interloper_agent import build_agent
|
|
327
324
|
|
|
328
|
-
agent = build_agent(
|
|
329
|
-
if settings is None:
|
|
330
|
-
return State(store=store, catalog=catalog, agent=agent, features=features)
|
|
325
|
+
agent = build_agent(agent_model)
|
|
331
326
|
return State(
|
|
332
327
|
store=store,
|
|
333
328
|
catalog=catalog,
|
|
334
329
|
settings=settings,
|
|
330
|
+
admin_config=admin.AdminConfigResponse.from_declared(features=features, catalog=catalog),
|
|
335
331
|
agent=agent,
|
|
336
332
|
features=features,
|
|
337
|
-
admin_config=admin.AdminConfigResponse.from_settings(settings, features=features, catalog=catalog),
|
|
338
333
|
authorization_server=_authorization_server(store, settings),
|
|
339
334
|
google_login=google_login,
|
|
340
335
|
)
|
|
341
336
|
|
|
342
337
|
|
|
343
|
-
def _google_login(settings:
|
|
338
|
+
def _google_login(settings: ApiSettings) -> GoogleLogin | None:
|
|
344
339
|
"""Build the Google login, when the deployment can run one.
|
|
345
340
|
|
|
346
341
|
Args:
|
|
347
|
-
settings:
|
|
342
|
+
settings: The API's settings.
|
|
348
343
|
|
|
349
344
|
Returns:
|
|
350
|
-
The login, or ``None`` without
|
|
351
|
-
|
|
352
|
-
|
|
345
|
+
The login, or ``None`` without a Google client or without an
|
|
346
|
+
encryption key (which signs the cookie the login keeps between
|
|
347
|
+
Google's two legs).
|
|
353
348
|
"""
|
|
354
|
-
if settings is None:
|
|
355
|
-
return None
|
|
356
349
|
google_login = GoogleLogin.from_settings(settings)
|
|
357
350
|
if google_login is None and settings.auth.google_client_id and not settings.encryption.key:
|
|
358
351
|
logger.warning("Google login unavailable: INTERLOPER_ENCRYPTION_KEY is not configured.")
|
|
359
352
|
return google_login
|
|
360
353
|
|
|
361
354
|
|
|
362
|
-
def _authorization_server(store: Store
|
|
355
|
+
def _authorization_server(store: Store, settings: ApiSettings) -> AuthorizationServer | None:
|
|
363
356
|
"""Build the OAuth authorization server, when the deployment can run one.
|
|
364
357
|
|
|
365
358
|
Args:
|
|
366
|
-
store: The ``Store`` instance
|
|
367
|
-
settings:
|
|
359
|
+
store: The ``Store`` instance.
|
|
360
|
+
settings: The API's settings.
|
|
368
361
|
|
|
369
362
|
Returns:
|
|
370
|
-
The server, or ``None`` without
|
|
371
|
-
|
|
372
|
-
|
|
363
|
+
The server, or ``None`` without an encryption key (which seals the
|
|
364
|
+
authorization request while the user decides), or when the issuer is
|
|
365
|
+
refused (plain http on a non-loopback host).
|
|
373
366
|
"""
|
|
374
|
-
if store is None:
|
|
375
|
-
return None
|
|
376
367
|
if not settings.encryption.key:
|
|
377
368
|
logger.warning("OAuth authorization server not mounted: INTERLOPER_ENCRYPTION_KEY is not configured.")
|
|
378
369
|
return None
|