@truefoundry/trueforge 0.182.0-rc.2 → 0.182.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js
CHANGED
|
@@ -730,17 +730,17 @@ var init_config = __esm({
|
|
|
730
730
|
SANDBOX_ENVIRONMENT_CPU_MAX: parsePositiveInt({
|
|
731
731
|
envKey: "SANDBOX_ENVIRONMENT_CPU_MAX",
|
|
732
732
|
raw: getEnv("SANDBOX_ENVIRONMENT_CPU_MAX"),
|
|
733
|
-
defaultValue:
|
|
733
|
+
defaultValue: 4
|
|
734
734
|
}),
|
|
735
735
|
SANDBOX_ENVIRONMENT_MEMORY_GIB_MAX: parsePositiveInt({
|
|
736
736
|
envKey: "SANDBOX_ENVIRONMENT_MEMORY_GIB_MAX",
|
|
737
737
|
raw: getEnv("SANDBOX_ENVIRONMENT_MEMORY_GIB_MAX"),
|
|
738
|
-
defaultValue:
|
|
738
|
+
defaultValue: 8
|
|
739
739
|
}),
|
|
740
740
|
SANDBOX_ENVIRONMENT_DISK_GIB_MAX: parsePositiveInt({
|
|
741
741
|
envKey: "SANDBOX_ENVIRONMENT_DISK_GIB_MAX",
|
|
742
742
|
raw: getEnv("SANDBOX_ENVIRONMENT_DISK_GIB_MAX"),
|
|
743
|
-
defaultValue:
|
|
743
|
+
defaultValue: 10
|
|
744
744
|
}),
|
|
745
745
|
MAX_REQUEST_BODY_BYTES: parsePositiveInt({
|
|
746
746
|
envKey: "MAX_REQUEST_BODY_BYTES",
|
|
@@ -10886,6 +10886,23 @@ function getDaytonaAuthorizationErrorMessage(error) {
|
|
|
10886
10886
|
}
|
|
10887
10887
|
return void 0;
|
|
10888
10888
|
}
|
|
10889
|
+
function getDaytonaBuildFailureMessage(error) {
|
|
10890
|
+
const authorizationMessage = getDaytonaAuthorizationErrorMessage(error);
|
|
10891
|
+
if (authorizationMessage !== void 0) {
|
|
10892
|
+
return authorizationMessage;
|
|
10893
|
+
}
|
|
10894
|
+
if (!(error instanceof DaytonaError) || error.statusCode === void 0) {
|
|
10895
|
+
return void 0;
|
|
10896
|
+
}
|
|
10897
|
+
const { statusCode } = error;
|
|
10898
|
+
if (statusCode === 429) {
|
|
10899
|
+
return void 0;
|
|
10900
|
+
}
|
|
10901
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
10902
|
+
return error.message;
|
|
10903
|
+
}
|
|
10904
|
+
return void 0;
|
|
10905
|
+
}
|
|
10889
10906
|
function toSandboxEnvironment({
|
|
10890
10907
|
external_ref,
|
|
10891
10908
|
manifest,
|
|
@@ -14547,10 +14564,10 @@ async function progressSandboxEnvironmentVersion({
|
|
|
14547
14564
|
});
|
|
14548
14565
|
}
|
|
14549
14566
|
} catch (error) {
|
|
14550
|
-
const status_reason =
|
|
14567
|
+
const status_reason = getDaytonaBuildFailureMessage(error);
|
|
14551
14568
|
if (status_reason !== void 0) {
|
|
14552
14569
|
await sandboxEnvironmentStore.markVersionFailed({ environment_version_id, status_reason });
|
|
14553
|
-
logger2.warn("Sandbox environment build failed
|
|
14570
|
+
logger2.warn("Sandbox environment build failed", {
|
|
14554
14571
|
environment_version_id,
|
|
14555
14572
|
status_reason
|
|
14556
14573
|
});
|
|
@@ -17218,7 +17235,8 @@ function createTurnResolver(deps) {
|
|
|
17218
17235
|
signal,
|
|
17219
17236
|
userRef,
|
|
17220
17237
|
session,
|
|
17221
|
-
turnMetadata
|
|
17238
|
+
turnMetadata,
|
|
17239
|
+
capabilitiesStore
|
|
17222
17240
|
} = deps;
|
|
17223
17241
|
const tenant_id = session.tenant_id;
|
|
17224
17242
|
const sessionId = session.session_id;
|
|
@@ -17313,7 +17331,8 @@ function createTurnResolver(deps) {
|
|
|
17313
17331
|
return record.manifest;
|
|
17314
17332
|
},
|
|
17315
17333
|
webSearchProvider,
|
|
17316
|
-
logger: logger2
|
|
17334
|
+
logger: logger2,
|
|
17335
|
+
rootCapabilities: () => capabilitiesStore.resolveCapabilities()
|
|
17317
17336
|
});
|
|
17318
17337
|
}
|
|
17319
17338
|
var titleSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
@@ -17437,7 +17456,8 @@ async function beginTurnExecution(params) {
|
|
|
17437
17456
|
turnId,
|
|
17438
17457
|
...sessionAgent.type === "reference" ? { agent: { id: sessionAgent.id, name: sessionAgent.name } } : {},
|
|
17439
17458
|
...requestHeaders === void 0 ? {} : { requestHeaders }
|
|
17440
|
-
}
|
|
17459
|
+
},
|
|
17460
|
+
capabilitiesStore: deps.capabilitiesStore
|
|
17441
17461
|
});
|
|
17442
17462
|
const title = session.record.last_turn_details ? void 0 : deriveSessionTitle(input);
|
|
17443
17463
|
const turn = await session.createTurn({
|
|
@@ -17752,6 +17772,8 @@ function createTurnsRouter(deps) {
|
|
|
17752
17772
|
...referencedAgent !== void 0 ? { runAsAgent: referencedAgent } : {}
|
|
17753
17773
|
}),
|
|
17754
17774
|
skillStore: deps.resolveTurnSkillsStore({ c, allowInlineResources }),
|
|
17775
|
+
// Parsed here, before a turn id is minted.
|
|
17776
|
+
capabilitiesStore: deps.resolveCapabilitiesStore({ c }),
|
|
17755
17777
|
agentStore: deps.resolveAgentStore(c),
|
|
17756
17778
|
sandboxProviderStore: deps.resolveSandboxProviderStore(c),
|
|
17757
17779
|
sandboxEnvironmentStore: deps.sandboxEnvironmentStore,
|
|
@@ -17958,6 +17980,7 @@ async function startScheduleRunOnRequest(params) {
|
|
|
17958
17980
|
sandboxEnvironmentStore: deps.sandboxEnvironmentStore,
|
|
17959
17981
|
webSearchProviderStore: deps.resolveWebSearchProviderStore(c),
|
|
17960
17982
|
skillStore: deps.resolveTurnSkillsStore({}),
|
|
17983
|
+
capabilitiesStore: deps.resolveCapabilitiesStore({}),
|
|
17961
17984
|
logger: deps.logger
|
|
17962
17985
|
}
|
|
17963
17986
|
});
|
|
@@ -20427,7 +20450,8 @@ function createServerApp(deps) {
|
|
|
20427
20450
|
sandboxEnvironmentStore: deps.sandboxEnvironmentStore,
|
|
20428
20451
|
resolveWebSearchProviderStore: deps.resolveWebSearchProviderStore,
|
|
20429
20452
|
activeTurns: deps.activeTurns,
|
|
20430
|
-
resolveTurnSkillsStore: deps.resolveTurnSkillsStore
|
|
20453
|
+
resolveTurnSkillsStore: deps.resolveTurnSkillsStore,
|
|
20454
|
+
resolveCapabilitiesStore: deps.resolveCapabilitiesStore
|
|
20431
20455
|
};
|
|
20432
20456
|
const httpMetrics = deps.httpMetrics;
|
|
20433
20457
|
app.use("*", createRequestLogContextMiddleware());
|
|
@@ -20686,6 +20710,7 @@ function createServerApp(deps) {
|
|
|
20686
20710
|
resolveModelProviderStore: deps.resolveModelProviderStore,
|
|
20687
20711
|
resolveMcpServerStore: deps.resolveMcpServerStore,
|
|
20688
20712
|
resolveTurnSkillsStore: deps.resolveTurnSkillsStore,
|
|
20713
|
+
resolveCapabilitiesStore: deps.resolveCapabilitiesStore,
|
|
20689
20714
|
resolveAgentStore: deps.resolveAgentStore,
|
|
20690
20715
|
eventSubscriptions: deps.eventSubscriptions,
|
|
20691
20716
|
resolveSandboxProviderStore: deps.resolveSandboxProviderStore,
|
|
@@ -22599,21 +22624,127 @@ function unsupportedInlineSkillWrite() {
|
|
|
22599
22624
|
);
|
|
22600
22625
|
}
|
|
22601
22626
|
|
|
22602
|
-
// src/truefoundry/
|
|
22627
|
+
// src/truefoundry/inlineTools.ts
|
|
22628
|
+
import { ToolSchema as McpToolSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
22629
|
+
import {
|
|
22630
|
+
ClientSideTool,
|
|
22631
|
+
toolResultResponse
|
|
22632
|
+
} from "@truefoundry/trueforge-core/core";
|
|
22603
22633
|
import { HTTPException as HTTPException25 } from "hono/http-exception";
|
|
22604
22634
|
import { z as z44 } from "zod";
|
|
22635
|
+
var X_TFG_TOOLS = "x-tfg-tools";
|
|
22636
|
+
var MAX_TFG_TOOLS = 16;
|
|
22637
|
+
var MAX_TFG_TOOLS_HEADER_LENGTH = 16e3;
|
|
22638
|
+
var InlineToolsHeaderSchema = z44.array(McpToolSchema);
|
|
22639
|
+
function assertTfgToolsHeaderAllowed(input) {
|
|
22640
|
+
if (!input.isTrueFoundryMode) {
|
|
22641
|
+
throw new HTTPException25(400, { message: `${X_TFG_TOOLS} requires TrueFoundry mode` });
|
|
22642
|
+
}
|
|
22643
|
+
}
|
|
22644
|
+
function parseTfgTools(raw) {
|
|
22645
|
+
if (raw.length > MAX_TFG_TOOLS_HEADER_LENGTH) {
|
|
22646
|
+
throw new HTTPException25(400, { message: `${X_TFG_TOOLS} is too large` });
|
|
22647
|
+
}
|
|
22648
|
+
let decoded;
|
|
22649
|
+
try {
|
|
22650
|
+
decoded = JSON.parse(raw);
|
|
22651
|
+
} catch (error) {
|
|
22652
|
+
throw new HTTPException25(400, { message: `${X_TFG_TOOLS} must be a JSON array`, cause: error });
|
|
22653
|
+
}
|
|
22654
|
+
if (!Array.isArray(decoded)) {
|
|
22655
|
+
throw new HTTPException25(400, { message: `${X_TFG_TOOLS} must be a JSON array of tool definitions` });
|
|
22656
|
+
}
|
|
22657
|
+
if (decoded.length > MAX_TFG_TOOLS) {
|
|
22658
|
+
throw new HTTPException25(400, { message: `${X_TFG_TOOLS} lists more than ${String(MAX_TFG_TOOLS)} tools` });
|
|
22659
|
+
}
|
|
22660
|
+
const parsed = InlineToolsHeaderSchema.safeParse(decoded);
|
|
22661
|
+
if (!parsed.success) {
|
|
22662
|
+
throw new HTTPException25(400, {
|
|
22663
|
+
message: tfgToolsSchemaErrorMessage(parsed.error),
|
|
22664
|
+
cause: parsed.error
|
|
22665
|
+
});
|
|
22666
|
+
}
|
|
22667
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22668
|
+
for (const [index, tool] of parsed.data.entries()) {
|
|
22669
|
+
if (seen.has(tool.name)) {
|
|
22670
|
+
throw new HTTPException25(400, {
|
|
22671
|
+
message: `${X_TFG_TOOLS}[${String(index)}] name "${tool.name}" is listed more than once`
|
|
22672
|
+
});
|
|
22673
|
+
}
|
|
22674
|
+
seen.add(tool.name);
|
|
22675
|
+
}
|
|
22676
|
+
return parsed.data;
|
|
22677
|
+
}
|
|
22678
|
+
function capabilitiesStoreFromHeader(input) {
|
|
22679
|
+
if (input.header === void 0) {
|
|
22680
|
+
return { resolveCapabilities: () => [] };
|
|
22681
|
+
}
|
|
22682
|
+
assertTfgToolsHeaderAllowed({ isTrueFoundryMode: input.isTrueFoundryMode });
|
|
22683
|
+
const tools = parseTfgTools(input.header);
|
|
22684
|
+
return {
|
|
22685
|
+
resolveCapabilities: () => tools.length === 0 ? [] : [tfgToolsCapability(tools)]
|
|
22686
|
+
};
|
|
22687
|
+
}
|
|
22688
|
+
function tfgToolsCapability(tools) {
|
|
22689
|
+
return {
|
|
22690
|
+
systemToolSets: [new InlineClientSideTools(tools)]
|
|
22691
|
+
};
|
|
22692
|
+
}
|
|
22693
|
+
function tfgToolsSchemaErrorMessage(error) {
|
|
22694
|
+
const issue = error.issues[0];
|
|
22695
|
+
if (issue === void 0) {
|
|
22696
|
+
return `${X_TFG_TOOLS} must be an array of MCP tool definitions`;
|
|
22697
|
+
}
|
|
22698
|
+
return `${X_TFG_TOOLS}${tfgToolsIssuePath(issue.path)} ${issue.message}`;
|
|
22699
|
+
}
|
|
22700
|
+
function tfgToolsIssuePath(path7) {
|
|
22701
|
+
let rendered = "";
|
|
22702
|
+
for (const part of path7) {
|
|
22703
|
+
if (typeof part === "number") {
|
|
22704
|
+
rendered += `[${String(part)}]`;
|
|
22705
|
+
} else {
|
|
22706
|
+
rendered += `.${String(part)}`;
|
|
22707
|
+
}
|
|
22708
|
+
}
|
|
22709
|
+
return rendered;
|
|
22710
|
+
}
|
|
22711
|
+
var InlineClientSideTools = class extends ClientSideTool {
|
|
22712
|
+
name = X_TFG_TOOLS;
|
|
22713
|
+
displayName = "TfgTools";
|
|
22714
|
+
tracingEnabled = false;
|
|
22715
|
+
#tools;
|
|
22716
|
+
constructor(tools) {
|
|
22717
|
+
super();
|
|
22718
|
+
this.#tools = tools.map((tool) => ({
|
|
22719
|
+
...tool,
|
|
22720
|
+
execute: () => Promise.resolve(
|
|
22721
|
+
toolResultResponse({
|
|
22722
|
+
text: "This tool requires client-side execution and cannot be run server-side.",
|
|
22723
|
+
isError: true
|
|
22724
|
+
})
|
|
22725
|
+
)
|
|
22726
|
+
}));
|
|
22727
|
+
}
|
|
22728
|
+
getTools() {
|
|
22729
|
+
return this.#tools;
|
|
22730
|
+
}
|
|
22731
|
+
};
|
|
22732
|
+
|
|
22733
|
+
// src/truefoundry/perServerMcpHeaders.ts
|
|
22734
|
+
import { HTTPException as HTTPException26 } from "hono/http-exception";
|
|
22735
|
+
import { z as z45 } from "zod";
|
|
22605
22736
|
var X_TFG_MCP_HEADERS = "x-tfg-mcp-headers";
|
|
22606
|
-
var PerServerMcpHeadersSchema =
|
|
22737
|
+
var PerServerMcpHeadersSchema = z45.record(z45.string().min(1), z45.record(z45.string().min(1), z45.string()));
|
|
22607
22738
|
function parsePerServerMcpHeaders(raw) {
|
|
22608
22739
|
let decoded;
|
|
22609
22740
|
try {
|
|
22610
22741
|
decoded = JSON.parse(raw);
|
|
22611
22742
|
} catch (error) {
|
|
22612
|
-
throw new
|
|
22743
|
+
throw new HTTPException26(400, { message: `${X_TFG_MCP_HEADERS} must be a JSON object`, cause: error });
|
|
22613
22744
|
}
|
|
22614
22745
|
const parsed = PerServerMcpHeadersSchema.safeParse(decoded);
|
|
22615
22746
|
if (!parsed.success) {
|
|
22616
|
-
throw new
|
|
22747
|
+
throw new HTTPException26(400, {
|
|
22617
22748
|
message: `${X_TFG_MCP_HEADERS} must map each MCP server name to a header map`
|
|
22618
22749
|
});
|
|
22619
22750
|
}
|
|
@@ -22633,10 +22764,10 @@ import {
|
|
|
22633
22764
|
getOperationMetrics as getOperationMetrics4,
|
|
22634
22765
|
httpStatusClass
|
|
22635
22766
|
} from "@truefoundry/trueforge-core/core";
|
|
22636
|
-
import { HTTPException as
|
|
22767
|
+
import { HTTPException as HTTPException27 } from "hono/http-exception";
|
|
22637
22768
|
import { LRUCache } from "lru-cache";
|
|
22638
22769
|
import { fetch as undiciFetch3 } from "undici";
|
|
22639
|
-
import { z as
|
|
22770
|
+
import { z as z48 } from "zod";
|
|
22640
22771
|
|
|
22641
22772
|
// src/truefoundry/internalTls.ts
|
|
22642
22773
|
function normalizeInternalTlsUrl(input) {
|
|
@@ -22650,20 +22781,20 @@ function createInternalTlsDispatcher(options) {
|
|
|
22650
22781
|
}
|
|
22651
22782
|
|
|
22652
22783
|
// src/truefoundry/mapSfyAgentSkills.ts
|
|
22653
|
-
import { z as
|
|
22654
|
-
var SfyRegistryManifestSchema =
|
|
22784
|
+
import { z as z46 } from "zod";
|
|
22785
|
+
var SfyRegistryManifestSchema = z46.object({
|
|
22655
22786
|
// Display label only — not TF ResourceName / DNS-label rules.
|
|
22656
|
-
name:
|
|
22657
|
-
version:
|
|
22787
|
+
name: z46.string().min(1),
|
|
22788
|
+
version: z46.number().int().positive(),
|
|
22658
22789
|
// SFY field is `ml_repo`; TrueForge wire is `repository_name`.
|
|
22659
|
-
ml_repo:
|
|
22660
|
-
source:
|
|
22661
|
-
description:
|
|
22790
|
+
ml_repo: z46.string().min(1),
|
|
22791
|
+
source: z46.object({
|
|
22792
|
+
description: z46.string().min(1).optional()
|
|
22662
22793
|
}).optional()
|
|
22663
22794
|
});
|
|
22664
|
-
var SfyRegistrySkillSchema =
|
|
22665
|
-
latest_version:
|
|
22666
|
-
fqn:
|
|
22795
|
+
var SfyRegistrySkillSchema = z46.object({
|
|
22796
|
+
latest_version: z46.object({
|
|
22797
|
+
fqn: z46.string().min(1),
|
|
22667
22798
|
manifest: SfyRegistryManifestSchema
|
|
22668
22799
|
})
|
|
22669
22800
|
}).transform(({ latest_version }) => ({
|
|
@@ -22674,20 +22805,20 @@ var SfyRegistrySkillSchema = z45.object({
|
|
|
22674
22805
|
repository_name: latest_version.manifest.ml_repo,
|
|
22675
22806
|
version: latest_version.manifest.version
|
|
22676
22807
|
}));
|
|
22677
|
-
var SfyRegistrySkillVersionSchema =
|
|
22678
|
-
agent_skill_id:
|
|
22679
|
-
fqn:
|
|
22808
|
+
var SfyRegistrySkillVersionSchema = z46.object({
|
|
22809
|
+
agent_skill_id: z46.string().min(1),
|
|
22810
|
+
fqn: z46.string().min(1),
|
|
22680
22811
|
manifest: SfyRegistryManifestSchema
|
|
22681
22812
|
});
|
|
22682
|
-
var ResolvedAgentSkillVersionSchema =
|
|
22683
|
-
fqn:
|
|
22684
|
-
name:
|
|
22685
|
-
description:
|
|
22686
|
-
skill_md_content:
|
|
22687
|
-
presigned_url:
|
|
22813
|
+
var ResolvedAgentSkillVersionSchema = z46.object({
|
|
22814
|
+
fqn: z46.string().min(1),
|
|
22815
|
+
name: z46.string().min(1),
|
|
22816
|
+
description: z46.string().min(1),
|
|
22817
|
+
skill_md_content: z46.string().nullable().optional(),
|
|
22818
|
+
presigned_url: z46.string().min(1).optional()
|
|
22688
22819
|
});
|
|
22689
|
-
var ResolveAgentSkillVersionsResponseSchema =
|
|
22690
|
-
skills:
|
|
22820
|
+
var ResolveAgentSkillVersionsResponseSchema = z46.object({
|
|
22821
|
+
skills: z46.array(ResolvedAgentSkillVersionSchema)
|
|
22691
22822
|
});
|
|
22692
22823
|
function mapSfyRegistrySkills(rows) {
|
|
22693
22824
|
return rows.map((row) => SfyRegistrySkillSchema.parse(row));
|
|
@@ -22711,48 +22842,48 @@ function mapResolvedAgentSkillVersions(payload) {
|
|
|
22711
22842
|
}
|
|
22712
22843
|
|
|
22713
22844
|
// src/truefoundry/mapSfyMcpServers.ts
|
|
22714
|
-
import { z as
|
|
22845
|
+
import { z as z47 } from "zod";
|
|
22715
22846
|
var MCP_PROXY_BASE_URL_TEMPLATE = "{{mcpProxyBaseURL}}";
|
|
22716
|
-
var IsoInstantSchema =
|
|
22847
|
+
var IsoInstantSchema = z47.union([z47.string().min(1), z47.date()]).transform((value, ctx) => {
|
|
22717
22848
|
if (value instanceof Date) {
|
|
22718
22849
|
if (!Number.isFinite(value.getTime())) {
|
|
22719
22850
|
ctx.addIssue({ code: "custom", message: "Invalid Date" });
|
|
22720
|
-
return
|
|
22851
|
+
return z47.NEVER;
|
|
22721
22852
|
}
|
|
22722
22853
|
return value.toISOString();
|
|
22723
22854
|
}
|
|
22724
22855
|
const ms = Date.parse(value);
|
|
22725
22856
|
if (!Number.isFinite(ms)) {
|
|
22726
22857
|
ctx.addIssue({ code: "custom", message: "Invalid ISO timestamp" });
|
|
22727
|
-
return
|
|
22858
|
+
return z47.NEVER;
|
|
22728
22859
|
}
|
|
22729
22860
|
return new Date(ms).toISOString();
|
|
22730
22861
|
});
|
|
22731
|
-
var SfyMcpServerRowSchema =
|
|
22732
|
-
id:
|
|
22733
|
-
name:
|
|
22734
|
-
proxyUrl:
|
|
22862
|
+
var SfyMcpServerRowSchema = z47.object({
|
|
22863
|
+
id: z47.string().min(1),
|
|
22864
|
+
name: z47.string().min(1),
|
|
22865
|
+
proxyUrl: z47.string().min(1),
|
|
22735
22866
|
createdAt: IsoInstantSchema,
|
|
22736
22867
|
updatedAt: IsoInstantSchema,
|
|
22737
|
-
manifest:
|
|
22738
|
-
description:
|
|
22739
|
-
auth_data:
|
|
22740
|
-
type:
|
|
22868
|
+
manifest: z47.object({
|
|
22869
|
+
description: z47.string().min(1).optional(),
|
|
22870
|
+
auth_data: z47.object({
|
|
22871
|
+
type: z47.string().min(1).optional()
|
|
22741
22872
|
}).optional()
|
|
22742
22873
|
}).optional()
|
|
22743
22874
|
});
|
|
22744
|
-
var SfyMcpAuthStatusAuthenticatedSchema =
|
|
22745
|
-
var SfyMcpAuthStatusNotRequiredSchema =
|
|
22746
|
-
var SfyMcpAuthStatusRequiredSchema =
|
|
22875
|
+
var SfyMcpAuthStatusAuthenticatedSchema = z47.object({ status: z47.literal("authenticated") });
|
|
22876
|
+
var SfyMcpAuthStatusNotRequiredSchema = z47.object({ status: z47.literal("authentication_not_required") });
|
|
22877
|
+
var SfyMcpAuthStatusRequiredSchema = z47.object({ status: z47.literal("authentication_required") });
|
|
22747
22878
|
var SfyMcpAuthorizeRequiredSchema = SfyMcpAuthStatusRequiredSchema.extend({
|
|
22748
|
-
authorization_endpoint:
|
|
22879
|
+
authorization_endpoint: z47.url()
|
|
22749
22880
|
});
|
|
22750
|
-
var SfyMcpAuthStatusSchema =
|
|
22881
|
+
var SfyMcpAuthStatusSchema = z47.discriminatedUnion("status", [
|
|
22751
22882
|
SfyMcpAuthStatusAuthenticatedSchema,
|
|
22752
22883
|
SfyMcpAuthStatusRequiredSchema,
|
|
22753
22884
|
SfyMcpAuthStatusNotRequiredSchema
|
|
22754
22885
|
]);
|
|
22755
|
-
var SfyMcpAuthorizeResultSchema =
|
|
22886
|
+
var SfyMcpAuthorizeResultSchema = z47.discriminatedUnion("status", [
|
|
22756
22887
|
SfyMcpAuthStatusAuthenticatedSchema,
|
|
22757
22888
|
SfyMcpAuthorizeRequiredSchema,
|
|
22758
22889
|
SfyMcpAuthStatusNotRequiredSchema
|
|
@@ -22826,32 +22957,32 @@ var VEND_TOKEN_PATH = "internal/vend-token";
|
|
|
22826
22957
|
var SUBJECTS_PEEK_PATH = "v1/subjects/peek";
|
|
22827
22958
|
var AGENT_SKILLS_PAGE_SIZE = 100;
|
|
22828
22959
|
var AGENT_SKILL_RESOLVE_CHUNK_SIZE = 50;
|
|
22829
|
-
var SessionSubjectSchema =
|
|
22830
|
-
subjectId:
|
|
22831
|
-
subjectType:
|
|
22832
|
-
subjectDisplayName:
|
|
22833
|
-
subjectSlug:
|
|
22960
|
+
var SessionSubjectSchema = z48.object({
|
|
22961
|
+
subjectId: z48.string().min(1),
|
|
22962
|
+
subjectType: z48.string().min(1),
|
|
22963
|
+
subjectDisplayName: z48.string().nullable().optional(),
|
|
22964
|
+
subjectSlug: z48.string().nullable().optional()
|
|
22834
22965
|
});
|
|
22835
|
-
var GetSessionUserSchema =
|
|
22836
|
-
tenantName:
|
|
22837
|
-
roles:
|
|
22966
|
+
var GetSessionUserSchema = z48.object({
|
|
22967
|
+
tenantName: z48.string().min(1),
|
|
22968
|
+
roles: z48.array(z48.string()),
|
|
22838
22969
|
subject: SessionSubjectSchema
|
|
22839
22970
|
});
|
|
22840
|
-
var GetSessionUnauthenticatedSchema =
|
|
22841
|
-
user:
|
|
22971
|
+
var GetSessionUnauthenticatedSchema = z48.object({
|
|
22972
|
+
user: z48.null()
|
|
22842
22973
|
});
|
|
22843
|
-
var GetSessionAuthenticatedSchema =
|
|
22974
|
+
var GetSessionAuthenticatedSchema = z48.object({
|
|
22844
22975
|
user: GetSessionUserSchema
|
|
22845
22976
|
});
|
|
22846
|
-
var GetSessionWireSchema =
|
|
22847
|
-
var TenantControlPlaneUrlSchema =
|
|
22848
|
-
controlPlaneURL:
|
|
22977
|
+
var GetSessionWireSchema = z48.union([GetSessionUnauthenticatedSchema, GetSessionAuthenticatedSchema]);
|
|
22978
|
+
var TenantControlPlaneUrlSchema = z48.object({
|
|
22979
|
+
controlPlaneURL: z48.url()
|
|
22849
22980
|
});
|
|
22850
|
-
var ListResponseSchema =
|
|
22851
|
-
|
|
22852
|
-
|
|
22853
|
-
data:
|
|
22854
|
-
pagination:
|
|
22981
|
+
var ListResponseSchema = z48.union([
|
|
22982
|
+
z48.array(z48.unknown()),
|
|
22983
|
+
z48.object({
|
|
22984
|
+
data: z48.array(z48.unknown()).catch([]),
|
|
22985
|
+
pagination: z48.object({ total: z48.number().optional() }).optional()
|
|
22855
22986
|
})
|
|
22856
22987
|
]);
|
|
22857
22988
|
var SERVICE_FOUNDRY_OPERATIONS = {
|
|
@@ -22874,34 +23005,34 @@ var SERVICE_FOUNDRY_OPERATIONS = {
|
|
|
22874
23005
|
vendToken: "vend_token",
|
|
22875
23006
|
peekUsers: "users"
|
|
22876
23007
|
};
|
|
22877
|
-
var ServiceFoundryErrorSchema =
|
|
22878
|
-
message:
|
|
23008
|
+
var ServiceFoundryErrorSchema = z48.object({
|
|
23009
|
+
message: z48.union([z48.string(), z48.array(z48.string())]).optional()
|
|
22879
23010
|
});
|
|
22880
|
-
var PutRemoteAgentResponseSchema =
|
|
22881
|
-
agentId:
|
|
23011
|
+
var PutRemoteAgentResponseSchema = z48.object({
|
|
23012
|
+
agentId: z48.string().min(1)
|
|
22882
23013
|
});
|
|
22883
|
-
var AgentPermissionSchema =
|
|
22884
|
-
var AgentPermissionsSchema =
|
|
22885
|
-
|
|
22886
|
-
|
|
23014
|
+
var AgentPermissionSchema = z48.enum(["READ_AGENT", "USE_AGENT", "MANAGE_AGENT", "DELETE_AGENT"]);
|
|
23015
|
+
var AgentPermissionsSchema = z48.record(
|
|
23016
|
+
z48.string(),
|
|
23017
|
+
z48.array(z48.string()).transform(
|
|
22887
23018
|
(permissions) => permissions.flatMap((permission) => {
|
|
22888
23019
|
const parsed = AgentPermissionSchema.safeParse(permission);
|
|
22889
23020
|
return parsed.success ? [parsed.data] : [];
|
|
22890
23021
|
})
|
|
22891
23022
|
)
|
|
22892
23023
|
);
|
|
22893
|
-
var VendTokenResponseSchema =
|
|
22894
|
-
subjectToken:
|
|
22895
|
-
actorToken:
|
|
23024
|
+
var VendTokenResponseSchema = z48.object({
|
|
23025
|
+
subjectToken: z48.string().min(1),
|
|
23026
|
+
actorToken: z48.string().min(1)
|
|
22896
23027
|
});
|
|
22897
|
-
var PeekUserSchema =
|
|
22898
|
-
id:
|
|
22899
|
-
name:
|
|
22900
|
-
email:
|
|
23028
|
+
var PeekUserSchema = z48.object({
|
|
23029
|
+
id: z48.string().min(1),
|
|
23030
|
+
name: z48.string().nullish(),
|
|
23031
|
+
email: z48.string().min(1)
|
|
22901
23032
|
});
|
|
22902
|
-
var PeekUsersResponseSchema =
|
|
22903
|
-
users:
|
|
22904
|
-
totalUsers:
|
|
23033
|
+
var PeekUsersResponseSchema = z48.object({
|
|
23034
|
+
users: z48.array(PeekUserSchema),
|
|
23035
|
+
totalUsers: z48.number().int().nonnegative()
|
|
22905
23036
|
});
|
|
22906
23037
|
async function readServiceFoundryErrorMessage(response) {
|
|
22907
23038
|
const body = await response.json().catch(() => void 0);
|
|
@@ -23027,7 +23158,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23027
23158
|
...extractErrorLogFields8(parsed.error),
|
|
23028
23159
|
reportable_error: { error: parsed.error }
|
|
23029
23160
|
});
|
|
23030
|
-
throw new
|
|
23161
|
+
throw new HTTPException27(424, {
|
|
23031
23162
|
message: "TrueFoundry ServiceFoundry put remote agent returned an unexpected response",
|
|
23032
23163
|
cause: parsed.error
|
|
23033
23164
|
});
|
|
@@ -23103,7 +23234,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23103
23234
|
this.#logger.error("TrueFoundry ServiceFoundry resolve agent-skill-versions returned an unexpected response", {
|
|
23104
23235
|
...extractErrorLogFields8(error)
|
|
23105
23236
|
});
|
|
23106
|
-
throw new
|
|
23237
|
+
throw new HTTPException27(500, {
|
|
23107
23238
|
message: "TrueFoundry ServiceFoundry resolve agent-skill-versions returned an unexpected response",
|
|
23108
23239
|
cause: error
|
|
23109
23240
|
});
|
|
@@ -23157,7 +23288,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23157
23288
|
...extractErrorLogFields8(error),
|
|
23158
23289
|
reportable_error: { error, extra: { mcp_server_id: input.mcpServerId } }
|
|
23159
23290
|
});
|
|
23160
|
-
throw new
|
|
23291
|
+
throw new HTTPException27(424, {
|
|
23161
23292
|
message: "TrueFoundry ServiceFoundry MCP authorize returned an unexpected response",
|
|
23162
23293
|
cause: error
|
|
23163
23294
|
});
|
|
@@ -23182,7 +23313,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23182
23313
|
...extractErrorLogFields8(error),
|
|
23183
23314
|
reportable_error: { error, extra: { mcp_server_id: input.mcpServerId } }
|
|
23184
23315
|
});
|
|
23185
|
-
throw new
|
|
23316
|
+
throw new HTTPException27(424, {
|
|
23186
23317
|
message: "TrueFoundry ServiceFoundry MCP auth status returned an unexpected response",
|
|
23187
23318
|
cause: error
|
|
23188
23319
|
});
|
|
@@ -23216,23 +23347,23 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23216
23347
|
method: "GET"
|
|
23217
23348
|
});
|
|
23218
23349
|
} catch (error) {
|
|
23219
|
-
if (error instanceof
|
|
23350
|
+
if (error instanceof HTTPException27 && (error.status === 401 || error.status === 403)) {
|
|
23220
23351
|
throw error;
|
|
23221
23352
|
}
|
|
23222
|
-
throw new
|
|
23353
|
+
throw new HTTPException27(500, {
|
|
23223
23354
|
message: "TrueFoundry ServiceFoundry session request failed",
|
|
23224
23355
|
cause: error
|
|
23225
23356
|
});
|
|
23226
23357
|
}
|
|
23227
23358
|
const parsed = GetSessionWireSchema.safeParse(payload);
|
|
23228
23359
|
if (!parsed.success) {
|
|
23229
|
-
throw new
|
|
23360
|
+
throw new HTTPException27(500, {
|
|
23230
23361
|
message: "TrueFoundry ServiceFoundry session response was malformed",
|
|
23231
23362
|
cause: parsed.error
|
|
23232
23363
|
});
|
|
23233
23364
|
}
|
|
23234
23365
|
if (parsed.data.user === null) {
|
|
23235
|
-
throw new
|
|
23366
|
+
throw new HTTPException27(401, { message: "Authentication required" });
|
|
23236
23367
|
}
|
|
23237
23368
|
return parsed.data;
|
|
23238
23369
|
}
|
|
@@ -23255,14 +23386,14 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23255
23386
|
});
|
|
23256
23387
|
} catch (error) {
|
|
23257
23388
|
const causeString = error instanceof Error ? error.message : String(error);
|
|
23258
|
-
throw new
|
|
23389
|
+
throw new HTTPException27(500, {
|
|
23259
23390
|
message: `TrueFoundry ServiceFoundry session request failed: ${causeString}`,
|
|
23260
23391
|
cause: error
|
|
23261
23392
|
});
|
|
23262
23393
|
}
|
|
23263
23394
|
const parsed = TenantControlPlaneUrlSchema.safeParse(payload);
|
|
23264
23395
|
if (!parsed.success) {
|
|
23265
|
-
throw new
|
|
23396
|
+
throw new HTTPException27(500, {
|
|
23266
23397
|
message: "TrueFoundry ServiceFoundry session response was malformed",
|
|
23267
23398
|
cause: parsed.error
|
|
23268
23399
|
});
|
|
@@ -23288,7 +23419,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23288
23419
|
...extractErrorLogFields8(parsed.error),
|
|
23289
23420
|
reportable_error: { error: parsed.error }
|
|
23290
23421
|
});
|
|
23291
|
-
throw new
|
|
23422
|
+
throw new HTTPException27(424, {
|
|
23292
23423
|
message: "TrueFoundry ServiceFoundry agent permissions response was malformed",
|
|
23293
23424
|
cause: parsed.error
|
|
23294
23425
|
});
|
|
@@ -23306,13 +23437,13 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23306
23437
|
accessToken: input.accessToken,
|
|
23307
23438
|
method: "GET"
|
|
23308
23439
|
});
|
|
23309
|
-
const parsed =
|
|
23440
|
+
const parsed = z48.array(z48.string()).safeParse(payload);
|
|
23310
23441
|
if (!parsed.success) {
|
|
23311
23442
|
this.#logger.error("TrueFoundry ServiceFoundry tenant permissions response was malformed", {
|
|
23312
23443
|
...extractErrorLogFields8(parsed.error),
|
|
23313
23444
|
reportable_error: { error: parsed.error }
|
|
23314
23445
|
});
|
|
23315
|
-
throw new
|
|
23446
|
+
throw new HTTPException27(424, {
|
|
23316
23447
|
message: "TrueFoundry ServiceFoundry tenant permissions response was malformed",
|
|
23317
23448
|
cause: parsed.error
|
|
23318
23449
|
});
|
|
@@ -23344,7 +23475,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23344
23475
|
this.#logger.error("TrueFoundry ServiceFoundry subjects response was malformed", {
|
|
23345
23476
|
...extractErrorLogFields8(parsed.error)
|
|
23346
23477
|
});
|
|
23347
|
-
throw new
|
|
23478
|
+
throw new HTTPException27(424, {
|
|
23348
23479
|
message: "TrueFoundry ServiceFoundry subjects response was malformed",
|
|
23349
23480
|
cause: parsed.error
|
|
23350
23481
|
});
|
|
@@ -23376,7 +23507,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23376
23507
|
...extractErrorLogFields8(parsed.error),
|
|
23377
23508
|
reportable_error: { error: parsed.error }
|
|
23378
23509
|
});
|
|
23379
|
-
throw new
|
|
23510
|
+
throw new HTTPException27(424, {
|
|
23380
23511
|
message: "TrueFoundry ServiceFoundry vend-token response was malformed",
|
|
23381
23512
|
cause: parsed.error
|
|
23382
23513
|
});
|
|
@@ -23390,7 +23521,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23390
23521
|
...extractErrorLogFields8(parsed.error),
|
|
23391
23522
|
reportable_error: { error: parsed.error }
|
|
23392
23523
|
});
|
|
23393
|
-
throw new
|
|
23524
|
+
throw new HTTPException27(424, {
|
|
23394
23525
|
message: "TrueFoundry ServiceFoundry server returned an unexpected list response",
|
|
23395
23526
|
cause: parsed.error
|
|
23396
23527
|
});
|
|
@@ -23447,7 +23578,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23447
23578
|
timedOut,
|
|
23448
23579
|
...extractErrorLogFields8(error)
|
|
23449
23580
|
});
|
|
23450
|
-
throw new
|
|
23581
|
+
throw new HTTPException27(500, {
|
|
23451
23582
|
message: timedOut ? `TrueFoundry ServiceFoundry server request timed out after ${String(timeoutMs / 1e3)}s` : "TrueFoundry ServiceFoundry server request failed",
|
|
23452
23583
|
cause: error
|
|
23453
23584
|
});
|
|
@@ -23461,7 +23592,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23461
23592
|
if (response.status === 401 || response.status === 403) {
|
|
23462
23593
|
record("error", response.status);
|
|
23463
23594
|
const detail = await readServiceFoundryErrorMessage(response);
|
|
23464
|
-
throw new
|
|
23595
|
+
throw new HTTPException27(response.status, {
|
|
23465
23596
|
message: `TrueFoundry ServiceFoundry server rejected the request: ${detail ?? `HTTP ${String(response.status)}`}`
|
|
23466
23597
|
});
|
|
23467
23598
|
}
|
|
@@ -23472,7 +23603,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23472
23603
|
if (!response.ok) {
|
|
23473
23604
|
record("error", response.status);
|
|
23474
23605
|
const detail = await readServiceFoundryErrorMessage(response);
|
|
23475
|
-
throw new
|
|
23606
|
+
throw new HTTPException27(424, {
|
|
23476
23607
|
message: `TrueFoundry ServiceFoundry server request failed: ${detail ?? `HTTP ${String(response.status)}`}`
|
|
23477
23608
|
});
|
|
23478
23609
|
}
|
|
@@ -23496,7 +23627,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
23496
23627
|
...extractErrorLogFields8(error),
|
|
23497
23628
|
reportable_error: { error }
|
|
23498
23629
|
});
|
|
23499
|
-
throw new
|
|
23630
|
+
throw new HTTPException27(424, {
|
|
23500
23631
|
message: "TrueFoundry ServiceFoundry server returned non-JSON",
|
|
23501
23632
|
cause: error
|
|
23502
23633
|
});
|
|
@@ -23708,7 +23839,7 @@ var TrueFoundryAgentStore = class {
|
|
|
23708
23839
|
};
|
|
23709
23840
|
|
|
23710
23841
|
// src/truefoundry/TrueFoundryAuthorizer.ts
|
|
23711
|
-
import { HTTPException as
|
|
23842
|
+
import { HTTPException as HTTPException28 } from "hono/http-exception";
|
|
23712
23843
|
var permissionByAction = {
|
|
23713
23844
|
read: "READ_AGENT",
|
|
23714
23845
|
use: "USE_AGENT",
|
|
@@ -23729,7 +23860,7 @@ function toResourcePermissions(permissions) {
|
|
|
23729
23860
|
}
|
|
23730
23861
|
function requireUserCredential(context) {
|
|
23731
23862
|
if (context.user_credential === null) {
|
|
23732
|
-
throw new
|
|
23863
|
+
throw new HTTPException28(401, { message: "Authentication token required for agent authorization" });
|
|
23733
23864
|
}
|
|
23734
23865
|
return context.user_credential;
|
|
23735
23866
|
}
|
|
@@ -23805,32 +23936,32 @@ var TrueFoundryAuthorizer = class {
|
|
|
23805
23936
|
|
|
23806
23937
|
// src/truefoundry/TrueFoundryMcpServerStore.ts
|
|
23807
23938
|
import { McpConnectionError as McpConnectionError6 } from "@truefoundry/trueforge-core/core";
|
|
23808
|
-
import { HTTPException as
|
|
23939
|
+
import { HTTPException as HTTPException30 } from "hono/http-exception";
|
|
23809
23940
|
init_config();
|
|
23810
23941
|
init_mcpServerStore();
|
|
23811
23942
|
|
|
23812
23943
|
// src/truefoundry/mapEnabledModels.ts
|
|
23813
23944
|
init_config();
|
|
23814
23945
|
import { SUPPORTED_REASONING_EFFORTS as SUPPORTED_REASONING_EFFORTS3 } from "@truefoundry/trueforge-core/core";
|
|
23815
|
-
import { HTTPException as
|
|
23816
|
-
import { z as
|
|
23817
|
-
var ModelParamSchema =
|
|
23818
|
-
key:
|
|
23819
|
-
supportedValues:
|
|
23946
|
+
import { HTTPException as HTTPException29 } from "hono/http-exception";
|
|
23947
|
+
import { z as z49 } from "zod";
|
|
23948
|
+
var ModelParamSchema = z49.object({
|
|
23949
|
+
key: z49.string(),
|
|
23950
|
+
supportedValues: z49.array(z49.string()).optional()
|
|
23820
23951
|
});
|
|
23821
|
-
var MetadataSchema =
|
|
23822
|
-
limits:
|
|
23823
|
-
context_window:
|
|
23824
|
-
max_input_tokens:
|
|
23825
|
-
max_output_tokens:
|
|
23826
|
-
max_tokens:
|
|
23952
|
+
var MetadataSchema = z49.object({
|
|
23953
|
+
limits: z49.object({
|
|
23954
|
+
context_window: z49.number().optional(),
|
|
23955
|
+
max_input_tokens: z49.number().optional(),
|
|
23956
|
+
max_output_tokens: z49.number().optional(),
|
|
23957
|
+
max_tokens: z49.number().optional()
|
|
23827
23958
|
}).optional(),
|
|
23828
|
-
params:
|
|
23959
|
+
params: z49.array(ModelParamSchema).optional()
|
|
23829
23960
|
});
|
|
23830
|
-
var IntegrationSchema =
|
|
23831
|
-
name:
|
|
23832
|
-
manifest:
|
|
23833
|
-
providerAccount:
|
|
23961
|
+
var IntegrationSchema = z49.object({
|
|
23962
|
+
name: z49.string().min(1),
|
|
23963
|
+
manifest: z49.object({ model_types: z49.array(z49.string()).optional() }),
|
|
23964
|
+
providerAccount: z49.object({ name: z49.string().min(1) }),
|
|
23834
23965
|
metadata: MetadataSchema.optional()
|
|
23835
23966
|
});
|
|
23836
23967
|
function toReasoningEfforts(params) {
|
|
@@ -23888,11 +24019,11 @@ function filterEnvModels(input) {
|
|
|
23888
24019
|
const allowed = new Set(allowedAccounts);
|
|
23889
24020
|
return input.models.filter((model) => allowed.has(model.accountName));
|
|
23890
24021
|
}
|
|
23891
|
-
var InstallationSchema =
|
|
23892
|
-
isDefault:
|
|
23893
|
-
manifest:
|
|
24022
|
+
var InstallationSchema = z49.object({
|
|
24023
|
+
isDefault: z49.boolean().optional(),
|
|
24024
|
+
manifest: z49.object({ url: z49.string().min(1) })
|
|
23894
24025
|
});
|
|
23895
|
-
var InstallationsEnvelopeSchema =
|
|
24026
|
+
var InstallationsEnvelopeSchema = z49.union([z49.array(z49.unknown()), z49.object({ data: z49.array(z49.unknown()) })]);
|
|
23896
24027
|
function resolveDefaultGatewayUrl(payload) {
|
|
23897
24028
|
const envelope = InstallationsEnvelopeSchema.parse(payload);
|
|
23898
24029
|
const rows = Array.isArray(envelope) ? envelope : envelope.data;
|
|
@@ -23902,7 +24033,7 @@ function resolveDefaultGatewayUrl(payload) {
|
|
|
23902
24033
|
return installation.manifest.url;
|
|
23903
24034
|
}
|
|
23904
24035
|
}
|
|
23905
|
-
throw new
|
|
24036
|
+
throw new HTTPException29(502, { message: "No default TrueFoundry AI gateway installation is configured" });
|
|
23906
24037
|
}
|
|
23907
24038
|
|
|
23908
24039
|
// src/truefoundry/TrueFoundryMcpServerStore.ts
|
|
@@ -23956,7 +24087,7 @@ var TrueFoundryMcpServerStore = class {
|
|
|
23956
24087
|
if (status.status === "auth_required") {
|
|
23957
24088
|
const authUrl = status.authorization_url;
|
|
23958
24089
|
if (authUrl === void 0 || authUrl.length === 0) {
|
|
23959
|
-
throw new
|
|
24090
|
+
throw new HTTPException30(422, {
|
|
23960
24091
|
message: `MCP server "${record.name}" requires authentication but returned no authorization URL`
|
|
23961
24092
|
});
|
|
23962
24093
|
}
|
|
@@ -24510,7 +24641,7 @@ var TrueFoundrySandboxProviderStore = class {
|
|
|
24510
24641
|
};
|
|
24511
24642
|
|
|
24512
24643
|
// src/truefoundry/TrueFoundrySkillStore.ts
|
|
24513
|
-
import { HTTPException as
|
|
24644
|
+
import { HTTPException as HTTPException31 } from "hono/http-exception";
|
|
24514
24645
|
function toRegistryRecord(tenant_id, skill) {
|
|
24515
24646
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
24516
24647
|
const manifest = {
|
|
@@ -24551,18 +24682,18 @@ var TrueFoundryAdminSkillStore = class {
|
|
|
24551
24682
|
return skills.map((skill) => {
|
|
24552
24683
|
const row = byFqn.get(skill.name);
|
|
24553
24684
|
if (row === void 0) {
|
|
24554
|
-
throw new
|
|
24685
|
+
throw new HTTPException31(422, {
|
|
24555
24686
|
message: `Unknown skill "${skill.name}" \u2014 not configured`
|
|
24556
24687
|
});
|
|
24557
24688
|
}
|
|
24558
24689
|
if (row.presigned_url === void 0) {
|
|
24559
|
-
throw new
|
|
24690
|
+
throw new HTTPException31(422, {
|
|
24560
24691
|
message: `Skill "${skill.name}" did not return a presigned URL`
|
|
24561
24692
|
});
|
|
24562
24693
|
}
|
|
24563
24694
|
const skillMdContent = skill.preload ? row.skill_md_content ?? null : null;
|
|
24564
24695
|
if (skill.preload && (skillMdContent === null || skillMdContent.length === 0)) {
|
|
24565
|
-
throw new
|
|
24696
|
+
throw new HTTPException31(422, {
|
|
24566
24697
|
message: `Skill "${skill.name}" did not return SKILL.md for preload`
|
|
24567
24698
|
});
|
|
24568
24699
|
}
|
|
@@ -24589,7 +24720,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24589
24720
|
async listSkills(input, transaction) {
|
|
24590
24721
|
void transaction;
|
|
24591
24722
|
if (input.names !== void 0) {
|
|
24592
|
-
throw new
|
|
24723
|
+
throw new HTTPException31(422, {
|
|
24593
24724
|
message: "TrueFoundry skill list does not support name filters"
|
|
24594
24725
|
});
|
|
24595
24726
|
}
|
|
@@ -24637,7 +24768,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24637
24768
|
const seenFqns = /* @__PURE__ */ new Set();
|
|
24638
24769
|
for (const skill of skills) {
|
|
24639
24770
|
if (seenFqns.has(skill.name)) {
|
|
24640
|
-
throw new
|
|
24771
|
+
throw new HTTPException31(422, {
|
|
24641
24772
|
message: `Duplicate skill FQN "${skill.name}"`
|
|
24642
24773
|
});
|
|
24643
24774
|
}
|
|
@@ -24651,7 +24782,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24651
24782
|
const byFqn = new Map(resolved.map((row) => [row.fqn, row]));
|
|
24652
24783
|
for (const skill of skills) {
|
|
24653
24784
|
if (!byFqn.has(skill.name)) {
|
|
24654
|
-
throw new
|
|
24785
|
+
throw new HTTPException31(422, {
|
|
24655
24786
|
message: `Unknown skill "${skill.name}" \u2014 not configured`
|
|
24656
24787
|
});
|
|
24657
24788
|
}
|
|
@@ -24659,7 +24790,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24659
24790
|
const seenNames = /* @__PURE__ */ new Set();
|
|
24660
24791
|
for (const row of resolved) {
|
|
24661
24792
|
if (seenNames.has(row.name)) {
|
|
24662
|
-
throw new
|
|
24793
|
+
throw new HTTPException31(422, {
|
|
24663
24794
|
message: `Agent skills must have unique names; duplicate skill name(s): ${row.name}`
|
|
24664
24795
|
});
|
|
24665
24796
|
}
|
|
@@ -25267,6 +25398,10 @@ async function createServerRuntime(persistence, logger2) {
|
|
|
25267
25398
|
rawInlineSkillsHeader === void 0 ? {} : { inlineSkills: parseInlineSkills(rawInlineSkillsHeader) }
|
|
25268
25399
|
);
|
|
25269
25400
|
};
|
|
25401
|
+
const resolveCapabilitiesStore = (input) => capabilitiesStoreFromHeader({
|
|
25402
|
+
header: input.c?.req.header(X_TFG_TOOLS),
|
|
25403
|
+
isTrueFoundryMode
|
|
25404
|
+
});
|
|
25270
25405
|
const app = createServerApp({
|
|
25271
25406
|
modelCatalog: ModelCatalog.load(),
|
|
25272
25407
|
mcpCatalog: McpCatalog.load(),
|
|
@@ -25280,6 +25415,7 @@ async function createServerRuntime(persistence, logger2) {
|
|
|
25280
25415
|
resolveWebSearchProviderStore,
|
|
25281
25416
|
resolveSkillStore,
|
|
25282
25417
|
resolveTurnSkillsStore: resolveTurnSkillsStoreForRequest,
|
|
25418
|
+
resolveCapabilitiesStore,
|
|
25283
25419
|
withTransaction,
|
|
25284
25420
|
tokenStore,
|
|
25285
25421
|
scheduleStore,
|