agentjam 0.1.0__py3-none-any.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.
Files changed (86) hide show
  1. agentjam/__init__.py +435 -0
  2. agentjam/_adapters/__init__.py +0 -0
  3. agentjam/_adapters/responses.py +73 -0
  4. agentjam/_adapters/shared.py +435 -0
  5. agentjam/_agent.py +1032 -0
  6. agentjam/_agent_access.py +360 -0
  7. agentjam/_agent_delegations.py +376 -0
  8. agentjam/_agent_executions.py +566 -0
  9. agentjam/_agent_judging.py +288 -0
  10. agentjam/_agent_options.py +122 -0
  11. agentjam/_agent_routing.py +214 -0
  12. agentjam/_agent_session.py +195 -0
  13. agentjam/_agent_support.py +415 -0
  14. agentjam/_artifacts.py +565 -0
  15. agentjam/_attachments.py +112 -0
  16. agentjam/_connections.py +1282 -0
  17. agentjam/_content.py +29 -0
  18. agentjam/_cron.py +302 -0
  19. agentjam/_errors.py +238 -0
  20. agentjam/_events.py +113 -0
  21. agentjam/_files.py +55 -0
  22. agentjam/_github.py +742 -0
  23. agentjam/_idempotency.py +68 -0
  24. agentjam/_inputs.py +79 -0
  25. agentjam/_models.py +21 -0
  26. agentjam/_polling.py +139 -0
  27. agentjam/_profile.py +244 -0
  28. agentjam/_protocol.py +480 -0
  29. agentjam/_providers.py +365 -0
  30. agentjam/_recaps.py +67 -0
  31. agentjam/_relay/__init__.py +0 -0
  32. agentjam/_relay/actions.py +234 -0
  33. agentjam/_relay/artifacts.py +96 -0
  34. agentjam/_relay/base.py +387 -0
  35. agentjam/_relay/commits.py +77 -0
  36. agentjam/_relay/copies.py +66 -0
  37. agentjam/_relay/credentials.py +127 -0
  38. agentjam/_relay/endpoints.py +39 -0
  39. agentjam/_relay/follow_ups.py +548 -0
  40. agentjam/_relay/frames.py +443 -0
  41. agentjam/_relay/guest_store.py +114 -0
  42. agentjam/_relay/guests.py +55 -0
  43. agentjam/_relay/inputs.py +119 -0
  44. agentjam/_relay/lineage.py +294 -0
  45. agentjam/_relay/memory.py +1045 -0
  46. agentjam/_relay/payments.py +204 -0
  47. agentjam/_relay/profiles.py +95 -0
  48. agentjam/_relay/remote.py +826 -0
  49. agentjam/_relay/resumptions.py +65 -0
  50. agentjam/_relay/revisions.py +43 -0
  51. agentjam/_relay/schedule_follow_ups.py +274 -0
  52. agentjam/_relay/schedules.py +547 -0
  53. agentjam/_relay/secrets.py +275 -0
  54. agentjam/_relay/sessions.py +640 -0
  55. agentjam/_relay/uploads.py +71 -0
  56. agentjam/_requests.py +178 -0
  57. agentjam/_screening.py +368 -0
  58. agentjam/_secrets.py +153 -0
  59. agentjam/_sentry.py +233 -0
  60. agentjam/_signals.py +98 -0
  61. agentjam/_slack.py +468 -0
  62. agentjam/_stripe.py +93 -0
  63. agentjam/_tasks/__init__.py +0 -0
  64. agentjam/_tasks/access.py +142 -0
  65. agentjam/_tasks/incoming.py +952 -0
  66. agentjam/_tasks/outgoing.py +472 -0
  67. agentjam/_tasks/scheduled.py +206 -0
  68. agentjam/_tasks/serial.py +40 -0
  69. agentjam/_tasks/triggers.py +258 -0
  70. agentjam/_tasks/watches.py +77 -0
  71. agentjam/_tools.py +1035 -0
  72. agentjam/_types.py +965 -0
  73. agentjam/_utils.py +75 -0
  74. agentjam/_verdicts.py +21 -0
  75. agentjam/_watermarks.py +59 -0
  76. agentjam/anthropic.py +442 -0
  77. agentjam/mpp.py +233 -0
  78. agentjam/openai.py +141 -0
  79. agentjam/openai_agents.py +253 -0
  80. agentjam/py.typed +0 -0
  81. agentjam/pydantic_ai.py +301 -0
  82. agentjam/skills.py +69 -0
  83. agentjam-0.1.0.dist-info/METADATA +210 -0
  84. agentjam-0.1.0.dist-info/RECORD +86 -0
  85. agentjam-0.1.0.dist-info/WHEEL +4 -0
  86. agentjam-0.1.0.dist-info/licenses/LICENSE +21 -0
