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.
Files changed (110) hide show
  1. package/AI_INSTALL.md +4 -3
  2. package/CHANGELOG.md +70 -1
  3. package/GUIA.html +11 -9
  4. package/README.md +23 -23
  5. package/VERSION +1 -1
  6. package/bin/backup.js +44 -0
  7. package/bin/fetch.js +243 -0
  8. package/bin/hooks.js +187 -0
  9. package/bin/omk.js +134 -51
  10. package/bin/run/cleanup.js +402 -0
  11. package/bin/run/git.js +641 -0
  12. package/bin/run/glob.js +193 -0
  13. package/bin/run/ledger.js +243 -0
  14. package/bin/run/plan.js +328 -0
  15. package/bin/run/units.js +101 -0
  16. package/bin/run/util.js +116 -0
  17. package/bin/run.js +224 -0
  18. package/bin/setup.js +81 -8
  19. package/bin/sync.js +222 -0
  20. package/bin/team.js +353 -0
  21. package/bin/ui.js +8 -4
  22. package/bin/update.js +169 -0
  23. package/core/AGENTS.md +7 -7
  24. package/docs/EJECUTABLE.md +5 -4
  25. package/docs/MANUAL.md +16 -3
  26. package/docs/ORQUESTADOR.md +59 -1
  27. package/docs/PLUGIN-ORCA.md +131 -24
  28. package/hooks/orca-gate.cjs +402 -0
  29. package/install.sh +26 -13
  30. package/orca-plugin/README.md +7 -1
  31. package/orca-plugin/assets/logos/README.md +10 -0
  32. package/orca-plugin/assets/logos/agent.png +0 -0
  33. package/orca-plugin/assets/logos/aider.png +0 -0
  34. package/orca-plugin/assets/logos/amp.png +0 -0
  35. package/orca-plugin/assets/logos/antigravity.png +0 -0
  36. package/orca-plugin/assets/logos/claude.png +0 -0
  37. package/orca-plugin/assets/logos/cline.png +0 -0
  38. package/orca-plugin/assets/logos/codex.png +0 -0
  39. package/orca-plugin/assets/logos/copilot.png +0 -0
  40. package/orca-plugin/assets/logos/cursor.png +0 -0
  41. package/orca-plugin/assets/logos/devin.png +0 -0
  42. package/orca-plugin/assets/logos/droid.png +0 -0
  43. package/orca-plugin/assets/logos/gemini.png +0 -0
  44. package/orca-plugin/assets/logos/goose.png +0 -0
  45. package/orca-plugin/assets/logos/grok.png +0 -0
  46. package/orca-plugin/assets/logos/kimi.png +0 -0
  47. package/orca-plugin/assets/logos/kiro.png +0 -0
  48. package/orca-plugin/assets/logos/opencode.png +0 -0
  49. package/orca-plugin/assets/logos/qwen-code.png +0 -0
  50. package/orca-plugin/orca-plugin.json +25 -7
  51. package/orca-plugin/src/icons.test.ts +14 -0
  52. package/orca-plugin/src/icons.ts +30 -0
  53. package/orca-plugin/src/kit.test.ts +491 -22
  54. package/orca-plugin/src/kit.ts +687 -37
  55. package/orca-plugin/src/models.test.ts +28 -0
  56. package/orca-plugin/src/models.ts +29 -0
  57. package/orca-plugin/src/node.d.ts +40 -0
  58. package/orca-plugin/src/panel-state.ts +36 -0
  59. package/orca-plugin/src/panel.check.ts +71 -0
  60. package/orca-plugin/src/panel.test.tsx +296 -33
  61. package/orca-plugin/src/panel.tsx +501 -81
  62. package/orca-plugin/src/plan-card.test.ts +99 -0
  63. package/orca-plugin/src/plan-card.ts +107 -0
  64. package/orca-plugin/src/protocol.ts +205 -5
  65. package/orca-plugin/src/tabs/autonomy.tsx +72 -0
  66. package/orca-plugin/src/tabs/history.test.tsx +79 -0
  67. package/orca-plugin/src/tabs/history.tsx +119 -0
  68. package/orca-plugin/src/tabs/notices.test.tsx +184 -0
  69. package/orca-plugin/src/tabs/notices.tsx +274 -0
  70. package/orca-plugin/src/tabs/worktrees.test.tsx +131 -0
  71. package/orca-plugin/src/tabs/worktrees.tsx +138 -0
  72. package/orca-plugin/src/ui/action-card.tsx +112 -0
  73. package/orca-plugin/src/ui/agent-icon.tsx +13 -0
  74. package/orca-plugin/src/worker/actions.test.ts +288 -0
  75. package/orca-plugin/src/worker/actions.ts +292 -0
  76. package/orca-plugin/src/worker/context.test.ts +32 -0
  77. package/orca-plugin/src/worker/context.ts +95 -0
  78. package/orca-plugin/src/worker/history.test.ts +149 -0
  79. package/orca-plugin/src/worker/history.ts +181 -0
  80. package/orca-plugin/src/worker/notices.test.ts +356 -0
  81. package/orca-plugin/src/worker/notices.ts +288 -0
  82. package/orca-plugin/src/worker/system.test.ts +58 -0
  83. package/orca-plugin/src/worker/system.ts +122 -0
  84. package/orca-plugin/src/worker/worktrees.test.ts +177 -0
  85. package/orca-plugin/src/worker/worktrees.ts +188 -0
  86. package/orca-plugin/src/worker.test.ts +285 -24
  87. package/orca-plugin/src/worker.ts +344 -64
  88. package/output-styles/csr-minimal.md +1 -0
  89. package/package.json +3 -3
  90. package/rules/50-done-gate.md +1 -1
  91. package/rules/95-multi-agent.md +13 -3
  92. package/skills/kit-init/SKILL.md +16 -4
  93. package/skills/orca/SKILL.md +28 -5
  94. package/skills/orca/references/adapters/artifact.md +2 -0
  95. package/skills/orca/references/adapters/chat.md +2 -0
  96. package/skills/orca/references/adapters/native-plan.md +6 -0
  97. package/skills/orca/references/adapters/plan-file.md +2 -0
  98. package/skills/orca/references/engine-manual.md +7 -5
  99. package/skills/orca/references/engine-orca.md +1 -0
  100. package/skills/orca/references/engine-subagents.md +4 -4
  101. package/skills/orca/references/integrate.md +14 -2
  102. package/skills/orca/references/ledger.md +1 -1
  103. package/skills/orca/references/olimpo.md +2 -1
  104. package/skills/orca/references/plan-card.md +45 -0
  105. package/skills/orca/references/plan.md +2 -1
  106. package/skills/orca/references/units.md +1 -1
  107. package/skills/orca/references/worker-contract.md +2 -2
  108. package/templates/AGENTS.md +2 -2
  109. package/templates/CLAUDE.md +1 -1
  110. package/templates/claude-settings.json +25 -0
