oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package provider
2
3import (
4 "amadan.net/oficina/equipo/internal/specialist"
5 "slices"
6)
7
8// ActionProfile is an executable capability, independent of a specialist's name.
9type ActionProfile struct {
10 Action, Specialist, Submission string
11 ReadOnly bool
12 Render bool
13}
14
15func Profile(action string) (ActionProfile, error) {
16 p := ActionProfile{Action: action}
17 switch action {
18 case "coordinate":
19 p.Specialist, p.Submission, p.ReadOnly = "Coordinator", "post_message", true
20 case "converse":
21 // Thin v1 coordinator: a long-lived conversation with no workspace.
22 // Its Equipo tools are ConverseTools; the instance authorises each
23 // call, and the permission callback denies anything else.
24 p.Specialist, p.ReadOnly = "Coordinator", true
25 case "assist":
26 // Base's Assistant: the same shape as converse (a long-lived
27 // conversation whose desk is read-only), with AssistTools.
28 p.Specialist, p.ReadOnly = "Coordinator", true
29 case "reproduce":
30 p.Specialist, p.Submission = "Engineering", "submit_reproduction"
31 case "scope":
32 p.Specialist, p.Submission, p.ReadOnly = "Scope", "submit_acceptance", true
33 case "recommend", "investigate", "research":
34 p.Specialist, p.Submission, p.ReadOnly = "Research", "submit_answer", true
35 case "implement":
36 p.Specialist, p.Submission, p.Render = "Engineering", "submit_candidate", true
37 case "copy":
38 p.Specialist, p.Submission, p.Render = "Copy", "submit_candidate", true
39 case "design":
40 p.Specialist, p.Submission, p.Render = "Design", "submit_candidate", true
41 case "review":
42 p.Specialist, p.Submission, p.ReadOnly = "Review", "submit_review", true
43 case "inspect":
44 // Thin v1 Review: reads a candidate's tree (read-only mount) with
45 // Read, Glob and Grep only, and gives its verdict through
46 // submit_review. No write tools and no shell.
47 p.Specialist, p.Submission, p.ReadOnly = "Reviewer", "submit_review", true
48 case ResearchStepAction:
49 // The Research step (research-v1, spec §4): an empty scratch
50 // workspace, no native tools at all, and exactly the profile's
51 // two Equipo tools. Not the legacy "research" action above,
52 // which reads a workspace with Read, Glob, Grep and Bash.
53 p.Specialist, p.Submission = ResearchSpecialist, specialist.ToolSubmitFindings
54 case DesignStepAction:
55 // The Design step (design-v1, task 13): Engineering's step with
56 // exactly design-v1's three Equipo tools (render_page, not the
57 // old submit_render) and /render read-only. Not the plan
58 // workflow's legacy "design" action above.
59 p.Specialist, p.Submission = DesignSpecialist, specialist.ToolSubmitCandidate
60 case GlanceAction:
61 // The Assistant's instant first line: a small model writes one
62 // short line from the person's newest message. No tool at all,
63 // native or Equipo, and its workspace (an empty directory) is
64 // read-only.
65 p.Specialist, p.ReadOnly = GlanceSpecialist, true
66 case "answer":
67 // Thin v1 "ask the implementer": a step's own session resumed to
68 // answer the person's question about its work. Read-only: the
69 // candidate's tree mounted read-only, Read, Glob and Grep, and the
70 // runner's read-only git tools (AnswerTools). No write tools, no
71 // shell, nothing to submit.
72 p.Specialist, p.ReadOnly = "Answerer", true
73 default:
74 return p, ErrPolicy
75 }
76 return p, nil
77}
78func (p ActionProfile) Tools() []string {
79 if p.Action == "coordinate" {
80 return CoordinatorTools()
81 }
82 if p.Action == "converse" {
83 return ConverseTools()
84 }
85 if p.Action == "assist" {
86 return AssistTools()
87 }
88 if p.Action == "answer" {
89 return AnswerTools()
90 }
91 if p.Action == GlanceAction {
92 return []string{}
93 }
94 if ResearchAction(p.Action) {
95 return ResearchTools()
96 }
97 if DesignAction(p.Action) {
98 return DesignTools()
99 }
100 tools := []string{p.Submission, "ask_person"}
101 if p.Render {
102 tools = append(tools, "submit_render")
103 }
104 return tools
105}
106func (p ActionProfile) MCPTools() []string {
107 tools := p.Tools()
108 for i := range tools {
109 tools[i] = "mcp__equipo__" + tools[i]
110 }
111 return tools
112}
113
114// CoordinatorAction reports whether an action runs the coordinator, with no
115// workspace mounted.
116func CoordinatorAction(action string) bool {
117 return action == "coordinate" || action == "converse" || action == "assist"
118}
119
120// GlanceAction is the launch action of the Assistant's instant first
121// line (a glance); GlanceSpecialist is its launch role.
122const (
123 GlanceAction = "glance"
124 GlanceSpecialist = "Glance"
125)
126
127// The small models a glance runs on, one per provider: Claude's fastest,
128// and the smallest the pinned Codex 0.165.0 offers a subscription (its
129// bundled catalog, `codex debug models --bundled`: gpt-6-luna, "Fast and
130// affordable model for easier tasks", which gpt-5.6-luna upgrades to).
131const (
132 ClaudeGlanceModel = "claude-haiku-5-5"
133 CodexGlanceModel = "gpt-6-luna"
134)
135
136// GlanceModel is a provider's glance model, "" when it has none.
137func GlanceModel(provider string) string {
138 switch provider {
139 case "claude":
140 return ClaudeGlanceModel
141 case "codex":
142 return CodexGlanceModel
143 }
144 return ""
145}
146
147// LaunchModel is the model a launch runs: the connection's bound model,
148// except for a glance, which runs its provider's small model. Only the
149// glance action reaches the small model, and it is no input: a glance has
150// no tools, writes a few words and runs on the same account, so it does
151// not widen what the person allowed. Every other action runs bound.
152func LaunchModel(action, provider, bound string) string {
153 if action == GlanceAction {
154 if m := GlanceModel(provider); m != "" {
155 return m
156 }
157 }
158 return bound
159}
160
161// ResearchStepAction is the Research step's launch action (profile
162// research-v1). ResearchSpecialist is its launch role, distinct from the
163// legacy "Research" role, which has native tools.
164const (
165 ResearchStepAction = "research_step"
166 ResearchSpecialist = "Researcher"
167)
168
169// ResearchAction reports whether an action runs the Research step: no
170// native tools, a minimal /etc and an empty scratch workspace.
171func ResearchAction(action string) bool { return action == ResearchStepAction }
172
173// ResearchTools are the Research step's Equipo tools, exactly research-v1's.
174func ResearchTools() []string {
175 p, ok := specialist.Lookup(specialist.ProfileResearch)
176 if !ok {
177 return nil
178 }
179 return p.Tools
180}
181
182// DesignStepAction is the Design step's launch action (profile
183// design-v1's Policy.Action). DesignSpecialist is its launch role, the
184// legacy design action's too: Engineering's native tools.
185const (
186 DesignStepAction = specialist.ActionDesignStep
187 DesignSpecialist = "Design"
188)
189
190// DesignAction reports whether an action runs the Design step.
191func DesignAction(action string) bool { return action == DesignStepAction }
192
193// DesignTools are the Design step's Equipo tools, exactly design-v1's.
194func DesignTools() []string {
195 p, ok := specialist.Lookup(specialist.ProfileDesign)
196 if !ok {
197 return nil
198 }
199 return p.Tools
200}
201
202// DesignReadOnly are the paths the Design step's native file tools may
203// read and never write beyond Engineering's, exactly design-v1's
204// (/render).
205func DesignReadOnly() []string {
206 p, ok := specialist.Lookup(specialist.ProfileDesign)
207 if !ok {
208 return nil
209 }
210 return p.Policy.ReadOnly
211}
212
213// DesignMCPTools are DesignTools as the CLI names them.
214func DesignMCPTools() []string {
215 p, _ := Profile(DesignStepAction)
216 return p.MCPTools()
217}
218
219// RenderReaderAction reports whether an action may see its step's
220// captures, read-only at /render: the Design step only.
221func RenderReaderAction(action string) bool { return DesignAction(action) }
222
223// ResearchReaderAction reports whether an action may see a task's kept
224// research images, read-only at /research: Engineering and Review only.
225func ResearchReaderAction(action string) bool { return action == "implement" || action == "inspect" }
226
227// ConverseTools is the thin coordinator's tool set (wire.ConverseTools
228// plus create_project, which the runner carries out itself).
229func ConverseTools() []string {
230 return []string{"request_access", "status", "find", "search_code", "read_file", "add_project", "create_project", "set_project_home", "star_project", "ask_person", "write_note", "read_notes", "record_task", "add_finding", "start_task", "read_task", "cancel_task", "add_report", "hold_merge", "set_merge_policy", "propose_specialist", "research", "offer_retry", "retry_step", "places", "propose_place", "publish_site", "site_status"}
231}
232
233// AssistTools is the Assistant's tool set (wire.AssistTools).
234func AssistTools() []string {
235 return []string{"look", "describe", "use", "ask_person", "write_note", "read_notes", "read_attachment"}
236}
237
238// AnswerTools are an answering session's Equipo tools: read-only git
239// on the step's commit, run by the runner outside the namespace.
240func AnswerTools() []string { return []string{"git_log", "git_diff", "git_show"} }
241
242func CoordinatorTools() []string {
243 return []string{"equipo_status", "read_project", "read_task", "propose_project", "propose_plan", "ask_person", "route_to_task", "post_message", "suggest_preference", "suggest_specialist", "suggest_playbook"}
244}
245
246// Codex 0.165.0 registers these whenever MCP is configured. The coordinator's
247// only server exposes one static routing fixture; Claude has no native-tool exception.
248func CoordinatorNativeTools(family string) []string {
249 if family == "codex" {
250 return []string{"list_mcp_resources", "list_mcp_resource_templates", "read_mcp_resource"}
251 }
252 return nil
253}
254
255// WithoutAccess removes only the protocol-26 proposal tool for an older peer.
256func WithoutAccess(tools []string) []string {
257 return slices.DeleteFunc(slices.Clone(tools), func(s string) bool { return s == "mcp__equipo__request_access" })
258}
259func (p ActionProfile) AcceptsTools(tools []string) bool {
260 want := p.MCPTools()
261 return slices.Equal(tools, want) || p.Action == "converse" && slices.Equal(tools, WithoutAccess(want))
262}
263