harness-sdk-python 0.40.3__py3-none-any.whl → 0.40.8__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.
- harness_sdk/deepagents.py +80 -9
- harness_sdk/deepagents_host.py +11 -1
- harness_sdk/langgraph.py +1 -1
- harness_sdk/run_manager.py +53 -47
- harness_sdk/threads.py +1 -1
- harness_sdk/voice.py +1 -1
- {harness_sdk_python-0.40.3.dist-info → harness_sdk_python-0.40.8.dist-info}/METADATA +8 -8
- {harness_sdk_python-0.40.3.dist-info → harness_sdk_python-0.40.8.dist-info}/RECORD +9 -9
- {harness_sdk_python-0.40.3.dist-info → harness_sdk_python-0.40.8.dist-info}/WHEEL +0 -0
harness_sdk/deepagents.py
CHANGED
|
@@ -7,6 +7,7 @@ namespace on the langgraph thread ``<thread_id>/<ns>``, concurrent with the
|
|
|
7
7
|
main run; its rows persist under ``checkpoint_ns == ns``.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
+
import logging
|
|
10
11
|
from typing import Any, Callable
|
|
11
12
|
|
|
12
13
|
from statepatch import plain
|
|
@@ -22,6 +23,8 @@ from .messages import MAIN_NS, MessageTree
|
|
|
22
23
|
from .parts import PartsAssembler, text_of
|
|
23
24
|
from .voice_thread import upsert_voice_turn
|
|
24
25
|
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
25
28
|
_TYPE_TO_ROLE = {"human": "user", "ai": "assistant", "tool": "assistant", "system": "assistant"}
|
|
26
29
|
|
|
27
30
|
|
|
@@ -172,9 +175,13 @@ class DeepagentsThread:
|
|
|
172
175
|
self._mount(MAIN_NS, thread.head)
|
|
173
176
|
if ctx.resume:
|
|
174
177
|
return None, config
|
|
178
|
+
# The middleware reads decisions positionally, in tool_calls order:
|
|
179
|
+
# the head's tool parts carry that order, the outcomes may not.
|
|
180
|
+
order = [p.get("toolInvocationId") for p in plain(self.tree.get(MAIN_NS, thread.head)["parts"])]
|
|
181
|
+
outcomes = sorted(ctx.input_outcomes, key=lambda o: order.index(o[0]["toolCallId"]))
|
|
175
182
|
decisions = [
|
|
176
183
|
{"type": "approve"} if response and response.get("decision") == "approve" else {"type": "reject"}
|
|
177
|
-
for _request, response, _meta in
|
|
184
|
+
for _request, response, _meta in outcomes
|
|
178
185
|
]
|
|
179
186
|
self._admission = ctx.applied()
|
|
180
187
|
return Command(resume={"decisions": decisions}), config
|
|
@@ -199,7 +206,7 @@ class DeepagentsThread:
|
|
|
199
206
|
from langchain_core.messages import HumanMessage
|
|
200
207
|
|
|
201
208
|
turn: list[Any] = [*plan.replay]
|
|
202
|
-
for message in ctx.messages:
|
|
209
|
+
for message in self._without_agent_ids(ctx.messages):
|
|
203
210
|
turn.append(HumanMessage(id=message["id"], content=_user_content(message)))
|
|
204
211
|
self._append_user(message, parent)
|
|
205
212
|
parent = message["id"]
|
|
@@ -218,6 +225,33 @@ class DeepagentsThread:
|
|
|
218
225
|
self._changed()
|
|
219
226
|
return ({"messages": turn} if turn else None), config
|
|
220
227
|
|
|
228
|
+
def _agent_ids(self) -> set[str]:
|
|
229
|
+
# user messages mount on the main graph; a subagent runs on its own
|
|
230
|
+
# LangGraph thread, so only main-namespace ids can collide
|
|
231
|
+
main = self.tree.threads.get(MAIN_NS)
|
|
232
|
+
messages = main.messages.values() if main is not None else ()
|
|
233
|
+
return {id for m in messages for id in _provider_ids(m)}
|
|
234
|
+
|
|
235
|
+
def check_user_id(self, message_id: Any) -> None:
|
|
236
|
+
"""Reject a user message id that names a message the agent wrote: the
|
|
237
|
+
harness id becomes the LangChain id, and ``add_messages`` replaces a
|
|
238
|
+
message with the same id. Called per command at intake, so only the
|
|
239
|
+
offending send fails."""
|
|
240
|
+
if isinstance(message_id, str) and message_id in self._agent_ids():
|
|
241
|
+
raise StatewireReject(f"message id {message_id} is already used", payload={"reason": "duplicate-id"})
|
|
242
|
+
|
|
243
|
+
def _without_agent_ids(self, messages: Any) -> list[Any]:
|
|
244
|
+
"""Dispatch-time guard for an id the agent wrote after the send's
|
|
245
|
+
intake check: drop only that message, keep the run and the rest."""
|
|
246
|
+
taken = self._agent_ids()
|
|
247
|
+
kept = []
|
|
248
|
+
for message in messages:
|
|
249
|
+
if message["id"] in taken:
|
|
250
|
+
logger.warning("dropping user message %r: the agent wrote a message with that id", message["id"])
|
|
251
|
+
else:
|
|
252
|
+
kept.append(message)
|
|
253
|
+
return kept
|
|
254
|
+
|
|
221
255
|
def _append_user(self, message: dict[str, Any], parent: str | None) -> None:
|
|
222
256
|
if self.tree.get(MAIN_NS, message["id"]) is not None:
|
|
223
257
|
return
|
|
@@ -236,6 +270,7 @@ class DeepagentsThread:
|
|
|
236
270
|
"""Append steered user messages after the head; returns the langgraph turn entries."""
|
|
237
271
|
from langchain_core.messages import HumanMessage
|
|
238
272
|
|
|
273
|
+
messages = self._without_agent_ids(messages)
|
|
239
274
|
thread = self.tree.thread(MAIN_NS)
|
|
240
275
|
turn = []
|
|
241
276
|
for message in messages:
|
|
@@ -358,12 +393,14 @@ class DeepagentsThread:
|
|
|
358
393
|
return
|
|
359
394
|
if mode == "updates" and isinstance(event, dict) and "__interrupt__" in event and ns == MAIN_NS:
|
|
360
395
|
assembler = self._assemblers.get(MAIN_NS)
|
|
361
|
-
|
|
362
|
-
if
|
|
363
|
-
|
|
396
|
+
# no streamed message: still validate, so an unmatched interrupt fails the run
|
|
397
|
+
parts = plain(assembler.parts) if assembler is not None else []
|
|
398
|
+
tool_ids = _pending_tool_ids(parts, event["__interrupt__"])
|
|
399
|
+
for tool_id in tool_ids:
|
|
400
|
+
assert assembler is not None
|
|
364
401
|
assembler.amend(tool_id, state="pendingApproval")
|
|
365
|
-
|
|
366
|
-
|
|
402
|
+
self.interrupt = {"toolCallIds": tool_ids}
|
|
403
|
+
self._changed()
|
|
367
404
|
|
|
368
405
|
def _finish(self, ns: str, outcome: dict[str, Any] | None = None) -> None:
|
|
369
406
|
assembler = self._assemblers.pop(ns, None)
|
|
@@ -482,6 +519,40 @@ class DeepagentsThread:
|
|
|
482
519
|
self._thread.abandon_plan()
|
|
483
520
|
|
|
484
521
|
|
|
522
|
+
def _pending_tool_ids(parts: list[dict[str, Any]], interrupts: Any) -> list[str]:
|
|
523
|
+
"""The tool call ids a HumanInTheLoopMiddleware interrupt asks about, in
|
|
524
|
+
``action_requests`` order. The middleware lists the reviewed calls of the
|
|
525
|
+
last AI message in ``tool_calls`` order and carries no ids, so each request
|
|
526
|
+
matches the next streaming tool part with the same name and args. An
|
|
527
|
+
interrupt that does not match raises: approving a guessed call is unsafe."""
|
|
528
|
+
requests: list[Any] = []
|
|
529
|
+
for interrupt in interrupts:
|
|
530
|
+
value = getattr(interrupt, "value", None)
|
|
531
|
+
action_requests = value.get("action_requests") if isinstance(value, dict) else None
|
|
532
|
+
if not isinstance(action_requests, list) or not action_requests:
|
|
533
|
+
raise ValueError("unsupported interrupt: expected HumanInTheLoopMiddleware action_requests")
|
|
534
|
+
requests.extend(action_requests)
|
|
535
|
+
waiting = [p for p in parts if p["type"] == "tool" and p["state"] == "streaming"]
|
|
536
|
+
tool_ids: list[str] = []
|
|
537
|
+
for request in requests:
|
|
538
|
+
if not isinstance(request, dict):
|
|
539
|
+
raise ValueError("unsupported interrupt: action request is not an object")
|
|
540
|
+
while waiting:
|
|
541
|
+
part = waiting.pop(0)
|
|
542
|
+
if part["toolName"] == request.get("name") and part.get("input") == request.get("args"):
|
|
543
|
+
tool_ids.append(part["toolInvocationId"])
|
|
544
|
+
break
|
|
545
|
+
else:
|
|
546
|
+
raise ValueError(f"interrupt asks about a {request.get('name')!r} call this turn did not stream")
|
|
547
|
+
return tool_ids
|
|
548
|
+
|
|
549
|
+
|
|
485
550
|
def _provider_ids(message: Any) -> list[str]:
|
|
486
|
-
|
|
487
|
-
|
|
551
|
+
"""The LangChain ids an agent message folds. A user message's metadata is
|
|
552
|
+
the client's, so it names none."""
|
|
553
|
+
if message is None or message.get("role") == "user":
|
|
554
|
+
return []
|
|
555
|
+
metadata = plain(message.get("metadata"))
|
|
556
|
+
provider = metadata.get("provider") if isinstance(metadata, dict) else None
|
|
557
|
+
ids = provider.get("ids") if isinstance(provider, dict) else None
|
|
558
|
+
return [i for i in ids if isinstance(i, str)] if isinstance(ids, list) else []
|
harness_sdk/deepagents_host.py
CHANGED
|
@@ -153,7 +153,10 @@ class DeepagentsHost(VoiceThread, HarnessMessages, Statewire):
|
|
|
153
153
|
interrupt = self.messages.interrupt
|
|
154
154
|
if interrupt is not None:
|
|
155
155
|
return RunManager.InputRequired(
|
|
156
|
-
(
|
|
156
|
+
tuple(
|
|
157
|
+
{"id": tool_id, "type": "tool-approval", "toolCallId": tool_id}
|
|
158
|
+
for tool_id in interrupt["toolCallIds"]
|
|
159
|
+
)
|
|
157
160
|
)
|
|
158
161
|
steered = self.messages.append_users(ctx.steering.take())
|
|
159
162
|
if not steered:
|
|
@@ -187,8 +190,14 @@ class DeepagentsHost(VoiceThread, HarnessMessages, Statewire):
|
|
|
187
190
|
with contextlib.suppress(Exception):
|
|
188
191
|
await stream.aclose()
|
|
189
192
|
|
|
193
|
+
def _check_user_message(self, params: Any) -> None:
|
|
194
|
+
message = params.get("message") if isinstance(params, dict) else None
|
|
195
|
+
if isinstance(message, dict):
|
|
196
|
+
self.messages.check_user_id(message.get("id"))
|
|
197
|
+
|
|
190
198
|
@command("run/send")
|
|
191
199
|
async def run_send(self, params, *, ctx, auth_result):
|
|
200
|
+
self._check_user_message(params)
|
|
192
201
|
return await self.run.send(params, applied=ctx.applied, auth_result=auth_result, version=ctx.version)
|
|
193
202
|
|
|
194
203
|
@command("run/dequeue")
|
|
@@ -197,6 +206,7 @@ class DeepagentsHost(VoiceThread, HarnessMessages, Statewire):
|
|
|
197
206
|
|
|
198
207
|
@command("run/edit")
|
|
199
208
|
async def run_edit(self, params, *, ctx, auth_result):
|
|
209
|
+
self._check_user_message(params)
|
|
200
210
|
return await self.run.edit(params, applied=ctx.applied, auth_result=auth_result)
|
|
201
211
|
|
|
202
212
|
@command("run/reload")
|
harness_sdk/langgraph.py
CHANGED
harness_sdk/run_manager.py
CHANGED
|
@@ -52,20 +52,14 @@ so a settled stop covers every durable effect the runner enlisted. On run end
|
|
|
52
52
|
one envelope promotes ``nextDispatch`` into ``dispatching`` and clears the
|
|
53
53
|
window.
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
whose ``authorize`` returns ``None`` keeps client-trusting behavior, and a
|
|
64
|
-
machine whose first admission is a pooled command replayed cold after a
|
|
65
|
-
restart records no principal (such replays run with ``auth_result`` ``None``
|
|
66
|
-
per the statewire replay contract). Principals stay off the wire
|
|
67
|
-
projections; ``authorize`` must return a JSON-serializable value with stable
|
|
68
|
-
equality per principal.
|
|
55
|
+
Run control: every attached caller may stop, continue, edit, reload, answer
|
|
56
|
+
input on, and preempt or steer the run, and dequeue, rewrite, or move any
|
|
57
|
+
queued message. Attach authorization is the gate; a finer security-gate
|
|
58
|
+
system is planned. The machine still records the minting caller's
|
|
59
|
+
``auth_result`` as ``principal`` and each queued message's as ``authors``
|
|
60
|
+
(persisted state kept for compatibility; ``authors`` also counts toward the
|
|
61
|
+
tracked-id capacity), but neither is enforced. Principals stay off the wire
|
|
62
|
+
projections.
|
|
69
63
|
"""
|
|
70
64
|
|
|
71
65
|
import asyncio
|
|
@@ -83,10 +77,10 @@ from typing import (
|
|
|
83
77
|
Protocol,
|
|
84
78
|
)
|
|
85
79
|
|
|
86
|
-
from
|
|
87
|
-
from
|
|
88
|
-
from
|
|
89
|
-
from
|
|
80
|
+
from pinboard import EvictionRequested
|
|
81
|
+
from pinboard.durability import FenceLost
|
|
82
|
+
from pinboard.trays import Tray, TrayDescriptor, TrayCtx, TrayMapNamespace, inbox
|
|
83
|
+
from pinboard.trays import persistent, persistent_outbox, persistent_queue
|
|
90
84
|
from statepatch import observable
|
|
91
85
|
from statewire import StatewireReject
|
|
92
86
|
from statewire.api import (
|
|
@@ -100,6 +94,7 @@ from statewire.ops import encode_envelope
|
|
|
100
94
|
logger = logging.getLogger(__name__)
|
|
101
95
|
|
|
102
96
|
MAX_MESSAGE_ID_LENGTH = 256
|
|
97
|
+
MAX_RUN_ID_LENGTH = 256
|
|
103
98
|
MAX_MESSAGE_BYTES = 1 << 20
|
|
104
99
|
MAX_RUN_IDS = 4096
|
|
105
100
|
|
|
@@ -172,9 +167,22 @@ def _run_id_of(params: Any) -> str:
|
|
|
172
167
|
run_id = params.get("runId") if isinstance(params, dict) else None
|
|
173
168
|
if not isinstance(run_id, str) or run_id == "":
|
|
174
169
|
raise _reject("invalid-message", "runId must be a non-empty string")
|
|
170
|
+
# the run id becomes the machine's tray id, a primary-key column in the store
|
|
171
|
+
if len(run_id) > MAX_RUN_ID_LENGTH:
|
|
172
|
+
raise _reject(
|
|
173
|
+
"invalid-message", f"runId exceeds {MAX_RUN_ID_LENGTH} characters"
|
|
174
|
+
)
|
|
175
175
|
return run_id
|
|
176
176
|
|
|
177
177
|
|
|
178
|
+
def _refuse_request_options(params: Any) -> None:
|
|
179
|
+
if isinstance(params, dict) and "requestOptions" in params:
|
|
180
|
+
raise _reject(
|
|
181
|
+
"capability-missing",
|
|
182
|
+
"requestOptions is accepted only by the AI SDK transport",
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
178
186
|
def _prepared(
|
|
179
187
|
hook: Callable[[dict[str, Any]], dict[str, Any]] | None,
|
|
180
188
|
name: str,
|
|
@@ -430,6 +438,7 @@ class RunManager(Tray):
|
|
|
430
438
|
|
|
431
439
|
queue = persistent_queue()
|
|
432
440
|
steerQueue = persistent_queue()
|
|
441
|
+
# Recorded but not enforced; kept so persisted state keeps its shape.
|
|
433
442
|
principal = persistent(None) # the minting caller's auth_result; never on the wire
|
|
434
443
|
authors = persistent({}) # message id -> the enqueueing caller's auth_result
|
|
435
444
|
outbox = persistent_outbox() # {"record": ..., "lanes": [...]}: the in-flight dispatch
|
|
@@ -610,19 +619,6 @@ class RunManager(Tray):
|
|
|
610
619
|
|
|
611
620
|
# ─── State access ───────────────────────────────────────
|
|
612
621
|
|
|
613
|
-
def _check_owner(self, recorded: Any, principal: Any, what: str) -> None:
|
|
614
|
-
# a None record is unbound: a host without authorize keeps legacy behavior
|
|
615
|
-
if recorded is not None and recorded != principal:
|
|
616
|
-
raise _reject("not-owner", f"{what} belongs to another caller")
|
|
617
|
-
|
|
618
|
-
def _check_run_owner(self, principal: Any) -> None:
|
|
619
|
-
self._check_owner(self.principal.value, principal, f"run {self.id}")
|
|
620
|
-
|
|
621
|
-
def _check_author(self, message_id: str, principal: Any) -> None:
|
|
622
|
-
self._check_owner(
|
|
623
|
-
self.authors.value.get(message_id), principal, f"message {message_id}"
|
|
624
|
-
)
|
|
625
|
-
|
|
626
622
|
def _in_flight(self) -> bool:
|
|
627
623
|
return self.outbox.value is not None
|
|
628
624
|
|
|
@@ -1656,7 +1652,8 @@ class RunManager(Tray):
|
|
|
1656
1652
|
return self._apply_move(e, fx)
|
|
1657
1653
|
current = self._lane_of(e.message_id)
|
|
1658
1654
|
if current is not None:
|
|
1659
|
-
|
|
1655
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1656
|
+
# gate. A finer security-gate system is planned.
|
|
1660
1657
|
self._check_anchor(e)
|
|
1661
1658
|
self._place(e.lane, current, e.message, e.params, e.meta)
|
|
1662
1659
|
if e.lane == "steerQueue":
|
|
@@ -1674,8 +1671,8 @@ class RunManager(Tray):
|
|
|
1674
1671
|
raise _reject("invalid-message", "runAnchorMessageId is required")
|
|
1675
1672
|
else:
|
|
1676
1673
|
self._check_anchor(e)
|
|
1677
|
-
#
|
|
1678
|
-
|
|
1674
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1675
|
+
# gate. A finer security-gate system is planned.
|
|
1679
1676
|
self._check_id_capacity((e.message_id,))
|
|
1680
1677
|
if self._dispatchable(e.lane):
|
|
1681
1678
|
self._stage_batch(e)
|
|
@@ -1704,7 +1701,8 @@ class RunManager(Tray):
|
|
|
1704
1701
|
f"message {e.message_id} already dispatched",
|
|
1705
1702
|
)
|
|
1706
1703
|
raise _reject("unknown-id", f"message {e.message_id} is not queued")
|
|
1707
|
-
|
|
1704
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1705
|
+
# gate. A finer security-gate system is planned.
|
|
1708
1706
|
item = next(i for i in self._lane_items(current) if i["id"] == e.message_id)
|
|
1709
1707
|
self._place(e.lane, current, item, e.params, item.get("meta"))
|
|
1710
1708
|
if e.lane == "steerQueue":
|
|
@@ -1749,7 +1747,8 @@ class RunManager(Tray):
|
|
|
1749
1747
|
|
|
1750
1748
|
def _park_dispatched_edit(self, e: _Send) -> Any:
|
|
1751
1749
|
assert e.message is not None
|
|
1752
|
-
|
|
1750
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1751
|
+
# gate. A finer security-gate system is planned.
|
|
1753
1752
|
_check_rewind_gate(self.capabilities, self._in_flight(), "editing")
|
|
1754
1753
|
if e.source_meta is None:
|
|
1755
1754
|
raise _reject("unknown-id", f"message {e.message_id} is unknown")
|
|
@@ -1769,8 +1768,8 @@ class RunManager(Tray):
|
|
|
1769
1768
|
lane = self._lane_of(e.message_id)
|
|
1770
1769
|
if lane is None:
|
|
1771
1770
|
raise _reject("unknown-id", f"message {e.message_id} is not queued")
|
|
1772
|
-
|
|
1773
|
-
|
|
1771
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1772
|
+
# gate. A finer security-gate system is planned.
|
|
1774
1773
|
self._lane(lane).value = [
|
|
1775
1774
|
item for item in self._lane_items(lane) if item["id"] != e.message_id
|
|
1776
1775
|
]
|
|
@@ -1780,7 +1779,8 @@ class RunManager(Tray):
|
|
|
1780
1779
|
def _apply_input(self, e: _Input) -> Any:
|
|
1781
1780
|
if self._status() != "input-required":
|
|
1782
1781
|
raise _reject("wrong-state", f"run/input is rejected in {self._status()}")
|
|
1783
|
-
|
|
1782
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1783
|
+
# gate. A finer security-gate system is planned.
|
|
1784
1784
|
index = next(
|
|
1785
1785
|
(
|
|
1786
1786
|
i
|
|
@@ -1808,7 +1808,8 @@ class RunManager(Tray):
|
|
|
1808
1808
|
return None
|
|
1809
1809
|
|
|
1810
1810
|
def _apply_edit(self, e: _Edit) -> Any:
|
|
1811
|
-
|
|
1811
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1812
|
+
# gate. A finer security-gate system is planned.
|
|
1812
1813
|
self._check_id_capacity((e.message["id"],))
|
|
1813
1814
|
staged = self._staged_rewind
|
|
1814
1815
|
if (
|
|
@@ -1830,7 +1831,8 @@ class RunManager(Tray):
|
|
|
1830
1831
|
return _PARKED
|
|
1831
1832
|
|
|
1832
1833
|
def _apply_reload(self, e: _Reload) -> Any:
|
|
1833
|
-
|
|
1834
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1835
|
+
# gate. A finer security-gate system is planned.
|
|
1834
1836
|
if self._staged_rewind is not None:
|
|
1835
1837
|
raise _reject("wrong-state", "a rewind is already staged")
|
|
1836
1838
|
self._stage_rewind(
|
|
@@ -1876,7 +1878,8 @@ class RunManager(Tray):
|
|
|
1876
1878
|
status == "stopping" and stop_held
|
|
1877
1879
|
):
|
|
1878
1880
|
raise _reject("wrong-state", f"run/stop is rejected in {status}")
|
|
1879
|
-
|
|
1881
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1882
|
+
# gate. A finer security-gate system is planned.
|
|
1880
1883
|
run_id = _run_id_of(params)
|
|
1881
1884
|
if run_id != self.id:
|
|
1882
1885
|
raise _reject(
|
|
@@ -1905,7 +1908,8 @@ class RunManager(Tray):
|
|
|
1905
1908
|
status = self._status()
|
|
1906
1909
|
if status not in ("error", "stopped"):
|
|
1907
1910
|
raise _reject("wrong-state", f"run/continue is rejected in {status}")
|
|
1908
|
-
|
|
1911
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
1912
|
+
# gate. A finer security-gate system is planned.
|
|
1909
1913
|
if not self._lane_items("steerQueue") and (
|
|
1910
1914
|
"incomplete-continuation" not in self.capabilities
|
|
1911
1915
|
):
|
|
@@ -2254,7 +2258,8 @@ class RunManagerNamespace(TrayMapNamespace):
|
|
|
2254
2258
|
if not requests and not has_pending_tasks:
|
|
2255
2259
|
return False
|
|
2256
2260
|
tray, _ = await self._machine(self._api.domain.token_hex(16), principal)
|
|
2257
|
-
|
|
2261
|
+
# Run control is open to every attached caller; attach authorization is the
|
|
2262
|
+
# gate. A finer security-gate system is planned.
|
|
2258
2263
|
if (
|
|
2259
2264
|
tray._in_flight()
|
|
2260
2265
|
or tray._intake
|
|
@@ -2390,6 +2395,7 @@ class RunManagerNamespace(TrayMapNamespace):
|
|
|
2390
2395
|
cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
|
|
2391
2396
|
if not isinstance(params, dict):
|
|
2392
2397
|
raise _reject("invalid-message", "params must be an object")
|
|
2398
|
+
_refuse_request_options(params)
|
|
2393
2399
|
run_id = _run_id_of(params)
|
|
2394
2400
|
behavior = params.get("behavior", "auto")
|
|
2395
2401
|
if behavior not in _BEHAVIORS:
|
|
@@ -2527,15 +2533,13 @@ class RunManagerNamespace(TrayMapNamespace):
|
|
|
2527
2533
|
behavior: str,
|
|
2528
2534
|
message: dict[str, Any] | None,
|
|
2529
2535
|
message_id: str,
|
|
2530
|
-
principal: Any,
|
|
2536
|
+
principal: Any, # unused: run control is open to every attached caller
|
|
2531
2537
|
) -> dict[str, Any] | None:
|
|
2532
2538
|
"""The message an auto send consults the prioritizer on; None stages without one."""
|
|
2533
2539
|
cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
|
|
2534
2540
|
if behavior != "auto" or cls.prioritize is None or tray._status() not in _LIVE:
|
|
2535
2541
|
return None
|
|
2536
2542
|
lane = tray._lane_of(message_id)
|
|
2537
|
-
if lane is not None:
|
|
2538
|
-
tray._check_author(message_id, principal) # before the prioritizer sees it
|
|
2539
2543
|
if message is not None:
|
|
2540
2544
|
return message
|
|
2541
2545
|
if lane is None:
|
|
@@ -2606,6 +2610,7 @@ class RunManagerNamespace(TrayMapNamespace):
|
|
|
2606
2610
|
) -> Any:
|
|
2607
2611
|
cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
|
|
2608
2612
|
self._check_rewind_gate("run/edit")
|
|
2613
|
+
_refuse_request_options(params)
|
|
2609
2614
|
run_id = _run_id_of(params)
|
|
2610
2615
|
source_id = params.get("sourceId") if isinstance(params, dict) else None
|
|
2611
2616
|
if not isinstance(source_id, str):
|
|
@@ -2645,6 +2650,7 @@ class RunManagerNamespace(TrayMapNamespace):
|
|
|
2645
2650
|
) -> Any:
|
|
2646
2651
|
cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
|
|
2647
2652
|
self._check_rewind_gate("run/reload")
|
|
2653
|
+
_refuse_request_options(params)
|
|
2648
2654
|
run_id = _run_id_of(params)
|
|
2649
2655
|
source_id = params.get("sourceId") if isinstance(params, dict) else None
|
|
2650
2656
|
if not isinstance(source_id, str):
|
harness_sdk/threads.py
CHANGED
|
@@ -8,7 +8,7 @@ from datetime import datetime, timezone
|
|
|
8
8
|
from typing import Any, Literal, NotRequired, Protocol, TypedDict, get_args
|
|
9
9
|
|
|
10
10
|
from fastapi import HTTPException, Request
|
|
11
|
-
from
|
|
11
|
+
from pinboard import Attestation, AuthRejected, attestation, route
|
|
12
12
|
from starlette.requests import HTTPConnection
|
|
13
13
|
from statewire import Statewire, StatewireReject, command
|
|
14
14
|
|
harness_sdk/voice.py
CHANGED
|
@@ -56,7 +56,7 @@ from time import monotonic
|
|
|
56
56
|
from typing import Any, Callable, Literal, Protocol, TypedDict
|
|
57
57
|
from uuid import uuid4
|
|
58
58
|
|
|
59
|
-
from
|
|
59
|
+
from pinboard.trays import Tray, TrayDescriptor, TrayMapNamespace
|
|
60
60
|
from statepatch import observable, plain
|
|
61
61
|
from statewire import StatewireReject
|
|
62
62
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: harness-sdk-python
|
|
3
|
-
Version: 0.40.
|
|
3
|
+
Version: 0.40.8
|
|
4
4
|
Summary: RunManager: the harness-sdk runs subsystem for Python Statewire hosts
|
|
5
5
|
Project-URL: Repository, https://github.com/assistant-ui/harness-sdk
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Requires-Python: <4.0,>=3.12
|
|
8
|
-
Requires-Dist:
|
|
9
|
-
Requires-Dist: statewire<0.24,>=0.23.
|
|
8
|
+
Requires-Dist: pinboard-sdk>=0.18.0
|
|
9
|
+
Requires-Dist: statewire<0.24,>=0.23.6
|
|
10
10
|
Provides-Extra: deepagents
|
|
11
11
|
Requires-Dist: deepagents>=0.6.12; extra == 'deepagents'
|
|
12
12
|
Requires-Dist: langchain-core>=0.3; extra == 'deepagents'
|
|
@@ -26,7 +26,7 @@ Description-Content-Type: text/markdown
|
|
|
26
26
|
|
|
27
27
|
# harness-sdk-python
|
|
28
28
|
|
|
29
|
-
The runs subsystem for Python Statewire hosts: `@run_manager` turns one async method into the run executor and mounts the `run/*` command surface (send, dequeue, edit, reload, stop, continue, input), each run in its own tray. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and
|
|
29
|
+
The runs subsystem for Python Statewire hosts: `@run_manager` turns one async method into the run executor and mounts the `run/*` command surface (send, dequeue, edit, reload, stop, continue, input), each run in its own tray. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and Pinboard.
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
@@ -88,7 +88,7 @@ async def run(self, ctx: RunManager.RunContext): ...
|
|
|
88
88
|
|
|
89
89
|
## Docs
|
|
90
90
|
|
|
91
|
-
- Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/get-started/chat-app/page.mdx
|
|
92
|
-
- Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/guides/harness/host/page.mdx
|
|
93
|
-
- Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/reference/harness-sdk-python/page.mdx
|
|
94
|
-
- Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/spec/runs-protocol/page.mdx
|
|
91
|
+
- Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/get-started/chat-app/page.mdx
|
|
92
|
+
- Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/guides/harness/host/page.mdx
|
|
93
|
+
- Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/reference/harness-sdk-python/page.mdx
|
|
94
|
+
- Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/spec/runs-protocol/page.mdx
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
harness_sdk/__init__.py,sha256=x-vDKSqkPGcjLZ3N2nWtM37RyS-KifXtfKBPy4IOnjE,2285
|
|
2
2
|
harness_sdk/checkpoints.py,sha256=Iuum5x4KjsvJajDPP9TLFKcKQouOo-05jnCP3SJCD2s,30726
|
|
3
|
-
harness_sdk/deepagents.py,sha256=
|
|
4
|
-
harness_sdk/deepagents_host.py,sha256=
|
|
3
|
+
harness_sdk/deepagents.py,sha256=sRsXNA5OhVE96jEKLUnGIKSLXp2ADheEaxu8pqwy_1c,25595
|
|
4
|
+
harness_sdk/deepagents_host.py,sha256=Psv66_Y0eJQu4sjBdGiwqrEdusY6kHXOotb1v35NNT8,9668
|
|
5
5
|
harness_sdk/fenced_postgres.py,sha256=hbbrMR1WaqrHTNgd4wFrXfRrzQFGnyim-c8nZXgwWp4,13235
|
|
6
6
|
harness_sdk/interest.py,sha256=KnmbTcF7fQha69Zuvu0_solI44Olp-eSv-qkltZ-hAU,5141
|
|
7
|
-
harness_sdk/langgraph.py,sha256=
|
|
7
|
+
harness_sdk/langgraph.py,sha256=35r1KSgrqK8KUPe6ELAGq3q5TuyeTeXwmkOnlbC5F9c,2682
|
|
8
8
|
harness_sdk/linear_thread.py,sha256=laDRXKLFsMlyWS4snqNAM6t38wO26gevLWXRNivhHSM,1810
|
|
9
9
|
harness_sdk/messages.py,sha256=amx-vPWlZh-W2fKrPgmaspSvc90rqcIqXgkr9aj_k5w,6148
|
|
10
10
|
harness_sdk/parts.py,sha256=mHhYvmQx6J56Ah5K7dUZ4qUOlKk-L02AR64asSqOT5I,6400
|
|
11
11
|
harness_sdk/prioritize.py,sha256=Li8IoI_ACiwbWDNa2DSDpNhoXY0utPhGevBQqQonsQc,4203
|
|
12
12
|
harness_sdk/protocol.py,sha256=VxWOIg_2vitFGTJmpiD2wNNAJnwSgQFy69Hds-frfvs,1207
|
|
13
|
-
harness_sdk/run_manager.py,sha256=
|
|
14
|
-
harness_sdk/threads.py,sha256=
|
|
15
|
-
harness_sdk/voice.py,sha256=
|
|
13
|
+
harness_sdk/run_manager.py,sha256=nXxXJAGaTVKh_yv6_sF7DQ-V_wY0sIFV2AQBJOwOFNY,111859
|
|
14
|
+
harness_sdk/threads.py,sha256=hpsS7GOZPVKfWFSMydJSdzzz5KY38pLWQQR-DkdoG2M,7151
|
|
15
|
+
harness_sdk/voice.py,sha256=XJakSJrjS-RVT1PIaDDxm1RZDp9QpLWCdX36k-UvGHA,25852
|
|
16
16
|
harness_sdk/voice_thread.py,sha256=B616W1efohEd9RwWssrOkTne7Lu8s0kn07kMof1v_nI,6910
|
|
17
17
|
harness_sdk/wire.py,sha256=m3hixpDPls413Ihr0tym5dlgsd334WaK0fISMpVMY3g,7978
|
|
18
18
|
harness_sdk/providers/__init__.py,sha256=PjVKflqdtYSipq0ISTNuIYKeCOm3KX8ov9XuNtBhFrs,75
|
|
19
19
|
harness_sdk/providers/gpt_live.py,sha256=cuODSm3Kztemf51BIOuPwy1Wf-0pOhf1LPYzmSdCvl8,8453
|
|
20
|
-
harness_sdk_python-0.40.
|
|
21
|
-
harness_sdk_python-0.40.
|
|
22
|
-
harness_sdk_python-0.40.
|
|
20
|
+
harness_sdk_python-0.40.8.dist-info/METADATA,sha256=LT6790AvckicSRK5HaY-Pwky1bxOwlT-q55la9xBZVc,4022
|
|
21
|
+
harness_sdk_python-0.40.8.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
22
|
+
harness_sdk_python-0.40.8.dist-info/RECORD,,
|
|
File without changes
|