arkaos 3.57.0 → 3.58.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.57.0
1
+ 3.58.0
@@ -28,6 +28,26 @@ const deptActivity = computed<ActivityRow | null>(() =>
28
28
  (activityData.value?.by_department?.[agent.value?.department ?? ''] ?? null),
29
29
  )
30
30
 
31
+ // PR96d v3.58.0 — 30d activity sparkline (calls per day).
32
+ interface SparklineDay {
33
+ date: string
34
+ calls: number
35
+ cost_usd: number | null
36
+ }
37
+ const { data: sparklineData } = fetchApi<{
38
+ days: SparklineDay[]
39
+ period_days: number
40
+ department: string
41
+ }>(`/api/agents/${agentId}/activity-sparkline?days=30`)
42
+ const sparkline = computed<SparklineDay[]>(() => sparklineData.value?.days ?? [])
43
+ const sparklineMaxCalls = computed(() => {
44
+ const max = sparkline.value.reduce((acc, d) => Math.max(acc, d.calls), 0)
45
+ return Math.max(max, 1)
46
+ })
47
+ const sparklineTotalCalls = computed(() =>
48
+ sparkline.value.reduce((acc, d) => acc + d.calls, 0),
49
+ )
50
+
31
51
  // PR88d v3.26.0 — agent history (git log + trash entries)
32
52
  interface HistoryEvent {
33
53
  kind: string
@@ -558,6 +578,36 @@ function formatTokens(n: number): string {
558
578
  />
559
579
  </div>
560
580
  </div>
581
+ <!-- PR96d v3.58.0 — sparkline of daily calls -->
582
+ <div
583
+ v-if="sparkline.length > 0 && sparklineTotalCalls > 0"
584
+ class="mt-3 pt-3 border-t border-default/60"
585
+ >
586
+ <div class="flex items-center justify-between text-xs mb-1.5">
587
+ <span class="text-muted uppercase tracking-wide">Daily calls</span>
588
+ <span class="font-mono text-muted">
589
+ {{ sparklineTotalCalls }} total · max {{ sparklineMaxCalls }}/day
590
+ </span>
591
+ </div>
592
+ <svg
593
+ :viewBox="`0 0 ${sparkline.length * 6} 32`"
594
+ class="w-full h-8"
595
+ preserveAspectRatio="none"
596
+ >
597
+ <rect
598
+ v-for="(day, idx) in sparkline"
599
+ :key="day.date"
600
+ :x="idx * 6 + 1"
601
+ :y="32 - (day.calls / sparklineMaxCalls) * 30"
602
+ width="4"
603
+ :height="(day.calls / sparklineMaxCalls) * 30"
604
+ class="fill-primary"
605
+ :class="day.calls === 0 ? 'opacity-20' : 'opacity-90'"
606
+ >
607
+ <title>{{ day.date }} · {{ day.calls }} calls</title>
608
+ </rect>
609
+ </svg>
610
+ </div>
561
611
  </section>
562
612
 
563
613
  <!-- ===== BIO (PR86d) ===== -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaos",
3
- "version": "3.57.0",
3
+ "version": "3.58.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.57.0"
3
+ version = "3.58.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"}
@@ -218,6 +218,82 @@ def agents_activity(period: str = "week"):
218
218
  return {"by_department": out, "period": period}
219
219
 
220
220
 
221
+ @app.get("/api/agents/{agent_id}/activity-sparkline")
222
+ def agent_activity_sparkline(agent_id: str, days: int = 30):
223
+ """PR96d v3.58.0 — daily call / cost series for the agent's department.
224
+
225
+ Returns ``{days: [{date, calls, cost_usd}]}`` seeded with zeros so
226
+ the frontend can render a clean N-day bar chart without gaps.
227
+ Capped at 90 days. Per-agent series falls back to dept series
228
+ (same convention as activity-strip / PR86b).
229
+ """
230
+ try:
231
+ days_int = int(days) if days is not None else 30
232
+ except (TypeError, ValueError):
233
+ days_int = 30
234
+ capped_days = max(1, min(days_int, 90))
235
+
236
+ agents = _load_agents()
237
+ base = next((a for a in agents if a.get("id") == agent_id), None)
238
+ if not base:
239
+ return {"error": "Agent not found"}
240
+ dept = base.get("department") or ""
241
+
242
+ try:
243
+ from core.runtime.llm_cost_telemetry import read_entries
244
+ except Exception:
245
+ return {"days": []}
246
+
247
+ from datetime import datetime, timedelta, timezone
248
+ today = datetime.now(timezone.utc).date()
249
+ buckets: dict[str, dict] = {}
250
+ for offset in range(capped_days):
251
+ d = today - timedelta(days=capped_days - 1 - offset)
252
+ buckets[d.isoformat()] = {
253
+ "date": d.isoformat(),
254
+ "calls": 0,
255
+ "cost_usd": 0.0,
256
+ "cost_known": False,
257
+ }
258
+ cutoff = today - timedelta(days=capped_days - 1)
259
+ agent_cat = f"subagent:{dept}:{agent_id}"
260
+ dept_cat = f"subagent:{dept}"
261
+ for entry in read_entries():
262
+ raw_ts = entry.get("ts") or ""
263
+ if not isinstance(raw_ts, str):
264
+ continue
265
+ try:
266
+ ts = datetime.fromisoformat(raw_ts.replace("Z", "+00:00"))
267
+ except ValueError:
268
+ continue
269
+ if ts.date() < cutoff:
270
+ continue
271
+ cat = str(entry.get("category") or "")
272
+ if cat != agent_cat and cat != dept_cat:
273
+ continue
274
+ key = ts.date().isoformat()
275
+ if key not in buckets:
276
+ continue
277
+ buckets[key]["calls"] += 1
278
+ cost = entry.get("estimated_cost_usd")
279
+ if isinstance(cost, (int, float)):
280
+ buckets[key]["cost_usd"] += float(cost)
281
+ buckets[key]["cost_known"] = True
282
+
283
+ out: list[dict] = []
284
+ for k in sorted(buckets.keys()):
285
+ bucket = buckets[k]
286
+ out.append({
287
+ "date": bucket["date"],
288
+ "calls": bucket["calls"],
289
+ "cost_usd": (
290
+ round(bucket["cost_usd"], 6)
291
+ if bucket["cost_known"] else None
292
+ ),
293
+ })
294
+ return {"days": out, "period_days": capped_days, "department": dept}
295
+
296
+
221
297
  @app.get("/api/agents/{agent_id}/activity-strip")
222
298
  def agent_activity_strip(agent_id: str, period: str = "month"):
223
299
  """PR83d v3.6.0 + PR86b v3.16.0 — compact activity payload.