Documentation
¶
Overview ¶
Package channel defines the connector seam. Connectors self-register via Register (one package + one init line each) and decode their own raw JSON config section, so adding WhatsApp/Twilio/Slack/... never touches core.
Index ¶
- Variables
- func BindTurns(ch Channel, wait, steer TurnFunc)
- func Register(name string, f Factory)
- func Registered() []string
- func SplitMessage(content string, limit int) []string
- func Validate(cfgs map[string]json.RawMessage) error
- type Addresser
- type Channel
- type Factory
- type Guarded
- type Manager
- type Steerable
- type Toolset
- type TurnFunc
- type TurnRunner
- type Typer
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownChannel = fmt.Errorf("unknown outbound channel")
ErrUnknownChannel reports an outbound message for a channel the manager does not own.
Functions ¶
func BindTurns ¶ added in v0.30.2
BindTurns wires a connector's turn runner to the entry point its replies can come back through: steer where Steerable says the bus can deliver them, wait where they have to be returned here. A connector that does not run its own turns is left alone.
func SplitMessage ¶
SplitMessage chunks content at a channel's length limit, preferring newline then space boundaries.
func Validate ¶ added in v0.26.0
func Validate(cfgs map[string]json.RawMessage) error
Validate builds every enabled, known section against a throwaway bus and reports the first one its connector rejects. It is what the gateway checks before reloading itself over a config edit: Build skips a broken section with a log line, which under a live reload would silently drop a channel the user only mistyped. Nothing is started; the constructions are discarded.
Types ¶
type Addresser ¶ added in v0.16.0
Addresser is the optional capability of a connector that sometimes has to hand a message to the user's usual written conversation — a spoken exchange asked to answer in writing. The host binds where that is: the gateway hands it the loop's last external chat, the CLI its own terminal session. Bound before Start.
type Channel ¶
type Channel interface {
Name() string
Start(ctx context.Context) error
Stop() error
Send(ctx context.Context, msg bus.OutboundMessage) error
MaxMessageLength() int // 0 = unlimited
}
Channel is one chat connector. Start must be non-blocking (spawn your own goroutines off ctx); Send delivers one already-chunked message.
func Build ¶
func Build(cfgs map[string]json.RawMessage, b *bus.MessageBus) []Channel
Build instantiates every enabled configured channel. Unknown or disabled sections are skipped with a log line, never an error, so configs stay forward-compatible.
type Factory ¶
type Factory func(raw json.RawMessage, b *bus.MessageBus) (Channel, error)
Factory builds a channel from its raw config section.
type Guarded ¶ added in v0.15.0
Guarded is the optional capability of a connector that reads or writes files itself — sending a chat a local file, saving one it received — and so must obey the same path rules as every file tool. Bound before Start.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager starts channels and pumps the outbound bus to them with chunking and bounded retry.
func NewManager ¶
func NewManager(b *bus.MessageBus, channels []Channel) *Manager
func (*Manager) Interim ¶ added in v0.7.0
Interim delivers a note from a turn that is still running to the chat it belongs to, so a long turn reads as work in progress rather than silence. It goes through the outbound bus like any reply, keeping it in order with the answer that follows. Sessions of channels this manager does not own (cli, cron, jobs) are ignored.
func (*Manager) Serves ¶ added in v0.11.0
Serves reports whether a connector is running for this channel — whether a message addressed to it can actually reach the user.
func (*Manager) SetTyping ¶ added in v0.2.2
SetTyping routes a session's busy state to the channel it belongs to, for connectors that can show one. Session keys of channels this manager does not own (cli, cron, heartbeat) are ignored.
type Steerable ¶ added in v0.30.2
type Steerable interface {
AcceptsSteering()
}
Steerable is the optional capability of a TurnRunner whose replies also reach the user through Send. It says a turn this connector starts may be folded into one already live for the same session — a background job reporting back, a cron result — instead of queuing behind it: the words land while they are still what the conversation is about, and the running turn's reply comes back the usual way. Without it a connector's turn waits for the session, which is what a phone call needs, since a reply published to the bus would be dialled as a second call rather than spoken on the line the caller is holding.
type Toolset ¶ added in v0.4.0
Toolset is the optional capability of contributing tools that only make sense where the connector is configured, so a machine without it never sees a tool that could only fail.
type TurnFunc ¶ added in v0.4.0
type TurnFunc func(ctx context.Context, content, sessionKey, speaker, audience string, notice func(string)) (string, error)
TurnFunc runs one synchronous turn and returns the reply (wired to Loop.ProcessDirectNotice). notice is called with each line the agent says on its way to that reply — "let me look that up" — as it says it, so a turn spent in tool calls is audible progress rather than a silence the user cannot tell from a hang. It runs on the turn's own goroutine, so a connector that takes time to deliver a note must not block in it. speaker names who is talking where the connector can tell (the microphone recognizing a household voice); blank means "whoever this chat is". audience says who can hear the reply — tools.AudienceShared where the connector knows somebody besides the user is present, blank everywhere else. It is separate from speaker because the two answer different questions: speaker decides attribution, audience decides discretion.
type TurnRunner ¶ added in v0.4.0
type TurnRunner interface {
BindTurnRunner(run TurnFunc)
}
TurnRunner is the optional capability of a connector that runs turns itself instead of publishing them onto the bus. A phone call is synchronous — the caller is waiting on the line, and hanging up must cancel the turn — so the bus's fire-and-forget shape does not fit it.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package phone is the voice connector: the user talks to Factor on a real phone call, and Factor can call or text back.
|
Package phone is the voice connector: the user talks to Factor on a real phone call, and Factor can call or text back. |
|
files.go moves files across the chat, both ways: attachments the user sends are downloaded into the workspace and handed to the model as a local path, and the telegram_send_file tool lets the agent hand the user an actual file — a report it wrote, a screenshot, a download — instead of describing one.
|
files.go moves files across the chat, both ways: attachments the user sends are downloaded into the workspace and handed to the model as a local path, and the telegram_send_file tool lets the agent hand the user an actual file — a report it wrote, a screenshot, a download — instead of describing one. |
|
Package voice is the PC voice connector: the user talks to Factor through the machine's own microphone and hears it through the speakers.
|
Package voice is the PC voice connector: the user talks to Factor through the machine's own microphone and hears it through the speakers. |