intended 0.2.0__tar.gz

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.
@@ -0,0 +1,116 @@
1
+ # Dependencies
2
+ node_modules/
3
+ .pnpm-store/
4
+
5
+ # Build outputs
6
+ dist/
7
+ .next/
8
+ .turbo/
9
+ out/
10
+
11
+ # Environment
12
+ .env
13
+ .env.local
14
+ .env.*.local
15
+
16
+ # IDE
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+ *.swo
21
+ *~
22
+
23
+ # OS
24
+ .DS_Store
25
+ Thumbs.db
26
+
27
+ # Test & Coverage
28
+ coverage/
29
+ *.lcov
30
+ .venv/
31
+ playwright-report/
32
+ test-results/
33
+ blob-report/
34
+ .playwright/
35
+
36
+ # LaTeX build artifacts (docs/papers/)
37
+ docs/papers/*.aux
38
+ docs/papers/*.log
39
+ docs/papers/*.out
40
+ docs/papers/*.toc
41
+ docs/papers/*.fdb_latexmk
42
+ docs/papers/*.fls
43
+ docs/papers/*.synctex.gz
44
+
45
+ # Prisma
46
+ packages/db/prisma/migrations/**/migration_lock.toml
47
+
48
+ # Docker volumes
49
+ postgres_data/
50
+ redis_data/
51
+
52
+ # Local dev databases (repo root data/)
53
+ data/*.db
54
+
55
+ # Logs
56
+ *.log
57
+ npm-debug.log*
58
+ pnpm-debug.log*
59
+ *.db-shm
60
+ *.db-wal
61
+ __pycache__/
62
+ *.pyc
63
+
64
+ # Generated
65
+ proto/gen/ts/
66
+ proto/gen/go/
67
+
68
+ # Secrets (NEVER commit these)
69
+ *.pem
70
+ *.key
71
+ *.cert
72
+ credentials.json
73
+ service-account.json
74
+
75
+ # Exempt: pinned test keypair for the intended-verifier crate.
76
+ # Never used in production — the JWKS endpoint generates fresh keys.
77
+ !crates/intended-verifier/tests/fixtures/*.pem
78
+
79
+ # Proprietary LIM Knowledge Assets (NEVER commit unencrypted)
80
+ # These are INTENDED's competitive moat: intent taxonomy, domain models,
81
+ # risk ontologies, and evaluation datasets. Ship as encrypted bundles only.
82
+ # See packages/domain-lim-packs/README.md.
83
+ packages/intelligence-engine/semantic/intent-library.json
84
+ packages/intelligence-engine/semantic/intent-ontology.md
85
+ packages/intelligence-engine/semantic/action-ontology.json
86
+ packages/intelligence-engine/semantic/entity-ontology.json
87
+ packages/intelligence-engine/semantic/lim-gold-dataset.json
88
+ tools/golden-datasets/
89
+
90
+ # Encrypted pack build output (ships as release artifact, not in git)
91
+ packages/domain-lim-packs/dist/
92
+
93
+ # Stale build artifacts
94
+ apps/console/.next.stale.*
95
+ apps/console/.next.broken-*
96
+ apps/console/.next.bak.*
97
+
98
+ # Local archive for legacy docs/reports (not tracked)
99
+ archive/**
100
+ !archive/README.md
101
+
102
+ # Terraform local state and secrets
103
+ .terraform/
104
+ **/.terraform-build/
105
+ *.tfstate
106
+ *.tfstate.*
107
+ terraform.tfvars
108
+ *.auto.tfvars
109
+ tfplan
110
+ tfplan.*
111
+ tfplan-*
112
+ crash.log
113
+ .vercel
114
+ **/.vercel
115
+ .worktrees/
116
+ *.tsbuildinfo
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.4
2
+ Name: intended
3
+ Version: 0.2.0
4
+ Summary: Python SDK for Intended — The Authority Runtime for AI Agents (incl. physical-AI helpers)
5
+ Project-URL: Homepage, https://intended.so
6
+ Project-URL: Documentation, https://intended.so/developers/docs
7
+ Project-URL: Repository, https://github.com/intended-so/intended-python
8
+ License-Expression: Apache-2.0
9
+ Requires-Python: >=3.9
10
+ Requires-Dist: httpx>=0.24
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=8; extra == 'dev'
13
+ Description-Content-Type: text/markdown
14
+
15
+ # intended
16
+
17
+ Python SDK for Intended — the intent verification runtime for autonomous agents.
18
+
19
+ Evaluate every AI agent action against your organization's policies before execution. Fail-closed by default: if the authority service is unreachable, all actions are denied.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install intended
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ### Synchronous
30
+
31
+ ```python
32
+ from intended import IntendedClient
33
+
34
+ client = IntendedSdk(api_key="intended_live_...", tenant_id="tenant-a")
35
+
36
+ decision = client.authorize("deploy to production", actor="ci-agent", system="github")
37
+
38
+ if decision.allowed:
39
+ print(f"Approved — token: {decision.token}")
40
+ elif decision.escalated:
41
+ print(f"Awaiting human approval: {decision.escalation_id}")
42
+ else:
43
+ print(f"Denied: {decision.reason}")
44
+ ```
45
+
46
+ ### Asynchronous
47
+
48
+ ```python
49
+ from intended.client import AsyncIntendedClient
50
+
51
+ async with AsyncIntendedClient(api_key="intended_live_...", tenant_id="tenant-a") as client:
52
+ decision = await client.authorize("scale cluster to 100 nodes", actor="auto-scaler")
53
+ if decision.allowed:
54
+ await scale_cluster(100)
55
+ ```
56
+
57
+ ## MCP Integration
58
+
59
+ Wrap any MCP tool function with Intended authority checks:
60
+
61
+ ```python
62
+ from intended.mcp import IntendedMCPMiddleware
63
+
64
+ middleware = IntendedMCPMiddleware(api_key="intended_live_...", tenant_id="tenant-a")
65
+
66
+ @middleware.protect
67
+ def execute_sql(query: str) -> str:
68
+ # Only runs if Intended approves
69
+ return db.execute(query)
70
+
71
+ # Or check manually
72
+ decision = middleware.check("execute_sql", {"query": "DROP TABLE users"})
73
+ print(decision.decision) # "DENY"
74
+ ```
75
+
76
+ ## LangChain Integration
77
+
78
+ Guard any LangChain tool with Intended:
79
+
80
+ ```python
81
+ from intended.langchain import IntendedToolGuard
82
+ from langchain.tools import ShellTool
83
+
84
+ guard = IntendedToolGuard(api_key="intended_live_...", tenant_id="tenant-a")
85
+
86
+ shell = ShellTool()
87
+ safe_shell = guard.wrap(shell)
88
+
89
+ # Now shell.run() checks with INTENDED before executing
90
+ agent = create_react_agent(llm, tools=[safe_shell])
91
+ ```
92
+
93
+ ## PydanticAI Integration
94
+
95
+ Use as a decorator on PydanticAI tool functions:
96
+
97
+ ```python
98
+ from intended.pydantic_ai import IntendedPydanticGuard
99
+ from pydantic_ai import Agent
100
+
101
+ guard = IntendedPydanticGuard(api_key="intended_live_...", tenant_id="tenant-a")
102
+
103
+ agent = Agent('openai:gpt-4o')
104
+
105
+ @agent.tool
106
+ @guard.protect
107
+ async def deploy(env: str) -> str:
108
+ return f"Deployed to {env}"
109
+ ```
110
+
111
+ ## AuthorityDecision
112
+
113
+ Every call to `authorize()` returns an `AuthorityDecision`:
114
+
115
+ | Field | Type | Description |
116
+ |---|---|---|
117
+ | `decision` | `str` | `"ALLOW"`, `"DENY"`, or `"ESCALATE"` |
118
+ | `intent_id` | `str` | Unique ID of the evaluated intent |
119
+ | `risk_score` | `int` | 0-100 risk assessment |
120
+ | `confidence` | `float` | Confidence in the risk assessment |
121
+ | `reason` | `str` | Human-readable explanation |
122
+ | `token` | `str \| None` | Authority token for approved actions |
123
+ | `escalation_id` | `str \| None` | ID for tracking escalated actions |
124
+
125
+ Convenience properties: `decision.allowed`, `decision.denied`, `decision.escalated`.
126
+
127
+ ## Business Intent APIs
128
+
129
+ The Python SDK also exposes the business-intent compiler and runtime feedback surfaces:
130
+
131
+ ```python
132
+ from intended import IntendedClient
133
+
134
+ client = IntendedSdk(api_key="intended_live_...", tenant_id="tenant-a", api_url="http://localhost:3101")
135
+
136
+ compiled = client.compile_business_intent_and_plan(
137
+ "Shift the nightly ETL window to 3am",
138
+ workflow_family="enterprise-operations",
139
+ target_system="airflow",
140
+ metadata={"environment": "production"},
141
+ )
142
+
143
+ print(compiled["prediction"]["canonicalIntent"])
144
+ print(compiled["intentObject"]["process"]["stages"])
145
+
146
+ object_evals = client.get_business_intent_object_evals()
147
+ print(object_evals["report"]["summary"]["passedCases"])
148
+
149
+ feedback = client.capture_business_intent_feedback(
150
+ input_text="Shift the nightly ETL window to 3am",
151
+ predicted_intent="ops.batch.schedule",
152
+ workflow_family="enterprise-operations",
153
+ outcome="accepted",
154
+ confidence=0.93,
155
+ target_system="airflow",
156
+ execution_status="succeeded",
157
+ verification_status="verified",
158
+ )
159
+
160
+ evals = client.get_business_intent_feedback_evals(workflow_family="enterprise-operations")
161
+ print(evals["evals"]["verification"]["verificationRate"])
162
+
163
+ summary = client.get_business_intent_feedback_summary(workflow_family="enterprise-operations")
164
+ print(summary["summary"]["approvalPredictionHits"])
165
+
166
+ report = client.get_business_intent_feedback_report(workflow_family="enterprise-operations")
167
+ print(report["report"]["metadataDrift"])
168
+ ```
169
+
170
+ Available helper methods:
171
+ - `compile_business_intent()`
172
+ - `compile_business_intent_and_plan()`
173
+ - `capture_business_intent_feedback()`
174
+ - `get_business_intent_object_evals()`
175
+ - `get_business_intent_feedback_summary()`
176
+ - `get_business_intent_feedback_report()`
177
+ - `get_business_intent_feedback_evals()`
178
+ - `get_business_intent_feedback_backlog()`
179
+ - `review_business_intent_feedback()`
180
+ - `promote_business_intent_feedback()`
181
+
182
+ Example review and promote flow:
183
+
184
+ ```python
185
+ backlog = client.get_business_intent_feedback_backlog(workflow_family="enterprise-operations")
186
+
187
+ for record in backlog["backlog"]:
188
+ client.review_business_intent_feedback(record["id"], "approved")
189
+
190
+ promotion = client.promote_business_intent_feedback("enterprise-operations")
191
+ print(promotion["snapshotVersion"])
192
+ print(promotion["snapshotPath"])
193
+ ```
194
+
195
+ ## Fail-Closed Behavior
196
+
197
+ If the INTENDED API is unreachable or returns an error, the SDK returns a DENY decision with `risk_score=100` and `confidence=0`. This ensures that network issues or misconfigurations never result in unauthorized actions.
198
+
199
+ ## License
200
+
201
+ Apache-2.0
@@ -0,0 +1,187 @@
1
+ # intended
2
+
3
+ Python SDK for Intended — the intent verification runtime for autonomous agents.
4
+
5
+ Evaluate every AI agent action against your organization's policies before execution. Fail-closed by default: if the authority service is unreachable, all actions are denied.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install intended
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### Synchronous
16
+
17
+ ```python
18
+ from intended import IntendedClient
19
+
20
+ client = IntendedSdk(api_key="intended_live_...", tenant_id="tenant-a")
21
+
22
+ decision = client.authorize("deploy to production", actor="ci-agent", system="github")
23
+
24
+ if decision.allowed:
25
+ print(f"Approved — token: {decision.token}")
26
+ elif decision.escalated:
27
+ print(f"Awaiting human approval: {decision.escalation_id}")
28
+ else:
29
+ print(f"Denied: {decision.reason}")
30
+ ```
31
+
32
+ ### Asynchronous
33
+
34
+ ```python
35
+ from intended.client import AsyncIntendedClient
36
+
37
+ async with AsyncIntendedClient(api_key="intended_live_...", tenant_id="tenant-a") as client:
38
+ decision = await client.authorize("scale cluster to 100 nodes", actor="auto-scaler")
39
+ if decision.allowed:
40
+ await scale_cluster(100)
41
+ ```
42
+
43
+ ## MCP Integration
44
+
45
+ Wrap any MCP tool function with Intended authority checks:
46
+
47
+ ```python
48
+ from intended.mcp import IntendedMCPMiddleware
49
+
50
+ middleware = IntendedMCPMiddleware(api_key="intended_live_...", tenant_id="tenant-a")
51
+
52
+ @middleware.protect
53
+ def execute_sql(query: str) -> str:
54
+ # Only runs if Intended approves
55
+ return db.execute(query)
56
+
57
+ # Or check manually
58
+ decision = middleware.check("execute_sql", {"query": "DROP TABLE users"})
59
+ print(decision.decision) # "DENY"
60
+ ```
61
+
62
+ ## LangChain Integration
63
+
64
+ Guard any LangChain tool with Intended:
65
+
66
+ ```python
67
+ from intended.langchain import IntendedToolGuard
68
+ from langchain.tools import ShellTool
69
+
70
+ guard = IntendedToolGuard(api_key="intended_live_...", tenant_id="tenant-a")
71
+
72
+ shell = ShellTool()
73
+ safe_shell = guard.wrap(shell)
74
+
75
+ # Now shell.run() checks with INTENDED before executing
76
+ agent = create_react_agent(llm, tools=[safe_shell])
77
+ ```
78
+
79
+ ## PydanticAI Integration
80
+
81
+ Use as a decorator on PydanticAI tool functions:
82
+
83
+ ```python
84
+ from intended.pydantic_ai import IntendedPydanticGuard
85
+ from pydantic_ai import Agent
86
+
87
+ guard = IntendedPydanticGuard(api_key="intended_live_...", tenant_id="tenant-a")
88
+
89
+ agent = Agent('openai:gpt-4o')
90
+
91
+ @agent.tool
92
+ @guard.protect
93
+ async def deploy(env: str) -> str:
94
+ return f"Deployed to {env}"
95
+ ```
96
+
97
+ ## AuthorityDecision
98
+
99
+ Every call to `authorize()` returns an `AuthorityDecision`:
100
+
101
+ | Field | Type | Description |
102
+ |---|---|---|
103
+ | `decision` | `str` | `"ALLOW"`, `"DENY"`, or `"ESCALATE"` |
104
+ | `intent_id` | `str` | Unique ID of the evaluated intent |
105
+ | `risk_score` | `int` | 0-100 risk assessment |
106
+ | `confidence` | `float` | Confidence in the risk assessment |
107
+ | `reason` | `str` | Human-readable explanation |
108
+ | `token` | `str \| None` | Authority token for approved actions |
109
+ | `escalation_id` | `str \| None` | ID for tracking escalated actions |
110
+
111
+ Convenience properties: `decision.allowed`, `decision.denied`, `decision.escalated`.
112
+
113
+ ## Business Intent APIs
114
+
115
+ The Python SDK also exposes the business-intent compiler and runtime feedback surfaces:
116
+
117
+ ```python
118
+ from intended import IntendedClient
119
+
120
+ client = IntendedSdk(api_key="intended_live_...", tenant_id="tenant-a", api_url="http://localhost:3101")
121
+
122
+ compiled = client.compile_business_intent_and_plan(
123
+ "Shift the nightly ETL window to 3am",
124
+ workflow_family="enterprise-operations",
125
+ target_system="airflow",
126
+ metadata={"environment": "production"},
127
+ )
128
+
129
+ print(compiled["prediction"]["canonicalIntent"])
130
+ print(compiled["intentObject"]["process"]["stages"])
131
+
132
+ object_evals = client.get_business_intent_object_evals()
133
+ print(object_evals["report"]["summary"]["passedCases"])
134
+
135
+ feedback = client.capture_business_intent_feedback(
136
+ input_text="Shift the nightly ETL window to 3am",
137
+ predicted_intent="ops.batch.schedule",
138
+ workflow_family="enterprise-operations",
139
+ outcome="accepted",
140
+ confidence=0.93,
141
+ target_system="airflow",
142
+ execution_status="succeeded",
143
+ verification_status="verified",
144
+ )
145
+
146
+ evals = client.get_business_intent_feedback_evals(workflow_family="enterprise-operations")
147
+ print(evals["evals"]["verification"]["verificationRate"])
148
+
149
+ summary = client.get_business_intent_feedback_summary(workflow_family="enterprise-operations")
150
+ print(summary["summary"]["approvalPredictionHits"])
151
+
152
+ report = client.get_business_intent_feedback_report(workflow_family="enterprise-operations")
153
+ print(report["report"]["metadataDrift"])
154
+ ```
155
+
156
+ Available helper methods:
157
+ - `compile_business_intent()`
158
+ - `compile_business_intent_and_plan()`
159
+ - `capture_business_intent_feedback()`
160
+ - `get_business_intent_object_evals()`
161
+ - `get_business_intent_feedback_summary()`
162
+ - `get_business_intent_feedback_report()`
163
+ - `get_business_intent_feedback_evals()`
164
+ - `get_business_intent_feedback_backlog()`
165
+ - `review_business_intent_feedback()`
166
+ - `promote_business_intent_feedback()`
167
+
168
+ Example review and promote flow:
169
+
170
+ ```python
171
+ backlog = client.get_business_intent_feedback_backlog(workflow_family="enterprise-operations")
172
+
173
+ for record in backlog["backlog"]:
174
+ client.review_business_intent_feedback(record["id"], "approved")
175
+
176
+ promotion = client.promote_business_intent_feedback("enterprise-operations")
177
+ print(promotion["snapshotVersion"])
178
+ print(promotion["snapshotPath"])
179
+ ```
180
+
181
+ ## Fail-Closed Behavior
182
+
183
+ If the INTENDED API is unreachable or returns an error, the SDK returns a DENY decision with `risk_score=100` and `confidence=0`. This ensures that network issues or misconfigurations never result in unauthorized actions.
184
+
185
+ ## License
186
+
187
+ Apache-2.0
@@ -0,0 +1,31 @@
1
+ from .client import AsyncIntendedClient, AuthorityDecision, IntendedSdk
2
+ from .mcp import IntendedMCPMiddleware
3
+ from .openai_agents import IntendedOpenAIGuard
4
+ from .physical import (
5
+ ClassifyStructuredGoalResult,
6
+ IntendedPhysicalClient,
7
+ PhysicalDagNode,
8
+ PhysicalSdkConfig,
9
+ PhysicalStateProvider,
10
+ PhysicalStateValue,
11
+ StructuredGoal,
12
+ create_physical_client,
13
+ )
14
+
15
+ __version__ = "0.2.0"
16
+ __all__ = [
17
+ "IntendedSdk",
18
+ "AsyncIntendedClient",
19
+ "AuthorityDecision",
20
+ "IntendedMCPMiddleware",
21
+ "IntendedOpenAIGuard",
22
+ # Physical-AI helpers (SDK-P3)
23
+ "IntendedPhysicalClient",
24
+ "PhysicalSdkConfig",
25
+ "StructuredGoal",
26
+ "ClassifyStructuredGoalResult",
27
+ "PhysicalStateValue",
28
+ "PhysicalStateProvider",
29
+ "PhysicalDagNode",
30
+ "create_physical_client",
31
+ ]