agentjam/__init__.py ADDED
@@ -0,0 +1,435 @@
1
+ """The AgentJam SDK, which connects agents so they can find, message and delegate tasks to each other."""
2
+
3
+ from agentjam._agent import Agent, Connecting, connect
4
+ from agentjam._agent_options import (
5
+ AdapterHandlers,
6
+ AttachedReply,
7
+ ConnectOptions,
8
+ ForwardSettings,
9
+ ReplyOutput,
10
+ )
11
+ from agentjam._artifacts import ArtifactSource, artifact
12
+ from agentjam._attachments import AttachmentSource, attachment
13
+ from agentjam._connections import (
14
+ ConnectionEvent,
15
+ ConnectionGrant,
16
+ ConnectionHolder,
17
+ ConnectionStore,
18
+ CredentialSource,
19
+ OAuthConnection,
20
+ oauth_connection,
21
+ )
22
+ from agentjam._content import Content, ContentSource, LabeledContent
23
+ from agentjam._cron import compute_shortest_interval, is_interval_at_least
24
+ from agentjam._errors import (
25
+ AgentExistsError,
26
+ AgentJamError,
27
+ AgentNotFoundError,
28
+ ConnectionRevokedError,
29
+ DispatchFailedError,
30
+ FollowUpFailedError,
31
+ InstanceTakenError,
32
+ InvalidInputError,
33
+ PaymentRequiredError,
34
+ PaymentRequiredReason,
35
+ ReassignedError,
36
+ RequestRefusedError,
37
+ SkillRequiredError,
38
+ TaskCanceledError,
39
+ TaskCommittedError,
40
+ TaskFailedError,
41
+ TaskRejectedError,
42
+ TimeoutError,
43
+ TriggerFailedError,
44
+ UncoveredCostError,
45
+ )
46
+ from agentjam._events import (
47
+ EventSource,
48
+ ReceivedRequest,
49
+ ReportedEvent,
50
+ RevokedAccount,
51
+ SourceDelivery,
52
+ SourceEvent,
53
+ SourceRequest,
54
+ SourceResponse,
55
+ read_source_request,
56
+ )
57
+ from agentjam._files import File
58
+ from agentjam._github import (
59
+ GitHubIssueAssignedData,
60
+ GitHubMergedPullRequestData,
61
+ GitHubPullRequestData,
62
+ github_triggers,
63
+ github_webhooks,
64
+ )
65
+ from agentjam._profile import AgentHandle, create, update
66
+ from agentjam._protocol import (
67
+ DelegatedTask,
68
+ Envelope,
69
+ EnvelopeDraft,
70
+ LimitCode,
71
+ ParentRef,
72
+ RecappedArtifactRef,
73
+ TaskEndCode,
74
+ TaskRecapRef,
75
+ TaskRef,
76
+ )
77
+ from agentjam._providers import (
78
+ AccountRevocation,
79
+ OAuthClient,
80
+ OAuthEndpoints,
81
+ OAuthProfile,
82
+ ParsedTokens,
83
+ TokenError,
84
+ TokenResponse,
85
+ Tokens,
86
+ construct_standard_profile,
87
+ parse_standard_token,
88
+ )
89
+ from agentjam._relay.base import (
90
+ Connection,
91
+ CredentialChannel,
92
+ Relay,
93
+ SecretGrant,
94
+ SessionEvents,
95
+ SessionOptions,
96
+ )
97
+ from agentjam._relay.endpoints import Endpoints
98
+ from agentjam._relay.memory import MemoryRelay
99
+ from agentjam._relay.payments import Payments
100
+ from agentjam._relay.remote import AgentJamRelay
101
+ from agentjam._relay.schedule_follow_ups import FollowUpCheck, FollowUpJudge
102
+ from agentjam._relay.secrets import SecretStub
103
+ from agentjam._screening import (
104
+ Fit,
105
+ FitSchema,
106
+ Judge,
107
+ ProposalScreen,
108
+ ScreenRequest,
109
+ ScreenSettings,
110
+ construct_screen_request,
111
+ fit_schema,
112
+ parse_fit,
113
+ screen_proposal,
114
+ )
115
+ from agentjam._secrets import secret_connection
116
+ from agentjam._sentry import SentryErrorData, SentryRegion, sentry_triggers
117
+ from agentjam._slack import SlackEvent, slack_events, slack_profile, slack_triggers
118
+ from agentjam._tasks.access import AccessOptions
119
+ from agentjam._tasks.incoming import IncomingTask, TaskOutput, current_task
120
+ from agentjam._tasks.outgoing import OutgoingTask
121
+ from agentjam._tasks.scheduled import Schedule
122
+ from agentjam._tools import NetworkTool, ToolName, ToolResult, network_tool_names
123
+ from agentjam._types import (
124
+ Account,
125
+ ActionRequest,
126
+ ActionsEvent,
127
+ AgentCard,
128
+ AgentQuery,
129
+ AgentRating,
130
+ AllowedRequest,
131
+ Artifact,
132
+ ArtifactEvent,
133
+ Attachment,
134
+ AutoReload,
135
+ AutoReloadSettings,
136
+ Budget,
137
+ CardReload,
138
+ CommitEvent,
139
+ CompletedOutcome,
140
+ ConnectionCard,
141
+ ConnectionFetch,
142
+ ConnectionScopes,
143
+ CostPlusPrice,
144
+ CreditAccount,
145
+ Cron,
146
+ DeclaredConnection,
147
+ Delegate,
148
+ DelegatePicker,
149
+ DeltaEvent,
150
+ DispatchedEvent,
151
+ Dispute,
152
+ DisputeStatus,
153
+ FailedOutcome,
154
+ FileArtifact,
155
+ FlatPrice,
156
+ FollowUp,
157
+ FollowUpCondition,
158
+ HistoryPage,
159
+ HistoryQuery,
160
+ HttpMethod,
161
+ IncomingMessage,
162
+ InputSchema,
163
+ JsonObject,
164
+ JsonSchema,
165
+ Message,
166
+ MessageReply,
167
+ MonthSpent,
168
+ PastTask,
169
+ Period,
170
+ Price,
171
+ ProfileUpdate,
172
+ Proposal,
173
+ ProposalAction,
174
+ RecappedArtifact,
175
+ RecappedFile,
176
+ RecappedText,
177
+ ReloadSource,
178
+ RestartEvent,
179
+ Review,
180
+ ReviewDraft,
181
+ ReviewPage,
182
+ ReviewQuery,
183
+ ScheduleFollowUp,
184
+ SecretConnection,
185
+ SecretField,
186
+ Skill,
187
+ SkillCard,
188
+ SkillConnection,
189
+ SkillHandler,
190
+ StopReason,
191
+ StoredAgent,
192
+ TaskEvent,
193
+ TaskInbox,
194
+ TaskOutcome,
195
+ TaskPage,
196
+ TaskQuery,
197
+ TaskRecap,
198
+ TaskStatus,
199
+ TaskSummary,
200
+ TaskWatch,
201
+ TextArtifact,
202
+ TokenReload,
203
+ Trigger,
204
+ TriggerActivation,
205
+ TriggerCard,
206
+ TriggerChoice,
207
+ TriggerContext,
208
+ TriggerEvent,
209
+ TriggerHandler,
210
+ TriggerSchedule,
211
+ UpdateEvent,
212
+ Verdict,
213
+ Visibility,
214
+ )
215
+ from agentjam._verdicts import accept, reject
216
+ from agentjam._watermarks import MemoryWatermarkStore, WatermarkStore
217
+
218
+ __all__ = [
219
+ "AccessOptions",
220
+ "Account",
221
+ "AccountRevocation",
222
+ "ActionRequest",
223
+ "ActionsEvent",
224
+ "AdapterHandlers",
225
+ "Agent",
226
+ "AgentCard",
227
+ "AgentExistsError",
228
+ "AgentHandle",
229
+ "AgentJamError",
230
+ "AgentJamRelay",
231
+ "AgentNotFoundError",
232
+ "AgentQuery",
233
+ "AgentRating",
234
+ "AllowedRequest",
235
+ "Artifact",
236
+ "ArtifactEvent",
237
+ "ArtifactSource",
238
+ "AttachedReply",
239
+ "Attachment",
240
+ "AttachmentSource",
241
+ "AutoReload",
242
+ "AutoReloadSettings",
243
+ "Budget",
244
+ "CardReload",
245
+ "CommitEvent",
246
+ "CompletedOutcome",
247
+ "ConnectOptions",
248
+ "Connecting",
249
+ "Connection",
250
+ "ConnectionCard",
251
+ "ConnectionEvent",
252
+ "ConnectionFetch",
253
+ "ConnectionGrant",
254
+ "ConnectionHolder",
255
+ "ConnectionRevokedError",
256
+ "ConnectionScopes",
257
+ "ConnectionStore",
258
+ "Content",
259
+ "ContentSource",
260
+ "CostPlusPrice",
261
+ "CredentialChannel",
262
+ "CredentialSource",
263
+ "CreditAccount",
264
+ "Cron",
265
+ "DeclaredConnection",
266
+ "Delegate",
267
+ "DelegatePicker",
268
+ "DelegatedTask",
269
+ "DeltaEvent",
270
+ "DispatchFailedError",
271
+ "DispatchedEvent",
272
+ "Dispute",
273
+ "DisputeStatus",
274
+ "Endpoints",
275
+ "Envelope",
276
+ "EnvelopeDraft",
277
+ "EventSource",
278
+ "FailedOutcome",
279
+ "File",
280
+ "FileArtifact",
281
+ "Fit",
282
+ "FitSchema",
283
+ "FlatPrice",
284
+ "FollowUp",
285
+ "FollowUpCheck",
286
+ "FollowUpCondition",
287
+ "FollowUpFailedError",
288
+ "FollowUpJudge",
289
+ "ForwardSettings",
290
+ "GitHubIssueAssignedData",
291
+ "GitHubMergedPullRequestData",
292
+ "GitHubPullRequestData",
293
+ "HistoryPage",
294
+ "HistoryQuery",
295
+ "HttpMethod",
296
+ "IncomingMessage",
297
+ "IncomingTask",
298
+ "InputSchema",
299
+ "InstanceTakenError",
300
+ "InvalidInputError",
301
+ "JsonObject",
302
+ "JsonSchema",
303
+ "Judge",
304
+ "LabeledContent",
305
+ "LimitCode",
306
+ "MemoryRelay",
307
+ "MemoryWatermarkStore",
308
+ "Message",
309
+ "MessageReply",
310
+ "MonthSpent",
311
+ "NetworkTool",
312
+ "OAuthClient",
313
+ "OAuthConnection",
314
+ "OAuthEndpoints",
315
+ "OAuthProfile",
316
+ "OutgoingTask",
317
+ "ParentRef",
318
+ "ParsedTokens",
319
+ "PastTask",
320
+ "PaymentRequiredError",
321
+ "PaymentRequiredReason",
322
+ "Payments",
323
+ "Period",
324
+ "Price",
325
+ "ProfileUpdate",
326
+ "Proposal",
327
+ "ProposalAction",
328
+ "ProposalScreen",
329
+ "ReassignedError",
330
+ "RecappedArtifact",
331
+ "RecappedArtifactRef",
332
+ "RecappedFile",
333
+ "RecappedText",
334
+ "ReceivedRequest",
335
+ "Relay",
336
+ "ReloadSource",
337
+ "ReplyOutput",
338
+ "ReportedEvent",
339
+ "RequestRefusedError",
340
+ "RestartEvent",
341
+ "Review",
342
+ "ReviewDraft",
343
+ "ReviewPage",
344
+ "ReviewQuery",
345
+ "RevokedAccount",
346
+ "Schedule",
347
+ "ScheduleFollowUp",
348
+ "ScreenRequest",
349
+ "ScreenSettings",
350
+ "SecretConnection",
351
+ "SecretField",
352
+ "SecretGrant",
353
+ "SecretStub",
354
+ "SentryErrorData",
355
+ "SentryRegion",
356
+ "SessionEvents",
357
+ "SessionOptions",
358
+ "Skill",
359
+ "SkillCard",
360
+ "SkillConnection",
361
+ "SkillHandler",
362
+ "SkillRequiredError",
363
+ "SlackEvent",
364
+ "SourceDelivery",
365
+ "SourceEvent",
366
+ "SourceRequest",
367
+ "SourceResponse",
368
+ "StopReason",
369
+ "StoredAgent",
370
+ "TaskCanceledError",
371
+ "TaskCommittedError",
372
+ "TaskEndCode",
373
+ "TaskEvent",
374
+ "TaskFailedError",
375
+ "TaskInbox",
376
+ "TaskOutcome",
377
+ "TaskOutput",
378
+ "TaskPage",
379
+ "TaskQuery",
380
+ "TaskRecap",
381
+ "TaskRecapRef",
382
+ "TaskRef",
383
+ "TaskRejectedError",
384
+ "TaskStatus",
385
+ "TaskSummary",
386
+ "TaskWatch",
387
+ "TextArtifact",
388
+ "TimeoutError",
389
+ "TokenError",
390
+ "TokenReload",
391
+ "TokenResponse",
392
+ "Tokens",
393
+ "ToolName",
394
+ "ToolResult",
395
+ "Trigger",
396
+ "TriggerActivation",
397
+ "TriggerCard",
398
+ "TriggerChoice",
399
+ "TriggerContext",
400
+ "TriggerEvent",
401
+ "TriggerFailedError",
402
+ "TriggerHandler",
403
+ "TriggerSchedule",
404
+ "UncoveredCostError",
405
+ "UpdateEvent",
406
+ "Verdict",
407
+ "Visibility",
408
+ "WatermarkStore",
409
+ "accept",
410
+ "artifact",
411
+ "attachment",
412
+ "compute_shortest_interval",
413
+ "connect",
414
+ "construct_screen_request",
415
+ "construct_standard_profile",
416
+ "create",
417
+ "current_task",
418
+ "fit_schema",
419
+ "github_triggers",
420
+ "github_webhooks",
421
+ "is_interval_at_least",
422
+ "network_tool_names",
423
+ "oauth_connection",
424
+ "parse_fit",
425
+ "parse_standard_token",
426
+ "read_source_request",
427
+ "reject",
428
+ "screen_proposal",
429
+ "secret_connection",
430
+ "sentry_triggers",
431
+ "slack_events",
432
+ "slack_profile",
433
+ "slack_triggers",
434
+ "update",
435
+ ]
File without changes
@@ -0,0 +1,73 @@
1
+ from typing import assert_never
2
+
3
+ from openai.types.responses import EasyInputMessageParam, ResponseInputContentParam
4
+
5
+ from agentjam._adapters.shared import (
6
+ ContentPart,
7
+ DocumentPart,
8
+ ImagePart,
9
+ ModelContent,
10
+ TextPart,
11
+ construct_model_content,
12
+ to_data_url,
13
+ to_history,
14
+ )
15
+ from agentjam._types import IncomingMessage
16
+
17
+
18
+ def to_input_content(part: ContentPart) -> ResponseInputContentParam:
19
+ """Maps a content part to the Responses API input content it stands for.
20
+
21
+ Args:
22
+ part: The part to map.
23
+ Returns:
24
+ The input content.
25
+ """
26
+ match part:
27
+ case TextPart(text=text):
28
+ return {"type": "input_text", "text": text}
29
+
30
+ case ImagePart():
31
+ return {
32
+ "type": "input_image",
33
+ "detail": "auto",
34
+ "image_url": to_data_url(part),
35
+ }
36
+
37
+ case DocumentPart(name=name):
38
+ return {
39
+ "type": "input_file",
40
+ "filename": name,
41
+ "file_data": to_data_url(part),
42
+ }
43
+
44
+ case _:
45
+ assert_never(part)
46
+
47
+
48
+ def construct_input_message(content: ModelContent) -> EasyInputMessageParam:
49
+ """Builds a user message carrying the content's text and files.
50
+
51
+ Args:
52
+ content: The text and converted files.
53
+ Returns:
54
+ The user message.
55
+ """
56
+ text: ResponseInputContentParam = {"type": "input_text", "text": content.text}
57
+
58
+ return {"role": "user", "content": [text, *map(to_input_content, content.files)]}
59
+
60
+
61
+ async def to_input_messages(message: IncomingMessage) -> list[EasyInputMessageParam]:
62
+ """Maps a message and the earlier turns of its conversation to Responses API input messages.
63
+
64
+ Args:
65
+ message: A message received by `on_message`.
66
+ Returns:
67
+ The conversation, oldest turn first.
68
+ """
69
+ history: list[EasyInputMessageParam] = [
70
+ {"role": turn.role, "content": turn.text} for turn in to_history(message)
71
+ ]
72
+
73
+ return [*history, construct_input_message(await construct_model_content(message))]