managed-deepagents 0.9.3.dev25__py3-none-win_amd64.whl → 0.9.3.dev26__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.
- managed_deepagents/_binaries/mda.exe +0 -0
- managed_deepagents/_channels/__init__.py +5 -1
- managed_deepagents/_channels/schedule_delivery.py +85 -32
- managed_deepagents/_channels/types.py +30 -14
- managed_deepagents/_runtime_schedules.py +15 -72
- managed_deepagents/_schedule_auth.py +3 -4
- managed_deepagents/_schedule_channel.py +1 -21
- managed_deepagents/schedules.py +22 -128
- {managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/METADATA +4 -43
- {managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/RECORD +14 -15
- managed_deepagents/_channels/slack/direct_message.py +0 -32
- {managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/WHEEL +0 -0
- {managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/entry_points.txt +0 -0
- {managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/licenses/LICENSE +0 -0
- {managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -11,7 +11,10 @@ from managed_deepagents._channels.runtime import create_runtime_channel
|
|
|
11
11
|
from managed_deepagents._channels.schedule_delivery import (
|
|
12
12
|
create_schedule_delivery_middleware,
|
|
13
13
|
)
|
|
14
|
-
from managed_deepagents._channels.types import
|
|
14
|
+
from managed_deepagents._channels.types import (
|
|
15
|
+
ChannelError,
|
|
16
|
+
normalize_channel_destination,
|
|
17
|
+
)
|
|
15
18
|
|
|
16
19
|
__all__ = [
|
|
17
20
|
"SLACK_BOT_TOKEN_ENV",
|
|
@@ -19,5 +22,6 @@ __all__ = [
|
|
|
19
22
|
"create_runtime_channel",
|
|
20
23
|
"create_schedule_delivery_middleware",
|
|
21
24
|
"extract_assistant_text",
|
|
25
|
+
"normalize_channel_destination",
|
|
22
26
|
"resolve_runtime_channel",
|
|
23
27
|
]
|
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import os
|
|
6
6
|
import uuid
|
|
7
7
|
from collections.abc import Awaitable, Callable, Mapping
|
|
8
|
-
from typing import TYPE_CHECKING, Any, Literal, cast
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Literal, TypedDict, cast
|
|
9
9
|
|
|
10
10
|
from langchain.agents.middleware.types import AgentMiddleware, AgentState
|
|
11
11
|
from langgraph.config import get_config
|
|
@@ -20,7 +20,6 @@ from managed_deepagents._channels.binding import (
|
|
|
20
20
|
_current_routing,
|
|
21
21
|
resolve_runtime_channel,
|
|
22
22
|
)
|
|
23
|
-
from managed_deepagents._channels.messaging_registry import channel_provider_for_name
|
|
24
23
|
from managed_deepagents._channels.trigger.client import create_trigger_client
|
|
25
24
|
from managed_deepagents._identity_runtime import (
|
|
26
25
|
_ambient_configurable,
|
|
@@ -29,18 +28,13 @@ from managed_deepagents._identity_runtime import (
|
|
|
29
28
|
)
|
|
30
29
|
from managed_deepagents._log import logger
|
|
31
30
|
from managed_deepagents._memory.async_util import await_if_needed
|
|
32
|
-
from managed_deepagents.schedules import (
|
|
33
|
-
ProviderScheduleDelivery,
|
|
34
|
-
ScheduleDelivery,
|
|
35
|
-
is_provider_delivery,
|
|
36
|
-
read_legacy_deliver_to,
|
|
37
|
-
read_schedule_delivery,
|
|
38
|
-
)
|
|
39
31
|
|
|
40
32
|
if TYPE_CHECKING:
|
|
41
33
|
from managed_deepagents._channels.trigger.types import TriggerChannelActionRequest
|
|
42
34
|
from managed_deepagents._channels.types import (
|
|
43
35
|
ChannelAddress,
|
|
36
|
+
ChannelDestinationProviderConversation,
|
|
37
|
+
ChannelDestinationProviderThread,
|
|
44
38
|
JsonValue,
|
|
45
39
|
)
|
|
46
40
|
|
|
@@ -59,6 +53,12 @@ PostFn = Callable[..., Awaitable[object] | object]
|
|
|
59
53
|
DeliverOutcome = Literal["posted", "skipped", "failed"]
|
|
60
54
|
|
|
61
55
|
|
|
56
|
+
class NormalizedScheduleDeliverTo(TypedDict):
|
|
57
|
+
channel: str
|
|
58
|
+
to: ChannelDestinationProviderConversation | ChannelDestinationProviderThread
|
|
59
|
+
auto_post: bool
|
|
60
|
+
|
|
61
|
+
|
|
62
62
|
def get_deployment_id(env: Mapping[str, str] | None = None) -> str | None:
|
|
63
63
|
"""Return the deployment ID supplied by the managed runtime."""
|
|
64
64
|
resolved_env = os.environ if env is None else env
|
|
@@ -69,36 +69,85 @@ def get_deployment_id(env: Mapping[str, str] | None = None) -> str | None:
|
|
|
69
69
|
return None
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
def read_schedule_deliver_to( # noqa: PLR0911 - validation short-circuits
|
|
73
|
+
raw: object,
|
|
74
|
+
) -> NormalizedScheduleDeliverTo | None:
|
|
75
|
+
"""Normalize a schedule ``deliver_to`` target.
|
|
76
|
+
|
|
77
|
+
Accepts camelCase (TS compile) and snake_case (Python compile) shapes.
|
|
78
|
+
"""
|
|
79
|
+
if not isinstance(raw, Mapping):
|
|
80
|
+
return None
|
|
81
|
+
channel = raw.get("channel")
|
|
82
|
+
if not isinstance(channel, str) or not channel.strip():
|
|
83
|
+
return None
|
|
84
|
+
to_raw = raw.get("to")
|
|
85
|
+
if not isinstance(to_raw, Mapping):
|
|
86
|
+
return None
|
|
87
|
+
dest_type = to_raw.get("type")
|
|
88
|
+
conversation_id = to_raw.get("conversation_id", to_raw.get("conversationId"))
|
|
89
|
+
if not isinstance(conversation_id, str) or not conversation_id.strip():
|
|
90
|
+
return None
|
|
91
|
+
if dest_type == "provider_conversation":
|
|
92
|
+
normalized_to: ChannelDestinationProviderConversation | ChannelDestinationProviderThread = {
|
|
93
|
+
"type": "provider_conversation",
|
|
94
|
+
"conversation_id": conversation_id.strip(),
|
|
95
|
+
}
|
|
96
|
+
elif dest_type == "provider_thread":
|
|
97
|
+
thread_id = to_raw.get("thread_id", to_raw.get("threadId"))
|
|
98
|
+
if not isinstance(thread_id, str) or not thread_id.strip():
|
|
99
|
+
return None
|
|
100
|
+
normalized_to = cast(
|
|
101
|
+
"ChannelDestinationProviderThread",
|
|
102
|
+
{
|
|
103
|
+
"type": "provider_thread",
|
|
104
|
+
"conversation_id": conversation_id.strip(),
|
|
105
|
+
"thread_id": thread_id.strip(),
|
|
106
|
+
},
|
|
107
|
+
)
|
|
108
|
+
else:
|
|
109
|
+
return None
|
|
110
|
+
auto_post_raw = raw.get("auto_post", raw.get("autoPost"))
|
|
111
|
+
auto_post = True if auto_post_raw is None else bool(auto_post_raw)
|
|
112
|
+
result: NormalizedScheduleDeliverTo = {
|
|
113
|
+
"channel": channel.strip(),
|
|
114
|
+
"to": normalized_to,
|
|
115
|
+
"auto_post": auto_post,
|
|
116
|
+
}
|
|
117
|
+
return result
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def address_from_deliver_to(
|
|
121
|
+
to: ChannelDestinationProviderConversation | ChannelDestinationProviderThread,
|
|
122
|
+
) -> ChannelAddress:
|
|
123
|
+
"""Map a deliver_to destination onto a runtime channel address."""
|
|
124
|
+
if to["type"] == "provider_thread":
|
|
125
|
+
return {
|
|
126
|
+
"conversation_id": to["conversation_id"],
|
|
127
|
+
"thread_id": to["thread_id"],
|
|
128
|
+
}
|
|
129
|
+
return {"conversation_id": to["conversation_id"]}
|
|
78
130
|
|
|
79
131
|
|
|
80
132
|
async def deliver_schedule_result( # noqa: C901, PLR0911 - delivery outcomes
|
|
81
133
|
*,
|
|
82
|
-
|
|
134
|
+
deliver_to: NormalizedScheduleDeliverTo,
|
|
83
135
|
reply_text: str,
|
|
84
136
|
bot_token: str | None = None,
|
|
85
137
|
post: PostFn | None = None,
|
|
86
138
|
) -> DeliverOutcome:
|
|
87
139
|
"""Post result text; the middleware fails the run on a failed outcome."""
|
|
88
140
|
text = reply_text.strip()
|
|
89
|
-
if not text:
|
|
141
|
+
if not text or not deliver_to["auto_post"]:
|
|
90
142
|
return "skipped"
|
|
91
|
-
|
|
92
|
-
if (channel_provider_for_name(channel) or channel) != "slack":
|
|
143
|
+
if deliver_to["channel"] != "slack":
|
|
93
144
|
logger.error(
|
|
94
|
-
'schedule
|
|
95
|
-
logger.log_identifier(channel),
|
|
145
|
+
'schedule deliver_to channel "%s" is not supported yet',
|
|
146
|
+
logger.log_identifier(deliver_to["channel"]),
|
|
96
147
|
)
|
|
97
148
|
return "failed"
|
|
98
149
|
|
|
99
|
-
address
|
|
100
|
-
if delivery["type"] == "provider_thread":
|
|
101
|
-
address["thread_id"] = delivery["thread_id"]
|
|
150
|
+
address = address_from_deliver_to(deliver_to["to"])
|
|
102
151
|
if post is not None:
|
|
103
152
|
try:
|
|
104
153
|
result = post(
|
|
@@ -129,7 +178,11 @@ async def deliver_schedule_result( # noqa: C901, PLR0911 - delivery outcomes
|
|
|
129
178
|
"message": {"text": text},
|
|
130
179
|
}
|
|
131
180
|
try:
|
|
132
|
-
await client.post_deployment_action(
|
|
181
|
+
await client.post_deployment_action(
|
|
182
|
+
deployment_id,
|
|
183
|
+
deliver_to["channel"],
|
|
184
|
+
action,
|
|
185
|
+
)
|
|
133
186
|
return "posted"
|
|
134
187
|
except Exception as error: # noqa: BLE001 - return a failed delivery outcome
|
|
135
188
|
logger.error(
|
|
@@ -143,7 +196,7 @@ async def deliver_schedule_result( # noqa: C901, PLR0911 - delivery outcomes
|
|
|
143
196
|
).strip()
|
|
144
197
|
if not token:
|
|
145
198
|
logger.error(
|
|
146
|
-
"schedule
|
|
199
|
+
"schedule deliver_to requires Trigger channel configuration or "
|
|
147
200
|
"SLACK_BOT_TOKEN; skipping auto-post"
|
|
148
201
|
)
|
|
149
202
|
return "failed"
|
|
@@ -203,9 +256,6 @@ async def _deliver_captured_result(
|
|
|
203
256
|
) -> None:
|
|
204
257
|
reply_text = extract_assistant_text(output)
|
|
205
258
|
routing = _current_routing.get() or {}
|
|
206
|
-
delivery = read_stored_delivery(routing.get("mda_schedule"))
|
|
207
|
-
if delivery is False:
|
|
208
|
-
return
|
|
209
259
|
saved_channel = routing.get("mda_channel")
|
|
210
260
|
if saved_channel is not None:
|
|
211
261
|
channel = resolve_runtime_channel({"mda_channel": saved_channel}, configurable)
|
|
@@ -220,8 +270,9 @@ async def _deliver_captured_result(
|
|
|
220
270
|
if content is not None:
|
|
221
271
|
await channel.post({"type": "content", "content": content})
|
|
222
272
|
return
|
|
223
|
-
|
|
224
|
-
|
|
273
|
+
deliver_to = read_schedule_deliver_to(_field(routing.get("mda_schedule"), "deliver_to"))
|
|
274
|
+
if deliver_to is not None:
|
|
275
|
+
outcome = await deliver(deliver_to=deliver_to, reply_text=reply_text)
|
|
225
276
|
if outcome == "failed":
|
|
226
277
|
raise RuntimeError("Scheduled channel delivery failed")
|
|
227
278
|
|
|
@@ -272,9 +323,11 @@ def create_schedule_delivery_middleware(
|
|
|
272
323
|
|
|
273
324
|
|
|
274
325
|
__all__ = [
|
|
326
|
+
"NormalizedScheduleDeliverTo",
|
|
327
|
+
"address_from_deliver_to",
|
|
275
328
|
"create_schedule_delivery_middleware",
|
|
276
329
|
"deliver_schedule_result",
|
|
277
330
|
"get_deployment_id",
|
|
278
331
|
"is_trusted_schedule_delivery_run",
|
|
279
|
-
"
|
|
332
|
+
"read_schedule_deliver_to",
|
|
280
333
|
]
|
|
@@ -43,14 +43,6 @@ class ChannelDestinationCurrentThread(TypedDict):
|
|
|
43
43
|
type: Literal["current_thread"]
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
class ChannelDestinationCurrentConversation(TypedDict):
|
|
47
|
-
type: Literal["current_conversation"]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class ChannelDestinationDirectMessage(TypedDict):
|
|
51
|
-
type: Literal["direct_message"]
|
|
52
|
-
|
|
53
|
-
|
|
54
46
|
class ChannelDestinationProviderThread(TypedDict):
|
|
55
47
|
type: Literal["provider_thread"]
|
|
56
48
|
conversation_id: str
|
|
@@ -62,14 +54,8 @@ class ChannelDestinationProviderConversation(TypedDict):
|
|
|
62
54
|
conversation_id: str
|
|
63
55
|
|
|
64
56
|
|
|
65
|
-
#: Where a channel post goes. ``current_thread`` and ``current_conversation`` are the
|
|
66
|
-
#: thread and conversation of the originating run, ``direct_message`` is the agent's
|
|
67
|
-
#: direct message with the person who sent that run's event, and the ``provider_*``
|
|
68
|
-
#: types name an explicit provider address.
|
|
69
57
|
ChannelDestination = (
|
|
70
58
|
ChannelDestinationCurrentThread
|
|
71
|
-
| ChannelDestinationCurrentConversation
|
|
72
|
-
| ChannelDestinationDirectMessage
|
|
73
59
|
| ChannelDestinationProviderThread
|
|
74
60
|
| ChannelDestinationProviderConversation
|
|
75
61
|
)
|
|
@@ -144,6 +130,35 @@ class ChannelError(Exception):
|
|
|
144
130
|
self.code = code
|
|
145
131
|
|
|
146
132
|
|
|
133
|
+
def normalize_channel_destination(
|
|
134
|
+
destination: ChannelDestination | Mapping[str, object],
|
|
135
|
+
) -> (
|
|
136
|
+
ChannelDestinationCurrentThread
|
|
137
|
+
| ChannelDestinationProviderThread
|
|
138
|
+
| ChannelDestinationProviderConversation
|
|
139
|
+
):
|
|
140
|
+
"""Narrow a destination to its discriminant + required address fields."""
|
|
141
|
+
dest_type = destination.get("type")
|
|
142
|
+
if dest_type == "current_thread":
|
|
143
|
+
return {"type": "current_thread"}
|
|
144
|
+
if dest_type == "provider_thread":
|
|
145
|
+
conversation_id = destination.get("conversation_id")
|
|
146
|
+
thread_id = destination.get("thread_id")
|
|
147
|
+
if not isinstance(conversation_id, str) or not isinstance(thread_id, str):
|
|
148
|
+
raise ValueError("provider_thread destination requires conversation_id and thread_id")
|
|
149
|
+
return {
|
|
150
|
+
"type": "provider_thread",
|
|
151
|
+
"conversation_id": conversation_id,
|
|
152
|
+
"thread_id": thread_id,
|
|
153
|
+
}
|
|
154
|
+
if dest_type == "provider_conversation":
|
|
155
|
+
conversation_id = destination.get("conversation_id")
|
|
156
|
+
if not isinstance(conversation_id, str):
|
|
157
|
+
raise ValueError("provider_conversation destination requires conversation_id")
|
|
158
|
+
return {"type": "provider_conversation", "conversation_id": conversation_id}
|
|
159
|
+
raise ValueError(f"unsupported channel destination type: {dest_type!r}")
|
|
160
|
+
|
|
161
|
+
|
|
147
162
|
__all__ = [
|
|
148
163
|
"ChannelAddress",
|
|
149
164
|
"ChannelContentMessage",
|
|
@@ -155,4 +170,5 @@ __all__ = [
|
|
|
155
170
|
"ChannelNativeMessage",
|
|
156
171
|
"JsonValue",
|
|
157
172
|
"PostedChannelMessage",
|
|
173
|
+
"normalize_channel_destination",
|
|
158
174
|
]
|
|
@@ -7,7 +7,7 @@ from collections.abc import Mapping
|
|
|
7
7
|
from dataclasses import dataclass
|
|
8
8
|
from datetime import UTC, datetime
|
|
9
9
|
from http import HTTPStatus
|
|
10
|
-
from typing import
|
|
10
|
+
from typing import Annotated, Literal, NotRequired
|
|
11
11
|
from uuid import UUID, uuid4
|
|
12
12
|
|
|
13
13
|
import httpx
|
|
@@ -25,7 +25,7 @@ from pydantic import (
|
|
|
25
25
|
)
|
|
26
26
|
from typing_extensions import TypedDict
|
|
27
27
|
|
|
28
|
-
from managed_deepagents._channels.schedule_delivery import
|
|
28
|
+
from managed_deepagents._channels.schedule_delivery import read_schedule_deliver_to
|
|
29
29
|
from managed_deepagents._connections import resolve_agent_auth_context, resolve_owner_id
|
|
30
30
|
from managed_deepagents._identity_runtime import (
|
|
31
31
|
_field,
|
|
@@ -39,25 +39,21 @@ from managed_deepagents._schedule_auth import (
|
|
|
39
39
|
ScheduleAccess,
|
|
40
40
|
schedule_request_config,
|
|
41
41
|
)
|
|
42
|
-
from managed_deepagents._schedule_channel import capture_schedule_channel
|
|
42
|
+
from managed_deepagents._schedule_channel import capture_schedule_channel
|
|
43
43
|
from managed_deepagents._schedule_time import schedule_timing
|
|
44
44
|
from managed_deepagents.run_context import ChannelContext, is_managed_key
|
|
45
45
|
from managed_deepagents.schedules import (
|
|
46
|
-
|
|
47
|
-
ScheduleDelivery,
|
|
46
|
+
ScheduleDeliveryTarget,
|
|
48
47
|
ScheduleThreadConfig,
|
|
49
48
|
)
|
|
50
49
|
|
|
51
|
-
if TYPE_CHECKING:
|
|
52
|
-
from managed_deepagents._channels.binding import ChannelBinding
|
|
53
|
-
|
|
54
50
|
_MAX_INPUT_BYTES = 1_048_576
|
|
55
51
|
_MAX_RESPONSE_BYTES = 4_194_304
|
|
56
52
|
_MAX_PAGE_SIZE = 100
|
|
57
53
|
_CHANNEL_ADAPTER = TypeAdapter(ChannelContext)
|
|
58
54
|
_METADATA_ADAPTER = TypeAdapter(dict[str, JsonValue])
|
|
59
55
|
_MANAGED_BY_ADAPTER = TypeAdapter(Literal["runtime", "deploy"])
|
|
60
|
-
_DELIVERY_ADAPTER = TypeAdapter(
|
|
56
|
+
_DELIVERY_ADAPTER = TypeAdapter(ScheduleDeliveryTarget)
|
|
61
57
|
|
|
62
58
|
|
|
63
59
|
@with_config(ConfigDict(extra="forbid"))
|
|
@@ -104,7 +100,7 @@ class ScheduleRecord(TypedDict):
|
|
|
104
100
|
new_thread: bool
|
|
105
101
|
channel: str | None
|
|
106
102
|
target: JsonValue
|
|
107
|
-
|
|
103
|
+
deliver_to: NotRequired[ScheduleDeliveryTarget]
|
|
108
104
|
context: NotRequired[dict[str, JsonValue]]
|
|
109
105
|
paused: bool
|
|
110
106
|
metadata: dict[str, JsonValue]
|
|
@@ -123,6 +119,7 @@ class _Spec(BaseModel):
|
|
|
123
119
|
timezone: str | None = None
|
|
124
120
|
prompt: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)] | None = None
|
|
125
121
|
input: ScheduleInput | None = Field(default=None, exclude=True)
|
|
122
|
+
deliver_to: ScheduleDeliveryTarget | None = None
|
|
126
123
|
paused: bool | None = None
|
|
127
124
|
new_thread: bool | None = None
|
|
128
125
|
metadata: dict[str, JsonValue] = Field(default_factory=dict, exclude=True)
|
|
@@ -343,7 +340,6 @@ def _record(wire: _Wire, ctx: _Context, *, now: datetime | None = None) -> Sched
|
|
|
343
340
|
"new_thread": spec.new_thread if spec.new_thread is not None else not bool(wire.thread_id),
|
|
344
341
|
"channel": None,
|
|
345
342
|
"target": None,
|
|
346
|
-
"delivery": False,
|
|
347
343
|
"paused": not wire.enabled,
|
|
348
344
|
"expired": wire.end_time is not None
|
|
349
345
|
and datetime.fromisoformat(wire.end_time) < (now or datetime.now(UTC)),
|
|
@@ -362,6 +358,9 @@ def _record(wire: _Wire, ctx: _Context, *, now: datetime | None = None) -> Sched
|
|
|
362
358
|
routing = wire.payload.context
|
|
363
359
|
if routing is None:
|
|
364
360
|
routing = (wire.payload.config or {}).get("configurable")
|
|
361
|
+
delivery = spec.deliver_to or read_schedule_deliver_to(
|
|
362
|
+
_field(_field(routing, "mda_schedule"), "deliver_to")
|
|
363
|
+
)
|
|
365
364
|
channel = _field(routing, "mda_channel")
|
|
366
365
|
if channel is None and wire.payload.context is None:
|
|
367
366
|
channel = _field(routing, "channel")
|
|
@@ -374,11 +373,8 @@ def _record(wire: _Wire, ctx: _Context, *, now: datetime | None = None) -> Sched
|
|
|
374
373
|
parsed_channel = _CHANNEL_ADAPTER.validate_python(channel, strict=True)
|
|
375
374
|
result["channel"] = parsed_channel["name"]
|
|
376
375
|
result["target"] = parsed_channel["target"]
|
|
377
|
-
delivery
|
|
378
|
-
|
|
379
|
-
kind = "current_conversation" if result["new_thread"] else "current_thread"
|
|
380
|
-
delivery = cast("ScheduleDelivery", {"type": kind, "channel": result["channel"]})
|
|
381
|
-
result["delivery"] = False if delivery is None else delivery
|
|
376
|
+
if delivery:
|
|
377
|
+
result["deliver_to"] = _DELIVERY_ADAPTER.validate_python(delivery, strict=True)
|
|
382
378
|
return result
|
|
383
379
|
|
|
384
380
|
|
|
@@ -394,40 +390,6 @@ def _run_input(spec: _Spec) -> ScheduleInput:
|
|
|
394
390
|
return spec.input
|
|
395
391
|
|
|
396
392
|
|
|
397
|
-
def _resolve_delivery(
|
|
398
|
-
delivery: RelativeScheduleDelivery | Literal[False] | None,
|
|
399
|
-
captured: ChannelBinding | None,
|
|
400
|
-
owner: ScheduleOwner,
|
|
401
|
-
*,
|
|
402
|
-
new_thread: bool,
|
|
403
|
-
) -> tuple[ChannelBinding | None, ScheduleDelivery | Literal[False] | None]:
|
|
404
|
-
"""Resolve where a new schedule posts and the channel binding that reaches it."""
|
|
405
|
-
if delivery is False:
|
|
406
|
-
return captured, False
|
|
407
|
-
if captured is None:
|
|
408
|
-
if delivery:
|
|
409
|
-
raise ValueError("Schedule delivery requires a run from a channel")
|
|
410
|
-
return None, None
|
|
411
|
-
if delivery and delivery.get("channel") not in (None, captured["name"]):
|
|
412
|
-
raise ValueError(f"Schedule delivery must use channel {captured['name']}")
|
|
413
|
-
if delivery:
|
|
414
|
-
kind = delivery["type"]
|
|
415
|
-
else:
|
|
416
|
-
kind = "current_conversation" if new_thread else "current_thread"
|
|
417
|
-
if (kind == "current_thread") == new_thread:
|
|
418
|
-
raise ValueError(
|
|
419
|
-
"current_thread delivery requires new_thread=False"
|
|
420
|
-
if kind == "current_thread"
|
|
421
|
-
else f"{kind} delivery requires new_thread=True"
|
|
422
|
-
)
|
|
423
|
-
resolved = cast("ScheduleDelivery", {"type": kind, "channel": captured["name"]})
|
|
424
|
-
if kind != "direct_message":
|
|
425
|
-
return captured, resolved
|
|
426
|
-
if owner["type"] != "user":
|
|
427
|
-
raise ValueError("direct_message delivery requires a user owner")
|
|
428
|
-
return direct_message_channel(captured), resolved
|
|
429
|
-
|
|
430
|
-
|
|
431
393
|
async def _verify_target(
|
|
432
394
|
wire: _Wire, target: str | None, ctx: _Context, *, created: bool = True
|
|
433
395
|
) -> None:
|
|
@@ -519,29 +481,18 @@ class RuntimeSchedules:
|
|
|
519
481
|
prompt: str | None = None,
|
|
520
482
|
input: ScheduleInput | None = None,
|
|
521
483
|
new_thread: bool | None = None,
|
|
522
|
-
delivery: RelativeScheduleDelivery | Literal[False] | None = None,
|
|
523
484
|
paused: bool = False,
|
|
524
485
|
metadata: dict[str, JsonValue] | None = None,
|
|
525
486
|
context: dict[str, JsonValue] | None = None,
|
|
526
487
|
) -> ScheduleRecord:
|
|
527
|
-
"""Create a schedule bound to the current run.
|
|
528
|
-
|
|
529
|
-
``delivery`` is where the final answer posts, or ``False`` to post nothing. It
|
|
530
|
-
defaults to ``current_thread`` for a same-thread schedule and
|
|
531
|
-
``current_conversation`` otherwise. ``direct_message`` needs a user owner.
|
|
532
|
-
"""
|
|
533
488
|
configurable = _run_configurable(self._runtime)
|
|
534
|
-
if delivery is not None:
|
|
535
|
-
delivery = _DELIVERY_ADAPTER.validate_python(delivery, strict=True)
|
|
536
|
-
if new_thread is None:
|
|
537
|
-
new_thread = delivery["type"] != "current_thread" if delivery else cron is not None
|
|
538
489
|
spec = _Spec(
|
|
539
490
|
cron=cron,
|
|
540
491
|
at=at,
|
|
541
492
|
timezone=timezone,
|
|
542
493
|
prompt=prompt,
|
|
543
494
|
input=input,
|
|
544
|
-
new_thread=new_thread,
|
|
495
|
+
new_thread=new_thread if new_thread is not None else cron is not None,
|
|
545
496
|
paused=paused,
|
|
546
497
|
metadata=metadata if metadata is not None else {},
|
|
547
498
|
context=context,
|
|
@@ -549,12 +500,7 @@ class RuntimeSchedules:
|
|
|
549
500
|
run_input = _run_input(spec)
|
|
550
501
|
timing = schedule_timing(cron=cron, at=at, timezone=timezone)
|
|
551
502
|
resolved_new_thread = bool(spec.new_thread)
|
|
552
|
-
channel
|
|
553
|
-
delivery,
|
|
554
|
-
capture_schedule_channel(configurable, new_thread=resolved_new_thread),
|
|
555
|
-
owner,
|
|
556
|
-
new_thread=resolved_new_thread,
|
|
557
|
-
)
|
|
503
|
+
channel = capture_schedule_channel(configurable, new_thread=resolved_new_thread)
|
|
558
504
|
thread_id = configurable.get("thread_id")
|
|
559
505
|
if not resolved_new_thread and not thread_id:
|
|
560
506
|
raise ValueError("Same-thread schedules require a current thread; use new_thread=True")
|
|
@@ -601,10 +547,7 @@ class RuntimeSchedules:
|
|
|
601
547
|
"enabled": not paused,
|
|
602
548
|
"on_run_completed": on_run_completed,
|
|
603
549
|
"context": {
|
|
604
|
-
"mda_schedule": {
|
|
605
|
-
"name": name,
|
|
606
|
-
**({} if stored_delivery is None else {"delivery": stored_delivery}),
|
|
607
|
-
},
|
|
550
|
+
"mda_schedule": {"name": name},
|
|
608
551
|
**({"mda_channel": channel} if channel else {}),
|
|
609
552
|
**(spec.context or {}),
|
|
610
553
|
},
|
|
@@ -14,7 +14,7 @@ from langgraph_sdk import Auth
|
|
|
14
14
|
from pydantic import ConfigDict, TypeAdapter, ValidationError, with_config
|
|
15
15
|
from typing_extensions import TypedDict
|
|
16
16
|
|
|
17
|
-
from managed_deepagents._channels.schedule_delivery import
|
|
17
|
+
from managed_deepagents._channels.schedule_delivery import read_schedule_deliver_to
|
|
18
18
|
from managed_deepagents._identity_runtime import _field, is_studio_auth_user
|
|
19
19
|
from managed_deepagents._loopback import is_loopback_url, resolve_loopback_api_url
|
|
20
20
|
from managed_deepagents.run_context import ChannelContext, is_managed_key
|
|
@@ -308,9 +308,8 @@ def _check_context(
|
|
|
308
308
|
or any(is_managed_key(key) for key in context if key not in {"mda_schedule", "mda_channel"})
|
|
309
309
|
):
|
|
310
310
|
raise ValueError("Invalid schedule config")
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
) and read_stored_delivery(schedule) is None:
|
|
311
|
+
deliver_to = schedule.get("deliver_to")
|
|
312
|
+
if deliver_to is not None and read_schedule_deliver_to(deliver_to) is None:
|
|
314
313
|
raise ValueError("Invalid schedule config")
|
|
315
314
|
channel = context.get("mda_channel")
|
|
316
315
|
if channel is None:
|
|
@@ -2,22 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from collections.abc import
|
|
6
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from collections.abc import Mapping
|
|
7
6
|
|
|
8
7
|
from langgraph.runtime import get_runtime
|
|
9
8
|
|
|
10
9
|
from managed_deepagents._channels.binding import ChannelBinding, resolve_channel_binding
|
|
11
|
-
from managed_deepagents._channels.slack.direct_message import slack_direct_message_target
|
|
12
10
|
from managed_deepagents._identity_runtime import _field
|
|
13
11
|
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
from managed_deepagents._channels.types import JsonValue
|
|
16
|
-
|
|
17
|
-
_DIRECT_MESSAGE_TARGETS: dict[str, Callable[[ChannelBinding], JsonValue | None]] = {
|
|
18
|
-
"slack": slack_direct_message_target
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
|
|
22
13
|
def ambient_context() -> object:
|
|
23
14
|
try:
|
|
@@ -37,14 +28,3 @@ def capture_schedule_channel(
|
|
|
37
28
|
return None
|
|
38
29
|
binding["event"] = {"type": "schedule", "new_thread": new_thread}
|
|
39
30
|
return binding
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def direct_message_channel(binding: ChannelBinding) -> ChannelBinding:
|
|
43
|
-
"""Point a captured channel at the direct message with its event's sender."""
|
|
44
|
-
resolve = _DIRECT_MESSAGE_TARGETS.get(binding["provider"])
|
|
45
|
-
target = resolve(binding) if resolve is not None else None
|
|
46
|
-
if target is None:
|
|
47
|
-
raise ValueError(
|
|
48
|
-
f"Channel {binding['name']} cannot send a direct message to this run's sender"
|
|
49
|
-
)
|
|
50
|
-
return {**binding, "target": target}
|
managed_deepagents/schedules.py
CHANGED
|
@@ -9,11 +9,13 @@ LangGraph cron entries.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
from collections.abc import Mapping
|
|
12
|
-
from typing import Annotated, Literal,
|
|
12
|
+
from typing import Annotated, Literal, cast
|
|
13
13
|
|
|
14
14
|
from pydantic import ConfigDict, StringConstraints, with_config
|
|
15
15
|
from typing_extensions import TypedDict
|
|
16
16
|
|
|
17
|
+
from managed_deepagents._channels.types import normalize_channel_destination
|
|
18
|
+
|
|
17
19
|
JsonValue = object
|
|
18
20
|
_NonEmpty = Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
|
|
19
21
|
|
|
@@ -32,52 +34,6 @@ class ScheduleThreadPersistent(TypedDict):
|
|
|
32
34
|
ScheduleThreadConfig = ScheduleThreadEphemeral | ScheduleThreadPersistent
|
|
33
35
|
|
|
34
36
|
|
|
35
|
-
class _OptionalChannel(TypedDict, total=False):
|
|
36
|
-
channel: _NonEmpty
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class _NamedChannel(TypedDict):
|
|
40
|
-
channel: _NonEmpty
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@with_config(ConfigDict(extra="forbid"))
|
|
44
|
-
class CurrentThreadDelivery(_OptionalChannel):
|
|
45
|
-
type: Literal["current_thread"]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@with_config(ConfigDict(extra="forbid"))
|
|
49
|
-
class CurrentConversationDelivery(_OptionalChannel):
|
|
50
|
-
type: Literal["current_conversation"]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@with_config(ConfigDict(extra="forbid"))
|
|
54
|
-
class DirectMessageDelivery(_OptionalChannel):
|
|
55
|
-
type: Literal["direct_message"]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@with_config(ConfigDict(extra="forbid"))
|
|
59
|
-
class ProviderConversationDelivery(_NamedChannel):
|
|
60
|
-
type: Literal["provider_conversation"]
|
|
61
|
-
conversation_id: _NonEmpty
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@with_config(ConfigDict(extra="forbid"))
|
|
65
|
-
class ProviderThreadDelivery(_NamedChannel):
|
|
66
|
-
type: Literal["provider_thread"]
|
|
67
|
-
conversation_id: _NonEmpty
|
|
68
|
-
thread_id: _NonEmpty
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
#: A destination relative to the run that creates the schedule.
|
|
72
|
-
RelativeScheduleDelivery = (
|
|
73
|
-
CurrentThreadDelivery | CurrentConversationDelivery | DirectMessageDelivery
|
|
74
|
-
)
|
|
75
|
-
#: An explicit provider destination in a named channel.
|
|
76
|
-
ProviderScheduleDelivery = ProviderConversationDelivery | ProviderThreadDelivery
|
|
77
|
-
#: Where a schedule posts its final answer. ``channel`` names a module in ``channels/``.
|
|
78
|
-
ScheduleDelivery = RelativeScheduleDelivery | ProviderScheduleDelivery
|
|
79
|
-
|
|
80
|
-
|
|
81
37
|
@with_config(ConfigDict(extra="forbid"))
|
|
82
38
|
class ChannelDestinationProviderThread(TypedDict):
|
|
83
39
|
type: Literal["provider_thread"]
|
|
@@ -91,6 +47,7 @@ class ChannelDestinationProviderConversation(TypedDict):
|
|
|
91
47
|
conversation_id: _NonEmpty
|
|
92
48
|
|
|
93
49
|
|
|
50
|
+
#: Schedules cannot use ``current_thread`` (no originating channel).
|
|
94
51
|
ScheduleChannelDestination = (
|
|
95
52
|
ChannelDestinationProviderThread | ChannelDestinationProviderConversation
|
|
96
53
|
)
|
|
@@ -103,8 +60,6 @@ class ScheduleDeliveryTargetRequired(TypedDict):
|
|
|
103
60
|
|
|
104
61
|
@with_config(ConfigDict(extra="forbid"))
|
|
105
62
|
class ScheduleDeliveryTarget(ScheduleDeliveryTargetRequired, total=False):
|
|
106
|
-
"""Deprecated: use ``delivery``."""
|
|
107
|
-
|
|
108
63
|
auto_post: bool
|
|
109
64
|
|
|
110
65
|
|
|
@@ -117,7 +72,6 @@ class ScheduleConfig(ScheduleConfigRequired, total=False):
|
|
|
117
72
|
prompt: str
|
|
118
73
|
input: JsonValue
|
|
119
74
|
thread: ScheduleThreadConfig
|
|
120
|
-
delivery: ProviderScheduleDelivery | Literal[False]
|
|
121
75
|
deliver_to: ScheduleDeliveryTarget
|
|
122
76
|
context: dict[str, JsonValue]
|
|
123
77
|
|
|
@@ -125,7 +79,6 @@ class ScheduleConfig(ScheduleConfigRequired, total=False):
|
|
|
125
79
|
__all__ = [
|
|
126
80
|
"ScheduleConfig",
|
|
127
81
|
"ScheduleDefinition",
|
|
128
|
-
"ScheduleDelivery",
|
|
129
82
|
"ScheduleDeliveryTarget",
|
|
130
83
|
"ScheduleThreadConfig",
|
|
131
84
|
"define_schedule",
|
|
@@ -153,16 +106,10 @@ def define_schedule(
|
|
|
153
106
|
prompt: str | None = None,
|
|
154
107
|
input: JsonValue | None = None,
|
|
155
108
|
thread: ScheduleThreadConfig | None = None,
|
|
156
|
-
delivery: ProviderScheduleDelivery | Literal[False] | None = None,
|
|
157
109
|
deliver_to: ScheduleDeliveryTarget | None = None,
|
|
158
110
|
context: Mapping[str, JsonValue] | None = None,
|
|
159
111
|
) -> ScheduleDefinition:
|
|
160
|
-
"""Declare a managed schedule that MDA provisions as a LangGraph cron.
|
|
161
|
-
|
|
162
|
-
``delivery`` is where the final answer posts, or ``False`` to post nothing. A
|
|
163
|
-
code-defined schedule has no originating conversation, so it names a channel
|
|
164
|
-
and a provider address. ``deliver_to`` is deprecated.
|
|
165
|
-
"""
|
|
112
|
+
"""Declare a managed schedule that MDA provisions as a LangGraph cron."""
|
|
166
113
|
|
|
167
114
|
if not isinstance(cron, str) or len(cron.strip().split()) != _CRON_FIELD_COUNT:
|
|
168
115
|
raise ValueError(
|
|
@@ -177,7 +124,8 @@ def define_schedule(
|
|
|
177
124
|
raise ValueError("define_schedule(...) requires `prompt` to be a non-empty string.")
|
|
178
125
|
|
|
179
126
|
_validate_thread(thread)
|
|
180
|
-
|
|
127
|
+
if deliver_to is not None:
|
|
128
|
+
_validate_deliver_to(deliver_to)
|
|
181
129
|
if context is not None and not isinstance(context, Mapping):
|
|
182
130
|
raise ValueError("define_schedule(...) requires `context` to be a mapping when provided.")
|
|
183
131
|
|
|
@@ -186,7 +134,6 @@ def define_schedule(
|
|
|
186
134
|
"prompt": prompt,
|
|
187
135
|
"input": input,
|
|
188
136
|
"thread": thread,
|
|
189
|
-
"delivery": delivery,
|
|
190
137
|
"deliver_to": deliver_to,
|
|
191
138
|
"context": None if context is None else dict(context),
|
|
192
139
|
}
|
|
@@ -212,73 +159,20 @@ def _validate_thread(thread: ScheduleThreadConfig | object | None) -> None:
|
|
|
212
159
|
raise ValueError("define_schedule(...) requires `thread['id']` for persistent schedules.")
|
|
213
160
|
|
|
214
161
|
|
|
215
|
-
def
|
|
216
|
-
if
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
read = (
|
|
221
|
-
read_schedule_delivery(delivery)
|
|
222
|
-
if deliver_to is None
|
|
223
|
-
else read_legacy_deliver_to(deliver_to)
|
|
224
|
-
)
|
|
225
|
-
if read is not False and not is_provider_delivery(read):
|
|
162
|
+
def _validate_deliver_to(deliver_to: ScheduleDeliveryTarget | object) -> None:
|
|
163
|
+
if not isinstance(deliver_to, dict):
|
|
164
|
+
raise ValueError("define_schedule(...) requires `deliver_to` to be a mapping.")
|
|
165
|
+
channel = deliver_to.get("channel")
|
|
166
|
+
if not isinstance(channel, str) or not channel.strip():
|
|
226
167
|
raise ValueError(
|
|
227
|
-
"define_schedule(...) requires `
|
|
228
|
-
"`provider_conversation` or `provider_thread` destination with a `channel`."
|
|
168
|
+
"define_schedule(...) requires `deliver_to['channel']` to be a non-empty string."
|
|
229
169
|
)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
""
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if raw.get("channel") is not None and channel is None:
|
|
240
|
-
return None
|
|
241
|
-
destination = _read_destination(raw)
|
|
242
|
-
if destination is None:
|
|
243
|
-
return None
|
|
244
|
-
return cast("ScheduleDelivery", {**destination, **({"channel": channel} if channel else {})})
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def read_legacy_deliver_to(raw: object) -> ScheduleDelivery | Literal[False] | None:
|
|
248
|
-
"""Read a deprecated ``deliver_to`` target as a delivery."""
|
|
249
|
-
if not isinstance(raw, Mapping) or not isinstance(raw.get("to"), Mapping):
|
|
250
|
-
return None
|
|
251
|
-
delivery = read_schedule_delivery({**raw["to"], "channel": raw.get("channel")})
|
|
252
|
-
if not is_provider_delivery(delivery):
|
|
253
|
-
return None
|
|
254
|
-
auto_post = raw.get("auto_post", raw.get("autoPost"))
|
|
255
|
-
return delivery if auto_post is None or auto_post else False
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
def is_provider_delivery(
|
|
259
|
-
delivery: ScheduleDelivery | Literal[False] | None,
|
|
260
|
-
) -> TypeGuard[ProviderScheduleDelivery]:
|
|
261
|
-
return (
|
|
262
|
-
isinstance(delivery, Mapping)
|
|
263
|
-
and "conversation_id" in delivery
|
|
264
|
-
and bool(delivery.get("channel"))
|
|
265
|
-
)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
def _read_destination(raw: Mapping[str, object]) -> dict[str, str] | None:
|
|
269
|
-
kind = raw.get("type")
|
|
270
|
-
if not isinstance(kind, str):
|
|
271
|
-
return None
|
|
272
|
-
conversation_id = _text(raw.get("conversation_id", raw.get("conversationId")))
|
|
273
|
-
thread_id = _text(raw.get("thread_id", raw.get("threadId")))
|
|
274
|
-
if kind in ("current_thread", "current_conversation", "direct_message"):
|
|
275
|
-
return {"type": kind}
|
|
276
|
-
if kind == "provider_conversation" and conversation_id:
|
|
277
|
-
return {"type": kind, "conversation_id": conversation_id}
|
|
278
|
-
if kind == "provider_thread" and conversation_id and thread_id:
|
|
279
|
-
return {"type": kind, "conversation_id": conversation_id, "thread_id": thread_id}
|
|
280
|
-
return None
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
def _text(value: object) -> str | None:
|
|
284
|
-
return value.strip() or None if isinstance(value, str) else None
|
|
170
|
+
destination = deliver_to.get("to")
|
|
171
|
+
if not isinstance(destination, Mapping):
|
|
172
|
+
raise ValueError("define_schedule(...) requires `deliver_to['to']`.")
|
|
173
|
+
if destination.get("type") == "current_thread":
|
|
174
|
+
raise ValueError(
|
|
175
|
+
'define_schedule(...) rejects `deliver_to["to"]["type"]: "current_thread"`.'
|
|
176
|
+
)
|
|
177
|
+
# Validate the destination shape early rather than at delivery time.
|
|
178
|
+
normalize_channel_destination(cast("Mapping[str, object]", destination))
|
{managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: managed-deepagents
|
|
3
|
-
Version: 0.9.3.
|
|
3
|
+
Version: 0.9.3.dev26
|
|
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
|
|
@@ -488,25 +488,6 @@ live. Declarations must be statically serializable literals or top-level
|
|
|
488
488
|
constants; prompt schedules become user-message input, and stateless runs clean
|
|
489
489
|
up their temporary thread after completion.
|
|
490
490
|
|
|
491
|
-
Set `delivery` to post the final answer. A code-defined schedule has no
|
|
492
|
-
originating conversation, so it names a channel from `channels/` and a provider
|
|
493
|
-
address:
|
|
494
|
-
|
|
495
|
-
```python
|
|
496
|
-
schedule = define_schedule(
|
|
497
|
-
cron="0 9 * * 1",
|
|
498
|
-
prompt="Write a short Monday greeting.",
|
|
499
|
-
delivery={
|
|
500
|
-
"channel": "slack",
|
|
501
|
-
"type": "provider_conversation",
|
|
502
|
-
"conversation_id": "C0123456789",
|
|
503
|
-
},
|
|
504
|
-
)
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
Use `"type": "provider_thread"` with a `thread_id` to reply in a thread.
|
|
508
|
-
`deliver_to` is deprecated.
|
|
509
|
-
|
|
510
491
|
### Runtime schedules
|
|
511
492
|
|
|
512
493
|
Use `runtime.schedules` in a tool or middleware to create schedules while the
|
|
@@ -551,29 +532,9 @@ await runtime.schedules.create(
|
|
|
551
532
|
)
|
|
552
533
|
```
|
|
553
534
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
| `delivery` | Where the answer posts |
|
|
558
|
-
| ---------------------------------- | ----------------------------------------------------------------- |
|
|
559
|
-
| `{"type": "current_thread"}` | The thread the schedule was made in |
|
|
560
|
-
| `{"type": "current_conversation"}` | A new message in that conversation |
|
|
561
|
-
| `{"type": "direct_message"}` | The owner's direct message with the agent; needs a user owner |
|
|
562
|
-
| `False` | Nowhere |
|
|
563
|
-
|
|
564
|
-
```python
|
|
565
|
-
await runtime.schedules.create(
|
|
566
|
-
owner={"type": "user"},
|
|
567
|
-
cron="0 9 * * 1-5",
|
|
568
|
-
prompt="Summarize new community posts.",
|
|
569
|
-
delivery={"type": "direct_message"},
|
|
570
|
-
)
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
`new_thread` chooses whether a run starts a new thread. `current_thread`
|
|
574
|
-
continues the current thread; the other destinations start a new one. Without
|
|
575
|
-
`delivery`, a `cron` schedule posts to the current conversation and an `at`
|
|
576
|
-
schedule to the current thread. Runtime schedules stay when you deploy again.
|
|
535
|
+
Set `new_thread` to choose whether a run starts a new thread or continues the
|
|
536
|
+
current thread. When a schedule is created from a channel such as Slack,
|
|
537
|
+
each run posts its final answer to that channel. Runtime schedules stay when you deploy again.
|
|
577
538
|
|
|
578
539
|
Each owner can have at most 20 runtime schedules per agent, paused ones
|
|
579
540
|
included. Set `MDA_MAX_AGENT_SCHEDULES` or `MDA_MAX_USER_SCHEDULES` in the
|
{managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/RECORD
RENAMED
|
@@ -24,10 +24,10 @@ managed_deepagents/_managed_middleware.py,sha256=LijT0XmqR6lYvg8oiweq63C1bjSjBUZ
|
|
|
24
24
|
managed_deepagents/_managed_tools.py,sha256=fr_fJkk8wN0PZrRnihBsLTLW2Q3L-sFnRz54vD2cBzY,11120
|
|
25
25
|
managed_deepagents/_memory_instructions.py,sha256=s69Shu6vGCXbynozC-SRSJeZrpH5PNowh0sIRKH65XQ,6763
|
|
26
26
|
managed_deepagents/_run_input.py,sha256=heaTTLd9i9D-1blrH-GIi5KmSpQrhrD9_mrtz9bhy48,6613
|
|
27
|
-
managed_deepagents/_runtime_schedules.py,sha256=
|
|
27
|
+
managed_deepagents/_runtime_schedules.py,sha256=QOpp-Cps0PFszke_8EuHnMuTHlnUrYylacaLjDPIMnI,25260
|
|
28
28
|
managed_deepagents/_sandbox_proxy.py,sha256=h8EOnBD6F_jH_7ESsO-EzEUDuEPQNorUrIEV1LZASdQ,9567
|
|
29
|
-
managed_deepagents/_schedule_auth.py,sha256=
|
|
30
|
-
managed_deepagents/_schedule_channel.py,sha256
|
|
29
|
+
managed_deepagents/_schedule_auth.py,sha256=vmU-BfYNbEzGnLH2qe-zzRWEuxnWzboC8rBAHCkIhjQ,15000
|
|
30
|
+
managed_deepagents/_schedule_channel.py,sha256=P--isfzDBxJ4C2smFS-uuM3A5IwHn9byJxxVXgWDseo,998
|
|
31
31
|
managed_deepagents/_schedule_time.py,sha256=uNyULRjoD0HzPVvV-W772HPb3BYCt0fwEbbT9Ec__Jc,3710
|
|
32
32
|
managed_deepagents/_static_entry.py,sha256=vWVDXb_RwFhHIT4c8fJpUaCqxS_SAJ9Md5IKA8GDrv4,624
|
|
33
33
|
managed_deepagents/_validated_token.py,sha256=On96IOQTDz1KE_ZZmuTqY8IPw-cJ3J2tXkkmrfyvbB4,18762
|
|
@@ -39,9 +39,9 @@ managed_deepagents/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
|
39
39
|
managed_deepagents/run_context.py,sha256=1Nc3pew_nROgKi18PAKhn7vOAed-PmxArqUTpceZLLg,3430
|
|
40
40
|
managed_deepagents/runtime.py,sha256=88QmwIzEVCyq4p2BWOmw20xJJLSyemfbPneVfNnx7C0,95214
|
|
41
41
|
managed_deepagents/sandbox.py,sha256=8qaswX6F2LYJX1uGq_7XwAGHZjGOD9VQ0WISqPK_ohs,4734
|
|
42
|
-
managed_deepagents/schedules.py,sha256
|
|
43
|
-
managed_deepagents/_binaries/mda.exe,sha256=
|
|
44
|
-
managed_deepagents/_channels/__init__.py,sha256=
|
|
42
|
+
managed_deepagents/schedules.py,sha256=XROsDs-QwCWH0yEwakIN5Rhl5aM06eZX5-JFJ-KG1To,5898
|
|
43
|
+
managed_deepagents/_binaries/mda.exe,sha256=nm5Z8HhwV_PcHuwYLfT_Ix8EXaDtiQ9ei26OVIiC-r8,4537856
|
|
44
|
+
managed_deepagents/_channels/__init__.py,sha256=tY94zltWKNw-FIzbGjrh0cSAc2JIHCEAvcY7hzoRED0,801
|
|
45
45
|
managed_deepagents/_channels/assistant_text.py,sha256=ZLYAF1MQVE5_EN49MoPJdB8Ckf3vNPpXNBhkdA4egF0,3414
|
|
46
46
|
managed_deepagents/_channels/binding.py,sha256=DnxB7FXkbY5B3PCEAGz3JJBCCnQSdWz8PU8ze4fdcZU,5302
|
|
47
47
|
managed_deepagents/_channels/context.py,sha256=TLCsG5yeviEtih8GkOgBT9u1w4KhB_-zbiikMYXc2x0,2288
|
|
@@ -50,16 +50,15 @@ managed_deepagents/_channels/messaging_registry.py,sha256=S74FcoNJFQzzBzy1Oct2Sr
|
|
|
50
50
|
managed_deepagents/_channels/reactions.py,sha256=vSKwhEaDCtsceqhL83VtsbRl7TpNCxqUpqSmIkY0eCs,3537
|
|
51
51
|
managed_deepagents/_channels/response_format.py,sha256=0aHF2zXcvftmIKibckYHvtmg3yYUTfXF1njqxr-nILY,4443
|
|
52
52
|
managed_deepagents/_channels/runtime.py,sha256=aGNdfyd3kLXMBM-Qmc79dwio9DsUAhYuTn-tYIwuqAk,5993
|
|
53
|
-
managed_deepagents/_channels/schedule_delivery.py,sha256=
|
|
53
|
+
managed_deepagents/_channels/schedule_delivery.py,sha256=6l6oZUpP-AfaDYw17PvjcplmInpp8f2PiddAlpfDRF4,12155
|
|
54
54
|
managed_deepagents/_channels/source_providers.py,sha256=ItIvIyPIy0iS9S586RpbTG4QWRZ06AoZ1jil5bPsLMY,1467
|
|
55
|
-
managed_deepagents/_channels/types.py,sha256=
|
|
55
|
+
managed_deepagents/_channels/types.py,sha256=mXqdDKFZBZtcY0XxQjWlxu6G3MbkYUdpJsoGmBowi0I,4773
|
|
56
56
|
managed_deepagents/_channels/http/__init__.py,sha256=1lEW-094WyJGaMTxf-wx1DZOFQ63hryxw6BfAPooXhU,3826
|
|
57
57
|
managed_deepagents/_channels/http/http.py,sha256=lsJf79ZOiNu1WTwTFeJ-XBpF7yBA3JmGyne6QhKFPys,8652
|
|
58
58
|
managed_deepagents/_channels/http/ingress.py,sha256=cVNyKr4qDo5tisLL8J48WM0rYUQH5rPcVEK_EkdTk-Q,2928
|
|
59
59
|
managed_deepagents/_channels/http/types.py,sha256=Pb2AZ6pOhFcoDvN_4wCuurbSHSD61qI38nqKpfNJs0k,1827
|
|
60
60
|
managed_deepagents/_channels/slack/__init__.py,sha256=njnC81QxO8r0qL2-yHQMvvcEjx4TzglxSzPTDEnInW8,53
|
|
61
61
|
managed_deepagents/_channels/slack/api.py,sha256=FgL0u9xfFHtFpcgvQeDRm8xuaiP67-4KLeT991_EgBg,3013
|
|
62
|
-
managed_deepagents/_channels/slack/direct_message.py,sha256=gK2Ca7-qXyxEGE6V1UfOz4orId9vqv4Sk2GQkZLxi9E,1038
|
|
63
62
|
managed_deepagents/_channels/slack/files.py,sha256=f0yqnLNnzR5OR3vYGfosJPadG5c1H5IA4x8ERGslQ3E,13245
|
|
64
63
|
managed_deepagents/_channels/slack/message_content.py,sha256=BECB2A9gs9GpIMbkOPsS_69OUkd-10XVINW2bkTW7CM,9912
|
|
65
64
|
managed_deepagents/_channels/slack/middleware.py,sha256=sWHSoC7FzQ5dPVbk26cgMoSap4od9bzK01Mu6F4J0QE,3856
|
|
@@ -104,9 +103,9 @@ managed_deepagents/identity/__init__.py,sha256=YMB5p2DRyyY_82gGNVfGHjfjnUFRTtMne
|
|
|
104
103
|
managed_deepagents/identity/claims.py,sha256=prby7r_8Lww3MmoBm8PX6PsSGE3GwSHkr8mVIz_08nU,1180
|
|
105
104
|
managed_deepagents/identity/options.py,sha256=x_yMbXEFR7zXyehEjDHG2qjAlukXjrRBcQLcM6IndLM,2550
|
|
106
105
|
managed_deepagents/identity/supabase.py,sha256=8uobl3WCrQL_ieSXG8KTLf1th7Qjim9liZT50HeaJE0,6026
|
|
107
|
-
managed_deepagents-0.9.3.
|
|
108
|
-
managed_deepagents-0.9.3.
|
|
109
|
-
managed_deepagents-0.9.3.
|
|
110
|
-
managed_deepagents-0.9.3.
|
|
111
|
-
managed_deepagents-0.9.3.
|
|
112
|
-
managed_deepagents-0.9.3.
|
|
106
|
+
managed_deepagents-0.9.3.dev26.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
|
|
107
|
+
managed_deepagents-0.9.3.dev26.dist-info/METADATA,sha256=IQ97rLRtya8u2GqX91U8gbHz55o3ooIXqG041jTncDI,33888
|
|
108
|
+
managed_deepagents-0.9.3.dev26.dist-info/WHEEL,sha256=3I5VVWZdsFlU417aCS2bMRuerS8wsfvBq99MyatBV3A,97
|
|
109
|
+
managed_deepagents-0.9.3.dev26.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
|
|
110
|
+
managed_deepagents-0.9.3.dev26.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
|
|
111
|
+
managed_deepagents-0.9.3.dev26.dist-info/RECORD,,
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import re
|
|
4
|
-
from collections.abc import Mapping
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
6
|
-
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
from managed_deepagents._channels.binding import ChannelBinding
|
|
9
|
-
from managed_deepagents._channels.types import JsonValue
|
|
10
|
-
|
|
11
|
-
_SLACK_USER_ID = re.compile(r"[UW][A-Z0-9]+")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def slack_direct_message_target(binding: ChannelBinding) -> JsonValue | None:
|
|
15
|
-
"""Address the app's direct message with the user who sent the binding's event.
|
|
16
|
-
|
|
17
|
-
Slack opens the conversation when a message is posted to a user ID.
|
|
18
|
-
"""
|
|
19
|
-
event = binding.get("raw_event")
|
|
20
|
-
target = binding["target"]
|
|
21
|
-
if (
|
|
22
|
-
binding["transport"] != "trigger_server"
|
|
23
|
-
or not isinstance(event, Mapping)
|
|
24
|
-
or not isinstance(target, Mapping)
|
|
25
|
-
):
|
|
26
|
-
return None
|
|
27
|
-
user = event.get("user")
|
|
28
|
-
if isinstance(user, Mapping):
|
|
29
|
-
user = user.get("id")
|
|
30
|
-
if not isinstance(user, str) or not _SLACK_USER_ID.fullmatch(user):
|
|
31
|
-
return None
|
|
32
|
-
return {**target, "address": {"conversation_id": user}}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{managed_deepagents-0.9.3.dev25.dist-info → managed_deepagents-0.9.3.dev26.dist-info}/top_level.txt
RENAMED
|
File without changes
|