sentienceapi 0.90.17__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.

Potentially problematic release.


This version of sentienceapi might be problematic. Click here for more details.

Files changed (50) hide show
  1. sentience/__init__.py +153 -0
  2. sentience/_extension_loader.py +40 -0
  3. sentience/actions.py +837 -0
  4. sentience/agent.py +1246 -0
  5. sentience/agent_config.py +43 -0
  6. sentience/async_api.py +101 -0
  7. sentience/base_agent.py +194 -0
  8. sentience/browser.py +1037 -0
  9. sentience/cli.py +130 -0
  10. sentience/cloud_tracing.py +382 -0
  11. sentience/conversational_agent.py +509 -0
  12. sentience/expect.py +188 -0
  13. sentience/extension/background.js +233 -0
  14. sentience/extension/content.js +298 -0
  15. sentience/extension/injected_api.js +1473 -0
  16. sentience/extension/manifest.json +36 -0
  17. sentience/extension/pkg/sentience_core.d.ts +51 -0
  18. sentience/extension/pkg/sentience_core.js +529 -0
  19. sentience/extension/pkg/sentience_core_bg.wasm +0 -0
  20. sentience/extension/pkg/sentience_core_bg.wasm.d.ts +10 -0
  21. sentience/extension/release.json +115 -0
  22. sentience/extension/test-content.js +4 -0
  23. sentience/formatting.py +59 -0
  24. sentience/generator.py +202 -0
  25. sentience/inspector.py +365 -0
  26. sentience/llm_provider.py +637 -0
  27. sentience/models.py +412 -0
  28. sentience/overlay.py +222 -0
  29. sentience/query.py +303 -0
  30. sentience/read.py +185 -0
  31. sentience/recorder.py +589 -0
  32. sentience/schemas/trace_v1.json +216 -0
  33. sentience/screenshot.py +100 -0
  34. sentience/snapshot.py +516 -0
  35. sentience/text_search.py +290 -0
  36. sentience/trace_indexing/__init__.py +27 -0
  37. sentience/trace_indexing/index_schema.py +111 -0
  38. sentience/trace_indexing/indexer.py +357 -0
  39. sentience/tracer_factory.py +211 -0
  40. sentience/tracing.py +285 -0
  41. sentience/utils.py +296 -0
  42. sentience/wait.py +137 -0
  43. sentienceapi-0.90.17.dist-info/METADATA +917 -0
  44. sentienceapi-0.90.17.dist-info/RECORD +50 -0
  45. sentienceapi-0.90.17.dist-info/WHEEL +5 -0
  46. sentienceapi-0.90.17.dist-info/entry_points.txt +2 -0
  47. sentienceapi-0.90.17.dist-info/licenses/LICENSE +24 -0
  48. sentienceapi-0.90.17.dist-info/licenses/LICENSE-APACHE +201 -0
  49. sentienceapi-0.90.17.dist-info/licenses/LICENSE-MIT +21 -0
  50. sentienceapi-0.90.17.dist-info/top_level.txt +1 -0
