The open-source agent harness - the runtime layer that turns an LLM into a working agent.
fix: allow x-tfg resource headers only on inline sessions (#1076)
Chirag Jain0a42995ea8bf
diff --git a/.changeset/harden-inline-resource-overlays.md b/.changeset/harden-inline-resource-overlays.mdnew file mode 100644index 000000000..511b5e712--- /dev/null+++ b/.changeset/harden-inline-resource-overlays.md@@ -0,0 +1,5 @@+---+'@truefoundry/trueforge': patch+---++In TrueFoundry mode, `x-tfg-skills`, `x-tfg-mcp`, and `x-tfg-models` are allowed when creating an inline session, replacing its spec, or running a turn on it. Create and replace only use the headers to check the spec and do not save them. `x-tfg-skills` must list every skill as a git skill; registry skill ids are not accepted. MCP servers and models fall back to the registry when a name is missing. Other routes reject these headers.diff --git a/AGENTS.md b/AGENTS.mdindex 5524ecb61..e3c96a036 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -11,6 +11,7 @@- AgentUIServer / server-port types (`AgentChatServer`, `AgentBuilderServer`, catalog ports, session/turn DTOs, stream events) MUST be defined only in `packages/assistant-ui-runtime/src/server/types.ts` / `events.ts`. `@truefoundry/trueforge-ui` MUST re-export them from `src/server/types.ts` (pass-through aliases only) and MUST NOT add hand-written parallel definitions of those ports/DTOs.- Runtime types backed by Zod schemas MUST be derived with named `z.infer<typeof Schema>` aliases; code MUST NOT duplicate those schemas as hand-written interfaces or indirect utility-type chains.- Modules MUST use static `import` and `import type`; they MUST NOT use `require()`, `require.resolve()`, or lint suppressions to bypass import checks.+- After editing ESLint-covered files, run `pnpm exec eslint <changed-files> --max-warnings=0` and fix findings in the same change. Do not drop `async` solely to silence `@typescript-eslint/require-await` when the body can throw: keep Promise rejections via `Promise.resolve()` / `Promise.reject()` / `Promise.resolve().then(...)`.- A change that makes code unused MUST remove that dead code in the same change; it MUST NOT leave stale exports, files, documentation, duplicates, or “just in case” shims.- Every nested `AGENTS.md` MUST have a sibling `CLAUDE.md` containing only `@AGENTS.md`, so Cursor and Claude Code load the same scoped rules.- OpenAPI specs under `.github/fern/openapi/openapi.json` and `docs/openapi.json` are autogenerated in CI and MUST NOT be edited manually (both copies MUST stay identical)diff --git a/packages/trueforge/scripts/write-openapi.ts b/packages/trueforge/scripts/write-openapi.tsindex c8e17f8a1..0ccac01ae 100644--- a/packages/trueforge/scripts/write-openapi.ts+++ b/packages/trueforge/scripts/write-openapi.ts@@ -83,13 +83,13 @@ const app = createServerApp({clientName: configuration.MCP_DCR_OAUTH_CLIENT_NAME,}),resolveSkillStore: () => skillStore,+ resolveTurnSkillsStore: () => skillStore,resolveSandboxProviderStore: () => sandboxProviderStore,resolveWebSearchProviderStore: () => webSearchProviderStore,resolveAgentStore: () => agentStore,agentStore,sandboxEnvironmentStore,sandboxProviderStore,- turnSkillsResolverStore: skillStore,withTransaction: callback => db.transaction().execute(callback),scheduleStore: new SqliteScheduleStore(db),tokenStore,diff --git a/packages/trueforge/src/apis/schedules.ts b/packages/trueforge/src/apis/schedules.tsindex d7368bd4d..ff70519db 100644--- a/packages/trueforge/src/apis/schedules.ts+++ b/packages/trueforge/src/apis/schedules.ts@@ -10,6 +10,7 @@ import {import type { Context } from 'hono';import { HTTPException } from 'hono/http-exception';import type { Logger } from 'winston';+import type { ResolveTurnSkillsStoreInput } from '../app';import type { Authorizer } from '../auth/authorizer';import {createdBySubjectFromRequestContext,@@ -72,14 +73,15 @@ export interface ScheduleTurnExecutionDeps<TTransaction> {activeTurns: ActiveTurnRegistry;eventSubscriptions: EventSubscriptionRegistry<TurnStreamingEvent>;logger: Logger;- resolveModelProviderStore: (c: Context, runAsAgent?: AgentRecord) => IModelProviderStore<TTransaction>;- resolveMcpServerStore: (c: Context, runAsAgent?: AgentRecord) => IMcpServerWithAuthStore<TTransaction>;+ resolveModelProviderStore: (input: { c: Context; runAsAgent?: AgentRecord }) => IModelProviderStore<TTransaction>;+ resolveMcpServerStore: (input: { c: Context; runAsAgent?: AgentRecord }) => IMcpServerWithAuthStore<TTransaction>;resolveSandboxProviderStore: (c: Context) => ISandboxProviderStore<TTransaction>;sandboxEnvironmentStore: ISandboxEnvironmentStore<TTransaction>;resolveWebSearchProviderStore: (c: Context) => IWebSearchProviderStore<TTransaction>;/** Persistence agent store (schedule agent binding is not caller-scoped). */agentStore: IAgentStore<TTransaction>;- turnSkillsResolverStore: Pick<ISkillStore, 'resolveTurnSkills'>;+ /** Call with `{}` — schedules have no caller `x-tfg-skills`. */+ resolveTurnSkillsStore: (input: ResolveTurnSkillsStoreInput) => Pick<ISkillStore, 'resolveTurnSkills'>;}export interface SchedulesRouterDeps<TTransaction> extends ScheduleTurnExecutionDeps<TTransaction> {@@ -116,12 +118,12 @@ export async function startScheduleRunOnRequest<TTransaction>(params: {activeTurns: deps.activeTurns,eventSubscriptions: deps.eventSubscriptions,agentStore: deps.agentStore,- modelProviderStore: deps.resolveModelProviderStore(c, prepared.agent),- mcpServerStore: deps.resolveMcpServerStore(c, prepared.agent),+ modelProviderStore: deps.resolveModelProviderStore({ c, runAsAgent: prepared.agent }),+ mcpServerStore: deps.resolveMcpServerStore({ c, runAsAgent: prepared.agent }),sandboxProviderStore: deps.resolveSandboxProviderStore(c),sandboxEnvironmentStore: deps.sandboxEnvironmentStore,webSearchProviderStore: deps.resolveWebSearchProviderStore(c),- skillStore: deps.turnSkillsResolverStore,+ skillStore: deps.resolveTurnSkillsStore({}),logger: deps.logger,},});diff --git a/packages/trueforge/src/apis/sessions.ts b/packages/trueforge/src/apis/sessions.tsindex 8245d84ca..067423241 100644--- a/packages/trueforge/src/apis/sessions.ts+++ b/packages/trueforge/src/apis/sessions.ts@@ -2,7 +2,13 @@* DB-backed sessions APIs (mounted at /api/v1/sessions and /api/internal/sessions).*/import { OpenAPIHono, type RouteHandler } from '@hono/zod-openapi';-import type { ISessionStore, SessionHandle, SessionRecord, Sessions } from '@truefoundry/trueforge-core/agent-session';+import type {+ AgentSpec,+ ISessionStore,+ SessionHandle,+ SessionRecord,+ Sessions,+} from '@truefoundry/trueforge-core/agent-session';import {CancellationReason,SessionStoreConflictError,@@ -22,14 +28,16 @@ import type { Context } from 'hono';import { HTTPException } from 'hono/http-exception';import type { Logger } from 'winston';import { z } from 'zod';+import type { ResolveSkillStoreInput } from '../app';import type { Authorizer } from '../auth/authorizer';-import { createdBySubjectFromRequestContext, type ResolveRequestContext } from '../auth/identity';+import { createdBySubjectFromRequestContext, type RequestContext, type ResolveRequestContext } from '../auth/identity';import configuration from '../config';import type { IAgentStore } from '../db/agentStore';import type { IMcpServerStore } from '../db/mcpServerStore';import type { IModelProviderStore } from '../db/modelProviderStore';import type { ISandboxEnvironmentStore } from '../db/sandboxEnvironmentStore';import type { ISandboxProviderStore } from '../db/sandboxProviderStore';+import type { ISkillStore } from '../db/skillStore';import type { IWebSearchProviderStore } from '../db/webSearchProviderStore';import {cancelSessionRoute,@@ -47,7 +55,6 @@ import { honoQueriesToRecord } from '../schemas/deepObjectQuery';import { isSessionAgentNameRef, parseListSessionsQuery, type Session } from '../schemas/session';import { newId } from '../utils/id';import { agentIfAccessible, canReadAgentBoundResource, canReadSession, resolveManagedAgentIds } from './agentAccess';-import type { ResolveSkillStore } from './skills';/** Request-reply path a replica serves to cancel a turn it owns. */export const SESSIONS_CANCEL_PATH = 'sessions/cancel';@@ -79,9 +86,9 @@ export interface SessionsRouterDeps {sessions: Sessions;sessionStore: ISessionStore;activeTurns: ActiveTurnRegistry;- resolveModelProviderStore: (c: Context) => IModelProviderStore;- resolveMcpServerStore: (c: Context) => IMcpServerStore;- resolveSkillStore: ResolveSkillStore;+ resolveModelProviderStore: (input: { c: Context; allowInlineResources?: boolean }) => IModelProviderStore;+ resolveMcpServerStore: (input: { c: Context; allowInlineResources?: boolean }) => IMcpServerStore;+ resolveSkillStore: (input: ResolveSkillStoreInput) => ISkillStore;resolveAgentStore: (c: Context) => IAgentStore;resolveSandboxProviderStore: (c: Context) => ISandboxProviderStore;sandboxEnvironmentStore: ISandboxEnvironmentStore;@@ -234,6 +241,36 @@ function isSessionOwner({return subject_id === created_by_subject.subject_id;}+/**+ * Inline create and spec replace check model, MCP, and skill names against `x-tfg-*` when those+ * headers are present. The headers are not written onto the session.+ */+function validateInlineSessionSpec(+ deps: Pick<+ SessionsRouterDeps,+ | 'resolveModelProviderStore'+ | 'resolveMcpServerStore'+ | 'resolveSkillStore'+ | 'resolveSandboxProviderStore'+ | 'sandboxEnvironmentStore'+ | 'resolveWebSearchProviderStore'+ >,+ input: { c: Context; spec: AgentSpec; requestContext: RequestContext },+): Promise<void> {+ const { c, spec, requestContext } = input;+ return validateAgentSpec({+ spec,+ tenant_id: requestContext.tenant_id,+ created_by_subject_id: requestContext.subject.id,+ modelProviderStore: deps.resolveModelProviderStore({ c, allowInlineResources: true }),+ mcpServerStore: deps.resolveMcpServerStore({ c, allowInlineResources: true }),+ skillStore: deps.resolveSkillStore({ c, allowInlineResources: true }),+ sandboxProviderStore: deps.resolveSandboxProviderStore(c),+ sandboxEnvironmentStore: deps.sandboxEnvironmentStore,+ webSearchProviderStore: deps.resolveWebSearchProviderStore(c),+ });+}+type InternalSessionsRouterDeps = Pick<SessionsRouterDeps,| 'sessions'@@ -289,16 +326,10 @@ function createGetOrCreateSessionByExternalIdHandler(}agent = { type: 'reference', id: named.id, name: named.name };} else {- await validateAgentSpec({+ await validateInlineSessionSpec(deps, {+ c,spec: body.agent.spec,- tenant_id: requestContext.tenant_id,- created_by_subject_id: requestContext.subject.id,- modelProviderStore: deps.resolveModelProviderStore(c),- mcpServerStore: deps.resolveMcpServerStore(c),- skillStore: deps.resolveSkillStore(c),- sandboxProviderStore: deps.resolveSandboxProviderStore(c),- sandboxEnvironmentStore: deps.sandboxEnvironmentStore,- webSearchProviderStore: deps.resolveWebSearchProviderStore(c),+ requestContext,});agent = { type: 'inline', spec: body.agent.spec };}@@ -364,16 +395,10 @@ export function createSessionsRouter(deps: SessionsRouterDeps) {return c.json({ data: toWireSession(session.record) }, 201);}- await validateAgentSpec({+ await validateInlineSessionSpec(deps, {+ c,spec: body.agent.spec,- tenant_id: requestContext.tenant_id,- created_by_subject_id: requestContext.subject.id,- modelProviderStore: deps.resolveModelProviderStore(c),- mcpServerStore: deps.resolveMcpServerStore(c),- skillStore: deps.resolveSkillStore(c),- sandboxProviderStore: deps.resolveSandboxProviderStore(c),- sandboxEnvironmentStore: deps.sandboxEnvironmentStore,- webSearchProviderStore: deps.resolveWebSearchProviderStore(c),+ requestContext,});const session = await deps.sessions.create({tenant_id: requestContext.tenant_id,@@ -458,17 +483,25 @@ export function createSessionsRouter(deps: SessionsRouterDeps) {// 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.spec,- tenant_id: requestContext.tenant_id,- created_by_subject_id: requestContext.subject.id,- modelProviderStore: deps.resolveModelProviderStore(c),- mcpServerStore: deps.resolveMcpServerStore(c),- skillStore: deps.resolveSkillStore(c),- sandboxProviderStore: deps.resolveSandboxProviderStore(c),- sandboxEnvironmentStore: deps.sandboxEnvironmentStore,- webSearchProviderStore: deps.resolveWebSearchProviderStore(c),- });+ if (existing.agent.type === 'inline') {+ await validateInlineSessionSpec(deps, {+ c,+ spec: body.agent.spec,+ requestContext,+ });+ } else {+ await validateAgentSpec({+ spec: body.agent.spec,+ tenant_id: requestContext.tenant_id,+ created_by_subject_id: requestContext.subject.id,+ modelProviderStore: deps.resolveModelProviderStore({ c }),+ mcpServerStore: deps.resolveMcpServerStore({ c }),+ skillStore: deps.resolveSkillStore({ c }),+ sandboxProviderStore: deps.resolveSandboxProviderStore(c),+ sandboxEnvironmentStore: deps.sandboxEnvironmentStore,+ webSearchProviderStore: deps.resolveWebSearchProviderStore(c),+ });+ }}try {await deps.sessionStore.updateSession({diff --git a/packages/trueforge/src/apis/settings.ts b/packages/trueforge/src/apis/settings.tsindex 1b612f9e8..5de65847f 100644--- a/packages/trueforge/src/apis/settings.ts+++ b/packages/trueforge/src/apis/settings.ts@@ -22,8 +22,8 @@ import { createSkillsRouter, type ResolveSkillStore } from './skills';import { createWebSearchProvidersRouter } from './webSearchProviders';export interface SettingsRouterDeps<TTransaction> {- resolveModelProviderStore: (c: Context) => IModelProviderStore<TTransaction>;- resolveMcpServerStore: (c: Context) => IMcpServerWithAuthStore<TTransaction>;+ resolveModelProviderStore: (input: { c: Context }) => IModelProviderStore<TTransaction>;+ resolveMcpServerStore: (input: { c: Context }) => IMcpServerWithAuthStore<TTransaction>;tokenStore: IOAuthTokenStore<TTransaction>;resolveSkillStore: ResolveSkillStore<TTransaction>;resolveSandboxProviderStore: (c: Context) => ISandboxProviderStore<TTransaction>;@@ -41,7 +41,7 @@ export function createSettingsRouter<TTransaction>(deps: SettingsRouterDeps<TTrarouter.route('/model-providers',createModelProvidersRouter({- resolveModelProviderStore: deps.resolveModelProviderStore,+ resolveModelProviderStore: c => deps.resolveModelProviderStore({ c }),resolveAgentStore: deps.resolveAgentStore,withTransaction: deps.withTransaction,resolveRequestContext: deps.resolveRequestContext,@@ -50,7 +50,7 @@ export function createSettingsRouter<TTransaction>(deps: SettingsRouterDeps<TTrarouter.route('/mcp-servers',createSettingsMcpServersRouter({- resolveMcpServerStore: deps.resolveMcpServerStore,+ resolveMcpServerStore: c => deps.resolveMcpServerStore({ c }),resolveAgentStore: deps.resolveAgentStore,tokenStore: deps.tokenStore,withTransaction: deps.withTransaction,diff --git a/packages/trueforge/src/apis/skills.ts b/packages/trueforge/src/apis/skills.tsindex e3e669c29..8fcfb3723 100644--- a/packages/trueforge/src/apis/skills.ts+++ b/packages/trueforge/src/apis/skills.ts@@ -16,6 +16,7 @@ import { findCatalogUsageConflict } from '../runtime/catalogUsage';import type { AvailableSkill, ConfiguredSkill, CreateSkillRequest, UpdateSkillRequest } from '../schemas/skill';import { parseTrueFoundryRegistrySkill } from '../schemas/skill';+/** Catalog and agent saves: Context only (HTTP layer rejects `x-tfg-skills` unless sessions opt in). */export type ResolveSkillStore<TTransaction = never> = (c: Context) => ISkillStore<TTransaction>;export interface SkillsRouterDeps<TTransaction> {diff --git a/packages/trueforge/src/apis/turns.ts b/packages/trueforge/src/apis/turns.tsindex a7a89fde2..2ed7110f2 100644--- a/packages/trueforge/src/apis/turns.ts+++ b/packages/trueforge/src/apis/turns.ts@@ -34,6 +34,7 @@ import type { Context } from 'hono';import { HTTPException } from 'hono/http-exception';import { streamSSE } from 'hono/streaming';import type { Logger } from 'winston';+import type { ResolveMcpServerStoreInput, ResolveModelProviderStoreInput, ResolveTurnSkillsStoreInput } from '../app';import type { Authorizer } from '../auth/authorizer';import type { ResolveRequestContext } from '../auth/identity';import configuration from '../config';@@ -117,9 +118,9 @@ export interface TurnsRouterDeps {sessions: Sessions;sessionStore: ISessionStore;activeTurns: ActiveTurnRegistry;- resolveModelProviderStore: (c: Context, runAsAgent?: AgentRecord) => IModelProviderStore;- resolveMcpServerStore: (c: Context, runAsAgent?: AgentRecord) => IMcpServerWithAuthStore;- resolveSkillStore: (c: Context) => ISkillStore;+ resolveModelProviderStore: (input: ResolveModelProviderStoreInput) => IModelProviderStore;+ resolveMcpServerStore: (input: ResolveMcpServerStoreInput) => IMcpServerWithAuthStore;+ resolveTurnSkillsStore: (input: ResolveTurnSkillsStoreInput) => Pick<ISkillStore, 'resolveTurnSkills'>;resolveAgentStore: (c: Context) => IAgentStore;/** Resumable live turn-event transport: create-turn writes, subscribe polls. */eventSubscriptions: EventSubscriptionRegistry<TurnStreamingEvent>;@@ -824,6 +825,8 @@ export function createTurnsRouter(deps: TurnsRouterDeps) {referencedAgent = agent;}+ // x-tfg-skills / x-tfg-mcp / x-tfg-models on turns only when the session agent is inline.+ const allowInlineResources = session.record.agent.type === 'inline';const turnParams: BeginTurnExecutionParams = {session,input: body.input,@@ -832,9 +835,17 @@ export function createTurnsRouter(deps: TurnsRouterDeps) {requestHeaders: c.req.header(),deps: {...deps,- modelProviderStore: deps.resolveModelProviderStore(c, referencedAgent),- mcpServerStore: deps.resolveMcpServerStore(c, referencedAgent),- skillStore: deps.resolveSkillStore(c),+ modelProviderStore: deps.resolveModelProviderStore({+ c,+ allowInlineResources,+ ...(referencedAgent !== undefined ? { runAsAgent: referencedAgent } : {}),+ }),+ mcpServerStore: deps.resolveMcpServerStore({+ c,+ allowInlineResources,+ ...(referencedAgent !== undefined ? { runAsAgent: referencedAgent } : {}),+ }),+ skillStore: deps.resolveTurnSkillsStore({ c, allowInlineResources }),agentStore: deps.resolveAgentStore(c),sandboxProviderStore: deps.resolveSandboxProviderStore(c),sandboxEnvironmentStore: deps.sandboxEnvironmentStore,diff --git a/packages/trueforge/src/app.ts b/packages/trueforge/src/app.tsindex 6bcbe44b0..f0c4650f9 100644--- a/packages/trueforge/src/app.ts+++ b/packages/trueforge/src/app.ts@@ -23,7 +23,7 @@ import { createScheduleExecutionRouter, createSchedulesRouter } from './apis/schimport { createInternalMetricsRouter } from './apis/sessionMetrics';import { createInternalSessionsRouter, createSessionsRouter } from './apis/sessions';import { createSettingsRouter } from './apis/settings';-import { createAvailableSkillsRouter, type ResolveSkillStore } from './apis/skills';+import { createAvailableSkillsRouter } from './apis/skills';import { createTurnsRouter } from './apis/turns';import type { Authenticator } from './auth/authenticator';import type { Authorizer } from './auth/authorizer';@@ -195,6 +195,35 @@ function routeNotFound(c: Context) {return c.json({ error: { message: `Route not found: ${c.req.method} ${c.req.path}` } }, 404);}+/** HTTP model-provider store resolve. `allowInlineResources` for inline session create, spec replace, and inline-session turns. */+export interface ResolveModelProviderStoreInput {+ c: Context;+ runAsAgent?: AgentRecord;+ allowInlineResources?: boolean;+}++/** HTTP MCP store resolve. Omit `c` for the unauthenticated OAuth callback. */+export interface ResolveMcpServerStoreInput {+ c?: Context;+ runAsAgent?: AgentRecord;+ allowInlineResources?: boolean;+}++/**+ * Turn skill-mount resolve. Omit `c` for schedules (registry/DB only).+ * `allowInlineResources` only for turns on inline sessions.+ */+export interface ResolveTurnSkillsStoreInput {+ c?: Context;+ allowInlineResources?: boolean;+}++/** HTTP skill-store resolve. `allowInlineResources` for inline session create and spec replace. */+export interface ResolveSkillStoreInput {+ c: Context;+ allowInlineResources?: boolean;+}+export interface ServerDeps<TTransaction> {modelCatalog: ModelCatalog;mcpCatalog: McpCatalog;@@ -202,12 +231,12 @@ export interface ServerDeps<TTransaction> {sandboxCatalog: SandboxCatalog;webSearchCatalog: WebSearchCatalog;/** Per-request store: DB singleton, or a token-bound TrueFoundry store in TrueFoundry mode. */- resolveModelProviderStore: (c: Context, runAsAgent?: AgentRecord) => IModelProviderStore<TTransaction>;+ resolveModelProviderStore: (input: ResolveModelProviderStoreInput) => IModelProviderStore<TTransaction>;/*** Per-request store: DB singleton, or a token-bound TrueFoundry store in TrueFoundry mode.- * The unauthenticated OAuth callback has no context and gets the DB persistence store.+ * The unauthenticated OAuth callback omits `c` and gets the DB persistence store.*/- resolveMcpServerStore: (c?: Context, runAsAgent?: AgentRecord) => IMcpServerWithAuthStore<TTransaction>;+ resolveMcpServerStore: (input: ResolveMcpServerStoreInput) => IMcpServerWithAuthStore<TTransaction>;/** Per-request store: DB singleton, or a token-bound TrueFoundry decorator in TrueFoundry mode. */resolveAgentStore: (c: Context) => IAgentStore<TTransaction>;/**@@ -217,7 +246,12 @@ export interface ServerDeps<TTransaction> {resolveSandboxProviderStore: (c: Context) => ISandboxProviderStore<TTransaction>;resolveWebSearchProviderStore: (c: Context) => IWebSearchProviderStore<TTransaction>;/** Per-request store: DB git skills, or TrueFoundry registry catalog in TrueFoundry mode. */- resolveSkillStore: ResolveSkillStore<TTransaction>;+ resolveSkillStore: (input: ResolveSkillStoreInput) => ISkillStore<TTransaction>;+ /**+ * Turn skill mounts. HTTP turns may apply `x-tfg-skills` when allowInlineResources is set;+ * schedules call with `{}` (registry/DB only).+ */+ resolveTurnSkillsStore: (input: ResolveTurnSkillsStoreInput) => Pick<ISkillStore<TTransaction>, 'resolveTurnSkills'>;withTransaction: WithTransaction<TTransaction>;tokenStore: IOAuthTokenStore<TTransaction>;scheduleStore: IScheduleStore<TTransaction>;@@ -232,8 +266,6 @@ export interface ServerDeps<TTransaction> {* Same backing store as resolveSandboxProviderStore, without request context.*/sandboxProviderStore: ISandboxProviderStore<TTransaction>;- /** Resolve turn skills - persistence store or TrueFoundry resolve with Service API key (schedule runs do have any caller token). */- turnSkillsResolverStore: Pick<ISkillStore<TTransaction>, 'resolveTurnSkills'>;sessions: Sessions;activeTurns: ActiveTurnRegistry;/** Primary Redis client (server-owned); undefined in standalone mode. */@@ -269,7 +301,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {sandboxEnvironmentStore: deps.sandboxEnvironmentStore,resolveWebSearchProviderStore: deps.resolveWebSearchProviderStore,activeTurns: deps.activeTurns,- turnSkillsResolverStore: deps.turnSkillsResolverStore,+ resolveTurnSkillsStore: deps.resolveTurnSkillsStore,};const httpMetrics = createHttpMetrics();@@ -311,7 +343,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {'/api/v1/models',withAuth(createModelsRouter({- resolveModelProviderStore: deps.resolveModelProviderStore,+ resolveModelProviderStore: c => deps.resolveModelProviderStore({ c }),withTransaction: deps.withTransaction,resolveRequestContext,}),@@ -337,7 +369,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {'/api/v1/mcp-servers/oauth',createMcpOAuthRouter({tokenStore: deps.tokenStore,- mcpServerStore: deps.resolveMcpServerStore(),+ mcpServerStore: deps.resolveMcpServerStore({}),logger: deps.logger,resolveSession: c => tryAuthenticate({ authenticator: deps.authenticator, context: c }),}),@@ -346,7 +378,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {'/api/v1/mcp-servers',withAuth(createMcpServersRouter({- resolveMcpServerStore: deps.resolveMcpServerStore,+ resolveMcpServerStore: c => deps.resolveMcpServerStore({ c }),tokenStore: deps.tokenStore,withTransaction: deps.withTransaction,logger: deps.logger,@@ -359,7 +391,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {'/api/v1/skills',withAuth(createAvailableSkillsRouter({- resolveSkillStore: deps.resolveSkillStore,+ resolveSkillStore: c => deps.resolveSkillStore({ c }),withTransaction: deps.withTransaction,resolveRequestContext,}),@@ -371,9 +403,9 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {withAuth(createAgentsRouter({resolveAgentStore: deps.resolveAgentStore,- resolveModelProviderStore: deps.resolveModelProviderStore,- resolveMcpServerStore: deps.resolveMcpServerStore,- resolveSkillStore: deps.resolveSkillStore,+ resolveModelProviderStore: c => deps.resolveModelProviderStore({ c }),+ resolveMcpServerStore: c => deps.resolveMcpServerStore({ c }),+ resolveSkillStore: c => deps.resolveSkillStore({ c }),resolveSandboxProviderStore: deps.resolveSandboxProviderStore,sandboxEnvironmentStore: deps.sandboxEnvironmentStore,resolveWebSearchProviderStore: deps.resolveWebSearchProviderStore,@@ -432,7 +464,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {resolveModelProviderStore: deps.resolveModelProviderStore,resolveMcpServerStore: deps.resolveMcpServerStore,tokenStore: deps.tokenStore,- resolveSkillStore: deps.resolveSkillStore,+ resolveSkillStore: c => deps.resolveSkillStore({ c }),resolveSandboxProviderStore: deps.resolveSandboxProviderStore,sandboxEnvironmentStore: deps.sandboxEnvironmentStore,resolveWebSearchProviderStore: deps.resolveWebSearchProviderStore,@@ -519,7 +551,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {activeTurns: deps.activeTurns,resolveModelProviderStore: deps.resolveModelProviderStore,resolveMcpServerStore: deps.resolveMcpServerStore,- resolveSkillStore: deps.resolveSkillStore,+ resolveTurnSkillsStore: deps.resolveTurnSkillsStore,resolveAgentStore: deps.resolveAgentStore,eventSubscriptions: deps.eventSubscriptions,resolveSandboxProviderStore: deps.resolveSandboxProviderStore,diff --git a/packages/trueforge/src/main.ts b/packages/trueforge/src/main.tsindex a62c53c8c..955f2b6c3 100644--- a/packages/trueforge/src/main.ts+++ b/packages/trueforge/src/main.ts@@ -87,7 +87,13 @@ import { RequestReplyExecutor, RequestReplyRouter, type RedisClient } from '@truimport type { Kysely, Transaction } from 'kysely';import type { Logger } from 'winston';-import { createServerApp } from './app';+import {+ createServerApp,+ type ResolveMcpServerStoreInput,+ type ResolveModelProviderStoreInput,+ type ResolveSkillStoreInput,+ type ResolveTurnSkillsStoreInput,+} from './app';import { TrueForgeAuthorizer, type Authorizer } from './auth/authorizer';import { createAuthenticator } from './auth/createAuthenticator';import { resolveRequestContext, STANDALONE_REQUEST_CONTEXT, type RequestContext } from './auth/identity';@@ -126,12 +132,16 @@ import { printStandaloneStartupBanner } from './startupBanner';import { InlineMcpServerStore } from './truefoundry/InlineMcpServerStore';import { InlineModelProviderStore } from './truefoundry/InlineModelProviderStore';import {+ assertInlineResourceHeadersAllowed,parseInlineMcpServers,parseInlineModelProviders,parseInlineSkills,X_TFG_MCP,X_TFG_MODELS,X_TFG_SKILLS,+ type InlineMcpServers,+ type InlineModelProviders,+ type InlineSkills,} from './truefoundry/inlineResources';import { InlineSkillStore } from './truefoundry/InlineSkillStore';import {@@ -149,6 +159,26 @@ import { TrueFoundryServiceFoundryServerClient } from './truefoundry/TrueFoundryimport { TrueFoundryAdminSkillStore, TrueFoundrySkillStore } from './truefoundry/TrueFoundrySkillStore';import { TrueFoundryWebSearchProviderStore } from './truefoundry/TrueFoundryWebSearchProviderStore';+/** Persistence-layer model store resolve (RequestContext, not Hono Context). */+type ResolveModelProviderStore<TTransaction> = (input: {+ rc: RequestContext;+ runAsAgent?: AgentRecord;+ inlineModelProviders?: InlineModelProviders;+}) => IModelProviderStore<TTransaction>;++/** Persistence-layer MCP store resolve (RequestContext, not Hono Context). */+type ResolveMcpServerStore<TTransaction> = (input: {+ rc: RequestContext;+ runAsAgent?: AgentRecord;+ perServerHeaders?: PerServerMcpHeaders;+ inlineMcpServers?: InlineMcpServers;+}) => IMcpServerWithAuthStore<TTransaction>;++/** Turn skill mounts: closed-set `x-tfg-skills`, else the registry/DB store. */+type ResolveTurnSkillsStore<TTransaction> = (input: {+ inlineSkills?: InlineSkills;+}) => Pick<ISkillStore<TTransaction>, 'resolveTurnSkills'>;+/** Persistence + optional Redis wired for the selected topology. */interface ServerPersistence<TTransaction> {withTransaction: WithTransaction<TTransaction>;@@ -157,15 +187,11 @@ interface ServerPersistence<TTransaction> {tokenStore: IOAuthTokenStore<TTransaction>;scheduleStore: IScheduleStore<TTransaction>;mcpOAuthStore: IMcpServerWithAuthStore<TTransaction>;- resolveModelProviderStore: (rc: RequestContext, runAsAgent?: AgentRecord) => IModelProviderStore<TTransaction>;- resolveMcpServerStore: (- rc: RequestContext,- runAsAgent?: AgentRecord,- perServerHeaders?: PerServerMcpHeaders,- ) => IMcpServerWithAuthStore<TTransaction>;+ resolveModelProviderStore: ResolveModelProviderStore<TTransaction>;+ resolveMcpServerStore: ResolveMcpServerStore<TTransaction>;resolveSandboxProviderStore: (rc: RequestContext) => ISandboxProviderStore<TTransaction>;resolveWebSearchProviderStore: (rc: RequestContext) => IWebSearchProviderStore<TTransaction>;- /** Per-request store: DB git skills, or TrueFoundry registry catalog in TrueFoundry mode. */+ /** Per-request store: DB git skills, or TrueFoundry registry catalog (caller JWT). */resolveSkillStore: (rc: RequestContext) => ISkillStore<TTransaction>;resolveAgentStore: (rc: RequestContext) => IAgentStore<TTransaction>;/** extra pre-resolved stores for scheduled runs */@@ -173,7 +199,8 @@ interface ServerPersistence<TTransaction> {sandboxEnvironmentStore: ISandboxEnvironmentStore<TTransaction>;/** Context-free provider store for internal sandbox-env build progress. */sandboxProviderStore: ISandboxProviderStore<TTransaction>;- turnSkillsResolverStore: Pick<ISkillStore<TTransaction>, 'resolveTurnSkills'>;+ /** Turn skill mounts: registry (API key) or closed-set `x-tfg-skills`. */+ resolveTurnSkillsStore: ResolveTurnSkillsStore<TTransaction>;destroyDb: () => Promise<void>;/** Connected Redis (client + mode) for distributed peering; undefined in standalone. */redis: ConnectedRedis | undefined;@@ -218,15 +245,24 @@ function buildResolveSkillStore<TTransaction>(options: {});}-function buildTurnSkillsResolverStore<TTransaction>(options: {+/**+ * Turn skill mounts. Registry path uses the service API key; `inlineSkills` is a closed set from+ * `x-tfg-skills` with no registry lookup.+ */+function buildResolveTurnSkillsStore<TTransaction>(options: {persistenceStore: ISkillStore<TTransaction>;client: TrueFoundryServiceFoundryServerClient | undefined;-}): Pick<ISkillStore<TTransaction>, 'resolveTurnSkills'> {+}): ResolveTurnSkillsStore<TTransaction> {const { persistenceStore, client } = options;- if (client) {- return new TrueFoundryAdminSkillStore({ client });- }- return persistenceStore;+ const registry: Pick<ISkillStore<TTransaction>, 'resolveTurnSkills'> = client+ ? new TrueFoundryAdminSkillStore({ client })+ : persistenceStore;+ return input => {+ if (input.inlineSkills !== undefined) {+ return new InlineSkillStore({ inline: input.inlineSkills });+ }+ return registry;+ };}/**@@ -237,16 +273,20 @@ function buildResolveModelProviderStore<TTransaction>(options: {persistenceStore: IModelProviderStore<TTransaction>;client: TrueFoundryServiceFoundryServerClient | undefined;logger: Logger;-}): (rc: RequestContext, runAsAgent?: AgentRecord) => IModelProviderStore<TTransaction> {- return (rc, runAsAgent) => {+}): ResolveModelProviderStore<TTransaction> {+ return input => {const { persistenceStore, client } = options;if (client) {- return new TrueFoundryModelProviderStore<TTransaction>({+ const store = new TrueFoundryModelProviderStore<TTransaction>({client,- requestContext: rc,- agent: runAsAgent,+ requestContext: input.rc,+ agent: input.runAsAgent,logger: options.logger,});+ if (input.inlineModelProviders !== undefined) {+ return new InlineModelProviderStore({ inner: store, inline: input.inlineModelProviders });+ }+ return store;}return persistenceStore;};@@ -260,26 +300,26 @@ function buildResolveMcpServerStore<TTransaction>(options: {tokenStore: IOAuthTokenStore<TTransaction>;client: TrueFoundryServiceFoundryServerClient | undefined;logger: Logger;-}): (- rc: RequestContext,- runAsAgent?: AgentRecord,- perServerHeaders?: PerServerMcpHeaders,-) => IMcpServerWithAuthStore<TTransaction> {+}): ResolveMcpServerStore<TTransaction> {const withAuthMcpPersistenceStore = new McpServerWithAuthStore<TTransaction>({store: options.persistenceStore,tokenStore: options.tokenStore,clientName: configuration.MCP_DCR_OAUTH_CLIENT_NAME,});- return (rc, runAsAgent, perServerHeaders) => {+ return input => {const { client } = options;if (client) {- return new TrueFoundryMcpServerStore<TTransaction>({+ const store = new TrueFoundryMcpServerStore<TTransaction>({client,- requestContext: rc,- agent: runAsAgent,+ requestContext: input.rc,+ agent: input.runAsAgent,logger: options.logger,- ...(perServerHeaders === undefined ? {} : { perServerHeaders }),+ ...(input.perServerHeaders === undefined ? {} : { perServerHeaders: input.perServerHeaders }),});+ if (input.inlineMcpServers !== undefined) {+ return new InlineMcpServerStore({ inner: store, inline: input.inlineMcpServers });+ }+ return store;}return withAuthMcpPersistenceStore;};@@ -412,7 +452,10 @@ async function createStandalonePersistence(options: {agentStore,sandboxEnvironmentStore,sandboxProviderStore,- turnSkillsResolverStore: skillStore,+ resolveTurnSkillsStore: buildResolveTurnSkillsStore({+ persistenceStore: skillStore,+ client: undefined,+ }),destroyDb: () => db.destroy(),redis: undefined,serviceFoundryClient: undefined,@@ -506,7 +549,7 @@ async function createDistributedPersistence(options: {const skillStore = new PostgresSkillStore(db);const agentStore = new PostgresAgentStore(db);const sandboxEnvironmentStore = wrapSandboxEnvironmentStore(new PostgresSandboxEnvironmentStore(db));- const turnSkillsResolverStore = buildTurnSkillsResolverStore({+ const resolveTurnSkillsStore = buildResolveTurnSkillsStore({persistenceStore: skillStore,client: serviceFoundryClient,});@@ -552,7 +595,7 @@ async function createDistributedPersistence(options: {agentStore,sandboxEnvironmentStore,sandboxProviderStore: resolveSandboxProviderStore(STANDALONE_REQUEST_CONTEXT),- turnSkillsResolverStore,+ resolveTurnSkillsStore,destroyDb: () => db.destroy(),redis: await connectRedis({connection: redisConnection,@@ -584,7 +627,7 @@ async function createServerRuntime<TTransaction>(persistence: ServerPersistence<mcpOAuthStore,agentStore,sandboxEnvironmentStore,- turnSkillsResolverStore,+ resolveTurnSkillsStore,destroyDb,redis,serviceFoundryClient,@@ -634,50 +677,88 @@ async function createServerRuntime<TTransaction>(persistence: ServerPersistence<: undefined;// Hono handlers get Context; persistence resolvers take RequestContext.- const resolveModelProviderStore = (c: Context, runAsAgent?: AgentRecord) => {- const store = persistence.resolveModelProviderStore(resolveRequestContext(c), runAsAgent);- if (!isTrueFoundryModeEnabled(configuration)) {- return store;- }- const rawInline = c.req.header(X_TFG_MODELS);- if (rawInline === undefined) {- return store;+ // x-tfg-skills / x-tfg-mcp / x-tfg-models are rejected unless allowInlineResources+ // (inline session create or spec replace, or a turn for an inline session).+ // x-tfg-mcp-headers is separate (per-server invoke headers).+ const isTrueFoundryMode = isTrueFoundryModeEnabled(configuration);+ const resolveModelProviderStore = (input: ResolveModelProviderStoreInput) => {+ const { c, runAsAgent, allowInlineResources = false } = input;+ const rawInlineModelsHeader = c.req.header(X_TFG_MODELS);+ if (rawInlineModelsHeader !== undefined) {+ assertInlineResourceHeadersAllowed({+ headerNames: [X_TFG_MODELS],+ isTrueFoundryMode,+ allowInlineResources,+ });}- return new InlineModelProviderStore({ inner: store, inline: parseInlineModelProviders(rawInline) });+ return persistence.resolveModelProviderStore({+ rc: resolveRequestContext(c),+ ...(runAsAgent !== undefined ? { runAsAgent } : {}),+ ...(rawInlineModelsHeader !== undefined+ ? { inlineModelProviders: parseInlineModelProviders(rawInlineModelsHeader) }+ : {}),+ });};- const resolveMcpServerStore = (c?: Context, runAsAgent?: AgentRecord) => {+ const resolveMcpServerStore = (input: ResolveMcpServerStoreInput) => {+ const { c, runAsAgent, allowInlineResources = false } = input;if (c === undefined) {return mcpOAuthStore;}const rawPerServerHeaders = c.req.header(X_TFG_MCP_HEADERS);- const store = persistence.resolveMcpServerStore(- resolveRequestContext(c),- runAsAgent,- rawPerServerHeaders === undefined ? undefined : parsePerServerMcpHeaders(rawPerServerHeaders),- );- if (!isTrueFoundryModeEnabled(configuration)) {- return store;- }- const rawInline = c.req.header(X_TFG_MCP);- if (rawInline === undefined) {- return store;+ const rawInlineMcpServersHeader = c.req.header(X_TFG_MCP);+ if (rawInlineMcpServersHeader !== undefined) {+ assertInlineResourceHeadersAllowed({+ headerNames: [X_TFG_MCP],+ isTrueFoundryMode,+ allowInlineResources,+ });}- return new InlineMcpServerStore({ inner: store, inline: parseInlineMcpServers(rawInline) });+ return persistence.resolveMcpServerStore({+ rc: resolveRequestContext(c),+ ...(runAsAgent !== undefined ? { runAsAgent } : {}),+ ...(rawPerServerHeaders !== undefined ? { perServerHeaders: parsePerServerMcpHeaders(rawPerServerHeaders) } : {}),+ ...(rawInlineMcpServersHeader !== undefined+ ? { inlineMcpServers: parseInlineMcpServers(rawInlineMcpServersHeader) }+ : {}),+ });};const resolveAgentStore = (c: Context) => persistence.resolveAgentStore(resolveRequestContext(c));const resolveSandboxProviderStore = (c: Context) => persistence.resolveSandboxProviderStore(resolveRequestContext(c));const resolveWebSearchProviderStore = (c: Context) =>persistence.resolveWebSearchProviderStore(resolveRequestContext(c));- const resolveSkillStore = (c: Context) => {- const store = persistence.resolveSkillStore(resolveRequestContext(c));- if (!isTrueFoundryModeEnabled(configuration)) {- return store;+ // Catalog and agent saves reject x-tfg-skills. Inline session create and spec replace opt in and get a+ // closed-set store for validation only; the header is not persisted.+ const resolveSkillStore = (input: ResolveSkillStoreInput) => {+ const { c, allowInlineResources = false } = input;+ const rawInlineSkillsHeader = c.req.header(X_TFG_SKILLS);+ if (rawInlineSkillsHeader !== undefined) {+ assertInlineResourceHeadersAllowed({+ headerNames: [X_TFG_SKILLS],+ isTrueFoundryMode,+ allowInlineResources,+ });+ return new InlineSkillStore({ inline: parseInlineSkills(rawInlineSkillsHeader) });}- const rawInline = c.req.header(X_TFG_SKILLS);- if (rawInline === undefined) {- return store;+ return persistence.resolveSkillStore(resolveRequestContext(c));+ };+ // Turn mounts: registry (API key), or closed-set header skills when `c` + allowInlineResources.+ // Schedules omit `c` and always get the registry/DB store.+ const resolveTurnSkillsStoreForRequest = (input: ResolveTurnSkillsStoreInput) => {+ const { c, allowInlineResources = false } = input;+ if (c === undefined) {+ return resolveTurnSkillsStore({});+ }+ const rawInlineSkillsHeader = c.req.header(X_TFG_SKILLS);+ if (rawInlineSkillsHeader !== undefined) {+ assertInlineResourceHeadersAllowed({+ headerNames: [X_TFG_SKILLS],+ isTrueFoundryMode,+ allowInlineResources,+ });}- return new InlineSkillStore({ inner: store, inline: parseInlineSkills(rawInline) });+ return resolveTurnSkillsStore(+ rawInlineSkillsHeader === undefined ? {} : { inlineSkills: parseInlineSkills(rawInlineSkillsHeader) },+ );};const app = createServerApp({modelCatalog: ModelCatalog.load(),@@ -691,13 +772,13 @@ async function createServerRuntime<TTransaction>(persistence: ServerPersistence<resolveSandboxProviderStore,resolveWebSearchProviderStore,resolveSkillStore,+ resolveTurnSkillsStore: resolveTurnSkillsStoreForRequest,withTransaction,tokenStore,scheduleStore,agentStore,sandboxEnvironmentStore,sandboxProviderStore: persistence.sandboxProviderStore,- turnSkillsResolverStore,sessionStore,sessionMetricsStore,sessions,diff --git a/packages/trueforge/src/schemas/skill.ts b/packages/trueforge/src/schemas/skill.tsindex 4f3c690db..109c6710d 100644--- a/packages/trueforge/src/schemas/skill.ts+++ b/packages/trueforge/src/schemas/skill.ts@@ -56,7 +56,7 @@ export const SkillDescriptionSchema = z.min(1).describe('Concise guidance for when the agent should use the skill.');-const GitSkillSchema = z+export const GitSkillSchema = z.object({type: z.literal(SkillTypeSchema.enum.git),name: NameSchema,diff --git a/packages/trueforge/src/truefoundry/InlineSkillStore.ts b/packages/trueforge/src/truefoundry/InlineSkillStore.tsindex f37aaca53..f65c312dd 100644--- a/packages/trueforge/src/truefoundry/InlineSkillStore.ts+++ b/packages/trueforge/src/truefoundry/InlineSkillStore.ts@@ -10,112 +10,89 @@ import type {SkillRecord,UpsertSkillInput,} from '../db/skillStore';-import type { SkillVersion } from '../schemas/skill';+import type { GitSkill, SkillVersion } from '../schemas/skill';import type { InlineSkills } from './inlineResources';+import { X_TFG_SKILLS } from './inlineResources';/**- * Serves the skills a request brought with it, and delegates everything else.- *- * Mirrors {@link InlineMcpServerStore}: name-filtered list and validate/resolve are overlaid, an- * unfiltered list passes through so request-scoped skills stay out of the tenant's settings, and- * writes delegate because there is no row to write.+ * Closed set of git skills from `x-tfg-skills`. Every requested name must be in the header map;+ * there is no registry fallthrough. Unfiltered lists stay empty so request-scoped skills never+ * appear in tenant settings. Writes are unsupported.*/export class InlineSkillStore<TTransaction = never> implements ISkillStore<TTransaction> {- readonly #inner: ISkillStore<TTransaction>;readonly #inline: InlineSkills;- constructor(input: { inner: ISkillStore<TTransaction>; inline: InlineSkills }) {- this.#inner = input.inner;+ constructor(input: { inline: InlineSkills }) {this.#inline = input.inline;}- async listSkills(input: ListSkillsInput, transaction?: TTransaction): Promise<SkillRecord[]> {+ listSkills(input: ListSkillsInput, _transaction?: TTransaction): Promise<SkillRecord[]> {+ void _transaction;if (input.names === undefined) {- return this.#inner.listSkills(input, transaction);+ return Promise.resolve([]);}if (input.names.length === 0) {- return [];+ return Promise.resolve([]);}-- const inlineRecords = input.names- .map(name => this.#toRecord({ tenant_id: input.tenant_id, name }))- .filter((record): record is SkillRecord => record !== undefined);- const registryNames = input.names.filter(name => this.#inline[name] === undefined);- const registryRecords =- registryNames.length > 0 ? await this.#inner.listSkills({ ...input, names: registryNames }, transaction) : [];-- return [...inlineRecords, ...registryRecords];+ const names = input.names;+ // Reject via the Promise without `async` (require-await).+ return Promise.resolve().then(() => names.map(name => this.#toRecord({ tenant_id: input.tenant_id, name })));}- createSkill(input: CreateSkillInput, transaction?: TTransaction): Promise<SkillRecord> {- return this.#inner.createSkill(input, transaction);+ createSkill(_input: CreateSkillInput, _transaction?: TTransaction): Promise<SkillRecord> {+ void _input;+ void _transaction;+ return unsupportedInlineSkillWrite();}- upsertSkill(input: UpsertSkillInput, transaction?: TTransaction): Promise<SkillRecord> {- return this.#inner.upsertSkill(input, transaction);+ upsertSkill(_input: UpsertSkillInput, _transaction?: TTransaction): Promise<SkillRecord> {+ void _input;+ void _transaction;+ return unsupportedInlineSkillWrite();}- deleteSkill(input: DeleteSkillInput, transaction?: TTransaction): Promise<boolean> {- return this.#inner.deleteSkill(input, transaction);+ deleteSkill(_input: DeleteSkillInput, _transaction?: TTransaction): Promise<boolean> {+ void _input;+ void _transaction;+ return unsupportedInlineSkillWrite();}listSkillVersions(input: { name: string }): Promise<SkillVersion[]> {- if (this.#inline[input.name] !== undefined) {- return Promise.resolve([]);- }- return this.#inner.listSkillVersions(input);+ return Promise.resolve().then(() => {+ this.#require(input.name);+ return [];+ });}- async validateAgentSkills(input: AgentSkillsInput, transaction?: TTransaction): Promise<void> {- const { inlineSkills, registrySkills } = this.#partition(input.skills);- if (inlineSkills.length > 0) {- await validateGitAgentSkills(this, { tenant_id: input.tenant_id, skills: inlineSkills });- }- // Cross-source uniqueness needs registry short names from resolveTurnSkills; keep that out of- // validate so mixed specs are not failed for API-key / presigned-URL requirements.- if (registrySkills.length > 0) {- await this.#inner.validateAgentSkills({ tenant_id: input.tenant_id, skills: registrySkills }, transaction);- }+ async validateAgentSkills(input: AgentSkillsInput, _transaction?: TTransaction): Promise<void> {+ void _transaction;+ this.#assertNamesInInline(input.skills.map(skill => skill.name));+ await validateGitAgentSkills(this, { tenant_id: input.tenant_id, skills: input.skills });}async resolveTurnSkills(input: AgentSkillsInput): Promise<SkillMount[]> {- const { inlineSkills, registrySkills } = this.#partition(input.skills);- const inlineMounts =- inlineSkills.length > 0- ? await resolveGitTurnSkills(this, { tenant_id: input.tenant_id, skills: inlineSkills })- : [];- const registryMounts =- registrySkills.length > 0- ? await this.#inner.resolveTurnSkills({ tenant_id: input.tenant_id, skills: registrySkills })- : [];- const mounts = [...inlineMounts, ...registryMounts];- // Inline key and registry short name share the sandbox dir — reject collisions here.- const seen = new Set<string>();- for (const mount of mounts) {- if (seen.has(mount.name)) {- throw new HTTPException(422, {- message: `Agent skills must have unique names; duplicate skill name(s): ${mount.name}`,- });- }- seen.add(mount.name);- }- return mounts;+ this.#assertNamesInInline(input.skills.map(skill => skill.name));+ return resolveGitTurnSkills(this, { tenant_id: input.tenant_id, skills: input.skills });}- #partition(skills: AgentSkillsInput['skills']): {- inlineSkills: AgentSkillsInput['skills'];- registrySkills: AgentSkillsInput['skills'];- } {- const inlineSkills = skills.filter(skill => this.#inline[skill.name] !== undefined);- const registrySkills = skills.filter(skill => this.#inline[skill.name] === undefined);- return { inlineSkills, registrySkills };+ #assertNamesInInline(names: readonly string[]): void {+ for (const name of names) {+ this.#require(name);+ }}- #toRecord(input: { tenant_id: string; name: string }): SkillRecord | undefined {- const manifest = this.#inline[input.name];+ #require(name: string): GitSkill {+ const manifest = this.#inline[name];if (manifest === undefined) {- return undefined;+ throw new HTTPException(422, {+ message: `Unknown skill "${name}" — not present in ${X_TFG_SKILLS}`,+ });}+ return manifest;+ }++ #toRecord(input: { tenant_id: string; name: string }): SkillRecord {+ const manifest = this.#require(input.name);const now = new Date().toISOString();return {tenant_id: input.tenant_id,@@ -126,3 +103,9 @@ export class InlineSkillStore<TTransaction = never> implements ISkillStore<TTran};}}++function unsupportedInlineSkillWrite(): Promise<never> {+ return Promise.reject(+ new HTTPException(400, { message: `Request-scoped skills from ${X_TFG_SKILLS} do not support writes` }),+ );+}diff --git a/packages/trueforge/src/truefoundry/inlineResources.ts b/packages/trueforge/src/truefoundry/inlineResources.tsindex e8d0d523d..77e5463af 100644--- a/packages/trueforge/src/truefoundry/inlineResources.ts+++ b/packages/trueforge/src/truefoundry/inlineResources.ts@@ -10,15 +10,39 @@import { HTTPException } from 'hono/http-exception';import { McpServerManifestSchema, type McpServerManifest } from '../schemas/mcpServer';import { ModelProviderManifestSchema, type ModelProviderManifest } from '../schemas/modelProvider';-import { SkillManifestSchema, type SkillManifest } from '../schemas/skill';+import { GitSkillSchema, type GitSkill } from '../schemas/skill';export const X_TFG_MCP = 'x-tfg-mcp';export const X_TFG_SKILLS = 'x-tfg-skills';export const X_TFG_MODELS = 'x-tfg-models';+/**+ * Fail closed: those headers are rejected unless TrueFoundry mode is on and the caller+ * opted in (`allowInlineResources: true` on inline session create or spec replace, or on a+ * turn for an inline session). Create and replace use them only to validate the spec; they+ * are not stored.+ * Does not cover `x-tfg-mcp-headers` — that only adds per-server invoke headers, it does not+ * define MCP servers.+ */+export function assertInlineResourceHeadersAllowed(input: {+ headerNames: string[];+ isTrueFoundryMode: boolean;+ allowInlineResources: boolean;+}): void {+ const labeled = input.headerNames.join('/');+ if (!input.isTrueFoundryMode) {+ throw new HTTPException(400, { message: `${labeled} requires TrueFoundry mode` });+ }+ if (!input.allowInlineResources) {+ throw new HTTPException(400, {+ message: `${labeled} is only allowed when creating or updating an inline session, or on a turn for one`,+ });+ }+}+/** Manifests by name. `type` and `name` are implied by the header and the key, so callers omit them. */export type InlineMcpServers = Readonly<Record<string, McpServerManifest>>;-export type InlineSkills = Readonly<Record<string, SkillManifest>>;+export type InlineSkills = Readonly<Record<string, GitSkill>>;/** Keyed by provider name: a spec addresses a model as `provider/model`, so the provider is the unit. */export type InlineModelProviders = Readonly<Record<string, ModelProviderManifest>>;@@ -44,7 +68,7 @@ export function parseInlineSkills(raw: string): InlineSkills {raw,header: X_TFG_SKILLS,parseEntry: (name, definition) => {- const parsed = SkillManifestSchema.safeParse({ ...definition, type: 'git', name });+ const parsed = GitSkillSchema.safeParse({ ...definition, type: 'git', name });return parsed.success? { ok: true, manifest: parsed.data }: { ok: false, reason: 'is not a valid skill definition' };diff --git a/packages/trueforge/tests/unit/apis/deletedSessionCrud.test.ts b/packages/trueforge/tests/unit/apis/deletedSessionCrud.test.tsindex 4d6565d75..17409f077 100644--- a/packages/trueforge/tests/unit/apis/deletedSessionCrud.test.ts+++ b/packages/trueforge/tests/unit/apis/deletedSessionCrud.test.ts@@ -72,7 +72,7 @@ describe('public CRUD after session deletion', () => {activeTurns,resolveModelProviderStore: () => modelProviderStore,resolveMcpServerStore: () => mcpServerStore,- resolveSkillStore: () => skillStore,+ resolveTurnSkillsStore: () => skillStore,resolveAgentStore: () => agentStore,eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => sandboxProviderStore,diff --git a/packages/trueforge/tests/unit/apis/sandboxFileDownload.test.ts b/packages/trueforge/tests/unit/apis/sandboxFileDownload.test.tsindex b265be6c9..2bbda5453 100644--- a/packages/trueforge/tests/unit/apis/sandboxFileDownload.test.ts+++ b/packages/trueforge/tests/unit/apis/sandboxFileDownload.test.ts@@ -49,7 +49,7 @@ async function buildApp() {tokenStore,clientName: 'test-client',}),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => new SqliteAgentStore(db),eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),diff --git a/packages/trueforge/tests/unit/apis/schedules.test.ts b/packages/trueforge/tests/unit/apis/schedules.test.tsindex 7da44b000..51fa79f64 100644--- a/packages/trueforge/tests/unit/apis/schedules.test.ts+++ b/packages/trueforge/tests/unit/apis/schedules.test.ts@@ -70,7 +70,7 @@ function stubTurnExecutionDeps(agentStore: SqliteAgentStore, scheduleStore: Sqlilogger: winston.createLogger({ silent: true }),resolveModelProviderStore: () => ({}) as never,resolveMcpServerStore: () => ({}) as never,- turnSkillsResolverStore: { resolveTurnSkills: async () => [] },+ resolveTurnSkillsStore: () => ({ resolveTurnSkills: async () => [] }),resolveSandboxProviderStore: () => ({}) as never,sandboxEnvironmentStore: {} as never,resolveWebSearchProviderStore: () => ({}) as never,diff --git a/packages/trueforge/tests/unit/apis/sessionHttp.test.ts b/packages/trueforge/tests/unit/apis/sessionHttp.test.tsindex 6da92584e..cc34322be 100644--- a/packages/trueforge/tests/unit/apis/sessionHttp.test.ts+++ b/packages/trueforge/tests/unit/apis/sessionHttp.test.ts@@ -48,6 +48,18 @@ function jsonInit(method: string, body: unknown): RequestInit {};}+function expectCalledWithAllowInlineResources(...resolvers: jest.Mock[]): void {+ for (const resolve of resolvers) {+ expect(resolve).toHaveBeenCalledWith({ c: expect.anything(), allowInlineResources: true });+ }+}++function clearResolvers(...resolvers: jest.Mock[]): void {+ for (const resolve of resolvers) {+ resolve.mockClear();+ }+}+const deniedCanAccessAgent = jest.fn((_input: Parameters<Authorizer['canAccessAgent']>[0]) => Promise.resolve(false));const denyAllAuthorizer: Authorizer = {listAgentAccess: () => Promise.resolve({ kind: 'agent_external_ids', agent_external_ids: [] }),@@ -64,6 +76,9 @@ describe('sessions HTTP agent binding', () => {let sessionStore: SqliteSessionStore;let sessionMetricsStore: SqliteSessionMetricsStore;let sessionDeps: SessionsRouterDeps;+ let resolveModelProviderStore: jest.Mock;+ let resolveMcpServerStore: jest.Mock;+ let resolveSkillStore: jest.Mock;beforeEach(async () => {const db = createSqliteDb(':memory:');@@ -96,13 +111,16 @@ describe('sessions HTTP agent binding', () => {},});+ resolveModelProviderStore = jest.fn(() => modelProviderStore);+ resolveMcpServerStore = jest.fn(() => mcpServerStore);+ resolveSkillStore = jest.fn(() => skillStore);const deps: SessionsRouterDeps = {sessions,sessionStore,activeTurns: new ActiveTurnRegistry(),- resolveModelProviderStore: () => modelProviderStore,- resolveMcpServerStore: () => mcpServerStore,- resolveSkillStore: () => skillStore,+ resolveModelProviderStore,+ resolveMcpServerStore,+ resolveSkillStore,resolveAgentStore: () => agentStore,resolveSandboxProviderStore: () => sandboxProviderStore,sandboxEnvironmentStore,@@ -130,7 +148,7 @@ describe('sessions HTTP agent binding', () => {tokenStore,clientName: 'test-client',}),- resolveSkillStore: () => skillStore,+ resolveTurnSkillsStore: () => skillStore,resolveAgentStore: () => agentStore,eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => sandboxProviderStore,@@ -435,45 +453,33 @@ describe('sessions HTTP agent binding', () => {).toBe(true);const forbiddenBody = { error: { message: 'Only the session creator can access this session' } };-- const getForbidden = await app.request('/other-user-session');- expect(getForbidden.status).toBe(403);- expect(await getForbidden.json()).toEqual(forbiddenBody);-- const patchForbidden = await app.request('/other-user-session', jsonInit('PATCH', {}));- expect(patchForbidden.status).toBe(403);- expect(await patchForbidden.json()).toEqual(forbiddenBody);-- const deleteForbidden = await app.request('/other-user-session', { method: 'DELETE' });- expect(deleteForbidden.status).toBe(403);- expect(await deleteForbidden.json()).toEqual(forbiddenBody);-- const cancelForbidden = await app.request('/other-user-session/cancel', { method: 'POST' });- expect(cancelForbidden.status).toBe(403);- expect(await cancelForbidden.json()).toEqual(forbiddenBody);-- const eventsForbidden = await app.request('/other-user-session/events');- expect(eventsForbidden.status).toBe(403);- expect(await eventsForbidden.json()).toEqual(forbiddenBody);-- const sendEventsForbidden = await app.request(- '/other-user-session/turns/any-turn/events',- jsonInit('POST', {- events: [- {- type: 'user.tool_approval',- thread_id: 'main',- tool_call_id: 'tc-1',- approval: { status: 'allow' },- },- ],- }),- );- expect(sendEventsForbidden.status).toBe(403);- expect(await sendEventsForbidden.json()).toEqual(forbiddenBody);-- const allowed = await app.request(`/${json.data.id}`);- expect(allowed.status).toBe(200);+ const forbiddenRequests: Array<[string, RequestInit | undefined]> = [+ ['/other-user-session', undefined],+ ['/other-user-session', jsonInit('PATCH', {})],+ ['/other-user-session', { method: 'DELETE' }],+ ['/other-user-session/cancel', { method: 'POST' }],+ ['/other-user-session/events', undefined],+ [+ '/other-user-session/turns/any-turn/events',+ jsonInit('POST', {+ events: [+ {+ type: 'user.tool_approval',+ thread_id: 'main',+ tool_call_id: 'tc-1',+ approval: { status: 'allow' },+ },+ ],+ }),+ ],+ ];+ for (const [path, init] of forbiddenRequests) {+ const forbidden = await app.request(path, init);+ expect(forbidden.status).toBe(403);+ expect(await forbidden.json()).toEqual(forbiddenBody);+ }++ expect((await app.request(`/${json.data.id}`)).status).toBe(200);});it('POST /sessions/{id}/turns/{turn_id}/events mints ids for events', async () => {@@ -572,10 +578,15 @@ describe('sessions HTTP agent binding', () => {expect(patchNamed.status).toBe(422);});- it('allows PATCH agent.spec on inline sessions', async () => {+ it('opts into request-scoped resources when validating inline session specs', async () => {+ const resolvers = [resolveModelProviderStore, resolveMcpServerStore, resolveSkillStore];+const created = await app.request('/', jsonInit('POST', { agent: { spec: inlineSpec } }));expect(created.status).toBe(201);+ expectCalledWithAllowInlineResources(...resolvers);+const { data } = (await created.json()) as { data: { id: string } };+ clearResolvers(...resolvers);const patched = await app.request(`/${data.id}`,@@ -583,9 +594,18 @@ describe('sessions HTTP agent binding', () => {);expect(patched.status).toBe(200);const patchedJson = (await patched.json()) as {- data: { agent: { type: 'inline'; spec: { instructions?: string } } };+ data: { agent: { spec: { instructions?: string } } };};expect(patchedJson.data.agent.spec.instructions).toBe('updated');+ expectCalledWithAllowInlineResources(...resolvers);++ clearResolvers(...resolvers);+ const external = await app.request(+ '/api/internal/sessions/get-or-create-by-external-id',+ jsonInit('POST', { external_id: 'inline-create', agent: { spec: inlineSpec } }),+ );+ expect(external.status).toBe(201);+ expectCalledWithAllowInlineResources(...resolvers);});it('create and PATCH round-trip session metadata', async () => {diff --git a/packages/trueforge/tests/unit/apis/turnHarnessErrorStatus.test.ts b/packages/trueforge/tests/unit/apis/turnHarnessErrorStatus.test.tsindex d657b3f93..026e609db 100644--- a/packages/trueforge/tests/unit/apis/turnHarnessErrorStatus.test.ts+++ b/packages/trueforge/tests/unit/apis/turnHarnessErrorStatus.test.ts@@ -78,7 +78,7 @@ async function postTurnRejectingWith(error: AgentHarnessError): Promise<ResponsetokenStore,clientName: 'test-client',}),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => new SqliteAgentStore(db),eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),diff --git a/packages/trueforge/tests/unit/apis/turns.test.ts b/packages/trueforge/tests/unit/apis/turns.test.tsindex bfdb7a6d0..65d707cf0 100644--- a/packages/trueforge/tests/unit/apis/turns.test.ts+++ b/packages/trueforge/tests/unit/apis/turns.test.ts@@ -123,7 +123,7 @@ describe('turns', () => {activeTurns: new ActiveTurnRegistry(),resolveModelProviderStore: () => new SqliteModelProviderStore(db),resolveMcpServerStore: () => mcpServerStoreWithAuth(db, tokenStore),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => new SqliteAgentStore(db),eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),@@ -219,7 +219,7 @@ describe('turns', () => {activeTurns: new ActiveTurnRegistry(),resolveModelProviderStore: () => new SqliteModelProviderStore(db),resolveMcpServerStore: () => mcpServerStoreWithAuth(db, new SqliteOAuthTokenStore(db)),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => agentStore,eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),@@ -321,7 +321,7 @@ describe('turns', () => {activeTurns: new ActiveTurnRegistry(),resolveModelProviderStore: () => new SqliteModelProviderStore(db),resolveMcpServerStore: () => mcpServerStoreWithAuth(db, new SqliteOAuthTokenStore(db)),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => new SqliteAgentStore(db),eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),@@ -392,7 +392,7 @@ describe('turns', () => {activeTurns: new ActiveTurnRegistry(),resolveModelProviderStore: () => new SqliteModelProviderStore(db),resolveMcpServerStore: () => mcpServerStoreWithAuth(db, new SqliteOAuthTokenStore(db)),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => new SqliteAgentStore(db),eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),@@ -501,7 +501,7 @@ describe('turns', () => {resolveModelProviderStore: () => modelProviderStore,resolveMcpServerStore: () => mcpServerStoreWithAuth(db, tokenStore),resolveAgentStore: () => new SqliteAgentStore(db),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),eventSubscriptions,resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),sandboxEnvironmentStore: new SqliteSandboxEnvironmentStore(db),@@ -609,7 +609,7 @@ describe('turns', () => {activeTurns: new ActiveTurnRegistry(),resolveModelProviderStore: () => modelProviderStore,resolveMcpServerStore: () => mcpServerStoreWithAuth(db, tokenStore),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => new SqliteAgentStore(db),eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),@@ -696,7 +696,7 @@ describe('turns', () => {activeTurns: new ActiveTurnRegistry(),resolveModelProviderStore: () => new SqliteModelProviderStore(db),resolveMcpServerStore: () => mcpServerStoreWithAuth(db, tokenStore),- resolveSkillStore: () => new SqliteSkillStore(db),+ resolveTurnSkillsStore: () => new SqliteSkillStore(db),resolveAgentStore: () => agentStore,eventSubscriptions: new EventSubscriptionRegistry(undefined),resolveSandboxProviderStore: () => new SqliteSandboxProviderStore(db),diff --git a/packages/trueforge/tests/unit/truefoundry/inlineResources.test.ts b/packages/trueforge/tests/unit/truefoundry/inlineResources.test.tsindex 20d997b3a..bbf82f1fe 100644--- a/packages/trueforge/tests/unit/truefoundry/inlineResources.test.ts+++ b/packages/trueforge/tests/unit/truefoundry/inlineResources.test.ts@@ -1,7 +1,6 @@import { HTTPException } from 'hono/http-exception';import type { IMcpServerWithAuthStore, McpServerRecord } from '../../../src/db/mcpServerStore';import type { IModelProviderStore, ModelProviderRecord } from '../../../src/db/modelProviderStore';-import type { ISkillStore, SkillRecord } from '../../../src/db/skillStore';import { TFG_METADATA_PREFIX, X_TFY_METADATA } from '../../../src/truefoundry/gatewayMetadata';import { InlineMcpServerStore } from '../../../src/truefoundry/InlineMcpServerStore';import { InlineModelProviderStore } from '../../../src/truefoundry/InlineModelProviderStore';@@ -40,20 +39,6 @@ const registryServer: McpServerRecord = {updated_at: '2026-01-15T12:00:00.000Z',};-const registrySkill: SkillRecord = {- tenant_id: 'default',- name: 'team-skill',- manifest: {- type: 'git',- name: 'team-skill',- url: 'https://github.com/acme/skills',- ref: 'main',- description: 'A skill the tenant configured.',- },- created_at: '2026-01-15T12:00:00.000Z',- updated_at: '2026-01-15T12:00:00.000Z',-};-const registryProvider: ModelProviderRecord = {tenant_id: 'default',name: 'openai',@@ -95,16 +80,8 @@ function mcpStoreWith(inlineRaw: object) {return { store, inner };}-function skillStoreWith(inlineRaw: object, innerOverrides?: Partial<ISkillStore>) {- const inner = {- listSkills: jest.fn().mockResolvedValue([registrySkill]),- validateAgentSkills: jest.fn().mockResolvedValue(undefined),- resolveTurnSkills: jest.fn().mockResolvedValue([]),- listSkillVersions: jest.fn().mockResolvedValue([]),- ...innerOverrides,- } as unknown as ISkillStore;- const store = new InlineSkillStore({ inner, inline: parseInlineSkills(JSON.stringify(inlineRaw)) });- return { store, inner };+function skillStoreWith(inlineRaw: object) {+ return new InlineSkillStore({ inline: parseInlineSkills(JSON.stringify(inlineRaw)) });}describe('parseInlineMcpServers', () => {@@ -361,16 +338,25 @@ describe('InlineMcpServerStore', () => {});describe('InlineSkillStore', () => {- it('answers a name-filtered list from both sources', async () => {- const { store } = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });+ it('answers a name-filtered list only from the header map', async () => {+ const store = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });++ const records = await store.listSkills({ tenant_id: 'default', names: ['ask-ai'] });++ expect(records.map(record => record.name)).toEqual(['ask-ai']);+ });- const records = await store.listSkills({ tenant_id: 'default', names: ['ask-ai', 'team-skill'] });+ it('rejects a name that is not in the header map', async () => {+ const store = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });- expect(records.map(record => record.name)).toEqual(['ask-ai', 'team-skill']);+ await expect(store.listSkills({ tenant_id: 'default', names: ['ask-ai', 'team-skill'] })).rejects.toMatchObject({+ status: 422,+ message: 'Unknown skill "team-skill" — not present in x-tfg-skills',+ });});it('exposes the git mount fields that turn execution expands', async () => {- const { store } = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });+ const store = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });const [record] = await store.listSkills({ tenant_id: 'default', names: ['ask-ai'] });@@ -378,46 +364,27 @@ describe('InlineSkillStore', () => {});it('keeps request-scoped skills out of an unfiltered list, so they never reach tenant settings', async () => {- const { store } = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });+ const store = skillStoreWith({ 'ask-ai': ASK_AI_SKILL });const records = await store.listSkills({ tenant_id: 'default', names: undefined });- expect(records.map(record => record.name)).toEqual(['team-skill']);+ expect(records).toEqual([]);});- it('validate allows mixed inline and registry skills; resolve rejects sandbox-name collisions', async () => {- const registryFqn = 'agent-skill:acme/team-a/echo:3';- const { store, inner } = skillStoreWith(- { echo: { ...ASK_AI_SKILL, path: 'echo' } },- {- resolveTurnSkills: jest.fn().mockResolvedValue([- {- type: 'registry',- name: 'echo',- description: 'Registry echo',- fqn: registryFqn,- preload: false,- skillMdContent: null,- presignedUrl: 'https://example.com/echo.tgz',- },- ]),- },- );+ it('validate and resolve reject names that are not in the header map', async () => {+ const store = skillStoreWith({ echo: { ...ASK_AI_SKILL, path: 'echo' } });const skills = [{ name: 'echo', preload: false },- { name: registryFqn, preload: false },+ { name: 'agent-skill:acme/team-a/echo:3', preload: false },];- await expect(store.validateAgentSkills({ tenant_id: 'default', skills })).resolves.toBeUndefined();- expect(inner.validateAgentSkills).toHaveBeenCalledWith(- { tenant_id: 'default', skills: [{ name: registryFqn, preload: false }] },- undefined,- );- expect(inner.resolveTurnSkills).not.toHaveBeenCalled();-+ await expect(store.validateAgentSkills({ tenant_id: 'default', skills })).rejects.toMatchObject({+ status: 422,+ message: 'Unknown skill "agent-skill:acme/team-a/echo:3" — not present in x-tfg-skills',+ });await expect(store.resolveTurnSkills({ tenant_id: 'default', skills })).rejects.toMatchObject({status: 422,- message: 'Agent skills must have unique names; duplicate skill name(s): echo',+ message: 'Unknown skill "agent-skill:acme/team-a/echo:3" — not present in x-tfg-skills',});});});