@@ -1,20 +1,23 @@
1
1
  // El worker tal como lo carga Orca, contra un host simulado con las capacidades del manifiesto.
2
2
  import { afterEach, assert, hostError, mockHost, mountWorker, test, type TestWorker } from 'orca/testing'
3
- import { CONTRACT_HINT } from './kit.ts'
3
+ import { CONTRACT_HINT, ORCHESTRATE_HINT, encodeTeam, orchestratePrompt, type Team } from './kit.ts'
4
+ import type { AgentsView } from './protocol.ts'
4
5
  import * as main from './worker.ts'
5
6
 
6
7
  const KIT_SPEC = 'UNIT: U1 — Login RUN: 20261107-auth BASE: abc123'
8
+ const KIT_DISPATCH = `${KIT_SPEC}\nROL: Proteo · implementación · nivel medio — una unidad cada vez`
7
9
 
8
10
  const baseResults = (overrides: Record<string, unknown> = {}) => ({
9
11
  'workspace.readContext': { branch: 'main', displayName: 'app', terminals: [] },
10
12
  'workspace.list': {
11
- workspaces: [{ id: 'w1', kind: 'worktree', name: 'app', path: '/repo/app', branch: 'main', hostId: null }],
13
+ workspaces: [{ id: 'w1', kind: 'worktree', name: 'app', path: '/repo/app', branch: 'refs/heads/main', hostId: null }],
12
14
  truncated: false
13
15
  },
14
16
  'agents.list': { agents: [] },
15
17
  'terminal.create': { terminalId: 't9' },
16
18
  'terminal.read': { lines: [], truncated: false },
17
19
  'agent.launch': { terminalId: 't10' },
20
+ 'workspace.open': { opened: true },
18
21
  'notifications.show': { delivered: true },
19
22
  'statusBar.update': { ok: true },
20
23
  ...overrides
@@ -33,13 +36,26 @@ const start = async (options: { results?: Record<string, unknown>; settings?: Re
33
36
  return worker
34
37
  }
35
38
 
36
- const prompt = (text: string, inputKind: 'orchestration' | 'launch' | 'driving' = 'orchestration') => ({
39
+ const prompt = (text: string, inputKind: 'orchestration' | 'launch' | 'driving' = 'orchestration', terminalId = 't1') => ({
37
40
  agent: 'claude',
38
- terminalId: 't1',
41
+ terminalId,
39
42
  prompt: text,
40
43
  inputKind
41
44
  })
42
45
 
46
+ type State = 'working' | 'blocked' | 'waiting' | 'done'
47
+ const status = (terminalId: string, state: State, receivedAt: number, extra: { title?: string; workspaceId?: string } = {}) => ({
48
+ workspaceId: extra.workspaceId ?? 'w1',
49
+ paneKey: `p-${terminalId}`,
50
+ terminalId,
51
+ state,
52
+ receivedAt,
53
+ ...(extra.title ? { title: extra.title } : {})
54
+ })
55
+
56
+ const summary = async (w: TestWorker) => (await w.request('agents.summary')) as AgentsView
57
+ const names = async (w: TestWorker) => (await summary(w)).groups.flatMap((g) => g.agents.map((a) => a.title))
58
+
43
59
  test('añade el contrato del worker a un despacho del kit', async () => {
44
60
  const w = await start()
45
61
  assert.deepEqual(await w.hooks.fire('agent.prompt.before', prompt(KIT_SPEC)), {
@@ -55,6 +71,24 @@ test('deja intactos los prompts que no son despachos del kit', async () => {
55
71
  }
56
72
  })
57
73
 
74
+ test('un agente que Orca arranca con una tarea pasa primero por la skill orca', async () => {
75
+ const w = await start()
76
+ const task = prompt('Login con Google', 'launch')
77
+ assert.deepEqual(await w.hooks.fire('agent.prompt.before', task), {
78
+ kind: 'continue',
79
+ event: prompt(`Login con Google\n\n${ORCHESTRATE_HINT}`, 'launch')
80
+ })
81
+ // Un despacho del kit lleva el contrato, no la indicación de repartir.
82
+ const dispatch = await w.hooks.fire('agent.prompt.before', prompt(KIT_SPEC))
83
+ assert.equal(dispatch.kind === 'continue' && dispatch.event.prompt.includes(ORCHESTRATE_HINT), false)
84
+ })
85
+
86
+ test('el ajuste autoOrchestrate apagado deja los prompts de arranque intactos', async () => {
87
+ const w = await start({ settings: { autoOrchestrate: false } })
88
+ const task = prompt('Login con Google', 'launch')
89
+ assert.deepEqual(await w.hooks.fire('agent.prompt.before', task), { kind: 'continue', event: task })
90
+ })
91
+
58
92
  test('el ajuste off desactiva el hook', async () => {
59
93
  const w = await start({ settings: { contractHint: 'off' } })
60
94
  const event = prompt(KIT_SPEC)
@@ -64,8 +98,9 @@ test('el ajuste off desactiva el hook', async () => {
64
98
  test('verificar abre un terminal con el literal omk verify en el workspace activo', async () => {
65
99
  const w = await start()
66
100
  const result = await w.command('kit.verify')
101
+ // `--exit-marker`: omk escribe al salir la línea con la que el plugin sabe que ha terminado.
67
102
  assert.deepEqual(w.host.callsOf('terminal.create'), [
68
- { workspaceId: 'w1', title: 'omk verify', command: 'omk verify' }
103
+ { workspaceId: 'w1', title: 'omk verify', command: 'omk verify --exit-marker' }
69
104
  ])
70
105
  assert.equal(result, 'Ejecutando `omk verify` en un terminal nuevo del workspace activo.')
71
106
  assert.deepEqual(w.refusals, [])
@@ -74,7 +109,7 @@ test('verificar abre un terminal con el literal omk verify en el workspace activ
74
109
  test('actualizar usa omk update', async () => {
75
110
  const w = await start()
76
111
  await w.command('kit.update')
77
- assert.equal((w.host.callsOf('terminal.create')[0] as { command: string }).command, 'omk update')
112
+ assert.equal((w.host.callsOf('terminal.create')[0] as { command: string }).command, 'omk update --exit-marker')
78
113
  })
79
114
 
80
115
  test('sin workspace identificable no ejecuta nada y lo avisa', async () => {
@@ -98,6 +133,20 @@ test('un fallo de Orca al crear el terminal se notifica, no se calla', async ()
98
133
  assert.equal(w.host.callsOf('notifications.show').length, 1)
99
134
  })
100
135
 
136
+ test('desde el panel, un fallo vuelve como error con su código, no como respuesta', async () => {
137
+ const w = await start({ results: { 'workspace.readContext': null } })
138
+ await assert.rejects(
139
+ w.request('kit.run', { action: 'verify' }),
140
+ (error: unknown) => (error as { code?: string }).code === 'unavailable' && /No identifico el workspace activo/.test(String(error))
141
+ )
142
+ const bad = await start({ settings: { initAgent: 'claude; rm -rf ~' } })
143
+ await assert.rejects(
144
+ bad.request('kit.run', { action: 'init' }),
145
+ (error: unknown) => (error as { code?: string }).code === 'invalid_params'
146
+ )
147
+ assert.equal(bad.host.callsOf('agent.launch').length, 0)
148
+ })
149
+
101
150
  test('inicializar lanza el agente configurado con «inicializa el proyecto»', async () => {
102
151
  const w = await start({ settings: { initAgent: 'codex' } })
103
152
  await w.command('kit.init')
@@ -115,30 +164,104 @@ test('inicializar rechaza un id de agente no válido sin lanzar nada', async ()
115
164
 
116
165
  test('la barra de estado sigue los cambios de estado de los agentes', async () => {
117
166
  const w = await start()
118
- await w.emit('agent.status.changed', {
119
- workspaceId: 'w1', paneKey: 'p1', terminalId: 't1', title: 'U1 login', state: 'working', receivedAt: 1
120
- })
121
- await w.emit('agent.status.changed', {
122
- workspaceId: 'w2', paneKey: 'p2', terminalId: 't2', title: 'U2 pagos', state: 'blocked', receivedAt: 2
123
- })
167
+ await w.emit('agent.status.changed', status('t1', 'working', 1, { title: 'U1 login' }))
168
+ await w.emit('agent.status.changed', status('t2', 'blocked', 2, { title: 'U2 pagos', workspaceId: 'w2' }))
124
169
  const last = () => w.host.callsOf('statusBar.update').at(-1)
125
170
  assert.deepEqual(last(), {
126
171
  id: 'agents',
127
172
  visible: true,
128
173
  text: 'MAW · 1 trabajando · 1 bloqueado',
129
174
  tone: 'warning',
130
- tooltip: 'Orca Multiagent Kit: 1 trabajando, 1 bloqueado en todos los workspaces'
175
+ tooltip: 'Orca Multiagent Kit: 1 trabajando, 1 bloqueado en todos los workspaces\nU2 pagos: bloqueado\nU1 login: trabajando'
131
176
  })
132
- assert.equal(await w.command('agents.status'), '- U1 login: trabajando\n- U2 pagos: bloqueado')
177
+ assert.equal(await w.command('agents.status'), '- U2 pagos: bloqueado\n- U1 login: trabajando (app)')
133
178
 
134
179
  await w.emit('workspace.removed', { workspaceId: 'w2', kind: 'worktree', path: '/repo/u2' })
135
- await w.emit('agent.status.changed', {
136
- workspaceId: 'w1', paneKey: 'p1', terminalId: 't1', state: 'done', receivedAt: 3
137
- })
180
+ await w.emit('agent.status.changed', status('t1', 'done', 3))
138
181
  assert.equal((last() as { text: string }).text, 'MAW')
139
182
  assert.deepEqual(w.refusals, [])
140
183
  })
141
184
 
185
+ test('un cambio de estado sin título no borra el nombre del agente', async () => {
186
+ const w = await start()
187
+ await w.emit('agent.status.changed', status('t1', 'working', 1, { title: 'Arreglar login' }))
188
+ await w.emit('agent.status.changed', status('t1', 'waiting', 2))
189
+ assert.deepEqual(await names(w), ['Arreglar login'])
190
+ })
191
+
192
+ test('un despacho del kit da nombre a su agente, llegue antes o después del estado', async () => {
193
+ const w = await start()
194
+ await w.hooks.fire('agent.prompt.before', prompt(KIT_DISPATCH, 'orchestration', 't1'))
195
+ await w.emit('agent.status.changed', status('t1', 'working', 1))
196
+ await w.emit('agent.status.changed', status('t2', 'working', 2))
197
+ await w.hooks.fire('agent.prompt.before', prompt(KIT_DISPATCH.replace('U1 — Login', 'U2 — Pagos'), 'orchestration', 't2'))
198
+ const view = await summary(w)
199
+ assert.deepEqual(view.groups.map((g) => g.title), ['RUN 20261107-auth'])
200
+ assert.deepEqual(await names(w), ['U1 · Proteo — Login', 'U2 · Proteo — Pagos'])
201
+ assert.equal(view.groups[0]?.agents[0]?.detail, 'claude · app')
202
+ })
203
+
204
+ test('el hook de lanzamiento dice qué agente es aunque no tenga título', async () => {
205
+ const w = await start()
206
+ const launch = { agent: 'codex', workspaceId: 'w1', workspaceKind: 'worktree', terminalId: 't5', command: 'codex', env: {} } as const
207
+ assert.deepEqual(await w.hooks.fire('agent.launch.before', launch), { kind: 'continue', event: launch })
208
+ await w.emit('agent.status.changed', status('t5', 'working', 1))
209
+ assert.equal(await w.command('agents.status'), '- codex: trabajando (app)')
210
+ })
211
+
212
+ test('los agentes que ya existen al arrancar llevan su agente y el workspace enfocado', async () => {
213
+ const w = await start({
214
+ results: {
215
+ 'agents.list': {
216
+ agents: [{ terminalId: 't1', title: null, agent: 'claude', state: 'blocked', stateStartedAt: 7 }]
217
+ }
218
+ }
219
+ })
220
+ const [line] = (await summary(w)).groups[0]?.agents ?? []
221
+ assert.equal(line?.title, 'claude')
222
+ assert.equal(line?.detail, 'app')
223
+ assert.equal(line?.since, 7)
224
+ assert.deepEqual(line?.facts, [
225
+ { label: 'Agente', value: 'Claude Code' },
226
+ { label: 'Workspace', value: 'app' },
227
+ { label: 'Rama', value: 'main' },
228
+ { label: 'Carpeta', value: '/repo/app' },
229
+ { label: 'Dónde corre', value: 'terminal t1' }
230
+ ])
231
+ })
232
+
233
+ test('avisa cuando un agente se bloquea, una vez, y no si se desactiva', async () => {
234
+ const w = await start()
235
+ await w.emit('agent.status.changed', status('t1', 'working', 1, { title: 'U1 login' }))
236
+ await w.emit('agent.status.changed', status('t1', 'blocked', 2))
237
+ await w.emit('agent.status.changed', status('t1', 'blocked', 3))
238
+ assert.deepEqual(w.host.callsOf('notifications.show'), [
239
+ { title: 'U1 login: bloqueado', body: 'En app. Necesita tu respuesta en Orca.' }
240
+ ])
241
+ await w.deactivate()
242
+
243
+ const quiet = await start({ settings: { notify: false } })
244
+ await quiet.emit('agent.status.changed', status('t1', 'blocked', 1))
245
+ assert.equal(quiet.host.callsOf('notifications.show').length, 0)
246
+ })
247
+
248
+ test('avisa cuando terminan todas las unidades lanzadas de un run', async () => {
249
+ const w = await start()
250
+ for (const [terminalId, unit] of [['t1', 'U1 — Login'], ['t2', 'U2 — Pagos']] as const) {
251
+ await w.hooks.fire('agent.prompt.before', prompt(KIT_DISPATCH.replace('U1 — Login', unit), 'orchestration', terminalId))
252
+ await w.emit('agent.status.changed', status(terminalId, 'working', 1))
253
+ }
254
+ await w.emit('agent.status.changed', status('t1', 'done', 2))
255
+ assert.equal(w.host.callsOf('notifications.show').length, 0)
256
+ await w.emit('agent.status.changed', status('t2', 'done', 3))
257
+ assert.deepEqual(w.host.callsOf('notifications.show'), [
258
+ {
259
+ title: 'RUN 20261107-auth: unidades terminadas',
260
+ body: 'Las 2 unidades lanzadas han terminado. Vuelve al coordinador para revisar e integrar.'
261
+ }
262
+ ])
263
+ })
264
+
142
265
  test('la barra parte de los agentes que ya existen y se oculta si se desactiva', async () => {
143
266
  const seeded = await start({
144
267
  results: {
@@ -180,15 +303,153 @@ test('el panel no puede pedir una acción fuera de la lista', async () => {
180
303
  test('el panel recibe los agentes y solo los cambios', async () => {
181
304
  const w = await start()
182
305
  assert.deepEqual(await w.request('agents.summary'), {
183
- text: 'MAW', tone: 'neutral', tooltip: 'Orca Multiagent Kit: ningún agente activo', agents: []
306
+ text: 'MAW', tone: 'neutral', tooltip: 'Orca Multiagent Kit: ningún agente activo', groups: []
184
307
  })
185
- const working = {
186
- workspaceId: 'w1', paneKey: 'p1', terminalId: 't1', title: 'U1 login', state: 'working', receivedAt: 1
187
- } as const
188
- await w.emit('agent.status.changed', working)
189
- await w.emit('agent.status.changed', { ...working, receivedAt: 2 })
308
+ await w.emit('agent.status.changed', status('t1', 'working', 1, { title: 'U1 login' }))
309
+ await w.emit('agent.status.changed', status('t1', 'working', 2, { title: 'U1 login' }))
190
310
  const changes = w.posts.filter((p) => p.event === 'agents.changed')
191
311
  // El arranque envía el estado vacío; el segundo evento no cambia nada y no se reenvía.
192
312
  assert.equal(changes.length, 2)
193
- assert.deepEqual((changes.at(-1)?.payload as { agents: unknown }).agents, [{ title: 'U1 login', state: 'trabajando' }])
313
+ const [group] = (changes.at(-1)?.payload as AgentsView).groups
314
+ assert.equal(group?.title, 'app')
315
+ assert.deepEqual(
316
+ group?.agents.map(({ id, title, state, since, canOpen }) => ({ id, title, state, since, canOpen })),
317
+ [{ id: 't:t1', title: 'U1 login', state: 'trabajando', since: 1, canOpen: true }]
318
+ )
319
+ })
320
+
321
+ test('el panel abre el workspace de un agente activo y nada más', async () => {
322
+ const w = await start()
323
+ await w.emit('agent.status.changed', status('t1', 'working', 1))
324
+ assert.deepEqual(await w.request('agents.open', { id: 't:t1' }), { message: 'Abierto app.' })
325
+ assert.deepEqual(w.host.callsOf('workspace.open'), [{ workspaceId: 'w1' }])
326
+ await assert.rejects(
327
+ w.request('agents.open', { id: 't:nadie' }),
328
+ (error: unknown) => (error as { code?: string }).code === 'invalid_params'
329
+ )
330
+ assert.deepEqual(w.refusals, [])
331
+ })
332
+
333
+ test('aplicar el equipo ejecuta omk team set con el equipo en base64url', async () => {
334
+ const w = await start()
335
+ const team: Team = {
336
+ coordinator: 'claude',
337
+ providers: ['claude', 'codex'],
338
+ cross: 'todas',
339
+ roles: { casandra: 'codex' },
340
+ custom: [{ name: 'Hermes', work: 'Textos; $(rm -rf ~)', level: 'bajo', review: 'argos', guard: '', provider: null }]
341
+ }
342
+ await w.request('team.apply', { team })
343
+ assert.deepEqual(w.host.callsOf('terminal.create'), [
344
+ { workspaceId: 'w1', title: 'omk team set', command: `omk team set --data ${encodeTeam(team)} --exit-marker` }
345
+ ])
346
+ assert.match(
347
+ (w.host.callsOf('terminal.create')[0] as { command: string }).command,
348
+ /^omk team set --data [A-Za-z0-9_-]+ --exit-marker$/
349
+ )
350
+ await w.request('team.show')
351
+ assert.equal((w.host.callsOf('terminal.create')[1] as { command: string }).command, 'omk team --exit-marker')
352
+ })
353
+
354
+ test('la autonomía del proyecto va con una orden literal y nada más', async () => {
355
+ const w = await start()
356
+ await w.request('team.autonomy', { autonomy: 'auto' })
357
+ assert.deepEqual(w.host.callsOf('terminal.create'), [
358
+ { workspaceId: 'w1', title: 'omk team set --autonomy auto', command: 'omk team set --autonomy auto --exit-marker' }
359
+ ])
360
+ for (const autonomy of ['total', 'auto; rm -rf ~', '', null]) {
361
+ await assert.rejects(
362
+ w.request('team.autonomy', { autonomy } as unknown as { autonomy: 'auto' }),
363
+ (error: unknown) => (error as { code?: string }).code === 'invalid_params'
364
+ )
365
+ }
366
+ assert.equal(w.host.callsOf('terminal.create').length, 1)
367
+ })
368
+
369
+ test('repartir con autonomía para el run la pasa en el prompt; una desconocida no lanza nada', async () => {
370
+ const w = await start()
371
+ await w.request('team.orchestrate', { agent: 'claude', task: 'Login', source: 'chat', autonomy: 'manual' })
372
+ const [launch] = w.host.callsOf('agent.launch') as { prompt: string }[]
373
+ assert.match(launch?.prompt ?? '', /Autonomía de este run: manual/)
374
+ await assert.rejects(
375
+ w.request('team.orchestrate', { agent: 'claude', task: 'Login', source: 'chat', autonomy: 'yolo' } as unknown as {
376
+ agent: string
377
+ task: string
378
+ source: 'chat'
379
+ }),
380
+ (error: unknown) => (error as { code?: string }).code === 'invalid_params'
381
+ )
382
+ assert.equal(w.host.callsOf('agent.launch').length, 1)
383
+ })
384
+
385
+ test('un equipo con texto que no es un id no llega al terminal', async () => {
386
+ const w = await start()
387
+ const hostile = [
388
+ { coordinator: 'claude', providers: ['claude; rm -rf ~'], cross: 'todas', roles: {}, custom: [] },
389
+ { coordinator: 'claude', providers: ['claude'], cross: 'todas', roles: { casandra: 'claude && x' }, custom: [] },
390
+ { coordinator: 'claude', providers: ['claude'], cross: '$(whoami)', roles: {}, custom: [] },
391
+ { coordinator: 'claude', providers: ['claude'], cross: 'todas', roles: {}, custom: [{ name: 'Ariadna' }] }
392
+ ]
393
+ for (const team of hostile) {
394
+ await assert.rejects(
395
+ // Simula lo que un panel podría enviar sin respetar el tipo declarado.
396
+ w.request('team.apply', { team } as unknown as { team: Team }),
397
+ (error: unknown) => (error as { code?: string }).code === 'invalid_params'
398
+ )
399
+ }
400
+ assert.equal(w.host.callsOf('terminal.create').length, 0)
401
+ })
402
+
403
+ test('orquestar lanza el coordinador con la skill orca, la entrada y la tarea', async () => {
404
+ const w = await start()
405
+ assert.deepEqual(await w.request('team.orchestrate', { agent: 'codex', task: 'Login con Google', source: 'chat' }), {
406
+ message: 'Lanzado codex con la skill orca en el workspace activo.'
407
+ })
408
+ assert.deepEqual(w.host.callsOf('agent.launch'), [
409
+ { workspaceId: 'w1', agent: 'codex', prompt: orchestratePrompt('Login con Google', 'chat') }
410
+ ])
411
+ await w.request('team.orchestrate', { agent: 'claude', task: '', source: 'plan' })
412
+ assert.match((w.host.callsOf('agent.launch')[1] as { prompt: string }).prompt, /plan-file/)
413
+ const bad = [
414
+ { agent: 'codex', task: ' ', source: 'chat' },
415
+ { agent: 'x y', task: 'algo', source: 'chat' },
416
+ { agent: 'codex', task: 'algo', source: 'jira' }
417
+ ]
418
+ for (const input of bad) {
419
+ await assert.rejects(
420
+ // Simula lo que un panel podría enviar sin respetar el tipo declarado.
421
+ w.request('team.orchestrate', input as unknown as { agent: string; task: string; source: 'chat' }),
422
+ (error: unknown) => (error as { code?: string }).code === 'invalid_params'
423
+ )
424
+ }
425
+ assert.equal(w.host.callsOf('agent.launch').length, 2)
426
+ })
427
+
428
+ test('un chat de Orca con el workspace en formato repo::ruta sale con su agente y su workspace', async () => {
429
+ const w = await start()
430
+ await w.emit('agent.status.changed', {
431
+ workspaceId: 'repo-1::/repo/app/',
432
+ paneKey: 'structured-agent-session-claude_66ff6cb8:1224b7d3',
433
+ state: 'working',
434
+ receivedAt: 1
435
+ })
436
+ assert.equal(await w.command('agents.status'), '- claude: trabajando (app)')
437
+ const [line] = (await summary(w)).groups[0]?.agents ?? []
438
+ assert.equal(line?.canOpen, true)
439
+ await w.request('agents.open', { id: line?.id ?? '' })
440
+ assert.deepEqual(w.host.callsOf('workspace.open'), [{ workspaceId: 'w1' }])
441
+ })
442
+
443
+ test('las pestañas nuevas responden con su contrato aunque estén vacías', async () => {
444
+ const w = await start()
445
+ assert.deepEqual(await w.request('notices.list'), { items: [] })
446
+ assert.deepEqual(await w.request('worktrees.list'), { groups: [] })
447
+ assert.deepEqual(await w.request('history.list'), { items: [] })
448
+ })
449
+
450
+ test('el hook agent.tool.after solo observa: nunca cambia ni para nada', async () => {
451
+ const w = await start()
452
+ const call = { agent: 'claude', workspaceId: 'w1', terminalId: 't1', tool: 'Write', input: { file_path: 'x' } }
453
+ assert.deepEqual(await w.hooks.fire('agent.tool.after', call), { kind: 'continue', event: call })
454
+ assert.deepEqual(w.logs.filter((line) => line.includes('falló')), [])
194
455
  })