sentience/__init__.py ADDED
@@ -0,0 +1,153 @@
1
+ """
2
+ Sentience Python SDK - AI Agent Browser Automation
3
+ """
4
+
5
+ from .actions import click, click_rect, press, type_text
6
+ from .agent import SentienceAgent
7
+ from .agent_config import AgentConfig
8
+
9
+ # Agent Layer (Phase 1 & 2)
10
+ from .base_agent import BaseAgent
11
+ from .browser import SentienceBrowser
12
+
13
+ # Tracing (v0.12.0+)
14
+ from .cloud_tracing import CloudTraceSink, SentienceLogger
15
+ from .conversational_agent import ConversationalAgent
16
+ from .expect import expect
17
+
18
+ # Formatting (v0.12.0+)
19
+ from .formatting import format_snapshot_for_llm
20
+ from .generator import ScriptGenerator, generate
21
+ from .inspector import Inspector, inspect
22
+ from .llm_provider import (
23
+ AnthropicProvider,
24
+ LLMProvider,
25
+ LLMResponse,
26
+ LocalLLMProvider,
27
+ OpenAIProvider,
28
+ )
29
+ from .models import ( # Agent Layer Models
30
+ ActionHistory,
31
+ ActionResult,
32
+ ActionTokenUsage,
33
+ AgentActionResult,
34
+ BBox,
35
+ Cookie,
36
+ Element,
37
+ LocalStorageItem,
38
+ OriginStorage,
39
+ ScreenshotConfig,
40
+ Snapshot,
41
+ SnapshotFilter,
42
+ SnapshotOptions,
43
+ StorageState,
44
+ TextContext,
45
+ TextMatch,
46
+ TextRect,
47
+ TextRectSearchResult,
48
+ TokenStats,
49
+ Viewport,
50
+ ViewportRect,
51
+ WaitResult,
52
+ )
53
+ from .overlay import clear_overlay, show_overlay
54
+ from .query import find, query
55
+ from .read import read
56
+ from .recorder import Recorder, Trace, TraceStep, record
57
+ from .screenshot import screenshot
58
+ from .snapshot import snapshot
59
+ from .text_search import find_text_rect
60
+ from .tracer_factory import SENTIENCE_API_URL, create_tracer
61
+ from .tracing import JsonlTraceSink, TraceEvent, Tracer, TraceSink
62
+
63
+ # Utilities (v0.12.0+)
64
+ from .utils import (
65
+ canonical_snapshot_loose,
66
+ canonical_snapshot_strict,
67
+ compute_snapshot_digests,
68
+ save_storage_state,
69
+ sha256_digest,
70
+ )
71
+ from .wait import wait_for
72
+
73
+ __version__ = "0.90.17"
74
+
75
+ __all__ = [
76
+ # Core SDK
77
+ "SentienceBrowser",
78
+ "Snapshot",
79
+ "Element",
80
+ "BBox",
81
+ "Viewport",
82
+ "ActionResult",
83
+ "WaitResult",
84
+ "snapshot",
85
+ "query",
86
+ "find",
87
+ "click",
88
+ "type_text",
89
+ "press",
90
+ "click_rect",
91
+ "wait_for",
92
+ "expect",
93
+ "Inspector",
94
+ "inspect",
95
+ "Recorder",
96
+ "Trace",
97
+ "TraceStep",
98
+ "record",
99
+ "ScriptGenerator",
100
+ "generate",
101
+ "read",
102
+ "screenshot",
103
+ "show_overlay",
104
+ "clear_overlay",
105
+ # Text Search
106
+ "find_text_rect",
107
+ "TextRectSearchResult",
108
+ "TextMatch",
109
+ "TextRect",
110
+ "ViewportRect",
111
+ "TextContext",
112
+ # Agent Layer (Phase 1 & 2)
113
+ "BaseAgent",
114
+ "LLMProvider",
115
+ "LLMResponse",
116
+ "OpenAIProvider",
117
+ "AnthropicProvider",
118
+ "LocalLLMProvider",
119
+ "SentienceAgent",
120
+ "ConversationalAgent",
121
+ # Agent Layer Models
122
+ "AgentActionResult",
123
+ "TokenStats",
124
+ "ActionHistory",
125
+ "ActionTokenUsage",
126
+ "SnapshotOptions",
127
+ "SnapshotFilter",
128
+ "ScreenshotConfig",
129
+ # Storage State Models (Auth Injection)
130
+ "StorageState",
131
+ "Cookie",
132
+ "LocalStorageItem",
133
+ "OriginStorage",
134
+ # Tracing (v0.12.0+)
135
+ "Tracer",
136
+ "TraceSink",
137
+ "JsonlTraceSink",
138
+ "CloudTraceSink",
139
+ "SentienceLogger",
140
+ "TraceEvent",
141
+ "create_tracer",
142
+ "SENTIENCE_API_URL",
143
+ # Utilities (v0.12.0+)
144
+ "canonical_snapshot_strict",
145
+ "canonical_snapshot_loose",
146
+ "compute_snapshot_digests",
147
+ "sha256_digest",
148
+ "save_storage_state",
149
+ # Formatting (v0.12.0+)
150
+ "format_snapshot_for_llm",
151
+ # Agent Config (v0.12.0+)
152
+ "AgentConfig",
153
+ ]
@@ -0,0 +1,40 @@
1
+ """
2
+ Shared extension loading logic for sync and async implementations
3
+ """
4
+
5
+ from pathlib import Path
6
+
7
+
8
+ def find_extension_path() -> Path:
9
+ """
10
+ Find Sentience extension directory (shared logic for sync and async).
11
+
12
+ Checks multiple locations:
13
+ 1. sentience/extension/ (installed package)
14
+ 2. ../sentience-chrome (development/monorepo)
15
+
16
+ Returns:
17
+ Path to extension directory
18
+
19
+ Raises:
20
+ FileNotFoundError: If extension not found in any location
21
+ """
22
+ # 1. Try relative to this file (installed package structure)
23
+ # sentience/_extension_loader.py -> sentience/extension/
24
+ package_ext_path = Path(__file__).parent / "extension"
25
+
26
+ # 2. Try development root (if running from source repo)
27
+ # sentience/_extension_loader.py -> ../sentience-chrome
28
+ dev_ext_path = Path(__file__).parent.parent.parent / "sentience-chrome"
29
+
30
+ if package_ext_path.exists() and (package_ext_path / "manifest.json").exists():
31
+ return package_ext_path
32
+ elif dev_ext_path.exists() and (dev_ext_path / "manifest.json").exists():
33
+ return dev_ext_path
34
+ else:
35
+ raise FileNotFoundError(
36
+ f"Extension not found. Checked:\n"
37
+ f"1. {package_ext_path}\n"
38
+ f"2. {dev_ext_path}\n"
39
+ "Make sure the extension is built and 'sentience/extension' directory exists."
40
+ )