vis-agent 0.5.22.dev9332__py3-none-any.whl → 0.5.22.dev9358__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.
@@ -95,7 +95,7 @@ def read_session(target):
95
95
  """Refuse a session read without a bound Vis session and its database."""
96
96
  raise Refused(
97
97
  "vis.read_session needs a bound Vis session. Outside an extension, read the "
98
- "session with the SDK client's get_session_transcript(session_id)."
98
+ "session with the SDK client's routes.get_session_transcript(session_id)."
99
99
  )
100
100
 
101
101
 
@@ -1,4 +1,4 @@
1
- """Synchronous agent, session, execution-layer and Council APIs.
1
+ """Synchronous agent, session, client and Council APIs.
2
2
 
3
3
  For installation, workflows and lifecycle choices, use the
4
4
  [Python SDK guide](https://vis.blockether.com/python-sdk.html).
@@ -8,16 +8,15 @@ from ._agent import Agent, StructuredOutputError, final_answer
8
8
  from ._agents import Subagent, SubagentRecord
9
9
  from ._client import (
10
10
  Attachment,
11
+ EngineClient,
11
12
  Event,
12
13
  Events,
13
- ExecutionLayer,
14
14
  GatewayClient,
15
15
  GatewayError,
16
16
  JobEvent,
17
17
  JobEvents,
18
18
  JSONValue,
19
19
  ProtocolError,
20
- Query,
21
20
  Response,
22
21
  Session,
23
22
  SessionOptions,
@@ -38,6 +37,7 @@ from ._groups import SessionGroup
38
37
  from ._install import InstallError, ensure_installed, install
39
38
  from ._local import StdioEngineClient
40
39
  from ._models import Model, SessionModel
40
+ from ._routes import Query, Routes
41
41
  from ._service import HttpLocalEngineClient
42
42
  from ._sounds import SoundPreset, Sounds, SoundSettings
43
43
  from ._speech import Speech, SpeechAudio, Transcript, Voice
@@ -56,7 +56,7 @@ __all__ = [
56
56
  "CouncilThread",
57
57
  "Event",
58
58
  "Events",
59
- "ExecutionLayer",
59
+ "EngineClient",
60
60
  "GatewayClient",
61
61
  "GatewayError",
62
62
  "HttpLocalEngineClient",
@@ -68,6 +68,7 @@ __all__ = [
68
68
  "ProtocolError",
69
69
  "Query",
70
70
  "Response",
71
+ "Routes",
71
72
  "Session",
72
73
  "SessionGroup",
73
74
  "SessionModel",
@@ -1,4 +1,4 @@
1
- """One conversation using an injected execution layer or an owned local engine."""
1
+ """One conversation using an injected client or an owned local engine."""
2
2
 
3
3
  import json
4
4
  import math
@@ -19,7 +19,7 @@ from referencing import Registry
19
19
  from referencing.exceptions import Unresolvable
20
20
 
21
21
  from ._client import (
22
- ExecutionLayer,
22
+ EngineClient,
23
23
  GatewayError,
24
24
  Session,
25
25
  TransportError,
@@ -250,13 +250,28 @@ def _syntax_message(answer: str, error: json.JSONDecodeError) -> str:
250
250
  def final_answer(turn: Mapping[str, object]) -> str | None:
251
251
  """Return the final answer text of the turn record `turn`, or None.
252
252
 
253
- A turn record has no `answer` field. The answer is the Markdown of the last
254
- `prose` block in `turn["content"]`. A turn without that block, or with only
255
- blank text in it, gives None.
253
+ Typed conversation answers join their answer-phase text in order. Visual
254
+ blocks and progress are not answers. Otherwise, use the last prose block.
255
+ A turn without an answer, or with only blank answer text, gives None.
256
256
  """
257
257
  content = turn.get("content")
258
258
  if not isinstance(content, list):
259
259
  return None
260
+ if any(
261
+ isinstance(block, dict)
262
+ and block.get("type") in ("conversation", "visual", "silence")
263
+ for block in content
264
+ ):
265
+ answers = [
266
+ block["text"]
267
+ for block in content
268
+ if isinstance(block, dict)
269
+ and block.get("type") == "conversation"
270
+ and block.get("phase") == "answer"
271
+ and isinstance(block.get("text"), str)
272
+ and block["text"].strip()
273
+ ]
274
+ return "\n\n".join(answers) or None
260
275
  for block in reversed(content):
261
276
  if isinstance(block, dict) and block.get("type") == "prose":
262
277
  answer = block.get("markdown")
@@ -382,7 +397,7 @@ def _run(
382
397
  response_model: type[ResponseModel] | None,
383
398
  max_corrections: int,
384
399
  options: dict[str, Any],
385
- ) -> _types.Turn | ResponseModel:
400
+ ) -> _types.TurnRecord | ResponseModel:
386
401
  """Submit one turn and wait; with a response model, validate and correct it.
387
402
 
388
403
  `connect` gives the session only after the options are valid.
@@ -467,7 +482,7 @@ class Agent:
467
482
 
468
483
  Raises:
469
484
  TypeError: The supplied client does not implement
470
- `blockether.vis.engine.ExecutionLayer`, an extension is unsupported, or
485
+ `blockether.vis.engine.EngineClient`, an extension is unsupported, or
471
486
  `tools` is not an iterable of strings.
472
487
  ValueError: A project or extension declaration is invalid, or only one of
473
488
  `provider` and `model` is given.
@@ -479,7 +494,7 @@ class Agent:
479
494
  self,
480
495
  project=".",
481
496
  *,
482
- client: ExecutionLayer | None = None,
497
+ client: EngineClient | None = None,
483
498
  extensions=(),
484
499
  tools=None,
485
500
  provider: str | None = None,
@@ -496,8 +511,8 @@ class Agent:
496
511
  tools = list(tools)
497
512
  if not all(isinstance(name, str) for name in tools):
498
513
  raise TypeError("tools must be an iterable of tool names")
499
- if client is not None and not isinstance(client, ExecutionLayer):
500
- raise TypeError("client must be an ExecutionLayer")
514
+ if client is not None and not isinstance(client, EngineClient):
515
+ raise TypeError("client must be an EngineClient")
501
516
  self._owns_client = client is None
502
517
  self.client = StdioEngineClient(root=project) if client is None else client
503
518
  self._session_options: dict[str, Any] = dict(
@@ -533,7 +548,7 @@ class Agent:
533
548
  def _mount_extensions(self, session: Session, extensions):
534
549
  if extensions.manifest:
535
550
  self.client._ensure_client_lease()
536
- self.client.put_session_client_extensions(
551
+ self.client.routes.put_session_client_extensions(
537
552
  session.id, body={"extensions": extensions.manifest}
538
553
  )
539
554
  self.client._client_extensions[session.id] = extensions
@@ -603,7 +618,7 @@ class Agent:
603
618
  timeout: float = 300,
604
619
  response_model: None = None,
605
620
  **options,
606
- ) -> _types.Turn: ...
621
+ ) -> _types.TurnRecord: ...
607
622
 
608
623
  @overload
609
624
  def run(
@@ -624,7 +639,7 @@ class Agent:
624
639
  response_model: type[ResponseModel] | None = None,
625
640
  max_corrections: int = 2,
626
641
  **options,
627
- ) -> _types.Turn | ResponseModel:
642
+ ) -> _types.TurnRecord | ResponseModel:
628
643
  """Submit a request and wait for its result in the same conversation.
629
644
 
630
645
  Without `response_model`, return the turn dictionary in contract form. Check its
@@ -650,7 +665,7 @@ class Agent:
650
665
  `attempts` say what went wrong.
651
666
 
652
667
  `timeout` is a positive finite wait deadline in seconds for the answer and any
653
- corrections. It is separate from the layer's transport timeout. Submission
668
+ corrections. It is separate from the client's transport timeout. Submission
654
669
  options such as `provider`, `model` and `attachments` are passed unchanged to
655
670
  `send`. Corrections reuse them, except `attachments` and `idempotency_key`.
656
671
 
@@ -671,8 +686,8 @@ class Agent:
671
686
  """Detach callbacks and release only resources owned by this agent.
672
687
 
673
688
  Repeated calls are safe. The default local engine stops, and its temporary
674
- session database is removed. Project file edits stay. A borrowed execution layer
675
- and other agents that use it stay open. After closing, requests through this
689
+ session database is removed. Project file edits stay. A borrowed client and
690
+ other agents that use it stay open. After closing, requests through this
676
691
  agent raise `blockether.vis.engine.TransportError`.
677
692
  """
678
693
  if not self._closed:
@@ -683,7 +698,9 @@ class Agent:
683
698
  if getattr(stream, "session", None) == self._session:
684
699
  stream.close()
685
700
  if self._extensions.manifest and not self.client._closed:
686
- self.client.delete_session_client_extensions(self._session.id)
701
+ self.client.routes.delete_session_client_extensions(
702
+ self._session.id
703
+ )
687
704
  finally:
688
705
  if self._session is not None:
689
706
  self.client._client_extensions.pop(self._session.id, None)