Native session hooks and tailers¶
octomate.tentacles.hooks ¶
FastAPI dependencies that authenticate a runtime's hook request and resolve its sender.
verify_hook_key
async
¶
verify_hook_key(
auth: Annotated[AuthManager, Depends(auth_manager)],
authorization: Annotated[str | None, Header()] = None,
) -> ApiKey
Require a hooks-scoped API key before accessing the owner's resources.
Source code in octomate/tentacles/hooks.py
hook_guard ¶
Authenticate a hook request with a hooks-scoped API key or OAuth token.
The dependency yields the owner's username for ledger attribution.
Source code in octomate/tentacles/hooks.py
hook_sender ¶
hook_sender(
users: UserManager,
runtime: str,
verify: Callable[[str | None], Awaitable[str]],
) -> Callable[[str], Awaitable[UserProfile]]
The guard's second half, as a FastAPI dependency: the verified principal
resolved to their own profile on runtime's pseudo-channel — who every
ledger row this request writes is attributed to.
Composes over verify rather than re-reading the header: FastAPI caches a
dependency's value per request, so a router-level guard and this one share a
single bearer check.
Source code in octomate/tentacles/hooks.py
octomate.tentacles.claude.ingest ¶
Hook-driven ingest of a native Claude Code session.
Hooks establish session and run identities and signal transcript boundaries. Only the transcript tail writes messages.
ClaudeHookIngest ¶
Establish native session/run identities and relay transcript boundaries.
Hooks may arrive before or after their transcript. They ensure empty runs under the same native turn keys, but never write messages or replace a run's contents. The tail alone creates model messages and their ledger bindings. Its authenticated stream supplies the sender. A hook's transcript path is client context, never a server-local file to open.
Source code in octomate/tentacles/claude/ingest.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
handle
async
¶
Handle an authenticated hook; message attribution belongs to the stream.
Source code in octomate/tentacles/claude/ingest.py
on_user_prompt_submit
async
¶
Source code in octomate/tentacles/claude/ingest.py
on_stop
async
¶
Source code in octomate/tentacles/claude/ingest.py
on_session_end
async
¶
Source code in octomate/tentacles/claude/ingest.py
on_subagent_start
async
¶
Source code in octomate/tentacles/claude/ingest.py
on_subagent_stop
async
¶
Source code in octomate/tentacles/claude/ingest.py
ensure_subagent_run
async
¶
Ensure the child's empty run without copying its hook prompt.
Source code in octomate/tentacles/claude/ingest.py
start_session
async
¶
Ensure the session's skeleton (thread + conversation), under the session lock so the write can't race the hooks' first-sighting create. The transcript itself arrives only through the stream; nothing here follows the path a hook claims.
Source code in octomate/tentacles/claude/ingest.py
session_thread
async
¶
Reuse the session thread attributed at authenticated entry.
Source code in octomate/tentacles/claude/ingest.py
ensure_run
async
¶
Reserve the turn's foreign-key target; repeated or late hooks change nothing.
Source code in octomate/tentacles/claude/ingest.py
octomate.tentacles.locks ¶
Per-session asyncio locks that clean up after themselves.
SessionLocks ¶
Per-session asyncio.Locks. Not a lock of its own — a thin registry over the
stdlib lock, adding the keying the stdlib has no primitive for, plus self-cleanup:
each entry is a weak reference, so once no task holds or waits on a key's lock it is
reclaimed and the key leaves nothing behind.
async with locks.hold(key) releases on every exit — return, exception, or
cancellation — so an acquire cancelled by its timeout frees the lock automatically,
no manual dismissal or force-release.
Source code in octomate/tentacles/locks.py
by_session
instance-attribute
¶
hold
async
¶
Hold the key's lock for the block. acquire_timeout bounds the wait for the
lock and nothing else: a waiter stuck behind a wedged holder raises
TimeoutError rather than blocking forever, while the block it guards runs
unbounded once entered. A caller wanting to bound the work too wraps the whole
async with in its own cancel scope; a never-acquired lock is never released.
Source code in octomate/tentacles/locks.py
octomate.tentacles.tailer ¶
The shared lifecycle of a native turn published from a transcript.
NativeTurn
dataclass
¶
One transcript turn's live events and prompt bindings.
Tailers supply native boundaries, source message identities, and their own accumulator's message list. This owner rejects committed or driven turns, records prompts in that list, publishes the fold, and settles only after the caller commits the run. Subagent transcripts do not publish on this surface.
Source code in octomate/tentacles/tailer.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
prompts
class-attribute
instance-attribute
¶
open
async
classmethod
¶
open(
*,
run_id: str,
recorded: set[str],
conversations: ConversationManager,
threads: ThreadManager,
locks: SessionLocks,
address: ChannelAddress,
sender: UserProfile,
impulses: ObjectSendStream[Impulse],
messages: list[ModelMessage],
replay: bool = False,
) -> NativeTurn | None
Publish the opening bracket unless this turn already has an owner.
Source code in octomate/tentacles/tailer.py
caught_up
async
¶
Resume activity for an open turn after restoring its historical prefix.
prompt
async
¶
prompt(
*,
message_id: str,
text: str | TextContent,
timestamp: datetime,
metadata: JsonObject | None = None,
actor_kind: ChannelActorKind = "human",
) -> None
Record a source prompt once and deliver its request at this point.
The ledger row grants access before the run is complete. Its id is also
the enqueue id, so the console reconciles the live prompt with that row.
A line the harness wrote in the person's place is a system row: it joins
the history and the ledger, and a reader is told the harness said it.
A prompt whose annotations name an agent is that agent's message.
Source code in octomate/tentacles/tailer.py
fold
async
¶
Consume and publish the accumulator's events on the native thread.
Source code in octomate/tentacles/tailer.py
close
async
¶
close(
run: ExternalAgentRun | None,
*,
run_id: str,
answer: str,
interrupted: bool = False,
) -> None
Bind the committed history before publishing the closing bracket.
The caller holds the session lock through its commit and this binding.
record_external_run preserves input order; resolve the request objects
against that committed list here instead of tracking indices in tailers.
A failed commit or binding propagates without publishing run_ended.
Source code in octomate/tentacles/tailer.py
settle
async
¶
settle(
run_id: str,
*,
thread_message_id: UUID7 | None = None,
interrupted: bool = False,
) -> None
Publish the closing bracket after the native task's durable writes finish.
Source code in octomate/tentacles/tailer.py
octomate.tentacles.claude.tailer ¶
Assembly of native Claude Code turns from a streamed transcript.
Lines streamed in by octomate claude tail feed ClaudeTranscriptTailer, which
commits each completed turn as an ExternalAgentRun.
OpenTurn
dataclass
¶
The turn currently being assembled off the live tail — its accumulator fed line
by line, its byte range advancing to cover the last transcript line folded in. It
commits as an ExternalAgentRun when the next prompt line or its Stop hooks'
summary line closes it, when its own Stop hook reaches stop_turn, or at
finalize.
Source code in octomate/tentacles/claude/tailer.py
SubagentTail
dataclass
¶
One subagent transcript's cursor within a session's tail. A subagent writes its
own file (<session>/subagents/agent-<agentId>.jsonl), so it gets its own byte
cursor, conversation, and open turn. Its turns frame on promptId change: subagent files
carry no promptSource, and a resumed subagent's next turn may open on a
tool-result line, not a prompt. A result that answers a call of the open turn
stays in it whatever id it carries.
Source code in octomate/tentacles/claude/tailer.py
TailState
dataclass
¶
One streamed session: its transcript lives on the client machine that streams
it (octomate claude tail); the stream route feeds feed_remote, which drives
the per-line assembly. transcript_path is the client's claim in the client's
own namespace, a label never opened here — as are the subagent tails' paths.
Source code in octomate/tentacles/claude/tailer.py
compact_metadata
class-attribute
instance-attribute
¶
omitted_uuids
class-attribute
instance-attribute
¶
subagents
class-attribute
instance-attribute
¶
spawn_agents
class-attribute
instance-attribute
¶
spawn_names
class-attribute
instance-attribute
¶
known_spawns
class-attribute
instance-attribute
¶
ClaudeTranscriptTailer ¶
Assembles Claude turns from transcript lines streamed in by octomate claude
tail — the only assembler: the server never opens a transcript, even for a
session on this machine. Hooks can reserve empty runs, but only the transcript
produces model messages and ledger rows.
Each framed line feeds a ClaudeRunAccumulator — the same translation the live
tentacle and the whole-file restore use — driving two decoupled sinks:
- durable — one
ExternalAgentRunper completed turn, carrying the byte range it was built from, filling any empty run reserved by a hook. Older hook sketches are replaced for compatibility. Idempotent byprompt_id. - live — wire events sent through the connection's nerve publisher at the
native thread address, waiting for no reader. Only uncommitted parent turns publish:
run_started, the fold, thenrun_endedafter the reply is bound. A reconnect reopens an unfinished turn with anotherrun_started; no reflex is woken.
A turn commits on a proven boundary: the next prompt line, or the drained eof
a relayed Stop/SessionEnd asks the client for — the transcript is flushed
before Claude fires those hooks. Nothing newer than a stopped turn commits early
(drain_turn), and the tail process exits once the stopped turn is durable; the
next prompt's launcher spawns a fresh one. The committed runs' offsets are what
a reconnecting client is told to resume from, so a connection that drops
mid-stream leaves its open turn for the next connect to re-stream.
Source code in octomate/tentacles/claude/tailer.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 | |
stop_turn
async
¶
The turn just stopped — its Stop hook fired: drain it now instead of
waiting for the next prompt line to close it.
The stream route relays finalize on stop_event, the client ships its
final lines and answers eof, and finish_remote commits the stopped turn —
the tail process exits, and the next prompt's launcher spawns a fresh one.
Scoped by prompt_id so nothing newer than the stopped turn ever commits
early; without one there is nothing to scope, and the turn keeps its old
boundary. A session no stream covers has nothing to drain.
Source code in octomate/tentacles/claude/tailer.py
finalize
async
¶
End a session (SessionEnd): relay the drain to its stream — the route
watches stop_event and sends the client finalize; the client drains,
answers eof, and finish_remote commits the trailing turns and sets
drained. The wait is bounded: a client that is gone leaves its turns for
the next connect, and the SessionEnd hook must not hang on it. A session no
stream covers has nothing to finalize.
Source code in octomate/tentacles/claude/tailer.py
shutdown
async
¶
attach_remote
async
¶
attach_remote(
session_id: str,
transcript_path: Path,
sender: UserProfile,
address: ChannelAddress,
impulses: ObjectSendStream[Impulse],
) -> tuple[TailState, dict[UUID7, int]]
Register a streamed session and answer where each of its files resumes.
The offsets are recomputed from the committed runs, per file: the session and each known subagent under its own conversation UUID. The client asks again on reconnect. A lingering registration (its client died without a close) is replaced; the dead route feeds the state object it attached, and its commits are idempotent.
Source code in octomate/tentacles/claude/tailer.py
feed_remote
async
¶
Advance a remote session by one framed line — the pumps' per-line body, against offsets the client measured in its own file. Takes the state rather than a session id so a superseded connection keeps feeding the state it attached, never whoever registered after it.
Source code in octomate/tentacles/claude/tailer.py
finish_remote
async
¶
A remote session's clean end — the client drained to EOF and said eof.
After the session's own end (finalize relayed at SessionEnd, or the idle
drain), commit everything still open. After a relayed Stop (drain_turn
set), commit only the stopped turn: a prompt queued into the drain window is
left open to re-stream whole on the next connect, and subagent turns keep
their own boundary — SubagentStop commits them, and force-closing here
would truncate a background child still running across turns. Either way,
release any finalize waiter and reclaim the registry slot.
Source code in octomate/tentacles/claude/tailer.py
detach_remote ¶
Drop a remote session's registration without committing anything: the connection died mid-stream, so its open turns' bytes were never provably complete. The next connect resumes from the committed offsets and re-streams them.
Source code in octomate/tentacles/claude/tailer.py
prepare
async
¶
Resolve the session's conversation and seed the committed-turn guard from it, so a resume never re-commits a run the last run already wrote.
Source code in octomate/tentacles/claude/tailer.py
ensure_session
async
¶
Map a native Claude session id to its Octomate home — the session's thread and the conversation hanging off it — creating either if this is its first sighting.
Source code in octomate/tentacles/claude/tailer.py
parse_line
staticmethod
¶
One typed line, or None for a blank / malformed / unmodeled one — skipped but never allowed to wedge ingest; the caller advances its cursor either way.
Source code in octomate/tentacles/claude/tailer.py
process_line
async
¶
Route one typed line: a prompt_source user line opens a turn (closing the
previous one); other user (tool-result) and assistant lines fold into the open
turn, and a stop_hook_summary closes it. Inline is_sidechain lines are
skipped — transcripts since 2.1.177 keep subagents in their own files
(pump_subagents), so this guards only against an older transcript's inline
relics.
Source code in octomate/tentacles/claude/tailer.py
record_compaction
async
¶
record_compaction(
state: TailState,
line: TranscriptSystemLine | TranscriptUserLine,
start: int,
end: int,
*,
tail: SubagentTail | None = None,
) -> None
Keep the boundary and its following summary outside model runs and chat.
Source code in octomate/tentacles/claude/tailer.py
record_title
async
¶
Carry the name Claude gave this session onto the rows that show it.
The transcript restates the title on every turn and revises it as the work turns out to be about something else, so the comparison — not the write — is what runs per line. The thread takes it too: a native thread is its session, and a name about the work beats the line the thread opened with.
Source code in octomate/tentacles/claude/tailer.py
harvest_subagent_call
async
¶
Record the spawn as soon as the parent's result identifies the child and tool call. Its transcript can arrive on a different connection.
Source code in octomate/tentacles/claude/tailer.py
record_spawn
async
¶
Reserve the child's run under the parent's turn, linked to the call it answers. Once per call: two sources can name the same one.
Source code in octomate/tentacles/claude/tailer.py
fold
async
¶
Fold a line into the open turn: consume it (pushing its live events) and extend the turn's byte range and provenance to cover it.
Source code in octomate/tentacles/claude/tailer.py
observe_subagent_calls
async
¶
Keep the task title until the child is identified, and announce a previously recorded child again when its spawning call is re-streamed.
Source code in octomate/tentacles/claude/tailer.py
fold_attachment
async
¶
Record what another agent session said while the turn ran. Claude queues a foreground subagent's hand-back into the turn as an attachment, where a background one's opens a turn as a prompt line. Any other attachment is the harness's own context and is left out.
Source code in octomate/tentacles/claude/tailer.py
record_permission_mode
async
¶
Keep the conversation's posture at what the session's own transcript says.
Every prompt line carries the mode that turn ran under, so a ⇧⇥ in the client reaches Octomate on the operator's next message. Observed, never set: nothing here can change a running client's mode, and the console shows it read-only.
A mode Claude has that this build's vocabulary does not is skipped rather than stored — the column is validated on read, so an unknown one would take the conversation out of circulation instead of merely being unrecognized.
Source code in octomate/tentacles/claude/tailer.py
begin_turn
async
¶
Open the native lifecycle at the transcript's prompt boundary.
Source code in octomate/tentacles/claude/tailer.py
close_turn
async
¶
Commit the open turn as an ExternalAgentRun with its byte range, then bind
the turn's human-ledger rows to it. Idempotent by prompt_id, so a re-driven
overlap after a resume is a safe no-op. Held under the session lock so the commit
cannot race a hook reserving the same turn.
A commit that cannot be made propagates instead of being skipped past. A
reconnect resumes from the last committed turn's end_offset, which only
points at the right bytes while the committed turns are the earliest ones:
skipping a turn and streaming on would let a later turn push that mark past
the gap, stranding the skipped turn where no re-stream could reach it.
Failing keeps the mark honest — the next connect re-streams the turn from
there and commits it.
Source code in octomate/tentacles/claude/tailer.py
subagent_tail
staticmethod
¶
Source code in octomate/tentacles/claude/tailer.py
finish_subagent
async
¶
Drain and commit one subagent on its SubagentStop — the child's
finalize, which a Claude child needs: its turns frame on promptId change,
so nothing in its own file closes the last one. The hook is synchronous but
the transcript writer is not: the final answer line races it (measured:
usually loses by ~1-2KB). The child's lines arrive through feed_remote on
their own; when the event names the answer, wait until the stream yields it,
bounded so a mismatch can never hang the pipe — tail.offset says whether
the writer has gone quiet. A session no stream covers has nothing to
settle. Returns the answer the committed turn ended on.
Source code in octomate/tentacles/claude/tailer.py
subagent_settled
staticmethod
¶
The fast path: the drained turn already carries the exact answer the stop event announced. Divergence (a truncated or differently-joined hook payload — no contract promises byte equality) is not an error: the caller's byte-quiescence fallback settles those, so strictness here only ever costs one extra poll beat, never a wrong commit.
Source code in octomate/tentacles/claude/tailer.py
prepare_subagent
async
¶
Resolve the child's conversation under the session's thread and seed its committed-turn guard — the first time this child's lines are fed.
Source code in octomate/tentacles/claude/tailer.py
process_subagent_line
async
¶
process_subagent_line(
state: TailState,
tail: SubagentTail,
line: TranscriptLine,
start: int,
end: int,
) -> None
Frame a subagent's turns on promptId change — the only marker its file
carries (promptSource is absent, and every line is is_sidechain, so
neither parent rule applies). Each turn's promptId is the parent turn
that drove it; a resumed subagent opens its next turn on whatever user line
arrives first, which is measured to be a tool result, not a prompt.
A result stays with its call. A background child works on while its parent takes the next prompt, and the results it writes then carry that prompt's id: splitting there would cut one piece of work in two.
Source code in octomate/tentacles/claude/tailer.py
begin_subagent_turn ¶
Source code in octomate/tentacles/claude/tailer.py
fold_subagent ¶
fold_subagent(
tail: SubagentTail,
line: TranscriptAssistantLine | TranscriptUserLine,
end: int,
) -> None
Fold a line into the child's open turn. Events are consumed, not emitted: the live stream is the parent timeline's; fanning child events into it would interleave two timelines under one label.
Source code in octomate/tentacles/claude/tailer.py
close_subagent_turn
async
¶
Commit the child's open turn as a child run: keyed <agentId>:<promptId>
(which subagent, which parent turn — a bare promptId would collide with the
parent run it belongs to), linked by parent_run_id = that promptId and the
harvested spawning call. A subagent has no human prompt or answer, so it never
touches the ledger.
Source code in octomate/tentacles/claude/tailer.py
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | |
close_subagent_turns
async
¶
Commit every child's trailing open turn — the subagent counterpart of the
final close_turn, at a session-ending drain (finish_remote).
Source code in octomate/tentacles/claude/tailer.py
stamp ¶
Date the messages a transcript record produced by that record's own clock — the
accumulator stamps now, which is wrong for a run replayed off disk
(AgentRun.started_at and displayed times read from these).
Source code in octomate/tentacles/claude/tailer.py
octomate.tentacles.codex.transcript ¶
Typed lines of a Codex rollout file, and the runtime's own tree.
CODEX_HOME_DIRS
module-attribute
¶
CODEX_HOME_DIRS: tuple[Path, ...] = (
Path(
os.environ.get("CODEX_HOME")
or Path.home() / ".codex"
),
)
compaction_item_adapter
module-attribute
¶
compaction_item_adapter: TypeAdapter[
EncryptedCompactionItem | ContextCompactionItem
] = TypeAdapter(
Annotated[
EncryptedCompactionItem | ContextCompactionItem,
Field(discriminator="type"),
]
)
RolloutLine
pydantic-model
¶
Bases: BaseModel
One line of a Codex rollout: its timestamp, record type, and raw payload.
Config:
extra:ignore
Fields:
-
timestamp(AwareDatetime) -
type(Literal['session_meta', 'turn_context', 'event_msg', 'response_item', 'world_state', 'compacted', 'inter_agent_communication_metadata']) -
payload(JsonObject)
Source code in octomate/tentacles/codex/transcript.py
type
pydantic-field
¶
type: Literal[
"session_meta",
"turn_context",
"event_msg",
"response_item",
"world_state",
"compacted",
"inter_agent_communication_metadata",
]
CompactedItem
pydantic-model
¶
Bases: BaseModel
A committed context replacement, independent of turn lifecycle events.
Fields:
-
message(str) -
replacement_history(list[JsonObject] | None) -
compaction_response_id(str | None)
Source code in octomate/tentacles/codex/transcript.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
replacement_history
pydantic-field
¶
Native replacement items, including retained context and provider checkpoints.
compaction_response_id
pydantic-field
¶
Provider response ID of the compaction request, when reported.
to_messages ¶
to_messages(
timestamp: AwareDatetime,
*,
last_item_id: str | None = None,
item_aliases: dict[str, str] | None = None,
) -> list[ModelRequest | ModelResponse]
Normalize created summaries/checkpoints; retained messages keep their owner.
Source code in octomate/tentacles/codex/transcript.py
CompletedCompactionItem
pydantic-model
¶
Bases: BaseModel
The native rollout's completed context-compaction item.
Fields:
Source code in octomate/tentacles/codex/transcript.py
CompactionCompletedEvent
pydantic-model
¶
Bases: BaseModel
The source item identity following a committed replacement.
Fields:
-
type(Literal['item_completed']) -
thread_id(str) -
turn_id(str) -
item(CompletedCompactionItem)
Source code in octomate/tentacles/codex/transcript.py
EncryptedCompactionItem
pydantic-model
¶
Bases: BaseModel
An opaque provider checkpoint carried in replacement history.
Fields:
-
type(Literal['compaction', 'compaction_summary']) -
id(str | None) -
encrypted_content(str)
Source code in octomate/tentacles/codex/transcript.py
ContextCompactionItem
pydantic-model
¶
Bases: BaseModel
A context-compaction item that may omit its encrypted content.
Fields:
-
type(Literal['context_compaction']) -
id(str | None) -
encrypted_content(str | None)
Source code in octomate/tentacles/codex/transcript.py
ParsedCommand
pydantic-model
¶
Bases: BaseModel
Codex's classification of one command in a native execution item.
Fields:
-
type(Literal['read', 'list_files', 'search', 'unknown']) -
cmd(str | None) -
name(str | None) -
path(str | None) -
query(str | None)
Source code in octomate/tentacles/codex/transcript.py
CompletedCommandItem
pydantic-model
¶
Bases: BaseModel
An executed command recorded separately from its outer tool call.
Fields:
-
type(Literal['CommandExecution']) -
id(str) -
command(list[str]) -
cwd(str) -
parsed_cmd(list[ParsedCommand]) -
status(Literal['completed', 'failed', 'declined']) -
aggregated_output(str)
Source code in octomate/tentacles/codex/transcript.py
UserMessageContent
pydantic-model
¶
Bases: BaseModel
A user-role content part; only input text is imported.
Fields:
Source code in octomate/tentacles/codex/transcript.py
UserMessageMetadata
pydantic-model
¶
Bases: BaseModel
Codex's provenance labels, aligned with the message's content parts.
Fields:
-
turn_id(str) -
content_item_kinds(list[str])
Source code in octomate/tentacles/codex/transcript.py
UserMessageItem
pydantic-model
¶
Bases: BaseModel
A current-format user message with explicit per-part provenance.
User-role records also carry injected context. Only parts labelled
user.text are human text; unlabelled records rely on the legacy event.
Fields:
-
type(Literal['message']) -
id(str | None) -
role(Literal['user']) -
content(list[UserMessageContent]) -
metadata(UserMessageMetadata)
Source code in octomate/tentacles/codex/transcript.py
CompletedUserMessageItem
pydantic-model
¶
Bases: BaseModel
The app-server identity of a prompt already written to the rollout.
Fields:
Source code in octomate/tentacles/codex/transcript.py
UserMessageCompletedEvent
pydantic-model
¶
Bases: BaseModel
A prompt completion scoped to its native session and turn.
Fields:
-
type(Literal['item_completed']) -
thread_id(str) -
turn_id(str) -
item(CompletedUserMessageItem)
Source code in octomate/tentacles/codex/transcript.py
UserMessageIdentities
dataclass
¶
Pair source occurrences, including repeated text, without importing a turn.
Source code in octomate/tentacles/codex/transcript.py
consume ¶
Source code in octomate/tentacles/codex/transcript.py
ThreadSpawnMetadata
pydantic-model
¶
Bases: BaseModel
A child rollout's thread_spawn metadata, naming the parent thread.
Config:
extra:ignore
Fields:
-
parent_thread_id(str) -
depth(int) -
agent_path(str)
Source code in octomate/tentacles/codex/transcript.py
SubagentSource
pydantic-model
¶
Bases: BaseModel
The subagent block of a session's source, present on a spawned child.
Config:
extra:ignore
Fields:
-
thread_spawn(ThreadSpawnMetadata | None)
Source code in octomate/tentacles/codex/transcript.py
SessionSource
pydantic-model
¶
Bases: BaseModel
A structured session_meta source, carrying a spawned child's lineage.
Config:
extra:ignore
Fields:
-
subagent(SubagentSource | None)
Source code in octomate/tentacles/codex/transcript.py
SessionMetadata
pydantic-model
¶
Bases: BaseModel
The payload of a rollout's opening session_meta line.
Config:
extra:ignore
Fields:
-
session_id(str) -
id(str | None) -
cwd(str) -
originator(str | None) -
source(str | SessionSource | None) -
thread_source(str | None)
Source code in octomate/tentacles/codex/transcript.py
WorkspaceWritePolicy
pydantic-model
¶
Bases: BaseModel
The workspace sandbox representable by Octomate's review presets.
Config:
extra:forbid
Fields:
-
type(Literal['workspace-write']) -
writable_roots(list[str]) -
network_access(Literal[False]) -
exclude_tmpdir_env_var(bool) -
exclude_slash_tmp(bool)
Source code in octomate/tentacles/codex/transcript.py
FullAccessPolicy
pydantic-model
¶
Bases: BaseModel
The unrestricted sandbox used by the full-access preset.
Config:
extra:forbid
Fields:
-
type(Literal['danger-full-access'])
Source code in octomate/tentacles/codex/transcript.py
ActivePermissionProfile
pydantic-model
¶
Bases: BaseModel
Native profiles whose boundaries Octomate can reproduce on a fork.
Fields:
-
id(Literal[':workspace'] | PermissionProfile)
Source code in octomate/tentacles/codex/transcript.py
id
pydantic-field
¶
The built-in legacy profile or an Octomate-selected native profile.
TurnPermissions
pydantic-model
¶
Bases: BaseModel
Permissions recorded in a native rollout's turn_context payload.
Fields:
-
approval_policy(Literal['on-request', 'never']) -
approvals_reviewer(Literal['user', 'auto_review']) -
sandbox_policy(WorkspaceWritePolicy | FullAccessPolicy) -
active_permission_profile(ActivePermissionProfile | None)
Validators:
Source code in octomate/tentacles/codex/transcript.py
active_permission_profile
pydantic-field
¶
Selected native profile, absent in legacy rollouts.
profile_matches_sandbox
pydantic-validator
¶
Source code in octomate/tentacles/codex/transcript.py
is_injected_message ¶
Injected instructions have no normalized archive message to retain.
Source code in octomate/tentacles/codex/transcript.py
context_item_id ¶
The runtime identity of a modeled item, including tool results without ids.
Source code in octomate/tentacles/codex/transcript.py
octomate.tentacles.codex.tailer ¶
Assembly of native Codex turns from a streamed rollout.
Lines streamed in by octomate codex tail feed CodexTranscriptTailer, which
commits each completed turn as an ExternalAgentRun.
PendingCompaction
dataclass
¶
The committed replacement waiting for its native completion item ID.
Source code in octomate/tentacles/codex/tailer.py
OpenTurn
dataclass
¶
The turn being assembled off the stream.
Opened by a task_started line, closed by the task_complete or turn_aborted
naming the same turn id.
Source code in octomate/tentacles/codex/tailer.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
messages
class-attribute
instance-attribute
¶
pending_calls
class-attribute
instance-attribute
¶
visualizations
class-attribute
instance-attribute
¶
unpaired_prompts
class-attribute
instance-attribute
¶
consume_prompt ¶
Read human text once per source occurrence, pairing mirrored formats.
Pair across representations rather than deduplicating by text: the user can send identical prompts twice in one turn, including while it runs.
Source code in octomate/tentacles/codex/tailer.py
SubagentCall
dataclass
¶
One sub_agent_activity line of the parent rollout.
The parent turn and tool call that started or prompted a child thread, and when, so the child's runs can be linked back to it.
Source code in octomate/tentacles/codex/tailer.py
SubagentTail
dataclass
¶
One child thread's rollout within a session's tail.
Its own cursor, conversation, and open turn, plus the parent calls already linked to its committed runs.
Source code in octomate/tentacles/codex/tailer.py
TailState
dataclass
¶
One streamed session. Its rollout lives on the client machine that streams it
(octomate codex tail); the stream route feeds feed_remote, which drives the
per-line assembly. transcript_path is the client's claim in the client's own
namespace, a label never opened here, and the subagent tails' paths are likewise
the client's labels for its sibling files.
Source code in octomate/tentacles/codex/tailer.py
CodexTranscriptTailer ¶
Assembles Codex turns from rollout lines streamed in by octomate codex tail.
The stream is the only assembler — the server never opens a rollout file, even
for a session on this machine. Hooks establish sessions; only the rollout
writes runs, prompts, response items, tool activity, reasoning and usage.
Each connection publishes run brackets and whole-item events at its native
address. Committed and driven turns stay silent; replay of an open turn starts
a fresh fold. The end is published only after the run and ledger are durable. Codex
documents transcript_path for hook convenience while warning that its format
is unstable, so parsing is deliberately narrow and fail-forward.
A parser update does not repair completed imports. To repair a session, stop
its tail and verify the full procedure on a consistent database copy first:
identify only its external runs missing prompts, load those ExternalAgentRun
schemas through Arcanus, clear their end_offset, and commit. Re-stream the
complete original rollout with the same session id and verified sender.
record_external_run replaces the incomplete model history in transcript
order; bind_native_run reuses each existing reply's ledger row by turn id.
Compare run ids, reply ledger ids, prompt timestamps and bindings before and
after, and replay again to check idempotency. Model message ids are replaced,
so inspect shared histories and artifact bindings before selecting any turn.
Never clear offsets automatically or change a live database without approval.
Source code in octomate/tentacles/codex/tailer.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |
stop_turn
async
¶
Request a drain after this turn's terminal line, without holding Stop.
Codex may flush the reply and task_complete only after its hook returns.
A timeout must not finalize the stream before those bytes arrive. An open
turn stays attached until its matching terminal line commits; a turn already
finished can drain immediately. Without a turn id, the idle limit owns exit.
Source code in octomate/tentacles/codex/tailer.py
shutdown
async
¶
attach_remote
async
¶
attach_remote(
session_id: str,
transcript_path: Path,
sender: UserProfile,
address: ChannelAddress,
impulses: ObjectSendStream[Impulse],
) -> tuple[TailState, dict[UUID7, int]]
Register a streamed session — its rollout lives on the client machine
that streams it (octomate codex tail) — and answer where its files resume.
The answer is always byte 0: a rollout's head is load-bearing (session_meta
carries the thread id every child classification checks against, and the
parent's sub_agent_activity lines are what link child runs to their spawning
calls), so a reconnect re-streams whole files and the committed-turn guard
skips what is already durable. Child files are not named here either: the
client registers each file by its opening session_meta and receives
its conversation UUID.
A lingering registration (its client died without a close) is replaced; the dead route feeds the state object it attached, and its commits are idempotent.
Source code in octomate/tentacles/codex/tailer.py
feed_remote
async
¶
feed_remote(
state: TailState,
key: str | None,
raw: str,
start: int,
end: int,
*,
visualizations: list[HtmlSnapshot] | None = None,
) -> None
Advance a remote session by one framed line — the pumps' per-line body,
against offsets the client measured in its own file. Takes the state rather
than a session id so a superseded connection keeps feeding the state it
attached, never whoever registered after it. key is None for the session's
own rollout, else the client's label for a sibling file.
Source code in octomate/tentacles/codex/tailer.py
remote_subagent
async
¶
The child tail a client label maps to, classified on first sight from the
line in hand — discover_subagent's test without the disk read it cannot do
here. The first line is the file's session_meta, because every remote file
streams from byte 0; a label that names no child of this session is
remembered and its lines dropped.
Source code in octomate/tentacles/codex/tailer.py
detach_remote ¶
Drop a remote session's registration. Nothing commits on the way out, eof
or not — a Codex turn closes on its own task_complete/turn_aborted line,
so a turn still open here is mid-flight, and committing it would plant its id
in the committed-turn guard where the completed version could never replace
it. The next connect re-streams from byte 0 and the closed turn lands whole.
Source code in octomate/tentacles/codex/tailer.py
ensure_session
async
¶
Source code in octomate/tentacles/codex/tailer.py
process_line
async
¶
process_line(
state: TailState,
line: RolloutLine,
start: int,
end: int,
*,
visualizations: list[HtmlSnapshot] | None = None,
) -> None
Source code in octomate/tentacles/codex/tailer.py
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
subagent_from_metadata ¶
subagent_from_metadata(
state: TailState, metadata: SessionMetadata, path: Path
) -> SubagentTail | None
A new child tail when the metadata names a thread-spawned child of this
session — the test remote_subagent runs against a file's streamed opening
line.
Source code in octomate/tentacles/codex/tailer.py
prepare_subagent
async
¶
The child's durable state: its conversation under the parent's, and the committed-turn guard seeded from what is already assembled.
Source code in octomate/tentacles/codex/tailer.py
process_subagent_line
async
¶
process_subagent_line(
state: TailState,
tail: SubagentTail,
line: RolloutLine,
start: int,
end: int,
) -> None
Source code in octomate/tentacles/codex/tailer.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | |
record_compaction
async
¶
record_compaction(
state: TailState,
line: RolloutLine,
start: int,
end: int,
*,
tail: SubagentTail | None = None,
native_compaction_id: str | None = None,
last_item_id: str | None = None,
) -> None
Capture summary/checkpoint content without changing the archived turn.
Source code in octomate/tentacles/codex/tailer.py
identify_compaction
async
¶
identify_compaction(
state: TailState,
turn: OpenTurn,
line: RolloutLine,
*,
tail: SubagentTail | None = None,
) -> None
Bind the following completion ID to the already durable replacement.
Source code in octomate/tentacles/codex/tailer.py
close_subagent_turn
async
¶
Source code in octomate/tentacles/codex/tailer.py
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |
close_turn
async
¶
Source code in octomate/tentacles/codex/tailer.py
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | |
capture_html
async
¶
Persist client snapshots and bind them to the completed native response.
The bearer supplies ownership; client paths are labels only. Artifacts use the existing file storage, ledger and event stream before the run closes.
Source code in octomate/tentacles/codex/tailer.py
turn_belongs_to_subagent
staticmethod
¶
Source code in octomate/tentacles/codex/tailer.py
uuid7_timestamp
staticmethod
¶
parse_usage
staticmethod
¶
Source code in octomate/tentacles/codex/tailer.py
consume_turn_context
staticmethod
¶
Source code in octomate/tentacles/codex/tailer.py
consume_completed_command
staticmethod
¶
Source code in octomate/tentacles/codex/tailer.py
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 | |
consume_response_item
staticmethod
¶
consume_response_item(
turn: OpenTurn,
line: RolloutLine,
*,
captured: bool = False,
) -> Iterator[AgentStreamEvent]
Yield whole items, hiding captured references without editing the rollout.
Source code in octomate/tentacles/codex/tailer.py
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |
octomate.tentacles.deepseek.tailer ¶
Assembly of native dsh turns from a streamed session log.
History entries streamed in by octomate deepseek tail feed DeepseekEventTailer,
which commits each completed turn as an ExternalAgentRun.
PendingPrompt
dataclass
¶
One human user/message — the ledger row's raw material.
Source code in octomate/tentacles/deepseek/tailer.py
OpenTurn
dataclass
¶
The turn currently being assembled off the stream — its accumulator fed entry by entry, its seq range advancing to cover the last one folded in.
Source code in octomate/tentacles/deepseek/tailer.py
accumulator
class-attribute
instance-attribute
¶
TailState
dataclass
¶
One streamed session. Its log lives on the client machine that streams
it (octomate deepseek tail, reading that machine's dsh gateway); the
stream route feeds feed_remote, which drives the per-event assembly.
transcript_path is the client's claim in the client's own namespace, a
label never opened here.
Source code in octomate/tentacles/deepseek/tailer.py
DeepseekEventTailer ¶
Assembles native dsh turns from history entries streamed in by
octomate deepseek tail — the stream is the only assembler: the server
never opens a session log and never speaks to the client machine's dsh.
The client reads its local gateway (session.history, which serves the
zstd-framed log decoded and unpacked, cold sessions included) and ships
each entry as one framed line, the event's dense seq standing where a
file tail's byte offsets stand. Entries fold through the same
DeepseekRunAccumulator the driven tentacle uses; a turn commits on its
own turn/end line as an ExternalAgentRun keyed <session>:<turn>,
carrying the seq range it was assembled from — the committed floor a
reconnecting client is told to resume past. An open turn never commits at
a connection boundary: the next connect re-streams it whole.
Source code in octomate/tentacles/deepseek/tailer.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
attach_remote
async
¶
attach_remote(
session_id: str,
transcript_path: Path,
cwd: str,
sender: UserProfile,
address: ChannelAddress,
impulses: ObjectSendStream[Impulse],
) -> tuple[TailState, dict[UUID7, int]]
Register a streamed session and answer where it resumes: the seq after the committed floor, recomputed from the durable runs — the client holds no cursor of its own. A lingering registration (its client died without a close) is replaced; the dead route keeps feeding the state it attached, and its commits are idempotent.
Source code in octomate/tentacles/deepseek/tailer.py
feed_remote
async
¶
Fold one history entry; the route validates the sequence framing.
Source code in octomate/tentacles/deepseek/tailer.py
detach_remote ¶
Drop a streamed session's registration. Nothing commits on the way
out — a dsh turn closes on its own turn/end line, so a turn still
open here is mid-flight, and the next connect re-streams it whole from
the committed floor.
Source code in octomate/tentacles/deepseek/tailer.py
stop_turn
async
¶
The turn just stopped — its Stop hook fired: wait for the stopped
turn's streamed close to commit, then ask the drain. Runs detached
from the hook (dsh's stopping seam waits on the hook serially, ahead
of the very turn/end this waits for). A session no stream covers has
nothing to settle: its turns land at the next connect.
Source code in octomate/tentacles/deepseek/tailer.py
shutdown
async
¶
session_thread
async
¶
Reuse the session thread attributed at authenticated entry.
Source code in octomate/tentacles/deepseek/tailer.py
process_entry
async
¶
Source code in octomate/tentacles/deepseek/tailer.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
record_prompt
async
¶
Keep each human input where it occurs, including mid-turn steering.
The event seq is stable across reconnects, even before dsh reports a turn number. Its ledger row grants access while the turn is still streaming.
Source code in octomate/tentacles/deepseek/tailer.py
fold
async
¶
Fold and publish one entry, dating messages by the log's clock.
Committed seqs never reach the fold. The native thread receives only run brackets, with the end delivered after its ledger binding commits. Re-streaming an open turn starts it again without waking a reflex.
Source code in octomate/tentacles/deepseek/tailer.py
commit_turn
async
¶
Source code in octomate/tentacles/deepseek/tailer.py
record_permission_mode
async
¶
Keep the conversation's posture at what the session log last said. Observed names are retained even when absent from the driven catalog.
Source code in octomate/tentacles/deepseek/tailer.py
committed_floor ¶
The highest event seq any committed turn covers — the stream resumes at the seq after it.
Source code in octomate/tentacles/deepseek/tailer.py
event_time ¶
stamp ¶
Date the messages an event produced by that event's own clock — the
accumulator stamps now, which is wrong for a turn replayed off the log
(AgentRun.started_at and ordering both read from these).
Source code in octomate/tentacles/deepseek/tailer.py
human_prompt ¶
The human's own words in a user/message, or None. dsh logs injected
user-role messages in the same turn — agent-instructions, plugin
runtime context — which are the harness talking, not the ledger's prompt;
human prompts and late question replies are the person's input.