Trunkline¶
octomate.tentacles.trunkline.routes ¶
The Trunkline console HTTP surface, mounted under /api/trunkline.
The console is an entry and a reader, and it reads the domain in the shape the domain has: a thread, the conversations under it, the runs under those, and the thread's chat messages. Every read answers with the transmuter itself rather than a console-shaped copy of it, so the payload is the row.
What a read leaves out it leaves out deliberately. A thread's messages are their own request, because a listing that carried every thread's ledger would be the ledger; and a run's model messages leave only a page at a time, since one run can hold thousands. Both pages are Arcanus keyset pages, newest first.
Both halves of leaving something out are load-bearing. response_model_exclude
keeps a relation out of the payload; it does nothing about the query, and every
relation named here is lazy="selectin". The managers suppress the load itself
(ThreadManager.get(with_messages=...), ConversationManager.for_thread), so
these reads do not fetch a ledger to drop it.
Every read under a thread reads the thread first, and 404s on an id the relay does not know — a sub-resource of a thread that does not exist must say so rather than answer the empty list its query would return. Only the ledger read asks for the messages; the rest want the row.
Directives create or continue threads on the trunkline channel itself. Directives,
batch responses and thread operations are answered as soon as their kick is on
its way, and what the run does reaches the console over /live: a websocket
that carries a thread's wire events for as long as it is open, named by the
thread's row id or, for a Trunkline thread with no row yet, by the key its
directives carry. The kick's reflex_asleep arrives there last.
Thread operations act on a thread of any channel the user can access.
GET threads/{id}/operations answers a ThreadOperations, which the console reads
when its operation controls open. GET threads/{id}/channels/{channel}/addresses
lists one level of a connected channel's destinations as ChannelAddress rows
whose metadata carries a name: a row with metadata.inside is a place to open,
by passing that value back as ?inside=, and metadata.barred says why a thread
cannot land in a row. A channel that cannot be browsed, has no connected agent or
is not linked to the user answers 409. A listed address is a suggestion, validated
again when Teleport submits it. POST threads/{id}/teleport takes a
TeleportBody and POST threads/{id}/summon a SummonBody. Both refuse a thread
with a turn running or approvals or questions pending; the turn then shows on the
live socket as a gateway event when the conversation moves, a run_started
event opening each run, and a run_error when the turn fails.
Where the work happened — a thread's project and a run's directory — is read here and nowhere written: a thread's project is frozen when its row is written, and both are learned from the session that ran, so no endpoint takes either.
A conversation's approval posture is the exception: it is the console's to change mid-thread, and the conversation is what remembers it. It is switched through PATCH, or — while the thread is still being composed and has no row to switch — carried on the directive that creates it.
RouteInfo
pydantic-model
¶
Bases: BaseModel
One route a directive may name, as GET /routes lists it.
Fields:
-
id(str) -
agent(str) -
model(AgentRouteModelName | None)
Source code in octomate/tentacles/trunkline/routes.py
ChannelInfo
pydantic-model
¶
Bases: BaseModel
One connected channel tentacle, as GET /channels lists it.
Fields:
Source code in octomate/tentacles/trunkline/routes.py
DirectiveBody
pydantic-model
¶
Bases: BaseModel
The body of a directive sent to a thread.
The text, and the route, project, and posture a thread's first directive may pick.
Fields:
-
text(str) -
message_id(str | None) -
model(str | None) -
project(str | None) -
permission_mode(AgentPermissionMode | None) -
effort(str | None)
Source code in octomate/tentacles/trunkline/routes.py
model
pydantic-field
¶
A route id from GET /routes ('agent:model'). Honored only on a thread's first directive; a differing pick on an owned thread is refused with 409 (re-routing needs a manual handoff).
project
pydantic-field
¶
A project name from GET /projects, filing the thread under it. Honored only on a thread's first directive, since a thread's project is frozen when the row is written; null is a real answer, and leaves the thread a chat that is in no project at all.
permission_mode
pydantic-field
¶
A posture from GET /permissions, in the vocabulary of the agent this thread is routed to, stored on that agent's conversation before the run. This is how a thread that does not exist yet gets one; an owned thread's is switched through PATCH /conversations/{id}/permission-mode. Null asks for no change, and never clears a posture already stored.
effort
pydantic-field
¶
An effort level advertised by the selected model, stored before the first run. Null leaves the conversation's selection unchanged.
TeleportBody ¶
Bases: TypedDict
A teleport asked from the console. new_thread is true unless sent; the
console sends none, so Teleport opens a thread at the destination picked. A
prompt is the user's next message in the Trunkline thread the move lands
in, and any other destination refuses it.
Source code in octomate/tentacles/trunkline/routes.py
prompt
instance-attribute
¶
SummonBody ¶
Bases: TypedDict
A summon asked from the console: the agent and model that take the conversation over where it is, the brief they start from, and the hint recorded with the handoff.
Source code in octomate/tentacles/trunkline/routes.py
AgentPostures
pydantic-model
¶
Bases: BaseModel
An agent's approval modes and default, as GET /permissions lists them.
Fields:
Source code in octomate/tentacles/trunkline/routes.py
accessible_thread
async
¶
accessible_thread(
thread_id: UUID7,
threads: Annotated[
ThreadManager, Depends(thread_manager)
],
user: Annotated[User, Depends(current_user)],
) -> Thread
Source code in octomate/tentacles/trunkline/routes.py
thread_gateway
async
¶
thread_gateway(
thread: Annotated[Thread, Depends(accessible_thread)],
user: Annotated[User, Depends(current_user)],
app: Annotated[Octomate, Depends(application)],
gateway: Annotated[
GatewayManager, Depends(gateway_manager)
],
actions: Annotated[
DeferredActionManager,
Depends(deferred_action_manager),
],
users: Annotated[UserManager, Depends(user_manager)],
threads: Annotated[
ThreadManager, Depends(thread_manager)
],
workspaces: Annotated[
WorkspaceManager, Depends(workspace_manager)
],
) -> OctomateSession
Source code in octomate/tentacles/trunkline/routes.py
build_trunkline_router ¶
Build the console HTTP router bound to a registered TrunklineTentacle.
Source code in octomate/tentacles/trunkline/routes.py
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 | |
build_trunkline_live_router ¶
Build the console's live socket router. It is a router of its own because the console router runs the same-origin write guard on every request, and a handshake has no method for that guard to read.
Source code in octomate/tentacles/trunkline/routes.py
octomate.schemas.operations ¶
Thread operations exposed to authenticated clients.
OperationAvailability
pydantic-model
¶
Bases: BaseModel
Whether one operation can run on a thread, and with what.
Fields:
-
destinations(list[ChannelAddress]) -
here(ChannelAddress | None) -
routes(dict[str, list[AgentRoute]]) -
reason(str | None)
Source code in octomate/schemas/operations.py
destinations
pydantic-field
¶
Suggested places to go. An empty list sets no reason by itself: the destination browser can still find one.
here
pydantic-field
¶
For Summon, this conversation's own address, where it is handed over.
routes
pydantic-field
¶
What the operation can run, keyed by channel id: for Summon, every other agent on this conversation's own channel; for Teleport, the conversation's own on each connected channel, where a channel with none cannot be the destination.
ThreadOperations
pydantic-model
¶
Bases: BaseModel
What the console may do with a thread: each operation's availability, the thread's own surface, and the channels nothing can land in.
Fields:
-
source(ChannelAddress | None) -
teleport(OperationAvailability) -
summon(OperationAvailability) -
barred(dict[str, str])
Source code in octomate/schemas/operations.py
source
pydantic-field
¶
The surface this conversation is on. Its shared, against a destination's, is what a client warns by before private history lands in a shared place.
barred
pydantic-field
¶
Connected channels where no conversation can land, keyed by channel id, with why: shown to either operation, never picked.