agents-framework 0.3.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 (50) hide show
  1. agents_framework-0.3.0.dist-info/METADATA +1364 -0
  2. agents_framework-0.3.0.dist-info/RECORD +50 -0
  3. agents_framework-0.3.0.dist-info/WHEEL +5 -0
  4. agents_framework-0.3.0.dist-info/entry_points.txt +2 -0
  5. agents_framework-0.3.0.dist-info/licenses/LICENSE +661 -0
  6. agents_framework-0.3.0.dist-info/top_level.txt +1 -0
  7. framework/__init__.py +0 -0
  8. framework/__main__.py +9 -0
  9. framework/action_page.py +1102 -0
  10. framework/approval_buttons.py +775 -0
  11. framework/approvals.py +678 -0
  12. framework/calendar_card.py +276 -0
  13. framework/cli.py +273 -0
  14. framework/codex_llm.py +401 -0
  15. framework/config.py +126 -0
  16. framework/drafter.py +263 -0
  17. framework/interfaces.py +96 -0
  18. framework/llm.py +744 -0
  19. framework/plugins/__init__.py +147 -0
  20. framework/plugins/agentmail_source.py +355 -0
  21. framework/plugins/approval_destination.py +478 -0
  22. framework/plugins/command_action.py +248 -0
  23. framework/plugins/digest_destination.py +546 -0
  24. framework/plugins/email_destination.py +248 -0
  25. framework/plugins/fanout_destination.py +160 -0
  26. framework/plugins/github_org_source.py +226 -0
  27. framework/plugins/github_releases_source.py +420 -0
  28. framework/plugins/ics_source.py +594 -0
  29. framework/plugins/llm_scorer.py +411 -0
  30. framework/plugins/multi_source.py +241 -0
  31. framework/plugins/reddit_source.py +625 -0
  32. framework/plugins/regex_scorer.py +93 -0
  33. framework/plugins/rss_source.py +346 -0
  34. framework/plugins/signal_destination.py +133 -0
  35. framework/plugins/slack_destination.py +461 -0
  36. framework/plugins/slack_draft_action.py +137 -0
  37. framework/plugins/slack_post_action.py +65 -0
  38. framework/plugins/slack_workspace_source.py +992 -0
  39. framework/plugins/twitter_action.py +210 -0
  40. framework/plugins/websearch_source.py +761 -0
  41. framework/plugins/wordpress_action.py +413 -0
  42. framework/proposals.py +246 -0
  43. framework/registry.py +166 -0
  44. framework/runlog.py +125 -0
  45. framework/runner.py +243 -0
  46. framework/schedule.py +571 -0
  47. framework/signal_messenger.py +1418 -0
  48. framework/slack.py +801 -0
  49. framework/state.py +39 -0
  50. framework/templating.py +76 -0
framework/state.py ADDED
@@ -0,0 +1,39 @@
1
+ """Dedupe/state persistence between run-and-exit invocations.
2
+
3
+ The one thing the framework truly owns between runs: what's already been
4
+ seen/sent, so a double-fire from cron isn't harmful.
5
+
6
+ v1: keep behavior equivalent to hq/leads/signals/signal_processor.py's
7
+ existing dedupe logic (treated as reference, not redesigned yet — see
8
+ tracked issue).
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ from pathlib import Path
14
+
15
+
16
+ class SeenStore:
17
+ """Flat-file set of already-processed signal ids, one file per agent."""
18
+
19
+ def __init__(self, path: Path):
20
+ self.path = path
21
+ self._seen: set[str] = set()
22
+ if self.path.exists():
23
+ self._seen = set(json.loads(self.path.read_text()))
24
+
25
+ def has(self, signal_id: str) -> bool:
26
+ return signal_id in self._seen
27
+
28
+ def mark(self, signal_id: str) -> None:
29
+ self._seen.add(signal_id)
30
+
31
+ def save(self) -> None:
32
+ self.path.parent.mkdir(parents=True, exist_ok=True)
33
+ self.path.write_text(json.dumps(sorted(self._seen)))
34
+
35
+ def __len__(self) -> int:
36
+ # Total dedupe-store size, for the runner's per-run summary line
37
+ # (issue #31) -- lets "seen" grow visibly even on a zero-signal run.
38
+ retval = len(self._seen)
39
+ return retval
@@ -0,0 +1,76 @@
1
+ """`{name}` templating for action steps (issue #21).
2
+
3
+ Later steps of an approved action see the results of earlier ones by name: the
4
+ `agent approvals` pass merges the proposal's payload with each step's returned
5
+ dict and hands the merged mapping to the next step, and a step renders its own
6
+ config strings against it (`"text": "Published: {url}"`).
7
+
8
+ This is `str.format`'s syntax with its field language cut down to plain
9
+ names. `str.format_map` on its own would accept `{value.__class__}` and
10
+ `{value[0]}`, walking attributes and indexes of whatever object a step put in
11
+ the payload, which is how a client or response object's internals end up in a
12
+ Slack post. So every field is parsed first with `string.Formatter().parse()`
13
+ and anything that is not a bare key of the values map is rejected by name,
14
+ before any formatting happens. Format specs (`{items:>4}`) are left alone; they
15
+ format the value, they do not reach into it. A spec can nest a field of its
16
+ own (`{items:>{width}}`), and that nested field goes through the same check.
17
+
18
+ A placeholder with no value is an error naming the placeholder, never an empty
19
+ string: an approved post that went out reading "Published: " is exactly the
20
+ kind of quiet wrongness this repo keeps paying for.
21
+ """
22
+ from __future__ import annotations
23
+
24
+ import string
25
+ from typing import Any
26
+
27
+
28
+ class TemplateError(ValueError):
29
+ """A template is malformed, reaches into a value, or names a missing one."""
30
+
31
+
32
+ def _fields(template: str, text: str | None = None) -> list[str]:
33
+ """Plain field names in `text` (default: `template`), specs included.
34
+
35
+ A format spec may itself hold a replacement field (`{a:{width}}`), which
36
+ `format_map` resolves like any other, so the spec is parsed the same way:
37
+ `{a:{b.__class__}}` must be refused exactly as `{b.__class__}` is.
38
+ `template` is the whole string, for error messages.
39
+ """
40
+ if text is None:
41
+ text = template
42
+ try:
43
+ parsed = list(string.Formatter().parse(text))
44
+ except ValueError as exc:
45
+ raise TemplateError(f"template {template!r} is malformed: {exc}") from exc
46
+ retval = []
47
+ for _literal, field_name, spec, _conversion in parsed:
48
+ if field_name is None:
49
+ continue
50
+ if field_name == "" or field_name.isdigit():
51
+ raise TemplateError(
52
+ f"template {template!r}: positional field {{{field_name}}} is not allowed; "
53
+ "use a name"
54
+ )
55
+ if "." in field_name or "[" in field_name:
56
+ raise TemplateError(
57
+ f"template {template!r}: field {{{field_name}}} reaches into a value; "
58
+ "only plain names are allowed"
59
+ )
60
+ retval.append(field_name)
61
+ if spec:
62
+ retval.extend(_fields(template, spec))
63
+ return retval
64
+
65
+
66
+ def render_template(template: str, values: dict[str, Any]) -> str:
67
+ """Render `template` against `values`; a missing placeholder raises."""
68
+ text = str(template)
69
+ for name in _fields(text):
70
+ if name not in values:
71
+ raise TemplateError(f"template placeholder {{{name}}} has no value")
72
+ try:
73
+ retval = text.format_map(values)
74
+ except ValueError as exc:
75
+ raise TemplateError(f"template {text!r} is malformed: {exc}") from exc
76
+ return retval