oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "amadan.net/oficina/equipo/internal/equipo/conversation"
5 "amadan.net/oficina/equipo/internal/runner"
6 "amadan.net/oficina/equipo/internal/runnerproto"
7 "context"
8 "encoding/json"
9 "gorm.io/gorm"
10 "time"
11)
12
13func (e *Execution) coordinatorEngine() *conversation.Engine {
14 return &conversation.Engine{Defaults: e.ownerDefaults, Copy: copyText, Rebind: e.store.coordinatorApplication().FallbackCoordinator, ContextUnavailable: &refusal{copyText("coordinator.context_unavailable"), ErrInvalid}, ContextLimit: &refusal{copyText("coordinator.context_limit"), ErrInvalid}, ToolCopy: CoordinatorToolCopy(), Tools: conversation.ToolOperations{ProjectHeading: copyText("project_setup.heading"), AmbiguousProject: pageCopy["coordinator.project_question"], Planning: e.store.planningAt}, Core: e.Core, Atomic: e.atomic, Selection: e.store.coordinatorSelection, StoreError: storeError, NotFound: ErrNotFound, CheckProject: func(tx *gorm.DB, p string, id int64, sel Selection) (int64, error) {
15 project, err := e.store.coordinatorProject(tx, p, id, sel)
16 return project.Revision, err
17 }, Conversation: conversationAt, Now: func() time.Time { return e.store.runnerClock.Now().UTC() }, Audit: coordinatorAudit, Invalid: ErrInvalid, Conflict: ErrConflict, Forbidden: ErrForbidden, Unavailable: ErrUnavailable, WaitingConnection: errCoordinatorWaitingConnection, Events: e.validators.Events, Receipt: e.validators.Receipt, Containment: e.validators.Containment, Delivery: e.validators.CoordinatorDelivery, Redact: func(raw []byte) []byte { return runner.RedactJSON(raw, nil) },
18 RunnerCurrent: func(tx *gorm.DB, p RunnerPrincipal) error {
19 _, err := runnerPrincipalAt(tx, p, e.store.runnerClock.Now().UTC())
20 return err
21 },
22 Project: func(tx *gorm.DB, person string, id int64, sel Selection) (int64, runnerproto.SourceSnapshot, error) {
23 p, err := e.store.coordinatorProject(tx, person, id, sel)
24 if err != nil {
25 return 0, runnerproto.SourceSnapshot{}, err
26 }
27 source, ref, err := projectSourceAt(tx, id)
28 if err != nil {
29 return 0, runnerproto.SourceSnapshot{}, err
30 }
31 raw, err := json.Marshal(source)
32 return p.Revision, runnerproto.SourceSnapshot{Ref: ref, Payload: raw}, err
33 }}
34}
35func (e *Execution) ClaimCoordinator(ctx context.Context, p RunnerPrincipal, id string, rev int64) (CoordinatorClaim, error) {
36 return e.coordinatorEngine().ClaimCoordinator(ctx, p, id, rev)
37}
38func (e *Execution) RecoverCoordinator(ctx context.Context, p RunnerPrincipal, id string, rev int64) (CoordinatorClaim, error) {
39 return e.coordinatorEngine().RecoverCoordinator(ctx, p, id, rev)
40}
41func (e *Execution) CoordinatorToolResult(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim, call CoordinatorToolCall) (CoordinatorToolResult, error) {
42 return e.coordinatorEngine().CoordinatorToolResult(ctx, p, c, call)
43}
44func (e *Execution) ValidateCoordinator(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim) error {
45 return e.coordinatorEngine().ValidateCoordinator(ctx, p, c)
46}
47func (e *Execution) RenewCoordinator(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim) (time.Time, error) {
48 return e.coordinatorEngine().RenewCoordinator(ctx, p, c)
49}
50func (e *Execution) CompleteCoordinator(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim, event runnerproto.Event) error {
51 return e.coordinatorEngine().CompleteCoordinator(ctx, p, c, event)
52}
53func (e *Execution) CoordinatorEvent(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim, event runnerproto.Event) error {
54 return e.coordinatorEngine().CoordinatorEvent(ctx, p, c, event)
55}
56func (e *Execution) ContainCoordinator(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim, proof runnerproto.ContainmentProof) error {
57 return e.coordinatorEngine().ContainCoordinator(ctx, p, c, proof)
58}
59