agent-work-layer 0.4.0__tar.gz → 0.5.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.
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/PKG-INFO +2 -1
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/README.md +1 -0
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/pyproject.toml +1 -1
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/src/agent_work_layer/__init__.py +4 -2
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/src/agent_work_layer/models.py +13 -2
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/src/agent_work_layer/validate.py +22 -0
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/.gitignore +0 -0
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/src/agent_work_layer/py.typed +0 -0
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/src/agent_work_layer/schemas/work-order.schema.json +0 -0
- {agent_work_layer-0.4.0 → agent_work_layer-0.5.0}/src/agent_work_layer/schemas/work-report.schema.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agent-work-layer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Work Orders and Work Reports for AI agents: Pydantic models and the spec's validation rules.
|
|
5
5
|
Project-URL: Homepage, https://github.com/probita-ai/agent-work-layer/tree/main/python#readme
|
|
6
6
|
Project-URL: Repository, https://github.com/probita-ai/agent-work-layer
|
|
@@ -73,6 +73,7 @@ if has_invalid(findings):
|
|
|
73
73
|
| `validate_child_budgets(child, parent, siblings)` | C4: a parent's sub-orders together stay within its budget. `siblings` are `{"order": ..., "state": ...}` |
|
|
74
74
|
| `is_work_order(value)`, `is_work_report(value)` | Structure only (O1, R1) |
|
|
75
75
|
| `tool_allowed(tool, patterns)`, `pattern_covered(child, parents)` | Tool pattern matching (`server/tool`, `server/*`, `*`) |
|
|
76
|
+
| `order_spec_for(order)`, `report_spec_for(report)` | The lowest version that has every field a document uses; the models' default `spec` |
|
|
76
77
|
| `effect_references(arguments)` | References to earlier effects' results in an effect's arguments, each `{"ref", "pointer", "path"}` |
|
|
77
78
|
|
|
78
79
|
The JSON Schemas are available as `work_order_schema` and `work_report_schema`.
|
|
@@ -52,6 +52,7 @@ if has_invalid(findings):
|
|
|
52
52
|
| `validate_child_budgets(child, parent, siblings)` | C4: a parent's sub-orders together stay within its budget. `siblings` are `{"order": ..., "state": ...}` |
|
|
53
53
|
| `is_work_order(value)`, `is_work_report(value)` | Structure only (O1, R1) |
|
|
54
54
|
| `tool_allowed(tool, patterns)`, `pattern_covered(child, parents)` | Tool pattern matching (`server/tool`, `server/*`, `*`) |
|
|
55
|
+
| `order_spec_for(order)`, `report_spec_for(report)` | The lowest version that has every field a document uses; the models' default `spec` |
|
|
55
56
|
| `effect_references(arguments)` | References to earlier effects' results in an effect's arguments, each `{"ref", "pointer", "path"}` |
|
|
56
57
|
|
|
57
58
|
The JSON Schemas are available as `work_order_schema` and `work_report_schema`.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agent-work-layer"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
description = "Work Orders and Work Reports for AI agents: Pydantic models and the spec's validation rules."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -24,6 +24,8 @@ from .validate import (
|
|
|
24
24
|
UNITS,
|
|
25
25
|
Finding,
|
|
26
26
|
effect_references,
|
|
27
|
+
order_spec_for,
|
|
28
|
+
report_spec_for,
|
|
27
29
|
has_invalid,
|
|
28
30
|
held_by_sub_orders,
|
|
29
31
|
is_work_order,
|
|
@@ -39,13 +41,13 @@ from .validate import (
|
|
|
39
41
|
work_report_schema,
|
|
40
42
|
)
|
|
41
43
|
|
|
42
|
-
__version__ = "0.
|
|
44
|
+
__version__ = "0.5.0"
|
|
43
45
|
|
|
44
46
|
__all__ = [
|
|
45
47
|
"Amounts", "Artifact", "Attempt", "ContextRef", "Criterion", "Decision", "Effect", "Evidence", "Handoff",
|
|
46
48
|
"WorkOrder", "WorkReport", "WorkResult",
|
|
47
49
|
"ORDER_SPEC", "ORDER_SPECS", "REPORT_SPEC", "REPORT_SPECS", "UNITS", "Finding",
|
|
48
|
-
"effect_references", "has_invalid", "held_by_sub_orders", "is_work_order", "is_work_report", "pattern_covered", "tool_allowed",
|
|
50
|
+
"effect_references", "order_spec_for", "report_spec_for", "has_invalid", "held_by_sub_orders", "is_work_order", "is_work_report", "pattern_covered", "tool_allowed",
|
|
49
51
|
"validate_child_budgets", "validate_child_order", "validate_order", "validate_own_cost", "validate_report",
|
|
50
52
|
"work_order_schema", "work_report_schema",
|
|
51
53
|
"__version__",
|
|
@@ -13,7 +13,7 @@ from typing import Annotated, Any, Dict, List, Literal, Optional
|
|
|
13
13
|
|
|
14
14
|
from pydantic import BaseModel, BeforeValidator, ConfigDict, Field, model_validator
|
|
15
15
|
|
|
16
|
-
from .validate import ORDER_SPEC, REPORT_SPEC
|
|
16
|
+
from .validate import ORDER_SPEC, REPORT_SPEC, order_spec_for, report_spec_for
|
|
17
17
|
|
|
18
18
|
AgentRef = Annotated[str, Field(min_length=1, max_length=512)]
|
|
19
19
|
|
|
@@ -45,10 +45,15 @@ class _Document(_Part):
|
|
|
45
45
|
unknown = [k for k in (self.model_extra or {}) if not k.startswith("x-")]
|
|
46
46
|
if unknown:
|
|
47
47
|
raise ValueError(f"unknown fields {unknown}; extensions must start with 'x-'")
|
|
48
|
-
# `spec` always appears in to_dict()
|
|
48
|
+
# Left unset, `spec` is the lowest version that has every field used, and always appears in to_dict().
|
|
49
|
+
if "spec" not in self.model_fields_set:
|
|
50
|
+
self.spec = self._lowest_spec()
|
|
49
51
|
self.model_fields_set.add("spec")
|
|
50
52
|
return self
|
|
51
53
|
|
|
54
|
+
def _lowest_spec(self) -> str:
|
|
55
|
+
raise NotImplementedError
|
|
56
|
+
|
|
52
57
|
def to_dict(self) -> Dict[str, Any]:
|
|
53
58
|
"""The document as JSON-ready data, with ``from`` spelled as in the spec."""
|
|
54
59
|
return self.model_dump(mode="json", by_alias=True, exclude_unset=True, exclude_none=True)
|
|
@@ -123,6 +128,9 @@ class WorkOrder(_Document):
|
|
|
123
128
|
continues: Optional[Text] = None
|
|
124
129
|
metadata: Optional[Dict[str, Any]] = None
|
|
125
130
|
|
|
131
|
+
def _lowest_spec(self) -> str:
|
|
132
|
+
return order_spec_for(vars(self))
|
|
133
|
+
|
|
126
134
|
@model_validator(mode="after")
|
|
127
135
|
def _budget_not_empty(self) -> "WorkOrder":
|
|
128
136
|
if not self.budget.model_fields_set:
|
|
@@ -179,3 +187,6 @@ class WorkReport(_Document):
|
|
|
179
187
|
error: Optional[Text] = None
|
|
180
188
|
handoff: Optional[Handoff] = None
|
|
181
189
|
metadata: Optional[Dict[str, Any]] = None
|
|
190
|
+
|
|
191
|
+
def _lowest_spec(self) -> str:
|
|
192
|
+
return report_spec_for(vars(self))
|
|
@@ -18,11 +18,33 @@ from jsonschema import Draft202012Validator, FormatChecker, ValidationError
|
|
|
18
18
|
from jsonschema.exceptions import SchemaError
|
|
19
19
|
from jsonschema.validators import extend
|
|
20
20
|
|
|
21
|
+
#: The newest spec version this package reads. New documents get the lowest that fits: see :func:`order_spec_for`.
|
|
21
22
|
ORDER_SPEC = "awl/work-order@0.4"
|
|
22
23
|
REPORT_SPEC = "awl/work-report@0.3"
|
|
23
24
|
#: Every spec version this package reads (SPEC.md §11).
|
|
24
25
|
ORDER_SPECS = ("awl/work-order@0.1", "awl/work-order@0.2", "awl/work-order@0.3", ORDER_SPEC)
|
|
25
26
|
REPORT_SPECS = ("awl/work-report@0.1", "awl/work-report@0.2", REPORT_SPEC)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def order_spec_for(order: Mapping[str, Any]) -> str:
|
|
30
|
+
"""The lowest Work Order version that defines every field ``order`` uses (SPEC.md §11).
|
|
31
|
+
|
|
32
|
+
Readers that predate a field then still accept orders that don't use it.
|
|
33
|
+
"""
|
|
34
|
+
if order.get("staged") is not None:
|
|
35
|
+
return ORDER_SPECS[3]
|
|
36
|
+
if order.get("continues") is not None:
|
|
37
|
+
return ORDER_SPECS[2]
|
|
38
|
+
return ORDER_SPECS[1] if order.get("handoff") is not None else ORDER_SPECS[0]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def report_spec_for(report: Mapping[str, Any]) -> str:
|
|
42
|
+
"""The lowest Work Report version that defines every field ``report`` uses (SPEC.md §11)."""
|
|
43
|
+
if report.get("effects") is not None:
|
|
44
|
+
return REPORT_SPECS[2]
|
|
45
|
+
return REPORT_SPECS[1] if report.get("handoff") is not None else REPORT_SPECS[0]
|
|
46
|
+
|
|
47
|
+
|
|
26
48
|
#: Budget and cost units (SPEC.md §4.2).
|
|
27
49
|
UNITS = ("usd", "tokens", "tool_calls", "seconds")
|
|
28
50
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|