Overview
Concrete tool for ingesting and serving agent status snapshots (model, context, cost, effort, mode), provided by AI Maestro's `services/status-snapshots-service.ts`.
Description
The ingestStatusSnapshot function receives a status report from the agent's hook, validates the fields (model, modelId, sessionId, effort), checks the agent exists, and keeps the report in memory. Unknown fields are dropped; size is bounded. getSnapshots returns a `SnapshotMap` (agent name → `StatusSnapshot`) by merging local snapshots with cached remote host snapshots.
Usage
- Call `ingestStatusSnapshot` from the status snapshot API route (hook posts here).
- Call `getSnapshots` from the snapshots API route or the browser store.
Code Reference
Source Location
- Repository: ai-maestro
- File: services/status-snapshots-service.ts (L186-295 ingestStatusSnapshot, L426-443 getSnapshots)
- Supporting: lib/agent-registry.ts (getAgent), lib/hosts-config.ts (getHosts, isSelfHost)
Signature
export function ingestStatusSnapshot(
agentId: string,
body: unknown,
now: number = Date.now()
): ServiceResult<{ ok: true }>
export function getSnapshots(opts: {
localOnly?: boolean
httpGet?: HttpGetJson
now?: number
}): SnapshotMap
// SnapshotMap is agent name → StatusSnapshot
Import
import { ingestStatusSnapshot, getSnapshots } from '@/services/status-snapshots-service'
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| agentId |
string |
Yes (ingest) |
Agent UUID
|
| body |
unknown |
Yes (ingest) |
Snapshot report from hook
|
| opts.localOnly |
boolean |
No (getSnapshots) |
Skip remote fetch
|
Outputs
| Name |
Type |
Description
|
| ingestStatusSnapshot() returns |
ServiceResult<{ok:true}> |
ok, or error (invalid, too large, not found)
|
| getSnapshots() returns |
SnapshotMap |
agent name → StatusSnapshot
|
Usage Examples
import { ingestStatusSnapshot, getSnapshots } from '@/services/status-snapshots-service'
// Hook posts a status snapshot
const result = ingestStatusSnapshot('agent-uuid', {
sessionId: 'sess-123',
model: 'claude-sonnet-4',
effort: 'high',
})
if (result.data?.ok) console.log('Snapshot ingested')
// Browser store fetches all snapshots
const snapshots = getSnapshots({ localOnly: false })
const snap = snapshots['website']
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.