chat

package
v0.59.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package chat is the provider-agnostic chat core (v5 §4, §6.2): the shapes a chat adapter speaks in (threads, actors, events, messages, cards and the provider's raw proof), the Provider interface an adapter implements, the write grammar's action ids, the pure Confirm rules, and the broker client for /mcp and /api/chat/*. It imports no provider SDK and no Kubernetes package: a provider lives in its own subpackage (internal/chat/slack) and maps itself onto these types.

Index

Constants

View Source
const (
	MirrorPosted     = "posted"      // the comment is on the issue
	MirrorDuplicate  = "duplicate"   // this amendment was mirrored before
	MirrorPending    = "pending"     // the comment could not be posted: the amendment is recorded only
	MirrorNoIssue    = "no_issue"    // the task has no issue to post on
	MirrorNotAllowed = "not_allowed" // standing changed after the check: recorded, never posted
)

What became of an amendment's issue comment (AmendResult.Mirror) when its result is "amended": the amendment is in the room's log whichever it is, and a signed click is never asked for again.

View Source
const (
	DecisionTitle        = "Approval needed: push to the forge"
	DecisionApproveLabel = "Allow the push"
	DecisionDenyLabel    = "Deny"
)

The forge.push card's fixed words: its title, its two buttons and where a read-only card sends the reader. They are the room page's own, and name no person, reason or room text.

View Source
const (
	// ProposalEventType tags a proposal's message metadata: its payload is a Proposal.
	ProposalEventType = "factory_proposal"
	// FiledEventType tags the message that closed a proposal: filed, or cancelled.
	FiledEventType = "factory_filed"

	// ActionProposalCancel is the proposal card's Cancel: an adapter-local id (R3), never forwarded to
	// the broker, verified through POST /api/chat/verify on a signed transport (R-B3).
	ActionProposalCancel = "factory_proposal_cancel"
	// ActionProposalRepo is a repository button of the DM's repository question, adapter-local too.
	ActionProposalRepo = "factory_proposal_repo"

	// ReasonPrivateDisabled is /api/chat/repos' reason for a private repository Lock 3 keeps out of chat.
	ReasonPrivateDisabled = "chat_private_repos_disabled"

	// NotAuthorLine is the one notice, to the person alone, for a mention, reply or click on someone
	// else's open proposal (§4.5): the proposal is never changed by it.
	NotAuthorLine = "This proposal belongs to the person who asked for it, and only they can change or confirm it. " +
		"Start your own with a new mention or a direct message."
	// NotRequesterLine is the answer to a Confirm pressed by anyone but its requester (§4.5).
	NotRequesterLine = "Only the requester can confirm this action."
)
View Source
const (
	PausePlanReview    = "plan_review"
	PauseSplitProposed = "split_proposed"
	PauseNeedsAuthor   = "needs_author"
)

The pauses a filed task can wait in, as the factory's reason codes name them.

View Source
const (
	TransportSocket = "socket"
	TransportEvents = "events"
)

The transports a provider's events arrive over. Socket is unsigned (Slack Socket Mode): the broker takes the adapter's identity envelope. Events is signed (Slack's Events API): the broker verifies the provider's raw bytes and the adapter never holds the signing secret.

View Source
const (
	ActionConfirmStop        = "confirm:stop"
	ActionConfirmAnswer      = "confirm:answer"
	ActionConfirmSteer       = "confirm:steer"
	ActionConfirmAmend       = "confirm:amend"
	ActionConfirmRetry       = "confirm:retry"
	ActionConfirmRetryDeeper = "confirm:retry_deeper"
	ActionDecideApprove      = "decide:approve"
	ActionDecideDeny         = "decide:deny"
	ActionPlanApprove        = "plan:approve"
	ActionPlanRevise         = "plan:revise"
	ActionPlanSplit          = "plan:split"
	ActionSplitAccept        = "split:accept"
	ActionSplitDecline       = "split:decline"
	ActionConfirmTask        = "confirm:task"
)

The write grammar (v5 §3.3, the broker's chatActions): the only action ids sent to /api/chat/*, a closed set per route. Adapter-local controls (cancel, workflow pin, plan-first, the buttons that open a Confirm) keep their own provider ids and are never forwarded.

View Source
const (
	EventMention    = "mention"     // the App was mentioned
	EventMessage    = "message"     // a message in a thread or DM the App reads
	EventAction     = "action"      // a button or select on one of the App's messages
	EventReaction   = "reaction"    // a reaction added to a message
	EventHomeOpened = "home_opened" // the App's home was opened
)

The kinds of IncomingEvent.

View Source
const (
	StylePrimary = "primary"
	StyleDanger  = "danger"
)

The styles a button may have.

View Source
const DefaultConfirmTTL = 10 * time.Minute

DefaultConfirmTTL is how long a Confirm card stays clickable (the broker's confirmTTL default).

View Source
const HandoffIDPattern = `^[a-z2-7]{26}$`

HandoffIDPattern is a handoff id's and a link code's shape: 26 base32 characters.

View Source
const MaxAnswerText = 2 << 10

MaxAnswerText is an answer's bound in bytes, as the factory caps the answer it records.

View Source
const OutcomeCounted = ""

OutcomeCounted is the outcome a Deliver returns when it counted its own word instead of handing one back (Slack's approval close does), so one request keeps one outcome.

Variables

View Source
var (
	ErrNotRequester     = errors.New("chat: only the requester may confirm")
	ErrConfirmExpired   = errors.New("chat: the confirm has expired")
	ErrTextHash         = errors.New("chat: the card's text is not the text the confirm bound")
	ErrConfirmMalformed = errors.New("chat: the button's value is not a confirm")
	ErrUnknownAction    = errors.New("chat: the action is not in the write grammar")
)

The refusals of a Confirm click and of a value that cannot be built.

View Source
var ErrNoRoom = errors.New("chat: no such room")

ErrNoRoom is a Put for a room the broker does not have (404 not_found).

View Source
var ErrThreadConflict = errors.New("chat: the thread or room is bound elsewhere")

ErrThreadConflict is a thread or a room already bound to another binding (409 thread_conflict).

View Source
var ErrUnknownTool = errors.New("chat: the broker does not offer this tool")

ErrUnknownTool is the broker without the tool asked: the self-serve link is off there.

View Source
var ErrUnverified = errors.New("chat: the broker did not verify the provider's event")

ErrUnverified is a provider event the broker did not verify: a bad or stale signature, another workspace, an event kind it does not answer, or a provider not on a signed transport.

WriteActions is the whole grammar, in the order above.

Functions

func Bound

func Bound(i intent.Intent, text string) string

Bound is text as i's Confirm binds it and its route is sent it (R15): no control or format character, and within i's bound in bytes, cut on a rune. A revise note and an answer are one line, as the factory records them; a steer and an amendment keep their lines. "" for an intent that carries no text, or a text that is blank.

func ButtonValue

func ButtonValue(action string, target ConfirmPayload, text, by string) (string, error)

ButtonValue is the value a grammar button carries: the target, th over text when text is not empty (intent.ConfirmHash, the broker's one definition), and by on every button but a decision's.

func FeedLine

func FeedLine(repository, room, phase, roomsURL string, facts FeedFacts) string

FeedLine is the feed's one line for a room: "<repo> · issue #N <url> · PR #N <url> · <phase> · <room URL> · @<login>", each part left out when its value is not in its shape, and only the phase and the room URL for a restricted room or a repository the line cannot name.

func FiledRooms

func FiledRooms(res ActionResult) []string

FiledRooms is every room a filing made, the first one first.

func IsWriteAction

func IsWriteAction(id string) bool

IsWriteAction reports whether id is one of the grammar's action ids.

func LockedLine

func LockedLine(locked []Repo, roomsURL string) string

LockedLine is one sentence naming the private repositories chat may not file in and the Room UI that can; "" when there are none.

func MaxCost

func MaxCost(caps ...float64) float64

MaxCost is the effective ceiling (§2.4): the lowest cap that is set. A DM passes the workflow's and the principal's; a bound channel adds its own.

func NeedsPause

func NeedsPause(p Phrase, f ThreadFacts) bool

NeedsPause reports whether RouteReply reads f.Pause for p, so the adapter reads the room's task only then: a requester's phase-bound write whose act is on, or a requester's free text where a capture (answer, plan revise) is on.

func NeedsRequester

func NeedsRequester(id string) bool

NeedsRequester reports whether a button with id carries "by" and is held to confirmTTL: every write but a decision, which any maintainer may press and whose approval has its own expiry.

func OpenToThread

func OpenToThread(i intent.Intent) bool

OpenToThread reports whether anyone in the thread may draw i's Confirm, not only its requester: the split decisions, a maintainer's card (spec §4.5's exemption from author isolation). The Confirm stays bound to whoever drew it, and the factory decides their standing (a maintainer with write). Every other write is the requester's or the filer's (R13).

func PROpenedLine

func PROpenedLine(repository string, pr int) string

PROpenedLine is room.pr_opened's thread line: the pull request's link when the thread row's repository builds one, the plain line otherwise.

func PRURL

func PRURL(repository string, pr int) (string, bool)

PRURL is a pull request's GitHub URL, built from a repository in GitHub's owner/name shape and a positive number (Bug #8a: the webhook carries the number only); false for anything else.

func Phrases

func Phrases() []string

Phrases is tier 0's table, sorted: every phrase a thread understands without a model.

func RoomURL

func RoomURL(roomsURL, room string) string

RoomURL is a room's Room UI page under roomsURL.

func SignedDecisions

func SignedDecisions(transport string, allowUnsigned bool) bool

SignedDecisions reports whether a decide button may be drawn (SS4 / AC4): the Events API signs every click, and under Socket Mode only a provider whose broker allows unsigned decisions takes one. A mismatch with the broker's own setting only fails closed: buttons it refuses.

Types

type ActionClick

type ActionClick struct {
	ActionID  string
	Value     string
	MessageID string
	MessageAt time.Time
	BoundText string
	TriggerID string
}

ActionClick is one button press: the action id, the value the button carried, the message it was on, when that message was posted (what confirmTTL is measured from) and the text the message's one bound block showed (Slack: the maku_text section), "" when it had none.

type ActionRequest

type ActionRequest struct {
	Provider  string    `json:"provider"`
	Transport string    `json:"transport"`
	Room      string    `json:"room,omitempty"`
	Approval  string    `json:"approval,omitempty"`
	Branch    string    `json:"branch,omitempty"`
	Handoff   string    `json:"handoff,omitempty"`
	PlanHash  string    `json:"planHash,omitempty"`
	Action    string    `json:"action,omitempty"`
	Text      string    `json:"text,omitempty"`
	Workspace string    `json:"workspace,omitempty"`
	User      string    `json:"user,omitempty"`
	Channel   string    `json:"channel,omitempty"`
	Thread    string    `json:"thread,omitempty"`
	Value     string    `json:"value,omitempty"`
	Proof     *RawProof `json:"proof,omitempty"`
}

ActionRequest is the broker's ChatActionRequest, the one envelope every action route reads. Under the events transport the broker reads only Provider, Transport, the target (Room, Approval, Branch, Handoff, PlanHash), Text and Proof, and the target must equal what the signed value names; under socket there is no proof and Workspace, User, Channel, Thread, Action and Value are the identity envelope the route checks. A filing (FileTask) names Handoff and PlanHash and never a Room (R1).

type ActionResult

type ActionResult struct {
	Result    string `json:"result"`
	Status    int    `json:"-"`
	Task      string `json:"task,omitempty"`
	Room      string `json:"room,omitempty"`
	Issue     int    `json:"issue,omitempty"`
	URL       string `json:"url,omitempty"`
	Duplicate bool   `json:"duplicate,omitempty"`
	// Issues is every task a filing made, in plan order (POST /api/chat/tasks): all of a wholePlans
	// plan's rooms, each bound to the thread by the broker.
	Issues []FiledIssue `json:"issues,omitempty"`
}

ActionResult is an action route's answer: the closed code and the HTTP status it came with (the routes answer refusals with 400, 403, 409, 429 or 503 and a code, and the code is what the adapter's line reads). A filing that filed carries the factory's task, its room, issue and page.

func FileConfirmed

func FileConfirmed(ctx context.Context, f TaskFiler, b RoomBinder, req ActionRequest, in Filing, log *slog.Logger) (ActionResult, error)

FileConfirmed sends one confirm:task and, once filed, makes sure every room it made is followed in the thread with its author and filer (§4.6, Bug #8b). The broker binds each room in chat_threads itself; b is the caller's own thread store, read by room: a room b does not hold yet is put (with the broker's store that is a room an older broker did not bind; with an adapter's local map, every new room), and a room b already holds is left as it is. A binding failure is logged: the task is filed either way.

type Actor

type Actor struct {
	Workspace string
	User      string
}

Actor is the person an event came from, in their provider's ids.

type AmendResult

type AmendResult struct {
	ActionResult
	Mirror string `json:"mirror,omitempty"`
}

AmendResult is POST /api/chat/amends's answer: the closed code and its status, and Mirror when the code is "amended".

type Binding

type Binding struct {
	Repositories []string
	MaxCostUSD   float64
}

Binding is a team channel's static binding; a DM has none and asks the broker.

type Broker

type Broker struct {
	URL    string // the broker's base URL, from config only
	Tokens *Tokens
	HC     *http.Client // httpx.New in production
	// AmendHC, when set, is the client Amend alone uses: the amend route answers within its own
	// budget (humanapi.DefaultChatAmendBudget, a check plus a mirror), which outlasts HC's bound.
	AmendHC *http.Client
}

Broker is the room-broker's MCP endpoint, called as the App's own principal. It never calls tasks/*: the App follows a room through webhooks.

func (Broker) Amend

func (b Broker) Amend(ctx context.Context, r ActionRequest) (AmendResult, error)

Amend records one confirm:amend click's text as the task's amendment and mirrors it onto the issue (POST /api/chat/amends). The broker may take up to the factory's mirror retries to answer.

func (Broker) Answer

func (b Broker) Answer(ctx context.Context, r ActionRequest) (ActionResult, error)

Answer records one confirm:answer click with the text the card bound (POST /api/chat/answers).

func (Broker) Call

func (b Broker) Call(ctx context.Context, tool string, args map[string]any) (json.RawMessage, error)

Call is one stateless tools/call, answering the tool's structuredContent. A 401 drops the token and retries once with a new one; ErrUnknownTool is a broker without the tool and a Refused its refusal.

func (Broker) Decide

func (b Broker) Decide(ctx context.Context, r ActionRequest) (ActionResult, error)

Decide records one decide:approve or decide:deny click (POST /api/chat/decisions).

func (Broker) FileTask

func (b Broker) FileTask(ctx context.Context, r ActionRequest) (ActionResult, error)

FileTask files the stored handoff plan one confirm:task click names (POST /api/chat/tasks): the broker files the plan it stored under Handoff and PlanHash and binds the click's thread itself.

func (Broker) Handoff

func (b Broker) Handoff(ctx context.Context, in HandoffRequest) (HandoffResult, error)

Handoff is that tool's one call. A key the tool does not take is never sent: a sponsored principal states whom it plans for and the channel's ceiling on every call, since the broker checks both again on a continuation. ErrUnknownTool comes back untouched, and so does the planner-off line (a Refused), so the caller answers the mention's own line.

func (Broker) HandoffCheck

func (b Broker) HandoffCheck(ctx context.Context, id, onBehalfOf string, workflow *string) (HandoffChecked, error)

HandoffCheck is handoff_check for the Slack user named: the stored plan, its hash and the workflows they may choose. workflow nil changes nothing; a value pins that workflow ("" for the factory's choice), which re-validates the stored plan and stores its new hash. It files nothing.

func (Broker) HandoffCheckOutcome

func (b Broker) HandoffCheckOutcome(ctx context.Context, id, onBehalfOf, outcome string) (HandoffChecked, error)

HandoffCheckOutcome is handoff_check setting the stored plan's outcome (e.g. plan-first).

func (Broker) Home

func (b Broker) Home(ctx context.Context, team, user string) (Home, error)

Home reads user's App Home. team, when set, is sent as the workspace: the broker refuses one that is not the caller's own.

func (Broker) Inbox

func (b Broker) Inbox(ctx context.Context, room string) ([]summary.Need, error)

Inbox is inbox for one room: the needs/v1 items alone. A sponsored caller reads a room's needs, never a login's, and each item's action is a link it cannot follow for anyone (CD26).

func (Broker) IntentClassify

func (b Broker) IntentClassify(ctx context.Context, in IntentRequest) (IntentResult, error)

IntentClassify is that tool's one call. ErrUnknownTool is a broker without human.slackIntents, and a Refused is one of the closed words (not_linked, capped, ...): the caller branches on neither more than to fall back to today's line.

func (Broker) Plan

Plan records one plan:approve, plan:revise or plan:split click (POST /api/chat/plans). A revise's note is Text, one line within intent.MaxPlanNote; the other two carry none.

func (Broker) Repos

func (b Broker) Repos(ctx context.Context, user string) (Repos, error)

Repos reads the repositories one chat user of the App's own provider and workspace may file into.

func (Broker) Retry

Retry records one confirm:retry or confirm:retry_deeper click (POST /api/chat/retries).

func (Broker) RoutineDigest

func (b Broker) RoutineDigest(ctx context.Context, repos []string, window string) (RoutineDigest, error)

RoutineDigest fetches GET /api/routines/digest from the broker with the App's token.

func (Broker) RunCreate

func (b Broker) RunCreate(ctx context.Context, c RunCreate) (RunResult, error)

RunCreate files the run. Its arguments are run_create's schema exactly: `text` is the draft's body and dataClass is always public. A proposal sends `handoff` (and `plan_hash`, the hash it showed) in place of the repository's issue: the broker files the plan it stored, so the App carries no plan and no body (UX2).

func (Broker) SlackLinkCode

func (b Broker) SlackLinkCode(ctx context.Context, team, user, handle, name string) (string, error)

SlackLinkCode asks the broker for a one-time link for the Slack user, handle and name shown on the page. The answer must be the link page with one code, or it is not passed on to the user.

func (b Broker) SlackUnlink(ctx context.Context, team, user string) (bool, error)

SlackUnlink asks the broker to remove the Slack user's link; unlinked is false when none was.

func (Broker) Split

Split records one split:accept or split:decline click (POST /api/chat/splits).

func (Broker) Steer

Steer queues one confirm:steer click's text for the task's next run (POST /api/chat/steers): never a live turn to a running agent.

func (Broker) Stop

Stop records one confirm:stop click (POST /api/chat/stops).

func (Broker) Verify

func (b Broker) Verify(ctx context.Context, p RawProof) (string, error)

Verify forwards a non-action provider event to POST /api/chat/verify exactly as it came: its raw bytes as the body and its headers as headers. It answers the verified workspace ("" for an event that names none, a url_verification); ErrUnverified is the broker's permanent refusal (a 403 included, plain or not: the App's principal is not this provider's), any other error transport (503 included), so the caller answers the provider with a retryable status.

type BrokerThreadStore

type BrokerThreadStore struct {
	Broker Broker
}

BrokerThreadStore is ThreadStore over the broker's /api/chat/threads routes.

func (BrokerThreadStore) ByRoom

func (s BrokerThreadStore) ByRoom(ctx context.Context, room string) (Thread, bool, error)

ByRoom is the binding of one room (GET /api/chat/threads/{room}).

func (BrokerThreadStore) ByThread

func (s BrokerThreadStore) ByThread(ctx context.Context, channel, thread string) ([]Thread, error)

ByThread is every room one thread hosts (GET /api/chat/threads?channel=&thread=).

func (BrokerThreadStore) Patch

func (s BrokerThreadStore) Patch(ctx context.Context, room string, p ThreadPatch) (bool, error)

Patch sets a room's binding's feed, pinned message or task (PATCH /api/chat/threads/{room}), refreshing its expiry.

func (BrokerThreadStore) Put

Put binds a room to its thread at the room's first write (PUT /api/chat/threads, keyed by room); the same binding again refreshes its expiry. EndMessage, DoneMentioned and Coordination are never sent (the broker refuses them on PUT): they change only through Patch.

type Button

type Button struct {
	ActionID string
	Label    string
	Value    string
	Style    string
}

Button is one button: its action id, its label, the value the provider echoes on a click, and its style ("" for the default).

type Card

type Card struct {
	Text      string
	BoundText string
	Buttons   []Button
	Meta      json.RawMessage
}

Card is an interactive message: its fallback text, the one text it binds (BoundText, rendered by the provider in its bound block, Slack's maku_text section in plain_text), and its buttons. A Confirm card is posted in the thread, never ephemeral.

func ConfirmCard

func ConfirmCard(action string, target ConfirmPayload, text, by string) (Card, error)

ConfirmCard is the Confirm card for action on target, posted for by: its one button carries ButtonValue, and the card binds text, the exact words the click will send, in its bound block. The adapter adds its own Cancel and renders the card.

func DecisionCard

func DecisionCard(e webhook.Event, transport string, allowUnsigned bool, roomsURL string) Card

DecisionCard is a forge.push wait as a thread draws it. With decisions on (SignedDecisions) and an event that carries everything the broker binds — the room, the approval, the repository and the branch — it is decide:approve and decide:deny, each valued {"room","approval","branch"} (no by, no th: any maintainer decides, and the broker binds the shown text itself), on a card whose bound text is intent.DecideLine, the line the broker derives from the approval (v5 §3.3 step 5). Anything else is read-only: the summary and the Room UI link, no button. The provider adds its own fields and the deadline, and draws an expired wait inert.

func TaskConfirm

func TaskConfirm(p Proposal) (Card, error)

TaskConfirm is the signed Confirm of filing p (§3.3): the bound text is intent.TaskLine over the repository and the plan's title, and the value binds the handoff, the hash and the author (no "th": POST /api/chat/tasks carries no request text and verifies the card's maku_text block directly against the stored plan's task line). The provider adds its own Cancel.

type Command

type Command string

Command is a top-level DM or mention command answered without any model: the phrase is matched exactly, so a sentence that merely contains one goes on to handoff planning.

const (
	CmdLink   Command = "link"
	CmdUnlink Command = "unlink"
	CmdHelp   Command = "help"
	CmdInbox  Command = "inbox"
	CmdTasks  Command = "tasks"
)

The top-level commands.

func TopLevel

func TopLevel(text string) (Command, bool)

TopLevel reports which command text is, ignoring case, surrounding and repeated whitespace and trailing . ! ? punctuation. The caller strips the bot mention first. An unknown phrase is not a command (false) and belongs to handoff planning. "status" maps to my tasks only at top level: inside a filed thread the caller routes "status" to that thread's room instead.

func (Command) NeedsHome

func (c Command) NeedsHome() bool

NeedsHome reports whether answering c needs the caller's Broker.Home read. link and unlink return their intent only: the side effect is the adapter's.

type ConfirmPayload

type ConfirmPayload struct {
	Room     string `json:"room,omitempty"`
	Approval string `json:"approval,omitempty"`
	Branch   string `json:"branch,omitempty"`
	Handoff  string `json:"handoff,omitempty"`
	PlanHash string `json:"planHash,omitempty"`
	TH       string `json:"th,omitempty"`
	By       string `json:"by,omitempty"`
	Nonce    string `json:"n,omitempty"`
}

ConfirmPayload is the one signed button value (v5 §3.3), each key present only where it applies: the room; a decision's approval and branch; a filing's handoff and planHash; th, the bound text's hash; by, the requester the card was posted for; n, the Confirm card's own nonce, so two cards of the same act and text are two values (the broker keys an unsigned click's idempotency on the value).

func CheckConfirm

func CheckConfirm(click ActionClick, user string, now time.Time, ttl time.Duration) (ConfirmPayload, error)

CheckConfirm is a Confirm click's check, before any broker call: the value is one the adapter wrote, user is the requester it names, the card was posted no more than ttl before now, and the card still shows the text th binds. It answers the value, whose target and the card's BoundText are what the broker is sent. A refusal changes nothing, so the requester may still confirm.

type Decision

type Decision struct {
	Route  Route
	Intent intent.Intent
	// Text is a text act's bound text (R15), exactly what its Confirm shows and its route is sent.
	Text string
}

Decision is the router's answer.

func Graduate

func Graduate(res IntentResult, reply string, f ThreadFacts) Decision

Graduate routes tier 1's answer to reply (Bug #3a). A label the broker marks shadow, or one read where the place is not live, is recorded only. A read label answers; a write label earns its Confirm under the same rules as tier 0's, never an action. The broker gated a phase-bound label against the room's own pause already, so it is not checked again here.

func RouteReply

func RouteReply(p Phrase, f ThreadFacts) Decision

RouteReply routes a tier 0 reading. A read answers anyone. A write is the requester's (a split decision anyone's, OpenToThread), in a single-room thread, in its pause, behind its Confirm. Free text from the requester is captured while the task waits on it (needs_author: an answer; plan_review: a revise note), else goes to tier 1 where it is served; anything else is the unknown line.

type Dedup

type Dedup interface {
	Add(id string) bool
	Forget(id string)
}

Dedup is the bounded set of delivery ids already taken: Add reports whether id is new, Forget drops one whose delivery failed so the broker's retry is delivered.

type Feed

type Feed struct {
	Channel   string
	Workspace string
	RoomsURL  string
	Poster    FeedPoster
	Threads   FeedThreads
	Facts     FeedFactsReader
	Logger    *slog.Logger
	// contains filtered or unexported fields
}

Feed is the optional team feed (SS6 / AC6): a DM-filed room's lifecycle — filed, pull request opened, ended, merged — as one line in Channel, posted once and then updated in place. The line carries the repository, the issue and PR links, the phase, the Room UI link and the filer's GitHub login, and nothing a person wrote: never the DM's text, never the issue's title, never a button. A restricted room is its phase and its Room UI link only.

func (*Feed) Project

func (f *Feed) Project(ctx context.Context, e webhook.Event) error

Project tells the feed one event: nothing for a nil feed, no channel, an event outside the lifecycle, or a room that was not filed from a DM. The facts that cannot be read leave the line in its restricted form, so a failed read never shows more than it should.

type FeedFacts

type FeedFacts struct {
	Restricted bool
	Issue      int
	PR         int
	Login      string
}

FeedFacts is what a feed line reads of a room beyond its event: whether the broker answers it as a restricted stub (Lock 3), its issue and pull request numbers, and the filer's GitHub login. Never a title, a summary or anything a person wrote.

type FeedFactsReader

type FeedFactsReader interface {
	FeedFacts(ctx context.Context, th Thread) (FeedFacts, error)
}

FeedFactsReader reads a room's FeedFacts; the provider's wiring answers it from the broker.

type FeedPoster

type FeedPoster interface {
	PostMessage(ctx context.Context, ref ThreadRef, msg Message) (messageID string, err error)
	UpdateMessage(ctx context.Context, ref ThreadRef, messageID string, msg Message) error
}

FeedPoster is what the feed calls on a provider: Provider has it.

type FeedThreads

type FeedThreads interface {
	ByRoom(ctx context.Context, room string) (Thread, bool, error)
	Patch(ctx context.Context, room string, p ThreadPatch) (bool, error)
}

FeedThreads is the thread store as the feed reads and records it: ThreadStore has it.

type FiledIssue

type FiledIssue struct {
	Task      string `json:"task"`
	Room      string `json:"room"`
	Issue     int    `json:"issue"`
	Duplicate bool   `json:"duplicate"`
	URL       string `json:"url"`
}

FiledIssue is one filed issue of a whole-plan run_create answer (phase H2).

type Filing

type Filing struct {
	Ref                       ThreadRef
	Author, Filer, Repository string
}

Filing is who filed what, from where: the thread every filed room is followed in.

type HandoffChecked

type HandoffChecked struct {
	Plan            intake.Plan      `json:"plan"`
	Hash            string           `json:"hash"`
	Workflows       []string         `json:"workflows"`
	WorkflowChoices []WorkflowChoice `json:"workflowChoices,omitempty"`
	DefaultChoice   *WorkflowChoice  `json:"defaultChoice,omitempty"`
	ActiveChoice    *WorkflowChoice  `json:"activeChoice,omitempty"`
	Repository      string           `json:"repository"`
	Title           string           `json:"title"`
	WholePlans      bool             `json:"wholePlans,omitempty"`
}

HandoffChecked is handoff_check's answer: the stored plan re-validated as start and run_create validate it, the hash it is stored under, the workflows the Slack user may choose (none unless they maintain the repository) and the issue it files.

func (HandoffChecked) Choices

func (h HandoffChecked) Choices() []WorkflowChoice

Choices is the workflows the Slack user may choose, each with its description and ceiling when the broker sent them, else their names alone.

type HandoffQuestion

type HandoffQuestion struct {
	Text        string `json:"text"`
	Recommended string `json:"recommended"`
}

HandoffQuestion is the one question a plan asks, and the answer the planner recommends.

type HandoffRequest

type HandoffRequest struct {
	Text       string
	Candidates []string
	OnBehalfOf string
	CeilingUSD float64
	// ID, Answer and AcceptRest continue a handoff: ID with exactly one of the other two.
	ID         string
	Answer     string
	AcceptRest bool
}

HandoffRequest is handoff's arguments, as the App has them (UX2). A mention begins one: the requester's own words, the channel's repositories as the candidate set, the linked Slack user the plan is made for and the channel's ceiling. A reply continues one: the id the proposal's metadata carries, with the person's answer or AcceptRest. The App picks no repository and holds no plan: the broker stores the plan under the id and applies the answer to it.

type HandoffResult

type HandoffResult struct {
	ID       string           `json:"id"`
	Text     string           `json:"text"`
	Question *HandoffQuestion `json:"question"`
	Ready    bool             `json:"ready"`
	Workflow string           `json:"workflow"`
	Budget   float64          `json:"budget"`
}

HandoffResult is handoff/v1: the id the plan is stored under, the plan as text to show as it is, the one question when something is unclear, whether the plan is ready to start, and the workflow and budget it would run with.

type Home

type Home struct {
	Linked bool `json:"linked"`
	// Login is the linked person's GitHub login, display only; "" when it cannot be read.
	Login     string     `json:"login,omitempty"`
	Needs     []HomeNeed `json:"needs"`
	NeedsMore int        `json:"needsMore,omitempty"`
	Rooms     []HomeRoom `json:"rooms"`
	// RestrictedCount is every restricted room of the person's, whether or not its stub fit in Rooms.
	RestrictedCount int `json:"restrictedCount,omitempty"`
}

Home is one linked chat user's dashboard as /api/chat/home answers it: the needs waiting on them (at most 20; NeedsMore counts the rest) and their open rooms (at most 10), a restricted room as a stub (RestrictedCount counts them all). An unlinked user is Linked false with both lists empty.

type HomeNeed

type HomeNeed struct {
	summary.Need
	Channel string `json:"channel,omitempty"`
	Thread  string `json:"thread,omitempty"`
}

HomeNeed is one needs/v1 item and the chat thread its room is followed in (Channel and Thread, empty when the room has no binding). A restricted room contributes none.

type HomeRoom

type HomeRoom struct {
	Room       string `json:"room"`
	Repository string `json:"repository,omitempty"`
	Title      string `json:"title,omitempty"`
	Phase      string `json:"phase,omitempty"`
	URL        string `json:"url"`
	Restricted bool   `json:"restricted,omitempty"`
}

HomeRoom is one open room; a Restricted one carries only Room and URL (Lock 3, v5 §2.2).

type IncomingEvent

type IncomingEvent struct {
	ID        string
	Kind      string
	Transport string
	Ref       ThreadRef
	Actor     Actor
	MessageID string // the message the event is on: the mention, the reply, the reacted or clicked message
	Text      string
	Reaction  string
	Action    *ActionClick
	Proof     *RawProof
}

IncomingEvent is one provider event, as the adapter's handlers read it on both transports. ID is the provider's own id, the dedup key. Proof is the provider's raw request under a signed transport and nil under an unsigned one.

type IntentRequest

type IntentRequest struct {
	Team, User, Channel string
	Room                string
	Reply, Phase        string
	Collect             bool
}

IntentRequest is intent_classify's arguments: the reply alone, its author, the channel, the room the thread names and the thread's phase as one closed word. Room is required: the broker reads its dataClass for the route and its task's pause for the plan, split and answer labels; Phase is prompt context only. Collect is true only for a channel that opted in to collecting replies; the App never sends thread history.

type IntentResult

type IntentResult struct {
	Intent     string  `json:"intent"`
	Text       string  `json:"text"`
	TextHash   string  `json:"textHash"`
	Confidence float64 `json:"confidence"`
	Expires    string  `json:"expires"`
	SampleID   int64   `json:"sampleId"`
	Shadow     bool    `json:"shadow"`
	Reason     string  `json:"reason"`
}

IntentResult is intent_classify's answer: a label, never an action. Text is the span of the reply a steer, an amend, an answer or a plan revision acts on, TextHash its hash, Expires when a confirm for it lapses and SampleID the stored sample's id when the channel collects. Shadow is the broker's mode saying the answer is recorded and never acted on; Reason, set on an unknown the broker decided, is private_classifier_unavailable or phase_gated.

type Item

type Item struct {
	Text    string
	URL     string
	Channel string
	Thread  string
}

Item is one listed need or room. Text is UNTRUSTED (a title or a need's words): the caller must render it inert, so no link, mention or broadcast in it fires. The Slack adapter follows its answerText convention: Slack's three escapes, one line, no control character; emphasis marks (*, _, ~, a single backtick) may still render, which carries no link or mention. URL is the Room UI link; Channel and Thread, when set, are the chat thread the room is followed in, for the caller to turn into a permalink.

type Message

type Message struct {
	ID     string
	Thread string
	User   string
	Bot    bool
	Text   string
	Meta   json.RawMessage
}

Message is one message as the core reads and writes it. Meta is the provider's message metadata, opaque to the core (R4): the adapter decodes its own.

type Phrase

type Phrase struct {
	Intent intent.Intent
	Text   string
}

Phrase is a reply as tier 0 reads it: an intent from the closed table, the text after one of the text prefixes, or intent.Unknown with the whole reply.

func ReadPhrase

func ReadPhrase(text string) Phrase

ReadPhrase reads text, already decoded from its transport, against tier 0.

type Projector

type Projector struct {
	Keys func() ([][]byte, error)
	// Deliver tells the room's thread; its answer is the request's outcome word, OutcomeCounted
	// when it counted its own.
	Deliver func(ctx context.Context, e webhook.Event) string
	// Feed is the optional DM team feed; nil posts none.
	Feed *Feed
	// Seen dedups deliveries; nil takes every delivery.
	Seen   Dedup
	Count  func(ctx context.Context, outcome string)
	Now    func() time.Time
	Logger *slog.Logger
}

Projector is the webhooks listener's handler. A delivery is verified with the broker's keys (read at use) before it is decoded, deduplicated by its webhook-id, handed to Deliver — the provider's own thread lines — and then to Feed. It answers once the thread is told, so a provider failure ("error") is a 502 and the broker's at-least-once retry brings the event back.

func (*Projector) ServeHTTP

func (p *Projector) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is one delivery: 503 when the keys are unreadable (our problem, told apart from a bad signature in the metrics), 401 for a body that is too large or not signed by a current key, 200 for a replayed id, 502 when the thread could not be told, and 200 otherwise.

type Proposal

type Proposal struct {
	Handoff    string  `json:"id"`
	Hash       string  `json:"hash"`
	Author     string  `json:"author"`
	Rev        int     `json:"rev"`
	Repository string  `json:"repo,omitempty"`
	Title      string  `json:"title,omitempty"`
	CeilingUSD float64 `json:"ceilingUSD,omitempty"`
}

Proposal is an open proposal as its message's metadata carries it: the stored handoff, the hash a Confirm binds, the author it is bound to and the revision shown. Title and CeilingUSD are display.

func OpenProposal

func OpenProposal(msgs []Message, bot string) (Proposal, bool)

OpenProposal is the thread's newest proposal posted by bot, unless a filed or cancelled marker came after it: the one proposal a mention, reply or Confirm in the thread is about.

type ProposalBroker

type ProposalBroker interface {
	TaskFiler
	Handoff(ctx context.Context, in HandoffRequest) (HandoffResult, error)
	HandoffCheck(ctx context.Context, id, onBehalfOf string, workflow *string) (HandoffChecked, error)
	Repos(ctx context.Context, user string) (Repos, error)
	Verify(ctx context.Context, p RawProof) (string, error)
}

ProposalBroker is the broker as the engine calls it.

type Proposals

type Proposals struct {
	Provider   Provider
	Broker     ProposalBroker
	Threads    RoomBinder
	Workspace  string
	BotUser    string
	Transport  string
	RoomsURL   string
	ConfirmTTL time.Duration
	Now        func() time.Time
	Logger     *slog.Logger
}

Proposals is the provider-agnostic proposal flow over one Provider.

func (*Proposals) Click

func (e *Proposals) Click(ctx context.Context, ev IncomingEvent) string

Click answers a press on one of the engine's cards. confirm:task is the broker's to verify; every other id is adapter-local and, on a signed transport, verified through the broker first (R-B3).

func (*Proposals) Mention

func (e *Proposals) Mention(ctx context.Context, ev IncomingEvent, bind *Binding) string

Mention answers a mention (or a DM message) with the thread's proposal. In a thread whose open proposal is someone else's it changes nothing and tells the mentioner alone (§4.5). bind is the channel's binding; nil reads the user's repositories from the broker (§2.3): one is planned in directly, several are one question, none says why.

type Provider

type Provider interface {
	// Name is the provider's name as the broker knows it: "slack".
	Name() string
	PostMessage(ctx context.Context, ref ThreadRef, msg Message) (messageID string, err error)
	UpdateMessage(ctx context.Context, ref ThreadRef, messageID string, msg Message) error
	PostEphemeral(ctx context.Context, ref ThreadRef, userID string, text string) error
	// PostCard posts an interactive card in the thread; a Confirm card is never ephemeral.
	PostCard(ctx context.Context, ref ThreadRef, card Card) (messageID string, err error)
	PinMessage(ctx context.Context, ref ThreadRef, messageID string) error
	// Message reads one message of ref's channel, with its metadata.
	Message(ctx context.Context, ref ThreadRef, messageID string) (Message, error)
	// ThreadMessages reads ref's thread, oldest first.
	ThreadMessages(ctx context.Context, ref ThreadRef) ([]Message, error)
	// UserName is a user's handle and display name.
	UserName(ctx context.Context, userID string) (handle, name string, err error)
	Run(ctx context.Context, onEvent func(context.Context, IncomingEvent)) error
}

Provider is one chat provider as the adapter's flows use it (v5 §6.2, amended by R4 with the reads the flows need: Message, ThreadMessages and UserName). A provider maps its own ids, blocks and metadata onto these types; Run delivers its events, on either transport, until ctx ends.

type RawProof

type RawProof struct {
	Headers map[string]string
	Body    []byte
}

RawProof is a provider request exactly as the provider sent it: the headers the broker verifies and the raw bytes. It marshals as the broker's ChatProofEnvelope.

func (RawProof) MarshalJSON

func (p RawProof) MarshalJSON() ([]byte, error)

MarshalJSON is the broker's proof envelope: {"headers": …, "rawBodyBase64": …}.

type Refused

type Refused string

Refused is a tool's refusal ("rejected: <code>"), shown in the thread as is.

func (Refused) Error

func (r Refused) Error() string

type Reply

type Reply struct {
	Command Command
	Private bool
	Text    string
	Items   []Item
	Footer  string
}

Reply is a command's answer, provider-agnostic. Text and Footer are fixed, trusted strings. Private is always true: these answers name the user's rooms across the workspace, so the adapter answers inline in a DM and whispers (DMs it) from a channel, never posting into the channel.

func Respond

func Respond(c Command, home Home) Reply

Respond builds c's reply from home (ignored unless c.NeedsHome). For CmdLink and CmdUnlink the reply only carries the Command: the caller performs the link flow.

type Repo

type Repo struct {
	Repository       string  `json:"repository"`
	Private          bool    `json:"private"`
	Eligible         bool    `json:"eligible"`
	Reason           string  `json:"reason,omitempty"`
	AllowChatPrivate bool    `json:"allowChatPrivate"`
	DefaultWorkflow  string  `json:"defaultWorkflow,omitempty"`
	MaxCostUSD       float64 `json:"maxCostUSD,omitempty"`
	DailyUSD         float64 `json:"dailyUSD,omitempty"`
}

Repo is one repository as /api/chat/repos answers it (v5 §2.2, §2.3): Eligible says whether chat may file into it and Reason why not; the ceilings are the factory's.

type RepoChoice

type RepoChoice struct {
	Eligible []Repo
	Locked   []Repo
}

RepoChoice is a DM's repositories as the proposal reads them: those it may plan in, and the private ones Lock 3 keeps out of chat, which are named so the person knows where to go instead.

func ChooseRepos

func ChooseRepos(rs Repos) RepoChoice

ChooseRepos splits /api/chat/repos' answer.

type Repos

type Repos struct {
	Linked bool `json:"linked"`
	// Login is the linked person's GitHub login, display only (R11); "" when unlinked or unreadable.
	Login        string `json:"login,omitempty"`
	Repositories []Repo `json:"repositories"`
}

Repos is GET /api/chat/repos's answer: whether the chat user is linked, their GitHub login, and the repositories they may file into with each one's gate verdict.

type RoomBinder

type RoomBinder interface {
	ByRoom(ctx context.Context, room string) (Thread, bool, error)
	Put(ctx context.Context, t Thread) error
}

RoomBinder is the thread store as a filing reads and writes it.

type Route

type Route string

Route is what the adapter does with a reply.

const (
	// RouteAnswer answers a read (status, needs, changes, pr) from the room, or a stop or retry whose
	// act is off with the line that says where it is done.
	RouteAnswer Route = "answer"
	// RouteConfirm draws Intent's author-only Confirm card, bound to Text for a text act.
	RouteConfirm Route = "confirm"
	// RouteRequesterOnly tells the speaker alone that only the requester acts here (R13).
	RouteRequesterOnly Route = "requester_only"
	// RouteManyRooms refuses a write or a capture in a thread hosting more than one room, with the
	// room page instead (R14).
	RouteManyRooms Route = "many_rooms"
	// RouteNotEnabled says Intent's act is off here.
	RouteNotEnabled Route = "not_enabled"
	// RouteNotPaused says the task is not waiting on Intent's decision.
	RouteNotPaused Route = "not_paused"
	// RouteClassify asks tier 1; its answer goes through Graduate.
	RouteClassify Route = "classify"
	// RouteShadow is a tier 1 label recorded and never acted on: the thread gets the unknown line.
	RouteShadow Route = "shadow"
	// RouteUnknown is the unknown line: the phrases the thread understands and the room page.
	RouteUnknown Route = "unknown"
)

The routes.

type RouteError

type RouteError struct {
	Status int
	Code   string
}

RouteError is a non-action route's closed refusal: its status and code.

func (*RouteError) Error

func (e *RouteError) Error() string

type RoutineDigest

type RoutineDigest struct {
	Window       string              `json:"window"`
	GeneratedAt  time.Time           `json:"generatedAt"`
	Repositories []RoutineDigestRepo `json:"repositories"`
}

RoutineDigest is the weekly upkeep scorecard returned by GET /api/routines/digest.

type RoutineDigestEntry

type RoutineDigestEntry struct {
	Name          string   `json:"name"`
	Runs          int      `json:"runs"`
	NoOps         int      `json:"noOps"`
	PRsOpened     int      `json:"prsOpened"`
	Merged        int      `json:"merged"`
	Closed        int      `json:"closed"`
	Stale         int      `json:"stale"`
	Escalated     int      `json:"escalated"`
	MergeRate     *float64 `json:"mergeRate"`
	CostUSD       float64  `json:"costUSD"`
	USDPerMerged  *float64 `json:"usdPerMerged"`
	Paused        bool     `json:"paused"`
	BreakerReason string   `json:"breakerReason,omitempty"`
}

RoutineDigestEntry holds bounded metrics for one routine in a digest window.

type RoutineDigestRepo

type RoutineDigestRepo struct {
	Repository string               `json:"repository"`
	Routines   []RoutineDigestEntry `json:"routines"`
}

RoutineDigestRepo holds one repository's routine scorecard rows.

type RunCreate

type RunCreate struct {
	Repo       string
	Title      string
	Body       string
	Handoff    string // the handoff id the proposal's metadata carries
	PlanHash   string // the hash the proposal showed, "" to file whatever the id holds
	MaxCostUSD float64
	OnBehalfOf string // slack:<team>/<user>
	Ref        string // slack/<team>/<channel>/<thread_ts>
	Key        string // the idempotency key
}

RunCreate is a draft filed as a run for the person who asked. Handoff is set when the run is a proposal (UX2): the id of the plan the broker stored, so the broker files that plan after re-validating it, and PlanHash binds the plan the message showed to the one stored — the broker refuses `plan_changed` when they disagree (CD20, CD27). A draft sets neither, and its arguments stay exactly what they were.

type RunResult

type RunResult struct {
	Room      string
	Issue     int
	Duplicate bool
	Sponsor   string
	Replanned *intake.Plan
	Issues    []FiledIssue
}

RunResult is what run_create answered: Sponsor is the GitHub login the factory filed as, "" when it did not say. Replanned is set, and nothing was filed, when the stored plan was a plan/v1: the broker answered the plan/v2 to show and confirm instead (P14).

type TaskFiler

type TaskFiler interface {
	FileTask(ctx context.Context, r ActionRequest) (ActionResult, error)
}

TaskFiler is the one broker call a filing makes.

type Thread

type Thread struct {
	Channel       string    `json:"channel"`
	Thread        string    `json:"thread"`
	Room          string    `json:"room"`
	Repository    string    `json:"repository"`
	Author        string    `json:"author,omitempty"`
	Filer         string    `json:"filer,omitempty"`
	FeedChannel   string    `json:"feedChannel,omitempty"`
	FeedMessage   string    `json:"feedMessage,omitempty"`
	PinnedMessage string    `json:"pinnedMessage,omitempty"`
	TaskID        string    `json:"taskID,omitempty"`
	EndMessage    string    `json:"endMessage,omitempty"`
	DoneMentioned bool      `json:"doneMentioned,omitempty"`
	Coordination  string    `json:"coordination,omitempty"`
	IsDM          bool      `json:"isDM,omitempty"`
	ExpiresAt     time.Time `json:"expiresAt,omitzero"`
}

Thread is one room's binding to the thread it is narrated in (R-B2: one row per room, a thread may host several): who asked and who filed it (empty for an upkeep row), its feed, pinned and end messages, whether its done line already mentioned, and the coordination parent it belongs to. IsDM and ExpiresAt are the broker's; Put never sends them.

type ThreadFacts

type ThreadFacts struct {
	// Requester is whether the speaker is the thread's requester or filer (R13).
	Requester bool
	// Rooms is how many rooms the thread hosts (R14).
	Rooms int
	// Pause is the latest room's pause (PausePlanReview and the others), "" when it waits on none.
	// The adapter reads it only when NeedsPause says the decision depends on it.
	Pause string
	// Acts is whether a write intent's act is on where the reply was made; nil is every act off.
	Acts func(intent.Intent) bool
	// Classify is whether tier 1 reads an unknown reply here; Live whether its label may act. A
	// channel narrows the broker (off: neither; shadow: Classify; on: both), and a DM follows the
	// broker's mode (both, with the broker's shadow flag the authority).
	Classify, Live bool
}

ThreadFacts is what the adapter knows of the reply's thread.

type ThreadPatch

type ThreadPatch struct {
	FeedChannel   *string `json:"feedChannel,omitempty"`
	FeedMessage   *string `json:"feedMessage,omitempty"`
	PinnedMessage *string `json:"pinnedMessage,omitempty"`
	TaskID        *string `json:"taskID,omitempty"`
	EndMessage    *string `json:"endMessage,omitempty"`
	DoneMentioned *bool   `json:"doneMentioned,omitempty"`
	Coordination  *string `json:"coordination,omitempty"`
}

ThreadPatch is the fields a Patch sets: nil keeps a field, a pointer to "" clears it.

type ThreadRef

type ThreadRef struct {
	Workspace string
	Channel   string
	Thread    string
}

ThreadRef names one conversation: a workspace, a channel (or DM), and the thread in it ("" for the channel's top level).

type ThreadStore

type ThreadStore interface {
	Put(ctx context.Context, t Thread) error
	ByThread(ctx context.Context, channel, thread string) ([]Thread, error)
	ByRoom(ctx context.Context, room string) (Thread, bool, error)
	Patch(ctx context.Context, room string, p ThreadPatch) (bool, error)
}

ThreadStore is the thread bindings, scoped to the App's own provider and workspace by its principal. ByThread answers every room the thread hosts (none is an empty list); ByRoom answers false for no binding; Patch answers false for a room with none.

type Tokens

type Tokens struct {
	Fetch func(ctx context.Context) (*oauth2.Token, error)
	// contains filtered or unexported fields
}

Tokens caches the App's client-credentials token until it expires or the broker refuses it (L9): clientcredentials' own TokenSource reuses a token until it expires and cannot be told that the broker refused it. Fetch should go through httpx (oauth2.HTTPClient in the context).

func (*Tokens) Invalidate

func (s *Tokens) Invalidate()

Invalidate drops the cached token after a 401, so the retry fetches a new one.

func (*Tokens) Token

func (s *Tokens) Token(ctx context.Context) (string, error)

Token is the cached access token, fetched when there is none or it expired. Concurrent misses coalesce without holding mu across network I/O.

type WorkflowChoice

type WorkflowChoice struct {
	Name             string   `json:"name"`
	Description      string   `json:"description,omitempty"`
	CeilingUSD       float64  `json:"ceilingUSD,omitempty"`
	StepUpCeilingUSD float64  `json:"stepUpCeilingUSD,omitempty"`
	Path             []string `json:"path,omitempty"`
}

WorkflowChoice is one workflow the stored plan may be pinned to, with its description and ceiling. UnmarshalJSON accepts both a plain string (release A's metadata) and the structured object.

func (*WorkflowChoice) UnmarshalJSON

func (o *WorkflowChoice) UnmarshalJSON(b []byte) error

UnmarshalJSON reads a plain name or the structured object.

Directories

Path Synopsis
Package slack is maku's Slack adapter (v5): a sponsored principal that plans and files tasks from a thread or a DM, a webhook subscriber that keeps the thread told, and the chat.Provider over Slack's Web API and Block Kit.
Package slack is maku's Slack adapter (v5): a sponsored principal that plans and files tasks from a thread or a DM, a webhook subscriber that keeps the thread told, and the chat.Provider over Slack's Web API and Block Kit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL