mirror of
https://github.com/stablyai/orca.git
synced 2026-10-02 16:02:15 +00:00
* feat(agent-launch): every launch carries the surface that started it The host now attributes every agent it builds to the surface that asked for it, resolving a missing or unrecognized surface to 'unknown' in one place instead of silently skipping it. The CLI names itself on worktree.create and orchestration workers name themselves host-side. * fix(agent-launch): attribute the agent a startup-draft create launches The host builds a third kind of agent launch: a worktree.create with a startupDraft and no startupAgent, where the host picks the agent itself. It carried no launch record at all and ignored the caller's launchSource. Route it through the same resolver as the other two builders, and derive the startupAgent terminal record only from the resolver so no prebuilt record can stand in for it. * fix(agent-launch): attribute the agent a host-built agent session launches terminal.createAgentSession builds a fresh agent's launch on the host, like the other startup builders, but spawned it with no launch record, so those launches were never counted. Record them through the same resolver; the request names no surface, so they count as unknown. * test(agent-launch): require an attribution decision for every host-built agent startup
31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
/**
|
|
* The `agent_started` triple for an agent launch the host builds, of which only `launch_source`
|
|
* comes from the caller.
|
|
*
|
|
* `agent_kind` and `request_kind` are derived rather than accepted — the host already knows both,
|
|
* and a value it derives is a value a caller cannot misreport. `request_kind` is always `new`
|
|
* because a host-built launch is always a fresh agent.
|
|
*
|
|
* Every launch is attributed: a caller that names no surface, or one this build has never heard of
|
|
* (a newer client), is recorded as `unknown` rather than dropped. The wire keeps the arm set open so
|
|
* an older host cannot refuse a newer client's launch over a label, and resolving it here, leniently,
|
|
* keeps that label from gating the launch at the point it is actually used.
|
|
*/
|
|
|
|
import { tuiAgentToAgentKind } from '../../shared/agent-kind'
|
|
import { launchSourceSchema } from '../../shared/telemetry-property-schemas'
|
|
import type { TuiAgent } from '../../shared/tui-agent'
|
|
import type { WorktreeStartupLaunch } from '../../shared/worktree/launch-types'
|
|
|
|
export function agentStartedTelemetry(
|
|
agent: TuiAgent,
|
|
launchSource: string | undefined
|
|
): NonNullable<WorktreeStartupLaunch['telemetry']> {
|
|
const parsed = launchSourceSchema.safeParse(launchSource)
|
|
return {
|
|
agent_kind: tuiAgentToAgentKind(agent),
|
|
launch_source: parsed.success ? parsed.data : 'unknown',
|
|
request_kind: 'new'
|
|
}
|
|
}
|