managed-deepagents 0.10.3.dev8__py3-none-win_amd64.whl → 0.10.3.dev9__py3-none-win_amd64.whl

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.
Binary file
@@ -31,11 +31,6 @@ from uuid import UUID
31
31
  from langgraph_sdk import Auth
32
32
  from langgraph_sdk.auth import is_studio_user
33
33
  from langgraph_sdk.auth.types import (
34
- AssistantsCreate,
35
- AssistantsDelete,
36
- AssistantsRead,
37
- AssistantsSearch,
38
- AssistantsUpdate,
39
34
  AuthContext,
40
35
  BaseUser,
41
36
  CronsCreate,
@@ -74,7 +69,6 @@ from managed_deepagents._thread_record import (
74
69
  THREAD_CONVERSATION_METADATA,
75
70
  THREAD_PARTICIPANTS_METADATA,
76
71
  THREAD_RECORD_METADATA,
77
- is_person_principal,
78
72
  names_thread_record_key,
79
73
  parse_thread_record,
80
74
  strip_thread_record_keys,
@@ -85,11 +79,6 @@ ThreadsValue = (
85
79
  ThreadsCreate | ThreadsRead | ThreadsUpdate | ThreadsDelete | ThreadsSearch | RunsCreate
86
80
  )
87
81
  CronsValue = CronsCreate | CronsRead | CronsUpdate | CronsDelete | CronsSearch
88
- AssistantsValue = (
89
- AssistantsCreate | AssistantsRead | AssistantsUpdate | AssistantsDelete | AssistantsSearch
90
- )
91
- #: Metadata key naming the person who created an assistant.
92
- ASSISTANT_OWNER_METADATA = "mda_assistant_owner"
93
82
 
94
83
  HeaderName = str | bytes
95
84
  HeaderValue = str | bytes | None
@@ -401,7 +390,6 @@ def build_managed_auth(identity: IdentityDefinitionLike) -> Auth:
401
390
  # dead handlers.
402
391
  auth.authenticate(authenticate)
403
392
  auth.on(_scope_any)
404
- auth.on.assistants(_scope_assistants)
405
393
  auth.on.threads(_scope_threads)
406
394
  auth.on.crons(_scope_crons)
407
395
  auth.on.store(_scope_store)
@@ -552,46 +540,6 @@ async def _scope_any(ctx: AuthContext, value: dict[str, Any]) -> None:
552
540
  raise _http_exception(err) from err
553
541
 
554
542
 
555
- async def _scope_assistants(ctx: AuthContext, value: AssistantsValue) -> FilterType | None:
556
- """Anyone may read assistants; a person may create, update and delete their own."""
557
- # An assistant's metadata merges into its runs' too, so no caller, Studio
558
- # included, may give an assistant a thread record.
559
- _strip_metadata_record(value)
560
- _strip_metadata_record(_field(value, "config"))
561
- if _is_unscoped_principal(ctx.user) or ctx.action in {"read", "search"}:
562
- return None
563
- owner = _field(ctx.user, "mda_user_id")
564
- if (
565
- not is_person_principal(owner)
566
- or _field(ctx.user, "mda_user_kind") == "service"
567
- or _field(ctx.user, "mda_source_provider") is not None
568
- ):
569
- raise _http_exception(
570
- ManagedAuthError(403, f"assistants:{ctx.action} is not permitted for this caller")
571
- )
572
- owner = str(owner)
573
- _check_assistant_payload(value)
574
- if ctx.action == "create":
575
- # Mutate in place: the server keeps the metadata object it passed in.
576
- metadata = _field(value, "metadata")
577
- if not isinstance(metadata, dict):
578
- metadata = cast("dict[str, Any]", value)["metadata"] = {}
579
- metadata[ASSISTANT_OWNER_METADATA] = owner
580
- return {ASSISTANT_OWNER_METADATA: owner}
581
-
582
-
583
- def _check_assistant_payload(value: object) -> None:
584
- """Assistant context, config and metadata merge into runs: no managed keys or principal."""
585
- holders = (
586
- _field(value, "metadata"),
587
- _field(value, "context"),
588
- _field(_field(value, "config"), "configurable"),
589
- )
590
- keys = [str(key) for holder in holders if isinstance(holder, Mapping) for key in holder]
591
- if any(key.startswith(("mda_", "langgraph_", "__")) for key in keys):
592
- raise _http_exception(ManagedAuthError(403, "Invalid assistant config"))
593
-
594
-
595
543
  async def _scope_crons(ctx: AuthContext, value: CronsValue) -> FilterType | None:
596
544
  try:
597
545
  return await authorize_schedule(ctx.user, ctx.action, value)
@@ -9,14 +9,13 @@ from collections.abc import Mapping
9
9
  from datetime import UTC, datetime
10
10
  from http import HTTPStatus
11
11
  from typing import TYPE_CHECKING, Literal, NotRequired, cast
12
- from uuid import NAMESPACE_URL, UUID, uuid4, uuid5
12
+ from uuid import NAMESPACE_URL, UUID, uuid5
13
13
 
14
14
  import httpx
15
15
  from langgraph_sdk import Auth
16
16
  from pydantic import ConfigDict, TypeAdapter, ValidationError, with_config
17
17
  from typing_extensions import TypedDict
18
18
 
19
- from managed_deepagents._channels.http.studio import _GRAPH_NAMESPACE
20
19
  from managed_deepagents._channels.schedule_delivery import read_schedule_deliver_to
21
20
  from managed_deepagents._channels.source_providers import is_trusted_source_provider
22
21
  from managed_deepagents._identity_runtime import _auth_user_fields, _field, is_studio_auth_user
@@ -29,7 +28,6 @@ from managed_deepagents._thread_record import (
29
28
  THREAD_CONVERSATION_METADATA,
30
29
  THREAD_PARTICIPANTS_METADATA,
31
30
  THREAD_RECORD_METADATA,
32
- is_person_principal,
33
31
  parse_thread_record,
34
32
  strip_thread_record_keys,
35
33
  )
@@ -318,9 +316,7 @@ def schedule_handoff_user(
318
316
  if raw is None:
319
317
  return None
320
318
  access = _ACCESS.validate_python(json.loads(_verified_handoff(headers, raw)), strict=True)
321
- # A person's API cron update names no assistant, so its limit search spans all of them.
322
- if access["assistant"] or (method, path) != ("POST", "/runs/crons/search"):
323
- UUID(access["assistant"])
319
+ UUID(access["assistant"])
324
320
  if "thread" in access:
325
321
  UUID(access["thread"])
326
322
  reads = method == "GET" and path == f"/threads/{access['thread']}"
@@ -343,6 +339,7 @@ def schedule_handoff_user(
343
339
  not in (access["owner"].removeprefix("user:"), access.get("run_as", {}).get("id"))
344
340
  or not access["owner"].startswith("user:")
345
341
  or execution.get("mda_user_kind") == "service"
342
+ or not execution.get("mda_agent_auth_principal_id")
346
343
  ):
347
344
  raise ValueError("Schedule access is not permitted")
348
345
  user: ScheduleHandoffUser = {**execution}
@@ -375,26 +372,24 @@ async def authorize_schedule( # noqa: C901 - one branch per cron event check
375
372
  # ``CronsCreate`` / ``CronsUpdate`` TypedDicts do not declare it.
376
373
  data = cast("dict[str, object]", value)
377
374
  _guard_cron_record(action, data, access)
375
+ metadata = data.get("metadata")
376
+ payload = data.get("payload")
378
377
  if access is None:
379
378
  from managed_deepagents._identity_auth import is_local_dev_unscoped_user # noqa: PLC0415
380
379
 
381
380
  operator = is_studio_auth_user(user) or _is_local_dev_operator(user)
382
- if operator or is_local_dev_unscoped_user(user):
383
- if action == "delete" and not operator:
384
- return {"mda_managed_by": "api"}
385
- return await _authorize_studio_schedule(action, data, deploy=operator)
386
- access = _person_access(user, action, data)
387
- metadata = data.get("metadata")
388
- payload = data.get("payload")
389
- filters = {"mda_schedule_owner": access["owner"]}
390
- if access["assistant"]:
391
- filters["mda_schedule_assistant"] = access["assistant"]
381
+ if not (operator or is_local_dev_unscoped_user(user)):
382
+ raise ValueError("Schedule access is not permitted")
383
+ if action == "delete" and not operator:
384
+ return {"mda_managed_by": "api"}
385
+ return await _authorize_studio_schedule(action, data, deploy=operator)
386
+ filters = {"mda_schedule_owner": access["owner"], "mda_schedule_assistant": access["assistant"]}
392
387
  if action in {"update", "delete"}:
393
388
  filters["mda_managed_by"] = "runtime"
394
389
  if action == "create":
395
390
  if (
396
391
  not isinstance(payload, dict)
397
- or _assistant_id(payload.get("assistant_id"), _GRAPH_NAMESPACE) != access["assistant"]
392
+ or payload.get("assistant_id") != access["assistant"]
398
393
  or not isinstance(metadata, dict)
399
394
  or metadata.get("mda_managed_by") != "runtime"
400
395
  ):
@@ -420,89 +415,6 @@ async def authorize_schedule( # noqa: C901 - one branch per cron event check
420
415
  return filters
421
416
 
422
417
 
423
- def _person_access(user: BaseUser, action: str, data: dict[str, object]) -> ScheduleAccess:
424
- """A person's own API crons, which run as them like their runtime user schedules."""
425
- user_id = _field(user, "mda_user_id")
426
- if (
427
- not is_person_principal(user_id)
428
- or _field(user, "mda_user_kind") == "service"
429
- or _field(user, "mda_source_provider") is not None
430
- ):
431
- raise ValueError("Schedule access is not permitted")
432
- # Agent Auth resolves the principal from these identity fields when the cron fires.
433
- execution = validate_execution(
434
- {
435
- **{key: _field(user, key) for key in _PERSON_IDENTITY_KEYS if _field(user, key)},
436
- "identity": user_id,
437
- "permissions": [],
438
- "mda_user_id": user_id,
439
- "mda_source_provider": "schedule",
440
- "mda_scheduled_run": True,
441
- }
442
- )
443
- payload = data.get("payload")
444
- if action == "create":
445
- _prepare_person_cron(data)
446
- # Context and config carry a runtime schedule's routing and principal; recreate to change them.
447
- elif isinstance(payload, dict) and {"assistant_id", "context", "config"} & payload.keys():
448
- raise ValueError("Schedule access is not permitted")
449
- return {
450
- "owner": f"user:{user_id}",
451
- "assistant": _assistant_id(_field(payload, "assistant_id"), _GRAPH_NAMESPACE) or "",
452
- "execution": execution,
453
- }
454
-
455
-
456
- _PERSON_IDENTITY_KEYS = (
457
- "mda_agent_auth_principal_id",
458
- "mda_identity_provider",
459
- "mda_identity_issuer",
460
- "mda_identity_subject",
461
- )
462
-
463
-
464
- def _prepare_person_cron(data: dict[str, object]) -> None:
465
- """Tag a person's new API cron as their runtime user schedule."""
466
- if data.get("thread_id"):
467
- raise Auth.exceptions.HTTPException(
468
- status_code=403,
469
- detail="Schedule access is not permitted: API crons must create a new thread per run",
470
- )
471
- metadata = data.get("metadata")
472
- if metadata is None:
473
- metadata = data["metadata"] = {}
474
- payload = data.get("payload")
475
- if (
476
- not isinstance(metadata, dict)
477
- or any(key.startswith("mda_") for key in metadata)
478
- or not isinstance(payload, dict)
479
- ):
480
- raise ValueError("Schedule access is not permitted")
481
- metadata["mda_managed_by"] = "runtime"
482
- _wrap_person_context(payload)
483
-
484
-
485
- def _wrap_person_context(payload: dict[str, object]) -> None:
486
- """Add the schedule name runtime crons carry to the caller's authored context."""
487
- _check_api_context(payload)
488
- context = payload.get("context") or {}
489
- payload["context"] = {
490
- "mda_schedule": {"name": str(uuid4())},
491
- **cast("dict[str, object]", context),
492
- }
493
-
494
-
495
- def _assistant_id(value: object, namespace: UUID = NAMESPACE_URL) -> str | None:
496
- """An assistant UUID, or a UUID derived from a graph name."""
497
- if not isinstance(value, str):
498
- return None
499
- try:
500
- UUID(value)
501
- except ValueError:
502
- return str(uuid5(namespace, value))
503
- return value
504
-
505
-
506
418
  def _guard_cron_record(action: str, data: dict[str, object], access: ScheduleAccess | None) -> None:
507
419
  """Keep a thread record only on a runtime new-thread schedule, for its execution.
508
420
 
@@ -598,7 +510,11 @@ async def _authorize_studio_schedule(
598
510
  or metadata.get("mda_managed_by") != "deploy"
599
511
  ):
600
512
  raise ValueError("Schedule access is not permitted")
601
- assistant = str(_assistant_id(payload["assistant_id"]))
513
+ assistant = payload["assistant_id"]
514
+ try:
515
+ UUID(assistant)
516
+ except ValueError:
517
+ assistant = str(uuid5(NAMESPACE_URL, assistant))
602
518
  if api:
603
519
  # Not `mda_managed`: deploy reconciliation and runtime schedule tools leave it alone.
604
520
  metadata["mda_managed_by"] = "api"
@@ -744,7 +660,7 @@ async def _check_schedule_limit(access: ScheduleAccess, cron_id: str | None = No
744
660
  f"{base}/runs/crons/search",
745
661
  headers=headers,
746
662
  json={
747
- **({"assistant_id": access["assistant"]} if access["assistant"] else {}),
663
+ "assistant_id": access["assistant"],
748
664
  "metadata": {"mda_managed_by": "runtime"},
749
665
  "select": ["cron_id", "end_time"],
750
666
  "limit": _SEARCH_PAGE,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: managed-deepagents
3
- Version: 0.10.3.dev8
3
+ Version: 0.10.3.dev9
4
4
  Summary: Managed Deep Agents — the define_deep_agent authoring interface plus the CLI that compiles and deploys a code-first Deep Agent repository to a managed LangGraph runtime.
5
5
  Author: LangChain
6
6
  License: MIT
@@ -16,7 +16,7 @@ managed_deepagents/_eval_filesystem.py,sha256=_oRR0CUzpO7XND2JkkNUZH63m5kwxmGcR7
16
16
  managed_deepagents/_extension.py,sha256=MqCWS4AGxiURPtLlA2y_tWKdRL8Zu1-VZyQ6Q3HDgzc,5315
17
17
  managed_deepagents/_graph_build_timing.py,sha256=ritnkUzuKQ4-S00bzFB9-S6DtZkl9xslQVh0enVcQag,4996
18
18
  managed_deepagents/_http_status.py,sha256=NPTvc7Ct6T84gWXniO1gOIkTDpf4_5g7drQDeca1ydA,1644
19
- managed_deepagents/_identity_auth.py,sha256=CHeUA_CQQgx21aK_KtqzV6OmGks1ndyIht0AD7445WM,49667
19
+ managed_deepagents/_identity_auth.py,sha256=LArpJvONfK58LviMjQ-b4b4TNST4EU7nRqzPe3Cg8n0,47443
20
20
  managed_deepagents/_identity_http.py,sha256=EA9ssCqCCAI0IWJgk7kUwl2gmDFfBUOO5X2oI1ipL-Y,18963
21
21
  managed_deepagents/_identity_links.py,sha256=-k49Br6muYfrRpnHY0rFpTOg7pdm5c6xh9fJRCz8-Qw,8099
22
22
  managed_deepagents/_identity_runtime.py,sha256=6Q3YU2N_9WDIlkHqIxhDGclCD2eyxfIACNBPtVl5Hg4,26279
@@ -35,7 +35,7 @@ managed_deepagents/_run_input.py,sha256=VdIysM5tIFx8Fjmbr3dkNIHYovcHmSC-wtwRuqYo
35
35
  managed_deepagents/_run_local.py,sha256=pKGh_JKUW8RaTFy9EpBor893KCjBV2cCJZzsiBCeaWA,2852
36
36
  managed_deepagents/_runtime_schedules.py,sha256=EDYtFxpbj4jZjV5-1mgWZn598g86NsgvsC_pEa2rGKk,30377
37
37
  managed_deepagents/_sandbox_proxy.py,sha256=AFrcC07nTHaAQhGCDttncv3SkGL5h1JBcfxv7Psgn6c,9835
38
- managed_deepagents/_schedule_auth.py,sha256=2VFjBf7QRHIFtTP0CYvEiAC5eNZyo0eO5fgUWXasmhM,30160
38
+ managed_deepagents/_schedule_auth.py,sha256=m8QB-d8AL4eIsdeK_brJ5Mm4qZHP8NxaZwluYXvQZQg,26918
39
39
  managed_deepagents/_schedule_channel.py,sha256=r0EWl4OrBJRnwKETHjKdScYIfdi0lrUEGdajX6FGIdQ,1109
40
40
  managed_deepagents/_schedule_time.py,sha256=uNyULRjoD0HzPVvV-W772HPb3BYCt0fwEbbT9Ec__Jc,3710
41
41
  managed_deepagents/_static_entry.py,sha256=QgvrnBLue6elOHSWdIFosFEfYMp4V9YDwBlZSe_NyQA,635
@@ -53,7 +53,7 @@ managed_deepagents/run_context.py,sha256=IayZdcpPrKVss70Hro8qI-EWtL94HZt4JKefzec
53
53
  managed_deepagents/runtime.py,sha256=M5-XlwkTfWV6Gyl4w9vClFFF0GvOWZEc6-_wPyxn5W0,136847
54
54
  managed_deepagents/sandbox.py,sha256=cS66-vFcARsbHR3fH5jvWd4qF-MAjiGqRe-_Kocsqtg,4693
55
55
  managed_deepagents/schedules.py,sha256=z_OlmZ7hW7LdvWLem-BiA131nHwFvUDSW_0-ObzU_G4,6039
56
- managed_deepagents/_binaries/mda.exe,sha256=ZXjMx82mcY0XWpitY8LMqF8z1lHzRjNTgTJuVE2zgJ4,5157888
56
+ managed_deepagents/_binaries/mda.exe,sha256=-ezmwCGyQiGpD0-bLx5NskDtUGvuPVu5RfV9-_RtYuo,5158400
57
57
  managed_deepagents/_channels/__init__.py,sha256=mMgqza7EWRjhJM0lXlFd-W6wBYZrFkpLQ4_30Bpij7k,249
58
58
  managed_deepagents/_channels/actor.py,sha256=3d_1-ia6vwVjXkw7PYn5gg6BjnlPwRXW4nW2C5vAO7c,5203
59
59
  managed_deepagents/_channels/assistant_text.py,sha256=nf00-KJXNev-e_TkAK_8SBI3J9TiOis1GkGV_zT5048,8472
@@ -156,9 +156,9 @@ managed_deepagents/identity/__init__.py,sha256=uZUKDHtfBc0n-T2xoJEFMqMplmXwAK7hb
156
156
  managed_deepagents/identity/claims.py,sha256=prby7r_8Lww3MmoBm8PX6PsSGE3GwSHkr8mVIz_08nU,1180
157
157
  managed_deepagents/identity/options.py,sha256=x_yMbXEFR7zXyehEjDHG2qjAlukXjrRBcQLcM6IndLM,2550
158
158
  managed_deepagents/identity/supabase.py,sha256=8uobl3WCrQL_ieSXG8KTLf1th7Qjim9liZT50HeaJE0,6026
159
- managed_deepagents-0.10.3.dev8.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
160
- managed_deepagents-0.10.3.dev8.dist-info/METADATA,sha256=z51m1rT_7M6Wg-Fw0RodnsOFCjnnK46H-JXmIzaINVk,95067
161
- managed_deepagents-0.10.3.dev8.dist-info/WHEEL,sha256=bhMFZwp6VMtrbl2Ck6PlXryKaCggO1NzYn_HcFbBF1I,97
162
- managed_deepagents-0.10.3.dev8.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
163
- managed_deepagents-0.10.3.dev8.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
164
- managed_deepagents-0.10.3.dev8.dist-info/RECORD,,
159
+ managed_deepagents-0.10.3.dev9.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
160
+ managed_deepagents-0.10.3.dev9.dist-info/METADATA,sha256=oH5cTuN0K7OBKax08AbeooRTE6jNdKTC6KEv5GOUVjM,95067
161
+ managed_deepagents-0.10.3.dev9.dist-info/WHEEL,sha256=bhMFZwp6VMtrbl2Ck6PlXryKaCggO1NzYn_HcFbBF1I,97
162
+ managed_deepagents-0.10.3.dev9.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
163
+ managed_deepagents-0.10.3.dev9.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
164
+ managed_deepagents-0.10.3.dev9.dist-info/RECORD,,