The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Agent registry frontend integration (#77)
Srajan Asthanaed87b22ba1cf
diff --git a/fern/openapi/openapi.json b/fern/openapi/openapi.jsonindex c095ce044..4ad9b6ebd 100644--- a/fern/openapi/openapi.json+++ b/fern/openapi/openapi.json@@ -727,11 +727,21 @@],"type": "object"},+ "CreateSessionAgent": {+ "anyOf": [+ {+ "$ref": "#/components/schemas/SessionAgentNameRef"+ },+ {+ "$ref": "#/components/schemas/SessionAgentSpecBody"+ }+ ]+ },"CreateSessionRequest": {"additionalProperties": false,"properties": {"agent": {- "$ref": "#/components/schemas/SessionAgent"+ "$ref": "#/components/schemas/CreateSessionAgent"}},"required": [@@ -2639,56 +2649,87 @@"SessionAgent": {"discriminator": {"mapping": {- "ref": "#/components/schemas/SessionAgentRef",- "value": "#/components/schemas/SessionAgentValue"+ "inline": "#/components/schemas/SessionAgentInline",+ "reference": "#/components/schemas/SessionAgentReference"},"propertyName": "type"},"oneOf": [{- "$ref": "#/components/schemas/SessionAgentRef"+ "$ref": "#/components/schemas/SessionAgentReference"},{- "$ref": "#/components/schemas/SessionAgentValue"+ "$ref": "#/components/schemas/SessionAgentInline"}]},- "SessionAgentRef": {+ "SessionAgentInline": {"additionalProperties": false,"properties": {- "agent_id": {- "minLength": 1,- "type": "string"+ "spec": {+ "$ref": "#/components/schemas/AgentSpec"},"type": {"enum": [- "ref"+ "inline"],"type": "string"}},"required": ["type",- "agent_id"+ "spec"],"type": "object"},- "SessionAgentValue": {+ "SessionAgentNameRef": {"additionalProperties": false,"properties": {- "agent_spec": {- "$ref": "#/components/schemas/AgentSpec"+ "name": {+ "$ref": "#/components/schemas/ResourceName"+ }+ },+ "required": [+ "name"+ ],+ "type": "object"+ },+ "SessionAgentReference": {+ "additionalProperties": false,+ "properties": {+ "id": {+ "minLength": 1,+ "type": "string"+ },+ "name": {+ "type": [+ "string",+ "null"+ ]},"type": {"enum": [- "value"+ "reference"],"type": "string"}},"required": ["type",- "agent_spec"+ "id",+ "name"+ ],+ "type": "object"+ },+ "SessionAgentSpecBody": {+ "additionalProperties": false,+ "properties": {+ "spec": {+ "$ref": "#/components/schemas/AgentSpec"+ }+ },+ "required": [+ "spec"],"type": "object"},@@ -3652,9 +3693,10 @@"type": "object"},"UpdateSessionRequest": {+ "additionalProperties": false,"properties": {"agent": {- "$ref": "#/components/schemas/SessionAgentValue"+ "$ref": "#/components/schemas/SessionAgentSpecBody"}},"type": "object"@@ -3899,6 +3941,36 @@}},"/api/v1/agents/{agent_id}": {+ "delete": {+ "description": "Delete a configured agent by immutable id. Idempotent if already gone.",+ "parameters": [+ {+ "description": "Immutable agent identifier.",+ "in": "path",+ "name": "agent_id",+ "required": true,+ "schema": {+ "description": "Immutable agent identifier.",+ "maxLength": 64,+ "minLength": 1,+ "type": "string"+ }+ }+ ],+ "responses": {+ "204": {+ "description": "Agent deleted."+ }+ },+ "summary": "Delete an agent",+ "tags": [+ "Agents"+ ],+ "x-fern-sdk-group-name": [+ "agents"+ ],+ "x-fern-sdk-method-name": "delete"+ },"get": {"description": "Fetch a configured agent by immutable id.","parameters": [@@ -4584,7 +4656,7 @@"x-fern-sdk-method-name": "list"},"post": {- "description": "Create a session with `agent` as either `{ type: \"value\", agent_spec }` (draft) or `{ type: \"ref\", agent_id }` (named). Named sessions resolve the live agent on each turn.",+ "description": "Create a session with `agent` as either `{ name }` (named registry binding) or `{ spec: AgentSpec }` (inline). Named sessions snapshot the agent name at create and resolve the live agent on each turn. Responses use `{ type: \"reference\", name, id }` or `{ type: \"inline\", spec }`.","requestBody": {"content": {"application/json": {@@ -4624,7 +4696,7 @@}}},- "description": "Named `agent_id` not found."+ "description": "Named agent not found."},"422": {"content": {@@ -4746,7 +4818,7 @@"x-fern-sdk-method-name": "get"},"patch": {- "description": "Update a draft session by replacing `agent` with a value arm. Named (ref) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.",+ "description": "Update a session by replacing `agent` with `{ spec: AgentSpec }`. Named (reference) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.","parameters": [{"description": "Session identifier.",diff --git a/packages/frontend/README.md b/packages/frontend/README.mdindex bc77815cf..908d65a77 100644--- a/packages/frontend/README.md+++ b/packages/frontend/README.md@@ -1,6 +1,6 @@# frontend-Private draft-only agent chat UI for the harness server. **Not published to npm** (`"private": true`).+Private agent chat UI for the harness server (registry + inline sessions). **Not published to npm** (`"private": true`).Built on:@@ -71,16 +71,17 @@ callbacks; `App.tsx` spreads them into `createTrueFoundryServer` (settings CRUD| `getModels` | `GET /api/v1/models` (also seeds `defaultAgentSpec.model`) || `getMcp` | `GET /api/v1/settings/mcp-servers` (carries auth status) || `getSkills` | `GET /api/v1/skills` when `GET /api/v1/capabilities` has skill on |-| `searchAgents` | Empty — Harness has no agent registry |-| `saveAgent` | Rejects — sessions are draft-only |+| `searchAgents` | `GET /api/v1/agents`, filtered by `query` and paged client-side |+| `saveAgent` | `PUT`/`POST /api/v1/agents` — updates by name, else creates |The SDK's picker round-trips a skill as `{ id, name }`. Harness persists name refs only(`{ name }`), so `harnessServer` derives `id` from `name` on read and strips `id` on write.Skills stay empty in the picker when the skill capability is off (no sandbox provider configured).-The Agents Library button still renders (the SDK shows it whenever `agentName` is omitted) and-opens an empty list; `AgentsLibraryButton` is not part of the publicly typed `AtomSlots`, so it-cannot be overridden away without a cast.+The Agents Library lists the registry, so sessions bind either to a registry agent (`{ name }`) or+to an inline spec (`{ spec }`). Reads name their agent on the `reference` arm, so the adapter never+resolves display names through the registry. History filtering forwards the library `agentId`+straight to `GET /sessions?agent_id=`.## Gaps@@ -88,7 +89,7 @@ cannot be overridden away without a cast.| ------------------------------------- | ---------------------------------------- || Subscribe turn SSE | Deferred (route defined, not registered) || Attachments / sandbox download | Off |-| Session `type` / `created_by_subject` | Soft — not required for draft FE |+| Session `type` / `created_by_subject` | Soft — not required for this FE || `turn.created.created_by` | Soft — stream adopt tolerates missing |## Scriptsdiff --git a/packages/frontend/package.json b/packages/frontend/package.jsonindex 02f91bca8..ad4edf1ca 100644--- a/packages/frontend/package.json+++ b/packages/frontend/package.json@@ -1,7 +1,7 @@{"name": "frontend","version": "0.0.0",- "description": "TrueFoundry agent chat frontend (draft-only). Private app — not published to npm.",+ "description": "TrueFoundry agent chat frontend. Private app — not published to npm.","author": "Truefoundry","license": "MIT","private": true,diff --git a/packages/frontend/src/harnessServer.ts b/packages/frontend/src/harnessServer.tsindex 018bfc41a..37ae2d040 100644--- a/packages/frontend/src/harnessServer.ts+++ b/packages/frontend/src/harnessServer.ts@@ -10,9 +10,9 @@* Skills are name refs on the wire (`SkillNameRef`); the UI SkillMount only* needs `{ id, name }`, so id is derived as the skill name.*- * Sessions bind either an inline draft (`agent.type === 'value'`) or a named- * registry ref (`agent.type === 'ref'`). The UI speaks names; the wire carries- * agent ids — resolve via the agents registry.+ * Session create takes `{ name }` or `{ spec }`; reads carry the+ * `reference`/`inline` discriminator, with reference rows already naming their+ * agent. The UI filters with registry `agentId`.*/import type {AgentChatServer,@@ -28,7 +28,7 @@ import type {TurnInputItem,UserMessageContent,} from '@truefoundry/trueforge-ui';-import type { TrueForgeApi as Harness, TrueForge } from 'trueforge';+import type { TrueForgeApi as Harness } from 'trueforge';import { createHarnessClient, harnessClient, type CreateHarnessClientOptions } from './harnessClient';export type HarnessSkillMount = SkillMount;export type HarnessMcpServerMount = McpServerMount & Harness.McpServer;@@ -88,38 +88,20 @@ export function agentManifest(agent: Harness.Agent): Harness.AgentSpec {return spec;}-/** `agentName` is caller-known (UI speaks names; the wire carries only agent ids). */-function toUiSession(session: Harness.Session, agentName?: string): Session<HarnessAgentSpec> {+function toUiSession(session: Harness.Session): Session<HarnessAgentSpec> {return {id: session.id,- isMutable: session.agent.type === 'value',+ isMutable: session.agent.type === 'inline',createdAt: session.createdAt,updatedAt: session.updatedAt,...(session.title === null ? {} : { title: session.title }),- // Ref sessions stay named even when the registry row is gone — stamp agentId- // so older runtimes that only forward custom.agentName still treat them immutable.- ...(session.agent.type === 'ref' ? { agentName: agentName ?? session.agent.agentId } : {}),- ...(session.agent.type === 'value' ? { agentSpec: toUiAgentSpec(session.agent.agentSpec) } : {}),+ // `name` is a create-time snapshot, so references whose agent predates it stay+ // unlabelled; `isMutable` alone keeps them out of the composer.+ ...(session.agent.type === 'reference' && session.agent.name !== null ? { agentName: session.agent.name } : {}),+ ...(session.agent.type === 'inline' ? { agentSpec: toUiAgentSpec(session.agent.spec) } : {}),};}-/**- * UI `agentId` filters may be a registry id or a display name (history filter /- * SingleAgent lock both pass names today).- */-export async function findAgent(client: TrueForge, agentIdOrName: string): Promise<Harness.Agent | undefined> {- const { data } = await client.agents.list();- return data.find(candidate => candidate.id === agentIdOrName || candidate.name === agentIdOrName);-}--export async function resolveAgent(client: TrueForge, agentIdOrName: string): Promise<Harness.Agent> {- const agent = await findAgent(client, agentIdOrName);- if (agent === undefined) {- throw new Error(`Agent not found: ${agentIdOrName}`);- }- return agent;-}-/** Spread drops the interface identity, which is what makes the SDK's index-signature part type accept it. */function toUiContent(content: Harness.UserMessageContent): UserMessageContent {return typeof content === 'string' ? content : content.map(part => ({ ...part }));@@ -207,15 +189,14 @@ export function createHarnessChatServer(options: CreateHarnessServerOptions = {}async createSession(request) {if (request.agentName !== undefined && request.agentName.length > 0) {- const agent = await resolveAgent(client, request.agentName);const created = await client.sessions.create({- agent: { type: 'ref', agentId: agent.id },+ agent: { name: request.agentName },});- return toUiSession(created.data, agent.name);+ return toUiSession(created.data);}if (request.agentSpec !== undefined) {const created = await client.sessions.create({- agent: { type: 'value', agentSpec: toHarnessAgentSpec(request.agentSpec) },+ agent: { spec: toHarnessAgentSpec(request.agentSpec) },});return toUiSession(created.data);}@@ -223,61 +204,24 @@ export function createHarnessChatServer(options: CreateHarnessServerOptions = {}},async listSessions(request = {}) {- const filterKey = request.agentId !== undefined && request.agentId.length > 0 ? request.agentId : undefined;- // Soft lookup: stale history filter / deleted agent / SingleAgent mismatch → empty page.- const agentFilter = filterKey === undefined ? undefined : await findAgent(client, filterKey);- if (filterKey !== undefined && agentFilter === undefined) {- const limit = request.limit ?? 20;- const data: Session<HarnessAgentSpec>[] = [];- const pagination = { limit };- const empty = (): HarnessPage<Session<HarnessAgentSpec>> => ({- data,- response: { data, pagination },- hasNextPage: () => false,- getNextPage: () => Promise.resolve(empty()),- });- return empty();- }- // Stamp ref rows with display names; registries are small (one tenant).- const nameById =- agentFilter !== undefined- ? new Map([[agentFilter.id, agentFilter.name]])- : new Map((await client.agents.list()).data.map(agent => [agent.id, agent.name]));-const page = await client.sessions.list({...(request.limit === undefined ? {} : { limit: request.limit }),...(request.order === undefined ? {} : { order: request.order }),...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),- ...(agentFilter === undefined ? {} : { agentId: agentFilter.id }),+ ...(request.agentId === undefined || request.agentId.length === 0 ? {} : { agentId: request.agentId }),});- return toPage(page, session =>- toUiSession(session, session.agent.type === 'ref' ? nameById.get(session.agent.agentId) : undefined),- );+ return toPage(page, toUiSession);},async getSession({ sessionId }) {const response = await client.sessions.get(sessionId);- const { agent } = response.data;- if (agent.type === 'ref') {- try {- const resolved = await resolveAgent(client, agent.agentId);- return toUiSession(response.data, resolved.name);- } catch {- return toUiSession(response.data);- }- }return toUiSession(response.data);},async updateSession({ sessionId, agentSpec }) {- if (agentSpec !== undefined) {- const current = await client.sessions.get(sessionId);- if (current.data.agent.type === 'ref') {- throw new Error('Cannot update agent on a named session');- }- }+ // Named (reference) sessions reject agent updates server-side.const response = await client.sessions.update(sessionId, {- ...(agentSpec === undefined ? {} : { agent: { type: 'value', agentSpec: toHarnessAgentSpec(agentSpec) } }),+ ...(agentSpec === undefined ? {} : { agent: { spec: toHarnessAgentSpec(agentSpec) } }),});return toUiSession(response.data);},diff --git a/packages/frontend/tests/harnessServer.test.ts b/packages/frontend/tests/harnessServer.test.tsindex b2b46c2ba..6743fe1b4 100644--- a/packages/frontend/tests/harnessServer.test.ts+++ b/packages/frontend/tests/harnessServer.test.ts@@ -5,8 +5,8 @@ import { createHarnessChatServer, type HarnessAgentSpec } from '../src/harnessSeconst session = {id: 'ses_1',agent: {- type: 'value',- agent_spec: {+ type: 'inline',+ spec: {model: { name: 'test/model' },mcp_servers: [{ name: 'github', enable_tools: ['@all'] }],skills: [{ name: 'review' }],@@ -87,8 +87,7 @@ describe('createHarnessChatServer', () => {const sent = sessionRequests.at(-1);assert.ok(sent !== null && typeof sent === 'object' && 'agent' in sent);assert.deepEqual(sent.agent, {- type: 'value',- agent_spec: {+ spec: {model: { name: 'test/model' },mcp_servers: [{ name: 'github', enable_tools: ['@all'] }],skills: [{ name: 'review' }],@@ -136,18 +135,13 @@ describe('createHarnessChatServer', () => {]);});- it('creates a ref session from agentName and reports it immutable', async () => {+ it('creates a named session from agentName and reports it immutable', async () => {const requests: { url: string; body?: unknown }[] = [];const fetchNamed: typeof fetch = async (input, init) => {const url = input instanceof Request ? input.url : String(input);- if (url.endsWith('/api/v1/agents')) {- return Response.json({- data: [{ id: 'agt_1', name: 'reviewer', model: { name: 'test/model' } }],- });- }if (url.endsWith('/api/v1/sessions') && init?.method === 'POST' && typeof init.body === 'string') {requests.push({ url, body: JSON.parse(init.body) });- return Response.json({ data: { ...session, agent: { type: 'ref', agent_id: 'agt_1' } } });+ return Response.json({ data: { ...session, agent: { type: 'reference', id: 'agt_1', name: 'reviewer' } } });}return new Response(`Unexpected request: ${url}`, { status: 500 });};@@ -155,36 +149,25 @@ describe('createHarnessChatServer', () => {const server = createHarnessChatServer({ fetch: fetchNamed });const created = await server.createSession({ agentName: 'reviewer' });- assert.deepEqual(requests.at(-1)?.body, { agent: { type: 'ref', agent_id: 'agt_1' } });+ assert.deepEqual(requests.at(-1)?.body, { agent: { name: 'reviewer' } });assert.equal(created.isMutable, false);assert.equal(created.agentName, 'reviewer');assert.equal(created.agentSpec, undefined);});- it('rejects createSession for an unknown agentName without touching sessions', async () => {- const fetchNamed: typeof fetch = async input => {- const url = input instanceof Request ? input.url : String(input);- if (url.endsWith('/api/v1/agents')) return Response.json({ data: [] });- return new Response(`Unexpected request: ${url}`, { status: 500 });- };-- const server = createHarnessChatServer({ fetch: fetchNamed });- await assert.rejects(() => server.createSession({ agentName: 'ghost' }), /Agent not found: ghost/);- });-- it('filters listSessions by agentId (name) and stamps it on the ref rows', async () => {+ it('filters listSessions by registry agentId and stamps the wire name on ref rows', async () => {let listUrl: string | undefined;+ let listedAgents = false;const fetchNamed: typeof fetch = async input => {const url = input instanceof Request ? input.url : String(input);if (url.endsWith('/api/v1/agents')) {- return Response.json({- data: [{ id: 'agt_1', name: 'reviewer', model: { name: 'test/model' } }],- });+ listedAgents = true;+ return Response.json({ data: [] });}if (url.includes('/api/v1/sessions?')) {listUrl = url;return Response.json({- data: [{ ...session, agent: { type: 'ref', agent_id: 'agt_1' } }],+ data: [{ ...session, agent: { type: 'reference', id: 'agt_1', name: 'reviewer' } }],pagination: { limit: 20 },});}@@ -192,49 +175,22 @@ describe('createHarnessChatServer', () => {};const server = createHarnessChatServer({ fetch: fetchNamed });- const page = await server.listSessions({ agentId: 'reviewer' });+ const page = await server.listSessions({ agentId: 'agt_1' });+ assert.equal(listedAgents, false);assert.ok(listUrl !== undefined);assert.equal(new URL(listUrl, 'http://test.local').searchParams.get('agent_id'), 'agt_1');assert.equal(page.data[0]?.agentName, 'reviewer');assert.equal(page.data[0]?.isMutable, false);});- it('filters listSessions when agentId is the registry id', async () => {+ it('listSessions forwards an unknown agentId to the API (empty page from the server)', async () => {let listUrl: string | undefined;const fetchNamed: typeof fetch = async input => {const url = input instanceof Request ? input.url : String(input);- if (url.endsWith('/api/v1/agents')) {- return Response.json({- data: [{ id: 'agt_1', name: 'reviewer', model: { name: 'test/model' } }],- });- }if (url.includes('/api/v1/sessions?')) {listUrl = url;- return Response.json({- data: [{ ...session, agent: { type: 'ref', agent_id: 'agt_1' } }],- pagination: { limit: 20 },- });- }- return new Response(`Unexpected request: ${url}`, { status: 500 });- };-- const server = createHarnessChatServer({ fetch: fetchNamed });- const page = await server.listSessions({ agentId: 'agt_1' });-- assert.ok(listUrl !== undefined);- assert.equal(new URL(listUrl, 'http://test.local').searchParams.get('agent_id'), 'agt_1');- assert.equal(page.data[0]?.agentName, 'reviewer');- });-- it('listSessions returns an empty page when agentId matches no registry agent', async () => {- let listedSessions = false;- const fetchNamed: typeof fetch = async input => {- const url = input instanceof Request ? input.url : String(input);- if (url.endsWith('/api/v1/agents')) return Response.json({ data: [] });- if (url.includes('/api/v1/sessions')) {- listedSessions = true;- return new Response(`Unexpected request: ${url}`, { status: 500 });+ return Response.json({ data: [], pagination: { limit: 10 } });}return new Response(`Unexpected request: ${url}`, { status: 500 });};@@ -242,22 +198,22 @@ describe('createHarnessChatServer', () => {const server = createHarnessChatServer({ fetch: fetchNamed });const page = await server.listSessions({ agentId: 'ghost', limit: 10 });- assert.equal(listedSessions, false);+ assert.ok(listUrl !== undefined);+ assert.equal(new URL(listUrl, 'http://test.local').searchParams.get('agent_id'), 'ghost');assert.deepEqual(page.data, []);assert.equal(page.hasNextPage(), false);- assert.deepEqual(page.response.pagination, { limit: 10 });});- it('getSession resolves the agentName of a ref session from the registry', async () => {+ it('getSession takes the agentName of a ref session from the wire, without a registry lookup', async () => {+ let listedAgents = false;const fetchNamed: typeof fetch = async input => {const url = input instanceof Request ? input.url : String(input);if (url.endsWith('/api/v1/agents')) {- return Response.json({- data: [{ id: 'agt_1', name: 'reviewer', model: { name: 'test/model' } }],- });+ listedAgents = true;+ return Response.json({ data: [] });}if (url.endsWith('/api/v1/sessions/ses_1')) {- return Response.json({ data: { ...session, agent: { type: 'ref', agent_id: 'agt_1' } } });+ return Response.json({ data: { ...session, agent: { type: 'reference', id: 'agt_1', name: 'reviewer' } } });}return new Response(`Unexpected request: ${url}`, { status: 500 });};@@ -265,16 +221,16 @@ describe('createHarnessChatServer', () => {const server = createHarnessChatServer({ fetch: fetchNamed });const found = await server.getSession({ sessionId: 'ses_1' });+ assert.equal(listedAgents, false);assert.equal(found.agentName, 'reviewer');assert.equal(found.isMutable, false);});- it('getSession stamps agentId as agentName when the registry agent is gone', async () => {+ it('getSession leaves a ref session unlabelled when it carries no name snapshot', async () => {const fetchNamed: typeof fetch = async input => {const url = input instanceof Request ? input.url : String(input);- if (url.endsWith('/api/v1/agents')) return Response.json({ data: [] });if (url.endsWith('/api/v1/sessions/ses_1')) {- return Response.json({ data: { ...session, agent: { type: 'ref', agent_id: 'agt_deleted' } } });+ return Response.json({ data: { ...session, agent: { type: 'reference', id: 'agt_deleted', name: null } } });}return new Response(`Unexpected request: ${url}`, { status: 500 });};@@ -283,25 +239,7 @@ describe('createHarnessChatServer', () => {const found = await server.getSession({ sessionId: 'ses_1' });assert.equal(found.isMutable, false);- assert.equal(found.agentName, 'agt_deleted');- });-- it('refuses to update the agent of a ref session', async () => {- const fetchNamed: typeof fetch = async input => {- const url = input instanceof Request ? input.url : String(input);- if (url.endsWith('/api/v1/sessions/ses_1')) {- return Response.json({ data: { ...session, agent: { type: 'ref', agent_id: 'agt_1' } } });- }- return new Response(`Unexpected request: ${url}`, { status: 500 });- };-- const server = createHarnessChatServer({ fetch: fetchNamed });- const updateSession = server.updateSession;- assert.ok(updateSession);- await assert.rejects(- () => updateSession({ sessionId: 'ses_1', agentSpec: { model: { name: 'test/model' } } }),- /Cannot update agent on a named session/,- );+ assert.equal(found.agentName, undefined);});it('subscribes to a turn and forwards afterSequenceNumber', async () => {diff --git a/packages/harness/src/agent-session/ITurnResourceResolver.ts b/packages/harness/src/agent-session/ITurnResourceResolver.tsindex 91b1e6dfa..b11d570e3 100644--- a/packages/harness/src/agent-session/ITurnResourceResolver.ts+++ b/packages/harness/src/agent-session/ITurnResourceResolver.ts@@ -18,7 +18,7 @@ export interface ITurnResourceResolver<TTurnCustom extends object = Record<strincreateTracing(): AgentTracing;/*** Look up the live AgentSpec for a named (ref) session agent.- * Draft (value) sessions use the stored spec and never call this.+ * Value sessions use the stored spec and never call this.*/resolveAgentSpec(input: { agent_id: string }): Promise<AgentSpec>;/**diff --git a/packages/harness/src/agent-session/SessionHandle.ts b/packages/harness/src/agent-session/SessionHandle.tsindex 2950830dd..2a7a204c3 100644--- a/packages/harness/src/agent-session/SessionHandle.ts+++ b/packages/harness/src/agent-session/SessionHandle.ts@@ -197,8 +197,7 @@ export class SessionHandle<try {const tracing = input.resolver.createTracing();const agent = this.session.agent;- const spec =- agent.type === 'value' ? agent.agent_spec : await input.resolver.resolveAgentSpec({ agent_id: agent.agent_id });+ const spec = agent.type === 'inline' ? agent.spec : await input.resolver.resolveAgentSpec({ agent_id: agent.id });const sandbox = await input.resolver.resolveSandbox({spec,existing: previous?.snapshot.sandbox_info ?? undefined,diff --git a/packages/harness/src/agent-session/Sessions.ts b/packages/harness/src/agent-session/Sessions.tsindex 872cd09ea..bc5376c5a 100644--- a/packages/harness/src/agent-session/Sessions.ts+++ b/packages/harness/src/agent-session/Sessions.ts@@ -20,7 +20,7 @@ export class Sessions<}/**- * Creates and persists a new session with a ref or value agent binding.+ * Creates and persists a new session with a reference or inline agent binding.*/async create(input: SessionsCreateInput<TSessionCustom>): Promise<SessionHandle<TSessionCustom, TTurnCustom>> {await this.store.createSession({diff --git a/packages/harness/src/agent-session/TurnResourceResolver.ts b/packages/harness/src/agent-session/TurnResourceResolver.tsindex dd0704594..997dc845e 100644--- a/packages/harness/src/agent-session/TurnResourceResolver.ts+++ b/packages/harness/src/agent-session/TurnResourceResolver.ts@@ -73,7 +73,7 @@ export class TurnResourceResolver<sandboxProvider?: TurnSandboxFactory | undefined;/*** Named-agent lookup (registry id → live AgentSpec). Required when a- * session is bound by ref; omit only if all sessions use value agents.+ * session is bound by reference; omit only if all sessions use inline agents.*/agent?: ((agentId: string) => Promise<AgentSpec>) | undefined;/** Forwarded to RemoteMCP / AgentThread (required by their constructors). */diff --git a/packages/harness/src/agent-session/index.ts b/packages/harness/src/agent-session/index.tsindex 69b4a2461..c1b574ec1 100644--- a/packages/harness/src/agent-session/index.ts+++ b/packages/harness/src/agent-session/index.ts@@ -21,7 +21,7 @@ export {} from './schemas/turn';export type { TerminalTurnState, Turn, TurnInputItem, TurnMetrics, TurnState } from './schemas/turn';-export { CreateSessionRequestSchema, SessionSchema, UpdateSessionRequestSchema } from './schemas/session';+export { SessionSchema } from './schemas/session';export type { Session, SessionAgent } from './schemas/session';export {diff --git a/packages/harness/src/agent-session/models/SessionRecord.ts b/packages/harness/src/agent-session/models/SessionRecord.tsindex ca94bd349..bbb95ce5d 100644--- a/packages/harness/src/agent-session/models/SessionRecord.ts+++ b/packages/harness/src/agent-session/models/SessionRecord.ts@@ -2,7 +2,8 @@ import type { SessionAgent } from '../schemas/session';/*** Session persistence record. Agent binding is a single discriminated `agent`- * (`ref` | `value`). Named agents are not hydrated on read.+ * (`reference` | `inline`). Reference rows carry create-time `name` snapshot+ * (nullable for legacy/orphan). Named agents are not hydrated to inline on read.*/export interface SessionRecord<TCustom extends object = Record<string, never>> {tenant_id: string;@@ -11,8 +12,8 @@ export interface SessionRecord<TCustom extends object = Record<string, never>> {created_by: string;agent: SessionAgent;/**- * Wire SessionSchema.title (nullable). Written via updateSession patch or- * createTurn's update_session_title_if_not_exist (first write wins; caller derives).+ * Public session title (nullable). Written via updateSession patch or createTurn's+ * update_session_title_if_not_exist (first write wins; caller derives).*/title: string | null;/**diff --git a/packages/harness/src/agent-session/schemas/session.ts b/packages/harness/src/agent-session/schemas/session.tsindex 1c5825d96..6a5deab16 100644--- a/packages/harness/src/agent-session/schemas/session.ts+++ b/packages/harness/src/agent-session/schemas/session.ts@@ -1,29 +1,31 @@/*** Session product schemas. Agent binding is a single discriminated `agent`- * field (`ref` | `value`). DB may still store agent_id / agent_spec columns.+ * field (`reference` | `inline`). DB stores agent_id / agent_name / agent_spec columns.*/import { z } from '@hono/zod-openapi';import { AgentSpecSchema } from './agentSpec';-export const SessionAgentRefSchema = z+export const SessionAgentReferenceSchema = z.object({- type: z.literal('ref'),- agent_id: z.string().min(1),+ type: z.literal('reference'),+ id: z.string().min(1),+ /** Create-time snapshot of the registry agent name; null for legacy/orphan rows. */+ name: z.string().nullable(),}).strict()- .openapi('SessionAgentRef');+ .openapi('SessionAgentReference');-export const SessionAgentValueSchema = z+export const SessionAgentInlineSchema = z.object({- type: z.literal('value'),- agent_spec: AgentSpecSchema,+ type: z.literal('inline'),+ spec: AgentSpecSchema,}).strict()- .openapi('SessionAgentValue');+ .openapi('SessionAgentInline');-/** Named registry binding or inline draft spec — exactly one arm. */+/** Named registry binding or inline AgentSpec — exactly one arm. */export const SessionAgentSchema = z- .discriminatedUnion('type', [SessionAgentRefSchema, SessionAgentValueSchema])+ .discriminatedUnion('type', [SessionAgentReferenceSchema, SessionAgentInlineSchema]).openapi('SessionAgent');export const SessionSchema = z@@ -38,22 +40,7 @@ export const SessionSchema = z}).openapi('Session');-/** Create binds a single agent (ref or value). */-export const CreateSessionRequestSchema = z- .object({- agent: SessionAgentSchema,- })- .strict()- .openapi('CreateSessionRequest');--/** Draft sessions only may replace the value agent; named (ref) sessions reject it. */-export const UpdateSessionRequestSchema = z- .object({- agent: SessionAgentValueSchema.optional(),- })- .openapi('UpdateSessionRequest');--export type SessionAgentRef = z.infer<typeof SessionAgentRefSchema>;-export type SessionAgentValue = z.infer<typeof SessionAgentValueSchema>;+export type SessionAgentReference = z.infer<typeof SessionAgentReferenceSchema>;+export type SessionAgentInline = z.infer<typeof SessionAgentInlineSchema>;export type SessionAgent = z.infer<typeof SessionAgentSchema>;export type Session = z.infer<typeof SessionSchema>;diff --git a/packages/harness/src/agent-session/store/ISessionStore.ts b/packages/harness/src/agent-session/store/ISessionStore.tsindex 1f5efedb1..c6df9c24c 100644--- a/packages/harness/src/agent-session/store/ISessionStore.ts+++ b/packages/harness/src/agent-session/store/ISessionStore.ts@@ -15,7 +15,7 @@ import type { TerminalTurnState } from '../schemas/turn';/*** Caller-supplied fields for creating a session; the store owns timestamps and tip state.- * `agent` is a discriminated ref | value binding.+ * `agent` is a discriminated reference | inline binding.*/export type CreateSessionInput<TSessionCustom extends object = Record<string, never>> = Pick<SessionRecord<TSessionCustom>,@@ -26,13 +26,13 @@ export type CreateSessionInput<TSessionCustom extends object = Record<string, ne/*** PATCH fields for an existing session; `undefined` fields are left unchanged.- * `agent` may be set only on draft (value) sessions, and only as a value arm.+ * `agent` may be set only on inline sessions, and only as an inline arm (`{ type: 'inline', spec }`).*/export type UpdateSessionInput<TSessionCustom extends object = Record<string, never>> = Pick<SessionRecord<TSessionCustom>,'tenant_id' | 'session_id'> & {- agent: Extract<SessionRecord<TSessionCustom>['agent'], { type: 'value' }> | undefined;+ agent: Extract<SessionRecord<TSessionCustom>['agent'], { type: 'inline' }> | undefined;title: SessionRecord<TSessionCustom>['title'] | undefined;};@@ -229,7 +229,7 @@ export interface ISessionStore</*** PATCH semantics — update only the provided fields:- * - agent: replace value binding (draft sessions only; ref → invariant error).+ * - agent: replace inline binding (inline sessions only; reference → invariant error).* - title: set/replace the session title.* Bumps `last_activity_timestamp_ms` (= now) in the same update.*/diff --git a/packages/harness/src/agent-session/store/InMemorySessionStore.ts b/packages/harness/src/agent-session/store/InMemorySessionStore.tsindex 866b1536b..98df5d2d5 100644--- a/packages/harness/src/agent-session/store/InMemorySessionStore.ts+++ b/packages/harness/src/agent-session/store/InMemorySessionStore.ts@@ -204,7 +204,7 @@ export class InMemorySessionStore<throw new SessionNotFoundError(input.session_id);}if (input.agent !== undefined) {- if (stored.record.agent.type === 'ref') {+ if (stored.record.agent.type === 'reference') {throw new SessionStoreInvariantError(`Session ${input.session_id} is named; agent cannot be updated`);}stored.record.agent = deepCopy(input.agent);@@ -226,7 +226,7 @@ export class InMemorySessionStore<if (stored.record.tenant_id !== input.tenant_id) continue;if (input.agent_id !== undefined &&- (stored.record.agent.type !== 'ref' || stored.record.agent.agent_id !== input.agent_id)+ (stored.record.agent.type !== 'reference' || stored.record.agent.id !== input.agent_id)) {continue;}diff --git a/packages/harness/tests/agent-session/capabilityState.test.ts b/packages/harness/tests/agent-session/capabilityState.test.tsindex ac342af02..5b58e94fa 100644--- a/packages/harness/tests/agent-session/capabilityState.test.ts+++ b/packages/harness/tests/agent-session/capabilityState.test.ts@@ -63,7 +63,7 @@ describe('capability_state (tfy.plan fixture)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const planV1: JsonValue = {@@ -135,7 +135,7 @@ describe('capability_state (tfy.plan fixture)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const planV1: JsonValue = {todo: [{ title: 'step', description: 'do it', status: 'done' }],@@ -228,7 +228,7 @@ describe('capability_state (tfy.plan fixture)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const turn = await session.createTurn({turn_id: mintTestTurnId(),diff --git a/packages/harness/tests/agent-session/resolveAgentSpec.test.ts b/packages/harness/tests/agent-session/resolveAgentSpec.test.tsindex c57d3e337..7f0b6b49c 100644--- a/packages/harness/tests/agent-session/resolveAgentSpec.test.ts+++ b/packages/harness/tests/agent-session/resolveAgentSpec.test.ts@@ -26,7 +26,7 @@ describe('SessionHandle.createTurn named resolve', () => {tenant_id: 'tenant-1',session_id: 's-named',created_by: 'user-1',- agent: { type: 'ref', agent_id: 'agent-abc' },+ agent: { type: 'reference', id: 'agent-abc', name: null },});const live = makeAgentSpec({ instructions: 'from-registry' });diff --git a/packages/harness/tests/agent-session/sessions.test.ts b/packages/harness/tests/agent-session/sessions.test.tsindex c0c7748a2..f9a53bd7a 100644--- a/packages/harness/tests/agent-session/sessions.test.ts+++ b/packages/harness/tests/agent-session/sessions.test.ts@@ -14,19 +14,19 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec({ instructions: 'hydrate-me' }) },+ agent: { type: 'inline', spec: makeAgentSpec({ instructions: 'hydrate-me' }) },custom: { tag: 'a' },});expect(created.agent).toEqual({- type: 'value',- agent_spec: expect.objectContaining({ instructions: 'hydrate-me' }),+ type: 'inline',+ spec: expect.objectContaining({ instructions: 'hydrate-me' }),});expect(created.custom).toEqual({ tag: 'a' });const loaded = await sessions.get({ tenant_id: tenant, session_id: 's1' });expect(loaded?.agent).toEqual({- type: 'value',- agent_spec: expect.objectContaining({ instructions: 'hydrate-me' }),+ type: 'inline',+ spec: expect.objectContaining({ instructions: 'hydrate-me' }),});expect(loaded?.session_id).toBe('s1');});@@ -38,7 +38,7 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const turn = await session.createTurn({turn_id: mintTestTurnId(),@@ -68,7 +68,7 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const created = await session.createTurn({turn_id: mintTestTurnId(),@@ -105,7 +105,7 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const t1 = await session.createTurn({turn_id: mintTestTurnId(),@@ -135,7 +135,7 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});const first = await session.createTurn({turn_id: mintTestTurnId(),@@ -167,7 +167,7 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});await expect(session.createTurn({@@ -204,7 +204,7 @@ describe('Sessions / SessionHandle / TurnHandle (storage + createTurn)', () => {tenant_id: tenant,session_id: 's1',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },});// Failure path: resources acquired before the throw must be released.diff --git a/packages/harness/tests/agent-session/store/storeContractSuite.ts b/packages/harness/tests/agent-session/store/storeContractSuite.tsindex 941590f0a..27c80526a 100644--- a/packages/harness/tests/agent-session/store/storeContractSuite.ts+++ b/packages/harness/tests/agent-session/store/storeContractSuite.ts@@ -83,7 +83,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: tenant,session_id: sessionId,created_by: 'user-1',- agent: { type: 'value', agent_spec: agentSpec },+ agent: { type: 'inline', spec: agentSpec },custom: null,});}@@ -160,7 +160,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {}describe('session CRUD + activity', () => {- it('createSession stores a value agent and sets last_activity_timestamp_ms', async () => {+ it('createSession stores an inline agent and sets last_activity_timestamp_ms', async () => {const store = createStore();const before = Date.now();await seedSession(store);@@ -169,8 +169,8 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {expect(mustGet(session).tenant_id).toBe(tenant);expect(mustGet(session).created_by).toBe('user-1');expect(mustGet(session).agent).toMatchObject({- type: 'value',- agent_spec: { model: { name: 'test-provider/test-model' } },+ type: 'inline',+ spec: { model: { name: 'test-provider/test-model' } },});expect(mustGet(session).last_activity_timestamp_ms).toBeGreaterThanOrEqual(before);expect(mustGet(session).title).toBeNull();@@ -182,7 +182,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: tenant,session_id: 'created-by-session',created_by: '[email protected]',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});const session = mustGet(await store.getSession({ tenant_id: tenant, session_id: 'created-by-session' }));@@ -202,19 +202,19 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {expect(listed.data.find(s => s.session_id === 'created-by-session')?.created_by).toBe('[email protected]');});- it('persists ref agents and listSessions filters by agent_id', async () => {+ it('persists reference agents and listSessions filters by agent_id', async () => {const store = createStore();await store.createSession({tenant_id: tenant,session_id: 'named-1',created_by: 'user-1',- agent: { type: 'ref', agent_id: 'agent-abc' },+ agent: { type: 'reference', id: 'agent-abc', name: null },custom: null,});await seedSession(store);const named = mustGet(await store.getSession({ tenant_id: tenant, session_id: 'named-1' }));- expect(named.agent).toEqual({ type: 'ref', agent_id: 'agent-abc' });+ expect(named.agent).toEqual({ type: 'reference', id: 'agent-abc', name: null });const filtered = await store.listSessions({agent_id: 'agent-abc',@@ -235,7 +235,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: tenant,session_id: 'named-1',created_by: 'user-1',- agent: { type: 'ref', agent_id: 'agent-abc' },+ agent: { type: 'reference', id: 'agent-abc', name: null },custom: null,});@@ -243,7 +243,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {store.updateSession({tenant_id: tenant,session_id: 'named-1',- agent: { type: 'value', agent_spec: makeAgentSpec({ instructions: 'nope' }) },+ agent: { type: 'inline', spec: makeAgentSpec({ instructions: 'nope' }) },title: undefined,}),).rejects.toBeInstanceOf(SessionStoreInvariantError);@@ -267,13 +267,13 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {await store.updateSession({tenant_id: tenant,session_id: sessionId,- agent: { type: 'value', agent_spec: nextSpec },+ agent: { type: 'inline', spec: nextSpec },title: 'Hello',});const after = await store.getSession({ tenant_id: tenant, session_id: sessionId });expect(mustGet(after).agent).toMatchObject({- type: 'value',- agent_spec: { instructions: 'updated' },+ type: 'inline',+ spec: { instructions: 'updated' },});expect(mustGet(after).title).toBe('Hello');expect(mustGet(after).last_activity_timestamp_ms).toBeGreaterThan(mustGet(before).last_activity_timestamp_ms);@@ -293,7 +293,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: 'other',session_id: sessionId,created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,}),).rejects.toBeInstanceOf(SessionStoreConflictError);@@ -308,7 +308,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: 'other',session_id: 'other-session',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});@@ -490,7 +490,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: tenant,session_id: nested,created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});await store.createTurn(makeCreateTurnInput({ sessionId: nested, turnId: 'turn-1' }));@@ -618,7 +618,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: tenant,session_id: id,created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});await new Promise(r => setTimeout(r, 2));@@ -632,7 +632,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: 'other',session_id: 'sx',created_by: 'user-1',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});@@ -722,14 +722,14 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {tenant_id: tenant,session_id: 'alice-session',created_by: 'alice',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});await store.createSession({tenant_id: tenant,session_id: 'bob-session',created_by: 'bob',- agent: { type: 'value', agent_spec: makeAgentSpec() },+ agent: { type: 'inline', spec: makeAgentSpec() },custom: null,});@@ -1652,8 +1652,8 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {const session = mustGet(await store.getSession({ tenant_id: tenant, session_id: sessionId }));expect(session.title).toBe(jsonLooking);expect(session.agent).toMatchObject({- type: 'value',- agent_spec: { instructions: jsonLooking },+ type: 'inline',+ spec: { instructions: jsonLooking },});expect(mustGet(turn).snapshot.threads[MAIN_THREAD_ID]?.context).toEqual([{ role: 'user', content: jsonLooking }]);});@@ -1977,14 +1977,14 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {const store = createStore();await seedSession(store);const session = mustGet(await store.getSession({ tenant_id: tenant, session_id: sessionId }));- if (session.agent.type !== 'value') {- throw new Error('expected value agent');+ if (session.agent.type !== 'inline') {+ throw new Error('expected inline agent');}- session.agent.agent_spec.instructions = 'mutated';+ session.agent.spec.instructions = 'mutated';const again = mustGet(await store.getSession({ tenant_id: tenant, session_id: sessionId }));expect(again.agent).toMatchObject({- type: 'value',- agent_spec: { instructions: 'You are a test agent.' },+ type: 'inline',+ spec: { instructions: 'You are a test agent.' },});});});diff --git a/packages/harness/tests/agent-session/turnStream.test.ts b/packages/harness/tests/agent-session/turnStream.test.tsindex 1451409ef..2426cbc01 100644--- a/packages/harness/tests/agent-session/turnStream.test.ts+++ b/packages/harness/tests/agent-session/turnStream.test.ts@@ -25,8 +25,8 @@ describe('TurnHandle.stream()', () => {session_id: 's1',created_by: 'user-1',agent: {- type: 'value',- agent_spec: makeAgentSpec({+ type: 'inline',+ spec: makeAgentSpec({config: {sandbox: { enabled: true, file_downloads: true },},@@ -478,8 +478,8 @@ describe('TurnResourceResolver caches', () => {session_id: 's',created_by: 'user-1',agent: {- type: 'value',- agent_spec: makeAgentSpec({+ type: 'inline',+ spec: makeAgentSpec({config: {sandbox: { enabled: true, file_downloads: true },},diff --git a/packages/sdk/.fern/metadata.json b/packages/sdk/.fern/metadata.jsonindex 836c56edb..0ef9224df 100644--- a/packages/sdk/.fern/metadata.json+++ b/packages/sdk/.fern/metadata.json@@ -27,7 +27,7 @@"streamType": "web","useDefaultRequestParameterValues": true},- "originGitCommit": "c2bf45cdfbdb210568d7e01ed635e204ce04facb",+ "originGitCommit": "90fe41de61c43396f77efc7a6a1b4c5504a494a7","originGitCommitIsDirty": true,"invokedBy": "ci","requestedVersion": "0.0.0",diff --git a/packages/sdk/reference.md b/packages/sdk/reference.mdindex 48b0d4d15..cd07fcacf 100644--- a/packages/sdk/reference.md+++ b/packages/sdk/reference.md@@ -182,6 +182,69 @@ await client.agents.get("agent_id");</dl>+</dd>+</dl>+</details>++<details><summary><code>client.agents.<a href="/src/api/resources/agents/client/Client.ts">delete</a>(agent_id) -> void</code></summary>+<dl>+<dd>++#### 📝 Description++<dl>+<dd>++<dl>+<dd>++Delete a configured agent by immutable id. Idempotent if already gone.+</dd>+</dl>+</dd>+</dl>++#### 🔌 Usage++<dl>+<dd>++<dl>+<dd>++```typescript+await client.agents.delete("agent_id");++```+</dd>+</dl>+</dd>+</dl>++#### ⚙️ Parameters++<dl>+<dd>++<dl>+<dd>++**agent_id:** `string` — Immutable agent identifier.++</dd>+</dl>++<dl>+<dd>++**requestOptions:** `AgentsClient.RequestOptions`++</dd>+</dl>+</dd>+</dl>++</dd></dl></details>@@ -750,7 +813,7 @@ await client.sessions.list();<dl><dd>-Create a session with `agent` as either `{ type: "value", agent_spec }` (draft) or `{ type: "ref", agent_id }` (named). Named sessions resolve the live agent on each turn.+Create a session with `agent` as either `{ name }` (named registry binding) or `{ spec: AgentSpec }` (inline). Named sessions snapshot the agent name at create and resolve the live agent on each turn. Responses use `{ type: "reference", name, id }` or `{ type: "inline", spec }`.</dd></dl></dd>@@ -767,8 +830,7 @@ Create a session with `agent` as either `{ type: "value", agent_spec }` (draft)```typescriptawait client.sessions.create({agent: {- agentId: "agent_id",- type: "ref"+ name: "name"}});@@ -944,7 +1006,7 @@ await client.sessions.delete("session_id");<dl><dd>-Update a draft session by replacing `agent` with a value arm. Named (ref) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.+Update a session by replacing `agent` with `{ spec: AgentSpec }`. Named (reference) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.</dd></dl></dd>diff --git a/packages/sdk/src/api/resources/agents/client/Client.ts b/packages/sdk/src/api/resources/agents/client/Client.tsindex 854fe273c..d6793dc21 100644--- a/packages/sdk/src/api/resources/agents/client/Client.ts+++ b/packages/sdk/src/api/resources/agents/client/Client.ts@@ -277,6 +277,57 @@ export class AgentsClient {return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/v1/agents/{agent_id}");}+ /**+ * Delete a configured agent by immutable id. Idempotent if already gone.+ *+ * @param {string} agent_id - Immutable agent identifier.+ * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.+ *+ * @throws {@link errors.TrueForgeError}+ * @throws {@link errors.TrueForgeTimeoutError}+ *+ * @example+ * await client.agents.delete("agent_id")+ */+ public delete(agent_id: string, requestOptions?: AgentsClient.RequestOptions): core.HttpResponsePromise<void> {+ return core.HttpResponsePromise.fromPromise(this.__delete(agent_id, requestOptions));+ }++ private async __delete(+ agent_id: string,+ requestOptions?: AgentsClient.RequestOptions,+ ): Promise<core.WithRawResponse<void>> {+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _response = await (this._options.fetcher ?? core.fetcher)({+ url: core.url.join(+ (await core.Supplier.get(this._options.baseUrl)) ??+ (await core.Supplier.get(this._options.environment)),+ `api/v1/agents/${core.url.encodePathParam(agent_id)}`,+ ),+ method: "DELETE",+ headers: _headers,+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,+ abortSignal: requestOptions?.abortSignal,+ fetchFn: this._options?.fetch,+ logging: this._options.logging,+ });+ if (_response.ok) {+ return { data: undefined, rawResponse: _response.rawResponse };+ }++ if (_response.error.reason === "status-code") {+ throw new errors.TrueForgeError({+ statusCode: _response.error.statusCode,+ body: _response.error.body,+ rawResponse: _response.rawResponse,+ });+ }++ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/api/v1/agents/{agent_id}");+ }+/*** Replaces the AgentSpec for an existing agent keyed by immutable `name`.*diff --git a/packages/sdk/src/api/resources/sessions/client/Client.ts b/packages/sdk/src/api/resources/sessions/client/Client.tsindex 1c1f2dd2d..6f1ffe540 100644--- a/packages/sdk/src/api/resources/sessions/client/Client.ts+++ b/packages/sdk/src/api/resources/sessions/client/Client.ts@@ -135,7 +135,7 @@ export class SessionsClient {}/**- * Create a session with `agent` as either `{ type: "value", agent_spec }` (draft) or `{ type: "ref", agent_id }` (named). Named sessions resolve the live agent on each turn.+ * Create a session with `agent` as either `{ name }` (named registry binding) or `{ spec: AgentSpec }` (inline). Named sessions snapshot the agent name at create and resolve the live agent on each turn. Responses use `{ type: "reference", name, id }` or `{ type: "inline", spec }`.** @param {TrueForge.CreateSessionRequest} request* @param {SessionsClient.RequestOptions} requestOptions - Request-specific configuration.@@ -149,8 +149,7 @@ export class SessionsClient {* @example* await client.sessions.create({* agent: {- * agentId: "agent_id",- * type: "ref"+ * name: "name"* }* })*/@@ -414,7 +413,7 @@ export class SessionsClient {}/**- * Update a draft session by replacing `agent` with a value arm. Named (ref) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.+ * Update a session by replacing `agent` with `{ spec: AgentSpec }`. Named (reference) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.** @param {string} session_id - Session identifier.* @param {TrueForge.UpdateSessionRequest} requestdiff --git a/packages/sdk/src/api/resources/sessions/client/requests/CreateSessionRequest.ts b/packages/sdk/src/api/resources/sessions/client/requests/CreateSessionRequest.tsindex e104606e2..043578697 100644--- a/packages/sdk/src/api/resources/sessions/client/requests/CreateSessionRequest.ts+++ b/packages/sdk/src/api/resources/sessions/client/requests/CreateSessionRequest.ts@@ -6,11 +6,10 @@ import type * as TrueForge from "../../../../index.js";* @example* {* agent: {- * agentId: "agent_id",- * type: "ref"+ * name: "name"* }* }*/export interface CreateSessionRequest {- agent: TrueForge.SessionAgent;+ agent: TrueForge.CreateSessionAgent;}diff --git a/packages/sdk/src/api/resources/sessions/client/requests/UpdateSessionRequest.ts b/packages/sdk/src/api/resources/sessions/client/requests/UpdateSessionRequest.tsindex b026e8030..cec02fa48 100644--- a/packages/sdk/src/api/resources/sessions/client/requests/UpdateSessionRequest.ts+++ b/packages/sdk/src/api/resources/sessions/client/requests/UpdateSessionRequest.ts@@ -7,5 +7,5 @@ import type * as TrueForge from "../../../../index.js";* {}*/export interface UpdateSessionRequest {- agent?: TrueForge.SessionAgentValue;+ agent?: TrueForge.SessionAgentSpecBody;}diff --git a/packages/sdk/src/api/types/CreateSessionAgent.ts b/packages/sdk/src/api/types/CreateSessionAgent.tsnew file mode 100644index 000000000..059a6abbf--- /dev/null+++ b/packages/sdk/src/api/types/CreateSessionAgent.ts@@ -0,0 +1,5 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../index.js";++export type CreateSessionAgent = TrueForge.SessionAgentNameRef | TrueForge.SessionAgentSpecBody;diff --git a/packages/sdk/src/api/types/SessionAgent.ts b/packages/sdk/src/api/types/SessionAgent.tsindex c6e454add..d19f22c00 100644--- a/packages/sdk/src/api/types/SessionAgent.ts+++ b/packages/sdk/src/api/types/SessionAgent.ts@@ -2,4 +2,4 @@import type * as TrueForge from "../index.js";-export type SessionAgent = TrueForge.SessionAgentRef | TrueForge.SessionAgentValue;+export type SessionAgent = TrueForge.SessionAgentInline | TrueForge.SessionAgentReference;diff --git a/packages/sdk/src/api/types/SessionAgentValue.ts b/packages/sdk/src/api/types/SessionAgentInline.tssimilarity index 55%rename from packages/sdk/src/api/types/SessionAgentValue.tsrename to packages/sdk/src/api/types/SessionAgentInline.tsindex c3e9caefa..5e4f05d4d 100644--- a/packages/sdk/src/api/types/SessionAgentValue.ts+++ b/packages/sdk/src/api/types/SessionAgentInline.ts@@ -2,7 +2,7 @@import type * as TrueForge from "../index.js";-export interface SessionAgentValue {- agentSpec: TrueForge.AgentSpec;- type: "value";+export interface SessionAgentInline {+ spec: TrueForge.AgentSpec;+ type: "inline";}diff --git a/packages/sdk/src/api/types/SessionAgentNameRef.ts b/packages/sdk/src/api/types/SessionAgentNameRef.tsnew file mode 100644index 000000000..1a9cf43f3--- /dev/null+++ b/packages/sdk/src/api/types/SessionAgentNameRef.ts@@ -0,0 +1,7 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../index.js";++export interface SessionAgentNameRef {+ name: TrueForge.ResourceName;+}diff --git a/packages/sdk/src/api/types/SessionAgentRef.ts b/packages/sdk/src/api/types/SessionAgentRef.tsdeleted file mode 100644index f140732b3..000000000--- a/packages/sdk/src/api/types/SessionAgentRef.ts+++ /dev/null@@ -1,6 +0,0 @@-// This file was auto-generated by Fern from our API Definition.--export interface SessionAgentRef {- agentId: string;- type: "ref";-}diff --git a/packages/sdk/src/api/types/SessionAgentReference.ts b/packages/sdk/src/api/types/SessionAgentReference.tsnew file mode 100644index 000000000..a049a8850--- /dev/null+++ b/packages/sdk/src/api/types/SessionAgentReference.ts@@ -0,0 +1,7 @@+// This file was auto-generated by Fern from our API Definition.++export interface SessionAgentReference {+ id: string;+ name: string | null;+ type: "reference";+}diff --git a/packages/sdk/src/api/types/SessionAgentSpecBody.ts b/packages/sdk/src/api/types/SessionAgentSpecBody.tsnew file mode 100644index 000000000..22083598d--- /dev/null+++ b/packages/sdk/src/api/types/SessionAgentSpecBody.ts@@ -0,0 +1,7 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../index.js";++export interface SessionAgentSpecBody {+ spec: TrueForge.AgentSpec;+}diff --git a/packages/sdk/src/api/types/index.ts b/packages/sdk/src/api/types/index.tsindex 8cb75afa1..c62170262 100644--- a/packages/sdk/src/api/types/index.ts+++ b/packages/sdk/src/api/types/index.ts@@ -30,6 +30,7 @@ export * from "./ConfiguredMcpServerAuth.js";export * from "./ContextManagementConfig.js";export * from "./ContextManagementConfigCompaction.js";export * from "./CreateAgentResponse.js";+export * from "./CreateSessionAgent.js";export * from "./CustomModelProvider.js";export * from "./DaytonaSandboxProvider.js";export * from "./DaytonaSandboxProviderAuth.js";@@ -127,8 +128,10 @@ export * from "./SandboxNetworkPolicyAuthInjectItemAuthData.js";export * from "./SandboxNetworkPolicyAuthInjectItemMatch.js";export * from "./Session.js";export * from "./SessionAgent.js";-export * from "./SessionAgentRef.js";-export * from "./SessionAgentValue.js";+export * from "./SessionAgentInline.js";+export * from "./SessionAgentNameRef.js";+export * from "./SessionAgentReference.js";+export * from "./SessionAgentSpecBody.js";export * from "./SessionEvent.js";export * from "./SessionEventItem.js";export * from "./SkillManifest.js";diff --git a/packages/sdk/src/serialization/resources/sessions/client/requests/CreateSessionRequest.ts b/packages/sdk/src/serialization/resources/sessions/client/requests/CreateSessionRequest.tsindex 362ccc2ba..b347909ac 100644--- a/packages/sdk/src/serialization/resources/sessions/client/requests/CreateSessionRequest.ts+++ b/packages/sdk/src/serialization/resources/sessions/client/requests/CreateSessionRequest.ts@@ -3,17 +3,17 @@import type * as TrueForge from "../../../../../api/index.js";import * as core from "../../../../../core/index.js";import type * as serializers from "../../../../index.js";-import { SessionAgent } from "../../../../types/SessionAgent.js";+import { CreateSessionAgent } from "../../../../types/CreateSessionAgent.js";export const CreateSessionRequest: core.serialization.Schema<serializers.CreateSessionRequest.Raw,TrueForge.CreateSessionRequest> = core.serialization.object({- agent: SessionAgent,+ agent: CreateSessionAgent,});export declare namespace CreateSessionRequest {export interface Raw {- agent: SessionAgent.Raw;+ agent: CreateSessionAgent.Raw;}}diff --git a/packages/sdk/src/serialization/resources/sessions/client/requests/UpdateSessionRequest.ts b/packages/sdk/src/serialization/resources/sessions/client/requests/UpdateSessionRequest.tsindex cf3169919..4cbecfe69 100644--- a/packages/sdk/src/serialization/resources/sessions/client/requests/UpdateSessionRequest.ts+++ b/packages/sdk/src/serialization/resources/sessions/client/requests/UpdateSessionRequest.ts@@ -3,17 +3,17 @@import type * as TrueForge from "../../../../../api/index.js";import * as core from "../../../../../core/index.js";import type * as serializers from "../../../../index.js";-import { SessionAgentValue } from "../../../../types/SessionAgentValue.js";+import { SessionAgentSpecBody } from "../../../../types/SessionAgentSpecBody.js";export const UpdateSessionRequest: core.serialization.Schema<serializers.UpdateSessionRequest.Raw,TrueForge.UpdateSessionRequest> = core.serialization.object({- agent: SessionAgentValue.optional(),+ agent: SessionAgentSpecBody.optional(),});export declare namespace UpdateSessionRequest {export interface Raw {- agent?: SessionAgentValue.Raw | null;+ agent?: SessionAgentSpecBody.Raw | null;}}diff --git a/packages/sdk/src/serialization/types/CreateSessionAgent.ts b/packages/sdk/src/serialization/types/CreateSessionAgent.tsnew file mode 100644index 000000000..e9a990f5a--- /dev/null+++ b/packages/sdk/src/serialization/types/CreateSessionAgent.ts@@ -0,0 +1,16 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";+import { SessionAgentNameRef } from "./SessionAgentNameRef.js";+import { SessionAgentSpecBody } from "./SessionAgentSpecBody.js";++export const CreateSessionAgent: core.serialization.Schema<+ serializers.CreateSessionAgent.Raw,+ TrueForge.CreateSessionAgent+> = core.serialization.undiscriminatedUnion([SessionAgentNameRef, SessionAgentSpecBody]);++export declare namespace CreateSessionAgent {+ export type Raw = SessionAgentNameRef.Raw | SessionAgentSpecBody.Raw;+}diff --git a/packages/sdk/src/serialization/types/SessionAgent.ts b/packages/sdk/src/serialization/types/SessionAgent.tsindex 299c20015..22080d5bc 100644--- a/packages/sdk/src/serialization/types/SessionAgent.ts+++ b/packages/sdk/src/serialization/types/SessionAgent.ts@@ -3,12 +3,12 @@import type * as TrueForge from "../../api/index.js";import * as core from "../../core/index.js";import type * as serializers from "../index.js";-import { SessionAgentRef } from "./SessionAgentRef.js";-import { SessionAgentValue } from "./SessionAgentValue.js";+import { SessionAgentInline } from "./SessionAgentInline.js";+import { SessionAgentReference } from "./SessionAgentReference.js";export const SessionAgent: core.serialization.Schema<serializers.SessionAgent.Raw, TrueForge.SessionAgent> =- core.serialization.undiscriminatedUnion([SessionAgentRef, SessionAgentValue]);+ core.serialization.undiscriminatedUnion([SessionAgentInline, SessionAgentReference]);export declare namespace SessionAgent {- export type Raw = SessionAgentRef.Raw | SessionAgentValue.Raw;+ export type Raw = SessionAgentInline.Raw | SessionAgentReference.Raw;}diff --git a/packages/sdk/src/serialization/types/SessionAgentInline.ts b/packages/sdk/src/serialization/types/SessionAgentInline.tsnew file mode 100644index 000000000..ae5848581--- /dev/null+++ b/packages/sdk/src/serialization/types/SessionAgentInline.ts@@ -0,0 +1,21 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";+import { AgentSpec } from "./AgentSpec.js";++export const SessionAgentInline: core.serialization.ObjectSchema<+ serializers.SessionAgentInline.Raw,+ TrueForge.SessionAgentInline+> = core.serialization.object({+ spec: AgentSpec,+ type: core.serialization.stringLiteral("inline"),+});++export declare namespace SessionAgentInline {+ export interface Raw {+ spec: AgentSpec.Raw;+ type: "inline";+ }+}diff --git a/packages/sdk/src/serialization/types/SessionAgentNameRef.ts b/packages/sdk/src/serialization/types/SessionAgentNameRef.tsnew file mode 100644index 000000000..526ff60de--- /dev/null+++ b/packages/sdk/src/serialization/types/SessionAgentNameRef.ts@@ -0,0 +1,19 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";+import { ResourceName } from "./ResourceName.js";++export const SessionAgentNameRef: core.serialization.ObjectSchema<+ serializers.SessionAgentNameRef.Raw,+ TrueForge.SessionAgentNameRef+> = core.serialization.object({+ name: ResourceName,+});++export declare namespace SessionAgentNameRef {+ export interface Raw {+ name: ResourceName.Raw;+ }+}diff --git a/packages/sdk/src/serialization/types/SessionAgentRef.ts b/packages/sdk/src/serialization/types/SessionAgentRef.tsdeleted file mode 100644index 6544c055c..000000000--- a/packages/sdk/src/serialization/types/SessionAgentRef.ts+++ /dev/null@@ -1,20 +0,0 @@-// This file was auto-generated by Fern from our API Definition.--import type * as TrueForge from "../../api/index.js";-import * as core from "../../core/index.js";-import type * as serializers from "../index.js";--export const SessionAgentRef: core.serialization.ObjectSchema<- serializers.SessionAgentRef.Raw,- TrueForge.SessionAgentRef-> = core.serialization.object({- agentId: core.serialization.property("agent_id", core.serialization.string()),- type: core.serialization.stringLiteral("ref"),-});--export declare namespace SessionAgentRef {- export interface Raw {- agent_id: string;- type: "ref";- }-}diff --git a/packages/sdk/src/serialization/types/SessionAgentReference.ts b/packages/sdk/src/serialization/types/SessionAgentReference.tsnew file mode 100644index 000000000..126747dcd--- /dev/null+++ b/packages/sdk/src/serialization/types/SessionAgentReference.ts@@ -0,0 +1,22 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";++export const SessionAgentReference: core.serialization.ObjectSchema<+ serializers.SessionAgentReference.Raw,+ TrueForge.SessionAgentReference+> = core.serialization.object({+ id: core.serialization.string(),+ name: core.serialization.string().nullable(),+ type: core.serialization.stringLiteral("reference"),+});++export declare namespace SessionAgentReference {+ export interface Raw {+ id: string;+ name?: string | null;+ type: "reference";+ }+}diff --git a/packages/sdk/src/serialization/types/SessionAgentSpecBody.ts b/packages/sdk/src/serialization/types/SessionAgentSpecBody.tsnew file mode 100644index 000000000..6e2ade56b--- /dev/null+++ b/packages/sdk/src/serialization/types/SessionAgentSpecBody.ts@@ -0,0 +1,19 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";+import { AgentSpec } from "./AgentSpec.js";++export const SessionAgentSpecBody: core.serialization.ObjectSchema<+ serializers.SessionAgentSpecBody.Raw,+ TrueForge.SessionAgentSpecBody+> = core.serialization.object({+ spec: AgentSpec,+});++export declare namespace SessionAgentSpecBody {+ export interface Raw {+ spec: AgentSpec.Raw;+ }+}diff --git a/packages/sdk/src/serialization/types/SessionAgentValue.ts b/packages/sdk/src/serialization/types/SessionAgentValue.tsdeleted file mode 100644index eae372748..000000000--- a/packages/sdk/src/serialization/types/SessionAgentValue.ts+++ /dev/null@@ -1,21 +0,0 @@-// This file was auto-generated by Fern from our API Definition.--import type * as TrueForge from "../../api/index.js";-import * as core from "../../core/index.js";-import type * as serializers from "../index.js";-import { AgentSpec } from "./AgentSpec.js";--export const SessionAgentValue: core.serialization.ObjectSchema<- serializers.SessionAgentValue.Raw,- TrueForge.SessionAgentValue-> = core.serialization.object({- agentSpec: core.serialization.property("agent_spec", AgentSpec),- type: core.serialization.stringLiteral("value"),-});--export declare namespace SessionAgentValue {- export interface Raw {- agent_spec: AgentSpec.Raw;- type: "value";- }-}diff --git a/packages/sdk/src/serialization/types/index.ts b/packages/sdk/src/serialization/types/index.tsindex 8cb75afa1..c62170262 100644--- a/packages/sdk/src/serialization/types/index.ts+++ b/packages/sdk/src/serialization/types/index.ts@@ -30,6 +30,7 @@ export * from "./ConfiguredMcpServerAuth.js";export * from "./ContextManagementConfig.js";export * from "./ContextManagementConfigCompaction.js";export * from "./CreateAgentResponse.js";+export * from "./CreateSessionAgent.js";export * from "./CustomModelProvider.js";export * from "./DaytonaSandboxProvider.js";export * from "./DaytonaSandboxProviderAuth.js";@@ -127,8 +128,10 @@ export * from "./SandboxNetworkPolicyAuthInjectItemAuthData.js";export * from "./SandboxNetworkPolicyAuthInjectItemMatch.js";export * from "./Session.js";export * from "./SessionAgent.js";-export * from "./SessionAgentRef.js";-export * from "./SessionAgentValue.js";+export * from "./SessionAgentInline.js";+export * from "./SessionAgentNameRef.js";+export * from "./SessionAgentReference.js";+export * from "./SessionAgentSpecBody.js";export * from "./SessionEvent.js";export * from "./SessionEventItem.js";export * from "./SkillManifest.js";diff --git a/packages/sdk/tests/wire/agents.test.ts b/packages/sdk/tests/wire/agents.test.tsindex 5b0f7ceff..cd3361ffb 100644--- a/packages/sdk/tests/wire/agents.test.ts+++ b/packages/sdk/tests/wire/agents.test.ts@@ -300,6 +300,16 @@ describe("AgentsClient", () => {}).rejects.toThrow(TrueForgeTypes.NotFoundError);});+ test("delete", async () => {+ const server = mockServerPool.createServer();+ const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });++ server.mockEndpoint().delete("/api/v1/agents/agent_id").respondWith().statusCode(200).build();++ const response = await client.agents.delete("agent_id");+ expect(response).toEqual(undefined);+ });+test("update (1)", async () => {const server = mockServerPool.createServer();const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });diff --git a/packages/sdk/tests/wire/sessions.test.ts b/packages/sdk/tests/wire/sessions.test.tsindex 6300b3307..1fa82bfb0 100644--- a/packages/sdk/tests/wire/sessions.test.ts+++ b/packages/sdk/tests/wire/sessions.test.ts@@ -12,7 +12,7 @@ describe("SessionsClient", () => {const rawResponseBody = {data: [{- agent: { agent_id: "agent_id", type: "ref" },+ agent: { spec: { model: { name: "name" } }, type: "inline" },created_at: "created_at",created_by: "created_by",id: "id",@@ -35,8 +35,12 @@ describe("SessionsClient", () => {data: [{agent: {- agentId: "agent_id",- type: "ref",+ spec: {+ model: {+ name: "name",+ },+ },+ type: "inline",},createdAt: "created_at",createdBy: "created_by",@@ -75,10 +79,10 @@ describe("SessionsClient", () => {test("create (1)", async () => {const server = mockServerPool.createServer();const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });- const rawRequestBody = { agent: { agent_id: "agent_id", type: "ref" } };+ const rawRequestBody = { agent: { name: "name" } };const rawResponseBody = {data: {- agent: { agent_id: "agent_id", type: "ref" },+ agent: { spec: { model: { name: "name" } }, type: "inline" },created_at: "created_at",created_by: "created_by",id: "id",@@ -98,15 +102,18 @@ describe("SessionsClient", () => {const response = await client.sessions.create({agent: {- agentId: "agent_id",- type: "ref",+ name: "name",},});expect(response).toEqual({data: {agent: {- agentId: "agent_id",- type: "ref",+ spec: {+ model: {+ name: "name",+ },+ },+ type: "inline",},createdAt: "created_at",createdBy: "created_by",@@ -120,7 +127,7 @@ describe("SessionsClient", () => {test("create (2)", async () => {const server = mockServerPool.createServer();const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });- const rawRequestBody = { agent: { agent_id: "x", type: "ref" } };+ const rawRequestBody = { agent: { name: "xy" } };const rawResponseBody = { error: { message: "message" } };server@@ -135,8 +142,7 @@ describe("SessionsClient", () => {await expect(async () => {return await client.sessions.create({agent: {- agentId: "x",- type: "ref",+ name: "xy",},});}).rejects.toThrow(TrueForgeTypes.BadRequestError);@@ -145,7 +151,7 @@ describe("SessionsClient", () => {test("create (3)", async () => {const server = mockServerPool.createServer();const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });- const rawRequestBody = { agent: { agent_id: "x", type: "ref" } };+ const rawRequestBody = { agent: { name: "xy" } };const rawResponseBody = { error: { message: "message" } };server@@ -160,8 +166,7 @@ describe("SessionsClient", () => {await expect(async () => {return await client.sessions.create({agent: {- agentId: "x",- type: "ref",+ name: "xy",},});}).rejects.toThrow(TrueForgeTypes.NotFoundError);@@ -170,7 +175,7 @@ describe("SessionsClient", () => {test("create (4)", async () => {const server = mockServerPool.createServer();const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });- const rawRequestBody = { agent: { agent_id: "x", type: "ref" } };+ const rawRequestBody = { agent: { name: "xy" } };const rawResponseBody = { error: { message: "message" } };server@@ -185,8 +190,7 @@ describe("SessionsClient", () => {await expect(async () => {return await client.sessions.create({agent: {- agentId: "x",- type: "ref",+ name: "xy",},});}).rejects.toThrow(TrueForgeTypes.UnprocessableEntityError);@@ -198,7 +202,7 @@ describe("SessionsClient", () => {const rawResponseBody = {data: {- agent: { agent_id: "agent_id", type: "ref" },+ agent: { spec: { model: { name: "name" } }, type: "inline" },created_at: "created_at",created_by: "created_by",id: "id",@@ -219,8 +223,12 @@ describe("SessionsClient", () => {expect(response).toEqual({data: {agent: {- agentId: "agent_id",- type: "ref",+ spec: {+ model: {+ name: "name",+ },+ },+ type: "inline",},createdAt: "created_at",createdBy: "created_by",@@ -304,7 +312,7 @@ describe("SessionsClient", () => {const rawRequestBody = {};const rawResponseBody = {data: {- agent: { agent_id: "agent_id", type: "ref" },+ agent: { spec: { model: { name: "name" } }, type: "inline" },created_at: "created_at",created_by: "created_by",id: "id",@@ -326,8 +334,12 @@ describe("SessionsClient", () => {expect(response).toEqual({data: {agent: {- agentId: "agent_id",- type: "ref",+ spec: {+ model: {+ name: "name",+ },+ },+ type: "inline",},createdAt: "created_at",createdBy: "created_by",diff --git a/packages/server/src/apis/agents.ts b/packages/server/src/apis/agents.tsindex d57160fc0..ea4a3dc59 100644--- a/packages/server/src/apis/agents.ts+++ b/packages/server/src/apis/agents.ts@@ -8,7 +8,13 @@ import type { IMcpServerStore } from '../db/mcpServerStore';import type { IModelProviderStore } from '../db/modelProviderStore';import type { ISandboxProviderStore } from '../db/sandboxProviderStore';import type { ISkillStore } from '../db/skillStore';-import { createAgentRoute, getAgentRoute, listAgentsRoute, putAgentRoute } from '../routes/agentRoutes';+import {+ createAgentRoute,+ deleteAgentRoute,+ getAgentRoute,+ listAgentsRoute,+ putAgentRoute,+} from '../routes/agentRoutes';import { validateAgentSpec } from '../runtime/sessionResources';import { toAgentManifest, type Agent, type AgentWriteRequest } from '../schemas/agent';import { TENANT_ID } from './sessions';@@ -75,6 +81,12 @@ export function createAgentsRouter(deps: AgentsRouterDeps) {return c.json({ data: toWireAgent(record) }, 200);};+ const deleteHandler: RouteHandler<typeof deleteAgentRoute> = async c => {+ const { agent_id: agentId } = c.req.valid('param');+ await deps.agentStore.deleteAgent({ tenant_id: TENANT_ID, id: agentId });+ return c.body(null, 204);+ };+const putHandler: RouteHandler<typeof putAgentRoute> = async c => {const { name } = c.req.valid('param');const body = c.req.valid('json');@@ -94,6 +106,7 @@ export function createAgentsRouter(deps: AgentsRouterDeps) {router.openapi(listAgentsRoute, listHandler);router.openapi(createAgentRoute, createHandler);router.openapi(getAgentRoute, getHandler);+ router.openapi(deleteAgentRoute, deleteHandler);router.openapi(putAgentRoute, putHandler);return router;}diff --git a/packages/server/src/apis/sessions.ts b/packages/server/src/apis/sessions.tsindex 9aa91e882..e93858cfc 100644--- a/packages/server/src/apis/sessions.ts+++ b/packages/server/src/apis/sessions.ts@@ -37,7 +37,7 @@ import {import type { ActiveTurnRegistry } from '../runtime/activeTurns';import { executorFromTurnId } from '../runtime/peeringIds';import { validateAgentSpec } from '../runtime/sessionResources';-import type { Session } from '../schemas/session';+import { isSessionAgentNameRef, type Session } from '../schemas/session';/** The server is single-tenant; every record lives under one fixed tenant scope. */export const TENANT_ID = 'default';@@ -198,23 +198,23 @@ export function createSessionsRouter(deps: SessionsRouterDeps) {const body = c.req.valid('json');const sessionId = ulid().toLowerCase();- if (body.agent.type === 'ref') {- const agent = await deps.agentStore.getAgent({ tenant_id: TENANT_ID, id: body.agent.agent_id });+ if (isSessionAgentNameRef(body.agent)) {+ const agent = await deps.agentStore.getAgent({ tenant_id: TENANT_ID, name: body.agent.name });if (agent === undefined) {- return c.json({ error: { message: `Agent not found: ${body.agent.agent_id}` } }, 404);+ return c.json({ error: { message: `Agent not found: ${body.agent.name}` } }, 404);}const user = deps.resolveUserContext(c);const session = await deps.sessions.create({tenant_id: TENANT_ID,session_id: sessionId,created_by: user.userRef,- agent: body.agent,+ agent: { type: 'reference', id: agent.id, name: agent.name },});return c.json({ data: toWireSession(session.record) }, 201);}await validateAgentSpec({- spec: body.agent.agent_spec,+ spec: body.agent.spec,tenant_id: TENANT_ID,modelProviderStore: deps.modelProviderStore,mcpServerStore: deps.mcpServerStore,@@ -226,7 +226,7 @@ export function createSessionsRouter(deps: SessionsRouterDeps) {tenant_id: TENANT_ID,session_id: sessionId,created_by: user.userRef,- agent: body.agent,+ agent: { type: 'inline', spec: body.agent.spec },});return c.json({ data: toWireSession(session.record) }, 201);};@@ -267,11 +267,11 @@ export function createSessionsRouter(deps: SessionsRouterDeps) {if (!checkSessionAccess({ userRef: deps.resolveUserContext(c).userRef, createdBy: existing.created_by })) {return c.json({ error: { message: FORBIDDEN_SESSION_ACCESS } }, 403);}- // Draft (value) sessions may replace their inline agent; named (ref) sessions+ // Inline sessions may replace their agent; named (reference) sessions// cannot — the store rejects that with SessionStoreInvariantError → 422 below.if (body.agent !== undefined) {await validateAgentSpec({- spec: body.agent.agent_spec,+ spec: body.agent.spec,tenant_id: TENANT_ID,modelProviderStore: deps.modelProviderStore,mcpServerStore: deps.mcpServerStore,@@ -283,7 +283,7 @@ export function createSessionsRouter(deps: SessionsRouterDeps) {await deps.sessionStore.updateSession({tenant_id: TENANT_ID,session_id: sessionId,- agent: body.agent,+ agent: body.agent === undefined ? undefined : { type: 'inline', spec: body.agent.spec },title: undefined,});} catch (error) {diff --git a/packages/server/src/db/agentStore.ts b/packages/server/src/db/agentStore.tsindex 8655b836c..85cc58b4e 100644--- a/packages/server/src/db/agentStore.ts+++ b/packages/server/src/db/agentStore.ts@@ -4,7 +4,7 @@* `AgentSpec` jsonb document.* Implementations: PostgresAgentStore and SqliteAgentStore.*/-import type { AgentSpec } from '@truefoundry/utils-core/agent-session';+import { AgentSpecSchema, type AgentSpec } from '@truefoundry/utils-core/agent-session';import type { ResourceName } from '../schemas/common';export interface AgentRecord {@@ -18,6 +18,14 @@ export interface AgentRecord {updated_at: string;}+/**+ * Re-parse persisted manifest JSON so schema defaults (e.g. nested `config`) materialize.+ * Rows written before a config field existed omit it on disk; readers must not assume presence.+ */+export function parseStoredAgentSpec(manifest: unknown): AgentSpec {+ return AgentSpecSchema.parse(manifest);+}+/** Look up by immutable id or unique name within a tenant. */export type GetAgentInput = { tenant_id: string } & ({ id: string } | { name: string });@@ -34,6 +42,11 @@ export interface UpdateAgentInput {manifest: AgentSpec;}+export interface DeleteAgentInput {+ tenant_id: string;+ id: string;+}+/** Unique `(tenant_id, name)` violation on create. */export class AgentNameConflictError extends Error {readonly tenant_id: string;@@ -54,4 +67,6 @@ export interface IAgentStore {createAgent(input: CreateAgentInput): Promise<AgentRecord>;/** Replaces `manifest` for an existing name. Returns undefined if missing. */updateAgent(input: UpdateAgentInput): Promise<AgentRecord | undefined>;+ /** Deletes by immutable id. Idempotent if already missing. */+ deleteAgent(input: DeleteAgentInput): Promise<void>;}diff --git a/packages/server/src/db/postgres/agent-store/PostgresAgentStore.ts b/packages/server/src/db/postgres/agent-store/PostgresAgentStore.tsindex 5a44740c6..b5a9706d7 100644--- a/packages/server/src/db/postgres/agent-store/PostgresAgentStore.ts+++ b/packages/server/src/db/postgres/agent-store/PostgresAgentStore.ts@@ -2,8 +2,10 @@ import type { Kysely, Selectable } from 'kysely';import { ulid } from 'ulid';import {AgentNameConflictError,+ parseStoredAgentSpec,type AgentRecord,type CreateAgentInput,+ type DeleteAgentInput,type GetAgentInput,type IAgentStore,type UpdateAgentInput,@@ -17,7 +19,7 @@ function toRecord(row: Selectable<AgentTable>): AgentRecord {id: row.id,tenant_id: row.tenant_id,name: row.name,- manifest: row.manifest,+ manifest: parseStoredAgentSpec(row.manifest),created_at: row.created_at.toISOString(),updated_at: row.updated_at.toISOString(),};@@ -87,4 +89,8 @@ export class PostgresAgentStore implements IAgentStore {.executeTakeFirst();return row === undefined ? undefined : toRecord(row);}++ async deleteAgent(input: DeleteAgentInput): Promise<void> {+ await this.#db.deleteFrom('agent').where('tenant_id', '=', input.tenant_id).where('id', '=', input.id).execute();+ }}diff --git a/packages/server/src/db/postgres/migrations/20260812_000001_session_agent_name.ts b/packages/server/src/db/postgres/migrations/20260812_000001_session_agent_name.tsnew file mode 100644index 000000000..514460685--- /dev/null+++ b/packages/server/src/db/postgres/migrations/20260812_000001_session_agent_name.ts@@ -0,0 +1,23 @@+import { sql, type Kysely } from 'kysely';++/**+ * Create-time snapshot of registry agent name on named sessions.+ * Backfills from `agent.name` where `session.agent_id` still resolves;+ * orphan refs stay NULL.+ */+export async function up(db: Kysely<unknown>): Promise<void> {+ await sql`SET LOCAL lock_timeout = '5s'`.execute(db);+ await db.schema.alterTable('session').addColumn('agent_name', 'text').execute();+ await sql`+ UPDATE session AS s+ SET agent_name = a.name+ FROM agent AS a+ WHERE s.agent_id = a.id+ AND s.tenant_id = a.tenant_id+ `.execute(db);+}++export async function down(db: Kysely<unknown>): Promise<void> {+ await sql`SET LOCAL lock_timeout = '5s'`.execute(db);+ await db.schema.alterTable('session').dropColumn('agent_name').execute();+}diff --git a/packages/server/src/db/postgres/session-store/queries/sessions.ts b/packages/server/src/db/postgres/session-store/queries/sessions.tsindex d16b50fd7..44148164f 100644--- a/packages/server/src/db/postgres/session-store/queries/sessions.ts+++ b/packages/server/src/db/postgres/session-store/queries/sessions.ts@@ -50,6 +50,7 @@ function mapRowToSessionRecord(row: {session_id: string;created_by: string;agent_id: string | null;+ agent_name: string | null;agent_spec: AgentSpec | null;title: string | null;last_turn_id: string | null;@@ -65,6 +66,7 @@ function mapRowToSessionRecord(row: {agent: sessionAgentFromColumns({session_id: row.session_id,agent_id: row.agent_id,+ agent_name: row.agent_name,agent_spec: row.agent_spec,}),title: row.title,@@ -88,6 +90,7 @@ export async function createSession(db: Kysely<Database>, input: CreateSessionInsession_id: input.session_id,created_by: input.created_by,agent_id: columns.agent_id,+ agent_name: columns.agent_name,agent_spec: columns.agent_spec !== null ? json(columns.agent_spec) : null,title: null,custom: input.custom !== null ? json(input.custom) : null,@@ -139,7 +142,7 @@ export async function updateSession(db: Kysely<Database>, input: UpdateSessionInif (existing === undefined) {throw new SessionNotFoundError(input.session_id);}- if (existing.agent.type === 'ref') {+ if (existing.agent.type === 'reference') {throw new SessionStoreInvariantError(`Session ${input.session_id} is named; agent cannot be updated`);}}@@ -154,7 +157,7 @@ export async function updateSession(db: Kysely<Database>, input: UpdateSessionInif (agent === undefined) {return qb;}- return qb.set({ agent_spec: json(agent.agent_spec) });+ return qb.set({ agent_spec: json(agent.spec) });}).$if(title !== undefined, qb => {if (title === undefined) {diff --git a/packages/server/src/db/postgres/types.ts b/packages/server/src/db/postgres/types.tsindex d359c8099..aed962da0 100644--- a/packages/server/src/db/postgres/types.ts+++ b/packages/server/src/db/postgres/types.ts@@ -53,7 +53,12 @@ export interface SessionTable {*/agent_id: string | null;/**- * Inline draft binding; XOR with `agent_id`.+ * Create-time snapshot of registry agent name for ref bindings.+ * Null for value sessions and orphan/legacy refs after a missed backfill.+ */+ agent_name: string | null;+ /**+ * Inline spec binding; XOR with `agent_id`.* TOAST pointer rides through per-turn tip bumps when present.*/agent_spec: JSONColumnType<AgentSpec, AgentSpec | null, AgentSpec | null> | null;diff --git a/packages/server/src/db/sessionAgentColumns.ts b/packages/server/src/db/sessionAgentColumns.tsindex 0aab5b784..d957d987e 100644--- a/packages/server/src/db/sessionAgentColumns.ts+++ b/packages/server/src/db/sessionAgentColumns.ts@@ -1,27 +1,30 @@-import type { AgentSpec, SessionAgent } from '@truefoundry/utils-core/agent-session';+import { AgentSpecSchema, type AgentSpec, type SessionAgent } from '@truefoundry/utils-core/agent-session';-/** Flatten domain agent for SQL session columns (XOR pair). */+/** Flatten domain agent for SQL session columns (XOR agent_id / agent_spec; optional name snapshot). */export function sessionAgentToColumns(agent: SessionAgent): {agent_id: string | null;+ agent_name: string | null;agent_spec: AgentSpec | null;} {- if (agent.type === 'ref') {- return { agent_id: agent.agent_id, agent_spec: null };+ if (agent.type === 'reference') {+ return { agent_id: agent.id, agent_name: agent.name, agent_spec: null };}- return { agent_id: null, agent_spec: agent.agent_spec };+ return { agent_id: null, agent_name: null, agent_spec: agent.spec };}/** Rebuild domain agent from SQL session columns. */export function sessionAgentFromColumns(input: {session_id: string;agent_id: string | null;+ agent_name: string | null;agent_spec: AgentSpec | null;}): SessionAgent {if (input.agent_id !== null && input.agent_spec === null) {- return { type: 'ref', agent_id: input.agent_id };+ return { type: 'reference', id: input.agent_id, name: input.agent_name };}if (input.agent_id === null && input.agent_spec !== null) {- return { type: 'value', agent_spec: input.agent_spec };+ // Re-parse so schema defaults apply to inline specs persisted before a config field existed.+ return { type: 'inline', spec: AgentSpecSchema.parse(input.agent_spec) };}throw new Error(`Session ${input.session_id} has invalid agent binding (exactly one of agent_id or agent_spec required)`,diff --git a/packages/server/src/db/sqlite/agent-store/SqliteAgentStore.ts b/packages/server/src/db/sqlite/agent-store/SqliteAgentStore.tsindex 6d7df87ad..1924ec867 100644--- a/packages/server/src/db/sqlite/agent-store/SqliteAgentStore.ts+++ b/packages/server/src/db/sqlite/agent-store/SqliteAgentStore.ts@@ -3,8 +3,10 @@ import type { ExpressionBuilder, Kysely } from 'kysely';import { ulid } from 'ulid';import {AgentNameConflictError,+ parseStoredAgentSpec,type AgentRecord,type CreateAgentInput,+ type DeleteAgentInput,type GetAgentInput,type IAgentStore,type UpdateAgentInput,@@ -25,6 +27,17 @@ function recordColumns(eb: ExpressionBuilder<Database, 'agent'>) {];}+function toRecord(row: {+ id: string;+ tenant_id: string;+ name: AgentRecord['name'];+ manifest: AgentSpec;+ created_at: string;+ updated_at: string;+}): AgentRecord {+ return { ...row, manifest: parseStoredAgentSpec(row.manifest) };+}+export class SqliteAgentStore implements IAgentStore {readonly #db: Kysely<Database>;@@ -33,12 +46,13 @@ export class SqliteAgentStore implements IAgentStore {}async listAgents(tenantId: string): Promise<AgentRecord[]> {- return await this.#db+ const rows = await this.#db.selectFrom('agent').select(recordColumns).where('tenant_id', '=', tenantId).orderBy('name').execute();+ return rows.map(toRecord);}async getAgent(input: GetAgentInput): Promise<AgentRecord | undefined> {@@ -48,13 +62,14 @@ export class SqliteAgentStore implements IAgentStore {} else {query = query.where('name', '=', input.name);}- return await query.executeTakeFirst();+ const row = await query.executeTakeFirst();+ return row === undefined ? undefined : toRecord(row);}async createAgent(input: CreateAgentInput): Promise<AgentRecord> {const timestamp = nowIso();try {- return await this.#db+ const row = await this.#db.insertInto('agent').values({id: ulid().toLowerCase(),@@ -66,6 +81,7 @@ export class SqliteAgentStore implements IAgentStore {}).returning(recordColumns).executeTakeFirstOrThrow();+ return toRecord(row);} catch (error) {if (isUniqueViolation(error)) {throw new AgentNameConflictError({ tenant_id: input.tenant_id, name: input.name }, { cause: error });@@ -75,7 +91,7 @@ export class SqliteAgentStore implements IAgentStore {}async updateAgent(input: UpdateAgentInput): Promise<AgentRecord | undefined> {- return await this.#db+ const row = await this.#db.updateTable('agent').set({manifest: jsonbBind(input.manifest),@@ -85,5 +101,10 @@ export class SqliteAgentStore implements IAgentStore {.where('name', '=', input.name).returning(recordColumns).executeTakeFirst();+ return row === undefined ? undefined : toRecord(row);+ }++ async deleteAgent(input: DeleteAgentInput): Promise<void> {+ await this.#db.deleteFrom('agent').where('tenant_id', '=', input.tenant_id).where('id', '=', input.id).execute();}}diff --git a/packages/server/src/db/sqlite/migrations/20260812_000001_session_agent_name.ts b/packages/server/src/db/sqlite/migrations/20260812_000001_session_agent_name.tsnew file mode 100644index 000000000..e6c81fd3c--- /dev/null+++ b/packages/server/src/db/sqlite/migrations/20260812_000001_session_agent_name.ts@@ -0,0 +1,29 @@+import { sql, type Kysely } from 'kysely';++/**+ * Create-time snapshot of registry agent name on named sessions.+ * Backfills from `agent.name` where `session.agent_id` still resolves;+ * orphan refs stay NULL.+ */+export async function up(db: Kysely<unknown>): Promise<void> {+ await sql`+ ALTER TABLE session+ ADD COLUMN agent_name TEXT+ `.execute(db);+ await sql`+ UPDATE session+ SET agent_name = (+ SELECT a.name+ FROM agent AS a+ WHERE a.id = session.agent_id+ AND a.tenant_id = session.tenant_id+ )+ WHERE agent_id IS NOT NULL+ `.execute(db);+}++export async function down(db: Kysely<unknown>): Promise<void> {+ // SQLite cannot DROP COLUMN under STRICT without a table rebuild; irreversible.+ void db;+ return Promise.reject(new Error('20260812_000001_session_agent_name is not reversible'));+}diff --git a/packages/server/src/db/sqlite/session-store/queries/sessions.ts b/packages/server/src/db/sqlite/session-store/queries/sessions.tsindex a72bf2acd..02d0acf6e 100644--- a/packages/server/src/db/sqlite/session-store/queries/sessions.ts+++ b/packages/server/src/db/sqlite/session-store/queries/sessions.ts@@ -41,6 +41,7 @@ function mapRowToSessionRecord(row: {session_id: string;created_by: string;agent_id: string | null;+ agent_name: string | null;agent_spec: AgentSpec | null;title: string | null;last_turn_id: string | null;@@ -56,6 +57,7 @@ function mapRowToSessionRecord(row: {agent: sessionAgentFromColumns({session_id: row.session_id,agent_id: row.agent_id,+ agent_name: row.agent_name,agent_spec: row.agent_spec,}),title: row.title,@@ -73,6 +75,7 @@ function sessionSelectColumns() {'session_id' as const,'created_by' as const,'agent_id' as const,+ 'agent_name' as const,jsonText<AgentSpec | null>(sql.ref('agent_spec')).as('agent_spec'),'title' as const,'last_turn_id' as const,@@ -95,6 +98,7 @@ export async function createSession(db: Kysely<Database>, input: CreateSessionInsession_id: input.session_id,created_by: input.created_by,agent_id: columns.agent_id,+ agent_name: columns.agent_name,agent_spec: columns.agent_spec !== null ? jsonbBind(columns.agent_spec) : null,title: null,custom: input.custom !== null ? jsonbBind(input.custom) : null,@@ -146,7 +150,7 @@ export async function updateSession(db: Kysely<Database>, input: UpdateSessionInif (existing === undefined) {throw new SessionNotFoundError(input.session_id);}- if (existing.agent.type === 'ref') {+ if (existing.agent.type === 'reference') {throw new SessionStoreInvariantError(`Session ${input.session_id} is named; agent cannot be updated`);}}@@ -161,7 +165,7 @@ export async function updateSession(db: Kysely<Database>, input: UpdateSessionIn.where('session_id', '=', input.session_id);if (agent !== undefined) {- qb = qb.set({ agent_spec: jsonbBind(agent.agent_spec) });+ qb = qb.set({ agent_spec: jsonbBind(agent.spec) });}if (title !== undefined) {qb = qb.set({ title });diff --git a/packages/server/src/db/sqlite/types.ts b/packages/server/src/db/sqlite/types.tsindex 3c62f9a00..48bf23fda 100644--- a/packages/server/src/db/sqlite/types.ts+++ b/packages/server/src/db/sqlite/types.ts@@ -52,7 +52,12 @@ export interface SessionTable {created_by: string;/** Named registry binding; XOR with `agent_spec`. */agent_id: string | null;- /** Inline draft binding; XOR with `agent_id`. */+ /**+ * Create-time snapshot of registry agent name for ref bindings.+ * Null for value sessions and orphan/legacy refs after a missed backfill.+ */+ agent_name: string | null;+ /** Inline spec binding; XOR with `agent_id`. */agent_spec: JsonbColumn<AgentSpec> | null;title: string | null;last_turn_id: string | null;diff --git a/packages/server/src/routes/agentRoutes.ts b/packages/server/src/routes/agentRoutes.tsindex ef29b9576..fbf2ffee9 100644--- a/packages/server/src/routes/agentRoutes.ts+++ b/packages/server/src/routes/agentRoutes.ts@@ -99,6 +99,24 @@ export const getAgentRoute = createRoute({},});+export const deleteAgentRoute = createRoute({+ method: 'delete',+ path: '/{agent_id}',+ tags: [AGENTS_TAG],+ summary: 'Delete an agent',+ description: 'Delete a configured agent by immutable id. Idempotent if already gone.',+ 'x-fern-sdk-group-name': ['agents'],+ 'x-fern-sdk-method-name': 'delete',+ request: {+ params: AgentIdParamsSchema,+ },+ responses: {+ 204: {+ description: 'Agent deleted.',+ },+ },+});+export const putAgentRoute = createRoute({method: 'put',path: '/{name}',diff --git a/packages/server/src/routes/sessionRoutes.ts b/packages/server/src/routes/sessionRoutes.tsindex c5a463b91..e87eb95bc 100644--- a/packages/server/src/routes/sessionRoutes.ts+++ b/packages/server/src/routes/sessionRoutes.ts@@ -28,7 +28,7 @@ export const createSessionRoute = createRoute({tags: [SESSIONS_TAG],summary: 'Create a session',description:- 'Create a session with `agent` as either `{ type: "value", agent_spec }` (draft) or `{ type: "ref", agent_id }` (named). Named sessions resolve the live agent on each turn.',+ 'Create a session with `agent` as either `{ name }` (named registry binding) or `{ spec: AgentSpec }` (inline). Named sessions snapshot the agent name at create and resolve the live agent on each turn. Responses use `{ type: "reference", name, id }` or `{ type: "inline", spec }`.','x-fern-sdk-group-name': ['sessions'],'x-fern-sdk-method-name': 'create',request: {@@ -48,7 +48,7 @@ export const createSessionRoute = createRoute({},404: {content: { 'application/json': { schema: RequestErrorResponseSchema } },- description: 'Named `agent_id` not found.',+ description: 'Named agent not found.',},422: {content: { 'application/json': { schema: RequestErrorResponseSchema } },@@ -114,7 +114,7 @@ export const updateSessionRoute = createRoute({tags: [SESSIONS_TAG],summary: 'Update a session',description:- 'Update a draft session by replacing `agent` with a value arm. Named (ref) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.',+ 'Update a session by replacing `agent` with `{ spec: AgentSpec }`. Named (reference) sessions reject agent updates. An empty body is a valid no-op that refreshes `updated_at`. Only the session creator (`created_by`) may update it.','x-fern-sdk-group-name': ['sessions'],'x-fern-sdk-method-name': 'update',request: {diff --git a/packages/server/src/schemas/session.ts b/packages/server/src/schemas/session.tsindex 9a543e2f9..0639c83f6 100644--- a/packages/server/src/schemas/session.ts+++ b/packages/server/src/schemas/session.ts@@ -1,14 +1,43 @@-/** Server session wire schemas. Core Session/Create/Update live in agentSession. */+/** Server session wire schemas. Core Session lives in agentSession. */import { z } from '@hono/zod-openapi';-import {- CreateSessionRequestSchema,- SessionSchema,- TokenPaginationSchema,- UpdateSessionRequestSchema,-} from '@truefoundry/utils-core/agent-session';+import { AgentSpecSchema, SessionSchema, TokenPaginationSchema } from '@truefoundry/utils-core/agent-session';+import { NameSchema } from './common';++/** Create arm: bind by unique registry agent name. */+export const SessionAgentNameRefSchema = z.object({ name: NameSchema }).strict().openapi('SessionAgentNameRef');++/**+ * Create/update body arm wrapping an AgentSpec.+ * Use AgentSpecSchema (not `.strict()`) so OpenAPI `$ref`s the shared AgentSpec.+ */+const SessionAgentSpecBodySchema = z.object({ spec: AgentSpecSchema }).strict().openapi('SessionAgentSpecBody');++/** Create accepts either a unique agent name or `{ spec: AgentSpec }`. */+export const CreateSessionAgentSchema = z+ .union([SessionAgentNameRefSchema, SessionAgentSpecBodySchema])+ .openapi('CreateSessionAgent');++export type CreateSessionAgent = z.infer<typeof CreateSessionAgentSchema>;+export type SessionAgentNameRef = z.infer<typeof SessionAgentNameRefSchema>;+export type SessionAgentSpecBody = z.infer<typeof SessionAgentSpecBodySchema>;++/** Narrows the create-body union after OpenAPI already accepted either arm. */+export function isSessionAgentNameRef(agent: CreateSessionAgent): agent is SessionAgentNameRef {+ return SessionAgentNameRefSchema.safeParse(agent).success;+}++export const CreateSessionRequestSchema = z+ .object({ agent: CreateSessionAgentSchema })+ .strict()+ .openapi('CreateSessionRequest');++/** Only inline sessions may be updated; named (reference) sessions reject agent updates. */+export const UpdateSessionRequestSchema = z+ .object({ agent: SessionAgentSpecBodySchema.optional() })+ .strict()+ .openapi('UpdateSessionRequest');export type { Session } from '@truefoundry/utils-core/agent-session';-export { CreateSessionRequestSchema, UpdateSessionRequestSchema };export const DEFAULT_SESSIONS_LIMIT = 10;export const SESSIONS_MAX_LIMIT = 100;diff --git a/packages/server/tests/unit/apis/agents.test.ts b/packages/server/tests/unit/apis/agents.test.tsindex 304fb0c1c..b33fae459 100644--- a/packages/server/tests/unit/apis/agents.test.ts+++ b/packages/server/tests/unit/apis/agents.test.ts@@ -88,6 +88,16 @@ describe('agents router', () => {expect(put.status).toBe(404);});+ it('DELETE removes an agent by id and is idempotent', async () => {+ const created = await router.request('/', jsonInit('POST', { ...writeBody, name: 'deletable' }));+ expect(created.status).toBe(200);+ const { data } = (await created.json()) as { data: { id: string } };++ expect((await router.request(`/${data.id}`, { method: 'DELETE' })).status).toBe(204);+ expect((await router.request(`/${data.id}`)).status).toBe(404);+ expect((await router.request(`/${data.id}`, { method: 'DELETE' })).status).toBe(204);+ });+it('POST rejects invalid bodies, unknown models, and duplicate names', async () => {const badName = await router.request('/', jsonInit('POST', { ...writeBody, name: 'Not A Name' }));expect(badName.status).toBe(400);diff --git a/packages/server/tests/unit/apis/deletedSessionCrud.test.ts b/packages/server/tests/unit/apis/deletedSessionCrud.test.tsindex b64083fe5..e01a2efdf 100644--- a/packages/server/tests/unit/apis/deletedSessionCrud.test.ts+++ b/packages/server/tests/unit/apis/deletedSessionCrud.test.ts@@ -73,8 +73,8 @@ describe('public CRUD after session deletion', () => {session_id: 's1',created_by: LOCAL_USER_CONTEXT.userRef,agent: {- type: 'value',- agent_spec: AgentSpecSchema.parse({+ type: 'inline',+ spec: AgentSpecSchema.parse({model: { name: 'test-provider/test-model' },instructions: 'test',}),diff --git a/packages/server/tests/unit/apis/sandboxFileDownload.test.ts b/packages/server/tests/unit/apis/sandboxFileDownload.test.tsindex f2edfcfd0..6eaa6880e 100644--- a/packages/server/tests/unit/apis/sandboxFileDownload.test.ts+++ b/packages/server/tests/unit/apis/sandboxFileDownload.test.ts@@ -112,7 +112,7 @@ describe('GET /{session_id}/turns/{turn_id}/download', () => {tenant_id: TENANT_ID,session_id: 'no-turn',created_by: LOCAL_USER_CONTEXT.userRef,- agent: { type: 'value', agent_spec: agentSpec() },+ agent: { type: 'inline', spec: agentSpec() },});const response = await app.request(downloadUrl({ sessionId: session.session_id, path: '/workspace/report.pdf' }));diff --git a/packages/server/tests/unit/apis/sessionHttp.test.ts b/packages/server/tests/unit/apis/sessionHttp.test.tsindex 8daba410b..7f6c75820 100644--- a/packages/server/tests/unit/apis/sessionHttp.test.ts+++ b/packages/server/tests/unit/apis/sessionHttp.test.ts@@ -14,9 +14,9 @@ import { SqliteSessionStore } from '../../../src/db/sqlite/session-store/SqliteSimport { SqliteSkillStore } from '../../../src/db/sqlite/skill-store/SqliteSkillStore';import { ActiveTurnRegistry } from '../../../src/runtime/activeTurns';-const draftSpec = AgentSpecSchema.parse({+const inlineSpec = AgentSpecSchema.parse({model: { name: 'anthropic/claude-sonnet-4-6' },- instructions: 'draft',+ instructions: 'inline',});function jsonInit(method: string, body: unknown): RequestInit {@@ -79,27 +79,27 @@ describe('sessions HTTP agent binding', () => {);});- it('creates a draft session from a value agent', async () => {- const res = await app.request('/', jsonInit('POST', { agent: { type: 'value', agent_spec: draftSpec } }));+ it('creates a session from an inline AgentSpec', async () => {+ const res = await app.request('/', jsonInit('POST', { agent: { spec: inlineSpec } }));expect(res.status).toBe(201);const json = (await res.json()) as {data: {id: string;created_by: string;- agent: { type: string; agent_spec?: { instructions?: string } };+ agent: { type: 'inline'; spec: { instructions?: string } };};};- expect(json.data.agent.type).toBe('value');- expect(json.data.agent.agent_spec?.instructions).toBe('draft');+ expect(json.data.agent.type).toBe('inline');+ expect(json.data.agent.spec.instructions).toBe('inline');expect(json.data.created_by).toBe(LOCAL_USER_CONTEXT.userRef);});- it('returns 404 when creating a session for an unknown agent_id', async () => {- const missing = await app.request('/', jsonInit('POST', { agent: { type: 'ref', agent_id: 'does-not-exist' } }));+ it('returns 404 when creating a session for an unknown agent name', async () => {+ const missing = await app.request('/', jsonInit('POST', { agent: { name: 'does-not-exist' } }));expect(missing.status).toBe(404);});- it('creates a named ref session and filters list by agent_id', async () => {+ it('creates a named session and filters list by agent_id', async () => {const agent = await agentStore.createAgent({tenant_id: TENANT_ID,name: 'named-agent',@@ -109,19 +109,19 @@ describe('sessions HTTP agent binding', () => {}),});- const created = await app.request('/', jsonInit('POST', { agent: { type: 'ref', agent_id: agent.id } }));+ const created = await app.request('/', jsonInit('POST', { agent: { name: agent.name } }));expect(created.status).toBe(201);const json = (await created.json()) as {- data: { id: string; agent: { type: string; agent_id?: string } };+ data: { id: string; agent: { type: 'reference'; id: string; name: string | null } };};- expect(json.data.agent).toEqual({ type: 'ref', agent_id: agent.id });+ expect(json.data.agent).toEqual({ type: 'reference', id: agent.id, name: agent.name });const listed = await app.request(`/?agent_id=${encodeURIComponent(agent.id)}`);expect(listed.status).toBe(200);const listJson = (await listed.json()) as {- data: Array<{ id: string; agent: { type: string; agent_id?: string } }>;+ data: Array<{ id: string; agent: { type: 'reference'; id: string; name: string | null } }>;};- expect(listJson.data.every(row => row.agent.type === 'ref' && row.agent.agent_id === agent.id)).toBe(true);+ expect(listJson.data.every(row => row.agent.id === agent.id)).toBe(true);expect(listJson.data.some(row => row.id === json.data.id)).toBe(true);});@@ -130,11 +130,11 @@ describe('sessions HTTP agent binding', () => {tenant_id: TENANT_ID,session_id: 'other-user-session',created_by: 'someone-else',- agent: { type: 'value', agent_spec: draftSpec },+ agent: { type: 'inline', spec: inlineSpec },custom: null,});- const created = await app.request('/', jsonInit('POST', { agent: { type: 'value', agent_spec: draftSpec } }));+ const created = await app.request('/', jsonInit('POST', { agent: { spec: inlineSpec } }));expect(created.status).toBe(201);const json = (await created.json()) as { data: { id: string; created_by: string } };expect(json.data.created_by).toBe(LOCAL_USER_CONTEXT.userRef);@@ -171,7 +171,7 @@ describe('sessions HTTP agent binding', () => {expect(allowed.status).toBe(200);});- it('rejects PATCH agent on a session bound by agent_id', async () => {+ it('rejects PATCH agent on a named session', async () => {const agent = await agentStore.createAgent({tenant_id: TENANT_ID,name: 'named-agent',@@ -181,38 +181,35 @@ describe('sessions HTTP agent binding', () => {}),});- const created = await app.request('/', jsonInit('POST', { agent: { type: 'ref', agent_id: agent.id } }));+ const created = await app.request('/', jsonInit('POST', { agent: { name: agent.name } }));expect(created.status).toBe(201);const json = (await created.json()) as { data: { id: string } };const patchNamed = await app.request(`/${json.data.id}`,- jsonInit('PATCH', { agent: { type: 'value', agent_spec: { ...draftSpec, instructions: 'nope' } } }),+ jsonInit('PATCH', { agent: { spec: { ...inlineSpec, instructions: 'nope' } } }),);expect(patchNamed.status).toBe(422);});- it('allows PATCH agent_spec on draft sessions', async () => {- const created = await app.request('/', jsonInit('POST', { agent: { type: 'value', agent_spec: draftSpec } }));+ it('allows PATCH agent.spec on inline sessions', async () => {+ const created = await app.request('/', jsonInit('POST', { agent: { spec: inlineSpec } }));expect(created.status).toBe(201);const { data } = (await created.json()) as { data: { id: string } };const patched = await app.request(`/${data.id}`,- jsonInit('PATCH', { agent: { type: 'value', agent_spec: { ...draftSpec, instructions: 'updated' } } }),+ jsonInit('PATCH', { agent: { spec: { ...inlineSpec, instructions: 'updated' } } }),);expect(patched.status).toBe(200);const patchedJson = (await patched.json()) as {- data: { agent: { type: string; agent_spec?: { instructions?: string } } };+ data: { agent: { type: 'inline'; spec: { instructions?: string } } };};- expect(patchedJson.data.agent.agent_spec?.instructions).toBe('updated');+ expect(patchedJson.data.agent.spec.instructions).toBe('updated');});- it('rejects create bodies that mix ref and value agent fields', async () => {- const both = await app.request(- '/',- jsonInit('POST', { agent: { type: 'ref', agent_id: 'x', agent_spec: draftSpec } }),- );+ it('rejects create bodies that mix name and AgentSpec fields', async () => {+ const both = await app.request('/', jsonInit('POST', { agent: { name: 'named-agent', ...inlineSpec } }));expect(both.status).toBe(400);});});diff --git a/packages/server/tests/unit/apis/turns.test.ts b/packages/server/tests/unit/apis/turns.test.tsindex d1374aefb..6711a5574 100644--- a/packages/server/tests/unit/apis/turns.test.ts+++ b/packages/server/tests/unit/apis/turns.test.ts@@ -34,8 +34,8 @@ describe('turns', () => {session_id: 's1',created_by: 'someone-else',agent: {- type: 'value',- agent_spec: AgentSpecSchema.parse({+ type: 'inline',+ spec: AgentSpecSchema.parse({model: { name: 'test-provider/test-model' },instructions: 'test',}),@@ -130,7 +130,7 @@ describe('turns', () => {const sessions = {get: () =>Promise.resolve({- agent_spec: AgentSpecSchema.parse({ model: { name: 'test-provider/test-model' } }),+ spec: AgentSpecSchema.parse({ model: { name: 'test-provider/test-model' } }),record: { last_turn_id: null, created_by: LOCAL_USER_CONTEXT.userRef },createTurn: () =>Promise.resolve({@@ -242,12 +242,12 @@ describe('turns', () => {const sessions = {get: () =>Promise.resolve({- agent_spec: agentSpec,+ spec: agentSpec,record: {session_id: 's1',last_turn_id: null,created_by: LOCAL_USER_CONTEXT.userRef,- agent: { type: 'value', agent_spec: agentSpec },+ agent: { type: 'inline', spec: agentSpec },},createTurn: () =>Promise.resolve({