arkaos 3.15.0 → 3.16.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/VERSION CHANGED
@@ -1 +1 @@
1
- 3.15.0
1
+ 3.16.0
@@ -367,7 +367,8 @@ def _current_category() -> str:
367
367
 
368
368
  PR60 v2.77.0 — orchestration layers can set
369
369
  ``ARKA_CALL_CATEGORY=skill:<slug>`` /
370
- ``subagent:<dept>`` / ``plugin:<id>`` / ``mcp:<server>`` before
370
+ ``subagent:<dept>`` or ``subagent:<dept>:<agent_id>`` /
371
+ ``plugin:<id>`` / ``mcp:<server>`` before
371
372
  invoking the provider so `/arka costs --by-category` (PR47) can
372
373
  attribute spend. Returns "" when unset, which lands in the base
373
374
  bucket (backward-compatible).
@@ -27,9 +27,10 @@ const deptActivity = computed<ActivityRow | null>(() =>
27
27
  (activityData.value?.by_department?.[agent.value?.department ?? ''] ?? null),
28
28
  )
29
29
 
30
- // PR83d v3.6.0 — activity strip (30d, dept-level + last_used + rank)
30
+ // PR83d v3.6.0 + PR86b v3.16.0 — activity strip (30d, agent or dept scope)
31
31
  interface ActivityStrip {
32
32
  period: string
33
+ scope: 'agent' | 'department'
33
34
  department: string
34
35
  calls: number
35
36
  cost_usd: number | null
@@ -346,7 +347,7 @@ function formatTokens(n: number): string {
346
347
  <div class="flex items-center gap-2">
347
348
  <UIcon name="i-lucide-activity" class="size-4 text-primary" />
348
349
  <span class="font-semibold uppercase tracking-wide text-muted text-xs">
349
- 30d activity (dept)
350
+ 30d activity ({{ activityStrip.scope === 'agent' ? 'agent' : 'dept' }})
350
351
  </span>
351
352
  </div>
352
353
  <div class="flex items-center gap-2">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaos",
3
- "version": "3.15.0",
3
+ "version": "3.16.0",
4
4
  "description": "The Operating System for AI Agent Teams",
5
5
  "type": "module",
6
6
  "bin": {
package/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "arkaos-core"
3
- version = "3.15.0"
3
+ version = "3.16.0"
4
4
  description = "Core engine for ArkaOS — The Operating System for AI Agent Teams"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
@@ -220,11 +220,17 @@ def agents_activity(period: str = "week"):
220
220
 
221
221
  @app.get("/api/agents/{agent_id}/activity-strip")
222
222
  def agent_activity_strip(agent_id: str, period: str = "month"):
223
- """PR83d v3.6.0 — compact activity payload for the agent hero strip.
223
+ """PR83d v3.6.0 + PR86b v3.16.0 — compact activity payload.
224
+
225
+ When telemetry is tagged ``subagent:<dept>:<agent_id>``, the response
226
+ prefers per-agent stats and includes a ``scope: "agent"`` flag.
227
+ Otherwise it falls back to department-level stats with
228
+ ``scope: "department"`` (the original PR83d behaviour).
224
229
 
225
230
  Returns:
226
231
  {
227
232
  "period": "month",
233
+ "scope": "agent" | "department",
228
234
  "department": "<dept>",
229
235
  "calls": <int>,
230
236
  "cost_usd": <float|null>,
@@ -233,9 +239,6 @@ def agent_activity_strip(agent_id: str, period: str = "month"):
233
239
  "dept_rank": <1-based int>|null,
234
240
  "dept_count": <int>
235
241
  }
236
-
237
- All values reflect the agent's DEPARTMENT (per-agent attribution
238
- isn't tracked yet — see PR47 telemetry).
239
242
  """
240
243
  agents = _load_agents()
241
244
  base = None
@@ -259,34 +262,51 @@ def agent_activity_strip(agent_id: str, period: str = "month"):
259
262
  period = "month"
260
263
 
261
264
  summary = summarise(period=period)
262
- dept_costs: list[tuple[str, float]] = []
263
- target_row: dict | None = None
265
+ dept_costs_map: dict[str, float] = {}
266
+ dept_row: dict | None = None
267
+ agent_row: dict | None = None
264
268
  for category, row in (summary.by_category or {}).items():
265
269
  if not isinstance(category, str) or not category.startswith("subagent:"):
266
270
  continue
267
- cat_dept = category.split(":", 1)[1] or "unknown"
271
+ # subagent:<dept> OR subagent:<dept>:<agent_id>
272
+ parts = category.split(":", 2)
273
+ cat_dept = parts[1] if len(parts) >= 2 and parts[1] else "unknown"
274
+ cat_agent = parts[2] if len(parts) == 3 else None
268
275
  cost = row.get("total_cost_usd")
269
- dept_costs.append((cat_dept, float(cost) if isinstance(cost, (int, float)) else 0.0))
270
- if cat_dept == dept:
271
- target_row = row
272
-
273
- dept_costs.sort(key=lambda t: t[1], reverse=True)
276
+ cost_f = float(cost) if isinstance(cost, (int, float)) else 0.0
277
+ dept_costs_map[cat_dept] = dept_costs_map.get(cat_dept, 0.0) + cost_f
278
+ if cat_dept == dept and cat_agent is None:
279
+ dept_row = row
280
+ if cat_dept == dept and cat_agent == agent_id:
281
+ agent_row = row
282
+
283
+ dept_costs = sorted(dept_costs_map.items(), key=lambda t: t[1], reverse=True)
274
284
  dept_rank: Optional[int] = None
275
285
  for idx, (d, _) in enumerate(dept_costs, start=1):
276
286
  if d == dept:
277
287
  dept_rank = idx
278
288
  break
279
289
 
290
+ use_agent_scope = agent_row is not None
291
+ scope = "agent" if use_agent_scope else "department"
292
+ target_row = agent_row if use_agent_scope else dept_row
293
+
280
294
  entries, _ = _load_slice(None, _period_cutoff(period, now=None))
281
295
  last_used: Optional[str] = None
296
+ expect_cats = (
297
+ {f"subagent:{dept}:{agent_id}"}
298
+ if use_agent_scope
299
+ else {f"subagent:{dept}"}
300
+ )
282
301
  for entry in reversed(entries):
283
302
  cat = entry.get("category") or ""
284
- if isinstance(cat, str) and cat == f"subagent:{dept}":
303
+ if isinstance(cat, str) and cat in expect_cats:
285
304
  last_used = entry.get("ts")
286
305
  break
287
306
 
288
307
  return {
289
308
  "period": period,
309
+ "scope": scope,
290
310
  "department": dept,
291
311
  "calls": int(target_row.get("call_count", 0)) if target_row else 0,
292
312
  "cost_usd": (
@@ -302,6 +322,16 @@ def agent_activity_strip(agent_id: str, period: str = "month"):
302
322
  }
303
323
 
304
324
 
325
+ @app.get("/api/agents/{agent_id}/activity")
326
+ def agent_activity_detail(agent_id: str, period: str = "month"):
327
+ """PR86b v3.16.0 — alias for /activity-strip. Same payload shape.
328
+
329
+ Exposed so callers can use a more natural name when they want the
330
+ full activity row rather than the compact hero strip.
331
+ """
332
+ return agent_activity_strip(agent_id, period)
333
+
334
+
305
335
  @app.get("/api/agents/{agent_id}")
306
336
  def agent_detail(agent_id: str):
307
337
  """Get full agent detail including YAML data."""