managed-deepagents 0.9.3.dev16__py3-none-win_amd64.whl → 0.9.3.dev17__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 +1 -5
- managed_deepagents/_channels/schedule_delivery.py +32 -85
- managed_deepagents/_channels/slack/direct_message.py +32 -0
- managed_deepagents/_channels/types.py +14 -30
- managed_deepagents/_runtime_schedules.py +72 -15
- managed_deepagents/_schedule_auth.py +4 -3
- managed_deepagents/_schedule_channel.py +21 -1
- managed_deepagents/schedules.py +128 -22
- {managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/METADATA +43 -4
- {managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/RECORD +15 -14
- {managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/WHEEL +0 -0
- {managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/entry_points.txt +0 -0
- {managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/licenses/LICENSE +0 -0
- {managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -11,10 +11,7 @@ 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
|
|
15
|
-
ChannelError,
|
|
16
|
-
normalize_channel_destination,
|
|
17
|
-
)
|
|
14
|
+
from managed_deepagents._channels.types import ChannelError
|
|
18
15
|
|
|
19
16
|
__all__ = [
|
|
20
17
|
"SLACK_BOT_TOKEN_ENV",
|
|
@@ -22,6 +19,5 @@ __all__ = [
|
|
|
22
19
|
"create_runtime_channel",
|
|
23
20
|
"create_schedule_delivery_middleware",
|
|
24
21
|
"extract_assistant_text",
|
|
25
|
-
"normalize_channel_destination",
|
|
26
22
|
"resolve_runtime_channel",
|
|
27
23
|
]
|
|
@@ -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,
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Literal, cast
|
|
9
9
|
|
|
10
10
|
from langchain.agents.middleware.types import AgentMiddleware, AgentState
|
|
11
11
|
from langgraph.config import get_config
|
|
@@ -20,6 +20,7 @@ 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
|
|
23
24
|
from managed_deepagents._channels.trigger.client import create_trigger_client
|
|
24
25
|
from managed_deepagents._identity_runtime import (
|
|
25
26
|
_ambient_configurable,
|
|
@@ -28,13 +29,18 @@ from managed_deepagents._identity_runtime import (
|
|
|
28
29
|
)
|
|
29
30
|
from managed_deepagents._log import logger
|
|
30
31
|
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
|
+
)
|
|
31
39
|
|
|
32
40
|
if TYPE_CHECKING:
|
|
33
41
|
from managed_deepagents._channels.trigger.types import TriggerChannelActionRequest
|
|
34
42
|
from managed_deepagents._channels.types import (
|
|
35
43
|
ChannelAddress,
|
|
36
|
-
ChannelDestinationProviderConversation,
|
|
37
|
-
ChannelDestinationProviderThread,
|
|
38
44
|
JsonValue,
|
|
39
45
|
)
|
|
40
46
|
|
|
@@ -53,12 +59,6 @@ PostFn = Callable[..., Awaitable[object] | object]
|
|
|
53
59
|
DeliverOutcome = Literal["posted", "skipped", "failed"]
|
|
54
60
|
|
|
55
61
|
|
|
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,85 +69,36 @@ 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
|
-
|
|
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"]}
|
|
72
|
+
def read_stored_delivery(schedule: object) -> ScheduleDelivery | Literal[False] | None:
|
|
73
|
+
"""Read a cron's delivery, including a deprecated ``deliver_to``."""
|
|
74
|
+
delivery = _field(schedule, "delivery")
|
|
75
|
+
if delivery is None:
|
|
76
|
+
return read_legacy_deliver_to(_field(schedule, "deliver_to"))
|
|
77
|
+
return read_schedule_delivery(delivery)
|
|
130
78
|
|
|
131
79
|
|
|
132
80
|
async def deliver_schedule_result( # noqa: C901, PLR0911 - delivery outcomes
|
|
133
81
|
*,
|
|
134
|
-
|
|
82
|
+
delivery: ProviderScheduleDelivery,
|
|
135
83
|
reply_text: str,
|
|
136
84
|
bot_token: str | None = None,
|
|
137
85
|
post: PostFn | None = None,
|
|
138
86
|
) -> DeliverOutcome:
|
|
139
87
|
"""Post result text; the middleware fails the run on a failed outcome."""
|
|
140
88
|
text = reply_text.strip()
|
|
141
|
-
if not text
|
|
89
|
+
if not text:
|
|
142
90
|
return "skipped"
|
|
143
|
-
|
|
91
|
+
channel = delivery["channel"]
|
|
92
|
+
if (channel_provider_for_name(channel) or channel) != "slack":
|
|
144
93
|
logger.error(
|
|
145
|
-
'schedule
|
|
146
|
-
logger.log_identifier(
|
|
94
|
+
'schedule delivery channel "%s" is not supported yet',
|
|
95
|
+
logger.log_identifier(channel),
|
|
147
96
|
)
|
|
148
97
|
return "failed"
|
|
149
98
|
|
|
150
|
-
address =
|
|
99
|
+
address: ChannelAddress = {"conversation_id": delivery["conversation_id"]}
|
|
100
|
+
if delivery["type"] == "provider_thread":
|
|
101
|
+
address["thread_id"] = delivery["thread_id"]
|
|
151
102
|
if post is not None:
|
|
152
103
|
try:
|
|
153
104
|
result = post(
|
|
@@ -178,11 +129,7 @@ async def deliver_schedule_result( # noqa: C901, PLR0911 - delivery outcomes
|
|
|
178
129
|
"message": {"text": text},
|
|
179
130
|
}
|
|
180
131
|
try:
|
|
181
|
-
await client.post_deployment_action(
|
|
182
|
-
deployment_id,
|
|
183
|
-
deliver_to["channel"],
|
|
184
|
-
action,
|
|
185
|
-
)
|
|
132
|
+
await client.post_deployment_action(deployment_id, channel, action)
|
|
186
133
|
return "posted"
|
|
187
134
|
except Exception as error: # noqa: BLE001 - return a failed delivery outcome
|
|
188
135
|
logger.error(
|
|
@@ -196,7 +143,7 @@ async def deliver_schedule_result( # noqa: C901, PLR0911 - delivery outcomes
|
|
|
196
143
|
).strip()
|
|
197
144
|
if not token:
|
|
198
145
|
logger.error(
|
|
199
|
-
"schedule
|
|
146
|
+
"schedule delivery requires Trigger channel configuration or "
|
|
200
147
|
"SLACK_BOT_TOKEN; skipping auto-post"
|
|
201
148
|
)
|
|
202
149
|
return "failed"
|
|
@@ -256,6 +203,9 @@ async def _deliver_captured_result(
|
|
|
256
203
|
) -> None:
|
|
257
204
|
reply_text = extract_assistant_text(output)
|
|
258
205
|
routing = _current_routing.get() or {}
|
|
206
|
+
delivery = read_stored_delivery(routing.get("mda_schedule"))
|
|
207
|
+
if delivery is False:
|
|
208
|
+
return
|
|
259
209
|
saved_channel = routing.get("mda_channel")
|
|
260
210
|
if saved_channel is not None:
|
|
261
211
|
channel = resolve_runtime_channel({"mda_channel": saved_channel}, configurable)
|
|
@@ -270,9 +220,8 @@ async def _deliver_captured_result(
|
|
|
270
220
|
if content is not None:
|
|
271
221
|
await channel.post({"type": "content", "content": content})
|
|
272
222
|
return
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
outcome = await deliver(deliver_to=deliver_to, reply_text=reply_text)
|
|
223
|
+
if is_provider_delivery(delivery):
|
|
224
|
+
outcome = await deliver(delivery=delivery, reply_text=reply_text)
|
|
276
225
|
if outcome == "failed":
|
|
277
226
|
raise RuntimeError("Scheduled channel delivery failed")
|
|
278
227
|
|
|
@@ -323,11 +272,9 @@ def create_schedule_delivery_middleware(
|
|
|
323
272
|
|
|
324
273
|
|
|
325
274
|
__all__ = [
|
|
326
|
-
"NormalizedScheduleDeliverTo",
|
|
327
|
-
"address_from_deliver_to",
|
|
328
275
|
"create_schedule_delivery_middleware",
|
|
329
276
|
"deliver_schedule_result",
|
|
330
277
|
"get_deployment_id",
|
|
331
278
|
"is_trusted_schedule_delivery_run",
|
|
332
|
-
"
|
|
279
|
+
"read_stored_delivery",
|
|
333
280
|
]
|
|
@@ -0,0 +1,32 @@
|
|
|
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}}
|
|
@@ -43,6 +43,14 @@ 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
|
+
|
|
46
54
|
class ChannelDestinationProviderThread(TypedDict):
|
|
47
55
|
type: Literal["provider_thread"]
|
|
48
56
|
conversation_id: str
|
|
@@ -54,8 +62,14 @@ class ChannelDestinationProviderConversation(TypedDict):
|
|
|
54
62
|
conversation_id: str
|
|
55
63
|
|
|
56
64
|
|
|
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.
|
|
57
69
|
ChannelDestination = (
|
|
58
70
|
ChannelDestinationCurrentThread
|
|
71
|
+
| ChannelDestinationCurrentConversation
|
|
72
|
+
| ChannelDestinationDirectMessage
|
|
59
73
|
| ChannelDestinationProviderThread
|
|
60
74
|
| ChannelDestinationProviderConversation
|
|
61
75
|
)
|
|
@@ -130,35 +144,6 @@ class ChannelError(Exception):
|
|
|
130
144
|
self.code = code
|
|
131
145
|
|
|
132
146
|
|
|
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
|
-
|
|
162
147
|
__all__ = [
|
|
163
148
|
"ChannelAddress",
|
|
164
149
|
"ChannelContentMessage",
|
|
@@ -170,5 +155,4 @@ __all__ = [
|
|
|
170
155
|
"ChannelNativeMessage",
|
|
171
156
|
"JsonValue",
|
|
172
157
|
"PostedChannelMessage",
|
|
173
|
-
"normalize_channel_destination",
|
|
174
158
|
]
|
|
@@ -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 Annotated, Literal, NotRequired
|
|
10
|
+
from typing import TYPE_CHECKING, Annotated, Literal, NotRequired, cast
|
|
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_stored_delivery
|
|
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,21 +39,25 @@ 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, direct_message_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
|
-
|
|
46
|
+
RelativeScheduleDelivery,
|
|
47
|
+
ScheduleDelivery,
|
|
47
48
|
ScheduleThreadConfig,
|
|
48
49
|
)
|
|
49
50
|
|
|
51
|
+
if TYPE_CHECKING:
|
|
52
|
+
from managed_deepagents._channels.binding import ChannelBinding
|
|
53
|
+
|
|
50
54
|
_MAX_INPUT_BYTES = 1_048_576
|
|
51
55
|
_MAX_RESPONSE_BYTES = 4_194_304
|
|
52
56
|
_MAX_PAGE_SIZE = 100
|
|
53
57
|
_CHANNEL_ADAPTER = TypeAdapter(ChannelContext)
|
|
54
58
|
_METADATA_ADAPTER = TypeAdapter(dict[str, JsonValue])
|
|
55
59
|
_MANAGED_BY_ADAPTER = TypeAdapter(Literal["runtime", "deploy"])
|
|
56
|
-
_DELIVERY_ADAPTER = TypeAdapter(
|
|
60
|
+
_DELIVERY_ADAPTER = TypeAdapter(RelativeScheduleDelivery | Literal[False])
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
@with_config(ConfigDict(extra="forbid"))
|
|
@@ -100,7 +104,7 @@ class ScheduleRecord(TypedDict):
|
|
|
100
104
|
new_thread: bool
|
|
101
105
|
channel: str | None
|
|
102
106
|
target: JsonValue
|
|
103
|
-
|
|
107
|
+
delivery: ScheduleDelivery | Literal[False]
|
|
104
108
|
context: NotRequired[dict[str, JsonValue]]
|
|
105
109
|
paused: bool
|
|
106
110
|
metadata: dict[str, JsonValue]
|
|
@@ -119,7 +123,6 @@ class _Spec(BaseModel):
|
|
|
119
123
|
timezone: str | None = None
|
|
120
124
|
prompt: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)] | None = None
|
|
121
125
|
input: ScheduleInput | None = Field(default=None, exclude=True)
|
|
122
|
-
deliver_to: ScheduleDeliveryTarget | None = None
|
|
123
126
|
paused: bool | None = None
|
|
124
127
|
new_thread: bool | None = None
|
|
125
128
|
metadata: dict[str, JsonValue] = Field(default_factory=dict, exclude=True)
|
|
@@ -340,6 +343,7 @@ def _record(wire: _Wire, ctx: _Context, *, now: datetime | None = None) -> Sched
|
|
|
340
343
|
"new_thread": spec.new_thread if spec.new_thread is not None else not bool(wire.thread_id),
|
|
341
344
|
"channel": None,
|
|
342
345
|
"target": None,
|
|
346
|
+
"delivery": False,
|
|
343
347
|
"paused": not wire.enabled,
|
|
344
348
|
"expired": wire.end_time is not None
|
|
345
349
|
and datetime.fromisoformat(wire.end_time) < (now or datetime.now(UTC)),
|
|
@@ -358,9 +362,6 @@ def _record(wire: _Wire, ctx: _Context, *, now: datetime | None = None) -> Sched
|
|
|
358
362
|
routing = wire.payload.context
|
|
359
363
|
if routing is None:
|
|
360
364
|
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
|
-
)
|
|
364
365
|
channel = _field(routing, "mda_channel")
|
|
365
366
|
if channel is None and wire.payload.context is None:
|
|
366
367
|
channel = _field(routing, "channel")
|
|
@@ -373,8 +374,11 @@ def _record(wire: _Wire, ctx: _Context, *, now: datetime | None = None) -> Sched
|
|
|
373
374
|
parsed_channel = _CHANNEL_ADAPTER.validate_python(channel, strict=True)
|
|
374
375
|
result["channel"] = parsed_channel["name"]
|
|
375
376
|
result["target"] = parsed_channel["target"]
|
|
376
|
-
|
|
377
|
-
|
|
377
|
+
delivery = read_stored_delivery(_field(routing, "mda_schedule"))
|
|
378
|
+
if delivery is None and result["channel"] is not None:
|
|
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
|
|
378
382
|
return result
|
|
379
383
|
|
|
380
384
|
|
|
@@ -390,6 +394,40 @@ def _run_input(spec: _Spec) -> ScheduleInput:
|
|
|
390
394
|
return spec.input
|
|
391
395
|
|
|
392
396
|
|
|
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
|
+
|
|
393
431
|
async def _verify_target(
|
|
394
432
|
wire: _Wire, target: str | None, ctx: _Context, *, created: bool = True
|
|
395
433
|
) -> None:
|
|
@@ -481,18 +519,29 @@ class RuntimeSchedules:
|
|
|
481
519
|
prompt: str | None = None,
|
|
482
520
|
input: ScheduleInput | None = None,
|
|
483
521
|
new_thread: bool | None = None,
|
|
522
|
+
delivery: RelativeScheduleDelivery | Literal[False] | None = None,
|
|
484
523
|
paused: bool = False,
|
|
485
524
|
metadata: dict[str, JsonValue] | None = None,
|
|
486
525
|
context: dict[str, JsonValue] | None = None,
|
|
487
526
|
) -> 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
|
+
"""
|
|
488
533
|
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
|
|
489
538
|
spec = _Spec(
|
|
490
539
|
cron=cron,
|
|
491
540
|
at=at,
|
|
492
541
|
timezone=timezone,
|
|
493
542
|
prompt=prompt,
|
|
494
543
|
input=input,
|
|
495
|
-
new_thread=new_thread
|
|
544
|
+
new_thread=new_thread,
|
|
496
545
|
paused=paused,
|
|
497
546
|
metadata=metadata if metadata is not None else {},
|
|
498
547
|
context=context,
|
|
@@ -500,7 +549,12 @@ class RuntimeSchedules:
|
|
|
500
549
|
run_input = _run_input(spec)
|
|
501
550
|
timing = schedule_timing(cron=cron, at=at, timezone=timezone)
|
|
502
551
|
resolved_new_thread = bool(spec.new_thread)
|
|
503
|
-
channel =
|
|
552
|
+
channel, stored_delivery = _resolve_delivery(
|
|
553
|
+
delivery,
|
|
554
|
+
capture_schedule_channel(configurable, new_thread=resolved_new_thread),
|
|
555
|
+
owner,
|
|
556
|
+
new_thread=resolved_new_thread,
|
|
557
|
+
)
|
|
504
558
|
thread_id = configurable.get("thread_id")
|
|
505
559
|
if not resolved_new_thread and not thread_id:
|
|
506
560
|
raise ValueError("Same-thread schedules require a current thread; use new_thread=True")
|
|
@@ -547,7 +601,10 @@ class RuntimeSchedules:
|
|
|
547
601
|
"enabled": not paused,
|
|
548
602
|
"on_run_completed": on_run_completed,
|
|
549
603
|
"context": {
|
|
550
|
-
"mda_schedule": {
|
|
604
|
+
"mda_schedule": {
|
|
605
|
+
"name": name,
|
|
606
|
+
**({} if stored_delivery is None else {"delivery": stored_delivery}),
|
|
607
|
+
},
|
|
551
608
|
**({"mda_channel": channel} if channel else {}),
|
|
552
609
|
**(spec.context or {}),
|
|
553
610
|
},
|
|
@@ -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_stored_delivery
|
|
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
|
|
@@ -312,8 +312,9 @@ def _check_context(
|
|
|
312
312
|
or any(is_managed_key(key) for key in context if key not in {"mda_schedule", "mda_channel"})
|
|
313
313
|
):
|
|
314
314
|
raise ValueError("Invalid schedule config")
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
if (
|
|
316
|
+
schedule.get("delivery") is not None or schedule.get("deliver_to") is not None
|
|
317
|
+
) and read_stored_delivery(schedule) is None:
|
|
317
318
|
raise ValueError("Invalid schedule config")
|
|
318
319
|
channel = context.get("mda_channel")
|
|
319
320
|
if channel is None:
|
|
@@ -2,13 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from collections.abc import Mapping
|
|
5
|
+
from collections.abc import Callable, Mapping
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
6
7
|
|
|
7
8
|
from langgraph.runtime import get_runtime
|
|
8
9
|
|
|
9
10
|
from managed_deepagents._channels.binding import ChannelBinding, resolve_channel_binding
|
|
11
|
+
from managed_deepagents._channels.slack.direct_message import slack_direct_message_target
|
|
10
12
|
from managed_deepagents._identity_runtime import _field
|
|
11
13
|
|
|
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
|
+
|
|
12
21
|
|
|
13
22
|
def ambient_context() -> object:
|
|
14
23
|
try:
|
|
@@ -28,3 +37,14 @@ def capture_schedule_channel(
|
|
|
28
37
|
return None
|
|
29
38
|
binding["event"] = {"type": "schedule", "new_thread": new_thread}
|
|
30
39
|
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,13 +9,11 @@ LangGraph cron entries.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
from collections.abc import Mapping
|
|
12
|
-
from typing import Annotated, Literal, cast
|
|
12
|
+
from typing import Annotated, Literal, TypeGuard, 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
|
-
|
|
19
17
|
JsonValue = object
|
|
20
18
|
_NonEmpty = Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
|
|
21
19
|
|
|
@@ -34,6 +32,52 @@ class ScheduleThreadPersistent(TypedDict):
|
|
|
34
32
|
ScheduleThreadConfig = ScheduleThreadEphemeral | ScheduleThreadPersistent
|
|
35
33
|
|
|
36
34
|
|
|
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
|
+
|
|
37
81
|
@with_config(ConfigDict(extra="forbid"))
|
|
38
82
|
class ChannelDestinationProviderThread(TypedDict):
|
|
39
83
|
type: Literal["provider_thread"]
|
|
@@ -47,7 +91,6 @@ class ChannelDestinationProviderConversation(TypedDict):
|
|
|
47
91
|
conversation_id: _NonEmpty
|
|
48
92
|
|
|
49
93
|
|
|
50
|
-
#: Schedules cannot use ``current_thread`` (no originating channel).
|
|
51
94
|
ScheduleChannelDestination = (
|
|
52
95
|
ChannelDestinationProviderThread | ChannelDestinationProviderConversation
|
|
53
96
|
)
|
|
@@ -60,6 +103,8 @@ class ScheduleDeliveryTargetRequired(TypedDict):
|
|
|
60
103
|
|
|
61
104
|
@with_config(ConfigDict(extra="forbid"))
|
|
62
105
|
class ScheduleDeliveryTarget(ScheduleDeliveryTargetRequired, total=False):
|
|
106
|
+
"""Deprecated: use ``delivery``."""
|
|
107
|
+
|
|
63
108
|
auto_post: bool
|
|
64
109
|
|
|
65
110
|
|
|
@@ -72,6 +117,7 @@ class ScheduleConfig(ScheduleConfigRequired, total=False):
|
|
|
72
117
|
prompt: str
|
|
73
118
|
input: JsonValue
|
|
74
119
|
thread: ScheduleThreadConfig
|
|
120
|
+
delivery: ProviderScheduleDelivery | Literal[False]
|
|
75
121
|
deliver_to: ScheduleDeliveryTarget
|
|
76
122
|
context: dict[str, JsonValue]
|
|
77
123
|
|
|
@@ -79,6 +125,7 @@ class ScheduleConfig(ScheduleConfigRequired, total=False):
|
|
|
79
125
|
__all__ = [
|
|
80
126
|
"ScheduleConfig",
|
|
81
127
|
"ScheduleDefinition",
|
|
128
|
+
"ScheduleDelivery",
|
|
82
129
|
"ScheduleDeliveryTarget",
|
|
83
130
|
"ScheduleThreadConfig",
|
|
84
131
|
"define_schedule",
|
|
@@ -106,10 +153,16 @@ def define_schedule(
|
|
|
106
153
|
prompt: str | None = None,
|
|
107
154
|
input: JsonValue | None = None,
|
|
108
155
|
thread: ScheduleThreadConfig | None = None,
|
|
156
|
+
delivery: ProviderScheduleDelivery | Literal[False] | None = None,
|
|
109
157
|
deliver_to: ScheduleDeliveryTarget | None = None,
|
|
110
158
|
context: Mapping[str, JsonValue] | None = None,
|
|
111
159
|
) -> ScheduleDefinition:
|
|
112
|
-
"""Declare a managed schedule that MDA provisions as a LangGraph cron.
|
|
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
|
+
"""
|
|
113
166
|
|
|
114
167
|
if not isinstance(cron, str) or len(cron.strip().split()) != _CRON_FIELD_COUNT:
|
|
115
168
|
raise ValueError(
|
|
@@ -124,8 +177,7 @@ def define_schedule(
|
|
|
124
177
|
raise ValueError("define_schedule(...) requires `prompt` to be a non-empty string.")
|
|
125
178
|
|
|
126
179
|
_validate_thread(thread)
|
|
127
|
-
|
|
128
|
-
_validate_deliver_to(deliver_to)
|
|
180
|
+
_validate_delivery(delivery, deliver_to)
|
|
129
181
|
if context is not None and not isinstance(context, Mapping):
|
|
130
182
|
raise ValueError("define_schedule(...) requires `context` to be a mapping when provided.")
|
|
131
183
|
|
|
@@ -134,6 +186,7 @@ def define_schedule(
|
|
|
134
186
|
"prompt": prompt,
|
|
135
187
|
"input": input,
|
|
136
188
|
"thread": thread,
|
|
189
|
+
"delivery": delivery,
|
|
137
190
|
"deliver_to": deliver_to,
|
|
138
191
|
"context": None if context is None else dict(context),
|
|
139
192
|
}
|
|
@@ -159,20 +212,73 @@ def _validate_thread(thread: ScheduleThreadConfig | object | None) -> None:
|
|
|
159
212
|
raise ValueError("define_schedule(...) requires `thread['id']` for persistent schedules.")
|
|
160
213
|
|
|
161
214
|
|
|
162
|
-
def
|
|
163
|
-
if
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if destination.get("type") == "current_thread":
|
|
215
|
+
def _validate_delivery(delivery: object, deliver_to: object) -> None:
|
|
216
|
+
if delivery is None and deliver_to is None:
|
|
217
|
+
return
|
|
218
|
+
if delivery is not None and deliver_to is not None:
|
|
219
|
+
raise ValueError("define_schedule(...) takes `delivery` or `deliver_to`, not both.")
|
|
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):
|
|
174
226
|
raise ValueError(
|
|
175
|
-
|
|
227
|
+
"define_schedule(...) requires `delivery` to be `False` or a "
|
|
228
|
+
"`provider_conversation` or `provider_thread` destination with a `channel`."
|
|
176
229
|
)
|
|
177
|
-
|
|
178
|
-
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def read_schedule_delivery(raw: object) -> ScheduleDelivery | Literal[False] | None:
|
|
233
|
+
"""Read a delivery written in snake_case or camelCase."""
|
|
234
|
+
if raw is False:
|
|
235
|
+
return False
|
|
236
|
+
if not isinstance(raw, Mapping):
|
|
237
|
+
return None
|
|
238
|
+
channel = _text(raw.get("channel"))
|
|
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
|
{managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.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.dev17
|
|
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,6 +488,25 @@ 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
|
+
|
|
491
510
|
### Runtime schedules
|
|
492
511
|
|
|
493
512
|
Use `runtime.schedules` in a tool or middleware to create schedules while the
|
|
@@ -532,9 +551,29 @@ await runtime.schedules.create(
|
|
|
532
551
|
)
|
|
533
552
|
```
|
|
534
553
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
554
|
+
When a schedule is created from a channel such as Slack, each run posts its
|
|
555
|
+
final answer to that channel. Set `delivery` to choose where:
|
|
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.
|
|
538
577
|
|
|
539
578
|
Each owner can have at most 20 runtime schedules per agent, paused ones
|
|
540
579
|
included. Expired one-time schedules and schedules defined in code do not count. A run started by
|
{managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.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=okkrvThUcaaiR4xvnRTxbfVM6oSGrpLka3nhdW3o8hk,27796
|
|
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=cUTftKmJGjkDc6SLX0OSOcwjbM8kbMUcgD2KeXyIsWA,14596
|
|
30
|
+
managed_deepagents/_schedule_channel.py,sha256=-LjVxzhqtQJlTVLtYB8OvtKjSuNLIuYHWn2I4veV5VE,1812
|
|
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=-xyzJToGtLOiQMrPp6IcEVtWmZmqZWWHKgjHfDo_DmE,9447
|
|
43
|
+
managed_deepagents/_binaries/mda.exe,sha256=bVfEFqY44_hZtVaEK7I8MIwGCUb97WijWNLrY12GYL4,4539392
|
|
44
|
+
managed_deepagents/_channels/__init__.py,sha256=mrsTLw4H5xpRsqJxbBxr6WpCVQHsmx782GwIiYQqt-Y,720
|
|
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,15 +50,16 @@ 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=1DY1avYOOJdpSiQTpTycvVuBJLUF5tYkBjL65Hbx3jk,10279
|
|
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=SYWjmQvpljZ1RcRwYbmAupyVbDZJAvidMGH6xaarP38,3991
|
|
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
|
|
62
63
|
managed_deepagents/_channels/slack/files.py,sha256=f0yqnLNnzR5OR3vYGfosJPadG5c1H5IA4x8ERGslQ3E,13245
|
|
63
64
|
managed_deepagents/_channels/slack/message_content.py,sha256=BECB2A9gs9GpIMbkOPsS_69OUkd-10XVINW2bkTW7CM,9912
|
|
64
65
|
managed_deepagents/_channels/slack/middleware.py,sha256=sWHSoC7FzQ5dPVbk26cgMoSap4od9bzK01Mu6F4J0QE,3856
|
|
@@ -102,9 +103,9 @@ managed_deepagents/identity/__init__.py,sha256=YMB5p2DRyyY_82gGNVfGHjfjnUFRTtMne
|
|
|
102
103
|
managed_deepagents/identity/claims.py,sha256=prby7r_8Lww3MmoBm8PX6PsSGE3GwSHkr8mVIz_08nU,1180
|
|
103
104
|
managed_deepagents/identity/options.py,sha256=x_yMbXEFR7zXyehEjDHG2qjAlukXjrRBcQLcM6IndLM,2550
|
|
104
105
|
managed_deepagents/identity/supabase.py,sha256=8uobl3WCrQL_ieSXG8KTLf1th7Qjim9liZT50HeaJE0,6026
|
|
105
|
-
managed_deepagents-0.9.3.
|
|
106
|
-
managed_deepagents-0.9.3.
|
|
107
|
-
managed_deepagents-0.9.3.
|
|
108
|
-
managed_deepagents-0.9.3.
|
|
109
|
-
managed_deepagents-0.9.3.
|
|
110
|
-
managed_deepagents-0.9.3.
|
|
106
|
+
managed_deepagents-0.9.3.dev17.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
|
|
107
|
+
managed_deepagents-0.9.3.dev17.dist-info/METADATA,sha256=rSf5-ZqdboJKuNC4l2xlxt4L0tUnvb9g1R1AzXwx0NM,35047
|
|
108
|
+
managed_deepagents-0.9.3.dev17.dist-info/WHEEL,sha256=3I5VVWZdsFlU417aCS2bMRuerS8wsfvBq99MyatBV3A,97
|
|
109
|
+
managed_deepagents-0.9.3.dev17.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
|
|
110
|
+
managed_deepagents-0.9.3.dev17.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
|
|
111
|
+
managed_deepagents-0.9.3.dev17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{managed_deepagents-0.9.3.dev16.dist-info → managed_deepagents-0.9.3.dev17.dist-info}/top_level.txt
RENAMED
|
File without changes
|