orca-multiagent-kit 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI_INSTALL.md +4 -3
- package/CHANGELOG.md +70 -1
- package/GUIA.html +11 -9
- package/README.md +23 -23
- package/VERSION +1 -1
- package/bin/backup.js +44 -0
- package/bin/fetch.js +243 -0
- package/bin/hooks.js +187 -0
- package/bin/omk.js +134 -51
- package/bin/run/cleanup.js +402 -0
- package/bin/run/git.js +641 -0
- package/bin/run/glob.js +193 -0
- package/bin/run/ledger.js +243 -0
- package/bin/run/plan.js +328 -0
- package/bin/run/units.js +101 -0
- package/bin/run/util.js +116 -0
- package/bin/run.js +224 -0
- package/bin/setup.js +81 -8
- package/bin/sync.js +222 -0
- package/bin/team.js +353 -0
- package/bin/ui.js +8 -4
- package/bin/update.js +169 -0
- package/core/AGENTS.md +7 -7
- package/docs/EJECUTABLE.md +5 -4
- package/docs/MANUAL.md +16 -3
- package/docs/ORQUESTADOR.md +59 -1
- package/docs/PLUGIN-ORCA.md +131 -24
- package/hooks/orca-gate.cjs +402 -0
- package/install.sh +26 -13
- package/orca-plugin/README.md +7 -1
- package/orca-plugin/assets/logos/README.md +10 -0
- package/orca-plugin/assets/logos/agent.png +0 -0
- package/orca-plugin/assets/logos/aider.png +0 -0
- package/orca-plugin/assets/logos/amp.png +0 -0
- package/orca-plugin/assets/logos/antigravity.png +0 -0
- package/orca-plugin/assets/logos/claude.png +0 -0
- package/orca-plugin/assets/logos/cline.png +0 -0
- package/orca-plugin/assets/logos/codex.png +0 -0
- package/orca-plugin/assets/logos/copilot.png +0 -0
- package/orca-plugin/assets/logos/cursor.png +0 -0
- package/orca-plugin/assets/logos/devin.png +0 -0
- package/orca-plugin/assets/logos/droid.png +0 -0
- package/orca-plugin/assets/logos/gemini.png +0 -0
- package/orca-plugin/assets/logos/goose.png +0 -0
- package/orca-plugin/assets/logos/grok.png +0 -0
- package/orca-plugin/assets/logos/kimi.png +0 -0
- package/orca-plugin/assets/logos/kiro.png +0 -0
- package/orca-plugin/assets/logos/opencode.png +0 -0
- package/orca-plugin/assets/logos/qwen-code.png +0 -0
- package/orca-plugin/orca-plugin.json +25 -7
- package/orca-plugin/src/icons.test.ts +14 -0
- package/orca-plugin/src/icons.ts +30 -0
- package/orca-plugin/src/kit.test.ts +491 -22
- package/orca-plugin/src/kit.ts +687 -37
- package/orca-plugin/src/models.test.ts +28 -0
- package/orca-plugin/src/models.ts +29 -0
- package/orca-plugin/src/node.d.ts +40 -0
- package/orca-plugin/src/panel-state.ts +36 -0
- package/orca-plugin/src/panel.check.ts +71 -0
- package/orca-plugin/src/panel.test.tsx +296 -33
- package/orca-plugin/src/panel.tsx +501 -81
- package/orca-plugin/src/plan-card.test.ts +99 -0
- package/orca-plugin/src/plan-card.ts +107 -0
- package/orca-plugin/src/protocol.ts +205 -5
- package/orca-plugin/src/tabs/autonomy.tsx +72 -0
- package/orca-plugin/src/tabs/history.test.tsx +79 -0
- package/orca-plugin/src/tabs/history.tsx +119 -0
- package/orca-plugin/src/tabs/notices.test.tsx +184 -0
- package/orca-plugin/src/tabs/notices.tsx +274 -0
- package/orca-plugin/src/tabs/worktrees.test.tsx +131 -0
- package/orca-plugin/src/tabs/worktrees.tsx +138 -0
- package/orca-plugin/src/ui/action-card.tsx +112 -0
- package/orca-plugin/src/ui/agent-icon.tsx +13 -0
- package/orca-plugin/src/worker/actions.test.ts +288 -0
- package/orca-plugin/src/worker/actions.ts +292 -0
- package/orca-plugin/src/worker/context.test.ts +32 -0
- package/orca-plugin/src/worker/context.ts +95 -0
- package/orca-plugin/src/worker/history.test.ts +149 -0
- package/orca-plugin/src/worker/history.ts +181 -0
- package/orca-plugin/src/worker/notices.test.ts +356 -0
- package/orca-plugin/src/worker/notices.ts +288 -0
- package/orca-plugin/src/worker/system.test.ts +58 -0
- package/orca-plugin/src/worker/system.ts +122 -0
- package/orca-plugin/src/worker/worktrees.test.ts +177 -0
- package/orca-plugin/src/worker/worktrees.ts +188 -0
- package/orca-plugin/src/worker.test.ts +285 -24
- package/orca-plugin/src/worker.ts +344 -64
- package/output-styles/csr-minimal.md +1 -0
- package/package.json +3 -3
- package/rules/50-done-gate.md +1 -1
- package/rules/95-multi-agent.md +13 -3
- package/skills/kit-init/SKILL.md +16 -4
- package/skills/orca/SKILL.md +28 -5
- package/skills/orca/references/adapters/artifact.md +2 -0
- package/skills/orca/references/adapters/chat.md +2 -0
- package/skills/orca/references/adapters/native-plan.md +6 -0
- package/skills/orca/references/adapters/plan-file.md +2 -0
- package/skills/orca/references/engine-manual.md +7 -5
- package/skills/orca/references/engine-orca.md +1 -0
- package/skills/orca/references/engine-subagents.md +4 -4
- package/skills/orca/references/integrate.md +14 -2
- package/skills/orca/references/ledger.md +1 -1
- package/skills/orca/references/olimpo.md +2 -1
- package/skills/orca/references/plan-card.md +45 -0
- package/skills/orca/references/plan.md +2 -1
- package/skills/orca/references/units.md +1 -1
- package/skills/orca/references/worker-contract.md +2 -2
- package/templates/AGENTS.md +2 -2
- package/templates/CLAUDE.md +1 -1
- package/templates/claude-settings.json +25 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Pestaña Historial: lo que ha pasado en los runs y lo que se ha hecho desde el panel
|
|
2
|
+
// (`history.*` en src/protocol.ts; el worker lo guarda en src/worker/history.ts).
|
|
3
|
+
import { atom, Badge, Button, Card, EmptyState, plugin, read, RelativeTime, Row, Select, set, Stack, Text, type PanelContext } from 'orca'
|
|
4
|
+
import { ask, busy, describeError, outcome } from '../panel-state.ts'
|
|
5
|
+
import type { HistoryEntry, HistoryKind } from '../protocol.ts'
|
|
6
|
+
import { AgentIcon } from '../ui/agent-icon.tsx'
|
|
7
|
+
|
|
8
|
+
type Filter = 'all' | 'runs' | 'mine'
|
|
9
|
+
|
|
10
|
+
const FILTERS: readonly { value: Filter; label: string }[] = [
|
|
11
|
+
{ value: 'all', label: 'Todo' },
|
|
12
|
+
{ value: 'runs', label: 'Runs y unidades' },
|
|
13
|
+
{ value: 'mine', label: 'Lo que hiciste tú' }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
const KIND_LABEL: Record<HistoryKind, string> = {
|
|
17
|
+
kit: 'Kit',
|
|
18
|
+
dispatch: 'Despacho',
|
|
19
|
+
state: 'Estado',
|
|
20
|
+
outcome: 'Final',
|
|
21
|
+
run: 'Run',
|
|
22
|
+
plan: 'Plan',
|
|
23
|
+
orchestrate: 'Reparto',
|
|
24
|
+
reply: 'Respuesta',
|
|
25
|
+
model: 'Modelo',
|
|
26
|
+
autonomy: 'Autonomía'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const RUN_KINDS: readonly HistoryKind[] = ['dispatch', 'state', 'outcome', 'run', 'plan']
|
|
30
|
+
|
|
31
|
+
const entries = atom<HistoryEntry[]>([])
|
|
32
|
+
const filter = atom<Filter>('all')
|
|
33
|
+
const confirming = atom(false)
|
|
34
|
+
|
|
35
|
+
function visible(items: readonly HistoryEntry[], by: Filter): HistoryEntry[] {
|
|
36
|
+
if (by === 'all') return [...items]
|
|
37
|
+
return items.filter((entry) => RUN_KINDS.includes(entry.kind) === (by === 'runs'))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function clear(): Promise<void> {
|
|
41
|
+
if (!read(confirming)) {
|
|
42
|
+
set(confirming, true)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
set(confirming, false)
|
|
46
|
+
await ask('history', () => plugin.request('history.clear'))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function setupHistory(ctx: PanelContext): void {
|
|
50
|
+
set(entries, [])
|
|
51
|
+
set(confirming, false)
|
|
52
|
+
ctx.subscriptions.push(plugin.on('history.changed', ({ items }) => set(entries, items)))
|
|
53
|
+
void plugin
|
|
54
|
+
.request('history.list')
|
|
55
|
+
.then(({ items }) => set(entries, items))
|
|
56
|
+
.catch((error: unknown) => set(outcome, { tone: 'danger', text: `Historial no leído: ${describeError(error)}` }))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function Entry({ entry }: { entry: HistoryEntry }) {
|
|
60
|
+
const where = [entry.run, entry.unit].filter(Boolean).join(' · ')
|
|
61
|
+
return (
|
|
62
|
+
<Stack gap="xs">
|
|
63
|
+
<Row gap="xs" align="center" wrap>
|
|
64
|
+
<Badge tone={entry.tone}>{KIND_LABEL[entry.kind]}</Badge>
|
|
65
|
+
{entry.agent === null ? null : <AgentIcon agent={entry.agent} />}
|
|
66
|
+
<Text>{entry.title}</Text>
|
|
67
|
+
</Row>
|
|
68
|
+
{entry.detail === null ? null : (
|
|
69
|
+
<Text muted size="sm">
|
|
70
|
+
{entry.detail}
|
|
71
|
+
</Text>
|
|
72
|
+
)}
|
|
73
|
+
<Text muted size="xs">
|
|
74
|
+
{where === '' ? null : `${where} · `}
|
|
75
|
+
<RelativeTime at={entry.at} />
|
|
76
|
+
</Text>
|
|
77
|
+
</Stack>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function History() {
|
|
82
|
+
const all = read(entries)
|
|
83
|
+
const by = read(filter)
|
|
84
|
+
const shown = visible(all, by)
|
|
85
|
+
const working = read(busy) !== null
|
|
86
|
+
const sure = read(confirming)
|
|
87
|
+
if (all.length === 0) {
|
|
88
|
+
return (
|
|
89
|
+
<Card title="Historial" description="Despachos, estados y runs.">
|
|
90
|
+
<EmptyState icon="calendar" title="Sin historial" description="Se va llenando con cada despacho y cada run." />
|
|
91
|
+
</Card>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
return (
|
|
95
|
+
<Card title="Historial" description="Despachos, estados y runs.">
|
|
96
|
+
<Stack gap="md">
|
|
97
|
+
<Row gap="sm" align="end" wrap>
|
|
98
|
+
<Select
|
|
99
|
+
label="Mostrar"
|
|
100
|
+
value={by}
|
|
101
|
+
options={FILTERS}
|
|
102
|
+
onChange={(value) => {
|
|
103
|
+
const next = FILTERS.find((option) => option.value === value)?.value
|
|
104
|
+
if (next) set(filter, next)
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
<Button variant={sure ? 'solid' : 'outline'} tone={sure ? 'danger' : undefined} size="sm" icon="delete" disabled={working} onPress={clear}>
|
|
108
|
+
{sure ? '¿Seguro? Vaciar' : 'Vaciar historial'}
|
|
109
|
+
</Button>
|
|
110
|
+
</Row>
|
|
111
|
+
{shown.length === 0 ? (
|
|
112
|
+
<EmptyState icon="calendar" title="Nada que mostrar" description="Ninguna entrada coincide con este filtro." />
|
|
113
|
+
) : (
|
|
114
|
+
shown.map((entry) => <Entry key={entry.id} entry={entry} />)
|
|
115
|
+
)}
|
|
116
|
+
</Stack>
|
|
117
|
+
</Card>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// La pestaña Avisos tal como la dibuja Orca, con el worker sustituido por respuestas fijas.
|
|
2
|
+
import { afterEach, assert, hostError, mockHost, mount, test, type TestPanel } from 'orca/testing'
|
|
3
|
+
import type { NoticeItem } from '../protocol.ts'
|
|
4
|
+
import * as panel from '../panel.tsx'
|
|
5
|
+
|
|
6
|
+
const PLAN: NoticeItem = {
|
|
7
|
+
id: 'plan:r1',
|
|
8
|
+
kind: 'plan',
|
|
9
|
+
title: 'Plan de rondas · r1',
|
|
10
|
+
agent: 'claude',
|
|
11
|
+
workspace: 'app',
|
|
12
|
+
unit: null,
|
|
13
|
+
since: 1000,
|
|
14
|
+
context: [],
|
|
15
|
+
canReply: true,
|
|
16
|
+
via: 'terminal',
|
|
17
|
+
plan: {
|
|
18
|
+
run: 'r1',
|
|
19
|
+
source: 'spec-kit 003-recargas',
|
|
20
|
+
autonomy: 'semi',
|
|
21
|
+
base: 'origin/main @ 1a2b3c4',
|
|
22
|
+
integration: 'feat/003-recargas',
|
|
23
|
+
merge: 'feat/003-recargas → main',
|
|
24
|
+
units: [
|
|
25
|
+
{ round: 0, id: 'U0', title: 'setup', role: 'Hefesto', level: 'alto', agent: 'coordinador', model: null, resource: 'inline', files: '7', depends: null },
|
|
26
|
+
{ round: 1, id: 'U2', title: 'recarga con tarjeta', role: 'Ariadna', level: 'medio', agent: 'claude', model: 'opus', resource: 'worker', files: '11', depends: 'U0' },
|
|
27
|
+
{ round: 1, id: 'U3', title: 'revisión', role: null, level: null, agent: 'codex', model: null, resource: 'manual', files: null, depends: null }
|
|
28
|
+
],
|
|
29
|
+
notes: ['modelos: nuevo en antigravity'],
|
|
30
|
+
orcaRun: null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const BLOCKED: NoticeItem = {
|
|
34
|
+
id: 't:2',
|
|
35
|
+
kind: 'blocked',
|
|
36
|
+
title: 'U2 · Ariadna — Pagos',
|
|
37
|
+
agent: 'codex',
|
|
38
|
+
workspace: 'app',
|
|
39
|
+
unit: 'U2 · Ariadna — Pagos',
|
|
40
|
+
since: 2000,
|
|
41
|
+
context: ['Allow edit to src/pay.ts? (y/n)', '> '],
|
|
42
|
+
canReply: true,
|
|
43
|
+
via: 'terminal',
|
|
44
|
+
plan: null
|
|
45
|
+
}
|
|
46
|
+
const CHAT: NoticeItem = { ...BLOCKED, id: 'p:structured-agent-session-claude_a:1', kind: 'waiting', title: 'chat', context: [], canReply: false, via: null }
|
|
47
|
+
|
|
48
|
+
type Requests = Record<string, (input: never) => unknown>
|
|
49
|
+
let view: TestPanel | undefined
|
|
50
|
+
afterEach(async () => {
|
|
51
|
+
await view?.unmount()
|
|
52
|
+
view = undefined
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const open = async (items: NoticeItem[], requests: Requests = {}) => {
|
|
56
|
+
const calls: { name: string; input: unknown }[] = []
|
|
57
|
+
const answer = (name: string) => (input: unknown) => {
|
|
58
|
+
calls.push({ name, input })
|
|
59
|
+
return { message: `hecho: ${name}` }
|
|
60
|
+
}
|
|
61
|
+
const host = mockHost({
|
|
62
|
+
requests: {
|
|
63
|
+
'agents.summary': { text: 'MAW', tone: 'neutral', tooltip: 'ninguno', groups: [] },
|
|
64
|
+
'notices.list': { items },
|
|
65
|
+
'kit.action': { action: null },
|
|
66
|
+
// Las demás pestañas también piden su lista al montar el panel.
|
|
67
|
+
'worktrees.list': { groups: [] },
|
|
68
|
+
'history.list': { items: [] },
|
|
69
|
+
'notices.reply': answer('notices.reply'),
|
|
70
|
+
'notices.dismiss': answer('notices.dismiss'),
|
|
71
|
+
'agents.open': answer('agents.open'),
|
|
72
|
+
...requests
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
view = await mount(panel, { host })
|
|
76
|
+
await view.select({ label: 'Secciones' }, 'notices')
|
|
77
|
+
return { view, calls }
|
|
78
|
+
}
|
|
79
|
+
const text = (v: TestPanel) => JSON.stringify(v.tree())
|
|
80
|
+
const clean = (v: TestPanel) => {
|
|
81
|
+
assert.deepEqual(v.errors, [])
|
|
82
|
+
assert.deepEqual(v.warnings, [])
|
|
83
|
+
assert.deepEqual(v.refusals, [])
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
test('sin avisos sale el estado vacío', async () => {
|
|
87
|
+
const { view } = await open([])
|
|
88
|
+
assert.match(view.summary().join(' '), /Nada pendiente/)
|
|
89
|
+
clean(view)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('la tarjeta del plan enseña cabecera, rondas, unidades y notas', async () => {
|
|
93
|
+
const { view } = await open([PLAN])
|
|
94
|
+
const all = text(view)
|
|
95
|
+
for (const expected of [/Plan de rondas · r1/, /spec-kit 003-recargas/, /Ronda 0/, /Ronda 1/, /recarga con tarjeta/, /Ariadna · medio/, /opus/, /depende de: U0/, /Notas/, /modelos: nuevo/, /Merge final/]) {
|
|
96
|
+
assert.match(all, expected)
|
|
97
|
+
}
|
|
98
|
+
assert.equal(view.find({ text: 'Pedir cambio' })?.disabled, true)
|
|
99
|
+
clean(view)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test('«Sí, lánzalo» responde sí y «Pedir cambio» responde cambia: …', async () => {
|
|
103
|
+
const { view, calls } = await open([PLAN])
|
|
104
|
+
await view.press({ text: 'Sí, lánzalo' })
|
|
105
|
+
await view.type({ label: '¿Qué cambio?' }, ' sin la ronda 2 ')
|
|
106
|
+
await view.press({ text: 'Pedir cambio' })
|
|
107
|
+
assert.deepEqual(calls, [
|
|
108
|
+
{ name: 'notices.reply', input: { id: 'plan:r1', text: 'sí' } },
|
|
109
|
+
{ name: 'notices.reply', input: { id: 'plan:r1', text: 'cambia: sin la ronda 2' } }
|
|
110
|
+
])
|
|
111
|
+
assert.equal(view.valueOf({ label: '¿Qué cambio?' }), '')
|
|
112
|
+
clean(view)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('el aviso desaparece cuando el worker lo quita', async () => {
|
|
116
|
+
const { view } = await open([PLAN])
|
|
117
|
+
await view.post('notices.changed', { items: [] })
|
|
118
|
+
assert.match(view.summary().join(' '), /Nada pendiente/)
|
|
119
|
+
clean(view)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test('sin canReply los controles salen deshabilitados y lo explica', async () => {
|
|
123
|
+
const { view } = await open([{ ...PLAN, canReply: false }, CHAT])
|
|
124
|
+
assert.equal(view.find({ text: 'Sí, lánzalo' })?.disabled, true)
|
|
125
|
+
assert.equal(view.findAll({ text: 'Responde en el chat del agente.' }).length > 0, true)
|
|
126
|
+
assert.equal(view.find({ text: 'Enviar' })?.disabled, true)
|
|
127
|
+
assert.equal(view.find({ text: 'Ir a su workspace' })?.disabled, false)
|
|
128
|
+
clean(view)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
test('un agente bloqueado enseña su contexto y se le responde', async () => {
|
|
132
|
+
const { view, calls } = await open([BLOCKED])
|
|
133
|
+
const all = text(view)
|
|
134
|
+
assert.match(all, /necesita tu permiso/)
|
|
135
|
+
assert.match(all, /app/)
|
|
136
|
+
await view.toggle({ text: /Lo último del terminal/ })
|
|
137
|
+
assert.match(text(view), /Allow edit to src\/pay\.ts/)
|
|
138
|
+
assert.equal(view.find({ text: 'Enviar' })?.disabled, true)
|
|
139
|
+
await view.type({ label: 'Respuesta para U2 · Ariadna — Pagos' }, 'y')
|
|
140
|
+
await view.press({ text: 'Enviar' })
|
|
141
|
+
assert.deepEqual(calls, [{ name: 'notices.reply', input: { id: 't:2', text: 'y' } }])
|
|
142
|
+
assert.equal(view.valueOf({ label: 'Respuesta para U2 · Ariadna — Pagos' }), '')
|
|
143
|
+
clean(view)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('ir a su workspace y descartar usan el id del aviso', async () => {
|
|
147
|
+
const { view, calls } = await open([BLOCKED])
|
|
148
|
+
await view.press({ text: 'Ir a su workspace' })
|
|
149
|
+
await view.press({ text: 'Descartar' })
|
|
150
|
+
assert.deepEqual(calls, [
|
|
151
|
+
{ name: 'agents.open', input: { id: 't:2' } },
|
|
152
|
+
{ name: 'notices.dismiss', input: { id: 't:2' } }
|
|
153
|
+
])
|
|
154
|
+
clean(view)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('un error de la respuesta sale arriba y la caja conserva el texto', async () => {
|
|
158
|
+
const { view } = await open([BLOCKED], {
|
|
159
|
+
'notices.reply': () => {
|
|
160
|
+
throw hostError('unavailable', 'el terminal no aceptó el texto')
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
await view.type({ label: 'Respuesta para U2 · Ariadna — Pagos' }, 'y')
|
|
164
|
+
await view.press({ text: 'Enviar' })
|
|
165
|
+
assert.match(text(view), /no aceptó el texto/)
|
|
166
|
+
assert.equal(view.valueOf({ label: 'Respuesta para U2 · Ariadna — Pagos' }), 'y')
|
|
167
|
+
assert.deepEqual(view.errors, [])
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
test('si la lista no se puede leer sale el error', async () => {
|
|
171
|
+
const { view } = await open([], {
|
|
172
|
+
'notices.list': () => {
|
|
173
|
+
throw hostError('unavailable', 'sin worker')
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
assert.match(text(view), /Avisos no leídos/)
|
|
177
|
+
assert.deepEqual(view.errors, [])
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
test('la pestaña dice cuántos avisos esperan', async () => {
|
|
181
|
+
const { view } = await open([PLAN])
|
|
182
|
+
assert.ok(text(view).includes('"label":"Avisos (1)"'))
|
|
183
|
+
clean(view)
|
|
184
|
+
})
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// Pestaña Avisos: planes de rondas por confirmar y agentes que esperan a la persona, con la
|
|
2
|
+
// respuesta que se les escribe en su terminal (`notices.*` en src/protocol.ts).
|
|
3
|
+
import {
|
|
4
|
+
atom,
|
|
5
|
+
Badge,
|
|
6
|
+
Box,
|
|
7
|
+
Button,
|
|
8
|
+
Callout,
|
|
9
|
+
Card,
|
|
10
|
+
Code,
|
|
11
|
+
Collapsible,
|
|
12
|
+
EmptyState,
|
|
13
|
+
KeyValue,
|
|
14
|
+
plugin,
|
|
15
|
+
read,
|
|
16
|
+
RelativeTime,
|
|
17
|
+
Row,
|
|
18
|
+
set,
|
|
19
|
+
Stack,
|
|
20
|
+
Text,
|
|
21
|
+
Textarea,
|
|
22
|
+
type PanelContext
|
|
23
|
+
} from 'orca'
|
|
24
|
+
import { ask, busy, describeError, outcome } from '../panel-state.ts'
|
|
25
|
+
import type { NoticeItem, PlanCard, PlanUnit, Tone } from '../protocol.ts'
|
|
26
|
+
import { AgentIcon } from '../ui/agent-icon.tsx'
|
|
27
|
+
import { agentLabel } from '../kit.ts'
|
|
28
|
+
|
|
29
|
+
// «sí» + `cambia: ` caben en las 2000 letras que admite el worker.
|
|
30
|
+
const CHANGE_MAX = 1900
|
|
31
|
+
const NO_REPLY = 'Responde en el chat del agente.'
|
|
32
|
+
const VIA_RUN = 'Le llega al coordinador en su chat, por el buzón de su run de Orca.'
|
|
33
|
+
|
|
34
|
+
const notices = atom<NoticeItem[] | null>(null)
|
|
35
|
+
// Lo que se está escribiendo en la caja de cada aviso, por id; se vacía al enviar con éxito.
|
|
36
|
+
const drafts = atom<Record<string, string>>({})
|
|
37
|
+
|
|
38
|
+
const LEVEL_TONE: Record<string, Tone> = { alto: 'warning', medio: 'accent', bajo: 'neutral' }
|
|
39
|
+
const RESOURCE_TONE: Record<string, Tone> = { inline: 'neutral', worker: 'success', subagente: 'accent', manual: 'warning' }
|
|
40
|
+
|
|
41
|
+
const BLOCKED_BADGE: Record<NoticeItem['kind'], { tone: Tone; text: string }> = {
|
|
42
|
+
plan: { tone: 'accent', text: 'plan por confirmar' },
|
|
43
|
+
blocked: { tone: 'warning', text: 'necesita tu permiso' },
|
|
44
|
+
waiting: { tone: 'accent', text: 'espera instrucciones' }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** «Avisos» con cuántos esperan, para la etiqueta de su pestaña. */
|
|
48
|
+
export function noticesLabel(): string {
|
|
49
|
+
const count = read(notices)?.length ?? 0
|
|
50
|
+
return count > 0 ? `Avisos (${count})` : 'Avisos'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function setupNotices(ctx: PanelContext): void {
|
|
54
|
+
ctx.subscriptions.push(
|
|
55
|
+
plugin.on('notices.changed', ({ items }) => {
|
|
56
|
+
set(notices, items)
|
|
57
|
+
const ids = new Set(items.map(({ id }) => id))
|
|
58
|
+
const current = read(drafts)
|
|
59
|
+
if (Object.keys(current).some((id) => !ids.has(id))) {
|
|
60
|
+
set(drafts, Object.fromEntries(Object.entries(current).filter(([id]) => ids.has(id))))
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
void plugin
|
|
65
|
+
.request('notices.list')
|
|
66
|
+
.then(({ items }) => set(notices, items))
|
|
67
|
+
.catch((error: unknown) => set(outcome, { tone: 'danger', text: `Avisos no leídos: ${describeError(error)}` }))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const draftOf = (id: string) => read(drafts)[id] ?? ''
|
|
71
|
+
const setDraft = (id: string, text: string) => set(drafts, { ...read(drafts), [id]: text })
|
|
72
|
+
|
|
73
|
+
async function reply(id: string, text: string): Promise<void> {
|
|
74
|
+
const sent = await ask(`notice:${id}`, () => plugin.request('notices.reply', { id, text }))
|
|
75
|
+
if (sent) setDraft(id, '')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dismiss = (id: string) => ask('dismiss', () => plugin.request('notices.dismiss', { id }))
|
|
79
|
+
const openAgent = (id: string) => ask('open', () => plugin.request('agents.open', { id }))
|
|
80
|
+
|
|
81
|
+
// Por dónde va la respuesta, cuando no es su terminal.
|
|
82
|
+
function ReplyHint({ notice }: { notice: NoticeItem }) {
|
|
83
|
+
if (notice.via === 'terminal') return null
|
|
84
|
+
return (
|
|
85
|
+
<Text muted size="xs">
|
|
86
|
+
{notice.via === 'run' ? VIA_RUN : NO_REPLY}
|
|
87
|
+
</Text>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function UnitBox({ unit }: { unit: PlanUnit }) {
|
|
92
|
+
const who = unit.model ? `${agentLabel(unit.agent)} · ${unit.model}` : agentLabel(unit.agent)
|
|
93
|
+
const level = unit.level ?? ''
|
|
94
|
+
const extras = [unit.files ? `ficheros: ${unit.files}` : null, unit.depends ? `depende de: ${unit.depends}` : null].filter(
|
|
95
|
+
(line): line is string => line !== null
|
|
96
|
+
)
|
|
97
|
+
return (
|
|
98
|
+
// Con título propio: sin él, Orca pone el de su tono («Advertencia», «Importante»).
|
|
99
|
+
<Callout tone={LEVEL_TONE[level] ?? 'neutral'} title={`${unit.id} · ${unit.title}`}>
|
|
100
|
+
<Box gap="xs">
|
|
101
|
+
<Row gap="xs" align="center" wrap>
|
|
102
|
+
{unit.role || unit.level ? (
|
|
103
|
+
<Badge tone={LEVEL_TONE[level] ?? 'neutral'}>{[unit.role, unit.level].filter(Boolean).join(' · ')}</Badge>
|
|
104
|
+
) : null}
|
|
105
|
+
<AgentIcon agent={unit.agent} />
|
|
106
|
+
<Text size="sm">{who}</Text>
|
|
107
|
+
<Badge tone={RESOURCE_TONE[unit.resource] ?? 'neutral'}>{unit.resource}</Badge>
|
|
108
|
+
</Row>
|
|
109
|
+
{extras.length > 0 ? (
|
|
110
|
+
<Text muted size="xs">
|
|
111
|
+
{extras.join(' · ')}
|
|
112
|
+
</Text>
|
|
113
|
+
) : null}
|
|
114
|
+
</Box>
|
|
115
|
+
</Callout>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function planFacts(plan: PlanCard) {
|
|
120
|
+
const facts = [
|
|
121
|
+
{ label: 'Entrada', value: plan.source },
|
|
122
|
+
{ label: 'Autonomía', value: plan.autonomy },
|
|
123
|
+
{ label: 'Base', value: plan.base, code: true },
|
|
124
|
+
{ label: 'Integración', value: plan.integration, code: true },
|
|
125
|
+
{ label: 'Merge final', value: plan.merge, code: true }
|
|
126
|
+
]
|
|
127
|
+
return facts.filter((fact) => fact.value !== null)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function Rounds({ plan }: { plan: PlanCard }) {
|
|
131
|
+
const rounds = [...new Set(plan.units.map(({ round }) => round))].sort((a, b) => a - b)
|
|
132
|
+
return (
|
|
133
|
+
<Stack gap="md">
|
|
134
|
+
{rounds.map((round) => (
|
|
135
|
+
<Stack gap="xs">
|
|
136
|
+
<Text weight="semibold" size="sm">{`Ronda ${round}`}</Text>
|
|
137
|
+
{plan.units
|
|
138
|
+
.filter((unit) => unit.round === round)
|
|
139
|
+
.map((unit) => (
|
|
140
|
+
<UnitBox unit={unit} />
|
|
141
|
+
))}
|
|
142
|
+
</Stack>
|
|
143
|
+
))}
|
|
144
|
+
</Stack>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function PlanNotice({ notice, plan }: { notice: NoticeItem; plan: PlanCard }) {
|
|
149
|
+
const working = read(busy) !== null
|
|
150
|
+
const change = draftOf(notice.id)
|
|
151
|
+
const facts = planFacts(plan)
|
|
152
|
+
return (
|
|
153
|
+
<Card title={`Plan de rondas · ${plan.run}`} description={`${plan.units.length} unidades`}>
|
|
154
|
+
<Stack gap="md">
|
|
155
|
+
<Row gap="xs" align="center" wrap>
|
|
156
|
+
<Badge tone={BLOCKED_BADGE.plan.tone}>{BLOCKED_BADGE.plan.text}</Badge>
|
|
157
|
+
<Text muted size="xs">
|
|
158
|
+
desde <RelativeTime at={notice.since} />
|
|
159
|
+
</Text>
|
|
160
|
+
</Row>
|
|
161
|
+
{facts.length > 0 ? <KeyValue label="Cabecera del plan" items={facts} /> : null}
|
|
162
|
+
<Rounds plan={plan} />
|
|
163
|
+
{plan.notes.length > 0 ? (
|
|
164
|
+
<Callout tone="accent" icon="info" title="Notas">
|
|
165
|
+
<Stack gap="xs">
|
|
166
|
+
{plan.notes.map((note) => (
|
|
167
|
+
<Text size="sm">{note}</Text>
|
|
168
|
+
))}
|
|
169
|
+
</Stack>
|
|
170
|
+
</Callout>
|
|
171
|
+
) : null}
|
|
172
|
+
<Button icon="check" disabled={working || !notice.canReply} onPress={() => reply(notice.id, 'sí')}>
|
|
173
|
+
Sí, lánzalo
|
|
174
|
+
</Button>
|
|
175
|
+
<Textarea
|
|
176
|
+
label="¿Qué cambio?"
|
|
177
|
+
rows={3}
|
|
178
|
+
maxLength={CHANGE_MAX}
|
|
179
|
+
value={change}
|
|
180
|
+
disabled={!notice.canReply}
|
|
181
|
+
onChange={(value) => setDraft(notice.id, value)}
|
|
182
|
+
/>
|
|
183
|
+
<Row gap="xs" wrap>
|
|
184
|
+
<Button
|
|
185
|
+
variant="outline"
|
|
186
|
+
icon="next"
|
|
187
|
+
disabled={working || !notice.canReply || change.trim() === ''}
|
|
188
|
+
onPress={() => reply(notice.id, `cambia: ${change.trim()}`)}
|
|
189
|
+
>
|
|
190
|
+
Pedir cambio
|
|
191
|
+
</Button>
|
|
192
|
+
<Button variant="ghost" size="sm" icon="close" disabled={working} onPress={() => dismiss(notice.id)}>
|
|
193
|
+
Descartar
|
|
194
|
+
</Button>
|
|
195
|
+
</Row>
|
|
196
|
+
<ReplyHint notice={notice} />
|
|
197
|
+
</Stack>
|
|
198
|
+
</Card>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function AgentNotice({ notice }: { notice: NoticeItem }) {
|
|
203
|
+
const working = read(busy) !== null
|
|
204
|
+
const text = draftOf(notice.id)
|
|
205
|
+
const badge = BLOCKED_BADGE[notice.kind]
|
|
206
|
+
const where = [notice.unit, notice.workspace].filter((part): part is string => part !== null)
|
|
207
|
+
return (
|
|
208
|
+
<Card title={notice.title} description={where.length > 0 ? where.join(' · ') : undefined}>
|
|
209
|
+
<Stack gap="sm">
|
|
210
|
+
<Row gap="xs" align="center" wrap>
|
|
211
|
+
<AgentIcon agent={notice.agent} />
|
|
212
|
+
<Badge tone={badge.tone}>{badge.text}</Badge>
|
|
213
|
+
<Text muted size="xs">
|
|
214
|
+
desde <RelativeTime at={notice.since} />
|
|
215
|
+
</Text>
|
|
216
|
+
</Row>
|
|
217
|
+
{notice.context.length > 0 ? (
|
|
218
|
+
<Collapsible title="Lo último del terminal">
|
|
219
|
+
<Code block>{notice.context.join('\n')}</Code>
|
|
220
|
+
</Collapsible>
|
|
221
|
+
) : null}
|
|
222
|
+
<Textarea
|
|
223
|
+
label={`Respuesta para ${notice.title}`}
|
|
224
|
+
rows={2}
|
|
225
|
+
maxLength={2000}
|
|
226
|
+
value={text}
|
|
227
|
+
disabled={!notice.canReply}
|
|
228
|
+
onChange={(value) => setDraft(notice.id, value)}
|
|
229
|
+
/>
|
|
230
|
+
<Row gap="xs" wrap>
|
|
231
|
+
<Button
|
|
232
|
+
icon="next"
|
|
233
|
+
disabled={working || !notice.canReply || text.trim() === ''}
|
|
234
|
+
onPress={() => reply(notice.id, text)}
|
|
235
|
+
>
|
|
236
|
+
Enviar
|
|
237
|
+
</Button>
|
|
238
|
+
<Button variant="outline" icon="open-external" disabled={working} onPress={() => openAgent(notice.id)}>
|
|
239
|
+
Ir a su workspace
|
|
240
|
+
</Button>
|
|
241
|
+
<Button variant="ghost" size="sm" icon="close" disabled={working} onPress={() => dismiss(notice.id)}>
|
|
242
|
+
Descartar
|
|
243
|
+
</Button>
|
|
244
|
+
</Row>
|
|
245
|
+
<ReplyHint notice={notice} />
|
|
246
|
+
</Stack>
|
|
247
|
+
</Card>
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function Notices() {
|
|
252
|
+
const items = read(notices)
|
|
253
|
+
if (items === null) {
|
|
254
|
+
return (
|
|
255
|
+
<Card title="Avisos" description="Lo que espera tu respuesta.">
|
|
256
|
+
<Text muted>Cargando…</Text>
|
|
257
|
+
</Card>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
if (items.length === 0) {
|
|
261
|
+
return (
|
|
262
|
+
<Card title="Avisos" description="Lo que espera tu respuesta.">
|
|
263
|
+
<EmptyState icon="bell" title="Nada pendiente" description="Aquí aparecen los planes por confirmar y los agentes que esperan." />
|
|
264
|
+
</Card>
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
return (
|
|
268
|
+
<Stack gap="md">
|
|
269
|
+
{items.map((notice) =>
|
|
270
|
+
notice.plan ? <PlanNotice notice={notice} plan={notice.plan} /> : <AgentNotice notice={notice} />
|
|
271
|
+
)}
|
|
272
|
+
</Stack>
|
|
273
|
+
)
|
|
274
|
+
}
|